diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-08-03 17:03:59 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-08-03 17:03:59 +0200 |
commit | f7decf41d8d0062901cd39c42a3669a80537c7df (patch) | |
tree | d3032265df11eee6e3eaf8b4b081524bef5e72b2 /src/Core.cpp | |
parent | 2017-07-29 (diff) | |
download | AltCraft-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/Core.cpp | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/src/Core.cpp b/src/Core.cpp deleted file mode 100644 index 3a89c07..0000000 --- a/src/Core.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "Core.hpp" -#include "NetworkClient.hpp" - -Core::Core() { - coreLoop = std::thread(&Core::ExecuteCoreLoop, this); - render = new Render(900, 480, "AltCraft"); -} - -Core::~Core() { - delete render; - coreLoop.join(); -} - -void Core::ExecuteRenderLoop() { - render->ExecuteRenderLoop(); -} - -void Core::ExecuteCoreLoop() { - - EventListener events; - events.RegisterHandler(EventType::ConnectionSuccessfull, [](EventData eventData) { - GlobalAppStateData data = {GlobalState::Loading}; - EventAgregator::PushEvent(EventType::GlobalAppState, EventData{data}); - }); - events.RegisterHandler(EventType::GlobalAppState, [this](EventData eventData) { - auto data = std::get<GlobalAppStateData>(eventData); - globalState = data.state; - }); - - while (globalState != GlobalState::Exiting) { - if (events.IsEventsQueueIsNotEmpty()) { - events.HandleEvent(); - } - } -} - -void Core::ExecuteNetworkLoop() { - NetworkClient *nc; - EventListener events; - bool isRunning = true; - events.RegisterHandler(EventType::ConnectToServer, [](EventData eventData) { - auto data = std::get<ConnectToServerData>(eventData); - try { - nc = new NetworkClient(data.address, data.port, "HelloOne", isRunning); - } catch (std::exception &e) { - GlobalAppStateData data{GlobalState::Exiting}; - EventAgregator::PushEvent(EventType::GlobalAppState, data); - } - }); - events.RegisterHandler(EventType::Disconnect, [nc](EventData eventData) { - delete nc; - nc = nullptr; - }); - - while (globalState != GlobalState::Exiting) { - - } - delete nc; -} |