1 /*************************************************************************** 2 * Mechanized Assault and Exploration Reloaded Projectfile * 3 * * 4 * This program is free software; you can redistribute it and/or modify * 5 * it under the terms of the GNU General Public License as published by * 6 * the Free Software Foundation; either version 2 of the License, or * 7 * (at your option) any later version. * 8 * * 9 * This program is distributed in the hope that it will be useful, * 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 * GNU General Public License for more details. * 13 * * 14 * You should have received a copy of the GNU General Public License * 15 * along with this program; if not, write to the * 16 * Free Software Foundation, Inc., * 17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 19 20 #ifndef ui_graphical_menu_control_menucontrollermultiplayerclientH 21 #define ui_graphical_menu_control_menucontrollermultiplayerclientH 22 23 #include <memory> 24 25 #include "utility/signal/signalconnectionmanager.h" 26 #include "network.h" 27 #include "utility/runnable.h" 28 #include "utility/thread/concurrentqueue.h" 29 30 class cApplication; 31 class cWindowNetworkLobbyClient; 32 class cWindowLandingPositionSelection; 33 class cNetworkClientGameNew; 34 class cNetMessage; 35 class cMapReceiver; 36 class cPlayerLandingStatus; 37 38 class cTCP; 39 40 class cMenuControllerMultiplayerClient : public INetMessageReceiver, public cRunnable, public std::enable_shared_from_this<cMenuControllerMultiplayerClient> 41 { 42 public: 43 cMenuControllerMultiplayerClient (cApplication& application); 44 ~cMenuControllerMultiplayerClient(); 45 46 void start(); 47 48 virtual void pushEvent (std::unique_ptr<cNetMessage> message) MAXR_OVERRIDE_FUNCTION; 49 virtual std::unique_ptr<cNetMessage> popEvent() MAXR_OVERRIDE_FUNCTION; 50 51 virtual void run() MAXR_OVERRIDE_FUNCTION; 52 private: 53 cSignalConnectionManager signalConnectionManager; 54 55 cConcurrentQueue<std::unique_ptr<cNetMessage>> messageQueue; 56 57 std::shared_ptr<cTCP> network; 58 59 cApplication& application; 60 61 std::shared_ptr<cWindowNetworkLobbyClient> windowNetworkLobby; 62 63 std::shared_ptr<cWindowLandingPositionSelection> windowLandingPositionSelection; 64 65 std::shared_ptr<cNetworkClientGameNew> newGame; 66 67 std::unique_ptr<cMapReceiver> mapReceiver; 68 69 std::vector<std::unique_ptr<cPlayerLandingStatus>> playersLandingStatus; 70 71 std::string triedLoadMapName; 72 std::string lastRequestedMapName; 73 74 void reset(); 75 76 void handleWantLocalPlayerReadyChange(); 77 void handleChatMessageTriggered(); 78 void handleLocalPlayerAttributesChanged(); 79 80 void connect(); 81 82 void startSavedGame(); 83 84 void startGamePreparation(); 85 86 void startClanSelection(bool isFirstWindowOnGamePreparation); 87 void startLandingUnitSelection(bool isFirstWindowOnGamePreparation); 88 void startLandingPositionSelection(); 89 void startNewGame(); 90 void checkReallyWantsToQuit(); 91 92 void handleNetMessage (cNetMessage& message); 93 94 void handleNetMessage_TCP_CLOSE (cNetMessage& message); 95 void handleNetMessage_MU_MSG_CHAT (cNetMessage& message); 96 void handleNetMessage_MU_MSG_REQ_IDENTIFIKATION (cNetMessage& message); 97 void handleNetMessage_MU_MSG_PLAYER_NUMBER (cNetMessage& message); 98 void handleNetMessage_MU_MSG_PLAYERLIST (cNetMessage& message); 99 void handleNetMessage_MU_MSG_OPTINS (cNetMessage& message); 100 void handleNetMessage_MU_MSG_GO (cNetMessage& message); 101 void handleNetMessage_MU_MSG_LANDING_STATE (cNetMessage& message); 102 void handleNetMessage_MU_MSG_ALL_LANDED (cNetMessage& message); 103 void handleNetMessage_GAME_EV_REQ_RECON_IDENT (cNetMessage& message); 104 void handleNetMessage_GAME_EV_RECONNECT_ANSWER (cNetMessage& message); 105 void handleNetMessage_MU_MSG_IN_LANDING_POSITION_SELECTION_STATUS (cNetMessage& message); 106 void handleNetMessage_MU_MSG_PLAYER_HAS_SELECTED_LANDING_POSITION (cNetMessage& message); 107 void handleNetMessage_MU_MSG_PLAYER_HAS_ABORTED_GAME_PREPARATION (cNetMessage& message); 108 109 void initMapDownload (cNetMessage& message); 110 void receiveMapData (cNetMessage& message); 111 void canceledMapDownload (cNetMessage& message); 112 void finishedMapDownload (cNetMessage& message); 113 114 void saveOptions(); 115 }; 116 117 #endif // ui_graphical_menu_control_menucontrollermultiplayerclientH 118