mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 06:14:08 +08:00
Added UI class and UI rendering class
This commit is contained in:
43
src/ui/managers/GameUIManager.cpp
Normal file
43
src/ui/managers/GameUIManager.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "GameUIManager.h"
|
||||
|
||||
GameUIManager::GameUIManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GameUIManager::~GameUIManager() {
|
||||
|
||||
}
|
||||
|
||||
void GameUIManager::init() {
|
||||
auto button = std::make_unique<Button>();
|
||||
button->setBackgroundColor({255, 100, 0, 255});
|
||||
button->setBorder(2, {0, 0, 0, 255});
|
||||
button->setPosition(20, 20);
|
||||
button->setEnabled(true);
|
||||
button->setVisible(true);
|
||||
button->setText("hello,world!!", {"SourceHanSansSC-Regular.otf", 48, {0, 0, 0, 255}});
|
||||
m_buttons.push_back(std::move(button));
|
||||
}
|
||||
|
||||
|
||||
|
||||
const UIRenderData& GameUIManager::getUIRenderData() {
|
||||
CollectRenderData();
|
||||
return m_uiRenderData;
|
||||
}
|
||||
|
||||
void GameUIManager::CollectRenderData() {
|
||||
|
||||
//SDL_Log("CollectRenderData called. buttons count = %zu", m_buttons.size());
|
||||
// 清理上一帧的数据
|
||||
m_uiRenderData.buttons.clear();
|
||||
//SDL_Log("collect data\n");
|
||||
for (auto& button : m_buttons) {
|
||||
if(!button->isVisible()) {
|
||||
continue;
|
||||
|
||||
}
|
||||
m_uiRenderData.buttons.push_back(button->getButtonDate());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user