Skip to content
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
12 changes: 12 additions & 0 deletions src/SharpModMenu/PlayerMenuState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,15 @@
if (value)
Driver.ActiveMenuStates.Add(this);
else
{
Driver.ActiveMenuStates.Remove(this);
if (ShowingHtmlContent)
{
ShowingHtmlContent = false;
Player.PrintToCenterHtml(HtmlContent ?? "<font></font>", 0);
HtmlContent = null;
}
}
}
}

Expand Down Expand Up @@ -242,7 +250,7 @@
private bool CreateInitialInvisibleWorldTextEntity()
{
return false;
var observerInfo = Player.GetObserverInfo();

Check warning on line 253 in src/SharpModMenu/PlayerMenuState.cs

View workflow job for this annotation

GitHub Actions / Continuous integration

Unreachable code detected

if (_CreatedFor.HasValue && _CreatedFor.Value == observerInfo.Observing?.Handle)
return false;
Expand Down Expand Up @@ -363,7 +371,7 @@
{
return false; // nothing to parent to right now, further work needed

if (ReferenceEquals(CurrentMenu, LastPresented))

Check warning on line 374 in src/SharpModMenu/PlayerMenuState.cs

View workflow job for this annotation

GitHub Actions / Continuous integration

Unreachable code detected
{
if (CurrentMenu is not null && !CurrentMenu.IsDirty)
return true;
Expand Down Expand Up @@ -609,13 +617,17 @@
}

public bool ForceRefresh = true;
public bool ShowingHtmlContent;
public void Tick()
{
if (CurrentMenu is null)
return;

if (PresentingHtml && HtmlContent is not null)
{
ShowingHtmlContent = true;
Player.PrintToCenterHtml(HtmlContent);
}

var observerInfo = Player.GetObserverInfo();

Expand Down
23 changes: 23 additions & 0 deletions src/SharpModMenu/SharpModMenu.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

Expand All @@ -13,6 +14,7 @@
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;

using CSSUniversalMenuAPI;

using static CounterStrikeSharp.API.Core.Listeners;

namespace SharpModMenu;
Expand Down Expand Up @@ -58,6 +60,7 @@

RegisterListener<OnTick>(OnTick);
RegisterListener<CheckTransmit>(OnCheckTransmit);
RegisterListener<OnMapStart>(OnMapStartHandler);
}

public override void Unload(bool hotReload)
Expand All @@ -67,8 +70,28 @@
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<CCSGameRulesProxy>("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++)
Expand Down Expand Up @@ -349,7 +372,7 @@

if (false)
{
var sb = new StringBuilder();

Check warning on line 375 in src/SharpModMenu/SharpModMenu.cs

View workflow job for this annotation

GitHub Actions / Continuous integration

Unreachable code detected
for (int n = 0; n < span.Length; n++)
{
if (n % 16 == 0)
Expand Down
Loading