Compare commits

...

7 Commits

Author SHA1 Message Date
a2b80ef600 Fixes 2025-11-14 09:43:09 +05:30
9ff39d7245 Fixes 2025-11-12 23:07:53 +05:30
9d6f525b81 Fixes 2025-11-11 09:24:14 +05:30
67cb23d589 Fixes 2025-11-10 09:49:22 +05:30
73d26b2f35 Fixes 2025-11-08 23:46:47 +05:30
042ff451b1 Fixes 2025-11-06 01:01:32 +05:30
a7113afcf6 Editor Setup 2025-11-06 00:00:19 +05:30
114 changed files with 15566 additions and 770 deletions

View File

@ -1,6 +1,7 @@
---
BasedOnStyle: Microsoft
IndentWidth: 4
SortIncludes: false
---
Language: Cpp
FixNamespaceComments: true

BIN
Resources/logo-868x507.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
Resources/logo-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

BIN
Resources/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -0,0 +1,14 @@
<Assets>
<IAEngine>
<EngineVersion>1.0.0</EngineVersion>
<EditorVersion>1.0.0</EditorVersion>
</IAEngine>
<Properties>
</Properties>
<Entries>
</Entries>
</Assets>

View File

Before

Width:  |  Height:  |  Size: 622 B

After

Width:  |  Height:  |  Size: 622 B

View File

Before

Width:  |  Height:  |  Size: 983 B

After

Width:  |  Height:  |  Size: 983 B

View File

Before

Width:  |  Height:  |  Size: 735 B

After

Width:  |  Height:  |  Size: 735 B

View File

Before

Width:  |  Height:  |  Size: 748 B

After

Width:  |  Height:  |  Size: 748 B

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 386 B

After

Width:  |  Height:  |  Size: 386 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

Before

Width:  |  Height:  |  Size: 648 B

After

Width:  |  Height:  |  Size: 648 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 371 B

After

Width:  |  Height:  |  Size: 371 B

View File

Before

Width:  |  Height:  |  Size: 99 B

After

Width:  |  Height:  |  Size: 99 B

View File

Before

Width:  |  Height:  |  Size: 99 B

After

Width:  |  Height:  |  Size: 99 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 99 B

After

Width:  |  Height:  |  Size: 99 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,29 @@
<Scene name="GameMap">
<IAEngine>
<EngineVersion>1.0.0</EngineVersion>
<EditorVersion>1.0.0</EditorVersion>
</IAEngine>
<Properties>
<Extent width="800" height="608"></Extent>
</Properties>
<Assets>
<Entry name="SpriteSheet_Player"></Entry>
<Entry name="TileSheet_MiddlePath"></Entry>
<Entry name="TileSheet_MiddleWater"></Entry>
<Entry name="TileSheet_MiddleGrass"></Entry>
<Entry name="TileSheet_Path"></Entry>
<Entry name="TileSheet_Water"></Entry>
<Entry name="TileSheet_Beach"></Entry>
<Entry name="TileSheet_Cliff"></Entry>
<Entry name="TileSheet_FarmLand"></Entry>
</Assets>
<Nodes>
</Nodes>
<Grid tileWidth="16" tileHeight="16">
</Grid>
</Scene>

11
Samples/RPG/Project.iae Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<Project name="RPG Sample">
<IAEngine>
<EngineVersion>1.0.0</EngineVersion>
<EditorVersion>1.0.0</EditorVersion>
</IAEngine>
<Properties>
<Window x="1920" y="23" />
<StartupScene>MainMenu</StartupScene>
</Properties>
</Project>

View File

@ -1,34 +0,0 @@
<Resources>
<IAEngine>
<EngineVersion>1.0.0</EngineVersion>
<EditorVersion>1.0.0</EditorVersion>
</IAEngine>
<Properties>
</Properties>
<Entries>
<SpriteSheet name="SpriteSheet_Player" path="Cute_Fantasy_Free/Player/Player.png" spriteWidth="32" spriteHeight="32">
<Animation name="IdleDown" frameCount="6"></Animation>
<Animation name="IdleRight" frameCount="6"></Animation>
<Animation name="IdleUp" frameCount="6"></Animation>
<Animation name="WalkDown" frameCount="6"></Animation>
<Animation name="WalkRight" frameCount="6"></Animation>
<Animation name="WalkUp" frameCount="6"></Animation>
<Animation name="AttackDown" frameCount="4"></Animation>
<Animation name="AttackRight" frameCount="4"></Animation>
<Animation name="AttackUp" frameCount="4"></Animation>
<Animation name="Die" frameCount="4"></Animation>
</SpriteSheet>
<TileSheet name="TileSheet_MiddlePath" path="Cute_Fantasy_Free/Tiles/Path_Middle.png" tileWidth="16" tileHeight="16"></TileSheet>
<TileSheet name="TileSheet_MiddleWater" path="Cute_Fantasy_Free/Tiles/Water_Middle.png" tileWidth="16" tileHeight="16"></TileSheet>
<TileSheet name="TileSheet_MiddleGrass" path="Cute_Fantasy_Free/Tiles/Grass_Middle.png" tileWidth="16" tileHeight="16"></TileSheet>
<TileSheet name="TileSheet_Path" path="Cute_Fantasy_Free/Tiles/Path_Tile.png" tileWidth="16" tileHeight="16"></TileSheet>
<TileSheet name="TileSheet_Water" path="Cute_Fantasy_Free/Tiles/Water_Tile.png" tileWidth="16" tileHeight="16"></TileSheet>
<TileSheet name="TileSheet_Beach" path="Cute_Fantasy_Free/Tiles/Beach_Tile.png" tileWidth="16" tileHeight="16"></TileSheet>
<TileSheet name="TileSheet_Cliff" path="Cute_Fantasy_Free/Tiles/Cliff_Tile.png" tileWidth="16" tileHeight="16"></TileSheet>
<TileSheet name="TileSheet_FarmLand" path="Cute_Fantasy_Free/Tiles/FarmLand_Tile.png" tileWidth="16" tileHeight="16"></TileSheet>
</Entries>
</Resources>

View File

@ -1,108 +0,0 @@
<Scene name="GameMap">
<IAEngine>
<EngineVersion>1.0.0</EngineVersion>
<EditorVersion>1.0.0</EditorVersion>
</IAEngine>
<Properties>
<Extent width="800" height="608"></Extent>
</Properties>
<Resources>
<Entry name="SpriteSheet_Player"></Entry>
<Entry name="TileSheet_MiddlePath"></Entry>
<Entry name="TileSheet_MiddleWater"></Entry>
<Entry name="TileSheet_MiddleGrass"></Entry>
<Entry name="TileSheet_Path"></Entry>
<Entry name="TileSheet_Water"></Entry>
<Entry name="TileSheet_Beach"></Entry>
<Entry name="TileSheet_Cliff"></Entry>
<Entry name="TileSheet_FarmLand"></Entry>
</Resources>
<Nodes>
</Nodes>
<Grid tileWidth="16" tileHeight="16">
<Repeat times="50">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="30">
<Cell tileSheet="TileSheet_MiddleWater" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="30">
<Cell tileSheet="TileSheet_MiddleWater" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="13">
<Cell tileSheet="TileSheet_MiddleWater" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Cell tileSheet="TileSheet_Beach" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
<Cell tileSheet="TileSheet_Beach" tileX="1" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
<Cell tileSheet="TileSheet_Beach" tileX="2" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
<Repeat times="14">
<Cell tileSheet="TileSheet_MiddleWater" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="13">
<Cell tileSheet="TileSheet_MiddleWater" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Cell tileSheet="TileSheet_Beach" tileX="0" tileY="1" collisionMask="0" colorOverlay="#ffffffff"></Cell>
<Cell tileSheet="TileSheet_Beach" tileX="1" tileY="1" collisionMask="0" colorOverlay="#ffffffff"></Cell>
<Cell tileSheet="TileSheet_Beach" tileX="2" tileY="1" collisionMask="0" colorOverlay="#ffffffff"></Cell>
<Repeat times="14">
<Cell tileSheet="TileSheet_MiddleWater" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="13">
<Cell tileSheet="TileSheet_MiddleWater" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Cell tileSheet="TileSheet_Beach" tileX="0" tileY="2" collisionMask="0" colorOverlay="#ffffffff"></Cell>
<Cell tileSheet="TileSheet_Beach" tileX="1" tileY="2" collisionMask="0" colorOverlay="#ffffffff"></Cell>
<Cell tileSheet="TileSheet_Beach" tileX="2" tileY="2" collisionMask="0" colorOverlay="#ffffffff"></Cell>
<Repeat times="14">
<Cell tileSheet="TileSheet_MiddleWater" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="30">
<Cell tileSheet="TileSheet_MiddleWater" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="10">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
<Repeat times="50">
<Cell tileSheet="TileSheet_MiddleGrass" tileX="0" tileY="0" collisionMask="0" colorOverlay="#ffffffff"></Cell>
</Repeat>
</Grid>
</Scene>

View File

@ -1,4 +1,6 @@
add_subdirectory(Common/)
add_subdirectory(ConfigData/)
add_subdirectory(RenderCore/)
add_subdirectory(IAEngine/)
add_subdirectory(CLI/)

10
Src/Common/CMakeLists.txt Normal file
View File

@ -0,0 +1,10 @@
set(SRC_FILES
"imp/cpp/Common.cpp"
)
add_library(Common STATIC ${SRC_FILES})
target_include_directories(Common PUBLIC inc)
target_include_directories(Common PRIVATE imp/hpp)
target_link_libraries(Common PUBLIC IACore SDL3::SDL3 glm::glm pugixml::pugixml)

View File

View File

@ -0,0 +1,48 @@
// 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 <IACore/Exception.hpp>
#include <IACore/Logger.hpp>
#include <IACore/Map.hpp>
#include <IACore/Memory.hpp>
#include <IACore/String.hpp>
#include <IACore/Vector.hpp>
#include <glm/ext/matrix_clip_space.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <glm/ext/scalar_constants.hpp>
#include <glm/mat4x4.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
namespace ia::iae
{
STATIC CONSTEXPR IA_VERSION_TYPE ENGINE_VERSION = IA_MAKE_VERSION(1, 0, 0);
using Handle = INT64;
STATIC CONSTEXPR Handle INVALID_HANDLE = -1;
using Vec2 = glm::vec2;
using Vec3 = glm::vec3;
using Vec4 = glm::vec4;
using IVec2 = glm::ivec2;
using IVec3 = glm::ivec3;
using IVec4 = glm::ivec4;
using Mat4 = glm::mat4;
} // namespace ia::iae

View File

@ -0,0 +1,10 @@
set(SRC_FILES
"imp/cpp/ConfigData.cpp"
)
add_library(ConfigData STATIC ${SRC_FILES})
target_include_directories(ConfigData PUBLIC inc)
target_include_directories(ConfigData PRIVATE imp/hpp)
target_link_libraries(ConfigData PUBLIC Common)

View File

@ -0,0 +1,95 @@
// 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 <ConfigData/ConfigData.hpp>
#include <IACore/File.hpp>
#include <filesystem>
namespace ia::iae
{
ConfigData::ConfigData(IN pugi::xml_document &&document, IN CONST String &type, IN CONST String &name,
IN pugi::xml_node propertiesNode, IN Vector<pugi::xml_node> &&childNodes)
: m_document(IA_MOVE(document)), m_type(type), m_name(name), m_propertiesNode(propertiesNode),
m_childNodes(IA_MOVE(childNodes))
{
}
RefPtr<ConfigData> ConfigData::LoadFromFile(IN CONST String &path)
{
const auto result = LoadFromMemory(File::ReadToString(path));
result->m_filePath = std::filesystem::canonical(path.c_str()).string().c_str();
return result;
}
RefPtr<ConfigData> ConfigData::LoadFromMemory(IN CONST String &data)
{
pugi::xml_document doc;
if (!doc.load_string(data.c_str()))
return nullptr;
if (std::distance(doc.children().begin(), doc.children().end()) != 1)
return nullptr;
const auto rootNode = *doc.children().begin();
// Verify Engine Version
{
const auto engineInfoNode = rootNode.child("IAEngine");
if (!engineInfoNode)
return nullptr;
const auto engineVersionNode = engineInfoNode.child("EngineVersion");
if (!engineVersionNode)
return nullptr;
const auto engineVersion = IA_PARSE_VERSION_STRING(engineVersionNode.text().as_string());
if (engineVersion > ENGINE_VERSION)
{
CFG_LOG_WARN("XML data file was created with a newer version of IAEngine, skipping..");
return nullptr;
}
}
const auto propertiesNode = rootNode.child("Properties");
if (!propertiesNode)
return nullptr;
Vector<pugi::xml_node> childNodes;
for (auto &c : rootNode.children())
{
if ((!strcmp(c.name(), "Properties")) || (!strcmp(c.name(), "IAEngine")))
continue;
childNodes.pushBack(c);
}
const auto nameAttr = rootNode.attribute("name");
return MakeRefPtr<ConfigData>(IA_MOVE(doc), rootNode.name(), nameAttr ? nameAttr.as_string() : "",
propertiesNode, IA_MOVE(childNodes));
}
VOID ConfigData::WriteChangesToDisk()
{
if (m_filePath.empty())
return;
m_document.save_file(m_filePath.c_str());
}
pugi::xml_node ConfigData::Property(IN CONST String &name)
{
return m_propertiesNode.child(name.c_str());
}
} // namespace ia::iae

View File

@ -0,0 +1,33 @@
// 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 <Common/Base.hpp>
#include <pugixml.hpp>
#define CFG_LOG_TAG "CFG"
#define CFG_LOG_INFO(...) ia::Logger::Info(CFG_LOG_TAG, __VA_ARGS__)
#define CFG_LOG_WARN(...) ia::Logger::Warn(CFG_LOG_TAG, __VA_ARGS__)
#define CFG_LOG_ERROR(...) ia::Logger::Error(CFG_LOG_TAG, __VA_ARGS__)
#define CFG_LOG_SUCCESS(...) ia::Logger::Success(CFG_LOG_TAG, __VA_ARGS__)
namespace ia::iae
{
} // namespace ia::iae

View File

@ -0,0 +1,63 @@
// 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 <ConfigData/Base.hpp>
namespace ia::iae
{
class ConfigData
{
public:
STATIC RefPtr<ConfigData> LoadFromFile(IN CONST String &path);
STATIC RefPtr<ConfigData> LoadFromMemory(IN CONST String &data);
VOID WriteChangesToDisk();
public:
pugi::xml_node Property(IN CONST String &name);
public:
CONST String &Type() CONST
{
return m_type;
}
CONST String &Name() CONST
{
return m_name;
}
CONST Vector<pugi::xml_node> &Children() CONST
{
return m_childNodes;
}
private:
String m_filePath{};
CONST String m_type;
CONST String m_name;
CONST pugi::xml_document m_document;
CONST pugi::xml_node m_propertiesNode;
CONST Vector<pugi::xml_node> m_childNodes;
public:
ConfigData(IN pugi::xml_document &&document, IN CONST String &type, IN CONST String &name,
IN pugi::xml_node propertiesNode, IN Vector<pugi::xml_node> &&childNodes);
};
} // namespace ia::iae

View File

@ -1,5 +1,24 @@
set(SRC_FILES
"imp/cpp/Main.cpp"
"imp/cpp/Editor.cpp"
"imp/cpp/Project.cpp"
"imp/cpp/UI/UI.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/FilePreview.cpp"
"imp/cpp/UI/View/AssetBrowser.cpp"
"imp/cpp/UI/View/Console.cpp"
"imp/cpp/UI/View/Nodes.cpp"
"imp/cpp/UI/View/Package.cpp"
"imp/cpp/UI/View/Scene.cpp"
"imp/cpp/UI/View/Game.cpp"
"imp/cpp/UI/View/Asset.cpp"
"imp/cpp/UI/View/Properties.cpp"
# imgui
"imp/cpp/Vendor/imgui/imgui.cpp"
@ -8,6 +27,8 @@ set(SRC_FILES
"imp/cpp/Vendor/imgui/imgui_widgets.cpp"
"imp/cpp/Vendor/imgui/backends/imgui_impl_sdl3.cpp"
"imp/cpp/Vendor/imgui/backends/imgui_impl_sdlgpu3.cpp"
"imp/cpp/Vendor/FontAwesome7.cpp"
)
add_executable(IAE_Editor ${SRC_FILES})

View File

@ -0,0 +1,220 @@
// 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 <Editor.hpp>
#include <IAEngine/IAEngine.hpp>
#include <RenderCore/RenderCore.hpp>
#include <SDL3/SDL.h>
#include <Vendor/imgui/backends/imgui_impl_sdl3.h>
#include <Vendor/imgui/backends/imgui_impl_sdlgpu3.h>
#include <UI/UI.hpp>
#include <UI/View/Asset.hpp>
#include <UI/View/FilePreview.hpp>
#include <LogoIcon.hpp>
namespace ia::iae
{
EXTERN UINT8 DATA_TTF_FONTAWESOME7FREESOLID900[];
EXTERN SIZE_T SIZE_TTF_FONTAWESOME7FREESOLID900;
EXTERN SDL_Window *g_windowHandle;
Editor Editor::s_instance{};
ImDrawData *g_imDrawData{};
IVec2 g_windowExtent{800, 600};
Map<String, String> g_assetNameMap;
SIZE_T g_uniqueNameCounter{0};
String generate_unique_asset_name()
{
return BuildString("Asset_", g_uniqueNameCounter++);
}
VOID Editor::LoadProject(IN CONST String &directory)
{
m_activeProject = Project::Load(directory);
}
VOID Editor::OpenFile(IN Path path)
{
const auto assetName = AssetManager::GetAssetName(path.string().c_str());
if (assetName.size())
{
UI::GetAssetView()->Open(assetName);
UI::OpenAssetView();
}
else
{
UI::GetFilePreviewView()->Open(path);
UI::OpenFilePreviewView();
}
}
VOID Editor::MarkAsAsset(IN Path path)
{
const auto assetName = generate_unique_asset_name();
AssetManager::AssignAssetName(AssetManager::LoadTexture(path.string().c_str()), assetName);
UI::CloseFilePreviewView();
UI::GetAssetView()->Open(assetName);
UI::OpenAssetView();
}
VOID Editor::RemoveFromAssets(IN CONST String &assetName)
{
}
INT32 Editor::Run(IN INT32 argc, IN PCCHAR argv[])
{
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_GAMEPAD))
THROW_UNKNOWN("Failed to intialize SDL: ", SDL_GetError());
if (!(g_windowHandle = SDL_CreateWindow("IAEngine", g_windowExtent.x, g_windowExtent.y, SDL_WINDOW_RESIZABLE)))
THROW_UNKNOWN("Failed to create the SDL window: ", SDL_GetError());
LoadProject(".");
SDL_SetWindowPosition(g_windowHandle, m_activeProject->WindowPosition().x, m_activeProject->WindowPosition().y);
SDL_MaximizeWindow(g_windowHandle);
SDL_GetWindowSizeInPixels(g_windowHandle, &g_windowExtent.x, &g_windowExtent.y);
SDL_Surface *iconSurface = SDL_CreateSurface(LOGO_ICON_WIDTH, LOGO_ICON_HEIGHT, SDL_PIXELFORMAT_RGBA32);
if (iconSurface)
{
for (UINT32 i = 0; i < LOGO_ICON_WIDTH * LOGO_ICON_HEIGHT * 4; i += 4)
{
STATIC UINT32 p{0xFFFFFFFF};
const auto pixel = ((PUINT8) &p);
const auto pixels = (PUINT8) iconSurface->pixels;
LOGO_ICON_GET_PIXEL(LOGO_ICON_DATA, pixel);
pixels[i + 0] = pixel[0];
pixels[i + 1] = pixel[1];
pixels[i + 2] = pixel[2];
pixels[i + 3] = 0xFF;
}
SDL_SetWindowIcon(g_windowHandle, iconSurface);
SDL_DestroySurface(iconSurface);
}
SDL_SetWindowTitle(g_windowHandle, BuildString("IAEngine - ", m_activeProject->Name()).c_str());
RDC::Initialize(g_windowExtent, g_windowHandle, true);
const auto mainScale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
IMGUI_CHECKVERSION();
ImGui::CreateContext();
auto &imGUIIO = ImGui::GetIO();
imGUIIO.IniFilename = nullptr;
imGUIIO.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
imGUIIO.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
ImGuiStyle &style = ImGui::GetStyle();
style.ScaleAllSizes(mainScale);
style.FontScaleDpi = mainScale;
ImGui_ImplSDLGPU3_InitInfo initInfo{.Device = RDC_Device::GetHandle(),
.ColorTargetFormat = RDC_Device::GetSwapchainTextureFormat(),
.PresentMode = SDL_GPU_PRESENTMODE_VSYNC};
ImGui_ImplSDL3_InitForSDLGPU(g_windowHandle);
ImGui_ImplSDLGPU3_Init(&initInfo);
ImFontConfig fontConfig;
fontConfig.MergeMode = true;
fontConfig.PixelSnapH = true;
fontConfig.FontDataOwnedByAtlas = false;
fontConfig.GlyphOffset.y = 1.5f;
fontConfig.SizePixels = 12.0f;
static const ImWchar icon_ranges[] = {ICON_MIN_FA, ICON_MAX_FA, 0};
imGUIIO.Fonts->AddFontDefault();
imGUIIO.Fonts->AddFontFromMemoryTTF((PVOID) DATA_TTF_FONTAWESOME7FREESOLID900,
SIZE_TTF_FONTAWESOME7FREESOLID900, 0.0f, &fontConfig, icon_ranges);
imGUIIO.Fonts->Build();
UI::Initialize();
SDL_Event event{};
while (true)
{
SDL_PollEvent(&event);
if (event.type == SDL_EVENT_QUIT)
break;
UI::ProcessEvent(&event);
UI::Update();
ImGui_ImplSDL3_ProcessEvent(&event);
ImGui_ImplSDLGPU3_NewFrame();
ImGui_ImplSDL3_NewFrame();
ImGui::NewFrame();
UI::Draw();
ImGui::Render();
STATIC SDL_GPURenderPass *ActiveRenderPass{};
STATIC SDL_GPUCommandBuffer *ActiveCommandBuffer{};
STATIC SDL_GPUColorTargetInfo ActiveColorTargetInfo{.clear_color = SDL_FColor{0.0f, 0.0f, 0.0f, 1.0f},
.load_op = SDL_GPU_LOADOP_CLEAR,
.store_op = SDL_GPU_STOREOP_STORE};
if (!(ActiveCommandBuffer = SDL_AcquireGPUCommandBuffer(RDC_Device::GetHandle())))
THROW_UNKNOWN("Failed to acquire SDL GPU command buffer: ", SDL_GetError());
g_imDrawData = ImGui::GetDrawData();
ImGui_ImplSDLGPU3_PrepareDrawData(g_imDrawData, ActiveCommandBuffer);
SDL_GPUTexture *swapChainTexture{};
if (!SDL_WaitAndAcquireGPUSwapchainTexture(ActiveCommandBuffer, g_windowHandle, &swapChainTexture, nullptr,
nullptr))
THROW_UNKNOWN("Failed to acquire SDL GPU Swapchain texture: ", SDL_GetError());
ActiveColorTargetInfo.texture = swapChainTexture;
ActiveColorTargetInfo.clear_color = SDL_FColor{0.3f, 0.3f, 0.3f, 1.0f};
ActiveRenderPass = SDL_BeginGPURenderPass(ActiveCommandBuffer, &ActiveColorTargetInfo, 1, nullptr);
ImGui_ImplSDLGPU3_RenderDrawData(g_imDrawData, ActiveCommandBuffer, ActiveRenderPass);
SDL_EndGPURenderPass(ActiveRenderPass);
SDL_SubmitGPUCommandBuffer(ActiveCommandBuffer);
RDC_Device::WaitForIdle();
}
IVec2 currentWindowPosition{};
SDL_GetWindowPosition(g_windowHandle, &currentWindowPosition.x, &currentWindowPosition.y);
m_activeProject->WindowPosition() = currentWindowPosition;
m_activeProject->Update();
UI::Terminate();
ImGui_ImplSDL3_Shutdown();
ImGui_ImplSDLGPU3_Shutdown();
ImGui::DestroyContext();
SDL_DestroyWindow(g_windowHandle);
return 0;
}
} // namespace ia::iae

View File

@ -14,169 +14,9 @@
// 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 <SDL3/SDL.h>
#include <Vendor/imgui/backends/imgui_impl_sdl3.h>
#include <Vendor/imgui/backends/imgui_impl_sdlgpu3.h>
#include <Vendor/imgui/imgui.h>
namespace ia::iae
{
ImDrawData *g_imDrawData{};
EXTERN Vec2 g_designViewport;
EXTERN SDL_Window *g_windowHandle;
INT32 Run(IN INT32 argc, IN PCCHAR argv[])
{
INT32 frameCounter{0};
IVec2 windowExtent{800, 600};
g_designViewport = windowExtent;
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_GAMEPAD))
THROW_UNKNOWN("Failed to intialize SDL: ", SDL_GetError());
if (!(g_windowHandle = SDL_CreateWindow("IAEngine", windowExtent.x, windowExtent.y,
SDL_WINDOW_RESIZABLE | SDL_WINDOW_MAXIMIZED)))
THROW_UNKNOWN("Failed to create the SDL window: ", SDL_GetError());
SDL_MaximizeWindow(g_windowHandle);
SDL_GetWindowSizeInPixels(g_windowHandle, &windowExtent.x, &windowExtent.y);
IAEngine::__Initialize();
auto gamePreviewTexture = new RDC_Texture(RDC_Texture::EType::SAMPLED, 800, 600);
const auto mainScale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
IMGUI_CHECKVERSION();
ImGui::CreateContext();
auto &imGUIIO = ImGui::GetIO();
imGUIIO.IniFilename = nullptr;
imGUIIO.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
imGUIIO.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
ImGui::StyleColorsClassic();
ImGuiStyle &style = ImGui::GetStyle();
style.ScaleAllSizes(mainScale);
style.FontScaleDpi = mainScale;
ImGui_ImplSDLGPU3_InitInfo initInfo{.Device = RDC_Device::GetHandle(),
.ColorTargetFormat = RDC_Device::GetSwapchainTextureFormat(),
.PresentMode = SDL_GPU_PRESENTMODE_VSYNC};
ImGui_ImplSDL3_InitForSDLGPU(g_windowHandle);
ImGui_ImplSDLGPU3_Init(&initInfo);
SDL_Event event{};
while (true)
{
SDL_PollEvent(&event);
if (event.type == SDL_EVENT_QUIT)
break;
IAEngine::__ProcessEvent(&event);
IAEngine::__Update();
ImGui_ImplSDL3_ProcessEvent(&event);
frameCounter++;
if (frameCounter >= 60)
{
frameCounter = 0;
IAEngine::__FixedUpdate();
}
IAEngine::__RenderToTexture(gamePreviewTexture->GetHandle());
ImGui_ImplSDLGPU3_NewFrame();
ImGui_ImplSDL3_NewFrame();
ImGui::NewFrame();
{
ImGui::Begin("Scene");
ImGui::Image(gamePreviewTexture->GetHandle(), {800, 600});
ImGui::End();
}
ImGui::Render();
STATIC SDL_GPURenderPass *ActiveRenderPass{};
STATIC SDL_GPUCommandBuffer *ActiveCommandBuffer{};
STATIC SDL_GPUColorTargetInfo ActiveColorTargetInfo{.clear_color = SDL_FColor{0.0f, 0.0f, 0.0f, 1.0f},
.load_op = SDL_GPU_LOADOP_CLEAR,
.store_op = SDL_GPU_STOREOP_STORE};
if (!(ActiveCommandBuffer = SDL_AcquireGPUCommandBuffer(RDC_Device::GetHandle())))
THROW_UNKNOWN("Failed to acquire SDL GPU command buffer: ", SDL_GetError());
g_imDrawData = ImGui::GetDrawData();
ImGui_ImplSDLGPU3_PrepareDrawData(g_imDrawData, ActiveCommandBuffer);
SDL_GPUTexture *swapChainTexture{};
if (!SDL_WaitAndAcquireGPUSwapchainTexture(ActiveCommandBuffer, g_windowHandle, &swapChainTexture, nullptr,
nullptr))
THROW_UNKNOWN("Failed to acquire SDL GPU Swapchain texture: ", SDL_GetError());
ActiveColorTargetInfo.texture = swapChainTexture;
ActiveColorTargetInfo.clear_color = SDL_FColor{0.3f, 0.3f, 0.3f, 1.0f};
ActiveRenderPass = SDL_BeginGPURenderPass(ActiveCommandBuffer, &ActiveColorTargetInfo, 1, nullptr);
ImGui_ImplSDLGPU3_RenderDrawData(g_imDrawData, ActiveCommandBuffer, ActiveRenderPass);
SDL_EndGPURenderPass(ActiveRenderPass);
SDL_SubmitGPUCommandBuffer(ActiveCommandBuffer);
RDC_Device::WaitForIdle();
}
ImGui_ImplSDL3_Shutdown();
ImGui_ImplSDLGPU3_Shutdown();
ImGui::DestroyContext();
delete gamePreviewTexture;
IAEngine::__Terminate();
SDL_DestroyWindow(g_windowHandle);
return 0;
}
} // namespace ia::iae
#include <Editor.hpp>
int main(int argc, char *argv[])
{
return ia::iae::Run(argc, (const char **) argv);
return ia::iae::Editor::Instance().Run(argc, (const char **) argv);
}
#include <IAEngine/LibInterface.hpp>
C_DECL(GameRequestedConfig *Game_GetConfigRequest())
{
return nullptr;
}
C_DECL(VOID Game_OnInitialize())
{
}
C_DECL(VOID Game_OnTerminate())
{
}
C_DECL(VOID Game_OnDebugDraw())
{
RDC::DrawRect({10, 10}, {700, 500}, {1.0f, 0.0f, 0.0f, 1.0f});
}
C_DECL(VOID Game_OnFixedUpdate())
{
}
C_DECL(VOID Game_OnUpdate(IN FLOAT32 deltaTime))
{
}
C_DECL(VOID Game_OnResize(IN INT32 newWidth, IN INT32 newHeight))
{
}

View File

@ -0,0 +1,56 @@
// 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 <Project.hpp>
#include <filesystem>
namespace ia::iae
{
RefPtr<Project> Project::Load(IN CONST String &directory)
{
auto config = ConfigData::LoadFromFile(BuildString(directory, "/", "Project.iae"));
return MakeRefPtr<Project>(config->Name(), std::filesystem::canonical(directory.c_str()).string().c_str(), IA_MOVE(config));
}
VOID Project::Update()
{
// Update Window Position
const auto windowNode = m_configData->Property("Window");
windowNode.attribute("x").set_value(m_windowPosition.x);
windowNode.attribute("y").set_value(m_windowPosition.y);
m_configData->WriteChangesToDisk();
}
Project::Project(IN CONST String &name, IN CONST String &absolutePath, IN RefPtr<ConfigData> &&configData)
: m_projectName(name), m_projectAbsolutePath(absolutePath),
m_assetDirectory(BuildString(absolutePath, "/Assets/")), m_configData(IA_MOVE(configData))
{
IA_ASSERT(std::filesystem::exists(m_assetDirectory.c_str()));
const auto windowNode = m_configData->Property("Window");
if(windowNode && windowNode.attribute("x") && windowNode.attribute("y"))
{
m_windowPosition.x = windowNode.attribute("x").as_int();
m_windowPosition.y = windowNode.attribute("y").as_int();
}
}
Project::~Project()
{
}
} // namespace ia::iae

View File

View File

@ -0,0 +1,126 @@
// 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;
}
BOOL* isOpen = v->Value.IsCloseable ? &v->Value.IsOpen : nullptr;
if (ImGui::BeginTabItem(v->Value.View->IconAndName().c_str(), isOpen, flags))
{
v->Value.View->Render();
ImGui::EndTabItem();
m_activeTabName = v->Key.c_str();
}
}
ImGui::EndTabBar();
ImGui::End();
}
VOID TabContainer::Update()
{
for (const auto &t : m_tabViews)
t->Value.View->Update();
}
VOID TabContainer::ProcessEvent(IN SDL_Event *event)
{
for (const auto &t : m_tabViews)
t->Value.View->ProcessEvent(event);
}
VOID TabContainer::AddTab(IN CONST String &name, IN IView *view, IN BOOL isCloseable)
{
RemoveTab(name);
view->Initialize();
m_tabViews[name] = Tab{.View = view, .IsCloseable = isCloseable};
if (!m_activeTabName)
m_activeTabName = name.c_str();
}
VOID TabContainer::RemoveTab(IN CONST String &name)
{
if (!m_tabViews.contains(name))
return;
m_tabViews[name].IsOpen = false;
if (m_tabViews[name].View)
m_tabViews[name].View->Terminate();
delete m_tabViews[name].View;
m_tabViews[name] = {};
}
VOID TabContainer::OpenTab(IN CONST String &name)
{
if (!m_tabViews.contains(name))
return;
m_tabViews[name].IsOpen = true;
}
VOID TabContainer::CloseTab(IN CONST String &name)
{
if (!m_tabViews.contains(name))
return;
m_tabViews[name].IsOpen = false;
}
VOID TabContainer::ChangeActiveTab(IN PCCHAR name)
{
m_pendingActiveTabName = name;
}
IView *TabContainer::GetTab(IN CONST String &name)
{
return m_tabViews[name].View;
}
} // namespace ia::iae

View File

@ -0,0 +1,223 @@
// 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/Asset.hpp>
#include <UI/View/AssetBrowser.hpp>
#include <UI/View/Console.hpp>
#include <UI/View/FilePreview.hpp>
#include <UI/View/Nodes.hpp>
#include <UI/View/Package.hpp>
#include <UI/View/Properties.hpp>
#include <UI/View/Scene.hpp>
#include <UI/View/Game.hpp>
#include <UI/TabContainer.hpp>
namespace ia::iae
{
STATIC CONSTEXPR PCCHAR VIEW_NAME_ASSET_BROWSER = "AssetBrowser";
STATIC CONSTEXPR PCCHAR VIEW_NAME_FILE_PREVIEW = "FilePreview";
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";
STATIC CONSTEXPR PCCHAR VIEW_NAME_GAME = "Game";
EXTERN IVec2 g_windowExtent;
IView *UI::s_focusedView{};
TabContainer g_tabContainerB;
TabContainer g_tabContainerTL;
TabContainer g_tabContainerTM;
TabContainer g_tabContainerTR;
VOID UI::OpenFilePreviewView()
{
g_tabContainerTR.OpenTab(VIEW_NAME_FILE_PREVIEW);
g_tabContainerTR.ChangeActiveTab(VIEW_NAME_FILE_PREVIEW);
}
VOID UI::CloseFilePreviewView()
{
g_tabContainerTR.CloseTab(VIEW_NAME_FILE_PREVIEW);
}
VOID UI::OpenAssetView()
{
g_tabContainerTR.OpenTab(VIEW_NAME_ASSET);
g_tabContainerTR.ChangeActiveTab(VIEW_NAME_ASSET);
}
VOID UI::CloseAssetView()
{
g_tabContainerTR.CloseTab(VIEW_NAME_ASSET);
}
class View_Asset *UI::GetAssetView()
{
return (View_Asset *) g_tabContainerTR.GetTab(VIEW_NAME_ASSET);
}
class View_FilePreview *UI::GetFilePreviewView()
{
return (View_FilePreview *) g_tabContainerTR.GetTab(VIEW_NAME_FILE_PREVIEW);
}
VOID UI::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_tabContainerTM.AddTab<View_Game>(VIEW_NAME_GAME);
g_tabContainerTR.AddTab<View_Properties>(VIEW_NAME_PROPERTIES);
g_tabContainerTR.AddTab<View_Asset>(VIEW_NAME_ASSET, true);
g_tabContainerTR.AddTab<View_FilePreview>(VIEW_NAME_FILE_PREVIEW, true);
g_tabContainerTR.CloseTab(VIEW_NAME_ASSET);
g_tabContainerTR.CloseTab(VIEW_NAME_FILE_PREVIEW);
}
VOID UI::Terminate()
{
g_tabContainerB.Terminate();
g_tabContainerTL.Terminate();
g_tabContainerTM.Terminate();
g_tabContainerTR.Terminate();
}
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()
{
DrawMenuBar();
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);
}
VOID UI::DrawTextCentered(IN CONST ImVec2 &viewExtent, IN CONST String &text)
{
ImRect rect{{}, viewExtent};
const auto textSize = ImGui::CalcTextSize(text.c_str());
UI::AlignCursorHCenter(rect, textSize.x);
UI::AlignCursorVCenter(rect, textSize.y);
ImGui::Text("%s", text.c_str());
}
} // namespace ia::iae

View File

@ -0,0 +1,214 @@
// 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>
#include <IAEngine/Asset/AssetManager.hpp>
#include <RenderCore/RenderCore.hpp>
#include <Editor.hpp>
namespace ia::iae
{
VOID View_Asset::Initialize()
{
SetName("Asset");
SetIcon(ICON_FA_STAR);
}
VOID View_Asset::Terminate()
{
}
VOID View_Asset::Render()
{
PreRender();
if (!m_asset)
{
PostRender();
return;
}
STATIC CHAR NAME_BUFFER[256];
memcpy(NAME_BUFFER, m_assetName.c_str(), m_assetName.size() + 1);
ImGui::Text("Name: ");
ImGui::SameLine();
ImGui::InputText("##name", NAME_BUFFER, sizeof(NAME_BUFFER));
m_assetName = NAME_BUFFER;
DrawAssetTypePicker();
switch (m_asset->GetType())
{
case EAssetType::TEXTURE:
RenderTextureAsset();
break;
case EAssetType::SPRITE:
RenderSpriteAsset();
break;
case EAssetType::TILESHEET:
RenderTileSheetAsset();
break;
case EAssetType::SPRITESHEET:
RenderSpriteSheetAsset();
break;
case EAssetType::INVALID:
case EAssetType::SOUND:
case EAssetType::SCENE:
case EAssetType::PLUGIN:
case EAssetType::PACKAGE:
break;
}
PostRender();
}
VOID View_Asset::Update()
{
}
VOID View_Asset::OnEvent(IN SDL_Event *event)
{
}
VOID View_Asset::Open(IN String assetName)
{
m_assetName = assetName;
const auto asset = AssetManager::GetAssetByName<Asset_Texture>(m_assetName);
m_assetImageHandle = RDC::BakeTexture(asset->GetHandle()->ImagePtr);
m_assetImageExtent = {asset->GetHandle()->ImagePtr->Width, asset->GetHandle()->ImagePtr->Height};
m_asset = asset;
m_assetType = asset->GetType();
}
VOID View_Asset::Close()
{
m_assetName = "";
m_asset = nullptr;
m_assetImageHandle = 0;
m_assetImageExtent = {};
m_assetType = EAssetType::INVALID;
}
VOID View_Asset::RenderTextureAsset()
{
const auto asset = (Asset_Texture *) m_asset;
DrawAssetImage(0.75f, {0, 0});
}
VOID View_Asset::RenderSpriteAsset()
{
const auto asset = (Asset_Sprite *) m_asset;
DrawAssetImage(0.75f, {0, 0});
}
VOID View_Asset::RenderTileSheetAsset()
{
const auto asset = (Asset_TileSheet *) m_asset;
ImGui::Text("Tile Width: ");
ImGui::SameLine();
ImGui::InputInt("##TileWidth", &asset->TileWidth());
if (asset->TileWidth() < 1)
asset->TileWidth() = 1;
if (asset->TileWidth() > m_assetImageExtent.x)
asset->TileWidth() = m_assetImageExtent.x;
ImGui::Text("Tile Height: ");
ImGui::SameLine();
ImGui::InputInt("##TileHeight", &asset->TileHeight());
if (asset->TileHeight() < 1)
asset->TileHeight() = 1;
if (asset->TileHeight() > m_assetImageExtent.y)
asset->TileHeight() = m_assetImageExtent.y;
DrawAssetImage(0.75f, {asset->TileWidth(), asset->TileHeight()});
}
VOID View_Asset::RenderSpriteSheetAsset()
{
const auto asset = (Asset_SpriteSheet *) m_asset;
}
VOID View_Asset::DrawAssetImage(IN FLOAT32 relativeWidth, IN IVec2 gridSize)
{
ImVec2 base_pos = ImGui::GetCursorScreenPos();
const auto ImageWidth = m_extent.x * relativeWidth;
const auto aspectRatio =
static_cast<FLOAT32>(m_assetImageExtent.y) / static_cast<FLOAT32>(m_assetImageExtent.x);
const auto ImageHeight = aspectRatio * ImageWidth;
ImGui::Image((ImTextureRef) m_assetImageHandle, {ImageWidth, ImageHeight});
if((!gridSize.x) || (!gridSize.y))
return;
gridSize.x *= ImageWidth/m_assetImageExtent.x;
gridSize.y *= ImageHeight/m_assetImageExtent.y;
ImDrawList *draw_list = ImGui::GetWindowDrawList();
auto gridCountX = ImageWidth / gridSize.x;
auto gridCountY = ImageHeight / gridSize.y;
ImU32 grid_color = IM_COL32(200, 200, 200, 50);
float grid_thickness = 1.0f;
ImGui::Dummy(ImVec2(ImageWidth, ImageHeight));
for (int i = 0; i <= gridCountX; ++i)
{
ImVec2 p1 = ImVec2(base_pos.x + i * gridSize.x, base_pos.y);
ImVec2 p2 = ImVec2(base_pos.x + i * gridSize.x, base_pos.y + ImageHeight);
draw_list->AddLine(p1, p2, grid_color, grid_thickness);
}
for (int i = 0; i <= gridCountY; ++i)
{
ImVec2 p1 = ImVec2(base_pos.x, base_pos.y + i * gridSize.y);
ImVec2 p2 = ImVec2(base_pos.x + ImageWidth, base_pos.y + i * gridSize.y);
draw_list->AddLine(p1, p2, grid_color, grid_thickness);
}
}
VOID View_Asset::DrawAssetTypePicker()
{
ImGui::Text("Asset Type: ");
ImGui::SameLine();
ImGui::Combo("##", (INT32 *) &m_assetType, "None\0Texture\0Sprite\0TileSheet\0SpriteSheet\0");
if (m_assetType != m_asset->GetType())
{
ImGui::SameLine();
if (ImGui::Button("Apply"))
{
if (m_assetType == EAssetType::INVALID)
{
Editor::Instance().RemoveFromAssets(m_assetName);
Close();
UI::CloseAssetView();
}
m_asset = AssetManager::ChangeAssetType(m_assetName, m_assetType);
}
}
}
} // namespace ia::iae

View File

@ -0,0 +1,152 @@
// 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 <Editor.hpp>
#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()))
{
if (t.IsDirectory)
{
ChangeCurrentOpenDirectory(t.Path);
break;
}
OpenAsset(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::Update()
{
}
VOID View_AssetBrowser::OnEvent(IN SDL_Event *event)
{
}
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)
{
Editor::Instance().OpenFile(path);
}
} // namespace ia::iae

View File

@ -0,0 +1,46 @@
// 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();
}
VOID View_Console::Update(){
}
VOID View_Console::OnEvent(IN SDL_Event *event)
{
}
} // namespace ia::iae

View File

@ -0,0 +1,170 @@
// 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/FilePreview.hpp>
#include <IAEngine/Asset/AssetManager.hpp>
#include <RenderCore/RenderCore.hpp>
#include <Editor.hpp>
#include <fstream>
namespace ia::iae
{
BOOL is_extension_one_of(IN PCCHAR ext, IN std::initializer_list<PCCHAR> values)
{
for (const auto &t : values)
{
if (!strcmp(ext, t))
return true;
}
return false;
}
Vector<String> get_lines_of_file(IN CONST Path &path)
{
Vector<String> result;
std::string line;
std::ifstream file(path);
while (std::getline(file, line))
result.pushBack(line.c_str());
return result;
}
VOID View_FilePreview::Initialize()
{
SetName("File Preview");
SetIcon(ICON_FA_MAGNIFYING_GLASS);
}
VOID View_FilePreview::Terminate()
{
}
VOID View_FilePreview::Render()
{
PreRender();
if (m_filePath.empty())
{
PostRender();
return;
}
switch (m_fileType)
{
case EFileType::UNKNOWN:
RenderUnknownFile();
break;
case EFileType::TEXT:
RenderTextFile();
break;
case EFileType::IMAGE:
RenderImageFile();
break;
}
PostRender();
}
VOID View_FilePreview::Update()
{
}
VOID View_FilePreview::OnEvent(IN SDL_Event *event)
{
}
VOID View_FilePreview::Open(IN Path path)
{
Close();
m_filePath = path;
m_fileType = EFileType::UNKNOWN;
const auto ext = path.extension().string();
if (is_extension_one_of(&ext[1], {"txt", "xml", "md", "cpp", "c", "hpp", "h"}))
{
m_fileType = EFileType::TEXT;
const auto lines = get_lines_of_file(path);
m_fileDataSize = lines.size();
const auto fileData = new String[m_fileDataSize];
for (SIZE_T i = 0; i < m_fileDataSize; i++)
fileData[i] = lines[i];
m_fileData = fileData;
}
else if (is_extension_one_of(&ext[1], {"png", "jpg", "webp"}))
{
m_fileType = EFileType::IMAGE;
m_fileDataSize = SIZE_MAX;
const auto image = AssetManager::LoadTexture(path.string().c_str())->GetHandle()->ImagePtr;
m_fileDataExtent = IVec2{image->Width, image->Height};
m_fileData = (PVOID)RDC::BakeTexture(image);
}
}
VOID View_FilePreview::Close()
{
switch (m_fileType)
{
case EFileType::UNKNOWN:
break;
case EFileType::TEXT:
delete[] ((String *) m_fileData);
m_fileDataSize = 0;
m_fileData = nullptr;
break;
case EFileType::IMAGE:
m_fileDataSize = 0;
m_fileData = nullptr;
m_fileDataExtent = {};
break;
}
m_filePath = Path();
m_fileType = EFileType::UNKNOWN;
}
VOID View_FilePreview::RenderTextFile()
{
const auto lines = (String*)m_fileData;
for(SIZE_T i = 0; i < m_fileDataSize; i++)
ImGui::Text("%s", lines[i].c_str());
}
VOID View_FilePreview::RenderImageFile()
{
UI::PadX();
UI::PadY();
if(ImGui::Button("Mark as Asset"))
Editor::Instance().MarkAsAsset(m_filePath);
UI::PadY();
const auto ImageWidth = m_extent.x * 0.75f;
UI::AlignCursorHCenter(ImRect{{}, m_extent}, ImageWidth);
const auto aspectRatio = static_cast<FLOAT32>(m_fileDataExtent.y)/static_cast<FLOAT32>(m_fileDataExtent.x);
ImGui::Image((ImTextureRef)m_fileData, {ImageWidth, aspectRatio * ImageWidth});
}
VOID View_FilePreview::RenderUnknownFile()
{
UI::DrawTextCentered(m_extent, "Unsupported File Format");
}
} // namespace ia::iae

View File

@ -0,0 +1,99 @@
// 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 <Editor.hpp>
#include <UI/View/Game.hpp>
#include <RenderCore/RenderCore.hpp>
#include <IAEngine/LibInterface.hpp>
namespace ia::iae
{
VOID View_Game::Initialize()
{
SetName("Game");
SetIcon(ICON_FA_GAMEPAD);
IAEngine::__Initialize(SCENE_EDITOR_RESOULTION, Editor::Instance().GetActiveProject()->AssetDirectory());
m_gameRenderTexture = new RDC_Texture(RDC_Texture::EType::SAMPLED, SCENE_EDITOR_RESOULTION.x, SCENE_EDITOR_RESOULTION.y);
}
VOID View_Game::Terminate()
{
delete m_gameRenderTexture;
}
VOID View_Game::Render()
{
PreRender();
ImGui::Image(m_gameRenderTexture->GetHandle(), m_extent);
PostRender();
}
VOID View_Game::Update()
{
STATIC INT32 frameCounter{0};
IAEngine::__Update();
frameCounter++;
if (frameCounter >= 60)
{
frameCounter = 0;
IAEngine::__FixedUpdate();
}
IAEngine::__RenderToTexture(m_gameRenderTexture->GetHandle());
}
VOID View_Game::OnEvent(IN SDL_Event *event)
{
IAEngine::__ProcessEvent(event);
}
} // 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))
{
}

View File

@ -0,0 +1,38 @@
// 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/IView.hpp>
namespace ia::iae
{
VOID IView::ProcessEvent(IN SDL_Event *event)
{
if (UI::GetFocusedView() == this)
OnEvent(event);
}
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

View File

@ -0,0 +1,46 @@
// 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();
}
VOID View_Nodes::Update(){
}
VOID View_Nodes::OnEvent(IN SDL_Event *event)
{
}
} // namespace ia::iae

View File

@ -0,0 +1,46 @@
// 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();
}
VOID View_Package::Update(){
}
VOID View_Package::OnEvent(IN SDL_Event *event)
{
}
} // namespace ia::iae

View File

@ -0,0 +1,46 @@
// 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();
}
VOID View_Properties::Update(){
}
VOID View_Properties::OnEvent(IN SDL_Event *event)
{
}
} // namespace ia::iae

View File

@ -0,0 +1,52 @@
// 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 <Editor.hpp>
#include <UI/View/Scene.hpp>
#include <RenderCore/RenderCore.hpp>
namespace ia::iae
{
VOID View_Scene::Initialize()
{
SetName("Scene");
SetIcon(ICON_FA_HASHTAG);
}
VOID View_Scene::Terminate()
{
}
VOID View_Scene::Render()
{
PreRender();
PostRender();
}
VOID View_Scene::Update()
{
STATIC INT32 frameCounter{0};
}
VOID View_Scene::OnEvent(IN SDL_Event *event)
{
}
} // namespace ia::iae

View File

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,32 @@
// 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 <IAEngine/Base.hpp>
#include <Vendor/imgui/imgui.h>
#include <Vendor/IconsFontAwesome7.h>
#include <SDL3/SDL.h>
#include <filesystem>
namespace ia::iae
{
namespace fs = std::filesystem;
using Path = std::filesystem::path;
}

View File

@ -0,0 +1,52 @@
// 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 <Project.hpp>
namespace ia::iae
{
class Editor
{
STATIC Editor s_instance;
public:
STATIC Editor &Instance()
{
return s_instance;
}
public:
VOID LoadProject(IN CONST String &directory);
VOID OpenFile(IN Path path);
VOID MarkAsAsset(IN Path path);
VOID RemoveFromAssets(IN CONST String& assetName);
public:
CONST Project *GetActiveProject() CONST
{
return m_activeProject.get();
}
public:
INT32 Run(IN INT32 argc, IN PCCHAR argv[]);
private:
RefPtr<Project> m_activeProject{};
};
} // namespace ia::iae

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,60 @@
// 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 <Base.hpp>
#include <ConfigData/ConfigData.hpp>
namespace ia::iae
{
class Project
{
public:
STATIC RefPtr<Project> Load(IN CONST String &directory);
VOID Update();
public:
IVec2 &WindowPosition()
{
return m_windowPosition;
}
CONST String &Name() CONST
{
return m_projectName;
}
CONST String &AssetDirectory() CONST
{
return m_assetDirectory;
}
private:
IVec2 m_windowPosition{};
CONST String m_projectName;
CONST String m_assetDirectory;
CONST String m_projectAbsolutePath;
RefPtr<ConfigData> m_configData;
public:
Project(IN CONST String &name, IN CONST String &absolutePath, IN RefPtr<ConfigData>&& configData);
~Project();
};
} // namespace ia::iae

View File

@ -0,0 +1,32 @@
// 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 <Base.hpp>
#include <Vendor/imgui/imgui_internal.h>
namespace ia::iae
{
STATIC CONSTEXPR IVec2 SCENE_EDITOR_RESOULTION = {800, 604};
STATIC CONSTEXPR Vec2 LAYOUT_TOP_LEFT_VIEW_EXTENT = {0.275f, 0.55f};
STATIC CONSTEXPR Vec2 LAYOUT_TOP_MIDDLE_VIEW_EXTENT = {0.45f, 0.55f};
STATIC CONSTEXPR Vec2 LAYOUT_TOP_RIGHT_VIEW_EXTENT = {0.275f, 0.55f};
STATIC CONSTEXPR Vec2 LAYOUT_BOTTOM_VIEW_EXTENT = {1.0f, 0.45f};
STATIC CONSTEXPR FLOAT32 MENUBAR_HEIGHT = 18.0f;
} // namespace ia::iae

View File

View File

@ -0,0 +1,65 @@
// 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
{
struct Tab
{
IView* View{};
BOOL IsOpen{true};
BOOL IsCloseable{false};
};
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, IN BOOL isCloseable = false);
IView *GetTab(IN CONST String &name);
VOID RemoveTab(IN CONST String &name);
VOID OpenTab(IN CONST String& name);
VOID CloseTab(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, Tab> m_tabViews;
private:
VOID AddTab(IN CONST String &name, IN IView *view, IN BOOL isCloseable);
};
template<typename ViewType> VOID TabContainer::AddTab(IN CONST String &name, IN BOOL isCloseable)
{
AddTab(name, new ViewType(), isCloseable);
}
} // namespace ia::iae

View File

@ -0,0 +1,69 @@
// 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/Base.hpp>
namespace ia::iae
{
class UI
{
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);
STATIC VOID DrawTextCentered(IN CONST ImVec2& viewExtent, IN CONST String& text);
public:
STATIC VOID OpenFilePreviewView();
STATIC VOID CloseFilePreviewView();
STATIC VOID OpenAssetView();
STATIC VOID CloseAssetView();
STATIC class View_Asset* GetAssetView();
STATIC class View_FilePreview *GetFilePreviewView();
STATIC class IView *GetFocusedView()
{
return s_focusedView;
}
private:
STATIC class IView *s_focusedView;
private:
STATIC VOID Initialize();
STATIC VOID Terminate();
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

@ -0,0 +1,56 @@
// 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>
#include <IAEngine/Asset/IAsset.hpp>
namespace ia::iae
{
class View_Asset : public IView
{
public:
VOID Open(IN String assetName);
VOID Close();
public:
VOID Initialize();
VOID Terminate();
VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
private:
VOID RenderTextureAsset();
VOID RenderSpriteAsset();
VOID RenderTileSheetAsset();
VOID RenderSpriteSheetAsset();
VOID DrawAssetTypePicker();
VOID DrawAssetImage(IN FLOAT32 relativeWidth, IN IVec2 gridSize);
private:
class IAsset *m_asset{};
String m_assetName{};
Handle m_assetImageHandle{};
IVec2 m_assetImageExtent{};
EAssetType m_assetType{};
};
} // namespace ia::iae

View File

@ -0,0 +1,59 @@
// 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>
#include <filesystem>
namespace ia::iae
{
class View_AssetBrowser : public IView
{
struct FileEntry
{
PCCHAR Icon{""};
String Name{};
BOOL IsDirectory{};
String IconAndName{};
std::filesystem::path Path{};
};
public:
VOID Initialize();
VOID Terminate();
VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
private:
VOID ChangeCurrentOpenDirectory(IN CONST std::filesystem::path &path);
VOID FillFileEntries(IN CONST std::filesystem::path &path, IN Vector<FileEntry> &fileEntries);
PCCHAR GetFileEntryIcon(IN PCCHAR extension);
VOID OpenAsset(IN CONST std::filesystem::path &path);
private:
Vector<FileEntry> m_assetDirectoryFiles;
std::filesystem::path m_assetDirectoryPath{};
Vector<FileEntry> m_currentOpenDirectoryFiles;
std::filesystem::path m_currentOpenDirectoryPath{};
};
} // namespace ia::iae::editor

View File

@ -0,0 +1,34 @@
// 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 View_Console : public IView
{
public:
VOID Initialize();
VOID Terminate();
VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
};
}

View File

@ -0,0 +1,58 @@
// 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 View_FilePreview : public IView
{
enum class EFileType
{
UNKNOWN,
TEXT,
IMAGE,
};
public:
VOID Open(IN Path path);
VOID Close();
public:
VOID Initialize();
VOID Terminate();
VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
private:
VOID RenderTextFile();
VOID RenderImageFile();
VOID RenderUnknownFile();
private:
Path m_filePath{};
EFileType m_fileType{EFileType::UNKNOWN};
PVOID m_fileData{};
SIZE_T m_fileDataSize{};
IVec2 m_fileDataExtent{};
};
} // namespace ia::iae

View File

@ -0,0 +1,43 @@
// 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 View_Game : public IView
{
public:
VOID Initialize();
VOID Terminate();
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_gameRenderTexture;
};
} // namespace ia::iae

View File

@ -0,0 +1,82 @@
// 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/UI.hpp>
namespace ia::iae
{
class IView
{
protected:
PURE_VIRTUAL(VOID OnEvent(IN SDL_Event *event));
public:
PURE_VIRTUAL(VOID Initialize());
PURE_VIRTUAL(VOID Terminate());
PURE_VIRTUAL(VOID Render());
PURE_VIRTUAL(VOID Update());
public:
VOID SetIcon(IN PCCHAR icon);
VOID SetName(IN CONST String &name);
VIRTUAL VOID ProcessEvent(IN SDL_Event *event);
public:
CONST String &Name() CONST
{
return m_name;
}
CONST PCCHAR Icon() CONST
{
return m_icon;
}
CONST String &IconAndName() CONST
{
return m_iconAndName;
}
protected:
INLINE VOID PreRender();
INLINE VOID PostRender();
protected:
ImVec2 m_extent{};
String m_name{};
PCCHAR m_icon{};
String m_iconAndName{};
public:
VIRTUAL ~IView()
{
}
};
VOID IView::PreRender()
{
m_extent = ImGui::GetContentRegionAvail();
ImGui::BeginChild("##");
}
VOID IView::PostRender()
{
ImGui::EndChild();
}
} // namespace ia::iae

View File

@ -0,0 +1,34 @@
// 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 View_Nodes : public IView
{
public:
VOID Initialize();
VOID Terminate();
VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
};
}

View File

@ -0,0 +1,34 @@
// 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 View_Package : public IView
{
public:
VOID Initialize();
VOID Terminate();
VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
};
}

View File

@ -0,0 +1,34 @@
// 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 View_Properties : public IView
{
public:
VOID Initialize();
VOID Terminate();
VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
};
}

View File

@ -0,0 +1,40 @@
// 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 View_Scene : public IView
{
public:
VOID Initialize();
VOID Terminate();
VOID Render();
VOID Update();
protected:
VOID OnEvent(IN SDL_Event *event);
public:
VOID ProcessEvent(IN SDL_Event *event)
{
OnEvent(event);
}
};
} // namespace ia::iae

View File

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,8 @@ set(SRC_FILES
"imp/cpp/Scene.cpp"
"imp/cpp/GameData.cpp"
"imp/cpp/Asset/AssetManager.cpp"
#"imp/cpp/EmbeddedResources.cpp"
)
@ -11,5 +13,5 @@ add_library(IAEngine STATIC ${SRC_FILES})
target_include_directories(IAEngine PUBLIC inc)
target_include_directories(IAEngine PRIVATE imp/hpp)
target_link_libraries(IAEngine PUBLIC RenderCore pugixml::pugixml)
target_link_libraries(IAEngine PUBLIC RenderCore ConfigData)
target_link_libraries(IAEngine PRIVATE ZLIB::ZLIBSTATIC SDL3_mixer::SDL3_mixer)

View File

@ -0,0 +1,365 @@
// 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/Asset/AssetManager.hpp>
#include <IAEngine/IAEngine.hpp>
#include <SDL3/SDL_iostream.h>
#define STB_IMAGE_IMPLEMENTATION
#include <Vendor/stb/stb_image.h>
#include <RenderCore/RenderCore.hpp>
#include <IACore/DynamicLib.hpp>
#include <filesystem>
namespace ia::iae
{
Map<String, String> g_assetNameToPathMap;
Map<String, String> g_assetPathToNameMap;
String AssetManager::s_assetDirectory;
Vector<IAsset *> AssetManager::s_assets;
Map<String, IAsset *> AssetManager::s_assetNames;
ImageView *CreateTextureFromFile(IN PCCHAR path, IN INT32 tileWidth = -1, IN INT32 tileHeight = -1)
{
const auto data = AssetManager::ReadBinaryAsset(path);
INT32 w, h, n;
auto pixels = stbi_load_from_memory(data.data(), data.size(), &w, &h, &n, STBI_rgb_alpha);
if (!pixels)
THROW_INVALID_DATA(path);
const auto t = RDC::CreateImageView(RDC::CreateImage(pixels, w, h), tileWidth == -1 ? 1 : w / tileWidth,
tileHeight == -1 ? 1 : h / tileHeight);
stbi_image_free(pixels);
return t;
}
VOID AssetManager::Initialize()
{
}
VOID AssetManager::Terminate()
{
for (SIZE_T i = 0; i < s_assets.size(); i++)
DestroyAsset(s_assets[i]);
}
String get_relative_asset_path(IN CONST String& _path)
{
std::string __path = _path.c_str();
const auto t = std::filesystem::path(_path.c_str());
return t.is_absolute() ? String(__path.substr(__path.find("Assets") + 7).c_str()) : _path;
}
String AssetManager::GetAssetName(IN CONST String &_path)
{
const auto path = get_relative_asset_path(_path);
if(g_assetPathToNameMap.contains(path))
return g_assetPathToNameMap[path];
return "";
}
IAsset* AssetManager::ChangeAssetType(IN CONST String& assetName, IN EAssetType newType)
{
if(!s_assetNames.contains(assetName))
return nullptr;
const auto currentAsset = (Asset_Texture*)s_assetNames[assetName];
if(newType == currentAsset->GetType())
return currentAsset;
IAsset* asset{};
switch(newType)
{
case EAssetType::TEXTURE:
asset = new Asset_Texture(currentAsset->GetHandle());
break;
case EAssetType::SPRITE:
asset = new Asset_Sprite(currentAsset->GetHandle());
break;
case EAssetType::TILESHEET:
asset = new Asset_TileSheet(currentAsset->GetHandle(), currentAsset->GetHandle()->ImagePtr->Width, currentAsset->GetHandle()->ImagePtr->Height);
break;
case EAssetType::SPRITESHEET:
asset = new Asset_SpriteSheet(currentAsset->GetHandle(), currentAsset->GetHandle()->ImagePtr->Width, currentAsset->GetHandle()->ImagePtr->Height, {});
break;
case EAssetType::INVALID:
case EAssetType::SOUND:
case EAssetType::SCENE:
case EAssetType::PLUGIN:
case EAssetType::PACKAGE:
break;
}
DestroyAsset(s_assetNames[assetName]);
s_assetNames[assetName] = asset;
return asset;
}
VOID AssetManager::SetAssetDirectory(IN CONST String &path)
{
s_assetDirectory = path;
}
String AssetManager::ReadTextAsset(IN CONST String &path)
{
const auto t =
std::filesystem::path(path.c_str()).is_absolute() ? path : BuildString(s_assetDirectory, "/", path);
SDL_IOStream *f = SDL_IOFromFile(t.c_str(), "r");
if (!f)
THROW_FILE_OPEN_READ(t);
Vector<CHAR> result;
SDL_SeekIO(f, 0, SDL_IO_SEEK_END);
result.resize(SDL_TellIO(f) + 1);
SDL_SeekIO(f, 0, SDL_IO_SEEK_SET);
SDL_ReadIO(f, result.data(), result.size());
result.back() = '\0';
SDL_CloseIO(f);
return result.data();
}
Vector<UINT8> AssetManager::ReadBinaryAsset(IN CONST String &path)
{
const auto t =
std::filesystem::path(path.c_str()).is_absolute() ? path : BuildString(s_assetDirectory, "/", path);
SDL_IOStream *f = SDL_IOFromFile(t.c_str(), "rb");
if (!f)
THROW_FILE_OPEN_READ(t);
Vector<UINT8> result;
SDL_SeekIO(f, 0, SDL_IO_SEEK_END);
result.resize(SDL_TellIO(f));
SDL_SeekIO(f, 0, SDL_IO_SEEK_SET);
SDL_ReadIO(f, result.data(), result.size());
SDL_CloseIO(f);
return result;
}
Asset_Texture *AssetManager::LoadTexture(IN CONST String &path)
{
const auto t = new Asset_Texture(CreateTextureFromFile(path.c_str()));
t->SetPath(get_relative_asset_path(path));
s_assets.pushBack(t);
return t;
}
Asset_Sprite *AssetManager::LoadSprite(IN CONST String &path)
{
return nullptr;
}
Asset_SpriteSheet *AssetManager::LoadSpriteSheet(IN CONST String &path)
{
return nullptr;
}
Asset_TileSheet *AssetManager::LoadTileSheet(IN CONST String &path)
{
return nullptr;
}
IAsset_Package *AssetManager::LoadPackage(IN CONST String &path)
{
return nullptr;
}
Asset_Texture *AssetManager::CreateTexture(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height)
{
return new Asset_Texture(RDC::CreateImageView(RDC::CreateImage(rgbaData, width, height)));
}
Asset_Sprite *AssetManager::CreateSprite(IN CONST Asset_Texture *texture)
{
return new Asset_Sprite(texture->m_handle);
}
Asset_SpriteSheet *AssetManager::CreateSpriteSheet(IN CONST Vector<Asset_Texture *> &sprites,
IN CONST Map<String, INT32> &animations)
{
return nullptr;
}
Asset_SpriteSheet *AssetManager::CreateSpriteSheet(IN CONST Asset_Texture *texture, IN INT32 frameWidth,
IN INT32 frameHeight, IN CONST Map<String, INT32> &animations)
{
return nullptr;
}
Asset_TileSheet *AssetManager::CreateTileSheet(IN CONST Asset_Texture *texture, IN INT32 tileWidth,
IN INT32 tileHeight)
{
const auto image = texture->m_handle->ImagePtr;
const auto t = new Asset_TileSheet(
RDC::CreateImageView(image, image->Width / tileWidth, image->Height / tileHeight), tileWidth, tileHeight);
s_assets.pushBack(t);
return t;
}
VOID AssetManager::DestroyAsset(IN IAsset *asset)
{
asset->Destroy();
delete asset;
for (auto &t : s_assets)
if (t == asset)
t = nullptr;
for (auto &t : s_assetNames)
if (t->Value == asset)
t->Value = nullptr;
}
IAsset *AssetManager::GetAssetByName(IN CONST String &name)
{
return s_assetNames[name];
}
VOID AssetManager::AssignAssetName(IN IAsset *asset, IN CONST String &name)
{
s_assetNames[name] = asset;
g_assetNameToPathMap[name] = asset->GetPath();
g_assetPathToNameMap[asset->GetPath()] = name;
}
Asset_Scene *AssetManager::CreateScene(IN IVec2 extent)
{
const auto t = new Asset_Scene(new Scene(extent));
s_assets.pushBack(t);
return t;
}
} // namespace ia::iae
namespace ia::iae
{
IAsset::IAsset(IN EAssetType type) : m_type(type)
{
}
IAsset::~IAsset()
{
}
VOID Asset_Texture::Compile()
{
}
VOID Asset_Texture::Destroy()
{
}
VOID Asset_TileSheet::Compile()
{
}
VOID Asset_TileSheet::Destroy()
{
}
VOID Asset_Sprite::Compile()
{
}
VOID Asset_Sprite::Destroy()
{
}
VOID Asset_SpriteSheet::Compile()
{
}
VOID Asset_SpriteSheet::Destroy()
{
}
VOID Asset_Scene::Compile()
{
}
VOID Asset_Scene::Destroy()
{
}
VOID Asset_Plugin::Compile()
{
}
VOID Asset_Plugin::Destroy()
{
}
VOID IAsset_Package::Compile()
{
}
VOID IAsset_Package::Destroy()
{
}
} // namespace ia::iae
#include <zlib.h>
namespace ia::iae
{
Vector<UINT8> AssetManager::Inflate(IN PCUINT8 data, IN SIZE_T dataSize)
{
STATIC UINT8 TMP_BUFFER[16384];
Vector<UINT8> result;
result.reserve(dataSize * 3);
z_stream stream;
stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
stream.opaque = Z_NULL;
stream.avail_in = 0;
stream.next_in = Z_NULL;
if (inflateInit(&stream) != Z_OK)
THROW_UNKNOWN("Inflate failed: init zlib inflate");
stream.avail_in = dataSize;
stream.next_in = (Bytef *) data;
while (true)
{
stream.avail_out = sizeof(TMP_BUFFER);
stream.next_out = TMP_BUFFER;
const auto r = inflate(&stream, Z_SYNC_FLUSH);
result.insert(result.end(), sizeof(TMP_BUFFER) - stream.avail_out, TMP_BUFFER);
if (r == Z_STREAM_END)
break;
else if (r != Z_OK)
THROW_INVALID_DATA("Inflate failed: zlib inflation");
}
inflateEnd(&stream);
return result;
}
Vector<UINT8> AssetManager::Deflate(IN PCUINT8 data, IN SIZE_T dataSize)
{
Vector<UINT8> result;
auto deflateBound = compressBound(dataSize);
result.resize(deflateBound);
compress(result.data(), &deflateBound, data, dataSize);
result.resize(deflateBound);
return result;
}
} // namespace ia::iae

File diff suppressed because one or more lines are too long

View File

@ -17,88 +17,19 @@
#include <GameData.hpp>
#include <IAEngine/IAEngine.hpp>
#include <pugixml.hpp>
#include <ConfigData/ConfigData.hpp>
#include <filesystem>
namespace ia::iae
{
class XMLData
{
public:
STATIC XMLData *Load(IN CONST String &path);
CONST String Type;
CONST String Name;
CONST pugi::xml_node PropertiesNode;
CONST Vector<pugi::xml_node> ChildNodes;
private:
CONST pugi::xml_document m_document;
XMLData(IN pugi::xml_document &&document, IN CONST String &type, IN CONST String &name,
IN pugi::xml_node propertiesNode, IN CONST Vector<pugi::xml_node> &childNodes);
};
XMLData::XMLData(IN pugi::xml_document &&document, IN CONST String &type, IN CONST String &name,
IN pugi::xml_node propertiesNode, IN CONST Vector<pugi::xml_node> &childNodes)
: m_document(IA_MOVE(document)), Type(type), Name(name), PropertiesNode(propertiesNode), ChildNodes(childNodes)
{
}
XMLData *XMLData::Load(IN CONST String &path)
{
pugi::xml_document doc;
if (!doc.load_file(path.c_str()))
return nullptr;
if (std::distance(doc.children().begin(), doc.children().end()) != 1)
return nullptr;
const auto rootNode = *doc.children().begin();
// Verify Engine Version
{
const auto engineInfoNode = rootNode.child("IAEngine");
if (!engineInfoNode)
return nullptr;
const auto engineVersionNode = engineInfoNode.child("EngineVersion");
if (!engineVersionNode)
return nullptr;
const auto engineVersion = IA_PARSE_VERSION_STRING(engineVersionNode.text().as_string());
if (engineVersion > IAEngine::ENGINE_VERSION)
{
IAE_LOG_WARN("XML data file was created with a newer version of IAEngine, skipping..");
return nullptr;
}
}
const auto propertiesNode = rootNode.child("Properties");
if (!propertiesNode)
return nullptr;
Vector<pugi::xml_node> childNodes;
for (auto &c : rootNode.children())
{
if ((!strcmp(c.name(), "Properties")) || (!strcmp(c.name(), "IAEngine")))
continue;
childNodes.pushBack(c);
}
const auto nameAttr = rootNode.attribute("name");
return new XMLData(IA_MOVE(doc), rootNode.name(), nameAttr ? nameAttr.as_string() : "", propertiesNode,
childNodes);
}
} // namespace ia::iae
namespace ia::iae
{
RefPtr<Scene> g_entryScene{};
Asset_Scene* g_entryScene{};
VOID GameData::Initialize()
{
if (!LoadResourceData())
if (!LoadAssetData())
{
IAE_LOG_WARN("Couldn't load \"Resources.XML\", skipping..");
IAE_LOG_WARN("Couldn't load \"Assets.XML\", skipping..");
return;
}
if (!LoadSceneData())
@ -114,7 +45,7 @@ namespace ia::iae
BOOL GameData::LoadSceneData()
{
for (const auto &entry : std::filesystem::directory_iterator("Resources/Scenes/"))
for (const auto &entry : std::filesystem::directory_iterator(BuildString(AssetManager::GetAssetDirectory(), "/Scenes/").c_str()))
{
const auto scene = ParseScene(entry.path().string().c_str());
if (!scene)
@ -126,14 +57,14 @@ namespace ia::iae
return true;
}
BOOL GameData::LoadResourceData()
BOOL GameData::LoadAssetData()
{
auto xml = XMLData::Load("Resources/Resources.xml");
auto xml = ConfigData::LoadFromFile(BuildString(AssetManager::GetAssetDirectory(), "/Assets.xml"));
if (!xml)
return false;
pugi::xml_node entriesNode{};
for (const auto &node : xml->ChildNodes)
for (const auto &node : xml->Children())
{
if (!strcmp(node.name(), "Entries"))
{
@ -154,8 +85,8 @@ namespace ia::iae
}
else if (!strcmp(entry.name(), "TileSheet"))
{
IAEngine::AssignResourceName(
IAEngine::CreateTileSheet(BuildString("Resources/", entry.attribute("path").as_string()),
AssetManager::AssignAssetName(
AssetManager::CreateTileSheet(AssetManager::LoadTexture(entry.attribute("path").as_string()),
entry.attribute("tileWidth").as_int(),
entry.attribute("tileHeight").as_int()),
entry.attribute("name").as_string());
@ -164,42 +95,41 @@ namespace ia::iae
THROW_INVALID_DATA();
}
delete xml;
return true;
}
RefPtr<Scene> GameData::ParseScene(IN CONST String &path)
Asset_Scene* GameData::ParseScene(IN CONST String &path)
{
const auto xml = XMLData::Load(path);
const auto xml = ConfigData::LoadFromFile(path);
if (!xml)
return nullptr;
const auto extentNode = xml->PropertiesNode.child("Extent");
const auto extentNode = xml->Property("Extent");
if (!extentNode)
return nullptr;
const auto extent = IVec2{extentNode.attribute("width").as_int(), extentNode.attribute("height").as_int()};
RefPtr<Scene> scene = MakeRefPtr<Scene>(extent);
auto scene = AssetManager::CreateScene(extent);
for (const auto &child : xml->ChildNodes)
for (const auto &child : xml->Children())
{
if (!strcmp(child.name(), "Resources"))
if (!strcmp(child.name(), "Assets"))
{
for (const auto &r : child.children())
scene->AddReferencedResources(IAEngine::GetResourceByName(r.attribute("name").as_string()));
scene->GetHandle()->AddReferencedResources(AssetManager::GetAssetByName<IAsset>(r.attribute("name").as_string()));
}
else if (!strcmp(child.name(), "Nodes"))
{
}
else if (!strcmp(child.name(), "Grid"))
{
ParseSceneGrid(scene.get(), &child);
ParseSceneGrid(scene->GetHandle(), &child);
}
else
THROW_INVALID_DATA();
}
IAEngine::AssignResourceName(IAEngine::AddScene(scene), xml->Name);
AssetManager::AssignAssetName(scene, xml->Name());
if (!g_entryScene)
g_entryScene = scene;
@ -225,7 +155,7 @@ namespace ia::iae
return;
auto& cell = scene->GetGridCell(tileCursorX, tileCursorY);
cell.TileSheetTexture = IAEngine::GetResourceByName(cellNode.attribute("tileSheet").as_string());
cell.TileSheet = AssetManager::GetAssetByName<Asset_TileSheet>(cellNode.attribute("tileSheet").as_string());
cell.TileIndex.x = cellNode.attribute("tileX").as_int();
cell.TileIndex.y = cellNode.attribute("tileY").as_int();
cell.CollisionMask = cellNode.attribute("collisionMask").as_ullong();
@ -261,7 +191,7 @@ namespace ia::iae
}
}
RefPtr<Scene> GameData::GetEntryScene()
Asset_Scene* GameData::GetEntryScene()
{
return g_entryScene;
}

View File

@ -18,50 +18,12 @@
#include <GameData.hpp>
#include <IAEngine/LibInterface.hpp>
#define STB_IMAGE_IMPLEMENTATION
#include <Vendor/stb/stb_image.h>
#include <RenderCore/RenderCore.hpp>
namespace ia::iae
{
struct Resource
{
enum class EType
{
INVALID,
Asset_Scene *g_activeScene{};
TEXTURE,
SPRITE_SHEET,
SOUND,
SCENE
};
EType Type{EType::INVALID};
};
struct Resource_Texture : public Resource
{
Handle Texture;
};
struct Resource_SpriteSheet : public Resource_Texture
{
Vector<INT32> FrameCounts;
};
struct Resource_Scene : public Resource
{
RefPtr<Scene> SceneRef;
};
RefPtr<Scene> g_activeScene;
Vector<Resource *> g_resources;
Map<String, Handle> g_resourceNames;
} // namespace ia::iae
namespace ia::iae
{
String g_gameName;
String g_gamePackageName;
String g_gameDeveloperName;
@ -71,11 +33,7 @@ namespace ia::iae
Vec2 g_designViewport;
SDL_Window *g_windowHandle{};
#if defined(__IA_DEBUG) && __IA_DEBUG
BOOL g_isDebugMode = true;
#else
BOOL g_isDebugMode = false;
#endif
Vector<Asset_Plugin *> g_plugins;
BOOL g_isHeadlessMode = false;
@ -115,7 +73,7 @@ namespace ia::iae
// EmbeddedResources::Initialize();
IAEngine::__Initialize();
IAEngine::__Initialize(g_designViewport, "./Assets/");
SDL_Event event{};
while (true)
@ -150,273 +108,148 @@ namespace ia::iae
namespace ia::iae
{
VOID IAEngine::__Initialize()
VOID IAEngine::__Initialize(IN IVec2 designResolution, IN CONST String& assetDirectory)
{
g_isHeadlessMode = false;
g_designViewport = designResolution;
RDC::Initialize(IVec2{g_designViewport.x, g_designViewport.y}, g_windowHandle, g_isDebugMode);
AssetManager::SetAssetDirectory(assetDirectory);
GameData::Initialize();
ChangeActiveScene(GameData::GetEntryScene() ? GameData::GetEntryScene()
: CreateScene({g_designViewport.x, g_designViewport.y}));
ChangeActiveScene(GameData::GetEntryScene()
? GameData::GetEntryScene()
: AssetManager::CreateScene({g_designViewport.x, g_designViewport.y}));
Game_OnInitialize();
//for (auto &p : g_plugins)
// p->OnInitialize();
}
VOID IAEngine::__InitializeHeadless()
VOID IAEngine::__InitializeHeadless(IN CONST String& assetDirectory)
{
g_isHeadlessMode = true;
if(!g_designViewport.x || !g_designViewport.y)
if (!g_designViewport.x || !g_designViewport.y)
g_designViewport = {800, 600};
AssetManager::SetAssetDirectory(assetDirectory);
GameData::Initialize();
ChangeActiveScene(GameData::GetEntryScene() ? GameData::GetEntryScene()
: CreateScene({g_designViewport.x, g_designViewport.y}));
ChangeActiveScene(GameData::GetEntryScene()
? GameData::GetEntryScene()
: AssetManager::CreateScene({g_designViewport.x, g_designViewport.y}));
Game_OnInitialize();
//for (auto &p : g_plugins)
// p->OnInitialize();
}
VOID IAEngine::__Terminate()
{
//for (auto &p : g_plugins)
// p->OnTerminate();
Game_OnTerminate();
GameData::Terminate();
RDC::Terminate();
for (SIZE_T i = 0; i < g_resources.size(); i++)
DestroyResource(i);
}
VOID IAEngine::__RenderToWindow()
{
g_activeScene->OnDraw();
g_activeScene->GetHandle()->OnDraw();
RDC::RenderToWindow();
g_activeScene->OnDebugDraw();
g_activeScene->GetHandle()->OnDebugDraw();
Game_OnDebugDraw();
//for (auto &p : g_plugins)
// p->OnDebugDraw();
}
VOID IAEngine::__RenderToTexture(IN PVOID textureHandle)
{
g_activeScene->OnDraw();
g_activeScene->GetHandle()->OnDraw();
RDC::RenderToTexture((SDL_GPUTexture *) textureHandle);
g_activeScene->OnDebugDraw();
g_activeScene->GetHandle()->OnDebugDraw();
Game_OnDebugDraw();
//for (auto &p : g_plugins)
// p->OnDebugDraw();
}
VOID IAEngine::__Update()
{
FLOAT32 deltaTime = 0;
g_activeScene->OnUpdate(deltaTime);
g_activeScene->GetHandle()->OnUpdate(deltaTime);
Game_OnUpdate(deltaTime);
//for (auto &p : g_plugins)
// p->OnUpdate(deltaTime);
}
VOID IAEngine::__FixedUpdate()
{
g_activeScene->OnFixedUpdate();
g_activeScene->GetHandle()->OnFixedUpdate();
Game_OnFixedUpdate();
//for (auto &p : g_plugins)
// p->OnFixedUpdate();
}
VOID IAEngine::__ProcessEvent(IN PVOID _event)
{
const auto event = (SDL_Event *) _event;
}
} // namespace ia::iae
namespace ia::iae
{
Handle CreateTextureFromFile(IN PCCHAR path, IN INT32 tileWidth = -1, IN INT32 tileHeight = -1)
VOID IAEngine::AddPlugin(IN Asset_Plugin *plugin)
{
INT32 w, h, n;
auto pixels = stbi_load(path, &w, &h, &n, STBI_rgb_alpha);
if (!pixels)
THROW_INVALID_DATA(path);
const auto t =
RDC::CreateImage(pixels, w, h, tileWidth == -1 ? 1 : w / tileWidth, tileHeight == -1 ? 1 : h / tileHeight);
stbi_image_free(pixels);
return t;
}
Handle IAEngine::CreateSprite(IN CONST String &path)
{
const auto t = new Resource_Texture();
t->Type = Resource::EType::TEXTURE;
t->Texture = CreateTextureFromFile(path.c_str());
g_resources.pushBack(t);
return (Handle) g_resources.size() - 1;
}
Handle IAEngine::CreateSprite(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height)
{
const auto t = new Resource_Texture();
t->Type = Resource::EType::TEXTURE;
t->Texture = RDC::CreateImage(rgbaData, width, height);
g_resources.pushBack(t);
return (Handle) g_resources.size() - 1;
}
Handle IAEngine::CreateSpriteSheet(IN CONST Vector<Vector<Handle>> &animations)
{
THROW_NOT_IMPLEMENTED();
return INVALID_HANDLE;
}
Handle IAEngine::CreateSpriteSheet(IN CONST String &path, IN INT32 spriteWidth, IN INT32 spriteHeight,
IN CONST Vector<INT32> &frameCounts)
{
const auto t = new Resource_SpriteSheet();
t->Type = Resource::EType::SPRITE_SHEET;
t->FrameCounts = frameCounts;
t->Texture = CreateTextureFromFile(path.c_str(), spriteWidth, spriteHeight);
g_resources.pushBack(t);
return (Handle) g_resources.size() - 1;
}
Handle IAEngine::CreateTileSheet(IN CONST String &path, IN INT32 tileWidth, IN INT32 tileHeight)
{
const auto t = new Resource_Texture();
t->Type = Resource::EType::TEXTURE;
t->Texture = CreateTextureFromFile(path.c_str(), tileWidth, tileHeight);
g_resources.pushBack(t);
return (Handle) g_resources.size() - 1;
}
Handle IAEngine::CreateTileSheet(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height, IN INT32 tileWidth,
IN INT32 tileHeight)
{
const auto t = new Resource_Texture();
t->Type = Resource::EType::TEXTURE;
t->Texture = RDC::CreateImage(rgbaData, width, height, width / tileWidth, height / tileHeight);
g_resources.pushBack(t);
return (Handle) g_resources.size() - 1;
}
VOID IAEngine::DestroyResource(IN Handle resource)
{
if (!g_resources[resource])
return;
switch (g_resources[resource]->Type)
{
case Resource::EType::INVALID:
break;
case Resource::EType::TEXTURE:
case Resource::EType::SPRITE_SHEET:
RDC::DestroyImage(static_cast<Resource_Texture *>(g_resources[resource])->Texture);
break;
case Resource::EType::SOUND:
break;
case Resource::EType::SCENE:
static_cast<Resource_Scene *>(g_resources[resource])->SceneRef.reset();
break;
}
delete g_resources[resource];
g_resources[resource] = nullptr;
for (auto &t : g_resourceNames)
if (t->Value == resource)
t->Value = INVALID_HANDLE;
}
Handle IAEngine::GetResourceByName(IN CONST String &name)
{
return g_resourceNames[name];
}
VOID IAEngine::AssignResourceName(IN Handle resource, IN CONST String &name)
{
g_resourceNames[name] = resource;
}
VOID IAEngine::LoadResources(IN CONST Vector<Handle> &resources)
{
Vector<Handle> atlasTextures;
for (const auto &handle : resources)
{
switch (g_resources[handle]->Type)
{
case Resource::EType::SCENE:
case Resource::EType::INVALID:
break;
case Resource::EType::TEXTURE:
case Resource::EType::SPRITE_SHEET:
atlasTextures.pushBack(static_cast<Resource_Texture *>(g_resources[handle])->Texture);
break;
case Resource::EType::SOUND:
break;
}
}
RDC::CompileTextures(atlasTextures);
g_plugins.pushBack(plugin);
}
} // namespace ia::iae
namespace ia::iae
{
VOID IAEngine::DrawTile(IN Handle tileSheet, IN INT32 tileIndexX, IN INT32 tileIndexY, IN Vec2 position,
VOID IAEngine::DrawTile(IN Asset_TileSheet *tileSheet, IN INT32 tileIndexX, IN INT32 tileIndexY, IN Vec2 position,
IN Vec2 scale, IN FLOAT32 rotation, IN BOOL flipH, IN BOOL flipV, IN Vec2 uvOffset)
{
const auto t = static_cast<Resource_Texture *>(g_resources[tileSheet]);
RDC::DrawSpriteTopLeft(t->Texture, tileIndexX, tileIndexY, position, scale, rotation, flipH, flipV, uvOffset);
}
VOID IAEngine::DrawSprite(IN Handle sprite, IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN BOOL flipH,
IN BOOL flipV, IN Vec2 uvOffset)
{
const auto t = static_cast<Resource_Texture *>(g_resources[sprite]);
RDC::DrawSpriteTopLeft(t->Texture, 0, 0, position, scale, rotation, flipH, flipV, uvOffset);
}
VOID IAEngine::DrawSprite(IN Handle spriteSheet, IN INT32 animationIndex, IN INT32 frameIndex, IN Vec2 position,
IN Vec2 scale, IN FLOAT32 rotation, IN BOOL flipH, IN BOOL flipV, IN Vec2 uvOffset)
{
const auto t = static_cast<Resource_SpriteSheet *>(g_resources[spriteSheet]);
RDC::DrawSpriteTopLeft(t->Texture, frameIndex, animationIndex, position, scale, rotation, flipH, flipV,
RDC::DrawSpriteTopLeft(tileSheet->GetHandle(), tileIndexX, tileIndexY, position, scale, rotation, flipH, flipV,
uvOffset);
}
VOID IAEngine::DrawSprite(IN Asset_Sprite *sprite, IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation,
IN BOOL flipH, IN BOOL flipV, IN Vec2 uvOffset)
{
RDC::DrawSpriteTopLeft(sprite->GetHandle(), 0, 0, position, scale, rotation, flipH, flipV, uvOffset);
}
VOID IAEngine::DrawSprite(IN Asset_SpriteSheet *spriteSheet, IN INT32 animationIndex, IN INT32 frameIndex,
IN Vec2 position, IN Vec2 scale, IN FLOAT32 rotation, IN BOOL flipH, IN BOOL flipV,
IN Vec2 uvOffset)
{
RDC::DrawSpriteTopLeft(spriteSheet->GetHandle(), frameIndex, animationIndex, position, scale, rotation, flipH,
flipV, uvOffset);
}
} // namespace ia::iae
namespace ia::iae
{
RefPtr<Scene> IAEngine::GetActiveScene()
Asset_Scene *IAEngine::GetActiveScene()
{
return g_activeScene;
}
RefPtr<Scene> IAEngine::CreateScene(IN IVec2 extent)
{
return MakeRefPtr<Scene>(extent);
}
VOID IAEngine::ChangeActiveScene(IN RefPtr<Scene> scene)
VOID IAEngine::ChangeActiveScene(IN Asset_Scene *scene)
{
g_activeScene = scene;
LoadResources(scene->GetReferencedResources());
}
VOID IAEngine::ChangeActiveScene(IN Handle scene)
{
ChangeActiveScene(static_cast<Resource_Scene *>(g_resources[scene])->SceneRef);
}
Handle IAEngine::AddScene(IN RefPtr<Scene> scene)
{
const auto t = new Resource_Scene();
t->Type = Resource::EType::SCENE;
t->SceneRef = scene;
g_resources.pushBack(t);
return (Handle) g_resources.size() - 1;
}
} // namespace ia::iae

View File

@ -18,6 +18,10 @@
namespace ia::iae
{
Scene::Scene()
{
}
Scene::Scene(IN IVec2 extent) : m_extent(extent)
{
}
@ -26,6 +30,11 @@ namespace ia::iae
{
}
VOID Scene::SetExtent(IN IVec2 extent)
{
m_extent = extent;
}
VOID Scene::SetupGrid(IN IVec2 gridCellSize)
{
m_gridCellSize = gridCellSize;
@ -38,13 +47,10 @@ namespace ia::iae
INT32 tileCursorX{}, tileCursorY{};
for (const auto &cell : m_gridCells)
{
if (cell.TileSheetTexture)
IAEngine::DrawTile(cell.TileSheetTexture, cell.TileIndex.x, cell.TileIndex.y,
{
tileCursorX * m_gridCellSize.x,
tileCursorY * m_gridCellSize.y
},
{1.0f, 1.0f}, 0.0f);
if (cell.TileSheet)
IAEngine::DrawTile(cell.TileSheet, cell.TileIndex.x, cell.TileIndex.y,
{tileCursorX * m_gridCellSize.x, tileCursorY * m_gridCellSize.y}, {1.0f, 1.0f},
0.0f);
tileCursorX++;
if (tileCursorX >= GetGridSize().x)
{
@ -64,6 +70,6 @@ namespace ia::iae
VOID Scene::OnUpdate(IN FLOAT32 deltaTime)
{
//Renderer::SetCameraPosition(m_cameraPosition);
// Renderer::SetCameraPosition(m_cameraPosition);
}
} // namespace ia::iae

View File

@ -0,0 +1,34 @@
// 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 <IAEngine/Base.hpp>
namespace ia::iae
{
class EmbeddedResources
{
public:
STATIC VOID Initialize();
STATIC VOID Terminate();
STATIC CONST Vector<UINT8>& GetResource(IN CONST String& name);
private:
STATIC Map<String, Vector<UINT8>> s_resources;
};
}

View File

@ -16,20 +16,20 @@
#pragma once
#include <IAEngine/Scene.hpp>
#include <IAEngine/Asset/AssetManager.hpp>
namespace ia::iae
{
class GameData
{
public:
STATIC RefPtr<Scene> GetEntryScene();
STATIC Asset_Scene* GetEntryScene();
private:
STATIC BOOL LoadSceneData();
STATIC BOOL LoadResourceData();
STATIC BOOL LoadAssetData();
STATIC RefPtr<Scene> ParseScene(IN CONST String& path);
STATIC Asset_Scene* ParseScene(IN CONST String& path);
STATIC VOID ParseSceneGrid(IN Scene* scene, IN PCVOID gridNode);
private:

View File

@ -0,0 +1,95 @@
// 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 <IAEngine/Asset/Package.hpp>
#include <IAEngine/Asset/Plugin.hpp>
#include <IAEngine/Asset/Scene.hpp>
#include <IAEngine/Asset/Sound.hpp>
#include <IAEngine/Asset/Sprite.hpp>
#include <IAEngine/Asset/SpriteSheet.hpp>
#include <IAEngine/Asset/Texture.hpp>
#include <IAEngine/Asset/TileSheet.hpp>
namespace ia::iae
{
class AssetManager final
{
public:
STATIC VOID SetAssetDirectory(IN CONST String &path);
STATIC String ReadTextAsset(IN CONST String &path);
STATIC Vector<UINT8> ReadBinaryAsset(IN CONST String &path);
public:
STATIC Asset_Texture *LoadTexture(IN CONST String &path);
STATIC Asset_Sprite *LoadSprite(IN CONST String &path);
STATIC Asset_SpriteSheet *LoadSpriteSheet(IN CONST String &path);
STATIC Asset_TileSheet *LoadTileSheet(IN CONST String &path);
STATIC IAsset_Package *LoadPackage(IN CONST String &path);
STATIC Asset_Scene *CreateScene(IN IVec2 extent);
STATIC Asset_Texture *CreateTexture(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height);
STATIC Asset_Sprite *CreateSprite(IN CONST Asset_Texture *texture);
STATIC Asset_SpriteSheet *CreateSpriteSheet(IN CONST Vector<Asset_Texture*>& sprites, IN CONST Map<String, INT32> &animations);
STATIC Asset_SpriteSheet *CreateSpriteSheet(IN CONST Asset_Texture *texture, IN INT32 frameWidth,
IN INT32 frameHeight, IN CONST Map<String, INT32> &animations);
STATIC Asset_TileSheet *CreateTileSheet(IN CONST Asset_Texture *texture, IN INT32 tileWidth,
IN INT32 tileHeight);
STATIC VOID DestroyAsset(IN IAsset *asset);
STATIC VOID AssignAssetName(IN IAsset *asset, IN CONST String &name);
STATIC String GetAssetName(IN CONST String& path);
STATIC IAsset* ChangeAssetType(IN CONST String& assetName, IN EAssetType newType);
template<typename AssetType>
requires std::is_base_of<IAsset, AssetType>::value
STATIC AssetType *GetAssetByName(IN CONST String &name);
public:
STATIC Vector<UINT8> Inflate(IN PCUINT8 data, IN SIZE_T dataSize);
STATIC Vector<UINT8> Deflate(IN PCUINT8 data, IN SIZE_T dataSize);
public:
STATIC CONST String &GetAssetDirectory()
{
return s_assetDirectory;
}
protected:
STATIC String s_assetDirectory;
STATIC Vector<IAsset *> s_assets;
STATIC Map<String, IAsset *> s_assetNames;
protected:
STATIC IAsset *GetAssetByName(IN CONST String &name);
private:
STATIC VOID Initialize();
STATIC VOID Terminate();
friend class IAEngine;
};
template<typename AssetType>
requires std::is_base_of<IAsset, AssetType>::value
AssetType *AssetManager::GetAssetByName(IN CONST String &name)
{
return (AssetType *) GetAssetByName(name);
}
} // namespace ia::iae

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/>.
#pragma once
#include <IAEngine/Base.hpp>
namespace ia::iae
{
enum class EAssetType: INT32
{
INVALID,
TEXTURE,
SPRITE,
TILESHEET,
SPRITESHEET,
SOUND,
SCENE,
PLUGIN,
PACKAGE
};
class IAsset
{
public:
IAsset(IN EAssetType type);
VIRTUAL ~IAsset();
PURE_VIRTUAL(VOID Compile());
PURE_VIRTUAL(VOID Destroy());
public:
String GetPath() CONST
{
return m_path;
}
VOID SetPath(IN CONST String &path)
{
m_path = path;
}
EAssetType GetType() CONST
{
return m_type;
}
protected:
String m_path;
CONST EAssetType m_type;
};
} // namespace ia::iae

View File

@ -0,0 +1,49 @@
// 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 <IACore/StreamReader.hpp>
#include <IAEngine/Asset/IAsset.hpp>
namespace ia::iae
{
class IAsset_Package : public IAsset
{
public:
struct AssetRef
{
String Path;
Handle RefHandle{INVALID_HANDLE};
EAssetType Type{EAssetType::INVALID};
};
public:
IAsset_Package(IN Handle handle) : IAsset(EAssetType::PACKAGE)
{
}
VIRTUAL VOID Compile();
VIRTUAL VOID Destroy();
PURE_VIRTUAL(Vector<AssetRef>::const_iterator ListAssets());
PURE_VIRTUAL(RefPtr<IStreamReader> GetAssetData(IN Handle refHandle));
protected:
friend class AssetManager;
};
} // namespace ia::iae

View File

@ -0,0 +1,40 @@
// 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 <IAEngine/Asset/IAsset.hpp>
namespace ia::iae
{
class Asset_Plugin : public IAsset
{
public:
Asset_Plugin(IN Handle handle) : IAsset(EAssetType::PLUGIN), m_handle(handle)
{
}
VIRTUAL VOID Compile();
VIRTUAL VOID Destroy();
INLINE Handle GetHandle();
protected:
CONST Handle m_handle;
friend class AssetManager;
};
} // namespace ia::iae

View File

@ -0,0 +1,46 @@
// 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 <IAEngine/Asset/IAsset.hpp>
#include <IAEngine/Scene.hpp>
namespace ia::iae
{
class Asset_Scene : public IAsset
{
public:
Asset_Scene(IN Scene* handle) : IAsset(EAssetType::SCENE), m_handle(handle)
{
}
VIRTUAL VOID Compile();
VIRTUAL VOID Destroy();
INLINE Scene* GetHandle();
protected:
Scene* CONST m_handle;
friend class AssetManager;
};
INLINE Scene* Asset_Scene::GetHandle()
{
return m_handle;
}
} // namespace ia::iae

View File

@ -0,0 +1,45 @@
// 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 <IAEngine/Asset/IAsset.hpp>
namespace ia::iae
{
class Asset_Sound : public IAsset
{
public:
Asset_Sound(IN Handle handle) : IAsset(EAssetType::SOUND), m_handle(handle)
{
}
VIRTUAL VOID Compile();
VIRTUAL VOID Destroy();
INLINE Handle GetHandle();
protected:
CONST Handle m_handle;
friend class AssetManager;
};
INLINE Handle Asset_Sound::GetHandle()
{
return m_handle;
}
} // namespace ia::iae

View File

@ -0,0 +1,36 @@
// 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 <IAEngine/Asset/Texture.hpp>
namespace ia::iae
{
class Asset_Sprite : public Asset_Texture
{
public:
Asset_Sprite(IN ImageView* textureHandle) : Asset_Texture(textureHandle, EAssetType::SPRITE)
{
}
VIRTUAL VOID Compile();
VIRTUAL VOID Destroy();
protected:
friend class AssetManager;
};
}

View File

@ -0,0 +1,65 @@
// 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 <IAEngine/Asset/Texture.hpp>
namespace ia::iae
{
class Asset_SpriteSheet : public Asset_Texture
{
public:
struct AnimationDesc
{
INT32 StartRow{};
INT32 FrameCount{};
};
public:
Asset_SpriteSheet(IN ImageView *textureHandle, IN INT32 frameWidth, IN INT32 frameHeight,
IN Map<String, AnimationDesc> &&animations)
: Asset_Texture(textureHandle, EAssetType::SPRITESHEET), m_frameWidth(frameWidth),
m_frameHeight(frameHeight), m_animations(IA_MOVE(animations))
{
}
VIRTUAL VOID Compile();
VIRTUAL VOID Destroy();
INT32 &FrameWidth()
{
return m_frameWidth;
}
INT32 &FrameHeight()
{
return m_frameHeight;
}
Map<String, AnimationDesc> &Animations()
{
return m_animations;
}
protected:
INT32 m_frameWidth;
INT32 m_frameHeight;
Map<String, AnimationDesc> m_animations;
friend class AssetManager;
};
} // namespace ia::iae

Some files were not shown because too many files have changed in this diff Show More