From 6bc1984bf61c53ca6232498348053d28c1138a6b Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Thu, 28 Sep 2023 00:49:35 -0400 Subject: [PATCH 1/2] Added runtime --project argument --- Editor/Editor.cpp | 10 ++-- Nuake/src/Audio/AudioManager.cpp | 4 +- Runtime/Runtime.cpp | 87 +++++++++++++++++++++++++++++++- 3 files changed, 93 insertions(+), 8 deletions(-) diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index ddee641d..f3451af2 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -195,20 +195,22 @@ int ApplicationMain(int argc, char* argv[]) return 0; } + + +#ifdef NK_WIN #ifdef NK_DIST - #include "windows.h" - int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cdmline, int cmdshow) { return ApplicationMain(__argc, __argv); } +#endif +#endif -#else int main(int argc, char* argv[]) { return ApplicationMain(argc, argv); } -#endif + diff --git a/Nuake/src/Audio/AudioManager.cpp b/Nuake/src/Audio/AudioManager.cpp index cca3030b..02a0d9cf 100644 --- a/Nuake/src/Audio/AudioManager.cpp +++ b/Nuake/src/Audio/AudioManager.cpp @@ -30,9 +30,7 @@ namespace Nuake { // TODO: Sample rate, back end, buffer size, flags. #ifdef NK_WIN m_Soloud->init(); -#endif - -#ifdef NK_LINUX +#else m_Soloud->init(SoLoud::Soloud::CLIP_ROUNDOFF, SoLoud::Soloud::ALSA) #endif m_AudioThread = std::thread(&AudioManager::AudioThreadLoop, this); diff --git a/Runtime/Runtime.cpp b/Runtime/Runtime.cpp index 098b98da..8f4e1961 100644 --- a/Runtime/Runtime.cpp +++ b/Runtime/Runtime.cpp @@ -5,15 +5,100 @@ #include +struct LaunchSettings +{ + int32_t monitor = -1; + Nuake::Vector2 resolution = { 1920, 1080 }; + std::string windowTitle = "Nuake Editor "; + std::string projectPath; +}; + +std::vector ParseArguments(int argc, char* argv[]) +{ + std::vector args; + for (uint32_t i = 0; i < argc; i++) + { + args.push_back(std::string(argv[i])); + } + return args; +} + +LaunchSettings ParseLaunchSettings(const std::vector& 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(); - const std::string projectPath = "./game.project"; + std::string projectPath; + if (launchSettings.projectPath.empty()) + { + projectPath = "./game.project"; + } + else + { + projectPath = launchSettings.projectPath; + } + FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath)); Ref project = Nuake::Project::New(); From 739fd97e35beff706b5f712720064befbf4d60e0 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Thu, 28 Sep 2023 00:53:40 -0400 Subject: [PATCH 2/2] Fixed wad converter --- Nuake/src/Scene/Systems/WadConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nuake/src/Scene/Systems/WadConverter.cpp b/Nuake/src/Scene/Systems/WadConverter.cpp index d17635ef..d98d33ae 100644 --- a/Nuake/src/Scene/Systems/WadConverter.cpp +++ b/Nuake/src/Scene/Systems/WadConverter.cpp @@ -351,7 +351,7 @@ namespace Nuake ConvertedTextures = std::vector(); - auto pathSplits = String::Split(std::string(wadPath.begin(), wadPath.end() - 4), '\\'); + auto pathSplits = String::Split(std::string(wadPath.begin(), wadPath.end() - 4), '/'); WadName = pathSplits[std::size(pathSplits) - 1]; TargetDirectory = "/textures/" + WadName + "/";