This commit is contained in:
Isuru Samarathunga
2025-11-11 09:24:14 +05:30
parent 67cb23d589
commit 9d6f525b81
33 changed files with 654 additions and 285 deletions

View File

@ -5,7 +5,11 @@ set(SRC_FILES
"imp/cpp/Project.cpp" "imp/cpp/Project.cpp"
"imp/cpp/UI/UI.cpp" "imp/cpp/UI/UI.cpp"
"imp/cpp/UI/View/Main.cpp" "imp/cpp/UI/Popup.cpp"
"imp/cpp/UI/Window.cpp"
"imp/cpp/UI/TabContainer.cpp"
"imp/cpp/UI/View/IView.cpp"
"imp/cpp/UI/View/Asset.cpp" "imp/cpp/UI/View/Asset.cpp"
"imp/cpp/UI/View/AssetBrowser.cpp" "imp/cpp/UI/View/AssetBrowser.cpp"
"imp/cpp/UI/View/Console.cpp" "imp/cpp/UI/View/Console.cpp"
@ -21,6 +25,8 @@ set(SRC_FILES
"imp/cpp/Vendor/imgui/imgui_widgets.cpp" "imp/cpp/Vendor/imgui/imgui_widgets.cpp"
"imp/cpp/Vendor/imgui/backends/imgui_impl_sdl3.cpp" "imp/cpp/Vendor/imgui/backends/imgui_impl_sdl3.cpp"
"imp/cpp/Vendor/imgui/backends/imgui_impl_sdlgpu3.cpp" "imp/cpp/Vendor/imgui/backends/imgui_impl_sdlgpu3.cpp"
"imp/cpp/Vendor/FontAwesome7.cpp"
) )
add_executable(IAE_Editor ${SRC_FILES}) add_executable(IAE_Editor ${SRC_FILES})

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,108 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <UI/TabContainer.hpp>
namespace ia::iae
{
INT32 g_tabContainerCount{0};
TabContainer::TabContainer() : m_containerID(BuildString("TabContainer##", g_tabContainerCount++)), m_tabBarID(BuildString("TabBar##", g_tabContainerCount++))
{
}
VOID TabContainer::Initialize()
{
}
VOID TabContainer::Terminate()
{
for (const auto &t : m_tabViews)
RemoveTab(t->Key);
}
VOID TabContainer::Draw(IN ImVec2 position, IN ImVec2 size)
{
ImGui::Begin(m_containerID.c_str(), nullptr,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoTitleBar);
ImGui::SetWindowPos(position);
ImGui::SetWindowSize(size);
ImGui::BeginTabBar(m_tabBarID.c_str());
for (const auto &v : m_tabViews)
{
ImGuiTabItemFlags flags{};
if (m_pendingActiveTabName && m_pendingActiveTabName == v->Key)
{
flags |= ImGuiTabItemFlags_SetSelected;
m_pendingActiveTabName = nullptr;
}
if (ImGui::BeginTabItem(v->Value->IconAndName().c_str(), nullptr, flags))
{
v->Value->Render();
ImGui::EndTabItem();
m_activeTabName = v->Key.c_str();
}
}
ImGui::EndTabBar();
ImGui::End();
}
VOID TabContainer::Update()
{
for (const auto &t : m_tabViews)
t->Value->Update();
}
VOID TabContainer::ProcessEvent(IN SDL_Event *event)
{
for (const auto &t : m_tabViews)
t->Value->ProcessEvent(event);
}
VOID TabContainer::AddTab(IN CONST String &name, IN IView *view)
{
RemoveTab(name);
view->Initialize();
m_tabViews[name] = view;
if (!m_activeTabName)
m_activeTabName = name.c_str();
}
VOID TabContainer::RemoveTab(IN CONST String &name)
{
if (!m_tabViews.contains(name))
return;
if (m_tabViews[name])
m_tabViews[name]->Terminate();
delete m_tabViews[name];
m_tabViews[name] = nullptr;
}
VOID TabContainer::ChangeActiveTab(IN PCCHAR name)
{
m_pendingActiveTabName = name;
}
IView *TabContainer::GetTab(IN CONST String &name)
{
return m_tabViews[name];
}
} // namespace ia::iae

View File

