18#define IMGUI_DEFINE_MATH_OPERATORS
21#include "../Submodules/imgui/imgui.h"
22#include "../Submodules/imgui/backends/imgui_impl_opengl3.h"
23#include "../Submodules/imgui/backends/imgui_impl_glfw.h"
24#include "../Submodules/ImGuizmo/src/ImGuizmo.h"
25#include "misc/cpp/imgui_stdlib.h"
34#define START_WITH_IMGUI true
36#define START_WITH_IMGUI false
57#pragma region static_functions
82#pragma region overridden_functions
86 return std::make_unique<Editor>(*
this);
89 auto onUpdate(
float dt) ->
void override;
96 auto load(
const Stream& stream) ->
void override;
97 auto save(
Stream& stream)
const ->
void override;
101#pragma region Editor_Functions
160 template <typename T,
int instance = 0>
245#pragma region member_variables
270#pragma region helper_functions
288#pragma region messaging_functions
295#pragma region static_variables
301template <
typename T,
int instance>
305 namespace fs = std::filesystem;
308 static auto index = 0;
309 static std::vector<std::string> itemNames;
311 for (
auto& entry : fs::directory_iterator(
"Data" / directory))
313 if (entry.path().extension() ==
".json")
315 itemNames.push_back(entry.path().stem().string());
319 std::vector<const char*> items;
320 for (
auto& name : itemNames)
322 items.push_back(name.c_str());
325 ImGui::Text(
"Select %s :", directory.string().c_str());
326 ImGui::SetNextItemWidth(150.0f);
327 ImGui::Combo(
"##Items",
330 static_cast<int>(items.size())
333 if (ImGui::Button(
"Add"))
336 const auto& selected = itemNames[index];
344#undef START_WITH_IMGUI
sys::Json Stream
Definition AudioObject.h:20
#define START_WITH_IMGUI
Definition Editor.h:34
friend Entity
Definition GameObject.h:90
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:24
An object that manages many of a single type of particle.
Definition ParticleEmitter.h:32
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:256
auto getSliderRatio() const -> float
Definition Editor.cpp:797
ParticleEmitter * selectedEmitter
the emitter last selected on a particleGenerator
Definition Editor.h:267
auto deleteSelectedEntity(const Message *message) -> Message
Definition Editor.cpp:991
Entity * selectedEntity
The entity currently selected in the Scene Tree.
Definition Editor.h:254
static const float IndentWidth
Definition Editor.h:69
auto PreRender() -> void
Definition Editor.cpp:384
auto shouldShowGui() const -> bool
Definition Editor.h:106
static void drawEditorTopBar()
draw the top bar of the editor
Definition Editor.cpp:922
auto drawEntitiesCompact() -> bool
used to determine how much spacing to give entities in the scene view
Definition Editor.cpp:460
static auto getEnum() -> Type
function required by all systems
Definition Editor.h:62
auto deselect(Entity *entity) -> void
deselects and entity if it is currently selected.
Definition Editor.cpp:782
auto operator=(Editor &&other) noexcept -> Editor &=default
ImFont * defaultFont
The default font of the Editor.
Definition Editor.h:247
auto drawSceneMenu() -> void
draw the tree of Entities that exist in a scene
Definition Editor.cpp:420
auto getSceneViewPortMousePosition() -> Vector4D &
Definition Editor.cpp:751
void calculateViewportCoords(float width, float height)
helper function to calculate the coordinates of the mouse over the viewport
Definition Editor.cpp:955
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:790
auto getSelectedEntity() -> Entity *
return selected entity, or nullptr if no entity is selected
Definition Editor.cpp:777
auto EntityComponentsEditor() const -> void
Definition Editor.cpp:542
auto isSelected(Entity *entity) -> bool
check whether an entity is currently selected in the editor
Definition Editor.cpp:772
auto select(Entity *selected) -> void
selects an Entity, and shows it's children in the Component view editor
Definition Editor.cpp:767
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Editor.h:91
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Editor.h:84
auto linkMessages() -> void
Definition Editor.cpp:980
static auto displayTexture(const gfx::Texture *texture) -> void
show a texture in a small square
Definition Editor.cpp:635
Vector4D editorMousePos
Position of the mouse relative to the scene viewport.
Definition Editor.h:263
~Editor() override
Definition Editor.cpp:514
auto PostRender() -> void
Post render will run all the normal Render() stuff instead of old function to allow for frame bufferi...
Definition Editor.cpp:804
static const ImVec2 SmallButtonSize
Definition Editor.h:67
static auto showMakeFromFileMenu(const std::filesystem::path &directory) -> std::unique_ptr< T >
Shows a dropdown menu of every json in a directory inside the Data/ folder, and constructs objects fr...
Definition Editor.h:302
auto operator=(const Editor &other) -> Editor &
Definition Editor.cpp:528
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Editor.cpp:728
auto EmitterEditor() const -> void
draw editor for adjusting settings of the selected emitter
Definition Editor.cpp:554
auto toggleGuizmos() -> void
Definition Editor.cpp:829
auto receiveShowGUIKeyPressed(const Message *message) -> Message
Definition Editor.cpp:759
Editor()
Definition Editor.cpp:465
auto drawSystemMenu() -> void
Draw the window that shows all the systems in the game.
Definition Editor.cpp:394
bool showImGui
Whether the Editor should be shown.
Definition Editor.h:260
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Editor.cpp:719
float sliderRatio
The ratio of the total width a slider should take up.
Definition Editor.h:249
Editor(const Editor &other)=default
static auto showTexturePickerMenu() -> gfx::Texture *
creates a dropdown menu to select a new texture.
Definition Editor.cpp:564
ImGuiTextFilter entityFilter
IMGui filter for searching the scene tree. currently unused, as filtering a tree is non-trivial.
Definition Editor.h:252
auto getDefaultFont() -> ImFont *
Definition Editor.h:52
auto onUpdate(float dt) -> void override
called once every frame.
Definition Editor.cpp:688
auto SceneViewPort() -> void
This is the Window that activates the viewport and renders the framebuffer.
Definition Editor.cpp:1004
static auto showMeshPickerMenu() -> gfx::Mesh *
shows a dropdown menu to choose meshes
Definition Editor.cpp:643
auto load(const Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Editor.cpp:723
static auto make(const std::string &name) -> std::unique_ptr< T >
create an object and heap allocate it.
Definition Factory.h:45
Definition FlipCardAction.h:25
the type of elements in a basic_json container
Definition GameObject.h:37