Skip to content

Commit

Permalink
Enhancement: Confirm dialog for Mod Delete
Browse files Browse the repository at this point in the history
Resolves #269
Only adds en-GB strings, translations needed for other langs.
  • Loading branch information
dreamsyntax committed Nov 29, 2024
1 parent 0037b18 commit bfd4123
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using ReverseMarkdown.Converters;

namespace Reloaded.Mod.Launcher.Lib.Commands.Mod;

/// <summary>
Expand All @@ -20,7 +22,15 @@ public DeleteModCommand(PathTuple<ModConfig>? modTuple)
/// <inheritdoc />
public void Execute(object? parameter)
{
// Delete folder contents.
var deleteConfirm = Actions.DisplayMessagebox.Invoke(Resources.DeleteModDialogTitle.Get(), string.Format(Resources.DeleteModDialogDescription.Get(), _modTuple.Config.ModName), new Actions.DisplayMessageBoxParams()

Check warning on line 25 in source/Reloaded.Mod.Launcher.Lib/Commands/Mod/DeleteModCommand.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
{
StartupLocation = Actions.WindowStartupLocation.CenterScreen,
Type = Actions.MessageBoxType.OkCancel
});

if (!deleteConfirm)
return;

var directory = Path.GetDirectoryName(_modTuple!.Path) ?? throw new InvalidOperationException(Resources.ErrorFailedToGetDirectoryOfMod.Get());
Directory.Delete(directory, true);
}
Expand Down
4 changes: 4 additions & 0 deletions source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,8 @@ public static void Init(IDictionaryResourceProvider provider)
// Update 1.26.0: Drag & Drop Mods
public static IDictionaryResource<string> DragDropInstalledModsTitle { get; set; }
public static IDictionaryResource<string> DragDropInstalledModsDescription { get; set; }

// Update 1.28.4: Delete Mod Dialog
public static IDictionaryResource<string> DeleteModDialogTitle { get; set; }
public static IDictionaryResource<string> DeleteModDialogDescription { get; set; }
}
4 changes: 4 additions & 0 deletions source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -716,4 +716,8 @@ For more info, refer to the tutorial. Don't forget to set correct Publish target
<sys:String x:Key="DownloadPackagesPrevious">Previous</sys:String>
<sys:String x:Key="DownloadPackagesNext">Next</sys:String>

<!-- Update 1.28.4: Delete Mod Dialog -->
<sys:String x:Key="DeleteModDialogTitle">Delete Mod</sys:String>
<sys:String x:Key="DeleteModDialogDescription">{0}&#x0a;will be deleted.</sys:String>

</ResourceDictionary>

0 comments on commit bfd4123

Please # to comment.