EstablishConnectionsWindow.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. ** Command & Conquer Generals(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. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. ///// EstablishConnectionsWindow.cpp /////////////////////////
  24. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  25. #include "GameClient/GameWindowManager.h"
  26. #include "Common/NameKeyGenerator.h"
  27. #include "GameClient/EstablishConnectionsMenu.h"
  28. #include "GameNetwork/GUIUtil.h"
  29. #include "GameNetwork/GameSpy/StagingRoomGameInfo.h"
  30. static WindowLayout *establishConnectionsLayout;
  31. static NameKeyType buttonQuitID = NAMEKEY_INVALID;
  32. static NameKeyType staticPlayer1NameID = NAMEKEY_INVALID;
  33. static NameKeyType staticPlayer2NameID = NAMEKEY_INVALID;
  34. static NameKeyType staticPlayer3NameID = NAMEKEY_INVALID;
  35. static NameKeyType staticPlayer4NameID = NAMEKEY_INVALID;
  36. static NameKeyType staticPlayer5NameID = NAMEKEY_INVALID;
  37. static NameKeyType staticPlayer6NameID = NAMEKEY_INVALID;
  38. static NameKeyType staticPlayer7NameID = NAMEKEY_INVALID;
  39. static NameKeyType staticPlayer1StatusID = NAMEKEY_INVALID;
  40. static NameKeyType staticPlayer2StatusID = NAMEKEY_INVALID;
  41. static NameKeyType staticPlayer3StatusID = NAMEKEY_INVALID;
  42. static NameKeyType staticPlayer4StatusID = NAMEKEY_INVALID;
  43. static NameKeyType staticPlayer5StatusID = NAMEKEY_INVALID;
  44. static NameKeyType staticPlayer6StatusID = NAMEKEY_INVALID;
  45. static NameKeyType staticPlayer7StatusID = NAMEKEY_INVALID;
  46. static GameWindow *buttonQuitWindow = NULL;
  47. static GameWindow *staticPlayer1Name = NULL;
  48. static GameWindow *staticPlayer2Name = NULL;
  49. static GameWindow *staticPlayer3Name = NULL;
  50. static GameWindow *staticPlayer4Name = NULL;
  51. static GameWindow *staticPlayer5Name = NULL;
  52. static GameWindow *staticPlayer6Name = NULL;
  53. static GameWindow *staticPlayer7Name = NULL;
  54. static GameWindow *staticPlayer1Status = NULL;
  55. static GameWindow *staticPlayer2Status = NULL;
  56. static GameWindow *staticPlayer3Status = NULL;
  57. static GameWindow *staticPlayer4Status = NULL;
  58. static GameWindow *staticPlayer5Status = NULL;
  59. static GameWindow *staticPlayer6Status = NULL;
  60. static GameWindow *staticPlayer7Status = NULL;
  61. static const char *layoutFilename = "GameSpyGameOptionsMenu.wnd";
  62. static const char *parentName = "GameSpyGameOptionsMenuParent";
  63. static const char *gadgetsToHide[] =
  64. {
  65. "MapWindow",
  66. "StaticTextGameName",
  67. "StaticTextTeam",
  68. "StaticTextFaction",
  69. "StaticTextColor",
  70. "StaticTextPlayers",
  71. "TextEntryMapDisplay",
  72. "ButtonSelectMap",
  73. "ButtonStart",
  74. "StaticTextMapPreview",
  75. NULL // keep this last
  76. };
  77. static const char *perPlayerGadgetsToHide[] =
  78. {
  79. "ComboBoxTeam",
  80. "ComboBoxColor",
  81. "ComboBoxPlayerTemplate",
  82. "ComboBoxPlayer",
  83. "ButtonAccept",
  84. "GenericPing",
  85. //"ButtonStartPosition",
  86. NULL // keep this last
  87. };
  88. static const char *qmlayoutFilename = "WOLQuickMatchMenu.wnd";
  89. static const char *qmparentName = "WOLQuickMatchMenuParent";
  90. static const char *qmgadgetsToHide[] =
  91. {
  92. "StaticTextTitle",
  93. "ButtonBack",
  94. "ButtonOptions",
  95. "ButtonBuddies",
  96. "ButtonWiden",
  97. "ButtonStop",
  98. "ButtonStart",
  99. NULL // keep this last
  100. };
  101. static const char *qmperPlayerGadgetsToHide[] =
  102. {
  103. //"ButtonStartPosition",
  104. NULL // keep this last
  105. };
  106. static void showGameSpyGameOptionsUnderlyingGUIElements( Bool show )
  107. {
  108. ShowUnderlyingGUIElements( show, layoutFilename, parentName, gadgetsToHide, perPlayerGadgetsToHide );
  109. }
  110. static void showGameSpyQMUnderlyingGUIElements( Bool show )
  111. {
  112. ShowUnderlyingGUIElements( show, qmlayoutFilename, qmparentName, qmgadgetsToHide, qmperPlayerGadgetsToHide );
  113. }
  114. static void InitEstablishConnectionsDialog( void ) {
  115. buttonQuitID = TheNameKeyGenerator->nameToKey( AsciiString("EstablishConnectionsScreen.wnd:ButtonQuit") );
  116. buttonQuitWindow = TheWindowManager->winGetWindowFromId(NULL, buttonQuitID);
  117. }
  118. void ShowEstablishConnectionsWindow( void ) {
  119. if (establishConnectionsLayout == NULL) {
  120. establishConnectionsLayout = TheWindowManager->winCreateLayout( "Menus/EstablishConnectionsScreen.wnd" );
  121. InitEstablishConnectionsDialog();
  122. }
  123. establishConnectionsLayout->hide(FALSE);
  124. TheWindowManager->winSetFocus(establishConnectionsLayout->getFirstWindow());
  125. if (!TheGameSpyGame->isQMGame())
  126. {
  127. showGameSpyGameOptionsUnderlyingGUIElements(FALSE);
  128. }
  129. else
  130. {
  131. showGameSpyQMUnderlyingGUIElements(FALSE);
  132. }
  133. }
  134. void HideEstablishConnectionsWindow( void ) {
  135. if (establishConnectionsLayout == NULL) {
  136. // establishConnectionsLayout = TheWindowManager->winCreateLayout( "Menus/EstablishConnectionsScreen.wnd" );
  137. // InitEstablishConnectionsDialog();
  138. return;
  139. }
  140. // establishConnectionsLayout->hide(TRUE);
  141. // establishConnectionsLayout->hide(TRUE);
  142. // TheWindowManager->winDestroy(establishConnectionsLayout);
  143. establishConnectionsLayout->destroyWindows();
  144. establishConnectionsLayout->deleteInstance();
  145. establishConnectionsLayout = NULL;
  146. if (!TheGameSpyGame->isQMGame())
  147. {
  148. showGameSpyGameOptionsUnderlyingGUIElements(TRUE);
  149. }
  150. else
  151. {
  152. showGameSpyQMUnderlyingGUIElements(TRUE);
  153. }
  154. }
  155. WindowMsgHandledType EstablishConnectionsControlInput(GameWindow *window, UnsignedInt msg,
  156. WindowMsgData mData1, WindowMsgData mData2) {
  157. return MSG_IGNORED;
  158. }
  159. WindowMsgHandledType EstablishConnectionsControlSystem(GameWindow *window, UnsignedInt msg,
  160. WindowMsgData mData1, WindowMsgData mData2) {
  161. switch (msg) {
  162. case GBM_SELECTED:
  163. {
  164. GameWindow *control = (GameWindow *)mData1;
  165. Int controlID = control->winGetWindowId();
  166. if (controlID == buttonQuitID) {
  167. TheEstablishConnectionsMenu->abortGame();
  168. }
  169. break;
  170. }
  171. } // end switch
  172. return MSG_HANDLED;
  173. }