mirror of
https://github.com/roflmuffin/CounterStrikeSharp.git
synced 2025-12-05 15:40:24 -08:00
Add CenterHtmlMenu button colors (#398)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,7 @@ public enum PostSelectAction
|
||||
public abstract class BaseMenu : IMenu
|
||||
{
|
||||
public string Title { get; set; }
|
||||
|
||||
public List<ChatMenuOption> MenuOptions { get; } = new();
|
||||
public PostSelectAction PostSelectAction { get; set; } = PostSelectAction.Reset;
|
||||
public bool ExitButton { get; set; } = true;
|
||||
|
||||
@@ -22,6 +22,12 @@ namespace CounterStrikeSharp.API.Modules.Menu;
|
||||
public class CenterHtmlMenu : BaseMenu
|
||||
{
|
||||
private readonly BasePlugin? _plugin;
|
||||
public string TitleColor { get; set; } = "yellow";
|
||||
public string EnabledColor { get; set; } = "green";
|
||||
public string DisabledColor { get; set; } = "grey";
|
||||
public string PrevPageColor { get; set; } = "yellow";
|
||||
public string NextPageColor { get; set; } = "yellow";
|
||||
public string CloseColor { get; set; } = "red";
|
||||
|
||||
public CenterHtmlMenu(string title, BasePlugin plugin) : base(ModifyTitle(title))
|
||||
{
|
||||
@@ -32,7 +38,7 @@ public class CenterHtmlMenu : BaseMenu
|
||||
public CenterHtmlMenu(string title) : base(ModifyTitle(title))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override void Open(CCSPlayerController player)
|
||||
{
|
||||
if (_plugin == null)
|
||||
@@ -96,35 +102,40 @@ public class CenterHtmlMenuInstance : BaseMenuInstance
|
||||
return;
|
||||
}
|
||||
|
||||
if (Menu is not CenterHtmlMenu centerHtmlMenu)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.Append($"<b><font color='yellow'>{Menu.Title}</font></b>");
|
||||
builder.Append($"<b><font color='{centerHtmlMenu.TitleColor}'>{centerHtmlMenu.Title}</font></b>");
|
||||
builder.AppendLine("<br>");
|
||||
|
||||
var keyOffset = 1;
|
||||
|
||||
for (var i = CurrentOffset; i < Math.Min(CurrentOffset + MenuItemsPerPage, Menu.MenuOptions.Count); i++)
|
||||
for (var i = CurrentOffset; i < Math.Min(CurrentOffset + MenuItemsPerPage, centerHtmlMenu.MenuOptions.Count); i++)
|
||||
{
|
||||
var option = Menu.MenuOptions[i];
|
||||
string color = option.Disabled ? "grey" : "green";
|
||||
var option = centerHtmlMenu.MenuOptions[i];
|
||||
string color = option.Disabled ? centerHtmlMenu.DisabledColor : centerHtmlMenu.EnabledColor;
|
||||
builder.Append($"<font color='{color}'>!{keyOffset++}</font> {option.Text}");
|
||||
builder.AppendLine("<br>");
|
||||
}
|
||||
|
||||
if (HasPrevButton)
|
||||
{
|
||||
builder.AppendFormat("<font color='yellow'>!7</font> <- Prev");
|
||||
builder.AppendFormat($"<font color='{centerHtmlMenu.PrevPageColor}'>!7</font> <- Prev");
|
||||
builder.AppendLine("<br>");
|
||||
}
|
||||
|
||||
if (HasNextButton)
|
||||
{
|
||||
builder.AppendFormat("<font color='yellow'>!8</font> -> Next");
|
||||
builder.AppendFormat($"<font color='{centerHtmlMenu.NextPageColor}'>!8</font> -> Next");
|
||||
builder.AppendLine("<br>");
|
||||
}
|
||||
|
||||
if (Menu.ExitButton)
|
||||
if (centerHtmlMenu.ExitButton)
|
||||
{
|
||||
builder.AppendFormat("<font color='red'>!9</font> -> Close");
|
||||
builder.AppendFormat($"<font color='{centerHtmlMenu.CloseColor}'>!9</font> -> Close");
|
||||
builder.AppendLine("<br>");
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,12 @@ namespace CounterStrikeSharp.API.Modules.Menu;
|
||||
|
||||
public class ChatMenu : BaseMenu
|
||||
{
|
||||
public char TitleColor { get; set; } = ChatColors.Yellow;
|
||||
public char EnabledColor { get; set; } = ChatColors.Green;
|
||||
public char DisabledColor { get; set; } = ChatColors.Grey;
|
||||
public char PrevPageColor { get; set; } = ChatColors.Yellow;
|
||||
public char NextPageColor { get; set; } = ChatColors.Yellow;
|
||||
public char CloseColor { get; set; } = ChatColors.Red;
|
||||
public ChatMenu(string title) : base(title)
|
||||
{
|
||||
ExitButton = false;
|
||||
@@ -39,30 +45,35 @@ public class ChatMenuInstance : BaseMenuInstance
|
||||
|
||||
public override void Display()
|
||||
{
|
||||
Player.PrintToChat(Menu.Title);
|
||||
if (Menu is not ChatMenu chatMenu)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player.PrintToChat($" {chatMenu.TitleColor} {chatMenu.Title}");
|
||||
Player.PrintToChat("---");
|
||||
|
||||
var keyOffset = 1;
|
||||
for (var i = CurrentOffset; i < Math.Min(CurrentOffset + MenuItemsPerPage, Menu.MenuOptions.Count); i++)
|
||||
{
|
||||
var option = Menu.MenuOptions[i];
|
||||
|
||||
Player.PrintToChat($" {(option.Disabled ? ChatColors.Grey : ChatColors.Green)} !{keyOffset++} {ChatColors.Default}{option.Text}");
|
||||
char color = option.Disabled ? chatMenu.DisabledColor : chatMenu.EnabledColor;
|
||||
Player.PrintToChat($" {color} !{keyOffset++} {ChatColors.Default}{option.Text}");
|
||||
}
|
||||
|
||||
if (HasPrevButton)
|
||||
{
|
||||
Player.PrintToChat($" {ChatColors.Yellow}!7 {ChatColors.Default}-> Prev");
|
||||
Player.PrintToChat($" {chatMenu.PrevPageColor}!7 {ChatColors.Default}-> Prev");
|
||||
}
|
||||
|
||||
if (HasNextButton)
|
||||
{
|
||||
Player.PrintToChat($" {ChatColors.Yellow}!8 {ChatColors.Default}-> Next");
|
||||
Player.PrintToChat($" {chatMenu.NextPageColor}!8 {ChatColors.Default}-> Next");
|
||||
}
|
||||
|
||||
if (Menu.ExitButton)
|
||||
{
|
||||
Player.PrintToChat($" {ChatColors.Red}!9 {ChatColors.Default}-> Close");
|
||||
Player.PrintToChat($" {chatMenu.CloseColor}!9 {ChatColors.Default}-> Close");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user