mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Move dictionary logic to new Options object
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
- Move InternalProgram up a level in options, fix XAML
|
||||
- Fix path assignment from UI
|
||||
- Reduce reach of original Options type
|
||||
- Move dictionary logic to new Options object
|
||||
|
||||
### 3.6.0 (2025-11-28)
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace MPF.Frontend.Test
|
||||
{
|
||||
public class OptionsTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("key2", null, "key", false, false)]
|
||||
[InlineData("key", null, "key", false, false)]
|
||||
[InlineData("key", "", "key", false, false)]
|
||||
[InlineData("key", "INVALID", "key", false, false)]
|
||||
[InlineData("key", "true", "key", false, true)]
|
||||
public void GetBooleanSettingTest(string key, string? value, string expectedKey, bool defaultValue, bool expectedValue)
|
||||
{
|
||||
Dictionary<string, string?> settings = new() { [key] = value };
|
||||
bool actual = Options.GetBooleanSetting(settings, expectedKey, defaultValue);
|
||||
Assert.Equal(expectedValue, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("key2", null, "key", -1, -1)]
|
||||
[InlineData("key", null, "key", -1, -1)]
|
||||
[InlineData("key", "", "key", -1, -1)]
|
||||
[InlineData("key", "INVALID", "key", -1, -1)]
|
||||
[InlineData("key", "12345", "key", -1, 12345)]
|
||||
public void GetInt32SettingTest(string key, string? value, string expectedKey, int defaultValue, int expectedValue)
|
||||
{
|
||||
Dictionary<string, string?> settings = new() { [key] = value };
|
||||
int actual = Options.GetInt32Setting(settings, expectedKey, defaultValue);
|
||||
Assert.Equal(expectedValue, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("key2", null, "key", null, null)]
|
||||
[InlineData("key", null, "key", null, null)]
|
||||
[InlineData("key", "", "key", null, "")]
|
||||
[InlineData("key", "INVALID", "key", null, "INVALID")]
|
||||
[InlineData("key", "String", "key", null, "String")]
|
||||
public void GetStringSettingTest(string key, string? value, string expectedKey, string? defaultValue, string? expectedValue)
|
||||
{
|
||||
Dictionary<string, string?> settings = new() { [key] = value };
|
||||
string? actual = Options.GetStringSetting(settings, expectedKey, defaultValue);
|
||||
Assert.Equal(expectedValue, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,942 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using AaruSettings = MPF.ExecutionContexts.Aaru.SettingConstants;
|
||||
using DICSettings = MPF.ExecutionContexts.DiscImageCreator.SettingConstants;
|
||||
// using DreamdumpSectorOrder = MPF.ExecutionContexts.Dreamdump.SectorOrder;
|
||||
// using DreamdumpSettings = MPF.ExecutionContexts.Dreamdump.SettingConstants;
|
||||
using LogCompression = MPF.Processors.LogCompression;
|
||||
using RedumperDriveType = MPF.ExecutionContexts.Redumper.DriveType;
|
||||
using RedumperReadMethod = MPF.ExecutionContexts.Redumper.ReadMethod;
|
||||
using RedumperSectorOrder = MPF.ExecutionContexts.Redumper.SectorOrder;
|
||||
using RedumperSettings = MPF.ExecutionContexts.Redumper.SettingConstants;
|
||||
|
||||
namespace MPF.Frontend
|
||||
{
|
||||
/// <summary>
|
||||
/// Options that use a flat, dictionary-based structure
|
||||
/// </summary>
|
||||
internal class Options
|
||||
{
|
||||
#region Default Paths
|
||||
|
||||
/// <summary>
|
||||
/// Default Aaru path
|
||||
/// </summary>
|
||||
private static string DefaultAaruPath
|
||||
{
|
||||
get
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
string executableName = Environment.OSVersion.Platform switch
|
||||
{
|
||||
PlatformID.Unix => "aaru",
|
||||
PlatformID.MacOSX => "aaru",
|
||||
_ => "aaru.exe"
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
|
||||
#if NET20 || NET35
|
||||
return Path.Combine("Programs", Path.Combine("Aaru", executableName));
|
||||
#else
|
||||
return Path.Combine("Programs", "Aaru", executableName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default DiscImageCreator path
|
||||
/// </summary>
|
||||
private static string DefaultDiscImageCreatorPath
|
||||
{
|
||||
get
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
string executableName = Environment.OSVersion.Platform switch
|
||||
{
|
||||
PlatformID.Unix => "DiscImageCreator.out",
|
||||
PlatformID.MacOSX => "DiscImageCreator",
|
||||
_ => "DiscImageCreator.exe"
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
|
||||
#if NET20 || NET35
|
||||
return Path.Combine("Programs", Path.Combine("Creator", executableName));
|
||||
#else
|
||||
return Path.Combine("Programs", "Creator", executableName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
/// <summary>
|
||||
/// Default Dreamdump path
|
||||
/// </summary>
|
||||
private static string DefaultDreamdumpPath
|
||||
{
|
||||
get
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
string executableName = Environment.OSVersion.Platform switch
|
||||
{
|
||||
PlatformID.Unix => "dreamdump",
|
||||
PlatformID.MacOSX => "dreamdump",
|
||||
_ => "dreamdump.exe"
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
|
||||
#if NET20 || NET35
|
||||
return Path.Combine("Programs", Path.Combine("Dreamdump", executableName));
|
||||
#else
|
||||
return Path.Combine("Programs", "Dreamdump", executableName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
/// <summary>
|
||||
/// Default Redumper path
|
||||
/// </summary>
|
||||
private static string DefaultRedumperPath
|
||||
{
|
||||
get
|
||||
{
|
||||
#pragma warning disable IDE0072
|
||||
string executableName = Environment.OSVersion.Platform switch
|
||||
{
|
||||
PlatformID.Unix => "redumper",
|
||||
PlatformID.MacOSX => "redumper",
|
||||
_ => "redumper.exe"
|
||||
};
|
||||
#pragma warning restore IDE0072
|
||||
|
||||
#if NET20 || NET35
|
||||
return Path.Combine("Programs", Path.Combine("Redumper", executableName));
|
||||
#else
|
||||
return Path.Combine("Programs", "Redumper", executableName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// All settings in the form of a dictionary
|
||||
/// </summary>
|
||||
public Dictionary<string, string?> Settings { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicate if the program is being run with a clean configuration
|
||||
/// </summary>
|
||||
public bool FirstRun
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "FirstRun", true); }
|
||||
set { Settings["FirstRun"] = value.ToString(); }
|
||||
}
|
||||
|
||||
#region Internal Program
|
||||
|
||||
/// <summary>
|
||||
/// Path to Aaru
|
||||
/// </summary>
|
||||
public string? AaruPath
|
||||
{
|
||||
get { return GetStringSetting(Settings, "AaruPath", DefaultAaruPath); }
|
||||
set { Settings["AaruPath"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Path to DiscImageCreator
|
||||
/// </summary>
|
||||
public string? DiscImageCreatorPath
|
||||
{
|
||||
get { return GetStringSetting(Settings, "DiscImageCreatorPath", DefaultDiscImageCreatorPath); }
|
||||
set { Settings["DiscImageCreatorPath"] = value; }
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Path to Dreamdump
|
||||
// /// </summary>
|
||||
// public string? DreamdumpPath
|
||||
// {
|
||||
// get { return GetStringSetting(Settings, "DreamdumpPath", DefaultDreamdumpPath); }
|
||||
// set { Settings["DreamdumpPath"] = value; }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Path to Redumper
|
||||
/// </summary>
|
||||
public string? RedumperPath
|
||||
{
|
||||
get { return GetStringSetting(Settings, "RedumperPath", DefaultRedumperPath); }
|
||||
set { Settings["RedumperPath"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Currently selected dumping program
|
||||
/// </summary>
|
||||
public InternalProgram InternalProgram
|
||||
{
|
||||
get
|
||||
{
|
||||
var valueString = GetStringSetting(Settings, "InternalProgram", InternalProgram.Redumper.ToString());
|
||||
var valueEnum = valueString.ToInternalProgram();
|
||||
return valueEnum == InternalProgram.NONE ? InternalProgram.Redumper : valueEnum;
|
||||
}
|
||||
set
|
||||
{
|
||||
Settings["InternalProgram"] = value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UI Defaults
|
||||
|
||||
/// <summary>
|
||||
/// Enable dark mode for UI elements
|
||||
/// </summary>
|
||||
public bool EnableDarkMode
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "EnableDarkMode", false); }
|
||||
set { Settings["EnableDarkMode"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable purple mode for UI elements
|
||||
/// </summary>
|
||||
/// <remarks>This is a hidden setting</remarks>
|
||||
public bool EnablePurpMode
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "EnablePurpMode", false); }
|
||||
set { Settings["EnablePurpMode"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom color setting
|
||||
/// </summary>
|
||||
/// <remarks>This is a hidden setting</remarks>
|
||||
public string? CustomBackgroundColor
|
||||
{
|
||||
get { return GetStringSetting(Settings, "CustomBackgroundColor", null); }
|
||||
set { Settings["CustomBackgroundColor"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom color setting
|
||||
/// </summary>
|
||||
/// <remarks>This is a hidden setting</remarks>
|
||||
public string? CustomTextColor
|
||||
{
|
||||
get { return GetStringSetting(Settings, "CustomTextColor", null); }
|
||||
set { Settings["CustomTextColor"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check for updates on startup
|
||||
/// </summary>
|
||||
public bool CheckForUpdatesOnStartup
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "CheckForUpdatesOnStartup", true); }
|
||||
set { Settings["CheckForUpdatesOnStartup"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to copy the update URL to the clipboard if one is found
|
||||
/// </summary>
|
||||
public bool CopyUpdateUrlToClipboard
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "CopyUpdateUrlToClipboard", true); }
|
||||
set { Settings["CopyUpdateUrlToClipboard"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fast update label - Skips disc checks and updates path only
|
||||
/// </summary>
|
||||
public bool FastUpdateLabel
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "FastUpdateLabel", false); }
|
||||
set { Settings["FastUpdateLabel"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default interface language to launch MPF into
|
||||
/// </summary>
|
||||
public InterfaceLanguage DefaultInterfaceLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
var valueString = GetStringSetting(Settings, "DefaultInterfaceLanguage", InterfaceLanguage.AutoDetect.ShortName());
|
||||
return valueString.ToInterfaceLanguage();
|
||||
}
|
||||
set
|
||||
{
|
||||
Settings["DefaultInterfaceLanguage"] = value.ShortName();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default output path for dumps
|
||||
/// </summary>
|
||||
public string? DefaultOutputPath
|
||||
{
|
||||
get { return GetStringSetting(Settings, "DefaultOutputPath", "ISO"); }
|
||||
set { Settings["DefaultOutputPath"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default system if none can be detected
|
||||
/// </summary>
|
||||
public RedumpSystem? DefaultSystem
|
||||
{
|
||||
get
|
||||
{
|
||||
var valueString = GetStringSetting(Settings, "DefaultSystem", RedumpSystem.IBMPCcompatible.ToString());
|
||||
var valueEnum = (valueString ?? string.Empty).ToRedumpSystem();
|
||||
return valueEnum;
|
||||
}
|
||||
set
|
||||
{
|
||||
Settings["DefaultSystem"] = value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show the debug menu item
|
||||
/// </summary>
|
||||
/// <remarks>This is a hidden setting</remarks>
|
||||
public bool ShowDebugViewMenuItem
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "ShowDebugViewMenuItem", false); }
|
||||
set { Settings["ShowDebugViewMenuItem"] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dumping Speeds
|
||||
|
||||
/// <summary>
|
||||
/// Default CD dumping speed
|
||||
/// </summary>
|
||||
public int PreferredDumpSpeedCD
|
||||
{
|
||||
get { return GetInt32Setting(Settings, "PreferredDumpSpeedCD", 24); }
|
||||
set { Settings["PreferredDumpSpeedCD"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default DVD dumping speed
|
||||
/// </summary>
|
||||
public int PreferredDumpSpeedDVD
|
||||
{
|
||||
get { return GetInt32Setting(Settings, "PreferredDumpSpeedDVD", 16); }
|
||||
set { Settings["PreferredDumpSpeedDVD"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default HD-DVD dumping speed
|
||||
/// </summary>
|
||||
public int PreferredDumpSpeedHDDVD
|
||||
{
|
||||
get { return GetInt32Setting(Settings, "PreferredDumpSpeedHDDVD", 8); }
|
||||
set { Settings["PreferredDumpSpeedHDDVD"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default BD dumping speed
|
||||
/// </summary>
|
||||
public int PreferredDumpSpeedBD
|
||||
{
|
||||
get { return GetInt32Setting(Settings, "PreferredDumpSpeedBD", 8); }
|
||||
set { Settings["PreferredDumpSpeedBD"] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Aaru
|
||||
|
||||
/// <summary>
|
||||
/// Enable debug output while dumping by default
|
||||
/// </summary>
|
||||
public bool AaruEnableDebug
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, AaruSettings.EnableDebug, AaruSettings.EnableDebugDefault); }
|
||||
set { Settings[AaruSettings.EnableDebug] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable verbose output while dumping by default
|
||||
/// </summary>
|
||||
public bool AaruEnableVerbose
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, AaruSettings.EnableVerbose, AaruSettings.EnableVerboseDefault); }
|
||||
set { Settings[AaruSettings.EnableVerbose] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable force dumping of media by default
|
||||
/// </summary>
|
||||
public bool AaruForceDumping
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, AaruSettings.ForceDumping, AaruSettings.ForceDumpingDefault); }
|
||||
set { Settings[AaruSettings.ForceDumping] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default number of sector/subchannel rereads
|
||||
/// </summary>
|
||||
public int AaruRereadCount
|
||||
{
|
||||
get { return GetInt32Setting(Settings, AaruSettings.RereadCount, AaruSettings.RereadCountDefault); }
|
||||
set { Settings[AaruSettings.RereadCount] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Strip personal data information from Aaru metadata by default
|
||||
/// </summary>
|
||||
public bool AaruStripPersonalData
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, AaruSettings.StripPersonalData, AaruSettings.StripPersonalDataDefault); }
|
||||
set { Settings[AaruSettings.StripPersonalData] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DiscImageCreator
|
||||
|
||||
/// <summary>
|
||||
/// Enable multi-sector read flag by default
|
||||
/// </summary>
|
||||
public bool DICMultiSectorRead
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, DICSettings.MultiSectorRead, DICSettings.MultiSectorReadDefault); }
|
||||
set { Settings[DICSettings.MultiSectorRead] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Include a default multi-sector read value
|
||||
/// </summary>
|
||||
public int DICMultiSectorReadValue
|
||||
{
|
||||
get { return GetInt32Setting(Settings, DICSettings.MultiSectorReadValue, DICSettings.MultiSectorReadValueDefault); }
|
||||
set { Settings[DICSettings.MultiSectorReadValue] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable overly-secure dumping flags by default
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Split this into component parts later. Currently does:
|
||||
/// - Scan sector protection and set subchannel read level to 2 for CD
|
||||
/// - Set scan file protect flag for DVD
|
||||
/// </remarks>
|
||||
public bool DICParanoidMode
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, DICSettings.ParanoidMode, DICSettings.ParanoidModeDefault); }
|
||||
set { Settings[DICSettings.ParanoidMode] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable the Quiet flag by default
|
||||
/// </summary>
|
||||
public bool DICQuietMode
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, DICSettings.QuietMode, DICSettings.QuietModeDefault); }
|
||||
set { Settings[DICSettings.QuietMode] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default number of C2 rereads
|
||||
/// </summary>
|
||||
public int DICRereadCount
|
||||
{
|
||||
get { return GetInt32Setting(Settings, DICSettings.RereadCount, DICSettings.RereadCountDefault); }
|
||||
set { Settings[DICSettings.RereadCount] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default number of DVD/HD-DVD/BD rereads
|
||||
/// </summary>
|
||||
public int DICDVDRereadCount
|
||||
{
|
||||
get { return GetInt32Setting(Settings, DICSettings.DVDRereadCount, DICSettings.DVDRereadCountDefault); }
|
||||
set { Settings[DICSettings.DVDRereadCount] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use the CMI flag for supported disc types
|
||||
/// </summary>
|
||||
public bool DICUseCMIFlag
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, DICSettings.UseCMIFlag, DICSettings.UseCMIFlagDefault); }
|
||||
set { Settings[DICSettings.UseCMIFlag] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dreamdump
|
||||
|
||||
// /// <summary>
|
||||
// /// Enable options incompatible with redump submissions
|
||||
// /// </summary>
|
||||
// public bool DreamdumpNonRedumpMode
|
||||
// {
|
||||
// get { return GetBooleanSetting(Settings, "DreamdumpNonRedumpMode", false); }
|
||||
// set { Settings["DreamdumpNonRedumpMode"] = value.ToString(); }
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Currently selected default Dreamdump sector order
|
||||
// /// </summary>
|
||||
// public DreamdumpSectorOrder DreamdumpSectorOrder
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// var valueString = GetStringSetting(Settings, DreamdumpSettings.SectorOrder, DreamdumpSettings.SectorOrderDefault);
|
||||
// return valueString.ToDreamdumpSectorOrder();
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// Settings[DreamdumpSettings.SectorOrder] = value.ToString();
|
||||
// }
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Default number of rereads
|
||||
// /// </summary>
|
||||
// public int DreamdumpRereadCount
|
||||
// {
|
||||
// get { return GetInt32Setting(Settings, DreamdumpSettings.RereadCount, DreamdumpSettings.RereadCountDefault); }
|
||||
// set { Settings[DreamdumpSettings.RereadCount] = value.ToString(); }
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Redumper
|
||||
|
||||
/// <summary>
|
||||
/// Enable skeleton output while dumping by default
|
||||
/// </summary>
|
||||
/// <remarks>This is a hidden setting</remarks>
|
||||
public bool RedumperEnableSkeleton
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, RedumperSettings.EnableSkeleton, RedumperSettings.EnableSkeletonDefault); }
|
||||
set { Settings[RedumperSettings.EnableSkeleton] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable verbose output while dumping by default
|
||||
/// </summary>
|
||||
public bool RedumperEnableVerbose
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, RedumperSettings.EnableVerbose, RedumperSettings.EnableVerboseDefault); }
|
||||
set { Settings[RedumperSettings.EnableVerbose] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default number of redumper Plextor leadin retries
|
||||
/// </summary>
|
||||
public int RedumperLeadinRetryCount
|
||||
{
|
||||
get { return GetInt32Setting(Settings, RedumperSettings.LeadinRetryCount, RedumperSettings.LeadinRetryCountDefault); }
|
||||
set { Settings[RedumperSettings.LeadinRetryCount] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable options incompatible with redump submissions
|
||||
/// </summary>
|
||||
public bool RedumperNonRedumpMode
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "RedumperNonRedumpMode", false); }
|
||||
set { Settings["RedumperNonRedumpMode"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Currently selected default redumper drive type
|
||||
/// </summary>
|
||||
public RedumperDriveType RedumperDriveType
|
||||
{
|
||||
get
|
||||
{
|
||||
var valueString = GetStringSetting(Settings, RedumperSettings.DriveType, RedumperSettings.DriveTypeDefault.ToString());
|
||||
return valueString.ToRedumperDriveType();
|
||||
}
|
||||
set
|
||||
{
|
||||
Settings[RedumperSettings.DriveType] = value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Currently selected default redumper drive pregap start sector
|
||||
/// </summary>
|
||||
public int RedumperDrivePregapStart
|
||||
{
|
||||
get { return GetInt32Setting(Settings, RedumperSettings.DrivePregapStart, RedumperSettings.DrivePregapStartDefault); }
|
||||
set { Settings[RedumperSettings.DrivePregapStart] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Currently selected default redumper read method
|
||||
/// </summary>
|
||||
public RedumperReadMethod RedumperReadMethod
|
||||
{
|
||||
get
|
||||
{
|
||||
var valueString = GetStringSetting(Settings, RedumperSettings.ReadMethod, RedumperSettings.ReadMethodDefault.ToString());
|
||||
return valueString.ToRedumperReadMethod();
|
||||
}
|
||||
set
|
||||
{
|
||||
Settings[RedumperSettings.ReadMethod] = value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Currently selected default redumper sector order
|
||||
/// </summary>
|
||||
public RedumperSectorOrder RedumperSectorOrder
|
||||
{
|
||||
get
|
||||
{
|
||||
var valueString = GetStringSetting(Settings, RedumperSettings.SectorOrder, RedumperSettings.SectorOrderDefault.ToString());
|
||||
return valueString.ToRedumperSectorOrder();
|
||||
}
|
||||
set
|
||||
{
|
||||
Settings[RedumperSettings.SectorOrder] = value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default number of rereads
|
||||
/// </summary>
|
||||
public int RedumperRereadCount
|
||||
{
|
||||
get { return GetInt32Setting(Settings, RedumperSettings.RereadCount, RedumperSettings.RereadCountDefault); }
|
||||
set { Settings[RedumperSettings.RereadCount] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable the refine sector mode flag by default
|
||||
/// </summary>
|
||||
public bool RedumperRefineSectorMode
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, RedumperSettings.RefineSectorMode, RedumperSettings.RefineSectorModeDefault); }
|
||||
set { Settings[RedumperSettings.RefineSectorMode] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Extra Dumping Options
|
||||
|
||||
/// <summary>
|
||||
/// Scan the disc for protection after dumping
|
||||
/// </summary>
|
||||
public bool ScanForProtection
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "ScanForProtection", true); }
|
||||
set { Settings["ScanForProtection"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add placeholder values in the submission info
|
||||
/// </summary>
|
||||
public bool AddPlaceholders
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "AddPlaceholders", true); }
|
||||
set { Settings["AddPlaceholders"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show the media information window after dumping
|
||||
/// </summary>
|
||||
public bool PromptForDiscInformation
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "PromptForDiscInformation", true); }
|
||||
set { Settings["PromptForDiscInformation"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pull all information from Redump if signed in
|
||||
/// </summary>
|
||||
public bool PullAllInformation
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "PullAllInformation", false); }
|
||||
set { Settings["PullAllInformation"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable tabs in all input fields
|
||||
/// </summary>
|
||||
public bool EnableTabsInInputFields
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "EnableTabsInInputFields", true); }
|
||||
set { Settings["EnableTabsInInputFields"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Limit outputs to Redump-supported values only
|
||||
/// </summary>
|
||||
public bool EnableRedumpCompatibility
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "EnableRedumpCompatibility", true); }
|
||||
set { Settings["EnableRedumpCompatibility"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show disc eject reminder before the media information window is shown
|
||||
/// </summary>
|
||||
public bool ShowDiscEjectReminder
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "ShowDiscEjectReminder", true); }
|
||||
set { Settings["ShowDiscEjectReminder"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ignore fixed drives when populating the list
|
||||
/// </summary>
|
||||
public bool IgnoreFixedDrives
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "IgnoreFixedDrives", true); }
|
||||
set { Settings["IgnoreFixedDrives"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the dump filename as a suffix to the auto-generated files
|
||||
/// </summary>
|
||||
public bool AddFilenameSuffix
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "AddFilenameSuffix", false); }
|
||||
set { Settings["AddFilenameSuffix"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Output the compressed JSON version of the submission info
|
||||
/// </summary>
|
||||
public bool OutputSubmissionJSON
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "OutputSubmissionJSON", false); }
|
||||
set { Settings["OutputSubmissionJSON"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Include log files in serialized JSON data
|
||||
/// </summary>
|
||||
public bool IncludeArtifacts
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "IncludeArtifacts", false); }
|
||||
set { Settings["IncludeArtifacts"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compress output log files to reduce space
|
||||
/// </summary>
|
||||
public bool CompressLogFiles
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "CompressLogFiles", true); }
|
||||
set { Settings["CompressLogFiles"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compression type used during log compression
|
||||
/// </summary>
|
||||
public LogCompression LogCompression
|
||||
{
|
||||
get
|
||||
{
|
||||
var valueString = GetStringSetting(Settings, "LogCompression", LogCompression.DeflateMaximum.ToString());
|
||||
return valueString.ToLogCompression();
|
||||
}
|
||||
set
|
||||
{
|
||||
Settings["LogCompression"] = value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete unnecessary files to reduce space
|
||||
/// </summary>
|
||||
public bool DeleteUnnecessaryFiles
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "DeleteUnnecessaryFiles", false); }
|
||||
set { Settings["DeleteUnnecessaryFiles"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a PS3 IRD file after dumping PS3 BD-ROM discs
|
||||
/// </summary>
|
||||
public bool CreateIRDAfterDumping
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "CreateIRDAfterDumping", false); }
|
||||
set { Settings["CreateIRDAfterDumping"] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Skip Options
|
||||
|
||||
/// <summary>
|
||||
/// Skip detecting known system on disc scan
|
||||
/// </summary>
|
||||
public bool SkipSystemDetection
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "SkipSystemDetection", false); }
|
||||
set { Settings["SkipSystemDetection"] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protection Scanning Options
|
||||
|
||||
/// <summary>
|
||||
/// Scan archive contents during protection scanning
|
||||
/// </summary>
|
||||
public bool ScanArchivesForProtection
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "ScanArchivesForProtection", true); }
|
||||
set { Settings["ScanArchivesForProtection"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Include debug information with scan results
|
||||
/// </summary>
|
||||
public bool IncludeDebugProtectionInformation
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "IncludeDebugProtectionInformation", false); }
|
||||
set { Settings["IncludeDebugProtectionInformation"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove drive letters from protection scan output
|
||||
/// </summary>
|
||||
public bool HideDriveLetters
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "HideDriveLetters", false); }
|
||||
set { Settings["HideDriveLetters"] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logging Options
|
||||
|
||||
/// <summary>
|
||||
/// Enable verbose and debug logs to be written
|
||||
/// </summary>
|
||||
public bool VerboseLogging
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "VerboseLogging", true); }
|
||||
set { Settings["VerboseLogging"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Have the log panel expanded by default on startup
|
||||
/// </summary>
|
||||
public bool OpenLogWindowAtStartup
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "OpenLogWindowAtStartup", true); }
|
||||
set { Settings["OpenLogWindowAtStartup"] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Redump Login Information
|
||||
|
||||
/// <summary>
|
||||
/// Enable retrieving match information from Redump
|
||||
/// </summary>
|
||||
public bool RetrieveMatchInformation
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "RetrieveMatchInformation", true); }
|
||||
set { Settings["RetrieveMatchInformation"] = value.ToString(); }
|
||||
}
|
||||
|
||||
public string? RedumpUsername
|
||||
{
|
||||
get { return GetStringSetting(Settings, "RedumpUsername", ""); }
|
||||
set { Settings["RedumpUsername"] = value; }
|
||||
}
|
||||
|
||||
// TODO: Figure out a way to keep this encrypted in some way, BASE64 to start?
|
||||
public string? RedumpPassword
|
||||
{
|
||||
get { return GetStringSetting(Settings, "RedumpPassword", ""); }
|
||||
set { Settings["RedumpPassword"] = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor taking a dictionary for settings
|
||||
/// </summary>
|
||||
/// <param name="settings"></param>
|
||||
public Options(Dictionary<string, string?>? settings = null)
|
||||
{
|
||||
Settings = settings ?? [];
|
||||
}
|
||||
|
||||
#region Helpers
|
||||
|
||||
/// <summary>
|
||||
/// Get a Boolean setting from a settings, dictionary
|
||||
/// </summary>
|
||||
/// <param name="settings">Dictionary representing the settings</param>
|
||||
/// <param name="key">Setting key to get a value for</param>
|
||||
/// <param name="defaultValue">Default value to return if no value is found</param>
|
||||
/// <returns>Setting value if possible, default value otherwise</returns>
|
||||
internal static bool GetBooleanSetting(Dictionary<string, string?> settings, string key, bool defaultValue)
|
||||
{
|
||||
if (settings.ContainsKey(key))
|
||||
{
|
||||
if (bool.TryParse(settings[key], out bool value))
|
||||
return value;
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get an Int32 setting from a settings, dictionary
|
||||
/// </summary>
|
||||
/// <param name="settings">Dictionary representing the settings</param>
|
||||
/// <param name="key">Setting key to get a value for</param>
|
||||
/// <param name="defaultValue">Default value to return if no value is found</param>
|
||||
/// <returns>Setting value if possible, default value otherwise</returns>
|
||||
internal static int GetInt32Setting(Dictionary<string, string?> settings, string key, int defaultValue)
|
||||
{
|
||||
if (settings.ContainsKey(key))
|
||||
{
|
||||
if (int.TryParse(settings[key], out int value))
|
||||
return value;
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a String setting from a settings, dictionary
|
||||
/// </summary>
|
||||
/// <param name="settings">Dictionary representing the settings</param>
|
||||
/// <param name="key">Setting key to get a value for</param>
|
||||
/// <param name="defaultValue">Default value to return if no value is found</param>
|
||||
/// <returns>Setting value if possible, default value otherwise</returns>
|
||||
internal static string? GetStringSetting(Dictionary<string, string?> settings, string key, string? defaultValue)
|
||||
{
|
||||
if (settings.ContainsKey(key))
|
||||
return settings[key];
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using SabreTools.RedumpLib.Data;
|
||||
using AaruConstants = MPF.ExecutionContexts.Aaru.SettingConstants;
|
||||
using DiscImageCreatorConstants = MPF.ExecutionContexts.DiscImageCreator.SettingConstants;
|
||||
using DreamdumpConstants = MPF.ExecutionContexts.Dreamdump.SettingConstants;
|
||||
using LogCompression = MPF.Processors.LogCompression;
|
||||
using RedumperConstants = MPF.ExecutionContexts.Redumper.SettingConstants;
|
||||
|
||||
namespace MPF.Frontend
|
||||
@@ -73,7 +74,7 @@ namespace MPF.Frontend
|
||||
/// TODO: Remove when Options is no longer relevant
|
||||
public Dictionary<string, string?> Settings
|
||||
{
|
||||
get { return ConvertToOptions().Settings; }
|
||||
get { return ConvertToDictionary(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -91,8 +92,102 @@ namespace MPF.Frontend
|
||||
/// <param name="source">Dictionary representing settings</param>
|
||||
/// TODO: Remove when Options is no longer relevant
|
||||
public SegmentedOptions(Dictionary<string, string?>? source = null)
|
||||
: this(new Options(source))
|
||||
{
|
||||
source ??= [];
|
||||
|
||||
FirstRun = GetBooleanSetting(source, "FirstRun", true);
|
||||
CheckForUpdatesOnStartup = GetBooleanSetting(source, "CheckForUpdatesOnStartup", true);
|
||||
VerboseLogging = GetBooleanSetting(source, "VerboseLogging", true);
|
||||
var valueString = GetStringSetting(source, "InternalProgram", InternalProgram.Redumper.ToString());
|
||||
var tempInternalProgram = valueString.ToInternalProgram();
|
||||
InternalProgram = tempInternalProgram == InternalProgram.NONE ? InternalProgram.Redumper : tempInternalProgram;
|
||||
|
||||
GUI.CopyUpdateUrlToClipboard = GetBooleanSetting(source, "CopyUpdateUrlToClipboard", 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);
|
||||
GUI.Theming.CustomTextColor = GetStringSetting(source, "CustomTextColor", null);
|
||||
|
||||
GUI.FastUpdateLabel = GetBooleanSetting(source, "FastUpdateLabel", false);
|
||||
GUI.IgnoreFixedDrives = GetBooleanSetting(source, "IgnoreFixedDrives", true);
|
||||
GUI.SkipSystemDetection = GetBooleanSetting(source, "SkipSystemDetection", false);
|
||||
|
||||
Dumping.AaruPath = GetStringSetting(source, "AaruPath", DumpSettings.DefaultAaruPath) ?? DumpSettings.DefaultAaruPath;
|
||||
Dumping.DiscImageCreatorPath = GetStringSetting(source, "DiscImageCreatorPath", DumpSettings.DefaultDiscImageCreatorPath) ?? DumpSettings.DefaultDiscImageCreatorPath;
|
||||
Dumping.DreamdumpPath = GetStringSetting(source, "DreamdumpPath", DumpSettings.DefaultDreamdumpPath) ?? DumpSettings.DefaultDreamdumpPath;
|
||||
Dumping.RedumperPath = GetStringSetting(source, "RedumperPath", DumpSettings.DefaultRedumperPath) ?? DumpSettings.DefaultRedumperPath;
|
||||
|
||||
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.Aaru.EnableDebug = GetBooleanSetting(source, AaruConstants.EnableDebug, AaruConstants.EnableDebugDefault);
|
||||
Dumping.Aaru.EnableVerbose = GetBooleanSetting(source, AaruConstants.EnableVerbose, AaruConstants.EnableVerboseDefault);
|
||||
Dumping.Aaru.ForceDumping = GetBooleanSetting(source, AaruConstants.ForceDumping, AaruConstants.ForceDumpingDefault);
|
||||
Dumping.Aaru.RereadCount = GetInt32Setting(source, AaruConstants.RereadCount, AaruConstants.RereadCountDefault);
|
||||
Dumping.Aaru.StripPersonalData = GetBooleanSetting(source, AaruConstants.StripPersonalData, AaruConstants.StripPersonalDataDefault);
|
||||
|
||||
Dumping.DIC.MultiSectorRead = GetBooleanSetting(source, DiscImageCreatorConstants.MultiSectorRead, DiscImageCreatorConstants.MultiSectorReadDefault);
|
||||
Dumping.DIC.MultiSectorReadValue = GetInt32Setting(source, DiscImageCreatorConstants.MultiSectorReadValue, DiscImageCreatorConstants.MultiSectorReadValueDefault);
|
||||
Dumping.DIC.ParanoidMode = GetBooleanSetting(source, DiscImageCreatorConstants.ParanoidMode, DiscImageCreatorConstants.ParanoidModeDefault);
|
||||
Dumping.DIC.QuietMode = GetBooleanSetting(source, DiscImageCreatorConstants.QuietMode, DiscImageCreatorConstants.QuietModeDefault);
|
||||
Dumping.DIC.RereadCount = GetInt32Setting(source, DiscImageCreatorConstants.RereadCount, DiscImageCreatorConstants.RereadCountDefault);
|
||||
Dumping.DIC.DVDRereadCount = GetInt32Setting(source, DiscImageCreatorConstants.DVDRereadCount, DiscImageCreatorConstants.DVDRereadCountDefault);
|
||||
Dumping.DIC.UseCMIFlag = GetBooleanSetting(source, DiscImageCreatorConstants.UseCMIFlag, DiscImageCreatorConstants.UseCMIFlagDefault);
|
||||
|
||||
Dumping.Dreamdump.NonRedumpMode = GetBooleanSetting(source, "DreamdumpNonRedumpMode", false);
|
||||
valueString = GetStringSetting(source, DreamdumpConstants.SectorOrder, DreamdumpConstants.SectorOrderDefault.ToString());
|
||||
Dumping.Dreamdump.SectorOrder = valueString.ToDreamdumpSectorOrder();
|
||||
Dumping.Dreamdump.RereadCount = GetInt32Setting(source, DreamdumpConstants.RereadCount, DreamdumpConstants.RereadCountDefault);
|
||||
|
||||
Dumping.Redumper.EnableSkeleton = GetBooleanSetting(source, RedumperConstants.EnableSkeleton, RedumperConstants.EnableSkeletonDefault);
|
||||
Dumping.Redumper.EnableVerbose = GetBooleanSetting(source, RedumperConstants.EnableVerbose, RedumperConstants.EnableVerboseDefault);
|
||||
Dumping.Redumper.LeadinRetryCount = GetInt32Setting(source, RedumperConstants.LeadinRetryCount, RedumperConstants.LeadinRetryCountDefault);
|
||||
Dumping.Redumper.NonRedumpMode = GetBooleanSetting(source, "RedumperNonRedumpMode", false);
|
||||
valueString = GetStringSetting(source, RedumperConstants.DriveType, RedumperConstants.DriveTypeDefault.ToString());
|
||||
Dumping.Redumper.DriveType = valueString.ToRedumperDriveType();
|
||||
Dumping.Redumper.DrivePregapStart = GetInt32Setting(source, RedumperConstants.DrivePregapStart, RedumperConstants.DrivePregapStartDefault);
|
||||
valueString = GetStringSetting(source, RedumperConstants.ReadMethod, RedumperConstants.ReadMethodDefault.ToString());
|
||||
Dumping.Redumper.ReadMethod = valueString.ToRedumperReadMethod();
|
||||
valueString = GetStringSetting(source, RedumperConstants.SectorOrder, RedumperConstants.SectorOrderDefault.ToString());
|
||||
Dumping.Redumper.SectorOrder = valueString.ToRedumperSectorOrder();
|
||||
Dumping.Redumper.RereadCount = GetInt32Setting(source, RedumperConstants.RereadCount, RedumperConstants.RereadCountDefault);
|
||||
Dumping.Redumper.RefineSectorMode = GetBooleanSetting(source, RedumperConstants.RefineSectorMode, RedumperConstants.RefineSectorModeDefault);
|
||||
|
||||
Processing.ProtectionScanning.ScanForProtection = GetBooleanSetting(source, "ScanForProtection", true);
|
||||
Processing.ProtectionScanning.ScanArchivesForProtection = GetBooleanSetting(source, "ScanArchivesForProtection", true);
|
||||
Processing.ProtectionScanning.IncludeDebugProtectionInformation = GetBooleanSetting(source, "IncludeDebugProtectionInformation", false);
|
||||
Processing.ProtectionScanning.HideDriveLetters = GetBooleanSetting(source, "HideDriveLetters", false);
|
||||
|
||||
Processing.Login.RetrieveMatchInformation = GetBooleanSetting(source, "RetrieveMatchInformation", true);
|
||||
Processing.Login.RedumpUsername = GetStringSetting(source, "RedumpUsername", string.Empty);
|
||||
Processing.Login.RedumpPassword = GetStringSetting(source, "RedumpPassword", string.Empty);
|
||||
|
||||
Processing.MediaInformation.AddPlaceholders = GetBooleanSetting(source, "AddPlaceholders", true);
|
||||
Processing.MediaInformation.PromptForDiscInformation = GetBooleanSetting(source, "PromptForDiscInformation", true);
|
||||
Processing.MediaInformation.PullAllInformation = GetBooleanSetting(source, "PullAllInformation", false);
|
||||
Processing.MediaInformation.EnableTabsInInputFields = GetBooleanSetting(source, "EnableTabsInInputFields", true);
|
||||
Processing.MediaInformation.EnableRedumpCompatibility = GetBooleanSetting(source, "EnableRedumpCompatibility", true);
|
||||
|
||||
Processing.ShowDiscEjectReminder = GetBooleanSetting(source, "ShowDiscEjectReminder", true);
|
||||
Processing.AddFilenameSuffix = GetBooleanSetting(source, "AddFilenameSuffix", false);
|
||||
Processing.CreateIRDAfterDumping = GetBooleanSetting(source, "CreateIRDAfterDumping", false);
|
||||
Processing.OutputSubmissionJSON = GetBooleanSetting(source, "OutputSubmissionJSON", false);
|
||||
Processing.IncludeArtifacts = GetBooleanSetting(source, "IncludeArtifacts", false);
|
||||
Processing.CompressLogFiles = GetBooleanSetting(source, "CompressLogFiles", true);
|
||||
valueString = GetStringSetting(source, "LogCompression", LogCompression.DeflateMaximum.ToString());
|
||||
Processing.LogCompression = valueString.ToLogCompression();
|
||||
Processing.DeleteUnnecessaryFiles = GetBooleanSetting(source, "DeleteUnnecessaryFiles", false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -189,193 +284,162 @@ namespace MPF.Frontend
|
||||
Processing.DeleteUnnecessaryFiles = source.Processing.DeleteUnnecessaryFiles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor that converts from an existing Options object
|
||||
/// </summary>
|
||||
/// <param name="source">Options object to read from</param>
|
||||
/// TODO: Remove when Options is no longer relevant
|
||||
private SegmentedOptions(Options source)
|
||||
{
|
||||
FirstRun = source.FirstRun;
|
||||
CheckForUpdatesOnStartup = source.CheckForUpdatesOnStartup;
|
||||
VerboseLogging = source.VerboseLogging;
|
||||
InternalProgram = source.InternalProgram;
|
||||
|
||||
GUI.CopyUpdateUrlToClipboard = source.CopyUpdateUrlToClipboard;
|
||||
|
||||
GUI.DefaultInterfaceLanguage = source.DefaultInterfaceLanguage;
|
||||
GUI.ShowDebugViewMenuItem = source.ShowDebugViewMenuItem;
|
||||
GUI.OpenLogWindowAtStartup = source.OpenLogWindowAtStartup;
|
||||
GUI.Theming.EnableDarkMode = source.EnableDarkMode;
|
||||
GUI.Theming.EnablePurpMode = source.EnablePurpMode;
|
||||
GUI.Theming.CustomBackgroundColor = source.CustomBackgroundColor;
|
||||
GUI.Theming.CustomTextColor = source.CustomTextColor;
|
||||
|
||||
GUI.FastUpdateLabel = source.FastUpdateLabel;
|
||||
GUI.IgnoreFixedDrives = source.IgnoreFixedDrives;
|
||||
GUI.SkipSystemDetection = source.SkipSystemDetection;
|
||||
|
||||
Dumping.AaruPath = source.AaruPath ?? DumpSettings.DefaultAaruPath;
|
||||
Dumping.DiscImageCreatorPath = source.DiscImageCreatorPath ?? DumpSettings.DefaultDiscImageCreatorPath;
|
||||
// Dumping.DreamdumpPath = source.DreamdumpPath ?? DumpSettings.DefaultDreamdumpPath;
|
||||
Dumping.RedumperPath = source.RedumperPath ?? DumpSettings.DefaultRedumperPath;
|
||||
|
||||
Dumping.DefaultOutputPath = source.DefaultOutputPath;
|
||||
Dumping.DefaultSystem = source.DefaultSystem;
|
||||
|
||||
Dumping.DumpSpeeds.PreferredCD = source.PreferredDumpSpeedCD;
|
||||
Dumping.DumpSpeeds.PreferredDVD = source.PreferredDumpSpeedDVD;
|
||||
Dumping.DumpSpeeds.PreferredHDDVD = source.PreferredDumpSpeedHDDVD;
|
||||
Dumping.DumpSpeeds.PreferredBD = source.PreferredDumpSpeedBD;
|
||||
|
||||
Dumping.Aaru.EnableDebug = source.AaruEnableDebug;
|
||||
Dumping.Aaru.EnableVerbose = source.AaruEnableVerbose;
|
||||
Dumping.Aaru.ForceDumping = source.AaruForceDumping;
|
||||
Dumping.Aaru.RereadCount = source.AaruRereadCount;
|
||||
Dumping.Aaru.StripPersonalData = source.AaruStripPersonalData;
|
||||
|
||||
Dumping.DIC.MultiSectorRead = source.DICMultiSectorRead;
|
||||
Dumping.DIC.MultiSectorReadValue = source.DICMultiSectorReadValue;
|
||||
Dumping.DIC.ParanoidMode = source.DICParanoidMode;
|
||||
Dumping.DIC.QuietMode = source.DICQuietMode;
|
||||
Dumping.DIC.RereadCount = source.DICRereadCount;
|
||||
Dumping.DIC.DVDRereadCount = source.DICDVDRereadCount;
|
||||
Dumping.DIC.UseCMIFlag = source.DICUseCMIFlag;
|
||||
|
||||
// Dumping.Dreamdump.NonRedumpMode = source.DreamdumpNonRedumpMode;
|
||||
// Dumping.Dreamdump.SectorOrder = source.DreamdumpSectorOrder;
|
||||
// Dumping.Dreamdump.RereadCount = source.DreamdumpRereadCount;
|
||||
|
||||
Dumping.Redumper.EnableSkeleton = source.RedumperEnableSkeleton;
|
||||
Dumping.Redumper.EnableVerbose = source.RedumperEnableVerbose;
|
||||
Dumping.Redumper.LeadinRetryCount = source.RedumperLeadinRetryCount;
|
||||
Dumping.Redumper.NonRedumpMode = source.RedumperNonRedumpMode;
|
||||
Dumping.Redumper.DriveType = source.RedumperDriveType;
|
||||
Dumping.Redumper.DrivePregapStart = source.RedumperDrivePregapStart;
|
||||
Dumping.Redumper.ReadMethod = source.RedumperReadMethod;
|
||||
Dumping.Redumper.SectorOrder = source.RedumperSectorOrder;
|
||||
Dumping.Redumper.RereadCount = source.RedumperRereadCount;
|
||||
Dumping.Redumper.RefineSectorMode = source.RedumperRefineSectorMode;
|
||||
|
||||
Processing.ProtectionScanning.ScanForProtection = source.ScanForProtection;
|
||||
Processing.ProtectionScanning.ScanArchivesForProtection = source.ScanArchivesForProtection;
|
||||
Processing.ProtectionScanning.IncludeDebugProtectionInformation = source.IncludeDebugProtectionInformation;
|
||||
Processing.ProtectionScanning.HideDriveLetters = source.HideDriveLetters;
|
||||
|
||||
Processing.Login.RetrieveMatchInformation = source.RetrieveMatchInformation;
|
||||
Processing.Login.RedumpUsername = source.RedumpUsername;
|
||||
Processing.Login.RedumpPassword = source.RedumpPassword;
|
||||
|
||||
Processing.MediaInformation.AddPlaceholders = source.AddPlaceholders;
|
||||
Processing.MediaInformation.PromptForDiscInformation = source.PromptForDiscInformation;
|
||||
Processing.MediaInformation.PullAllInformation = source.PullAllInformation;
|
||||
Processing.MediaInformation.EnableTabsInInputFields = source.EnableTabsInInputFields;
|
||||
Processing.MediaInformation.EnableRedumpCompatibility = source.EnableRedumpCompatibility;
|
||||
|
||||
Processing.ShowDiscEjectReminder = source.ShowDiscEjectReminder;
|
||||
Processing.AddFilenameSuffix = source.AddFilenameSuffix;
|
||||
Processing.CreateIRDAfterDumping = source.CreateIRDAfterDumping;
|
||||
Processing.OutputSubmissionJSON = source.OutputSubmissionJSON;
|
||||
Processing.IncludeArtifacts = source.IncludeArtifacts;
|
||||
Processing.CompressLogFiles = source.CompressLogFiles;
|
||||
Processing.LogCompression = source.LogCompression;
|
||||
Processing.DeleteUnnecessaryFiles = source.DeleteUnnecessaryFiles;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Convert to an Options object
|
||||
/// Convert to a dictionary
|
||||
/// </summary>
|
||||
/// TODO: Remove when Options is no longer relevant
|
||||
internal Options ConvertToOptions()
|
||||
internal Dictionary<string, string?> ConvertToDictionary()
|
||||
{
|
||||
return new Options
|
||||
return new Dictionary<string, string?>
|
||||
{
|
||||
FirstRun = FirstRun,
|
||||
{ "FirstRun", FirstRun.ToString()},
|
||||
|
||||
AaruPath = Dumping.AaruPath,
|
||||
DiscImageCreatorPath = Dumping.DiscImageCreatorPath,
|
||||
// DreamdumpPath = Dumping.DreamdumpPath,
|
||||
RedumperPath = Dumping.RedumperPath,
|
||||
InternalProgram = InternalProgram,
|
||||
{ "AaruPath", Dumping.AaruPath },
|
||||
{ "DiscImageCreatorPath", Dumping.DiscImageCreatorPath },
|
||||
{ "DreamdumpPath", Dumping.DreamdumpPath },
|
||||
{ "RedumperPath", Dumping.RedumperPath },
|
||||
{ "InternalProgram", InternalProgram.ToString() },
|
||||
|
||||
EnableDarkMode = GUI.Theming.EnableDarkMode,
|
||||
EnablePurpMode = GUI.Theming.EnablePurpMode,
|
||||
CustomBackgroundColor = GUI.Theming.CustomBackgroundColor,
|
||||
CustomTextColor = GUI.Theming.CustomTextColor,
|
||||
CheckForUpdatesOnStartup = CheckForUpdatesOnStartup,
|
||||
CopyUpdateUrlToClipboard = GUI.CopyUpdateUrlToClipboard,
|
||||
FastUpdateLabel = GUI.FastUpdateLabel,
|
||||
DefaultInterfaceLanguage = GUI.DefaultInterfaceLanguage,
|
||||
DefaultOutputPath = Dumping.DefaultOutputPath,
|
||||
DefaultSystem = Dumping.DefaultSystem,
|
||||
ShowDebugViewMenuItem = GUI.ShowDebugViewMenuItem,
|
||||
{ "EnableDarkMode", GUI.Theming.EnableDarkMode.ToString() },
|
||||
{ "EnablePurpMode", GUI.Theming.EnablePurpMode.ToString() },
|
||||
{ "CustomBackgroundColor", GUI.Theming.CustomBackgroundColor },
|
||||
{ "CustomTextColor", GUI.Theming.CustomTextColor },
|
||||
{ "CheckForUpdatesOnStartup", CheckForUpdatesOnStartup.ToString() },
|
||||
{ "CopyUpdateUrlToClipboard", GUI.CopyUpdateUrlToClipboard.ToString() },
|
||||
{ "FastUpdateLabel", GUI.FastUpdateLabel.ToString() },
|
||||
{ "DefaultInterfaceLanguage", GUI.DefaultInterfaceLanguage.ShortName() },
|
||||
{ "DefaultOutputPath", Dumping.DefaultOutputPath },
|
||||
{ "DefaultSystem", Dumping.DefaultSystem.ToString() },
|
||||
{ "ShowDebugViewMenuItem", GUI.ShowDebugViewMenuItem.ToString() },
|
||||
|
||||
PreferredDumpSpeedCD = Dumping.DumpSpeeds.PreferredCD,
|
||||
PreferredDumpSpeedDVD = Dumping.DumpSpeeds.PreferredDVD,
|
||||
PreferredDumpSpeedHDDVD = Dumping.DumpSpeeds.PreferredHDDVD,
|
||||
PreferredDumpSpeedBD = Dumping.DumpSpeeds.PreferredBD,
|
||||
{ "PreferredDumpSpeedCD", Dumping.DumpSpeeds.PreferredCD.ToString() },
|
||||
{ "PreferredDumpSpeedDVD", Dumping.DumpSpeeds.PreferredDVD.ToString() },
|
||||
{ "PreferredDumpSpeedHDDVD", Dumping.DumpSpeeds.PreferredHDDVD.ToString() },
|
||||
{ "PreferredDumpSpeedBD", Dumping.DumpSpeeds.PreferredBD.ToString() },
|
||||
|
||||
AaruEnableDebug = Dumping.Aaru.EnableDebug,
|
||||
AaruEnableVerbose = Dumping.Aaru.EnableVerbose,
|
||||
AaruForceDumping = Dumping.Aaru.ForceDumping,
|
||||
AaruRereadCount = Dumping.Aaru.RereadCount,
|
||||
AaruStripPersonalData = Dumping.Aaru.StripPersonalData,
|
||||
{ AaruConstants.EnableDebug, Dumping.Aaru.EnableDebug.ToString() },
|
||||
{ AaruConstants.EnableVerbose, Dumping.Aaru.EnableVerbose.ToString() },
|
||||
{ AaruConstants.ForceDumping, Dumping.Aaru.ForceDumping.ToString() },
|
||||
{ AaruConstants.RereadCount, Dumping.Aaru.RereadCount.ToString() },
|
||||
{ AaruConstants.StripPersonalData, Dumping.Aaru.StripPersonalData.ToString() },
|
||||
|
||||
DICMultiSectorRead = Dumping.DIC.MultiSectorRead,
|
||||
DICMultiSectorReadValue = Dumping.DIC.MultiSectorReadValue,
|
||||
DICParanoidMode = Dumping.DIC.ParanoidMode,
|
||||
DICQuietMode = Dumping.DIC.QuietMode,
|
||||
DICRereadCount = Dumping.DIC.RereadCount,
|
||||
DICDVDRereadCount = Dumping.DIC.DVDRereadCount,
|
||||
DICUseCMIFlag = Dumping.DIC.UseCMIFlag,
|
||||
{ DiscImageCreatorConstants.MultiSectorRead, Dumping.DIC.MultiSectorRead.ToString() },
|
||||
{ DiscImageCreatorConstants.MultiSectorReadValue, Dumping.DIC.MultiSectorReadValue.ToString() },
|
||||
{ DiscImageCreatorConstants.ParanoidMode, Dumping.DIC.ParanoidMode.ToString() },
|
||||
{ DiscImageCreatorConstants.QuietMode, Dumping.DIC.QuietMode.ToString() },
|
||||
{ DiscImageCreatorConstants.RereadCount, Dumping.DIC.RereadCount.ToString() },
|
||||
{ DiscImageCreatorConstants.DVDRereadCount, Dumping.DIC.DVDRereadCount.ToString() },
|
||||
{ DiscImageCreatorConstants.UseCMIFlag, Dumping.DIC.UseCMIFlag.ToString() },
|
||||
|
||||
// DreamdumpNonRedumpMode = Dumping.Dreamdump.NonRedumpMode,
|
||||
// DreamdumpSectorOrder = Dumping.Dreamdump.SectorOrder,
|
||||
// DreamdumpRereadCount = Dumping.Dreamdump.RereadCount,
|
||||
{ "DreamdumpNonRedumpMode", Dumping.Dreamdump.NonRedumpMode.ToString() },
|
||||
{ DreamdumpConstants.SectorOrder, Dumping.Dreamdump.SectorOrder.ToString() },
|
||||
{ DreamdumpConstants.RereadCount, Dumping.Dreamdump.RereadCount.ToString() },
|
||||
|
||||
RedumperEnableSkeleton = Dumping.Redumper.EnableSkeleton,
|
||||
RedumperEnableVerbose = Dumping.Redumper.EnableVerbose,
|
||||
RedumperLeadinRetryCount = Dumping.Redumper.LeadinRetryCount,
|
||||
RedumperNonRedumpMode = Dumping.Redumper.NonRedumpMode,
|
||||
RedumperDriveType = Dumping.Redumper.DriveType,
|
||||
RedumperDrivePregapStart = Dumping.Redumper.DrivePregapStart,
|
||||
RedumperReadMethod = Dumping.Redumper.ReadMethod,
|
||||
RedumperSectorOrder = Dumping.Redumper.SectorOrder,
|
||||
RedumperRereadCount = Dumping.Redumper.RereadCount,
|
||||
RedumperRefineSectorMode = Dumping.Redumper.RefineSectorMode,
|
||||
{ RedumperConstants.EnableSkeleton, Dumping.Redumper.EnableSkeleton.ToString() },
|
||||
{ RedumperConstants.EnableVerbose, Dumping.Redumper.EnableVerbose.ToString() },
|
||||
{ RedumperConstants.LeadinRetryCount, Dumping.Redumper.LeadinRetryCount.ToString() },
|
||||
{ "RedumperNonRedumpMode", Dumping.Redumper.NonRedumpMode.ToString() },
|
||||
{ RedumperConstants.DriveType, Dumping.Redumper.DriveType.ToString() },
|
||||
{ RedumperConstants.DrivePregapStart, Dumping.Redumper.DrivePregapStart.ToString() },
|
||||
{ RedumperConstants.ReadMethod, Dumping.Redumper.ReadMethod.ToString() },
|
||||
{ RedumperConstants.SectorOrder, Dumping.Redumper.SectorOrder.ToString() },
|
||||
{ RedumperConstants.RereadCount, Dumping.Redumper.RereadCount.ToString() },
|
||||
{ RedumperConstants.RefineSectorMode, Dumping.Redumper.RefineSectorMode.ToString() },
|
||||
|
||||
ScanForProtection = Processing.ProtectionScanning.ScanForProtection,
|
||||
AddPlaceholders = Processing.MediaInformation.AddPlaceholders,
|
||||
PromptForDiscInformation = Processing.MediaInformation.PromptForDiscInformation,
|
||||
PullAllInformation = Processing.MediaInformation.PullAllInformation,
|
||||
EnableTabsInInputFields = Processing.MediaInformation.EnableTabsInInputFields,
|
||||
EnableRedumpCompatibility = Processing.MediaInformation.EnableRedumpCompatibility,
|
||||
ShowDiscEjectReminder = Processing.ShowDiscEjectReminder,
|
||||
IgnoreFixedDrives = GUI.IgnoreFixedDrives,
|
||||
AddFilenameSuffix = Processing.AddFilenameSuffix,
|
||||
OutputSubmissionJSON = Processing.OutputSubmissionJSON,
|
||||
IncludeArtifacts = Processing.IncludeArtifacts,
|
||||
CompressLogFiles = Processing.CompressLogFiles,
|
||||
LogCompression = Processing.LogCompression,
|
||||
DeleteUnnecessaryFiles = Processing.DeleteUnnecessaryFiles,
|
||||
CreateIRDAfterDumping = Processing.CreateIRDAfterDumping,
|
||||
{ "ScanForProtection", Processing.ProtectionScanning.ScanForProtection.ToString() },
|
||||
{ "AddPlaceholders", Processing.MediaInformation.AddPlaceholders.ToString() },
|
||||
{ "PromptForDiscInformation", Processing.MediaInformation.PromptForDiscInformation.ToString() },
|
||||
{ "PullAllInformation", Processing.MediaInformation.PullAllInformation.ToString() },
|
||||
{ "EnableTabsInInputFields", Processing.MediaInformation.EnableTabsInInputFields.ToString() },
|
||||
{ "EnableRedumpCompatibility", Processing.MediaInformation.EnableRedumpCompatibility.ToString() },
|
||||
{ "ShowDiscEjectReminder", Processing.ShowDiscEjectReminder.ToString() },
|
||||
{ "IgnoreFixedDrives", GUI.IgnoreFixedDrives.ToString() },
|
||||
{ "AddFilenameSuffix", Processing.AddFilenameSuffix.ToString() },
|
||||
{ "OutputSubmissionJSON", Processing.OutputSubmissionJSON.ToString() },
|
||||
{ "IncludeArtifacts", Processing.IncludeArtifacts.ToString() },
|
||||
{ "CompressLogFiles", Processing.CompressLogFiles.ToString() },
|
||||
{ "LogCompression", Processing.LogCompression.ToString() },
|
||||
{ "DeleteUnnecessaryFiles", Processing.DeleteUnnecessaryFiles.ToString() },
|
||||
{ "CreateIRDAfterDumping", Processing.CreateIRDAfterDumping.ToString() },
|
||||
|
||||
SkipSystemDetection = GUI.SkipSystemDetection,
|
||||
{ "SkipSystemDetection", GUI.SkipSystemDetection.ToString() },
|
||||
|
||||
ScanArchivesForProtection = Processing.ProtectionScanning.ScanArchivesForProtection,
|
||||
IncludeDebugProtectionInformation = Processing.ProtectionScanning.IncludeDebugProtectionInformation,
|
||||
HideDriveLetters = Processing.ProtectionScanning.HideDriveLetters,
|
||||
{ "ScanArchivesForProtection", Processing.ProtectionScanning.ScanArchivesForProtection.ToString() },
|
||||
{ "IncludeDebugProtectionInformation", Processing.ProtectionScanning.IncludeDebugProtectionInformation.ToString() },
|
||||
{ "HideDriveLetters", Processing.ProtectionScanning.HideDriveLetters.ToString() },
|
||||
|
||||
VerboseLogging = VerboseLogging,
|
||||
OpenLogWindowAtStartup = GUI.OpenLogWindowAtStartup,
|
||||
{ "VerboseLogging", VerboseLogging.ToString() },
|
||||
{ "OpenLogWindowAtStartup", GUI.OpenLogWindowAtStartup.ToString() },
|
||||
|
||||
RetrieveMatchInformation = Processing.Login.RetrieveMatchInformation,
|
||||
RedumpUsername = Processing.Login.RedumpUsername,
|
||||
RedumpPassword = Processing.Login.RedumpPassword,
|
||||
{ "RetrieveMatchInformation", Processing.Login.RetrieveMatchInformation.ToString() },
|
||||
{ "RedumpUsername", Processing.Login.RedumpUsername },
|
||||
{ "RedumpPassword", Processing.Login.RedumpPassword },
|
||||
};
|
||||
}
|
||||
|
||||
#region Helpers
|
||||
|
||||
/// <summary>
|
||||
/// Get a Boolean setting from a settings, dictionary
|
||||
/// </summary>
|
||||
/// <param name="settings">Dictionary representing the settings</param>
|
||||
/// <param name="key">Setting key to get a value for</param>
|
||||
/// <param name="defaultValue">Default value to return if no value is found</param>
|
||||
/// <returns>Setting value if possible, default value otherwise</returns>
|
||||
internal static bool GetBooleanSetting(Dictionary<string, string?> settings, string key, bool defaultValue)
|
||||
{
|
||||
if (settings.ContainsKey(key))
|
||||
{
|
||||
if (bool.TryParse(settings[key], out bool value))
|
||||
return value;
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get an Int32 setting from a settings, dictionary
|
||||
/// </summary>
|
||||
/// <param name="settings">Dictionary representing the settings</param>
|
||||
/// <param name="key">Setting key to get a value for</param>
|
||||
/// <param name="defaultValue">Default value to return if no value is found</param>
|
||||
/// <returns>Setting value if possible, default value otherwise</returns>
|
||||
internal static int GetInt32Setting(Dictionary<string, string?> settings, string key, int defaultValue)
|
||||
{
|
||||
if (settings.ContainsKey(key))
|
||||
{
|
||||
if (int.TryParse(settings[key], out int value))
|
||||
return value;
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a String setting from a settings, dictionary
|
||||
/// </summary>
|
||||
/// <param name="settings">Dictionary representing the settings</param>
|
||||
/// <param name="key">Setting key to get a value for</param>
|
||||
/// <param name="defaultValue">Default value to return if no value is found</param>
|
||||
/// <returns>Setting value if possible, default value otherwise</returns>
|
||||
internal static string? GetStringSetting(Dictionary<string, string?> settings, string key, string? defaultValue)
|
||||
{
|
||||
if (settings.ContainsKey(key))
|
||||
return settings[key];
|
||||
else
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Nested Option Types
|
||||
@@ -811,7 +875,7 @@ namespace MPF.Frontend
|
||||
/// Compression type used during log compression
|
||||
/// </summary>
|
||||
/// <remarks>Version 1 and greater</remarks>
|
||||
public Processors.LogCompression LogCompression { get; set; } = Processors.LogCompression.DeflateMaximum;
|
||||
public LogCompression LogCompression { get; set; } = LogCompression.DeflateMaximum;
|
||||
|
||||
/// <summary>
|
||||
/// Delete unnecessary files to reduce space
|
||||
|
||||
@@ -234,31 +234,12 @@ namespace MPF.Frontend.Tools
|
||||
if (string.IsNullOrEmpty(ConfigurationPath))
|
||||
return;
|
||||
|
||||
// Convert to an Options object
|
||||
var tempOptions = options.ConvertToOptions();
|
||||
|
||||
// Ensure default values are included
|
||||
PropertyInfo[] properties = typeof(Options).GetProperties();
|
||||
foreach (var property in properties)
|
||||
{
|
||||
// Skip dictionary properties
|
||||
if (property.Name == "Item")
|
||||
continue;
|
||||
|
||||
// Skip non-option properties
|
||||
if (property.Name == "Settings" || property.Name == "HasRedumpLogin")
|
||||
continue;
|
||||
|
||||
var val = property.GetValue(tempOptions, null);
|
||||
property.SetValue(tempOptions, val, null);
|
||||
}
|
||||
|
||||
var serializer = JsonSerializer.Create();
|
||||
var stream = File.Open(ConfigurationPath, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
using var sw = new StreamWriter(stream) { AutoFlush = true };
|
||||
var writer = new JsonTextWriter(sw) { Formatting = Formatting.Indented };
|
||||
|
||||
serializer.Serialize(writer, tempOptions.Settings, typeof(Dictionary<string, string>));
|
||||
serializer.Serialize(writer, options.ConvertToDictionary(), typeof(Dictionary<string, string>));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -275,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);
|
||||
serializer.Serialize(writer, options, typeof(SegmentedOptions));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user