[ClientApplication|ServerApplication] New parameter '-w/--working-dir' to set the working directory of the programs.
This commit is contained in:
parent
085ef782ed
commit
ceafa8cdc0
@ -24,6 +24,8 @@
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
#include "filesystem.hpp"
|
||||
|
||||
#include <gk/core/input/GamePad.hpp>
|
||||
#include <gk/core/Mouse.hpp>
|
||||
#include <gk/gl/GLCheck.hpp>
|
||||
@ -37,7 +39,7 @@
|
||||
|
||||
#include "TitleScreenState.hpp"
|
||||
|
||||
using namespace std::literals::string_literals;
|
||||
namespace fs = ghc::filesystem;
|
||||
|
||||
ClientApplication::ClientApplication(int argc, char **argv) : gk::CoreApplication(argc, argv) {
|
||||
}
|
||||
@ -47,9 +49,13 @@ void ClientApplication::init() {
|
||||
m_argumentParser.addArgument("port", {"-p", "--port", true});
|
||||
m_argumentParser.addArgument("singleplayer", {"-s", "--singleplayer", false});
|
||||
m_argumentParser.addArgument("multiplayer", {"-m", "--multiplayer", false});
|
||||
m_argumentParser.addArgument("working_dir", {"-w", "--working-dir", true});
|
||||
|
||||
gk::CoreApplication::init();
|
||||
|
||||
if (m_argumentParser.getArgument("working_dir").isFound)
|
||||
fs::current_path(m_argumentParser.getArgument("working_dir").parameter);
|
||||
|
||||
if (m_argumentParser.getArgument("host").isFound)
|
||||
m_host = m_argumentParser.getArgument("host").parameter;
|
||||
if (m_argumentParser.getArgument("port").isFound)
|
||||
|
@ -33,12 +33,17 @@ namespace fs = ghc::filesystem;
|
||||
|
||||
ServerApplication::ServerApplication(int argc, char **argv) : m_argumentParser(argc, argv) {
|
||||
std::srand(std::time(nullptr));
|
||||
|
||||
m_argumentParser.addArgument("port", {"-p", "--port", true});
|
||||
m_argumentParser.parse();
|
||||
}
|
||||
|
||||
void ServerApplication::init() {
|
||||
m_argumentParser.addArgument("port", {"-p", "--port", true});
|
||||
m_argumentParser.addArgument("working_dir", {"-w", "--working-dir", true});
|
||||
|
||||
m_argumentParser.parse();
|
||||
|
||||
if (m_argumentParser.getArgument("working_dir").isFound)
|
||||
fs::current_path(m_argumentParser.getArgument("working_dir").parameter);
|
||||
|
||||
if (m_argumentParser.getArgument("port").isFound)
|
||||
m_port = std::stoi(m_argumentParser.getArgument("port").parameter);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user