This commit is contained in:
Isuru Samarathunga
2025-11-10 09:49:22 +05:30
parent 73d26b2f35
commit 67cb23d589
69 changed files with 9716 additions and 194 deletions

View File

View File

@ -0,0 +1,66 @@
// 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 <IAEngine/IAEngine.hpp>
#include <RenderCore/RenderCore.hpp>
#include <UI/UI.hpp>
#include <UI/View/Main.hpp>
namespace ia::iae
{
View_Main g_mainView{};
VOID UI::Initialize()
{
g_mainView.Initialize();
}
VOID UI::Terminate()
{
g_mainView.Terminate();
}
VOID UI::Update()
{
}
VOID UI::Draw()
{
if (ImGui::BeginMainMenuBar())
{
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();
}
} // namespace ia::iae

View File

@ -0,0 +1,37 @@
// 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/Asset.hpp>
namespace ia::iae
{
VOID View_Asset::Initialize()
{
SetName("Asset");
SetIcon(ICON_FA_STAR);
}
VOID View_Asset::Terminate()
{
}
VOID View_Asset::Render()
{
PreRender();
PostRender();
}
} // namespace ia::iae

View File

@ -0,0 +1,136 @@
// 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>
namespace ia::iae
{
VOID View_AssetBrowser::Initialize()
{
SetName("Asset Browser");
SetIcon(ICON_FA_BOX_OPEN);
if (!std::filesystem::exists("Assets"))
THROW_INVALID_DATA("Not a valid IAEngine project directory");
m_assetDirectoryPath = std::filesystem::current_path() / "Assets/";
ChangeCurrentOpenDirectory(m_assetDirectoryPath);
FillFileEntries(m_assetDirectoryPath, m_assetDirectoryFiles);
}
VOID View_AssetBrowser::Terminate()
{
}
VOID View_AssetBrowser::Render()
{
PreRender();
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{7.5f, 7.5f});
if (ImGui::BeginTable("root", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_SizingStretchProp))
{
ImGui::TableSetupColumn("Navigation", ImGuiTableColumnFlags_WidthStretch, 0.15f);
ImGui::TableSetupColumn("Asset Browser", ImGuiTableColumnFlags_WidthStretch, 0.85f);
ImGui::TableNextColumn();
if (ImGui::BeginChild("Navigation", ImVec2(0, -FLT_MIN), ImGuiChildFlags_AlwaysUseWindowPadding))
{
for (const auto &t : m_assetDirectoryFiles)
{
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 1.75f);
if (ImGui::Selectable(t.IconAndName.c_str()) && t.IsDirectory)
ChangeCurrentOpenDirectory(t.Path);
}
}
ImGui::EndChild();
ImGui::TableNextColumn();
if (ImGui::BeginChild("Asset Browser", ImVec2(0, -FLT_MIN), ImGuiChildFlags_AlwaysUseWindowPadding))
{
for (const auto &t : m_currentOpenDirectoryFiles)
{
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 1.75f);
if (ImGui::Selectable(t.IconAndName.c_str()))
{
if (t.IsDirectory)
{
ChangeCurrentOpenDirectory(t.Path);
break;
}
OpenAsset(t.Path);
}
}
}
ImGui::EndChild();
ImGui::EndTable();
}
ImGui::PopStyleVar();
PostRender();
}
VOID View_AssetBrowser::ChangeCurrentOpenDirectory(IN CONST std::filesystem::path &path)
{
m_currentOpenDirectoryPath = path;
std::filesystem::current_path(m_currentOpenDirectoryPath);
if (path == m_assetDirectoryPath)
m_currentOpenDirectoryFiles.clear();
else
FillFileEntries(m_currentOpenDirectoryPath, m_currentOpenDirectoryFiles);
}
VOID View_AssetBrowser::FillFileEntries(IN CONST std::filesystem::path &path, IN Vector<FileEntry> &fileEntries)
{
fileEntries.clear();
for (const auto &t : std::filesystem::directory_iterator(path))
{
if (!t.is_directory())
continue;
fileEntries.pushBack({.Icon = ICON_FA_FOLDER,
.Name = t.path().filename().string().c_str(),
.IsDirectory = true,
.Path = t.path()});
fileEntries.back().IconAndName = BuildString(fileEntries.back().Icon, " ", fileEntries.back().Name);
}
for (const auto &t : std::filesystem::directory_iterator(path))
{
if (t.is_directory())
continue;
fileEntries.pushBack({.Icon = GetFileEntryIcon(t.path().extension().string().c_str()),
.Name = t.path().filename().string().c_str(),
.IsDirectory = false,
.Path = t.path()});
fileEntries.back().IconAndName = BuildString(fileEntries.back().Icon, " ", fileEntries.back().Name);
}
}
PCCHAR View_AssetBrowser::GetFileEntryIcon(IN PCCHAR extension)
{
if (!strcmp(extension, ".xml"))
return ICON_FA_CODE;
if (!strcmp(extension, ".png") || !strcmp(extension, ".jpg"))
return ICON_FA_IMAGE;
return ICON_FA_FILE;
}
VOID View_AssetBrowser::OpenAsset(IN CONST std::filesystem::path &path)
{
}
} // namespace ia::iae

View File

@ -0,0 +1,37 @@
// 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/Console.hpp>
namespace ia::iae
{
VOID View_Console::Initialize()
{
SetName("Console");
SetIcon(ICON_FA_TERMINAL);
}
VOID View_Console::Terminate()
{
}
VOID View_Console::Render()
{
PreRender();
PostRender();
}
} // namespace ia::iae

View File

@ -0,0 +1,161 @@
// 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

@ -0,0 +1,37 @@
// 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/Nodes.hpp>
namespace ia::iae
{
VOID View_Nodes::Initialize()
{
SetName("Nodes");
SetIcon(ICON_FA_CIRCLE_NODES);
}
VOID View_Nodes::Terminate()
{
}
VOID View_Nodes::Render()
{
PreRender();
PostRender();
}
} // namespace ia::iae

View File

@ -0,0 +1,37 @@
// 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/Package.hpp>
namespace ia::iae
{
VOID View_Package::Initialize()
{
SetName("Package");
SetIcon(ICON_FA_BOX_ARCHIVE);
}
VOID View_Package::Terminate()
{
}
VOID View_Package::Render()
{
PreRender();
PostRender();
}
} // namespace ia::iae

View File

@ -0,0 +1,37 @@
// 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/Properties.hpp>
namespace ia::iae
{
VOID View_Properties::Initialize()
{
SetName("Properties");
SetIcon(ICON_FA_LIST);
}
VOID View_Properties::Terminate()
{
}
VOID View_Properties::Render()
{
PreRender();
PostRender();
}
} // namespace ia::iae

View File

@ -0,0 +1,37 @@
// 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/Scene.hpp>
namespace ia::iae
{
VOID View_Scene::Initialize()
{
SetName("Scene");
SetIcon(ICON_FA_HASHTAG);
}
VOID View_Scene::Terminate()
{
}
VOID View_Scene::Render()
{
PreRender();
PostRender();
}
} // namespace ia::iae

View File