From 8d323246c0684809628f52adcdab7866abd75b4a Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Thu, 21 Sep 2023 11:28:59 -0400 Subject: [PATCH] Argument code clean up --- Editor/Editor.cpp | 36 +++++++++++++++++++++++------------- premake5.lua | 1 - 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 4993cfd1..8fb27fb2 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -61,31 +61,41 @@ LaunchSettings ParseLaunchSettings(const std::vector& arguments) size_t i = 0; for (const auto& arg : arguments) { + const size_t nextArgumentIndex = i + 1; + const bool containsAnotherArgument = nextArgumentIndex <= argumentSize; if (arg == "--project") { - if (i + 1 <= argumentSize) + if (!containsAnotherArgument) { - std::string projectPath = arguments[i + 1]; - launchSettings.projectPath = projectPath; + continue; } + + // Load project on start + std::string projectPath = arguments[i + 1]; + launchSettings.projectPath = projectPath; + } else if (arg == "--resolution") { - if (i + 1 <= argumentSize) + if (!containsAnotherArgument) { - 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); - } + 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") { - if (i + 1 <= argumentSize) + // Set editor window monitor + if (containsAnotherArgument) { launchSettings.monitor = stoi(arguments[i + 1]); } diff --git a/premake5.lua b/premake5.lua index ad7e8a8f..61a6a499 100644 --- a/premake5.lua +++ b/premake5.lua @@ -268,7 +268,6 @@ project "Editor" } entrypoint "WinMainCRTStartup" flags { "WinMain" } - buildoptions { "-mwindows"} -- copy a file from the objects directory to the target directory postbuildcommands {