CS2-菜单 游戏性拓展 通用内容 服务器管理

xiewangzhenyan 一级用户组 3月前 1018

菜单

CS2 - 交互中心“HTML”菜单

首先,我们需要将.dll导入到 .csproj 中

<ItemGroup>
  <Reference Include="Menu">
    <HintPath>path\to\Menu.dll</HintPath>
  </Reference>
</ItemGroup>
警告

确保 delete from,因为该库可从 Releases 中使用Menu.dllyourPlugin.dll/shared/Menu/Menu.dll

接下来,我们必须创建一个新的 Menu 对象

using Menu;
using Menu.Enums;

public class Plugin : BasePlugin
{
    public Menu.Menu Menu { get; } = new();
}

现在我们可以有一个入口点,例如 Command

public class Plugin : BasePlugin
{
    public Menu.Menu Menu { get; } = new();

    public override void Load(bool isReload)
    {
        AddCommand("css_test", "", (controller, _) =>
        {
            if (controller == null || !controller.IsValid)
                return;
    
            BuildMenu(controller);
        }
    }
}

 


private void BuildMenu(CCSPlayerController controller)
{
    // Create a Menu object which holds all data
    var mainMenu = new MenuBase(new MenuValue("Main Menu") { Prefix = "<font class=\"fontSize-L\">", Suffix = "<font class=\"fontSize-sm\">" });

    // Can add custom formatting, MenuValue[2] Cursor, MenuValue[2] Selector, MenuValue[2] Bool, MenuValue[4] Slider, MenuValue[1] Input
    var cursor = new MenuValue[2]
    {
        // MenuValue is the fundamental building block of everything in the Menu - MenuValue.Value, MenuValue.Prefix, MenuValue.Suffix
        new("--> ") { Prefix = "<font color=\"#FFFFFF\">", Suffix = "<font color=\"#FFFFFF\">" },
        new(" <--") { Prefix = "<font color=\"#FFFFFF\">", Suffix = "<font color=\"#FFFFFF\">" }
    };
    
    mainMenu.Cursor = cursor;

    // Let's add a simple text field to the menu, each (row) is a MenuItem which holds data for that (row)
    // Again MenuValue is the fundamental building block of everything in the Menu - MenuValue.Value, MenuValue.Prefix, MenuValue.Suffix

    var textItem = new MenuValue("Welcome to the new menu!");

    // Let's modify the prefix and suffix of the textItem

    textItem.Prefix = "<font color=\"#FF0000\">";
    textItem.Suffix = "<font color=\"#FFFFFF\">";

    // Simplified

    textItem = new MenuValue("Welcome to the new menu!")
    {
        Prefix = "<font color=\"#FF0000\">",
        Suffix = "<font color=\"#FFFFFF\">"
    };

    var simpleTextItem = new MenuItem(MenuItemType.Text, textItem);

    // Now let's add the textItem to the menu
    mainMenu.AddItem(simpleTextItem);

    // And let's add to the global stack to print to the player
    Menu.SetMenu(controller, mainMenu, (buttons, menu, item) => { });

    // If you want to create a sub-menu use the following, this nests the menu ontop of the current menu if there's any, otherwise it follows the same logic as SetMenu
    Menu.AddMenu(controller, mainMenu, (buttons, menu, item) => { });

    // The library automatically handles the deposition of the menu
    // Using Tab (Scoreboard) exists the menu, and Ctrl (Duck) will go back to the previous menu
}

 

上传的附件:

CSGO插件分享-申明 1、本网站名称:CSGO插件分享-中文站  网址:https://bbs.csgocn.net
2、本站的宗旨在于为CSGO玩家提供一个插件分享的中文资源平台,多数插件来源于SourceMod论坛,并配以中文介绍和安装教程。
3、欢迎有能力的朋友共享有趣的CSGO插件资源。
4、本站资源大多为百度网盘,如发现链接失效,可以点: 这里进行反馈,我们会第一时间更新。
最新回复 (10)
返回