mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Clean up options serialization and ordering
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
/// TODO: Remove when Options is no longer relevant
|
||||
[JsonIgnore]
|
||||
public Dictionary<string, string?> 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
|
||||
/// <summary>
|
||||
/// Default Aaru path
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
internal static string DefaultAaruPath
|
||||
{
|
||||
get
|
||||
@@ -478,6 +479,7 @@ namespace MPF.Frontend
|
||||
/// <summary>
|
||||
/// Default DiscImageCreator path
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
internal static string DefaultDiscImageCreatorPath
|
||||
{
|
||||
get
|
||||
@@ -502,6 +504,7 @@ namespace MPF.Frontend
|
||||
/// <summary>
|
||||
/// Default Dreamdump path
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
internal static string DefaultDreamdumpPath
|
||||
{
|
||||
get
|
||||
@@ -526,6 +529,7 @@ namespace MPF.Frontend
|
||||
/// <summary>
|
||||
/// Default Redumper path
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
internal static string DefaultRedumperPath
|
||||
{
|
||||
get
|
||||
@@ -626,10 +630,6 @@ namespace MPF.Frontend
|
||||
/// <remarks>Version 1 and greater</remarks>
|
||||
public RedumpSystem? DefaultSystem { get; set; } = RedumpSystem.IBMPCcompatible;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dumping Speeds
|
||||
|
||||
/// <summary>
|
||||
/// Default preferred dumping speeds per media type
|
||||
/// </summary>
|
||||
@@ -675,25 +675,25 @@ namespace MPF.Frontend
|
||||
/// Default CD dumping speed
|
||||
/// </summary>
|
||||
/// <remarks>Version 1 and greater</remarks>
|
||||
public int PreferredCD { get; set; } = 24;
|
||||
public int CD { get; set; } = 24;
|
||||
|
||||
/// <summary>
|
||||
/// Default DVD dumping speed
|
||||
/// </summary>
|
||||
/// <remarks>Version 1 and greater</remarks>
|
||||
public int PreferredDVD { get; set; } = 16;
|
||||
public int DVD { get; set; } = 16;
|
||||
|
||||
/// <summary>
|
||||
/// Default HD-DVD dumping speed
|
||||
/// </summary>
|
||||
/// <remarks>Version 1 and greater</remarks>
|
||||
public int PreferredHDDVD { get; set; } = 8;
|
||||
public int HDDVD { get; set; } = 8;
|
||||
|
||||
/// <summary>
|
||||
/// Default BD dumping speed
|
||||
/// </summary>
|
||||
/// <remarks>Version 1 and greater</remarks>
|
||||
public int PreferredBD { get; set; } = 8;
|
||||
public int Bluray { get; set; } = 8;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -709,6 +709,12 @@ namespace MPF.Frontend
|
||||
/// <remarks>Version 1 and greater</remarks>
|
||||
public bool CopyUpdateUrlToClipboard { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Have the log panel expanded by default on startup
|
||||
/// </summary>
|
||||
/// <remarks>Version 1 and greater</remarks>
|
||||
public bool OpenLogWindowAtStartup { get; set; } = true;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Interface
|
||||
@@ -725,12 +731,6 @@ namespace MPF.Frontend
|
||||
/// <remarks>Version 1 and greater; This is a hidden setting</remarks>
|
||||
public bool ShowDebugViewMenuItem { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Have the log panel expanded by default on startup
|
||||
/// </summary>
|
||||
/// <remarks>Version 1 and greater</remarks>
|
||||
public bool OpenLogWindowAtStartup { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Theme settings
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -310,28 +310,28 @@
|
||||
<Label Grid.Row="0" Grid.Column="0" Content="{DynamicResource CDLabelString}" />
|
||||
<Slider x:Name="DumpSpeedCDSlider" Grid.Row="0" Grid.Column="1" Minimum="0" Maximum="72" IsSnapToTickEnabled="True" TickPlacement="BottomRight"
|
||||
Ticks="{Binding Source={x:Static core:Constants.SpeedsForCDAsCollection}}"
|
||||
Value="{Binding Options.Dumping.DumpSpeeds.PreferredCD}" />
|
||||
Value="{Binding Options.Dumping.DumpSpeeds.CD}" />
|
||||
<TextBox x:Name="DumpSpeedCDTextBox" Grid.Row="0" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" VerticalAlignment="Center"
|
||||
Text="{Binding ElementName=DumpSpeedCDSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" Background="LightGray" Foreground="Gray"/>
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Content="{DynamicResource DVDLabelString}" />
|
||||
<Slider x:Name="DumpSpeedDVDSlider" Grid.Row="1" Grid.Column="1" Minimum="0" Maximum="24" IsSnapToTickEnabled="True" TickPlacement="BottomRight"
|
||||
Ticks="{Binding Source={x:Static core:Constants.SpeedsForDVDAsCollection}}"
|
||||
Value="{Binding Options.Dumping.DumpSpeeds.PreferredDVD}" />
|
||||
Value="{Binding Options.Dumping.DumpSpeeds.DVD}" />
|
||||
<TextBox x:Name="DumpSpeedDVDTextBox" Grid.Row="1" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" VerticalAlignment="Center"
|
||||
Text="{Binding ElementName=DumpSpeedDVDSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" Background="LightGray" Foreground="Gray"/>
|
||||
|
||||
<Label Grid.Row="2" Grid.Column="0" Content="{DynamicResource HDDVDLabelString}" />
|
||||
<Slider x:Name="DumpSpeedHDDVDSlider" Grid.Row="2" Grid.Column="1" Minimum="0" Maximum="24" IsSnapToTickEnabled="True" TickPlacement="BottomRight"
|
||||
Ticks="{Binding Source={x:Static core:Constants.SpeedsForHDDVDAsCollection}}"
|
||||
Value="{Binding Options.Dumping.DumpSpeeds.PreferredHDDVD}" />
|
||||
Value="{Binding Options.Dumping.DumpSpeeds.HDDVD}" />
|
||||
<TextBox x:Name="DumpSpeedHDDVDTextBox" Grid.Row="2" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" VerticalAlignment="Center"
|
||||
Text="{Binding ElementName=DumpSpeedHDDVDSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" Background="LightGray" Foreground="Gray"/>
|
||||
|
||||
<Label Grid.Row="3" Grid.Column="0" Content="{DynamicResource BDLabelString}" />
|
||||
<Slider x:Name="DumpSpeedBDSlider" Grid.Row="3" Grid.Column="1" Minimum="0" Maximum="16" IsSnapToTickEnabled="True" TickPlacement="BottomRight"
|
||||
Ticks="{Binding Source={x:Static core:Constants.SpeedsForBDAsCollection}}"
|
||||
Value="{Binding Options.Dumping.DumpSpeeds.PreferredBD}" />
|
||||
Value="{Binding Options.Dumping.DumpSpeeds.Bluray}" />
|
||||
<TextBox x:Name="DumpSpeedBDTextBox" Grid.Row="3" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" VerticalAlignment="Center"
|
||||
Text="{Binding ElementName=DumpSpeedBDSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" Background="LightGray" Foreground="Gray"/>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user