Hymn to Beauty
C++ 3D Engine
Editor.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "GUI/InputWindow.hpp"
9#include "GUI/LogView.hpp"
13#include <string>
14#include <json/json.h>
15#include <ImGuizmo.h>
16
17struct GLFWcursor;
18namespace Video {
20class Texture2D;
21}
22
24class Editor {
25 public:
27
31 Editor(Utility::Window* window, Video::LowLevelRenderer* lowLevelRenderer);
32
34 ~Editor();
35
37 void RenderHymn();
38
40
43 void Show(float deltaTime);
44
46
49 bool HasMadeChanges() const;
50
52 void Save() const;
53
55 void LoadSceneState();
56
58
61 bool ReadyToClose() const;
62
64
67 bool IsClosing() const;
68
70 void Close();
71
73
76 bool IsVisible() const;
77
79
82 void SetVisible(bool visible);
83
85
88 Entity* GetCamera() const;
89
90 // Whether the vertices for the paint mode are loaded or not.
91 bool vertsLoaded = false;
92
93 // Whether the paint mode is active or not.
94 bool paintModeActive = false;
95
96 private:
97 void ShowMainMenuBar(bool& play);
98 void ShowGridSettings();
99 void CreateGrid(int size);
100 void ControlEditorCamera(float deltaTime);
101 void Picking();
102 void Focus();
103 void PaintBrush(Entity* entity);
104 void WidgetGizmo(Entity* entity);
105
106 void Play();
107 void NewHymn();
108 void NewHymnClosed(const std::string& hymn);
109 void OpenHymn();
110 void OpenHymnClosed(const std::string& hymn);
111 void LoadActiveScene();
112
113 struct GridSettings {
114 int gridSize;
115 int lineWidth;
116 bool gridSnap;
117 int snapOption;
118 } gridSettings;
119
120 Utility::Window* window = nullptr;
121
122 bool visible = true;
123 GUI::SelectHymnWindow selectHymnWindow;
124 GUI::InputWindow inputWindow;
125 GUI::ResourceView resourceView;
126 GUI::LogView logView;
127 GUI::SettingsWindow settingsWindow;
128 GUI::SavePromptWindow savePromptWindow;
129 GUI::ProfilingWindow profilingWindow;
130
131 bool close;
132 bool savePromptAnswered;
133 bool showGridSettings;
134 Entity* parentEntity = nullptr;
135 Json::Value sceneState;
136
137 World cameraWorld;
138 Entity* cameraEntity;
139 Entity* currentEntity;
140 Entity* selectedEntity;
141 RayIntersection rayIntersector;
142 int nrOfVertices = 0;
143 int nrOfIndices = 0;
144 glm::vec3 normal;
145 float lastIntersect = INFINITY;
146 double lastX = 0.0;
147 double lastY = 0.0;
148
149 // Paint brush variables.
150 float paintTimer = 0.0f;
151 float paintSpawnRate[1] = {0.5f};
152 float paintObjScale[1] = {1.0f};
153 int paintScaleRandomness[1] = {1};
154 bool toolMenuPressed = false;
155 bool spreadRand = false;
156 std::string paintScene;
157
158 GLFWcursor* cursors[5];
159
160 ImGuizmo::MODE imguizmoMode = ImGuizmo::MODE::WORLD;
161
162 Video::Texture2D* lightTexture;
163 Video::Texture2D* soundSourceTexture;
164 Video::Texture2D* cameraTexture;
165};
Handles the main editor.
Definition: Editor.hpp:24
bool ReadyToClose() const
Is the editor ready to be closed, have we saved everything?
Definition: Editor.cpp:344
Editor(Utility::Window *window, Video::LowLevelRenderer *lowLevelRenderer)
Create new editor.
Definition: Editor.cpp:40
void LoadSceneState()
Loads the save editor state.
Definition: Editor.cpp:793
bool HasMadeChanges() const
Show the editor.
Definition: Editor.cpp:276
void SetVisible(bool visible)
Set whether the resource list should be visible.
Definition: Editor.cpp:360
bool paintModeActive
Definition: Editor.hpp:94
void Save() const
Save the hymn being edited.
Definition: Editor.cpp:270
void RenderHymn()
Render the hymn using the editor's debug visualization settings.
Definition: Editor.cpp:123
Entity * GetCamera() const
Get the editor camera.
Definition: Editor.cpp:364
void Close()
Close the editor.
Definition: Editor.cpp:352
bool vertsLoaded
Definition: Editor.hpp:91
~Editor()
Destructor.
Definition: Editor.cpp:112
bool IsVisible() const
Get whether the resource list is visible.
Definition: Editor.cpp:356
bool IsClosing() const
Is the editor preparing for closing down?
Definition: Editor.cpp:348
void Show(float deltaTime)
Show the editor.
Definition: Editor.cpp:138
Entity containing various components.
Definition: Entity.hpp:16
A window where input is configured.
Definition: InputWindow.hpp:5
Definition: LogView.hpp:8
Definition: ProfilingWindow.hpp:9
Displays all the hymn's resources.
Definition: ResourceView.hpp:21
A window that asks the user if they want to save before quitting.
Definition: SavePromptWindow.hpp:9
A window where a hymn can be selected.
Definition: SelectHymnWindow.hpp:9
Used to edit Hymn to Beauty settings.
Definition: SettingsWindow.hpp:8
The class handling intersection checks.
Definition: RayIntersection.hpp:7
Definition: Window.hpp:14
Low level renderer abstracting the underlaying graphics API (OpenGL or Vulkan).
Definition: LowLevelRenderer.hpp:27
A two-dimensional texture.
Definition: Texture2D.hpp:10
The game world containing all entities.
Definition: World.hpp:14
Definition: Editor.hpp:18