Unravel Engine C++ Reference
Loading...
Searching...
No Matches
inspector_particle_emitter.cpp
Go to the documentation of this file.
3#include "inspectors.h"
4
5namespace unravel
6{
8 entt::meta_any& var,
9 const meta_any_proxy& var_proxy,
10 const var_info& info,
11 const entt::meta_custom& custom) -> inspect_result
12{
13 inspect_result result;
14 auto& data = var.cast<particle_emitter_component&>();
15
16
17 // Current state display
18 const bool is_playing = data.is_playing();
19 const bool is_paused = data.is_paused();
20
21 // Status text
22 ImGui::Text("Status: ");
23 ImGui::SameLine();
24 if(!is_playing)
25 {
26 ImGui::TextColored(ImVec4(0.8f, 0.4f, 0.4f, 1.0f), "Stopped");
27 }
28 else if(is_paused)
29 {
30 ImGui::TextColored(ImVec4(0.8f, 0.8f, 0.4f, 1.0f), "Paused");
31 }
32 else
33 {
34 ImGui::TextColored(ImVec4(0.4f, 0.8f, 0.4f, 1.0f), "Playing");
35 }
36
37 ImGui::Spacing();
38
39 // Control buttons
40
41 // Play button
42 if(!is_playing || is_paused)
43 {
44 if(ImGui::Button("Play"))
45 {
46 data.play();
47 result.changed = true;
48 }
49
50 ImGui::SetItemTooltip("Start particle emission and simulation");
51 }
52 else
53 {
54 ImGui::BeginDisabled();
55 ImGui::Button("Play");
56 ImGui::EndDisabled();
57 }
58
59 ImGui::SameLine();
60
61 // Pause/Resume button
62 if(is_playing && !is_paused)
63 {
64 if(ImGui::Button("Pause"))
65 {
66 data.pause();
67 result.changed = true;
68 }
69 ImGui::SetItemTooltip("Pause particle simulation (particles remain visible)");
70 }
71 else if(is_playing && is_paused)
72 {
73 if(ImGui::Button("Resume"))
74 {
75 data.resume();
76 result.changed = true;
77 }
78 ImGui::SetItemTooltip("Resume particle simulation from paused state");
79 }
80 else
81 {
82 ImGui::BeginDisabled();
83 ImGui::Button("Pause");
84 ImGui::EndDisabled();
85 }
86
87 ImGui::SameLine();
88
89 // Stop button
90 if(is_playing)
91 {
92 if(ImGui::Button("Stop"))
93 {
94 data.stop();
95 result.changed = true;
96 }
97 ImGui::SetItemTooltip("Stop emission and clear all particles");
98
99 ImGui::SameLine();
100 if(ImGui::Button("Stop and Reset"))
101 {
102 data.stop_and_reset();
103 result.changed = true;
104 }
105 ImGui::SetItemTooltip("Stop emission and clear all particles");
106 }
107 else
108 {
109 ImGui::BeginDisabled();
110 ImGui::Button("Stop");
111 ImGui::SameLine();
112 ImGui::Button("Stop and Reset");
113 ImGui::EndDisabled();
114 }
115
116
117
118
119 if(!is_playing || is_paused)
120 {
121 if(ImGui::Button("Play(S)"))
122 {
123 data.play();
124 data.play_sub_emitters();
125 result.changed = true;
126 }
127
128 ImGui::SetItemTooltip("Start particle emission and simulation (with sub emitters)");
129 }
130 else
131 {
132 ImGui::BeginDisabled();
133 ImGui::Button("Play(S)");
134 ImGui::EndDisabled();
135 }
136
137 ImGui::SameLine();
138
139 // Pause/Resume button
140 if(is_playing && !is_paused)
141 {
142 if(ImGui::Button("Pause(S)"))
143 {
144 data.pause();
145 data.pause_sub_emitters();
146 result.changed = true;
147 }
148 ImGui::SetItemTooltip("Pause particle simulation (particles remain visible) (with sub emitters)");
149 }
150 else if(is_playing && is_paused)
151 {
152 if(ImGui::Button("Resume(S)"))
153 {
154 data.resume();
155 data.resume_sub_emitters();
156 result.changed = true;
157 }
158 ImGui::SetItemTooltip("Resume particle simulation from paused state (with sub emitters)");
159 }
160 else
161 {
162 ImGui::BeginDisabled();
163 ImGui::Button("Pause(S)");
164 ImGui::EndDisabled();
165 }
166
167 ImGui::SameLine();
168
169 // Stop button
170 if(is_playing)
171 {
172 if(ImGui::Button("Stop(S)"))
173 {
174 data.stop();
175 data.stop_sub_emitters();
176 result.changed = true;
177 }
178 ImGui::SetItemTooltip("Stop emission and clear all particles (with sub emitters)");
179
180 ImGui::SameLine();
181 if(ImGui::Button("Stop and Reset(S)"))
182 {
183 data.stop_and_reset();
184 data.stop_and_reset_sub_emitters();
185 result.changed = true;
186 }
187 ImGui::SetItemTooltip("Stop emission and clear all particles (with sub emitters)");
188 }
189 else
190 {
191 ImGui::BeginDisabled();
192 ImGui::Button("Stop(S)");
193 ImGui::SameLine();
194 ImGui::Button("Stop and Reset(S)");
195 ImGui::EndDisabled();
196 }
197
198 result |= inspect_var_properties(ctx, var, var_proxy, info, custom);
199 return result;
200}
201} // namespace unravel
Component that wraps the soa particle system emitter.
auto inspect_var_properties(rtti::context &ctx, entt::meta_any &var, const meta_any_proxy &var_proxy, const var_info &info, const entt::meta_custom &custom) -> inspect_result
Inspects all properties of a complex object recursively.
Result of an inspection operation indicating what changes occurred.
Definition inspector.h:164
bool changed
Whether the value was modified during inspection.
Definition inspector.h:166
auto inspect(rtti::context &ctx, entt::meta_any &var, const meta_any_proxy &var_proxy, const var_info &info, const entt::meta_custom &custom) -> inspect_result override
Safe deferred property access proxy for arbitrary object properties.
Definition inspector.h:216
Metadata about a variable being inspected.
Definition inspector.h:151