@ -18,49 +18,166 @@
#include <RenderCore/RenderCore.hpp> #include <RenderCore/RenderCore.hpp>
#include <UI/UI.hpp> #include <UI/UI.hpp>
#include <UI/View/Main.hpp> #include <UI/View/Asset.hpp>
#include <UI/View/AssetBrowser.hpp>
#include <UI/View/Console.hpp>
#include <UI/View/Nodes.hpp>
#include <UI/View/Package.hpp>
#include <UI/View/Properties.hpp>
#include <UI/View/Scene.hpp>
#include <UI/TabContainer.hpp>
namespace ia::iae namespace ia::iae
{ {
View_Main g_mainView{}; STATIC CONSTEXPR PCCHAR VIEW_NAME_ASSET_BROWSER = "AssetBrowser";
STATIC CONSTEXPR PCCHAR VIEW_NAME_ASSET = "Asset";
STATIC CONSTEXPR PCCHAR VIEW_NAME_CONSOLE = "Console";
STATIC CONSTEXPR PCCHAR VIEW_NAME_NODES = "Nodes";
STATIC CONSTEXPR PCCHAR VIEW_NAME_PACKAGE = "Package";
STATIC CONSTEXPR PCCHAR VIEW_NAME_PROPERTIES = "Properties";
STATIC CONSTEXPR PCCHAR VIEW_NAME_SCENE = "SCENE";
EXTERN IVec2 g_windowExtent;
IView *UI::s_focusedView{};
TabContainer g_tabContainerB;
TabContainer g_tabContainerTL;
TabContainer g_tabContainerTM;
TabContainer g_tabContainerTR;
VOID UI::FocusAssetView()
{
g_tabContainerTR.ChangeActiveTab(VIEW_NAME_ASSET);
}
class View_Asset *UI::GetAssetView()
{
return (View_Asset*)g_tabContainerTR.GetTab(VIEW_NAME_ASSET);
}
VOID UI::Initialize() VOID UI::Initialize()
{ {
g_mainView.Initialize(); g_tabContainerB.Initialize();
g_tabContainerTL.Initialize();
g_tabContainerTM.Initialize();
g_tabContainerTR.Initialize();
g_tabContainerB.AddTab<View_AssetBrowser>(VIEW_NAME_ASSET_BROWSER);
g_tabContainerB.AddTab<View_Console>(VIEW_NAME_CONSOLE);
g_tabContainerTL.AddTab<View_Nodes>(VIEW_NAME_NODES);
g_tabContainerTL.AddTab<View_Package>(VIEW_NAME_PACKAGE);
g_tabContainerTM.AddTab<View_Scene>(VIEW_NAME_SCENE);
g_tabContainerTR.AddTab<View_Properties>(VIEW_NAME_PROPERTIES);
g_tabContainerTR.AddTab<View_Asset>(VIEW_NAME_ASSET);
} }
VOID UI::Terminate() VOID UI::Terminate()
{ {
g_mainView.Terminate(); g_tabContainerB.Terminate();
g_tabContainerTL.Terminate();
g_tabContainerTM.Terminate();
g_tabContainerTR.Terminate();
} }
VOID UI::Update() VOID UI::Update()
{ {
g_tabContainerB.Update();
g_tabContainerTL.Update();
g_tabContainerTM.Update();
g_tabContainerTR.Update();
}
VOID UI::ProcessEvent(IN SDL_Event *event)
{
g_tabContainerB.ProcessEvent(event);
g_tabContainerTL.ProcessEvent(event);
g_tabContainerTM.ProcessEvent(event);
g_tabContainerTR.ProcessEvent(event);
} }
VOID UI::Draw() VOID UI::Draw()
{ {
if (ImGui::BeginMainMenuBar()) DrawMenuBar();
{
if (ImGui::BeginMenu("File"))
{
if (ImGui::MenuItem("New Scene", nullptr, nullptr))
{
}
//padY();
if (ImGui::MenuItem("Open Scene", nullptr, nullptr))
{
}
//padY();
ImGui::Separator();
//padY();
if (ImGui::MenuItem("Exit", nullptr, nullptr))
SDL_Quit();
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
g_mainView.Render(); g_tabContainerB.Draw({0.0f, LAYOUT_TOP_MIDDLE_VIEW_EXTENT.y * g_windowExtent.y + MENUBAR_HEIGHT},
{g_windowExtent.x * LAYOUT_BOTTOM_VIEW_EXTENT.x,
g_windowExtent.y * LAYOUT_BOTTOM_VIEW_EXTENT.y - MENUBAR_HEIGHT});
g_tabContainerTL.Draw({0.0f, MENUBAR_HEIGHT}, {g_windowExtent.x * LAYOUT_TOP_LEFT_VIEW_EXTENT.x,
g_windowExtent.y * LAYOUT_TOP_LEFT_VIEW_EXTENT.y});
g_tabContainerTM.Draw(
{g_windowExtent.x * LAYOUT_TOP_LEFT_VIEW_EXTENT.x, MENUBAR_HEIGHT},
{g_windowExtent.x * LAYOUT_TOP_MIDDLE_VIEW_EXTENT.x, g_windowExtent.y * LAYOUT_TOP_MIDDLE_VIEW_EXTENT.y});
g_tabContainerTR.Draw(
{g_windowExtent.x * (1.0f - LAYOUT_TOP_RIGHT_VIEW_EXTENT.x), MENUBAR_HEIGHT},
{g_windowExtent.x * LAYOUT_TOP_RIGHT_VIEW_EXTENT.x, g_windowExtent.y * LAYOUT_TOP_RIGHT_VIEW_EXTENT.y});
}
VOID UI::DrawMenuBar()
{
if (ImGui::BeginMainMenuBar())
{
if (ImGui::BeginMenu("File"))
{
if (ImGui::MenuItem("New Scene", nullptr, nullptr))
{
}
UI::PadY();
if (ImGui::MenuItem("Open Scene", nullptr, nullptr))
{
}
UI::PadY();
ImGui::Separator();
UI::PadY();
if (ImGui::MenuItem("Exit", nullptr, nullptr))
SDL_Quit();
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
}
VOID UI::PadX(IN FLOAT32 v)
{
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + v);
}
VOID UI::PadY(IN FLOAT32 v)
{
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + v);
}
VOID UI::AlignCursorLeft(IN CONST ImRect &rect)
{
ImGui::SetCursorPosX(rect.GetTL().x);
}
VOID UI::AlignCursorRight(IN CONST ImRect &rect, IN FLOAT32 width)
{
ImGui::SetCursorPosX(rect.GetWidth() - width);
}
VOID UI::AlignCursorTop(IN CONST ImRect &rect)
{
ImGui::SetCursorPosY(rect.AsVec4().y);
}
VOID UI::AlignCursorBottom(IN CONST ImRect &rect, IN FLOAT32 height)
{
ImGui::SetCursorPosY(rect.GetHeight() - height);
}
VOID UI::AlignCursorHCenter(IN CONST ImRect &rect, IN FLOAT32 width)
{
ImGui::SetCursorPosX((rect.GetWidth() - width) / 2.0f);
}
VOID UI::AlignCursorVCenter(IN CONST ImRect &rect, IN FLOAT32 height)
{
ImGui::SetCursorPosY((rect.GetHeight() - height) / 2.0f);
} }
} // namespace ia::iae } // namespace ia::iae

View File

@ -18,6 +18,11 @@
namespace ia::iae namespace ia::iae
{ {
struct AssetCacheEntry
{
};
VOID View_Asset::Initialize() VOID View_Asset::Initialize()
{ {
SetName("Asset"); SetName("Asset");
@ -32,6 +37,33 @@ namespace ia::iae
{ {
PreRender(); PreRender();
if(m_assetPath.empty())
{
PostRender();
return;
}
ImGui::Text("%s", m_assetPath.filename().string().c_str());
PostRender(); PostRender();
} }
VOID View_Asset::Update()
{
}
VOID View_Asset::OnEvent(IN SDL_Event *event)
{
}
VOID View_Asset::Open(IN Path path)
{
Close();
m_assetPath = path;
}
VOID View_Asset::Close()
{
m_assetPath = Path();
}
} // namespace ia::iae } // namespace ia::iae

View File

@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Editor.hpp>
#include <UI/View/AssetBrowser.hpp> #include <UI/View/AssetBrowser.hpp>
namespace ia::iae namespace ia::iae
@ -51,8 +52,15 @@ namespace ia::iae
for (const auto &t : m_assetDirectoryFiles) for (const auto &t : m_assetDirectoryFiles)
{ {
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 1.75f); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 1.75f);
if (ImGui::Selectable(t.IconAndName.c_str()) && t.IsDirectory) if (ImGui::Selectable(t.IconAndName.c_str()))
ChangeCurrentOpenDirectory(t.Path); {
if (t.IsDirectory)
{
ChangeCurrentOpenDirectory(t.Path);
break;
}
OpenAsset(t.Path);
}
} }
} }
ImGui::EndChild(); ImGui::EndChild();
@ -84,6 +92,14 @@ namespace ia::iae
PostRender(); PostRender();
} }
VOID View_AssetBrowser::Update()
{
}
VOID View_AssetBrowser::OnEvent(IN SDL_Event *event)
{
}
VOID View_AssetBrowser::ChangeCurrentOpenDirectory(IN CONST std::filesystem::path &path) VOID View_AssetBrowser::ChangeCurrentOpenDirectory(IN CONST std::filesystem::path &path)
{ {
m_currentOpenDirectoryPath = path; m_currentOpenDirectoryPath = path;
@ -131,6 +147,6 @@ namespace ia::iae
VOID View_AssetBrowser::OpenAsset(IN CONST std::filesystem::path &path) VOID View_AssetBrowser::OpenAsset(IN CONST std::filesystem::path &path)
{ {
Editor::Instance().OpenAsset(path);
} }
} // namespace ia::iae } // namespace ia::iae

View File

@ -34,4 +34,13 @@ namespace ia::iae
PostRender(); PostRender();
} }
VOID View_Console::Update(){
}
VOID View_Console::OnEvent(IN SDL_Event *event)
{
}
} // namespace ia::iae } // namespace ia::iae

