Added new options (#90)

* Split type combobox into system combobox and disc type combobox

* corrected indentation for xaml file

* fixed merge with head

* fixed format

* fixed issues for PR, added KnownSystem.CUSTOM

* removed Updater.cs which ended by error in commit

* fixed GetOuptutName() for new drive/system combobox

* added 4 new options: quiet mode, paranoid mode, disable media type detect and c2 reread amount

* added default C2 reread tries to config

* fixed issues for PR

* removed commented leftover
This commit is contained in:
Jacopo Santoni
2018-07-10 01:35:46 +02:00
committed by Matt Nadareski
parent 6141ce8539
commit d51adccab4
12 changed files with 195 additions and 36 deletions

View File

@@ -92,20 +92,28 @@ namespace DICUI.Test.Utilities
}
[Theory]
[InlineData(KnownSystem.AppleMacintosh, MediaType.CD, new string[] { DICFlags.C2Opcode, "20", DICFlags.NoFixSubQSecuROM, DICFlags.ScanFileProtect })]
[InlineData(KnownSystem.AppleMacintosh, MediaType.LaserDisc, null)]
[InlineData(KnownSystem.NintendoGameCube, MediaType.GameCubeGameDisc, new string[] { DICFlags.Raw })]
[InlineData(KnownSystem.IBMPCCompatible, MediaType.DVD, new string[] { })]
public void KnownSystemAndMediaTypeToParametersTest(KnownSystem? knownSystem, MediaType? mediaType, string[] expected)
[InlineData(KnownSystem.AppleMacintosh, MediaType.LaserDisc, true, 20, null)]
[InlineData(KnownSystem.NintendoGameCube, MediaType.GameCubeGameDisc, false, 20, new string[] { DICFlags.Raw })]
[InlineData(KnownSystem.IBMPCCompatible, MediaType.DVD, false, 20, new string[] { })]
/* paranoid mode tests */
[InlineData(KnownSystem.IBMPCCompatible, MediaType.CD, true, 1000, new string[] { DICFlags.C2Opcode, "1000", DICFlags.NoFixSubQSecuROM, DICFlags.ScanFileProtect, DICFlags.ScanSectorProtect, DICFlags.SubchannelReadLevel, "2"})]
[InlineData(KnownSystem.AppleMacintosh, MediaType.CD, false, 20, new string[] { DICFlags.C2Opcode, "20", DICFlags.NoFixSubQSecuROM, DICFlags.ScanFileProtect })]
[InlineData(KnownSystem.IBMPCCompatible, MediaType.DVD, true, 500, new string[] { DICFlags.CMI })]
[InlineData(KnownSystem.HDDVDVideo, MediaType.HDDVD, true, 500, new string[] { DICFlags.CMI })]
[InlineData(KnownSystem.IBMPCCompatible, MediaType.DVD, false, 500, new string[] { })]
[InlineData(KnownSystem.HDDVDVideo, MediaType.HDDVD, false, 500, new string[] { })]
/* reread c2 */
[InlineData(KnownSystem.SegaDreamcast, MediaType.GDROM, false, 1000, new string[] { DICFlags.C2Opcode, "1000", })]
[InlineData(KnownSystem.SegaDreamcast, MediaType.GDROM, false, -1, new string[] { DICFlags.C2Opcode })]
public void KnownSystemAndMediaTypeToParametersTest(KnownSystem? knownSystem, MediaType? mediaType, bool paranoid, int rereadC2, string[] expected)
{
List<string> actual = Converters.KnownSystemAndMediaTypeToParameters(knownSystem, mediaType);
List<string> actual = Converters.KnownSystemAndMediaTypeToParameters(knownSystem, mediaType, paranoid, rereadC2);
if (expected == null)
Assert.Null(actual);
HashSet<string> expectedSet = expected != null ? new HashSet<string>(expected) : null;
HashSet<string> actualSet = actual != null ? new HashSet<string>(actual) : null;
else
foreach (string param in expected)
Assert.Contains(param, actual);
Assert.Equal(expectedSet, actualSet);
}
[Theory]

View File

@@ -23,7 +23,7 @@ namespace DICUI.Test.Utilities
[Fact]
public void CreateListOfSystemsTest()
{
int expected = Enum.GetValues(typeof(KnownSystem)).Length - 4; // - 4 for markers categories
int expected = Enum.GetValues(typeof(KnownSystem)).Length - 5; // - 4 -1 for markers categories and KnownSystem.NONE
var actual = Validators.CreateListOfSystems();
Assert.Equal(expected, actual.Count);
}

View File

@@ -6,5 +6,7 @@
<add key="DefaultOutputPath" value="ISO"/>
<add key="preferredDumpSpeedCD" value="72"/>
<add key="preferredDumpSpeedDVD" value="24"/>
<add key="QuietMode" value="false"/>
<add key="RereadAmountForC2" value="20"/>
</appSettings>
</configuration>

View File

@@ -103,6 +103,7 @@
<Compile Include="External\ProtectionFind.cs" />
<Compile Include="UI\KnownSystemComboBoxItem.cs" />
<Compile Include="UI\AllowedSpeeds.cs" />
<Compile Include="UI\ViewModels.cs" />
<Compile Include="Utilities\DumpEnvironment.cs" />
<Compile Include="Utilities\Extensions.cs" />
<Compile Include="Utilities\Result.cs" />

View File

@@ -6,6 +6,7 @@
xmlns:local="clr-namespace:DICUI"
xmlns:utilities="clr-namespace:DICUI.Utilities"
mc:Ignorable="d"
x:Name="mainWindow"
Title="Disc Image Creator GUI" Height="450" Width="600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
<Window.Resources>
@@ -30,7 +31,7 @@
<MenuItem x:Name="AppExit" Header="E_xit" HorizontalAlignment="Left" Width="140" Click="AppExitClick" />
</MenuItem>
<MenuItem Header="_Tools">
<MenuItem x:Name="Options" Header="_Options" HorizontalAlignment="Left" Width="140" Click="OptionsClick"/>
<MenuItem x:Name="OptionsMenuItem" Header="_Options" HorizontalAlignment="Left" Width="140" Click="OptionsClick"/>
</MenuItem>
<MenuItem Header="_Help">
<MenuItem x:Name="About" Header="_About" HorizontalAlignment="Left" Width="140" Click="AboutClick"/>

View File

@@ -26,13 +26,18 @@ namespace DICUI
private Options _options;
private OptionsWindow _optionsWindow;
public bool QuietMode { get; set; }
public MainWindow()
{
QuietMode = true;
InitializeComponent();
// Initializes and load Options object
_options = new Options();
_options.Load();
ViewModels.OptionsViewModel = new OptionsViewModel(_options);
// Disable buttons until we load fully
StartStopButton.IsEnabled = false;
@@ -40,6 +45,7 @@ namespace DICUI
CopyProtectScanButton.IsEnabled = false;
}
#region Events
protected override void OnContentRendered(EventArgs e)
@@ -181,6 +187,7 @@ namespace DICUI
{
GetOutputNames();
SetSupportedDriveSpeed();
EnsureDiscInformation();
}
#endregion
@@ -228,6 +235,8 @@ namespace DICUI
List<KnownSystemComboBoxItem> comboBoxItems = new List<KnownSystemComboBoxItem>();
comboBoxItems.Add(new KnownSystemComboBoxItem(KnownSystem.NONE));
foreach (var group in mapping)
{
comboBoxItems.Add(new KnownSystemComboBoxItem(group.Key));
@@ -303,6 +312,10 @@ namespace DICUI
DICParameters = ParametersTextBox.Text,
QuietMode = _options.QuietMode,
ParanoidMode = _options.ParanoidMode,
RereadAmountC2 = _options.RereadAmountForC2,
System = SystemTypeComboBox.SelectedItem as KnownSystemComboBoxItem,
Type = MediaTypeComboBox.SelectedItem as MediaType?
};
@@ -475,7 +488,8 @@ namespace DICUI
return;
// Get the current optical disc type
_currentMediaType = Validators.GetDiscType(drive.Letter);
if (!_options.SkipMediaTypeDetection)
_currentMediaType = Validators.GetDiscType(drive.Letter);
}
/// <summary>

View File

