Refactored folder structure

This commit is contained in:
antopilo
2025-01-31 18:04:43 -05:00
parent a4e7e7d530
commit 1f3a5e02af
313 changed files with 2350 additions and 674 deletions

193
Runtime/Source/Runtime.cpp Normal file
View File

@@ -0,0 +1,193 @@
#include <Engine.h>
#include "Nuake/FileSystem/FileSystem.h"
#include "Nuake/FileSystem/File.h"
#include "Nuake/FileSystem/Directory.h"
#include "Nuake/Core/String.h"
#include "Nuake/Resource/Project.h"
//#include <Thirdparty/GLEW/include/GL/glew.h>
#include <imgui/imgui.h>
#include <Tracy.hpp>
#include <string>
#include <Nuake/Rendering/Renderer2D.h>
struct LaunchSettings
{
int32_t monitor = -1;
Nuake::Vector2 resolution = { 1920, 1080 };
std::string windowTitle = "Nuake Editor ";
std::string projectPath;
};
std::vector<std::string> ParseArguments(int argc, char* argv[])
{
std::vector<std::string> args;
for (uint32_t i = 0; i < argc; i++)
{
args.push_back(std::string(argv[i]));
}
return args;
}
LaunchSettings ParseLaunchSettings(const std::vector<std::string>& arguments)
{
using namespace Nuake;
LaunchSettings launchSettings;
const auto argumentSize = arguments.size();
size_t i = 0;
for (const auto& arg : arguments)
{
const size_t nextArgumentIndex = i + 1;
const bool containsAnotherArgument = nextArgumentIndex <= argumentSize;
if (arg == "--project")
{
if (!containsAnotherArgument)
{
continue;
}
// Load project on start
std::string projectPath = arguments[i + 1];
launchSettings.projectPath = projectPath;
}
else if (arg == "--resolution")
{
if (!containsAnotherArgument)
{
continue;
}
// Set editor window resolution
std::string resString = arguments[i + 1];
const auto& resSplits = String::Split(resString, 'x');
if (resSplits.size() == 2)
{
int width = stoi(resSplits[0]);
int height = stoi(resSplits[1]);
launchSettings.resolution = Vector2(width, height);
}
}
else if (arg == "--monitor")
{
// Set editor window monitor
if (containsAnotherArgument)
{
launchSettings.monitor = stoi(arguments[i + 1]);
}
}
i++;
}
return launchSettings;
}
int ApplicationMain(int argc, char* argv[])
{
using namespace Nuake;
const auto& arguments = ParseArguments(argc, argv);
LaunchSettings launchSettings = ParseLaunchSettings(arguments);
Engine::Init();
auto window = Nuake::Engine::GetCurrentWindow();
std::string projectPath;
if (launchSettings.projectPath.empty())
{
projectPath = "./game.project";
}
else
{
projectPath = launchSettings.projectPath;
}
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));
Ref<Nuake::Project> project = Nuake::Project::New();
project->FullPath = projectPath;
if (!FileSystem::FileExists(projectPath))
{
Logger::Log("game.project not found", "runtime", CRITICAL);
return -1;
}
const std::string& projectfileContent = FileSystem::ReadFile(projectPath, true);
if (projectfileContent.empty())
{
Logger::Log("game.project was empty", "runtime", CRITICAL);
return -1;
}
project->Deserialize(json::parse(projectfileContent));
window->ShowTitleBar(true);
window->SetDecorated(true);
window->SetTitle(project->Name);
Nuake::Engine::LoadProject(project);
Nuake::Engine::EnterPlayMode();
window->SetVSync(false);
while (!window->ShouldClose())
{
Nuake::Engine::Tick();
Engine::Draw();
const auto& WindowSize = window->GetSize();
//glViewport(0, 0, WindowSize.x, WindowSize.y);
Nuake::Renderer2D::BeginDraw(WindowSize);
ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->Pos);
ImGui::SetNextWindowSize(viewport->Size);
ImGui::SetNextWindowViewport(viewport->ID);
const auto& windowSize = Vector2(viewport->Size.x, viewport->Size.y);
Ref<FrameBuffer> framebuffer = Engine::GetCurrentWindow()->GetFrameBuffer();
if (framebuffer->GetSize() != windowSize)
{
framebuffer->QueueResize(windowSize);
}
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 0, 0 });
ImGui::Begin("Game", 0, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize);
{
//ImGui::Image((void*)Window::Get()->GetFrameBuffer()->GetTexture()->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0));
}
ImGui::End();
ImGui::PopStyleVar(2);
Engine::EndDraw();
FrameMark;
}
}
#ifdef NK_DIST
#ifdef NK_WIN
#include "windows.h"
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cdmline, int cmdshow)
{
return ApplicationMain(__argc, __argv);
}
#endif
#else
int main(int argc, char* argv[])
{
return ApplicationMain(argc, argv);
}
#endif

159
Runtime/premake5.lua Normal file
View File

@@ -0,0 +1,159 @@
project "Runtime"
kind "ConsoleApp"
language "C++"
debugdir (binaryOutputDir)
targetdir (binaryOutputDir)
objdir (intBinaryOutputDir)
files
{
"**.cpp",
"**.h"
}
includedirs
{
"../Nuake/Source/",
"../Nuake/Vendors",
"../Nuake/Vendors/nanosvg",
"../Nuake/Thirdparty/glad/include",
"../Nuake/Thirdparty/glfw/include",
"../Nuake/Thirdparty/assimp/include",
"../Nuake/Thirdparty/build",
"../Nuake/Thirdparty/JoltPhysics",
"../Nuake/Thirdparty/build",
"../Nuake/Thirdparty/soloud/include",
"/usr/include/gtk-3.0/",
"../Nuake/Thirdparty/recastnavigation/DebugUtils/Include",
"../Nuake/Thirdparty/recastnavigation/Detour/Include",
"../Nuake/Thirdparty/recastnavigation/DetourCrowd/Include",
"../Nuake/Thirdparty/recastnavigation/DetourTileCache/Include",
"../Nuake/Thirdparty/recastnavigation/Recast/Include",
"../Nuake/Thirdparty/yoga",
"../Nuake/Thirdparty/msdf-atlas-gen",
"../Nuake/Thirdparty/msdf-atlas-gen/msdfgen",
"../Nuake/Thirdparty/msdf-atlas-gen/msdfgen/include",
"../Nuake/Thirdparty/freetype/include",
"../Nuake/Thirdparty/tracy/public/tracy",
"../Nuake/Thirdparty/entt/src",
"../Nuake/Vendors/vulkan",
"../Nuake/Vendors/volk",
"../Nuake/Thirdparty/vma/include"
}
libdirs
{
"../Nuake/Thirdparty/GLEW/lib/Release/x64",
"../Nuake/Thirdparty/assimp/lib/",
"../bin/%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}/Nuake/",
"../Nuake/Thirdparty/JoltPhysics/bin/%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}/JoltPhysics/",
"../Nuake/Thirdparty/soloud/bin/%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}",
"../Nuake/Thirdparty/Coral/NetCore/",
"../Nuake/Thirdparty/freetype/bin/%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}/Freetype"
}
links
{
"Nuake",
"glad",
"GLFW",
"assimp",
"JoltPhysics",
"soloud",
"Coral.Native",
"DebugUtils",
"Detour",
"DetourCrowd",
"DetourTileCache",
"Recast",
"tracy",
"yoga",
"msdf-gen",
"msdf-atlas-gen",
"Freetype",
"vma"
}
defines {
table.unpack(globalDefines)
}
prebuildcommands {
'{ECHO} "Copying dxcompiler.dll to Working directory..."',
'{COPYFILE} "%{wks.location}Nuake/Thirdparty/dxc/bin/x64/dxcompiler.dll" "%{cfg.debugdir}/"',
'{ECHO} Copying Coral to Working directory...',
'{COPYFILE} "%{wks.location}Nuake/Thirdparty/Coral/Coral.Managed/bin/%{cfg.buildcfg}/Coral.Managed.dll" "%{cfg.debugdir}/"',
'{COPYFILE} "%{wks.location}Nuake/Thirdparty/Coral/Coral.Managed/bin/%{cfg.buildcfg}/Coral.Managed.runtimeconfig.json" "%{cfg.debugdir}/"',
'xcopy /E /I /Y "%{wks.location}Data" "%{cfg.debugdir}\\Resources"'
}
filter "system:windows"
cppdialect "C++20"
staticruntime "On"
defines {
"NK_WIN"
}
externalincludedirs { "../Nuake/Thirdparty/Coral/Coral.Native/Include/" }
filter { "system:windows", "action:vs*" }
flags
{
"MultiProcessorCompile",
}
filter "system:linux"
links
{
"GL",
"glfw",
"glad",
"X11",
"asound",
"glib-2.0",
"gtk-3",
"gobject-2.0"
}
includedirs
{
"/usr/include/gtk-3.0/",
"/usr/lib/glib-2.0/include",
"/usr/include/glib-2.0",
}
buildoptions { "`pkg-config --cflags glib-2.0 pango gdk-pixbuf-2.0 gtk-3 atk tk-3.0 glib-2.0`" }
linkoptions { "`pkg-config --libs glib-2.0 pango gdk-pixbuf-2.0 gtk-3 glib-2.0 lgobject-2.0`" }
filter "configurations:Debug"
runtime "Debug"
symbols "on"
defines
{
"NK_DEBUG"
}
buildoptions { "/Zi" }
filter "configurations:Release"
kind "WindowedApp"
runtime "Release"
optimize "on"
defines
{
"NK_DIST",
"WIN32_LEAN_AND_MEAN"
}
filter "configurations:Dist"
kind "WindowedApp"
runtime "Release"
optimize "on"
entrypoint "WinMainCRTStartup"
flags { }
defines
{
"NK_DIST",
"WIN32_LEAN_AND_MEAN"
}