Skip to content

Commit

Permalink
fix: remove characters limit for centerhtmlmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
samyycX committed Jan 22, 2025
1 parent 0f71e1a commit 3d87eec
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions managed/CounterStrikeSharp.API/Modules/Menu/CenterHtmlMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public class CenterHtmlMenu : BaseMenu
public string NextPageColor { get; set; } = "yellow";
public string CloseColor { get; set; } = "red";

public CenterHtmlMenu(string title, BasePlugin plugin) : base(ModifyTitle(title))
public CenterHtmlMenu(string title, BasePlugin plugin) : base(title)
{
_plugin = plugin;
}

[Obsolete("Use the constructor that takes a BasePlugin")]
public CenterHtmlMenu(string title) : base(ModifyTitle(title))
public CenterHtmlMenu(string title) : base(title)
{
}

Expand All @@ -45,40 +45,19 @@ public override void Open(CCSPlayerController player)
{
throw new InvalidOperationException("This method is unsupported with the CenterHtmlMenu constructor used." +
"Please provide a BasePlugin in the constructor.");
};

}
;

MenuManager.OpenCenterHtmlMenu(_plugin, player, this);
}

public override ChatMenuOption AddMenuOption(string display, Action<CCSPlayerController, ChatMenuOption> onSelect,
bool disabled = false)
{
var option = new ChatMenuOption(ModifyOptionDisplay(display), disabled, onSelect);
var option = new ChatMenuOption(display, disabled, onSelect);
MenuOptions.Add(option);
return option;
}

private static string ModifyTitle(string title)
{
if (title.Length > 32)
{
Application.Instance.Logger.LogWarning("Title should not be longer than 32 characters for a CenterHtmlMenu");
return title[..32];
}

return title;
}

private static string ModifyOptionDisplay(string display)
{
if (display.Length > 26)
{
Application.Instance.Logger.LogWarning("Display should not be longer than 26 characters for a CenterHtmlMenu item");
return display[..26];
}

return display;
}
}

public class CenterHtmlMenuInstance : BaseMenuInstance
Expand Down

0 comments on commit 3d87eec

Please sign in to comment.