This commit is contained in:
WilliamWsyHK 2024-05-19 21:56:45 +02:00 committed by GitHub
commit c0d0cb2f0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 807 additions and 529 deletions

View File

@ -183,8 +183,8 @@ namespace Ryujinx
ConfigurationPath = appDataConfigurationPath;
Logger.Notice.Print(LogClass.Application, $"No configuration file found. Saving default configuration to: {ConfigurationPath}");
ConfigurationState.Instance.LoadDefault();
ConfigurationState.Instance.ToFileFormat().SaveConfig(ConfigurationPath);
ConfigurationState.Shared.LoadDefault();
ConfigurationState.Shared.ToFileFormat().SaveConfig(ConfigurationPath);
}
else
{
@ -192,13 +192,13 @@ namespace Ryujinx
if (ConfigurationFileFormat.TryLoad(ConfigurationPath, out ConfigurationFileFormat configurationFileFormat))
{
ConfigurationState.Instance.Load(configurationFileFormat, ConfigurationPath);
ConfigurationState.Shared.Load(configurationFileFormat, ConfigurationPath);
}
else
{
Logger.Warning?.PrintMsg(LogClass.Application, $"Failed to load config! Loading the default config instead.\nFailed config location: {ConfigurationPath}");
ConfigurationState.Instance.LoadDefault();
ConfigurationState.Shared.LoadDefault();
}
}
@ -207,37 +207,37 @@ namespace Ryujinx
{
if (CommandLineState.OverrideGraphicsBackend.ToLower() == "opengl")
{
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl;
ConfigurationState.Shared.Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl;
}
else if (CommandLineState.OverrideGraphicsBackend.ToLower() == "vulkan")
{
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.Vulkan;
ConfigurationState.Shared.Graphics.GraphicsBackend.Value = GraphicsBackend.Vulkan;
}
}
// Check if HideCursor was overridden.
if (CommandLineState.OverrideHideCursor is not null)
{
ConfigurationState.Instance.HideCursor.Value = CommandLineState.OverrideHideCursor!.ToLower() switch
ConfigurationState.Shared.HideCursor.Value = CommandLineState.OverrideHideCursor!.ToLower() switch
{
"never" => HideCursorMode.Never,
"onidle" => HideCursorMode.OnIdle,
"always" => HideCursorMode.Always,
_ => ConfigurationState.Instance.HideCursor.Value,
_ => ConfigurationState.Shared.HideCursor.Value,
};
}
// Check if docked mode was overridden.
if (CommandLineState.OverrideDockedMode.HasValue)
{
ConfigurationState.Instance.System.EnableDockedMode.Value = CommandLineState.OverrideDockedMode.Value;
ConfigurationState.Shared.System.EnableDockedMode.Value = CommandLineState.OverrideDockedMode.Value;
}
// Logging system information.
PrintSystemInfo();
// Enable OGL multithreading on the driver, when available.
BackendThreading threadingMode = ConfigurationState.Instance.Graphics.BackendThreading;
BackendThreading threadingMode = ConfigurationState.Shared.Graphics.BackendThreading;
DriverUtilities.ToggleOGLThreading(threadingMode == BackendThreading.Off);
// Initialize Gtk.
@ -325,7 +325,7 @@ namespace Ryujinx
mainWindow.RunApplication(CommandLineState.LaunchPathArg, CommandLineState.StartFullscreenArg);
}
if (ConfigurationState.Instance.CheckUpdatesOnStart.Value && Updater.CanUpdate(false))
if (ConfigurationState.Shared.CheckUpdatesOnStart.Value && Updater.CanUpdate(false))
{
Updater.BeginParse(mainWindow, false).ContinueWith(task =>
{

View File

@ -10,26 +10,26 @@ namespace Ryujinx.UI.Helper
{
public static void ApplyTheme()
{
if (!ConfigurationState.Instance.UI.EnableCustomTheme)
if (!ConfigurationState.Shared.UI.EnableCustomTheme)
{
return;
}
if (File.Exists(ConfigurationState.Instance.UI.CustomThemePath) && (Path.GetExtension(ConfigurationState.Instance.UI.CustomThemePath) == ".css"))
if (File.Exists(ConfigurationState.Shared.UI.CustomThemePath) && (Path.GetExtension(ConfigurationState.Shared.UI.CustomThemePath) == ".css"))
{
CssProvider cssProvider = new();
cssProvider.LoadFromPath(ConfigurationState.Instance.UI.CustomThemePath);
cssProvider.LoadFromPath(ConfigurationState.Shared.UI.CustomThemePath);
StyleContext.AddProviderForScreen(Gdk.Screen.Default, cssProvider, 800);
}
else
{
Logger.Warning?.Print(LogClass.Application, $"The \"custom_theme_path\" section in \"{ReleaseInformation.ConfigName}\" contains an invalid path: \"{ConfigurationState.Instance.UI.CustomThemePath}\".");
Logger.Warning?.Print(LogClass.Application, $"The \"custom_theme_path\" section in \"{ReleaseInformation.ConfigName}\" contains an invalid path: \"{ConfigurationState.Shared.UI.CustomThemePath}\".");
ConfigurationState.Instance.UI.CustomThemePath.Value = "";
ConfigurationState.Instance.UI.EnableCustomTheme.Value = false;
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.UI.CustomThemePath.Value = "";
ConfigurationState.Shared.UI.EnableCustomTheme.Value = false;
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
}
}

View File

@ -202,32 +202,32 @@ namespace Ryujinx.UI
RendererWidgetBase.StatusUpdatedEvent += Update_StatusBar;
ConfigurationState.Instance.System.IgnoreMissingServices.Event += UpdateIgnoreMissingServicesState;
ConfigurationState.Instance.Graphics.AspectRatio.Event += UpdateAspectRatioState;
ConfigurationState.Instance.System.EnableDockedMode.Event += UpdateDockedModeState;
ConfigurationState.Instance.System.AudioVolume.Event += UpdateAudioVolumeState;
ConfigurationState.Shared.System.IgnoreMissingServices.Event += UpdateIgnoreMissingServicesState;
ConfigurationState.Shared.Graphics.AspectRatio.Event += UpdateAspectRatioState;
ConfigurationState.Shared.System.EnableDockedMode.Event += UpdateDockedModeState;
ConfigurationState.Shared.System.AudioVolume.Event += UpdateAudioVolumeState;
ConfigurationState.Instance.Multiplayer.Mode.Event += UpdateMultiplayerMode;
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Event += UpdateMultiplayerLanInterfaceId;
ConfigurationState.Shared.Multiplayer.Mode.Event += UpdateMultiplayerMode;
ConfigurationState.Shared.Multiplayer.LanInterfaceId.Event += UpdateMultiplayerLanInterfaceId;
if (ConfigurationState.Instance.UI.StartFullscreen)
if (ConfigurationState.Shared.UI.StartFullscreen)
{
_startFullScreen.Active = true;
}
_showConsole.Active = ConfigurationState.Instance.UI.ShowConsole.Value;
_showConsole.Active = ConfigurationState.Shared.UI.ShowConsole.Value;
_showConsole.Visible = ConsoleHelper.SetConsoleWindowStateSupported;
_actionMenu.Sensitive = false;
_pauseEmulation.Sensitive = false;
_resumeEmulation.Sensitive = false;
_nspShown.Active = ConfigurationState.Instance.UI.ShownFileTypes.NSP.Value;
_pfs0Shown.Active = ConfigurationState.Instance.UI.ShownFileTypes.PFS0.Value;
_xciShown.Active = ConfigurationState.Instance.UI.ShownFileTypes.XCI.Value;
_ncaShown.Active = ConfigurationState.Instance.UI.ShownFileTypes.NCA.Value;
_nroShown.Active = ConfigurationState.Instance.UI.ShownFileTypes.NRO.Value;
_nsoShown.Active = ConfigurationState.Instance.UI.ShownFileTypes.NSO.Value;
_nspShown.Active = ConfigurationState.Shared.UI.ShownFileTypes.NSP.Value;
_pfs0Shown.Active = ConfigurationState.Shared.UI.ShownFileTypes.PFS0.Value;
_xciShown.Active = ConfigurationState.Shared.UI.ShownFileTypes.XCI.Value;
_ncaShown.Active = ConfigurationState.Shared.UI.ShownFileTypes.NCA.Value;
_nroShown.Active = ConfigurationState.Shared.UI.ShownFileTypes.NRO.Value;
_nsoShown.Active = ConfigurationState.Shared.UI.ShownFileTypes.NSO.Value;
_nspShown.Toggled += NSP_Shown_Toggled;
_pfs0Shown.Toggled += PFS0_Shown_Toggled;
@ -238,43 +238,43 @@ namespace Ryujinx.UI
_fileTypesSubMenu.Visible = FileAssociationHelper.IsTypeAssociationSupported;
if (ConfigurationState.Instance.UI.GuiColumns.FavColumn)
if (ConfigurationState.Shared.UI.GuiColumns.FavColumn)
{
_favToggle.Active = true;
}
if (ConfigurationState.Instance.UI.GuiColumns.IconColumn)
if (ConfigurationState.Shared.UI.GuiColumns.IconColumn)
{
_iconToggle.Active = true;
}
if (ConfigurationState.Instance.UI.GuiColumns.AppColumn)
if (ConfigurationState.Shared.UI.GuiColumns.AppColumn)
{
_appToggle.Active = true;
}
if (ConfigurationState.Instance.UI.GuiColumns.DevColumn)
if (ConfigurationState.Shared.UI.GuiColumns.DevColumn)
{
_developerToggle.Active = true;
}
if (ConfigurationState.Instance.UI.GuiColumns.VersionColumn)
if (ConfigurationState.Shared.UI.GuiColumns.VersionColumn)
{
_versionToggle.Active = true;
}
if (ConfigurationState.Instance.UI.GuiColumns.TimePlayedColumn)
if (ConfigurationState.Shared.UI.GuiColumns.TimePlayedColumn)
{
_timePlayedToggle.Active = true;
}
if (ConfigurationState.Instance.UI.GuiColumns.LastPlayedColumn)
if (ConfigurationState.Shared.UI.GuiColumns.LastPlayedColumn)
{
_lastPlayedToggle.Active = true;
}
if (ConfigurationState.Instance.UI.GuiColumns.FileExtColumn)
if (ConfigurationState.Shared.UI.GuiColumns.FileExtColumn)
{
_fileExtToggle.Active = true;
}
if (ConfigurationState.Instance.UI.GuiColumns.FileSizeColumn)
if (ConfigurationState.Shared.UI.GuiColumns.FileSizeColumn)
{
_fileSizeToggle.Active = true;
}
if (ConfigurationState.Instance.UI.GuiColumns.PathColumn)
if (ConfigurationState.Shared.UI.GuiColumns.PathColumn)
{
_pathToggle.Active = true;
}
@ -307,8 +307,8 @@ namespace Ryujinx.UI
_tableStore.SetSortFunc(6, SortHelper.LastPlayedSort);
_tableStore.SetSortFunc(8, SortHelper.FileSizeSort);
int columnId = ConfigurationState.Instance.UI.ColumnSort.SortColumnId;
bool ascending = ConfigurationState.Instance.UI.ColumnSort.SortAscending;
int columnId = ConfigurationState.Shared.UI.ColumnSort.SortColumnId;
bool ascending = ConfigurationState.Shared.UI.ColumnSort.SortAscending;
_tableStore.SetSortColumnId(columnId, ascending ? SortType.Ascending : SortType.Descending);
@ -316,12 +316,12 @@ namespace Ryujinx.UI
_gameTable.SearchColumn = 2;
_gameTable.SearchEqualFunc = (model, col, key, iter) => !((string)model.GetValue(iter, col)).Contains(key, StringComparison.InvariantCultureIgnoreCase);
_hideUI.Label = _hideUI.Label.Replace("SHOWUIKEY", ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUI.ToString());
_hideUI.Label = _hideUI.Label.Replace("SHOWUIKEY", ConfigurationState.Shared.Hid.Hotkeys.Value.ShowUI.ToString());
UpdateColumns();
UpdateGameTable();
ConfigurationState.Instance.UI.GameDirs.Event += (sender, args) =>
ConfigurationState.Shared.UI.GameDirs.Event += (sender, args) =>
{
if (args.OldValue != args.NewValue)
{
@ -401,43 +401,43 @@ namespace Ryujinx.UI
CellRendererToggle favToggle = new();
favToggle.Toggled += FavToggle_Toggled;
if (ConfigurationState.Instance.UI.GuiColumns.FavColumn)
if (ConfigurationState.Shared.UI.GuiColumns.FavColumn)
{
_gameTable.AppendColumn("Fav", favToggle, "active", 0);
}
if (ConfigurationState.Instance.UI.GuiColumns.IconColumn)
if (ConfigurationState.Shared.UI.GuiColumns.IconColumn)
{
_gameTable.AppendColumn("Icon", new CellRendererPixbuf(), "pixbuf", 1);
}
if (ConfigurationState.Instance.UI.GuiColumns.AppColumn)
if (ConfigurationState.Shared.UI.GuiColumns.AppColumn)
{
_gameTable.AppendColumn("Application", new CellRendererText(), "text", 2);
}
if (ConfigurationState.Instance.UI.GuiColumns.DevColumn)
if (ConfigurationState.Shared.UI.GuiColumns.DevColumn)
{
_gameTable.AppendColumn("Developer", new CellRendererText(), "text", 3);
}
if (ConfigurationState.Instance.UI.GuiColumns.VersionColumn)
if (ConfigurationState.Shared.UI.GuiColumns.VersionColumn)
{
_gameTable.AppendColumn("Version", new CellRendererText(), "text", 4);
}
if (ConfigurationState.Instance.UI.GuiColumns.TimePlayedColumn)
if (ConfigurationState.Shared.UI.GuiColumns.TimePlayedColumn)
{
_gameTable.AppendColumn("Time Played", new CellRendererText(), "text", 5);
}
if (ConfigurationState.Instance.UI.GuiColumns.LastPlayedColumn)
if (ConfigurationState.Shared.UI.GuiColumns.LastPlayedColumn)
{
_gameTable.AppendColumn("Last Played", new CellRendererText(), "text", 6);
}
if (ConfigurationState.Instance.UI.GuiColumns.FileExtColumn)
if (ConfigurationState.Shared.UI.GuiColumns.FileExtColumn)
{
_gameTable.AppendColumn("File Ext", new CellRendererText(), "text", 7);
}
if (ConfigurationState.Instance.UI.GuiColumns.FileSizeColumn)
if (ConfigurationState.Shared.UI.GuiColumns.FileSizeColumn)
{
_gameTable.AppendColumn("File Size", new CellRendererText(), "text", 8);
}
if (ConfigurationState.Instance.UI.GuiColumns.PathColumn)
if (ConfigurationState.Shared.UI.GuiColumns.PathColumn)
{
_gameTable.AppendColumn("Path", new CellRendererText(), "text", 9);
}
@ -497,9 +497,9 @@ namespace Ryujinx.UI
IRenderer renderer;
if (ConfigurationState.Instance.Graphics.GraphicsBackend == GraphicsBackend.Vulkan)
if (ConfigurationState.Shared.Graphics.GraphicsBackend == GraphicsBackend.Vulkan)
{
string preferredGpu = ConfigurationState.Instance.Graphics.PreferredGpu.Value;
string preferredGpu = ConfigurationState.Shared.Graphics.PreferredGpu.Value;
renderer = new Graphics.Vulkan.VulkanRenderer(Vk.GetApi(), CreateVulkanSurface, VulkanHelper.GetRequiredInstanceExtensions, preferredGpu);
}
else
@ -507,7 +507,7 @@ namespace Ryujinx.UI
renderer = new Graphics.OpenGL.OpenGLRenderer();
}
BackendThreading threadingMode = ConfigurationState.Instance.Graphics.BackendThreading;
BackendThreading threadingMode = ConfigurationState.Shared.Graphics.BackendThreading;
bool threadedGAL = threadingMode == BackendThreading.On || (threadingMode == BackendThreading.Auto && renderer.PreferThreading);
@ -520,7 +520,7 @@ namespace Ryujinx.UI
IHardwareDeviceDriver deviceDriver = new DummyHardwareDeviceDriver();
if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.SDL2)
if (ConfigurationState.Shared.System.AudioBackend.Value == AudioBackend.SDL2)
{
if (SDL2HardwareDeviceDriver.IsSupported)
{
@ -534,7 +534,7 @@ namespace Ryujinx.UI
{
Logger.Warning?.Print(LogClass.Audio, "Found OpenAL, changing configuration.");
ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.OpenAl;
ConfigurationState.Shared.System.AudioBackend.Value = AudioBackend.OpenAl;
SaveConfig();
deviceDriver = new OpenALHardwareDeviceDriver();
@ -547,7 +547,7 @@ namespace Ryujinx.UI
{
Logger.Warning?.Print(LogClass.Audio, "Found SoundIO, changing configuration.");
ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SoundIo;
ConfigurationState.Shared.System.AudioBackend.Value = AudioBackend.SoundIo;
SaveConfig();
deviceDriver = new SoundIoHardwareDeviceDriver();
@ -559,7 +559,7 @@ namespace Ryujinx.UI
}
}
}
else if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.SoundIo)
else if (ConfigurationState.Shared.System.AudioBackend.Value == AudioBackend.SoundIo)
{
if (SoundIoHardwareDeviceDriver.IsSupported)
{
@ -573,7 +573,7 @@ namespace Ryujinx.UI
{
Logger.Warning?.Print(LogClass.Audio, "Found SDL2, changing configuration.");
ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SDL2;
ConfigurationState.Shared.System.AudioBackend.Value = AudioBackend.SDL2;
SaveConfig();
deviceDriver = new SDL2HardwareDeviceDriver();
@ -586,7 +586,7 @@ namespace Ryujinx.UI
{
Logger.Warning?.Print(LogClass.Audio, "Found OpenAL, changing configuration.");
ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.OpenAl;
ConfigurationState.Shared.System.AudioBackend.Value = AudioBackend.OpenAl;
SaveConfig();
deviceDriver = new OpenALHardwareDeviceDriver();
@ -598,7 +598,7 @@ namespace Ryujinx.UI
}
}
}
else if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.OpenAl)
else if (ConfigurationState.Shared.System.AudioBackend.Value == AudioBackend.OpenAl)
{
if (OpenALHardwareDeviceDriver.IsSupported)
{
@ -612,7 +612,7 @@ namespace Ryujinx.UI
{
Logger.Warning?.Print(LogClass.Audio, "Found SDL2, changing configuration.");
ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SDL2;
ConfigurationState.Shared.System.AudioBackend.Value = AudioBackend.SDL2;
SaveConfig();
deviceDriver = new SDL2HardwareDeviceDriver();
@ -625,7 +625,7 @@ namespace Ryujinx.UI
{
Logger.Warning?.Print(LogClass.Audio, "Found SoundIO, changing configuration.");
ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SoundIo;
ConfigurationState.Shared.System.AudioBackend.Value = AudioBackend.SoundIo;
SaveConfig();
deviceDriver = new SoundIoHardwareDeviceDriver();
@ -638,11 +638,11 @@ namespace Ryujinx.UI
}
}
var memoryConfiguration = ConfigurationState.Instance.System.ExpandRam.Value
var memoryConfiguration = ConfigurationState.Shared.System.ExpandRam.Value
? HLE.MemoryConfiguration.MemoryConfiguration6GiB
: HLE.MemoryConfiguration.MemoryConfiguration4GiB;
IntegrityCheckLevel fsIntegrityCheckLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None;
IntegrityCheckLevel fsIntegrityCheckLevel = ConfigurationState.Shared.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None;
HLE.HLEConfiguration configuration = new(_virtualFileSystem,
_libHacHorizonManager,
@ -653,23 +653,23 @@ namespace Ryujinx.UI
deviceDriver,
memoryConfiguration,
_uiHandler,
(SystemLanguage)ConfigurationState.Instance.System.Language.Value,
(RegionCode)ConfigurationState.Instance.System.Region.Value,
ConfigurationState.Instance.Graphics.EnableVsync,
ConfigurationState.Instance.System.EnableDockedMode,
ConfigurationState.Instance.System.EnablePtc,
ConfigurationState.Instance.System.EnableInternetAccess,
(SystemLanguage)ConfigurationState.Shared.System.Language.Value,
(RegionCode)ConfigurationState.Shared.System.Region.Value,
ConfigurationState.Shared.Graphics.EnableVsync,
ConfigurationState.Shared.System.EnableDockedMode,
ConfigurationState.Shared.System.EnablePtc,
ConfigurationState.Shared.System.EnableInternetAccess,
fsIntegrityCheckLevel,
ConfigurationState.Instance.System.FsGlobalAccessLogMode,
ConfigurationState.Instance.System.SystemTimeOffset,
ConfigurationState.Instance.System.TimeZone,
ConfigurationState.Instance.System.MemoryManagerMode,
ConfigurationState.Instance.System.IgnoreMissingServices,
ConfigurationState.Instance.Graphics.AspectRatio,
ConfigurationState.Instance.System.AudioVolume,
ConfigurationState.Instance.System.UseHypervisor,
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value,
ConfigurationState.Instance.Multiplayer.Mode);
ConfigurationState.Shared.System.FsGlobalAccessLogMode,
ConfigurationState.Shared.System.SystemTimeOffset,
ConfigurationState.Shared.System.TimeZone,
ConfigurationState.Shared.System.MemoryManagerMode,
ConfigurationState.Shared.System.IgnoreMissingServices,
ConfigurationState.Shared.Graphics.AspectRatio,
ConfigurationState.Shared.System.AudioVolume,
ConfigurationState.Shared.System.UseHypervisor,
ConfigurationState.Shared.Multiplayer.LanInterfaceId.Value,
ConfigurationState.Shared.Multiplayer.Mode);
_emulationContext = new HLE.Switch(configuration);
}
@ -732,7 +732,7 @@ namespace Ryujinx.UI
Thread applicationLibraryThread = new(() =>
{
_applicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs, ConfigurationState.Instance.System.Language);
_applicationLibrary.LoadApplications(ConfigurationState.Shared.UI.GameDirs, ConfigurationState.Shared.System.Language);
_updatingGameTable = false;
})
@ -746,7 +746,7 @@ namespace Ryujinx.UI
[Conditional("RELEASE")]
public void PerformanceCheck()
{
if (ConfigurationState.Instance.Logger.EnableTrace.Value)
if (ConfigurationState.Shared.Logger.EnableTrace.Value)
{
MessageDialog debugWarningDialog = new(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, null)
{
@ -757,14 +757,14 @@ namespace Ryujinx.UI
if (debugWarningDialog.Run() == (int)ResponseType.Yes)
{
ConfigurationState.Instance.Logger.EnableTrace.Value = false;
ConfigurationState.Shared.Logger.EnableTrace.Value = false;
SaveConfig();
}
debugWarningDialog.Dispose();
}
if (!string.IsNullOrWhiteSpace(ConfigurationState.Instance.Graphics.ShadersDumpPath.Value))
if (!string.IsNullOrWhiteSpace(ConfigurationState.Shared.Graphics.ShadersDumpPath.Value))
{
MessageDialog shadersDumpWarningDialog = new(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, null)
{
@ -775,7 +775,7 @@ namespace Ryujinx.UI
if (shadersDumpWarningDialog.Run() == (int)ResponseType.Yes)
{
ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = "";
ConfigurationState.Shared.Graphics.ShadersDumpPath.Value = "";
SaveConfig();
}
@ -958,13 +958,13 @@ namespace Ryujinx.UI
private RendererWidgetBase CreateRendererWidget()
{
if (ConfigurationState.Instance.Graphics.GraphicsBackend == GraphicsBackend.Vulkan)
if (ConfigurationState.Shared.Graphics.GraphicsBackend == GraphicsBackend.Vulkan)
{
return new VulkanRenderer(InputManager, ConfigurationState.Instance.Logger.GraphicsDebugLevel);
return new VulkanRenderer(InputManager, ConfigurationState.Shared.Logger.GraphicsDebugLevel);
}
else
{
return new OpenGLRenderer(InputManager, ConfigurationState.Instance.Logger.GraphicsDebugLevel);
return new OpenGLRenderer(InputManager, ConfigurationState.Shared.Logger.GraphicsDebugLevel);
}
}
@ -981,7 +981,7 @@ namespace Ryujinx.UI
{
ToggleExtraWidgets(false);
}
else if (startFullscreen || ConfigurationState.Instance.UI.StartFullscreen.Value)
else if (startFullscreen || ConfigurationState.Shared.UI.StartFullscreen.Value)
{
FullScreen_Toggled(null, null);
}
@ -1101,28 +1101,28 @@ namespace Ryujinx.UI
public static void UpdateGraphicsConfig()
{
int resScale = ConfigurationState.Instance.Graphics.ResScale;
float resScaleCustom = ConfigurationState.Instance.Graphics.ResScaleCustom;
int resScale = ConfigurationState.Shared.Graphics.ResScale;
float resScaleCustom = ConfigurationState.Shared.Graphics.ResScaleCustom;
Graphics.Gpu.GraphicsConfig.ResScale = (resScale == -1) ? resScaleCustom : resScale;
Graphics.Gpu.GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
Graphics.Gpu.GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
Graphics.Gpu.GraphicsConfig.EnableShaderCache = ConfigurationState.Instance.Graphics.EnableShaderCache;
Graphics.Gpu.GraphicsConfig.EnableTextureRecompression = ConfigurationState.Instance.Graphics.EnableTextureRecompression;
Graphics.Gpu.GraphicsConfig.EnableMacroHLE = ConfigurationState.Instance.Graphics.EnableMacroHLE;
Graphics.Gpu.GraphicsConfig.MaxAnisotropy = ConfigurationState.Shared.Graphics.MaxAnisotropy;
Graphics.Gpu.GraphicsConfig.ShadersDumpPath = ConfigurationState.Shared.Graphics.ShadersDumpPath;
Graphics.Gpu.GraphicsConfig.EnableShaderCache = ConfigurationState.Shared.Graphics.EnableShaderCache;
Graphics.Gpu.GraphicsConfig.EnableTextureRecompression = ConfigurationState.Shared.Graphics.EnableTextureRecompression;
Graphics.Gpu.GraphicsConfig.EnableMacroHLE = ConfigurationState.Shared.Graphics.EnableMacroHLE;
}
public void UpdateInternetAccess()
{
if (_gameLoaded)
{
_emulationContext.Configuration.EnableInternetAccess = ConfigurationState.Instance.System.EnableInternetAccess.Value;
_emulationContext.Configuration.EnableInternetAccess = ConfigurationState.Shared.System.EnableInternetAccess.Value;
}
}
public static void SaveConfig()
{
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
private void End()
@ -1243,8 +1243,8 @@ namespace Ryujinx.UI
{
TreeViewColumn column = (TreeViewColumn)sender;
ConfigurationState.Instance.UI.ColumnSort.SortColumnId.Value = column.SortColumnId;
ConfigurationState.Instance.UI.ColumnSort.SortAscending.Value = column.SortOrder == SortType.Ascending;
ConfigurationState.Shared.UI.ColumnSort.SortColumnId.Value = column.SortColumnId;
ConfigurationState.Shared.UI.ColumnSort.SortAscending.Value = column.SortOrder == SortType.Ascending;
SaveConfig();
}
@ -1267,7 +1267,7 @@ namespace Ryujinx.UI
private void DockedMode_Clicked(object sender, ButtonReleaseEventArgs args)
{
ConfigurationState.Instance.System.EnableDockedMode.Value = !ConfigurationState.Instance.System.EnableDockedMode.Value;
ConfigurationState.Shared.System.EnableDockedMode.Value = !ConfigurationState.Shared.System.EnableDockedMode.Value;
}
private static string GetVolumeLabelText(float volume)
@ -1283,7 +1283,7 @@ namespace Ryujinx.UI
{
if (_emulationContext.IsAudioMuted())
{
_emulationContext.SetVolume(ConfigurationState.Instance.System.AudioVolume);
_emulationContext.SetVolume(ConfigurationState.Shared.System.AudioVolume);
}
else
{
@ -1294,9 +1294,9 @@ namespace Ryujinx.UI
private void AspectRatio_Clicked(object sender, ButtonReleaseEventArgs args)
{
AspectRatio aspectRatio = ConfigurationState.Instance.Graphics.AspectRatio.Value;
AspectRatio aspectRatio = ConfigurationState.Shared.Graphics.AspectRatio.Value;
ConfigurationState.Instance.Graphics.AspectRatio.Value = ((int)aspectRatio + 1) > Enum.GetNames<AspectRatio>().Length - 1 ? AspectRatio.Fixed4x3 : aspectRatio + 1;
ConfigurationState.Shared.Graphics.AspectRatio.Value = ((int)aspectRatio + 1) > Enum.GetNames<AspectRatio>().Length - 1 ? AspectRatio.Fixed4x3 : aspectRatio + 1;
}
private void Row_Clicked(object sender, ButtonReleaseEventArgs args)
@ -1385,7 +1385,7 @@ namespace Ryujinx.UI
private void Exit_Pressed(object sender, EventArgs args)
{
if (!_gameLoaded || !ConfigurationState.Instance.ShowConfirmExit || GtkDialog.CreateExitDialog())
if (!_gameLoaded || !ConfigurationState.Shared.ShowConfirmExit || GtkDialog.CreateExitDialog())
{
SaveWindowSizePosition();
End();
@ -1394,7 +1394,7 @@ namespace Ryujinx.UI
private void Window_Close(object sender, DeleteEventArgs args)
{
if (!_gameLoaded || !ConfigurationState.Instance.ShowConfirmExit || GtkDialog.CreateExitDialog())
if (!_gameLoaded || !ConfigurationState.Shared.ShowConfirmExit || GtkDialog.CreateExitDialog())
{
SaveWindowSizePosition();
End();
@ -1407,12 +1407,12 @@ namespace Ryujinx.UI
private void SetWindowSizePosition()
{
DefaultWidth = ConfigurationState.Instance.UI.WindowStartup.WindowSizeWidth;
DefaultHeight = ConfigurationState.Instance.UI.WindowStartup.WindowSizeHeight;
DefaultWidth = ConfigurationState.Shared.UI.WindowStartup.WindowSizeWidth;
DefaultHeight = ConfigurationState.Shared.UI.WindowStartup.WindowSizeHeight;
Move(ConfigurationState.Instance.UI.WindowStartup.WindowPositionX, ConfigurationState.Instance.UI.WindowStartup.WindowPositionY);
Move(ConfigurationState.Shared.UI.WindowStartup.WindowPositionX, ConfigurationState.Shared.UI.WindowStartup.WindowPositionY);
if (ConfigurationState.Instance.UI.WindowStartup.WindowMaximized)
if (ConfigurationState.Shared.UI.WindowStartup.WindowMaximized)
{
Maximize();
}
@ -1423,11 +1423,11 @@ namespace Ryujinx.UI
GetSize(out int windowWidth, out int windowHeight);
GetPosition(out int windowXPos, out int windowYPos);
ConfigurationState.Instance.UI.WindowStartup.WindowMaximized.Value = IsMaximized;
ConfigurationState.Instance.UI.WindowStartup.WindowSizeWidth.Value = windowWidth;
ConfigurationState.Instance.UI.WindowStartup.WindowSizeHeight.Value = windowHeight;
ConfigurationState.Instance.UI.WindowStartup.WindowPositionX.Value = windowXPos;
ConfigurationState.Instance.UI.WindowStartup.WindowPositionY.Value = windowYPos;
ConfigurationState.Shared.UI.WindowStartup.WindowMaximized.Value = IsMaximized;
ConfigurationState.Shared.UI.WindowStartup.WindowSizeWidth.Value = windowWidth;
ConfigurationState.Shared.UI.WindowStartup.WindowSizeHeight.Value = windowHeight;
ConfigurationState.Shared.UI.WindowStartup.WindowPositionX.Value = windowXPos;
ConfigurationState.Shared.UI.WindowStartup.WindowPositionY.Value = windowYPos;
SaveConfig();
}
@ -1677,14 +1677,14 @@ namespace Ryujinx.UI
private void StartFullScreen_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.StartFullscreen.Value = _startFullScreen.Active;
ConfigurationState.Shared.UI.StartFullscreen.Value = _startFullScreen.Active;
SaveConfig();
}
private void ShowConsole_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.ShowConsole.Value = _showConsole.Active;
ConfigurationState.Shared.UI.ShowConsole.Value = _showConsole.Active;
SaveConfig();
}
@ -1807,7 +1807,7 @@ namespace Ryujinx.UI
private void Fav_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.GuiColumns.FavColumn.Value = _favToggle.Active;
ConfigurationState.Shared.UI.GuiColumns.FavColumn.Value = _favToggle.Active;
SaveConfig();
UpdateColumns();
@ -1815,7 +1815,7 @@ namespace Ryujinx.UI
private void Icon_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.GuiColumns.IconColumn.Value = _iconToggle.Active;
ConfigurationState.Shared.UI.GuiColumns.IconColumn.Value = _iconToggle.Active;
SaveConfig();
UpdateColumns();
@ -1823,7 +1823,7 @@ namespace Ryujinx.UI
private void App_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.GuiColumns.AppColumn.Value = _appToggle.Active;
ConfigurationState.Shared.UI.GuiColumns.AppColumn.Value = _appToggle.Active;
SaveConfig();
UpdateColumns();
@ -1831,7 +1831,7 @@ namespace Ryujinx.UI
private void Developer_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.GuiColumns.DevColumn.Value = _developerToggle.Active;
ConfigurationState.Shared.UI.GuiColumns.DevColumn.Value = _developerToggle.Active;
SaveConfig();
UpdateColumns();
@ -1839,7 +1839,7 @@ namespace Ryujinx.UI
private void Version_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.GuiColumns.VersionColumn.Value = _versionToggle.Active;
ConfigurationState.Shared.UI.GuiColumns.VersionColumn.Value = _versionToggle.Active;
SaveConfig();
UpdateColumns();
@ -1847,7 +1847,7 @@ namespace Ryujinx.UI
private void TimePlayed_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.GuiColumns.TimePlayedColumn.Value = _timePlayedToggle.Active;
ConfigurationState.Shared.UI.GuiColumns.TimePlayedColumn.Value = _timePlayedToggle.Active;
SaveConfig();
UpdateColumns();
@ -1855,7 +1855,7 @@ namespace Ryujinx.UI
private void LastPlayed_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.GuiColumns.LastPlayedColumn.Value = _lastPlayedToggle.Active;
ConfigurationState.Shared.UI.GuiColumns.LastPlayedColumn.Value = _lastPlayedToggle.Active;
SaveConfig();
UpdateColumns();
@ -1863,7 +1863,7 @@ namespace Ryujinx.UI
private void FileExt_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.GuiColumns.FileExtColumn.Value = _fileExtToggle.Active;
ConfigurationState.Shared.UI.GuiColumns.FileExtColumn.Value = _fileExtToggle.Active;
SaveConfig();
UpdateColumns();
@ -1871,7 +1871,7 @@ namespace Ryujinx.UI
private void FileSize_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.GuiColumns.FileSizeColumn.Value = _fileSizeToggle.Active;
ConfigurationState.Shared.UI.GuiColumns.FileSizeColumn.Value = _fileSizeToggle.Active;
SaveConfig();
UpdateColumns();
@ -1879,7 +1879,7 @@ namespace Ryujinx.UI
private void Path_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.GuiColumns.PathColumn.Value = _pathToggle.Active;
ConfigurationState.Shared.UI.GuiColumns.PathColumn.Value = _pathToggle.Active;
SaveConfig();
UpdateColumns();
@ -1887,7 +1887,7 @@ namespace Ryujinx.UI
private void NSP_Shown_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.ShownFileTypes.NSP.Value = _nspShown.Active;
ConfigurationState.Shared.UI.ShownFileTypes.NSP.Value = _nspShown.Active;
SaveConfig();
UpdateGameTable();
@ -1895,7 +1895,7 @@ namespace Ryujinx.UI
private void PFS0_Shown_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.ShownFileTypes.PFS0.Value = _pfs0Shown.Active;
ConfigurationState.Shared.UI.ShownFileTypes.PFS0.Value = _pfs0Shown.Active;
SaveConfig();
UpdateGameTable();
@ -1903,7 +1903,7 @@ namespace Ryujinx.UI
private void XCI_Shown_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.ShownFileTypes.XCI.Value = _xciShown.Active;
ConfigurationState.Shared.UI.ShownFileTypes.XCI.Value = _xciShown.Active;
SaveConfig();
UpdateGameTable();
@ -1911,7 +1911,7 @@ namespace Ryujinx.UI
private void NCA_Shown_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.ShownFileTypes.NCA.Value = _ncaShown.Active;
ConfigurationState.Shared.UI.ShownFileTypes.NCA.Value = _ncaShown.Active;
SaveConfig();
UpdateGameTable();
@ -1919,7 +1919,7 @@ namespace Ryujinx.UI
private void NRO_Shown_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.ShownFileTypes.NRO.Value = _nroShown.Active;
ConfigurationState.Shared.UI.ShownFileTypes.NRO.Value = _nroShown.Active;
SaveConfig();
UpdateGameTable();
@ -1927,7 +1927,7 @@ namespace Ryujinx.UI
private void NSO_Shown_Toggled(object sender, EventArgs args)
{
ConfigurationState.Instance.UI.ShownFileTypes.NSO.Value = _nsoShown.Active;
ConfigurationState.Shared.UI.ShownFileTypes.NSO.Value = _nsoShown.Active;
SaveConfig();
UpdateGameTable();

View File

@ -115,25 +115,25 @@ namespace Ryujinx.UI
_gpuCancellationTokenSource = new CancellationTokenSource();
_hideCursorMode = ConfigurationState.Instance.HideCursor;
_hideCursorMode = ConfigurationState.Shared.HideCursor;
_lastCursorMoveTime = Stopwatch.GetTimestamp();
ConfigurationState.Instance.HideCursor.Event += HideCursorStateChanged;
ConfigurationState.Instance.Graphics.AntiAliasing.Event += UpdateAnriAliasing;
ConfigurationState.Instance.Graphics.ScalingFilter.Event += UpdateScalingFilter;
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event += UpdateScalingFilterLevel;
ConfigurationState.Shared.HideCursor.Event += HideCursorStateChanged;
ConfigurationState.Shared.Graphics.AntiAliasing.Event += UpdateAnriAliasing;
ConfigurationState.Shared.Graphics.ScalingFilter.Event += UpdateScalingFilter;
ConfigurationState.Shared.Graphics.ScalingFilterLevel.Event += UpdateScalingFilterLevel;
}
private void UpdateScalingFilterLevel(object sender, ReactiveEventArgs<int> e)
{
Renderer.Window.SetScalingFilter((ScalingFilter)ConfigurationState.Instance.Graphics.ScalingFilter.Value);
Renderer.Window.SetScalingFilterLevel(ConfigurationState.Instance.Graphics.ScalingFilterLevel.Value);
Renderer.Window.SetScalingFilter((ScalingFilter)ConfigurationState.Shared.Graphics.ScalingFilter.Value);
Renderer.Window.SetScalingFilterLevel(ConfigurationState.Shared.Graphics.ScalingFilterLevel.Value);
}
private void UpdateScalingFilter(object sender, ReactiveEventArgs<Ryujinx.Common.Configuration.ScalingFilter> e)
{
Renderer.Window.SetScalingFilter((ScalingFilter)ConfigurationState.Instance.Graphics.ScalingFilter.Value);
Renderer.Window.SetScalingFilterLevel(ConfigurationState.Instance.Graphics.ScalingFilterLevel.Value);
Renderer.Window.SetScalingFilter((ScalingFilter)ConfigurationState.Shared.Graphics.ScalingFilter.Value);
Renderer.Window.SetScalingFilterLevel(ConfigurationState.Shared.Graphics.ScalingFilterLevel.Value);
}
public abstract void InitializeRenderer();
@ -172,10 +172,10 @@ namespace Ryujinx.UI
private void Renderer_Destroyed(object sender, EventArgs e)
{
ConfigurationState.Instance.HideCursor.Event -= HideCursorStateChanged;
ConfigurationState.Instance.Graphics.AntiAliasing.Event -= UpdateAnriAliasing;
ConfigurationState.Instance.Graphics.ScalingFilter.Event -= UpdateScalingFilter;
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event -= UpdateScalingFilterLevel;
ConfigurationState.Shared.HideCursor.Event -= HideCursorStateChanged;
ConfigurationState.Shared.Graphics.AntiAliasing.Event -= UpdateAnriAliasing;
ConfigurationState.Shared.Graphics.ScalingFilter.Event -= UpdateScalingFilter;
ConfigurationState.Shared.Graphics.ScalingFilterLevel.Event -= UpdateScalingFilterLevel;
NpadManager.Dispose();
Dispose();
@ -193,7 +193,7 @@ namespace Ryujinx.UI
_lastCursorMoveTime = Stopwatch.GetTimestamp();
}
if (ConfigurationState.Instance.Hid.EnableMouse)
if (ConfigurationState.Shared.Hid.EnableMouse)
{
Window.Cursor = _invisibleCursor;
}
@ -205,7 +205,7 @@ namespace Ryujinx.UI
protected override bool OnEnterNotifyEvent(EventCrossing evnt)
{
Window.Cursor = ConfigurationState.Instance.Hid.EnableMouse ? _invisibleCursor : null;
Window.Cursor = ConfigurationState.Shared.Hid.EnableMouse ? _invisibleCursor : null;
_isMouseInClient = true;
@ -294,7 +294,7 @@ namespace Ryujinx.UI
{
if (keyboard.IsPressed(Key.Escape))
{
if (!ConfigurationState.Instance.ShowConfirmExit || GtkDialog.CreateExitDialog())
if (!ConfigurationState.Shared.ShowConfirmExit || GtkDialog.CreateExitDialog())
{
Exit();
}
@ -316,8 +316,8 @@ namespace Ryujinx.UI
{
if (toggleDockedMode)
{
ConfigurationState.Instance.System.EnableDockedMode.Value =
!ConfigurationState.Instance.System.EnableDockedMode.Value;
ConfigurationState.Shared.System.EnableDockedMode.Value =
!ConfigurationState.Shared.System.EnableDockedMode.Value;
}
}
@ -325,7 +325,7 @@ namespace Ryujinx.UI
if (_isMouseInClient)
{
if (ConfigurationState.Instance.Hid.EnableMouse.Value)
if (ConfigurationState.Shared.Hid.EnableMouse.Value)
{
Window.Cursor = _invisibleCursor;
}
@ -367,7 +367,7 @@ namespace Ryujinx.UI
Renderer.ScreenCaptured += Renderer_ScreenCaptured;
}
NpadManager.Initialize(device, ConfigurationState.Instance.Hid.InputConfig, ConfigurationState.Instance.Hid.EnableKeyboard, ConfigurationState.Instance.Hid.EnableMouse);
NpadManager.Initialize(device, ConfigurationState.Shared.Hid.InputConfig, ConfigurationState.Shared.Hid.EnableKeyboard, ConfigurationState.Shared.Hid.EnableMouse);
TouchScreenManager.Initialize(device);
}
@ -443,9 +443,9 @@ namespace Ryujinx.UI
Device.Gpu.Renderer.Initialize(_glLogLevel);
Renderer.Window.SetAntiAliasing((Graphics.GAL.AntiAliasing)ConfigurationState.Instance.Graphics.AntiAliasing.Value);
Renderer.Window.SetScalingFilter((Graphics.GAL.ScalingFilter)ConfigurationState.Instance.Graphics.ScalingFilter.Value);
Renderer.Window.SetScalingFilterLevel(ConfigurationState.Instance.Graphics.ScalingFilterLevel.Value);
Renderer.Window.SetAntiAliasing((Graphics.GAL.AntiAliasing)ConfigurationState.Shared.Graphics.AntiAliasing.Value);
Renderer.Window.SetScalingFilter((Graphics.GAL.ScalingFilter)ConfigurationState.Shared.Graphics.ScalingFilter.Value);
Renderer.Window.SetScalingFilterLevel(ConfigurationState.Shared.Graphics.ScalingFilterLevel.Value);
_gpuBackendName = GetGpuBackendName();
_gpuDriverName = GetGpuDriverName();
@ -484,7 +484,7 @@ namespace Ryujinx.UI
if (_ticks >= _ticksPerFrame)
{
string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? "Docked" : "Handheld";
string dockedMode = ConfigurationState.Shared.System.EnableDockedMode ? "Docked" : "Handheld";
float scale = GraphicsConfig.ResScale;
if (scale != 1)
{
@ -496,7 +496,7 @@ namespace Ryujinx.UI
Device.GetVolume(),
_gpuBackendName,
dockedMode,
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
ConfigurationState.Shared.Graphics.AspectRatio.Value.ToText(),
$"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
$"FIFO: {Device.Statistics.GetFifoPercent():0.00} %",
$"GPU: {_gpuDriverName}"));
@ -644,7 +644,7 @@ namespace Ryujinx.UI
});
}
NpadManager.Update(ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
NpadManager.Update(ConfigurationState.Shared.Graphics.AspectRatio.Value.ToFloat());
if ((Toplevel as MainWindow).IsFocused)
{
@ -681,7 +681,7 @@ namespace Ryujinx.UI
{
if (Device.IsAudioMuted())
{
Device.SetVolume(ConfigurationState.Instance.System.AudioVolume);
Device.SetVolume(ConfigurationState.Shared.System.AudioVolume);
}
else
{
@ -723,9 +723,9 @@ namespace Ryujinx.UI
bool hasTouch = false;
// Get screen touch position
if ((Toplevel as MainWindow).IsFocused && !ConfigurationState.Instance.Hid.EnableMouse)
if ((Toplevel as MainWindow).IsFocused && !ConfigurationState.Shared.Hid.EnableMouse)
{
hasTouch = TouchScreenManager.Update(true, (_inputManager.MouseDriver as GTK3MouseDriver).IsButtonPressed(MouseButton.Button1), ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
hasTouch = TouchScreenManager.Update(true, (_inputManager.MouseDriver as GTK3MouseDriver).IsButtonPressed(MouseButton.Button1), ConfigurationState.Shared.Graphics.AspectRatio.Value.ToFloat());
}
if (!hasTouch)
@ -757,47 +757,47 @@ namespace Ryujinx.UI
{
KeyboardHotkeyState state = KeyboardHotkeyState.None;
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ToggleVsync))
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.ToggleVsync))
{
state |= KeyboardHotkeyState.ToggleVSync;
}
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Screenshot))
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.Screenshot))
{
state |= KeyboardHotkeyState.Screenshot;
}
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUI))
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.ShowUI))
{
state |= KeyboardHotkeyState.ShowUI;
}
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Pause))
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.Pause))
{
state |= KeyboardHotkeyState.Pause;
}
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ToggleMute))
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.ToggleMute))
{
state |= KeyboardHotkeyState.ToggleMute;
}
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ResScaleUp))
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.ResScaleUp))
{
state |= KeyboardHotkeyState.ResScaleUp;
}
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ResScaleDown))
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.ResScaleDown))
{
state |= KeyboardHotkeyState.ResScaleDown;
}
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.VolumeUp))
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.VolumeUp))
{
state |= KeyboardHotkeyState.VolumeUp;
}
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.VolumeDown))
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.VolumeDown))
{
state |= KeyboardHotkeyState.VolumeDown;
}

