Skip to content

Commit

Permalink
Promt for restart on changing generic mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Safairette committed Dec 22, 2024
1 parent 7f60142 commit e89c5fd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Languages/English/Keyed/ModMenu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,10 @@
<CE_Settings_PawnkindAutopatcher_Title>Enable pawnkind autopatcher</CE_Settings_PawnkindAutopatcher_Title>
<CE_Settings_PawnkindAutopatcher_Desc>Give unpatched pawnkinds equipped with a patched ranged weapon a small amount of ammunition.</CE_Settings_PawnkindAutopatcher_Desc>

<!-- ========== Pop-up window ========== -->

<CE_Settings_GenericRestartPopup>Changing the generic ammo mode requires a full restart to apply.\n\nWould you like to restart now?</CE_Settings_GenericRestartPopup>
<CE_Settings_AcceptRestart>Restart now</CE_Settings_AcceptRestart>
<CE_Settings_DeclineRestart>Continue</CE_Settings_DeclineRestart>
<CE_Settings_RestartTitle>Generic ammo setting has changed</CE_Settings_RestartTitle>
</LanguageData>
24 changes: 22 additions & 2 deletions Source/CombatExtended/CombatExtended/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -91,7 +92,6 @@ public void PostLoad()
}

modPart.PostLoad(content, settings);

}

// Initialize loadout generator
Expand All @@ -115,14 +115,34 @@ public void PostLoad()
}

LongEventHandler.QueueLongEvent(patches.Install, "CE_LongEvent_CompatibilityPatches", false, null);


genericState = settings.GenericAmmo;
}

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(() =>
Expand Down

0 comments on commit e89c5fd

Please sign in to comment.