Skip to content

Commit ce9fbd6

Browse files
committed
Implemented custom Manifest property UpdateCautionMessage
Relates to #299.
1 parent e0ba94c commit ce9fbd6

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Stardrop/Models/SMAPI/Manifest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ public class Manifest
3636

3737
/// <summary>Custom property for Stardrop.</summary>
3838
public bool DeleteOldVersion { get; set; }
39+
40+
/// <summary>Custom property for Stardrop.</summary>
41+
public string? UpdateCautionMessage { get; set; }
3942
}
4043
}

Stardrop/Views/MainWindow.axaml.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,6 +2260,25 @@ private async Task<List<Mod>> AddMods(string[]? filePaths)
22602260
continue;
22612261
}
22622262

2263+
// 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)
2264+
bool shouldProceedWithUpdate = true;
2265+
foreach (var manifest in pathToManifests.Values.Where(m => m is not null && HasModInstalled(m.UniqueID) is true && string.IsNullOrEmpty(m.UpdateCautionMessage) is false))
2266+
{
2267+
var requestWindow = new MessageWindow(String.Format(Program.translation.Get("ui.message.confirm_mod_update_caution"), manifest!.Name, manifest!.UpdateCautionMessage)) { Topmost = true };
2268+
if (await requestWindow.ShowDialog<bool>(this) is false)
2269+
{
2270+
Program.helper.Log($"User elected to skip mod update due to given Manifest.UpdateCautionMessage message for mod {manifest!.UniqueID}:{manifest!.UpdateCautionMessage}");
2271+
shouldProceedWithUpdate = false;
2272+
break;
2273+
}
2274+
}
2275+
2276+
// Skip updating if user elected to skip any of the bundled mods due to Manifest.UpdateCautionMessage
2277+
if (shouldProceedWithUpdate is false)
2278+
{
2279+
continue;
2280+
}
2281+
22632282
int currentManifestIndex = 1;
22642283
bool alwaysAskToDelete = Program.settings.AlwaysAskToDelete;
22652284
foreach (var manifestPath in pathToManifests.Keys)
@@ -2438,6 +2457,11 @@ private async Task<List<Mod>> AddMods(string[]? filePaths)
24382457
return addedMods;
24392458
}
24402459

2460+
private bool HasModInstalled(string uniqueID)
2461+
{
2462+
return _viewModel.Mods.Any(m => m.UniqueId.Equals(uniqueID, StringComparison.OrdinalIgnoreCase));
2463+
}
2464+
24412465
private void CreateDirectoryJunctions(List<string> arguments)
24422466
{
24432467
// Prepare the process

Stardrop/i18n/default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@
228228
"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.",
229229
"ui.message.require_nexus_login": "This action requires being signed into the Nexus Mods API.",
230230
"ui.message.succeeded_nexus_install": "Successfully installed the following mod via Nexus Mods:\n\n{0}",
231+
"ui.message.confirm_mod_update_caution": "{0}\nUpdate Caution Message:\n\n{1}\n\nProceed with the mod update?",
231232

232233
// Window Names
233234
"ui.window.settings.name": "Settings",

0 commit comments

Comments
 (0)