View File

@ -637,7 +637,7 @@ namespace Ryujinx.UI.Widgets
private void CreateShortcut_Clicked(object sender, EventArgs args)
{
byte[] appIcon = new ApplicationLibrary(_virtualFileSystem).GetApplicationIcon(_titleFilePath, ConfigurationState.Instance.System.Language);
byte[] appIcon = new ApplicationLibrary(_virtualFileSystem).GetApplicationIcon(_titleFilePath, ConfigurationState.Shared.System.Language);
ShortcutHelper.CreateAppShortcut(_titleFilePath, _titleName, _titleIdText, appIcon);
}
}

View File

@ -134,7 +134,7 @@ namespace Ryujinx.UI.Windows
builder.Autoconnect(this);
_playerIndex = controllerId;
_inputConfig = ConfigurationState.Instance.Hid.InputConfig.Value.Find(inputConfig => inputConfig.PlayerIndex == _playerIndex);
_inputConfig = ConfigurationState.Shared.Hid.InputConfig.Value.Find(inputConfig => inputConfig.PlayerIndex == _playerIndex);
Title = $"Ryujinx - Controller Settings - {_playerIndex}";
@ -1193,7 +1193,7 @@ namespace Ryujinx.UI.Windows
InputConfig inputConfig = GetValues();
var newConfig = new List<InputConfig>();
newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value);
newConfig.AddRange(ConfigurationState.Shared.Hid.InputConfig.Value);
if (_inputConfig == null && inputConfig != null)
{
@ -1213,13 +1213,13 @@ namespace Ryujinx.UI.Windows
}
}
_mainWindow.RendererWidget?.NpadManager.ReloadConfiguration(newConfig, ConfigurationState.Instance.Hid.EnableKeyboard, ConfigurationState.Instance.Hid.EnableMouse);
_mainWindow.RendererWidget?.NpadManager.ReloadConfiguration(newConfig, ConfigurationState.Shared.Hid.EnableKeyboard, ConfigurationState.Shared.Hid.EnableMouse);
// Atomically replace and signal input change.
// NOTE: Do not modify InputConfig.Value directly as other code depends on the on-change event.
ConfigurationState.Instance.Hid.InputConfig.Value = newConfig;
ConfigurationState.Shared.Hid.InputConfig.Value = newConfig;
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
Dispose();
}

