WOL_GSUP.H (10068B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 #ifdef WOLAPI_INTEGRATION 17 18 // wol_gsup.h "WOL Game Setup Dialog" 19 // ajw 08/06/98 20 21 // Class WOL_GameSetupDialog is a move away from doing dialogs purely in C, a format that I've maintained in the login and 22 // chat dialogs, mimicking how dialogs are done elsewhere in the code, but became frustrated with. 23 // Though I'll follow the same pattern as before, things will be centralized a little cleaner through the use of this object. 24 // Why a standard dialog class that would handle common input behavior and so forth (one that this class could derive from) 25 // wasn't written 5 years ago, I don't know... 26 27 #include "WolapiOb.h" 28 //class WolapiObject; 29 class IconListClass; 30 class EditClass; 31 class GaugeClass; 32 class CheckListClass; 33 class TextButtonClass; 34 class StaticButtonClass; 35 class DropListClass; 36 class ShapeButtonClass; 37 class BigCheckBoxClass; 38 class ToolTipClass; 39 40 //*********************************************************************************************** 41 enum RESULT_WOLGSUP 42 { 43 RESULT_WOLGSUP_BACKTOCHAT, 44 RESULT_WOLGSUP_FATALERROR, 45 RESULT_WOLGSUP_HOSTLEFT, 46 RESULT_WOLGSUP_STARTGAMEHOST, 47 RESULT_WOLGSUP_STARTGAME, 48 RESULT_WOLGSUP_RULESMISMATCH, 49 RESULT_WOLGSUP_LOGOUT, 50 }; 51 52 struct GAMEPARAMS 53 { 54 GlobalPacketType GPacket; 55 // My additions to game params. - ajw 56 bool bAftermathUnits; 57 bool bSlowUnitBuildRate; 58 }; 59 60 //*********************************************************************************************** 61 class WOL_GameSetupDialog 62 { 63 public: 64 WOL_GameSetupDialog( WolapiObject* pWO, bool bHost ); 65 ~WOL_GameSetupDialog(); 66 67 RESULT_WOLGSUP Run(); 68 69 public: 70 bool bHost; // True when I created the game channel and am the host. 71 72 bool bHostSayGo; // Trigger host instructing all to start game immediately. 73 bool bHostWaitingForGoTrigger; // True while host is waiting for go message to bounce back to him and trigger start. 74 bool bExitForGameTrigger; // Trigger exiting dialog for game. 75 76 77 void ProcessGuestRequest( User* pUser, const char* szRequest ); 78 void ProcessInform( char* szRequest ); 79 void OnGuestJoin( User* pUser ); 80 void OnGuestLeave( User* pUser ); 81 82 protected: 83 void Initialize(); 84 RESULT_WOLGSUP Show(); 85 void SetSpecialControlStates(); 86 void BindControls( bool bBind ); 87 bool ExitGameChannel(); 88 void DrawScenarioDescripIcon( const char* pDIB ) const; 89 void SetPlayerColor( const char* szName, PlayerColorType Color ); 90 PlayerColorType GetPlayerColor( const char* szName ); 91 void SetPlayerHouse( const char* szName, HousesType House ); 92 HousesType GetPlayerHouse( const char* szName ); 93 bool SetPlayerAccepted( const char* szName, bool bAccepted ); 94 bool IveAccepted(); 95 bool SetPlayerReadyToGo( const char* szName, const char* szReadyState ); 96 void ResetReadyToGo(); 97 bool bPlayerReadyToGo( const char* szName ); 98 bool bAllPlayersReadyToGo(); 99 100 bool bParamsUnfresh(); 101 void SendParams(); 102 bool AcceptParams( char* szParams ); 103 void SetGParamsToCurrent( GAMEPARAMS& GParams ); 104 105 void AcceptNewGuestPlayerInfo( char* szMsg ); 106 107 bool RequestPlayerColor( PlayerColorType Color ); 108 bool InformAboutPlayerColor( const char* szName, PlayerColorType Color, User* pUserPriv ); 109 bool InformAboutPlayerHouse( const char* szName, HousesType House, User* pUserPriv ); 110 bool InformAboutPlayerAccept( const char* szName, User* pUserPriv ); 111 bool InformAboutStart(); 112 bool InformAboutCancelStart(); 113 114 void ClearAllAccepts(); 115 bool bAllGuestsAccept(); 116 117 PlayerColorType ColorNextAvailable(); 118 119 void GuestIsReadyToPlay( const char* szName, const char* szReadyState ); 120 bool bNeedScenarioDownload(); 121 void HostSaysGo(); 122 void TriggerGameStart( char* szGoMessage ); 123 124 enum SCENARIO_GAMEKIND 125 { 126 SCENARIO_RA = 0, 127 SCENARIO_CS, 128 SCENARIO_AM, 129 SCENARIO_USER, 130 SCENARIO_UNINITIALIZED, 131 }; 132 void ScenarioDisplayMode( SCENARIO_GAMEKIND ScenKind ); 133 134 // bool bSpecialAftermathScenario( const char* szScenarioDescription ); 135 136 public: 137 int d_dialog_w; 138 int d_dialog_h; 139 int d_dialog_x; 140 int d_dialog_y; 141 int d_dialog_cx; 142 143 int d_txt6_h; 144 int d_margin1; 145 146 int d_house_w; 147 int d_house_h; 148 int d_house_x; 149 int d_house_y; 150 151 int d_color_w; 152 int d_color_h; 153 int d_color_x; 154 int d_color_y; 155 156 int d_playerlist_w; 157 int d_playerlist_h; 158 int d_playerlist_x; 159 int d_playerlist_y; 160 161 int d_scenariolist_w; 162 int d_scenariolist_h; 163 int d_scenariolist_x; 164 int d_scenariolist_y; 165 166 int d_gamekind_w; 167 int d_gamekind_h; 168 int d_gamekind_x; 169 int d_gamekind_y; 170 171 int d_count_w; 172 int d_count_h; 173 int d_count_x; 174 int d_count_y; 175 176 int d_level_w; 177 int d_level_h; 178 int d_level_x; 179 int d_level_y; 180 181 int d_credits_w; 182 int d_credits_h; 183 int d_credits_x; 184 int d_credits_y; 185 186 int d_aiplayers_w; 187 int d_aiplayers_h; 188 int d_aiplayers_x; 189 int d_aiplayers_y; 190 191 int d_options_w; 192 int d_options_h; 193 int d_options_x; 194 int d_options_y; 195 196 int d_disc_w; 197 int d_disc_h; 198 int d_disc_x; 199 int d_disc_y; 200 201 int d_send_w; 202 int d_send_h; 203 int d_send_x; 204 int d_send_y; 205 206 int d_ok_w; 207 int d_ok_h; 208 int d_ok_x; 209 int d_ok_y; 210 211 int d_cancel_w; 212 int d_cancel_h; 213 int d_cancel_x; 214 int d_cancel_y; 215 216 int d_accept_w; 217 int d_accept_h; 218 int d_accept_x; 219 int d_accept_y; 220 221 int d_amunits_w; 222 int d_amunits_h; 223 int d_amunits_x; 224 int d_amunits_y; 225 226 int d_action_w; 227 int d_action_h; 228 int d_action_x; 229 int d_action_y; 230 231 protected: 232 GadgetClass* commands; // The controls list. 233 234 IconListClass* pILPlayers; 235 IconListClass* pILScens; 236 IconListClass* pILDisc; 237 char szSendBuffer[ MAXCHATSENDLENGTH ]; 238 EditClass* pEditSend; 239 GaugeClass* pGaugeCount; 240 GaugeClass* pGaugeLevel; 241 GaugeClass* pGaugeCredits; 242 GaugeClass* pGaugeAIPlayers; 243 CheckListClass* pCheckListOptions; 244 TextButtonClass* pTextBtnOk; 245 TextButtonClass* pTextBtnCancel; 246 TextButtonClass* pTextBtnAcceptStart; 247 TextButtonClass* pTextBtnAction; 248 StaticButtonClass* pStaticDescrip; 249 StaticButtonClass* pStaticUnit; 250 StaticButtonClass* pStaticLevel; 251 StaticButtonClass* pStaticCredits; 252 StaticButtonClass* pStaticAIPlayers; 253 char szHouseBuffer[25]; // buffer for house droplist 254 DropListClass* pDropListHouse; 255 BigCheckBoxClass* pCheckAftermathUnits; 256 ShapeButtonClass* pShpBtnScenarioRA; 257 ShapeButtonClass* pShpBtnScenarioCS; 258 ShapeButtonClass* pShpBtnScenarioAM; 259 ShapeButtonClass* pShpBtnScenarioUser; 260 261 ToolTipClass* pTTipAcceptStart; 262 ToolTipClass* pTTipCancel; 263 ToolTipClass* pTTipAction; 264 265 WolapiObject* pWO; 266 267 268 GAMEPARAMS GParamsLastSent; // Used merely as a handy container for the vars I need to set. 269 270 DWORD dwTimeNextParamRefresh; // Param changes are sent by host at certain interval. 271 272 HousesType HousePrevious; 273 274 unsigned int nHostLastParamID; // Host's send update tracking packet ID. 275 unsigned int nGuestLastParamID; // Guest's record of last ID received from host. 276 277 bool bWaitingToStart; 278 279 bool bProcess; // True means continue doing input loop. 280 RESULT_WOLGSUP ResultReturn; // Value that will be returned from Show(). 281 char szNameOfHostWhoJustBailedOnUs[ WOL_NAME_LEN_MAX ]; // If set, triggers setup cancellation. 282 283 bool bParamsReceived; // True after any WOL_GAMEOPT_INFPARAMS messages have been received from a host. 284 285 bool bLeaveDueToRulesMismatchTrigger; 286 287 bool bRequestedScenarioDownload; 288 289 char szTriggerGameStartInfo[ ( WOL_NAME_LEN_MAX + 10 ) * 4 + 60 ]; 290 291 // Tooltips... 292 DWORD timeToolTipAppear; 293 ToolTipClass* pToolTipHead; // Head of list of ToolTips that parallels gadget list. 294 ToolTipClass* pToolTipHitLast; // ToolTip the mouse was last over, or null. 295 296 // Extra game params... 297 bool bAftermathUnits; // True if aftermath units are to be used in the game. 298 bool bSlowUnitBuildRate; 299 300 SCENARIO_GAMEKIND ScenKindCurrent; // Describes what gamekind of scenarios we are viewing, if host. 301 DynamicVectorClass< const char* > ar_szScenarios[ 4 ]; // Lists of scenarios, by SCENARIO_GAMEKIND. 302 // ar_szScenIndexes parallels ar_szScenarios, holds ScenarioIndex. It's actually an int, but I'm using void* to avoid 303 // template instantiation problems and the need to change defines.h. 304 DynamicVectorClass< void* > ar_szScenIndexes[ 4 ]; 305 306 //------------------------------------------------------------------------ 307 // Button Enumerations 308 //------------------------------------------------------------------------ 309 enum 310 { 311 BUTTON_DISCONNECT = 100, // Note: standard WOL button IDs must match values in WolapiObject::PrepareButtonsAndIcons(). 312 BUTTON_LEAVE, 313 BUTTON_REFRESH, 314 BUTTON_SQUELCH, 315 BUTTON_BAN, 316 BUTTON_KICK, 317 BUTTON_FINDPAGE, 318 BUTTON_OPTIONS, 319 BUTTON_LADDER, 320 BUTTON_HELP, 321 322 BUTTON_PLAYERLIST, 323 BUTTON_HOUSE, 324 BUTTON_SCENARIOLIST, 325 BUTTON_DISCLIST, 326 BUTTON_SENDEDIT, 327 BUTTON_COUNT, 328 BUTTON_LEVEL, 329 BUTTON_CREDITS, 330 BUTTON_AIPLAYERS, 331 BUTTON_PARAMS, 332 // BUTTON_OK, 333 BUTTON_CANCEL, 334 BUTTON_ACCEPTSTART, 335 BUTTON_ACTION, 336 BUTTON_AFTERMATHUNITS, 337 BUTTON_SCENARIO_RA, 338 BUTTON_SCENARIO_CS, 339 BUTTON_SCENARIO_AM, 340 BUTTON_SCENARIO_USER, 341 }; 342 343 //------------------------------------------------------------------------ 344 // Redraw values: in order from "top" to "bottom" layer of the dialog 345 //------------------------------------------------------------------------ 346 typedef enum { 347 REDRAW_NONE = 0, 348 REDRAW_PARMS, 349 REDRAW_MESSAGE, 350 REDRAW_COLORS, 351 REDRAW_BUTTONS, 352 REDRAW_BACKGROUND, 353 REDRAW_ALL = REDRAW_BACKGROUND 354 } RedrawType; 355 356 RedrawType display; 357 358 }; 359 360 #endif 361