From f673a9baea660411020ffb73b15d85fbea0f2007 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 7 Feb 2026 18:03:16 -0500 Subject: [PATCH] Clean up options serialization and ordering --- CHANGELIST.md | 1 + MPF.Frontend.Test/Tools/FrontendToolTests.cs | 8 +-- MPF.Frontend/Features/ListConfigFeature.cs | 14 ++--- MPF.Frontend/Options.cs | 60 ++++++++++---------- MPF.Frontend/Tools/FrontendTool.cs | 18 +++--- MPF.UI/Windows/OptionsWindow.xaml | 8 +-- 6 files changed, 53 insertions(+), 56 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 80d47fdb..4e957663 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -29,6 +29,7 @@ - Reduce reach of original Options type - Move dictionary logic to new Options object - Replace original Options object +- Clean up options serialization and ordering ### 3.6.0 (2025-11-28) diff --git a/MPF.Frontend.Test/Tools/FrontendToolTests.cs b/MPF.Frontend.Test/Tools/FrontendToolTests.cs index 3c2c8a6b..b4c53400 100644 --- a/MPF.Frontend.Test/Tools/FrontendToolTests.cs +++ b/MPF.Frontend.Test/Tools/FrontendToolTests.cs @@ -22,10 +22,10 @@ namespace MPF.Frontend.Test.Tools public void GetDefaultSpeedForMediaTypeSegmentedTest(MediaType? mediaType, int expected) { var options = new Options(); - options.Dumping.DumpSpeeds.PreferredCD = 72; - options.Dumping.DumpSpeeds.PreferredDVD = 24; - options.Dumping.DumpSpeeds.PreferredHDDVD = 24; - options.Dumping.DumpSpeeds.PreferredBD = 16; + options.Dumping.DumpSpeeds.CD = 72; + options.Dumping.DumpSpeeds.DVD = 24; + options.Dumping.DumpSpeeds.HDDVD = 24; + options.Dumping.DumpSpeeds.Bluray = 16; int actual = FrontendTool.GetDefaultSpeedForMediaType(mediaType, options); Assert.Equal(expected, actual); diff --git a/MPF.Frontend/Features/ListConfigFeature.cs b/MPF.Frontend/Features/ListConfigFeature.cs index ae4b4421..becc7ef7 100644 --- a/MPF.Frontend/Features/ListConfigFeature.cs +++ b/MPF.Frontend/Features/ListConfigFeature.cs @@ -42,9 +42,9 @@ namespace MPF.Frontend.Features // GUI Console.WriteLine("GUI:"); Console.WriteLine($" Copy Update URL to Clipboard = {options.GUI.CopyUpdateUrlToClipboard}"); + Console.WriteLine($" Open Log Window at Startup = {options.GUI.OpenLogWindowAtStartup}"); Console.WriteLine($" Default Interface Language = {options.GUI.DefaultInterfaceLanguage.LongName()}"); Console.WriteLine($" Show Debug Menu Item = {options.GUI.ShowDebugViewMenuItem}"); - Console.WriteLine($" Open Log Window at Startup = {options.GUI.OpenLogWindowAtStartup}"); Console.WriteLine(" Theming:"); Console.WriteLine($" Dark Mode = {options.GUI.Theming.EnableDarkMode}"); Console.WriteLine($" Purp Mode = {options.GUI.Theming.EnablePurpMode}"); @@ -68,14 +68,10 @@ namespace MPF.Frontend.Features Console.WriteLine($" Default Program = {options.InternalProgram.LongName()}"); Console.WriteLine($" Default Output Path = {options.Dumping.DefaultOutputPath}"); Console.WriteLine($" Default System = {options.Dumping.DefaultSystem.LongName()}"); - Console.WriteLine(); - - // Dumping Speeds - Console.WriteLine("Dumping Speeds:"); - Console.WriteLine($" Default CD Speed = {options.Dumping.DumpSpeeds.PreferredCD}"); - Console.WriteLine($" Default DVD Speed = {options.Dumping.DumpSpeeds.PreferredDVD}"); - Console.WriteLine($" Default HD-DVD Speed = {options.Dumping.DumpSpeeds.PreferredHDDVD}"); - Console.WriteLine($" Default Blu-ray Speed = {options.Dumping.DumpSpeeds.PreferredBD}"); + Console.WriteLine($" Default CD Speed = {options.Dumping.DumpSpeeds.CD}"); + Console.WriteLine($" Default DVD Speed = {options.Dumping.DumpSpeeds.DVD}"); + Console.WriteLine($" Default HD-DVD Speed = {options.Dumping.DumpSpeeds.HDDVD}"); + Console.WriteLine($" Default Blu-ray Speed = {options.Dumping.DumpSpeeds.Bluray}"); Console.WriteLine(); // Aaru diff --git a/MPF.Frontend/Options.cs b/MPF.Frontend/Options.cs index 114d1df7..b97ddd0f 100644 --- a/MPF.Frontend/Options.cs +++ b/MPF.Frontend/Options.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using Newtonsoft.Json; using SabreTools.RedumpLib.Data; using AaruConstants = MPF.ExecutionContexts.Aaru.SettingConstants; using DiscImageCreatorConstants = MPF.ExecutionContexts.DiscImageCreator.SettingConstants; @@ -72,6 +73,7 @@ namespace MPF.Frontend /// All settings in the form of a dictionary /// /// TODO: Remove when Options is no longer relevant + [JsonIgnore] public Dictionary Settings { get { return ConvertToDictionary(); } @@ -103,11 +105,11 @@ namespace MPF.Frontend InternalProgram = tempInternalProgram == InternalProgram.NONE ? InternalProgram.Redumper : tempInternalProgram; GUI.CopyUpdateUrlToClipboard = GetBooleanSetting(source, "CopyUpdateUrlToClipboard", true); + GUI.OpenLogWindowAtStartup = GetBooleanSetting(source, "OpenLogWindowAtStartup", true); valueString = GetStringSetting(source, "DefaultInterfaceLanguage", InterfaceLanguage.AutoDetect.ShortName()); GUI.DefaultInterfaceLanguage = valueString.ToInterfaceLanguage(); GUI.ShowDebugViewMenuItem = GetBooleanSetting(source, "ShowDebugViewMenuItem", false); - GUI.OpenLogWindowAtStartup = GetBooleanSetting(source, "OpenLogWindowAtStartup", true); GUI.Theming.EnableDarkMode = GetBooleanSetting(source, "EnableDarkMode", false); GUI.Theming.EnablePurpMode = GetBooleanSetting(source, "EnablePurpMode", false); GUI.Theming.CustomBackgroundColor = GetStringSetting(source, "CustomBackgroundColor", null); @@ -125,11 +127,10 @@ namespace MPF.Frontend Dumping.DefaultOutputPath = GetStringSetting(source, "DefaultOutputPath", "ISO"); valueString = GetStringSetting(source, "DefaultSystem", RedumpSystem.IBMPCcompatible.ToString()); Dumping.DefaultSystem = (valueString ?? string.Empty).ToRedumpSystem(); - - Dumping.DumpSpeeds.PreferredCD = GetInt32Setting(source, "PreferredDumpSpeedCD", 24); - Dumping.DumpSpeeds.PreferredDVD = GetInt32Setting(source, "PreferredDumpSpeedDVD", 16); - Dumping.DumpSpeeds.PreferredHDDVD = GetInt32Setting(source, "PreferredDumpSpeedHDDVD", 8); - Dumping.DumpSpeeds.PreferredBD = GetInt32Setting(source, "PreferredDumpSpeedBD", 8); + Dumping.DumpSpeeds.CD = GetInt32Setting(source, "PreferredDumpSpeedCD", 24); + Dumping.DumpSpeeds.DVD = GetInt32Setting(source, "PreferredDumpSpeedDVD", 16); + Dumping.DumpSpeeds.HDDVD = GetInt32Setting(source, "PreferredDumpSpeedHDDVD", 8); + Dumping.DumpSpeeds.Bluray = GetInt32Setting(source, "PreferredDumpSpeedBD", 8); Dumping.Aaru.EnableDebug = GetBooleanSetting(source, AaruConstants.EnableDebug, AaruConstants.EnableDebugDefault); Dumping.Aaru.EnableVerbose = GetBooleanSetting(source, AaruConstants.EnableVerbose, AaruConstants.EnableVerboseDefault); @@ -204,10 +205,10 @@ namespace MPF.Frontend InternalProgram = source.InternalProgram; GUI.CopyUpdateUrlToClipboard = source.GUI.CopyUpdateUrlToClipboard; + GUI.OpenLogWindowAtStartup = source.GUI.OpenLogWindowAtStartup; GUI.DefaultInterfaceLanguage = source.GUI.DefaultInterfaceLanguage; GUI.ShowDebugViewMenuItem = source.GUI.ShowDebugViewMenuItem; - GUI.OpenLogWindowAtStartup = source.GUI.OpenLogWindowAtStartup; GUI.Theming.EnableDarkMode = source.GUI.Theming.EnableDarkMode; GUI.Theming.EnablePurpMode = source.GUI.Theming.EnablePurpMode; GUI.Theming.CustomBackgroundColor = source.GUI.Theming.CustomBackgroundColor; @@ -224,11 +225,10 @@ namespace MPF.Frontend Dumping.DefaultOutputPath = source.Dumping.DefaultOutputPath; Dumping.DefaultSystem = source.Dumping.DefaultSystem; - - Dumping.DumpSpeeds.PreferredCD = source.Dumping.DumpSpeeds.PreferredCD; - Dumping.DumpSpeeds.PreferredDVD = source.Dumping.DumpSpeeds.PreferredDVD; - Dumping.DumpSpeeds.PreferredHDDVD = source.Dumping.DumpSpeeds.PreferredHDDVD; - Dumping.DumpSpeeds.PreferredBD = source.Dumping.DumpSpeeds.PreferredBD; + Dumping.DumpSpeeds.CD = source.Dumping.DumpSpeeds.CD; + Dumping.DumpSpeeds.DVD = source.Dumping.DumpSpeeds.DVD; + Dumping.DumpSpeeds.HDDVD = source.Dumping.DumpSpeeds.HDDVD; + Dumping.DumpSpeeds.Bluray = source.Dumping.DumpSpeeds.Bluray; Dumping.Aaru.EnableDebug = source.Dumping.Aaru.EnableDebug; Dumping.Aaru.EnableVerbose = source.Dumping.Aaru.EnableVerbose; @@ -313,10 +313,10 @@ namespace MPF.Frontend { "DefaultSystem", Dumping.DefaultSystem.ToString() }, { "ShowDebugViewMenuItem", GUI.ShowDebugViewMenuItem.ToString() }, - { "PreferredDumpSpeedCD", Dumping.DumpSpeeds.PreferredCD.ToString() }, - { "PreferredDumpSpeedDVD", Dumping.DumpSpeeds.PreferredDVD.ToString() }, - { "PreferredDumpSpeedHDDVD", Dumping.DumpSpeeds.PreferredHDDVD.ToString() }, - { "PreferredDumpSpeedBD", Dumping.DumpSpeeds.PreferredBD.ToString() }, + { "PreferredDumpSpeedCD", Dumping.DumpSpeeds.CD.ToString() }, + { "PreferredDumpSpeedDVD", Dumping.DumpSpeeds.DVD.ToString() }, + { "PreferredDumpSpeedHDDVD", Dumping.DumpSpeeds.HDDVD.ToString() }, + { "PreferredDumpSpeedBD", Dumping.DumpSpeeds.Bluray.ToString() }, { AaruConstants.EnableDebug, Dumping.Aaru.EnableDebug.ToString() }, { AaruConstants.EnableVerbose, Dumping.Aaru.EnableVerbose.ToString() }, @@ -454,6 +454,7 @@ namespace MPF.Frontend /// /// Default Aaru path /// + [JsonIgnore] internal static string DefaultAaruPath { get @@ -478,6 +479,7 @@ namespace MPF.Frontend /// /// Default DiscImageCreator path /// + [JsonIgnore] internal static string DefaultDiscImageCreatorPath { get @@ -502,6 +504,7 @@ namespace MPF.Frontend /// /// Default Dreamdump path /// + [JsonIgnore] internal static string DefaultDreamdumpPath { get @@ -526,6 +529,7 @@ namespace MPF.Frontend /// /// Default Redumper path /// + [JsonIgnore] internal static string DefaultRedumperPath { get @@ -626,10 +630,6 @@ namespace MPF.Frontend /// Version 1 and greater public RedumpSystem? DefaultSystem { get; set; } = RedumpSystem.IBMPCcompatible; - #endregion - - #region Dumping Speeds - /// /// Default preferred dumping speeds per media type /// @@ -675,25 +675,25 @@ namespace MPF.Frontend /// Default CD dumping speed /// /// Version 1 and greater - public int PreferredCD { get; set; } = 24; + public int CD { get; set; } = 24; /// /// Default DVD dumping speed /// /// Version 1 and greater - public int PreferredDVD { get; set; } = 16; + public int DVD { get; set; } = 16; /// /// Default HD-DVD dumping speed /// /// Version 1 and greater - public int PreferredHDDVD { get; set; } = 8; + public int HDDVD { get; set; } = 8; /// /// Default BD dumping speed /// /// Version 1 and greater - public int PreferredBD { get; set; } = 8; + public int Bluray { get; set; } = 8; } /// @@ -709,6 +709,12 @@ namespace MPF.Frontend /// Version 1 and greater public bool CopyUpdateUrlToClipboard { get; set; } = true; + /// + /// Have the log panel expanded by default on startup + /// + /// Version 1 and greater + public bool OpenLogWindowAtStartup { get; set; } = true; + #endregion #region Interface @@ -725,12 +731,6 @@ namespace MPF.Frontend /// Version 1 and greater; This is a hidden setting public bool ShowDebugViewMenuItem { get; set; } = false; - /// - /// Have the log panel expanded by default on startup - /// - /// Version 1 and greater - public bool OpenLogWindowAtStartup { get; set; } = true; - /// /// Theme settings /// diff --git a/MPF.Frontend/Tools/FrontendTool.cs b/MPF.Frontend/Tools/FrontendTool.cs index d5119280..0dc266cc 100644 --- a/MPF.Frontend/Tools/FrontendTool.cs +++ b/MPF.Frontend/Tools/FrontendTool.cs @@ -20,23 +20,23 @@ namespace MPF.Frontend.Tools return mediaType switch { // CD dump speed - MediaType.CDROM => options.Dumping.DumpSpeeds.PreferredCD, - MediaType.GDROM => options.Dumping.DumpSpeeds.PreferredCD, + MediaType.CDROM => options.Dumping.DumpSpeeds.CD, + MediaType.GDROM => options.Dumping.DumpSpeeds.CD, // DVD dump speed - MediaType.DVD => options.Dumping.DumpSpeeds.PreferredDVD, - MediaType.NintendoGameCubeGameDisc => options.Dumping.DumpSpeeds.PreferredDVD, - MediaType.NintendoWiiOpticalDisc => options.Dumping.DumpSpeeds.PreferredDVD, + MediaType.DVD => options.Dumping.DumpSpeeds.DVD, + MediaType.NintendoGameCubeGameDisc => options.Dumping.DumpSpeeds.DVD, + MediaType.NintendoWiiOpticalDisc => options.Dumping.DumpSpeeds.DVD, // HD-DVD dump speed - MediaType.HDDVD => options.Dumping.DumpSpeeds.PreferredHDDVD, + MediaType.HDDVD => options.Dumping.DumpSpeeds.HDDVD, // BD dump speed - MediaType.BluRay => options.Dumping.DumpSpeeds.PreferredBD, - MediaType.NintendoWiiUOpticalDisc => options.Dumping.DumpSpeeds.PreferredBD, + MediaType.BluRay => options.Dumping.DumpSpeeds.Bluray, + MediaType.NintendoWiiUOpticalDisc => options.Dumping.DumpSpeeds.Bluray, // Default - _ => options.Dumping.DumpSpeeds.PreferredCD, + _ => options.Dumping.DumpSpeeds.CD, }; #pragma warning restore IDE0072 } diff --git a/MPF.UI/Windows/OptionsWindow.xaml b/MPF.UI/Windows/OptionsWindow.xaml index a52997cc..f9afe7f7 100644 --- a/MPF.UI/Windows/OptionsWindow.xaml +++ b/MPF.UI/Windows/OptionsWindow.xaml @@ -310,28 +310,28 @@