From e89c5fdd994c35817de53503ea686390c5926051 Mon Sep 17 00:00:00 2001 From: Safairette <71556532+Safairette@users.noreply.github.com> Date: Sun, 22 Dec 2024 18:36:59 +0200 Subject: [PATCH] Promt for restart on changing generic mode --- Languages/English/Keyed/ModMenu.xml | 6 +++++ .../CombatExtended/Controller.cs | 24 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Languages/English/Keyed/ModMenu.xml b/Languages/English/Keyed/ModMenu.xml index 26db44cef2..ba462b30bc 100644 --- a/Languages/English/Keyed/ModMenu.xml +++ b/Languages/English/Keyed/ModMenu.xml @@ -125,4 +125,10 @@ Enable pawnkind autopatcher Give unpatched pawnkinds equipped with a patched ranged weapon a small amount of ammunition. + + + Changing the generic ammo mode requires a full restart to apply.\n\nWould you like to restart now? + Restart now + Continue + Generic ammo setting has changed \ No newline at end of file diff --git a/Source/CombatExtended/CombatExtended/Controller.cs b/Source/CombatExtended/CombatExtended/Controller.cs index ab2295ccef..f1d358d02a 100644 --- a/Source/CombatExtended/CombatExtended/Controller.cs +++ b/Source/CombatExtended/CombatExtended/Controller.cs @@ -24,6 +24,7 @@ public class Controller : Mod public static Settings settings; public static Controller instance; public static ModContentPack content; + private static bool genericState; private static Patches patches; private Vector2 scrollPosition; @@ -91,7 +92,6 @@ public void PostLoad() } modPart.PostLoad(content, settings); - } // Initialize loadout generator @@ -115,7 +115,8 @@ public void PostLoad() } LongEventHandler.QueueLongEvent(patches.Install, "CE_LongEvent_CompatibilityPatches", false, null); - + + genericState = settings.GenericAmmo; } public override string SettingsCategory() @@ -123,6 +124,25 @@ public override string SettingsCategory() return "Combat Extended"; } + public override void WriteSettings() + { + base.WriteSettings(); + if (settings.GenericAmmo != genericState) + { + GenericRestartPopup(); + } + } + + private static void GenericRestartPopup() + { + var acceptAction = new Action(() => + { + GenCommandLine.Restart(); + }); + var dialog = new Dialog_MessageBox("CE_Settings_GenericRestartPopup".Translate(), "CE_Settings_AcceptRestart".Translate(), acceptAction, "CE_Settings_DeclineRestart".Translate(), null, "CE_Settings_RestartTitle".Translate(), true); + Find.WindowStack.Add(dialog); + } + private static void DoTutorialPopup() { var enableAction = new Action(() =>