mirror of
https://github.com/libretro/MesenCE.git
synced 2026-11-11 03:01:50 -10:00
Also fixes DX11.0 support (for Win7 PCs that aren't fully updated), which stopped working after the recent variable refresh rate changes
52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Media;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using Mesen.Config;
|
|
using Mesen.Utilities;
|
|
using Microsoft.VisualBasic;
|
|
using System;
|
|
|
|
namespace Mesen.ViewModels
|
|
{
|
|
public partial class GameConfigViewModel : DisposableViewModel
|
|
{
|
|
[ObservableProperty] public partial GameConfig Config { get; set; }
|
|
public GameDipSwitches DipSwitches { get; }
|
|
|
|
public GameConfigViewModel()
|
|
{
|
|
if(Design.IsDesignMode) {
|
|
Config = new();
|
|
DipSwitches = new();
|
|
return;
|
|
}
|
|
|
|
Config = GameConfig.LoadGameConfig(MainWindowViewModel.Instance.RomInfo);
|
|
DipSwitches = DipSwitchDatabase.GetGameDipswitches(MainWindowViewModel.Instance.RomInfo.DipSwitches);
|
|
|
|
uint value = Config.DipSwitches;
|
|
foreach(DipSwitchDefinition def in DipSwitches.DipSwitches) {
|
|
def.SelectedOption = (int)(value & (def.Options.Count - 1));
|
|
|
|
//Shift bits
|
|
value /= (uint)def.Options.Count;
|
|
}
|
|
|
|
AddDisposable(ReactiveHelper.RegisterRecursiveObserver(Config, (s, e) => Config.ApplyConfig()));
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
uint value = 0;
|
|
for(int i = DipSwitches.DipSwitches.Count - 1; i >= 0; i--) {
|
|
DipSwitchDefinition def = DipSwitches.DipSwitches[i];
|
|
value *= (uint)def.Options.Count;
|
|
|
|
value |= (uint)def.SelectedOption;
|
|
}
|
|
Config.DipSwitches = value;
|
|
Config.Save();
|
|
}
|
|
}
|
|
}
|