Closed WidovV closed 4 months ago
The title color could also be added to a overloaded ctor
Happy with this PR & it looks fully backwards compatible. Are you ready for merge @WidovV?
@roflmuffin Hold up ima make a small Update to it :D
I added colors to the chat menu also.
Plugin:
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.Menu;
using CounterStrikeSharp.API.Modules.Utils;
namespace MenuTester;
public class MenuTest : BasePlugin
{
public override string ModuleName => "Menu test";
public override string ModuleVersion => "NaN";
public override string ModuleAuthor => "WidovV";
public override string ModuleDescription => "Testing menu colors";
[ConsoleCommand("css_centermenu")]
public void MenuTesting(CCSPlayerController player, CommandInfo info)
{
if (!player.IsValid)
return;
CenterHtmlMenu menu = new CenterHtmlMenu("Test menu!", this);
menu.TitleColor = "red";
menu.EnabledColor = "#b891e6";
menu.DisabledColor = "#262626";
menu.NextPageColor = "#2a977f";
menu.PrevPageColor = "#365df8";
menu.CloseColor = "#ffe3b7";
menu.AddMenuOption("Option 1", (_, _) => PrintMessageToPlayer(player, "option 1"));
menu.AddMenuOption("Option 2", (_, _) => PrintMessageToPlayer(player, "option 2"), true);
menu.AddMenuOption("Option 3", (_, _) => PrintMessageToPlayer(player, "option 3"));
menu.AddMenuOption("Option 4", (_, _) => PrintMessageToPlayer(player, "option 4"), true);
menu.AddMenuOption("Option 5", (_, _) => PrintMessageToPlayer(player, "option 5"));
menu.AddMenuOption("Option 6", (_, _) => PrintMessageToPlayer(player, "option 6"), true);
menu.AddMenuOption("Option 7", (_, _) => PrintMessageToPlayer(player, "option 7"));
menu.AddMenuOption("Option 8", (_, _) => PrintMessageToPlayer(player, "option 8"), true);
menu.AddMenuOption("Option 9", (_, _) => PrintMessageToPlayer(player, "option 9"));
menu.AddMenuOption("Option 10", (_, _) => PrintMessageToPlayer(player, "option 10"), true);
menu.AddMenuOption("Option 11", (_, _) => PrintMessageToPlayer(player, "option 11"));
menu.AddMenuOption("Option 12", (_, _) => PrintMessageToPlayer(player, "option 12"), true);
menu.AddMenuOption("Option 13", (_, _) => PrintMessageToPlayer(player, "option 13"));
menu.Open(player);
}
[ConsoleCommand("css_chatmenu")]
public void ChatMenuTesting(CCSPlayerController player, CommandInfo info)
{
if (!player.IsValid)
return;
ChatMenu chatMenu = new ChatMenu("Test chat menu!");
chatMenu.TitleColor = ChatColors.Magenta;
chatMenu.EnabledColor = ChatColors.Blue;
chatMenu.DisabledColor = ChatColors.Orange;
chatMenu.NextPageColor = ChatColors.Green;
chatMenu.PrevPageColor = ChatColors.White;
chatMenu.CloseColor = ChatColors.Magenta;
chatMenu.ExitButton = true;
chatMenu.AddMenuOption("Option 1", (_, _) => PrintMessageToPlayer(player, "option 1"));
chatMenu.AddMenuOption("Option 2", (_, _) => PrintMessageToPlayer(player, "option 2"), true);
chatMenu.AddMenuOption("Option 3", (_, _) => PrintMessageToPlayer(player, "option 3"));
chatMenu.AddMenuOption("Option 4", (_, _) => PrintMessageToPlayer(player, "option 4"), true);
chatMenu.AddMenuOption("Option 5", (_, _) => PrintMessageToPlayer(player, "option 5"));
chatMenu.AddMenuOption("Option 6", (_, _) => PrintMessageToPlayer(player, "option 6"), true);
chatMenu.AddMenuOption("Option 7", (_, _) => PrintMessageToPlayer(player, "option 7"));
chatMenu.AddMenuOption("Option 8", (_, _) => PrintMessageToPlayer(player, "option 8"), true);
chatMenu.AddMenuOption("Option 9", (_, _) => PrintMessageToPlayer(player, "option 9"));
chatMenu.AddMenuOption("Option 10", (_, _) => PrintMessageToPlayer(player, "option 10"), true);
chatMenu.AddMenuOption("Option 11", (_, _) => PrintMessageToPlayer(player, "option 11"));
chatMenu.AddMenuOption("Option 12", (_, _) => PrintMessageToPlayer(player, "option 12"), true);
chatMenu.AddMenuOption("Option 13", (_, _) => PrintMessageToPlayer(player, "option 13"));
chatMenu.Open(player);
}
private void PrintMessageToPlayer(CCSPlayerController player, string message)
{
MenuManager.CloseActiveMenu(player);
player.PrintToChat($"echo {message}");
}
}
I'm not sure if there should be any kind of string checks, as an example adding the '#' to the string-values in CenterHtmlMenus if it's missing etc.
Otherwise I'm ready for merge
I'm not sure if there should be any kind of string checks, as an example adding the '#' to the string-values in CenterHtmlMenus if it's missing etc.
I guess it's up to the plugin developer to check this IMO, good job
This pull request is only for allowing each developer to change the color of the title, enabled, disabled, previous page, next page and close color options in the centerhtmlmenu. Since ChatMenu and perhaps ConsoleMenu colors is restricted to the Colors class, a seperate and closed functionality to change these colors in the Center menu therefore it's not added into the IMenu interface. I haven't digged deeper into better solutions nor any safeguards, but I'll gladly work further on it.
Test plugin: