SpiecsEngine
 
Loading...
Searching...
No Matches
ImguiProperty.cpp
Go to the documentation of this file.
1/**
2* @file ImguiProperty.cpp.
3* @brief The ImguiProperty Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9
10namespace Spices {
11
13 {
15
16 /**
17 * @brief Begin render Property.
18 */
19 Begin();
20
21 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2.0f, 4.0f));
22
23 /**
24 * @brief Search String.
25 */
26 static std::string searchString;
27 static bool isEnableSearch = false;
28
29 /**
30 * @brief Begin render Search Input Text.
31 */
32 {
33 SPICES_PROFILE_ZONEN("ImguiProperty::Search");
34
35 ImGui::Spacing();
36 ImGui::PushItemWidth(m_PanelSize.x - ImGuiH::GetLineItemSize().x * 2.0f - ImGui::GetStyle().WindowPadding.x);
37 static char search[256] = {};
38 if (ImGui::InputTextWithHint("##", ICON_TEXT(ICON_MD_SEARCH, Search), search, 128))
39 {
40 searchString = std::string(search);
41 if (searchString.size() == 0) isEnableSearch = false;
42 else isEnableSearch = true;
43 }
44 ImGui::PopItemWidth();
45
46 ImGui::SameLine(m_PanelSize.x - ImGuiH::GetLineItemSize().x * 2.0f);
47 ImGui::Button(ICON_MD_FILTER_ALT, ImGuiH::GetLineItemSize());
48 ImGui::SameLine(m_PanelSize.x - ImGuiH::GetLineItemSize().x * 1.0f);
49 ImGui::Button(ICON_MD_REORDER, ImGuiH::GetLineItemSize());
50 ImGui::Spacing();
51 }
52
53 /**
54 * @brief End if not a select entity.
55 */
56 if (m_FrameInfo.m_PickEntityID.size() == 0)
57 {
58 SPICES_PROFILE_ZONEN("ImguiProperty::End");
59
60 ImGui::PopStyleVar();
61 End();
62
63 return;
64 }
65
66 /**
67 * @brief Render Datails.
68 */
69 {
70 SPICES_PROFILE_ZONEN("ImguiProperty::Datails");
71
72 {
73 ImGui::PushID("ImguiProperty::Add");
74
75 ImGui::Columns(2, 0, false);
76 ImGui::SetColumnWidth(0, ImGuiH::GetLineItemSize().x * 4.0f);
77 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.16f, 0.16f, 0.16f, 1.0f));
78 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.619f, 0.619f, 0.619f, 1.0f));
79 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.408f, 0.451f, 0.18f, 1.0f));
80 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.341f, 0.486f, 0.353f, 1.0f));
81 ImGui::Button(ICON_TEXT(ICON_MD_ADD, Add));
82 ImGui::PopStyleColor(4);
83 ImGui::NextColumn();
84
85 std::string ss;
86 ss = *m_FrameInfo.m_PickEntityID.end();
87 ImGui::PushItemWidth(m_PanelSize.x - ImGuiH::GetLineItemSize().x * 4.0f);
88 char text[128] = "";
89 if (ImGui::InputTextWithHint("##", ICON_TEXT_ROW(" ", ss.c_str()), text, 128)) {}
90 ImGui::PopItemWidth();
91
92 ImGui::Columns(1);
93 ImGui::PopID();
94 }
95
96 {
97 ImGui::PushID("ImguiProperty::Prim Path");
98 ImGui::Columns(2, 0, false);
99 ImGui::SetColumnWidth(0, ImGuiH::GetLineItemSize().x * 4.0f);
100 ImGui::Text("Prim Path");
101 ImGui::NextColumn();
102
103 std::stringstream ss;
104 ss << "/" << *m_FrameInfo.m_PickEntityID.end();
105 ImGui::PushItemWidth(m_PanelSize.x - ImGuiH::GetLineItemSize().x * 4.0f);
106 char textpath[128] = "";
107 if (ImGui::InputTextWithHint("##", ICON_TEXT_ROW(" ", ss.str().c_str()), textpath, 128)) {}
108 ImGui::PopItemWidth();
109
110 ImGui::Columns(1);
111 ImGui::PopID();
112 }
113
114 {
115 ImGui::PushID("ImguiProperty::Instanceable");
116 ImGui::Columns(2, 0, false);
117 ImGui::SetColumnWidth(0, ImGuiH::GetLineItemSize().x * 4.0f);
118 ImGui::Text("Instanceable");
119 ImGui::NextColumn();
120
121 static bool isChecked;
122 ImGuiH::Checkbox(&isChecked);
123 ImGui::Columns(1);
124 ImGui::PopID();
125 }
126 }
127
128 /**
129 * @brief Render All Component.
130 */
131 {
132 SPICES_PROFILE_ZONEN("ImguiProperty::Components");
133
134 entt::entity item = static_cast<entt::entity>(*m_FrameInfo.m_PickEntityID.end_k());
135 Entity entity(item, m_FrameInfo.m_World.get());
136
137 DrawComponent<TransformComponent> ("Transform", entity);
138 DrawComponent<CameraComponent> ("Camera", entity);
139 DrawComponent<DirectionalLightComponent>("DirectionalLight", entity);
140 DrawComponent<PointLightComponent> ("PointLight", entity);
141 DrawComponent<MeshComponent> ("Mesh", entity);
142 DrawComponent<NativeScriptComponent> ("NativeScript", entity);
143 DrawComponent<SkyBoxComponent> ("SkyBox", entity);
144 DrawComponent<SpriteComponent> ("Sprite", entity);
145 DrawComponent<LandscapeComponent> ("Landscape", entity);
146 DrawComponent<ParticleComponent> ("Particle", entity);
147 DrawComponent<EntityComponent> ("Attachment", entity);
148 DrawComponent<TagComponent> ("Tag", entity);
149 DrawComponent<UUIDComponent> ("UUID", entity);
150
151 if (ImGui::BeginPopupContextWindow(0, ImGuiPopupFlags_MouseButtonRight))
152 {
153 if (ImGui::BeginMenu("Add Component"))
154 {
155 if (ImGui::MenuItem("CameraComponent"))
156 {
157 AsyncTask(ThreadPoolEnum::Game, [=]() { Entity(item, m_FrameInfo.m_World.get()).AddComponent<CameraComponent>(); });
158 }
159 if (ImGui::MenuItem("DirectionalLightComponent"))
160 {
161 AsyncTask(ThreadPoolEnum::Game, [=]() { Entity(item, m_FrameInfo.m_World.get()).AddComponent<DirectionalLightComponent>(); });
162 }
163 if (ImGui::MenuItem("LandscapeComponent"))
164 {
165 AsyncTask(ThreadPoolEnum::Game, [=]() { Entity(item, m_FrameInfo.m_World.get()).AddComponent<LandscapeComponent>(); });
166 }
167 if (ImGui::MenuItem("MeshComponent"))
168 {
169 AsyncTask(ThreadPoolEnum::Game, [=]() { Entity(item, m_FrameInfo.m_World.get()).AddComponent<MeshComponent>(); });
170 }
171 if (ImGui::MenuItem("NativeScriptComponent"))
172 {
173 AsyncTask(ThreadPoolEnum::Game, [=]() { Entity(item, m_FrameInfo.m_World.get()).AddComponent<NativeScriptComponent>(); });
174 }
175 if (ImGui::MenuItem("ParticleComponent"))
176 {
177 AsyncTask(ThreadPoolEnum::Game, [=]() { Entity(item, m_FrameInfo.m_World.get()).AddComponent<ParticleComponent>(); });
178 }
179 if (ImGui::MenuItem("PointLightComponent"))
180 {
181 AsyncTask(ThreadPoolEnum::Game, [=]() { Entity(item, m_FrameInfo.m_World.get()).AddComponent<PointLightComponent>(); });
182 }
183 if (ImGui::MenuItem("SkyBoxComponent"))
184 {
185 AsyncTask(ThreadPoolEnum::Game, [=]() { Entity(item, m_FrameInfo.m_World.get()).AddComponent<SkyBoxComponent>(); });
186 }
187 if (ImGui::MenuItem("SpriteComponent"))
188 {
189 AsyncTask(ThreadPoolEnum::Game, [=]() { Entity(item, m_FrameInfo.m_World.get()).AddComponent<SpriteComponent>(); });
190 }
191 ImGui::MenuItem("WidgetComponent");
192
193 ImGui::EndMenu();
194 }
195 ImGui::EndPopup();
196 }
197 }
198
199 /**
200 * @brief End render Property.
201 */
202 ImGui::PopStyleVar();
203 End();
204 }
205}
#define ICON_TEXT(icon, text)
Definition ImguiHelper.h:24
#define ICON_TEXT_ROW(icon, text)
Definition ImguiHelper.h:25
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
CameraComponent Class. This class defines the specific behaves of CameraComponent.
DirectionalLightComponent Class. This class defines the specific behaves of DirectionalLightComponent...
EntityComponent Class. This class defines the specific behaves of EntityComponent.
Entity Class. This class defines the specific behaves of Entity.
Definition Entity.h:20
static void Checkbox(bool *isChecked)
ImGuiHelper Style Checkbox.
The ImGuiH Class. This class defines helper function for slate render.
Definition ImguiHelper.h:61
virtual void OnRender() override
This interface is called On SlateRenderer Render.
The ImguiProperty Class. This class defines how to render a Property.
FrameInfo & m_FrameInfo
The FrameData reference.
Definition ImguiUtils.h:166
void End()
End a slate.
LandscapeComponent Class. This class defines the specific behaves of LandscapeComponent.
MeshComponent Class. This class defines the specific behaves of MeshComponent.
NativeScriptComponent Class. This class defines the specific behaves of NativeScriptComponent....
ParticleComponent Class. This class defines the specific behaves of ParticleComponent.
PointLightComponent Class. This class defines the specific behaves of PointLightComponent.
SkyBoxComponent Class. This class defines the specific behaves of SkyBoxComponent.
SpriteComponent Class. This class defines the specific behaves of SpriteComponent.
TagComponent Class. This class defines the specific behaves of TagComponent.
TransformComponent Class. This class defines the specific behaves of TransformComponent.
UUIDComponent Class. This class defines the specific behaves of UUIDComponent.