View File

@ -14,17 +14,25 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <UI/View/IView.hpp> #include <UI/View/IView.hpp>
namespace ia::iae namespace ia::iae
{ {
class View_Main : public IView VOID IView::ProcessEvent(IN SDL_Event *event)
{ {
public: if (UI::GetFocusedView() == this)
VOID Initialize(); OnEvent(event);
VOID Terminate(); }
VOID Render();
}; VOID IView::SetIcon(IN PCCHAR icon)
{
m_icon = icon;
m_iconAndName = BuildString(m_icon, " ", m_name);
}
VOID IView::SetName(IN CONST String &name)
{
m_name = name;
m_iconAndName = m_icon ? BuildString(m_icon, " ", m_name) : m_name;
}
} // namespace ia::iae } // namespace ia::iae

View File

@ -1,161 +0,0 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <UI/View/AssetBrowser.hpp>
#include <UI/View/Main.hpp>
#include <UI/View/Scene.hpp>
#include <UI/View/Asset.hpp>
#include <UI/View/Console.hpp>
#include <UI/View/Nodes.hpp>
#include <UI/View/Package.hpp>
#include <UI/View/Properties.hpp>
namespace ia::iae
{
EXTERN IVec2 g_windowExtent;
View_Scene g_sceneView;
View_Asset g_assetView;
View_Console g_consoleView;
View_Nodes g_nodesView;
View_Package g_packageView;
View_Properties g_propertiesView;
View_AssetBrowser g_assetBrowserView;
Vector<IView *> g_bViews = {&g_assetBrowserView, &g_consoleView};
Vector<IView *> g_tlViews = {&g_nodesView, &g_packageView};
Vector<IView *> g_tmViews = {&g_sceneView};
Vector<IView *> g_trViews = {&g_propertiesView, &g_assetView};
VOID View_Main::Initialize()
{
for (const auto &v : g_bViews)
v->Initialize();
for (const auto &v : g_tlViews)
v->Initialize();
for (const auto &v : g_tmViews)
v->Initialize();
for (const auto &v : g_trViews)
v->Initialize();
}
VOID View_Main::Terminate()
{
for (const auto &v : g_bViews)
v->Terminate();
for (const auto &v : g_tlViews)
v->Terminate();
for (const auto &v : g_tmViews)
v->Terminate();
for (const auto &v : g_trViews)
v->Terminate();
}
VOID View_Main::Render()
{
PreRender();
{ // Top Left Window
ImGui::Begin("TL_Window", nullptr,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoTitleBar);
ImGui::SetWindowPos({0.0f, MENUBAR_HEIGHT});
ImGui::SetWindowSize(
{g_windowExtent.x * LAYOUT_TOP_LEFT_VIEW_EXTENT.x, g_windowExtent.y * LAYOUT_TOP_LEFT_VIEW_EXTENT.y});
ImGui::BeginTabBar("TL_TabBar");
for (const auto &v : g_tlViews)
{
if (ImGui::BeginTabItem(v->IconAndName().c_str()))
{
v->Render();
ImGui::EndTabItem();
}
}
ImGui::EndTabBar();
ImGui::End();
}
{ // Top Middle Window
ImGui::Begin("TM_Window", nullptr,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoTitleBar);
ImGui::SetWindowPos({g_windowExtent.x * LAYOUT_TOP_LEFT_VIEW_EXTENT.x, MENUBAR_HEIGHT});
ImGui::SetWindowSize({g_windowExtent.x * LAYOUT_TOP_MIDDLE_VIEW_EXTENT.x,
g_windowExtent.y * LAYOUT_TOP_MIDDLE_VIEW_EXTENT.y});
ImGui::BeginTabBar("TM_TabBar");
for (const auto &v : g_tmViews)
{
if (ImGui::BeginTabItem(v->IconAndName().c_str()))
{
v->Render();
ImGui::EndTabItem();
}
}
ImGui::EndTabBar();
ImGui::End();
}
{ // Top Right Window
ImGui::Begin("TR_Window", nullptr,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoTitleBar);
ImGui::SetWindowPos({g_windowExtent.x * (1.0f - LAYOUT_TOP_RIGHT_VIEW_EXTENT.x), MENUBAR_HEIGHT});
ImGui::SetWindowSize(
{g_windowExtent.x * LAYOUT_TOP_RIGHT_VIEW_EXTENT.x, g_windowExtent.y * LAYOUT_TOP_RIGHT_VIEW_EXTENT.y});
ImGui::BeginTabBar("TR_TabBar");
for (const auto &v : g_trViews)
{
if (ImGui::BeginTabItem(v->IconAndName().c_str()))
{
v->Render();
ImGui::EndTabItem();
}
}
ImGui::EndTabBar();
ImGui::End();
}
{ // Bottom Window
ImGui::Begin("B_Window", nullptr,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoTitleBar);
ImGui::SetWindowPos({0.0f, LAYOUT_TOP_MIDDLE_VIEW_EXTENT.y * g_windowExtent.y + MENUBAR_HEIGHT});
ImGui::SetWindowSize(
{g_windowExtent.x * LAYOUT_BOTTOM_VIEW_EXTENT.x, g_windowExtent.y * LAYOUT_BOTTOM_VIEW_EXTENT.y - MENUBAR_HEIGHT});
ImGui::BeginTabBar("B_TabBar");
for (const auto &v : g_bViews)
{
if (ImGui::BeginTabItem(v->IconAndName().c_str()))
{
v->Render();
ImGui::EndTabItem();
}
}
ImGui::EndTabBar();
ImGui::End();
}
PostRender();
}
} // namespace ia::iae

View File

@ -34,4 +34,13 @@ namespace ia::iae
PostRender(); PostRender();
} }
VOID View_Nodes::Update(){
}
VOID View_Nodes::OnEvent(IN SDL_Event *event)
{
}
} // namespace ia::iae } // namespace ia::iae

View File

@ -34,4 +34,13 @@ namespace ia::iae
PostRender(); PostRender();
} }
VOID View_Package::Update(){
}
VOID View_Package::OnEvent(IN SDL_Event *event)
{
}
} // namespace ia::iae } // namespace ia::iae

View File

@ -34,4 +34,13 @@ namespace ia::iae
PostRender(); PostRender();
} }
VOID View_Properties::Update(){
}
VOID View_Properties::OnEvent(IN SDL_Event *event)
{
}
} // namespace ia::iae } // namespace ia::iae

View File

@ -14,24 +14,86 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Editor.hpp>
#include <UI/View/Scene.hpp> #include <UI/View/Scene.hpp>
#include <RenderCore/RenderCore.hpp>
#include <IAEngine/LibInterface.hpp>
namespace ia::iae namespace ia::iae
{ {
VOID View_Scene::Initialize() VOID View_Scene::Initialize()
{ {
SetName("Scene"); SetName("Scene");
SetIcon(ICON_FA_HASHTAG); SetIcon(ICON_FA_HASHTAG);
IAEngine::__Initialize(SCENE_EDITOR_RESOULTION, Editor::Instance().GetActiveProject()->AssetDirectory());
m_gamePreviewTexture = new RDC_Texture(RDC_Texture::EType::SAMPLED, SCENE_EDITOR_RESOULTION.x, SCENE_EDITOR_RESOULTION.y);
} }
VOID View_Scene::Terminate() VOID View_Scene::Terminate()
{ {
delete m_gamePreviewTexture;
} }
VOID View_Scene::Render() VOID View_Scene::Render()
{ {
PreRender(); PreRender();
ImGui::Image(m_gamePreviewTexture->GetHandle(), {SCENE_EDITOR_RESOULTION.x, SCENE_EDITOR_RESOULTION.y});
PostRender(); PostRender();
} }
VOID View_Scene::Update()
{
STATIC INT32 frameCounter{0};
IAEngine::__Update();
frameCounter++;
if (frameCounter >= 60)
{
frameCounter = 0;
IAEngine::__FixedUpdate();
}
IAEngine::__RenderToTexture(m_gamePreviewTexture->GetHandle());
}
VOID View_Scene::OnEvent(IN SDL_Event *event)
{
IAEngine::__ProcessEvent(event);
}
} // namespace ia::iae } // namespace ia::iae
C_DECL(GameRequestedConfig *Game_GetConfigRequest())
{
return nullptr;
}
C_DECL(VOID Game_OnInitialize())
{
}
C_DECL(VOID Game_OnTerminate())
{
}
C_DECL(VOID Game_OnDebugDraw())
{
}
C_DECL(VOID Game_OnFixedUpdate())
{
}
C_DECL(VOID Game_OnUpdate(IN FLOAT32 deltaTime))
{
}
C_DECL(VOID Game_OnResize(IN INT32 newWidth, IN INT32 newHeight))
{
}

File diff suppressed because one or more lines are too long

View File

@ -21,7 +21,12 @@
#include <Vendor/imgui/imgui.h> #include <Vendor/imgui/imgui.h>
#include <Vendor/IconsFontAwesome7.h> #include <Vendor/IconsFontAwesome7.h>
#include <SDL3/SDL.h>
#include <filesystem>
namespace ia::iae namespace ia::iae
{ {
namespace fs = std::filesystem;
using Path = std::filesystem::path;
} }

View File

@ -33,6 +33,8 @@ namespace ia::iae
public: public:
VOID LoadProject(IN CONST String &directory); VOID LoadProject(IN CONST String &directory);
VOID OpenAsset(IN Path path);
public: public:
CONST Project *GetActiveProject() CONST CONST Project *GetActiveProject() CONST
{ {

View File

@ -17,6 +17,7 @@
#pragma once #pragma once
#include <Base.hpp> #include <Base.hpp>
#include <Vendor/imgui/imgui_internal.h>
namespace ia::iae namespace ia::iae
{ {

View File

@ -0,0 +1,55 @@
// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <UI/View/IView.hpp>
namespace ia::iae
{
class TabContainer
{
public:
TabContainer();
VOID Initialize();
VOID Terminate();
VOID Draw(IN ImVec2 position, IN ImVec2 size);
VOID Update();
VOID ProcessEvent(IN SDL_Event *event);
template<typename ViewType> INLINE VOID AddTab(IN CONST String &name);
IView *GetTab(IN CONST String &name);
VOID RemoveTab(IN CONST String &name);
VOID ChangeActiveTab(IN PCCHAR name);
private:
CONST String m_tabBarID;
CONST String m_containerID;
PCCHAR m_activeTabName{};
PCCHAR m_pendingActiveTabName{};
Map<String, IView *> m_tabViews;
private:
VOID AddTab(IN CONST String &name, IN IView *view);
};
template<typename ViewType> VOID TabContainer::AddTab(IN CONST String &name)
{
AddTab(name, new ViewType());
}
} // namespace ia::iae

View File

@ -22,11 +22,42 @@ namespace ia::iae
{ {
class UI class UI
{ {
public: public:
STATIC VOID PadX(IN FLOAT32 v = 5.0f);
STATIC VOID PadY(IN FLOAT32 v = 5.0f);
STATIC VOID AlignCursorLeft(IN CONST ImRect &rect);
STATIC VOID AlignCursorRight(IN CONST ImRect &rect, IN FLOAT32 width);
STATIC VOID AlignCursorTop(IN CONST ImRect &rect);
STATIC VOID AlignCursorBottom(IN CONST ImRect &rect, IN FLOAT32 height);
STATIC VOID AlignCursorHCenter(IN CONST ImRect &rect, IN FLOAT32 width);
STATIC VOID AlignCursorVCenter(IN CONST ImRect &rect, IN FLOAT32 height);
public:
STATIC VOID FocusAssetView();
STATIC class View_Asset *GetAssetView();
STATIC class IView *GetFocusedView()
{
return s_focusedView;
}
private:
STATIC class IView *s_focusedView;
private:
STATIC VOID Initialize(); STATIC VOID Initialize();
STATIC VOID Terminate(); STATIC VOID Terminate();
STATIC VOID Update();
STATIC VOID Draw(); STATIC VOID Draw();
STATIC VOID Update();
STATIC VOID ProcessEvent(IN SDL_Event *event);
friend class Editor;
private:
STATIC VOID DrawMenuBar();
}; };
} } // namespace ia::iae

View File

@ -22,9 +22,20 @@ namespace ia::iae
{ {
class View_Asset : public IView class View_Asset : public IView
{ {
public:
VOID Open(IN Path path);
VOID Close();
public: public:
VOID Initialize(); VOID Initialize();
VOID Terminate(); VOID Terminate();
VOID Render(); VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
private:
Path m_assetPath{};
}; };
} } // namespace ia::iae

View File

@ -37,6 +37,10 @@ namespace ia::iae
VOID Initialize(); VOID Initialize();
VOID Terminate(); VOID Terminate();
VOID Render(); VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
private: private:
VOID ChangeCurrentOpenDirectory(IN CONST std::filesystem::path &path); VOID ChangeCurrentOpenDirectory(IN CONST std::filesystem::path &path);

View File

@ -26,5 +26,9 @@ namespace ia::iae
VOID Initialize(); VOID Initialize();
VOID Terminate(); VOID Terminate();
VOID Render(); VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
}; };
} }

View File

@ -16,29 +16,25 @@
#pragma once #pragma once
#include <UI/Base.hpp> #include <UI/UI.hpp>
namespace ia::iae namespace ia::iae
{ {
class IView class IView
{ {
protected:
PURE_VIRTUAL(VOID OnEvent(IN SDL_Event *event));
public: public:
PURE_VIRTUAL(VOID Initialize()); PURE_VIRTUAL(VOID Initialize());
PURE_VIRTUAL(VOID Terminate()); PURE_VIRTUAL(VOID Terminate());
PURE_VIRTUAL(VOID Render()); PURE_VIRTUAL(VOID Render());
PURE_VIRTUAL(VOID Update());
public: public:
VOID SetIcon(IN PCCHAR icon) VOID SetIcon(IN PCCHAR icon);
{ VOID SetName(IN CONST String &name);
m_icon = icon; VIRTUAL VOID ProcessEvent(IN SDL_Event *event);
m_iconAndName = BuildString(m_icon, " ", m_name);
}
VOID SetName(IN CONST String &name)
{
m_name = name;
m_iconAndName = m_icon ? BuildString(m_icon, " ", m_name) : m_name;
}
public: public:
CONST String &Name() CONST CONST String &Name() CONST
@ -66,14 +62,21 @@ namespace ia::iae
String m_name{}; String m_name{};
PCCHAR m_icon{}; PCCHAR m_icon{};
String m_iconAndName{}; String m_iconAndName{};
public:
VIRTUAL ~IView()
{
}
}; };
VOID IView::PreRender() VOID IView::PreRender()
{ {
m_extent = ImGui::GetWindowSize(); m_extent = ImGui::GetWindowSize();
ImGui::BeginChild("##");
} }
VOID IView::PostRender() VOID IView::PostRender()
{ {
ImGui::EndChild();
} }
} // namespace ia::iae } // namespace ia::iae

View File

@ -26,5 +26,9 @@ namespace ia::iae
VOID Initialize(); VOID Initialize();
VOID Terminate(); VOID Terminate();
VOID Render(); VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
}; };
} }

