mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-26 10:33:05 +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> ToggleButtons;
|
||||
|
||||
public bool IsHypervisorAvailable => OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
|
||||
|
||||
public bool 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;
|
||||
public bool EnableInternetAccess
|
||||
{
|
||||
|
@ -177,16 +164,14 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
|||
}
|
||||
}
|
||||
|
||||
public bool UseHypervisor { get; set; }
|
||||
|
||||
public string TimeZone { get; set; }
|
||||
public int Language { get; set; }
|
||||
public int Region { get; set; }
|
||||
public int MemoryMode { get; set; }
|
||||
public int BaseStyleIndex { get; set; }
|
||||
|
||||
private readonly SettingsGraphicsViewModel _graphicsViewModel;
|
||||
private readonly SettingsAudioViewModel _audioViewModel;
|
||||
private readonly SettingsCpuViewModel _cpuViewModel;
|
||||
private readonly SettingsGraphicsViewModel _graphicsViewModel;
|
||||
private readonly SettingsLoggingViewModel _loggingViewModel;
|
||||
|
||||
public DateTimeOffset CurrentDate { get; set; }
|
||||
|
@ -226,6 +211,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
|||
VirtualFileSystem virtualFileSystem,
|
||||
ContentManager contentManager,
|
||||
SettingsAudioViewModel audioViewModel,
|
||||
SettingsCpuViewModel cpuViewModel,
|
||||
SettingsGraphicsViewModel graphicsViewModel,
|
||||
SettingsLoggingViewModel loggingViewModel) : this()
|
||||
{
|
||||
|
@ -233,10 +219,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
|||
_contentManager = contentManager;
|
||||
|
||||
_audioViewModel = audioViewModel;
|
||||
_cpuViewModel = cpuViewModel;
|
||||
_graphicsViewModel = graphicsViewModel;
|
||||
_loggingViewModel = loggingViewModel;
|
||||
|
||||
_audioViewModel.DirtyEvent += CheckIfModified;
|
||||
_cpuViewModel.DirtyEvent += CheckIfModified;
|
||||
_graphicsViewModel.DirtyEvent += CheckIfModified;
|
||||
_loggingViewModel.DirtyEvent += CheckIfModified;
|
||||
|
||||
|
@ -294,10 +282,10 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
|||
isDirty |= config.System.ExpandRam.Value != ExpandDramSize;
|
||||
isDirty |= config.System.IgnoreMissingServices.Value != IgnoreMissingServices;
|
||||
|
||||
// CPU
|
||||
isDirty |= config.System.EnablePtc.Value != EnablePptc;
|
||||
isDirty |= config.System.MemoryManagerMode.Value != (MemoryManagerMode)MemoryMode;
|
||||
isDirty |= config.System.UseHypervisor.Value != UseHypervisor;
|
||||
if (_cpuViewModel != null)
|
||||
{
|
||||
isDirty |= _cpuViewModel.CheckIfModified(config);
|
||||
}
|
||||
|
||||
if (_graphicsViewModel != null)
|
||||
{
|
||||
|
@ -406,11 +394,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Settings
|
|||
ExpandDramSize = config.System.ExpandRam;
|
||||
IgnoreMissingServices = config.System.IgnoreMissingServices;
|
||||
|
||||
// CPU
|
||||
EnablePptc = config.System.EnablePtc;
|
||||
MemoryMode = (int)config.System.MemoryManagerMode.Value;
|
||||
UseHypervisor = config.System.UseHypervisor;
|
||||
|
||||
// Network
|
||||
EnableInternetAccess = config.System.EnableInternetAccess;
|
||||
// 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.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);
|
||||
_cpuViewModel?.Save(config);
|
||||
_graphicsViewModel?.Save(config);
|
||||
|
||||
// Network
|
||||
config.System.EnableInternetAccess.Value = EnableInternetAccess;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<UserControl
|
||||
x:Class="Ryujinx.Ava.UI.Views.Settings.SettingsCPUView"
|
||||
x:Class="Ryujinx.Ava.UI.Views.Settings.SettingsCpuView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
|
@ -7,7 +7,7 @@
|
|||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels.Settings"
|
||||
mc:Ignorable="d"
|
||||
x:DataType="viewModels:SettingsViewModel">
|
||||
x:DataType="viewModels:SettingsCpuViewModel">
|
||||
<Design.DataContext>
|
||||
<viewModels:SettingsViewModel />
|
||||
</Design.DataContext>
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
using Avalonia.Controls;
|
||||
using Ryujinx.Ava.UI.ViewModels.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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
public readonly SettingsInputView InputPage;
|
||||
public readonly SettingsHotkeysView HotkeysPage;
|
||||
public readonly SettingsSystemView SystemPage;
|
||||
public readonly SettingsCPUView CpuPage;
|
||||
public readonly SettingsCpuView CpuPage;
|
||||
public readonly SettingsGraphicsView GraphicsPage;
|
||||
public readonly SettingsAudioView AudioPage;
|
||||
public readonly SettingsNetworkView NetworkPage;
|
||||
|
@ -30,6 +30,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
Title = $"{LocaleManager.Instance[LocaleKeys.Settings]}";
|
||||
|
||||
AudioPage = new SettingsAudioView();
|
||||
CpuPage = new SettingsCpuView();
|
||||
GraphicsPage = new SettingsGraphicsView();
|
||||
LoggingPage = new SettingsLoggingView();
|
||||
|
||||
|
@ -37,6 +38,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
virtualFileSystem,
|
||||
contentManager,
|
||||
AudioPage.ViewModel,
|
||||
CpuPage.ViewModel,
|
||||
GraphicsPage.ViewModel,
|
||||
LoggingPage.ViewModel);
|
||||
|
||||
|
@ -44,7 +46,6 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
InputPage = new SettingsInputView(ViewModel);
|
||||
HotkeysPage = new SettingsHotkeysView(ViewModel);
|
||||
SystemPage = new SettingsSystemView(ViewModel);
|
||||
CpuPage = new SettingsCPUView();
|
||||
NetworkPage = new SettingsNetworkView();
|
||||
|
||||
DataContext = ViewModel;
|
||||
|
|
Loading…
Reference in a new issue