summaryrefslogtreecommitdiffstats
path: root/src/Event.hpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-07 17:08:15 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-07 17:08:15 +0200
commit8b275c0b0a1064a813ef14a109b64e1fce461893 (patch)
tree7bb1cc13d2eb9be2a344b4cd35f5e581df970f0d /src/Event.hpp
parent2017-08-05 (diff)
downloadAltCraft-8b275c0b0a1064a813ef14a109b64e1fce461893.tar
AltCraft-8b275c0b0a1064a813ef14a109b64e1fce461893.tar.gz
AltCraft-8b275c0b0a1064a813ef14a109b64e1fce461893.tar.bz2
AltCraft-8b275c0b0a1064a813ef14a109b64e1fce461893.tar.lz
AltCraft-8b275c0b0a1064a813ef14a109b64e1fce461893.tar.xz
AltCraft-8b275c0b0a1064a813ef14a109b64e1fce461893.tar.zst
AltCraft-8b275c0b0a1064a813ef14a109b64e1fce461893.zip
Diffstat (limited to '')
-rw-r--r--src/Event.hpp96
1 files changed, 76 insertions, 20 deletions
diff --git a/src/Event.hpp b/src/Event.hpp
index c553058..232e6f2 100644
--- a/src/Event.hpp
+++ b/src/Event.hpp
@@ -9,6 +9,8 @@
#include <variant>
#include <functional>
+#include <SFML/Window.hpp>
+
#include "Vector.hpp"
#include "Packet.hpp"
#include "FSM.hpp"
@@ -18,13 +20,25 @@ enum class EventType {
ChunkChanged,
ConnectToServer,
ConnectionSuccessfull,
- GlobalAppState,
Disconnect,
RequestNetworkClient,
RegisterNetworkClient,
PlayerConnected,
RemoveLoadingScreen,
ConnectionFailed,
+ Exit,
+ Disconnected,
+ Connecting,
+ NetworkClientException,
+ MouseMoved,
+ KeyPressed,
+ KeyReleased,
+ InitalizeSectionRender,
+ UpdateSectionsRender,
+ CreateSectionRender,
+ CreatedSectionRender,
+ PlayerPosChanged,
+ DeleteSectionRender,
};
struct EchoData {
@@ -46,24 +60,8 @@ struct ConnectionSuccessfullData {
NetworkClient *ptr;
};
-enum class GlobalState {
- InitialLoading,
- MainMenu,
- Connecting,
- Loading,
- Playing,
- PauseMenu,
- Exiting,
-};
-
-void SetGlobalState(GlobalState state);
-
-struct GlobalAppStateData {
- GlobalState state;
-};
-
struct DisconnectData {
-
+ std::string reason;
};
struct SendPacketData {
@@ -96,9 +94,64 @@ struct ConnectionFailedData {
std::string reason;
};
+struct ExitData {
+
+};
+
+struct DisconnectedData {
+ std::string reason;
+};
+
+struct ConnectingData {
+
+};
+
+struct NetworkClientExceptionData {
+ std::string what;
+};
+
+struct MouseMovedData {
+ double x, y;
+};
+
+struct KeyPressedData {
+ sf::Keyboard::Key key;
+};
+
+struct KeyReleasedData {
+ sf::Keyboard::Key key;
+};
+
+struct InitalizeSectionRenderData {
+ Vector pos;
+};
+
+struct CreateSectionRenderData {
+ Vector pos;
+};
+
+struct CreatedSectionRenderData {
+ Vector pos;
+};
+
+struct PlayerPosChangedData {
+ Vector newPos;
+};
+
+struct UpdateSectionsRenderData {
+
+};
+
+struct DeleteSectionRenderData {
+ Vector pos;
+};
+
using EventData = std::variant<EchoData, ChunkChangedData, ConnectToServerData, ConnectionSuccessfullData,
- GlobalAppStateData, DisconnectData, SendPacketData, ReceivePacketData, RequestNetworkClientData,
- RegisterNetworkClientData, PlayerConnectedData, RemoveLoadingScreenData, ConnectionFailedData>;
+ DisconnectData, SendPacketData, ReceivePacketData, RequestNetworkClientData, RegisterNetworkClientData,
+ PlayerConnectedData, RemoveLoadingScreenData, ConnectionFailedData, ExitData, DisconnectedData,
+ ConnectingData, NetworkClientExceptionData, MouseMovedData, KeyPressedData, KeyReleasedData,
+ InitalizeSectionRenderData, CreateSectionRenderData, CreatedSectionRenderData, PlayerPosChangedData,
+ UpdateSectionsRenderData, DeleteSectionRenderData>;
struct Event {
EventType type;
@@ -120,6 +173,8 @@ class EventListener {
void PushEvent(Event event);
+ void DirectCall(Event event);
+
public:
EventListener();
~EventListener();
@@ -147,4 +202,5 @@ class EventAgregator {
public:
static void PushEvent(EventType type, EventData data);
+ static void DirectEventCall(EventType, EventData data);
}; \ No newline at end of file