mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 06:14:08 +08:00
Render the Actiontype
This commit is contained in:
@@ -17,9 +17,10 @@ void GameUIManager::init() {
|
||||
button->setPosition(20, 20);
|
||||
button->setEnabled(true);
|
||||
button->setVisible(true);
|
||||
button->setText("hello,world!!", {"SourceHanSansSC-Regular.otf", 48, {0, 0, 0, 255}});
|
||||
button->setName("TestButton");
|
||||
button->setText("Please Choose", {"SourceHanSansSC-Regular.otf", 48, {0, 0, 0, 255}});
|
||||
button->setName("ActionButton");
|
||||
m_buttons.emplace(button->getNameHash(), std::move(button));
|
||||
|
||||
auto label = std::make_unique<Label>();
|
||||
label->setPosition(1200, 20);
|
||||
label->setText("0 0", {"SourceHanSansSC-Regular.otf", 48, {0, 0, 0, 255}});
|
||||
@@ -67,3 +68,28 @@ void GameUIManager::UpdateMousePositon(float x, float y) {
|
||||
|
||||
m_labels[makeHash("MousePositionLabel")]->setText(pos);
|
||||
}
|
||||
|
||||
void GameUIManager::updateActionType(ActionType type) {
|
||||
// 根据传入的 ActionType 更新 UI 组件状态
|
||||
auto buttonIt = m_buttons.find(makeHash("ActionButton"));
|
||||
if (buttonIt != m_buttons.end()) {
|
||||
auto& button = buttonIt->second;
|
||||
switch (type) {
|
||||
case ActionType::GROW:
|
||||
button->setBackgroundColor({255, 100, 0, 255}); // 橙色
|
||||
button->setText("GROW");
|
||||
break;
|
||||
case ActionType::MOVE:
|
||||
button->setBackgroundColor({0, 255, 0, 255}); // 绿色
|
||||
button->setText("MOVE");
|
||||
break;
|
||||
case ActionType::SPORE:
|
||||
button->setBackgroundColor({0, 0, 255, 255}); // 蓝色
|
||||
button->setText("SPORE");
|
||||
break;
|
||||
default:
|
||||
button->setBackgroundColor({255, 100, 0, 255}); // 默认橙色
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user