Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promt for restart on changing generic mode #3605

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>Toggling 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>
22 changes: 21 additions & 1 deletion 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 @@ -116,13 +116,33 @@ 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
Loading