载入中...
搜索中...
未找到
UISystem.h
浏览该文件的文档.
1#pragma once
2
3#include "ui/UIHost.h"
4
5#include <string>
6#include <vector>
7
8namespace eve::graphics {
9class Canvas;
10}
11
12namespace eve::ui {
13class UIBackend;
14}
15
16namespace eve::ui {
17
18struct UIEvent {
19 UIHost *host = nullptr;
20 std::string hostName;
21 std::string nodeId;
22 std::string kind; // "click" | "toggle" | "value" | "text"
23 uint32_t handlerIndex = 0;
24 bool toggleValue = false;
25 float floatValue = 0.f;
26 std::string textValue;
27};
28
30struct UIClick {
31 std::string hostName;
32 std::string nodeId;
33};
34
36struct UIChange {
37 std::string hostName;
38 std::string nodeId;
39 std::string kind;
40};
41
43struct UIStats {
44 int hostCount = 0;
45 int nodeCount = 0;
46 double measureMs = 0.0;
47 double walkMs = 0.0;
48};
49
56 std::string key; // "hostName/nodeId"
58 uint64_t textureId = 0; // registered via UIBackend::registerTexture
59 int width = 0;
60 int height = 0;
61 bool hovered = false;
62 bool active = false; // mouse button held inside the viewport
63 float mouseX = 0.f; // widget-local
64 float mouseY = 0.f;
65 float dragDX = 0.f;
66 float dragDY = 0.f;
67 float wheel = 0.f;
68};
69
70class UISystem {
71public:
73 static void setBackend(UIBackend *backend);
74 static UIBackend *backend();
75 static const UIStats &stats();
77 static ViewportState *viewportState(const std::string &hostName, const std::string &nodeId);
79 static ViewportState *ensureViewport(const std::string &key, int w, int h);
80
82 static void render();
83
84 static std::vector<UIEvent> &pendingEvents();
85 static void dispatchEvents();
86
88 static UIHost *findHost(const std::string &name);
90 static UIHost *findHostByOwner(uint32_t ownerId);
91
92 static std::vector<UIClick> &clickQueue();
93 static std::vector<UIChange> &changeQueue();
95 static std::string consumeClick();
97 static std::string consumeClickFor(const std::string &hostName);
99 static std::string consumeChange();
100};
101
102} // namespace eve::ui
int h
int w
const char * name
Definition RockMesh.cpp:21
Platform / renderer backend for declarative UI. Concrete implementations live under ui/<backend>/ (e....
Definition UIBackend.h:18
ECS mount point for one UI panel/screen. Subclass to attach UI to game entities, e....
Definition UIHost.h:130
static ViewportState * ensureViewport(const std::string &key, int w, int h)
Definition UISystem.cpp:538
static UIBackend * backend()
Definition UISystem.cpp:535
static const UIStats & stats()
Definition UISystem.cpp:536
static std::vector< UIClick > & clickQueue()
Definition UISystem.cpp:531
static void setBackend(UIBackend *backend)
Definition UISystem.cpp:534
static std::string consumeChange()
Pop next change as "name/node"; empty if none.
Definition UISystem.cpp:696
static std::vector< UIChange > & changeQueue()
Definition UISystem.cpp:532
static UIHost * findHost(const std::string &name)
Lookup by Meta.name across the UIHost View.
Definition UISystem.cpp:561
static void dispatchEvents()
Definition UISystem.cpp:628
static UIHost * findHostByOwner(uint32_t ownerId)
First host with Meta.ownerId == ownerId, or nullptr.
Definition UISystem.cpp:573
static std::string consumeClick()
Pop next click as "name/node"; empty if none.
Definition UISystem.cpp:678
static void render()
Walk all UIHost (+ subclasses) via ECS View.
Definition UISystem.cpp:585
static std::string consumeClickFor(const std::string &hostName)
Pop next click for a specific host; returns node id only (or "").
Definition UISystem.cpp:686
static std::vector< UIEvent > & pendingEvents()
Definition UISystem.cpp:530
static ViewportState * viewportState(const std::string &hostName, const std::string &nodeId)
Definition UISystem.cpp:556
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition AnimTrail.h:6
Value/text/toggle change for script: "hostName/nodeId".
Definition UISystem.h:36
std::string kind
Definition UISystem.h:39
std::string nodeId
Definition UISystem.h:38
std::string hostName
Definition UISystem.h:37
One script-facing click: "hostName/nodeId".
Definition UISystem.h:30
std::string hostName
Definition UISystem.h:31
std::string nodeId
Definition UISystem.h:32
std::string textValue
Definition UISystem.h:26
std::string kind
Definition UISystem.h:22
std::string nodeId
Definition UISystem.h:21
uint32_t handlerIndex
Definition UISystem.h:23
std::string hostName
Definition UISystem.h:20
UIHost * host
Definition UISystem.h:19
double measureMs
Definition UISystem.h:46
graphics::Canvas * canvas
Definition UISystem.h:57