diff --git a/Sources/OvEditor/premake5.lua b/Sources/OvEditor/premake5.lua index f6e7e854..b48389df 100644 --- a/Sources/OvEditor/premake5.lua +++ b/Sources/OvEditor/premake5.lua @@ -50,6 +50,7 @@ project "OvEditor" "OvAudio", "OvCore", "OvDebug", + "OvGame", -- Necessary to be built before the editor to allow building "OvMaths", "OvPhysics", "OvRendering", diff --git a/Sources/OvEditor/src/OvEditor/Core/EditorActions.cpp b/Sources/OvEditor/src/OvEditor/Core/EditorActions.cpp index c44f2e23..2b72bf62 100644 --- a/Sources/OvEditor/src/OvEditor/Core/EditorActions.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/EditorActions.cpp @@ -216,7 +216,14 @@ void OvEditor::Core::EditorActions::Build(bool p_autoRun, bool p_tempFolder) void OvEditor::Core::EditorActions::BuildAtLocation(const std::string & p_configuration, const std::filesystem::path& p_buildPath, bool p_autoRun) { - std::string executableName = m_context.projectSettings.Get("executable_name") + ".exe"; + const std::string extension = +#if defined(_WIN32) + ".exe"; +#else + ""; +#endif + + const std::string executableName = m_context.projectSettings.Get("executable_name") + extension; bool failed = false; @@ -251,7 +258,8 @@ void OvEditor::Core::EditorActions::BuildAtLocation(const std::string & p_config err ); - const auto sceneFileName = m_context.projectSettings.Get("start_scene"); + auto sceneFileName = m_context.projectSettings.Get("start_scene"); + sceneFileName = OvTools::Utils::PathParser::MakeNonWindowsStyle(sceneFileName); if (!std::filesystem::exists(p_buildPath / "Data" / "User" / "Assets" / sceneFileName)) { @@ -330,8 +338,10 @@ void OvEditor::Core::EditorActions::BuildAtLocation(const std::string & p_config if (!err) { OVLOG_INFO("Builder data (Dlls and executable) copied"); + + const std::string initialExecutableName = "OvGame" + extension; - std::filesystem::rename(p_buildPath / "OvGame.exe", p_buildPath / executableName, err); + std::filesystem::rename(p_buildPath / initialExecutableName, p_buildPath / executableName, err); if (!err) { @@ -344,7 +354,7 @@ void OvEditor::Core::EditorActions::BuildAtLocation(const std::string & p_config if (std::filesystem::exists(exePath)) { - OvTools::Utils::SystemCalls::OpenFile(exePath.string(), p_buildPath.string()); + OvTools::Utils::SystemCalls::RunProgram(exePath.string(), p_buildPath.string()); } else { diff --git a/Sources/OvGame/src/OvGame/Core/Game.cpp b/Sources/OvGame/src/OvGame/Core/Game.cpp index f2e32942..de75666d 100644 --- a/Sources/OvGame/src/OvGame/Core/Game.cpp +++ b/Sources/OvGame/src/OvGame/Core/Game.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #ifdef _DEBUG @@ -35,7 +36,9 @@ OvGame::Core::Game::Game(Context & p_context) : >(); #endif - m_context.sceneManager.LoadScene(m_context.projectSettings.Get("start_scene")); + std::string startupScenePath = m_context.projectSettings.Get("start_scene"); + startupScenePath = OvTools::Utils::PathParser::MakeNonWindowsStyle(startupScenePath); + m_context.sceneManager.LoadScene(startupScenePath); m_context.sceneManager.GetCurrentScene()->Play(); } diff --git a/Sources/OvTools/include/OvTools/Utils/SystemCalls.h b/Sources/OvTools/include/OvTools/Utils/SystemCalls.h index e97ea169..1d4a04a5 100644 --- a/Sources/OvTools/include/OvTools/Utils/SystemCalls.h +++ b/Sources/OvTools/include/OvTools/Utils/SystemCalls.h @@ -32,6 +32,13 @@ namespace OvTools::Utils */ static void OpenFile(const std::string& p_file, const std::string & p_workingDir = ""); + /** + * Run a program + * @param p_file + * @param p_workingDir + */ + static void RunProgram(const std::string& p_file, const std::string& p_workingDir = ""); + /** * Open the given file for edition with the default application * @param p_file diff --git a/Sources/OvTools/src/OvTools/Utils/SystemCalls.cpp b/Sources/OvTools/src/OvTools/Utils/SystemCalls.cpp index 99203f88..d3e8a0bb 100644 --- a/Sources/OvTools/src/OvTools/Utils/SystemCalls.cpp +++ b/Sources/OvTools/src/OvTools/Utils/SystemCalls.cpp @@ -46,6 +46,20 @@ void OvTools::Utils::SystemCalls::OpenFile(const std::string & p_file, const std #endif } +void OvTools::Utils::SystemCalls::RunProgram(const std::string& p_file, const std::string& p_workingDir) +{ +#ifdef _WIN32 + OpenFile(p_file, p_workingDir); +#else + std::string command = "\"" + p_file + "\" &"; + if (!p_workingDir.empty()) + { + command = "cd \"" + p_workingDir + "\" && " + command; + } + std::system(command.c_str()); +#endif +} + void OvTools::Utils::SystemCalls::EditFile(const std::string & p_file) { #ifdef _WIN32