9#include "../ResourceSelector.hpp"
15class DirectionalLight;
76 template <
typename type>
void AddEditor(
const std::string& name, std::function<
void(type*)> editorFunction);
77 template <
typename type>
void AddComponent(
const std::string& name);
78 template <
typename type>
void EditComponent(
const std::string& name, std::function<
void(type*)> editorFunction);
98 char stringPropertyBuffer[128];
103 std::function<void()> addFunction;
104 std::function<void()> editFunction;
106 std::vector<Editor> editors;
107 std::vector<IShapeEditor*> shapeEditors;
108 int selectedShape = -1;
110 std::unique_ptr<GUI::RigidBodyEditor> rigidBodyEditor;
113 std::unique_ptr<GUI::TriggerEditor> triggerEditor;
115 bool albedoShow =
false;
116 bool normalShow =
false;
117 bool roughnessMetallicShow =
false;
119 bool textureShow =
false;
121 bool cameraLayers[32];
123 bool spriteLayers[32];
127template <
typename type>
void GUI::EntityEditor::AddEditor(
const std::string& name, std::function<
void(type*)> editorFunction) {
129 editor.addFunction = std::bind(&EntityEditor::AddComponent<type>,
this, name);
130 editor.editFunction = std::bind(&EntityEditor::EditComponent<type>,
this, name, editorFunction);
131 editors.push_back(editor);
134template <
typename type>
void GUI::EntityEditor::AddComponent(
const std::string& name) {
135 if (entity->GetComponent<type>() ==
nullptr) {
136 if (ImGui::Selectable(name.c_str())) {
137 entity->AddComponent<type>();
143template <
typename type>
void GUI::EntityEditor::EditComponent(
const std::string& name, std::function<
void(type*)> editorFunction) {
144 type* component = entity->GetComponent<type>();
145 if (component !=
nullptr && ImGui::CollapsingHeader(name.c_str())) {
146 ImGui::PushID(name.c_str());
148 editorFunction(component);
150 if (ImGui::Button(
"Remove"))
151 entity->KillComponent<type>();
Component handling a camera through which the world can be rendered.
Definition: Camera.hpp:8
Component describing a directional light source (like the sun).
Definition: DirectionalLight.hpp:8
Component describing a listener that can listen to sounds.
Definition: Listener.hpp:7
Component providing a material to Entity.
Definition: Material.hpp:9
Component providing geometry to an entity.
Definition: Mesh.hpp:11
Component describing a point light.
Definition: PointLight.hpp:8
Component that allows interacting with other physics components.
Definition: RigidBody.hpp:19
Component controlled by a script.
Definition: Script.hpp:13
Component describing a sound source.
Definition: SoundSource.hpp:11
Component describing a spot light.
Definition: SpotLight.hpp:8
Component defining a 2D sprite.
Definition: Sprite.hpp:11
Component defining a trigger event.
Definition: Trigger.hpp:14
Handles the main editor.
Definition: Editor.hpp:24
Editor(Utility::Window *window, Video::LowLevelRenderer *lowLevelRenderer)
Create new editor.
Definition: Editor.cpp:40
Entity containing various components.
Definition: Entity.hpp:16
Used to edit an entity.
Definition: EntityEditor.hpp:33
EntityEditor()
Create new entity editor.
Definition: EntityEditor.cpp:46
~EntityEditor()
Destructor.
Definition: EntityEditor.cpp:75
void Show()
Show the editor.
Definition: EntityEditor.cpp:81
bool ShowsEntity(Entity *entity)
Checks if the editor is showing this entity.
Definition: EntityEditor.cpp:203
void SetVisible(bool visible)
Set whether the window should be visible.
Definition: EntityEditor.cpp:211
void SetEntity(Entity *entity)
Set the entity to edit.
Definition: EntityEditor.cpp:161
Entity * GetEntity()
Get the entity being edited.
Definition: EntityEditor.cpp:199
bool IsVisible() const
Get whether the window is visible.
Definition: EntityEditor.cpp:207
Used to select a resource from the resource list.
Definition: ResourceSelector.hpp:7
Editor for rigid body components.
Definition: RigidBodyEditor.hpp:9
Used to edit a script.
Definition: ScriptEditor.hpp:9
Definition: TriggerEditor.hpp:12
Definition: BoxShapeEditor.hpp:5
Definition: AssetEditor.hpp:9