Merge pull request #29 from mnadareski/master

Add Custom Parameter Support
This commit is contained in:
reignstumble
2018-06-12 20:47:54 -04:00
committed by GitHub
3 changed files with 62 additions and 22 deletions

View File

@@ -30,28 +30,30 @@
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" VerticalAlignment="Center">Disc Type</Label>
<Label Grid.Row="1" Grid.Column="0" VerticalAlignment="Center">Output Filename</Label>
<Label Grid.Row="2" Grid.Column="0" VerticalAlignment="Center">Output Directory</Label>
<Label Grid.Row="3" Grid.Column="0" VerticalAlignment="Center">Drive Letter</Label>
<Label Grid.Row="4" Grid.Column="0" VerticalAlignment="Center">Drive Speed</Label>
<ComboBox x:Name="cmb_DiscType" Grid.Row="0" Grid.Column="1" Height="22" SelectionChanged="cmb_DiscType_SelectionChanged" />
<Label Grid.Row="1" Grid.Column="0" VerticalAlignment="Center">Output Filename</Label>
<TextBox x:Name="txt_OutputFilename" Grid.Row="1" Grid.Column="1" Height="22"></TextBox>
<Label Grid.Row="2" Grid.Column="0" VerticalAlignment="Center">Output Directory</Label>
<TextBox x:Name="txt_OutputDirectory" Grid.Row="2" Grid.Column="1" Height="22" Width="345" HorizontalAlignment="left" Text="ISO" />
<Button x:Name="btn_OutputDirectoryBrowse" Grid.Row="2" Grid.Column="1" Height="22" Width="50" HorizontalAlignment="Right" Content="Browse" Click="btn_OutputDirectoryBrowse_Click"/>
<Label Grid.Row="3" Grid.Column="0" VerticalAlignment="Center">Drive Letter</Label>
<ComboBox x:Name="cmb_DriveLetter" Grid.Row="3" Grid.Column="1" Height="22" Width="397" HorizontalAlignment="left" SelectionChanged="cmb_DriveLetter_SelectionChanged"/>
<ComboBox x:Name="cmb_DriveSpeed" Grid.Row="4" Grid.Column="1" Height="22" Width="60" HorizontalAlignment="left"/>
<Label Grid.Row="4" Grid.Column="0" VerticalAlignment="Center">Drive Speed</Label>
<ComboBox x:Name="cmb_DriveSpeed" Grid.Row="4" Grid.Column="1" Height="22" Width="60" HorizontalAlignment="left" SelectionChanged="cmb_DriveSpeed_SelectionChanged"/>
<Label Grid.Row="5" Grid.Column="0" VerticalAlignment="Center">Custom Parameters</Label>
<TextBox x:Name="txt_CustomParameters" Grid.Row="5" Grid.Column="1" Height="22" Width="397" HorizontalAlignment="left" IsEnabled="False" />
</Grid>
<Grid Grid.Row="1" Grid.Column="0" Margin="15,19.6,15.2,9.8" Grid.ColumnSpan="2">
@@ -76,9 +78,6 @@
</Grid.RowDefinitions>
<Label x:Name="lbl_Status" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Content="Waiting for CD or DVD..." />
</Grid>
</Grid>
</Window>

View File

