Brunot
Loading...
Searching...
No Matches
Editor.h
Go to the documentation of this file.
1// File: Editor.h
2// Description: The system manager, handles all systems in the engine
3// Author(s): Marcelo Escamilla, Bryley Elder (marcelo.escamilla@digipen.edu), (bryley.elder@digipen.edu)
4// 2025 / 10 / 03
5// (C) Digipen 2025
6// ____ __ __ __
7// /\__ _\/\ \ /\ \/\ \
8// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
9// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
10// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
11// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
12// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
13#pragma once
14
15#include "System/opengl.h"
16
17#include "../Submodules/imgui/imgui.h"
18#include "../Submodules/imgui/backends/imgui_impl_opengl3.h"
19#include "../Submodules/imgui/backends/imgui_impl_glfw.h"
20#include "Component/Table.h"
21#include "Audio/AudioObject.h"
22
23#ifndef EDITOR_H
24#define EDITOR_H
25#endif
26
27#ifndef NDEBUG
28#define START_WITH_IMGUI true
29#else
30#define START_WITH_IMGUI false
31#endif
32
33
34namespace sys
35{
36class Editor : public System
37{
38public:
39 auto getDefaultFont() -> ImFont*
40 {
41 return defaultFont;
42 }
43
44#pragma region static_functions
45
49 static auto getEnum() -> Type
50 {
51 return Type::Editor;
52 }
53
54
55#pragma endregion
56
57 Editor();
58 ~Editor() override;
59 Editor(const Editor& other) = default;
60 Editor(Editor&& other) noexcept;
61 auto operator=(const Editor& other) -> Editor&;
62 auto EntityComponentsEditor() -> void;
63 auto operator=(Editor&& other) noexcept -> Editor& = default;
64
65
66#pragma region overridden_functions
67
68 auto clone() const -> std::unique_ptr<GameObject> override
69 {
70 return std::make_unique<Editor>(*this);
71 }
72
73 auto onUpdate(float dt) -> void override;
74
75 auto endWindow() -> void override
76 {
77 }; // for debug ImGUI
78
79 auto onRender() -> void override;
80 auto load(Stream& stream) -> void override;
81 auto save(Stream& stream) const -> void override;
82
83#pragma endregion
84
85#pragma region Editor_Functions
86
87 auto PreRender() -> void;
88 auto PostRender() -> void;
89
90 auto shouldShowGui() const -> bool
91 {
92 return showImGui;
93 }
94
95
99 auto drawSystemMenu() -> void;
100
101
102 // Scene Menu Things
103
107 auto drawSceneMenu() -> void;
108
113 auto drawEntitiesCompact() -> bool;
114
120 auto receiveShowGUIKeyPressed(const Message* message) -> Message;
121
126 auto select(Entity* selected) -> void;
127
133 auto isSelected(Entity* entity) -> bool;
134
140 auto getSelectedEntity() -> Entity*;
141
147 auto deselect(Entity* entity) -> void;
148
156 auto isPassingFilter(Entity* entity) -> bool;
157
158 [[nodiscard]] auto getSliderRatio() const -> float;
159
160#pragma endregion
161
162private:
163#pragma region member_variables
165 ImFont* defaultFont;
167 float sliderRatio = 0.4f;
168
170 ImGuiTextFilter entityFilter;
174 bool compactEntityView = false;
175
178
179
180#pragma endregion
181
182#pragma region helper_functions
183
184static auto SceneViewPort() -> void;
185
186
187#pragma endregion
188
189#pragma region static_variables
190
191#pragma endregion
192};
193} // namespace sys
194
195
196#undef START_WITH_IMGUI
sys::Json Stream
Definition AudioObject.h:20
#define START_WITH_IMGUI
Definition Editor.h:28
The component responsible for facilitating the gameplay.
Definition Entity.h:33
friend Entity
Definition GameObject.h:84
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:23
Type
Definition System.h:20
@ Editor
Definition System.h:25
System(const std::string &typeName, Type systemType)
Definition System.cpp:75
bool compactEntityView
Whether the Scene Tree should be rendered more compact.
Definition Editor.h:174
auto getSliderRatio() const -> float
Definition Editor.cpp:626
Entity * selectedEntity
The entity currently selected in the Scene Tree.
Definition Editor.h:172
auto PreRender() -> void
Definition Editor.cpp:530
auto shouldShowGui() const -> bool
Definition Editor.h:90
auto drawEntitiesCompact() -> bool
used to determine how much spacing to give entities in the scene view
Definition Editor.cpp:436
auto load(Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Editor.cpp:564
static auto getEnum() -> Type
function required by all systems
Definition Editor.h:49
auto deselect(Entity *entity) -> void
deselects and entity if it is currently selected.
Definition Editor.cpp:611
auto operator=(Editor &&other) noexcept -> Editor &=default
ImFont * defaultFont
The default font of the Editor.
Definition Editor.h:165
auto drawSceneMenu() -> void
draw the tree of Entities that exist in a scene
Definition Editor.cpp:394
auto isPassingFilter(Entity *entity) -> bool
See if the an Entity is passing the filter and should be drawn in the Scene View Currently unimplemen...
Definition Editor.cpp:619
auto getSelectedEntity() -> Entity *
return selected entity, or nullptr if no entity is selected
Definition Editor.cpp:606
auto isSelected(Entity *entity) -> bool
check whether an entity is currently selected in the editor
Definition Editor.cpp:601
auto select(Entity *selected) -> void
selects an Entity, and shows it's children in the Component view editor
Definition Editor.cpp:596
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Editor.h:75
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Editor.h:68
~Editor() override
Definition Editor.cpp:488
auto PostRender() -> void
Post render will run all the normal Render() stuff instead of old function to allow for frame bufferi...
Definition Editor.cpp:633
auto operator=(const Editor &other) -> Editor &
Definition Editor.cpp:502
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Editor.cpp:569
auto receiveShowGUIKeyPressed(const Message *message) -> Message
Definition Editor.cpp:577
Editor()
Definition Editor.cpp:441
auto drawSystemMenu() -> void
Draw the window that shows all the systems in the game.
Definition Editor.cpp:371
bool showImGui
Whether the Editor should be shown.
Definition Editor.h:177
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Editor.cpp:560
auto EntityComponentsEditor() -> void
Definition Editor.cpp:516
float sliderRatio
The ratio of the total width a slider should take up.
Definition Editor.h:167
Editor(const Editor &other)=default
ImGuiTextFilter entityFilter
IMGui filter for searching the scene tree. currently unused, as filtering a tree is non-trivial.
Definition Editor.h:170
auto getDefaultFont() -> ImFont *
Definition Editor.h:39
auto onUpdate(float dt) -> void override
called once every frame.
Definition Editor.cpp:539
static auto SceneViewPort() -> void
This is the Window that activates the viewport and renders the framebuffer.
Definition Editor.cpp:657
the type of elements in a basic_json container
Definition GameObject.h:32
Definition Message.h:34