summaryrefslogtreecommitdiffstats
path: root/src/Render.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-10-20 10:04:29 +0200
committerGitHub <noreply@github.com>2018-10-20 10:04:29 +0200
commitb079abb0463e81978e189d2c0c6d2879f6bf9283 (patch)
tree31a921e8413ff4e944cacf4ab096c9a6d81e390e /src/Render.cpp
parentUpdate README.md (diff)
parent #11 Single field for ip and port (diff)
downloadAltCraft-b079abb0463e81978e189d2c0c6d2879f6bf9283.tar
AltCraft-b079abb0463e81978e189d2c0c6d2879f6bf9283.tar.gz
AltCraft-b079abb0463e81978e189d2c0c6d2879f6bf9283.tar.bz2
AltCraft-b079abb0463e81978e189d2c0c6d2879f6bf9283.tar.lz
AltCraft-b079abb0463e81978e189d2c0c6d2879f6bf9283.tar.xz
AltCraft-b079abb0463e81978e189d2c0c6d2879f6bf9283.tar.zst
AltCraft-b079abb0463e81978e189d2c0c6d2879f6bf9283.zip
Diffstat (limited to '')
-rw-r--r--src/Render.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/Render.cpp b/src/Render.cpp
index 58cf53d..21e815c 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -33,7 +33,6 @@ Render::Render(unsigned int windowWidth, unsigned int windowHeight,
//Read settings
strcpy(fieldUsername, Settings::Read("username", "HelloOne").c_str());
strcpy(fieldServerAddr, Settings::Read("serverAddr", "127.0.0.1").c_str());
- fieldServerPort = Settings::ReadInt("serverPort", 25565);
fieldDistance = Settings::ReadDouble("renderDistance", 2.0);
fieldTargetFps = Settings::ReadDouble("targetFps", 60.0);
fieldSensetivity = Settings::ReadDouble("mouseSensetivity", 0.1);
@@ -60,7 +59,6 @@ Render::Render(unsigned int windowWidth, unsigned int windowHeight,
Render::~Render() {
Settings::Write("username", fieldUsername);
Settings::Write("serverAddr", fieldServerAddr);
- Settings::WriteInt("serverPort", fieldServerPort);
Settings::WriteDouble("renderDistance", fieldDistance);
Settings::WriteDouble("targetFps", fieldTargetFps);
Settings::WriteDouble("mouseSensetivity", fieldSensetivity);
@@ -432,12 +430,22 @@ void Render::RenderGui() {
ImGui::SetNextWindowPosCenter();
ImGui::Begin("Menu", 0, windowFlags);
if (ImGui::Button("Connect")) {
- PUSH_EVENT("ConnectToServer", std::make_tuple(std::string(fieldServerAddr),
- (unsigned short) fieldServerPort, std::string(fieldUsername)));
+ std::string addr(fieldServerAddr);
+ size_t index = addr.find_last_of(':');
+ unsigned short port;
+ if (index == std::string::npos)
+ port = 25565;
+ else {
+ try {
+ port = std::stoi(addr.substr(index + 1));
+ } catch (std::exception &e) {
+ port = 25565;
+ }
+ }
+ PUSH_EVENT("ConnectToServer", std::make_tuple(addr.substr(0, index), port, std::string(fieldUsername)));
}
ImGui::InputText("Username", fieldUsername, 512);
ImGui::InputText("Address", fieldServerAddr, 512);
- ImGui::InputInt("Port", &fieldServerPort);
ImGui::Separator();
if (ImGui::Button("Exit"))
PUSH_EVENT("Exit",0);