@@ -63,6 +63,11 @@ namespace DICUI
GetOutputNames();
}
private void cmb_DriveSpeed_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
EnsureDiscInformation();
}
#endregion
#region Helpers
@@ -77,6 +82,8 @@ namespace DICUI
cmb_DiscType.DisplayMemberPath = "Item1";
cmb_DiscType.SelectedIndex = 0;
cmb_DiscType_SelectionChanged(null, null);
btn_Start.IsEnabled = false;
}
/// <summary>
@@ -136,16 +143,13 @@ namespace DICUI
string driveLetter = cmb_DriveLetter.Text;
string outputDirectory = txt_OutputDirectory.Text;
string outputFilename = txt_OutputFilename.Text;
int driveSpeed = (int)cmb_DriveSpeed.SelectedItem;
btn_Start.IsEnabled = false;
// Get the discType and processArguments from a given system and disc combo
// Get the currently selected item
var selected = cmb_DiscType.SelectedValue as Tuple<string, KnownSystem?, DiscType?>;
string discType = Utilities.GetBaseCommand(selected.Item3);
List<string> defaultParams = Utilities.GetDefaultParameters(selected.Item2, selected.Item3);
// Validate that everything is good
if (discType == null || defaultParams == null)
if (string.IsNullOrWhiteSpace(txt_CustomParameters.Text))
{
lbl_Status.Content = "Error! Current configuration is not supported!";
return;
@@ -164,11 +168,7 @@ namespace DICUI
{
Process process = new Process();
process.StartInfo.FileName = dicPath;
process.StartInfo.Arguments = discType
+ " " + driveLetter
+ " \"" + Path.Combine(outputDirectory, outputFilename) + "\" "
+ (selected.Item3 != DiscType.BD25 && selected.Item3 != DiscType.BD50 ? driveSpeed + " " : "")
+ string.Join(" ", defaultParams);
process.StartInfo.Arguments = txt_CustomParameters.Text;
process.Start();
process.WaitForExit();
});
@@ -181,7 +181,7 @@ namespace DICUI
if (!File.Exists(sgRawPath))
{
lbl_Status.Content = "Error! Could not find sg-raw!";
return;
break;
}
Process sgraw = new Process()
@@ -199,7 +199,7 @@ namespace DICUI
if (!File.Exists(psxtPath))
{
lbl_Status.Content = "Error! Could not find psxt001z!";
return;
break;
}
// Invoke the program with all 3 configurations
@@ -273,17 +273,21 @@ namespace DICUI
{
case DiscType.NONE:
lbl_Status.Content = "Please select a valid disc type";
btn_Start.IsEnabled = false;
break;
case DiscType.GameCubeGameDisc:
case DiscType.GDROM:
lbl_Status.Content = string.Format("{0} discs are partially supported by DIC", Utilities.DiscTypeToString(tuple.Item3));
btn_Start.IsEnabled = true;
break;
case DiscType.HDDVD:
case DiscType.UMD:
lbl_Status.Content = string.Format("{0} discs are not currently supported by DIC", Utilities.DiscTypeToString(tuple.Item3));
btn_Start.IsEnabled = true;
break;
default:
lbl_Status.Content = string.Format("{0} ready to dump", Utilities.DiscTypeToString(tuple.Item3));
btn_Start.IsEnabled = true;
break;
}
@@ -298,6 +302,40 @@ namespace DICUI
cmb_DriveSpeed.IsEnabled = true;
break;
}
// Special case for Custom input
if (tuple.Item1 == "Custom Input" && tuple.Item2 == KnownSystem.NONE && tuple.Item3 == DiscType.NONE)
{
txt_CustomParameters.IsEnabled = true;
txt_OutputFilename.IsEnabled = false;
txt_OutputDirectory.IsEnabled = false;
btn_OutputDirectoryBrowse.IsEnabled = false;
cmb_DriveLetter.IsEnabled = false;
cmb_DriveSpeed.IsEnabled = false;
lbl_Status.Content = "User input mode";
}
else
{
txt_CustomParameters.IsEnabled = false;
txt_OutputFilename.IsEnabled = true;
txt_OutputDirectory.IsEnabled = true;
btn_OutputDirectoryBrowse.IsEnabled = true;
cmb_DriveLetter.IsEnabled = true;
cmb_DriveSpeed.IsEnabled = true;
// Populate with the correct params for inputs (if we're not on the default option)
if (cmb_DiscType.SelectedIndex > 0)
{
var selected = cmb_DiscType.SelectedValue as Tuple<string, KnownSystem?, DiscType?>;
string discType = Utilities.GetBaseCommand(selected.Item3);
List<string> defaultParams = Utilities.GetDefaultParameters(selected.Item2, selected.Item3);
txt_CustomParameters.Text = discType
+ " " + cmb_DriveLetter.Text
+ " \"" + Path.Combine(txt_OutputDirectory.Text, txt_OutputFilename.Text + Utilities.GetDefaultExtension(selected.Item3)) + "\" "
+ (selected.Item3 != DiscType.BD25 && selected.Item3 != DiscType.BD50 ? (int)cmb_DriveSpeed.SelectedItem + " " : "")
+ string.Join(" ", defaultParams);
}
}
}
/// <summary>

View File

@@ -603,6 +603,9 @@ namespace DICUI
}
}
// Add final mapping for "Custom"
mapping.Add(new Tuple<string, KnownSystem?, DiscType?>("Custom Input", KnownSystem.NONE, DiscType.NONE));
return mapping;
}