View File

@ -151,54 +151,54 @@ namespace Ryujinx.UI.Windows
_scalingFilter.Changed += (sender, args) => _scalingFilterSlider.Visible = _scalingFilter.ActiveId == "2";
_galThreading.Changed += (sender, args) =>
{
if (_galThreading.ActiveId != ConfigurationState.Instance.Graphics.BackendThreading.Value.ToString())
if (_galThreading.ActiveId != ConfigurationState.Shared.Graphics.BackendThreading.Value.ToString())
{
GtkDialog.CreateInfoDialog("Warning - Backend Threading", "Ryujinx must be restarted after changing this option for it to apply fully. Depending on your platform, you may need to manually disable your driver's own multithreading when using Ryujinx's.");
}
};
// Setup Currents.
if (ConfigurationState.Instance.Logger.EnableTrace)
if (ConfigurationState.Shared.Logger.EnableTrace)
{
_traceLogToggle.Click();
}
if (ConfigurationState.Instance.Logger.EnableFileLog)
if (ConfigurationState.Shared.Logger.EnableFileLog)
{
_fileLogToggle.Click();
}
if (ConfigurationState.Instance.Logger.EnableError)
if (ConfigurationState.Shared.Logger.EnableError)
{
_errorLogToggle.Click();
}
if (ConfigurationState.Instance.Logger.EnableWarn)
if (ConfigurationState.Shared.Logger.EnableWarn)
{
_warningLogToggle.Click();
}
if (ConfigurationState.Instance.Logger.EnableInfo)
if (ConfigurationState.Shared.Logger.EnableInfo)
{
_infoLogToggle.Click();
}
if (ConfigurationState.Instance.Logger.EnableStub)
if (ConfigurationState.Shared.Logger.EnableStub)
{
_stubLogToggle.Click();
}
if (ConfigurationState.Instance.Logger.EnableDebug)
if (ConfigurationState.Shared.Logger.EnableDebug)
{
_debugLogToggle.Click();
}
if (ConfigurationState.Instance.Logger.EnableGuest)
if (ConfigurationState.Shared.Logger.EnableGuest)
{
_guestLogToggle.Click();
}
if (ConfigurationState.Instance.Logger.EnableFsAccessLog)
if (ConfigurationState.Shared.Logger.EnableFsAccessLog)
{
_fsAccessLogToggle.Click();
}
@ -208,29 +208,29 @@ namespace Ryujinx.UI.Windows
_graphicsDebugLevel.Append(level.ToString(), level.ToString());
}
_graphicsDebugLevel.SetActiveId(ConfigurationState.Instance.Logger.GraphicsDebugLevel.Value.ToString());
_graphicsDebugLevel.SetActiveId(ConfigurationState.Shared.Logger.GraphicsDebugLevel.Value.ToString());
if (ConfigurationState.Instance.System.EnableDockedMode)
if (ConfigurationState.Shared.System.EnableDockedMode)
{
_dockedModeToggle.Click();
}
if (ConfigurationState.Instance.EnableDiscordIntegration)
if (ConfigurationState.Shared.EnableDiscordIntegration)
{
_discordToggle.Click();
}
if (ConfigurationState.Instance.CheckUpdatesOnStart)
if (ConfigurationState.Shared.CheckUpdatesOnStart)
{
_checkUpdatesToggle.Click();
}
if (ConfigurationState.Instance.ShowConfirmExit)
if (ConfigurationState.Shared.ShowConfirmExit)
{
_showConfirmExitToggle.Click();
}
switch (ConfigurationState.Instance.HideCursor.Value)
switch (ConfigurationState.Shared.HideCursor.Value)
{
case HideCursorMode.Never:
_hideCursorNever.Click();
@ -243,42 +243,42 @@ namespace Ryujinx.UI.Windows
break;
}
if (ConfigurationState.Instance.Graphics.EnableVsync)
if (ConfigurationState.Shared.Graphics.EnableVsync)
{
_vSyncToggle.Click();
}
if (ConfigurationState.Instance.Graphics.EnableShaderCache)
if (ConfigurationState.Shared.Graphics.EnableShaderCache)
{
_shaderCacheToggle.Click();
}
if (ConfigurationState.Instance.Graphics.EnableTextureRecompression)
if (ConfigurationState.Shared.Graphics.EnableTextureRecompression)
{
_textureRecompressionToggle.Click();
}
if (ConfigurationState.Instance.Graphics.EnableMacroHLE)
if (ConfigurationState.Shared.Graphics.EnableMacroHLE)
{
_macroHLEToggle.Click();
}
if (ConfigurationState.Instance.System.EnablePtc)
if (ConfigurationState.Shared.System.EnablePtc)
{
_ptcToggle.Click();
}
if (ConfigurationState.Instance.System.EnableInternetAccess)
if (ConfigurationState.Shared.System.EnableInternetAccess)
{
_internetToggle.Click();
}
if (ConfigurationState.Instance.System.EnableFsIntegrityChecks)
if (ConfigurationState.Shared.System.EnableFsIntegrityChecks)
{
_fsicToggle.Click();
}
switch (ConfigurationState.Instance.System.MemoryManagerMode.Value)
switch (ConfigurationState.Shared.System.MemoryManagerMode.Value)
{
case MemoryManagerMode.SoftwarePageTable:
_mmSoftware.Click();
@ -291,27 +291,27 @@ namespace Ryujinx.UI.Windows
break;
}
if (ConfigurationState.Instance.System.ExpandRam)
if (ConfigurationState.Shared.System.ExpandRam)
{
_expandRamToggle.Click();
}
if (ConfigurationState.Instance.System.IgnoreMissingServices)
if (ConfigurationState.Shared.System.IgnoreMissingServices)
{
_ignoreToggle.Click();
}
if (ConfigurationState.Instance.Hid.EnableKeyboard)
if (ConfigurationState.Shared.Hid.EnableKeyboard)
{
_directKeyboardAccess.Click();
}
if (ConfigurationState.Instance.Hid.EnableMouse)
if (ConfigurationState.Shared.Hid.EnableMouse)
{
_directMouseAccess.Click();
}
if (ConfigurationState.Instance.UI.EnableCustomTheme)
if (ConfigurationState.Shared.UI.EnableCustomTheme)
{
_custThemeToggle.Click();
}
@ -345,41 +345,41 @@ namespace Ryujinx.UI.Windows
}
_systemTimeZoneEntry.WidthChars = Math.Max(20, maxLocationLength + 1); // Ensure minimum Entry width
_systemTimeZoneEntry.Text = _timeZoneContentManager.SanityCheckDeviceLocationName(ConfigurationState.Instance.System.TimeZone);
_systemTimeZoneEntry.Text = _timeZoneContentManager.SanityCheckDeviceLocationName(ConfigurationState.Shared.System.TimeZone);
_systemTimeZoneCompletion.MatchFunc = TimeZoneMatchFunc;
_systemLanguageSelect.SetActiveId(ConfigurationState.Instance.System.Language.Value.ToString());
_systemRegionSelect.SetActiveId(ConfigurationState.Instance.System.Region.Value.ToString());
_galThreading.SetActiveId(ConfigurationState.Instance.Graphics.BackendThreading.Value.ToString());
_resScaleCombo.SetActiveId(ConfigurationState.Instance.Graphics.ResScale.Value.ToString());
_anisotropy.SetActiveId(ConfigurationState.Instance.Graphics.MaxAnisotropy.Value.ToString());
_aspectRatio.SetActiveId(((int)ConfigurationState.Instance.Graphics.AspectRatio.Value).ToString());
_graphicsBackend.SetActiveId(((int)ConfigurationState.Instance.Graphics.GraphicsBackend.Value).ToString());
_antiAliasing.SetActiveId(((int)ConfigurationState.Instance.Graphics.AntiAliasing.Value).ToString());
_scalingFilter.SetActiveId(((int)ConfigurationState.Instance.Graphics.ScalingFilter.Value).ToString());
_systemLanguageSelect.SetActiveId(ConfigurationState.Shared.System.Language.Value.ToString());
_systemRegionSelect.SetActiveId(ConfigurationState.Shared.System.Region.Value.ToString());
_galThreading.SetActiveId(ConfigurationState.Shared.Graphics.BackendThreading.Value.ToString());
_resScaleCombo.SetActiveId(ConfigurationState.Shared.Graphics.ResScale.Value.ToString());
_anisotropy.SetActiveId(ConfigurationState.Shared.Graphics.MaxAnisotropy.Value.ToString());
_aspectRatio.SetActiveId(((int)ConfigurationState.Shared.Graphics.AspectRatio.Value).ToString());
_graphicsBackend.SetActiveId(((int)ConfigurationState.Shared.Graphics.GraphicsBackend.Value).ToString());
_antiAliasing.SetActiveId(((int)ConfigurationState.Shared.Graphics.AntiAliasing.Value).ToString());
_scalingFilter.SetActiveId(((int)ConfigurationState.Shared.Graphics.ScalingFilter.Value).ToString());
UpdatePreferredGpuComboBox();
_graphicsBackend.Changed += (sender, e) => UpdatePreferredGpuComboBox();
PopulateNetworkInterfaces();
_multiLanSelect.SetActiveId(ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value);
_multiModeSelect.SetActiveId(ConfigurationState.Instance.Multiplayer.Mode.Value.ToString());
_multiLanSelect.SetActiveId(ConfigurationState.Shared.Multiplayer.LanInterfaceId.Value);
_multiModeSelect.SetActiveId(ConfigurationState.Shared.Multiplayer.Mode.Value.ToString());
_custThemePath.Buffer.Text = ConfigurationState.Instance.UI.CustomThemePath;
_resScaleText.Buffer.Text = ConfigurationState.Instance.Graphics.ResScaleCustom.Value.ToString();
_scalingFilterLevel.Value = ConfigurationState.Instance.Graphics.ScalingFilterLevel.Value;
_custThemePath.Buffer.Text = ConfigurationState.Shared.UI.CustomThemePath;
_resScaleText.Buffer.Text = ConfigurationState.Shared.Graphics.ResScaleCustom.Value.ToString();
_scalingFilterLevel.Value = ConfigurationState.Shared.Graphics.ScalingFilterLevel.Value;
_resScaleText.Visible = _resScaleCombo.ActiveId == "-1";
_scalingFilterSlider.Visible = _scalingFilter.ActiveId == "2";
_graphicsShadersDumpPath.Buffer.Text = ConfigurationState.Instance.Graphics.ShadersDumpPath;
_fsLogSpinAdjustment.Value = ConfigurationState.Instance.System.FsGlobalAccessLogMode;
_systemTimeOffset = ConfigurationState.Instance.System.SystemTimeOffset;
_graphicsShadersDumpPath.Buffer.Text = ConfigurationState.Shared.Graphics.ShadersDumpPath;
_fsLogSpinAdjustment.Value = ConfigurationState.Shared.System.FsGlobalAccessLogMode;
_systemTimeOffset = ConfigurationState.Shared.System.SystemTimeOffset;
_gameDirsBox.AppendColumn("", new CellRendererText(), "text", 0);
_gameDirsBoxStore = new ListStore(typeof(string));
_gameDirsBox.Model = _gameDirsBoxStore;
foreach (string gameDir in ConfigurationState.Instance.UI.GameDirs.Value)
foreach (string gameDir in ConfigurationState.Shared.UI.GameDirs.Value)
{
_gameDirsBoxStore.AppendValues(gameDir);
}
@ -405,7 +405,7 @@ namespace Ryujinx.UI.Windows
_audioBackendSelect.EntryTextColumn = 0;
_audioBackendSelect.Entry.IsEditable = false;
switch (ConfigurationState.Instance.System.AudioBackend.Value)
switch (ConfigurationState.Shared.System.AudioBackend.Value)
{
case AudioBackend.OpenAl:
_audioBackendSelect.SetActiveIter(openAlIter);
@ -420,13 +420,13 @@ namespace Ryujinx.UI.Windows
_audioBackendSelect.SetActiveIter(dummyIter);
break;
default:
throw new InvalidOperationException($"{nameof(ConfigurationState.Instance.System.AudioBackend)} contains an invalid value: {ConfigurationState.Instance.System.AudioBackend.Value}");
throw new InvalidOperationException($"{nameof(ConfigurationState.Shared.System.AudioBackend)} contains an invalid value: {ConfigurationState.Shared.System.AudioBackend.Value}");
}
_audioBackendBox.Add(_audioBackendSelect);
_audioBackendSelect.Show();
_previousVolumeLevel = ConfigurationState.Instance.System.AudioVolume;
_previousVolumeLevel = ConfigurationState.Shared.System.AudioVolume;
_audioVolumeLabel = new Label("Volume: ");
_audioVolumeSlider = new Scale(Orientation.Horizontal, 0, 100, 1);
_audioVolumeLabel.MarginStart = 10;
@ -481,7 +481,7 @@ namespace Ryujinx.UI.Windows
if (Enum.Parse<GraphicsBackend>(_graphicsBackend.ActiveId) == GraphicsBackend.Vulkan)
{
var devices = Graphics.Vulkan.VulkanRenderer.GetPhysicalDevices();
string preferredGpuIdFromConfig = ConfigurationState.Instance.Graphics.PreferredGpu.Value;
string preferredGpuIdFromConfig = ConfigurationState.Shared.Graphics.PreferredGpu.Value;
string preferredGpuId = preferredGpuIdFromConfig;
bool noGpuId = string.IsNullOrEmpty(preferredGpuIdFromConfig);
@ -568,7 +568,7 @@ namespace Ryujinx.UI.Windows
_gameDirsBoxStore.IterNext(ref treeIter);
}
ConfigurationState.Instance.UI.GameDirs.Value = gameDirs;
ConfigurationState.Shared.UI.GameDirs.Value = gameDirs;
_directoryChanged = false;
}
@ -592,7 +592,7 @@ namespace Ryujinx.UI.Windows
if (_validTzRegions.Contains(_systemTimeZoneEntry.Text))
{
ConfigurationState.Instance.System.TimeZone.Value = _systemTimeZoneEntry.Text;
ConfigurationState.Shared.System.TimeZone.Value = _systemTimeZoneEntry.Text;
}
MemoryManagerMode memoryMode = MemoryManagerMode.SoftwarePageTable;
@ -608,69 +608,69 @@ namespace Ryujinx.UI.Windows
}
BackendThreading backendThreading = Enum.Parse<BackendThreading>(_galThreading.ActiveId);
if (ConfigurationState.Instance.Graphics.BackendThreading != backendThreading)
if (ConfigurationState.Shared.Graphics.BackendThreading != backendThreading)
{
DriverUtilities.ToggleOGLThreading(backendThreading == BackendThreading.Off);
}
ConfigurationState.Instance.Logger.EnableError.Value = _errorLogToggle.Active;
ConfigurationState.Instance.Logger.EnableTrace.Value = _traceLogToggle.Active;
ConfigurationState.Instance.Logger.EnableWarn.Value = _warningLogToggle.Active;
ConfigurationState.Instance.Logger.EnableInfo.Value = _infoLogToggle.Active;
ConfigurationState.Instance.Logger.EnableStub.Value = _stubLogToggle.Active;
ConfigurationState.Instance.Logger.EnableDebug.Value = _debugLogToggle.Active;
ConfigurationState.Instance.Logger.EnableGuest.Value = _guestLogToggle.Active;
ConfigurationState.Instance.Logger.EnableFsAccessLog.Value = _fsAccessLogToggle.Active;
ConfigurationState.Instance.Logger.EnableFileLog.Value = _fileLogToggle.Active;
ConfigurationState.Instance.Logger.GraphicsDebugLevel.Value = Enum.Parse<GraphicsDebugLevel>(_graphicsDebugLevel.ActiveId);
ConfigurationState.Instance.System.EnableDockedMode.Value = _dockedModeToggle.Active;
ConfigurationState.Instance.EnableDiscordIntegration.Value = _discordToggle.Active;
ConfigurationState.Instance.CheckUpdatesOnStart.Value = _checkUpdatesToggle.Active;
ConfigurationState.Instance.ShowConfirmExit.Value = _showConfirmExitToggle.Active;
ConfigurationState.Instance.HideCursor.Value = hideCursor;
ConfigurationState.Instance.Graphics.EnableVsync.Value = _vSyncToggle.Active;
ConfigurationState.Instance.Graphics.EnableShaderCache.Value = _shaderCacheToggle.Active;
ConfigurationState.Instance.Graphics.EnableTextureRecompression.Value = _textureRecompressionToggle.Active;
ConfigurationState.Instance.Graphics.EnableMacroHLE.Value = _macroHLEToggle.Active;
ConfigurationState.Instance.System.EnablePtc.Value = _ptcToggle.Active;
ConfigurationState.Instance.System.EnableInternetAccess.Value = _internetToggle.Active;
ConfigurationState.Instance.System.EnableFsIntegrityChecks.Value = _fsicToggle.Active;
ConfigurationState.Instance.System.MemoryManagerMode.Value = memoryMode;
ConfigurationState.Instance.System.ExpandRam.Value = _expandRamToggle.Active;
ConfigurationState.Instance.System.IgnoreMissingServices.Value = _ignoreToggle.Active;
ConfigurationState.Instance.Hid.EnableKeyboard.Value = _directKeyboardAccess.Active;
ConfigurationState.Instance.Hid.EnableMouse.Value = _directMouseAccess.Active;
ConfigurationState.Instance.UI.EnableCustomTheme.Value = _custThemeToggle.Active;
ConfigurationState.Instance.System.Language.Value = Enum.Parse<Language>(_systemLanguageSelect.ActiveId);
ConfigurationState.Instance.System.Region.Value = Enum.Parse<Common.Configuration.System.Region>(_systemRegionSelect.ActiveId);
ConfigurationState.Instance.System.SystemTimeOffset.Value = _systemTimeOffset;
ConfigurationState.Instance.UI.CustomThemePath.Value = _custThemePath.Buffer.Text;
ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = _graphicsShadersDumpPath.Buffer.Text;
ConfigurationState.Instance.System.FsGlobalAccessLogMode.Value = (int)_fsLogSpinAdjustment.Value;
ConfigurationState.Instance.Graphics.MaxAnisotropy.Value = float.Parse(_anisotropy.ActiveId, CultureInfo.InvariantCulture);
ConfigurationState.Instance.Graphics.AspectRatio.Value = Enum.Parse<AspectRatio>(_aspectRatio.ActiveId);
ConfigurationState.Instance.Graphics.BackendThreading.Value = backendThreading;
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = Enum.Parse<GraphicsBackend>(_graphicsBackend.ActiveId);
ConfigurationState.Instance.Graphics.PreferredGpu.Value = _preferredGpu.ActiveId;
ConfigurationState.Instance.Graphics.ResScale.Value = int.Parse(_resScaleCombo.ActiveId);
ConfigurationState.Instance.Graphics.ResScaleCustom.Value = resScaleCustom;
ConfigurationState.Instance.System.AudioVolume.Value = (float)_audioVolumeSlider.Value / 100.0f;
ConfigurationState.Instance.Graphics.AntiAliasing.Value = Enum.Parse<AntiAliasing>(_antiAliasing.ActiveId);
ConfigurationState.Instance.Graphics.ScalingFilter.Value = Enum.Parse<ScalingFilter>(_scalingFilter.ActiveId);
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Value = (int)_scalingFilterLevel.Value;
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value = _multiLanSelect.ActiveId;
ConfigurationState.Shared.Logger.EnableError.Value = _errorLogToggle.Active;
ConfigurationState.Shared.Logger.EnableTrace.Value = _traceLogToggle.Active;
ConfigurationState.Shared.Logger.EnableWarn.Value = _warningLogToggle.Active;
ConfigurationState.Shared.Logger.EnableInfo.Value = _infoLogToggle.Active;
ConfigurationState.Shared.Logger.EnableStub.Value = _stubLogToggle.Active;
ConfigurationState.Shared.Logger.EnableDebug.Value = _debugLogToggle.Active;
ConfigurationState.Shared.Logger.EnableGuest.Value = _guestLogToggle.Active;
ConfigurationState.Shared.Logger.EnableFsAccessLog.Value = _fsAccessLogToggle.Active;
ConfigurationState.Shared.Logger.EnableFileLog.Value = _fileLogToggle.Active;
ConfigurationState.Shared.Logger.GraphicsDebugLevel.Value = Enum.Parse<GraphicsDebugLevel>(_graphicsDebugLevel.ActiveId);
ConfigurationState.Shared.System.EnableDockedMode.Value = _dockedModeToggle.Active;
ConfigurationState.Shared.EnableDiscordIntegration.Value = _discordToggle.Active;
ConfigurationState.Shared.CheckUpdatesOnStart.Value = _checkUpdatesToggle.Active;
ConfigurationState.Shared.ShowConfirmExit.Value = _showConfirmExitToggle.Active;
ConfigurationState.Shared.HideCursor.Value = hideCursor;
ConfigurationState.Shared.Graphics.EnableVsync.Value = _vSyncToggle.Active;
ConfigurationState.Shared.Graphics.EnableShaderCache.Value = _shaderCacheToggle.Active;
ConfigurationState.Shared.Graphics.EnableTextureRecompression.Value = _textureRecompressionToggle.Active;
ConfigurationState.Shared.Graphics.EnableMacroHLE.Value = _macroHLEToggle.Active;
ConfigurationState.Shared.System.EnablePtc.Value = _ptcToggle.Active;
ConfigurationState.Shared.System.EnableInternetAccess.Value = _internetToggle.Active;
ConfigurationState.Shared.System.EnableFsIntegrityChecks.Value = _fsicToggle.Active;
ConfigurationState.Shared.System.MemoryManagerMode.Value = memoryMode;
ConfigurationState.Shared.System.ExpandRam.Value = _expandRamToggle.Active;
ConfigurationState.Shared.System.IgnoreMissingServices.Value = _ignoreToggle.Active;
ConfigurationState.Shared.Hid.EnableKeyboard.Value = _directKeyboardAccess.Active;
ConfigurationState.Shared.Hid.EnableMouse.Value = _directMouseAccess.Active;
ConfigurationState.Shared.UI.EnableCustomTheme.Value = _custThemeToggle.Active;
ConfigurationState.Shared.System.Language.Value = Enum.Parse<Language>(_systemLanguageSelect.ActiveId);
ConfigurationState.Shared.System.Region.Value = Enum.Parse<Common.Configuration.System.Region>(_systemRegionSelect.ActiveId);
ConfigurationState.Shared.System.SystemTimeOffset.Value = _systemTimeOffset;
ConfigurationState.Shared.UI.CustomThemePath.Value = _custThemePath.Buffer.Text;
ConfigurationState.Shared.Graphics.ShadersDumpPath.Value = _graphicsShadersDumpPath.Buffer.Text;
ConfigurationState.Shared.System.FsGlobalAccessLogMode.Value = (int)_fsLogSpinAdjustment.Value;
ConfigurationState.Shared.Graphics.MaxAnisotropy.Value = float.Parse(_anisotropy.ActiveId, CultureInfo.InvariantCulture);
ConfigurationState.Shared.Graphics.AspectRatio.Value = Enum.Parse<AspectRatio>(_aspectRatio.ActiveId);
ConfigurationState.Shared.Graphics.BackendThreading.Value = backendThreading;
ConfigurationState.Shared.Graphics.GraphicsBackend.Value = Enum.Parse<GraphicsBackend>(_graphicsBackend.ActiveId);
ConfigurationState.Shared.Graphics.PreferredGpu.Value = _preferredGpu.ActiveId;
ConfigurationState.Shared.Graphics.ResScale.Value = int.Parse(_resScaleCombo.ActiveId);
ConfigurationState.Shared.Graphics.ResScaleCustom.Value = resScaleCustom;
ConfigurationState.Shared.System.AudioVolume.Value = (float)_audioVolumeSlider.Value / 100.0f;
ConfigurationState.Shared.Graphics.AntiAliasing.Value = Enum.Parse<AntiAliasing>(_antiAliasing.ActiveId);
ConfigurationState.Shared.Graphics.ScalingFilter.Value = Enum.Parse<ScalingFilter>(_scalingFilter.ActiveId);
ConfigurationState.Shared.Graphics.ScalingFilterLevel.Value = (int)_scalingFilterLevel.Value;
ConfigurationState.Shared.Multiplayer.LanInterfaceId.Value = _multiLanSelect.ActiveId;
_previousVolumeLevel = ConfigurationState.Instance.System.AudioVolume.Value;
_previousVolumeLevel = ConfigurationState.Shared.System.AudioVolume.Value;
ConfigurationState.Instance.Multiplayer.Mode.Value = Enum.Parse<MultiplayerMode>(_multiModeSelect.ActiveId);
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value = _multiLanSelect.ActiveId;
ConfigurationState.Shared.Multiplayer.Mode.Value = Enum.Parse<MultiplayerMode>(_multiModeSelect.ActiveId);
ConfigurationState.Shared.Multiplayer.LanInterfaceId.Value = _multiLanSelect.ActiveId;
if (_audioBackendSelect.GetActiveIter(out TreeIter activeIter))
{
ConfigurationState.Instance.System.AudioBackend.Value = (AudioBackend)_audioBackendStore.GetValue(activeIter, 1);
ConfigurationState.Shared.System.AudioBackend.Value = (AudioBackend)_audioBackendStore.GetValue(activeIter, 1);
}
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
_parent.UpdateInternetAccess();
MainWindow.UpdateGraphicsConfig();
@ -684,7 +684,7 @@ namespace Ryujinx.UI.Windows
{
if (!_validTzRegions.Contains(_systemTimeZoneEntry.Text))
{
_systemTimeZoneEntry.Text = _timeZoneContentManager.SanityCheckDeviceLocationName(ConfigurationState.Instance.System.TimeZone);
_systemTimeZoneEntry.Text = _timeZoneContentManager.SanityCheckDeviceLocationName(ConfigurationState.Shared.System.TimeZone);
}
}
@ -824,7 +824,7 @@ namespace Ryujinx.UI.Windows
private void VolumeSlider_OnChange(object sender, EventArgs args)
{
ConfigurationState.Instance.System.AudioVolume.Value = (float)(_audioVolumeSlider.Value / 100);
ConfigurationState.Shared.System.AudioVolume.Value = (float)(_audioVolumeSlider.Value / 100);
}
private void SaveToggle_Activated(object sender, EventArgs args)
@ -840,7 +840,7 @@ namespace Ryujinx.UI.Windows
private void CloseToggle_Activated(object sender, EventArgs args)
{
ConfigurationState.Instance.System.AudioVolume.Value = _previousVolumeLevel;
ConfigurationState.Shared.System.AudioVolume.Value = _previousVolumeLevel;
Dispose();
}
}

