Skip to content

Commit

Permalink
#78: Allow opening multiple games' backup folders at once
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Jun 10, 2024
1 parent 754a449 commit ff8459b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Unreleased

* Added:
* You can now open the backup directories for multiple selected games at once.

## v0.15.0 (2024-06-08)

* Added:
Expand Down
34 changes: 22 additions & 12 deletions src/LudusaviPlaynite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,36 @@ public override IEnumerable<GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs
);
}

if (menuArgs.Games.Count == 1)
var backupPaths = menuArgs.Games.Select(GetBackupPath).Where(x => x != null);
if (backupPaths.Any())
{
var backupPath = GetBackupPath(menuArgs.Games[0]);
if (backupPath != null)
{
items.Add(
new GameMenuItem
items.Add(
new GameMenuItem
{
Description = translator.OpenBackupDirectory(),
MenuSection = translator.Ludusavi(),
Action = args =>
{
Description = translator.OpenBackupDirectory(),
MenuSection = translator.Ludusavi(),
Action = args =>
var failed = new List<string>();

foreach (var backupPath in backupPaths)
{
if (!Etc.OpenDir(backupPath))
{
interactor.ShowError(this.translator.CannotOpenFolder());
failed.Add(backupPath);
}
}

if (failed.Any())
{
var message = this.translator.CannotOpenFolder();
var paths = string.Join("\n", failed);
var body = $"{message}\n\n{paths}";
interactor.ShowError(body);
}
}
);
}
}
);
}

if (menuArgs.Games.Count == 1)
Expand Down

0 comments on commit ff8459b

Please sign in to comment.