载入中...
搜索中...
未找到
Inspector.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Export.h"
4#include "common/Runtime.h"
5#include "ui/Widget.h"
6
7#include <simplesquirrel/simplesquirrel.hpp>
8
9#include <functional>
10#include <string>
11#include <vector>
12
13namespace eve::ui {
14
15class UIHost;
16
37public:
38 Inspector() = default;
39 ~Inspector();
40 Inspector(const Inspector&) = delete;
41 Inspector& operator=(const Inspector&) = delete;
42
44 void refresh();
46 void open();
48 void close();
50 bool isOpen() const;
52 UIHost* host() const { return host_; }
53
55 bool selectClass(const std::string& name);
62 bool inspectObject(const ssq::Object& object);
64 const std::string& selectedClass() const { return selectedClass_; }
66 bool addInstance();
72 void setPickScene(std::function<ssq::Object()> pickScene);
74 bool selectInstance(int index);
76 void openNested(const std::string& className, const ssq::Object& object);
78 void back();
80 int instanceCount() const { return int(instances_.size()); }
82 int selectedIndex() const { return selectedInstance_; }
84 ssq::Object selectedInstance() const {
85 return (selectedInstance_ >= 0 &&
86 size_t(selectedInstance_) < instances_.size())
87 ? instances_[size_t(selectedInstance_)].object
88 : ssq::Object();
89 }
90
92 void sync();
94 WidgetDesc build();
95
96private:
97 struct InstanceEntry {
98 std::string label;
99 ssq::Object object;
100 };
101 struct NestedEntry {
102 std::string className;
103 ssq::Object object;
104 };
105
106 Runtime* runtime() const;
107 const ssq::Object* currentInstance() const;
108 int currentClassIndex() const;
109 void writeProperty(const std::string& name, ReflectedValue value);
110 void rebuildHost();
111 WidgetDesc propertyWidget(const std::string& ownerClass,
112 const ReflectedMember& member,
113 const ReflectedValue& value,
114 const ssq::Object& instance);
115 WidgetDesc arrayWidget(const std::string& ownerClass, const ReflectedMember& member,
116 const ssq::Object& instance);
117 WidgetDesc tableWidget(const std::string& ownerClass, const ReflectedMember& member,
118 const ssq::Object& instance);
119
120 std::vector<std::string> classNames_;
121 std::string selectedClass_;
122 std::vector<InstanceEntry> instances_;
123 std::vector<ReflectedMember> cachedMembers_;
124 std::vector<NestedEntry> navStack_;
125 std::function<ssq::Object()> pickScene_;
126 int selectedInstance_ = -1;
127 UIHost* host_ = nullptr;
128};
129
130} // namespace eve::ui
std::string value
#define EVENGINE_API
宿主(eve / libmain)导出宏;插件从进程导入同一批符号。
Definition Export.h:16
const char * name
Definition RockMesh.cpp:21
Reflection-driven property inspector (DevTools phase C, MVVM).
Definition Inspector.h:36
UIHost * host() const
The mounted inspector host (nullptr until open()); for embedding.
Definition Inspector.h:52
Inspector & operator=(const Inspector &)=delete
int selectedIndex() const
Index of the selected instance; -1 when none.
Definition Inspector.h:82
ssq::Object selectedInstance() const
Live script object of the selected instance (empty when none).
Definition Inspector.h:84
Inspector(const Inspector &)=delete
const std::string & selectedClass() const
Name of the currently selected class ("" when none).
Definition Inspector.h:64
int instanceCount() const
Number of live instances of the selected class.
Definition Inspector.h:80
ECS mount point for one UI panel/screen. Subclass to attach UI to game entities, e....
Definition UIHost.h:130
Declarative widget description (build once / on dirty → flatten into UIHost::Tree).
Definition Widget.h:13