WOL_GSUP.H 9.8 KB

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