[ClientApplication] Added '-u/--username' to change default username. [TitleScreenState] Now using default username with '-m/--multiplayer' and '-s/--singleplayer'.

This commit is contained in:
Quentin Bazin 2020-06-26 05:15:59 +02:00
parent e23603cf6e
commit 00e0d76bbc
5 changed files with 8 additions and 5 deletions

View File

@ -54,6 +54,7 @@ void ClientApplication::init() {
m_argumentParser.addArgument("multiplayer", {"-m", "--multiplayer", "Start in multiplayer mode."});
m_argumentParser.addArgument("working-dir", {"-w", "--working-dir", "Change the working directory to <dir>.", "dir"});
m_argumentParser.addArgument("texture-pack", {"-t", "--texture-pack", "Use texture pack <name>.", "name"});
m_argumentParser.addArgument("username", {"-u", "--username", "Use <username> when using -m or -s", "username"});
m_loggerHandler.setName("client");
@ -79,6 +80,9 @@ void ClientApplication::init() {
Config::loadConfigFromFile("config/client.lua");
if (m_argumentParser.getArgument("username").isFound)
Config::defaultUsername = m_argumentParser.getArgument("username").parameter;
m_keyboardHandler.loadKeysFromFile("config/keys.lua");
gk::GamePad::init(m_keyboardHandler);

View File

@ -99,6 +99,7 @@ void TitleScreenState::startSingleplayer(bool showLoadingState, const std::strin
auto &serverLoadingState = m_stateStack->push<ServerLoadingState>(game, showLoadingState, "localhost", sf::Socket::AnyPort, this);
serverLoadingState.setTexturePack(m_texturePack);
serverLoadingState.setUsername(Config::defaultUsername);
if (m_thread.joinable())
m_thread.join();
@ -119,6 +120,7 @@ void TitleScreenState::startMultiplayer(const std::string &host) {
auto &game = m_stateStack->push<GameState>();
auto &serverLoadingState = m_stateStack->push<ServerLoadingState>(game, false, host, m_port, this);
serverLoadingState.setTexturePack(m_texturePack);
serverLoadingState.setUsername(Config::defaultUsername);
}
void TitleScreenState::onGuiScaleChanged(const GuiScaleChangedEvent &event) {

View File

@ -39,10 +39,6 @@ ClientPlayer *ClientPlayer::s_instance = nullptr;
ClientPlayer::ClientPlayer(gk::Camera &camera) : m_camera(camera) {
m_cameraLocalPos = gk::Vector3f{0.f, 0.f, 1.625f};
m_viewAngleH = -90.f;
m_viewAngleV = 0.f;
m_viewAngleRoll = 0.f;
updateCamera();
m_camera.setDPosition(m_x + m_cameraLocalPos.x, m_y + m_cameraLocalPos.y, m_z + m_cameraLocalPos.z);

View File

@ -79,7 +79,7 @@ class Player : public gk::ISerializable {
u16 m_dimension = 0;
float m_viewAngleH = 0;
float m_viewAngleH = -90;
float m_viewAngleV = 0;
float m_viewAngleRoll = 0;

View File

@ -62,6 +62,7 @@ void PlayerList::disconnectPlayer(const std::string &name) {
if (it != m_players.end()) {
it->second.setClient(nullptr);
it->second.setNewPlayer(false);
gkInfo() << name << "is offline";
}
}