diff --git a/CHANGELIST.md b/CHANGELIST.md index bbd46380..80d47fdb 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -28,6 +28,7 @@ - Fix path assignment from UI - Reduce reach of original Options type - Move dictionary logic to new Options object +- Replace original Options object ### 3.6.0 (2025-11-28) diff --git a/MPF.CLI/Features/BaseFeature.cs b/MPF.CLI/Features/BaseFeature.cs index 326adba6..3d69711e 100644 --- a/MPF.CLI/Features/BaseFeature.cs +++ b/MPF.CLI/Features/BaseFeature.cs @@ -19,7 +19,7 @@ namespace MPF.CLI.Features /// /// User-defined options /// - public SegmentedOptions Options { get; protected set; } + public Options Options { get; protected set; } /// /// Currently-selected system @@ -65,7 +65,7 @@ namespace MPF.CLI.Features protected BaseFeature(string name, string[] flags, string description, string? detailed = null) : base(name, flags, description, detailed) { - Options = new SegmentedOptions(); + Options = new Options(); // Internal Program Options.InternalProgram = InternalProgram.NONE; diff --git a/MPF.Check/Features/BaseFeature.cs b/MPF.Check/Features/BaseFeature.cs index d4f0e489..da3e481e 100644 --- a/MPF.Check/Features/BaseFeature.cs +++ b/MPF.Check/Features/BaseFeature.cs @@ -18,7 +18,7 @@ namespace MPF.Check.Features /// /// User-defined options /// - public SegmentedOptions Options { get; protected set; } + public Options Options { get; protected set; } /// /// Currently-selected system @@ -40,7 +40,7 @@ namespace MPF.Check.Features protected BaseFeature(string name, string[] flags, string description, string? detailed = null) : base(name, flags, description, detailed) { - Options = new SegmentedOptions(); + Options = new Options(); // Internal Program Options.InternalProgram = InternalProgram.NONE; diff --git a/MPF.Check/Features/InteractiveFeature.cs b/MPF.Check/Features/InteractiveFeature.cs index e751b16b..9ef9c584 100644 --- a/MPF.Check/Features/InteractiveFeature.cs +++ b/MPF.Check/Features/InteractiveFeature.cs @@ -38,7 +38,7 @@ namespace MPF.Check.Features Options = OptionsLoader.LoadFromConfig(); if (Options.FirstRun) { - Options = new SegmentedOptions(); + Options = new Options(); // Internal Program Options.InternalProgram = InternalProgram.NONE; diff --git a/MPF.Check/Features/MainFeature.cs b/MPF.Check/Features/MainFeature.cs index 575a17fb..5d71305c 100644 --- a/MPF.Check/Features/MainFeature.cs +++ b/MPF.Check/Features/MainFeature.cs @@ -123,7 +123,7 @@ namespace MPF.Check.Features Options = OptionsLoader.LoadFromConfig(); if (Options.FirstRun) { - Options = new SegmentedOptions(); + Options = new Options(); // Internal Program Options.InternalProgram = InternalProgram.NONE; diff --git a/MPF.Frontend.Test/DumpEnvironmentTests.cs b/MPF.Frontend.Test/DumpEnvironmentTests.cs index 25ee78d4..da001049 100644 --- a/MPF.Frontend.Test/DumpEnvironmentTests.cs +++ b/MPF.Frontend.Test/DumpEnvironmentTests.cs @@ -15,7 +15,7 @@ namespace MPF.Frontend.Test [InlineData("stop D", 'D', false, MediaType.DVD, true)] public void ParametersValidSegmentedTest(string? parameters, char letter, bool isFloppy, MediaType? mediaType, bool expected) { - var options = new SegmentedOptions(); + var options = new Options(); options.InternalProgram = InternalProgram.DiscImageCreator; // TODO: This relies on creating real objects for the drive. Can we mock this out instead? diff --git a/MPF.Frontend.Test/Tools/FrontendToolTests.cs b/MPF.Frontend.Test/Tools/FrontendToolTests.cs index c7a2d6b2..3c2c8a6b 100644 --- a/MPF.Frontend.Test/Tools/FrontendToolTests.cs +++ b/MPF.Frontend.Test/Tools/FrontendToolTests.cs @@ -21,7 +21,7 @@ namespace MPF.Frontend.Test.Tools [InlineData(MediaType.NintendoWiiUOpticalDisc, 16)] public void GetDefaultSpeedForMediaTypeSegmentedTest(MediaType? mediaType, int expected) { - var options = new SegmentedOptions(); + var options = new Options(); options.Dumping.DumpSpeeds.PreferredCD = 72; options.Dumping.DumpSpeeds.PreferredDVD = 24; options.Dumping.DumpSpeeds.PreferredHDDVD = 24; diff --git a/MPF.Frontend/DumpEnvironment.cs b/MPF.Frontend/DumpEnvironment.cs index 68cb1236..adb5f3e6 100644 --- a/MPF.Frontend/DumpEnvironment.cs +++ b/MPF.Frontend/DumpEnvironment.cs @@ -47,9 +47,9 @@ namespace MPF.Frontend private readonly InternalProgram _internalProgram; /// - /// SegmentedOptions object representing user-defined options + /// Options object representing user-defined options /// - private readonly SegmentedOptions _options; + private readonly Options _options; /// /// Processor object representing how to process the outputs @@ -106,14 +106,14 @@ namespace MPF.Frontend /// /// /// - public DumpEnvironment(SegmentedOptions options, + public DumpEnvironment(Options options, string? outputPath, Drive? drive, RedumpSystem? system, InternalProgram? internalProgram) { // Set options object - _options = new SegmentedOptions(options); + _options = new Options(options); // Output paths OutputPath = FrontendTool.NormalizeOutputPaths(outputPath, false); diff --git a/MPF.Frontend/SegmentedOptions.cs b/MPF.Frontend/Options.cs similarity index 99% rename from MPF.Frontend/SegmentedOptions.cs rename to MPF.Frontend/Options.cs index 7ac31563..114d1df7 100644 --- a/MPF.Frontend/SegmentedOptions.cs +++ b/MPF.Frontend/Options.cs @@ -13,7 +13,7 @@ namespace MPF.Frontend /// /// Options that use nested types for setting arrangement /// - public class SegmentedOptions + public class Options { #region Properties @@ -84,14 +84,14 @@ namespace MPF.Frontend /// /// Empty constructor for serialization /// - public SegmentedOptions() { } + public Options() { } /// /// Constructor taking a dictionary for settings /// /// Dictionary representing settings /// TODO: Remove when Options is no longer relevant - public SegmentedOptions(Dictionary? source = null) + public Options(Dictionary? source = null) { source ??= []; @@ -191,12 +191,12 @@ namespace MPF.Frontend } /// - /// Constructor that converts from an existing SegmentedOptions object + /// Constructor that converts from an existing Options object /// - /// SegmentedOptions object to read from - public SegmentedOptions(SegmentedOptions? source) + /// Options object to read from + public Options(Options? source) { - source ??= new SegmentedOptions(); + source ??= new Options(); FirstRun = source.FirstRun; CheckForUpdatesOnStartup = source.CheckForUpdatesOnStartup; diff --git a/MPF.Frontend/ProcessUserInfoDelegate.cs b/MPF.Frontend/ProcessUserInfoDelegate.cs index e01254a8..aa448e5f 100644 --- a/MPF.Frontend/ProcessUserInfoDelegate.cs +++ b/MPF.Frontend/ProcessUserInfoDelegate.cs @@ -5,8 +5,8 @@ namespace MPF.Frontend /// /// Determines how user information is processed, if at all /// - /// SegmentedOptions set that may impact processing + /// Options set that may impact processing /// Submission info that may be overwritten /// True for successful updating, false or null otherwise - public delegate bool? ProcessUserInfoDelegate(SegmentedOptions? options, ref SubmissionInfo? info); + public delegate bool? ProcessUserInfoDelegate(Options? options, ref SubmissionInfo? info); } diff --git a/MPF.Frontend/Tools/FrontendTool.cs b/MPF.Frontend/Tools/FrontendTool.cs index 48cc751a..d5119280 100644 --- a/MPF.Frontend/Tools/FrontendTool.cs +++ b/MPF.Frontend/Tools/FrontendTool.cs @@ -14,7 +14,7 @@ namespace MPF.Frontend.Tools /// /// Get the default speed for a given media type from the supplied options /// - public static int GetDefaultSpeedForMediaType(MediaType? mediaType, SegmentedOptions options) + public static int GetDefaultSpeedForMediaType(MediaType? mediaType, Options options) { #pragma warning disable IDE0072 return mediaType switch diff --git a/MPF.Frontend/Tools/OptionsLoader.cs b/MPF.Frontend/Tools/OptionsLoader.cs index 8dd3e7fb..29732110 100644 --- a/MPF.Frontend/Tools/OptionsLoader.cs +++ b/MPF.Frontend/Tools/OptionsLoader.cs @@ -182,36 +182,36 @@ namespace MPF.Frontend.Tools /// /// Load the current set of options from the application configuration /// - public static SegmentedOptions LoadFromConfig() + public static Options LoadFromConfig() { // If no options path can be found if (string.IsNullOrEmpty(ConfigurationPath)) - return new SegmentedOptions(); + return new Options(); // If the file does not exist if (!File.Exists(ConfigurationPath) || new FileInfo(ConfigurationPath).Length == 0) - return new SegmentedOptions(); + return new Options(); var serializer = JsonSerializer.Create(); var stream = File.Open(ConfigurationPath, FileMode.Open, FileAccess.Read, FileShare.None); using var reader = new StreamReader(stream); var settings = serializer.Deserialize(reader, typeof(Dictionary)) as Dictionary; - return new SegmentedOptions(settings); + return new Options(settings); } /// /// Load the current set of options from the application configuration /// - public static SegmentedOptions LoadFromConfigNative() + public static Options LoadFromConfigNative() { // If no options path can be found if (string.IsNullOrEmpty(ConfigurationPath)) - return new SegmentedOptions(); + return new Options(); // If the file does not exist if (!File.Exists(ConfigurationPath) || new FileInfo(ConfigurationPath).Length == 0) - return new SegmentedOptions(); + return new Options(); var serializer = JsonSerializer.Create(); serializer.DefaultValueHandling = DefaultValueHandling.Ignore; @@ -222,13 +222,13 @@ namespace MPF.Frontend.Tools using var sr = new StreamReader(stream); var reader = new JsonTextReader(sr); - return serializer.Deserialize(reader) ?? new SegmentedOptions(); + return serializer.Deserialize(reader) ?? new Options(); } /// /// Save the current set of options to the application configuration /// - public static void SaveToConfig(SegmentedOptions options) + public static void SaveToConfig(Options options) { // If no options path can be found if (string.IsNullOrEmpty(ConfigurationPath)) @@ -245,7 +245,7 @@ namespace MPF.Frontend.Tools /// /// Save the current set of options to the application configuration /// - public static void SaveToConfigNative(SegmentedOptions options) + public static void SaveToConfigNative(Options options) { // If no options path can be found if (string.IsNullOrEmpty(ConfigurationPath)) @@ -256,7 +256,7 @@ namespace MPF.Frontend.Tools using var sw = new StreamWriter(stream) { AutoFlush = true }; var writer = new JsonTextWriter(sw) { Formatting = Formatting.Indented }; - serializer.Serialize(writer, options, typeof(SegmentedOptions)); + serializer.Serialize(writer, options, typeof(Options)); } /// diff --git a/MPF.Frontend/Tools/ProtectionTool.cs b/MPF.Frontend/Tools/ProtectionTool.cs index 735422fe..cd56dbd3 100644 --- a/MPF.Frontend/Tools/ProtectionTool.cs +++ b/MPF.Frontend/Tools/ProtectionTool.cs @@ -73,11 +73,11 @@ namespace MPF.Frontend.Tools /// /// Base output image path /// Drive object representing the current drive - /// SegmentedOptions object that determines what to scan + /// Options object that determines what to scan /// Optional progress callback public static async Task>> RunCombinedProtectionScans(string basePath, Drive? drive, - SegmentedOptions options, + Options options, IProgress? protectionProgress = null) { // Setup the output protections dictionary @@ -137,11 +137,11 @@ namespace MPF.Frontend.Tools /// Run protection scan on a given path /// /// Path to scan for protection - /// SegmentedOptions object that determines what to scan + /// Options object that determines what to scan /// Optional progress callback /// Set of all detected copy protections with an optional error string public static async Task>> RunProtectionScanOnPath(string path, - SegmentedOptions options, + Options options, IProgress? progress = null) { #if NET40 @@ -173,11 +173,11 @@ namespace MPF.Frontend.Tools /// Run protection scan on a disc image /// /// Image path to scan for protection - /// SegmentedOptions object that determines what to scan + /// Options object that determines what to scan /// Optional progress callback /// Set of all detected copy protections with an optional error string public static async Task>> RunProtectionScanOnImage(string image, - SegmentedOptions options, + Options options, IProgress? progress = null) { #if NET40 diff --git a/MPF.Frontend/Tools/SubmissionGenerator.cs b/MPF.Frontend/Tools/SubmissionGenerator.cs index 3ab404b6..7be264a5 100644 --- a/MPF.Frontend/Tools/SubmissionGenerator.cs +++ b/MPF.Frontend/Tools/SubmissionGenerator.cs @@ -37,7 +37,7 @@ namespace MPF.Frontend.Tools /// Drive object representing the current drive /// Currently selected system /// Currently selected media type - /// SegmentedOptions object representing user-defined options + /// Options object representing user-defined options /// Processor object representing how to process the outputs /// Optional result progress callback /// Optional protection progress callback @@ -47,7 +47,7 @@ namespace MPF.Frontend.Tools Drive? drive, RedumpSystem? system, MediaType? mediaType, - SegmentedOptions options, + Options options, BaseProcessor processor, IProgress? resultProgress = null, IProgress? protectionProgress = null) @@ -174,10 +174,10 @@ namespace MPF.Frontend.Tools /// /// Fill in a SubmissionInfo object from Redump, if possible /// - /// SegmentedOptions object representing user-defined options + /// Options object representing user-defined options /// Existing SubmissionInfo object to fill /// Optional result progress callback - public static async Task FillFromRedump(SegmentedOptions options, + public static async Task FillFromRedump(Options options, SubmissionInfo info, IProgress? resultProgress = null) { diff --git a/MPF.Frontend/ViewModels/CheckDumpViewModel.cs b/MPF.Frontend/ViewModels/CheckDumpViewModel.cs index ff735353..2ff51aa2 100644 --- a/MPF.Frontend/ViewModels/CheckDumpViewModel.cs +++ b/MPF.Frontend/ViewModels/CheckDumpViewModel.cs @@ -22,11 +22,11 @@ namespace MPF.Frontend.ViewModels /// /// Access to the current options /// - public SegmentedOptions Options + public Options Options { get => _options; } - private readonly SegmentedOptions _options; + private readonly Options _options; /// /// Indicates if SelectionChanged events can be executed diff --git a/MPF.Frontend/ViewModels/CreateIRDViewModel.cs b/MPF.Frontend/ViewModels/CreateIRDViewModel.cs index 713d9807..e636fda3 100644 --- a/MPF.Frontend/ViewModels/CreateIRDViewModel.cs +++ b/MPF.Frontend/ViewModels/CreateIRDViewModel.cs @@ -16,11 +16,11 @@ namespace MPF.Frontend.ViewModels /// /// Access to the current options /// - public SegmentedOptions Options + public Options Options { get => _options; } - private readonly SegmentedOptions _options; + private readonly Options _options; /// /// Indicates if SelectionChanged events can be executed diff --git a/MPF.Frontend/ViewModels/MainViewModel.cs b/MPF.Frontend/ViewModels/MainViewModel.cs index 0fcc96b1..223035ad 100644 --- a/MPF.Frontend/ViewModels/MainViewModel.cs +++ b/MPF.Frontend/ViewModels/MainViewModel.cs @@ -20,7 +20,7 @@ namespace MPF.Frontend.ViewModels /// /// Access to the current options /// - public SegmentedOptions Options + public Options Options { get => _options; set @@ -29,7 +29,7 @@ namespace MPF.Frontend.ViewModels OptionsLoader.SaveToConfig(_options); } } - private SegmentedOptions _options; + private Options _options; /// /// Indicates if SelectionChanged events can be executed @@ -983,14 +983,14 @@ namespace MPF.Frontend.ViewModels /// /// Indicates if the settings were saved or not /// Options representing the new, saved values - public void UpdateOptions(bool savedSettings, SegmentedOptions? newOptions) + public void UpdateOptions(bool savedSettings, Options? newOptions) { // Get which options to save var optionsToSave = savedSettings ? newOptions : Options; // Ensure the first run flag is unset - var continuingOptions = new SegmentedOptions(optionsToSave) { FirstRun = false }; - Options = new SegmentedOptions(continuingOptions); + var continuingOptions = new Options(optionsToSave) { FirstRun = false }; + Options = new Options(continuingOptions); // If settings were changed, reinitialize the UI if (savedSettings) diff --git a/MPF.Frontend/ViewModels/MediaInformationViewModel.cs b/MPF.Frontend/ViewModels/MediaInformationViewModel.cs index 6065c214..ee143765 100644 --- a/MPF.Frontend/ViewModels/MediaInformationViewModel.cs +++ b/MPF.Frontend/ViewModels/MediaInformationViewModel.cs @@ -12,9 +12,9 @@ namespace MPF.Frontend.ViewModels #region Fields /// - /// Application-level SegmentedOptions object + /// Application-level Options object /// - public SegmentedOptions Options { get; private set; } + public Options Options { get; private set; } /// /// SubmissionInfo object to fill and save @@ -195,7 +195,7 @@ namespace MPF.Frontend.ViewModels /// /// Constructor /// - public MediaInformationViewModel(SegmentedOptions options, SubmissionInfo? submissionInfo) + public MediaInformationViewModel(Options options, SubmissionInfo? submissionInfo) { Options = options; SubmissionInfo = submissionInfo?.Clone() as SubmissionInfo ?? new SubmissionInfo(); diff --git a/MPF.Frontend/ViewModels/OptionsViewModel.cs b/MPF.Frontend/ViewModels/OptionsViewModel.cs index 4edb9234..c8701652 100644 --- a/MPF.Frontend/ViewModels/OptionsViewModel.cs +++ b/MPF.Frontend/ViewModels/OptionsViewModel.cs @@ -32,7 +32,7 @@ namespace MPF.Frontend.ViewModels /// /// Current set of options /// - public SegmentedOptions Options { get; } + public Options Options { get; } /// /// Flag for if settings were saved or not @@ -88,15 +88,15 @@ namespace MPF.Frontend.ViewModels /// public OptionsViewModel() { - Options = new SegmentedOptions(); + Options = new Options(); } /// /// Constructor for in-code /// - public OptionsViewModel(SegmentedOptions baseOptions) + public OptionsViewModel(Options baseOptions) { - Options = new SegmentedOptions(baseOptions); + Options = new Options(baseOptions); } #region Population diff --git a/MPF.UI/Windows/CheckDumpWindow.xaml.cs b/MPF.UI/Windows/CheckDumpWindow.xaml.cs index 63f78d60..f4a22533 100644 --- a/MPF.UI/Windows/CheckDumpWindow.xaml.cs +++ b/MPF.UI/Windows/CheckDumpWindow.xaml.cs @@ -128,9 +128,9 @@ namespace MPF.UI.Windows /// Options set to pass to the information window /// SubmissionInfo object to display and possibly change /// Dialog open result - public bool? ShowMediaInformationWindow(SegmentedOptions? options, ref SubmissionInfo? submissionInfo) + public bool? ShowMediaInformationWindow(Options? options, ref SubmissionInfo? submissionInfo) { - var mediaInformationWindow = new MediaInformationWindow(options ?? new SegmentedOptions(), submissionInfo) + var mediaInformationWindow = new MediaInformationWindow(options ?? new Options(), submissionInfo) { Focusable = true, Owner = this, diff --git a/MPF.UI/Windows/MainWindow.xaml.cs b/MPF.UI/Windows/MainWindow.xaml.cs index cc28e9b5..a46d71e5 100644 --- a/MPF.UI/Windows/MainWindow.xaml.cs +++ b/MPF.UI/Windows/MainWindow.xaml.cs @@ -406,13 +406,13 @@ namespace MPF.UI.Windows /// Options set to pass to the information window /// SubmissionInfo object to display and possibly change /// Dialog open result - public bool? ShowMediaInformationWindow(SegmentedOptions? options, ref SubmissionInfo? submissionInfo) + public bool? ShowMediaInformationWindow(Options? options, ref SubmissionInfo? submissionInfo) { if (options?.Processing?.ShowDiscEjectReminder == true) CustomMessageBox.Show(this, (string)Application.Current.FindResource("EjectMessageString"), (string)Application.Current.FindResource("EjectTitleString"), MessageBoxButton.OK, MessageBoxImage.Information); - var mediaInformationWindow = new MediaInformationWindow(options ?? new SegmentedOptions(), submissionInfo) + var mediaInformationWindow = new MediaInformationWindow(options ?? new Options(), submissionInfo) { Focusable = true, Owner = this, diff --git a/MPF.UI/Windows/MediaInformationWindow.xaml.cs b/MPF.UI/Windows/MediaInformationWindow.xaml.cs index e33a1307..f43ecd0a 100644 --- a/MPF.UI/Windows/MediaInformationWindow.xaml.cs +++ b/MPF.UI/Windows/MediaInformationWindow.xaml.cs @@ -112,12 +112,12 @@ namespace MPF.UI.Windows /// /// Read-only access to the current media information view model /// - public MediaInformationViewModel MediaInformationViewModel => DataContext as MediaInformationViewModel ?? new MediaInformationViewModel(new SegmentedOptions(), new SubmissionInfo()); + public MediaInformationViewModel MediaInformationViewModel => DataContext as MediaInformationViewModel ?? new MediaInformationViewModel(new Options(), new SubmissionInfo()); /// /// Constructor /// - public MediaInformationWindow(SegmentedOptions options, SubmissionInfo? submissionInfo) + public MediaInformationWindow(Options options, SubmissionInfo? submissionInfo) { #if NET40_OR_GREATER || NETCOREAPP InitializeComponent(); @@ -156,7 +156,7 @@ namespace MPF.UI.Windows /// /// Manipulate fields based on the current disc /// - private void ManipulateFields(SegmentedOptions options, SubmissionInfo? submissionInfo) + private void ManipulateFields(Options options, SubmissionInfo? submissionInfo) { // Enable tabs in all fields, if required if (options.Processing.MediaInformation.EnableTabsInInputFields) diff --git a/MPF.UI/Windows/OptionsWindow.xaml.cs b/MPF.UI/Windows/OptionsWindow.xaml.cs index 402c94ad..cb9cd8ba 100644 --- a/MPF.UI/Windows/OptionsWindow.xaml.cs +++ b/MPF.UI/Windows/OptionsWindow.xaml.cs @@ -37,7 +37,7 @@ namespace MPF.UI.Windows /// /// Constructor /// - public OptionsWindow(SegmentedOptions options) + public OptionsWindow(Options options) { #if NET40_OR_GREATER || NETCOREAPP InitializeComponent();