Files
dl_old/project/dl_test/ui_game.cpp
T
2025-05-26 18:57:58 +08:00

70 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "ui_game.h"
#include "game_sudo.h"
UIGame::UIGame()
{
UI::Panel* panel = CreatePanel("root");
panel->SetPosScale({ 0.0f, 0.0f });
panel->SetPosPixel(POS_CONTENT);
UI::Panel* panel_menu = g_ui->CreatePanel();
panel_menu->SetLocator(createLocatorX(200));
g_ui->SetPanelParent(panel_menu, panel);
{
UI::ListBox* lst = g_ui->CreateListBoxDefault(true);
lst->SetItemCallback([](UI::Panel* item, Value v) {
if (v)
item->ExSetString(v.ToString());
else
item->ExSetString({});
});
_allGame.push_back("数独");
_allGame.push_back("贪吃蛇(TODO)");
lst->SetItemData(_allGame);
panel_menu->Add(lst);
_edt = lst;
}
{
UI::Text* txt = g_ui->CreateTextDefault();
txt->SetElementData(Align::LT);
txt->GetText()->SetMaxW(400);
panel_menu->Add(txt);
_txtInfo = txt;
}
}
void UIGame::Update()
{
if (_edt->IsSelectChange())
{
Value name = _edt->GetSelect();
if (name)
{
if (name.ToString() == "数独")
{
_txtInfo->SetString("数独游戏,双击进入。\n操作说明:按1-9选择数字,按~取消选择。");
}
else if (name.ToString() == "贪吃蛇(TODO)")
{
_txtInfo->SetString("贪吃蛇(未实现)。");
}
else
_txtInfo->SetString("");
}
}
Value enter = _edt->GetSelectClickDouble();
if (enter)
{
if (enter.ToString() == "数独")
{
g_scene->Del("child");
g_scene->Del("main");
g_scene->Add("game", new GameSudo);
}
}
}