View File

@ -26,5 +26,9 @@ namespace ia::iae
VOID Initialize(); VOID Initialize();
VOID Terminate(); VOID Terminate();
VOID Render(); VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
}; };
} }

View File

@ -26,5 +26,9 @@ namespace ia::iae
VOID Initialize(); VOID Initialize();
VOID Terminate(); VOID Terminate();
VOID Render(); VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
}; };
} }

View File

@ -26,5 +26,18 @@ namespace ia::iae
VOID Initialize(); VOID Initialize();
VOID Terminate(); VOID Terminate();
VOID Render(); VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
public:
VOID ProcessEvent(IN SDL_Event *event)
{
OnEvent(event);
}
private:
class RDC_Texture* m_gamePreviewTexture;
}; };
} } // namespace ia::iae

View File

@ -16,6 +16,7 @@
#include <GameData.hpp> #include <GameData.hpp>
#include <IAEngine/IAEngine.hpp> #include <IAEngine/IAEngine.hpp>
#include <IAEngine/AssetManager.hpp>
#include <ConfigData/ConfigData.hpp> #include <ConfigData/ConfigData.hpp>
@ -45,7 +46,7 @@ namespace ia::iae
BOOL GameData::LoadSceneData() BOOL GameData::LoadSceneData()
{ {
for (const auto &entry : std::filesystem::directory_iterator("Assets/Scenes/")) for (const auto &entry : std::filesystem::directory_iterator(BuildString(IAEngine::GetAssetManager()->GetAssetDirectory(), "/Scenes/").c_str()))
{ {
const auto scene = ParseScene(entry.path().string().c_str()); const auto scene = ParseScene(entry.path().string().c_str());
if (!scene) if (!scene)
@ -59,7 +60,7 @@ namespace ia::iae
BOOL GameData::LoadAssetData() BOOL GameData::LoadAssetData()
{ {
auto xml = ConfigData::LoadFromFile("Assets/Assets.xml"); auto xml = ConfigData::LoadFromFile(BuildString(IAEngine::GetAssetManager()->GetAssetDirectory(), "/Assets.xml"));
if (!xml) if (!xml)
return false; return false;

View File

@ -38,12 +38,6 @@ namespace ia::iae
AssetManager* g_assetManager{}; AssetManager* g_assetManager{};
AssetManager* g_defaultAssetManager{}; AssetManager* g_defaultAssetManager{};
#if defined(__IA_DEBUG) && __IA_DEBUG
BOOL g_isDebugMode = true;
#else
BOOL g_isDebugMode = false;
#endif
BOOL g_isHeadlessMode = false; BOOL g_isHeadlessMode = false;
INT32 Run(IN CONST String &name, IN CONST String &packageName, IN CONST String &developerName, INT32 Run(IN CONST String &name, IN CONST String &packageName, IN CONST String &developerName,
@ -82,7 +76,7 @@ namespace ia::iae
// EmbeddedResources::Initialize(); // EmbeddedResources::Initialize();
IAEngine::__Initialize("./Assets/"); IAEngine::__Initialize(g_designViewport, "./Assets/");
SDL_Event event{}; SDL_Event event{};
while (true) while (true)
@ -117,9 +111,10 @@ namespace ia::iae
namespace ia::iae namespace ia::iae
{ {
VOID IAEngine::__Initialize(IN CONST String& assetDirectory) VOID IAEngine::__Initialize(IN IVec2 designResolution, IN CONST String& assetDirectory)
{ {
g_isHeadlessMode = false; g_isHeadlessMode = false;
g_designViewport = designResolution;
RDC::Initialize(IVec2{g_designViewport.x, g_designViewport.y}, g_windowHandle, g_isDebugMode); RDC::Initialize(IVec2{g_designViewport.x, g_designViewport.y}, g_windowHandle, g_isDebugMode);

View File

@ -183,6 +183,12 @@ namespace ia::iae
STATIC Vector<UINT8> Inflate(IN PCUINT8 data, IN SIZE_T dataSize); STATIC Vector<UINT8> Inflate(IN PCUINT8 data, IN SIZE_T dataSize);
STATIC Vector<UINT8> Deflate(IN PCUINT8 data, IN SIZE_T dataSize); STATIC Vector<UINT8> Deflate(IN PCUINT8 data, IN SIZE_T dataSize);
public:
CONST String &GetAssetDirectory() CONST
{
return m_assetDirectory;
}
protected: protected:
String m_assetDirectory; String m_assetDirectory;
Vector<IAsset *> m_assets; Vector<IAsset *> m_assets;

View File

@ -27,4 +27,9 @@
namespace ia::iae namespace ia::iae
{ {
} #if (defined(__IA_DEBUG) && __IA_DEBUG) || (defined(__IAENGINE_DEBUG))
STATIC CONSTEXPR BOOL g_isDebugMode = true;
#else
STATIC CONSTEXPR BOOL g_isDebugMode = false;
#endif
} // namespace ia::iae

View File

@ -45,7 +45,7 @@ namespace ia::iae
IN BOOL flipH = false, IN BOOL flipV = false, IN Vec2 uvOffset = {}); IN BOOL flipH = false, IN BOOL flipV = false, IN Vec2 uvOffset = {});
public: public:
STATIC VOID __Initialize(IN CONST String& assetDirectory); STATIC VOID __Initialize(IN IVec2 designResolution, IN CONST String& assetDirectory);
STATIC VOID __InitializeHeadless(IN CONST String& assetDirectory); STATIC VOID __InitializeHeadless(IN CONST String& assetDirectory);
STATIC VOID __Terminate(); STATIC VOID __Terminate();
STATIC VOID __RenderToWindow(); STATIC VOID __RenderToWindow();

View File

@ -52,6 +52,9 @@ namespace ia::iae
VOID RDC::Initialize(IN IVec2 viewportExtent, IN SDL_Window *windowHandle, IN BOOL isDebugMode) VOID RDC::Initialize(IN IVec2 viewportExtent, IN SDL_Window *windowHandle, IN BOOL isDebugMode)
{ {
if(s_windowHandle)
return;
EmbeddedResources::Initialize(); EmbeddedResources::Initialize();
s_windowHandle = windowHandle; s_windowHandle = windowHandle;