public class CenterHtmlMenu : BaseMenu { private readonly BasePlugin? plugin; public…
- User
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)) { _plugin = plugin; } [Obsolete("Use the constructor that takes a BasePlugin")] public CenterHtmlMenu(string title) : base(ModifyTitle(title)) { } public override void Open(CCSPlayerController player) { if (_plugin == null) { 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); 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 CenterHtml : CenterHtmlMenu { private readonly BasePlugin _plugin; public CenterHtml(string title, BasePlugin plugin) : base(title, plugin) { _plugin = plugin; } public override ChatMenuOption AddMenuOption(string display, Action<CCSPlayerController, ChatMenuOption> onSelect, bool disabled = false) { var option = new ChatMenuOption(display, disabled, onSelect); MenuOptions.Add(option); return option; } public override void Open(CCSPlayerController player) { if (_plugin == null) { throw new InvalidOperationException("This method is unsupported with the CenterHtmlMenu constructor used." + "Please provide a BasePlugin in the constructor."); }; MenuManager.OpenCenterHtmlMenu(_plugin, player, this); } }1 меню это оригнальное, которое находится в другой ДЛЛ, но мне не нужен modify title как мне сделать чтобы он был без modify title? я не могу изменить в той ДЛЛ
- Assistant
- User
Method 'ModifyTitle' is never used Method 'ModifyOptionDisplay' is never used
- Assistant
Если ваши новые методы
ModifyTitleиModifyOptionDisplayне используются, это происходит потому, что компилятор не видит вызовов для них после того, как вы переопределили или скопировали их в своем коде. Поскольку в вашем примере они не используются, вот что можно сделать: