Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,3 @@
path = external/SPIRV-Cross
url = https://github.com/flingengine/SPIRV-Cross.git

[submodule "external/imgui_entt_entity_editor"]
path = external/imgui_entt_entity_editor
url = https://github.com/flingengine/imgui_entt_entity_editor.git
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ if( WITH_IMGUI_FLAG )
target_include_directories( ImGui PUBLIC external/imgui )

include_directories( external/imgui )
include_directories( external/imgui_entt_entity_editor )
endif()

include_directories( external/glm )
Expand Down
19 changes: 11 additions & 8 deletions FlingEngine/Editor/inc/BaseEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#include <imgui.h>
#include <entt/entity/registry.hpp>
#include "imgui_entt_entity_editor.hpp"
#include "WorldOutlinePanel.h"
#include "EntityEditorPanel.h"

namespace Fling
{
Expand All @@ -25,9 +26,9 @@ namespace Fling
*/
virtual void Draw(entt::registry& t_Reg, float DeltaTime);

// #TODO: Init and shutdown functions
// #TODO: Init and shutdown functions

protected:
protected:

virtual void OnLoadLevel(std::string t_FileName);

Expand All @@ -43,9 +44,11 @@ namespace Fling
bool m_DisplayWindowOptions = false;
bool m_DisplayCameraOptions = false;

/** Component editor so that we can draw our component window */
entt::entity m_CompEditorEntityType = entt::null;
MM::ImGuiEntityEditor<entt::registry> m_ComponentEditor;
/** Lists entities in the world and tracks which one is selected */
WorldOutlinePanel m_WorldOutline;

/** Inspects the entity currently selected in m_WorldOutline */
EntityEditorPanel m_EntityEditor;

virtual void DrawFileMenu();

Expand All @@ -56,7 +59,7 @@ namespace Fling
void DrawWorldOutline(entt::registry& t_Reg);

/** assumes that m_DisplayComponentEditor is true */
void DrawComponentEditor(entt::registry& t_Reg);
void DrawEntityEditor(entt::registry& t_Reg);

void DrawWindowOptions();

Expand All @@ -70,4 +73,4 @@ namespace Fling
// Draw Gizmos, etc
// Draw component editor
};
} // namespace Fling
} // namespace Fling
26 changes: 26 additions & 0 deletions FlingEngine/Editor/inc/EntityEditorPanel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include "FlingEditorPanel.h"

#include <entt/entity/registry.hpp>

namespace Fling
{
/**
* Re-usable ImGui panel that inspects a single entity: lists the components
* it has (via ComponentTypeRegistry), lets the user remove them, and offers
* an "Add Component" popup for any registered type the entity doesn't have.
*/
class EntityEditorPanel final : public FlingEditorPanel
{
public:
/** Draws the "Entity Editor" window for the current target entity. Call once per frame. */
virtual void Draw(entt::registry& t_Reg) override;

/** Sets which entity this panel inspects. Pass entt::null to show none. */
void SetTargetEntity(entt::entity t_Entity) { m_TargetEntity = t_Entity; }

private:
entt::entity m_TargetEntity = entt::null;
};
} // namespace Fling
25 changes: 25 additions & 0 deletions FlingEngine/Editor/inc/FlingEditorPanel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include <entt/entity/registry.hpp>

namespace Fling
{
/**
* Base class for the engine's ImGui editor windows.
*/
class FlingEditorPanel
{
public:
virtual ~FlingEditorPanel() = default;

/** Draws this panel's ImGui window. Call once per frame. */
virtual void Draw(entt::registry& t_Reg) = 0;

void Show() { m_ShowWindow = true; }
void Hide() { m_ShowWindow = false; }
bool IsShown() const { return m_ShowWindow; }

protected:
bool m_ShowWindow = true;
};
} // namespace Fling
27 changes: 27 additions & 0 deletions FlingEngine/Editor/inc/WorldOutlinePanel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include "FlingEditorPanel.h"

#include <entt/entity/registry.hpp>

namespace Fling
{
/**
* Re-usable ImGui panel that lists every entity in a registry. Supports
* creating and deleting entities, and tracks which entity is currently
* selected so other editor windows (e.g. EntityEditorPanel) can follow it.
*/
class WorldOutlinePanel final : public FlingEditorPanel
{
public:
/** Draws the "World Outline" window. Call this once per frame. */
virtual void Draw(entt::registry& t_Reg) override;

entt::entity GetSelectedEntity() const { return m_SelectedEntity; }

void SetSelectedEntity(entt::entity t_Entity) { m_SelectedEntity = t_Entity; }

private:
entt::entity m_SelectedEntity = entt::null;
};
} // namespace Fling
Loading
Loading