0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2025-01-09 15:51:59 +00:00

UI: Store config migrations in a dictionary and loop through it to do migrations.

This commit is contained in:
Evan Husted 2024-12-31 02:51:14 -06:00
parent 617c03119f
commit 19d2883a35

View file

@ -9,62 +9,196 @@ using Ryujinx.Common.Configuration.Multiplayer;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.HLE; using Ryujinx.HLE;
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using RyuLogger = Ryujinx.Common.Logging.Logger;
namespace Ryujinx.Ava.Utilities.Configuration namespace Ryujinx.Ava.Utilities.Configuration
{ {
public partial class ConfigurationState public partial class ConfigurationState
{ {
public void Load(ConfigurationFileFormat configurationFileFormat, string configurationFilePath) public void Load(ConfigurationFileFormat cff, string configurationFilePath)
{ {
// referenced by Migrate
bool configurationFileUpdated = false; bool configurationFileUpdated = false;
if (configurationFileFormat.Version is < 0 or > ConfigurationFileFormat.CurrentVersion) if (cff.Version is < 0 or > ConfigurationFileFormat.CurrentVersion)
{ {
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Unsupported configuration version {configurationFileFormat.Version}, loading default."); RyuLogger.Warning?.Print(LogClass.Application, $"Unsupported configuration version {cff.Version}, loading default.");
LoadDefault(); LoadDefault();
} }
Migrate(2, static cff => cff.SystemRegion = Region.USA); foreach ((int newVersion, Action<ConfigurationFileFormat> migratorFunction)
Migrate(3, static cff => cff.SystemTimeZone = "UTC"); in _migrations.OrderBy(x => x.Key))
Migrate(4, static cff => cff.MaxAnisotropy = -1);
Migrate(5, static cff => cff.SystemTimeOffset = 0);
Migrate(8, static cff => cff.EnablePtc = true);
Migrate(9, static cff =>
{ {
cff.ColumnSort = new ColumnSort if (cff.Version >= newVersion)
{ continue;
SortColumnId = 0,
SortAscending = false
};
RyuLogger.Warning?.Print(LogClass.Application,
$"Outdated configuration version {cff.Version}, migrating to version {newVersion}.");
migratorFunction(cff);
configurationFileUpdated = true;
}
EnableDiscordIntegration.Value = cff.EnableDiscordIntegration;
CheckUpdatesOnStart.Value = cff.CheckUpdatesOnStart;
ShowConfirmExit.Value = cff.ShowConfirmExit;
IgnoreApplet.Value = cff.IgnoreApplet;
RememberWindowState.Value = cff.RememberWindowState;
ShowTitleBar.Value = cff.ShowTitleBar;
EnableHardwareAcceleration.Value = cff.EnableHardwareAcceleration;
HideCursor.Value = cff.HideCursor;
Logger.EnableFileLog.Value = cff.EnableFileLog;
Logger.EnableDebug.Value = cff.LoggingEnableDebug;
Logger.EnableStub.Value = cff.LoggingEnableStub;
Logger.EnableInfo.Value = cff.LoggingEnableInfo;
Logger.EnableWarn.Value = cff.LoggingEnableWarn;
Logger.EnableError.Value = cff.LoggingEnableError;
Logger.EnableTrace.Value = cff.LoggingEnableTrace;
Logger.EnableGuest.Value = cff.LoggingEnableGuest;
Logger.EnableFsAccessLog.Value = cff.LoggingEnableFsAccessLog;
Logger.FilteredClasses.Value = cff.LoggingFilteredClasses;
Logger.GraphicsDebugLevel.Value = cff.LoggingGraphicsDebugLevel;
Graphics.ResScale.Value = cff.ResScale;
Graphics.ResScaleCustom.Value = cff.ResScaleCustom;
Graphics.MaxAnisotropy.Value = cff.MaxAnisotropy;
Graphics.AspectRatio.Value = cff.AspectRatio;
Graphics.ShadersDumpPath.Value = cff.GraphicsShadersDumpPath;
Graphics.BackendThreading.Value = cff.BackendThreading;
Graphics.GraphicsBackend.Value = cff.GraphicsBackend;
Graphics.PreferredGpu.Value = cff.PreferredGpu;
Graphics.AntiAliasing.Value = cff.AntiAliasing;
Graphics.ScalingFilter.Value = cff.ScalingFilter;
Graphics.ScalingFilterLevel.Value = cff.ScalingFilterLevel;
Graphics.VSyncMode.Value = cff.VSyncMode;
Graphics.EnableCustomVSyncInterval.Value = cff.EnableCustomVSyncInterval;
Graphics.CustomVSyncInterval.Value = cff.CustomVSyncInterval;
Graphics.EnableShaderCache.Value = cff.EnableShaderCache;
Graphics.EnableTextureRecompression.Value = cff.EnableTextureRecompression;
Graphics.EnableMacroHLE.Value = cff.EnableMacroHLE;
Graphics.EnableColorSpacePassthrough.Value = cff.EnableColorSpacePassthrough;
System.Language.Value = cff.SystemLanguage;
System.Region.Value = cff.SystemRegion;
System.TimeZone.Value = cff.SystemTimeZone;
System.SystemTimeOffset.Value = cff.SystemTimeOffset;
System.EnableDockedMode.Value = cff.DockedMode;
System.EnablePtc.Value = cff.EnablePtc;
System.EnableLowPowerPtc.Value = cff.EnableLowPowerPtc;
System.EnableInternetAccess.Value = cff.EnableInternetAccess;
System.EnableFsIntegrityChecks.Value = cff.EnableFsIntegrityChecks;
System.FsGlobalAccessLogMode.Value = cff.FsGlobalAccessLogMode;
System.AudioBackend.Value = cff.AudioBackend;
System.AudioVolume.Value = cff.AudioVolume;
System.MemoryManagerMode.Value = cff.MemoryManagerMode;
System.DramSize.Value = cff.DramSize;
System.IgnoreMissingServices.Value = cff.IgnoreMissingServices;
System.UseHypervisor.Value = cff.UseHypervisor;
UI.GuiColumns.FavColumn.Value = cff.GuiColumns.FavColumn;
UI.GuiColumns.IconColumn.Value = cff.GuiColumns.IconColumn;
UI.GuiColumns.AppColumn.Value = cff.GuiColumns.AppColumn;
UI.GuiColumns.DevColumn.Value = cff.GuiColumns.DevColumn;
UI.GuiColumns.VersionColumn.Value = cff.GuiColumns.VersionColumn;
UI.GuiColumns.TimePlayedColumn.Value = cff.GuiColumns.TimePlayedColumn;
UI.GuiColumns.LastPlayedColumn.Value = cff.GuiColumns.LastPlayedColumn;
UI.GuiColumns.FileExtColumn.Value = cff.GuiColumns.FileExtColumn;
UI.GuiColumns.FileSizeColumn.Value = cff.GuiColumns.FileSizeColumn;
UI.GuiColumns.PathColumn.Value = cff.GuiColumns.PathColumn;
UI.ColumnSort.SortColumnId.Value = cff.ColumnSort.SortColumnId;
UI.ColumnSort.SortAscending.Value = cff.ColumnSort.SortAscending;
UI.GameDirs.Value = cff.GameDirs;
UI.AutoloadDirs.Value = cff.AutoloadDirs ?? [];
UI.ShownFileTypes.NSP.Value = cff.ShownFileTypes.NSP;
UI.ShownFileTypes.PFS0.Value = cff.ShownFileTypes.PFS0;
UI.ShownFileTypes.XCI.Value = cff.ShownFileTypes.XCI;
UI.ShownFileTypes.NCA.Value = cff.ShownFileTypes.NCA;
UI.ShownFileTypes.NRO.Value = cff.ShownFileTypes.NRO;
UI.ShownFileTypes.NSO.Value = cff.ShownFileTypes.NSO;
UI.LanguageCode.Value = cff.LanguageCode;
UI.BaseStyle.Value = cff.BaseStyle;
UI.GameListViewMode.Value = cff.GameListViewMode;
UI.ShowNames.Value = cff.ShowNames;
UI.IsAscendingOrder.Value = cff.IsAscendingOrder;
UI.GridSize.Value = cff.GridSize;
UI.ApplicationSort.Value = cff.ApplicationSort;
UI.StartFullscreen.Value = cff.StartFullscreen;
UI.ShowConsole.Value = cff.ShowConsole;
UI.WindowStartup.WindowSizeWidth.Value = cff.WindowStartup.WindowSizeWidth;
UI.WindowStartup.WindowSizeHeight.Value = cff.WindowStartup.WindowSizeHeight;
UI.WindowStartup.WindowPositionX.Value = cff.WindowStartup.WindowPositionX;
UI.WindowStartup.WindowPositionY.Value = cff.WindowStartup.WindowPositionY;
UI.WindowStartup.WindowMaximized.Value = cff.WindowStartup.WindowMaximized;
Hid.EnableKeyboard.Value = cff.EnableKeyboard;
Hid.EnableMouse.Value = cff.EnableMouse;
Hid.Hotkeys.Value = cff.Hotkeys;
Hid.InputConfig.Value = cff.InputConfig ?? [];
Multiplayer.LanInterfaceId.Value = cff.MultiplayerLanInterfaceId;
Multiplayer.Mode.Value = cff.MultiplayerMode;
Multiplayer.DisableP2p.Value = cff.MultiplayerDisableP2p;
Multiplayer.LdnPassphrase.Value = cff.MultiplayerLdnPassphrase;
Multiplayer.LdnServer.Value = cff.LdnServer;
{
Hacks.ShowDirtyHacks.Value = cff.ShowDirtyHacks;
DirtyHacks hacks = new (cff.DirtyHacks ?? []);
Hacks.Xc2MenuSoftlockFix.Value = hacks.IsEnabled(DirtyHack.Xc2MenuSoftlockFix);
Hacks.EnableShaderTranslationDelay.Value = hacks.IsEnabled(DirtyHack.ShaderTranslationDelay);
Hacks.ShaderTranslationDelay.Value = hacks[DirtyHack.ShaderTranslationDelay].CoerceAtLeast(0);
}
if (configurationFileUpdated)
{
ToFileFormat().SaveConfig(configurationFilePath);
RyuLogger.Notice.Print(LogClass.Application, $"Configuration file updated to version {ConfigurationFileFormat.CurrentVersion}");
}
}
private static readonly Dictionary<int, Action<ConfigurationFileFormat>> _migrations =
Collections.NewDictionary<int, Action<ConfigurationFileFormat>>(
(2, static cff => cff.SystemRegion = Region.USA),
(3, static cff => cff.SystemTimeZone = "UTC"),
(4, static cff => cff.MaxAnisotropy = -1),
(5, static cff => cff.SystemTimeOffset = 0),
(8, static cff => cff.EnablePtc = true),
(9, static cff =>
{
cff.ColumnSort = new ColumnSort { SortColumnId = 0, SortAscending = false };
cff.Hotkeys = new KeyboardHotkeys { ToggleVSyncMode = Key.F1 }; cff.Hotkeys = new KeyboardHotkeys { ToggleVSyncMode = Key.F1 };
}); }),
Migrate(10, static cff => cff.AudioBackend = AudioBackend.OpenAl); (10, static cff => cff.AudioBackend = AudioBackend.OpenAl),
Migrate(11, static cff => (11, static cff =>
{ {
cff.ResScale = 1; cff.ResScale = 1;
cff.ResScaleCustom = 1.0f; cff.ResScaleCustom = 1.0f;
}); }),
Migrate(12, static cff => cff.LoggingGraphicsDebugLevel = GraphicsDebugLevel.None); (12, static cff => cff.LoggingGraphicsDebugLevel = GraphicsDebugLevel.None),
// 13 -> LDN1 // 13 -> LDN1
Migrate(14, static cff => cff.CheckUpdatesOnStart = true); (14, static cff => cff.CheckUpdatesOnStart = true),
Migrate(16, static cff => cff.EnableShaderCache = true); (16, static cff => cff.EnableShaderCache = true),
Migrate(17, static cff => cff.StartFullscreen = false); (17, static cff => cff.StartFullscreen = false),
Migrate(18, static cff => cff.AspectRatio = AspectRatio.Fixed16x9); (18, static cff => cff.AspectRatio = AspectRatio.Fixed16x9),
// 19 -> LDN2 // 19 -> LDN2
Migrate(20, static cff => cff.ShowConfirmExit = true); (20, static cff => cff.ShowConfirmExit = true),
Migrate(21, static cff => (21, static cff =>
{ {
// Initialize network config. // Initialize network config.
cff.MultiplayerMode = MultiplayerMode.Disabled; cff.MultiplayerMode = MultiplayerMode.Disabled;
cff.MultiplayerLanInterfaceId = "0"; cff.MultiplayerLanInterfaceId = "0";
}); }),
Migrate(22, static cff => cff.HideCursor = HideCursorMode.Never); (22, static cff => cff.HideCursor = HideCursorMode.Never),
Migrate(24, static cff => (24, static cff =>
{ {
cff.InputConfig = cff.InputConfig =
[ [
@ -116,18 +250,17 @@ namespace Ryujinx.Ava.Utilities.Configuration
StickButton = Key.H, StickButton = Key.H,
}, },
} }
]; ];
}); }),
Migrate(26, static cff => cff.MemoryManagerMode = MemoryManagerMode.HostMappedUnsafe); (26, static cff => cff.MemoryManagerMode = MemoryManagerMode.HostMappedUnsafe),
Migrate(27, static cff => cff.EnableMouse = false); (27, static cff => cff.EnableMouse = false),
Migrate(29, static cff => cff.Hotkeys = new KeyboardHotkeys (29,
static cff =>
cff.Hotkeys = new KeyboardHotkeys
{ {
ToggleVSyncMode = Key.F1, ToggleVSyncMode = Key.F1, Screenshot = Key.F8, ShowUI = Key.F4
Screenshot = Key.F8, }),
ShowUI = Key.F4 (30, static cff =>
});
Migrate(30, static cff =>
{ {
foreach (InputConfig config in cff.InputConfig) foreach (InputConfig config in cff.InputConfig)
{ {
@ -135,22 +268,20 @@ namespace Ryujinx.Ava.Utilities.Configuration
{ {
controllerConfig.Rumble = new RumbleConfigController controllerConfig.Rumble = new RumbleConfigController
{ {
EnableRumble = false, EnableRumble = false, StrongRumble = 1f, WeakRumble = 1f,
StrongRumble = 1f,
WeakRumble = 1f,
}; };
} }
} }
}); }),
Migrate(31, static cff => cff.BackendThreading = BackendThreading.Auto); (31, static cff => cff.BackendThreading = BackendThreading.Auto),
Migrate(32, static cff => cff.Hotkeys = new KeyboardHotkeys (32, static cff => cff.Hotkeys = new KeyboardHotkeys
{ {
ToggleVSyncMode = cff.Hotkeys.ToggleVSyncMode, ToggleVSyncMode = cff.Hotkeys.ToggleVSyncMode,
Screenshot = cff.Hotkeys.Screenshot, Screenshot = cff.Hotkeys.Screenshot,
ShowUI = cff.Hotkeys.ShowUI, ShowUI = cff.Hotkeys.ShowUI,
Pause = Key.F5, Pause = Key.F5,
}); }),
Migrate(33, static cff => (33, static cff =>
{ {
cff.Hotkeys = new KeyboardHotkeys cff.Hotkeys = new KeyboardHotkeys
{ {
@ -162,28 +293,30 @@ namespace Ryujinx.Ava.Utilities.Configuration
}; };
cff.AudioVolume = 1; cff.AudioVolume = 1;
}); }),
Migrate(34, static cff => cff.EnableInternetAccess = false); (34, static cff => cff.EnableInternetAccess = false),
Migrate(35, static cff => (35, static cff =>
{ {
foreach (StandardControllerInputConfig config in cff.InputConfig.OfType<StandardControllerInputConfig>()) foreach (StandardControllerInputConfig config in cff.InputConfig
.OfType<StandardControllerInputConfig>())
{ {
config.RangeLeft = 1.0f; config.RangeLeft = 1.0f;
config.RangeRight = 1.0f; config.RangeRight = 1.0f;
} }
}); }),
Migrate(36, static cff => cff.LoggingEnableTrace = false); (36, static cff => cff.LoggingEnableTrace = false),
Migrate(37, static cff => cff.ShowConsole = true); (37, static cff => cff.ShowConsole = true),
Migrate(38, static cff => (38, static cff =>
{ {
cff.BaseStyle = "Dark"; cff.BaseStyle = "Dark";
cff.GameListViewMode = 0; cff.GameListViewMode = 0;
cff.ShowNames = true; cff.ShowNames = true;
cff.GridSize = 2; cff.GridSize = 2;
cff.LanguageCode = "en_US"; cff.LanguageCode = "en_US";
}); }),
Migrate(39, static cff => cff.Hotkeys = new KeyboardHotkeys (39,
static cff => cff.Hotkeys = new KeyboardHotkeys
{ {
ToggleVSyncMode = cff.Hotkeys.ToggleVSyncMode, ToggleVSyncMode = cff.Hotkeys.ToggleVSyncMode,
Screenshot = cff.Hotkeys.Screenshot, Screenshot = cff.Hotkeys.Screenshot,
@ -192,9 +325,10 @@ namespace Ryujinx.Ava.Utilities.Configuration
ToggleMute = cff.Hotkeys.ToggleMute, ToggleMute = cff.Hotkeys.ToggleMute,
ResScaleUp = Key.Unbound, ResScaleUp = Key.Unbound,
ResScaleDown = Key.Unbound ResScaleDown = Key.Unbound
}); }),
Migrate(40, static cff => cff.GraphicsBackend = GraphicsBackend.OpenGl); (40, static cff => cff.GraphicsBackend = GraphicsBackend.OpenGl),
Migrate(41, static cff => cff.Hotkeys = new KeyboardHotkeys (41,
static cff => cff.Hotkeys = new KeyboardHotkeys
{ {
ToggleVSyncMode = cff.Hotkeys.ToggleVSyncMode, ToggleVSyncMode = cff.Hotkeys.ToggleVSyncMode,
Screenshot = cff.Hotkeys.Screenshot, Screenshot = cff.Hotkeys.Screenshot,
@ -205,16 +339,17 @@ namespace Ryujinx.Ava.Utilities.Configuration
ResScaleDown = cff.Hotkeys.ResScaleDown, ResScaleDown = cff.Hotkeys.ResScaleDown,
VolumeUp = Key.Unbound, VolumeUp = Key.Unbound,
VolumeDown = Key.Unbound VolumeDown = Key.Unbound
}); }),
Migrate(42, static cff => cff.EnableMacroHLE = true); (42, static cff => cff.EnableMacroHLE = true),
Migrate(43, static cff => cff.UseHypervisor = true); (43, static cff => cff.UseHypervisor = true),
Migrate(44, static cff => (44, static cff =>
{ {
cff.AntiAliasing = AntiAliasing.None; cff.AntiAliasing = AntiAliasing.None;
cff.ScalingFilter = ScalingFilter.Bilinear; cff.ScalingFilter = ScalingFilter.Bilinear;
cff.ScalingFilterLevel = 80; cff.ScalingFilterLevel = 80;
}); }),
Migrate(45, static cff => cff.ShownFileTypes = new ShownFileTypes (45,
static cff => cff.ShownFileTypes = new ShownFileTypes
{ {
NSP = true, NSP = true,
PFS0 = true, PFS0 = true,
@ -222,32 +357,33 @@ namespace Ryujinx.Ava.Utilities.Configuration
NCA = true, NCA = true,
NRO = true, NRO = true,
NSO = true NSO = true
}); }),
Migrate(46, static cff => cff.UseHypervisor = OperatingSystem.IsMacOS()); (46, static cff => cff.UseHypervisor = OperatingSystem.IsMacOS()),
Migrate(47, static cff => cff.WindowStartup = new WindowStartup (47,
static cff => cff.WindowStartup = new WindowStartup
{ {
WindowPositionX = 0, WindowPositionX = 0,
WindowPositionY = 0, WindowPositionY = 0,
WindowSizeHeight = 760, WindowSizeHeight = 760,
WindowSizeWidth = 1280, WindowSizeWidth = 1280,
WindowMaximized = false WindowMaximized = false
}); }),
Migrate(48, static cff => cff.EnableColorSpacePassthrough = false); (48, static cff => cff.EnableColorSpacePassthrough = false),
Migrate(49, static _ => (49, static _ =>
{ {
if (OperatingSystem.IsMacOS()) if (OperatingSystem.IsMacOS())
{ {
AppDataManager.FixMacOSConfigurationFolders(); AppDataManager.FixMacOSConfigurationFolders();
} }
}); }),
Migrate(50, static cff => cff.EnableHardwareAcceleration = true); (50, static cff => cff.EnableHardwareAcceleration = true),
Migrate(51, static cff => cff.RememberWindowState = true); (51, static cff => cff.RememberWindowState = true),
Migrate(52, static cff => cff.AutoloadDirs = []); (52, static cff => cff.AutoloadDirs = []),
Migrate(53, static cff => cff.EnableLowPowerPtc = false); (53, static cff => cff.EnableLowPowerPtc = false),
Migrate(54, static cff => cff.DramSize = MemoryConfiguration.MemoryConfiguration4GiB); (54, static cff => cff.DramSize = MemoryConfiguration.MemoryConfiguration4GiB),
Migrate(55, static cff => cff.IgnoreApplet = false); (55, static cff => cff.IgnoreApplet = false),
Migrate(56, static cff => cff.ShowTitleBar = !OperatingSystem.IsWindows()); (56, static cff => cff.ShowTitleBar = !OperatingSystem.IsWindows()),
Migrate(57, static cff => (57, static cff =>
{ {
cff.VSyncMode = VSyncMode.Switch; cff.VSyncMode = VSyncMode.Switch;
cff.EnableCustomVSyncInterval = false; cff.EnableCustomVSyncInterval = false;
@ -268,9 +404,9 @@ namespace Ryujinx.Ava.Utilities.Configuration
}; };
cff.CustomVSyncInterval = 120; cff.CustomVSyncInterval = 120;
}); }),
// 58 migration accidentally got skipped but it worked with no issues somehow lol // 58 migration accidentally got skipped, but it worked with no issues somehow lol
Migrate(59, static cff => (59, static cff =>
{ {
cff.ShowDirtyHacks = false; cff.ShowDirtyHacks = false;
cff.DirtyHacks = []; cff.DirtyHacks = [];
@ -278,136 +414,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
// This was accidentally enabled by default when it was PRed. That is not what we want, // This was accidentally enabled by default when it was PRed. That is not what we want,
// so as a compromise users who want to use it will simply need to re-enable it once after updating. // so as a compromise users who want to use it will simply need to re-enable it once after updating.
cff.IgnoreApplet = false; cff.IgnoreApplet = false;
}); })
);
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
Graphics.ResScale.Value = configurationFileFormat.ResScale;
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
Graphics.MaxAnisotropy.Value = configurationFileFormat.MaxAnisotropy;
Graphics.AspectRatio.Value = configurationFileFormat.AspectRatio;
Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath;
Graphics.BackendThreading.Value = configurationFileFormat.BackendThreading;
Graphics.GraphicsBackend.Value = configurationFileFormat.GraphicsBackend;
Graphics.PreferredGpu.Value = configurationFileFormat.PreferredGpu;
Graphics.AntiAliasing.Value = configurationFileFormat.AntiAliasing;
Graphics.ScalingFilter.Value = configurationFileFormat.ScalingFilter;
Graphics.ScalingFilterLevel.Value = configurationFileFormat.ScalingFilterLevel;
Logger.EnableDebug.Value = configurationFileFormat.LoggingEnableDebug;
Logger.EnableStub.Value = configurationFileFormat.LoggingEnableStub;
Logger.EnableInfo.Value = configurationFileFormat.LoggingEnableInfo;
Logger.EnableWarn.Value = configurationFileFormat.LoggingEnableWarn;
Logger.EnableError.Value = configurationFileFormat.LoggingEnableError;
Logger.EnableTrace.Value = configurationFileFormat.LoggingEnableTrace;
Logger.EnableGuest.Value = configurationFileFormat.LoggingEnableGuest;
Logger.EnableFsAccessLog.Value = configurationFileFormat.LoggingEnableFsAccessLog;
Logger.FilteredClasses.Value = configurationFileFormat.LoggingFilteredClasses;
Logger.GraphicsDebugLevel.Value = configurationFileFormat.LoggingGraphicsDebugLevel;
System.Language.Value = configurationFileFormat.SystemLanguage;
System.Region.Value = configurationFileFormat.SystemRegion;
System.TimeZone.Value = configurationFileFormat.SystemTimeZone;
System.SystemTimeOffset.Value = configurationFileFormat.SystemTimeOffset;
System.EnableDockedMode.Value = configurationFileFormat.DockedMode;
EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration;
CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart;
ShowConfirmExit.Value = configurationFileFormat.ShowConfirmExit;
IgnoreApplet.Value = configurationFileFormat.IgnoreApplet;
RememberWindowState.Value = configurationFileFormat.RememberWindowState;
ShowTitleBar.Value = configurationFileFormat.ShowTitleBar;
EnableHardwareAcceleration.Value = configurationFileFormat.EnableHardwareAcceleration;
HideCursor.Value = configurationFileFormat.HideCursor;
Graphics.VSyncMode.Value = configurationFileFormat.VSyncMode;
Graphics.EnableCustomVSyncInterval.Value = configurationFileFormat.EnableCustomVSyncInterval;
Graphics.CustomVSyncInterval.Value = configurationFileFormat.CustomVSyncInterval;
Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache;
Graphics.EnableTextureRecompression.Value = configurationFileFormat.EnableTextureRecompression;
Graphics.EnableMacroHLE.Value = configurationFileFormat.EnableMacroHLE;
Graphics.EnableColorSpacePassthrough.Value = configurationFileFormat.EnableColorSpacePassthrough;
System.EnablePtc.Value = configurationFileFormat.EnablePtc;
System.EnableLowPowerPtc.Value = configurationFileFormat.EnableLowPowerPtc;
System.EnableInternetAccess.Value = configurationFileFormat.EnableInternetAccess;
System.EnableFsIntegrityChecks.Value = configurationFileFormat.EnableFsIntegrityChecks;
System.FsGlobalAccessLogMode.Value = configurationFileFormat.FsGlobalAccessLogMode;
System.AudioBackend.Value = configurationFileFormat.AudioBackend;
System.AudioVolume.Value = configurationFileFormat.AudioVolume;
System.MemoryManagerMode.Value = configurationFileFormat.MemoryManagerMode;
System.DramSize.Value = configurationFileFormat.DramSize;
System.IgnoreMissingServices.Value = configurationFileFormat.IgnoreMissingServices;
System.UseHypervisor.Value = configurationFileFormat.UseHypervisor;
UI.GuiColumns.FavColumn.Value = configurationFileFormat.GuiColumns.FavColumn;
UI.GuiColumns.IconColumn.Value = configurationFileFormat.GuiColumns.IconColumn;
UI.GuiColumns.AppColumn.Value = configurationFileFormat.GuiColumns.AppColumn;
UI.GuiColumns.DevColumn.Value = configurationFileFormat.GuiColumns.DevColumn;
UI.GuiColumns.VersionColumn.Value = configurationFileFormat.GuiColumns.VersionColumn;
UI.GuiColumns.TimePlayedColumn.Value = configurationFileFormat.GuiColumns.TimePlayedColumn;
UI.GuiColumns.LastPlayedColumn.Value = configurationFileFormat.GuiColumns.LastPlayedColumn;
UI.GuiColumns.FileExtColumn.Value = configurationFileFormat.GuiColumns.FileExtColumn;
UI.GuiColumns.FileSizeColumn.Value = configurationFileFormat.GuiColumns.FileSizeColumn;
UI.GuiColumns.PathColumn.Value = configurationFileFormat.GuiColumns.PathColumn;
UI.ColumnSort.SortColumnId.Value = configurationFileFormat.ColumnSort.SortColumnId;
UI.ColumnSort.SortAscending.Value = configurationFileFormat.ColumnSort.SortAscending;
UI.GameDirs.Value = configurationFileFormat.GameDirs;
UI.AutoloadDirs.Value = configurationFileFormat.AutoloadDirs ?? [];
UI.ShownFileTypes.NSP.Value = configurationFileFormat.ShownFileTypes.NSP;
UI.ShownFileTypes.PFS0.Value = configurationFileFormat.ShownFileTypes.PFS0;
UI.ShownFileTypes.XCI.Value = configurationFileFormat.ShownFileTypes.XCI;
UI.ShownFileTypes.NCA.Value = configurationFileFormat.ShownFileTypes.NCA;
UI.ShownFileTypes.NRO.Value = configurationFileFormat.ShownFileTypes.NRO;
UI.ShownFileTypes.NSO.Value = configurationFileFormat.ShownFileTypes.NSO;
UI.LanguageCode.Value = configurationFileFormat.LanguageCode;
UI.BaseStyle.Value = configurationFileFormat.BaseStyle;
UI.GameListViewMode.Value = configurationFileFormat.GameListViewMode;
UI.ShowNames.Value = configurationFileFormat.ShowNames;
UI.IsAscendingOrder.Value = configurationFileFormat.IsAscendingOrder;
UI.GridSize.Value = configurationFileFormat.GridSize;
UI.ApplicationSort.Value = configurationFileFormat.ApplicationSort;
UI.StartFullscreen.Value = configurationFileFormat.StartFullscreen;
UI.ShowConsole.Value = configurationFileFormat.ShowConsole;
UI.WindowStartup.WindowSizeWidth.Value = configurationFileFormat.WindowStartup.WindowSizeWidth;
UI.WindowStartup.WindowSizeHeight.Value = configurationFileFormat.WindowStartup.WindowSizeHeight;
UI.WindowStartup.WindowPositionX.Value = configurationFileFormat.WindowStartup.WindowPositionX;
UI.WindowStartup.WindowPositionY.Value = configurationFileFormat.WindowStartup.WindowPositionY;
UI.WindowStartup.WindowMaximized.Value = configurationFileFormat.WindowStartup.WindowMaximized;
Hid.EnableKeyboard.Value = configurationFileFormat.EnableKeyboard;
Hid.EnableMouse.Value = configurationFileFormat.EnableMouse;
Hid.Hotkeys.Value = configurationFileFormat.Hotkeys;
Hid.InputConfig.Value = configurationFileFormat.InputConfig ?? [];
Multiplayer.LanInterfaceId.Value = configurationFileFormat.MultiplayerLanInterfaceId;
Multiplayer.Mode.Value = configurationFileFormat.MultiplayerMode;
Multiplayer.DisableP2p.Value = configurationFileFormat.MultiplayerDisableP2p;
Multiplayer.LdnPassphrase.Value = configurationFileFormat.MultiplayerLdnPassphrase;
Multiplayer.LdnServer.Value = configurationFileFormat.LdnServer;
Hacks.ShowDirtyHacks.Value = configurationFileFormat.ShowDirtyHacks;
{
DirtyHacks hacks = new (configurationFileFormat.DirtyHacks ?? []);
Hacks.Xc2MenuSoftlockFix.Value = hacks.IsEnabled(DirtyHack.Xc2MenuSoftlockFix);
Hacks.EnableShaderTranslationDelay.Value = hacks.IsEnabled(DirtyHack.ShaderTranslationDelay);
Hacks.ShaderTranslationDelay.Value = hacks[DirtyHack.ShaderTranslationDelay].CoerceAtLeast(0);
}
if (configurationFileUpdated)
{
ToFileFormat().SaveConfig(configurationFilePath);
Ryujinx.Common.Logging.Logger.Notice.Print(LogClass.Application, $"Configuration file updated to version {ConfigurationFileFormat.CurrentVersion}");
}
return;
void Migrate(int newVer, Action<ConfigurationFileFormat> migrator)
{
if (configurationFileFormat.Version >= newVer) return;
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version {newVer}.");
migrator(configurationFileFormat);
configurationFileUpdated = true;
}
}
} }
} }