summaryrefslogtreecommitdiffstats
path: root/src/Render.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-03 17:03:59 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-03 17:03:59 +0200
commitf7decf41d8d0062901cd39c42a3669a80537c7df (patch)
treed3032265df11eee6e3eaf8b4b081524bef5e72b2 /src/Render.cpp
parent2017-07-29 (diff)
downloadAltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar
AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.gz
AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.bz2
AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.lz
AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.xz
AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.zst
AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.zip
Diffstat (limited to '')
-rw-r--r--src/Render.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/Render.cpp b/src/Render.cpp
index ebfbc20..d45d5b6 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -64,7 +64,6 @@ void Render::RenderFrame() {
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
window->display();
}
@@ -89,6 +88,8 @@ void Render::HandleEvents() {
case sf::Keyboard::T:
SetMouseCapture(!isMouseCaptured);
break;
+ case sf::Keyboard::U:
+ EventAgregator::PushEvent(EventType::ConnectToServer, ConnectToServerData{"127.0.0.1", 25565});
default:
break;
}
@@ -122,6 +123,21 @@ void Render::SetMouseCapture(bool IsCaptured) {
}
void Render::ExecuteRenderLoop() {
+ EventListener listener;
+ listener.RegisterHandler(EventType::ConnectionSuccessfull, [this](EventData eventData) {
+ auto data = std::get<ConnectionSuccessfullData>(eventData);
+ window->setTitle("Connected");
+ });
+
+ listener.RegisterHandler(EventType::PlayerConnected, [this](EventData eventData) {
+ auto data = std::get<PlayerConnectedData>(eventData);
+ window->setTitle("Joined the game");
+ });
+
+ listener.RegisterHandler(EventType::RemoveLoadingScreen, [this](EventData eventData) {
+ window->setTitle("Loaded");
+ });
+
using namespace std::chrono_literals;
LoopExecutionTimeController timer(16ms);
while (isRunning) {
@@ -130,8 +146,10 @@ void Render::ExecuteRenderLoop() {
glCheckError();
RenderFrame();
+ while (listener.IsEventsQueueIsNotEmpty())
+ listener.HandleEvent();
timer.Update();
}
EventData data = GlobalAppStateData{GlobalState::Exiting};
- EventAgregator::PushEvent(EventType::GlobalAppState,data);
+ EventAgregator::PushEvent(EventType::GlobalAppState, data);
}