diff --git a/src/SharpModMenu/PlayerMenuState.cs b/src/SharpModMenu/PlayerMenuState.cs
index fd2759d..f025b40 100644
--- a/src/SharpModMenu/PlayerMenuState.cs
+++ b/src/SharpModMenu/PlayerMenuState.cs
@@ -142,7 +142,15 @@ private bool MenuActive
if (value)
Driver.ActiveMenuStates.Add(this);
else
+ {
Driver.ActiveMenuStates.Remove(this);
+ if (ShowingHtmlContent)
+ {
+ ShowingHtmlContent = false;
+ Player.PrintToCenterHtml(HtmlContent ?? "", 0);
+ HtmlContent = null;
+ }
+ }
}
}
@@ -609,13 +617,17 @@ private void BuildMenuStrings(Menu currentMenu, Action(OnTick);
RegisterListener(OnCheckTransmit);
+ RegisterListener(OnMapStartHandler);
}
public override void Unload(bool hotReload)
@@ -67,8 +70,28 @@ public override void Unload(bool hotReload)
ProcessUserCmdsFunc?.Unhook(ProcessUserCmds, HookMode.Pre);
}
+ // thanks to Deana for this snippet
+ private CCSGameRules? GameRulesEnt { get; set; }
+ private bool LoadedGameRules { get; set; }
+
+ private void OnMapStartHandler(string map)
+ {
+ GameRulesEnt = null;
+ LoadedGameRules = false;
+ }
+
private void OnTick()
{
+ if (!LoadedGameRules)
+ {
+ LoadedGameRules = true;
+ GameRulesEnt = Utilities.FindAllEntitiesByDesignerName("cs_gamerules").FirstOrDefault()?.GameRules;
+ }
+ else if (GameRulesEnt is not null)
+ {
+ GameRulesEnt.GameRestart = GameRulesEnt.RestartRoundTime < Server.CurrentTime;
+ }
+
if (UseFallbackWasdInputMethod)
{
for (int i = 0; i < DriverInstance!.ActiveMenuStates.Count; i++)