Compare commits

...

30 Commits
3.2.3 ... 3.2.4

Author SHA1 Message Date
Matt Nadareski
e72336a835 Bump version 2024-11-24 19:55:26 -05:00
Deterous
886a0a4f07 Add support for Redumper Xbox dumps (#766)
* Add support for Redumper Xbox dumps

* Fix doubleup of ranges variable name

* Don't use FileInfo

* Fix RemoveHeader

* Use manual Stream.CopyTo

* Capitalise DMI/PFI/SS hashes

* Final cleanup

* Final final cleanup
2024-11-24 19:50:45 -05:00
Deterous
093435e7b0 Don't add trailing spaces to BCA output (#765)
* Don't add trailing spaces to BCA output

* Fix import

* Fix var name
2024-11-23 22:32:40 -05:00
Matt Nadareski
59a427963d Fix PS3 firmware version being omitted 2024-11-23 19:59:25 -05:00
Deterous
19d6006aff Cleanup CleanSS check (#763)
* Cleanup CleanSS check

* Make ssv2 check consistent
2024-11-22 23:15:15 -05:00
Matt Nadareski
617b0ba2c5 Version gate remaining Linq statements 2024-11-22 12:44:50 -05:00
Matt Nadareski
195c83499c Clean up usings after last commit 2024-11-22 11:56:12 -05:00
Matt Nadareski
e5b02c27a8 Replace some uses of Regex.Replace 2024-11-22 11:50:07 -05:00
Deterous
c7b6b08397 Improve parameters for default output path (#762)
* Improve parameters for default output path

* ToUpperInvariant
2024-11-22 10:55:20 -05:00
Matt Nadareski
da6b2f0e24 Remove unncessary .NET Framework 4.0 gating 2024-11-21 13:29:06 -05:00
Matt Nadareski
c50c3edcc5 Don't preemptively sort protections 2024-11-21 12:08:02 -05:00
Matt Nadareski
d628b2a0dd Use List in protection formatting 2024-11-21 12:06:12 -05:00
Matt Nadareski
f6baaa6f5e Reduce unnecessary use of IEnumerable 2024-11-21 11:55:00 -05:00
Matt Nadareski
b05c82e903 Remove usages of this. from UI code 2024-11-21 11:49:14 -05:00
Matt Nadareski
65f472c4c9 Fix minor efficiency issues 2024-11-21 11:46:11 -05:00
Matt Nadareski
104dd4348b Update packages for bugfixes 2024-11-21 11:27:57 -05:00
Matt Nadareski
2337a2ed86 Use expanded version of split regex (fixes #761) 2024-11-20 11:41:28 -05:00
Deterous
2ce632f8b4 Fix PIC parser (#760) 2024-11-19 13:01:15 -05:00
Matt Nadareski
ce917f4f61 Remove usages of this. from themes 2024-11-18 15:44:43 -05:00
Matt Nadareski
d029cf4164 Add IMA extension for floppy disks 2024-11-18 15:39:43 -05:00
Matt Nadareski
74d52c2f3b Add Track 0/00/A/AA to Generic 2024-11-18 15:18:05 -05:00
Matt Nadareski
785786c3a9 Add unused "Generic" processor 2024-11-18 13:24:19 -05:00
Matt Nadareski
466d8f58b0 Add skeleton to Redumper CD by default 2024-11-18 12:22:50 -05:00
Matt Nadareski
bc690614e6 Remove usages of this. in more places 2024-11-18 12:21:13 -05:00
Deterous
d44798b27c Fix fully matching when multiple matches found (#759)
Co-authored-by: Matt Nadareski <mnadareski@outlook.com>
2024-11-17 19:33:09 -05:00
Matt Nadareski
595cd0d60f Consolidate parameter string splitting 2024-11-16 01:23:30 -05:00
Matt Nadareski
68fd5a2aa0 Be smarter about some data types 2024-11-16 01:07:47 -05:00
Matt Nadareski
6da98aa65c Add .NET 9 to target frameworks 2024-11-16 00:37:14 -05:00
Matt Nadareski
d8d149446f Be smarter about Linq usage 2024-11-12 22:18:08 -05:00
Matt Nadareski
4d0f48be10 Update Redumper to build 438 2024-11-06 16:06:22 -05:00
67 changed files with 1850 additions and 1914 deletions

View File

@@ -25,7 +25,7 @@ What version are you using?
**Build**
What runtime version are you using?
- [ ] .NET 8.0 running on (Operating System)
- [ ] .NET 9.0 running on (Operating System)
**Describe the issue**
A clear and concise description of what the bug is.

View File

@@ -12,7 +12,7 @@ jobs:
matrix:
project: [MPF.Check]
runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64]
framework: [net8.0] #[net20, net35, net40, net452, net472, net48, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0]
framework: [net9.0] #[net20, net35, net40, net452, net472, net48, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0, net9.0]
conf: [Debug] #[Release, Debug]
steps:
@@ -21,13 +21,13 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8')) && '-p:PublishSingleFile=true' || ''}}
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8') || startsWith(matrix.framework, 'net9')) && '-p:PublishSingleFile=true' || ''}}
- name: Archive build
run: |

View File

@@ -12,7 +12,7 @@ jobs:
matrix:
project: [MPF.CLI]
runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64]
framework: [net8.0] #[net20, net35, net40, net452, net472, net48, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0]
framework: [net9.0] #[net20, net35, net40, net452, net472, net48, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0, net9.0]
conf: [Debug] #[Release, Debug]
steps:
@@ -21,13 +21,13 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8')) && '-p:PublishSingleFile=true' || ''}}
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8') || startsWith(matrix.framework, 'net9')) && '-p:PublishSingleFile=true' || ''}}
- name: Archive build
run: |

View File

@@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore

View File

@@ -12,7 +12,7 @@ jobs:
matrix:
project: [MPF.UI]
runtime: [win-x86, win-x64]
framework: [net8.0-windows] #[net40, net452, net472, net48, netcoreapp3.1, net5.0-windows, net6.0-windows, net7.0-windows, net8.0-windows]
framework: [net9.0-windows] #[net40, net452, net472, net48, netcoreapp3.1, net5.0-windows, net6.0-windows, net7.0-windows, net8.0-windows, net9.0-windows]
conf: [Debug] #[Release, Debug]
steps:
@@ -21,13 +21,13 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8')) && '-p:PublishSingleFile=true' || ''}}
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8') || startsWith(matrix.framework, 'net9')) && '-p:PublishSingleFile=true' || ''}}
- name: Bundle DiscImageCreator
run: |
@@ -38,10 +38,10 @@ jobs:
- name: Bundle Redumper
run: |
wget https://github.com/superg/redumper/releases/download/build_416/redumper-2024.10.12_build416-win64.zip
unzip redumper-2024.10.12_build416-win64.zip
wget https://github.com/superg/redumper/releases/download/build_438/redumper-2024.11.03_build438-win64.zip
unzip redumper-2024.11.03_build438-win64.zip
mkdir -p MPF.UI/bin/${{ matrix.conf }}/${{ matrix.framework }}/${{ matrix.runtime }}/publish/Programs/Redumper
mv redumper-2024.10.12_build416-win64/bin/redumper.exe MPF.UI/bin/${{ matrix.conf }}/${{ matrix.framework }}/${{ matrix.runtime }}/publish/Programs/Redumper/
mv redumper-2024.11.03_build438-win64/bin/redumper.exe MPF.UI/bin/${{ matrix.conf }}/${{ matrix.framework }}/${{ matrix.runtime }}/publish/Programs/Redumper/
- name: Archive build
run: |

View File

@@ -11,7 +11,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore

2
.vscode/launch.json vendored
View File

@@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/MPF.Check/bin/Debug/net8.0/MPF.Check.dll",
"program": "${workspaceFolder}/MPF.Check/bin/Debug/net9.0/MPF.Check.dll",
"args": [],
"cwd": "${workspaceFolder}/MPF.Check",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console

View File

@@ -1,3 +1,35 @@
### 3.2.4 (2024-11-24)
- Update Redumper to build 438
- Be smarter about Linq usage
- Add .NET 9 to target frameworks
- Be smarter about some data types
- Consolidate parameter string splitting
- Fix fully matching when multiple matches found
- Remove usages of `this.` in more places
- Add `skeleton` to Redumper CD by default
- Add unused "Generic" processor
- Add Track 0/00/A/AA to Generic
- Add IMA extension for floppy disks
- Remove usages of `this.` from themes
- Fix PIC parser
- Use expanded version of split regex
- Update packages for bugfixes
- Fix minor efficiency issues
- Remove usages of `this.` from UI code
- Reduce unnecessary use of IEnumerable
- Use List in protection formatting
- Don't preemptively sort protections
- Remove unncessary .NET Framework 4.0 gating
- Improve parameters for default output path
- Replace some uses of Regex.Replace
- Clean up usings after last commit
- Version gate remaining Linq statements
- Cleanup CleanSS check
- Fix PS3 firmware version being omitted
- Don't add trailing spaces to BCA output
- Add support for Redumper Xbox dumps
### 3.2.3 (2024-11-06)
- Update to DIC 20240901

View File

@@ -2,15 +2,16 @@
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>latest</LangVersion>
<NoWarn>NU1902;NU1903</NoWarn>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<VersionPrefix>3.2.3</VersionPrefix>
<VersionPrefix>3.2.4</VersionPrefix>
<!-- Package Properties -->
<Title>MPF CLI</Title>
@@ -29,29 +30,22 @@
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`))">
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MPF.Frontend\MPF.Frontend.csproj" />
</ItemGroup>
<!-- Support for old .NET versions -->
<ItemGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net40`))">
<PackageReference Include="MinAsyncBridge" Version="0.12.4" />
<PackageReference Include="MinTasksExtensionsBridge" Version="0.3.4" />
<PackageReference Include="MinThreadingBridge" Version="0.11.4" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BinaryObjectScanner" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="3.1.16" GeneratePathProperty="true">
<PackageReference Include="BinaryObjectScanner" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="3.2.3" GeneratePathProperty="true">
<IncludeAssets>runtime; compile; build; native; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SabreTools.RedumpLib" Version="1.4.4" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.5.2" />
</ItemGroup>
<ItemGroup>

View File

@@ -158,13 +158,8 @@ namespace MPF.CLI
}
// Finally, attempt to do the output dance
#if NET40
var verifyTask = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress);
verifyTask.Wait();
var verifyResult = verifyTask.Result;
#else
var verifyResult = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress).ConfigureAwait(false).GetAwaiter().GetResult();
#endif
var verifyResult = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress)
.ConfigureAwait(false).GetAwaiter().GetResult();
Console.WriteLine(verifyResult.Message);
}

View File

@@ -2,15 +2,16 @@
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>latest</LangVersion>
<NoWarn>NU1902;NU1903</NoWarn>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<VersionPrefix>3.2.3</VersionPrefix>
<VersionPrefix>3.2.4</VersionPrefix>
<!-- Package Properties -->
<Title>MPF Check</Title>
@@ -29,11 +30,11 @@
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`))">
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
@@ -44,18 +45,11 @@
<ProjectReference Include="..\MPF.Frontend\MPF.Frontend.csproj" />
</ItemGroup>
<!-- Support for old .NET versions -->
<ItemGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net40`))">
<PackageReference Include="MinAsyncBridge" Version="0.12.4" />
<PackageReference Include="MinTasksExtensionsBridge" Version="0.3.4" />
<PackageReference Include="MinThreadingBridge" Version="0.11.4" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BinaryObjectScanner" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="3.1.16" GeneratePathProperty="true">
<PackageReference Include="BinaryObjectScanner" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="3.2.3" GeneratePathProperty="true">
<IncludeAssets>runtime; compile; build; native; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SabreTools.RedumpLib" Version="1.4.4" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.5.2" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,7 +1,6 @@
using System;
using System.IO;
#if NET40
using System.Threading;
using System.Threading.Tasks;
#endif
using BinaryObjectScanner;
@@ -110,7 +109,8 @@ namespace MPF.Check
var env = new DumpEnvironment(options, filepath, drive, knownSystem, mediaType, internalProgram: null, parameters: null);
// Finally, attempt to do the output dance
var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress, seedInfo: opts.Seed).GetAwaiter().GetResult();
var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress, seedInfo: opts.Seed)
.ConfigureAwait(false).GetAwaiter().GetResult();
Console.WriteLine(result.Message);
}
}

View File

@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using SabreTools.RedumpLib.Data;
namespace MPF.ExecutionContexts.Aaru
@@ -116,7 +114,12 @@ namespace MPF.ExecutionContexts.Aaru
public ExecutionContext(string? parameters) : base(parameters) { }
/// <inheritdoc/>
public ExecutionContext(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Dictionary<string, string?> options)
public ExecutionContext(RedumpSystem? system,
MediaType? type,
string? drivePath,
string filename,
int? driveSpeed,
Dictionary<string, string?> options)
: base(system, type, drivePath, filename, driveSpeed, options)
{
}
@@ -1082,7 +1085,7 @@ namespace MPF.ExecutionContexts.Aaru
if (string.IsNullOrEmpty(InputValue))
return null;
if (InputValue.Contains(' '))
if (InputValue!.Contains(" "))
parameters.Add($"\"{InputValue!.TrimEnd('\\')}\"");
else
parameters.Add(InputValue!.TrimEnd('\\'));
@@ -1193,7 +1196,10 @@ namespace MPF.ExecutionContexts.Aaru
}
/// <inheritdoc/>
protected override void SetDefaultParameters(string? drivePath, string filename, int? driveSpeed, Dictionary<string, string?> options)
protected override void SetDefaultParameters(string? drivePath,
string filename,
int? driveSpeed,
Dictionary<string, string?> options)
{
BaseCommand = $"{CommandStrings.MediaPrefixLong} {CommandStrings.MediaDump}";
@@ -1207,8 +1213,8 @@ namespace MPF.ExecutionContexts.Aaru
}
// First check to see if the combination of system and MediaType is valid
var validTypes = this.System.MediaTypes();
if (!validTypes.Contains(this.Type))
var validTypes = RedumpSystem.MediaTypes();
if (!validTypes.Contains(MediaType))
return;
// Set retry count
@@ -1231,40 +1237,40 @@ namespace MPF.ExecutionContexts.Aaru
// TODO: Look at dump-media formats and the like and see what options there are there to fill in defaults
// Now sort based on disc type
switch (this.Type)
switch (MediaType)
{
case MediaType.CDROM:
case SabreTools.RedumpLib.Data.MediaType.CDROM:
// Currently no defaults set
break;
case MediaType.DVD:
case SabreTools.RedumpLib.Data.MediaType.DVD:
this[FlagStrings.StoreEncryptedLong] = true; // TODO: Make this configurable
this[FlagStrings.TitleKeysLong] = false; // TODO: Make this configurable
this[FlagStrings.TrimLong] = true; // TODO: Make this configurable
break;
case MediaType.GDROM:
case SabreTools.RedumpLib.Data.MediaType.GDROM:
// Currently no defaults set
break;
case MediaType.HDDVD:
case SabreTools.RedumpLib.Data.MediaType.HDDVD:
this[FlagStrings.StoreEncryptedLong] = true; // TODO: Make this configurable
this[FlagStrings.TitleKeysLong] = false; // TODO: Make this configurable
this[FlagStrings.TrimLong] = true; // TODO: Make this configurable
break;
case MediaType.BluRay:
case SabreTools.RedumpLib.Data.MediaType.BluRay:
this[FlagStrings.StoreEncryptedLong] = true; // TODO: Make this configurable
this[FlagStrings.TitleKeysLong] = false; // TODO: Make this configurable
this[FlagStrings.TrimLong] = true; // TODO: Make this configurable
break;
// Special Formats
case MediaType.NintendoGameCubeGameDisc:
case SabreTools.RedumpLib.Data.MediaType.NintendoGameCubeGameDisc:
// Currently no defaults set
break;
case MediaType.NintendoWiiOpticalDisc:
case SabreTools.RedumpLib.Data.MediaType.NintendoWiiOpticalDisc:
// Currently no defaults set
break;
// Non-optical
case MediaType.FloppyDisk:
case SabreTools.RedumpLib.Data.MediaType.FloppyDisk:
// Currently no defaults set
break;
}
@@ -1280,19 +1286,14 @@ namespace MPF.ExecutionContexts.Aaru
return false;
// Now split the string into parts for easier validation
// https://stackoverflow.com/questions/14655023/split-a-string-that-has-white-spaces-unless-they-are-enclosed-within-quotes
parameters = parameters!.Trim();
List<string> parts = Regex.Matches(parameters, @"[\""].+?[\""]|[^ ]+", RegexOptions.Compiled)
.Cast<Match>()
.Select(m => m.Value)
.ToList();
List<string> parts = SplitParameterString(parameters!);
// Search for pre-command flags first
int start = 0;
for (start = 0; start < parts.Count; start++)
{
// Keep a count of keys to determine if we should break out to command handling or not
int keyCount = Keys.Count();
int keyCount = Keys.Count;
// Debug
ProcessBooleanParameter(parts, FlagStrings.DebugShort, FlagStrings.DebugLong, ref start, true);
@@ -1311,7 +1312,7 @@ namespace MPF.ExecutionContexts.Aaru
ProcessBooleanParameter(parts, FlagStrings.HelpShortAlt, FlagStrings.HelpLong, ref start, true);
// If we didn't add any new flags, break out since we might be at command handling
if (keyCount == Keys.Count())
if (keyCount == Keys.Count)
break;
}
@@ -1339,7 +1340,7 @@ namespace MPF.ExecutionContexts.Aaru
string? stringValue = null;
// Keep a count of keys to determine if we should break out to filename handling or not
int keyCount = Keys.Count();
int keyCount = Keys.Count;
#region Boolean flags
@@ -1706,7 +1707,7 @@ namespace MPF.ExecutionContexts.Aaru
#endregion
// If we didn't add any new flags, break out since we might be at filename handling
if (keyCount == Keys.Count())
if (keyCount == Keys.Count)
break;
}

View File

@@ -20,7 +20,7 @@ namespace MPF.ExecutionContexts
/// Set of flags to pass to the executable
/// </summary>
protected Dictionary<string, bool?> flags = [];
protected internal IEnumerable<string> Keys => flags.Keys;
protected internal List<string> Keys => [.. flags.Keys];
/// <summary>
/// Safe access to currently set flags
@@ -82,12 +82,12 @@ namespace MPF.ExecutionContexts
/// <summary>
/// Currently represented system
/// </summary>
public RedumpSystem? System { get; set; }
public RedumpSystem? RedumpSystem { get; set; }
/// <summary>
/// Currently represented media type
/// </summary>
public MediaType? Type { get; set; }
public MediaType? MediaType { get; set; }
#endregion
@@ -111,10 +111,15 @@ namespace MPF.ExecutionContexts
/// <param name="filename">Filename to use</param>
/// <param name="driveSpeed">Drive speed to use</param>
/// <param name="options">Dictionary object containing all settings that may be used for setting parameters</param>
public BaseExecutionContext(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Dictionary<string, string?> options)
public BaseExecutionContext(RedumpSystem? system,
MediaType? type,
string? drivePath,
string filename,
int? driveSpeed,
Dictionary<string, string?> options)
{
this.System = system;
this.Type = type;
RedumpSystem = system;
MediaType = type;
SetDefaultParameters(drivePath, filename, driveSpeed, options);
}
@@ -169,7 +174,10 @@ namespace MPF.ExecutionContexts
/// <param name="filename">Filename to use</param>
/// <param name="driveSpeed">Drive speed to use</param>
/// <param name="options">Dictionary containing all settings that may be used for setting parameters</param>
protected abstract void SetDefaultParameters(string? drivePath, string filename, int? driveSpeed, Dictionary<string, string?> options);
protected abstract void SetDefaultParameters(string? drivePath,
string filename,
int? driveSpeed,
Dictionary<string, string?> options);
/// <summary>
/// Scan a possible parameter string and populate whatever possible
@@ -290,6 +298,24 @@ namespace MPF.ExecutionContexts
#region Parameter Parsing
/// <summary>
/// Split a parameters string into a list while taking quotes into account
/// </summary>
/// <see href="https://stackoverflow.com/questions/14655023/split-a-string-that-has-white-spaces-unless-they-are-enclosed-within-quotes"/>
protected static List<string> SplitParameterString(string parameters)
{
// Ensure the parameter string is trimmed
parameters = parameters.Trim();
// Split the string using Regex
var matches = Regex.Matches(parameters, @"([a-zA-Z\-]*=)?[\""].+?[\""]|[^ ]+", RegexOptions.Compiled);
// Get just the values from the matches
var matchArr = new Match[matches.Count];
matches.CopyTo(matchArr, 0);
return [.. Array.ConvertAll(matchArr, m => m.Value)];
}
/// <summary>
/// Returns whether or not the selected item exists
/// </summary>
@@ -308,9 +334,9 @@ namespace MPF.ExecutionContexts
{
if (CommandSupport == null)
return false;
if (this.BaseCommand == null)
if (BaseCommand == null)
return false;
if (!CommandSupport.TryGetValue(this.BaseCommand, out var supported))
if (!CommandSupport.TryGetValue(BaseCommand, out var supported))
return false;
return supported.Contains(flag);
}

View File

@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using SabreTools.RedumpLib.Data;
namespace MPF.ExecutionContexts.DiscImageCreator
@@ -166,7 +164,12 @@ namespace MPF.ExecutionContexts.DiscImageCreator
public ExecutionContext(string? parameters) : base(parameters) { }
/// <inheritdoc/>
public ExecutionContext(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Dictionary<string, string?> options)
public ExecutionContext(RedumpSystem? system,
MediaType? type,
string? drivePath,
string filename,
int? driveSpeed,
Dictionary<string, string?> options)
: base(system, type, drivePath, filename, driveSpeed, options)
{
}
@@ -423,7 +426,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
{
if (DrivePath != null)
{
if (DrivePath.Contains(' '))
if (DrivePath.Contains(" "))
parameters.Add($"\"{DrivePath}\"");
else
parameters.Add(DrivePath);
@@ -960,17 +963,20 @@ namespace MPF.ExecutionContexts.DiscImageCreator
}
/// <inheritdoc/>
protected override void SetDefaultParameters(string? drivePath, string filename, int? driveSpeed, Dictionary<string, string?> options)
protected override void SetDefaultParameters(string? drivePath,
string filename,
int? driveSpeed,
Dictionary<string, string?> options)
{
SetBaseCommand(this.System, this.Type);
SetBaseCommand(RedumpSystem, MediaType);
DrivePath = drivePath;
DriveSpeed = driveSpeed;
Filename = filename;
// First check to see if the combination of system and MediaType is valid
var validTypes = this.System.MediaTypes();
if (!validTypes.Contains(this.Type))
var validTypes = RedumpSystem.MediaTypes();
if (!validTypes.Contains(MediaType))
return;
// Set disable beep flag, if needed
@@ -996,18 +1002,18 @@ namespace MPF.ExecutionContexts.DiscImageCreator
};
// Now sort based on disc type
switch (this.Type)
switch (MediaType)
{
case MediaType.CDROM:
case SabreTools.RedumpLib.Data.MediaType.CDROM:
this[FlagStrings.C2Opcode] = true;
this[FlagStrings.MultiSectorRead] = GetBooleanSetting(options, SettingConstants.MultiSectorRead, SettingConstants.MultiSectorReadDefault);
if (this[FlagStrings.MultiSectorRead] == true)
this.MultiSectorReadValue = GetInt32Setting(options, SettingConstants.MultiSectorReadValue, SettingConstants.MultiSectorReadValueDefault);
MultiSectorReadValue = GetInt32Setting(options, SettingConstants.MultiSectorReadValue, SettingConstants.MultiSectorReadValueDefault);
switch (this.System)
switch (RedumpSystem)
{
case RedumpSystem.AppleMacintosh:
case RedumpSystem.IBMPCcompatible:
case SabreTools.RedumpLib.Data.RedumpSystem.AppleMacintosh:
case SabreTools.RedumpLib.Data.RedumpSystem.IBMPCcompatible:
this[FlagStrings.NoFixSubQSecuROM] = true;
this[FlagStrings.ScanFileProtect] = true;
this[FlagStrings.ScanSectorProtect] = GetBooleanSetting(options, SettingConstants.ParanoidMode, SettingConstants.ParanoidModeDefault);
@@ -1016,48 +1022,48 @@ namespace MPF.ExecutionContexts.DiscImageCreator
SubchannelReadLevelValue = 2;
break;
case RedumpSystem.AtariJaguarCDInteractiveMultimediaSystem:
case SabreTools.RedumpLib.Data.RedumpSystem.AtariJaguarCDInteractiveMultimediaSystem:
this[FlagStrings.AtariJaguar] = true;
break;
case RedumpSystem.HasbroVideoNow:
case RedumpSystem.HasbroVideoNowColor:
case RedumpSystem.HasbroVideoNowJr:
case RedumpSystem.HasbroVideoNowXP:
case SabreTools.RedumpLib.Data.RedumpSystem.HasbroVideoNow:
case SabreTools.RedumpLib.Data.RedumpSystem.HasbroVideoNowColor:
case SabreTools.RedumpLib.Data.RedumpSystem.HasbroVideoNowJr:
case SabreTools.RedumpLib.Data.RedumpSystem.HasbroVideoNowXP:
this[FlagStrings.AddOffset] = true;
this.AddOffsetValue = 0; // Value needed for first run and placeholder after
AddOffsetValue = 0; // Value needed for first run and placeholder after
break;
case RedumpSystem.SonyPlayStation:
case SabreTools.RedumpLib.Data.RedumpSystem.SonyPlayStation:
this[FlagStrings.ScanAntiMod] = true;
this[FlagStrings.NoFixSubQLibCrypt] = true;
break;
}
break;
case MediaType.DVD:
case SabreTools.RedumpLib.Data.MediaType.DVD:
this[FlagStrings.CopyrightManagementInformation] = GetBooleanSetting(options, SettingConstants.UseCMIFlag, SettingConstants.UseCMIFlagDefault);
this[FlagStrings.ScanFileProtect] = GetBooleanSetting(options, SettingConstants.ParanoidMode, SettingConstants.ParanoidModeDefault);
this[FlagStrings.DVDReread] = true;
break;
case MediaType.GDROM:
case SabreTools.RedumpLib.Data.MediaType.GDROM:
this[FlagStrings.C2Opcode] = true;
break;
case MediaType.HDDVD:
case SabreTools.RedumpLib.Data.MediaType.HDDVD:
this[FlagStrings.CopyrightManagementInformation] = GetBooleanSetting(options, SettingConstants.UseCMIFlag, SettingConstants.UseCMIFlagDefault);
this[FlagStrings.DVDReread] = true;
break;
case MediaType.BluRay:
case SabreTools.RedumpLib.Data.MediaType.BluRay:
this[FlagStrings.DVDReread] = true;
break;
// Special Formats
case MediaType.NintendoGameCubeGameDisc:
case SabreTools.RedumpLib.Data.MediaType.NintendoGameCubeGameDisc:
this[FlagStrings.Raw] = true;
break;
case MediaType.NintendoWiiOpticalDisc:
case SabreTools.RedumpLib.Data.MediaType.NintendoWiiOpticalDisc:
this[FlagStrings.Raw] = true;
break;
// Non-optical
case MediaType.FloppyDisk:
case SabreTools.RedumpLib.Data.MediaType.FloppyDisk:
// Currently no defaults set
break;
}
@@ -1073,12 +1079,7 @@ namespace MPF.ExecutionContexts.DiscImageCreator
return false;
// Now split the string into parts for easier validation
// https://stackoverflow.com/questions/14655023/split-a-string-that-has-white-spaces-unless-they-are-enclosed-within-quotes
parameters = parameters!.Trim();
List<string> parts = Regex.Matches(parameters, @"[\""].+?[\""]|[^ ]+", RegexOptions.Compiled)
.Cast<Match>()
.Select(m => m.Value)
.ToList();
List<string> parts = SplitParameterString(parameters!);
// Determine what the commandline should look like given the first item
BaseCommand = parts[0];
@@ -1702,43 +1703,43 @@ namespace MPF.ExecutionContexts.DiscImageCreator
switch (type)
{
case MediaType.CDROM:
if (system == RedumpSystem.SuperAudioCD)
case SabreTools.RedumpLib.Data.MediaType.CDROM:
if (system == SabreTools.RedumpLib.Data.RedumpSystem.SuperAudioCD)
BaseCommand = CommandStrings.SACD;
else
BaseCommand = CommandStrings.CompactDisc;
return;
case MediaType.DVD:
if (system == RedumpSystem.MicrosoftXbox
|| system == RedumpSystem.MicrosoftXbox360)
case SabreTools.RedumpLib.Data.MediaType.DVD:
if (system == SabreTools.RedumpLib.Data.RedumpSystem.MicrosoftXbox
|| system == SabreTools.RedumpLib.Data.RedumpSystem.MicrosoftXbox360)
{
BaseCommand = CommandStrings.XBOX;
return;
}
BaseCommand = CommandStrings.DigitalVideoDisc;
return;
case MediaType.GDROM:
case SabreTools.RedumpLib.Data.MediaType.GDROM:
BaseCommand = CommandStrings.GDROM;
return;
case MediaType.HDDVD:
case SabreTools.RedumpLib.Data.MediaType.HDDVD:
BaseCommand = CommandStrings.DigitalVideoDisc;
return;
case MediaType.BluRay:
case SabreTools.RedumpLib.Data.MediaType.BluRay:
BaseCommand = CommandStrings.BluRay;
return;
case MediaType.NintendoGameCubeGameDisc:
case SabreTools.RedumpLib.Data.MediaType.NintendoGameCubeGameDisc:
BaseCommand = CommandStrings.DigitalVideoDisc;
return;
case MediaType.NintendoWiiOpticalDisc:
case SabreTools.RedumpLib.Data.MediaType.NintendoWiiOpticalDisc:
BaseCommand = CommandStrings.DigitalVideoDisc;
return;
case MediaType.FloppyDisk:
case SabreTools.RedumpLib.Data.MediaType.FloppyDisk:
BaseCommand = CommandStrings.Floppy;
return;
case MediaType.HardDisk:
case SabreTools.RedumpLib.Data.MediaType.HardDisk:
BaseCommand = CommandStrings.Disk;
return;
case MediaType.DataCartridge:
case SabreTools.RedumpLib.Data.MediaType.DataCartridge:
BaseCommand = CommandStrings.Tape;
return;

View File

@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<VersionPrefix>3.2.3</VersionPrefix>
<VersionPrefix>3.2.4</VersionPrefix>
<WarningsNotAsErrors>NU5104</WarningsNotAsErrors>
<!-- Package Properties -->
@@ -25,29 +25,8 @@
<InternalsVisibleTo Include="MPF.Test" />
</ItemGroup>
<!-- Support All Frameworks -->
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net4`))">
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>
<!-- Support for old .NET versions -->
<ItemGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net40`))">
<PackageReference Include="MinAsyncBridge" Version="0.12.4" />
<PackageReference Include="MinTasksExtensionsBridge" Version="0.3.4" />
<PackageReference Include="MinThreadingBridge" Version="0.11.4" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SabreTools.RedumpLib" Version="1.4.4" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.5.2" />
</ItemGroup>
</Project>

View File

@@ -18,11 +18,14 @@ namespace MPF.ExecutionContexts.Redumper
public const string RefineNew = "refinenew"; // Temporary command, to be removed later
public const string Verify = "verify";
public const string DVDKey = "dvdkey";
public const string Eject = "eject";
public const string DVDIsoKey = "dvdisokey";
public const string Protection = "protection";
public const string Split = "split";
public const string Hash = "hash";
public const string Info = "info";
public const string Skeleton = "skeleton";
public const string Debug = "debug";
public const string FixMSF = "fixmsf";
}
}

View File

