Added SceneEvent callback

This commit is contained in:
2025-12-13 16:07:22 +08:00
parent 18953d8124
commit 6f5c378cb0
5 changed files with 398 additions and 31 deletions

35
src/ui/base/IUIManager.h Normal file
View File

@@ -0,0 +1,35 @@
#pragma once
#include <SDL3/SDL.h>
#include <SDL3_ttf/SDL_ttf.h>
#include "ui/components/Button.h"
#include "ui/components/Label.h"
#include "ui/base/UIRenderData.h"
#include <memory>
#include <vector>
#include <unordered_map>
class IUIManager {
public:
virtual ~IUIManager() = default;
virtual void init() = 0;
virtual const UIRenderData& getUIRenderData() = 0;
// 收集渲染数据
virtual void CollectRenderData() = 0;
virtual void UpdateMousePositon(float x, float y) = 0;
protected:
std::unordered_map<int, std::unique_ptr<Button>> m_buttons;
std::unordered_map<int, std::unique_ptr<Label>> m_labels;
UIRenderData m_uiRenderData;
SDL_Renderer* m_renderer = nullptr;
TextRenderer* m_textRenderer = nullptr;
size_t makeHash(const std::string& name) {
return std::hash<std::string>{}(name);
}
};