mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
One more pass on options
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
- Add user-selectable Language Selection via dropdown in disc submission window for PS2
|
||||
- Separate out Aaru- and DIC-specific settings
|
||||
- Add new options based on original "Paranoid Mode" mega-option
|
||||
- Internal overhaul of options and dump environment
|
||||
|
||||
### 1.18 (2020-11-10)
|
||||
- Add more information extraction and generation for Aaru
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace MPF.Check
|
||||
// TODO: Replace this with Dictionary constructor
|
||||
var options = new Options
|
||||
{
|
||||
InternalProgram = internalProgram,
|
||||
InternalProgram = Converters.ToInternalProgram(internalProgram),
|
||||
ScanForProtection = scan && !string.IsNullOrWhiteSpace(path),
|
||||
PromptForDiscInformation = false,
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MPF.Utilities;
|
||||
|
||||
namespace MPF.Data
|
||||
{
|
||||
@@ -40,10 +41,18 @@ namespace MPF.Data
|
||||
/// <summary>
|
||||
/// Currently selected dumping program
|
||||
/// </summary>
|
||||
public string InternalProgram
|
||||
public InternalProgram InternalProgram
|
||||
{
|
||||
get { return GetStringSetting(_settings, "InternalProgram", Data.InternalProgram.DiscImageCreator.ToString()); }
|
||||
set { _settings["InternalProgram"] = value; }
|
||||
get
|
||||
{
|
||||
string valueString = GetStringSetting(_settings, "InternalProgram", InternalProgram.DiscImageCreator.ToString());
|
||||
var valueEnum = Converters.ToInternalProgram(valueString);
|
||||
return valueEnum == InternalProgram.NONE ? InternalProgram.DiscImageCreator : valueEnum;
|
||||
}
|
||||
set
|
||||
{
|
||||
_settings["InternalProgram"] = value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -50,11 +50,6 @@ namespace MPF.Utilities
|
||||
/// </summary>
|
||||
public MediaType? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Internal program to run
|
||||
/// </summary>
|
||||
public InternalProgram InternalProgram { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Options object representing user-defined options
|
||||
/// </summary>
|
||||
@@ -97,13 +92,9 @@ namespace MPF.Utilities
|
||||
this.System = system;
|
||||
this.Type = type;
|
||||
|
||||
this.InternalProgram = Converters.ToInternalProgram(options.InternalProgram);
|
||||
|
||||
SetParameters(parameters);
|
||||
this.Parameters.System = system;
|
||||
this.Parameters.Type = type;
|
||||
|
||||
SetInternalToolPath();
|
||||
}
|
||||
|
||||
#region Public Functionality
|
||||
@@ -114,77 +105,43 @@ namespace MPF.Utilities
|
||||
/// <param name="parameters">String representation of the parameters</param>
|
||||
public void SetParameters(string parameters)
|
||||
{
|
||||
switch (this.InternalProgram)
|
||||
switch (Options.InternalProgram)
|
||||
{
|
||||
// Dumping support
|
||||
case InternalProgram.Aaru:
|
||||
this.Parameters = new Aaru.Parameters(parameters);
|
||||
break;
|
||||
|
||||
case InternalProgram.DD:
|
||||
this.Parameters = new DD.Parameters(parameters);
|
||||
break;
|
||||
|
||||
case InternalProgram.DiscImageCreator:
|
||||
this.Parameters = new DiscImageCreator.Parameters(parameters);
|
||||
break;
|
||||
|
||||
// Verification support only
|
||||
case InternalProgram.CleanRip:
|
||||
this.Parameters = new CleanRip.Parameters(parameters);
|
||||
break;
|
||||
|
||||
case InternalProgram.DCDumper:
|
||||
this.Parameters = null; // TODO: Create correct parameter type when supported
|
||||
break;
|
||||
|
||||
case InternalProgram.UmdImageCreator:
|
||||
this.Parameters = new UmdImageCreator.Parameters(parameters);
|
||||
break;
|
||||
|
||||
// This should never happen, but it needs a fallback
|
||||
default:
|
||||
this.Parameters = new DiscImageCreator.Parameters(parameters);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the path on the parameters object based on the intermal program
|
||||
/// </summary>
|
||||
public void SetInternalToolPath()
|
||||
{
|
||||
switch (this.InternalProgram)
|
||||
{
|
||||
// Dumping support
|
||||
case InternalProgram.Aaru:
|
||||
this.Parameters.ExecutablePath = Options.AaruPath;
|
||||
break;
|
||||
|
||||
case InternalProgram.DD:
|
||||
this.Parameters = new DD.Parameters(parameters);
|
||||
this.Parameters.ExecutablePath = Options.DDPath;
|
||||
break;
|
||||
|
||||
case InternalProgram.DiscImageCreator:
|
||||
this.Parameters = new DiscImageCreator.Parameters(parameters);
|
||||
this.Parameters.ExecutablePath = Options.DiscImageCreatorPath;
|
||||
break;
|
||||
|
||||
// Verification support only
|
||||
case InternalProgram.CleanRip:
|
||||
this.Parameters = new CleanRip.Parameters(parameters);
|
||||
this.Parameters.ExecutablePath = null;
|
||||
break;
|
||||
|
||||
case InternalProgram.DCDumper:
|
||||
this.Parameters = null; // TODO: Create correct parameter type when supported
|
||||
this.Parameters.ExecutablePath = null;
|
||||
break;
|
||||
|
||||
case InternalProgram.UmdImageCreator:
|
||||
this.Parameters = new UmdImageCreator.Parameters(parameters);
|
||||
this.Parameters.ExecutablePath = null;
|
||||
break;
|
||||
|
||||
// This should never happen, but it needs a fallback
|
||||
default:
|
||||
this.InternalProgram = InternalProgram.DiscImageCreator;
|
||||
this.Parameters = new DiscImageCreator.Parameters(parameters);
|
||||
this.Parameters.ExecutablePath = Options.DiscImageCreatorPath;
|
||||
break;
|
||||
}
|
||||
@@ -309,7 +266,7 @@ namespace MPF.Utilities
|
||||
/// <returns></returns>
|
||||
public string GetExtension(MediaType? mediaType)
|
||||
{
|
||||
switch (this.InternalProgram)
|
||||
switch (Options.InternalProgram)
|
||||
{
|
||||
case InternalProgram.Aaru:
|
||||
return Aaru.Converters.Extension(mediaType);
|
||||
@@ -342,7 +299,7 @@ namespace MPF.Utilities
|
||||
|
||||
// Set the proper parameters
|
||||
string filename = OutputDirectory + Path.DirectorySeparatorChar + OutputFilename;
|
||||
switch (InternalProgram)
|
||||
switch (Options.InternalProgram)
|
||||
{
|
||||
case InternalProgram.Aaru:
|
||||
Parameters = new Aaru.Parameters(System, Type, Drive.Letter, filename, driveSpeed, Options);
|
||||
@@ -411,10 +368,10 @@ namespace MPF.Utilities
|
||||
return result;
|
||||
|
||||
// Execute internal tool
|
||||
progress?.Report(Result.Success($"Executing {this.InternalProgram}... please wait!"));
|
||||
progress?.Report(Result.Success($"Executing {Options.InternalProgram}... please wait!"));
|
||||
Directory.CreateDirectory(OutputDirectory);
|
||||
await Task.Run(() => Parameters.ExecuteInternalProgram());
|
||||
progress?.Report(Result.Success($"{this.InternalProgram} has finished!"));
|
||||
progress?.Report(Result.Success($"{Options.InternalProgram} has finished!"));
|
||||
|
||||
// Execute additional tools
|
||||
progress?.Report(Result.Success("Running any additional tools... please wait!"));
|
||||
@@ -455,7 +412,7 @@ namespace MPF.Utilities
|
||||
}
|
||||
|
||||
// Reset the drive automatically if confugured to
|
||||
if (InternalProgram == InternalProgram.DiscImageCreator && Options.DICResetDriveAfterDump)
|
||||
if (Options.InternalProgram == InternalProgram.DiscImageCreator && Options.DICResetDriveAfterDump)
|
||||
{
|
||||
resultProgress?.Report(Result.Success($"Resetting drive {Drive.Letter}"));
|
||||
ResetDrive();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace MPF.Test
|
||||
[InlineData("stop D", 'D', false, MediaType.DVD, true)]
|
||||
public void ParametersValidTest(string parameters, char letter, bool isFloppy, MediaType? mediaType, bool expected)
|
||||
{
|
||||
var options = new Options() { InternalProgram = "dic" };
|
||||
var options = new Options() { InternalProgram = InternalProgram.DiscImageCreator };
|
||||
var drive = isFloppy
|
||||
? new Drive(InternalDriveType.Floppy, new DriveInfo(letter.ToString()))
|
||||
: new Drive(InternalDriveType.Optical, new DriveInfo(letter.ToString()));
|
||||
@@ -38,7 +38,7 @@ namespace MPF.Test
|
||||
[InlineData("superhero", "blah&foo.bin", "superhero", "blah&foo.bin")]
|
||||
public void FixOutputPathsTest(string outputDirectory, string outputFilename, string expectedOutputDirectory, string expectedOutputFilename)
|
||||
{
|
||||
var options = new Options() { InternalProgram = "dic" };
|
||||
var options = new Options() { InternalProgram = InternalProgram.DiscImageCreator };
|
||||
var env = new DumpEnvironment(options, outputDirectory, outputFilename, null, KnownSystem.IBMPCCompatible, MediaType.CDROM, string.Empty);
|
||||
|
||||
env.FixOutputPaths();
|
||||
|
||||
@@ -459,7 +459,7 @@ namespace MPF.Windows
|
||||
string protections = await Validators.RunProtectionScanOnPath(drive.Letter + ":\\", progress);
|
||||
|
||||
// If SmartE is detected on the current disc, remove `/sf` from the flags for DIC only
|
||||
if (Env.InternalProgram == InternalProgram.DiscImageCreator && protections.Contains("SmartE"))
|
||||
if (Env.Options.InternalProgram == InternalProgram.DiscImageCreator && protections.Contains("SmartE"))
|
||||
{
|
||||
((DiscImageCreator.Parameters)Env.Parameters)[DiscImageCreator.Flag.ScanFileProtect] = false;
|
||||
LogOutput.VerboseLogLn($"SmartE detected, removing {DiscImageCreator.FlagStrings.ScanFileProtect} from parameters");
|
||||
@@ -748,8 +748,7 @@ namespace MPF.Windows
|
||||
/// <summary>
|
||||
/// Handler for DiscInformationWindow OnUpdated event
|
||||
/// </summary>
|
||||
/// <remarks>Identical to MediaScanButtonClick</remarks>
|
||||
public void OnOptionsUpdated()
|
||||
private void OnOptionsUpdated(object sender, EventArgs e)
|
||||
{
|
||||
InitializeUIValues(removeEventHandlers: true, rescanDrives: true);
|
||||
}
|
||||
@@ -760,10 +759,10 @@ namespace MPF.Windows
|
||||
private void OptionsMenuItemClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Show the window and wait for the response
|
||||
var optionsWindow = new OptionsWindow();
|
||||
optionsWindow.UIOptions = UIOptions;
|
||||
var optionsWindow = new OptionsWindow(UIOptions);
|
||||
optionsWindow.Owner = this;
|
||||
optionsWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
optionsWindow.Closed += OnOptionsUpdated;
|
||||
optionsWindow.Refresh();
|
||||
optionsWindow.Show();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<Button x:Name="DDPathButton" Grid.Row="2" Grid.Column="2" Height="22" Width="22" Content="..." Click="BrowseForPathClick" />
|
||||
|
||||
<Label Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Content="Dumping Program" />
|
||||
<ComboBox x:Name="InternalProgramComboBox" Grid.Row="3" Grid.Column="1" Height="22" HorizontalAlignment="Stretch" >
|
||||
<ComboBox x:Name="InternalProgramComboBox" Grid.Row="3" Grid.Column="1" Height="22" HorizontalAlignment="Stretch" ItemsSource="{Binding Path=InternalPrograms}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Path=Name}" />
|
||||
@@ -250,7 +250,7 @@
|
||||
<UniformGrid Columns="4" Margin="5,5,5,5" Height="28">
|
||||
<Label/> <!-- Empty label for padding -->
|
||||
<Button Name="AcceptButton" Height="25" Width="80" Content="Accept" Click="OnAcceptClick" />
|
||||
<Button Name="CancelButton" Height="25" Width="80" Content="Cancel" Click="OnCancelClick" />
|
||||
<Label/> <!-- Empty label for padding -->
|
||||
<Label/> <!-- Empty label for padding -->
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using MPF.Data;
|
||||
using MPF.Redump;
|
||||
using MPF.Utilities;
|
||||
using Button = System.Windows.Controls.Button;
|
||||
using TextBox = System.Windows.Controls.TextBox;
|
||||
|
||||
@@ -30,11 +30,12 @@ namespace MPF.Windows
|
||||
|
||||
#endregion
|
||||
|
||||
public OptionsWindow()
|
||||
public OptionsWindow(UIOptions uiOptions)
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
|
||||
UIOptions = uiOptions;
|
||||
PopulateInternalPrograms();
|
||||
}
|
||||
|
||||
@@ -63,16 +64,9 @@ namespace MPF.Windows
|
||||
/// </summary>
|
||||
private void PopulateInternalPrograms()
|
||||
{
|
||||
// We only support certain programs for dumping
|
||||
var internalPrograms = new List<InternalProgram> { InternalProgram.DiscImageCreator, InternalProgram.Aaru, InternalProgram.DD };
|
||||
InternalPrograms = new List<Element<InternalProgram>>();
|
||||
foreach (var internalProgram in internalPrograms)
|
||||
{
|
||||
InternalPrograms.Add(new Element<InternalProgram>(internalProgram));
|
||||
}
|
||||
|
||||
InternalProgramComboBox.ItemsSource = InternalPrograms;
|
||||
InternalProgramComboBox.SelectedIndex = 0;
|
||||
InternalPrograms = internalPrograms.Select(ip => new Element<InternalProgram>(ip)).ToList();
|
||||
InternalProgramComboBox.SelectedIndex = InternalPrograms.FindIndex(r => r == UIOptions.Options.InternalProgram);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -80,8 +74,6 @@ namespace MPF.Windows
|
||||
/// </summary>
|
||||
public void Refresh()
|
||||
{
|
||||
// Handle non-bindable fields
|
||||
InternalProgramComboBox.SelectedIndex = InternalPrograms.FindIndex(r => r == Converters.ToInternalProgram(UIOptions.Options.InternalProgram));
|
||||
RedumpPasswordBox.Password = UIOptions.Options.RedumpPassword;
|
||||
}
|
||||
|
||||
@@ -155,22 +147,12 @@ namespace MPF.Windows
|
||||
private void OnAcceptClick(object sender, EventArgs e)
|
||||
{
|
||||
// Handle non-bindable fields
|
||||
UIOptions.Options.InternalProgram = (InternalProgramComboBox.SelectedItem as Element<InternalProgram>)?.Name ?? InternalProgram.DiscImageCreator.ToString();
|
||||
var selectedInternalProgram = InternalProgramComboBox.SelectedItem as Element<InternalProgram>;
|
||||
UIOptions.Options.InternalProgram = selectedInternalProgram?.Value ?? InternalProgram.DiscImageCreator;
|
||||
UIOptions.Options.RedumpPassword = RedumpPasswordBox.Password;
|
||||
|
||||
UIOptions.Save();
|
||||
Hide();
|
||||
|
||||
(Owner as MainWindow).OnOptionsUpdated();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for CancelButton Click event
|
||||
/// </summary>
|
||||
private void OnCancelClick(object sender, EventArgs e)
|
||||
{
|
||||
// just hide the window and don't care
|
||||
Hide();
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user