@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using SabreTools.RedumpLib.Data;
namespace MPF.ExecutionContexts.Redumper
@@ -21,7 +19,7 @@ namespace MPF.ExecutionContexts.Redumper
public override string? OutputPath => Path.Combine(
ImagePathValue?.Trim('"') ?? string.Empty,
ImageNameValue?.Trim('"') ?? string.Empty)
+ GetDefaultExtension(this.Type);
+ GetDefaultExtension(MediaType);
/// <inheritdoc/>
public override int? Speed => SpeedValue;
@@ -161,7 +159,12 @@ namespace MPF.ExecutionContexts.Redumper
public ExecutionContext(string? parameters) : base(parameters) { }
/// <inheritdoc/>
public ExecutionContext(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Dictionary<string, string?> options)
public ExecutionContext(RedumpSystem? system,
MediaType? type,
string? drivePath,
string filename,
int? driveSpeed,
Dictionary<string, string?> options)
: base(system, type, drivePath, filename, driveSpeed, options)
{
}
@@ -181,6 +184,7 @@ namespace MPF.ExecutionContexts.Redumper
FlagStrings.HelpShort,
FlagStrings.Version,
FlagStrings.Verbose,
FlagStrings.AutoEject,
FlagStrings.Debug,
FlagStrings.Drive,
FlagStrings.Speed,
@@ -259,6 +263,10 @@ namespace MPF.ExecutionContexts.Redumper
if (this[FlagStrings.Verbose] == true)
parameters.Add(FlagStrings.Verbose);
// Auto Eject
if (this[FlagStrings.AutoEject] == true)
parameters.Add(FlagStrings.AutoEject);
// Debug
if (this[FlagStrings.Debug] == true)
parameters.Add(FlagStrings.Debug);
@@ -268,7 +276,7 @@ namespace MPF.ExecutionContexts.Redumper
{
if (DriveValue != null)
{
if (DriveValue.Contains(' '))
if (DriveValue.Contains(" "))
parameters.Add($"{FlagStrings.Drive}=\"{DriveValue}\"");
else
parameters.Add($"{FlagStrings.Drive}={DriveValue}");
@@ -498,14 +506,14 @@ namespace MPF.ExecutionContexts.Redumper
/// <inheritdoc/>
public override bool IsDumpingCommand()
{
return this.BaseCommand == CommandStrings.NONE
|| this.BaseCommand?.Contains(CommandStrings.CD) == true
|| this.BaseCommand?.Contains(CommandStrings.DVD) == true
|| this.BaseCommand?.Contains(CommandStrings.BluRay) == true
|| this.BaseCommand?.Contains(CommandStrings.SACD) == true
|| this.BaseCommand?.Contains(CommandStrings.New) == true
|| this.BaseCommand?.Contains(CommandStrings.Dump) == true
|| this.BaseCommand?.Contains(CommandStrings.DumpNew) == true;
return BaseCommand == CommandStrings.NONE
|| BaseCommand?.Contains(CommandStrings.CD) == true
|| BaseCommand?.Contains(CommandStrings.DVD) == true
|| BaseCommand?.Contains(CommandStrings.BluRay) == true
|| BaseCommand?.Contains(CommandStrings.SACD) == true
|| BaseCommand?.Contains(CommandStrings.New) == true
|| BaseCommand?.Contains(CommandStrings.Dump) == true
|| BaseCommand?.Contains(CommandStrings.DumpNew) == true;
}
/// <inheritdoc/>
@@ -545,34 +553,37 @@ namespace MPF.ExecutionContexts.Redumper
}
/// <inheritdoc/>
protected override void SetDefaultParameters(string? drivePath, string filename, int? driveSpeed, Dictionary<string, string?> options)
protected override void SetDefaultParameters(string? drivePath,
string filename,
int? driveSpeed,
Dictionary<string, string?> options)
{
// If we don't have a CD, DVD, HD-DVD, or BD, we can't dump using redumper
if (this.Type != MediaType.CDROM
&& this.Type != MediaType.DVD
&& this.Type != MediaType.HDDVD
&& this.Type != MediaType.BluRay)
if (MediaType != SabreTools.RedumpLib.Data.MediaType.CDROM
&& MediaType != SabreTools.RedumpLib.Data.MediaType.DVD
&& MediaType != SabreTools.RedumpLib.Data.MediaType.HDDVD
&& MediaType != SabreTools.RedumpLib.Data.MediaType.BluRay)
{
return;
}
BaseCommand = CommandStrings.NONE;
switch (this.Type)
switch (MediaType)
{
case MediaType.CDROM:
ModeValues = this.System switch
case SabreTools.RedumpLib.Data.MediaType.CDROM:
ModeValues = RedumpSystem switch
{
RedumpSystem.SuperAudioCD => [CommandStrings.SACD],
_ => [CommandStrings.CD],
SabreTools.RedumpLib.Data.RedumpSystem.SuperAudioCD => [CommandStrings.SACD],
_ => [CommandStrings.CD, CommandStrings.Skeleton],
};
break;
case MediaType.DVD:
case SabreTools.RedumpLib.Data.MediaType.DVD:
ModeValues = [CommandStrings.DVD];
break;
case MediaType.HDDVD: // TODO: Keep in sync if another command string shows up
case SabreTools.RedumpLib.Data.MediaType.HDDVD: // TODO: Keep in sync if another command string shows up
ModeValues = [CommandStrings.DVD];
break;
case MediaType.BluRay:
case SabreTools.RedumpLib.Data.MediaType.BluRay:
ModeValues = [CommandStrings.BluRay];
break;
default:
@@ -651,12 +662,7 @@ namespace MPF.ExecutionContexts.Redumper
return false;
// Now split the string into parts for easier validation
// https://stackoverflow.com/questions/14655023/split-a-string-that-has-white-spaces-unless-they-are-enclosed-within-quotes
parameters = parameters!.Trim();
List<string> parts = Regex.Matches(parameters, @"([a-zA-Z\-]*=)?[\""].+?[\""]|[^ ]+", RegexOptions.Compiled)
.Cast<Match>()
.Select(m => m.Value)
.ToList();
List<string> parts = SplitParameterString(parameters!);
// Setup the modes
ModeValues = [];
@@ -683,12 +689,15 @@ namespace MPF.ExecutionContexts.Redumper
case CommandStrings.RefineNew: // Temporary command, to be removed later
case CommandStrings.Verify:
case CommandStrings.DVDKey:
case CommandStrings.Eject:
case CommandStrings.DVDIsoKey:
case CommandStrings.Protection:
case CommandStrings.Split:
case CommandStrings.Hash:
case CommandStrings.Info:
case CommandStrings.Skeleton:
case CommandStrings.Debug:
//case CommandStrings.FixMSF:
ModeValues.Add(part);
break;
@@ -898,8 +907,8 @@ namespace MPF.ExecutionContexts.Redumper
}
// If the image name was not set, set it with a default value
if (string.IsNullOrEmpty(this.ImageNameValue))
this.ImageNameValue = "track";
if (string.IsNullOrEmpty(ImageNameValue))
ImageNameValue = "track";
return true;
}

View File

@@ -10,6 +10,7 @@ namespace MPF.ExecutionContexts.Redumper
public const string HelpShort = "-h";
public const string Version = "--version";
public const string Verbose = "--verbose";
public const string AutoEject = "--auto-eject";
public const string Debug = "--debug";
public const string Drive = "--drive";
public const string Speed = "--speed";

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace MPF.Frontend.ComboBoxItems
{
@@ -40,11 +39,10 @@ namespace MPF.Frontend.ComboBoxItems
/// Generate all elements associated with the data enum type
/// </summary>
/// <returns></returns>
public static IEnumerable<Element<T>> GenerateElements()
public static List<Element<T>> GenerateElements()
{
return Enum.GetValues(typeof(T))
.OfType<T>()
.Select(e => new Element<T>(e));
var enumArr = (T[])Enum.GetValues(typeof(T));
return [.. Array.ConvertAll(enumArr, e => new Element<T>(e))];
}
/// <inheritdoc/>

View File

@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
#if NET35_OR_GREATER || NETCOREAPP
using System.Linq;
#endif
using SabreTools.RedumpLib.Data;
namespace MPF.Frontend.ComboBoxItems
@@ -50,13 +52,26 @@ namespace MPF.Frontend.ComboBoxItems
/// Generate all elements for the known system combo box
/// </summary>
/// <returns></returns>
public static IEnumerable<RedumpSystemComboBoxItem> GenerateElements()
public static List<RedumpSystemComboBoxItem> GenerateElements()
{
var knownSystems = Enum.GetValues(typeof(RedumpSystem))
.OfType<RedumpSystem?>()
.Where(s => !s.IsMarker() && s.GetCategory() != SystemCategory.NONE)
.ToList();
var enumArr = (RedumpSystem[])Enum.GetValues(typeof(RedumpSystem));
var nullableArr = Array.ConvertAll(enumArr, s => (RedumpSystem?)s);
var knownSystems = Array.FindAll(nullableArr,
s => !s.IsMarker() && s.GetCategory() != SystemCategory.NONE);
#if NET20
// The resulting dictionary does not have ordered value lists
var mapping = new Dictionary<SystemCategory, List<RedumpSystem?>>();
foreach (var knownSystem in knownSystems)
{
var category = knownSystem.GetCategory();
if (!mapping.ContainsKey(category))
mapping[category] = [];
mapping[category].Add(knownSystem);
}
#else
// The resulting dictionary has ordered value lists
Dictionary<SystemCategory, List<RedumpSystem?>> mapping = knownSystems
.GroupBy(s => s.GetCategory())
.ToDictionary(
@@ -65,6 +80,7 @@ namespace MPF.Frontend.ComboBoxItems
.OrderBy(s => s.LongName())
.ToList()
);
#endif
var systemsValues = new List<RedumpSystemComboBoxItem>
{

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
#if NET462_OR_GREATER || NETCOREAPP
using Microsoft.Management.Infrastructure;
using Microsoft.Management.Infrastructure.Generic;
@@ -136,8 +136,13 @@ namespace MPF.Frontend
public static List<Drive> CreateListOfDrives(bool ignoreFixedDrives)
{
var drives = GetDriveList(ignoreFixedDrives);
drives = [.. drives.OrderBy(i => i == null ? "\0" : i.Name)];
return drives;
drives.Sort((d1, d2) =>
{
string d1Name = d1?.Name == null ? "\0" : d1.Name;
string d2Name = d2?.Name == null ? "\0" : d2.Name;
return d1Name.CompareTo(d2Name);
});
return [.. drives];
}
/// <summary>
@@ -223,7 +228,7 @@ namespace MPF.Frontend
/// </summary>
public void RefreshDrive()
{
var driveInfo = DriveInfo.GetDrives().FirstOrDefault(d => d?.Name == Name);
var driveInfo = Array.Find(DriveInfo.GetDrives(), d => d?.Name == Name);
PopulateFromDriveInfo(driveInfo);
}
@@ -252,20 +257,18 @@ namespace MPF.Frontend
// TODO: Reduce reliance on `DriveInfo`
// https://github.com/aaru-dps/Aaru/blob/5164a154e2145941472f2ee0aeb2eff3338ecbb3/Aaru.Devices/Windows/ListDevices.cs#L66
// Create an output drive list
var drives = new List<Drive>();
// Create an output drive array
Drive[] drives = [];
// Get all standard supported drive types
try
{
drives = DriveInfo.GetDrives()
.Where(d => desiredDriveTypes.Contains(d.DriveType))
.Select(d => Create(ToInternalDriveType(d.DriveType), d.Name) ?? new Drive())
.ToList();
var filteredDrives = Array.FindAll(DriveInfo.GetDrives(), d => desiredDriveTypes.Contains(d.DriveType));
drives = Array.ConvertAll(filteredDrives, d => Create(ToInternalDriveType(d.DriveType), d.Name) ?? new Drive());
}
catch
{
return drives;
return [.. drives];
}
// Find and update all floppy drives
@@ -282,7 +285,11 @@ namespace MPF.Frontend
if (mediaType != null && ((mediaType > 0 && mediaType < 11) || (mediaType > 12 && mediaType < 22)))
{
char devId = (properties["Caption"].Value as string ?? string.Empty)[0];
drives.ForEach(d => { if (d?.Name != null && d.Name[0] == devId) { d.InternalDriveType = Frontend.InternalDriveType.Floppy; } });
Array.ForEach(drives, d =>
{
if (d?.Name != null && d.Name[0] == devId)
d.InternalDriveType = Frontend.InternalDriveType.Floppy;
});
}
}
}
@@ -292,7 +299,7 @@ namespace MPF.Frontend
}
#endif
return drives;
return [.. drives];
}
/// <summary>

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
#if NET40
using System.Threading;
@@ -200,8 +199,8 @@ namespace MPF.Frontend
// Set system, type, and drive
if (_executionContext != null)
{
_executionContext.System = _system;
_executionContext.Type = _type;
_executionContext.RedumpSystem = _system;
_executionContext.MediaType = _type;
// Set some parameters, if not already set
OutputPath ??= _executionContext.OutputPath!;
@@ -503,7 +502,7 @@ namespace MPF.Frontend
resultProgress?.Report(ResultEventArgs.Failure(txtResult));
// Write the copy protection output
if (submissionInfo?.CopyProtection?.FullProtections != null && submissionInfo.CopyProtection.FullProtections.Any())
if (submissionInfo?.CopyProtection?.FullProtections != null && submissionInfo.CopyProtection.FullProtections.Count > 0)
{
if (_options.ScanForProtection)
{
@@ -755,7 +754,7 @@ namespace MPF.Frontend
private static bool WriteProtectionData(string? outputDirectory, string? filenameSuffix, SubmissionInfo? info, bool hideDriveLetters)
{
// Check to see if the inputs are valid
if (info?.CopyProtection?.FullProtections == null || !info.CopyProtection.FullProtections.Any())
if (info?.CopyProtection?.FullProtections == null || info.CopyProtection.FullProtections.Count == 0)
return true;
// Now write out to a generic file
@@ -773,7 +772,9 @@ namespace MPF.Frontend
using var sw = new StreamWriter(File.Open(path, FileMode.Create, FileAccess.Write), Encoding.UTF8);
List<string> sortedKeys = [.. info.CopyProtection.FullProtections.Keys.OrderBy(k => k)];
List<string> sortedKeys = [.. info.CopyProtection.FullProtections.Keys];
sortedKeys.Sort();
foreach (string key in sortedKeys)
{
string scanPath = key;

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using SabreTools.RedumpLib.Data;
namespace MPF.Frontend
@@ -17,34 +16,34 @@ namespace MPF.Frontend
/// <summary>
/// Set of accepted speeds for CD and GD media
/// </summary>
public static IList<int> CD => _speedValues.Where(s => s <= 72).ToList();
public static List<int> CD => _speedValues.FindAll(s => s <= 72);
/// <summary>
/// Set of accepted speeds for DVD media
/// </summary>
public static IList<int> DVD => _speedValues.Where(s => s <= 24).ToList();
public static List<int> DVD => _speedValues.FindAll(s => s <= 24);
/// <summary>
/// Set of accepted speeds for HD-DVD media
/// </summary>
public static IList<int> HDDVD => _speedValues.Where(s => s <= 24).ToList();
public static List<int> HDDVD => _speedValues.FindAll(s => s <= 24);
/// <summary>
/// Set of accepted speeds for BD media
/// </summary>
public static IList<int> BD => _speedValues.Where(s => s <= 16).ToList();
public static List<int> BD => _speedValues.FindAll(s => s <= 16);
/// <summary>
/// Set of accepted speeds for all other media
/// </summary>
public static IList<int> Unknown => _speedValues.Where(s => s <= 1).ToList();
public static List<int> Unknown => _speedValues.FindAll(s => s <= 1);
/// <summary>
/// Get list of all drive speeds for a given MediaType
/// </summary>
/// <param name="type">MediaType? that represents the current item</param>
/// <returns>Read-only list of drive speeds</returns>
public static IList<int> GetSpeedsForMediaType(MediaType? type)
public static List<int> GetSpeedsForMediaType(MediaType? type)
{
return type switch
{

View File

@@ -2,14 +2,15 @@
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>latest</LangVersion>
<NoWarn>NU1902;NU1903</NoWarn>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<VersionPrefix>3.2.3</VersionPrefix>
<VersionPrefix>3.2.4</VersionPrefix>
<!-- Package Properties -->
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
@@ -24,31 +25,12 @@
<InternalsVisibleTo Include="MPF.Test" />
</ItemGroup>
<!-- Support All Frameworks -->
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net4`))">
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MPF.ExecutionContexts\MPF.ExecutionContexts.csproj" />
<ProjectReference Include="..\MPF.Processors\MPF.Processors.csproj" />
</ItemGroup>
<!-- Support for old .NET versions -->
<ItemGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net40`))">
<PackageReference Include="MinAsyncBridge" Version="0.12.4" />
<PackageReference Include="MinTasksExtensionsBridge" Version="0.3.4" />
<PackageReference Include="MinThreadingBridge" Version="0.11.4" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith(`net452`))">
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
</ItemGroup>
@@ -58,12 +40,12 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BinaryObjectScanner" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="3.1.16" GeneratePathProperty="true">
<PackageReference Include="BinaryObjectScanner" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="3.2.3" GeneratePathProperty="true">
<IncludeAssets>runtime; compile; build; native; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="LibIRD" Version="0.9.1" />
<PackageReference Include="LibIRD" Version="0.9.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.4.4" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.5.2" />
</ItemGroup>
</Project>

View File

@@ -671,7 +671,7 @@ namespace MPF.Frontend
/// <param name="settings"></param>
public Options(Dictionary<string, string?>? settings = null)
{
this.Settings = settings ?? [];
Settings = settings ?? [];
}
/// <summary>
@@ -688,8 +688,8 @@ namespace MPF.Frontend
/// </summary>
public string? this[string key]
{
get => this.Settings[key];
set => this.Settings[key] = value;
get => Settings[key];
set => Settings[key] = value;
}
#region Helpers

View File

@@ -32,11 +32,7 @@ namespace MPF.Frontend
public ProcessingQueue(Action<T> customProcessing)
{
#if NET20 || NET35
_internalQueue = new Queue<T>();
#else
_internalQueue = new ConcurrentQueue<T>();
#endif
_internalQueue = [];
_customProcessing = customProcessing;
_tokenSource = new CancellationTokenSource();
#if NET20 || NET35
@@ -72,11 +68,7 @@ namespace MPF.Frontend
while (true)
{
// Nothing in the queue means we get to idle
#if NET20 || NET35
if (_internalQueue.Count == 0)
#else
if (_internalQueue.IsEmpty)
#endif
{
if (_tokenSource.IsCancellationRequested)
break;

View File

@@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using SabreTools.RedumpLib.Data;
@@ -115,7 +114,7 @@ namespace MPF.Frontend.Tools
}
// If we didn't already try English, try it now
if (!languages.Contains(Language.English))
if (!Array.Exists(languages, l => l == Language.English))
return NormalizeDiscTitle(title, Language.English);
// If all fails, then the title didn't need normalization
@@ -143,7 +142,7 @@ namespace MPF.Frontend.Tools
language = Language.English;
// Get the title split into parts
string[] splitTitle = title!.Split(' ').Where(s => !string.IsNullOrEmpty(s)).ToArray();
string[] splitTitle = Array.FindAll(title!.Split(' '), s => !string.IsNullOrEmpty(s));
// If we only have one part, we can't do anything
if (splitTitle.Length <= 1)

View File

@@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
@@ -576,7 +575,7 @@ namespace MPF.Frontend.Tools
try
{
var files = Directory.GetFiles(msxc, "*", SearchOption.TopDirectoryOnly);
var filenames = files.Select(Path.GetFileName).ToArray();
var filenames = Array.ConvertAll(files, Path.GetFileName);
return string.Join("\n", filenames);
}
catch

View File

@@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
using System.IO;
#if NET35_OR_GREATER || NETCOREAPP
using System.Linq;
#endif
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BinaryObjectScanner;
using SabreTools.IO.Extensions;
namespace MPF.Frontend.Tools
{
@@ -63,14 +66,29 @@ namespace MPF.Frontend.Tools
else if (protections.Count == 0)
return "None found [OMIT FROM SUBMISSION]";
// Get an ordered list of distinct found protections
var orderedDistinctProtections = protections
// Get a list of distinct found protections
#if NET20
var protectionValues = new List<string>();
foreach (var value in protections.Values)
{
if (value.Count == 0)
continue;
foreach (var prot in value)
{
if (!protectionValues.Contains(prot))
protectionValues.Add(prot);
}
}
#else
var protectionValues = protections
.SelectMany(kvp => kvp.Value)
.Distinct()
.OrderBy(p => p);
.ToList();
#endif
// Sanitize and join protections for writing
string protectionString = SanitizeFoundProtections(orderedDistinctProtections);
string protectionString = SanitizeFoundProtections(protectionValues);
if (string.IsNullOrEmpty(protectionString))
return "None found [OMIT FROM SUBMISSION]";
@@ -90,37 +108,14 @@ namespace MPF.Frontend.Tools
#if NET40
return await Task.Factory.StartNew(() =>
{
try
{
var antiModchip = new BinaryObjectScanner.Protection.PSXAntiModchip();
foreach (string file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories))
{
try
{
byte[] fileContent = File.ReadAllBytes(file);
var protection = antiModchip.CheckContents(file, fileContent, false);
if (!string.IsNullOrEmpty(protection))
return true;
}
catch { }
}
}
catch { }
return false;
});
#else
return await Task.Run(() =>
#endif
{
try
{
var antiModchip = new BinaryObjectScanner.Protection.PSXAntiModchip();
#if NET20 || NET35
foreach (string file in Directory.GetFiles(path, "*", SearchOption.AllDirectories))
#else
foreach (string file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories))
#endif
foreach (string file in IOExtensions.SafeGetFiles(path!, "*", SearchOption.AllDirectories))
{
try
{
@@ -136,86 +131,99 @@ namespace MPF.Frontend.Tools
return false;
});
#endif
}
/// <summary>
/// Sanitize unnecessary protection duplication from output
/// </summary>
/// <param name="foundProtections">Enumerable of found protections</param>
public static string SanitizeFoundProtections(IEnumerable<string> foundProtections)
public static string SanitizeFoundProtections(List<string> foundProtections)
{
// EXCEPTIONS
if (foundProtections.Any(p => p.StartsWith("[Exception opening file")))
if (foundProtections.Exists(p => p.StartsWith("[Exception opening file")))
{
foundProtections = foundProtections.Where(p => !p.StartsWith("[Exception opening file"));
#if NET20 || NET35 || NET40 || NET452 || NET462
var tempList = new List<string> { "Exception occurred while scanning [RESCAN NEEDED]" };
tempList.AddRange(foundProtections);
foundProtections = tempList.OrderBy(p => p);
#else
foundProtections = foundProtections
.Prepend("Exception occurred while scanning [RESCAN NEEDED]")
.OrderBy(p => p);
#endif
foundProtections = foundProtections.FindAll(p => !p.StartsWith("[Exception opening file"));
foundProtections.Add("Exception occurred while scanning [RESCAN NEEDED]");
}
// ActiveMARK
if (foundProtections.Any(p => p == "ActiveMARK 5") && foundProtections.Any(p => p == "ActiveMARK"))
foundProtections = foundProtections.Where(p => p != "ActiveMARK");
if (foundProtections.Exists(p => p == "ActiveMARK 5")
&& foundProtections.Exists(p => p == "ActiveMARK"))
{
foundProtections = foundProtections.FindAll(p => p != "ActiveMARK");
}
// Cactus Data Shield
if (foundProtections.Any(p => Regex.IsMatch(p, @"Cactus Data Shield [0-9]{3} .+", RegexOptions.Compiled)) && foundProtections.Any(p => p == "Cactus Data Shield 200"))
foundProtections = foundProtections.Where(p => p != "Cactus Data Shield 200");
if (foundProtections.Exists(p => Regex.IsMatch(p, @"Cactus Data Shield [0-9]{3} .+", RegexOptions.Compiled))
&& foundProtections.Exists(p => p == "Cactus Data Shield 200"))
{
foundProtections = foundProtections.FindAll(p => p != "Cactus Data Shield 200");
}
// CD-Check
foundProtections = foundProtections.Where(p => p != "Executable-Based CD Check");
foundProtections = foundProtections.FindAll(p => p != "Executable-Based CD Check");
// CD-Cops
if (foundProtections.Any(p => p == "CD-Cops") && foundProtections.Any(p => p.StartsWith("CD-Cops") && p.Length > "CD-Cops".Length))
foundProtections = foundProtections.Where(p => p != "CD-Cops");
if (foundProtections.Exists(p => p == "CD-Cops") && foundProtections.Exists(p => p.StartsWith("CD-Cops") && p.Length > "CD-Cops".Length))
foundProtections = foundProtections.FindAll(p => p != "CD-Cops");
// CD-Key / Serial
foundProtections = foundProtections.Where(p => p != "CD-Key / Serial");
foundProtections = foundProtections.FindAll(p => p != "CD-Key / Serial");
// Electronic Arts
if (foundProtections.Any(p => p == "EA CdKey Registration Module") && foundProtections.Any(p => p.StartsWith("EA CdKey Registration Module") && p.Length > "EA CdKey Registration Module".Length))
foundProtections = foundProtections.Where(p => p != "EA CdKey Registration Module");
if (foundProtections.Any(p => p == "EA DRM Protection") && foundProtections.Any(p => p.StartsWith("EA DRM Protection") && p.Length > "EA DRM Protection".Length))
foundProtections = foundProtections.Where(p => p != "EA DRM Protection");
if (foundProtections.Exists(p => p == "EA CdKey Registration Module")
&& foundProtections.Exists(p => p.StartsWith("EA CdKey Registration Module")
&& p.Length > "EA CdKey Registration Module".Length))
{
foundProtections = foundProtections.FindAll(p => p != "EA CdKey Registration Module");
}
if (foundProtections.Exists(p => p == "EA DRM Protection")
&& foundProtections.Exists(p => p.StartsWith("EA DRM Protection")
&& p.Length > "EA DRM Protection".Length))
{
foundProtections = foundProtections.FindAll(p => p != "EA DRM Protection");
}
// Games for Windows LIVE
if (foundProtections.Any(p => p == "Games for Windows LIVE") && foundProtections.Any(p => p.StartsWith("Games for Windows LIVE") && !p.Contains("Zero Day Piracy Protection") && p.Length > "Games for Windows LIVE".Length))
foundProtections = foundProtections.Where(p => p != "Games for Windows LIVE");
if (foundProtections.Exists(p => p == "Games for Windows LIVE")
&& foundProtections.Exists(p => p.StartsWith("Games for Windows LIVE")
&& !p.Contains("Zero Day Piracy Protection")
&& p.Length > "Games for Windows LIVE".Length))
{
foundProtections = foundProtections.FindAll(p => p != "Games for Windows LIVE");
}
// Impulse Reactor
if (foundProtections.Any(p => p.StartsWith("Impulse Reactor Core Module")) && foundProtections.Any(p => p == "Impulse Reactor"))
foundProtections = foundProtections.Where(p => p != "Impulse Reactor");
if (foundProtections.Exists(p => p.StartsWith("Impulse Reactor Core Module"))
&& foundProtections.Exists(p => p == "Impulse Reactor"))
{
foundProtections = foundProtections.FindAll(p => p != "Impulse Reactor");
}
// JoWood X-Prot
if (foundProtections.Any(p => p.StartsWith("JoWood X-Prot")))
if (foundProtections.Exists(p => p.StartsWith("JoWood X-Prot")))
{
if (foundProtections.Any(p => Regex.IsMatch(p, @"JoWood X-Prot [0-9]\.[0-9]\.[0-9]\.[0-9]{2}", RegexOptions.Compiled)))
if (foundProtections.Exists(p => Regex.IsMatch(p, @"JoWood X-Prot [0-9]\.[0-9]\.[0-9]\.[0-9]{2}", RegexOptions.Compiled)))
{
foundProtections = foundProtections.Where(p => p != "JoWood X-Prot")
.Where(p => p != "JoWood X-Prot v1.0-v1.3")
.Where(p => p != "JoWood X-Prot v1.4+")
.Where(p => p != "JoWood X-Prot v2");
foundProtections = foundProtections.FindAll(p => p != "JoWood X-Prot")
.FindAll(p => p != "JoWood X-Prot v1.0-v1.3")
.FindAll(p => p != "JoWood X-Prot v1.4+")
.FindAll(p => p != "JoWood X-Prot v2");
}
else if (foundProtections.Any(p => p == "JoWood X-Prot v2"))
else if (foundProtections.Exists(p => p == "JoWood X-Prot v2"))
{
foundProtections = foundProtections.Where(p => p != "JoWood X-Prot")
.Where(p => p != "JoWood X-Prot v1.0-v1.3")
.Where(p => p != "JoWood X-Prot v1.4+");
foundProtections = foundProtections.FindAll(p => p != "JoWood X-Prot")
.FindAll(p => p != "JoWood X-Prot v1.0-v1.3")
.FindAll(p => p != "JoWood X-Prot v1.4+");
}
else if (foundProtections.Any(p => p == "JoWood X-Prot v1.4+"))
else if (foundProtections.Exists(p => p == "JoWood X-Prot v1.4+"))
{
foundProtections = foundProtections.Where(p => p != "JoWood X-Prot")
.Where(p => p != "JoWood X-Prot v1.0-v1.3");
foundProtections = foundProtections.FindAll(p => p != "JoWood X-Prot")
.FindAll(p => p != "JoWood X-Prot v1.0-v1.3");
}
else if (foundProtections.Any(p => p == "JoWood X-Prot v1.0-v1.3"))
else if (foundProtections.Exists(p => p == "JoWood X-Prot v1.0-v1.3"))
{
foundProtections = foundProtections.Where(p => p != "JoWood X-Prot");
foundProtections = foundProtections.FindAll(p => p != "JoWood X-Prot");
}
}
@@ -223,7 +231,7 @@ namespace MPF.Frontend.Tools
// TODO: Figure this one out
// Online Registration
foundProtections = foundProtections.Where(p => !p.StartsWith("Executable-Based Online Registration"));
foundProtections = foundProtections.FindAll(p => !p.StartsWith("Executable-Based Online Registration"));
// ProtectDISC / VOB ProtectCD/DVD
// TODO: Figure this one out
@@ -232,136 +240,127 @@ namespace MPF.Frontend.Tools
// TODO: Figure this one out
// Cactus Data Shield / SafeDisc
if (foundProtections.Any(p => p == "Cactus Data Shield 300 (Confirm presence of other CDS-300 files)"))
if (foundProtections.Exists(p => p == "Cactus Data Shield 300 (Confirm presence of other CDS-300 files)"))
{
foundProtections = foundProtections
.Where(p => p != "Cactus Data Shield 300 (Confirm presence of other CDS-300 files)");
.FindAll(p => p != "Cactus Data Shield 300 (Confirm presence of other CDS-300 files)");
if (foundProtections.Any(p => !p.StartsWith("SafeDisc")))
{
#if NET20 || NET35 || NET40 || NET452 || NET462
var tempList = new List<string>();
tempList.AddRange(foundProtections);
tempList.Add("Cactus Data Shield 300");
foundProtections = tempList;
#else
foundProtections = foundProtections.Append("Cactus Data Shield 300");
#endif
}
if (foundProtections.Exists(p => !p.StartsWith("SafeDisc")))
foundProtections.Add("Cactus Data Shield 300");
}
// SafeDisc
if (foundProtections.Any(p => p.StartsWith("SafeDisc")))
if (foundProtections.Exists(p => p.StartsWith("SafeDisc")))
{
// Confirmed this set of checks works with Redump entries 10430, 11347, 13230, 18614, 28257, 31149, 31824, 52606, 57721, 58455, 58573, 62935, 63941, 64255, 65569, 66005, 70504, 73502, 74520, 78048, 79729, 83468, 98589, and 101261.
// Best case scenario for SafeDisc 2+: A full SafeDisc version is found in a line starting with "Macrovision Protected Application". All other SafeDisc detections can be safely scrubbed.
// TODO: Scrub "Macrovision Protected Application, " from before the SafeDisc version.
if (foundProtections.Any(p => Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled) && p.StartsWith("Macrovision Protected Application") && !p.Contains("SRV Tool APP")))
if (foundProtections.Exists(p => Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled) && p.StartsWith("Macrovision Protected Application") && !p.Contains("SRV Tool APP")))
{
foundProtections = foundProtections.Where(p => !p.StartsWith("Macrovision Protection File"))
.Where(p => !p.StartsWith("Macrovision Security Driver"))
.Where(p => !p.Contains("SRV Tool APP"))
.Where(p => p != "SafeDisc")
.Where(p => !p.StartsWith("Macrovision Protected Application [Version Expunged]"))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\/4\+", RegexOptions.Compiled)))
.Where(p => p != "SafeDisc 1/Lite")
.Where(p => p != "SafeDisc 2+")
.Where(p => p != "SafeDisc 3+ (DVD)");
foundProtections = foundProtections.FindAll(p => !p.StartsWith("Macrovision Protection File"))
.FindAll(p => !p.StartsWith("Macrovision Security Driver"))
.FindAll(p => !p.Contains("SRV Tool APP"))
.FindAll(p => p != "SafeDisc")
.FindAll(p => !p.StartsWith("Macrovision Protected Application [Version Expunged]"))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\/4\+", RegexOptions.Compiled)))
.FindAll(p => p != "SafeDisc 1/Lite")
.FindAll(p => p != "SafeDisc 2+")
.FindAll(p => p != "SafeDisc 3+ (DVD)");
}
// Next best case for SafeDisc 2+: A full SafeDisc version is found from the "SafeDisc SRV Tool APP".
else if (foundProtections.Any(p => Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled) && p.StartsWith("Macrovision Protected Application") && p.Contains("SRV Tool APP")))
else if (foundProtections.Exists(p => Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled) && p.StartsWith("Macrovision Protected Application") && p.Contains("SRV Tool APP")))
{
foundProtections = foundProtections.Where(p => !p.StartsWith("Macrovision Protection File"))
.Where(p => !p.StartsWith("Macrovision Security Driver"))
.Where(p => p != "SafeDisc")
.Where(p => !p.StartsWith("Macrovision Protected Application [Version Expunged]"))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\/4\+", RegexOptions.Compiled)))
.Where(p => p != "SafeDisc 1/Lite")
.Where(p => p != "SafeDisc 2+")
.Where(p => p != "SafeDisc 3+ (DVD)");
foundProtections = foundProtections.FindAll(p => !p.StartsWith("Macrovision Protection File"))
.FindAll(p => !p.StartsWith("Macrovision Security Driver"))
.FindAll(p => p != "SafeDisc")
.FindAll(p => !p.StartsWith("Macrovision Protected Application [Version Expunged]"))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\/4\+", RegexOptions.Compiled)))
.FindAll(p => p != "SafeDisc 1/Lite")
.FindAll(p => p != "SafeDisc 2+")
.FindAll(p => p != "SafeDisc 3+ (DVD)");
}
// Covers specific edge cases where older drivers are erroneously placed in discs with a newer version of SafeDisc, and the specific SafeDisc version is expunged.
else if (foundProtections.Any(p => Regex.IsMatch(p, @"SafeDisc [1-2]\.[0-9]{2}\.[0-9]{3}-[1-2]\.[0-9]{2}\.[0-9]{3}$", RegexOptions.Compiled) || Regex.IsMatch(p, @"SafeDisc [1-2]\.[0-9]{2}\.[0-9]{3}$", RegexOptions.Compiled)) && foundProtections.Any(p => p == "SafeDisc 3+ (DVD)"))
else if (foundProtections.Exists(p => Regex.IsMatch(p, @"SafeDisc [1-2]\.[0-9]{2}\.[0-9]{3}-[1-2]\.[0-9]{2}\.[0-9]{3}$", RegexOptions.Compiled) || Regex.IsMatch(p, @"SafeDisc [1-2]\.[0-9]{2}\.[0-9]{3}$", RegexOptions.Compiled)) && foundProtections.Exists(p => p == "SafeDisc 3+ (DVD)"))
{
foundProtections = foundProtections.Where(p => !p.StartsWith("Macrovision Protection File"))
.Where(p => !p.StartsWith("Macrovision Protected Application [Version Expunged]"))
.Where(p => !p.StartsWith("Macrovision Security Driver"))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [1-2]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [1-2]\.[0-9]{2}\.[0-9]{3}-[1-2]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.Where(p => p != "SafeDisc")
.Where(p => p != "SafeDisc 1/Lite")
.Where(p => p != "SafeDisc 2+");
foundProtections = foundProtections.FindAll(p => !p.StartsWith("Macrovision Protection File"))
.FindAll(p => !p.StartsWith("Macrovision Protected Application [Version Expunged]"))
.FindAll(p => !p.StartsWith("Macrovision Security Driver"))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [1-2]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [1-2]\.[0-9]{2}\.[0-9]{3}-[1-2]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.FindAll(p => p != "SafeDisc")
.FindAll(p => p != "SafeDisc 1/Lite")
.FindAll(p => p != "SafeDisc 2+");
}
// Best case for SafeDisc 1.X: A full SafeDisc version is found that isn't part of a version range.
else if (foundProtections.Any(p => Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}$", RegexOptions.Compiled) && !(Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled))))
else if (foundProtections.Exists(p => Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}$", RegexOptions.Compiled) && !(Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled))))
{
foundProtections = foundProtections.Where(p => !p.StartsWith("Macrovision Protection File"))
.Where(p => !p.StartsWith("Macrovision Security Driver"))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.Where(p => p != "SafeDisc")
.Where(p => p != "SafeDisc 1")
.Where(p => p != "SafeDisc 1/Lite");
foundProtections = foundProtections.FindAll(p => !p.StartsWith("Macrovision Protection File"))
.FindAll(p => !p.StartsWith("Macrovision Security Driver"))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.FindAll(p => p != "SafeDisc")
.FindAll(p => p != "SafeDisc 1")
.FindAll(p => p != "SafeDisc 1/Lite");
}
// Next best case for SafeDisc 1: A SafeDisc version range is found from "SECDRV.SYS".
// TODO: Scrub "Macrovision Security Driver {Version}" from before the SafeDisc version.
else if (foundProtections.Any(p => p.StartsWith("Macrovision Security Driver") && Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-[1-2]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled) || Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}$")))
else if (foundProtections.Exists(p => p.StartsWith("Macrovision Security Driver") && Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-[1-2]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled) || Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}$")))
{
foundProtections = foundProtections.Where(p => !p.StartsWith("Macrovision Protection File"))
.Where(p => !p.StartsWith("Macrovision Protected Application [Version Expunged]"))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.Where(p => p != "SafeDisc")
.Where(p => p != "SafeDisc 1")
.Where(p => p != "SafeDisc 1/Lite");
foundProtections = foundProtections.FindAll(p => !p.StartsWith("Macrovision Protection File"))
.FindAll(p => !p.StartsWith("Macrovision Protected Application [Version Expunged]"))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.FindAll(p => p != "SafeDisc")
.FindAll(p => p != "SafeDisc 1")
.FindAll(p => p != "SafeDisc 1/Lite");
}
// Next best case for SafeDisc 2+: A SafeDisc version range is found from "SECDRV.SYS".
// TODO: Scrub "Macrovision Security Driver {Version}" from before the SafeDisc version.
else if (foundProtections.Any(p => p.StartsWith("Macrovision Security Driver")))
else if (foundProtections.Exists(p => p.StartsWith("Macrovision Security Driver")))
{
foundProtections = foundProtections.Where(p => !p.StartsWith("Macrovision Protection File"))
.Where(p => !p.StartsWith("Macrovision Protected Application [Version Expunged]"))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.Where(p => p != "SafeDisc")
.Where(p => p != "SafeDisc 1")
.Where(p => p != "SafeDisc 1/Lite")
.Where(p => p != "SafeDisc 2+")
.Where(p => p != "SafeDisc 3+ (DVD)");
foundProtections = foundProtections.FindAll(p => !p.StartsWith("Macrovision Protection File"))
.FindAll(p => !p.StartsWith("Macrovision Protected Application [Version Expunged]"))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
.FindAll(p => p != "SafeDisc")
.FindAll(p => p != "SafeDisc 1")
.FindAll(p => p != "SafeDisc 1/Lite")
.FindAll(p => p != "SafeDisc 2+")
.FindAll(p => p != "SafeDisc 3+ (DVD)");
}
// Only SafeDisc Lite is found.
else if (foundProtections.Any(p => p == "SafeDisc Lite"))
else if (foundProtections.Exists(p => p == "SafeDisc Lite"))
{
foundProtections = foundProtections.Where(p => p != "SafeDisc")
.Where(p => !(Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-1\.[0-9]{2}\.[0-9]{3}\/Lite", RegexOptions.Compiled)));
foundProtections = foundProtections.FindAll(p => p != "SafeDisc")
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc 1\.[0-9]{2}\.[0-9]{3}-1\.[0-9]{2}\.[0-9]{3}\/Lite", RegexOptions.Compiled)));
}
// Only SafeDisc 3+ is found.
else if (foundProtections.Any(p => p == "SafeDisc 3+ (DVD)"))
else if (foundProtections.Exists(p => p == "SafeDisc 3+ (DVD)"))
{
foundProtections = foundProtections.Where(p => p != "SafeDisc")
.Where(p => p != "SafeDisc 2+")
.Where(p => !p.StartsWith("Macrovision Protection File"))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)));
foundProtections = foundProtections.FindAll(p => p != "SafeDisc")
.FindAll(p => p != "SafeDisc 2+")
.FindAll(p => !p.StartsWith("Macrovision Protection File"))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)));
}
// Only SafeDisc 2+ is found.
else if (foundProtections.Any(p => p == "SafeDisc 2+"))
else if (foundProtections.Exists(p => p == "SafeDisc 2+"))
{
foundProtections = foundProtections.Where(p => p != "SafeDisc")
.Where(p => !p.StartsWith("Macrovision Protection File"))
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)));
foundProtections = foundProtections.FindAll(p => p != "SafeDisc")
.FindAll(p => !p.StartsWith("Macrovision Protection File"))
.FindAll(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}\+", RegexOptions.Compiled)));
}
}
@@ -372,44 +371,52 @@ namespace MPF.Frontend.Tools
// TODO: Figure this one out
// StarForce
if (foundProtections.Any(p => p.StartsWith("StarForce")))
if (foundProtections.Exists(p => p.StartsWith("StarForce")))
{
if (foundProtections.Any(p => Regex.IsMatch(p, @"StarForce [0-9]+\..+", RegexOptions.Compiled)))
if (foundProtections.Exists(p => Regex.IsMatch(p, @"StarForce [0-9]+\..+", RegexOptions.Compiled)))
{
foundProtections = foundProtections.Where(p => p != "StarForce")
.Where(p => p != "StarForce 3-5")
.Where(p => p != "StarForce 5")
.Where(p => p != "StarForce 5 [Protected Module]");
foundProtections = foundProtections.FindAll(p => p != "StarForce")
.FindAll(p => p != "StarForce 3-5")
.FindAll(p => p != "StarForce 5")
.FindAll(p => p != "StarForce 5 [Protected Module]");
}
else if (foundProtections.Any(p => p == "StarForce 5 [Protected Module]"))
else if (foundProtections.Exists(p => p == "StarForce 5 [Protected Module]"))
{
foundProtections = foundProtections.Where(p => p != "StarForce")
.Where(p => p != "StarForce 3-5")
.Where(p => p != "StarForce 5");
foundProtections = foundProtections.FindAll(p => p != "StarForce")
.FindAll(p => p != "StarForce 3-5")
.FindAll(p => p != "StarForce 5");
}
else if (foundProtections.Any(p => p == "StarForce 5"))
else if (foundProtections.Exists(p => p == "StarForce 5"))
{
foundProtections = foundProtections.Where(p => p != "StarForce")
.Where(p => p != "StarForce 3-5");
foundProtections = foundProtections.FindAll(p => p != "StarForce")
.FindAll(p => p != "StarForce 3-5");
}
else if (foundProtections.Any(p => p == "StarForce 3-5"))
else if (foundProtections.Exists(p => p == "StarForce 3-5"))
{
foundProtections = foundProtections.Where(p => p != "StarForce");
foundProtections = foundProtections.FindAll(p => p != "StarForce");
}
}
// Sysiphus
if (foundProtections.Any(p => p == "Sysiphus") && foundProtections.Any(p => p.StartsWith("Sysiphus") && p.Length > "Sysiphus".Length))
foundProtections = foundProtections.Where(p => p != "Sysiphus");
if (foundProtections.Exists(p => p == "Sysiphus")
&& foundProtections.Exists(p => p.StartsWith("Sysiphus") && p.Length > "Sysiphus".Length))
{
foundProtections = foundProtections.FindAll(p => p != "Sysiphus");
}
// TAGES
// TODO: Figure this one out
// XCP
if (foundProtections.Any(p => p == "XCP") && foundProtections.Any(p => p.StartsWith("XCP") && p.Length > "XCP".Length))
foundProtections = foundProtections.Where(p => p != "XCP");
if (foundProtections.Exists(p => p == "XCP")
&& foundProtections.Exists(p => p.StartsWith("XCP") && p.Length > "XCP".Length))
{
foundProtections = foundProtections.FindAll(p => p != "XCP");
}
return string.Join(", ", foundProtections.ToArray());
// Sort and return the protections
foundProtections.Sort();
return string.Join(", ", [.. foundProtections]);
}
}
}

