Skip to content

Commit

Permalink
Merge pull request #499 from dreamsyntax/feature/delete-confirm
Browse files Browse the repository at this point in the history
Enhancement: Confirm dialog for Mod Delete
  • Loading branch information
Sewer56 authored Nov 29, 2024
2 parents 0037b18 + 9f21975 commit eb5ccfa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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 23 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 eb5ccfa

Please sign in to comment.