Files
MesenCE/UI/ViewModels/SnesConfigViewModel.cs
SourMesen 40335ce735 UI: Update to Avalonia 12, .NET 10 and replace ReactiveUI with MVVM community toolkit (#142)
Also fixes DX11.0 support (for Win7 PCs that aren't fully updated), which stopped working after the recent variable refresh rate changes
2026-07-03 16:04:42 +09:00

58 lines
1.6 KiB
C#

using Avalonia.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
using Mesen.Config;
using Mesen.Localization;
using Mesen.Utilities;
using System;
namespace Mesen.ViewModels
{
public partial class SnesConfigViewModel : DisposableViewModel
{
[ObservableProperty] public partial SnesConfig Config { get; set; }
[ObservableProperty] public partial SnesConfig OriginalConfig { get; set; }
[ObservableProperty] public partial SnesConfigTab SelectedTab { get; set; } = 0;
public SnesInputConfigViewModel Input { get; private set; }
[ObservableProperty] public partial bool IsDefaultSpcClockSpeed { get; set; } = true;
[ObservableProperty] public partial string SpcEffectiveClockSpeed { get; set; } = "";
public Enum[] AvailableRegions => new Enum[] {
ConsoleRegion.Auto,
ConsoleRegion.Ntsc,
ConsoleRegion.Pal
};
public SnesConfigViewModel()
{
Config = ConfigManager.Config.Snes;
OriginalConfig = Config.Clone();
Input = new SnesInputConfigViewModel(Config);
if(Design.IsDesignMode) {
return;
}
AddDisposable(Input);
AddDisposable(ReactiveHelper.RegisterRecursiveObserver(Config, (s, e) => { Config.ApplyConfig(); }));
AddDisposable(Config.ObserveProp(nameof(SnesConfig.SpcClockSpeedAdjustment), () => {
SpcEffectiveClockSpeed = ResourceHelper.GetMessage("SpcClockSpeedMsg", ((32000 + Config.SpcClockSpeedAdjustment) * 32).ToString());
IsDefaultSpcClockSpeed = Config.SpcClockSpeedAdjustment == 40;
}));
}
}
public enum SnesConfigTab
{
General,
Audio,
Emulation,
Input,
Overclocking,
Video,
Bsx
}
}