View File

@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
#if NET35_OR_GREATER || NETCOREAPP
using System.Linq;
#endif
using System.Threading.Tasks;
using BinaryObjectScanner;
using MPF.Processors;
@@ -85,11 +87,7 @@ namespace MPF.Frontend.Tools
// Get a list of matching IDs for each line in the DAT
if (!string.IsNullOrEmpty(info.TracksAndWriteOffsets!.ClrMameProData) && options.HasRedumpLogin)
#if NET40
_ = FillFromRedump(options, info, resultProgress);
#else
_ = await FillFromRedump(options, info, resultProgress);
#endif
// If we have both ClrMamePro and Size and Checksums data, remove the ClrMamePro
if (!string.IsNullOrEmpty(info.SizeAndChecksums?.CRC32))
@@ -159,7 +157,9 @@ namespace MPF.Frontend.Tools
/// <param name="options">Options object representing user-defined options</param>
/// <param name="info">Existing SubmissionInfo object to fill</param>
/// <param name="resultProgress">Optional result progress callback</param>
public async static Task<bool> FillFromRedump(Frontend.Options options, SubmissionInfo info, IProgress<ResultEventArgs>? resultProgress = null)
public async static Task<bool> FillFromRedump(Frontend.Options options,
SubmissionInfo info,
IProgress<ResultEventArgs>? resultProgress = null)
{
// If no username is provided
if (string.IsNullOrEmpty(options.RedumpUsername) || string.IsNullOrEmpty(options.RedumpPassword))
@@ -236,32 +236,32 @@ namespace MPF.Frontend.Tools
foundIdSets.Add(foundIds?.ToArray() ?? []);
// Ensure that all tracks are found
allFound &= (foundIds != null && foundIds.Count == 1);
allFound &= (foundIds != null && foundIds.Count >= 1);
}
// If all tracks were found, check if there are any fully-matched IDs
List<int>? fullyMatchedIDs = null;
HashSet<int>? fullyMatchedIdsSet = null;
if (allFound)
{
fullyMatchedIDs = null;
fullyMatchedIdsSet = null;
foreach (var set in foundIdSets)
{
// First track is always all IDs
if (fullyMatchedIDs == null)
if (fullyMatchedIdsSet == null)
{
fullyMatchedIDs = [.. set];
fullyMatchedIdsSet = [.. set];
continue;
}
// Try to intersect with all known IDs
fullyMatchedIDs = fullyMatchedIDs.Intersect(set).ToList();
if (!fullyMatchedIDs.Any())
fullyMatchedIdsSet.IntersectWith(set);
if (fullyMatchedIdsSet.Count == 0)
break;
}
}
// If we don't have any matches but we have a universal hash
if (!info.PartiallyMatchedIDs.Any() && info.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.UniversalHash) == true)
if (info.PartiallyMatchedIDs.Count == 0 && info.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.UniversalHash) == true)
{
string sha1 = info.CommonDiscInfo.CommentsSpecialFields[SiteCode.UniversalHash];
var foundIds = await Validator.ValidateUniversalHash(wc, info);
@@ -276,50 +276,44 @@ namespace MPF.Frontend.Tools
allFound = (foundIds != null && foundIds.Count == 1);
// If we found a match, then the disc is a match
if ((foundIds != null && foundIds.Count == 1) && foundIds != null)
fullyMatchedIDs = foundIds;
if (foundIds != null && foundIds.Count == 1)
fullyMatchedIdsSet = [.. foundIds];
else
fullyMatchedIDs = [];
fullyMatchedIdsSet = [];
}
// Make sure we only have unique IDs
info.PartiallyMatchedIDs = [.. info.PartiallyMatchedIDs.Distinct().OrderBy(id => id)];
// Get a list version of the fully matched IDs
List<int> fullyMatchedIdsList = fullyMatchedIdsSet != null ? [.. fullyMatchedIdsSet] : [];
resultProgress?.Report(ResultEventArgs.Success("Match finding complete! " + (fullyMatchedIDs != null && fullyMatchedIDs.Count > 0
? "Fully Matched IDs: " + string.Join(",", fullyMatchedIDs.Select(i => i.ToString()).ToArray())
// Make sure we only have unique IDs
var partiallyMatchedIds = new HashSet<int>();
partiallyMatchedIds.IntersectWith(info.PartiallyMatchedIDs);
info.PartiallyMatchedIDs = [.. partiallyMatchedIds];
info.PartiallyMatchedIDs.Sort();
resultProgress?.Report(ResultEventArgs.Success("Match finding complete! " + (fullyMatchedIdsList != null && fullyMatchedIdsList.Count > 0
? "Fully Matched IDs: " + string.Join(",", [.. fullyMatchedIdsList.ConvertAll(i => i.ToString())])
: "No matches found")));
// Exit early if one failed or there are no matched IDs
if (!allFound || fullyMatchedIDs == null || fullyMatchedIDs.Count == 0)
if (!allFound || fullyMatchedIdsList == null || fullyMatchedIdsList.Count == 0)
return false;
// Find the first matched ID where the track count matches, we can grab a bunch of info from it
int totalMatchedIDsCount = fullyMatchedIDs.Count;
int totalMatchedIDsCount = fullyMatchedIdsList.Count;
for (int i = 0; i < totalMatchedIDsCount; i++)
{
// Skip if the track count doesn't match
#if NET40
var validateTask = Validator.ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount);
validateTask.Wait();
if (!validateTask.Result)
#else
if (!await Validator.ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount))
#endif
if (!await Validator.ValidateTrackCount(wc, fullyMatchedIdsList[i], trackCount))
continue;
// Fill in the fields from the existing ID
resultProgress?.Report(ResultEventArgs.Success($"Filling fields from existing ID {fullyMatchedIDs[i]}..."));
#if NET40
var fillTask = Task.Factory.StartNew(() => Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation));
fillTask.Wait();
_ = fillTask.Result;
#else
_ = await Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation);
#endif
resultProgress?.Report(ResultEventArgs.Success($"Filling fields from existing ID {fullyMatchedIdsList[i]}..."));
_ = await Builder.FillFromId(wc, info, fullyMatchedIdsList[i], options.PullAllInformation);
resultProgress?.Report(ResultEventArgs.Success("Information filling complete!"));
// Set the fully matched ID to the current
info.FullyMatchedID = fullyMatchedIDs[i];
info.FullyMatchedID = fullyMatchedIdsList[i];
break;
}
@@ -424,7 +418,13 @@ namespace MPF.Frontend.Tools
}
// If only one label, don't mention fs
#if NET20
string[] keyArr = new string[labels.Count];
labels.Keys.CopyTo(keyArr, 0);
string firstLabel = keyArr[0];
#else
string firstLabel = labels.First().Key;
#endif
if (labels.Count == 1 && (firstLabel == driveLabel || driveLabel == null))
{
// Ignore common volume labels
@@ -450,7 +450,7 @@ namespace MPF.Frontend.Tools
}
// Ensure that no labels are empty
volLabels = volLabels.Where(l => !string.IsNullOrEmpty(l?.Trim())).ToList();
volLabels = volLabels.FindAll(l => !string.IsNullOrEmpty(l?.Trim()));
// Print each label separated by a comma and a space
if (volLabels.Count == 0)
@@ -828,7 +828,7 @@ namespace MPF.Frontend.Tools
SetCommentFieldIfNotExists(info, SiteCode.InternalSerialName, drive, PhysicalTool.GetPlayStation3Serial);
SetVersionIfNotExists(info, drive, PhysicalTool.GetPlayStation3Version);
SetCommentFieldIfNotExists(info, SiteCode.Patches, drive, FormatPlayStation3FirmwareVersion);
SetContentFieldIfNotExists(info, SiteCode.Patches, drive, FormatPlayStation3FirmwareVersion);
break;
case RedumpSystem.SonyPlayStation4:
@@ -898,6 +898,38 @@ namespace MPF.Frontend.Tools
info.CommonDiscInfo!.CommentsSpecialFields![key] = valueFunc(drive) ?? string.Empty;
}
/// <summary>
/// Determine if a content field exists based on key
/// </summary>
private static bool ContentFieldExists(SubmissionInfo info, SiteCode key, out string? value)
{
// Ensure the contents fields exist
if (info.CommonDiscInfo!.ContentsSpecialFields == null)
info.CommonDiscInfo.ContentsSpecialFields = [];
// Check if the field exists
if (!info.CommonDiscInfo.ContentsSpecialFields.TryGetValue(key, out value))
return false;
if (string.IsNullOrEmpty(value))
return false;
// The value is valid
return true;
}
/// <summary>
/// Set a content field if it doesn't already have a value
/// </summary>
private static void SetContentFieldIfNotExists(SubmissionInfo info, SiteCode key, Drive? drive, Func<Drive?, string?> valueFunc)
{
// If the field has a valid value, skip
if (ContentFieldExists(info, key, out _))
return;
// Set the value
info.CommonDiscInfo!.ContentsSpecialFields![key] = valueFunc(drive) ?? string.Empty;
}
/// <summary>
/// Set the version if it doesn't already have a value
/// </summary>

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using BinaryObjectScanner;
using MPF.Frontend.ComboBoxItems;
@@ -260,7 +259,7 @@ namespace MPF.Frontend.ViewModels
CancelButtonEnabled = true;
MediaTypes = [];
Systems = RedumpSystemComboBoxItem.GenerateElements().ToList();
Systems = RedumpSystemComboBoxItem.GenerateElements();
InternalPrograms = [];
PopulateMediaType();
@@ -296,7 +295,7 @@ namespace MPF.Frontend.ViewModels
public void ChangeSystem()
{
PopulateMediaType();
this.CheckDumpButtonEnabled = ShouldEnableCheckDumpButton();
CheckDumpButtonEnabled = ShouldEnableCheckDumpButton();
}
/// <summary>
@@ -304,7 +303,7 @@ namespace MPF.Frontend.ViewModels
/// </summary>
public void ChangeMediaType()
{
this.CheckDumpButtonEnabled = ShouldEnableCheckDumpButton();
CheckDumpButtonEnabled = ShouldEnableCheckDumpButton();
}
/// <summary>
@@ -312,7 +311,7 @@ namespace MPF.Frontend.ViewModels
/// </summary>
public void ChangeDumpingProgram()
{
this.CheckDumpButtonEnabled = ShouldEnableCheckDumpButton();
CheckDumpButtonEnabled = ShouldEnableCheckDumpButton();
}
/// <summary>
@@ -320,7 +319,7 @@ namespace MPF.Frontend.ViewModels
/// </summary>
public void ChangeInputPath()
{
this.CheckDumpButtonEnabled = ShouldEnableCheckDumpButton();
CheckDumpButtonEnabled = ShouldEnableCheckDumpButton();
}
#endregion
@@ -368,20 +367,20 @@ namespace MPF.Frontend.ViewModels
bool cachedCanExecuteSelectionChanged = CanExecuteSelectionChanged;
DisableEventHandlers();
if (this.CurrentSystem != null)
if (CurrentSystem != null)
{
var mediaTypeValues = this.CurrentSystem.MediaTypes();
int index = mediaTypeValues.FindIndex(m => m == this.CurrentMediaType);
var mediaTypeValues = CurrentSystem.MediaTypes();
int index = mediaTypeValues.FindIndex(m => m == CurrentMediaType);
MediaTypes = mediaTypeValues.Select(m => new Element<MediaType>(m ?? MediaType.NONE)).ToList();
this.MediaTypeComboBoxEnabled = MediaTypes.Count > 1;
this.CurrentMediaType = (index > -1 ? MediaTypes[index] : MediaTypes[0]);
MediaTypes = mediaTypeValues.ConvertAll(m => new Element<MediaType>(m ?? MediaType.NONE));
MediaTypeComboBoxEnabled = MediaTypes.Count > 1;
CurrentMediaType = (index > -1 ? MediaTypes[index] : MediaTypes[0]);
}
else
{
this.MediaTypeComboBoxEnabled = false;
this.MediaTypes = null;
this.CurrentMediaType = null;
MediaTypeComboBoxEnabled = false;
MediaTypes = null;
CurrentMediaType = null;
}
// Reenable event handlers, if necessary
@@ -398,15 +397,15 @@ namespace MPF.Frontend.ViewModels
DisableEventHandlers();
// Get the current internal program
InternalProgram internalProgram = this.Options.InternalProgram;
InternalProgram internalProgram = Options.InternalProgram;
// Create a static list of supported Check programs, not everything
var internalPrograms = new List<InternalProgram> { InternalProgram.Redumper, InternalProgram.Aaru, InternalProgram.DiscImageCreator, InternalProgram.CleanRip, InternalProgram.PS3CFW, InternalProgram.UmdImageCreator, InternalProgram.XboxBackupCreator };
InternalPrograms = internalPrograms.Select(ip => new Element<InternalProgram>(ip)).ToList();
InternalPrograms = internalPrograms.ConvertAll(ip => new Element<InternalProgram>(ip));
// Select the current default dumping program
int currentIndex = InternalPrograms.FindIndex(m => m == internalProgram);
this.CurrentProgram = (currentIndex > -1 ? InternalPrograms[currentIndex].Value : InternalPrograms[0].Value);
CurrentProgram = (currentIndex > -1 ? InternalPrograms[currentIndex].Value : InternalPrograms[0].Value);
// Reenable event handlers, if necessary
if (cachedCanExecuteSelectionChanged) EnableEventHandlers();
@@ -418,7 +417,7 @@ namespace MPF.Frontend.ViewModels
private bool ShouldEnableCheckDumpButton()
{
return this.CurrentSystem != null && this.CurrentMediaType != null && !string.IsNullOrEmpty(this.InputPath);
return CurrentSystem != null && CurrentMediaType != null && !string.IsNullOrEmpty(InputPath);
}
/// <summary>
@@ -450,7 +449,7 @@ namespace MPF.Frontend.ViewModels
if (string.IsNullOrEmpty(InputPath))
return "Invalid Input path";
if (!File.Exists(this.InputPath!.Trim('"')))
if (!File.Exists(InputPath!.Trim('"')))
return "Input Path is not a valid file";
// Disable UI while Check is running
@@ -459,7 +458,7 @@ namespace MPF.Frontend.ViewModels
DisableEventHandlers();
// Populate an environment
var env = new DumpEnvironment(Options, Path.GetFullPath(this.InputPath.Trim('"')), null, this.CurrentSystem, this.CurrentMediaType, this.CurrentProgram, parameters: null);
var env = new DumpEnvironment(Options, Path.GetFullPath(InputPath.Trim('"')), null, CurrentSystem, CurrentMediaType, CurrentProgram, parameters: null);
// Make new Progress objects
var resultProgress = new Progress<ResultEventArgs>();

View File

@@ -1,5 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System;
using System.Collections.Generic;
using MPF.Frontend.ComboBoxItems;
using MPF.Frontend.Tools;
using SabreTools.RedumpLib.Data;
@@ -27,12 +27,14 @@ namespace MPF.Frontend.ViewModels
/// <summary>
/// List of available disc categories
/// </summary>
public List<Element<DiscCategory>> Categories { get; private set; } = Element<DiscCategory>.GenerateElements().ToList();
public List<Element<DiscCategory>> Categories { get; private set; }
= Element<DiscCategory>.GenerateElements();
/// <summary>
/// List of available regions
/// </summary>
public List<Element<Region>> Regions { get; private set; } = Element<Region>.GenerateElements().ToList();
public List<Element<Region>> Regions { get; private set; }
= Element<Region>.GenerateElements();
/// <summary>
/// List of Redump-supported Regions
@@ -123,7 +125,8 @@ namespace MPF.Frontend.ViewModels
/// <summary>
/// List of available languages
/// </summary>
public List<Element<Language>> Languages { get; private set; } = Element<Language>.GenerateElements().ToList();
public List<Element<Language>> Languages { get; private set; }
= Element<Language>.GenerateElements();
/// <summary>
/// List of Redump-supported Languages
@@ -183,7 +186,8 @@ namespace MPF.Frontend.ViewModels
/// <summary>
/// List of available languages
/// </summary>
public List<Element<LanguageSelection>> LanguageSelections { get; private set; } = Element<LanguageSelection>.GenerateElements().ToList();
public List<Element<LanguageSelection>> LanguageSelections { get; private set; }
= Element<LanguageSelection>.GenerateElements();
#endregion
@@ -205,9 +209,9 @@ namespace MPF.Frontend.ViewModels
public void Load()
{
if (SubmissionInfo.CommonDiscInfo?.Languages != null)
Languages.ForEach(l => l.IsChecked = SubmissionInfo.CommonDiscInfo.Languages.Contains(l));
Languages.ForEach(l => l.IsChecked = Array.IndexOf(SubmissionInfo.CommonDiscInfo.Languages, l) > -1);
if (SubmissionInfo.CommonDiscInfo?.LanguageSelection != null)
LanguageSelections.ForEach(ls => ls.IsChecked = SubmissionInfo.CommonDiscInfo.LanguageSelection.Contains(ls));
LanguageSelections.ForEach(ls => ls.IsChecked = Array.IndexOf(SubmissionInfo.CommonDiscInfo.LanguageSelection, ls) > -1);
}
/// <summary>
@@ -218,10 +222,10 @@ namespace MPF.Frontend.ViewModels
{
if (SubmissionInfo.CommonDiscInfo == null)
SubmissionInfo.CommonDiscInfo = new CommonDiscInfoSection();
SubmissionInfo.CommonDiscInfo.Languages = Languages.Where(l => l.IsChecked).Select(l => l?.Value).ToArray();
if (!SubmissionInfo.CommonDiscInfo.Languages.Any())
SubmissionInfo.CommonDiscInfo.Languages = [.. Languages.FindAll(l => l.IsChecked).ConvertAll(l => l?.Value)];
if (SubmissionInfo.CommonDiscInfo.Languages.Length == 0)
SubmissionInfo.CommonDiscInfo.Languages = [null];
SubmissionInfo.CommonDiscInfo.LanguageSelection = LanguageSelections.Where(ls => ls.IsChecked).Select(ls => ls?.Value).ToArray();
SubmissionInfo.CommonDiscInfo.LanguageSelection = [.. LanguageSelections.FindAll(ls => ls.IsChecked).ConvertAll(ls => ls?.Value)];
SubmissionInfo.CommonDiscInfo.Title = FrontendTool.NormalizeDiscTitle(SubmissionInfo.CommonDiscInfo.Title, SubmissionInfo.CommonDiscInfo.Languages);
}
@@ -230,7 +234,7 @@ namespace MPF.Frontend.ViewModels
/// </summary>
public void SetRedumpLanguages()
{
this.Languages = RedumpLanguages.Select(l => new Element<Language>(l)).ToList();
Languages = RedumpLanguages.ConvertAll(l => new Element<Language>(l));
}
/// <summary>
@@ -238,7 +242,7 @@ namespace MPF.Frontend.ViewModels
/// </summary>
public void SetRedumpRegions()
{
this.Regions = RedumpRegions.Select(r => new Element<Region>(r)).ToList();
Regions = RedumpRegions.ConvertAll(r => new Element<Region>(r));
}
#endregion

View File

