WOL_GSUP.H 9.7 KB

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