mirror of
https://github.com/antopilo/Nuake.git
synced 2026-01-04 22:10:34 +03:00
Added runtime --project argument
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -5,15 +5,100 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
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();
|
||||
|
||||
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<Nuake::Project> project = Nuake::Project::New();
|
||||
|
||||
Reference in New Issue
Block a user