@@ -14,26 +14,26 @@ namespace DICUI
public int preferredDumpSpeedCD { get; set; }
public int preferredDumpSpeedDVD { get; set; }
public bool QuietMode { get; set; }
public bool ParanoidMode { get; set; }
public int RereadAmountForC2 { get; set; }
public bool SkipMediaTypeDetection { get; set; }
public void Save()
{
Configuration configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//TODO: reflection is used
//TODO: is remove needed, doesn't the value get directly overridden
Array.ForEach(
GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance),
p => {
configFile.AppSettings.Settings.Remove(p.Name);
configFile.AppSettings.Settings.Add(p.Name, p.GetValue(this) as string);
configFile.AppSettings.Settings.Add(p.Name, Convert.ToString(p.GetValue(this)));
}
);
//TODO: is remove needed, doesn't the value get directly overridden?
configFile.AppSettings.Settings.Remove("preferredDumpSpeedCD");
configFile.AppSettings.Settings.Add("preferredDumpSpeedCD", Convert.ToString(preferredDumpSpeedCD));
configFile.AppSettings.Settings.Remove("preferredDumpSpeedDVD");
configFile.AppSettings.Settings.Add("preferredDumpSpeedDVD", Convert.ToString(preferredDumpSpeedDVD));
configFile.Save(ConfigurationSaveMode.Modified);
}
@@ -46,6 +46,11 @@ namespace DICUI
this.preferredDumpSpeedCD = Int32.TryParse(ConfigurationManager.AppSettings["preferredDumpSpeedCD"], out int maxDumpSpeedCD) ? maxDumpSpeedCD : 72;
this.preferredDumpSpeedDVD = Int32.TryParse(ConfigurationManager.AppSettings["preferredDumpSpeedDVD"], out int maxDumpSpeedDVD) ? maxDumpSpeedDVD : 72;
this.QuietMode = Boolean.TryParse(ConfigurationManager.AppSettings["QuietMode"], out bool quietMode) ? quietMode : false;
this.ParanoidMode = Boolean.TryParse(ConfigurationManager.AppSettings["ParanoidMode"], out bool paranoidMode) ? paranoidMode : false;
this.SkipMediaTypeDetection = Boolean.TryParse(ConfigurationManager.AppSettings["SkipMediaTypeDetection"], out bool skipMediaTypeDetection) ? skipMediaTypeDetection : false;
this.RereadAmountForC2 = Int32.TryParse(ConfigurationManager.AppSettings["RereadAmountForC2"], out int rereadAmountForC2) ? rereadAmountForC2 : 20;
}

View File

@@ -4,18 +4,21 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lui="clr-namespace:DICUI.UI"
xmlns:l="clr-namespace:DICUI"
mc:Ignorable="d"
Title="Options" Height="300" Width="515.132">
Title="Options" Height="400" Width="515.132">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="100"/>
<RowDefinition Height="100"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<GroupBox Grid.Column="0" Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="Paths" />
<Grid Margin="10">
<Grid Margin="10,15,10,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="2.0*" />
@@ -65,8 +68,55 @@
</Grid>
</GroupBox>
<Grid Height="22" Grid.Row="2" Grid.Column="0">
<GroupBox Grid.Row="2" Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="Options" Padding="10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<CheckBox Grid.Column="0" VerticalAlignment="Center" Content="Quiet Mode"
DataContext="{Binding Source={x:Static lui:ViewModels.OptionsViewModel}}"
IsChecked="{Binding Path=QuietMode}"
ToolTip="Disable DiskImageCreator sounds"
/>
<CheckBox Grid.Column="1" VerticalAlignment="Center" Content="Paranoid Mode"
DataContext="{Binding Source={x:Static lui:ViewModels.OptionsViewModel}}"
IsChecked="{Binding Path=ParanoidMode}"
ToolTip="Enable pedandic and super-safe flags"
/>
<Grid Grid.Column="2" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="C2 Reread Tries:" />
<TextBox Grid.Column="1" VerticalAlignment="Center"
DataContext="{Binding Source={x:Static lui:ViewModels.OptionsViewModel}}"
Text="{Binding Path=RereadAmountForC2}"
ToolTip="Specifies how many rereads are attempted on C2 error"
/>
</Grid>
<CheckBox Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" VerticalAlignment="Center" Content="Skip Media Type Detection"
DataContext="{Binding Source={x:Static lui:ViewModels.OptionsViewModel}}"
IsChecked="{Binding Path=SkipMediaTypeDetection}"
ToolTip="Disable trying to guess media type inserted (may improve performance at startup)"
/>
</Grid>
</GroupBox>
<Grid Height="22" Grid.Row="3" Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1*"/>

52
DICUI/UI/ViewModels.cs Normal file
View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DICUI.UI
{
public class OptionsViewModel
{
private Options _options;
public OptionsViewModel(Options options)
{
this._options = options;
}
public bool QuietMode
{
get { return _options.QuietMode; }
set { _options.QuietMode = value; }
}
public bool ParanoidMode
{
get { return _options.ParanoidMode; }
set { _options.ParanoidMode = value; }
}
public bool SkipMediaTypeDetection
{
get { return _options.SkipMediaTypeDetection; }
set { _options.SkipMediaTypeDetection = value; }
}
public string RereadAmountForC2
{
get { return Convert.ToString(_options.RereadAmountForC2); }
set
{
if (Int32.TryParse(value, out int result))
_options.RereadAmountForC2 = result;
}
}
}
public static class ViewModels
{
public static OptionsViewModel OptionsViewModel { get; set; }
}
}