View File

@ -116,12 +116,12 @@ namespace Ryujinx.UI.App.Common
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", SearchOption.AllDirectories).Where(file =>
{
return
(Path.GetExtension(file).ToLower() is ".nsp" && ConfigurationState.Instance.UI.ShownFileTypes.NSP.Value) ||
(Path.GetExtension(file).ToLower() is ".pfs0" && ConfigurationState.Instance.UI.ShownFileTypes.PFS0.Value) ||
(Path.GetExtension(file).ToLower() is ".xci" && ConfigurationState.Instance.UI.ShownFileTypes.XCI.Value) ||
(Path.GetExtension(file).ToLower() is ".nca" && ConfigurationState.Instance.UI.ShownFileTypes.NCA.Value) ||
(Path.GetExtension(file).ToLower() is ".nro" && ConfigurationState.Instance.UI.ShownFileTypes.NRO.Value) ||
(Path.GetExtension(file).ToLower() is ".nso" && ConfigurationState.Instance.UI.ShownFileTypes.NSO.Value);
(Path.GetExtension(file).ToLower() is ".nsp" && ConfigurationState.Shared.UI.ShownFileTypes.NSP.Value) ||
(Path.GetExtension(file).ToLower() is ".pfs0" && ConfigurationState.Shared.UI.ShownFileTypes.PFS0.Value) ||
(Path.GetExtension(file).ToLower() is ".xci" && ConfigurationState.Shared.UI.ShownFileTypes.XCI.Value) ||
(Path.GetExtension(file).ToLower() is ".nca" && ConfigurationState.Shared.UI.ShownFileTypes.NCA.Value) ||
(Path.GetExtension(file).ToLower() is ".nro" && ConfigurationState.Shared.UI.ShownFileTypes.NRO.Value) ||
(Path.GetExtension(file).ToLower() is ".nso" && ConfigurationState.Shared.UI.ShownFileTypes.NSO.Value);
});
foreach (string app in files)

