summaryrefslogtreecommitdiffstats
path: root/src/Render.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-08-06 17:04:50 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-08-06 17:04:50 +0200
commite9904604ce0199d696c4941dff4f5ad84d22355f (patch)
tree1380d5b4f882a61aa1b5e9ee08d4aa4d72c00f48 /src/Render.cpp
parentSeparate lighting for each block face (diff)
downloadAltCraft-e9904604ce0199d696c4941dff4f5ad84d22355f.tar
AltCraft-e9904604ce0199d696c4941dff4f5ad84d22355f.tar.gz
AltCraft-e9904604ce0199d696c4941dff4f5ad84d22355f.tar.bz2
AltCraft-e9904604ce0199d696c4941dff4f5ad84d22355f.tar.lz
AltCraft-e9904604ce0199d696c4941dff4f5ad84d22355f.tar.xz
AltCraft-e9904604ce0199d696c4941dff4f5ad84d22355f.tar.zst
AltCraft-e9904604ce0199d696c4941dff4f5ad84d22355f.zip
Diffstat (limited to '')
-rw-r--r--src/Render.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/Render.cpp b/src/Render.cpp
index c44d2b4..d5a4b6a 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -12,12 +12,15 @@
#include "World.hpp"
#include "GameState.hpp"
#include "RendererWorld.hpp"
+#include "Settings.hpp"
Render::Render(unsigned int windowWidth, unsigned int windowHeight,
std::string windowTitle)
: timer(std::chrono::milliseconds(16)) {
InitEvents();
+ Settings::Load();
+
InitSdl(windowWidth, windowHeight, windowTitle);
glCheckError();
InitGlew();
@@ -27,10 +30,19 @@ Render::Render(unsigned int windowWidth, unsigned int windowHeight,
PrepareToRendering();
glCheckError();
+ strcpy(fieldUsername, Settings::Read("username", "HelloOne").c_str());
+ strcpy(fieldServerAddr, Settings::Read("serverAddr", "127.0.0.1").c_str());
+ fieldServerPort = std::stoi(Settings::Read("serverPort", "25565"));
+
LOG(INFO) << "Supported threads: " << std::thread::hardware_concurrency();
}
Render::~Render() {
+ Settings::Write("username", fieldUsername);
+ Settings::Write("serverAddr", fieldServerAddr);
+ Settings::Write("serverPort", std::to_string(fieldServerPort));
+ Settings::Save();
+
ImGui_ImplSdlGL3_Shutdown();
SDL_GL_DeleteContext(glContext);
SDL_DestroyWindow(window);
@@ -383,16 +395,13 @@ void Render::RenderGui() {
case State::MainMenu: {
ImGui::SetNextWindowPosCenter();
ImGui::Begin("Menu", 0, windowFlags);
- static char buff[512] = "127.0.0.1";
- static int port = 25565;
- static char buffName[512] = "HelloOne";
if (ImGui::Button("Connect")) {
- PUSH_EVENT("ConnectToServer", std::make_tuple(std::string(buff),
- (unsigned short) port, std::string(buffName)));
+ PUSH_EVENT("ConnectToServer", std::make_tuple(std::string(fieldServerAddr),
+ (unsigned short) fieldServerPort, std::string(fieldUsername)));
}
- ImGui::InputText("Username", buffName, 512);
- ImGui::InputText("Address", buff, 512);
- ImGui::InputInt("Port", &port);
+ ImGui::InputText("Username", fieldUsername, 512);
+ ImGui::InputText("Address", fieldServerAddr, 512);
+ ImGui::InputInt("Port", &fieldServerPort);
ImGui::Separator();
if (ImGui::Button("Exit"))
PUSH_EVENT("Exit",0);