mirror of
https://github.com/SourMesen/Mesen2.git
synced 2025-04-02 10:21:44 -04:00
UI: Fixed issues when changing options in both menu & config window at the same time
This commit is contained in:
parent
9504973e7c
commit
f18b20b2c9
14 changed files with 59 additions and 33 deletions
|
@ -82,7 +82,6 @@ namespace Mesen.Debugger.Windows
|
|||
}
|
||||
_timer.Stop();
|
||||
ConfigManager.Config.Debug.DebugLog.SaveWindowSettings(this);
|
||||
DataContext = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,11 +10,13 @@ namespace Mesen.ViewModels
|
|||
public class AudioConfigViewModel : DisposableViewModel
|
||||
{
|
||||
[Reactive] public AudioConfig Config { get; set; }
|
||||
[Reactive] public AudioConfig OriginalConfig { get; set; }
|
||||
[Reactive] public List<string> AudioDevices { get; set; } = new();
|
||||
|
||||
public AudioConfigViewModel()
|
||||
{
|
||||
Config = ConfigManager.Config.Audio.Clone();
|
||||
Config = ConfigManager.Config.Audio;
|
||||
OriginalConfig = Config.Clone();
|
||||
|
||||
if(Design.IsDesignMode) {
|
||||
return;
|
||||
|
|
|
@ -63,33 +63,38 @@ namespace Mesen.ViewModels
|
|||
|
||||
public void SaveConfig()
|
||||
{
|
||||
ConfigManager.Config.Audio = Audio?.Config.Clone() ?? ConfigManager.Config.Audio;
|
||||
ConfigManager.Config.Input = Input?.Config.Clone() ?? ConfigManager.Config.Input;
|
||||
ConfigManager.Config.Video = Video?.Config.Clone() ?? ConfigManager.Config.Video;
|
||||
ConfigManager.Config.Preferences = Preferences?.Config.Clone() ?? ConfigManager.Config.Preferences;
|
||||
ConfigManager.Config.Emulation = Emulation?.Config.Clone() ?? ConfigManager.Config.Emulation;
|
||||
ConfigManager.Config.Nes = Nes?.Config.Clone() ?? ConfigManager.Config.Nes;
|
||||
ConfigManager.Config.Snes = Snes?.Config.Clone() ?? ConfigManager.Config.Snes;
|
||||
ConfigManager.Config.Gameboy = Gameboy?.Config.Clone() ?? ConfigManager.Config.Gameboy;
|
||||
ConfigManager.Config.PcEngine = PcEngine?.Config.Clone() ?? ConfigManager.Config.PcEngine;
|
||||
ConfigManager.Config.ApplyConfig();
|
||||
ConfigManager.Config.Save();
|
||||
|
||||
ConfigManager.Config.Preferences.UpdateFileAssociations();
|
||||
}
|
||||
|
||||
public void RevertConfig()
|
||||
{
|
||||
ConfigManager.Config.Audio = Audio?.OriginalConfig ?? ConfigManager.Config.Audio;
|
||||
ConfigManager.Config.Input = Input?.OriginalConfig ?? ConfigManager.Config.Input;
|
||||
ConfigManager.Config.Video = Video?.OriginalConfig ?? ConfigManager.Config.Video;
|
||||
ConfigManager.Config.Preferences = Preferences?.OriginalConfig ?? ConfigManager.Config.Preferences;
|
||||
ConfigManager.Config.Emulation = Emulation?.OriginalConfig ?? ConfigManager.Config.Emulation;
|
||||
ConfigManager.Config.Nes = Nes?.OriginalConfig ?? ConfigManager.Config.Nes;
|
||||
ConfigManager.Config.Snes = Snes?.OriginalConfig ?? ConfigManager.Config.Snes;
|
||||
ConfigManager.Config.Gameboy = Gameboy?.OriginalConfig ?? ConfigManager.Config.Gameboy;
|
||||
ConfigManager.Config.PcEngine = PcEngine?.OriginalConfig ?? ConfigManager.Config.PcEngine;
|
||||
ConfigManager.Config.ApplyConfig();
|
||||
ConfigManager.Config.Save();
|
||||
}
|
||||
|
||||
public bool IsDirty()
|
||||
{
|
||||
return (
|
||||
Audio?.Config.IsIdentical(ConfigManager.Config.Audio) == false ||
|
||||
Input?.Config.IsIdentical(ConfigManager.Config.Input) == false ||
|
||||
Video?.Config.IsIdentical(ConfigManager.Config.Video) == false ||
|
||||
Preferences?.Config.IsIdentical(ConfigManager.Config.Preferences) == false ||
|
||||
Emulation?.Config.IsIdentical(ConfigManager.Config.Emulation) == false ||
|
||||
Nes?.Config.IsIdentical(ConfigManager.Config.Nes) == false ||
|
||||
Snes?.Config.IsIdentical(ConfigManager.Config.Snes) == false ||
|
||||
Gameboy?.Config.IsIdentical(ConfigManager.Config.Gameboy) == false ||
|
||||
PcEngine?.Config.IsIdentical(ConfigManager.Config.PcEngine) == false
|
||||
Audio?.OriginalConfig.IsIdentical(ConfigManager.Config.Audio) == false ||
|
||||
Input?.OriginalConfig.IsIdentical(ConfigManager.Config.Input) == false ||
|
||||
Video?.OriginalConfig.IsIdentical(ConfigManager.Config.Video) == false ||
|
||||
Preferences?.OriginalConfig.IsIdentical(ConfigManager.Config.Preferences) == false ||
|
||||
Emulation?.OriginalConfig.IsIdentical(ConfigManager.Config.Emulation) == false ||
|
||||
Nes?.OriginalConfig.IsIdentical(ConfigManager.Config.Nes) == false ||
|
||||
Snes?.OriginalConfig.IsIdentical(ConfigManager.Config.Snes) == false ||
|
||||
Gameboy?.OriginalConfig.IsIdentical(ConfigManager.Config.Gameboy) == false ||
|
||||
PcEngine?.OriginalConfig.IsIdentical(ConfigManager.Config.PcEngine) == false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,12 @@ namespace Mesen.ViewModels
|
|||
public class EmulationConfigViewModel : DisposableViewModel
|
||||
{
|
||||
[Reactive] public EmulationConfig Config { get; set; }
|
||||
[Reactive] public EmulationConfig OriginalConfig { get; set; }
|
||||
|
||||
public EmulationConfigViewModel()
|
||||
{
|
||||
Config = ConfigManager.Config.Emulation.Clone();
|
||||
Config = ConfigManager.Config.Emulation;
|
||||
OriginalConfig = Config.Clone();
|
||||
|
||||
if(Design.IsDesignMode) {
|
||||
return;
|
||||
|
|
|
@ -14,14 +14,16 @@ namespace Mesen.ViewModels
|
|||
public class GameboyConfigViewModel : DisposableViewModel
|
||||
{
|
||||
[Reactive] public GameboyConfig Config { get; set; }
|
||||
[Reactive] public GameboyConfig OriginalConfig { get; set; }
|
||||
[Reactive] public GameboyConfigTab SelectedTab { get; set; } = 0;
|
||||
|
||||
public ReactiveCommand<Button, Unit> SetupPlayer { get; }
|
||||
|
||||
public GameboyConfigViewModel()
|
||||
{
|
||||
Config = ConfigManager.Config.Gameboy.Clone();
|
||||
|
||||
Config = ConfigManager.Config.Gameboy;
|
||||
OriginalConfig = Config.Clone();
|
||||
|
||||
IObservable<bool> button1Enabled = this.WhenAnyValue(x => x.Config.Controller.Type, x => x.CanConfigure());
|
||||
SetupPlayer = ReactiveCommand.Create<Button>(btn => this.OpenSetup(btn, 0), button1Enabled);
|
||||
|
||||
|
|
|
@ -8,10 +8,12 @@ namespace Mesen.ViewModels
|
|||
public class InputConfigViewModel : DisposableViewModel
|
||||
{
|
||||
[Reactive] public InputConfig Config { get; set; }
|
||||
[Reactive] public InputConfig OriginalConfig { get; set; }
|
||||
|
||||
public InputConfigViewModel()
|
||||
{
|
||||
Config = ConfigManager.Config.Input.Clone();
|
||||
Config = ConfigManager.Config.Input;
|
||||
OriginalConfig = Config.Clone();
|
||||
|
||||
if(Design.IsDesignMode) {
|
||||
return;
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Mesen.ViewModels
|
|||
private NotificationListener? _listener = null;
|
||||
|
||||
[Reactive] public NesConfig Config { get; set; }
|
||||
[Reactive] public NesConfig OriginalConfig { get; set; }
|
||||
|
||||
[Reactive] public bool ShowExpansionVolume { get; set; }
|
||||
[Reactive] public bool ShowColorIndexes { get; set; }
|
||||
|
@ -47,7 +48,8 @@ namespace Mesen.ViewModels
|
|||
|
||||
public NesConfigViewModel(PreferencesConfig preferences)
|
||||
{
|
||||
Config = ConfigManager.Config.Nes.Clone();
|
||||
Config = ConfigManager.Config.Nes;
|
||||
OriginalConfig = Config.Clone();
|
||||
Input = new NesInputConfigViewModel(Config, preferences);
|
||||
|
||||
if(Design.IsDesignMode) {
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Mesen.ViewModels
|
|||
public class PceConfigViewModel : DisposableViewModel
|
||||
{
|
||||
[Reactive] public PcEngineConfig Config { get; set; }
|
||||
[Reactive] public PcEngineConfig OriginalConfig { get; set; }
|
||||
[Reactive] public PceConfigTab SelectedTab { get; set; } = 0;
|
||||
|
||||
public PceInputConfigViewModel Input { get; private set; }
|
||||
|
@ -27,7 +28,8 @@ namespace Mesen.ViewModels
|
|||
|
||||
public PceConfigViewModel()
|
||||
{
|
||||
Config = ConfigManager.Config.PcEngine.Clone();
|
||||
Config = ConfigManager.Config.PcEngine;
|
||||
OriginalConfig = Config.Clone();
|
||||
Input = new PceInputConfigViewModel(Config);
|
||||
|
||||
if(Design.IsDesignMode) {
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace Mesen.ViewModels
|
|||
public class PreferencesConfigViewModel : DisposableViewModel
|
||||
{
|
||||
[Reactive] public PreferencesConfig Config { get; set; }
|
||||
[Reactive] public PreferencesConfig OriginalConfig { get; set; }
|
||||
|
||||
public string DataStorageLocation { get; }
|
||||
public bool IsOsx { get; }
|
||||
|
@ -19,7 +20,8 @@ namespace Mesen.ViewModels
|
|||
|
||||
public PreferencesConfigViewModel()
|
||||
{
|
||||
Config = ConfigManager.Config.Preferences.Clone();
|
||||
Config = ConfigManager.Config.Preferences;
|
||||
OriginalConfig = Config.Clone();
|
||||
|
||||
IsOsx = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
DataStorageLocation = ConfigManager.HomeFolder;
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace Mesen.ViewModels
|
|||
public class SnesConfigViewModel : DisposableViewModel
|
||||
{
|
||||
[Reactive] public SnesConfig Config { get; set; }
|
||||
[Reactive] public SnesConfig OriginalConfig { get; set; }
|
||||
[Reactive] public SnesConfigTab SelectedTab { get; set; } = 0;
|
||||
|
||||
public SnesInputConfigViewModel Input { get; private set; }
|
||||
|
@ -21,7 +22,8 @@ namespace Mesen.ViewModels
|
|||
|
||||
public SnesConfigViewModel()
|
||||
{
|
||||
Config = ConfigManager.Config.Snes.Clone();
|
||||
Config = ConfigManager.Config.Snes;
|
||||
OriginalConfig = Config.Clone();
|
||||
Input = new SnesInputConfigViewModel(Config);
|
||||
|
||||
if(Design.IsDesignMode) {
|
||||
|
|
|
@ -25,11 +25,13 @@ namespace Mesen.ViewModels
|
|||
public ReactiveCommand<Unit, Unit> ResetPictureSettingsCommand { get; }
|
||||
|
||||
[Reactive] public VideoConfig Config { get; set; }
|
||||
[Reactive] public VideoConfig OriginalConfig { get; set; }
|
||||
public UInt32[] AvailableRefreshRates { get; } = new UInt32[] { 50, 60, 75, 100, 120, 144, 200, 240, 360 };
|
||||
|
||||
public VideoConfigViewModel()
|
||||
{
|
||||
Config = ConfigManager.Config.Video.Clone();
|
||||
Config = ConfigManager.Config.Video;
|
||||
OriginalConfig = Config.Clone();
|
||||
|
||||
PresetCompositeCommand = ReactiveCommand.Create(() => SetNtscPreset(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, false));
|
||||
PresetSVideoCommand = ReactiveCommand.Create(()=> SetNtscPreset(0, 0, 0, 0, 20, 0, 20, -100, -100, 0, 15, false));
|
||||
|
|
|
@ -47,6 +47,7 @@ namespace Mesen.Windows
|
|||
private void Cancel_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_promptToSave = false;
|
||||
_model.RevertConfig();
|
||||
Close();
|
||||
}
|
||||
|
||||
|
@ -81,7 +82,7 @@ namespace Mesen.Windows
|
|||
DialogResult result = await MesenMsgBox.Show(this, "PromptSaveChanges", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
||||
switch(result) {
|
||||
case DialogResult.Yes: _promptToSave = false; _model.SaveConfig(); Close(); break;
|
||||
case DialogResult.No: _promptToSave = false; Close(); break;
|
||||
case DialogResult.No: _promptToSave = false; _model.RevertConfig(); Close(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +102,11 @@ namespace Mesen.Windows
|
|||
|
||||
ConfigManager.Config.ApplyConfig();
|
||||
_model.Dispose();
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
DataContext = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,6 @@ namespace Mesen.Windows
|
|||
{
|
||||
base.OnClosing(e);
|
||||
InputApi.DisableAllKeys(false);
|
||||
DataContext = null;
|
||||
}
|
||||
|
||||
private void SelectKeyCombination(KeyCombination key)
|
||||
|
|
|
@ -78,7 +78,6 @@ namespace Mesen.Windows
|
|||
return;
|
||||
}
|
||||
_timer.Stop();
|
||||
DataContext = null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue