Reworked file structure

This commit is contained in:
antopilo
2025-01-30 22:41:17 -05:00
parent e8a84c98ec
commit 92a64f19ea
2215 changed files with 1832 additions and 2069 deletions

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 <dependencies/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

162
NuakeRuntime/premake5.lua Normal file
View File

@@ -0,0 +1,162 @@
project "NuakeRuntime"
kind "ConsoleApp"
language "C++"
debugdir ("Editor")
targetdir (binaryOutputDir)
objdir (intBinaryOutputDir)
files
{
"**.cpp",
"**.h"
}
includedirs
{
"../Nuake/Source/",
"../Nuake/Vendors",
"../Nuake/Vendors/nanosvg",
"../Nuake/dependencies/glad/include",
"../Nuake/dependencies/glfw/include",
"../Nuake/dependencies/assimp/include",
"../Nuake/dependencies/build",
"../Nuake/dependencies/JoltPhysics",
"../Nuake/dependencies/build",
"../Nuake/dependencies/soloud/include",
"/usr/include/gtk-3.0/",
"../Nuake/dependencies/recastnavigation/DebugUtils/Include",
"../Nuake/dependencies/recastnavigation/Detour/Include",
"../Nuake/dependencies/recastnavigation/DetourCrowd/Include",
"../Nuake/dependencies/recastnavigation/DetourTileCache/Include",
"../Nuake/dependencies/recastnavigation/Recast/Include",
"../Nuake/dependencies/yoga",
"../Nuake/dependencies/msdf-atlas-gen",
"../Nuake/dependencies/msdf-atlas-gen/msdfgen",
"../Nuake/dependencies/msdf-atlas-gen/msdfgen/include",
"../Nuake/dependencies/freetype/include",
"../Nuake/dependencies/tracy/public/tracy",
"../Nuake/dependencies/entt/src",
"../Nuake/Vendors/vulkan",
"../Nuake/Vendors/volk",
"../Nuake/dependencies/vma/include"
}
libdirs
{
"../Nuake/dependencies/GLEW/lib/Release/x64",
"../Nuake/dependencies/assimp/lib/",
"../bin/%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}/Nuake/",
"../Nuake/dependencies/JoltPhysics/bin/%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}/JoltPhysics/",
"../Nuake/dependencies/soloud/bin/%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}",
"../Nuake/dependencies/Coral/NetCore/",
"../Nuake/dependencies/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)
}
filter "system:windows"
cppdialect "C++20"
staticruntime "On"
defines {
"NK_WIN"
}
links
{
"opengl32.lib"
}
externalincludedirs { "../Nuake/dependencies/Coral/Coral.Native/Include/" }
--[[
postbuildcommands {
'{COPYFILE} "%{wks.location}/Nuake/dependencies/Coral/Coral.Managed/Coral.Managed.runtimeconfig.json" "%{wks.location}/%{prj.name}"'
}
]]--
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"
}