Changed selected type
Moving away from using the pure ENTT library types and starting to use my own
This commit is contained in:
parent
282844b905
commit
7223c20f1d
@ -3,11 +3,14 @@
|
|||||||
|
|
||||||
void Inspector::Draw()
|
void Inspector::Draw()
|
||||||
{
|
{
|
||||||
|
if (selected.isValid()) {
|
||||||
|
AddComponentDropDown();
|
||||||
|
ShowComponents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Inspector::AddComponentDropDown(YoggieEngine::Entity& selected)
|
void Inspector::AddComponentDropDown()
|
||||||
{
|
{
|
||||||
static char* names[] = { "Script Component", "Camera Component", "Light Component" };
|
static char* names[] = { "Script Component", "Camera Component", "Light Component" };
|
||||||
if (ImGui::Button("Add Component"))
|
if (ImGui::Button("Add Component"))
|
||||||
@ -28,7 +31,7 @@ void Inspector::AddComponentDropDown(YoggieEngine::Entity& selected)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Inspector::ShowComponents(YoggieEngine::Entity& selected)
|
void Inspector::ShowComponents()
|
||||||
{
|
{
|
||||||
auto component = selected.GetComponent<YoggieEngine::IdentifierComponent>();
|
auto component = selected.GetComponent<YoggieEngine::IdentifierComponent>();
|
||||||
ImGui::InputText("Name:", (char*)component.name.c_str(), component.name.size() * sizeof(char), ImGuiInputTextFlags_ReadOnly);
|
ImGui::InputText("Name:", (char*)component.name.c_str(), component.name.size() * sizeof(char), ImGuiInputTextFlags_ReadOnly);
|
||||||
|
@ -8,13 +8,15 @@ inline void ComponentView(const std::string& componentName, voidFunction func);
|
|||||||
|
|
||||||
class Inspector : public EditorWindow {
|
class Inspector : public EditorWindow {
|
||||||
public:
|
public:
|
||||||
Inspector() : EditorWindow("Inspector") {}
|
Inspector( YoggieEngine::Entity& selected ) : EditorWindow("Inspector"), selected(selected){}
|
||||||
|
|
||||||
void Draw()override;
|
void Draw()override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
void AddComponentDropDown(YoggieEngine::Entity& selected);
|
void AddComponentDropDown();
|
||||||
|
void ShowComponents();
|
||||||
|
|
||||||
void ShowComponents(YoggieEngine::Entity& selected);
|
|
||||||
|
|
||||||
|
YoggieEngine::Entity& selected;
|
||||||
};
|
};
|
||||||
|
@ -6,8 +6,8 @@ void SceneExplorer::Draw()
|
|||||||
YoggieEngine::Entity entity = YoggieEngine::Entity(enttNumber, &scene);
|
YoggieEngine::Entity entity = YoggieEngine::Entity(enttNumber, &scene);
|
||||||
auto id = entity.GetComponent<YoggieEngine::IdentifierComponent>();
|
auto id = entity.GetComponent<YoggieEngine::IdentifierComponent>();
|
||||||
|
|
||||||
if (ImGui::Selectable(id.name.c_str(), enttNumber == selected)) {
|
if (ImGui::Selectable(id.name.c_str(), entity == selected)) {
|
||||||
selected = enttNumber;
|
selected = YoggieEngine::Entity(enttNumber, &scene);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class SceneExplorer : public EditorWindow {
|
class SceneExplorer : public EditorWindow {
|
||||||
public:
|
public:
|
||||||
SceneExplorer(entt::entity& selected, YoggieEngine::Scene& scene)
|
SceneExplorer(YoggieEngine::Entity& selected, YoggieEngine::Scene& scene)
|
||||||
: EditorWindow("SceneExplorer"), scene(scene), selected(selected)
|
: EditorWindow("SceneExplorer"), scene(scene), selected(selected)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
entt::entity selected;
|
YoggieEngine::Entity& selected;
|
||||||
YoggieEngine::Scene& scene;
|
YoggieEngine::Scene& scene;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
#include "../../YoggieEngine/src/EntryPoint.h"
|
#include "../../YoggieEngine/src/EntryPoint.h"
|
||||||
#include <mini/ini.h>
|
#include <mini/ini.h>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
|
||||||
#include "AssetManagement/SceneSerializer.h"
|
#include "AssetManagement/SceneSerializer.h"
|
||||||
#include "AssetManagement/AssetManager.h"
|
#include "AssetManagement/AssetManager.h"
|
||||||
|
|
||||||
#include "Views/Viewport.h"
|
#include "Views/Viewport.h"
|
||||||
#include "PropertyPanels/SceneExplorer.h"
|
#include "PropertyPanels/SceneExplorer.h"
|
||||||
#include "AssetManagement/AssetFinder.h"
|
#include "AssetManagement/AssetFinder.h"
|
||||||
@ -20,10 +17,9 @@
|
|||||||
|
|
||||||
using namespace YoggieEngine;
|
using namespace YoggieEngine;
|
||||||
|
|
||||||
|
|
||||||
class Editor : public Application {
|
class Editor : public Application {
|
||||||
public:
|
public:
|
||||||
Editor() : Application("Editor"), Selected((entt::entity)-1){}
|
Editor() : Application("Editor"){}
|
||||||
|
|
||||||
void Run() override
|
void Run() override
|
||||||
{
|
{
|
||||||
@ -40,11 +36,13 @@ public:
|
|||||||
Viewport sceneview = Viewport(scene);
|
Viewport sceneview = Viewport(scene);
|
||||||
RuntimeControls rc = RuntimeControls();
|
RuntimeControls rc = RuntimeControls();
|
||||||
SceneExplorer explorer(Selected, scene);
|
SceneExplorer explorer(Selected, scene);
|
||||||
Inspector inspector = Inspector();
|
Inspector inspector = Inspector(Selected);
|
||||||
Settings settings = Settings();
|
Settings settings = Settings();
|
||||||
// AssetFinder assetsView = AssetFinder();
|
// AssetFinder assetsView = AssetFinder();
|
||||||
Console console = Console();
|
Console console = Console();
|
||||||
|
|
||||||
|
Selected = YoggieEngine::Entity((entt::entity) -1, &scene);
|
||||||
|
|
||||||
double previous = glfwGetTime();
|
double previous = glfwGetTime();
|
||||||
double lag = 0.0;
|
double lag = 0.0;
|
||||||
while (!appWindow.WindowShouldClose())
|
while (!appWindow.WindowShouldClose())
|
||||||
@ -129,14 +127,6 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (scene.getReg().valid(Selected)) {
|
|
||||||
Entity SelectedEntity = Entity(Selected, &scene);
|
|
||||||
inspector.AddComponentDropDown(SelectedEntity);
|
|
||||||
inspector.ShowComponents(SelectedEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
projectInfo.Update();
|
projectInfo.Update();
|
||||||
sceneview.Update();
|
sceneview.Update();
|
||||||
rc.Update();
|
rc.Update();
|
||||||
@ -164,7 +154,6 @@ public:
|
|||||||
// Load an empty project.
|
// Load an empty project.
|
||||||
mINI::INIStructure ini;
|
mINI::INIStructure ini;
|
||||||
|
|
||||||
|
|
||||||
if (std::filesystem::exists("build\\Debug\\Editor.ini"))
|
if (std::filesystem::exists("build\\Debug\\Editor.ini"))
|
||||||
{
|
{
|
||||||
mINI::INIFile file("build\\Debug\\Editor.ini");
|
mINI::INIFile file("build\\Debug\\Editor.ini");
|
||||||
@ -189,7 +178,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool SimulatePhysics = true;
|
bool SimulatePhysics = true;
|
||||||
entt::entity Selected;
|
YoggieEngine::Entity Selected;
|
||||||
|
|
||||||
Project project;
|
Project project;
|
||||||
Scene scene;
|
Scene scene;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
typedef uint64_t ENTITY_UUID;
|
#include "Scene.h"
|
||||||
|
|
||||||
namespace YoggieEngine {
|
namespace YoggieEngine {
|
||||||
class Scene;
|
|
||||||
class Entity {
|
class Entity {
|
||||||
public:
|
public:
|
||||||
Entity() = default;
|
Entity() = default;
|
||||||
@ -25,8 +26,15 @@ namespace YoggieEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Not Scene context aware!!
|
// NOTE: Not Scene context aware!!
|
||||||
bool operator== (Entity& other) {
|
inline bool operator== (Entity& other) {
|
||||||
return m_entity == other.m_entity;
|
return m_entity == other.m_entity;// && other.m_scene == m_scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool isValid() {
|
||||||
|
if (m_scene == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return m_scene->m_registry.valid(m_entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user