diff --git a/Stardrop/Models/SMAPI/Manifest.cs b/Stardrop/Models/SMAPI/Manifest.cs index 9d16c326..b4be1e48 100644 --- a/Stardrop/Models/SMAPI/Manifest.cs +++ b/Stardrop/Models/SMAPI/Manifest.cs @@ -34,7 +34,10 @@ public class Manifest //[JsonConverter(typeof(ManifestDependencyArrayConverter))] public ManifestDependency[] Dependencies { get; set; } - // Custom property for Stardrop. + /// Custom property for Stardrop. public bool DeleteOldVersion { get; set; } + + /// Custom property for Stardrop. + public string? UpdateCautionMessage { get; set; } } } diff --git a/Stardrop/Views/MainWindow.axaml.cs b/Stardrop/Views/MainWindow.axaml.cs index 10a1366c..eea3e639 100644 --- a/Stardrop/Views/MainWindow.axaml.cs +++ b/Stardrop/Views/MainWindow.axaml.cs @@ -2260,6 +2260,25 @@ private async Task> AddMods(string[]? filePaths) continue; } + // If this is a mod update and if the Manifest.UpdateCautionMessage has a value, display message (and confirm if user wants to continue with mod update) + bool shouldProceedWithUpdate = true; + foreach (var manifest in pathToManifests.Values.Where(m => m is not null && HasModInstalled(m.UniqueID) is true && string.IsNullOrEmpty(m.UpdateCautionMessage) is false)) + { + var requestWindow = new MessageWindow(String.Format(Program.translation.Get("ui.message.confirm_mod_update_caution"), manifest!.Name, manifest!.UpdateCautionMessage)) { Topmost = true }; + if (await requestWindow.ShowDialog(this) is false) + { + Program.helper.Log($"User elected to skip mod update due to given Manifest.UpdateCautionMessage message for mod {manifest!.UniqueID}:{manifest!.UpdateCautionMessage}"); + shouldProceedWithUpdate = false; + break; + } + } + + // Skip updating if user elected to skip any of the bundled mods due to Manifest.UpdateCautionMessage + if (shouldProceedWithUpdate is false) + { + continue; + } + int currentManifestIndex = 1; bool alwaysAskToDelete = Program.settings.AlwaysAskToDelete; foreach (var manifestPath in pathToManifests.Keys) @@ -2438,6 +2457,11 @@ private async Task> AddMods(string[]? filePaths) return addedMods; } + private bool HasModInstalled(string uniqueID) + { + return _viewModel.Mods.Any(m => m.UniqueId.Equals(uniqueID, StringComparison.OrdinalIgnoreCase)); + } + private void CreateDirectoryJunctions(List arguments) { // Prepare the process diff --git a/Stardrop/i18n/default.json b/Stardrop/i18n/default.json index 788c289b..ab0fb700 100644 --- a/Stardrop/i18n/default.json +++ b/Stardrop/i18n/default.json @@ -159,10 +159,10 @@ "ui.downloads_panel.download_canceled": "Canceled", "ui.downloads_panel.download_failed": "Failed", "ui_downloads_panel.download_success": "Complete!", - "ui.downloads_panel.no_downloads_label": "No downloads in progress", + "ui.downloads_panel.no_downloads_label": "No downloads in progress", // Downloads Panel - Tooltips - "ui.downloads_panel.tooltips.cancel_button": "Cancel", + "ui.downloads_panel.tooltips.cancel_button": "Cancel", "ui.downloads_panel.tooltips.remove_button": "Remove", // Tooltip for the button that clears out a completed or failed download // Warnings @@ -228,6 +228,7 @@ "ui.message.confirm_nxm_install": "Would you like to install the following mod:\n\n{0}\n\nYou can disable this confirmation in the settings menu.", "ui.message.require_nexus_login": "This action requires being signed into the Nexus Mods API.", "ui.message.succeeded_nexus_install": "Successfully installed the following mod via Nexus Mods:\n\n{0}", + "ui.message.confirm_mod_update_caution": "{0}\nUpdate Caution Message:\n\n{1}\n\nProceed with the mod update?", // Window Names "ui.window.settings.name": "Settings",