# Menu

# 说明

Menu类用于创建和管理游戏内菜单界面,提供用户交互功能。

# 如何使用

// 创建主菜单
Menu* mainMenu = Menu::Create("我的脚本");

// 添加子菜单
Menu* comboMenu = mainMenu->AddMenu("连招设置");

// 添加复选框
MenuOption* useQ = comboMenu->AddCheckBox("使用Q", true);

// 添加滑块
MenuOption* qRange = comboMenu->AddSlider("Q技能范围", 900, 500, 1200);

// 添加热键
MenuOption* comboKey = comboMenu->AddHotKey("连招按键", 0x0020); // 空格键

// 添加颜色选择器
MenuOption* drawColor = comboMenu->AddColorPick("显示颜色", true, MAKE_COLOR(255, 0, 0, 255));

// 添加分隔符
comboMenu->AddSeparator("高级设置");

// 添加选项列表
std::vector<const char*> modes = { "常规", "激进", "保守" };
MenuOption* comboMode = comboMenu->AddStringList("连招模式", 0, modes);

// 检查菜单选项值
if (useQ->GetBool() && comboKey->GetBool())
{
    // 执行使用Q技能的代码
}

int Menu::Language()

获取当前菜单的语言设置。

返回值 说明
0 英文
1 中文
int language = Menu::Language();
if (language == 1)
{
    // 中文界面相关逻辑
}

bool Menu::IsOpen()

检查菜单是否处于打开状态。

if (Menu::IsOpen())
{
    // 菜单打开时的逻辑
}

void Menu::AddTranslate(const char* englishText, const char8_t* ChineseText)

添加文本的中英文翻译。

参数名 参数类型 描述
englishText const char* 英文文本
ChineseText const char8_t* 中文文本
Menu::AddTranslate("Use Q", u8"使用Q");

static Menu* Menu::Create(const char* Title)

创建一个新的菜单。

参数名 参数类型 描述
Title const char* 菜单标题
Menu* mainMenu = Menu::Create("我的脚本");

Menu* Menu::AddMenu(const char* Title)

添加一个子菜单。

参数名 参数类型 描述
Title const char* 子菜单标题
Menu* comboMenu = mainMenu->AddMenu("连招设置");

MenuOption* Menu::AddCheckBox(const char* Name, bool Boolean)

添加一个复选框选项。

参数名 参数类型 描述
Name const char* 选项名称
Boolean bool 默认值
MenuOption* useQ = comboMenu->AddCheckBox("使用Q", true);

MenuOption* Menu::AddSlider(const char* Name, int Value, int MinValue, int MaxValue)

添加一个滑块选项。

参数名 参数类型 描述
Name const char* 选项名称
Value int 默认值
MinValue int 最小值
MaxValue int 最大值
MenuOption* qRange = comboMenu->AddSlider("Q技能范围", 900, 500, 1200);

MenuOption* Menu::AddHotKey(const char* Name, int DefaultKey)

添加一个热键选项。

参数名 参数类型 描述
Name const char* 选项名称
DefaultKey int 默认按键
MenuOption* comboKey = comboMenu->AddHotKey("连招按键", 0x0020); // 空格键

MenuOption* Menu::AddToggleKey(const char* Name, int DefaultKey, bool Boolean)

添加一个开关键选项。

参数名 参数类型 描述
Name const char* 选项名称
DefaultKey int 默认按键
Boolean bool 默认开关状态
MenuOption* farmToggle = comboMenu->AddToggleKey("清线模式", 0x0057, true); // W键

MenuOption* Menu::AddStringList(const char* Name, int DefaultIdx, std::vector<const char*> const& Elements)

添加一个字符串列表选项。

参数名 参数类型 描述
Name const char* 选项名称
DefaultIdx int 默认选中索引
Elements std::vector<const char*> const& 列表元素
std::vector<const char*> modes = { "常规", "激进", "保守" };
MenuOption* comboMode = comboMenu->AddStringList("连招模式", 0, modes);

MenuOption* Menu::AddColorPick(const char* Name, bool Boolean, int DefaultColor)

添加一个颜色选择器选项。

参数名 参数类型 描述
Name const char* 选项名称
Boolean bool 默认开关状态
DefaultColor int 默认颜色
MenuOption* drawColor = comboMenu->AddColorPick("显示颜色", true, MAKE_COLOR(255, 0, 0, 255));

void Menu::AddSeparator(const char* Txt = nullptr, int color = 0xFFFFFFFF)

添加一个分隔符。

参数名 参数类型 描述
Txt const char* 分隔符文本(可选)
color int 文本颜色(可选)
comboMenu->AddSeparator("高级设置");