@@ -2,12 +2,12 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using BinaryObjectScanner;
using MPF.Frontend.ComboBoxItems;
using MPF.Frontend.Tools;
using SabreTools.IO;
using SabreTools.IO.Extensions;
using SabreTools.RedumpLib.Data;
namespace MPF.Frontend.ViewModels
@@ -556,7 +556,7 @@ namespace MPF.Frontend.ViewModels
LogPanelExpanded = _options.OpenLogWindowAtStartup;
MediaTypes = [];
Systems = RedumpSystemComboBoxItem.GenerateElements().ToList();
Systems = RedumpSystemComboBoxItem.GenerateElements();
InternalPrograms = [];
}
@@ -612,18 +612,18 @@ namespace MPF.Frontend.ViewModels
VerboseLogLn("Scanning for drives..");
// Always enable the media scan
this.MediaScanButtonEnabled = true;
this.UpdateVolumeLabelEnabled = true;
MediaScanButtonEnabled = true;
UpdateVolumeLabelEnabled = true;
// If we have a selected drive, keep track of it
char? lastSelectedDrive = this.CurrentDrive?.Name?[0] ?? null;
char? lastSelectedDrive = CurrentDrive?.Name?[0] ?? null;
// Populate the list of drives and add it to the combo box
Drives = Drive.CreateListOfDrives(this.Options.IgnoreFixedDrives);
Drives = Drive.CreateListOfDrives(Options.IgnoreFixedDrives);
if (Drives.Count > 0)
{
VerboseLogLn($"Found {Drives.Count} drives: {string.Join(", ", Drives.Select(d => d.Name).ToArray())}");
VerboseLogLn($"Found {Drives.Count} drives: {string.Join(", ", [.. Drives.ConvertAll(d => d.Name)])}");
// Check for the last selected drive, if possible
int index = -1;
@@ -644,23 +644,23 @@ namespace MPF.Frontend.ViewModels
// Set the selected index
CurrentDrive = (index != -1 ? Drives[index] : Drives[0]);
this.Status = "Valid drive found! Choose your Media Type";
this.CopyProtectScanButtonEnabled = true;
Status = "Valid drive found! Choose your Media Type";
CopyProtectScanButtonEnabled = true;
// Get the current system type
if (index != -1)
DetermineSystemType();
// Only enable the start/stop if we don't have the default selected
this.StartStopButtonEnabled = ShouldEnableDumpingButton();
StartStopButtonEnabled = ShouldEnableDumpingButton();
}
else
{
VerboseLogLn("Found no drives");
this.CurrentDrive = null;
this.Status = "No valid drive found!";
this.StartStopButtonEnabled = false;
this.CopyProtectScanButtonEnabled = false;
CurrentDrive = null;
Status = "No valid drive found!";
StartStopButtonEnabled = false;
CopyProtectScanButtonEnabled = false;
}
// Reenable event handlers, if necessary
@@ -676,22 +676,22 @@ namespace MPF.Frontend.ViewModels
bool cachedCanExecuteSelectionChanged = CanExecuteSelectionChanged;
DisableEventHandlers();
if (this.CurrentSystem != null)
if (CurrentSystem != null)
{
var mediaTypeValues = this.CurrentSystem.MediaTypes();
int index = mediaTypeValues.FindIndex(m => m == this.CurrentMediaType);
if (this.CurrentMediaType != null && index == -1)
var mediaTypeValues = CurrentSystem.MediaTypes();
int index = mediaTypeValues.FindIndex(m => m == CurrentMediaType);
if (CurrentMediaType != null && index == -1)
VerboseLogLn($"Disc of type '{CurrentMediaType.LongName()}' found, but the current system does not support it!");
MediaTypes = mediaTypeValues.Select(m => new Element<MediaType>(m ?? MediaType.NONE)).ToList();
this.MediaTypeComboBoxEnabled = MediaTypes.Count > 1;
this.CurrentMediaType = (index > -1 ? MediaTypes[index] : MediaTypes[0]);
MediaTypes = mediaTypeValues.ConvertAll(m => new Element<MediaType>(m ?? MediaType.NONE));
MediaTypeComboBoxEnabled = MediaTypes.Count > 1;
CurrentMediaType = (index > -1 ? MediaTypes[index] : MediaTypes[0]);
}
else
{
this.MediaTypeComboBoxEnabled = false;
this.MediaTypes = null;
this.CurrentMediaType = null;
MediaTypeComboBoxEnabled = false;
MediaTypes = null;
CurrentMediaType = null;
}
// Reenable event handlers, if necessary
@@ -708,21 +708,23 @@ namespace MPF.Frontend.ViewModels
DisableEventHandlers();
// Create a static list of supported programs, not everything
InternalPrograms = Enum.GetValues(typeof(InternalProgram)).Cast<InternalProgram>().Where(ip => InternalProgramExists(ip)).Select(ip => new Element<InternalProgram>(ip)).ToList();
var ipArr = (InternalProgram[])Enum.GetValues(typeof(InternalProgram));
ipArr = Array.FindAll(ipArr, ip => InternalProgramExists(ip));
InternalPrograms = [.. Array.ConvertAll(ipArr, ip => new Element<InternalProgram>(ip))];
// Get the current internal program
InternalProgram internalProgram = this.Options.InternalProgram;
InternalProgram internalProgram = Options.InternalProgram;
// Select the current default dumping program
if (InternalPrograms.Count == 0)
{
// If no programs are found, default to InternalProgram.NONE
this.CurrentProgram = InternalProgram.NONE;
CurrentProgram = InternalProgram.NONE;
}
else
{
int currentIndex = InternalPrograms.FindIndex(m => m == internalProgram);
this.CurrentProgram = (currentIndex > -1 ? InternalPrograms[currentIndex].Value : InternalPrograms[0].Value);
CurrentProgram = (currentIndex > -1 ? InternalPrograms[currentIndex].Value : InternalPrograms[0].Value);
}
// Reenable event handlers, if necessary
@@ -738,7 +740,7 @@ namespace MPF.Frontend.ViewModels
/// </summary>
public void ChangeDumpingProgram()
{
VerboseLogLn($"Changed dumping program to: {((InternalProgram?)this.CurrentProgram).LongName()}");
VerboseLogLn($"Changed dumping program to: {((InternalProgram?)CurrentProgram).LongName()}");
EnsureDiscInformation();
// New output name depends on new environment
GetOutputNames(false);
@@ -764,7 +766,7 @@ namespace MPF.Frontend.ViewModels
/// </summary>
public void ChangeSystem()
{
VerboseLogLn($"Changed system to: {this.CurrentSystem.LongName()}");
VerboseLogLn($"Changed system to: {CurrentSystem.LongName()}");
PopulateMediaType();
GetOutputNames(false);
EnsureDiscInformation();
@@ -947,15 +949,15 @@ namespace MPF.Frontend.ViewModels
public void ToggleStartStop()
{
// Dump or stop the dump
if (this.StartStopButtonText as string == StartDumpingValue)
if (StartStopButtonText as string == StartDumpingValue)
{
StartDumping();
}
else if (this.StartStopButtonText as string == StopDumpingValue)
else if (StartStopButtonText as string == StopDumpingValue)
{
VerboseLogLn("Canceling dumping process...");
_environment?.CancelDumping();
this.CopyProtectScanButtonEnabled = true;
CopyProtectScanButtonEnabled = true;
}
}
@@ -971,7 +973,7 @@ namespace MPF.Frontend.ViewModels
// Ensure the first run flag is unset
var continuingOptions = new Frontend.Options(optionsToSave) { FirstRun = false };
this.Options = continuingOptions;
Options = continuingOptions;
// If settings were changed, reinitialize the UI
if (savedSettings)
@@ -1044,14 +1046,14 @@ namespace MPF.Frontend.ViewModels
public void FastUpdateLabel(bool removeEventHandlers)
{
// Disable the dumping button
this.StartStopButtonEnabled = false;
StartStopButtonEnabled = false;
// Safely uncheck the parameters box, just in case
if (this.ParametersCheckBoxEnabled == true)
if (ParametersCheckBoxEnabled == true)
{
bool cachedCanExecuteSelectionChanged = CanExecuteSelectionChanged;
this.DisableEventHandlers();
this.ParametersCheckBoxEnabled = false;
DisableEventHandlers();
ParametersCheckBoxEnabled = false;
if (cachedCanExecuteSelectionChanged) EnableEventHandlers();
}
@@ -1060,7 +1062,7 @@ namespace MPF.Frontend.ViewModels
DisableEventHandlers();
// Refresh the drive info
this.CurrentDrive?.RefreshDrive();
CurrentDrive?.RefreshDrive();
// Set the initial environment and UI values
_environment = DetermineEnvironment();
@@ -1071,7 +1073,7 @@ namespace MPF.Frontend.ViewModels
EnableEventHandlers();
// Enable the dumping button, if necessary
this.StartStopButtonEnabled = ShouldEnableDumpingButton();
StartStopButtonEnabled = ShouldEnableDumpingButton();
}
/// <summary>
@@ -1169,25 +1171,26 @@ namespace MPF.Frontend.ViewModels
private void CacheCurrentDiscType()
{
// If the selected item is invalid, we just skip
if (this.CurrentDrive == null)
if (CurrentDrive == null)
return;
// Get reasonable default values based on the current system
MediaType? defaultMediaType = this.CurrentSystem.MediaTypes().FirstOrDefault() ?? MediaType.CDROM;
var mediaTypes = CurrentSystem.MediaTypes();
MediaType? defaultMediaType = mediaTypes.Count > 0 ? mediaTypes[0] : MediaType.CDROM;
if (defaultMediaType == MediaType.NONE)
defaultMediaType = MediaType.CDROM;
// If we're skipping detection, set the default value
if (this.Options.SkipMediaTypeDetection)
if (Options.SkipMediaTypeDetection)
{
VerboseLogLn($"Media type detection disabled, defaulting to {defaultMediaType.LongName()}.");
CurrentMediaType = defaultMediaType;
}
// If the drive is marked active, try to read from it
else if (this.CurrentDrive.MarkedActive)
else if (CurrentDrive.MarkedActive)
{
VerboseLog($"Trying to detect media type for drive {this.CurrentDrive.Name} [{this.CurrentDrive.DriveFormat}] using size and filesystem.. ");
MediaType? detectedMediaType = this.CurrentDrive.GetMediaType(this.CurrentSystem);
VerboseLog($"Trying to detect media type for drive {CurrentDrive.Name} [{CurrentDrive.DriveFormat}] using size and filesystem.. ");
MediaType? detectedMediaType = CurrentDrive.GetMediaType(CurrentSystem);
// If we got either an error or no media, default to the current System default
if (detectedMediaType == null)
@@ -1214,17 +1217,17 @@ namespace MPF.Frontend.ViewModels
/// <summary>
/// Create a DumpEnvironment with all current settings
/// </summary>
/// <returns>Filled DumpEnvironment this.Parent</returns>
/// <returns>Filled DumpEnvironment Parent</returns>
private DumpEnvironment DetermineEnvironment()
{
return new DumpEnvironment(
this.Options,
EvaluateOutputPath(this.OutputPath),
this.CurrentDrive,
this.CurrentSystem,
this.CurrentMediaType,
this.CurrentProgram,
this.Parameters);
Options,
EvaluateOutputPath(OutputPath),
CurrentDrive,
CurrentSystem,
CurrentMediaType,
CurrentProgram,
Parameters);
}
/// <summary>
@@ -1232,32 +1235,32 @@ namespace MPF.Frontend.ViewModels
/// </summary>
private void DetermineSystemType()
{
if (Drives == null || Drives.Count == 0 || this.CurrentDrive == null)
if (Drives == null || Drives.Count == 0 || CurrentDrive == null)
{
VerboseLogLn("Skipping system type detection because no valid drives found!");
}
else if (this.CurrentDrive?.MarkedActive != true)
else if (CurrentDrive?.MarkedActive != true)
{
VerboseLogLn("Skipping system type detection because drive not marked as active!");
}
else if (!this.Options.SkipSystemDetection)
else if (!Options.SkipSystemDetection)
{
VerboseLog($"Trying to detect system for drive {this.CurrentDrive.Name}.. ");
VerboseLog($"Trying to detect system for drive {CurrentDrive.Name}.. ");
var currentSystem = GetRedumpSystem(CurrentDrive, Options.DefaultSystem) ?? Options.DefaultSystem;
VerboseLogLn(currentSystem == null ? "unable to detect." : ($"detected {currentSystem.LongName()}."));
if (currentSystem != null)
{
int sysIndex = Systems.FindIndex(s => s == currentSystem);
this.CurrentSystem = Systems[sysIndex];
CurrentSystem = Systems[sysIndex];
}
}
else if (this.Options.SkipSystemDetection && this.Options.DefaultSystem != null)
else if (Options.SkipSystemDetection && Options.DefaultSystem != null)
{
var currentSystem = this.Options.DefaultSystem;
var currentSystem = Options.DefaultSystem;
VerboseLogLn($"System detection disabled, setting to default of {currentSystem.LongName()}.");
int sysIndex = Systems.FindIndex(s => s == currentSystem);
this.CurrentSystem = Systems[sysIndex];
CurrentSystem = Systems[sysIndex];
}
}
@@ -1315,23 +1318,23 @@ namespace MPF.Frontend.ViewModels
// Get the status to write out
ResultEventArgs result = _environment.GetSupportStatus();
if (this.CurrentProgram == InternalProgram.NONE)
this.Status = "No dumping program found";
if (CurrentProgram == InternalProgram.NONE)
Status = "No dumping program found";
else
this.Status = result.Message;
Status = result.Message;
// Enable or disable the button
this.StartStopButtonEnabled = result && ShouldEnableDumpingButton();
StartStopButtonEnabled = result && ShouldEnableDumpingButton();
// If we're in a type that doesn't support drive speeds
this.DriveSpeedComboBoxEnabled = _environment.DoesSupportDriveSpeed();
DriveSpeedComboBoxEnabled = _environment.DoesSupportDriveSpeed();
// If input params are not enabled, generate the full parameters from the environment
if (!this.ParametersCheckBoxEnabled)
if (!ParametersCheckBoxEnabled)
{
var generated = _environment.GetFullParameters(this.DriveSpeed);
var generated = _environment.GetFullParameters(DriveSpeed);
if (generated != null)
this.Parameters = generated;
Parameters = generated;
}
}
@@ -1342,16 +1345,16 @@ namespace MPF.Frontend.ViewModels
/// <returns>String with %-delimited variables evaluated</returns>
public string EvaluateOutputPath(string outputPath)
{
string systemLong = this._currentSystem.LongName() ?? "Unknown System";
string systemLong = _currentSystem.LongName() ?? "Unknown System";
if (string.IsNullOrEmpty(systemLong))
systemLong = "Unknown System";
string systemShort = this._currentSystem.ShortName() ?? "unknown";
string systemShort = _currentSystem.ShortName() ?? "unknown";
if (string.IsNullOrEmpty(systemShort))
systemShort = "unknown";
string mediaLong = this._currentMediaType.LongName() ?? "Unknown Media";
string mediaLong = _currentMediaType.LongName() ?? "Unknown Media";
if (string.IsNullOrEmpty(mediaLong))
mediaLong = "Unknown Media";
string program = this._currentProgram.ToString() ?? "Unknown Program";
string program = _currentProgram.ToString() ?? "Unknown Program";
if (string.IsNullOrEmpty(program))
program = "Unknown Program";
string programShort = program == "DiscImageCreator" ? "DIC" : program;
@@ -1369,7 +1372,8 @@ namespace MPF.Frontend.ViewModels
return outputPath
.Replace("%SYSTEM%", systemLong)
.Replace("%SYS%", systemShort)
.Replace("%SYS%", systemShort.ToUpperInvariant())
.Replace("%sys%", systemShort)
.Replace("%MEDIA%", mediaLong)
.Replace("%PROGRAM%", program)
.Replace("%PROG%", programShort)
@@ -1384,20 +1388,20 @@ namespace MPF.Frontend.ViewModels
/// <param name="driveChanged">Force an updated name if the drive letter changes</param>
public void GetOutputNames(bool driveChanged)
{
if (Drives == null || Drives.Count == 0 || this.CurrentDrive == null)
if (Drives == null || Drives.Count == 0 || CurrentDrive == null)
{
VerboseLogLn("Skipping output name building because no valid drives found!");
return;
}
// Get the extension for the file for the next two statements
var extension = _environment?.GetDefaultExtension(this.CurrentMediaType);
var extension = _environment?.GetDefaultExtension(CurrentMediaType);
// Set the output filename, if it's not already
if (string.IsNullOrEmpty(this.OutputPath))
if (string.IsNullOrEmpty(OutputPath))
{
var label = GetFormattedVolumeLabel(CurrentDrive) ?? this.CurrentSystem.LongName();
var directory = this.Options.DefaultOutputPath;
var label = GetFormattedVolumeLabel(CurrentDrive) ?? CurrentSystem.LongName();
var directory = Options.DefaultOutputPath;
string filename = $"{label}{extension ?? ".bin"}";
// If the path ends with the label already
@@ -1406,19 +1410,19 @@ namespace MPF.Frontend.ViewModels
if (directory != null && label != null)
#if NET20 || NET35
this.OutputPath = Path.Combine(Path.Combine(directory, label), filename);
OutputPath = Path.Combine(Path.Combine(directory, label), filename);
#else
this.OutputPath = Path.Combine(directory, label, filename);
OutputPath = Path.Combine(directory, label, filename);
#endif
else
this.OutputPath = filename;
OutputPath = filename;
}
// Set the output filename, if we changed drives
else if (driveChanged)
{
var label = GetFormattedVolumeLabel(CurrentDrive) ?? this.CurrentSystem.LongName();
string oldPath = FrontendTool.NormalizeOutputPaths(this.OutputPath, false);
var label = GetFormattedVolumeLabel(CurrentDrive) ?? CurrentSystem.LongName();
string oldPath = FrontendTool.NormalizeOutputPaths(OutputPath, false);
string oldFilename = Path.GetFileNameWithoutExtension(oldPath);
var directory = Path.GetDirectoryName(oldPath);
string filename = $"{label}{extension ?? ".bin"}";
@@ -1433,26 +1437,26 @@ namespace MPF.Frontend.ViewModels
if (directory != null && label != null)
#if NET20 || NET35
this.OutputPath = Path.Combine(Path.Combine(directory, label), filename);
OutputPath = Path.Combine(Path.Combine(directory, label), filename);
#else
this.OutputPath = Path.Combine(directory, label, filename);
OutputPath = Path.Combine(directory, label, filename);
#endif
else
this.OutputPath = filename;
OutputPath = filename;
}
// Otherwise, reset the extension of the currently set path
else
{
string oldPath = FrontendTool.NormalizeOutputPaths(this.OutputPath, false);
string oldPath = FrontendTool.NormalizeOutputPaths(OutputPath, false);
string filename = Path.GetFileNameWithoutExtension(oldPath);
var directory = Path.GetDirectoryName(oldPath);
filename = $"{filename}{extension ?? ".bin"}";
if (directory != null)
this.OutputPath = Path.Combine(directory, filename);
OutputPath = Path.Combine(directory, filename);
else
this.OutputPath = filename;
OutputPath = filename;
}
}
@@ -1503,14 +1507,10 @@ namespace MPF.Frontend.ViewModels
// Bandai Playdia Quick Interactive System
try
{
#if NET20 || NET35
List<string> files = [.. Directory.GetFiles(drive.Name, "*", SearchOption.TopDirectoryOnly)];
#else
List<string> files = Directory.EnumerateFiles(drive.Name, "*", SearchOption.TopDirectoryOnly).ToList();
#endif
if (files.Any(f => f.EndsWith(".AJS", StringComparison.OrdinalIgnoreCase))
&& files.Any(f => f.EndsWith(".GLB", StringComparison.OrdinalIgnoreCase)))
if (files.Exists(f => f.EndsWith(".AJS", StringComparison.OrdinalIgnoreCase))
&& files.Exists(f => f.EndsWith(".GLB", StringComparison.OrdinalIgnoreCase)))
{
return RedumpSystem.BandaiPlaydiaQuickInteractiveSystem;
}
@@ -1556,11 +1556,7 @@ namespace MPF.Frontend.ViewModels
try
{
if (Directory.Exists(Path.Combine(drive.Name, "$SystemUpdate"))
#if NET20 || NET35
&& Directory.GetFiles(Path.Combine(drive.Name, "$SystemUpdate")).Any()
#else
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "$SystemUpdate")).Any()
#endif
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "$SystemUpdate")).Length > 0
&& drive.TotalSize <= 500_000_000)
{
return RedumpSystem.MicrosoftXbox360;
@@ -1712,21 +1708,13 @@ namespace MPF.Frontend.ViewModels
try
{
if (Directory.Exists(Path.Combine(drive.Name, "AUDIO_TS"))
#if NET20 || NET35
&& Directory.GetFiles(Path.Combine(drive.Name, "AUDIO_TS")).Any())
#else
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "AUDIO_TS")).Any())
#endif
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "AUDIO_TS")).Length > 0)
{
return RedumpSystem.DVDAudio;
}
else if (Directory.Exists(Path.Combine(drive.Name, "VIDEO_TS"))
#if NET20 || NET35
&& Directory.GetFiles(Path.Combine(drive.Name, "VIDEO_TS")).Any())
#else
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "VIDEO_TS")).Any())
#endif
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "VIDEO_TS")).Length > 0)
{
return RedumpSystem.DVDVideo;
}
@@ -1737,11 +1725,7 @@ namespace MPF.Frontend.ViewModels
try
{
if (Directory.Exists(Path.Combine(drive.Name, "HVDVD_TS"))
#if NET20 || NET35
&& Directory.GetFiles(Path.Combine(drive.Name, "HVDVD_TS")).Any())
#else
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "HVDVD_TS")).Any())
#endif
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "HVDVD_TS")).Length > 0)
{
return RedumpSystem.HDDVDVideo;
}
@@ -1752,11 +1736,7 @@ namespace MPF.Frontend.ViewModels
try
{
if (Directory.Exists(Path.Combine(drive.Name, "PHOTO_CD"))
#if NET20 || NET35
&& Directory.GetFiles(Path.Combine(drive.Name, "PHOTO_CD")).Any())
#else
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "PHOTO_CD")).Any())
#endif
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "PHOTO_CD")).Length > 0)
{
return RedumpSystem.PhotoCD;
}
@@ -1767,11 +1747,7 @@ namespace MPF.Frontend.ViewModels
try
{
if (Directory.Exists(Path.Combine(drive.Name, "VCD"))
#if NET20 || NET35
&& Directory.GetFiles(Path.Combine(drive.Name, "drive.VCD")).Any())
#else
&& Directory.EnumerateFiles(Path.Combine(drive.Name, "VCD")).Any())
#endif
&& IOExtensions.SafeGetFiles(Path.Combine(drive.Name, "VCD")).Length > 0)
{
return RedumpSystem.VideoCD;
}
@@ -1790,7 +1766,7 @@ namespace MPF.Frontend.ViewModels
public void ProcessCustomParameters()
{
// Set the execution context and processor
if (_environment?.SetExecutionContext(this.Parameters) != true)
if (_environment?.SetExecutionContext(Parameters) != true)
return;
if (_environment?.SetProcessor() != true)
return;
@@ -1798,21 +1774,22 @@ namespace MPF.Frontend.ViewModels
// Catch this in case there's an input path issue
try
{
int driveIndex = Drives.Select(d => d.Name?[0] ?? '\0').ToList().IndexOf(_environment.ContextInputPath?[0] ?? default);
this.CurrentDrive = (driveIndex != -1 ? Drives[driveIndex] : Drives[0]);
int driveIndex = Drives.ConvertAll(d => d.Name?[0] ?? '\0')
.IndexOf(_environment.ContextInputPath?[0] ?? default);
CurrentDrive = (driveIndex != -1 ? Drives[driveIndex] : Drives[0]);
}
catch { }
int driveSpeed = _environment.Speed ?? -1;
if (driveSpeed > 0)
this.DriveSpeed = driveSpeed;
DriveSpeed = driveSpeed;
else
_environment.Speed = this.DriveSpeed;
_environment.Speed = DriveSpeed;
// Disable change handling
DisableEventHandlers();
this.OutputPath = FrontendTool.NormalizeOutputPaths(_environment.ContextOutputPath, false);
OutputPath = FrontendTool.NormalizeOutputPaths(_environment.ContextOutputPath, false);
if (MediaTypes != null)
{
@@ -1820,7 +1797,7 @@ namespace MPF.Frontend.ViewModels
if (mediaType != null)
{
int mediaTypeIndex = MediaTypes.FindIndex(m => m == mediaType);
this.CurrentMediaType = (mediaTypeIndex > -1 ? MediaTypes[mediaTypeIndex] : MediaTypes[0]);
CurrentMediaType = (mediaTypeIndex > -1 ? MediaTypes[mediaTypeIndex] : MediaTypes[0]);
}
}
@@ -1831,51 +1808,41 @@ namespace MPF.Frontend.ViewModels
/// <summary>
/// Scan and show copy protection for the current disc
/// </summary>
#if NET40
public string? ScanAndShowProtection()
#else
public async Task<string?> ScanAndShowProtection()
#endif
{
// Determine current environment, just in case
_environment ??= DetermineEnvironment();
// If we don't have a valid drive
if (this.CurrentDrive?.Name == null)
if (CurrentDrive?.Name == null)
{
ErrorLogLn("No valid drive found!");
return null;
}
VerboseLogLn($"Scanning for copy protection in {this.CurrentDrive.Name}");
VerboseLogLn($"Scanning for copy protection in {CurrentDrive.Name}");
var tempContent = this.Status;
this.Status = "Scanning for copy protection... this might take a while!";
this.StartStopButtonEnabled = false;
this.MediaScanButtonEnabled = false;
this.UpdateVolumeLabelEnabled = false;
this.CopyProtectScanButtonEnabled = false;
var tempContent = Status;
Status = "Scanning for copy protection... this might take a while!";
StartStopButtonEnabled = false;
MediaScanButtonEnabled = false;
UpdateVolumeLabelEnabled = false;
CopyProtectScanButtonEnabled = false;
var progress = new Progress<ProtectionProgress>();
progress.ProgressChanged += ProgressUpdated;
try
{
#if NET40
var protectionTask = ProtectionTool.RunProtectionScanOnPath(this.CurrentDrive.Name, this.Options, progress);
protectionTask.Wait();
var protections = protectionTask.Result;
#else
var protections = await ProtectionTool.RunProtectionScanOnPath(this.CurrentDrive.Name, this.Options, progress);
#endif
var protections = await ProtectionTool.RunProtectionScanOnPath(CurrentDrive.Name, Options, progress);
var output = ProtectionTool.FormatProtections(protections);
LogLn($"Detected the following protections in {this.CurrentDrive.Name}:\r\n\r\n{output}");
LogLn($"Detected the following protections in {CurrentDrive.Name}:\r\n\r\n{output}");
this.Status = tempContent;
this.StartStopButtonEnabled = ShouldEnableDumpingButton();
this.MediaScanButtonEnabled = true;
this.UpdateVolumeLabelEnabled = true;
this.CopyProtectScanButtonEnabled = true;
Status = tempContent;
StartStopButtonEnabled = ShouldEnableDumpingButton();
MediaScanButtonEnabled = true;
UpdateVolumeLabelEnabled = true;
CopyProtectScanButtonEnabled = true;
return output;
}
@@ -1953,10 +1920,10 @@ namespace MPF.Frontend.ViewModels
// Now set the selected item, if possible
int index = MediaTypes.FindIndex(kvp => kvp.Value == CurrentMediaType);
if (this.CurrentMediaType != null && index == -1)
if (CurrentMediaType != null && index == -1)
VerboseLogLn($"Disc of type '{CurrentMediaType.LongName()}' found, but the current system does not support it!");
this.CurrentMediaType = (index > -1 ? MediaTypes[index] : MediaTypes[0]);
CurrentMediaType = (index > -1 ? MediaTypes[index] : MediaTypes[0]);
}
/// <summary>
@@ -1965,14 +1932,14 @@ namespace MPF.Frontend.ViewModels
public void SetSupportedDriveSpeed()
{
// Set the drive speed list that's appropriate
this.DriveSpeeds = (List<int>)InterfaceConstants.GetSpeedsForMediaType(CurrentMediaType);
VerboseLogLn($"Supported media speeds: {string.Join(", ", this.DriveSpeeds.Select(ds => ds.ToString()).ToArray())}");
DriveSpeeds = (List<int>)InterfaceConstants.GetSpeedsForMediaType(CurrentMediaType);
VerboseLogLn($"Supported media speeds: {string.Join(", ", [.. DriveSpeeds.ConvertAll(ds => ds.ToString())])}");
// Set the selected speed
int speed = FrontendTool.GetDefaultSpeedForMediaType(CurrentMediaType, Options);
VerboseLogLn($"Setting drive speed to: {speed}");
this.DriveSpeed = speed;
DriveSpeed = speed;
}
/// <summary>
@@ -1982,8 +1949,8 @@ namespace MPF.Frontend.ViewModels
{
return Drives != null
&& Drives.Count > 0
&& this.CurrentSystem != null
&& this.CurrentMediaType != null
&& CurrentSystem != null
&& CurrentMediaType != null
&& ProgramSupportsMedia();
}
@@ -2050,12 +2017,12 @@ namespace MPF.Frontend.ViewModels
_environment.RefreshDrive();
// If still in custom parameter mode, check that users meant to continue or not
if (this.ParametersCheckBoxEnabled == true && _displayUserMessage != null)
if (ParametersCheckBoxEnabled == true && _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);
if (result == true)
{
this.ParametersCheckBoxEnabled = false;
ParametersCheckBoxEnabled = false;
ProcessCustomParameters();
}
else if (result == null)
@@ -2081,7 +2048,7 @@ namespace MPF.Frontend.ViewModels
_environment.RefreshDrive();
// Output to the label and log
this.Status = "Starting dumping process... please wait!";
Status = "Starting dumping process... please wait!";
LogLn("Starting dumping process... please wait!");
LogLn("Look for the separate command window for more details");
@@ -2099,7 +2066,7 @@ namespace MPF.Frontend.ViewModels
if (!_environment.IsDumpingCommand())
{
LogLn("No dumping command was run, submission information will not be gathered.");
this.Status = "Execution complete!";
Status = "Execution complete!";
// Reset all UI elements
EnableAllUIElements();
@@ -2114,13 +2081,13 @@ namespace MPF.Frontend.ViewModels
else
{
ErrorLogLn(result.Message);
this.Status = "Execution failed!";
Status = "Execution failed!";
}
}
catch (Exception ex)
{
ErrorLogLn(ex.ToString());
this.Status = "An exception occurred!";
Status = "An exception occurred!";
}
finally
{
@@ -2259,9 +2226,9 @@ namespace MPF.Frontend.ViewModels
{
return program switch
{
InternalProgram.Redumper => File.Exists(this.Options.RedumperPath),
InternalProgram.Aaru => File.Exists(this.Options.AaruPath),
InternalProgram.DiscImageCreator => File.Exists(this.Options.DiscImageCreatorPath),
InternalProgram.Redumper => File.Exists(Options.RedumperPath),
InternalProgram.Aaru => File.Exists(Options.AaruPath),
InternalProgram.DiscImageCreator => File.Exists(Options.DiscImageCreatorPath),
_ => false,
};
}
@@ -2295,10 +2262,10 @@ namespace MPF.Frontend.ViewModels
var message = value?.Message;
// Update the label with only the first line of output
if (message != null && message.Contains('\n'))
this.Status = value?.Message?.Split('\n')[0] + " (See log output)";
if (message != null && message.Contains("\n"))
Status = value?.Message?.Split('\n')[0] + " (See log output)";
else
this.Status = value?.Message ?? string.Empty;
Status = value?.Message ?? string.Empty;
// Log based on success or failure
if (value != null && value)
@@ -2313,7 +2280,7 @@ namespace MPF.Frontend.ViewModels
private void ProgressUpdated(object? sender, ProtectionProgress value)
{
string message = $"{value.Percentage * 100:N2}%: {value.Filename} - {value.Protection}";
this.Status = message;
Status = message;
VerboseLogLn(message);
}

View File

@@ -1,9 +1,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using MPF.Frontend.ComboBoxItems;
using SabreTools.RedumpLib.Web;
using RedumperReadMethod = MPF.ExecutionContexts.Redumper.ReadMethod;
using RedumperSectorOrder = MPF.ExecutionContexts.Redumper.SectorOrder;
@@ -65,7 +62,7 @@ namespace MPF.Frontend.ViewModels
/// <summary>
/// Current list of supported system profiles
/// </summary>
public static List<RedumpSystemComboBoxItem> Systems => RedumpSystemComboBoxItem.GenerateElements().ToList();
public static List<RedumpSystemComboBoxItem> Systems => RedumpSystemComboBoxItem.GenerateElements();
#endregion
@@ -93,7 +90,7 @@ namespace MPF.Frontend.ViewModels
private static List<Element<InternalProgram>> PopulateInternalPrograms()
{
var internalPrograms = new List<InternalProgram> { InternalProgram.Redumper, InternalProgram.DiscImageCreator, InternalProgram.Aaru };
return internalPrograms.Select(ip => new Element<InternalProgram>(ip)).ToList();
return internalPrograms.ConvertAll(ip => new Element<InternalProgram>(ip));
}
/// <summary>
@@ -102,7 +99,7 @@ namespace MPF.Frontend.ViewModels
private static List<Element<RedumperReadMethod>> PopulateRedumperReadMethods()
{
var readMethods = new List<RedumperReadMethod> { RedumperReadMethod.NONE, RedumperReadMethod.D8, RedumperReadMethod.BE, RedumperReadMethod.BE_CDDA };
return readMethods.Select(rm => new Element<RedumperReadMethod>(rm)).ToList();
return readMethods.ConvertAll(rm => new Element<RedumperReadMethod>(rm));
}
/// <summary>
@@ -111,7 +108,7 @@ namespace MPF.Frontend.ViewModels
private static List<Element<RedumperSectorOrder>> PopulateRedumperSectorOrders()
{
var sectorOrders = new List<RedumperSectorOrder> { RedumperSectorOrder.NONE, RedumperSectorOrder.DATA_C2_SUB, RedumperSectorOrder.DATA_SUB_C2, RedumperSectorOrder.DATA_SUB, RedumperSectorOrder.DATA_C2 };
return sectorOrders.Select(so => new Element<RedumperSectorOrder>(so)).ToList();
return sectorOrders.ConvertAll(so => new Element<RedumperSectorOrder>(so));
}
#endregion

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Schema;
@@ -618,31 +617,16 @@ namespace MPF.Processors
continue;
// Build each row in consecutive order
string pvd = string.Empty;
#if NET20 || NET35 || NET40
byte[] pvdLine = new byte[16];
Array.Copy(pvdData, 0, pvdLine, 0, 16);
pvd += GenerateSectorOutputLine("0320", pvdLine);
Array.Copy(pvdData, 16, pvdLine, 0, 16);
pvd += GenerateSectorOutputLine("0330", pvdLine);
Array.Copy(pvdData, 32, pvdLine, 0, 16);
pvd += GenerateSectorOutputLine("0340", pvdLine);
Array.Copy(pvdData, 48, pvdLine, 0, 16);
pvd += GenerateSectorOutputLine("0350", pvdLine);
Array.Copy(pvdData, 64, pvdLine, 0, 16);
pvd += GenerateSectorOutputLine("0360", pvdLine);
Array.Copy(pvdData, 80, pvdLine, 0, 16);
pvd += GenerateSectorOutputLine("0370", pvdLine);
#else
pvd += GenerateSectorOutputLine("0320", new ReadOnlySpan<byte>(pvdData, 0, 16).ToArray());
pvd += GenerateSectorOutputLine("0330", new ReadOnlySpan<byte>(pvdData, 16, 16).ToArray());
pvd += GenerateSectorOutputLine("0340", new ReadOnlySpan<byte>(pvdData, 32, 16).ToArray());
pvd += GenerateSectorOutputLine("0350", new ReadOnlySpan<byte>(pvdData, 48, 16).ToArray());
pvd += GenerateSectorOutputLine("0360", new ReadOnlySpan<byte>(pvdData, 64, 16).ToArray());
pvd += GenerateSectorOutputLine("0370", new ReadOnlySpan<byte>(pvdData, 80, 16).ToArray());
#endif
var pvd = new StringBuilder();
return pvd;
pvd.AppendLine(GenerateSectorOutputLine("0320", pvdData, 0 * 16));
pvd.AppendLine(GenerateSectorOutputLine("0330", pvdData, 1 * 16));
pvd.AppendLine(GenerateSectorOutputLine("0340", pvdData, 2 * 16));
pvd.AppendLine(GenerateSectorOutputLine("0350", pvdData, 3 * 16));
pvd.AppendLine(GenerateSectorOutputLine("0360", pvdData, 4 * 16));
pvd.AppendLine(GenerateSectorOutputLine("0370", pvdData, 5 * 16));
return pvd.ToString();
}
}
@@ -732,13 +716,13 @@ namespace MPF.Processors
// Now generate the byte array data
var pvdData = new List<byte>();
pvdData.AddRange(new string(' ', 13).ToCharArray().Select(c => (byte)c));
pvdData.AddRange(Array.ConvertAll(new string(' ', 13).ToCharArray(), c => (byte)c));
pvdData.AddRange(GeneratePVDDateTimeBytes(creation));
pvdData.AddRange(GeneratePVDDateTimeBytes(modification));
pvdData.AddRange(GeneratePVDDateTimeBytes(expiration));
pvdData.AddRange(GeneratePVDDateTimeBytes(effective));
pvdData.Add(0x01);
pvdData.AddRange(new string((char)0, 14).ToCharArray().Select(c => (byte)c));
pvdData.AddRange(Array.ConvertAll(new string((char)0, 14).ToCharArray(), c => (byte)c));
// Return the filled array
return [.. pvdData];
@@ -780,7 +764,7 @@ namespace MPF.Processors
}
// Get and return the byte array
List<byte> dateTimeList = dateTimeString.ToCharArray().Select(c => (byte)c).ToList();
List<byte> dateTimeList = [.. Array.ConvertAll(dateTimeString.ToCharArray(), c => (byte)c)];
dateTimeList.Add(timeZoneNumber);
return [.. dateTimeList];
}
@@ -790,22 +774,26 @@ namespace MPF.Processors
/// </summary>
/// <param name="row">Row ID for outputting</param>
/// <param name="bytes">Bytes representing the data to write</param>
/// <param name="offset">Offset into the byte array</param>
/// <param name="length">Length of the byte array</param>
/// <returns>Formatted string representing the sector line</returns>
private static string? GenerateSectorOutputLine(string row, byte[] bytes)
private static string? GenerateSectorOutputLine(string row, byte[] bytes, int offset)
{
// If the data isn't correct, return null
if (bytes == null || bytes.Length != 16)
if (bytes == null || offset < 0 || offset >= bytes.Length || bytes.Length - offset < 16)
return null;
string pvdLine = $"{row} : ";
pvdLine += BitConverter.ToString(bytes.Take(8).ToArray()).Replace("-", " ");
pvdLine += " ";
pvdLine += BitConverter.ToString(bytes.Skip(8).Take(8).ToArray()).Replace("-", " ");
pvdLine += " ";
pvdLine += Encoding.ASCII.GetString([.. bytes]).Replace((char)0, '.').Replace('?', '.');
pvdLine += "\n";
var pvdLine = new StringBuilder();
return pvdLine;
pvdLine.Append($"{row} : ");
pvdLine.Append(BitConverter.ToString(bytes, offset + 0, 8).Replace("-", " "));
pvdLine.Append(" ");
pvdLine.Append(BitConverter.ToString(bytes, offset + 8, 8).Replace("-", " "));
pvdLine.Append(" ");
pvdLine.Append(Encoding.ASCII.GetString(bytes, offset, 16).Replace((char)0, '.').Replace('?', '.'));
return pvdLine.ToString();
}
/// <summary>
@@ -986,7 +974,7 @@ namespace MPF.Processors
foreach (OpticalDiscType opticalDisc in cicmSidecar.OpticalDisc)
{
// If there's no hardware information, skip
if (opticalDisc.DumpHardwareArray == null || !opticalDisc.DumpHardwareArray.Any())
if (opticalDisc.DumpHardwareArray == null || opticalDisc.DumpHardwareArray.Length == 0)
continue;
foreach (DumpHardwareType hardware in opticalDisc.DumpHardwareArray)

View File

@@ -4,8 +4,10 @@ using System.IO;
#if NET452_OR_GREATER || NETCOREAPP
using System.IO.Compression;
#endif
#if NET35_OR_GREATER || NETCOREAPP
using System.Linq;
using System.Text.RegularExpressions;
#endif
using System.Text;
using SabreTools.RedumpLib.Data;
namespace MPF.Processors
@@ -94,7 +96,7 @@ namespace MPF.Processors
var generatedFiles = GetGeneratedFilePaths(outputDirectory, filenameSuffix);
// Don't create an archive if there are no paths
if (!zippableFiles.Any() && !generatedFiles.Any())
if (zippableFiles.Count == 0 && generatedFiles.Count == 0)
{
status = "No files to compress!";
return true;
@@ -156,7 +158,7 @@ namespace MPF.Processors
// Get the list of deleteable files from the parameters object
var files = GetDeleteableFilePaths(combinedBase);
if (!files.Any())
if (files.Count == 0)
{
status = "No files to delete!";
return true;
@@ -413,8 +415,18 @@ namespace MPF.Processors
return [];
// Filter down to deleteable files
var deleteableFiles = outputFiles.Where(of => of.IsDeleteable);
var deleteableFiles = outputFiles.FindAll(of => of.IsDeleteable);
#if NET20
var deleteableFilenames = new List<string>();
foreach (var deleteableFile in deleteableFiles)
{
deleteableFilenames.AddRange(deleteableFile.Filenames);
}
return deleteableFilenames;
#else
return deleteableFiles.SelectMany(of => of.Filenames).ToList();
#endif
}
/// <summary>
@@ -518,8 +530,18 @@ namespace MPF.Processors
return [];
// Filter down to zippable files
var zippableFiles = outputFiles.Where(of => of.IsZippable);
var zippableFiles = outputFiles.FindAll(of => of.IsZippable);
#if NET20
var zippableFilenames = new List<string>();
foreach (var zippableFile in zippableFiles)
{
zippableFilenames.AddRange(zippableFile.Filenames);
}
return zippableFilenames;
#else
return zippableFiles.SelectMany(of => of.Filenames).ToList();
#endif
}
/// <summary>
@@ -579,8 +601,7 @@ namespace MPF.Processors
hex = hex.Substring(0, trimLength);
// TODO: Check for non-zero values in discarded PIC
return Regex.Replace(hex, ".{32}", "$0\n", RegexOptions.Compiled);
return SplitString(hex, 32);
}
catch
{
@@ -643,6 +664,32 @@ namespace MPF.Processors
}
}
/// <summary>
/// Split a string with newlines every <paramref name="count"/> characters
/// </summary>
protected static string SplitString(string? str, int count, bool trim = false)
{
// Ignore invalid inputs
if (str == null)
return string.Empty;
if (count < 1)
return str;
// Build the output string
var sb = new StringBuilder();
for (int i = 0; i < str.Length; i += count)
{
string line = str.Substring(i, count);
if (trim)
line = line.Trim();
sb.Append(line);
sb.Append('\n');
}
return sb.ToString();
}
#endregion
}
}

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Text;
using SabreTools.Hashing;
using SabreTools.Models.Logiqx;
using SabreTools.RedumpLib;
@@ -173,9 +173,18 @@ namespace MPF.Processors
if (hex == null)
return null;
// First separate into lines then into blocks of 4 hex digits
string bca = Regex.Replace(hex, ".{32}", "$0\n");
return Regex.Replace(bca, "[0-9a-fA-F]{4}", "$0 ");
// Separate into blocks of 4 hex digits and newlines
var bca = new StringBuilder();
for (int i = 0; i < hex.Length; i++)
{
bca.Append(hex[i]);
if ((i + 1) % 32 == 0)
bca.AppendLine();
else if ((i + 1) % 4 == 0)
bca.Append(' ');
}
return bca.ToString();
}
catch
{

View File

@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
#if NET35_OR_GREATER || NETCOREAPP
using System.Linq;
#endif
using System.Text.RegularExpressions;
using psxt001z;
using SabreTools.Models.Logiqx;
@@ -255,20 +257,22 @@ namespace MPF.Processors
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSHash] = xgd1SSHash ?? string.Empty;
}
if (GetXGDAuxSSInfo($"{basePath}_disc.txt", out var xgd1SS, out var xgd1SSVer))
if (GetXGDAuxSSInfo($"{basePath}_disc.txt", out var xgd1SS, out _))
{
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.SSVersion] = xgd1SSVer ?? string.Empty;
// We no longer care about SS Version from DIC
//info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.SSVersion] = xgd1SSVer ?? string.Empty;
info.Extras!.SecuritySectorRanges = xgd1SS ?? string.Empty;
}
}
else
{
if (GetXGDAuxInfo($"{basePath}_disc.txt", out var xgd1DMIHash, out var xgd1PFIHash, out var xgd1SSHash, out var xgd1SS, out var xgd1SSVer))
if (GetXGDAuxInfo($"{basePath}_disc.txt", out var xgd1DMIHash, out var xgd1PFIHash, out var xgd1SSHash, out var xgd1SS, out _))
{
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.DMIHash] = xgd1DMIHash ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.PFIHash] = xgd1PFIHash ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSHash] = xgd1SSHash ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSVersion] = xgd1SSVer ?? string.Empty;
// We no longer care about SS Version from DIC
//info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSVersion] = xgd1SSVer ?? string.Empty;
info.Extras!.SecuritySectorRanges = xgd1SS ?? string.Empty;
}
}
@@ -299,20 +303,22 @@ namespace MPF.Processors
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSHash] = xgd23SSHash ?? string.Empty;
}
if (GetXGDAuxSSInfo($"{basePath}_disc.txt", out var xgd23SS, out var xgd23SSVer))
if (GetXGDAuxSSInfo($"{basePath}_disc.txt", out var xgd23SS, out _))
{
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.SSVersion] = xgd23SSVer ?? string.Empty;
// We no longer care about SS Version from DIC
//info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.SSVersion] = xgd23SSVer ?? string.Empty;
info.Extras!.SecuritySectorRanges = xgd23SS ?? string.Empty;
}
}
else
{
if (GetXGDAuxInfo($"{basePath}_disc.txt", out var xgd23DMIHash, out var xgd23PFIHash, out var xgd23SSHash, out var xgd23SS, out var xgd23SSVer))
if (GetXGDAuxInfo($"{basePath}_disc.txt", out var xgd23DMIHash, out var xgd23PFIHash, out var xgd23SSHash, out var xgd23SS, out _))
{
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.DMIHash] = xgd23DMIHash ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.PFIHash] = xgd23PFIHash ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSHash] = xgd23SSHash ?? string.Empty;
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSVersion] = xgd23SSVer ?? string.Empty;
// We no longer care about SS Version from DIC
//info.CommonDiscInfo.CommentsSpecialFields[SiteCode.SSVersion] = xgd23SSVer ?? string.Empty;
info.Extras!.SecuritySectorRanges = xgd23SS ?? string.Empty;
}
}
@@ -326,7 +332,7 @@ namespace MPF.Processors
// Take only the first 16 lines for GD-ROM
if (!string.IsNullOrEmpty(info.Extras.Header))
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n').Take(16).ToArray());
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n'), 0, 16);
if (GetGDROMBuildInfo(info.Extras.Header,
out var serial,
@@ -347,7 +353,7 @@ namespace MPF.Processors
// Take only the last 16 lines for Sega CD
if (!string.IsNullOrEmpty(info.Extras.Header))
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n').Skip(16).ToArray());
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n'), 0, 16);
if (GetSegaCDBuildInfo(info.Extras.Header, out var scdSerial, out var fixedDate))
{
@@ -365,7 +371,7 @@ namespace MPF.Processors
// Take only the first 16 lines for GD-ROM
if (!string.IsNullOrEmpty(info.Extras.Header))
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n').Take(16).ToArray());
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n'), 0, 16);
if (GetGDROMBuildInfo(info.Extras.Header,
out var serial,
@@ -388,7 +394,7 @@ namespace MPF.Processors
// Take only the first 16 lines for GD-ROM
if (!string.IsNullOrEmpty(info.Extras.Header))
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n').Take(16).ToArray());
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n'), 0, 16);
if (GetGDROMBuildInfo(info.Extras.Header,
out var serial,
@@ -411,7 +417,7 @@ namespace MPF.Processors
// Take only the first 16 lines for GD-ROM
if (!string.IsNullOrEmpty(info.Extras.Header))
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n').Take(16).ToArray());
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n'), 0, 16);
if (GetGDROMBuildInfo(info.Extras.Header,
out var serial,
@@ -434,7 +440,7 @@ namespace MPF.Processors
// Take only the first 16 lines for GD-ROM
if (!string.IsNullOrEmpty(info.Extras.Header))
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n').Take(16).ToArray());
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n'), 0, 16);
if (GetGDROMBuildInfo(info.Extras.Header,
out var serial,
@@ -455,7 +461,7 @@ namespace MPF.Processors
// Take only the first 16 lines for Saturn
if (!string.IsNullOrEmpty(info.Extras.Header))
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n').Take(16).ToArray());
info.Extras.Header = string.Join("\n", info.Extras.Header.Split('\n'), 0, 16);
if (GetSaturnBuildInfo(info.Extras.Header, out var saturnSerial, out var saturnVersion, out var buildDate))
{
@@ -746,7 +752,7 @@ namespace MPF.Processors
return null;
var currentFiles = Directory.GetFiles(parentDirectory);
commandPath = currentFiles.FirstOrDefault(f => cmdFilenameRegex.IsMatch(f));
commandPath = Array.Find(currentFiles, f => cmdFilenameRegex.IsMatch(f));
if (string.IsNullOrEmpty(value: commandPath))
return null;
@@ -882,8 +888,8 @@ namespace MPF.Processors
}
// Create the output string
if (discTypeOrBookTypeSet.Any())
discTypeOrBookType = string.Join(", ", [.. discTypeOrBookTypeSet.OrderBy(s => s)]);
if (discTypeOrBookTypeSet.Count > 0)
discTypeOrBookType = string.Join(", ", [.. discTypeOrBookTypeSet]);
return true;
}
@@ -1181,7 +1187,7 @@ namespace MPF.Processors
else if (xgd && line.StartsWith("LayerBreak"))
{
// LayerBreak: <size> (L0 Video: <size>, L0 Middle: <size>, L0 Game: <size>)
string[] split = line.Split(' ').Where(s => !string.IsNullOrEmpty(s)).ToArray();
string[] split = Array.FindAll(line.Split(' '), s => !string.IsNullOrEmpty(s));
return split[1];
}
@@ -1189,7 +1195,7 @@ namespace MPF.Processors
else if (!xgd && line.StartsWith("LayerZeroSector"))
{
// LayerZeroSector: <size> (<hex>)
string[] split = line.Split(' ').Where(s => !string.IsNullOrEmpty(s)).ToArray();
string[] split = Array.FindAll(line.Split(' '), s => !string.IsNullOrEmpty(s));
return split[1];
}
@@ -1302,6 +1308,7 @@ namespace MPF.Processors
var trackSessionRegex = new Regex(@"^\s*Session\s*([0-9]{1,2}),.*?,\s*Track\s*([0-9]{1,2}).*?$", RegexOptions.Compiled);
// Read in the track session data
bool allFirstSession = true;
var trackSessionMapping = new Dictionary<string, string>();
while ((line = sr.ReadLine())?.StartsWith("========== OpCode") == false)
{
@@ -1312,11 +1319,15 @@ namespace MPF.Processors
if (!match.Success)
continue;
// Flag if there are additional sections
if (match.Groups[1].Value != "1")
allFirstSession = false;
trackSessionMapping[match.Groups[2].Value] = match.Groups[1].Value;
}
// If we have all Session 1, we can just skip out
if (trackSessionMapping.All(kvp => kvp.Value == "1"))
if (allFirstSession)
return null;
// Seek to the multisession data
@@ -1920,15 +1931,29 @@ namespace MPF.Processors
sr.ReadLine(); // Separator line
// Now that we're at the offsets, attempt to get the sample offset
string offset = sr.ReadLine()?.Split(' ')?.LastOrDefault() ?? string.Empty;
var offsetLine = sr.ReadLine()?.Split(' ');
string offset = offsetLine != null ? offsetLine[offsetLine.Length - 1] : string.Empty;
offsets.Add(offset);
}
// Deduplicate the offsets
#if NET20
var temp = new List<string>();
foreach (var offset in offsets)
{
if (offset == null || offset.Length == 0)
continue;
if (!temp.Contains(offset))
temp.Add(offset);
}
offsets = temp;
#else
offsets = offsets
.Where(s => !string.IsNullOrEmpty(s))
.FindAll(s => !string.IsNullOrEmpty(s))
.Distinct()
.ToList();
#endif
// Now that we're at the offsets, attempt to get the sample offset
return string.Join("; ", [.. offsets]);
@@ -1963,9 +1988,9 @@ namespace MPF.Processors
if (roms == null || roms.Length == 0)
return false;
dmihash = roms.FirstOrDefault(r => r.Name?.EndsWith("DMI.bin") == true)?.CRC?.ToUpperInvariant();
pfihash = roms.FirstOrDefault(r => r.Name?.EndsWith("PFI.bin") == true)?.CRC?.ToUpperInvariant();
sshash = roms.FirstOrDefault(r => r.Name?.EndsWith("SS.bin") == true)?.CRC?.ToUpperInvariant();
dmihash = Array.Find(roms, r => r.Name?.EndsWith("DMI.bin") == true)?.CRC?.ToUpperInvariant();
pfihash = Array.Find(roms, r => r.Name?.EndsWith("PFI.bin") == true)?.CRC?.ToUpperInvariant();
sshash = Array.Find(roms, r => r.Name?.EndsWith("SS.bin") == true)?.CRC?.ToUpperInvariant();
return true;
}

254
MPF.Processors/Generic.cs Normal file
View File

@@ -0,0 +1,254 @@
using System;
using System.Collections.Generic;
using System.IO;
using SabreTools.Hashing;
using SabreTools.Models.Logiqx;
using SabreTools.RedumpLib;
using SabreTools.RedumpLib.Data;
namespace MPF.Processors
{
/// <summary>
/// Represents processing generic outputs
/// </summary>
public sealed class Generic : BaseProcessor
{
/// <inheritdoc/>
public Generic(RedumpSystem? system, MediaType? type) : base(system, type) { }
#region BaseProcessor Implementations
/// <inheritdoc/>
public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, bool redumpCompat)
{
// Ensure that required sections exist
info = Builder.EnsureAllSections(info);
// Get the dumping program and version
info.DumpingInfo!.DumpingProgram = "UNKNOWN PROGRAM";
info.DumpingInfo.DumpingDate = GetDumpingDate(basePath);
// Get the Datafile information
var datafile = GetDatafile(basePath);
if (datafile != null)
info.TracksAndWriteOffsets!.ClrMameProData = ProcessingTool.GenerateDatfile(datafile);
// Extract info based generically on MediaType
switch (Type)
{
case MediaType.CDROM:
case MediaType.GDROM:
info.TracksAndWriteOffsets!.Cuesheet = ProcessingTool.GetFullFile($"{basePath}.cue") ?? string.Empty;
break;
case MediaType.DVD:
case MediaType.NintendoGameCubeGameDisc:
case MediaType.NintendoWiiOpticalDisc:
case MediaType.HDDVD:
case MediaType.BluRay:
case MediaType.UMD:
var firstRom = datafile?.Game?[0]?.Rom?[0];
if (firstRom != null)
{
info.SizeAndChecksums!.Size = long.Parse(firstRom.Size ?? "0");
info.SizeAndChecksums.CRC32 = firstRom.CRC;
info.SizeAndChecksums.MD5 = firstRom.MD5;
info.SizeAndChecksums.SHA1 = firstRom.SHA1;
}
break;
}
}
/// <inheritdoc/>
internal override List<OutputFile> GetOutputFiles(string? baseDirectory, string baseFilename)
{
return [];
}
#endregion
#region Information Extraction Methods
/// <summary>
/// Attempt to get the dumping date from a base path
/// </summary>
private static string? GetDumpingDate(string basePath)
{
DateTime? fileModifiedDate;
if (File.Exists($"{basePath}.iso"))
fileModifiedDate = ProcessingTool.GetFileModifiedDate($"{basePath}.iso");
else if (File.Exists($"{basePath}.cue"))
fileModifiedDate = ProcessingTool.GetFileModifiedDate($"{basePath}.cue");
else if (File.Exists($"{basePath}.bin"))
fileModifiedDate = ProcessingTool.GetFileModifiedDate($"{basePath}.bin");
else if (File.Exists($"{basePath} (Track 1).bin"))
fileModifiedDate = ProcessingTool.GetFileModifiedDate($"{basePath} (Track 1).bin");
else if (File.Exists($"{basePath} (Track 01).bin"))
fileModifiedDate = ProcessingTool.GetFileModifiedDate($"{basePath} (Track 01).bin");
else if (File.Exists($"{basePath}.ccd"))
fileModifiedDate = ProcessingTool.GetFileModifiedDate($"{basePath}.ccd");
else if (File.Exists($"{basePath}.img"))
fileModifiedDate = ProcessingTool.GetFileModifiedDate($"{basePath}.img");
else if (File.Exists($"{basePath}.mds"))
fileModifiedDate = ProcessingTool.GetFileModifiedDate($"{basePath}.mds");
else if (File.Exists($"{basePath}.mdf"))
fileModifiedDate = ProcessingTool.GetFileModifiedDate($"{basePath}.mdf");
else if (File.Exists($"{basePath}.ima"))
fileModifiedDate = ProcessingTool.GetFileModifiedDate($"{basePath}.ima");
else
return null;
return fileModifiedDate?.ToString("yyyy-MM-dd HH:mm:ss");
}
/// <summary>
/// Attempt to generate a datafile from a base path
/// </summary>
private static Datafile? GetDatafile(string basePath)
{
// Single-file outputs
if (File.Exists($"{basePath}.bin"))
{
var rom = GetRom($"{basePath}.bin");
if (rom != null)
return GetDatafile(basePath, rom);
}
else if (File.Exists($"{basePath}.ima"))
{
var rom = GetRom($"{basePath}.ima");
if (rom != null)
return GetDatafile(basePath, rom);
}
else if (File.Exists($"{basePath}.img"))
{
var rom = GetRom($"{basePath}.img");
if (rom != null)
return GetDatafile(basePath, rom);
}
else if (File.Exists($"{basePath}.iso"))
{
var rom = GetRom($"{basePath}.iso");
if (rom != null)
return GetDatafile(basePath, rom);
}
else if (File.Exists($"{basePath}.mdf"))
{
var rom = GetRom($"{basePath}.mdf");
if (rom != null)
return GetDatafile(basePath, rom);
}
// Multi-file outputs
else if (File.Exists($"{basePath} (Track 1).bin"))
{
var roms = new List<Rom>();
// Try Track 0
var track0rom = GetRom($"{basePath} (Track 0).bin");
if (track0rom != null)
roms.Add(track0rom);
// Hash all found tracks
for (int i = 1; i < 10; i++)
{
// Get the rom for the track
var rom = GetRom($"{basePath} (Track {i}).bin");
if (rom == null)
break;
// Add the track to the output
roms.Add(rom);
}
// Try Track A
var trackArom = GetRom($"{basePath} (Track A).bin");
if (trackArom != null)
roms.Add(trackArom);
// Create and return if there are any tracks
if (roms.Count > 0)
return GetDatafile(basePath, roms);
}
else if (File.Exists($"{basePath} (Track 01).bin"))
{
var roms = new List<Rom>();
// Try Track 00
var track00rom = GetRom($"{basePath} (Track 00).bin");
if (track00rom != null)
roms.Add(track00rom);
// Hash all found tracks
for (int i = 1; i < 100; i++)
{
// Get the rom for the track
var rom = GetRom($"{basePath} (Track {i:D2}).bin");
if (rom == null)
break;
// Add the track to the output
roms.Add(rom);
}
// Try Track AA
var trackAArom = GetRom($"{basePath} (Track AA).bin");
if (trackAArom != null)
roms.Add(trackAArom);
// Create and return if there are any tracks
if (roms.Count > 0)
return GetDatafile(basePath, roms);
}
// Unrecognized file input
return null;
}
/// <summary>
/// Generate a Datafile from a base path and a Rom
/// </summary>
private static Datafile? GetDatafile(string basePath, Rom rom)
=> GetDatafile(basePath, [rom]);
/// <summary>
/// Generate a Datafile from a base path and a list of Roms
/// </summary>
private static Datafile? GetDatafile(string basePath, List<Rom> roms)
{
// Return null if no Roms exist
if (roms.Count == 0)
return null;
// Format the new Datafile
return new Datafile
{
Game =
[
new Game
{
Name = Path.GetFileName(basePath),
Rom = [.. roms]
}
]
};
}
/// <summary>
/// Get a Rom object for a single file
/// </summary>
private static Rom? GetRom(string file)
{
// Skip missing or invalid files
if (!File.Exists(file))
return null;
if (!HashTool.GetStandardHashes(file, out long filesize, out var crc32, out var md5, out var sha1))
return null;
// Format the data into a rom object
return new Rom { Name = Path.GetFileName(file), Size = filesize.ToString(), CRC = crc32, MD5 = md5, SHA1 = sha1 };
}
#endregion
}
}

View File

@@ -2,14 +2,15 @@
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>latest</LangVersion>
<NoWarn>NU1902;NU1903</NoWarn>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<VersionPrefix>3.2.3</VersionPrefix>
<VersionPrefix>3.2.4</VersionPrefix>
<WarningsNotAsErrors>NU5104</WarningsNotAsErrors>
<!-- Package Properties -->
@@ -25,26 +26,7 @@
<InternalsVisibleTo Include="MPF.Test" />
</ItemGroup>
<!-- Support All Frameworks -->
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net4`))">
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>
<!-- Support for old .NET versions -->
<ItemGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net40`))">
<PackageReference Include="MinAsyncBridge" Version="0.12.4" />
<PackageReference Include="MinTasksExtensionsBridge" Version="0.3.4" />
<PackageReference Include="MinThreadingBridge" Version="0.11.4" />
</ItemGroup>
<ItemGroup Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`))">
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
</ItemGroup>
@@ -53,11 +35,11 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="psxt001z.Library" Version="0.21.0-rc1" />
<PackageReference Include="SabreTools.Hashing" Version="1.2.2" />
<PackageReference Include="SabreTools.Models" Version="1.4.11" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.4.4" />
<PackageReference Include="SabreTools.Serialization" Version="1.6.9" />
<PackageReference Include="psxt001z.Library" Version="0.21.0-rc2" />
<PackageReference Include="SabreTools.Hashing" Version="1.4.0" />
<PackageReference Include="SabreTools.Models" Version="1.5.3" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.5.2" />
<PackageReference Include="SabreTools.Serialization" Version="1.7.6" />
</ItemGroup>
</Project>

View File

@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using SabreTools.Hashing;
using SabreTools.Models.Logiqx;
using SabreTools.RedumpLib;
@@ -68,10 +67,7 @@ namespace MPF.Processors
if (id != null)
info.Extras!.DiscID = id.ToUpperInvariant().Substring(0, 24) + "XXXXXXXX";
if (string.IsNullOrEmpty(info.Extras!.PIC) && !string.IsNullOrEmpty(pic))
{
pic = Regex.Replace(pic, ".{32}", "$0\n");
info.Extras.PIC = pic;
}
info.Extras.PIC = SplitString(pic, 32);
}
}

View File

@@ -1,11 +1,14 @@
using System;
using System.IO;
#if NET35_OR_GREATER || NETCOREAPP
using System.Linq;
#endif
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using SabreTools.IO.Extensions;
using SabreTools.Models.Logiqx;
using SabreTools.Models.PIC;
using SabreTools.RedumpLib.Data;
@@ -31,14 +34,18 @@ namespace MPF.Processors
return null;
// Convert ASCII to byte via lookup table
int[] hexLookup = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F];
int[] hexLookup =
[
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
];
byte[] byteArray = new byte[hexString.Length / 2];
for (int i = 0; i < hexString.Length; i += 2)
{
// Convert next two chars to ASCII value relative to '0'
int a = Char.ToUpper(hexString[i]) - '0';
int b = Char.ToUpper(hexString[i + 1]) - '0';
int a = Char.ToUpperInvariant(hexString[i]) - '0';
int b = Char.ToUpperInvariant(hexString[i + 1]) - '0';
// Ensure hex string only has '0' through '9' and 'A' through 'F' (case insensitive)
if ((a < 0 || b < 0 || a > 22 || b > 22) || (a > 10 && a < 17) || (b > 10 && b < 17))
@@ -270,20 +277,13 @@ namespace MPF.Processors
if (di?.Units == null || di.Units.Length <= 1)
return false;
// Wrap big-endian reading
static int ReadFromArrayBigEndian(byte[]? bytes, int offset)
{
if (bytes == null)
return default;
#if NET20 || NET35 || NET40
byte[] rev = new byte[0x04];
Array.Copy(bytes, offset, rev, 0, 0x04);
#else
var span = new ReadOnlySpan<byte>(bytes, offset, 0x04);
byte[] rev = span.ToArray();
#endif
Array.Reverse(rev);
return BitConverter.ToInt32(rev, 0);
return bytes.ReadInt32BigEndian(ref offset);
}
// Layerbreak 1 (2+ layers)
@@ -745,7 +745,7 @@ namespace MPF.Processors
if (string.IsNullOrEmpty(inputPIC))
return null;
string cleanPIC = inputPIC!.Trim().Replace("\n", string.Empty);
string cleanPIC = inputPIC!.Trim().Replace("\n", string.Empty).Replace("\r", string.Empty);
if (cleanPIC.Length < 230)
return null;
@@ -921,7 +921,13 @@ namespace MPF.Processors
if (!GetXGDType(ss, out int xgdType))
return false;
if (xgdType == 3 && ss.Skip(32).Take(72).All(x => x == 0))
#if NET20
var checkArr = new byte[72];
Array.Copy(ss, 32, checkArr, 0, 72);
if (xgdType == 3 && Array.Exists(checkArr, x => x != 0))
#else
if (xgdType == 3 && ss.Skip(32).Take(72).Any(x => x != 0))
#endif
{
// Check for a cleaned SSv2
@@ -1073,7 +1079,13 @@ namespace MPF.Processors
case 3:
// Determine if XGD3 SS.bin is SSv1 (Kreon) or SSv2 (0800)
#if NET20
var checkArr = new byte[72];
Array.Copy(ss, 32, checkArr, 0, 72);
bool ssv2 = Array.Exists(checkArr, x => x != 0);
#else
bool ssv2 = ss.Skip(32).Take(72).Any(x => x != 0);
#endif
if (ssv2)
{

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using SabreTools.Hashing;
using SabreTools.Models.CueSheets;
@@ -173,7 +172,15 @@ namespace MPF.Processors
break;
case RedumpSystem.MicrosoftXbox:
string xmidString = ProcessingTool.GetXMID($"{basePath}.manufacturer");
// If .dmi / .pfi / .ss don't already exist, create them
if (!File.Exists($"{basePath}.dmi"))
RemoveHeader($"{basePath}.manufacturer", $"{basePath}.dmi");
if (!File.Exists($"{basePath}.pfi"))
RemoveHeader($"{basePath}.physical", $"{basePath}.pfi");
if (!File.Exists($"{basePath}.ss"))
ProcessingTool.CleanSS($"{basePath}.security", $"{basePath}.ss");
string xmidString = ProcessingTool.GetXMID($"{basePath}.dmi");
var xmid = SabreTools.Serialization.Wrappers.XMID.Create(xmidString);
if (xmid != null)
{
@@ -185,16 +192,32 @@ namespace MPF.Processors
info.CommonDiscInfo.Region = ProcessingTool.GetXGDRegion(xmid.Model.RegionIdentifier);
}
if (HashTool.GetStandardHashes($"{basePath}.manufacturer", out _, out string? dmi1Crc, out _, out _))
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.DMIHash] = dmi1Crc ?? string.Empty;
if (HashTool.GetStandardHashes($"{basePath}.physical", out _, out string? pfi1Crc, out _, out _))
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.PFIHash] = pfi1Crc ?? string.Empty;
string? dmi1Crc = HashTool.GetFileHash($"{basePath}.dmi", HashType.CRC32);
if (dmi1Crc != null)
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.DMIHash] = dmi1Crc.ToUpperInvariant();
string? pfi1Crc = HashTool.GetFileHash($"{basePath}.pfi", HashType.CRC32);
if (pfi1Crc != null)
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.PFIHash] = pfi1Crc.ToUpperInvariant();
string? ss1Crc = HashTool.GetFileHash($"{basePath}.ss", HashType.CRC32);
if (ss1Crc != null)
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.SSHash] = ss1Crc.ToUpperInvariant();
string? ranges1 = ProcessingTool.GetSSRanges($"{basePath}.ss");
if (!string.IsNullOrEmpty(ranges1))
info.Extras!.SecuritySectorRanges = ranges1;
// TODO: Support SS information when generated
break;
case RedumpSystem.MicrosoftXbox360:
string xemidString = ProcessingTool.GetXeMID($"{basePath}.manufacturer");
// If .dmi / .pfi / .ss don't already exist, create them
if (!File.Exists($"{basePath}.dmi"))
RemoveHeader($"{basePath}.manufacturer", $"{basePath}.dmi");
if (!File.Exists($"{basePath}.pfi"))
RemoveHeader($"{basePath}.physical", $"{basePath}.pfi");
if (!File.Exists($"{basePath}.ss"))
ProcessingTool.CleanSS($"{basePath}.security", $"{basePath}.ss");
string xemidString = ProcessingTool.GetXeMID($"{basePath}.dmi");
var xemid = SabreTools.Serialization.Wrappers.XeMID.Create(xemidString);
if (xemid != null)
{
@@ -206,12 +229,20 @@ namespace MPF.Processors
info.CommonDiscInfo.Region = ProcessingTool.GetXGDRegion(xemid.Model.RegionIdentifier);
}
if (HashTool.GetStandardHashes($"{basePath}.manufacturer", out _, out string? dmi23Crc, out _, out _))
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.DMIHash] = dmi23Crc ?? string.Empty;
if (HashTool.GetStandardHashes($"{basePath}.physical", out _, out string? pfi23Crc, out _, out _))
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.PFIHash] = pfi23Crc ?? string.Empty;
string? dmi23Crc = HashTool.GetFileHash($"{basePath}.dmi", HashType.CRC32);
if (dmi23Crc != null)
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.DMIHash] = dmi23Crc.ToUpperInvariant();
string? pfi23Crc = HashTool.GetFileHash($"{basePath}.pfi", HashType.CRC32);
if (pfi23Crc != null)
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.PFIHash] = pfi23Crc.ToUpperInvariant();
string? ss23Crc = HashTool.GetFileHash($"{basePath}.ss", HashType.CRC32);
if (ss23Crc != null)
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.SSHash] = ss23Crc.ToUpperInvariant();
string? ranges23 = ProcessingTool.GetSSRanges($"{basePath}.ss");
if (!string.IsNullOrEmpty(ranges23))
info.Extras!.SecuritySectorRanges = ranges23;
// TODO: Support SS information when generated
break;
case RedumpSystem.NamcoSegaNintendoTriforce:
@@ -450,6 +481,9 @@ namespace MPF.Processors
new($"{baseFilename}.asus", OutputFileFlags.Binary
| OutputFileFlags.Zippable,
"asus"),
new($"{baseFilename}.dmi", OutputFileFlags.Binary
| OutputFileFlags.Zippable,
"dmi"),
new($"{baseFilename}.hash", OutputFileFlags.Binary
| OutputFileFlags.Zippable,
"hash"),
@@ -466,6 +500,9 @@ namespace MPF.Processors
new($"{baseFilename}.1.manufacturer", OutputFileFlags.Binary
| OutputFileFlags.Zippable,
"manufacturer_1"),
new($"{baseFilename}.pfi", OutputFileFlags.Binary
| OutputFileFlags.Zippable,
"pfi"),
new([$"{baseFilename}.physical", $"{baseFilename}.0.physical"], OutputFileFlags.Required
| OutputFileFlags.Binary
| OutputFileFlags.Zippable,
@@ -547,6 +584,52 @@ namespace MPF.Processors
private static bool DatfileExists(string log)
=> GetDatfile(log) != null;
/// <summary>
/// Copies a file with the header removed
/// </summary>
/// <param name="inputFilename">Filename of file to copy from</param>
/// <param name="outputFilename">Filename of file to copy to</param>
/// <param name="headerLength">Length of header to remove</param>
private static bool RemoveHeader(string inputFilename, string outputFilename, int headerLength = 4)
{
// If the file doesn't exist, we can't copy
if (!File.Exists(inputFilename))
return false;
// If the output file already exists, don't overwrite
if (File.Exists(outputFilename))
return false;
try
{
using var inputStream = new FileStream(inputFilename, FileMode.Open, FileAccess.Read);
// If the header length is not valid, don't copy
if (headerLength < 1 || headerLength >= inputStream.Length)
return false;
using var outputStream = new FileStream(outputFilename, FileMode.Create, FileAccess.Write);
// Skip the header
inputStream.Seek(headerLength, SeekOrigin.Begin);
// inputStream.CopyTo(outputStream);
byte[] buffer = new byte[4096];
int count;
while ((count = inputStream.Read(buffer, 0, buffer.Length)) != 0)
{
outputStream.Write(buffer, 0, count);
}
return true;
}
catch
{
// We don't care what the exception is right now
return false;
}
}
#endregion
#region Information Extraction Methods
@@ -996,7 +1079,7 @@ namespace MPF.Processors
else if (line.StartsWith("data "))
{
// data { LBA: <startLBA> .. <endLBA>, length: <length>, hLBA: <startLBA> .. <endLBA> }
string[] split = line.Split(' ').Where(s => !string.IsNullOrEmpty(s)).ToArray();
string[] split = Array.FindAll(line.Split(' '), s => !string.IsNullOrEmpty(s));
layerbreak1 ??= split[7].TrimEnd(',');
}

View File

@@ -1,8 +1,9 @@
using System;
using System.IO;
#if NET452_OR_GREATER || NETCOREAPP
using System.IO.Compression;
#endif
using System.Linq;
#endif
using System.Text.RegularExpressions;
namespace MPF.Processors
@@ -55,7 +56,7 @@ namespace MPF.Processors
var directoryFiles = Directory.GetFiles(baseDirectory);
foreach (string file in directoryFiles)
{
if (Filenames.Any(pattern => Regex.IsMatch(file, pattern)))
if (Array.FindIndex(Filenames, pattern => Regex.IsMatch(file, pattern)) > -1)
return true;
}
@@ -77,7 +78,7 @@ namespace MPF.Processors
var archiveFiles = archive.Entries.Select(e => e.Name).ToList();
foreach (string file in archiveFiles)
{
if (Filenames.Any(pattern => Regex.IsMatch(file, pattern)))
if (Array.Exists(Filenames, pattern => Regex.IsMatch(file, pattern)))
return true;
}

View File

@@ -1,7 +1,5 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using SabreTools.Hashing;
using SabreTools.Models.Logiqx;
using SabreTools.RedumpLib;
@@ -127,9 +125,6 @@ namespace MPF.Processors
if (!string.IsNullOrEmpty(ranges))
info.Extras!.SecuritySectorRanges = ranges;
// TODO: Determine SS version?
//info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.SSVersion] =
// Recreate RawSS.bin
RecreateSS(logPath!, ssPath, Path.Combine(baseDirectory, "RawSS.bin"));

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using MPF.Frontend;
using Xunit;
@@ -47,7 +46,7 @@ namespace MPF.Test.Frontend
var testData = new List<object?[]>() { new object?[] { null, true } };
foreach (DriveType driveType in Enum.GetValues(typeof(DriveType)))
{
if (_mappableDriveTypes.Contains(driveType))
if (Array.IndexOf(_mappableDriveTypes, driveType) > -1)
testData.Add([driveType, false]);
else
testData.Add([driveType, true]);

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0;net9.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
@@ -15,13 +15,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeCoverage" Version="17.11.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Microsoft.CodeCoverage" Version="17.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.4.4" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.5.2" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.analyzers" Version="1.16.0" />
<PackageReference Include="xunit.analyzers" Version="1.17.0" />
<PackageReference Include="xunit.assert" Version="2.9.2" />
<PackageReference Include="xunit.core" Version="2.9.2" />
<PackageReference Include="xunit.extensibility.core" Version="2.9.2" />

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
using static MPF.Frontend.InterfaceConstants;
@@ -34,7 +33,7 @@ namespace MPF.UI
/// <summary>
/// Create a DoubleCollection out of a list of integer values
/// </summary>
private static DoubleCollection GetDoubleCollectionFromIntList(IList<int> list)
=> new(list.Select(i => Convert.ToDouble(i)).ToList());
private static DoubleCollection GetDoubleCollectionFromIntList(List<int> list)
=> [.. list.ConvertAll(i => Convert.ToDouble(i))];
}
}

View File

@@ -32,19 +32,11 @@ namespace WPFCustomMessageBox
{
get
{
#if NET35
return _TextBlock_Message!.Text;
#else
return TextBlock_Message.Text;
#endif
return TextBlock_Message!.Text;
}
set
{
#if NET35
_TextBlock_Message!.Text = value;
#else
TextBlock_Message.Text = value;
#endif
TextBlock_Message!.Text = value;
}
}
@@ -52,19 +44,11 @@ namespace WPFCustomMessageBox
{
get
{
#if NET35
return _Label_Ok!.Content.ToString();
#else
return Label_Ok.Content.ToString();
#endif
return Label_Ok!.Content.ToString();
}
set
{
#if NET35
_Label_Ok!.Content = value.TryAddKeyboardAccellerator();
#else
Label_Ok.Content = value.TryAddKeyboardAccellerator();
#endif
Label_Ok!.Content = value.TryAddKeyboardAccellerator();
}
}
@@ -72,19 +56,11 @@ namespace WPFCustomMessageBox
{
get
{
#if NET35
return _Label_Cancel!.Content.ToString();
#else
return Label_Cancel.Content.ToString();
#endif
return Label_Cancel!.Content.ToString();
}
set
{
#if NET35
_Label_Cancel!.Content = value.TryAddKeyboardAccellerator();
#else
Label_Cancel.Content = value.TryAddKeyboardAccellerator();
#endif
Label_Cancel!.Content = value.TryAddKeyboardAccellerator();
}
}
@@ -92,19 +68,11 @@ namespace WPFCustomMessageBox
{
get
{
#if NET35
return _Label_Yes!.Content.ToString();
#else
return Label_Yes.Content.ToString();
#endif
return Label_Yes!.Content.ToString();
}
set
{
#if NET35
_Label_Yes!.Content = value.TryAddKeyboardAccellerator();
#else
Label_Yes.Content = value.TryAddKeyboardAccellerator();
#endif
Label_Yes!.Content = value.TryAddKeyboardAccellerator();
}
}
@@ -112,19 +80,11 @@ namespace WPFCustomMessageBox
{
get
{
#if NET35
return _Label_No!.Content.ToString();
#else
return Label_No.Content.ToString();
#endif
return Label_No!.Content.ToString();
}
set
{
#if NET35
_Label_No!.Content = value.TryAddKeyboardAccellerator();
#else
Label_No.Content = value.TryAddKeyboardAccellerator();
#endif
Label_No!.Content = value.TryAddKeyboardAccellerator();
}
}
@@ -132,16 +92,16 @@ namespace WPFCustomMessageBox
#if NET35
private Button? _Button_Cancel => ItemHelper.FindChild<Button>(this, "Button_Cancel");
private Button? _Button_No => ItemHelper.FindChild<Button>(this, "Button_No");
private Button? _Button_OK => ItemHelper.FindChild<Button>(this, "Button_OK");
private Button? _Button_Yes => ItemHelper.FindChild<Button>(this, "Button_Yes");
private Button? Button_Cancel => ItemHelper.FindChild<Button>(this, "Button_Cancel");
private Button? Button_No => ItemHelper.FindChild<Button>(this, "Button_No");
private Button? Button_OK => ItemHelper.FindChild<Button>(this, "Button_OK");
private Button? Button_Yes => ItemHelper.FindChild<Button>(this, "Button_Yes");
private System.Windows.Controls.Image? _Image_MessageBox => ItemHelper.FindChild<System.Windows.Controls.Image>(this, "Image_MessageBox");
private Label? _Label_Cancel => ItemHelper.FindChild<Label>(this, "Label_Cancel");
private Label? _Label_No => ItemHelper.FindChild<Label>(this, "Label_No");
private Label? _Label_Ok => ItemHelper.FindChild<Label>(this, "Label_Ok");
private Label? _Label_Yes => ItemHelper.FindChild<Label>(this, "Label_Yes");
private TextBlock? _TextBlock_Message => ItemHelper.FindChild<TextBlock>(this, "TextBlock_Message");
private Label? Label_Cancel => ItemHelper.FindChild<Label>(this, "Label_Cancel");
private Label? Label_No => ItemHelper.FindChild<Label>(this, "Label_No");
private Label? Label_Ok => ItemHelper.FindChild<Label>(this, "Label_Ok");
private Label? Label_Yes => ItemHelper.FindChild<Label>(this, "Label_Yes");
private TextBlock? TextBlock_Message => ItemHelper.FindChild<TextBlock>(this, "TextBlock_Message");
#endif
@@ -185,11 +145,7 @@ namespace WPFCustomMessageBox
if (image.HasValue)
DisplayImage(image.Value);
else
#if NET35
_Image_MessageBox!.Visibility = Visibility.Collapsed;
#else
Image_MessageBox.Visibility = Visibility.Collapsed;
#endif
Image_MessageBox!.Visibility = Visibility.Collapsed;
}
protected override void OnSourceInitialized(EventArgs e)
@@ -206,75 +162,39 @@ namespace WPFCustomMessageBox
{
case MessageBoxButton.OKCancel:
// Hide all but OK, Cancel
#if NET35
_Button_OK!.Visibility = Visibility.Visible;
_Button_OK.Focus();
_Button_Cancel!.Visibility = Visibility.Visible;
_Button_Yes!.Visibility = Visibility.Collapsed;
_Button_No!.Visibility = Visibility.Collapsed;
#else
Button_OK.Visibility = Visibility.Visible;
Button_OK!.Visibility = Visibility.Visible;
Button_OK.Focus();
Button_Cancel.Visibility = Visibility.Visible;
Button_Cancel!.Visibility = Visibility.Visible;
Button_Yes.Visibility = Visibility.Collapsed;
Button_No.Visibility = Visibility.Collapsed;
#endif
Button_Yes!.Visibility = Visibility.Collapsed;
Button_No!.Visibility = Visibility.Collapsed;
break;
case MessageBoxButton.YesNo:
// Hide all but Yes, No
#if NET35
_Button_Yes!.Visibility = Visibility.Visible;
_Button_Yes.Focus();
_Button_No!.Visibility = Visibility.Visible;
_Button_OK!.Visibility = Visibility.Collapsed;
_Button_Cancel!.Visibility = Visibility.Collapsed;
#else
Button_Yes.Visibility = Visibility.Visible;
Button_Yes!.Visibility = Visibility.Visible;
Button_Yes.Focus();
Button_No.Visibility = Visibility.Visible;
Button_No!.Visibility = Visibility.Visible;
Button_OK.Visibility = Visibility.Collapsed;
Button_Cancel.Visibility = Visibility.Collapsed;
#endif
Button_OK!.Visibility = Visibility.Collapsed;
Button_Cancel!.Visibility = Visibility.Collapsed;
break;
case MessageBoxButton.YesNoCancel:
// Hide only OK
#if NET35
_Button_Yes!.Visibility = Visibility.Visible;
_Button_Yes.Focus();
_Button_No!.Visibility = Visibility.Visible;
_Button_Cancel!.Visibility = Visibility.Visible;
_Button_OK!.Visibility = Visibility.Collapsed;
#else
Button_Yes.Visibility = Visibility.Visible;
Button_Yes!.Visibility = Visibility.Visible;
Button_Yes.Focus();
Button_No.Visibility = Visibility.Visible;
Button_Cancel.Visibility = Visibility.Visible;
Button_No!.Visibility = Visibility.Visible;
Button_Cancel!.Visibility = Visibility.Visible;
Button_OK.Visibility = Visibility.Collapsed;
#endif
Button_OK!.Visibility = Visibility.Collapsed;
break;
default:
// Hide all but OK
#if NET35
_Button_OK!.Visibility = Visibility.Visible;
_Button_OK.Focus();
_Button_Yes!.Visibility = Visibility.Collapsed;
_Button_No!.Visibility = Visibility.Collapsed;
_Button_Cancel!.Visibility = Visibility.Collapsed;
#else
Button_OK.Visibility = Visibility.Visible;
Button_OK!.Visibility = Visibility.Visible;
Button_OK.Focus();
Button_Yes.Visibility = Visibility.Collapsed;
Button_No.Visibility = Visibility.Collapsed;
Button_Cancel.Visibility = Visibility.Collapsed;
#endif
Button_Yes!.Visibility = Visibility.Collapsed;
Button_No!.Visibility = Visibility.Collapsed;
Button_Cancel!.Visibility = Visibility.Collapsed;
break;
}
}
@@ -302,13 +222,8 @@ namespace WPFCustomMessageBox
break;
}
#if NET35
_Image_MessageBox!.Source = icon.ToImageSource();
_Image_MessageBox.Visibility = Visibility.Visible;
#else
Image_MessageBox.Source = icon.ToImageSource();
Image_MessageBox!.Source = icon.ToImageSource();
Image_MessageBox.Visibility = Visibility.Visible;
#endif
}
private void Button_OK_Click(object sender, RoutedEventArgs e)

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net40;net452;net462;net472;net48;netcoreapp3.1;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows</TargetFrameworks>
<TargetFrameworks>net40;net452;net462;net472;net48;netcoreapp3.1;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows;net9.0-windows</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
<OutputType>WinExe</OutputType>
<ApplicationIcon>Images\Icon.ico</ApplicationIcon>
@@ -11,12 +11,13 @@
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<ImportFrameworkWinFXTargets Condition="$(TargetFramework.StartsWith(`net3`))">true</ImportFrameworkWinFXTargets>
<LangVersion>latest</LangVersion>
<NoWarn>NU1902;NU1903</NoWarn>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<VersionPrefix>3.2.3</VersionPrefix>
<VersionPrefix>3.2.4</VersionPrefix>
<!-- Package Properties -->
<AssemblyName>MPF</AssemblyName>
@@ -37,7 +38,7 @@
<ReferenceWpfLunaTheme>false</ReferenceWpfLunaTheme>
<ReferenceWpfRoyaleTheme>false</ReferenceWpfRoyaleTheme>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`)) OR $(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`))">
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`)) OR $(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`))">
<ReferenceWpfAeroTheme>false</ReferenceWpfAeroTheme>
<ReferenceWpfAero2Theme>true</ReferenceWpfAero2Theme>
<ReferenceWpfAeroLiteTheme>false</ReferenceWpfAeroLiteTheme>
@@ -72,10 +73,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BinaryObjectScanner" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="3.1.16" GeneratePathProperty="true">
<PackageReference Include="BinaryObjectScanner" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="3.2.3" GeneratePathProperty="true">
<IncludeAssets>runtime; compile; build; native; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SabreTools.RedumpLib" Version="1.4.4" />
<PackageReference Include="SabreTools.RedumpLib" Version="1.5.2" />
</ItemGroup>
<ItemGroup>

View File

@@ -205,53 +205,53 @@ namespace MPF.UI
public void Apply()
{
// Handle application-wide resources
Application.Current.Resources[SystemColors.ActiveBorderBrushKey] = this.ActiveBorderBrush;
Application.Current.Resources[SystemColors.ControlBrushKey] = this.ControlBrush;
Application.Current.Resources[SystemColors.ControlTextBrushKey] = this.ControlTextBrush;
Application.Current.Resources[SystemColors.GrayTextBrushKey] = this.GrayTextBrush;
Application.Current.Resources[SystemColors.WindowBrushKey] = this.WindowBrush;
Application.Current.Resources[SystemColors.WindowTextBrushKey] = this.WindowTextBrush;
Application.Current.Resources[SystemColors.ActiveBorderBrushKey] = ActiveBorderBrush;
Application.Current.Resources[SystemColors.ControlBrushKey] = ControlBrush;
Application.Current.Resources[SystemColors.ControlTextBrushKey] = ControlTextBrush;
Application.Current.Resources[SystemColors.GrayTextBrushKey] = GrayTextBrush;
Application.Current.Resources[SystemColors.WindowBrushKey] = WindowBrush;
Application.Current.Resources[SystemColors.WindowTextBrushKey] = WindowTextBrush;
// Handle Button-specific resources
Application.Current.Resources["Button.Disabled.Background"] = this.Button_Disabled_Background;
Application.Current.Resources["Button.MouseOver.Background"] = this.Button_MouseOver_Background;
Application.Current.Resources["Button.Pressed.Background"] = this.Button_Pressed_Background;
Application.Current.Resources["Button.Static.Background"] = this.Button_Static_Background;
Application.Current.Resources["Button.Disabled.Background"] = Button_Disabled_Background;
Application.Current.Resources["Button.MouseOver.Background"] = Button_MouseOver_Background;
Application.Current.Resources["Button.Pressed.Background"] = Button_Pressed_Background;
Application.Current.Resources["Button.Static.Background"] = Button_Static_Background;
// Handle ComboBox-specific resources
Application.Current.Resources["ComboBox.Disabled.Background"] = this.ComboBox_Disabled_Background;
Application.Current.Resources["ComboBox.Disabled.Editable.Background"] = this.ComboBox_Disabled_Editable_Background;
Application.Current.Resources["ComboBox.Disabled.Editable.Button.Background"] = this.ComboBox_Disabled_Editable_Button_Background;
Application.Current.Resources["ComboBox.MouseOver.Background"] = this.ComboBox_MouseOver_Background;
Application.Current.Resources["ComboBox.MouseOver.Editable.Background"] = this.ComboBox_MouseOver_Editable_Background;
Application.Current.Resources["ComboBox.MouseOver.Editable.Button.Background"] = this.ComboBox_MouseOver_Editable_Button_Background;
Application.Current.Resources["ComboBox.Pressed.Background"] = this.ComboBox_Pressed_Background;
Application.Current.Resources["ComboBox.Pressed.Editable.Background"] = this.ComboBox_Pressed_Editable_Background;
Application.Current.Resources["ComboBox.Pressed.Editable.Button.Background"] = this.ComboBox_Pressed_Editable_Button_Background;
Application.Current.Resources["ComboBox.Static.Background"] = this.ComboBox_Static_Background;
Application.Current.Resources["ComboBox.Static.Editable.Background"] = this.ComboBox_Static_Editable_Background;
Application.Current.Resources["ComboBox.Static.Editable.Button.Background"] = this.ComboBox_Static_Editable_Button_Background;
Application.Current.Resources["ComboBox.Disabled.Background"] = ComboBox_Disabled_Background;
Application.Current.Resources["ComboBox.Disabled.Editable.Background"] = ComboBox_Disabled_Editable_Background;
Application.Current.Resources["ComboBox.Disabled.Editable.Button.Background"] = ComboBox_Disabled_Editable_Button_Background;
Application.Current.Resources["ComboBox.MouseOver.Background"] = ComboBox_MouseOver_Background;
Application.Current.Resources["ComboBox.MouseOver.Editable.Background"] = ComboBox_MouseOver_Editable_Background;
Application.Current.Resources["ComboBox.MouseOver.Editable.Button.Background"] = ComboBox_MouseOver_Editable_Button_Background;
Application.Current.Resources["ComboBox.Pressed.Background"] = ComboBox_Pressed_Background;
Application.Current.Resources["ComboBox.Pressed.Editable.Background"] = ComboBox_Pressed_Editable_Background;
Application.Current.Resources["ComboBox.Pressed.Editable.Button.Background"] = ComboBox_Pressed_Editable_Button_Background;
Application.Current.Resources["ComboBox.Static.Background"] = ComboBox_Static_Background;
Application.Current.Resources["ComboBox.Static.Editable.Background"] = ComboBox_Static_Editable_Background;
Application.Current.Resources["ComboBox.Static.Editable.Button.Background"] = ComboBox_Static_Editable_Button_Background;
// Handle CustomMessageBox-specific resources
Application.Current.Resources["CustomMessageBox.Static.Background"] = this.CustomMessageBox_Static_Background;
Application.Current.Resources["CustomMessageBox.Static.Background"] = CustomMessageBox_Static_Background;
// Handle MenuItem-specific resources
Application.Current.Resources["MenuItem.SubMenu.Background"] = this.MenuItem_SubMenu_Background;
Application.Current.Resources["MenuItem.SubMenu.Border"] = this.MenuItem_SubMenu_Border;
Application.Current.Resources["MenuItem.SubMenu.Background"] = MenuItem_SubMenu_Background;
Application.Current.Resources["MenuItem.SubMenu.Border"] = MenuItem_SubMenu_Border;
// Handle ProgressBar-specific resources
Application.Current.Resources["ProgressBar.Background"] = this.ProgressBar_Background;
Application.Current.Resources["ProgressBar.Background"] = ProgressBar_Background;
// Handle ScrollViewer-specific resources
Application.Current.Resources["ScrollViewer.ScrollBar.Background"] = this.ScrollViewer_ScrollBar_Background;
Application.Current.Resources["ScrollViewer.ScrollBar.Background"] = ScrollViewer_ScrollBar_Background;
// Handle TabItem-specific resources
Application.Current.Resources["TabItem.Selected.Background"] = this.TabItem_Selected_Background;
Application.Current.Resources["TabItem.Static.Background"] = this.TabItem_Static_Background;
Application.Current.Resources["TabItem.Static.Border"] = this.TabItem_Static_Border;
Application.Current.Resources["TabItem.Selected.Background"] = TabItem_Selected_Background;
Application.Current.Resources["TabItem.Static.Background"] = TabItem_Static_Background;
Application.Current.Resources["TabItem.Static.Border"] = TabItem_Static_Border;
// Handle TextBox-specific resources
Application.Current.Resources["TextBox.Static.Background"] = this.TextBox_Static_Background;
Application.Current.Resources["TextBox.Static.Background"] = TextBox_Static_Background;
}
}
}

View File

@@ -36,53 +36,53 @@ namespace MPF.UI.Themes
var foregroundBrush = new SolidColorBrush { Color = Color.FromArgb(0xff, foregroundR, foregroundG, foregroundB) };
// Handle application-wide resources
this.ActiveBorderBrush = foregroundBrush;
this.ControlBrush = backgroundBrush;
this.ControlTextBrush = foregroundBrush;
this.GrayTextBrush = foregroundBrush;
this.WindowBrush = backgroundBrush;
this.WindowTextBrush = foregroundBrush;
ActiveBorderBrush = foregroundBrush;
ControlBrush = backgroundBrush;
ControlTextBrush = foregroundBrush;
GrayTextBrush = foregroundBrush;
WindowBrush = backgroundBrush;
WindowTextBrush = foregroundBrush;
// Handle Button-specific resources
this.Button_Disabled_Background = backgroundBrush;
this.Button_MouseOver_Background = backgroundBrush;
this.Button_Pressed_Background = backgroundBrush;
this.Button_Static_Background = backgroundBrush;
Button_Disabled_Background = backgroundBrush;
Button_MouseOver_Background = backgroundBrush;
Button_Pressed_Background = backgroundBrush;
Button_Static_Background = backgroundBrush;
// Handle ComboBox-specific resources
this.ComboBox_Disabled_Background = backgroundBrush;
this.ComboBox_Disabled_Editable_Background = backgroundBrush;
this.ComboBox_Disabled_Editable_Button_Background = backgroundBrush;
this.ComboBox_MouseOver_Background = backgroundBrush;
this.ComboBox_MouseOver_Editable_Background = backgroundBrush;
this.ComboBox_MouseOver_Editable_Button_Background = backgroundBrush;
this.ComboBox_Pressed_Background = backgroundBrush;
this.ComboBox_Pressed_Editable_Background = backgroundBrush;
this.ComboBox_Pressed_Editable_Button_Background = backgroundBrush;
this.ComboBox_Static_Background = backgroundBrush;
this.ComboBox_Static_Editable_Background = backgroundBrush;
this.ComboBox_Static_Editable_Button_Background = backgroundBrush;
ComboBox_Disabled_Background = backgroundBrush;
ComboBox_Disabled_Editable_Background = backgroundBrush;
ComboBox_Disabled_Editable_Button_Background = backgroundBrush;
ComboBox_MouseOver_Background = backgroundBrush;
ComboBox_MouseOver_Editable_Background = backgroundBrush;
ComboBox_MouseOver_Editable_Button_Background = backgroundBrush;
ComboBox_Pressed_Background = backgroundBrush;
ComboBox_Pressed_Editable_Background = backgroundBrush;
ComboBox_Pressed_Editable_Button_Background = backgroundBrush;
ComboBox_Static_Background = backgroundBrush;
ComboBox_Static_Editable_Background = backgroundBrush;
ComboBox_Static_Editable_Button_Background = backgroundBrush;
// Handle CustomMessageBox-specific resources
this.CustomMessageBox_Static_Background = backgroundBrush;
CustomMessageBox_Static_Background = backgroundBrush;
// Handle MenuItem-specific resources
this.MenuItem_SubMenu_Background = backgroundBrush;
this.MenuItem_SubMenu_Border = Brushes.DarkGray;
MenuItem_SubMenu_Background = backgroundBrush;
MenuItem_SubMenu_Border = Brushes.DarkGray;
// Handle ProgressBar-specific resources
this.ProgressBar_Background = backgroundBrush;
ProgressBar_Background = backgroundBrush;
// Handle ScrollViewer-specific resources
this.ScrollViewer_ScrollBar_Background = backgroundBrush;
ScrollViewer_ScrollBar_Background = backgroundBrush;
// Handle TabItem-specific resources
this.TabItem_Selected_Background = backgroundBrush;
this.TabItem_Static_Background = backgroundBrush;
this.TabItem_Static_Border = Brushes.DarkGray;
TabItem_Selected_Background = backgroundBrush;
TabItem_Static_Background = backgroundBrush;
TabItem_Static_Border = Brushes.DarkGray;
// Handle TextBox-specific resources
this.TextBox_Static_Background = backgroundBrush;
TextBox_Static_Background = backgroundBrush;
}
}
}

View File

@@ -13,53 +13,53 @@ namespace MPF.UI.Themes
var darkModeBrush = new SolidColorBrush { Color = Color.FromArgb(0xff, 0x20, 0x20, 0x20) };
// Handle application-wide resources
this.ActiveBorderBrush = Brushes.Black;
this.ControlBrush = darkModeBrush;
this.ControlTextBrush = Brushes.White;
this.GrayTextBrush = Brushes.DarkGray;
this.WindowBrush = darkModeBrush;
this.WindowTextBrush = Brushes.White;
ActiveBorderBrush = Brushes.Black;
ControlBrush = darkModeBrush;
ControlTextBrush = Brushes.White;
GrayTextBrush = Brushes.DarkGray;
WindowBrush = darkModeBrush;
WindowTextBrush = Brushes.White;
// Handle Button-specific resources
this.Button_Disabled_Background = darkModeBrush;
this.Button_MouseOver_Background = darkModeBrush;
this.Button_Pressed_Background = darkModeBrush;
this.Button_Static_Background = darkModeBrush;
Button_Disabled_Background = darkModeBrush;
Button_MouseOver_Background = darkModeBrush;
Button_Pressed_Background = darkModeBrush;
Button_Static_Background = darkModeBrush;
// Handle ComboBox-specific resources
this.ComboBox_Disabled_Background = darkModeBrush;
this.ComboBox_Disabled_Editable_Background = darkModeBrush;
this.ComboBox_Disabled_Editable_Button_Background = darkModeBrush;
this.ComboBox_MouseOver_Background = darkModeBrush;
this.ComboBox_MouseOver_Editable_Background = darkModeBrush;
this.ComboBox_MouseOver_Editable_Button_Background = darkModeBrush;
this.ComboBox_Pressed_Background = darkModeBrush;
this.ComboBox_Pressed_Editable_Background = darkModeBrush;
this.ComboBox_Pressed_Editable_Button_Background = darkModeBrush;
this.ComboBox_Static_Background = darkModeBrush;
this.ComboBox_Static_Editable_Background = darkModeBrush;
this.ComboBox_Static_Editable_Button_Background = darkModeBrush;
ComboBox_Disabled_Background = darkModeBrush;
ComboBox_Disabled_Editable_Background = darkModeBrush;
ComboBox_Disabled_Editable_Button_Background = darkModeBrush;
ComboBox_MouseOver_Background = darkModeBrush;
ComboBox_MouseOver_Editable_Background = darkModeBrush;
ComboBox_MouseOver_Editable_Button_Background = darkModeBrush;
ComboBox_Pressed_Background = darkModeBrush;
ComboBox_Pressed_Editable_Background = darkModeBrush;
ComboBox_Pressed_Editable_Button_Background = darkModeBrush;
ComboBox_Static_Background = darkModeBrush;
ComboBox_Static_Editable_Background = darkModeBrush;
ComboBox_Static_Editable_Button_Background = darkModeBrush;
// Handle CustomMessageBox-specific resources
this.CustomMessageBox_Static_Background = darkModeBrush;
CustomMessageBox_Static_Background = darkModeBrush;
// Handle MenuItem-specific resources
this.MenuItem_SubMenu_Background = darkModeBrush;
this.MenuItem_SubMenu_Border = Brushes.DarkGray;
MenuItem_SubMenu_Background = darkModeBrush;
MenuItem_SubMenu_Border = Brushes.DarkGray;
// Handle ProgressBar-specific resources
this.ProgressBar_Background = darkModeBrush;
ProgressBar_Background = darkModeBrush;
// Handle ScrollViewer-specific resources
this.ScrollViewer_ScrollBar_Background = darkModeBrush;
ScrollViewer_ScrollBar_Background = darkModeBrush;
// Handle TabItem-specific resources
this.TabItem_Selected_Background = darkModeBrush;
this.TabItem_Static_Background = darkModeBrush;
this.TabItem_Static_Border = Brushes.DarkGray;
TabItem_Selected_Background = darkModeBrush;
TabItem_Static_Background = darkModeBrush;
TabItem_Static_Border = Brushes.DarkGray;
// Handle TextBox-specific resources
this.TextBox_Static_Background = darkModeBrush;
TextBox_Static_Background = darkModeBrush;
}
}
}

View File

@@ -11,77 +11,77 @@ namespace MPF.UI.Themes
public LightModeTheme()
{
// Handle application-wide resources
this.ActiveBorderBrush = null;
this.ControlBrush = null;
this.ControlTextBrush = null;
this.GrayTextBrush = null;
this.WindowBrush = null;
this.WindowTextBrush = null;
ActiveBorderBrush = null;
ControlBrush = null;
ControlTextBrush = null;
GrayTextBrush = null;
WindowBrush = null;
WindowTextBrush = null;
// Handle Button-specific resources
this.Button_Disabled_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xF4, 0xF4, 0xF4));
this.Button_MouseOver_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xBE, 0xE6, 0xFD));
this.Button_Pressed_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xC4, 0xE5, 0xF6));
this.Button_Static_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xDD, 0xDD, 0xDD));
Button_Disabled_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xF4, 0xF4, 0xF4));
Button_MouseOver_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xBE, 0xE6, 0xFD));
Button_Pressed_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xC4, 0xE5, 0xF6));
Button_Static_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xDD, 0xDD, 0xDD));
// Handle ComboBox-specific resources
this.ComboBox_Disabled_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xF0, 0xF0, 0xF0));
this.ComboBox_Disabled_Editable_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
this.ComboBox_Disabled_Editable_Button_Background = Brushes.Transparent;
this.ComboBox_MouseOver_Background = new LinearGradientBrush(
ComboBox_Disabled_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xF0, 0xF0, 0xF0));
ComboBox_Disabled_Editable_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
ComboBox_Disabled_Editable_Button_Background = Brushes.Transparent;
ComboBox_MouseOver_Background = new LinearGradientBrush(
Color.FromArgb(0xFF, 0xEC, 0xF4, 0xFC),
Color.FromArgb(0xFF, 0xDC, 0xEC, 0xFC),
new Point(0, 0),
new Point(0, 1));
this.ComboBox_MouseOver_Editable_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
this.ComboBox_MouseOver_Editable_Button_Background = new LinearGradientBrush(
ComboBox_MouseOver_Editable_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
ComboBox_MouseOver_Editable_Button_Background = new LinearGradientBrush(
Color.FromArgb(0xFF, 0xEB, 0xF4, 0xFC),
Color.FromArgb(0xFF, 0xDC, 0xEC, 0xFC),
new Point(0, 0),
new Point(0, 1));
this.ComboBox_Pressed_Background = new LinearGradientBrush(
ComboBox_Pressed_Background = new LinearGradientBrush(
Color.FromArgb(0xFF, 0xDA, 0xEC, 0xFC),
Color.FromArgb(0xFF, 0xC4, 0xE0, 0xFC),
new Point(0, 0),
new Point(0, 1));
this.ComboBox_Pressed_Editable_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
this.ComboBox_Pressed_Editable_Button_Background = new LinearGradientBrush(
ComboBox_Pressed_Editable_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
ComboBox_Pressed_Editable_Button_Background = new LinearGradientBrush(
Color.FromArgb(0xFF, 0xDA, 0xEB, 0xFC),
Color.FromArgb(0xFF, 0xC4, 0xE0, 0xFC),
new Point(0, 0),
new Point(0, 1));
this.ComboBox_Static_Background = new LinearGradientBrush(
ComboBox_Static_Background = new LinearGradientBrush(
Color.FromArgb(0xFF, 0xF0, 0xF0, 0xF0),
Color.FromArgb(0xFF, 0xE5, 0xE5, 0xE5),
new Point(0, 0),
new Point(0, 1));
this.ComboBox_Static_Editable_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
this.ComboBox_Static_Editable_Button_Background = Brushes.Transparent;
ComboBox_Static_Editable_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
ComboBox_Static_Editable_Button_Background = Brushes.Transparent;
// Handle CustomMessageBox-specific resources
this.CustomMessageBox_Static_Background = null;
CustomMessageBox_Static_Background = null;
// Handle MenuItem-specific resources
this.MenuItem_SubMenu_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xF0, 0xF0, 0xF0));
this.MenuItem_SubMenu_Border = Brushes.DarkGray;
MenuItem_SubMenu_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xF0, 0xF0, 0xF0));
MenuItem_SubMenu_Border = Brushes.DarkGray;
// Handle ProgressBar-specific resources
this.ProgressBar_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xE6, 0xE6, 0xE6));
ProgressBar_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xE6, 0xE6, 0xE6));
// Handle ScrollViewer-specific resources
this.ScrollViewer_ScrollBar_Background = Brushes.LightGray;
ScrollViewer_ScrollBar_Background = Brushes.LightGray;
// Handle TabItem-specific resources
this.TabItem_Selected_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
this.TabItem_Static_Background = new LinearGradientBrush(
TabItem_Selected_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
TabItem_Static_Background = new LinearGradientBrush(
Color.FromArgb(0xFF, 0xF0, 0xF0, 0xF0),
Color.FromArgb(0xFF, 0xE5, 0xE5, 0xE5),
new Point(0, 0),
new Point(0, 1));
this.TabItem_Static_Border = Brushes.DarkGray;
TabItem_Static_Border = Brushes.DarkGray;
// Handle TextBox-specific resources
this.TextBox_Static_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
TextBox_Static_Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
}
}
}

View File

@@ -35,10 +35,10 @@ namespace MPF.UI.UserControls
#if NET35
private Button? _ClearButton => ItemHelper.FindChild<Button>(this, "ClearButton");
private RichTextBox? _Output => ItemHelper.FindChild<RichTextBox>(this, "Output");
private ScrollViewer? _OutputViewer => ItemHelper.FindChild<ScrollViewer>(this, "OutputViewer");
private Button? _SaveButton => ItemHelper.FindChild<Button>(this, "SaveButton");
private Button? ClearButton => ItemHelper.FindChild<Button>(this, "ClearButton");
private RichTextBox? Output => ItemHelper.FindChild<RichTextBox>(this, "Output");
private ScrollViewer? OutputViewer => ItemHelper.FindChild<ScrollViewer>(this, "OutputViewer");
private Button? SaveButton => ItemHelper.FindChild<Button>(this, "SaveButton");
#endif
@@ -60,24 +60,13 @@ namespace MPF.UI.UserControls
LogQueue = new ProcessingQueue<LogLine>(ProcessLogLine);
// Add handlers
#if NET35
_OutputViewer!.SizeChanged += OutputViewerSizeChanged;
_Output!.TextChanged += OnTextChanged;
_ClearButton!.Click += OnClearButton;
_SaveButton!.Click += OnSaveButton;
#else
OutputViewer.SizeChanged += OutputViewerSizeChanged;
Output.TextChanged += OnTextChanged;
ClearButton.Click += OnClearButton;
SaveButton.Click += OnSaveButton;
#endif
OutputViewer!.SizeChanged += OutputViewerSizeChanged;
Output!.TextChanged += OnTextChanged;
ClearButton!.Click += OnClearButton;
SaveButton!.Click += OnSaveButton;
// Update the internal state
#if NET35
_Output.Document = Document;
#else
Output.Document = Document;
#endif
}
#region Logging
@@ -107,8 +96,8 @@ namespace MPF.UI.UserControls
public LogLine(string text, LogLevel logLevel)
{
this.Text = text;
this.LogLevel = logLevel;
Text = text;
LogLevel = logLevel;
}
/// <summary>
@@ -117,7 +106,7 @@ namespace MPF.UI.UserControls
/// <returns>Brush representing the color</returns>
public Brush GetForegroundColor()
{
return this.LogLevel switch
return LogLevel switch
{
LogLevel.SECRET => Brushes.Blue,
LogLevel.ERROR => Brushes.Red,
@@ -132,7 +121,7 @@ namespace MPF.UI.UserControls
/// <returns>Run object based on internal values</returns>
public Run GenerateRun()
{
return new Run { Text = this.Text, Foreground = GetForegroundColor() };
return new Run { Text = Text, Foreground = GetForegroundColor() };
}
}
@@ -214,11 +203,7 @@ namespace MPF.UI.UserControls
/// <summary>
/// Scroll the current view to the bottom
/// </summary>
#if NET35
public void ScrollToBottom() => _OutputViewer!.ScrollToBottom();
#else
public void ScrollToBottom() => OutputViewer.ScrollToBottom();
#endif
public void ScrollToBottom() => OutputViewer!.ScrollToBottom();
#endregion

View File

@@ -1,5 +1,8 @@
using System;
using System.IO;
#if NET40
using System.Threading.Tasks;
#endif
using System.Windows;
using System.Windows.Controls;
using MPF.Frontend.ViewModels;
@@ -25,18 +28,18 @@ namespace MPF.UI.Windows
#region Settings
private ComboBox? _DumpingProgramComboBox => ItemHelper.FindChild<ComboBox>(this, "DumpingProgramComboBox");
private Button? _InputPathBrowseButton => ItemHelper.FindChild<Button>(this, "InputPathBrowseButton");
private TextBox? _InputPathTextBox => ItemHelper.FindChild<TextBox>(this, "InputPathTextBox");
private ComboBox? _MediaTypeComboBox => ItemHelper.FindChild<ComboBox>(this, "MediaTypeComboBox");
private ComboBox? _SystemTypeComboBox => ItemHelper.FindChild<ComboBox>(this, "SystemTypeComboBox");
private ComboBox? DumpingProgramComboBox => ItemHelper.FindChild<ComboBox>(this, "DumpingProgramComboBox");
private Button? InputPathBrowseButton => ItemHelper.FindChild<Button>(this, "InputPathBrowseButton");
private TextBox? InputPathTextBox => ItemHelper.FindChild<TextBox>(this, "InputPathTextBox");
private ComboBox? MediaTypeComboBox => ItemHelper.FindChild<ComboBox>(this, "MediaTypeComboBox");
private ComboBox? SystemTypeComboBox => ItemHelper.FindChild<ComboBox>(this, "SystemTypeComboBox");
#endregion
#region Controls
private System.Windows.Controls.Button? _CheckDumpButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "CheckDumpButton");
private System.Windows.Controls.Button? _CancelButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "CancelButton");
private System.Windows.Controls.Button? CheckDumpButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "CheckDumpButton");
private System.Windows.Controls.Button? CancelButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "CancelButton");
#endregion
@@ -80,38 +83,19 @@ namespace MPF.UI.Windows
public void AddEventHandlers()
{
// Main buttons
#if NET35
_CheckDumpButton!.Click += OnCheckDumpClick;
_CancelButton!.Click += OnCancelClick;
#else
CheckDumpButton.Click += OnCheckDumpClick;
CancelButton.Click += OnCancelClick;
#endif
CheckDumpButton!.Click += OnCheckDumpClick;
CancelButton!.Click += OnCancelClick;
// User Area Click
#if NET35
_InputPathBrowseButton!.Click += InputPathBrowseButtonClick;
#else
InputPathBrowseButton.Click += InputPathBrowseButtonClick;
#endif
InputPathBrowseButton!.Click += InputPathBrowseButtonClick;
// User Area SelectionChanged
#if NET35
_SystemTypeComboBox!.SelectionChanged += SystemTypeComboBoxSelectionChanged;
_MediaTypeComboBox!.SelectionChanged += MediaTypeComboBoxSelectionChanged;
_DumpingProgramComboBox!.SelectionChanged += DumpingProgramComboBoxSelectionChanged;
#else
SystemTypeComboBox.SelectionChanged += SystemTypeComboBoxSelectionChanged;
MediaTypeComboBox.SelectionChanged += MediaTypeComboBoxSelectionChanged;
DumpingProgramComboBox.SelectionChanged += DumpingProgramComboBoxSelectionChanged;
#endif
SystemTypeComboBox!.SelectionChanged += SystemTypeComboBoxSelectionChanged;
MediaTypeComboBox!.SelectionChanged += MediaTypeComboBoxSelectionChanged;
DumpingProgramComboBox!.SelectionChanged += DumpingProgramComboBoxSelectionChanged;
// User Area TextChanged
#if NET35
_InputPathTextBox!.TextChanged += InputPathTextBoxTextChanged;
#else
InputPathTextBox.TextChanged += InputPathTextBoxTextChanged;
#endif
InputPathTextBox!.TextChanged += InputPathTextBoxTextChanged;
}
/// <summary>
@@ -192,7 +176,7 @@ namespace MPF.UI.Windows
WindowStartupLocation = WindowStartupLocation.CenterOwner,
};
discInformationWindow.Closed += delegate { this.Activate(); };
discInformationWindow.Closed += delegate { Activate(); };
bool? result = discInformationWindow.ShowDialog();
// Copy back the submission info changes, if necessary
@@ -209,17 +193,9 @@ namespace MPF.UI.Windows
/// <summary>
/// Handler for CheckDumpButton Click event
/// </summary>
#if NET40
private void OnCheckDumpClick(object sender, EventArgs e)
{
var checkTask = CheckDumpViewModel.CheckDump(ShowDiscInformationWindow);
checkTask.Wait();
string? errorMessage = checkTask.Result;
#else
private async void OnCheckDumpClick(object sender, EventArgs e)
{
string? errorMessage = await CheckDumpViewModel.CheckDump(ShowDiscInformationWindow);
#endif
if (string.IsNullOrEmpty(errorMessage))
{
bool? checkAgain = DisplayUserMessage("Check Complete", "The dump has been processed successfully! Would you like to check another dump?", 2, false);

View File

@@ -24,34 +24,34 @@ namespace MPF.UI.Windows
#region Settings
private Button? _InputPathBrowseButton => ItemHelper.FindChild<Button>(this, "InputPathBrowseButton");
private TextBox? _InputPathTextBox => ItemHelper.FindChild<TextBox>(this, "InputPathTextBox");
private Button? InputPathBrowseButton => ItemHelper.FindChild<Button>(this, "InputPathBrowseButton");
private TextBox? InputPathTextBox => ItemHelper.FindChild<TextBox>(this, "InputPathTextBox");
private Button? _LogPathBrowseButton => ItemHelper.FindChild<Button>(this, "LogPathBrowseButton");
private TextBox? _LogPathTextBox => ItemHelper.FindChild<TextBox>(this, "LogPathTextBox");
private Button? _KeyPathBrowseButton => ItemHelper.FindChild<Button>(this, "KeyPathBrowseButton");
private TextBox? _KeyPathTextBox => ItemHelper.FindChild<TextBox>(this, "KeyPathTextBox");
private TextBox? _KeyTextBox => ItemHelper.FindChild<TextBox>(this, "KeyTextBox");
private TextBox? _DiscIDTextBox => ItemHelper.FindChild<TextBox>(this, "DiscIDTextBox");
private Button? _PICPathBrowseButton => ItemHelper.FindChild<Button>(this, "PICPathBrowseButton");
private TextBox? _PICPathTextBox => ItemHelper.FindChild<TextBox>(this, "PICPathTextBox");
private TextBox? _PICTextBox => ItemHelper.FindChild<TextBox>(this, "PICTextBox");
private TextBox? _LayerbreakTextBox => ItemHelper.FindChild<TextBox>(this, "LayerbreakTextBox");
private Button? LogPathBrowseButton => ItemHelper.FindChild<Button>(this, "LogPathBrowseButton");
private TextBox? LogPathTextBox => ItemHelper.FindChild<TextBox>(this, "LogPathTextBox");
private Button? KeyPathBrowseButton => ItemHelper.FindChild<Button>(this, "KeyPathBrowseButton");
private TextBox? KeyPathTextBox => ItemHelper.FindChild<TextBox>(this, "KeyPathTextBox");
private TextBox? KeyTextBox => ItemHelper.FindChild<TextBox>(this, "KeyTextBox");
private TextBox? DiscIDTextBox => ItemHelper.FindChild<TextBox>(this, "DiscIDTextBox");
private Button? PICPathBrowseButton => ItemHelper.FindChild<Button>(this, "PICPathBrowseButton");
private TextBox? PICPathTextBox => ItemHelper.FindChild<TextBox>(this, "PICPathTextBox");
private TextBox? PICTextBox => ItemHelper.FindChild<TextBox>(this, "PICTextBox");
private TextBox? LayerbreakTextBox => ItemHelper.FindChild<TextBox>(this, "LayerbreakTextBox");
#endregion
#region Controls
private System.Windows.Controls.Button? _CreateIRDButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "CreateIRDButton");
private System.Windows.Controls.Button? _CancelButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "CancelButton");
private System.Windows.Controls.Button? CreateIRDButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "CreateIRDButton");
private System.Windows.Controls.Button? CancelButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "CancelButton");
#endregion
#region Expanders
private Expander? _KeyExpander => ItemHelper.FindChild<Expander>(this, "KeyExpander");
private Expander? _DiscIDExpander => ItemHelper.FindChild<Expander>(this, "DiscIDExpander");
private Expander? _PICExpander => ItemHelper.FindChild<Expander>(this, "PICExpander");
private Expander? KeyExpander => ItemHelper.FindChild<Expander>(this, "KeyExpander");
private Expander? DiscIDExpander => ItemHelper.FindChild<Expander>(this, "DiscIDExpander");
private Expander? PICExpander => ItemHelper.FindChild<Expander>(this, "PICExpander");
#endregion
@@ -95,47 +95,24 @@ namespace MPF.UI.Windows
public void AddEventHandlers()
{
// Main buttons
#if NET35
_CreateIRDButton!.Click += OnCreateIRDClick;
_CancelButton!.Click += OnCancelClick;
#else
CreateIRDButton.Click += OnCreateIRDClick;
CancelButton.Click += OnCancelClick;
#endif
CreateIRDButton!.Click += OnCreateIRDClick;
CancelButton!.Click += OnCancelClick;
// User Area Click
#if NET35
_InputPathBrowseButton!.Click += InputPathBrowseButtonClick;
_LogPathBrowseButton!.Click += LogPathBrowseButtonClick;
_KeyPathBrowseButton!.Click += KeyPathBrowseButtonClick;
_PICPathBrowseButton!.Click += PICPathBrowseButtonClick;
#else
InputPathBrowseButton.Click += InputPathBrowseButtonClick;
LogPathBrowseButton.Click += LogPathBrowseButtonClick;
KeyPathBrowseButton.Click += KeyPathBrowseButtonClick;
PICPathBrowseButton.Click += PICPathBrowseButtonClick;
#endif
InputPathBrowseButton!.Click += InputPathBrowseButtonClick;
LogPathBrowseButton!.Click += LogPathBrowseButtonClick;
KeyPathBrowseButton!.Click += KeyPathBrowseButtonClick;
PICPathBrowseButton!.Click += PICPathBrowseButtonClick;
// User Area TextChanged
#if NET35
_InputPathTextBox!.TextChanged += InputPathTextBoxTextChanged;
_LogPathTextBox!.TextChanged += LogPathTextBoxTextChanged;
_KeyPathTextBox!.TextChanged += KeyPathTextBoxTextChanged;
_KeyTextBox!.TextChanged += KeyTextBoxTextChanged;
_DiscIDTextBox!.TextChanged += DiscIDTextBoxTextChanged;
_PICPathTextBox!.TextChanged += PICPathTextBoxTextChanged;
_PICTextBox!.TextChanged += PICTextBoxTextChanged;
_LayerbreakTextBox!.TextChanged += LayerbreakTextBoxTextChanged;
#else
InputPathTextBox.TextChanged += InputPathTextBoxTextChanged;
LogPathTextBox.TextChanged += LogPathTextBoxTextChanged;
KeyPathTextBox.TextChanged += KeyPathTextBoxTextChanged;
KeyTextBox.TextChanged += KeyTextBoxTextChanged;
DiscIDTextBox.TextChanged += DiscIDTextBoxTextChanged;
PICPathTextBox.TextChanged += PICPathTextBoxTextChanged;
PICTextBox.TextChanged += PICTextBoxTextChanged;
LayerbreakTextBox.TextChanged += LayerbreakTextBoxTextChanged;
#endif
InputPathTextBox!.TextChanged += InputPathTextBoxTextChanged;
LogPathTextBox!.TextChanged += LogPathTextBoxTextChanged;
KeyPathTextBox!.TextChanged += KeyPathTextBoxTextChanged;
KeyTextBox!.TextChanged += KeyTextBoxTextChanged;
DiscIDTextBox!.TextChanged += DiscIDTextBoxTextChanged;
PICPathTextBox!.TextChanged += PICPathTextBoxTextChanged;
PICTextBox!.TextChanged += PICTextBoxTextChanged;
LayerbreakTextBox!.TextChanged += LayerbreakTextBoxTextChanged;
}
/// <summary>
@@ -330,15 +307,10 @@ namespace MPF.UI.Windows
/// </summary>
private void OnCreateIRDClick(object sender, EventArgs e)
{
#if NET35
if (_KeyExpander != null) _KeyExpander.IsExpanded = false;
if (_DiscIDExpander != null) _DiscIDExpander.IsExpanded = false;
if (_PICExpander != null) _PICExpander.IsExpanded = false;
#else
KeyExpander.IsExpanded = false;
DiscIDExpander.IsExpanded = false;
PICExpander.IsExpanded = false;
#endif
if (KeyExpander != null) KeyExpander.IsExpanded = false;
if (DiscIDExpander != null) DiscIDExpander.IsExpanded = false;
if (PICExpander != null) PICExpander.IsExpanded = false;
string tempStatus = CreateIRDViewModel.CreateIRDStatus;
bool[] enabledFields = CreateIRDViewModel.DisableUIFields();
CreateIRDViewModel.CreateIRDStatus = "Creating IRD... Please Wait";

View File

@@ -1,5 +1,4 @@
using System.Linq;
using System.Windows;
using System.Windows;
using System.Windows.Controls;
using MPF.Frontend;
using MPF.Frontend.ViewModels;
@@ -19,104 +18,104 @@ namespace MPF.UI.Windows
#region Common Info
private Grid? _LanguageSelectionGrid => ItemHelper.FindChild<Grid>(this, "LanguageSelectionGrid");
private Grid? LanguageSelectionGrid => ItemHelper.FindChild<Grid>(this, "LanguageSelectionGrid");
#endregion
#region Additional Info
private UserInput? _CommentsTextBox => ItemHelper.FindChild<UserInput>(this, "CommentsTextBox");
private UserInput? _DiscIDTextBox => ItemHelper.FindChild<UserInput>(this, "DiscIDTextBox");
private UserInput? _DiscKeyTextBox => ItemHelper.FindChild<UserInput>(this, "DiscKeyTextBox");
private UserInput? CommentsTextBox => ItemHelper.FindChild<UserInput>(this, "CommentsTextBox");
private UserInput? DiscIDTextBox => ItemHelper.FindChild<UserInput>(this, "DiscIDTextBox");
private UserInput? DiscKeyTextBox => ItemHelper.FindChild<UserInput>(this, "DiscKeyTextBox");
#endregion
#region Contents
private UserInput? _ExtrasTextBox => ItemHelper.FindChild<UserInput>(this, "ExtrasTextBox");
private UserInput? _GameFootageTextBox => ItemHelper.FindChild<UserInput>(this, "GameFootageTextBox");
private UserInput? _GamesTextBox => ItemHelper.FindChild<UserInput>(this, "GamesTextBox");
private UserInput? _GeneralContent => ItemHelper.FindChild<UserInput>(this, "GeneralContent");
private UserInput? _NetYarozeGamesTextBox => ItemHelper.FindChild<UserInput>(this, "NetYarozeGamesTextBox");
private UserInput? _PatchesTextBox => ItemHelper.FindChild<UserInput>(this, "PatchesTextBox");
private UserInput? _PlayableDemosTextBox => ItemHelper.FindChild<UserInput>(this, "PlayableDemosTextBox");
private UserInput? _RollingDemosTextBox => ItemHelper.FindChild<UserInput>(this, "RollingDemosTextBox");
private UserInput? _SavegamesTextBox => ItemHelper.FindChild<UserInput>(this, "SavegamesTextBox");
private UserInput? _TechDemosTextBox => ItemHelper.FindChild<UserInput>(this, "TechDemosTextBox");
private UserInput? _VideosTextBox => ItemHelper.FindChild<UserInput>(this, "VideosTextBox");
private UserInput? ExtrasTextBox => ItemHelper.FindChild<UserInput>(this, "ExtrasTextBox");
private UserInput? GameFootageTextBox => ItemHelper.FindChild<UserInput>(this, "GameFootageTextBox");
private UserInput? GamesTextBox => ItemHelper.FindChild<UserInput>(this, "GamesTextBox");
private UserInput? GeneralContent => ItemHelper.FindChild<UserInput>(this, "GeneralContent");
private UserInput? NetYarozeGamesTextBox => ItemHelper.FindChild<UserInput>(this, "NetYarozeGamesTextBox");
private UserInput? PatchesTextBox => ItemHelper.FindChild<UserInput>(this, "PatchesTextBox");
private UserInput? PlayableDemosTextBox => ItemHelper.FindChild<UserInput>(this, "PlayableDemosTextBox");
private UserInput? RollingDemosTextBox => ItemHelper.FindChild<UserInput>(this, "RollingDemosTextBox");
private UserInput? SavegamesTextBox => ItemHelper.FindChild<UserInput>(this, "SavegamesTextBox");
private UserInput? TechDemosTextBox => ItemHelper.FindChild<UserInput>(this, "TechDemosTextBox");
private UserInput? VideosTextBox => ItemHelper.FindChild<UserInput>(this, "VideosTextBox");
#endregion
#region Ringcodes
private GroupBox? _L0Info => ItemHelper.FindChild<GroupBox>(this, "L0Info");
private UserInput? _L0MasteringRing => ItemHelper.FindChild<UserInput>(this, "L0MasteringRing");
private UserInput? _L0MasteringSID => ItemHelper.FindChild<UserInput>(this, "L0MasteringSID");
private UserInput? _L0Toolstamp => ItemHelper.FindChild<UserInput>(this, "L0Toolstamp");
private UserInput? _L0MouldSID => ItemHelper.FindChild<UserInput>(this, "L0MouldSID");
private UserInput? _L0AdditionalMould => ItemHelper.FindChild<UserInput>(this, "L0AdditionalMould");
private GroupBox? _L1Info => ItemHelper.FindChild<GroupBox>(this, "L1Info");
private UserInput? _L1MasteringRing => ItemHelper.FindChild<UserInput>(this, "L1MasteringRing");
private UserInput? _L1MasteringSID => ItemHelper.FindChild<UserInput>(this, "L1MasteringSID");
private UserInput? _L1Toolstamp => ItemHelper.FindChild<UserInput>(this, "L1Toolstamp");
private UserInput? _L1MouldSID => ItemHelper.FindChild<UserInput>(this, "L1MouldSID");
private UserInput? _L1AdditionalMould => ItemHelper.FindChild<UserInput>(this, "L1AdditionalMould");
private GroupBox? _L2Info => ItemHelper.FindChild<GroupBox>(this, "L2Info");
private UserInput? _L2MasteringRing => ItemHelper.FindChild<UserInput>(this, "L2MasteringRing");
private UserInput? _L2MasteringSID => ItemHelper.FindChild<UserInput>(this, "L2MasteringSID");
private UserInput? _L2Toolstamp => ItemHelper.FindChild<UserInput>(this, "L2Toolstamp");
private GroupBox? _L3Info => ItemHelper.FindChild<GroupBox>(this, "L3Info");
private UserInput? _L3MasteringRing => ItemHelper.FindChild<UserInput>(this, "L3MasteringRing");
private UserInput? _L3MasteringSID => ItemHelper.FindChild<UserInput>(this, "L3MasteringSID");
private UserInput? _L3Toolstamp => ItemHelper.FindChild<UserInput>(this, "L3Toolstamp");
private GroupBox? L0Info => ItemHelper.FindChild<GroupBox>(this, "L0Info");
private UserInput? L0MasteringRing => ItemHelper.FindChild<UserInput>(this, "L0MasteringRing");
private UserInput? L0MasteringSID => ItemHelper.FindChild<UserInput>(this, "L0MasteringSID");
private UserInput? L0Toolstamp => ItemHelper.FindChild<UserInput>(this, "L0Toolstamp");
private UserInput? L0MouldSID => ItemHelper.FindChild<UserInput>(this, "L0MouldSID");
private UserInput? L0AdditionalMould => ItemHelper.FindChild<UserInput>(this, "L0AdditionalMould");
private GroupBox? L1Info => ItemHelper.FindChild<GroupBox>(this, "L1Info");
private UserInput? L1MasteringRing => ItemHelper.FindChild<UserInput>(this, "L1MasteringRing");
private UserInput? L1MasteringSID => ItemHelper.FindChild<UserInput>(this, "L1MasteringSID");
private UserInput? L1Toolstamp => ItemHelper.FindChild<UserInput>(this, "L1Toolstamp");
private UserInput? L1MouldSID => ItemHelper.FindChild<UserInput>(this, "L1MouldSID");
private UserInput? L1AdditionalMould => ItemHelper.FindChild<UserInput>(this, "L1AdditionalMould");
private GroupBox? L2Info => ItemHelper.FindChild<GroupBox>(this, "L2Info");
private UserInput? L2MasteringRing => ItemHelper.FindChild<UserInput>(this, "L2MasteringRing");
private UserInput? L2MasteringSID => ItemHelper.FindChild<UserInput>(this, "L2MasteringSID");
private UserInput? L2Toolstamp => ItemHelper.FindChild<UserInput>(this, "L2Toolstamp");
private GroupBox? L3Info => ItemHelper.FindChild<GroupBox>(this, "L3Info");
private UserInput? L3MasteringRing => ItemHelper.FindChild<UserInput>(this, "L3MasteringRing");
private UserInput? L3MasteringSID => ItemHelper.FindChild<UserInput>(this, "L3MasteringSID");
private UserInput? L3Toolstamp => ItemHelper.FindChild<UserInput>(this, "L3Toolstamp");
#endregion
#region Read-Only Info
private UserInput? _FullyMatchedID => ItemHelper.FindChild<UserInput>(this, "FullyMatchedID");
private UserInput? _PartiallyMatchedIDs => ItemHelper.FindChild<UserInput>(this, "PartiallyMatchedIDs");
private UserInput? _HashData => ItemHelper.FindChild<UserInput>(this, "HashData");
private UserInput? _HashDataSize => ItemHelper.FindChild<UserInput>(this, "HashDataSize");
private UserInput? _HashDataCRC => ItemHelper.FindChild<UserInput>(this, "HashDataCRC");
private UserInput? _HashDataMD5 => ItemHelper.FindChild<UserInput>(this, "HashDataMD5");
private UserInput? _HashDataSHA1 => ItemHelper.FindChild<UserInput>(this, "HashDataSHA1");
private UserInput? _HashDataLayerbreak1 => ItemHelper.FindChild<UserInput>(this, "HashDataLayerbreak1");
private UserInput? _HashDataLayerbreak2 => ItemHelper.FindChild<UserInput>(this, "HashDataLayerbreak2");
private UserInput? _HashDataLayerbreak3 => ItemHelper.FindChild<UserInput>(this, "HashDataLayerbreak3");
private UserInput? _AntiModchip => ItemHelper.FindChild<UserInput>(this, "AntiModchip");
private UserInput? _DiscOffset => ItemHelper.FindChild<UserInput>(this, "DiscOffset");
private UserInput? _DMIHash => ItemHelper.FindChild<UserInput>(this, "DMIHash");
private UserInput? _EDC => ItemHelper.FindChild<UserInput>(this, "EDC");
private UserInput? _ErrorsCount => ItemHelper.FindChild<UserInput>(this, "ErrorsCount");
private UserInput? _EXEDateBuildDate => ItemHelper.FindChild<UserInput>(this, "EXEDateBuildDate");
private UserInput? _Filename => ItemHelper.FindChild<UserInput>(this, "Filename");
private UserInput? _Header => ItemHelper.FindChild<UserInput>(this, "Header");
private UserInput? _InternalName => ItemHelper.FindChild<UserInput>(this, "InternalName");
private UserInput? _InternalSerialName => ItemHelper.FindChild<UserInput>(this, "InternalSerialName");
private UserInput? _Multisession => ItemHelper.FindChild<UserInput>(this, "Multisession");
private UserInput? _LibCrypt => ItemHelper.FindChild<UserInput>(this, "LibCrypt");
private UserInput? _LibCryptData => ItemHelper.FindChild<UserInput>(this, "LibCryptData");
private UserInput? _PFIHash => ItemHelper.FindChild<UserInput>(this, "PFIHash");
private UserInput? _PIC => ItemHelper.FindChild<UserInput>(this, "PIC");
private UserInput? _PVD => ItemHelper.FindChild<UserInput>(this, "PVD");
private UserInput? _RingNonZeroDataStart => ItemHelper.FindChild<UserInput>(this, "RingNonZeroDataStart");
private UserInput? _SecuROMData => ItemHelper.FindChild<UserInput>(this, "SecuROMData");
private UserInput? _SSHash => ItemHelper.FindChild<UserInput>(this, "SSHash");
private UserInput? _SecuritySectorRanges => ItemHelper.FindChild<UserInput>(this, "SecuritySectorRanges");
private UserInput? _SSVersion => ItemHelper.FindChild<UserInput>(this, "SSVersion");
private UserInput? _UniversalHash => ItemHelper.FindChild<UserInput>(this, "UniversalHash");
private UserInput? _VolumeLabel => ItemHelper.FindChild<UserInput>(this, "VolumeLabel");
private UserInput? _XeMID => ItemHelper.FindChild<UserInput>(this, "XeMID");
private UserInput? _XMID => ItemHelper.FindChild<UserInput>(this, "XMID");
private UserInput? FullyMatchedID => ItemHelper.FindChild<UserInput>(this, "FullyMatchedID");
private UserInput? PartiallyMatchedIDs => ItemHelper.FindChild<UserInput>(this, "PartiallyMatchedIDs");
private UserInput? HashData => ItemHelper.FindChild<UserInput>(this, "HashData");
private UserInput? HashDataSize => ItemHelper.FindChild<UserInput>(this, "HashDataSize");
private UserInput? HashDataCRC => ItemHelper.FindChild<UserInput>(this, "HashDataCRC");
private UserInput? HashDataMD5 => ItemHelper.FindChild<UserInput>(this, "HashDataMD5");
private UserInput? HashDataSHA1 => ItemHelper.FindChild<UserInput>(this, "HashDataSHA1");
private UserInput? HashDataLayerbreak1 => ItemHelper.FindChild<UserInput>(this, "HashDataLayerbreak1");
private UserInput? HashDataLayerbreak2 => ItemHelper.FindChild<UserInput>(this, "HashDataLayerbreak2");
private UserInput? HashDataLayerbreak3 => ItemHelper.FindChild<UserInput>(this, "HashDataLayerbreak3");
private UserInput? AntiModchip => ItemHelper.FindChild<UserInput>(this, "AntiModchip");
private UserInput? DiscOffset => ItemHelper.FindChild<UserInput>(this, "DiscOffset");
private UserInput? DMIHash => ItemHelper.FindChild<UserInput>(this, "DMIHash");
private UserInput? EDC => ItemHelper.FindChild<UserInput>(this, "EDC");
private UserInput? ErrorsCount => ItemHelper.FindChild<UserInput>(this, "ErrorsCount");
private UserInput? EXEDateBuildDate => ItemHelper.FindChild<UserInput>(this, "EXEDateBuildDate");
private UserInput? Filename => ItemHelper.FindChild<UserInput>(this, "Filename");
private UserInput? Header => ItemHelper.FindChild<UserInput>(this, "Header");
private UserInput? InternalName => ItemHelper.FindChild<UserInput>(this, "InternalName");
private UserInput? InternalSerialName => ItemHelper.FindChild<UserInput>(this, "InternalSerialName");
private UserInput? Multisession => ItemHelper.FindChild<UserInput>(this, "Multisession");
private UserInput? LibCrypt => ItemHelper.FindChild<UserInput>(this, "LibCrypt");
private UserInput? LibCryptData => ItemHelper.FindChild<UserInput>(this, "LibCryptData");
private UserInput? PFIHash => ItemHelper.FindChild<UserInput>(this, "PFIHash");
private UserInput? PIC => ItemHelper.FindChild<UserInput>(this, "PIC");
private UserInput? PVD => ItemHelper.FindChild<UserInput>(this, "PVD");
private UserInput? RingNonZeroDataStart => ItemHelper.FindChild<UserInput>(this, "RingNonZeroDataStart");
private UserInput? SecuROMData => ItemHelper.FindChild<UserInput>(this, "SecuROMData");
private UserInput? SSHash => ItemHelper.FindChild<UserInput>(this, "SSHash");
private UserInput? SecuritySectorRanges => ItemHelper.FindChild<UserInput>(this, "SecuritySectorRanges");
private UserInput? SSVersion => ItemHelper.FindChild<UserInput>(this, "SSVersion");
private UserInput? UniversalHash => ItemHelper.FindChild<UserInput>(this, "UniversalHash");
private UserInput? VolumeLabel => ItemHelper.FindChild<UserInput>(this, "VolumeLabel");
private UserInput? XeMID => ItemHelper.FindChild<UserInput>(this, "XeMID");
private UserInput? XMID => ItemHelper.FindChild<UserInput>(this, "XMID");
#endregion
#region Accept / Cancel
private Button? _AcceptButton => ItemHelper.FindChild<Button>(this, "AcceptButton");
private Button? _CancelButton => ItemHelper.FindChild<Button>(this, "CancelButton");
private Button? _RingCodeGuideButton => ItemHelper.FindChild<Button>(this, "RingCodeGuideButton");
private Button? AcceptButton => ItemHelper.FindChild<Button>(this, "AcceptButton");
private Button? CancelButton => ItemHelper.FindChild<Button>(this, "CancelButton");
private Button? RingCodeGuideButton => ItemHelper.FindChild<Button>(this, "RingCodeGuideButton");
#endregion
@@ -156,15 +155,9 @@ namespace MPF.UI.Windows
}
// Add handlers
#if NET35
_AcceptButton!.Click += OnAcceptClick;
_CancelButton!.Click += OnCancelClick;
_RingCodeGuideButton!.Click += OnRingCodeGuideClick;
#else
AcceptButton.Click += OnAcceptClick;
CancelButton.Click += OnCancelClick;
RingCodeGuideButton.Click += OnRingCodeGuideClick;
#endif
AcceptButton!.Click += OnAcceptClick;
CancelButton!.Click += OnCancelClick;
RingCodeGuideButton!.Click += OnRingCodeGuideClick;
// Update UI with new values
ManipulateFields(options, submissionInfo);
@@ -198,90 +191,44 @@ namespace MPF.UI.Windows
private void EnableTabsInInputFields()
{
// Additional Information
#if NET35
_CommentsTextBox!.Tab = true;
#else
CommentsTextBox.Tab = true;
#endif
CommentsTextBox!.Tab = true;
// Contents
#if NET35
_GeneralContent!.Tab = true;
_GamesTextBox!.Tab = true;
_NetYarozeGamesTextBox!.Tab = true;
_PlayableDemosTextBox!.Tab = true;
_RollingDemosTextBox!.Tab = true;
_TechDemosTextBox!.Tab = true;
_GameFootageTextBox!.Tab = true;
_VideosTextBox!.Tab = true;
_PatchesTextBox!.Tab = true;
_SavegamesTextBox!.Tab = true;
_ExtrasTextBox!.Tab = true;
#else
GeneralContent.Tab = true;
GamesTextBox.Tab = true;
NetYarozeGamesTextBox.Tab = true;
PlayableDemosTextBox.Tab = true;
RollingDemosTextBox.Tab = true;
TechDemosTextBox.Tab = true;
GameFootageTextBox.Tab = true;
VideosTextBox.Tab = true;
PatchesTextBox.Tab = true;
SavegamesTextBox.Tab = true;
ExtrasTextBox.Tab = true;
#endif
GeneralContent!.Tab = true;
GamesTextBox!.Tab = true;
NetYarozeGamesTextBox!.Tab = true;
PlayableDemosTextBox!.Tab = true;
RollingDemosTextBox!.Tab = true;
TechDemosTextBox!.Tab = true;
GameFootageTextBox!.Tab = true;
VideosTextBox!.Tab = true;
PatchesTextBox!.Tab = true;
SavegamesTextBox!.Tab = true;
ExtrasTextBox!.Tab = true;
// L0
#if NET35
_L0MasteringRing!.Tab = true;
_L0MasteringSID!.Tab = true;
_L0Toolstamp!.Tab = true;
_L0MouldSID!.Tab = true;
_L0AdditionalMould!.Tab = true;
#else
L0MasteringRing.Tab = true;
L0MasteringSID.Tab = true;
L0Toolstamp.Tab = true;
L0MouldSID.Tab = true;
L0AdditionalMould.Tab = true;
#endif
L0MasteringRing!.Tab = true;
L0MasteringSID!.Tab = true;
L0Toolstamp!.Tab = true;
L0MouldSID!.Tab = true;
L0AdditionalMould!.Tab = true;
// L1
#if NET35
_L1MasteringRing!.Tab = true;
_L1MasteringSID!.Tab = true;
_L1Toolstamp!.Tab = true;
_L1MouldSID!.Tab = true;
_L1AdditionalMould!.Tab = true;
#else
L1MasteringRing.Tab = true;
L1MasteringSID.Tab = true;
L1Toolstamp.Tab = true;
L1MouldSID.Tab = true;
L1AdditionalMould.Tab = true;
#endif
L1MasteringRing!.Tab = true;
L1MasteringSID!.Tab = true;
L1Toolstamp!.Tab = true;
L1MouldSID!.Tab = true;
L1AdditionalMould!.Tab = true;
// L2
#if NET35
_L2MasteringRing!.Tab = true;
_L2MasteringSID!.Tab = true;
_L2Toolstamp!.Tab = true;
#else
L2MasteringRing.Tab = true;
L2MasteringSID.Tab = true;
L2Toolstamp.Tab = true;
#endif
L2MasteringRing!.Tab = true;
L2MasteringSID!.Tab = true;
L2Toolstamp!.Tab = true;
// L3
#if NET35
_L3MasteringRing!.Tab = true;
_L3MasteringSID!.Tab = true;
_L3Toolstamp!.Tab = true;
#else
L3MasteringRing.Tab = true;
L3MasteringSID.Tab = true;
L3Toolstamp.Tab = true;
#endif
L3MasteringRing!.Tab = true;
L3MasteringSID!.Tab = true;
L3Toolstamp!.Tab = true;
}
/// <summary>
@@ -295,89 +242,15 @@ namespace MPF.UI.Windows
if (submissionInfo == null)
return;
#if NET35
if (submissionInfo.FullyMatchedID == null)
_FullyMatchedID!.Visibility = Visibility.Collapsed;
FullyMatchedID!.Visibility = Visibility.Collapsed;
if (submissionInfo.PartiallyMatchedIDs == null)
_PartiallyMatchedIDs!.Visibility = Visibility.Collapsed;
PartiallyMatchedIDs!.Visibility = Visibility.Collapsed;
else
_PartiallyMatchedIDs!.Text = string.Join(", ", submissionInfo.PartiallyMatchedIDs.Select(i => i.ToString()).ToArray());
if (string.IsNullOrEmpty(submissionInfo.TracksAndWriteOffsets?.ClrMameProData))
_HashData!.Visibility = Visibility.Collapsed;
if (submissionInfo.SizeAndChecksums?.Size == null || submissionInfo.SizeAndChecksums.Size == 0)
_HashDataSize!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.SizeAndChecksums?.CRC32))
_HashDataCRC!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.SizeAndChecksums?.MD5))
_HashDataMD5!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.SizeAndChecksums?.SHA1))
_HashDataSHA1!.Visibility = Visibility.Collapsed;
if (submissionInfo.SizeAndChecksums?.Layerbreak == null || submissionInfo.SizeAndChecksums.Layerbreak == 0)
_HashDataLayerbreak1!.Visibility = Visibility.Collapsed;
if (submissionInfo.SizeAndChecksums?.Layerbreak2 == null || submissionInfo.SizeAndChecksums.Layerbreak2 == 0)
_HashDataLayerbreak2!.Visibility = Visibility.Collapsed;
if (submissionInfo.SizeAndChecksums?.Layerbreak3 == null || submissionInfo.SizeAndChecksums.Layerbreak3 == 0)
_HashDataLayerbreak3!.Visibility = Visibility.Collapsed;
if (submissionInfo.CopyProtection?.AntiModchip == null)
_AntiModchip!.Visibility = Visibility.Collapsed;
if (submissionInfo.TracksAndWriteOffsets?.OtherWriteOffsets == null)
_DiscOffset!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.Keys?.Contains(SiteCode.DMIHash) != true)
_DMIHash!.Visibility = Visibility.Collapsed;
if (submissionInfo.EDC?.EDC == null)
_EDC!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.CommonDiscInfo?.ErrorsCount))
_ErrorsCount!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.CommonDiscInfo?.EXEDateBuildDate))
_EXEDateBuildDate!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.Filename) != true)
_Filename!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.Extras?.Header))
_Header!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.InternalName) != true)
_InternalName!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.InternalSerialName) != true)
_InternalSerialName!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.Multisession) != true)
_Multisession!.Visibility = Visibility.Collapsed;
if (submissionInfo.CopyProtection?.LibCrypt == null)
_LibCrypt!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.CopyProtection?.LibCryptData))
_LibCryptData!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.PFIHash) != true)
_PFIHash!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.Extras?.PIC))
_PIC!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.Extras?.PVD))
_PVD!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.RingNonZeroDataStart) != true)
_RingNonZeroDataStart!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.CopyProtection?.SecuROMData))
_SecuROMData!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.SSHash) != true)
_SSHash!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.Extras?.SecuritySectorRanges))
_SecuritySectorRanges!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.SSVersion) != true)
_SSVersion!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.UniversalHash) != true)
_UniversalHash!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.VolumeLabel) != true)
_VolumeLabel!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.XeMID) != true)
_XeMID!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.XMID) != true)
_XMID!.Visibility = Visibility.Collapsed;
#else
if (submissionInfo.FullyMatchedID == null)
FullyMatchedID.Visibility = Visibility.Collapsed;
if (submissionInfo.PartiallyMatchedIDs == null)
PartiallyMatchedIDs.Visibility = Visibility.Collapsed;
else
PartiallyMatchedIDs.Text = string.Join(", ", submissionInfo.PartiallyMatchedIDs.Select(i => i.ToString()).ToArray());
PartiallyMatchedIDs!.Text = string.Join(", ", [.. submissionInfo.PartiallyMatchedIDs.ConvertAll(i => i.ToString())]);
if (string.IsNullOrEmpty(submissionInfo.TracksAndWriteOffsets?.ClrMameProData))
HashData!.Visibility = Visibility.Collapsed;
if (submissionInfo.SizeAndChecksums?.Size == null)
if (submissionInfo.SizeAndChecksums?.Size == null || submissionInfo.SizeAndChecksums.Size == 0)
HashDataSize!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.SizeAndChecksums?.CRC32))
HashDataCRC!.Visibility = Visibility.Collapsed;
@@ -392,56 +265,55 @@ namespace MPF.UI.Windows
if (submissionInfo.SizeAndChecksums?.Layerbreak3 == null || submissionInfo.SizeAndChecksums.Layerbreak3 == 0)
HashDataLayerbreak3!.Visibility = Visibility.Collapsed;
if (submissionInfo.CopyProtection?.AntiModchip == null)
AntiModchip.Visibility = Visibility.Collapsed;
AntiModchip!.Visibility = Visibility.Collapsed;
if (submissionInfo.TracksAndWriteOffsets?.OtherWriteOffsets == null)
DiscOffset.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.Keys?.Contains(SiteCode.DMIHash) != true)
DMIHash.Visibility = Visibility.Collapsed;
DiscOffset!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.DMIHash) != true)
DMIHash!.Visibility = Visibility.Collapsed;
if (submissionInfo.EDC?.EDC == null)
EDC.Visibility = Visibility.Collapsed;
EDC!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.CommonDiscInfo?.ErrorsCount))
ErrorsCount.Visibility = Visibility.Collapsed;
ErrorsCount!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.CommonDiscInfo?.EXEDateBuildDate))
EXEDateBuildDate.Visibility = Visibility.Collapsed;
EXEDateBuildDate!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.Filename) != true)
Filename.Visibility = Visibility.Collapsed;
Filename!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.Extras?.Header))
Header.Visibility = Visibility.Collapsed;
Header!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.InternalName) != true)
InternalName.Visibility = Visibility.Collapsed;
InternalName!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.InternalSerialName) != true)
InternalSerialName.Visibility = Visibility.Collapsed;
InternalSerialName!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.Multisession) != true)
Multisession.Visibility = Visibility.Collapsed;
Multisession!.Visibility = Visibility.Collapsed;
if (submissionInfo.CopyProtection?.LibCrypt == null)
LibCrypt.Visibility = Visibility.Collapsed;
LibCrypt!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.CopyProtection?.LibCryptData))
LibCryptData.Visibility = Visibility.Collapsed;
LibCryptData!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.PFIHash) != true)
PFIHash.Visibility = Visibility.Collapsed;
PFIHash!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.Extras?.PIC))
PIC.Visibility = Visibility.Collapsed;
PIC!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.Extras?.PVD))
PVD.Visibility = Visibility.Collapsed;
PVD!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.RingNonZeroDataStart) != true)
RingNonZeroDataStart.Visibility = Visibility.Collapsed;
RingNonZeroDataStart!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.CopyProtection?.SecuROMData))
SecuROMData.Visibility = Visibility.Collapsed;
SecuROMData!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.SSHash) != true)
SSHash.Visibility = Visibility.Collapsed;
SSHash!.Visibility = Visibility.Collapsed;
if (string.IsNullOrEmpty(submissionInfo.Extras?.SecuritySectorRanges))
SecuritySectorRanges.Visibility = Visibility.Collapsed;
SecuritySectorRanges!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.SSVersion) != true)
SSVersion.Visibility = Visibility.Collapsed;
SSVersion!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.UniversalHash) != true)
UniversalHash.Visibility = Visibility.Collapsed;
UniversalHash!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.VolumeLabel) != true)
VolumeLabel.Visibility = Visibility.Collapsed;
VolumeLabel!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.XeMID) != true)
XeMID.Visibility = Visibility.Collapsed;
XeMID!.Visibility = Visibility.Collapsed;
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.XMID) != true)
XMID.Visibility = Visibility.Collapsed;
#endif
XMID!.Visibility = Visibility.Collapsed;
}
/// <summary>
@@ -458,37 +330,19 @@ namespace MPF.UI.Windows
{
case DiscType.CD:
case DiscType.GDROM:
#if NET35
_L0Info!.Header = "Data Side";
_L0MasteringRing!.Label = "Mastering Ring";
_L0MasteringSID!.Label = "Mastering SID";
_L0Toolstamp!.Label = "Toolstamp/Mastering Code";
_L0MouldSID!.Label = "Mould SID";
_L0AdditionalMould!.Label = "Additional Mould";
#else
L0Info.Header = "Data Side";
L0MasteringRing.Label = "Mastering Ring";
L0MasteringSID.Label = "Mastering SID";
L0Toolstamp.Label = "Toolstamp/Mastering Code";
L0MouldSID.Label = "Mould SID";
L0AdditionalMould.Label = "Additional Mould";
#endif
L0Info!.Header = "Data Side";
L0MasteringRing!.Label = "Mastering Ring";
L0MasteringSID!.Label = "Mastering SID";
L0Toolstamp!.Label = "Toolstamp/Mastering Code";
L0MouldSID!.Label = "Mould SID";
L0AdditionalMould!.Label = "Additional Mould";
#if NET35
_L1Info!.Header = "Label Side";
_L1MasteringRing!.Label = "Mastering Ring";
_L1MasteringSID!.Label = "Mastering SID";
_L1Toolstamp!.Label = "Mastering SID";
_L1MouldSID!.Label = "Mould SID";
_L1AdditionalMould!.Label = "Additional Mould";
#else
L1Info.Header = "Label Side";
L1MasteringRing.Label = "Mastering Ring";
L1MasteringSID.Label = "Mastering SID";
L1Toolstamp.Label = "Mastering SID";
L1MouldSID.Label = "Mould SID";
L1AdditionalMould.Label = "Additional Mould";
#endif
L1Info!.Header = "Label Side";
L1MasteringRing!.Label = "Mastering Ring";
L1MasteringSID!.Label = "Mastering SID";
L1Toolstamp!.Label = "Mastering SID";
L1MouldSID!.Label = "Mould SID";
L1AdditionalMould!.Label = "Additional Mould";
break;
case DiscType.DVD5:
@@ -510,212 +364,103 @@ namespace MPF.UI.Windows
// Quad-layer discs
if (submissionInfo?.SizeAndChecksums?.Layerbreak3 != default(long))
{
#if NET35
_L2Info!.Visibility = Visibility.Visible;
_L3Info!.Visibility = Visibility.Visible;
#else
L2Info.Visibility = Visibility.Visible;
L3Info.Visibility = Visibility.Visible;
#endif
L2Info!.Visibility = Visibility.Visible;
L3Info!.Visibility = Visibility.Visible;
#if NET35
_L0Info!.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
_L0MasteringRing!.Label = "Mastering Ring";
_L0MasteringSID!.Label = "Mastering SID";
_L0Toolstamp!.Label = "Toolstamp/Mastering Code";
_L0MouldSID!.Label = "Data Side Mould SID";
_L0AdditionalMould!.Label = "Data Side Additional Mould";
#else
L0Info.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
L0MasteringRing.Label = "Mastering Ring";
L0MasteringSID.Label = "Mastering SID";
L0Toolstamp.Label = "Toolstamp/Mastering Code";
L0MouldSID.Label = "Data Side Mould SID";
L0AdditionalMould.Label = "Data Side Additional Mould";
#endif
L0Info!.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
L0MasteringRing!.Label = "Mastering Ring";
L0MasteringSID!.Label = "Mastering SID";
L0Toolstamp!.Label = "Toolstamp/Mastering Code";
L0MouldSID!.Label = "Data Side Mould SID";
L0AdditionalMould!.Label = "Data Side Additional Mould";
#if NET35
_L1Info!.Header = "Layer 1";
_L1MasteringRing!.Label = "Mastering Ring";
_L1MasteringSID!.Label = "Mastering SID";
_L1Toolstamp!.Label = "Toolstamp/Mastering Code";
_L1MouldSID!.Label = "Label Side Mould SID";
_L1AdditionalMould!.Label = "Label Side Additional Mould";
#else
L1Info.Header = "Layer 1";
L1MasteringRing.Label = "Mastering Ring";
L1MasteringSID.Label = "Mastering SID";
L1Toolstamp.Label = "Toolstamp/Mastering Code";
L1MouldSID.Label = "Label Side Mould SID";
L1AdditionalMould.Label = "Label Side Additional Mould";
#endif
L1Info!.Header = "Layer 1";
L1MasteringRing!.Label = "Mastering Ring";
L1MasteringSID!.Label = "Mastering SID";
L1Toolstamp!.Label = "Toolstamp/Mastering Code";
L1MouldSID!.Label = "Label Side Mould SID";
L1AdditionalMould!.Label = "Label Side Additional Mould";
#if NET35
_L2Info!.Header = "Layer 2";
_L2MasteringRing!.Label = "Mastering Ring";
_L2MasteringSID!.Label = "Mastering SID";
_L2Toolstamp!.Label = "Toolstamp/Mastering Code";
#else
L2Info.Header = "Layer 2";
L2MasteringRing.Label = "Mastering Ring";
L2MasteringSID.Label = "Mastering SID";
L2Toolstamp.Label = "Toolstamp/Mastering Code";
#endif
L2Info!.Header = "Layer 2";
L2MasteringRing!.Label = "Mastering Ring";
L2MasteringSID!.Label = "Mastering SID";
L2Toolstamp!.Label = "Toolstamp/Mastering Code";
#if NET35
_L3Info!.Header = reverseOrder ? "Layer 3 (Inner)" : "Layer 3 (Outer)";
_L3MasteringRing!.Label = "Mastering Ring";
_L3MasteringSID!.Label = "Mastering SID";
_L3Toolstamp!.Label = "Toolstamp/Mastering Code";
#else
L3Info.Header = reverseOrder ? "Layer 3 (Inner)" : "Layer 3 (Outer)";
L3MasteringRing.Label = "Mastering Ring";
L3MasteringSID.Label = "Mastering SID";
L3Toolstamp.Label = "Toolstamp/Mastering Code";
#endif
L3Info!.Header = reverseOrder ? "Layer 3 (Inner)" : "Layer 3 (Outer)";
L3MasteringRing!.Label = "Mastering Ring";
L3MasteringSID!.Label = "Mastering SID";
L3Toolstamp!.Label = "Toolstamp/Mastering Code";
}
// Triple-layer discs
else if (submissionInfo?.SizeAndChecksums?.Layerbreak2 != default(long))
{
#if NET35
_L2Info!.Visibility = Visibility.Visible;
#else
L2Info.Visibility = Visibility.Visible;
#endif
L2Info!.Visibility = Visibility.Visible;
#if NET35
_L0Info!.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
_L0MasteringRing!.Label = "Mastering Ring";
_L0MasteringSID!.Label = "Mastering SID";
_L0Toolstamp!.Label = "Toolstamp/Mastering Code";
_L0MouldSID!.Label = "Data Side Mould SID";
_L0AdditionalMould!.Label = "Data Side Additional Mould";
#else
L0Info.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
L0MasteringRing.Label = "Mastering Ring";
L0MasteringSID.Label = "Mastering SID";
L0Toolstamp.Label = "Toolstamp/Mastering Code";
L0MouldSID.Label = "Data Side Mould SID";
L0AdditionalMould.Label = "Data Side Additional Mould";
#endif
L0Info!.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
L0MasteringRing!.Label = "Mastering Ring";
L0MasteringSID!.Label = "Mastering SID";
L0Toolstamp!.Label = "Toolstamp/Mastering Code";
L0MouldSID!.Label = "Data Side Mould SID";
L0AdditionalMould!.Label = "Data Side Additional Mould";
#if NET35
_L1Info!.Header = "Layer 1";
_L1MasteringRing!.Label = "Mastering Ring";
_L1MasteringSID!.Label = "Mastering SID";
_L1Toolstamp!.Label = "Toolstamp/Mastering Code";
_L1MouldSID!.Label = "Label Side Mould SID";
_L1AdditionalMould!.Label = "Label Side Additional Mould";
#else
L1Info.Header = "Layer 1";
L1MasteringRing.Label = "Mastering Ring";
L1MasteringSID.Label = "Mastering SID";
L1Toolstamp.Label = "Toolstamp/Mastering Code";
L1MouldSID.Label = "Label Side Mould SID";
L1AdditionalMould.Label = "Label Side Additional Mould";
#endif
L1Info!.Header = "Layer 1";
L1MasteringRing!.Label = "Mastering Ring";
L1MasteringSID!.Label = "Mastering SID";
L1Toolstamp!.Label = "Toolstamp/Mastering Code";
L1MouldSID!.Label = "Label Side Mould SID";
L1AdditionalMould!.Label = "Label Side Additional Mould";
#if NET35
_L2Info!.Header = reverseOrder ? "Layer 2 (Inner)" : "Layer 2 (Outer)";
_L2MasteringRing!.Label = "Mastering Ring";
_L2MasteringSID!.Label = "Mastering SID";
_L2Toolstamp!.Label = "Toolstamp/Mastering Code";
#else
L2Info.Header = reverseOrder ? "Layer 2 (Inner)" : "Layer 2 (Outer)";
L2MasteringRing.Label = "Mastering Ring";
L2MasteringSID.Label = "Mastering SID";
L2Toolstamp.Label = "Toolstamp/Mastering Code";
#endif
L2Info!.Header = reverseOrder ? "Layer 2 (Inner)" : "Layer 2 (Outer)";
L2MasteringRing!.Label = "Mastering Ring";
L2MasteringSID!.Label = "Mastering SID";
L2Toolstamp!.Label = "Toolstamp/Mastering Code";
}
// Double-layer discs
else if (submissionInfo?.SizeAndChecksums?.Layerbreak != default(long))
{
#if NET35
_L0Info!.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
_L0MasteringRing!.Label = "Mastering Ring";
_L0MasteringSID!.Label = "Mastering SID";
_L0Toolstamp!.Label = "Toolstamp/Mastering Code";
_L0MouldSID!.Label = "Data Side Mould SID";
_L0AdditionalMould!.Label = "Data Side Additional Mould";
#else
L0Info.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
L0MasteringRing.Label = "Mastering Ring";
L0MasteringSID.Label = "Mastering SID";
L0Toolstamp.Label = "Toolstamp/Mastering Code";
L0MouldSID.Label = "Data Side Mould SID";
L0AdditionalMould.Label = "Data Side Additional Mould";
#endif
L0Info!.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
L0MasteringRing!.Label = "Mastering Ring";
L0MasteringSID!.Label = "Mastering SID";
L0Toolstamp!.Label = "Toolstamp/Mastering Code";
L0MouldSID!.Label = "Data Side Mould SID";
L0AdditionalMould!.Label = "Data Side Additional Mould";
#if NET35
_L1Info!.Header = reverseOrder ? "Layer 1 (Inner)" : "Layer 1 (Outer)";
_L1MasteringRing!.Label = "Mastering Ring";
_L1MasteringSID!.Label = "Mastering SID";
_L1Toolstamp!.Label = "Toolstamp/Mastering Code";
_L1MouldSID!.Label = "Label Side Mould SID";
_L1AdditionalMould!.Label = "Label Side Additional Mould";
#else
L1Info.Header = reverseOrder ? "Layer 1 (Inner)" : "Layer 1 (Outer)";
L1MasteringRing.Label = "Mastering Ring";
L1MasteringSID.Label = "Mastering SID";
L1Toolstamp.Label = "Toolstamp/Mastering Code";
L1MouldSID.Label = "Label Side Mould SID";
L1AdditionalMould.Label = "Label Side Additional Mould";
#endif
L1Info!.Header = reverseOrder ? "Layer 1 (Inner)" : "Layer 1 (Outer)";
L1MasteringRing!.Label = "Mastering Ring";
L1MasteringSID!.Label = "Mastering SID";
L1Toolstamp!.Label = "Toolstamp/Mastering Code";
L1MouldSID!.Label = "Label Side Mould SID";
L1AdditionalMould!.Label = "Label Side Additional Mould";
}
// Single-layer discs
else
{
#if NET35
_L0Info!.Header = "Data Side";
_L0MasteringRing!.Label = "Mastering Ring";
_L0MasteringSID!.Label = "Mastering SID";
_L0Toolstamp!.Label = "Toolstamp/Mastering Code";
_L0MouldSID!.Label = "Mould SID";
_L0AdditionalMould!.Label = "Additional Mould";
#else
L0Info.Header = "Data Side";
L0MasteringRing.Label = "Mastering Ring";
L0MasteringSID.Label = "Mastering SID";
L0Toolstamp.Label = "Toolstamp/Mastering Code";
L0MouldSID.Label = "Mould SID";
L0AdditionalMould.Label = "Additional Mould";
#endif
L0Info!.Header = "Data Side";
L0MasteringRing!.Label = "Mastering Ring";
L0MasteringSID!.Label = "Mastering SID";
L0Toolstamp!.Label = "Toolstamp/Mastering Code";
L0MouldSID!.Label = "Mould SID";
L0AdditionalMould!.Label = "Additional Mould";
#if NET35
_L1Info!.Header = "Label Side";
_L1MasteringRing!.Label = "Mastering Ring";
_L1MasteringSID!.Label = "Mastering SID";
_L1Toolstamp!.Label = "Toolstamp/Mastering Code";
_L1MouldSID!.Label = "Mould SID";
_L1AdditionalMould!.Label = "Additional Mould";
#else
L1Info.Header = "Label Side";
L1MasteringRing.Label = "Mastering Ring";
L1MasteringSID.Label = "Mastering SID";
L1Toolstamp.Label = "Toolstamp/Mastering Code";
L1MouldSID.Label = "Mould SID";
L1AdditionalMould.Label = "Additional Mould";
#endif
L1Info!.Header = "Label Side";
L1MasteringRing!.Label = "Mastering Ring";
L1MasteringSID!.Label = "Mastering SID";
L1Toolstamp!.Label = "Toolstamp/Mastering Code";
L1MouldSID!.Label = "Mould SID";
L1AdditionalMould!.Label = "Additional Mould";
}
break;
// All other media we assume to have no rings
default:
#if NET35
_L0Info!.Visibility = Visibility.Collapsed;
_L1Info!.Visibility = Visibility.Collapsed;
_L2Info!.Visibility = Visibility.Collapsed;
_L3Info!.Visibility = Visibility.Collapsed;
#else
L0Info.Visibility = Visibility.Collapsed;
L1Info.Visibility = Visibility.Collapsed;
L2Info.Visibility = Visibility.Collapsed;
L3Info.Visibility = Visibility.Collapsed;
#endif
L0Info!.Visibility = Visibility.Collapsed;
L1Info!.Visibility = Visibility.Collapsed;
L2Info!.Visibility = Visibility.Collapsed;
L3Info!.Visibility = Visibility.Collapsed;
break;
}
}
@@ -730,29 +475,16 @@ namespace MPF.UI.Windows
switch (system)
{
case RedumpSystem.NintendoWiiU:
#if NET35
_DiscKeyTextBox!.Visibility = Visibility.Visible;
#else
DiscKeyTextBox.Visibility = Visibility.Visible;
#endif
DiscKeyTextBox!.Visibility = Visibility.Visible;
break;
case RedumpSystem.SonyPlayStation2:
#if NET35
_LanguageSelectionGrid!.Visibility = Visibility.Visible;
#else
LanguageSelectionGrid.Visibility = Visibility.Visible;
#endif
LanguageSelectionGrid!.Visibility = Visibility.Visible;
break;
case RedumpSystem.SonyPlayStation3:
#if NET35
_DiscKeyTextBox!.Visibility = Visibility.Visible;
_DiscIDTextBox!.Visibility = Visibility.Visible;
#else
DiscKeyTextBox.Visibility = Visibility.Visible;
DiscIDTextBox.Visibility = Visibility.Visible;
#endif
DiscKeyTextBox!.Visibility = Visibility.Visible;
DiscIDTextBox!.Visibility = Visibility.Visible;
break;
}
}

View File

@@ -1,5 +1,8 @@
using System;
using System.IO;
#if NET40
using System.Threading.Tasks;
#endif
using System.Windows;
using System.Windows.Controls;
using MPF.Frontend.ViewModels;
@@ -25,41 +28,41 @@ namespace MPF.UI.Windows
#region Top Menu Bar
private MenuItem? _AboutMenuItem => ItemHelper.FindChild<MenuItem>(this, "AboutMenuItem");
private MenuItem? _AppExitMenuItem => ItemHelper.FindChild<MenuItem>(this, "AppExitMenuItem");
private MenuItem? _CheckForUpdatesMenuItem => ItemHelper.FindChild<MenuItem>(this, "CheckForUpdatesMenuItem");
private MenuItem? _DebugViewMenuItem => ItemHelper.FindChild<MenuItem>(this, "DebugViewMenuItem");
private MenuItem? _CheckDumpMenuItem => ItemHelper.FindChild<MenuItem>(this, "CheckDumpMenuItem");
private MenuItem? _CreateIRDMenuItem => ItemHelper.FindChild<MenuItem>(this, "CreateIRDMenuItem");
private MenuItem? _OptionsMenuItem => ItemHelper.FindChild<MenuItem>(this, "OptionsMenuItem");
private MenuItem? AboutMenuItem => ItemHelper.FindChild<MenuItem>(this, "AboutMenuItem");
private MenuItem? AppExitMenuItem => ItemHelper.FindChild<MenuItem>(this, "AppExitMenuItem");
private MenuItem? CheckForUpdatesMenuItem => ItemHelper.FindChild<MenuItem>(this, "CheckForUpdatesMenuItem");
private MenuItem? DebugViewMenuItem => ItemHelper.FindChild<MenuItem>(this, "DebugViewMenuItem");
private MenuItem? CheckDumpMenuItem => ItemHelper.FindChild<MenuItem>(this, "CheckDumpMenuItem");
private MenuItem? CreateIRDMenuItem => ItemHelper.FindChild<MenuItem>(this, "CreateIRDMenuItem");
private MenuItem? OptionsMenuItem => ItemHelper.FindChild<MenuItem>(this, "OptionsMenuItem");
#endregion
#region Settings
private ComboBox? _DriveLetterComboBox => ItemHelper.FindChild<ComboBox>(this, "DriveLetterComboBox");
private ComboBox? _DriveSpeedComboBox => ItemHelper.FindChild<ComboBox>(this, "DriveSpeedComboBox");
private ComboBox? _DumpingProgramComboBox => ItemHelper.FindChild<ComboBox>(this, "DumpingProgramComboBox");
private CheckBox? _EnableParametersCheckBox => ItemHelper.FindChild<CheckBox>(this, "EnableParametersCheckBox");
private ComboBox? _MediaTypeComboBox => ItemHelper.FindChild<ComboBox>(this, "MediaTypeComboBox");
private Button? _OutputPathBrowseButton => ItemHelper.FindChild<Button>(this, "OutputPathBrowseButton");
private TextBox? _OutputPathTextBox => ItemHelper.FindChild<TextBox>(this, "OutputPathTextBox");
private ComboBox? _SystemTypeComboBox => ItemHelper.FindChild<ComboBox>(this, "SystemTypeComboBox");
private ComboBox? DriveLetterComboBox => ItemHelper.FindChild<ComboBox>(this, "DriveLetterComboBox");
private ComboBox? DriveSpeedComboBox => ItemHelper.FindChild<ComboBox>(this, "DriveSpeedComboBox");
private ComboBox? DumpingProgramComboBox => ItemHelper.FindChild<ComboBox>(this, "DumpingProgramComboBox");
private CheckBox? EnableParametersCheckBox => ItemHelper.FindChild<CheckBox>(this, "EnableParametersCheckBox");
private ComboBox? MediaTypeComboBox => ItemHelper.FindChild<ComboBox>(this, "MediaTypeComboBox");
private Button? OutputPathBrowseButton => ItemHelper.FindChild<Button>(this, "OutputPathBrowseButton");
private TextBox? OutputPathTextBox => ItemHelper.FindChild<TextBox>(this, "OutputPathTextBox");
private ComboBox? SystemTypeComboBox => ItemHelper.FindChild<ComboBox>(this, "SystemTypeComboBox");
#endregion
#region Controls
private Button? _CopyProtectScanButton => ItemHelper.FindChild<Button>(this, "CopyProtectScanButton");
private Button? _MediaScanButton => ItemHelper.FindChild<Button>(this, "MediaScanButton");
private Button? _StartStopButton => ItemHelper.FindChild<Button>(this, "StartStopButton");
private Button? _UpdateVolumeLabel => ItemHelper.FindChild<Button>(this, "UpdateVolumeLabel");
private Button? CopyProtectScanButton => ItemHelper.FindChild<Button>(this, "CopyProtectScanButton");
private Button? MediaScanButton => ItemHelper.FindChild<Button>(this, "MediaScanButton");
private Button? StartStopButton => ItemHelper.FindChild<Button>(this, "StartStopButton");
private Button? UpdateVolumeLabel => ItemHelper.FindChild<Button>(this, "UpdateVolumeLabel");
#endregion
#region Status
private LogOutput? _LogOutput => ItemHelper.FindChild<LogOutput>(this, "LogOutput");
private LogOutput? LogOutput => ItemHelper.FindChild<LogOutput>(this, "LogOutput");
#endregion
@@ -102,17 +105,9 @@ namespace MPF.UI.Windows
// Display the debug option in the menu, if necessary
if (MainViewModel.Options.ShowDebugViewMenuItem)
#if NET35
_DebugViewMenuItem!.Visibility = Visibility.Visible;
#else
DebugViewMenuItem.Visibility = Visibility.Visible;
#endif
DebugViewMenuItem!.Visibility = Visibility.Visible;
#if NET35
MainViewModel.Init(_LogOutput!.EnqueueLog, DisplayUserMessage, ShowDiscInformationWindow);
#else
MainViewModel.Init(LogOutput.EnqueueLog, DisplayUserMessage, ShowDiscInformationWindow);
#endif
MainViewModel.Init(LogOutput!.EnqueueLog, DisplayUserMessage, ShowDiscInformationWindow);
// Set the UI color scheme according to the options
ApplyTheme();
@@ -137,62 +132,31 @@ namespace MPF.UI.Windows
public void AddEventHandlers()
{
// Menu Bar Click
#if NET35
_AboutMenuItem!.Click += AboutClick;
_AppExitMenuItem!.Click += AppExitClick;
_CheckForUpdatesMenuItem!.Click += CheckForUpdatesClick;
_DebugViewMenuItem!.Click += DebugViewClick;
_CheckDumpMenuItem!.Click += CheckDumpMenuItemClick;
_CreateIRDMenuItem!.Click += CreateIRDMenuItemClick;
_OptionsMenuItem!.Click += OptionsMenuItemClick;
#else
AboutMenuItem.Click += AboutClick;
AppExitMenuItem.Click += AppExitClick;
CheckForUpdatesMenuItem.Click += CheckForUpdatesClick;
DebugViewMenuItem.Click += DebugViewClick;
CheckDumpMenuItem.Click += CheckDumpMenuItemClick;
CreateIRDMenuItem.Click += CreateIRDMenuItemClick;
OptionsMenuItem.Click += OptionsMenuItemClick;
#endif
AboutMenuItem!.Click += AboutClick;
AppExitMenuItem!.Click += AppExitClick;
CheckForUpdatesMenuItem!.Click += CheckForUpdatesClick;
DebugViewMenuItem!.Click += DebugViewClick;
CheckDumpMenuItem!.Click += CheckDumpMenuItemClick;
CreateIRDMenuItem!.Click += CreateIRDMenuItemClick;
OptionsMenuItem!.Click += OptionsMenuItemClick;
// User Area Click
#if NET35
_CopyProtectScanButton!.Click += CopyProtectScanButtonClick;
_EnableParametersCheckBox!.Click += EnableParametersCheckBoxClick;
_MediaScanButton!.Click += MediaScanButtonClick;
_UpdateVolumeLabel!.Click += UpdateVolumeLabelClick;
_OutputPathBrowseButton!.Click += OutputPathBrowseButtonClick;
_StartStopButton!.Click += StartStopButtonClick;
#else
CopyProtectScanButton.Click += CopyProtectScanButtonClick;
EnableParametersCheckBox.Click += EnableParametersCheckBoxClick;
MediaScanButton.Click += MediaScanButtonClick;
UpdateVolumeLabel.Click += UpdateVolumeLabelClick;
OutputPathBrowseButton.Click += OutputPathBrowseButtonClick;
StartStopButton.Click += StartStopButtonClick;
#endif
CopyProtectScanButton!.Click += CopyProtectScanButtonClick;
EnableParametersCheckBox!.Click += EnableParametersCheckBoxClick;
MediaScanButton!.Click += MediaScanButtonClick;
UpdateVolumeLabel!.Click += UpdateVolumeLabelClick;
OutputPathBrowseButton!.Click += OutputPathBrowseButtonClick;
StartStopButton!.Click += StartStopButtonClick;
// User Area SelectionChanged
#if NET35
_SystemTypeComboBox!.SelectionChanged += SystemTypeComboBoxSelectionChanged;
_MediaTypeComboBox!.SelectionChanged += MediaTypeComboBoxSelectionChanged;
_DriveLetterComboBox!.SelectionChanged += DriveLetterComboBoxSelectionChanged;
_DriveSpeedComboBox!.SelectionChanged += DriveSpeedComboBoxSelectionChanged;
_DumpingProgramComboBox!.SelectionChanged += DumpingProgramComboBoxSelectionChanged;
#else
SystemTypeComboBox.SelectionChanged += SystemTypeComboBoxSelectionChanged;
MediaTypeComboBox.SelectionChanged += MediaTypeComboBoxSelectionChanged;
DriveLetterComboBox.SelectionChanged += DriveLetterComboBoxSelectionChanged;
DriveSpeedComboBox.SelectionChanged += DriveSpeedComboBoxSelectionChanged;
DumpingProgramComboBox.SelectionChanged += DumpingProgramComboBoxSelectionChanged;
#endif
SystemTypeComboBox!.SelectionChanged += SystemTypeComboBoxSelectionChanged;
MediaTypeComboBox!.SelectionChanged += MediaTypeComboBoxSelectionChanged;
DriveLetterComboBox!.SelectionChanged += DriveLetterComboBoxSelectionChanged;
DriveSpeedComboBox!.SelectionChanged += DriveSpeedComboBoxSelectionChanged;
DumpingProgramComboBox!.SelectionChanged += DumpingProgramComboBoxSelectionChanged;
// User Area TextChanged
#if NET35
_OutputPathTextBox!.TextChanged += OutputPathTextBoxTextChanged;
#else
OutputPathTextBox.TextChanged += OutputPathTextBoxTextChanged;
#endif
OutputPathTextBox!.TextChanged += OutputPathTextBoxTextChanged;
}
/// <summary>
@@ -310,7 +274,7 @@ namespace MPF.UI.Windows
WindowStartupLocation = WindowStartupLocation.CenterOwner,
};
discInformationWindow.Closed += delegate { this.Activate(); };
discInformationWindow.Closed += delegate { Activate(); };
bool? result = discInformationWindow.ShowDialog();
// Copy back the submission info changes, if necessary
@@ -326,7 +290,7 @@ namespace MPF.UI.Windows
public void ShowCheckDumpWindow()
{
// Hide MainWindow while Check GUI is open
this.Hide();
Hide();
var checkDumpWindow = new CheckDumpWindow(this)
{
@@ -340,8 +304,8 @@ namespace MPF.UI.Windows
checkDumpWindow.Closed += delegate
{
// Unhide Main window after Check window has been closed
this.Show();
this.Activate();
Show();
Activate();
};
checkDumpWindow.Show();
}
@@ -352,7 +316,7 @@ namespace MPF.UI.Windows
public void ShowCreateIRDWindow()
{
// Hide MainWindow while Create IRD UI is open
this.Hide();
Hide();
var createIRDWindow = new CreateIRDWindow(this)
{
@@ -366,8 +330,8 @@ namespace MPF.UI.Windows
createIRDWindow.Closed += delegate
{
// Unhide Main window after Create IRD window has been closed
this.Show();
this.Activate();
Show();
Activate();
};
createIRDWindow.Show();
}
@@ -387,7 +351,7 @@ namespace MPF.UI.Windows
WindowStartupLocation = WindowStartupLocation.CenterOwner,
};
optionsWindow.Closed += delegate { this.Activate(); };
optionsWindow.Closed += delegate { Activate(); };
optionsWindow.Closed += OnOptionsUpdated;
optionsWindow.Show();
}
@@ -535,17 +499,9 @@ namespace MPF.UI.Windows
/// <summary>
/// Handler for CopyProtectScanButton Click event
/// </summary>
#if NET40
public void CopyProtectScanButtonClick(object sender, RoutedEventArgs e)
#else
public async void CopyProtectScanButtonClick(object sender, RoutedEventArgs e)
#endif
{
#if NET40
var output = MainViewModel.ScanAndShowProtection();
#else
var output = await MainViewModel.ScanAndShowProtection();
#endif
if (!MainViewModel.LogPanelExpanded)
{

View File

@@ -179,10 +179,11 @@
ItemsSource="{Binding InternalPrograms}" SelectedItem="{Binding Options.InternalProgram, Converter={StaticResource ElementConverter}, Mode=TwoWay}"
Style="{DynamicResource CustomComboBoxStyle}" />
<Label Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Content="Default Output Path" />
<Label Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Content="Default Output Path"
ToolTip="Variables allowed:&#x0a; &#37;SYSTEM&#37;&#9;(System name, long)&#x0a; &#37;SYS&#37;&#9;&#9;(System name, short)&#x0a; &#37;MEDIA&#37;&#9;(Media type)&#x0a; &#37;PROGRAM&#37;&#9;(Program name, long)&#x0a; &#37;PROG&#37;&#9;(Program name, short)&#x0a; &#37;LABEL&#37;&#9;(Volume label)&#x0a; &#37;DATE&#37;&#9;(Current date)&#x0a; &#37;DATETIME&#37;&#9;(Current date and time)" />
<TextBox x:Name="DefaultOutputPathTextBox" Grid.Row="4" Grid.Column="1" Height="22" HorizontalAlignment="Stretch"
Text="{Binding Options.DefaultOutputPath}" VerticalContentAlignment="Center"
ToolTip="Variables allowed:&#x0a; &#37;SYSTEM&#37;&#9;(System name, long)&#x0a; &#37;SYS&#37;&#9;&#9;(System name, short)&#x0a; &#37;MEDIA&#37;&#9;(Media type)&#x0a; &#37;PROGRAM&#37;&#9;(Program name, long)&#x0a; &#37;PROG&#37;&#9;(Program name, short)&#x0a; &#37;LABEL&#37;&#9;(Volume label)&#x0a; &#37;DATE&#37;&#9;(Current date)&#x0a; &#37;DATETIME&#37;&#9;(Current date and time)"/>
ToolTip="Variables allowed:&#x0a; &#37;SYSTEM&#37;&#9;(System name, long)&#x0a; &#37;SYS&#37;&#9;&#9;(System name, short)&#x0a; &#37;MEDIA&#37;&#9;(Media type)&#x0a; &#37;PROGRAM&#37;&#9;(Program name, long)&#x0a; &#37;PROG&#37;&#9;(Program name, short)&#x0a; &#37;LABEL&#37;&#9;(Volume label)&#x0a; &#37;DATE&#37;&#9;(Current date)&#x0a; &#37;DATETIME&#37;&#9;(Current date and time)" />
<Button x:Name="DefaultOutputPathButton" Grid.Row="4" Grid.Column="2" Height="22" Width="22" Content="..."
Style="{DynamicResource CustomButtonStyle}" />
</Grid>

View File

@@ -1,5 +1,8 @@
using System;
using System.IO;
#if NET40
using System.Threading;
#endif
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@@ -25,15 +28,15 @@ namespace MPF.UI.Windows
#if NET35
private System.Windows.Controls.Button? _AaruPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "AaruPathButton");
private System.Windows.Controls.Button? _AcceptButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "AcceptButton");
private System.Windows.Controls.Button? _CancelButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "CancelButton");
private System.Windows.Controls.Button? _DefaultOutputPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "DefaultOutputPathButton");
private System.Windows.Controls.Button? _DiscImageCreatorPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "DiscImageCreatorPathButton");
private System.Windows.Controls.Button? _RedumperPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "RedumperPathButton");
private System.Windows.Controls.Button? _RedumpLoginTestButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "RedumpLoginTestButton");
private PasswordBox? _RedumpPasswordBox => ItemHelper.FindChild<PasswordBox>(this, "RedumpPasswordBox");
private System.Windows.Controls.TextBox? _RedumpUsernameTextBox => ItemHelper.FindChild<System.Windows.Controls.TextBox>(this, "RedumpUsernameTextBox");
private System.Windows.Controls.Button? AaruPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "AaruPathButton");
private System.Windows.Controls.Button? AcceptButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "AcceptButton");
private System.Windows.Controls.Button? CancelButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "CancelButton");
private System.Windows.Controls.Button? DefaultOutputPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "DefaultOutputPathButton");
private System.Windows.Controls.Button? DiscImageCreatorPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "DiscImageCreatorPathButton");
private System.Windows.Controls.Button? RedumperPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "RedumperPathButton");
private System.Windows.Controls.Button? RedumpLoginTestButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "RedumpLoginTestButton");
private PasswordBox? RedumpPasswordBox => ItemHelper.FindChild<PasswordBox>(this, "RedumpPasswordBox");
private System.Windows.Controls.TextBox? RedumpUsernameTextBox => ItemHelper.FindChild<System.Windows.Controls.TextBox>(this, "RedumpUsernameTextBox");
#endif
@@ -64,34 +67,18 @@ namespace MPF.UI.Windows
DataContext = new OptionsViewModel(options);
// Set initial value for binding
#if NET35
_RedumpPasswordBox!.Password = options.RedumpPassword;
#else
RedumpPasswordBox.Password = options.RedumpPassword;
#endif
RedumpPasswordBox!.Password = options.RedumpPassword;
// Add handlers
#if NET35
_AaruPathButton!.Click += BrowseForPathClick;
_DiscImageCreatorPathButton!.Click += BrowseForPathClick;
_RedumperPathButton!.Click += BrowseForPathClick;
_DefaultOutputPathButton!.Click += BrowseForPathClick;
AaruPathButton!.Click += BrowseForPathClick;
DiscImageCreatorPathButton!.Click += BrowseForPathClick;
RedumperPathButton!.Click += BrowseForPathClick;
DefaultOutputPathButton!.Click += BrowseForPathClick;
_AcceptButton!.Click += OnAcceptClick;
_CancelButton!.Click += OnCancelClick;
_RedumpPasswordBox!.PasswordChanged += OnPasswordChanged;
_RedumpLoginTestButton!.Click += OnRedumpTestClick;
#else
AaruPathButton.Click += BrowseForPathClick;
DiscImageCreatorPathButton.Click += BrowseForPathClick;
RedumperPathButton.Click += BrowseForPathClick;
DefaultOutputPathButton.Click += BrowseForPathClick;
AcceptButton.Click += OnAcceptClick;
CancelButton.Click += OnCancelClick;
RedumpPasswordBox.PasswordChanged += OnPasswordChanged;
RedumpLoginTestButton.Click += OnRedumpTestClick;
#endif
AcceptButton!.Click += OnAcceptClick;
CancelButton!.Click += OnCancelClick;
RedumpPasswordBox!.PasswordChanged += OnPasswordChanged;
RedumpLoginTestButton!.Click += OnRedumpTestClick;
}
/// <summary>
@@ -102,7 +89,7 @@ namespace MPF.UI.Windows
base.OnContentRendered(e);
// Set the window title
OptionsViewModel.Title = this.Title;
OptionsViewModel.Title = Title;
}
#region UI Commands
@@ -199,13 +186,9 @@ namespace MPF.UI.Windows
/// <summary>
/// Test Redump credentials for validity
/// </summary>
private async Task ValidateRedumpCredentials()
private async Task<bool?> ValidateRedumpCredentials()
{
#if NET35
bool? success = await RedumpClient.ValidateCredentials(_RedumpUsernameTextBox!.Text, _RedumpPasswordBox!.Password);
#else
bool? success = await RedumpClient.ValidateCredentials(RedumpUsernameTextBox.Text, RedumpPasswordBox.Password);
#endif
bool? success = await RedumpClient.ValidateCredentials(RedumpUsernameTextBox!.Text, RedumpPasswordBox!.Password);
string message = OptionsViewModel.GetRedumpLoginResult(success);
if (success == true)
@@ -214,6 +197,8 @@ namespace MPF.UI.Windows
CustomMessageBox.Show(this, message, "Failure", MessageBoxButton.OK, MessageBoxImage.Error);
else
CustomMessageBox.Show(this, message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return success;
}
#endregion
@@ -260,26 +245,15 @@ namespace MPF.UI.Windows
/// </summary>
private void OnPasswordChanged(object sender, EventArgs e)
{
#if NET35
OptionsViewModel.Options.RedumpPassword = _RedumpPasswordBox!.Password;
#else
OptionsViewModel.Options.RedumpPassword = RedumpPasswordBox.Password;
#endif
OptionsViewModel.Options.RedumpPassword = RedumpPasswordBox!.Password;
}
/// <summary>
/// Test Redump credentials for validity
/// </summary>
#if NET40
private void OnRedumpTestClick(object sender, EventArgs e)
{
var validateTask = ValidateRedumpCredentials();
validateTask.Wait();
}
#else
private async void OnRedumpTestClick(object sender, EventArgs e) => await ValidateRedumpCredentials();
#endif
private async void OnRedumpTestClick(object sender, EventArgs e)
=> await ValidateRedumpCredentials();
#endregion
#endregion
}
}

View File

@@ -14,7 +14,7 @@ namespace MPF.UI.Windows
{
try
{
this.DialogResult = false;
DialogResult = false;
}
catch { }
@@ -26,7 +26,7 @@ namespace MPF.UI.Windows
/// </summary>
public void MinimizeButtonClick(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
WindowState = WindowState.Minimized;
}
/// <summary>
@@ -35,7 +35,7 @@ namespace MPF.UI.Windows
public void TitleMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
DragMove();
}
#endregion

View File

@@ -57,31 +57,31 @@ MPF.Check is a commandline-only program that allows users to generate submission
MPF.UI, MPF.CLI, and MPF.Check have the same system requirements for running, with the exception that MPF.UI is Windows-only.
- [Supported OS versions for .NET 8](https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md)
- Requires [.NET 8.0 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) if built without bundled runtime
- [Supported OS versions for .NET 9](https://github.com/dotnet/core/blob/main/release-notes/9.0/supported-os.md)
- Requires [.NET 9.0 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) if built without bundled runtime
Ensure that your operating system and runtimes are as up-to-date as possible, since some features may rely on those updates.
## Build Instructions
To build for .NET 8.0, ensure that the [.NET 8.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) (or later) is installed and included in your `PATH`. Then, run the following commands from command prompt, Powershell, Terminal, or shell:
To build for .NET 9.0, ensure that the [.NET 9.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) (or later) is installed and included in your `PATH`. Then, run the following commands from command prompt, Powershell, Terminal, or shell:
**MPF.UI (Windows only):**
```bash
dotnet build MPF/MPF.csproj --framework net8.0-windows --runtime [win-x86|win-x64]
dotnet build MPF/MPF.csproj --framework net9.0-windows --runtime [win-x86|win-x64]
```
**MPF.CLI (Windows, OSX, Linux):**
```bash
dotnet build MPF.CLI/MPF.CLI.csproj --framework net8.0 --runtime [win-x86|win-x64|win-arm64|linux-x64|linux-arm64|osx-x64|osx-arm64]
dotnet build MPF.CLI/MPF.CLI.csproj --framework net9.0 --runtime [win-x86|win-x64|win-arm64|linux-x64|linux-arm64|osx-x64|osx-arm64]
```
**MPF.Check (Windows, OSX, Linux):**
```bash
dotnet build MPF.Check/MPF.Check.csproj --framework net8.0 --runtime [win-x86|win-x64|win-arm64|linux-x64|linux-arm64|osx-x64|osx-arm64]
dotnet build MPF.Check/MPF.Check.csproj --framework net9.0 --runtime [win-x86|win-x64|win-arm64|linux-x64|linux-arm64|osx-x64|osx-arm64]
```
Choose one of `win-x86`, `win-x64`, `win-arm64`, `linux-x64`, `linux-arm64`, `osx-x64`, or `osx-arm64` depending on the machine you are targeting.

View File

@@ -1,5 +1,5 @@
# version format
version: 3.2.3-{build}
version: 3.2.4-{build}
# pull request template
pull_requests:

View File

@@ -1,7 +1,7 @@
#!/bin/bash
# This batch file assumes the following:
# - .NET 8.0 (or newer) SDK is installed and in PATH
# - .NET 9.0 (or newer) SDK is installed and in PATH
# - zip is installed and in PATH
# - Git is installed and in PATH
# - The relevant commandline programs are already downloaded
@@ -51,21 +51,21 @@ echo " No archive (-a) $NO_ARCHIVE"
echo " "
# Create the build matrix arrays
UI_FRAMEWORKS=("net8.0-windows")
UI_FRAMEWORKS=("net9.0-windows")
UI_RUNTIMES=("win-x86" "win-x64")
CHECK_FRAMEWORKS=("net8.0")
CHECK_FRAMEWORKS=("net9.0")
CHECK_RUNTIMES=("win-x86" "win-x64" "win-arm64" "linux-x64" "linux-arm64" "osx-x64" "osx-arm64")
# Use expanded framework lists, if requested
if [ $USE_ALL = true ]; then
UI_FRAMEWORKS=("net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0-windows" "net6.0-windows" "net7.0-windows" "net8.0-windows")
CHECK_FRAMEWORKS=("net20" "net35" "net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0")
UI_FRAMEWORKS=("net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0-windows" "net6.0-windows" "net7.0-windows" "net8.0-windows" "net9.0-windows")
CHECK_FRAMEWORKS=("net20" "net35" "net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0")
fi
# Create the filter arrays
SINGLE_FILE_CAPABLE=("net5.0" "net5.0-windows" "net6.0" "net6.0-windows" "net7.0" "net7.0-windows" "net8.0" "net8.0-windows")
VALID_APPLE_FRAMEWORKS=("net6.0" "net7.0" "net8.0")
VALID_CROSS_PLATFORM_FRAMEWORKS=("netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0")
SINGLE_FILE_CAPABLE=("net5.0" "net5.0-windows" "net6.0" "net6.0-windows" "net7.0" "net7.0-windows" "net8.0" "net8.0-windows" "net9.0" "net9.0-windows")
VALID_APPLE_FRAMEWORKS=("net6.0" "net7.0" "net8.0" "net9.0")
VALID_CROSS_PLATFORM_FRAMEWORKS=("netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0")
VALID_CROSS_PLATFORM_RUNTIMES=("win-arm64" "linux-x64" "linux-arm64" "osx-x64" "osx-arm64")
# Only build if requested

View File

@@ -1,5 +1,5 @@
# This batch file assumes the following:
# - .NET 8.0 (or newer) SDK is installed and in PATH
# - .NET 9.0 (or newer) SDK is installed and in PATH
# - 7-zip commandline (7z.exe) is installed and in PATH
# - Git for Windows is installed and in PATH
# - The relevant commandline programs are already downloaded
@@ -42,21 +42,21 @@ Write-Host " No archive (-NoArchive) $NO_ARCHIVE"
Write-Host " "
# Create the build matrix arrays
$UI_FRAMEWORKS = @('net8.0-windows')
$UI_FRAMEWORKS = @('net9.0-windows')
$UI_RUNTIMES = @('win-x86', 'win-x64')
$CHECK_FRAMEWORKS = @('net8.0')
$CHECK_FRAMEWORKS = @('net9.0')
$CHECK_RUNTIMES = @('win-x86', 'win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64')
# Use expanded framework lists, if requested
if ($USE_ALL.IsPresent) {
$UI_FRAMEWORKS = @('net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0-windows', 'net6.0-windows', 'net7.0-windows', 'net8.0-windows')
$CHECK_FRAMEWORKS = @('net20', 'net35', 'net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0')
$UI_FRAMEWORKS = @('net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0-windows', 'net6.0-windows', 'net7.0-windows', 'net8.0-windows', 'net9.0-windows')
$CHECK_FRAMEWORKS = @('net20', 'net35', 'net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0')
}
# Create the filter arrays
$SINGLE_FILE_CAPABLE = @('net5.0', 'net5.0-windows', 'net6.0', 'net6.0-windows', 'net7.0', 'net7.0-windows', 'net8.0', 'net8.0-windows')
$VALID_APPLE_FRAMEWORKS = @('net6.0', 'net7.0', 'net8.0')
$VALID_CROSS_PLATFORM_FRAMEWORKS = @('netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0')
$SINGLE_FILE_CAPABLE = @('net5.0', 'net5.0-windows', 'net6.0', 'net6.0-windows', 'net7.0', 'net7.0-windows', 'net8.0', 'net8.0-windows', 'net9.0', 'net9.0-windows')
$VALID_APPLE_FRAMEWORKS = @('net6.0', 'net7.0', 'net8.0', 'net9.0')
$VALID_CROSS_PLATFORM_FRAMEWORKS = @('netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0')
$VALID_CROSS_PLATFORM_RUNTIMES = @('win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64')
# Only build if requested
@@ -66,8 +66,8 @@ if (!$NO_BUILD.IsPresent) {
dotnet restore
# Create Nuget Packages
dotnet pack MPF.ExecutionContexts/MPF.ExecutionContexts.csproj --output $BUILD_FOLDER
dotnet pack MPF.Processors/MPF.Processors.csproj --output $BUILD_FOLDER
dotnet pack MPF.ExecutionContexts\MPF.ExecutionContexts.csproj --output $BUILD_FOLDER
dotnet pack MPF.Processors\MPF.Processors.csproj --output $BUILD_FOLDER
# Build UI
foreach ($FRAMEWORK in $UI_FRAMEWORKS) {