View File

@ -12,6 +12,7 @@ using Ryujinx.UI.Common.Helper;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text.Json.Nodes;
namespace Ryujinx.UI.Common.Configuration
@ -578,9 +579,16 @@ namespace Ryujinx.UI.Common.Configuration
}
/// <summary>
/// The default configuration instance
/// The shared configuration instance
/// </summary>
public static ConfigurationState Instance { get; private set; }
public static ConfigurationState Shared { get; private set; }
/// <summary>
/// The title-specific configuration instance
/// </summary>
public static ConfigurationState Title { get; private set; }
public string TitleId { get; private set; } = null;
/// <summary>
/// The UI section
@ -1602,12 +1610,123 @@ namespace Ryujinx.UI.Common.Configuration
public static void Initialize()
{
if (Instance != null)
if (Shared != null)
{
throw new InvalidOperationException("Configuration is already initialized");
}
Instance = new ConfigurationState();
Shared = new ConfigurationState();
}
public static ConfigurationState Instance(bool titleSpecific = false)
{
if (titleSpecific)
{
return Title ?? throw new InvalidOperationException("Title Configuration is not initialized!");
}
return Shared;
}
/// <summary>
/// Returns the configuration path on disk for the specified title.
/// </summary>
/// <param name="titleId">Id of the selected title</param>
/// <returns>Disk path for the title's configuration file.</returns>
public static string ConfigurationFilePathForTitle(string titleId)
{
string localConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{titleId}.json");
string appDataConfigurationPath = Path.Combine(AppDataManager.BaseDirPath, $"{titleId}.json");
// Now load the configuration as the other subsystems are now registered
string gameConfigurationPath = File.Exists(localConfigurationPath)
? localConfigurationPath
: appDataConfigurationPath;
return gameConfigurationPath;
}
/// <summary>
/// Returns true if a configuration file exists for the specified title.
/// </summary>
/// <param name="titleId">Id of the selected title</param>
/// <returns>True is a file exists, false otherwise.</returns>
public static bool HasConfigurationForTitle(string titleId)
{
if (titleId == null)
return false;
string localConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{titleId}.json");
string appDataConfigurationPath = Path.Combine(AppDataManager.BaseDirPath, $"{titleId}.json");
return File.Exists(localConfigurationPath) || File.Exists(appDataConfigurationPath);
}
/// <summary>
/// Loads the configuration for the specific title into the Title singleton.
/// <br/>
/// If no configuration exists, a new one will be written to disk with the same configuration as the Global configuration.
/// <br/>
/// If there is an issue with the Global configuration, the default values will be used instead.
/// </summary>
/// <param name="titleId">Id of the selected title</param>
public static void LoadOrCreateConfigurationStateForTitle(string titleId)
{
if (titleId == null)
return;
if (!HasConfigurationForTitle(titleId))
{
string gameConfigurationPath = ConfigurationFilePathForTitle(titleId);
// Program.ConfigurationPath is not visible, so we need to mimic it here..
string globalLocalConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Config.json");
string globalAppDataConfigurationPath = Path.Combine(AppDataManager.BaseDirPath, $"Config.json");
string globalConfigurationPath = File.Exists(globalLocalConfigurationPath) ? globalLocalConfigurationPath : File.Exists(globalAppDataConfigurationPath) ? globalAppDataConfigurationPath : null;
Title = new ConfigurationState { TitleId = titleId };
// No configuration, we load the shared config values and save it to disk.
if (ConfigurationFileFormat.TryLoad(globalConfigurationPath, out ConfigurationFileFormat configurationFileFormat))
{
Title.Load(configurationFileFormat, gameConfigurationPath);
}
else
{
Title.LoadDefault();
}
Title.ToFileFormat().SaveConfig(gameConfigurationPath);
}
else
{
if (!LoadConfigurationStateForTitle(titleId))
{
Title = new ConfigurationState { TitleId = titleId };
Title.LoadDefault();
}
}
}
/// <summary>
/// Loads the configuration for the specified title.
/// </summary>
/// <param name="titleId">Id of the title</param>
/// <returns>True if loading was successful, false otherwise.</returns>
public static bool LoadConfigurationStateForTitle(string titleId)
{
if (!HasConfigurationForTitle(titleId))
return false;
string gameConfigurationPath = ConfigurationFilePathForTitle(titleId);
if (ConfigurationFileFormat.TryLoad(gameConfigurationPath, out ConfigurationFileFormat configurationFileFormat))
{
Title = new ConfigurationState { TitleId = titleId };
Title.Load(configurationFileFormat, gameConfigurationPath);
return true;
}
return false;
}
}
}

View File

@ -11,16 +11,16 @@ namespace Ryujinx.UI.Common.Configuration
{
public static void Initialize()
{
ConfigurationState.Instance.Logger.EnableDebug.Event += ReloadEnableDebug;
ConfigurationState.Instance.Logger.EnableStub.Event += ReloadEnableStub;
ConfigurationState.Instance.Logger.EnableInfo.Event += ReloadEnableInfo;
ConfigurationState.Instance.Logger.EnableWarn.Event += ReloadEnableWarning;
ConfigurationState.Instance.Logger.EnableError.Event += ReloadEnableError;
ConfigurationState.Instance.Logger.EnableTrace.Event += ReloadEnableTrace;
ConfigurationState.Instance.Logger.EnableGuest.Event += ReloadEnableGuest;
ConfigurationState.Instance.Logger.EnableFsAccessLog.Event += ReloadEnableFsAccessLog;
ConfigurationState.Instance.Logger.FilteredClasses.Event += ReloadFilteredClasses;
ConfigurationState.Instance.Logger.EnableFileLog.Event += ReloadFileLogger;
ConfigurationState.Shared.Logger.EnableDebug.Event += ReloadEnableDebug;
ConfigurationState.Shared.Logger.EnableStub.Event += ReloadEnableStub;
ConfigurationState.Shared.Logger.EnableInfo.Event += ReloadEnableInfo;
ConfigurationState.Shared.Logger.EnableWarn.Event += ReloadEnableWarning;
ConfigurationState.Shared.Logger.EnableError.Event += ReloadEnableError;
ConfigurationState.Shared.Logger.EnableTrace.Event += ReloadEnableTrace;
ConfigurationState.Shared.Logger.EnableGuest.Event += ReloadEnableGuest;
ConfigurationState.Shared.Logger.EnableFsAccessLog.Event += ReloadEnableFsAccessLog;
ConfigurationState.Shared.Logger.FilteredClasses.Event += ReloadFilteredClasses;
ConfigurationState.Shared.Logger.EnableFileLog.Event += ReloadFileLogger;
}
private static void ReloadEnableDebug(object sender, ReactiveEventArgs<bool> e)

View File

@ -38,7 +38,7 @@ namespace Ryujinx.UI.Common
],
};
ConfigurationState.Instance.EnableDiscordIntegration.Event += Update;
ConfigurationState.Shared.EnableDiscordIntegration.Event += Update;
}
private static void Update(object sender, ReactiveEventArgs<bool> evnt)

View File

