diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index a354df3c..4fdcecdb 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -39,6 +39,7 @@ add_executable(${PROJECT_NAME} WIN32 src/panels/MenuBar.cpp src/panels/HierarchyPanel.cpp src/panels/SceneViewPanel.cpp + src/panels/GameViewPanel.cpp src/panels/InspectorPanel.cpp src/panels/ConsolePanel.cpp src/panels/ProjectPanel.cpp diff --git a/ui/src/Application.cpp b/ui/src/Application.cpp index cf231c04..47074823 100644 --- a/ui/src/Application.cpp +++ b/ui/src/Application.cpp @@ -47,6 +47,7 @@ bool Application::Initialize(HWND hwnd) { m_menuBar = std::make_unique(); m_hierarchyPanel = std::make_unique(); m_sceneViewPanel = std::make_unique(); + m_gameViewPanel = std::make_unique(); m_inspectorPanel = std::make_unique(); m_consolePanel = std::make_unique(); m_projectPanel = std::make_unique(); @@ -277,6 +278,7 @@ void Application::SetupDockspace() { ImGui::DockBuilderDockWindow("Hierarchy", dockLeft); ImGui::DockBuilderDockWindow("Scene", dockMain); + ImGui::DockBuilderDockWindow("Game", dockMain); ImGui::DockBuilderDockWindow("Inspector", dockRight); ImGui::DockBuilderDockWindow("Console", dockBottom); ImGui::DockBuilderDockWindow("Project", dockBottom); @@ -292,6 +294,7 @@ void Application::RenderUI() { m_hierarchyPanel->Render(); m_sceneViewPanel->Render(); + m_gameViewPanel->Render(); m_inspectorPanel->Render(); m_consolePanel->Render(); m_projectPanel->Render(); diff --git a/ui/src/Application.h b/ui/src/Application.h index 671da52f..8e1d92dd 100644 --- a/ui/src/Application.h +++ b/ui/src/Application.h @@ -10,6 +10,7 @@ #include "panels/MenuBar.h" #include "panels/HierarchyPanel.h" #include "panels/SceneViewPanel.h" +#include "panels/GameViewPanel.h" #include "panels/InspectorPanel.h" #include "panels/ConsolePanel.h" #include "panels/ProjectPanel.h" @@ -55,6 +56,7 @@ private: std::unique_ptr m_menuBar; std::unique_ptr m_hierarchyPanel; std::unique_ptr m_sceneViewPanel; + std::unique_ptr m_gameViewPanel; std::unique_ptr m_inspectorPanel; std::unique_ptr m_consolePanel; std::unique_ptr m_projectPanel; diff --git a/ui/src/panels/GameViewPanel.cpp b/ui/src/panels/GameViewPanel.cpp new file mode 100644 index 00000000..e1f89f38 --- /dev/null +++ b/ui/src/panels/GameViewPanel.cpp @@ -0,0 +1,31 @@ +#include "GameViewPanel.h" +#include +#include + +namespace UI { + +GameViewPanel::GameViewPanel() : Panel("Game") {} + +void GameViewPanel::Render() { + ImGui::Begin(m_name.c_str(), &m_isOpen, ImGuiWindowFlags_None); + + RenderGameView(); + + ImGui::End(); +} + +void GameViewPanel::RenderGameView() { + ImVec2 canvasSize = ImGui::GetContentRegionAvail(); + ImDrawList* drawList = ImGui::GetWindowDrawList(); + ImVec2 canvasPos = ImGui::GetCursorScreenPos(); + + ImU32 bgColor = IM_COL32(20, 20, 25, 255); + drawList->AddRectFilled(canvasPos, ImVec2(canvasPos.x + canvasSize.x, canvasPos.y + canvasSize.y), bgColor); + + const char* text = "Game View (Press Play)"; + ImVec2 textSize = ImGui::CalcTextSize(text); + ImVec2 textPos(canvasPos.x + (canvasSize.x - textSize.x) * 0.5f, canvasPos.y + (canvasSize.y - textSize.y) * 0.5f); + drawList->AddText(textPos, IM_COL32(128, 128, 128, 255), text); +} + +} diff --git a/ui/src/panels/GameViewPanel.h b/ui/src/panels/GameViewPanel.h new file mode 100644 index 00000000..f0797cdf --- /dev/null +++ b/ui/src/panels/GameViewPanel.h @@ -0,0 +1,16 @@ +#pragma once + +#include "Panel.h" + +namespace UI { + +class GameViewPanel : public Panel { +public: + GameViewPanel(); + void Render() override; + +private: + void RenderGameView(); +}; + +} diff --git a/ui/src/panels/SceneViewPanel.cpp b/ui/src/panels/SceneViewPanel.cpp index 3698b703..97ff809e 100644 --- a/ui/src/panels/SceneViewPanel.cpp +++ b/ui/src/panels/SceneViewPanel.cpp @@ -9,38 +9,14 @@ SceneViewPanel::SceneViewPanel() : Panel("Scene") {} void SceneViewPanel::Render() { ImGui::Begin(m_name.c_str(), &m_isOpen, ImGuiWindowFlags_None); - if (ImGui::BeginTabBar("SceneGameTabs")) { - if (ImGui::BeginTabItem("Scene")) { - m_isSceneView = true; - ImVec2 canvasSize = ImGui::GetContentRegionAvail(); - ImDrawList* drawList = ImGui::GetWindowDrawList(); - ImVec2 canvasPos = ImGui::GetCursorScreenPos(); - - ImU32 bgColor = IM_COL32(30, 30, 30, 255); - drawList->AddRectFilled(canvasPos, ImVec2(canvasPos.x + canvasSize.x, canvasPos.y + canvasSize.y), bgColor); - - RenderGrid(); - - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Game")) { - m_isSceneView = false; - ImVec2 canvasSize = ImGui::GetContentRegionAvail(); - ImDrawList* drawList = ImGui::GetWindowDrawList(); - ImVec2 canvasPos = ImGui::GetCursorScreenPos(); - - ImU32 bgColor = IM_COL32(20, 20, 25, 255); - drawList->AddRectFilled(canvasPos, ImVec2(canvasPos.x + canvasSize.x, canvasPos.y + canvasSize.y), bgColor); - - const char* text = "Game View (Press Play)"; - ImVec2 textSize = ImGui::CalcTextSize(text); - ImVec2 textPos(canvasPos.x + (canvasSize.x - textSize.x) * 0.5f, canvasPos.y + (canvasSize.y - textSize.y) * 0.5f); - drawList->AddText(textPos, IM_COL32(128, 128, 128, 255), text); - - ImGui::EndTabItem(); - } - ImGui::EndTabBar(); - } + ImVec2 canvasSize = ImGui::GetContentRegionAvail(); + ImDrawList* drawList = ImGui::GetWindowDrawList(); + ImVec2 canvasPos = ImGui::GetCursorScreenPos(); + + ImU32 bgColor = IM_COL32(30, 30, 30, 255); + drawList->AddRectFilled(canvasPos, ImVec2(canvasPos.x + canvasSize.x, canvasPos.y + canvasSize.y), bgColor); + + RenderGrid(); ImGui::End(); } diff --git a/ui/src/panels/SceneViewPanel.h b/ui/src/panels/SceneViewPanel.h index e0caede0..d81c47ec 100644 --- a/ui/src/panels/SceneViewPanel.h +++ b/ui/src/panels/SceneViewPanel.h @@ -10,7 +10,6 @@ public: void Render() override; private: - bool m_isSceneView = true; void RenderGrid(); };