View File

@@ -262,7 +262,7 @@ namespace DICUI.Utilities
/// <param name="sys">KnownSystem value to check</param>
/// <param name="type">MediaType value to check</param>
/// <returns>List of strings representing the parameters</returns>
public static List<string> KnownSystemAndMediaTypeToParameters(KnownSystem? sys, MediaType? type)
public static List<string> KnownSystemAndMediaTypeToParameters(KnownSystem? sys, MediaType? type, bool paranoid, int RereadAmountC2)
{
// First check to see if the combination of system and MediaType is valid
var validTypes = Validators.GetValidMediaTypes(sys);
@@ -271,12 +271,16 @@ namespace DICUI.Utilities
return null;
}
string rereadAmount = RereadAmountC2 > 0 ? Convert.ToString(RereadAmountC2) : null;
// Now sort based on disc type
List<string> parameters = new List<string>();
switch (type)
{
case MediaType.CD:
parameters.Add(DICFlags.C2Opcode); parameters.Add("20");
parameters.Add(DICFlags.C2Opcode);
if (rereadAmount != null)
parameters.Add(rereadAmount);
switch (sys)
{
@@ -284,11 +288,19 @@ namespace DICUI.Utilities
case KnownSystem.IBMPCCompatible:
parameters.Add(DICFlags.NoFixSubQSecuROM);
parameters.Add(DICFlags.ScanFileProtect);
parameters.Add(DICFlags.ScanSectorProtect);
if (paranoid)
{
parameters.Add(DICFlags.ScanSectorProtect);
parameters.Add(DICFlags.SubchannelReadLevel); parameters.Add("2");
}
break;
case KnownSystem.NECPCEngineTurboGrafxCD:
parameters.Add(DICFlags.MCN);
break;
case KnownSystem.SonyPlayStation:
parameters.Add(DICFlags.ScanAntiMod);
parameters.Add(DICFlags.NoFixSubQLibCrypt);
@@ -296,13 +308,17 @@ namespace DICUI.Utilities
}
break;
case MediaType.DVD:
// Currently no defaults set
if (paranoid)
parameters.Add(DICFlags.CMI);
break;
case MediaType.GDROM:
parameters.Add(DICFlags.C2Opcode); parameters.Add("20");
parameters.Add(DICFlags.C2Opcode);
if (rereadAmount != null)
parameters.Add(rereadAmount);
break;
case MediaType.HDDVD:
// Currently no defaults set
if (paranoid)
parameters.Add(DICFlags.CMI);
break;
case MediaType.BluRay:
// Currently no defaults set

View File

@@ -51,6 +51,11 @@ namespace DICUI.Utilities
public bool IsFloppy { get => Drive.IsFloppy; }
public string DICParameters;
// extra DIC arguments
public bool QuietMode;
public bool ParanoidMode;
public int RereadAmountC2;
// External process information
private Process dicProcess;
@@ -202,12 +207,17 @@ namespace DICUI.Utilities
return null;
string command = Converters.KnownSystemAndMediaTypeToBaseCommand(System, Type);
List<string> defaultParams = Converters.KnownSystemAndMediaTypeToParameters(System, Type);
List<string> defaultParams = Converters.KnownSystemAndMediaTypeToParameters(System, Type, ParanoidMode, RereadAmountC2);
if (QuietMode)
defaultParams.Add(DICFlags.DisableBeep);
return command
+ " " + Drive.Letter
+ " \"" + Path.Combine(OutputDirectory, OutputFilename) + "\" "
+ (Type.DoesSupportDriveSpeed() && System.DoesSupportDriveSpeed() ? driveSpeed + " " : "")
+ string.Join(" ", defaultParams);
+ string.Join(" ", defaultParams)
;
}
return null;

View File

@@ -379,7 +379,7 @@ namespace DICUI.Utilities
{
return Enum.GetValues(typeof(KnownSystem))
.OfType<KnownSystem?>()
.Where(s => !s.IsMarker())
.Where(s => !s.IsMarker() && s != KnownSystem.NONE)
.ToList();
}