Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/OvEditor/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ project "OvEditor"
"OvAudio",
"OvCore",
"OvDebug",
"OvGame", -- Necessary to be built before the editor to allow building
"OvMaths",
"OvPhysics",
"OvRendering",
Expand Down
18 changes: 14 additions & 4 deletions Sources/OvEditor/src/OvEditor/Core/EditorActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>("executable_name") + ".exe";
const std::string extension =
#if defined(_WIN32)
".exe";
#else
"";
#endif

const std::string executableName = m_context.projectSettings.Get<std::string>("executable_name") + extension;

bool failed = false;

Expand Down Expand Up @@ -251,7 +258,8 @@ void OvEditor::Core::EditorActions::BuildAtLocation(const std::string & p_config
err
);

const auto sceneFileName = m_context.projectSettings.Get<std::string>("start_scene");
auto sceneFileName = m_context.projectSettings.Get<std::string>("start_scene");
sceneFileName = OvTools::Utils::PathParser::MakeNonWindowsStyle(sceneFileName);

if (!std::filesystem::exists(p_buildPath / "Data" / "User" / "Assets" / sceneFileName))
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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
{
Expand Down
5 changes: 4 additions & 1 deletion Sources/OvGame/src/OvGame/Core/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <OvDebug/Logger.h>
#include <OvGame/Core/Game.h>
#include <OvTools/Utils/PathParser.h>
#include <OvUI/Widgets/Texts/Text.h>

#ifdef _DEBUG
Expand Down Expand Up @@ -35,7 +36,9 @@ OvGame::Core::Game::Game(Context & p_context) :
>();
#endif

m_context.sceneManager.LoadScene(m_context.projectSettings.Get<std::string>("start_scene"));
std::string startupScenePath = m_context.projectSettings.Get<std::string>("start_scene");
startupScenePath = OvTools::Utils::PathParser::MakeNonWindowsStyle(startupScenePath);
m_context.sceneManager.LoadScene(startupScenePath);
m_context.sceneManager.GetCurrentScene()->Play();
}

Expand Down
7 changes: 7 additions & 0 deletions Sources/OvTools/include/OvTools/Utils/SystemCalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions Sources/OvTools/src/OvTools/Utils/SystemCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down