diff --git a/Editor/src/EditorContext.h b/Editor/src/EditorContext.h index a3df695..2175397 100644 --- a/Editor/src/EditorContext.h +++ b/Editor/src/EditorContext.h @@ -1,6 +1,7 @@ #pragma once struct EditorContext { std::shared_ptr CurrentProject; + Scene MainScene; EditorContext() = default; diff --git a/Editor/src/SceneRuntime.h b/Editor/src/SceneRuntime.h index 3315017..5f3a716 100644 --- a/Editor/src/SceneRuntime.h +++ b/Editor/src/SceneRuntime.h @@ -5,10 +5,10 @@ #include "../../YoggieEngine/src/Scene/Entity.h" #include "Project.h" -class SceneRuntime : public ApplicationRuntime { +class EditorRuntime : public ApplicationRuntime { public: - SceneRuntime() = default; + EditorRuntime() = default; void Start() override { CurrentProject = std::make_shared("Random"); diff --git a/Editor/src/UI/widgets.cpp b/Editor/src/UI/widgets.cpp index 2d4573f..dd38810 100644 --- a/Editor/src/UI/widgets.cpp +++ b/Editor/src/UI/widgets.cpp @@ -42,8 +42,6 @@ void Inspector(entt::entity ent , Scene& scene) { ImGui::EndPopup(); } - - ImGui::NewLine(); auto component = entity.GetComponent(); @@ -62,6 +60,13 @@ void Inspector(entt::entity ent , Scene& scene) { } + if (entity.HasComponent()) { + auto& render3d = entity.GetComponent(); + if (ImGui::CollapsingHeader("Render3D", ImGuiTreeNodeFlags_DefaultOpen)) { + ImGui::ColorEdit3("Colour", glm::value_ptr(render3d.color)); + } + } + if (entity.HasComponent()) { auto& light = entity.GetComponent(); if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) { @@ -110,13 +115,8 @@ void SceneExplorer(entt::entity& selected, Scene& scene ) void Viewport(Framebuffer& framebuffer) { - unsigned int viewportWindowFlags = ImGuiWindowFlags_NoTitleBar - | ImGuiWindowFlags_NoDecoration - | ImGuiWindowFlags_NoScrollbar - | ImGuiWindowFlags_NoMove - | ImGuiWindowFlags_NoCollapse; + unsigned int viewportWindowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar ; - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 0,0 }); ImGui::Begin("Viewport", false, viewportWindowFlags); ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), ImVec2{ (float)800,(float)600 }); @@ -138,7 +138,18 @@ void Viewport(Framebuffer& framebuffer) { //ImGuizmo::Manipulate(glm::value_ptr(static_cam), glm::value_ptr(static_projection), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(trans)); ImGuizmo::ViewManipulate(glm::value_ptr(cam), 8.0f, ImVec2{ 0.0f,0.0f }, ImVec2{ 128.0f,128.0f }, 0x10101010); ImGui::End(); - ImGui::PopStyleVar(); + +} + +void GamePort(Framebuffer& framebuffer) +{ + unsigned int viewportWindowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar; + ImGui::Begin("Game", false, viewportWindowFlags); + + ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), ImVec2{ (float)800, (float)600 }); + + + ImGui::End(); } diff --git a/Editor/src/UI/widgets.h b/Editor/src/UI/widgets.h index 807e536..b6275d1 100644 --- a/Editor/src/UI/widgets.h +++ b/Editor/src/UI/widgets.h @@ -19,6 +19,8 @@ void SceneExplorer(entt::entity& selected, Scene& scene); void Viewport(Framebuffer& framebuffer); +void GamePort(Framebuffer& framebuffer); + void Settings(); void Console(); diff --git a/Editor/src/app.cpp b/Editor/src/app.cpp index 815fa38..7b17c1b 100644 --- a/Editor/src/app.cpp +++ b/Editor/src/app.cpp @@ -1,12 +1,13 @@ -#include -#include #include #include #include -#include +#include + #include -#include "../../libs/guizmo/ImGuizmo.h" +#include +#include +#include #include "UI/Widgets.h" #include "Project.h" @@ -230,6 +231,7 @@ public: //ShowStats(); Viewport(*activeRuntime.framebuffer); + GamePort(*activeRuntime.framebuffer); SceneExplorer(activeRuntime.Selected, activeRuntime.MainScene); Inspector(activeRuntime.Selected, activeRuntime.MainScene); @@ -245,7 +247,7 @@ public: private: EditorContext context; - SceneRuntime activeRuntime ; + EditorRuntime activeRuntime ; char* path = nullptr; char* savePath = nullptr; char* scenePath = nullptr;