mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-27 02:53:04 +00:00
Migrate CPU to SettingsCpuViewModel
This commit is contained in:
parent
7f61ac3ab8
commit
66205aa3a3
5 changed files with 96 additions and 38 deletions
74
src/Ryujinx/UI/ViewModels/Settings/SettingsCpuViewModel.cs
Normal file
74
src/Ryujinx/UI/ViewModels/Settings/SettingsCpuViewModel.cs
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
using Ryujinx.Common.Configuration;
|
||||||
|
using Ryujinx.UI.Common.Configuration;
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
|
{
|
||||||
|
public class SettingsCpuViewModel: BaseModel
|
||||||
|
{
|
||||||
|
public event Action DirtyEvent;
|
||||||
|
|
||||||
|
public bool IsHypervisorAvailable => OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
|
||||||
|
|
||||||
|
private bool _enablePptc;
|
||||||
|
public bool EnablePptc
|
||||||
|
{
|
||||||
|
get => _enablePptc;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_enablePptc = value;
|
||||||
|
DirtyEvent?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _useHypervisor;
|
||||||
|
public bool UseHypervisor
|
||||||
|
{
|
||||||
|
get => _useHypervisor;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_useHypervisor = value;
|
||||||
|
DirtyEvent?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int _memoryMode;
|
||||||
|
public int MemoryMode
|
||||||
|
{
|
||||||
|
get => _memoryMode;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_memoryMode = value;
|
||||||
|
DirtyEvent?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SettingsCpuViewModel()
|
||||||
|
{
|
||||||
|
ConfigurationState config = ConfigurationState.Instance;
|
||||||
|
|
||||||
|
EnablePptc = config.System.EnablePtc;
|
||||||
|
MemoryMode = (int)config.System.MemoryManagerMode.Value;
|
||||||
|
UseHypervisor = config.System.UseHypervisor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckIfModified(ConfigurationState config)
|
||||||
|
{
|
||||||
|
bool isDirty = false;
|
||||||
|
|
||||||
|
isDirty |= config.System.EnablePtc.Value != EnablePptc;
|
||||||
|
isDirty |= config.System.MemoryManagerMode.Value != (MemoryManagerMode)MemoryMode;
|
||||||
|
isDirty |= config.System.UseHypervisor.Value != UseHypervisor;
|
||||||
|
|
||||||
|
return isDirty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Save(ConfigurationState config)
|
||||||
|
{
|
||||||
|
config.System.EnablePtc.Value = EnablePptc;
|
||||||
|
config.System.MemoryManagerMode.Value = (MemoryManagerMode)MemoryMode;
|
||||||
|
config.System.UseHypervisor.Value = UseHypervisor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,8 +52,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
public event Action<bool> DirtyEvent;
|
public event Action<bool> DirtyEvent;
|
||||||
public event Action<bool> ToggleButtons;
|
public event Action<bool> ToggleButtons;
|
||||||
|
|
||||||
public bool IsHypervisorAvailable => OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
|
|
||||||
|
|
||||||
public bool DirectoryChanged
|
public bool DirectoryChanged
|
||||||
{
|
{
|
||||||
get => _directoryChanged;
|
get => _directoryChanged;
|
||||||
|
@ -122,17 +120,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _enablePptc;
|
|
||||||
public bool EnablePptc
|
|
||||||
{
|
|
||||||
get => _enablePptc;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_enablePptc = value;
|
|
||||||
CheckIfModified();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool _enableInternetAccess;
|
private bool _enableInternetAccess;
|
||||||
public bool EnableInternetAccess
|
public bool EnableInternetAccess
|
||||||
{
|
{
|
||||||
|
@ -177,16 +164,14 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UseHypervisor { get; set; }
|
|
||||||
|
|
||||||
public string TimeZone { get; set; }
|
public string TimeZone { get; set; }
|
||||||
public int Language { get; set; }
|
public int Language { get; set; }
|
||||||
public int Region { get; set; }
|
public int Region { get; set; }
|
||||||
public int MemoryMode { get; set; }
|
|
||||||
public int BaseStyleIndex { get; set; }
|
public int BaseStyleIndex { get; set; }
|
||||||
|
|
||||||
private readonly SettingsGraphicsViewModel _graphicsViewModel;
|
|
||||||
private readonly SettingsAudioViewModel _audioViewModel;
|
private readonly SettingsAudioViewModel _audioViewModel;
|
||||||
|
private readonly SettingsCpuViewModel _cpuViewModel;
|
||||||
|
private readonly SettingsGraphicsViewModel _graphicsViewModel;
|
||||||
private readonly SettingsLoggingViewModel _loggingViewModel;
|
private readonly SettingsLoggingViewModel _loggingViewModel;
|
||||||
|
|
||||||
public DateTimeOffset CurrentDate { get; set; }
|
public DateTimeOffset CurrentDate { get; set; }
|
||||||
|
@ -226,6 +211,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
VirtualFileSystem virtualFileSystem,
|
VirtualFileSystem virtualFileSystem,
|
||||||
ContentManager contentManager,
|
ContentManager contentManager,
|
||||||
SettingsAudioViewModel audioViewModel,
|
SettingsAudioViewModel audioViewModel,
|
||||||
|
SettingsCpuViewModel cpuViewModel,
|
||||||
SettingsGraphicsViewModel graphicsViewModel,
|
SettingsGraphicsViewModel graphicsViewModel,
|
||||||
SettingsLoggingViewModel loggingViewModel) : this()
|
SettingsLoggingViewModel loggingViewModel) : this()
|
||||||
{
|
{
|
||||||
|
@ -233,10 +219,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
|
|
||||||
_audioViewModel = audioViewModel;
|
_audioViewModel = audioViewModel;
|
||||||
|
_cpuViewModel = cpuViewModel;
|
||||||
_graphicsViewModel = graphicsViewModel;
|
_graphicsViewModel = graphicsViewModel;
|
||||||
_loggingViewModel = loggingViewModel;
|
_loggingViewModel = loggingViewModel;
|
||||||
|
|
||||||
_audioViewModel.DirtyEvent += CheckIfModified;
|
_audioViewModel.DirtyEvent += CheckIfModified;
|
||||||
|
_cpuViewModel.DirtyEvent += CheckIfModified;
|
||||||
_graphicsViewModel.DirtyEvent += CheckIfModified;
|
_graphicsViewModel.DirtyEvent += CheckIfModified;
|
||||||
_loggingViewModel.DirtyEvent += CheckIfModified;
|
_loggingViewModel.DirtyEvent += CheckIfModified;
|
||||||
|
|
||||||
|
@ -294,10 +282,10 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
isDirty |= config.System.ExpandRam.Value != ExpandDramSize;
|
isDirty |= config.System.ExpandRam.Value != ExpandDramSize;
|
||||||
isDirty |= config.System.IgnoreMissingServices.Value != IgnoreMissingServices;
|
isDirty |= config.System.IgnoreMissingServices.Value != IgnoreMissingServices;
|
||||||
|
|
||||||
// CPU
|
if (_cpuViewModel != null)
|
||||||
isDirty |= config.System.EnablePtc.Value != EnablePptc;
|
{
|
||||||
isDirty |= config.System.MemoryManagerMode.Value != (MemoryManagerMode)MemoryMode;
|
isDirty |= _cpuViewModel.CheckIfModified(config);
|
||||||
isDirty |= config.System.UseHypervisor.Value != UseHypervisor;
|
}
|
||||||
|
|
||||||
if (_graphicsViewModel != null)
|
if (_graphicsViewModel != null)
|
||||||
{
|
{
|
||||||
|
@ -406,11 +394,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
ExpandDramSize = config.System.ExpandRam;
|
ExpandDramSize = config.System.ExpandRam;
|
||||||
IgnoreMissingServices = config.System.IgnoreMissingServices;
|
IgnoreMissingServices = config.System.IgnoreMissingServices;
|
||||||
|
|
||||||
// CPU
|
|
||||||
EnablePptc = config.System.EnablePtc;
|
|
||||||
MemoryMode = (int)config.System.MemoryManagerMode.Value;
|
|
||||||
UseHypervisor = config.System.UseHypervisor;
|
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
EnableInternetAccess = config.System.EnableInternetAccess;
|
EnableInternetAccess = config.System.EnableInternetAccess;
|
||||||
// LAN interface index is loaded asynchronously in PopulateNetworkInterfaces()
|
// LAN interface index is loaded asynchronously in PopulateNetworkInterfaces()
|
||||||
|
@ -454,13 +437,9 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
||||||
config.System.ExpandRam.Value = ExpandDramSize;
|
config.System.ExpandRam.Value = ExpandDramSize;
|
||||||
config.System.IgnoreMissingServices.Value = IgnoreMissingServices;
|
config.System.IgnoreMissingServices.Value = IgnoreMissingServices;
|
||||||
|
|
||||||
// CPU
|
|
||||||
config.System.EnablePtc.Value = EnablePptc;
|
|
||||||
config.System.MemoryManagerMode.Value = (MemoryManagerMode)MemoryMode;
|
|
||||||
config.System.UseHypervisor.Value = UseHypervisor;
|
|
||||||
|
|
||||||
_graphicsViewModel?.Save(config);
|
|
||||||
_audioViewModel?.Save(config);
|
_audioViewModel?.Save(config);
|
||||||
|
_cpuViewModel?.Save(config);
|
||||||
|
_graphicsViewModel?.Save(config);
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
config.System.EnableInternetAccess.Value = EnableInternetAccess;
|
config.System.EnableInternetAccess.Value = EnableInternetAccess;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<UserControl
|
<UserControl
|
||||||
x:Class="Ryujinx.Ava.UI.Views.Settings.SettingsCPUView"
|
x:Class="Ryujinx.Ava.UI.Views.Settings.SettingsCpuView"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels.Settings"
|
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels.Settings"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
x:DataType="viewModels:SettingsViewModel">
|
x:DataType="viewModels:SettingsCpuViewModel">
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<viewModels:SettingsViewModel />
|
<viewModels:SettingsViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Ryujinx.Ava.UI.ViewModels.Settings;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Views.Settings
|
namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
{
|
{
|
||||||
public partial class SettingsCPUView : UserControl
|
public partial class SettingsCpuView : UserControl
|
||||||
{
|
{
|
||||||
public SettingsCPUView()
|
public SettingsCpuViewModel ViewModel;
|
||||||
|
|
||||||
|
public SettingsCpuView()
|
||||||
{
|
{
|
||||||
|
DataContext = ViewModel = new SettingsCpuViewModel();
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
public readonly SettingsInputView InputPage;
|
public readonly SettingsInputView InputPage;
|
||||||
public readonly SettingsHotkeysView HotkeysPage;
|
public readonly SettingsHotkeysView HotkeysPage;
|
||||||
public readonly SettingsSystemView SystemPage;
|
public readonly SettingsSystemView SystemPage;
|
||||||
public readonly SettingsCPUView CpuPage;
|
public readonly SettingsCpuView CpuPage;
|
||||||
public readonly SettingsGraphicsView GraphicsPage;
|
public readonly SettingsGraphicsView GraphicsPage;
|
||||||
public readonly SettingsAudioView AudioPage;
|
public readonly SettingsAudioView AudioPage;
|
||||||
public readonly SettingsNetworkView NetworkPage;
|
public readonly SettingsNetworkView NetworkPage;
|
||||||
|
@ -30,6 +30,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
Title = $"{LocaleManager.Instance[LocaleKeys.Settings]}";
|
Title = $"{LocaleManager.Instance[LocaleKeys.Settings]}";
|
||||||
|
|
||||||
AudioPage = new SettingsAudioView();
|
AudioPage = new SettingsAudioView();
|
||||||
|
CpuPage = new SettingsCpuView();
|
||||||
GraphicsPage = new SettingsGraphicsView();
|
GraphicsPage = new SettingsGraphicsView();
|
||||||
LoggingPage = new SettingsLoggingView();
|
LoggingPage = new SettingsLoggingView();
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
virtualFileSystem,
|
virtualFileSystem,
|
||||||
contentManager,
|
contentManager,
|
||||||
AudioPage.ViewModel,
|
AudioPage.ViewModel,
|
||||||
|
CpuPage.ViewModel,
|
||||||
GraphicsPage.ViewModel,
|
GraphicsPage.ViewModel,
|
||||||
LoggingPage.ViewModel);
|
LoggingPage.ViewModel);
|
||||||
|
|
||||||
|
@ -44,7 +46,6 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
InputPage = new SettingsInputView(ViewModel);
|
InputPage = new SettingsInputView(ViewModel);
|
||||||
HotkeysPage = new SettingsHotkeysView(ViewModel);
|
HotkeysPage = new SettingsHotkeysView(ViewModel);
|
||||||
SystemPage = new SettingsSystemView(ViewModel);
|
SystemPage = new SettingsSystemView(ViewModel);
|
||||||
CpuPage = new SettingsCPUView();
|
|
||||||
NetworkPage = new SettingsNetworkView();
|
NetworkPage = new SettingsNetworkView();
|
||||||
|
|
||||||
DataContext = ViewModel;
|
DataContext = ViewModel;
|
||||||
|
|
Loading…
Reference in a new issue