Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MPF.ExecutionContexts.Test/RedumperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void DefaultValueTest(RedumpSystem? system,
[Theory]
[InlineData("disc -h --version --verbose --auto-eject --drive=dr --speed=0 --retries=0 --image-path=path --image-name=image --overwrite --drive-type=dt --drive-read-offset=0 --drive-c2-shift=0 --drive-pregap-start=0 --drive-read-method=drm --drive-sector-order=dso --plextor-skip-leadin --plextor-leadin-retries=0 --asus-skip-leadout --force-offset=0 --audio-silence-threshold=0 --correct-offset-shift --offset-shift-relocate --force-split --leave-unchanged --force-qtoc --skip-fill=0 --iso9660-trim --lba-start=0 --lba-end=0 --refine-subchannel --skip=0 --dump-write-offset=0 --dump-read-size=0 --overread-leadout --force-unscrambled --legacy-subs --disable-cdtext")]
[InlineData("disc --help --version --verbose --auto-eject --drive=dr --speed=0 --retries=0 --image-path=path --image-name=image --overwrite --drive-type=dt --drive-read-offset=0 --drive-c2-shift=0 --drive-pregap-start=0 --drive-read-method=drm --drive-sector-order=dso --plextor-skip-leadin --plextor-leadin-retries=0 --asus-skip-leadout --force-offset=0 --audio-silence-threshold=0 --correct-offset-shift --offset-shift-relocate --force-split --leave-unchanged --force-qtoc --skip-fill=0 --iso9660-trim --lba-start=0 --lba-end=0 --refine-subchannel --skip=0 --dump-write-offset=0 --dump-read-size=0 --overread-leadout --force-unscrambled --legacy-subs --disable-cdtext")]
public void CDTest(string parameters)
public void DiscTest(string parameters)
{
string? expected = "disc --help --version --verbose --auto-eject --drive=dr --speed=0 --retries=0 --image-path=\"path\" --image-name=\"image\" --overwrite --drive-type=dt --drive-read-offset=0 --drive-c2-shift=0 --drive-pregap-start=0 --drive-read-method=drm --drive-sector-order=dso --plextor-skip-leadin --plextor-leadin-retries=0 --asus-skip-leadout --force-offset=0 --audio-silence-threshold=0 --correct-offset-shift --offset-shift-relocate --force-split --leave-unchanged --force-qtoc --skip-fill=0 --iso9660-trim --lba-start=0 --lba-end=0 --refine-subchannel --skip=0 --dump-write-offset=0 --dump-read-size=0 --overread-leadout --force-unscrambled --legacy-subs --disable-cdtext";
var context = new ExecutionContext(parameters);
Expand Down
15 changes: 12 additions & 3 deletions MPF.Frontend/DumpEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,21 @@ await Task.Run(() =>
else
resultProgress.Report(ResultEventArgs.Failure(compressResult));

// Delete unnecessary files only after zipping
if (_options.DeleteUnnecessaryFiles)
{
resultProgress.Report(ResultEventArgs.Success("Deleting unnecessary files..."));
bool deleteSuccess = _processor.DeleteUnnecessaryFiles(outputDirectory, outputFilename, out string deleteResult);
if (deleteSuccess)
resultProgress.Report(ResultEventArgs.Success(deleteResult));
else
resultProgress.Report(ResultEventArgs.Failure(deleteResult));
}

return compressSuccess;
});
}

// Delete unnecessary files, if required
if (_options.DeleteUnnecessaryFiles)
else if (_options.DeleteUnnecessaryFiles)
{
resultProgress.Report(ResultEventArgs.Success("Deleting unnecessary files..."));
bool deleteSuccess = _processor.DeleteUnnecessaryFiles(outputDirectory, outputFilename, out string deleteResult);
Expand Down
25 changes: 22 additions & 3 deletions MPF.Frontend/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ public Options Options

#region Properties

/// <summary>
/// Indicates the status of the check dump menu item
/// </summary>
public bool AskBeforeQuit
{
get => _askBeforeQuit;
set
{
_askBeforeQuit = value;
TriggerPropertyChanged(nameof(AskBeforeQuit));
}
}
private bool _askBeforeQuit;

/// <summary>
/// Indicates the status of the check dump menu item
/// </summary>
Expand Down Expand Up @@ -554,6 +568,7 @@ public MainViewModel()
_status = string.Empty;
_systems = [];

AskBeforeQuit = false;
OptionsMenuItemEnabled = true;
CheckDumpMenuItemEnabled = true;
CreateIRDMenuItemEnabled = true;
Expand Down Expand Up @@ -2146,6 +2161,9 @@ private bool ProgramSupportsMedia()
/// </summary>
public async void StartDumping()
{
// Ask user to confirm before exiting application during a dump
AskBeforeQuit = true;

// One last check to determine environment, just in case
_environment = DetermineEnvironment();

Expand All @@ -2155,17 +2173,16 @@ public async void StartDumping()
// If still in custom parameter mode, check that users meant to continue or not
if (ParametersCheckBoxEnabled == false && _displayUserMessage != null)
{
bool? result = _displayUserMessage("Custom Changes", "It looks like you have custom parameters that have not been saved. Would you like to apply those changes before starting to dump?", 3, true);
bool? result = _displayUserMessage("Custom Changes", "It looks like you have custom parameters that have not been saved. Would you like to dump with these custom parameters?", 2, true);
if (result == true)
{
ParametersCheckBoxEnabled = true;
ProcessCustomParameters();
}
else if (result == null)
else
{
return;
}
// If false, then we continue with the current known environment
}

try
Expand Down Expand Up @@ -2227,6 +2244,8 @@ public async void StartDumping()
}
finally
{
// Reallow quick exiting
AskBeforeQuit = false;
// Reset all UI elements
EnableAllUIElements();
}
Expand Down
5 changes: 4 additions & 1 deletion MPF.Processors/Redumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath
case MediaType.DVD:
case MediaType.HDDVD:
case MediaType.BluRay:
case MediaType.NintendoGameCubeGameDisc:
case MediaType.NintendoWiiOpticalDisc:
case MediaType.NintendoWiiUOpticalDisc:
info.Extras!.PVD = GetPVD($"{basePath}.log") ?? "Disc has no PVD";
info.TracksAndWriteOffsets!.ClrMameProData = GetDatfile($"{basePath}.log");

Expand All @@ -116,7 +119,7 @@ public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath
info.CommonDiscInfo!.ErrorsCount = (scsiErrors == -1 ? "Error retrieving error count" : scsiErrors.ToString());;

// Bluray-specific options
if (Type == MediaType.BluRay)
if (Type == MediaType.BluRay || Type == MediaType.NintendoWiiUOpticalDisc)
{
int trimLength = -1;
switch (System)
Expand Down
15 changes: 15 additions & 0 deletions MPF.UI/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.IO;
#if NET40
using System.Threading.Tasks;
Expand Down Expand Up @@ -74,6 +75,7 @@ public MainWindow()
{
#if NET40_OR_GREATER || NETCOREAPP
InitializeComponent();
this.Closing += MainWindowClosing;
#endif

#if NET452_OR_GREATER || NETCOREAPP
Expand Down Expand Up @@ -210,6 +212,19 @@ public void CheckForUpdates(bool showIfSame)
CustomMessageBox.Show(this, message, "Version Update Check", MessageBoxButton.OK, different ? MessageBoxImage.Exclamation : MessageBoxImage.Information);
}

/// <summary>
/// Ask to confirm quitting, when an operation is running
/// </summary>
public void MainWindowClosing(object? sender, CancelEventArgs e)
{
if (MainViewModel.AskBeforeQuit)
{
MessageBoxResult result = CustomMessageBox.Show(this, "A dump is still being processed, are you sure you want to quit?", "Quit", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
if (result == MessageBoxResult.No)
e.Cancel = true;
}
}

/// <summary>
/// Build a dummy SubmissionInfo and display it for testing
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion MPF.UI/Windows/WindowBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public void TitleMouseDown(object sender, MouseButtonEventArgs e)
{
1 => MessageBoxButton.OK,
2 => MessageBoxButton.YesNo,
3 => MessageBoxButton.YesNoCancel,

// This should not happen, but default to "OK"
_ => MessageBoxButton.OK,
Expand Down