@ -44,9 +44,9 @@ namespace Ryujinx.Ava
{
ApplyConfiguredTheme();
ConfigurationState.Instance.UI.BaseStyle.Event += ThemeChanged_Event;
ConfigurationState.Instance.UI.CustomThemePath.Event += ThemeChanged_Event;
ConfigurationState.Instance.UI.EnableCustomTheme.Event += CustomThemeChanged_Event;
ConfigurationState.Shared.UI.BaseStyle.Event += ThemeChanged_Event;
ConfigurationState.Shared.UI.CustomThemePath.Event += ThemeChanged_Event;
ConfigurationState.Shared.UI.EnableCustomTheme.Event += CustomThemeChanged_Event;
}
}
@ -90,13 +90,13 @@ namespace Ryujinx.Ava
{
try
{
string baseStyle = ConfigurationState.Instance.UI.BaseStyle;
string baseStyle = ConfigurationState.Shared.UI.BaseStyle;
if (string.IsNullOrWhiteSpace(baseStyle))
{
ConfigurationState.Instance.UI.BaseStyle.Value = "Auto";
ConfigurationState.Shared.UI.BaseStyle.Value = "Auto";
baseStyle = ConfigurationState.Instance.UI.BaseStyle;
baseStyle = ConfigurationState.Shared.UI.BaseStyle;
}
ThemeVariant systemTheme = DetectSystemTheme();

View File

@ -19,6 +19,7 @@ using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.Windows;
using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Multiplayer;
using Ryujinx.Common.Logging;
using Ryujinx.Common.SystemInterop;
@ -103,7 +104,7 @@ namespace Ryujinx.Ava
ForceChangeCursor
};
private CursorStates _cursorState = !ConfigurationState.Instance.Hid.EnableMouse.Value ?
private CursorStates _cursorState = !ConfigurationState.Shared.Hid.EnableMouse.Value ?
CursorStates.CursorIsVisible : CursorStates.CursorIsHidden;
private bool _isStopped;
@ -120,6 +121,14 @@ namespace Ryujinx.Ava
private bool _dialogShown;
private readonly bool _isFirmwareTitle;
private bool UseTitleConfiguration
{
get
{
return ConfigurationState.HasConfigurationForTitle(_viewModel.SelectedApplication?.TitleId);
}
}
private readonly object _lockObject = new();
public event EventHandler AppExit;
@ -154,7 +163,7 @@ namespace Ryujinx.Ava
_userChannelPersistence = userChannelPersistence;
_renderingThread = new Thread(RenderLoop) { Name = "GUI.RenderThread" };
_lastCursorMoveTime = Stopwatch.GetTimestamp();
_glLogLevel = ConfigurationState.Instance.Logger.GraphicsDebugLevel;
_glLogLevel = ConfigurationState.Instance(UseTitleConfiguration).Logger.GraphicsDebugLevel;
_topLevel = topLevel;
_inputManager.SetMouseDriver(new AvaloniaMouseDriver(_topLevel, renderer));
@ -179,7 +188,7 @@ namespace Ryujinx.Ava
_isFirmwareTitle = true;
}
ConfigurationState.Instance.HideCursor.Event += HideCursorState_Changed;
ConfigurationState.Shared.HideCursor.Event += HideCursorState_Changed;
_topLevel.PointerMoved += TopLevel_PointerEnteredOrMoved;
_topLevel.PointerEntered += TopLevel_PointerEnteredOrMoved;
@ -191,20 +200,20 @@ namespace Ryujinx.Ava
_defaultCursorWin = CreateArrowCursor();
}
ConfigurationState.Instance.System.IgnoreMissingServices.Event += UpdateIgnoreMissingServicesState;
ConfigurationState.Instance.Graphics.AspectRatio.Event += UpdateAspectRatioState;
ConfigurationState.Instance.System.EnableDockedMode.Event += UpdateDockedModeState;
ConfigurationState.Instance.System.AudioVolume.Event += UpdateAudioVolumeState;
ConfigurationState.Instance.System.EnableDockedMode.Event += UpdateDockedModeState;
ConfigurationState.Instance.System.AudioVolume.Event += UpdateAudioVolumeState;
ConfigurationState.Instance.Graphics.AntiAliasing.Event += UpdateAntiAliasing;
ConfigurationState.Instance.Graphics.ScalingFilter.Event += UpdateScalingFilter;
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event += UpdateScalingFilterLevel;
ConfigurationState.Instance.Graphics.EnableColorSpacePassthrough.Event += UpdateColorSpacePassthrough;
ConfigurationState.Instance(UseTitleConfiguration).System.IgnoreMissingServices.Event += UpdateIgnoreMissingServicesState;
ConfigurationState.Instance(UseTitleConfiguration).Graphics.AspectRatio.Event += UpdateAspectRatioState;
ConfigurationState.Instance(UseTitleConfiguration).System.EnableDockedMode.Event += UpdateDockedModeState;
ConfigurationState.Instance(UseTitleConfiguration).System.AudioVolume.Event += UpdateAudioVolumeState;
ConfigurationState.Instance(UseTitleConfiguration).System.EnableDockedMode.Event += UpdateDockedModeState;
ConfigurationState.Instance(UseTitleConfiguration).System.AudioVolume.Event += UpdateAudioVolumeState;
ConfigurationState.Instance(UseTitleConfiguration).Graphics.AntiAliasing.Event += UpdateAntiAliasing;
ConfigurationState.Instance(UseTitleConfiguration).Graphics.ScalingFilter.Event += UpdateScalingFilter;
ConfigurationState.Instance(UseTitleConfiguration).Graphics.ScalingFilterLevel.Event += UpdateScalingFilterLevel;
ConfigurationState.Instance(UseTitleConfiguration).Graphics.EnableColorSpacePassthrough.Event += UpdateColorSpacePassthrough;
ConfigurationState.Instance.System.EnableInternetAccess.Event += UpdateEnableInternetAccessState;
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Event += UpdateLanInterfaceIdState;
ConfigurationState.Instance.Multiplayer.Mode.Event += UpdateMultiplayerModeState;
ConfigurationState.Instance(UseTitleConfiguration).System.EnableInternetAccess.Event += UpdateEnableInternetAccessState;
ConfigurationState.Instance(UseTitleConfiguration).Multiplayer.LanInterfaceId.Event += UpdateLanInterfaceIdState;
ConfigurationState.Instance(UseTitleConfiguration).Multiplayer.Mode.Event += UpdateMultiplayerModeState;
_gpuCancellationTokenSource = new CancellationTokenSource();
_gpuDoneEvent = new ManualResetEvent(false);
@ -221,7 +230,7 @@ namespace Ryujinx.Ava
if (sender is MainWindow window)
{
if (ConfigurationState.Instance.HideCursor.Value == HideCursorMode.OnIdle)
if (ConfigurationState.Shared.HideCursor.Value == HideCursorMode.OnIdle)
{
_lastCursorMoveTime = Stopwatch.GetTimestamp();
}
@ -275,19 +284,21 @@ namespace Ryujinx.Ava
private void UpdateScalingFilterLevel(object sender, ReactiveEventArgs<int> e)
{
_renderer.Window?.SetScalingFilter((Graphics.GAL.ScalingFilter)ConfigurationState.Instance.Graphics.ScalingFilter.Value);
_renderer.Window?.SetScalingFilterLevel(ConfigurationState.Instance.Graphics.ScalingFilterLevel.Value);
ConfigurationState config = ConfigurationState.Instance(UseTitleConfiguration);
_renderer.Window?.SetScalingFilter((Graphics.GAL.ScalingFilter)config.Graphics.ScalingFilter.Value);
_renderer.Window?.SetScalingFilterLevel(config.Graphics.ScalingFilterLevel.Value);
}
private void UpdateScalingFilter(object sender, ReactiveEventArgs<ScalingFilter> e)
{
_renderer.Window?.SetScalingFilter((Graphics.GAL.ScalingFilter)ConfigurationState.Instance.Graphics.ScalingFilter.Value);
_renderer.Window?.SetScalingFilterLevel(ConfigurationState.Instance.Graphics.ScalingFilterLevel.Value);
ConfigurationState config = ConfigurationState.Instance(UseTitleConfiguration);
_renderer.Window?.SetScalingFilter((Graphics.GAL.ScalingFilter)config.Graphics.ScalingFilter.Value);
_renderer.Window?.SetScalingFilterLevel(config.Graphics.ScalingFilterLevel.Value);
}
private void UpdateColorSpacePassthrough(object sender, ReactiveEventArgs<bool> e)
{
_renderer.Window?.SetColorSpacePassthrough((bool)ConfigurationState.Instance.Graphics.EnableColorSpacePassthrough.Value);
_renderer.Window?.SetColorSpacePassthrough((bool)ConfigurationState.Instance(UseTitleConfiguration).Graphics.EnableColorSpacePassthrough.Value);
}
private void ShowCursor()
@ -405,7 +416,9 @@ namespace Ryujinx.Ava
DisplaySleep.Prevent();
NpadManager.Initialize(Device, ConfigurationState.Instance.Hid.InputConfig, ConfigurationState.Instance.Hid.EnableKeyboard, ConfigurationState.Instance.Hid.EnableMouse);
ConfigurationState config = ConfigurationState.Instance(UseTitleConfiguration);
NpadManager.Initialize(Device, config.Hid.InputConfig, config.Hid.EnableKeyboard, config.Hid.EnableMouse);
TouchScreenManager.Initialize(Device);
_viewModel.IsGameRunning = true;
@ -423,7 +436,7 @@ namespace Ryujinx.Ava
_renderingThread.Start();
_viewModel.Volume = ConfigurationState.Instance.System.AudioVolume.Value;
_viewModel.Volume = config.System.AudioVolume.Value;
MainLoop();
@ -534,14 +547,16 @@ namespace Ryujinx.Ava
MainWindowViewModel.UpdateGameMetadata(Device.Processes.ActiveApplication.ProgramIdText);
}
ConfigurationState.Instance.System.IgnoreMissingServices.Event -= UpdateIgnoreMissingServicesState;
ConfigurationState.Instance.Graphics.AspectRatio.Event -= UpdateAspectRatioState;
ConfigurationState.Instance.System.EnableDockedMode.Event -= UpdateDockedModeState;
ConfigurationState.Instance.System.AudioVolume.Event -= UpdateAudioVolumeState;
ConfigurationState.Instance.Graphics.ScalingFilter.Event -= UpdateScalingFilter;
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event -= UpdateScalingFilterLevel;
ConfigurationState.Instance.Graphics.AntiAliasing.Event -= UpdateAntiAliasing;
ConfigurationState.Instance.Graphics.EnableColorSpacePassthrough.Event -= UpdateColorSpacePassthrough;
ConfigurationState config = ConfigurationState.Instance(UseTitleConfiguration);
config.System.IgnoreMissingServices.Event -= UpdateIgnoreMissingServicesState;
config.Graphics.AspectRatio.Event -= UpdateAspectRatioState;
config.System.EnableDockedMode.Event -= UpdateDockedModeState;
config.System.AudioVolume.Event -= UpdateAudioVolumeState;
config.Graphics.ScalingFilter.Event -= UpdateScalingFilter;
config.Graphics.ScalingFilterLevel.Event -= UpdateScalingFilterLevel;
config.Graphics.AntiAliasing.Event -= UpdateAntiAliasing;
config.Graphics.EnableColorSpacePassthrough.Event -= UpdateColorSpacePassthrough;
_topLevel.PointerMoved -= TopLevel_PointerEnteredOrMoved;
_topLevel.PointerEntered -= TopLevel_PointerEnteredOrMoved;
@ -813,20 +828,22 @@ namespace Ryujinx.Ava
// Initialize Renderer.
IRenderer renderer;
if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan)
ConfigurationState config = ConfigurationState.Instance(UseTitleConfiguration);
if (config.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan)
{
renderer = new VulkanRenderer(
Vk.GetApi(),
(RendererHost.EmbeddedWindow as EmbeddedWindowVulkan).CreateSurface,
VulkanHelper.GetRequiredInstanceExtensions,
ConfigurationState.Instance.Graphics.PreferredGpu.Value);
config.Graphics.PreferredGpu.Value);
}
else
{
renderer = new OpenGLRenderer();
}
BackendThreading threadingMode = ConfigurationState.Instance.Graphics.BackendThreading;
BackendThreading threadingMode = config.Graphics.BackendThreading;
var isGALThreaded = threadingMode == BackendThreading.On || (threadingMode == BackendThreading.Auto && renderer.PreferThreading);
if (isGALThreaded)
@ -837,7 +854,7 @@ namespace Ryujinx.Ava
Logger.Info?.PrintMsg(LogClass.Gpu, $"Backend Threading ({threadingMode}): {isGALThreaded}");
// Initialize Configuration.
var memoryConfiguration = ConfigurationState.Instance.System.ExpandRam.Value ? MemoryConfiguration.MemoryConfiguration6GiB : MemoryConfiguration.MemoryConfiguration4GiB;
var memoryConfiguration = config.System.ExpandRam.Value ? MemoryConfiguration.MemoryConfiguration6GiB : MemoryConfiguration.MemoryConfiguration4GiB;
HLEConfiguration configuration = new(VirtualFileSystem,
_viewModel.LibHacHorizonManager,
@ -848,28 +865,28 @@ namespace Ryujinx.Ava
InitializeAudio(),
memoryConfiguration,
_viewModel.UiHandler,
(SystemLanguage)ConfigurationState.Instance.System.Language.Value,
(RegionCode)ConfigurationState.Instance.System.Region.Value,
ConfigurationState.Instance.Graphics.EnableVsync,
ConfigurationState.Instance.System.EnableDockedMode,
ConfigurationState.Instance.System.EnablePtc,
ConfigurationState.Instance.System.EnableInternetAccess,
ConfigurationState.Instance.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None,
ConfigurationState.Instance.System.FsGlobalAccessLogMode,
ConfigurationState.Instance.System.SystemTimeOffset,
ConfigurationState.Instance.System.TimeZone,
ConfigurationState.Instance.System.MemoryManagerMode,
ConfigurationState.Instance.System.IgnoreMissingServices,
ConfigurationState.Instance.Graphics.AspectRatio,
ConfigurationState.Instance.System.AudioVolume,
ConfigurationState.Instance.System.UseHypervisor,
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value,
ConfigurationState.Instance.Multiplayer.Mode);
(SystemLanguage)config.System.Language.Value,
(RegionCode)config.System.Region.Value,
config.Graphics.EnableVsync,
config.System.EnableDockedMode,
config.System.EnablePtc,
config.System.EnableInternetAccess,
config.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None,
config.System.FsGlobalAccessLogMode,
config.System.SystemTimeOffset,
config.System.TimeZone,
config.System.MemoryManagerMode,
config.System.IgnoreMissingServices,
config.Graphics.AspectRatio,
config.System.AudioVolume,
config.System.UseHypervisor,
config.Multiplayer.LanInterfaceId.Value,
config.Multiplayer.Mode);
Device = new Switch(configuration);
}
private static IHardwareDeviceDriver InitializeAudio()
private IHardwareDeviceDriver InitializeAudio()
{
var availableBackends = new List<AudioBackend>
{
@ -879,7 +896,9 @@ namespace Ryujinx.Ava
AudioBackend.Dummy,
};
AudioBackend preferredBackend = ConfigurationState.Instance.System.AudioBackend.Value;
ConfigurationState config = ConfigurationState.Instance(UseTitleConfiguration);
AudioBackend preferredBackend = config.System.AudioBackend.Value;
for (int i = 0; i < availableBackends.Count; i++)
{
@ -920,7 +939,7 @@ namespace Ryujinx.Ava
if (deviceDriver != null)
{
ConfigurationState.Instance.System.AudioBackend.Value = currentBackend;
config.System.AudioBackend.Value = currentBackend;
break;
}
}
@ -964,6 +983,8 @@ namespace Ryujinx.Ava
}
});
ConfigurationState config = ConfigurationState.Instance(UseTitleConfiguration);
_renderer = Device.Gpu.Renderer is ThreadedRenderer tr ? tr.BaseRenderer : Device.Gpu.Renderer;
_renderer.ScreenCaptured += Renderer_ScreenCaptured;
@ -972,10 +993,10 @@ namespace Ryujinx.Ava
Device.Gpu.Renderer.Initialize(_glLogLevel);
_renderer?.Window?.SetAntiAliasing((Graphics.GAL.AntiAliasing)ConfigurationState.Instance.Graphics.AntiAliasing.Value);
_renderer?.Window?.SetScalingFilter((Graphics.GAL.ScalingFilter)ConfigurationState.Instance.Graphics.ScalingFilter.Value);
_renderer?.Window?.SetScalingFilterLevel(ConfigurationState.Instance.Graphics.ScalingFilterLevel.Value);
_renderer?.Window?.SetColorSpacePassthrough(ConfigurationState.Instance.Graphics.EnableColorSpacePassthrough.Value);
_renderer?.Window?.SetAntiAliasing((Graphics.GAL.AntiAliasing)config.Graphics.AntiAliasing.Value);
_renderer?.Window?.SetScalingFilter((Graphics.GAL.ScalingFilter)config.Graphics.ScalingFilter.Value);
_renderer?.Window?.SetScalingFilterLevel(config.Graphics.ScalingFilterLevel.Value);
_renderer?.Window?.SetColorSpacePassthrough(config.Graphics.EnableColorSpacePassthrough.Value);
Width = (int)RendererHost.Bounds.Width;
Height = (int)RendererHost.Bounds.Height;
@ -1037,7 +1058,7 @@ namespace Ryujinx.Ava
public void InitStatus()
{
StatusInitEvent?.Invoke(this, new StatusInitEventArgs(
ConfigurationState.Instance.Graphics.GraphicsBackend.Value switch
ConfigurationState.Instance(UseTitleConfiguration).Graphics.GraphicsBackend.Value switch
{
GraphicsBackend.Vulkan => "Vulkan",
GraphicsBackend.OpenGl => "OpenGL",
@ -1048,8 +1069,9 @@ namespace Ryujinx.Ava
public void UpdateStatus()
{
ConfigurationState config = ConfigurationState.Instance(UseTitleConfiguration);
// Run a status update only when a frame is to be drawn. This prevents from updating the ui and wasting a render when no frame is queued.
string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? LocaleManager.Instance[LocaleKeys.Docked] : LocaleManager.Instance[LocaleKeys.Handheld];
string dockedMode = config.System.EnableDockedMode ? LocaleManager.Instance[LocaleKeys.Docked] : LocaleManager.Instance[LocaleKeys.Handheld];
if (GraphicsConfig.ResScale != 1)
{
@ -1060,14 +1082,14 @@ namespace Ryujinx.Ava
Device.EnableDeviceVsync,
LocaleManager.Instance[LocaleKeys.VolumeShort] + $": {(int)(Device.GetVolume() * 100)}%",
dockedMode,
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
config.Graphics.AspectRatio.Value.ToText(),
LocaleManager.Instance[LocaleKeys.Game] + $": {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
$"FIFO: {Device.Statistics.GetFifoPercent():00.00} %"));
}
public async Task ShowExitPrompt()
{
bool shouldExit = !ConfigurationState.Instance.ShowConfirmExit;
bool shouldExit = !ConfigurationState.Shared.ShowConfirmExit;
if (!shouldExit)
{
if (_dialogShown)
@ -1095,7 +1117,9 @@ namespace Ryujinx.Ava
return false;
}
NpadManager.Update(ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
ConfigurationState config = ConfigurationState.Instance(UseTitleConfiguration);
NpadManager.Update(config.Graphics.AspectRatio.Value.ToFloat());
if (_viewModel.IsActive)
{
@ -1103,14 +1127,14 @@ namespace Ryujinx.Ava
if (_isCursorInRenderer && !_viewModel.ShowLoadProgress)
{
if (ConfigurationState.Instance.Hid.EnableMouse.Value)
if (config.Hid.EnableMouse.Value)
{
isCursorVisible = ConfigurationState.Instance.HideCursor.Value == HideCursorMode.Never;
isCursorVisible = config.HideCursor.Value == HideCursorMode.Never;
}
else
{
isCursorVisible = ConfigurationState.Instance.HideCursor.Value == HideCursorMode.Never ||
(ConfigurationState.Instance.HideCursor.Value == HideCursorMode.OnIdle &&
isCursorVisible = config.HideCursor.Value == HideCursorMode.Never ||
(config.HideCursor.Value == HideCursorMode.OnIdle &&
Stopwatch.GetTimestamp() - _lastCursorMoveTime < CursorHideIdleTime * Stopwatch.Frequency);
}
}
@ -1210,9 +1234,9 @@ namespace Ryujinx.Ava
// Touchscreen.
bool hasTouch = false;
if (_viewModel.IsActive && !ConfigurationState.Instance.Hid.EnableMouse.Value)
if (_viewModel.IsActive && !config.Hid.EnableMouse.Value)
{
hasTouch = TouchScreenManager.Update(true, (_inputManager.MouseDriver as AvaloniaMouseDriver).IsButtonPressed(MouseButton.Button1), ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
hasTouch = TouchScreenManager.Update(true, (_inputManager.MouseDriver as AvaloniaMouseDriver).IsButtonPressed(MouseButton.Button1), config.Graphics.AspectRatio.Value.ToFloat());
}
if (!hasTouch)
@ -1229,39 +1253,45 @@ namespace Ryujinx.Ava
{
KeyboardHotkeyState state = KeyboardHotkeyState.None;
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ToggleVsync))
ReactiveObject<KeyboardHotkeys> hotkeys = ConfigurationState.Instance(UseTitleConfiguration).Hid.Hotkeys;
if (hotkeys.Value == null)
{
Thread.Sleep(500);
}
if (_keyboardInterface.IsPressed((Key)hotkeys.Value!.ToggleVsync))
{
state = KeyboardHotkeyState.ToggleVSync;
}
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Screenshot))
else if (_keyboardInterface.IsPressed((Key)hotkeys.Value.Screenshot))
{
state = KeyboardHotkeyState.Screenshot;
}
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUI))
else if (_keyboardInterface.IsPressed((Key)hotkeys.Value.ShowUI))
{
state = KeyboardHotkeyState.ShowUI;
}
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Pause))
else if (_keyboardInterface.IsPressed((Key)hotkeys.Value.Pause))
{
state = KeyboardHotkeyState.Pause;
}
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ToggleMute))
else if (_keyboardInterface.IsPressed((Key)hotkeys.Value.ToggleMute))
{
state = KeyboardHotkeyState.ToggleMute;
}
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ResScaleUp))
else if (_keyboardInterface.IsPressed((Key)hotkeys.Value.ResScaleUp))
{
state = KeyboardHotkeyState.ResScaleUp;
}
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ResScaleDown))
else if (_keyboardInterface.IsPressed((Key)hotkeys.Value.ResScaleDown))
{
state = KeyboardHotkeyState.ResScaleDown;
}
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.VolumeUp))
else if (_keyboardInterface.IsPressed((Key)hotkeys.Value.VolumeUp))
{
state = KeyboardHotkeyState.VolumeUp;
}
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.VolumeDown))
else if (_keyboardInterface.IsPressed((Key)hotkeys.Value.VolumeDown))
{
state = KeyboardHotkeyState.VolumeDown;
}

View File

@ -53,6 +53,8 @@
"GameListContextMenuOpenDeviceSaveDirectory": "Open Device Save Directory",
"GameListContextMenuOpenDeviceSaveDirectoryToolTip": "Opens the directory which contains Application's Device Save",
"GameListContextMenuOpenBcatSaveDirectory": "Open BCAT Save Directory",
"GameListContextMenuManageTitleSettings": "Manage Title Settings",
"GameListContextMenuManageTitleSettingsTooltip": "Opens the title settings window",
"GameListContextMenuOpenBcatSaveDirectoryToolTip": "Opens the directory which contains Application's BCAT Save",
"GameListContextMenuManageTitleUpdates": "Manage Title Updates",
"GameListContextMenuManageTitleUpdatesToolTip": "Opens the Title Update management window",

View File

@ -32,8 +32,8 @@ namespace Ryujinx.Ava.Common.Locale
private void Load()
{
var localeLanguageCode = !string.IsNullOrEmpty(ConfigurationState.Instance.UI.LanguageCode.Value) ?
ConfigurationState.Instance.UI.LanguageCode.Value : CultureInfo.CurrentCulture.Name.Replace('-', '_');
var localeLanguageCode = !string.IsNullOrEmpty(ConfigurationState.Shared.UI.LanguageCode.Value) ?
ConfigurationState.Shared.UI.LanguageCode.Value : CultureInfo.CurrentCulture.Name.Replace('-', '_');
// Load en_US as default, if the target language translation is missing or incomplete.
LoadDefaultLanguage();
@ -42,9 +42,9 @@ namespace Ryujinx.Ava.Common.Locale
// Save whatever we ended up with.
if (Program.PreviewerDetached)
{
ConfigurationState.Instance.UI.LanguageCode.Value = _localeLanguageCode;
ConfigurationState.Shared.UI.LanguageCode.Value = _localeLanguageCode;
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
}

View File

@ -112,7 +112,7 @@ namespace Ryujinx.Ava
PrintSystemInfo();
// Enable OGL multithreading on the driver, when available.
DriverUtilities.ToggleOGLThreading(ConfigurationState.Instance.Graphics.BackendThreading == BackendThreading.Off);
DriverUtilities.ToggleOGLThreading(ConfigurationState.Shared.Graphics.BackendThreading == BackendThreading.Off);
// Check if keys exists.
if (!File.Exists(Path.Combine(AppDataManager.KeysDirPath, "prod.keys")))
@ -150,8 +150,8 @@ namespace Ryujinx.Ava
ConfigurationPath = appDataConfigurationPath;
Logger.Notice.Print(LogClass.Application, $"No configuration file found. Saving default configuration to: {ConfigurationPath}");
ConfigurationState.Instance.LoadDefault();
ConfigurationState.Instance.ToFileFormat().SaveConfig(ConfigurationPath);
ConfigurationState.Shared.LoadDefault();
ConfigurationState.Shared.ToFileFormat().SaveConfig(ConfigurationPath);
}
else
{
@ -159,46 +159,46 @@ namespace Ryujinx.Ava
if (ConfigurationFileFormat.TryLoad(ConfigurationPath, out ConfigurationFileFormat configurationFileFormat))
{
ConfigurationState.Instance.Load(configurationFileFormat, ConfigurationPath);
ConfigurationState.Shared.Load(configurationFileFormat, ConfigurationPath);
}
else
{
Logger.Warning?.PrintMsg(LogClass.Application, $"Failed to load config! Loading the default config instead.\nFailed config location: {ConfigurationPath}");
ConfigurationState.Instance.LoadDefault();
ConfigurationState.Shared.LoadDefault();
}
}
UseHardwareAcceleration = ConfigurationState.Instance.EnableHardwareAcceleration.Value;
UseHardwareAcceleration = ConfigurationState.Shared.EnableHardwareAcceleration.Value;
// Check if graphics backend was overridden
if (CommandLineState.OverrideGraphicsBackend != null)
{
if (CommandLineState.OverrideGraphicsBackend.ToLower() == "opengl")
{
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl;
ConfigurationState.Shared.Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl;
}
else if (CommandLineState.OverrideGraphicsBackend.ToLower() == "vulkan")
{
ConfigurationState.Instance.Graphics.GraphicsBackend.Value = GraphicsBackend.Vulkan;
ConfigurationState.Shared.Graphics.GraphicsBackend.Value = GraphicsBackend.Vulkan;
}
}
// Check if docked mode was overriden.
if (CommandLineState.OverrideDockedMode.HasValue)
{
ConfigurationState.Instance.System.EnableDockedMode.Value = CommandLineState.OverrideDockedMode.Value;
ConfigurationState.Shared.System.EnableDockedMode.Value = CommandLineState.OverrideDockedMode.Value;
}
// Check if HideCursor was overridden.
if (CommandLineState.OverrideHideCursor is not null)
{
ConfigurationState.Instance.HideCursor.Value = CommandLineState.OverrideHideCursor!.ToLower() switch
ConfigurationState.Shared.HideCursor.Value = CommandLineState.OverrideHideCursor!.ToLower() switch
{
"never" => HideCursorMode.Never,
"onidle" => HideCursorMode.OnIdle,
"always" => HideCursorMode.Always,
_ => ConfigurationState.Instance.HideCursor.Value,
_ => ConfigurationState.Shared.HideCursor.Value,
};
}

View File

@ -34,6 +34,10 @@
IsEnabled="{Binding OpenBcatSaveDirectoryEnabled}"
ToolTip.Tip="{locale:Locale GameListContextMenuOpenBcatSaveDirectoryToolTip}" />
<Separator />
<MenuItem
Click="OpenTitleSettingsWindow_Click"
Header="{locale:Locale GameListContextMenuManageTitleSettings}"
ToolTip.Tip="{locale:Locale GameListContextMenuManageTitleSettingsTooltip}" />
<MenuItem
Click="OpenTitleUpdateManager_Click"
Header="{locale:Locale GameListContextMenuManageTitleUpdates}"

View File

@ -92,6 +92,16 @@ namespace Ryujinx.Ava.UI.Controls
}
}
public void OpenTitleSettingsWindow_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
if (viewModel?.SelectedApplication != null)
{
new SettingsWindow(viewModel.VirtualFileSystem, viewModel.ContentManager, viewModel.SelectedApplication).Show();
}
}
public async void OpenTitleUpdateManager_Click(object sender, RoutedEventArgs args)
{
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;

View File

@ -118,7 +118,7 @@ namespace Ryujinx.Ava.UI.Renderer
[SupportedOSPlatform("linux")]
private IPlatformHandle CreateLinux(IPlatformHandle control)
{
if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan)
if (ConfigurationState.Shared.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan)
{
X11Window = new GLXWindow(new NativeHandle(X11.DefaultDisplay), new NativeHandle(control.Handle));
X11Window.Hide();

View File

@ -45,7 +45,7 @@ namespace Ryujinx.Ava.UI.Renderer
}
var flags = OpenGLContextFlags.Compat;
if (ConfigurationState.Instance.Logger.GraphicsDebugLevel != GraphicsDebugLevel.None)
if (ConfigurationState.Shared.Logger.GraphicsDebugLevel != GraphicsDebugLevel.None)
{
flags |= OpenGLContextFlags.Debug;
}

View File

@ -16,8 +16,11 @@ namespace Ryujinx.Ava.UI.Renderer
public RendererHost()
{
InitializeComponent();
}
if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.OpenGl)
public RendererHost(GraphicsBackend graphicsBackend) : this()
{
if (graphicsBackend == GraphicsBackend.OpenGl)
{
EmbeddedWindow = new EmbeddedWindowOpenGL();
}

View File

@ -88,7 +88,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public AboutWindowViewModel()
{
Version = Program.Version;
UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value);
UpdateLogoTheme(ConfigurationState.Shared.UI.BaseStyle.Value);
Dispatcher.UIThread.InvokeAsync(DownloadPatronsJson);
ThemeManager.ThemeChanged += ThemeManager_ThemeChanged;
@ -96,7 +96,7 @@ namespace Ryujinx.Ava.UI.ViewModels
private void ThemeManager_ThemeChanged(object sender, EventArgs e)
{
Dispatcher.UIThread.Post(() => UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value));
Dispatcher.UIThread.Post(() => UpdateLogoTheme(ConfigurationState.Shared.UI.BaseStyle.Value));
}
private void UpdateLogoTheme(string theme)

