Emergency 20 Dokumentation  4.2.0
MultiplayerLobbyWindow.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
15 
16 #include <qsf/math/Color3.h>
17 
18 #include <array>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace em5
25 {
26  namespace packet
27  {
29  }
30  namespace multiplayer
31  {
32  struct HostEntry;
33  }
34 }
35 namespace Rocket
36 {
37  namespace Core
38  {
39  class ElementText;
40  }
41 }
42 
43 
44 //[-------------------------------------------------------]
45 //[ Namespace ]
46 //[-------------------------------------------------------]
47 namespace em5
48 {
49 
50 
51  //[-------------------------------------------------------]
52  //[ Classes ]
53  //[-------------------------------------------------------]
59  {
60 
61 
62  //[-------------------------------------------------------]
63  //[ Public methods ]
64  //[-------------------------------------------------------]
65  public:
66  explicit MultiplayerLobbyWindow(qsf::GuiContext& guiContext);
67  virtual ~MultiplayerLobbyWindow();
68  void setupHostLobby(const multiplayer::HostEntry* hostEntry);
69  void setupClientLobby(const multiplayer::HostEntry* hostEntry);
70  void addTextMessage(const std::string& user, const std::string& message, const qsf::Color3& color = qsf::Color3::WHITE);
71 
72 
73  //[-------------------------------------------------------]
74  //[ Public virtual qsf::GuiDocument methods ]
75  //[-------------------------------------------------------]
76  public:
77  virtual void processEvent(const std::string& eventKey, Rocket::Core::Event& event) override;
78 
79 
80  //[-------------------------------------------------------]
81  //[ Protected virtual em5::MainMenuWindowBase methods ]
82  //[-------------------------------------------------------]
83  protected:
84  virtual void onGoingBack() override;
85 
86 
87  //[-------------------------------------------------------]
88  //[ Protected virtual em5::GuiHotReloadSupport methods ]
89  //[-------------------------------------------------------]
90  protected:
91  virtual void onReloadGui() override;
92  virtual bool onDocumentPreShow() override;
93  virtual void onDocumentPreHide() override;
94 
95 
96  //[-------------------------------------------------------]
97  //[ Private definitions ]
98  //[-------------------------------------------------------]
99  private:
100  enum MatchmakingServerRegistationState
101  {
102  MATCHMAKING_SERVER_REGISTRATION_UNKNOWN = 0,
103  MATCHMAKING_SERVER_REGISTRATION,
104  MATCHMAKING_SERVER_REGISTRATION_SUCCESS_VALIDATION,
105  MATCHMAKING_SERVER_REGISTRATION_SUCCESS_CONFIRMED,
106  MATCHMAKING_SERVER_REGISTRATION_SUCCESS_FAILED,
107  MATCHMAKING_SERVER_REGISTRATION_FAILED
108  };
109 
110 
111  //[-------------------------------------------------------]
112  //[ Private methods ]
113  //[-------------------------------------------------------]
114  private:
115  void setupUI();
116  void setupUserListUIData(uint32 maxPlayerCount, bool forHost);
117  void setMatchmakingServerRegistationState(MatchmakingServerRegistationState matchmakingServerRegistationState);
118  void addUser(const multiplayer::SessionBase::PlayerInfo& playerInfo);
119  void removeUser(const multiplayer::SessionBase::PlayerInfo& playerInfo);
120 
121  // Multiplayer host/client signals
122  void setPlayerJoined(uint32 playerIndex, const multiplayer::SessionBase::PlayerInfo& playerInfo);
123  void setPlayerLeft(uint32 playerIndex, const multiplayer::SessionBase::PlayerInfo& playerInfo);
124  void onPlayerChangeReady(uint32 playerIndex, bool isReady);
125  void onCurrentStateChanged(multiplayer::SessionBase::State prevState, multiplayer::SessionBase::State newState);
126  void onChatMessage(const multiplayer::SessionBase::ChatMessage& message);
127  void startConnectionTest();
128  void onTestOpenPortResult(const em5::packet::TestOpenPortResponse& response);
129  void addTextToStatusArea(const std::string& text, const std::string& tooltipPrefix, bool failedText, bool clearAreaBeforeInserting);
130  void goBack();
131  void showElement(Rocket::Core::Element* element, bool show) const;
132  void fillInfoField();
133  void clearChat();
134  void onHostLostProxyConnection();
135 
136 
137  //[-------------------------------------------------------]
138  //[ Private definitions ]
139  //[-------------------------------------------------------]
140  private:
141  struct PlayerInfo
142  {
143  Rocket::Core::Element* mPlayerElement;
144  Rocket::Core::Element* mPlayerNameElement;
145  Rocket::Core::ElementText* mPlayerNameTextElement;
146  Rocket::Core::Element* mPlayerReadyElement;
147  Rocket::Core::Element* mPlayerCheckElement;
148 
149  PlayerInfo() :
150  mPlayerElement(nullptr),
151  mPlayerNameElement(nullptr),
152  mPlayerNameTextElement(nullptr),
153  mPlayerReadyElement(nullptr),
154  mPlayerCheckElement(nullptr)
155  {}
156 
157  };
158 
159 
160  //[-------------------------------------------------------]
161  //[ Private data ]
162  //[-------------------------------------------------------]
163  private:
164  MatchmakingServerRegistationState mMatchmakingServerRegistationState;
165  const multiplayer::HostEntry* mServer;
166  multiplayer::SessionBase* mMultiplayerSession;
167  bool mbClickOnBack;
168  bool mbFirstFocus;
169  bool mIsPVPMode;
170  bool mIsHost;
171  boost::signals2::connection mConnectionTestResultConnection;
172  boost::signals2::connection mHostLostProxyConnection;
173  Rocket::Core::Element* mLobbyStatusElement;
174  Rocket::Core::Element* mPlayerListElement;
175  std::vector<PlayerInfo> mPlayerElementList;
176 
177 
178  };
179 
180 
181 //[-------------------------------------------------------]
182 //[ Namespace ]
183 //[-------------------------------------------------------]
184 } // em5
Definition: ActionPriority.h:13
static const Color3 WHITE
White (sRGB="255 255 255", Hex="#FFFFFF")
Definition: Color3.h:41
unsigned int uint32
Definition: PlatformTypes.h:181
virtual void onGoingBack() override
Definition: SessionBase.h:139
Definition: OverlayComponent.h:29
virtual void processEvent(const std::string &eventKey, Rocket::Core::Event &event) override
Definition: SessionBase.h:105
This class represents a network package sent by the server as a response to the TestOpenPortRequest, telling the client (=game host) if it is reachable from the internet or not.
Definition: TestOpenPortResponse.h:35
Color class with red, green and blue component.
Definition: Color3.h:30
virtual bool onDocumentPreShow() override
State
Definition: SessionBase.h:93
Base window for main menu windows.
Definition: MainMenuWindowBase.h:40
void addTextMessage(const std::string &user, const std::string &message, const qsf::Color3 &color=qsf::Color3::WHITE)
Ingame Graphical User Interface (GUI) context class.
Definition: GuiContext.h:62
virtual void onReloadGui() override
Gets called when the GUI should be reloaded.
EMERGENCY 5 multiplayer session base class.
Definition: SessionBase.h:55
virtual void onDocumentPreHide() override
MultiplayerLobbyWindow(qsf::GuiContext &guiContext)
void setupClientLobby(const multiplayer::HostEntry *hostEntry)
void setupHostLobby(const multiplayer::HostEntry *hostEntry)
Multiplayer lobby window.
Definition: MultiplayerLobbyWindow.h:58
void show()
Show the document.
Definition: MatchmakingTypes.h:47