Skip to content

Commit 86d35a7

Browse files
authored
Merge pull request #16 from SubZeroPL/games-without-id
Games without Id
2 parents 523ac3a + d6ffb58 commit 86d35a7

File tree

4 files changed

+43
-16
lines changed

4 files changed

+43
-16
lines changed

AssM.csproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
<Nullable>enable</Nullable>
66
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
77
<ApplicationManifest>app.manifest</ApplicationManifest>
8-
<Version>1.6.0</Version>
8+
<Version>1.6.1</Version>
99
<Authors>SubZeroPL</Authors>
1010
<PackageProjectUrl>https://github.com/SubZeroPL/AssM/</PackageProjectUrl>
11-
<AssemblyVersion>1.6.0</AssemblyVersion>
12-
<FileVersion>1.6.0</FileVersion>
11+
<AssemblyVersion>1.6.1</AssemblyVersion>
12+
<FileVersion>1.6.1</FileVersion>
1313
<Title>AssM</Title>
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Avalonia" Version="11.2.3" />
18-
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.3" />
19-
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
20-
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3" />
21-
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3" />
17+
<PackageReference Include="Avalonia" Version="11.3.0" />
18+
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.0" />
19+
<PackageReference Include="Avalonia.Desktop" Version="11.3.0" />
20+
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.0" />
21+
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.0" />
2222
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
23-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.3" />
24-
<PackageReference Include="BouncyCastle.Cryptography" Version="2.5.0" />
23+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.0" />
24+
<PackageReference Include="BouncyCastle.Cryptography" Version="2.5.1" />
2525
<PackageReference Include="Markdown.Avalonia" Version="11.0.3-a1"/>
2626
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
2727
<PackageReference Include="NLog" Version="5.4.0" />

Classes/Functions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,16 @@ public static List<string> GetReadmeFilesInDirectory(string directory)
216216
return result;
217217
}
218218

219-
public static Game AddGameToList(string cuePath, Configuration configuration, ObservableCollection<Game> gameList)
219+
public static Game? AddGameToList(string cuePath, Configuration configuration, ObservableCollection<Game> gameList)
220220
{
221221
Logger.Debug($"Adding game to list from {cuePath}");
222222
var di = DiscInspector.ScanDisc(cuePath);
223+
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract - apparently there are games that have no Id in image (like SLPS-00018)
224+
if (di.Data.SerialNumber == null)
225+
{
226+
Logger.Error($"Failed to add game to list from {cuePath}{Environment.NewLine}Id not present in image");
227+
return null;
228+
}
223229
var title = configuration.GetTitleFromCue ? Path.GetFileNameWithoutExtension(cuePath) : di.Data.GameTitle;
224230
var game = new Game
225231
{

Windows/AddFolderProgressWindow.axaml.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ private void WorkerOnProgressChanged(object? sender, ProgressChangedEventArgs e)
2828
LabelFolderName.Content = dir;
2929
}
3030

31-
public void Process(List<string> dirs, ObservableCollection<Game> gameList, Configuration configuration, Action finishedCallback)
31+
public void Process(List<string> dirs, ObservableCollection<Game> gameList, Configuration configuration, Action<List<string>> finishedCallback)
3232
{
3333
var cueFiles = new List<string>();
34+
var errors = new List<string>();
3435
_worker.DoWork += (_, _) =>
3536
{
3637
foreach (var dir in dirs)
@@ -43,7 +44,11 @@ public void Process(List<string> dirs, ObservableCollection<Game> gameList, Conf
4344
foreach (var cueFile in cueFiles)
4445
{
4546
if (_worker.CancellationPending) return;
46-
Functions.AddGameToList(cueFile, configuration, gameList);
47+
var game = Functions.AddGameToList(cueFile, configuration, gameList);
48+
if (game == null)
49+
{
50+
errors.Add($"Failed to add game to list from {cueFile}{Environment.NewLine}Id not present in image");
51+
}
4752
}
4853

4954
if (string.IsNullOrWhiteSpace(configuration.OutputDirectory)) return;
@@ -54,7 +59,7 @@ public void Process(List<string> dirs, ObservableCollection<Game> gameList, Conf
5459
}
5560
};
5661

57-
_worker.RunWorkerCompleted += (_, _) => finishedCallback.Invoke();
62+
_worker.RunWorkerCompleted += (_, _) => finishedCallback.Invoke(errors);
5863

5964
_worker.RunWorkerAsync();
6065
}

Windows/MainWindow.axaml.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ private void AddGame(string cuePath)
134134
{
135135
if (string.IsNullOrWhiteSpace(cuePath)) return;
136136
var game = Functions.AddGameToList(cuePath, Configuration, GameList);
137+
if (game == null)
138+
{
139+
MessageBoxManager.GetMessageBoxStandard("Error",
140+
$"Failed to add game to list from {cuePath}{Environment.NewLine}Id not present in image",
141+
ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Error, WindowStartupLocation.CenterOwner)
142+
.ShowWindowDialogAsync(this);
143+
return;
144+
}
145+
137146
if (string.IsNullOrWhiteSpace(TextBoxOutputDirectory.Text)) return;
138147
Functions.LoadExistingData(game, Configuration);
139148
game.Modified = true;
@@ -163,10 +172,17 @@ private void AddFolderButton_OnClick(object? sender, RoutedEventArgs e)
163172
.ToList() ?? [];
164173
var progress = new AddFolderProgressWindow();
165174
_ = progress.ShowDialog(this);
166-
progress.Process(dirs, GameList, Configuration, () =>
175+
progress.Process(dirs, GameList, Configuration, (errors) =>
167176
{
168177
progress.Close();
169-
DataGridGameList.CollectionView.Refresh();
178+
DataGridGameList.CollectionView.Refresh();
179+
if (errors.Count > 0)
180+
{
181+
MessageBoxManager.GetMessageBoxStandard("Error",
182+
string.Join(Environment.NewLine, errors),
183+
ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Error, WindowStartupLocation.CenterOwner)
184+
.ShowWindowDialogAsync(this);
185+
}
170186
});
171187
}
172188

0 commit comments

Comments
 (0)