View File

@ -19,6 +19,7 @@ using Ryujinx.Common.Configuration.Hid.Keyboard;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Utilities;
using Ryujinx.Input;
using Ryujinx.UI.App.Common;
using Ryujinx.UI.Common.Configuration;
using System;
using System.Collections.Generic;
@ -51,9 +52,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
private object _configViewModel;
private string _profileName;
private bool _isLoaded;
private ApplicationData _applicationData;
private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
public bool IsTitleSpecificSettings => _applicationData != null;
public IGamepadDriver AvaloniaKeyboardDriver { get; }
public IGamepad SelectedGamepad { get; private set; }
@ -275,9 +279,20 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
PlayerIndexes.Add(new(PlayerIndex.Handheld, LocaleManager.Instance[LocaleKeys.ControllerSettingsHandheld]));
}
internal void SetApplicationData(ApplicationData applicationData)
{
_applicationData = applicationData;
OnPropertyChanged(nameof(_applicationData));
_isLoaded = false;
LoadConfiguration(ConfigurationState.Instance(IsTitleSpecificSettings).Hid.InputConfig.Value.Find(inputConfig => inputConfig.PlayerIndex == _playerId));
LoadDevice();
_isLoaded = true;
LoadProfiles();
}
private void LoadConfiguration(InputConfig inputConfig = null)
{
Config = inputConfig ?? ConfigurationState.Instance.Hid.InputConfig.Value.Find(inputConfig => inputConfig.PlayerIndex == _playerId);
Config = inputConfig ?? ConfigurationState.Shared.Hid.InputConfig.Value.Find(inputConfig => inputConfig.PlayerIndex == _playerId);
if (Config is StandardKeyboardInputConfig keyboardInputConfig)
{
@ -807,7 +822,9 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
List<InputConfig> newConfig = new();
newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value);
ConfigurationState configState = ConfigurationState.Instance(IsTitleSpecificSettings);
newConfig.AddRange(configState.Hid.InputConfig.Value);
newConfig.Remove(newConfig.Find(x => x == null));
@ -847,13 +864,15 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
}
}
_mainWindow.ViewModel.AppHost?.NpadManager.ReloadConfiguration(newConfig, ConfigurationState.Instance.Hid.EnableKeyboard, ConfigurationState.Instance.Hid.EnableMouse);
_mainWindow.ViewModel.AppHost?.NpadManager.ReloadConfiguration(newConfig, configState.Hid.EnableKeyboard, configState.Hid.EnableMouse);
// Atomically replace and signal input change.
// NOTE: Do not modify InputConfig.Value directly as other code depends on the on-change event.
ConfigurationState.Instance.Hid.InputConfig.Value = newConfig;
configState.Hid.InputConfig.Value = newConfig;
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
configState.ToFileFormat().SaveConfig(IsTitleSpecificSettings
? ConfigurationState.ConfigurationFilePathForTitle(_applicationData.TitleId)
: Program.ConfigurationPath);
}
public void NotifyChange(string property)
@ -863,6 +882,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public void NotifyChanges()
{
OnPropertyChanged(nameof(_applicationData));
OnPropertyChanged(nameof(ConfigViewModel));
OnPropertyChanged(nameof(IsController));
OnPropertyChanged(nameof(ShowSettings));

View File

@ -127,7 +127,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{
LoadConfigurableHotKeys();
Volume = ConfigurationState.Instance.System.AudioVolume;
Volume = ConfigurationState.Shared.System.AudioVolume;
}
}
@ -557,6 +557,9 @@ namespace Ryujinx.Ava.UI.ViewModels
{
_volume = value;
ConfigurationState config = ConfigurationState.Instance(SelectedApplication != null);
config.System.AudioVolume.Value = value;
if (_isGameRunning)
{
AppHost.Device.SetVolume(_volume);
@ -698,12 +701,12 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool StartGamesInFullscreen
{
get => ConfigurationState.Instance.UI.StartFullscreen;
get => ConfigurationState.Shared.UI.StartFullscreen;
set
{
ConfigurationState.Instance.UI.StartFullscreen.Value = value;
ConfigurationState.Shared.UI.StartFullscreen.Value = value;
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
OnPropertyChanged();
}
@ -711,12 +714,12 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool ShowConsole
{
get => ConfigurationState.Instance.UI.ShowConsole;
get => ConfigurationState.Shared.UI.ShowConsole;
set
{
ConfigurationState.Instance.UI.ShowConsole.Value = value;
ConfigurationState.Shared.UI.ShowConsole.Value = value;
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
OnPropertyChanged();
}
@ -756,44 +759,44 @@ namespace Ryujinx.Ava.UI.ViewModels
public Glyph Glyph
{
get => (Glyph)ConfigurationState.Instance.UI.GameListViewMode.Value;
get => (Glyph)ConfigurationState.Shared.UI.GameListViewMode.Value;
set
{
ConfigurationState.Instance.UI.GameListViewMode.Value = (int)value;
ConfigurationState.Shared.UI.GameListViewMode.Value = (int)value;
OnPropertyChanged();
OnPropertyChanged(nameof(IsGrid));
OnPropertyChanged(nameof(IsList));
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
}
public bool ShowNames
{
get => ConfigurationState.Instance.UI.ShowNames && ConfigurationState.Instance.UI.GridSize > 1; set
get => ConfigurationState.Shared.UI.ShowNames && ConfigurationState.Shared.UI.GridSize > 1; set
{
ConfigurationState.Instance.UI.ShowNames.Value = value;
ConfigurationState.Shared.UI.ShowNames.Value = value;
OnPropertyChanged();
OnPropertyChanged(nameof(GridSizeScale));
OnPropertyChanged(nameof(GridItemSelectorSize));
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
}
internal ApplicationSort SortMode
{
get => (ApplicationSort)ConfigurationState.Instance.UI.ApplicationSort.Value;
get => (ApplicationSort)ConfigurationState.Shared.UI.ApplicationSort.Value;
private set
{
ConfigurationState.Instance.UI.ApplicationSort.Value = (int)value;
ConfigurationState.Shared.UI.ApplicationSort.Value = (int)value;
OnPropertyChanged();
OnPropertyChanged(nameof(SortName));
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
}
@ -801,7 +804,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{
get
{
return ConfigurationState.Instance.UI.GridSize.Value switch
return ConfigurationState.Shared.UI.GridSize.Value switch
{
1 => 78,
2 => 100,
@ -816,7 +819,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{
get
{
return ConfigurationState.Instance.UI.GridSize.Value switch
return ConfigurationState.Shared.UI.GridSize.Value switch
{
1 => 120,
2 => ShowNames ? 210 : 150,
@ -829,10 +832,10 @@ namespace Ryujinx.Ava.UI.ViewModels
public int GridSizeScale
{
get => ConfigurationState.Instance.UI.GridSize;
get => ConfigurationState.Shared.UI.GridSize;
set
{
ConfigurationState.Instance.UI.GridSize.Value = value;
ConfigurationState.Shared.UI.GridSize.Value = value;
if (value < 2)
{
@ -848,7 +851,7 @@ namespace Ryujinx.Ava.UI.ViewModels
OnPropertyChanged(nameof(GridItemSelectorSize));
OnPropertyChanged(nameof(ShowNames));
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
}
@ -873,16 +876,16 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool IsAscending
{
get => ConfigurationState.Instance.UI.IsAscendingOrder;
get => ConfigurationState.Shared.UI.IsAscendingOrder;
private set
{
ConfigurationState.Instance.UI.IsAscendingOrder.Value = value;
ConfigurationState.Shared.UI.IsAscendingOrder.Value = value;
OnPropertyChanged();
OnPropertyChanged(nameof(SortMode));
OnPropertyChanged(nameof(SortName));
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
}
@ -941,10 +944,10 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool IsSortedByType => SortMode == ApplicationSort.FileType;
public bool IsSortedBySize => SortMode == ApplicationSort.FileSize;
public bool IsSortedByPath => SortMode == ApplicationSort.Path;
public bool IsGridSmall => ConfigurationState.Instance.UI.GridSize == 1;
public bool IsGridMedium => ConfigurationState.Instance.UI.GridSize == 2;
public bool IsGridLarge => ConfigurationState.Instance.UI.GridSize == 3;
public bool IsGridHuge => ConfigurationState.Instance.UI.GridSize == 4;
public bool IsGridSmall => ConfigurationState.Shared.UI.GridSize == 1;
public bool IsGridMedium => ConfigurationState.Shared.UI.GridSize == 2;
public bool IsGridLarge => ConfigurationState.Shared.UI.GridSize == 3;
public bool IsGridHuge => ConfigurationState.Shared.UI.GridSize == 4;
#endregion
@ -1276,17 +1279,17 @@ namespace Ryujinx.Ava.UI.ViewModels
public void LoadConfigurableHotKeys()
{
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUI, out var showUiKey))
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.ShowUI, out var showUiKey))
{
ShowUiKey = new KeyGesture(showUiKey);
}
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Screenshot, out var screenshotKey))
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.Screenshot, out var screenshotKey))
{
ScreenshotKey = new KeyGesture(screenshotKey);
}
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Pause, out var pauseKey))
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Shared.Hid.Hotkeys.Value.Pause, out var pauseKey))
{
PauseKey = new KeyGesture(pauseKey);
}
@ -1324,7 +1327,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public void SetAspectRatio(AspectRatio aspectRatio)
{
ConfigurationState.Instance.Graphics.AspectRatio.Value = aspectRatio;
ConfigurationState.Instance(SelectedApplication != null).Graphics.AspectRatio.Value = aspectRatio;
}
public async Task InstallFirmwareFromFile()
@ -1392,7 +1395,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{
if (IsGameRunning)
{
ConfigurationState.Instance.System.EnableDockedMode.Value = !ConfigurationState.Instance.System.EnableDockedMode.Value;
ConfigurationState.Shared.System.EnableDockedMode.Value = !ConfigurationState.Shared.System.EnableDockedMode.Value;
}
}
@ -1416,8 +1419,8 @@ namespace Ryujinx.Ava.UI.ViewModels
if (Program.PreviewerDetached)
{
ConfigurationState.Instance.UI.LanguageCode.Value = (string)languageCode;
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.UI.LanguageCode.Value = (string)languageCode;
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
}
@ -1514,6 +1517,16 @@ namespace Ryujinx.Ava.UI.ViewModels
public async Task LoadApplication(string path, bool startFullscreen = false, string titleName = "")
{
bool useTitleConfiguration = false;
if (SelectedApplication?.TitleId != null)
{
if (ConfigurationState.HasConfigurationForTitle(SelectedApplication.TitleId))
{
useTitleConfiguration = true;
ConfigurationState.LoadConfigurationStateForTitle(SelectedApplication.TitleId);
}
}
if (AppHost != null)
{
await ContentDialogHelper.CreateInfoDialog(
@ -1532,11 +1545,11 @@ namespace Ryujinx.Ava.UI.ViewModels
Logger.RestartTime();
SelectedIcon ??= ApplicationLibrary.GetApplicationIcon(path, ConfigurationState.Instance.System.Language);
SelectedIcon ??= ApplicationLibrary.GetApplicationIcon(path, ConfigurationState.Shared.System.Language);
PrepareLoadScreen();
RendererHostControl = new RendererHost();
RendererHostControl = new RendererHost(ConfigurationState.Instance(useTitleConfiguration).Graphics.GraphicsBackend);
AppHost = new AppHost(
RendererHostControl,
@ -1689,12 +1702,12 @@ namespace Ryujinx.Ava.UI.ViewModels
public static void SaveConfig()
{
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
}
public static async Task PerformanceCheck()
{
if (ConfigurationState.Instance.Logger.EnableTrace.Value)
if (ConfigurationState.Shared.Logger.EnableTrace.Value)
{
string mainMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckLoggingEnabledMessage];
string secondaryMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckLoggingEnabledConfirmMessage];
@ -1708,13 +1721,13 @@ namespace Ryujinx.Ava.UI.ViewModels
if (result == UserResult.Yes)
{
ConfigurationState.Instance.Logger.EnableTrace.Value = false;
ConfigurationState.Shared.Logger.EnableTrace.Value = false;
SaveConfig();
}
}
if (!string.IsNullOrWhiteSpace(ConfigurationState.Instance.Graphics.ShadersDumpPath.Value))
if (!string.IsNullOrWhiteSpace(ConfigurationState.Shared.Graphics.ShadersDumpPath.Value))
{
string mainMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckShaderDumpEnabledMessage];
string secondaryMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckShaderDumpEnabledConfirmMessage];
@ -1728,7 +1741,7 @@ namespace Ryujinx.Ava.UI.ViewModels
if (result == UserResult.Yes)
{
ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = "";
ConfigurationState.Shared.Graphics.ShadersDumpPath.Value = "";
SaveConfig();
}

View File

@ -16,6 +16,7 @@ using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Vulkan;
using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.HOS.Services.Time.TimeZone;
using Ryujinx.UI.App.Common;
using Ryujinx.UI.Common.Configuration;
using Ryujinx.UI.Common.Configuration.System;
using System;
@ -33,6 +34,8 @@ namespace Ryujinx.Ava.UI.ViewModels
{
private readonly VirtualFileSystem _virtualFileSystem;
private readonly ContentManager _contentManager;
private readonly ApplicationData _applicationData;
private TimeZoneContentManager _timeZoneContentManager;
private readonly List<string> _validTzRegions;
@ -55,6 +58,8 @@ namespace Ryujinx.Ava.UI.ViewModels
private int _networkInterfaceIndex;
private int _multiplayerModeIndex;
internal ApplicationData ApplicationData => _applicationData;
public int ResolutionScale
{
get => _resolutionScale;
@ -74,7 +79,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{
_graphicsBackendMultithreadingIndex = value;
if (_graphicsBackendMultithreadingIndex != (int)ConfigurationState.Instance.Graphics.BackendThreading.Value)
if (_graphicsBackendMultithreadingIndex != (int)ConfigurationState.Instance(IsTitleSpecificSettings).Graphics.BackendThreading.Value)
{
Dispatcher.UIThread.InvokeAsync(() =>
ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogSettingsBackendThreadingWarningMessage],
@ -219,7 +224,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{
_volume = value;
ConfigurationState.Instance.System.AudioVolume.Value = _volume / 100;
ConfigurationState.Instance(IsTitleSpecificSettings).System.AudioVolume.Value = _volume / 100;
OnPropertyChanged();
}
@ -232,6 +237,8 @@ namespace Ryujinx.Ava.UI.ViewModels
public AvaloniaList<string> GameDirectories { get; set; }
public ObservableCollection<ComboBoxItem> AvailableGpus { get; set; }
public bool IsTitleSpecificSettings => _applicationData != null;
public AvaloniaList<string> NetworkInterfaceList
{
get => new(_networkInterfaces.Keys);
@ -245,7 +252,7 @@ namespace Ryujinx.Ava.UI.ViewModels
set
{
_networkInterfaceIndex = value != -1 ? value : 0;
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value = _networkInterfaces[NetworkInterfaceList[_networkInterfaceIndex]];
ConfigurationState.Instance(IsTitleSpecificSettings).Multiplayer.LanInterfaceId.Value = _networkInterfaces[NetworkInterfaceList[_networkInterfaceIndex]];
}
}
@ -255,7 +262,7 @@ namespace Ryujinx.Ava.UI.ViewModels
set
{
_multiplayerModeIndex = value;
ConfigurationState.Instance.Multiplayer.Mode.Value = (MultiplayerMode)_multiplayerModeIndex;
ConfigurationState.Instance(IsTitleSpecificSettings).Multiplayer.Mode.Value = (MultiplayerMode)_multiplayerModeIndex;
}
}
@ -269,11 +276,23 @@ namespace Ryujinx.Ava.UI.ViewModels
}
}
public SettingsViewModel()
public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager, ApplicationData applicationData) : this(applicationData)
{
_virtualFileSystem = virtualFileSystem;
_contentManager = contentManager;
if (Program.PreviewerDetached)
{
Task.Run(LoadTimeZones);
}
}
public SettingsViewModel(ApplicationData applicationData = null)
{
GameDirectories = new AvaloniaList<string>();
TimeZones = new AvaloniaList<TimeZone>();
AvailableGpus = new ObservableCollection<ComboBoxItem>();
_applicationData = applicationData;
_validTzRegions = new List<string>();
_networkInterfaces = new Dictionary<string, string>();
@ -326,8 +345,9 @@ namespace Ryujinx.Ava.UI.ViewModels
}
// GPU configuration needs to be loaded during the async method or it will always return 0.
PreferredGpuIndex = _gpuIds.Contains(ConfigurationState.Instance.Graphics.PreferredGpu) ?
_gpuIds.IndexOf(ConfigurationState.Instance.Graphics.PreferredGpu) : 0;
ConfigurationState config = ConfigurationState.Instance(IsTitleSpecificSettings);
PreferredGpuIndex = _gpuIds.Contains(config.Graphics.PreferredGpu) ?
_gpuIds.IndexOf(config.Graphics.PreferredGpu) : 0;
Dispatcher.UIThread.Post(() => OnPropertyChanged(nameof(PreferredGpuIndex)));
}
@ -370,7 +390,7 @@ namespace Ryujinx.Ava.UI.ViewModels
}
// Network interface index needs to be loaded during the async method or it will always return 0.
NetworkInterfaceIndex = _networkInterfaces.Values.ToList().IndexOf(ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value);
NetworkInterfaceIndex = _networkInterfaces.Values.ToList().IndexOf(ConfigurationState.Instance(IsTitleSpecificSettings).Multiplayer.LanInterfaceId.Value);
Dispatcher.UIThread.Post(() => OnPropertyChanged(nameof(NetworkInterfaceIndex)));
}
@ -385,14 +405,28 @@ namespace Ryujinx.Ava.UI.ViewModels
public void LoadCurrentConfiguration()
{
ConfigurationState config = ConfigurationState.Instance;
ConfigurationState config;
if (IsTitleSpecificSettings)
{
if (!ConfigurationState.Title?.TitleId.Equals(_applicationData.TitleId) ?? true)
{
ConfigurationState.LoadOrCreateConfigurationStateForTitle(_applicationData.TitleId);
}
config = ConfigurationState.Title;
}
else
{
config = ConfigurationState.Shared;
}
// User Interface
EnableDiscordIntegration = config.EnableDiscordIntegration;
CheckUpdatesOnStart = config.CheckUpdatesOnStart;
ShowConfirmExit = config.ShowConfirmExit;
RememberWindowState = config.RememberWindowState;
HideCursor = (int)config.HideCursor.Value;
// Note: These settings are ignored if set in title-specific configurations, only the shared config's UI settings will be used.
EnableDiscordIntegration = ConfigurationState.Shared.EnableDiscordIntegration;
CheckUpdatesOnStart = ConfigurationState.Shared.CheckUpdatesOnStart;
ShowConfirmExit = ConfigurationState.Shared.ShowConfirmExit;
RememberWindowState = ConfigurationState.Shared.RememberWindowState;
HideCursor = (int)ConfigurationState.Shared.HideCursor.Value;
GameDirectories.Clear();
GameDirectories.AddRange(config.UI.GameDirs.Value);
@ -460,24 +494,25 @@ namespace Ryujinx.Ava.UI.ViewModels
// LAN interface index is loaded asynchronously in PopulateNetworkInterfaces()
// Logging
EnableFileLog = config.Logger.EnableFileLog;
EnableStub = config.Logger.EnableStub;
EnableInfo = config.Logger.EnableInfo;
EnableWarn = config.Logger.EnableWarn;
EnableError = config.Logger.EnableError;
EnableTrace = config.Logger.EnableTrace;
EnableGuest = config.Logger.EnableGuest;
EnableDebug = config.Logger.EnableDebug;
EnableFsAccessLog = config.Logger.EnableFsAccessLog;
FsGlobalAccessLogMode = config.System.FsGlobalAccessLogMode;
OpenglDebugLevel = (int)config.Logger.GraphicsDebugLevel.Value;
// Note: These settings are ignored if set in title-specific configurations, only the shared config's logging settings will be used.
EnableFileLog = ConfigurationState.Shared.Logger.EnableFileLog;
EnableStub = ConfigurationState.Shared.Logger.EnableStub;
EnableInfo = ConfigurationState.Shared.Logger.EnableInfo;
EnableWarn = ConfigurationState.Shared.Logger.EnableWarn;
EnableError = ConfigurationState.Shared.Logger.EnableError;
EnableTrace = ConfigurationState.Shared.Logger.EnableTrace;
EnableGuest = ConfigurationState.Shared.Logger.EnableGuest;
EnableDebug = ConfigurationState.Shared.Logger.EnableDebug;
EnableFsAccessLog = ConfigurationState.Shared.Logger.EnableFsAccessLog;
FsGlobalAccessLogMode = ConfigurationState.Shared.System.FsGlobalAccessLogMode;
OpenglDebugLevel = (int)ConfigurationState.Shared.Logger.GraphicsDebugLevel.Value;
MultiplayerModeIndex = (int)config.Multiplayer.Mode.Value;
}
public void SaveSettings()
{
ConfigurationState config = ConfigurationState.Instance;
ConfigurationState config = ConfigurationState.Instance(IsTitleSpecificSettings);
// User Interface
config.EnableDiscordIntegration.Value = EnableDiscordIntegration;
@ -543,7 +578,7 @@ namespace Ryujinx.Ava.UI.ViewModels
config.Graphics.ScalingFilter.Value = (ScalingFilter)ScalingFilter;
config.Graphics.ScalingFilterLevel.Value = ScalingFilterLevel;
if (ConfigurationState.Instance.Graphics.BackendThreading != (BackendThreading)GraphicsBackendMultithreadingIndex)
if (config.Graphics.BackendThreading != (BackendThreading)GraphicsBackendMultithreadingIndex)
{
DriverUtilities.ToggleOGLThreading(GraphicsBackendMultithreadingIndex == (int)BackendThreading.Off);
}
@ -581,7 +616,9 @@ namespace Ryujinx.Ava.UI.ViewModels
config.Multiplayer.LanInterfaceId.Value = _networkInterfaces[NetworkInterfaceList[NetworkInterfaceIndex]];
config.Multiplayer.Mode.Value = (MultiplayerMode)MultiplayerModeIndex;
config.ToFileFormat().SaveConfig(Program.ConfigurationPath);
config.ToFileFormat().SaveConfig(IsTitleSpecificSettings
? ConfigurationState.ConfigurationFilePathForTitle(_applicationData.TitleId)
: Program.ConfigurationPath);
MainWindow.UpdateGraphicsConfig();

View File

@ -44,7 +44,7 @@ namespace Ryujinx.Ava.UI.Views.Main
checkBoxes.Add(new CheckBox
{
Content = $".{fileName}",
IsChecked = ((FileTypes)item).GetConfigValue(ConfigurationState.Instance.UI.ShownFileTypes),
IsChecked = ((FileTypes)item).GetConfigValue(ConfigurationState.Shared.UI.ShownFileTypes),
Command = MiniCommand.Create(() => Window.ToggleFileType(fileName)),
});
}
@ -119,7 +119,15 @@ namespace Ryujinx.Ava.UI.Views.Main
public async void OpenSettings(object sender, RoutedEventArgs e)
{
Window.SettingsWindow = new(Window.VirtualFileSystem, Window.ContentManager);
if (ViewModel.IsGameRunning && ViewModel.SelectedApplication != null &&
ConfigurationState.HasConfigurationForTitle(ViewModel.SelectedApplication.TitleId))
{
Window.SettingsWindow = new(Window.VirtualFileSystem, Window.ContentManager, ViewModel.SelectedApplication);
}
else
{
Window.SettingsWindow = new(Window.VirtualFileSystem, Window.ContentManager);
}
await Window.SettingsWindow.ShowDialog(Window);

View File

@ -33,20 +33,24 @@ namespace Ryujinx.Ava.UI.Views.Main
private void VsyncStatus_PointerReleased(object sender, PointerReleasedEventArgs e)
{
ConfigurationState config = ConfigurationState.Instance(Window.ViewModel.SelectedApplication != null);
Window.ViewModel.AppHost.ToggleVSync();
config.Graphics.EnableVsync.Value = Window.ViewModel.AppHost.Device.EnableDeviceVsync;
Logger.Info?.Print(LogClass.Application, $"VSync toggled to: {Window.ViewModel.AppHost.Device.EnableDeviceVsync}");
}
private void DockedStatus_PointerReleased(object sender, PointerReleasedEventArgs e)
{
ConfigurationState.Instance.System.EnableDockedMode.Value = !ConfigurationState.Instance.System.EnableDockedMode.Value;
ConfigurationState config = ConfigurationState.Instance(Window.ViewModel.SelectedApplication != null);
config.System.EnableDockedMode.Value = !config.System.EnableDockedMode.Value;
}
private void AspectRatioStatus_OnClick(object sender, RoutedEventArgs e)
{
AspectRatio aspectRatio = ConfigurationState.Instance.Graphics.AspectRatio.Value;
ConfigurationState.Instance.Graphics.AspectRatio.Value = (int)aspectRatio + 1 > Enum.GetNames(typeof(AspectRatio)).Length - 1 ? AspectRatio.Fixed4x3 : aspectRatio + 1;
ConfigurationState config = ConfigurationState.Instance(Window.ViewModel.SelectedApplication != null);
AspectRatio aspectRatio = config.Graphics.AspectRatio.Value;
config.Graphics.AspectRatio.Value = (int)aspectRatio + 1 > Enum.GetNames(typeof(AspectRatio)).Length - 1 ? AspectRatio.Fixed4x3 : aspectRatio + 1;
}
private void Refresh_OnClick(object sender, RoutedEventArgs e)
@ -56,6 +60,8 @@ namespace Ryujinx.Ava.UI.Views.Main
private void VolumeStatus_OnPointerWheelChanged(object sender, PointerWheelEventArgs e)
{
ConfigurationState config = ConfigurationState.Instance(Window.ViewModel.SelectedApplication != null);
// Change the volume by 5% at a time
float newValue = Window.ViewModel.Volume + (float)e.Delta.Y * 0.05f;
@ -66,6 +72,8 @@ namespace Ryujinx.Ava.UI.Views.Main
_ => newValue,
};
config.System.AudioVolume.Value = Window.ViewModel.Volume;
e.Handled = true;
}
}

View File

@ -324,7 +324,7 @@ namespace Ryujinx.Ava.UI.Windows
await Dispatcher.UIThread.InvokeAsync(async () => await UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys));
}
if (ConfigurationState.Instance.CheckUpdatesOnStart.Value && Updater.CanUpdate(false))
if (ConfigurationState.Shared.CheckUpdatesOnStart.Value && Updater.CanUpdate(false))
{
await Updater.BeginParse(this, false).ContinueWith(task =>
{
@ -348,7 +348,7 @@ namespace Ryujinx.Ava.UI.Windows
private void SetWindowSizePosition()
{
if (!ConfigurationState.Instance.RememberWindowState)
if (!ConfigurationState.Shared.RememberWindowState)
{
ViewModel.WindowHeight = (720 + StatusBarHeight + MenuBarHeight) * Program.WindowScaleFactor;
ViewModel.WindowWidth = 1280 * Program.WindowScaleFactor;
@ -359,13 +359,13 @@ namespace Ryujinx.Ava.UI.Windows
return;
}
PixelPoint savedPoint = new(ConfigurationState.Instance.UI.WindowStartup.WindowPositionX,
ConfigurationState.Instance.UI.WindowStartup.WindowPositionY);
PixelPoint savedPoint = new(ConfigurationState.Shared.UI.WindowStartup.WindowPositionX,
ConfigurationState.Shared.UI.WindowStartup.WindowPositionY);
ViewModel.WindowHeight = ConfigurationState.Instance.UI.WindowStartup.WindowSizeHeight * Program.WindowScaleFactor;
ViewModel.WindowWidth = ConfigurationState.Instance.UI.WindowStartup.WindowSizeWidth * Program.WindowScaleFactor;
ViewModel.WindowHeight = ConfigurationState.Shared.UI.WindowStartup.WindowSizeHeight * Program.WindowScaleFactor;
ViewModel.WindowWidth = ConfigurationState.Shared.UI.WindowStartup.WindowSizeWidth * Program.WindowScaleFactor;
ViewModel.WindowState = ConfigurationState.Instance.UI.WindowStartup.WindowMaximized.Value ? WindowState.Maximized : WindowState.Normal;
ViewModel.WindowState = ConfigurationState.Shared.UI.WindowStartup.WindowMaximized.Value ? WindowState.Maximized : WindowState.Normal;
if (CheckScreenBounds(savedPoint))
{
@ -393,16 +393,16 @@ namespace Ryujinx.Ava.UI.Windows
private void SaveWindowSizePosition()
{
ConfigurationState.Instance.UI.WindowStartup.WindowMaximized.Value = WindowState == WindowState.Maximized;
ConfigurationState.Shared.UI.WindowStartup.WindowMaximized.Value = WindowState == WindowState.Maximized;
// Only save rectangle properties if the window is not in a maximized state.
if (WindowState != WindowState.Maximized)
{
ConfigurationState.Instance.UI.WindowStartup.WindowSizeHeight.Value = (int)Height;
ConfigurationState.Instance.UI.WindowStartup.WindowSizeWidth.Value = (int)Width;
ConfigurationState.Shared.UI.WindowStartup.WindowSizeHeight.Value = (int)Height;
ConfigurationState.Shared.UI.WindowStartup.WindowSizeWidth.Value = (int)Width;
ConfigurationState.Instance.UI.WindowStartup.WindowPositionX.Value = Position.X;
ConfigurationState.Instance.UI.WindowStartup.WindowPositionY.Value = Position.Y;
ConfigurationState.Shared.UI.WindowStartup.WindowPositionX.Value = Position.X;
ConfigurationState.Shared.UI.WindowStartup.WindowPositionY.Value = Position.Y;
}
MainWindowViewModel.SaveConfig();
@ -458,13 +458,17 @@ namespace Ryujinx.Ava.UI.Windows
public static void UpdateGraphicsConfig()
{
bool useTitleConfig =
ConfigurationState.HasConfigurationForTitle(MainWindowViewModel.SelectedApplication?.TitleId);
ConfigurationState config = ConfigurationState.Instance(useTitleConfig);
#pragma warning disable IDE0055 // Disable formatting
GraphicsConfig.ResScale = ConfigurationState.Instance.Graphics.ResScale == -1 ? ConfigurationState.Instance.Graphics.ResScaleCustom : ConfigurationState.Instance.Graphics.ResScale;
GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
GraphicsConfig.EnableShaderCache = ConfigurationState.Instance.Graphics.EnableShaderCache;
GraphicsConfig.EnableTextureRecompression = ConfigurationState.Instance.Graphics.EnableTextureRecompression;
GraphicsConfig.EnableMacroHLE = ConfigurationState.Instance.Graphics.EnableMacroHLE;
GraphicsConfig.ResScale = config.Graphics.ResScale == -1 ? ConfigurationState.Instance(useTitleConfig).Graphics.ResScaleCustom : ConfigurationState.Instance(useTitleConfig).Graphics.ResScale;
GraphicsConfig.MaxAnisotropy = config.Graphics.MaxAnisotropy;
GraphicsConfig.ShadersDumpPath = config.Graphics.ShadersDumpPath;
GraphicsConfig.EnableShaderCache = config.Graphics.EnableShaderCache;
GraphicsConfig.EnableTextureRecompression = config.Graphics.EnableTextureRecompression;
GraphicsConfig.EnableMacroHLE = config.Graphics.EnableMacroHLE;
#pragma warning restore IDE0055
}
@ -489,7 +493,7 @@ namespace Ryujinx.Ava.UI.Windows
protected override void OnClosing(WindowClosingEventArgs e)
{
if (!ViewModel.IsClosing && ViewModel.AppHost != null && ConfigurationState.Instance.ShowConfirmExit)
if (!ViewModel.IsClosing && ViewModel.AppHost != null && ConfigurationState.Shared.ShowConfirmExit)
{
e.Cancel = true;
@ -521,7 +525,7 @@ namespace Ryujinx.Ava.UI.Windows
return;
}
if (ConfigurationState.Instance.RememberWindowState)
if (ConfigurationState.Shared.RememberWindowState)
{
SaveWindowSizePosition();
}
@ -564,17 +568,17 @@ namespace Ryujinx.Ava.UI.Windows
_ = fileType switch
{
#pragma warning disable IDE0055 // Disable formatting
"NSP" => ConfigurationState.Instance.UI.ShownFileTypes.NSP.Value = !ConfigurationState.Instance.UI.ShownFileTypes.NSP,
"PFS0" => ConfigurationState.Instance.UI.ShownFileTypes.PFS0.Value = !ConfigurationState.Instance.UI.ShownFileTypes.PFS0,
"XCI" => ConfigurationState.Instance.UI.ShownFileTypes.XCI.Value = !ConfigurationState.Instance.UI.ShownFileTypes.XCI,
"NCA" => ConfigurationState.Instance.UI.ShownFileTypes.NCA.Value = !ConfigurationState.Instance.UI.ShownFileTypes.NCA,
"NRO" => ConfigurationState.Instance.UI.ShownFileTypes.NRO.Value = !ConfigurationState.Instance.UI.ShownFileTypes.NRO,
"NSO" => ConfigurationState.Instance.UI.ShownFileTypes.NSO.Value = !ConfigurationState.Instance.UI.ShownFileTypes.NSO,
"NSP" => ConfigurationState.Shared.UI.ShownFileTypes.NSP.Value = !ConfigurationState.Shared.UI.ShownFileTypes.NSP,
"PFS0" => ConfigurationState.Shared.UI.ShownFileTypes.PFS0.Value = !ConfigurationState.Shared.UI.ShownFileTypes.PFS0,
"XCI" => ConfigurationState.Shared.UI.ShownFileTypes.XCI.Value = !ConfigurationState.Shared.UI.ShownFileTypes.XCI,
"NCA" => ConfigurationState.Shared.UI.ShownFileTypes.NCA.Value = !ConfigurationState.Shared.UI.ShownFileTypes.NCA,
"NRO" => ConfigurationState.Shared.UI.ShownFileTypes.NRO.Value = !ConfigurationState.Shared.UI.ShownFileTypes.NRO,
"NSO" => ConfigurationState.Shared.UI.ShownFileTypes.NSO.Value = !ConfigurationState.Shared.UI.ShownFileTypes.NSO,
_ => throw new ArgumentOutOfRangeException(fileType),
#pragma warning restore IDE0055
};
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
ConfigurationState.Shared.ToFileFormat().SaveConfig(Program.ConfigurationPath);
LoadApplications();
}
@ -589,7 +593,7 @@ namespace Ryujinx.Ava.UI.Windows
Thread applicationLibraryThread = new(() =>
{
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs, ConfigurationState.Instance.System.Language);
ApplicationLibrary.LoadApplications(ConfigurationState.Shared.UI.GameDirs, ConfigurationState.Shared.System.Language);
_isLoading = false;
})

View File

@ -55,11 +55,13 @@
OpenPaneLength="200">
<ui:NavigationView.MenuItems>
<ui:NavigationViewItem
IsSelected="True"
IsSelected="{Binding !IsTitleSpecificSettings}"
IsVisible="{Binding !IsTitleSpecificSettings}"
Content="{locale:Locale SettingsTabGeneral}"
Tag="UiPage"
IconSource="New" />
<ui:NavigationViewItem
IsSelected="{Binding !IsTitleSpecificSettings}"
Content="{locale:Locale SettingsTabInput}"
Tag="InputPage"
IconSource="Games" />

View File

@ -3,7 +3,9 @@ using FluentAvalonia.Core;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.ViewModels.Input;
using Ryujinx.HLE.FileSystem;
using Ryujinx.UI.App.Common;
using System;
namespace Ryujinx.Ava.UI.Windows
@ -26,6 +28,20 @@ namespace Ryujinx.Ava.UI.Windows
Load();
}
public SettingsWindow(VirtualFileSystem virtualFileSystem, ContentManager contentManager,
ApplicationData applicationData)
{
Title = $"Ryujinx {Program.Version} - {LocaleManager.Instance[LocaleKeys.Settings]} - {applicationData.TitleName}";
ViewModel = new SettingsViewModel(virtualFileSystem, contentManager, applicationData);
DataContext = ViewModel;
ViewModel.CloseWindow += Close;
ViewModel.SaveSettingsEvent += SaveSettings;
InitializeComponent();
Load();
}
public SettingsWindow()
{
ViewModel = new SettingsViewModel();
@ -49,7 +65,7 @@ namespace Ryujinx.Ava.UI.Windows
{
Pages.Children.Clear();
NavPanel.SelectionChanged += NavPanelOnSelectionChanged;
NavPanel.SelectedItem = NavPanel.MenuItems.ElementAt(0);
NavPanel.SelectedItem = ViewModel.IsTitleSpecificSettings ? NavPanel.MenuItems.ElementAt(1) : NavPanel.MenuItems.ElementAt(0);
}
private void NavPanelOnSelectionChanged(object sender, NavigationViewSelectionChangedEventArgs e)
@ -63,6 +79,8 @@ namespace Ryujinx.Ava.UI.Windows
NavPanel.Content = UiPage;
break;
case "InputPage":
(InputPage.InputView.DataContext as InputViewModel)?.SetApplicationData(
ViewModel.ApplicationData);
NavPanel.Content = InputPage;
break;
case "HotkeysPage":