PopupLadderSelect.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. // FILE: PopupLadderSelect.cpp ////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // created: August 2002
  34. //
  35. // Filename: PopupLadderSelect.cpp
  36. //
  37. // author: Matthew D. Campbell
  38. //
  39. // purpose: Contains the Callbacks for the Ladder Select Popup
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. //-----------------------------------------------------------------------------
  44. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  45. //-----------------------------------------------------------------------------
  46. //-----------------------------------------------------------------------------
  47. // USER INCLUDES //////////////////////////////////////////////////////////////
  48. //-----------------------------------------------------------------------------
  49. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  50. #include "Common/GlobalData.h"
  51. #include "Common/Encrypt.h"
  52. #include "Common/NameKeyGenerator.h"
  53. #include "GameClient/WindowLayout.h"
  54. #include "GameClient/Gadget.h"
  55. #include "GameClient/GameText.h"
  56. #include "GameClient/KeyDefs.h"
  57. #include "GameClient/MapUtil.h"
  58. #include "GameClient/GadgetListBox.h"
  59. #include "GameClient/GadgetStaticText.h"
  60. #include "GameClient/GadgetTextEntry.h"
  61. #include "GameNetwork/GameSpy/LadderDefs.h"
  62. #include "GameNetwork/GameSpy/PeerDefs.h"
  63. //#include "GameNetwork/GameSpy/PeerThread.h"
  64. #include "GameNetwork/GameSpyOverlay.h"
  65. #ifdef _INTERNAL
  66. // for occasional debugging...
  67. //#pragma optimize("", off)
  68. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  69. #endif
  70. //-----------------------------------------------------------------------------
  71. // DEFINES ////////////////////////////////////////////////////////////////////
  72. //-----------------------------------------------------------------------------
  73. static NameKeyType parentID = NAMEKEY_INVALID;
  74. static NameKeyType listboxLadderSelectID = NAMEKEY_INVALID;
  75. static NameKeyType listboxLadderDetailsID = NAMEKEY_INVALID;
  76. static NameKeyType staticTextLadderNameID = NAMEKEY_INVALID;
  77. static NameKeyType buttonOkID = NAMEKEY_INVALID;
  78. static NameKeyType buttonCancelID = NAMEKEY_INVALID;
  79. static GameWindow *parent = NULL;
  80. static GameWindow *listboxLadderSelect = NULL;
  81. static GameWindow *listboxLadderDetails = NULL;
  82. static GameWindow *staticTextLadderName = NULL;
  83. static GameWindow *buttonOk = NULL;
  84. static GameWindow *buttonCancel = NULL;
  85. // password entry popup
  86. static NameKeyType passwordParentID = NAMEKEY_INVALID;
  87. static NameKeyType buttonPasswordOkID = NAMEKEY_INVALID;
  88. static NameKeyType buttonPasswordCancelID = NAMEKEY_INVALID;
  89. static NameKeyType textEntryPasswordID = NAMEKEY_INVALID;
  90. static GameWindow *passwordParent = NULL;
  91. static GameWindow *textEntryPassword = NULL;
  92. // incorrect password popup
  93. static NameKeyType badPasswordParentID = NAMEKEY_INVALID;
  94. static NameKeyType buttonBadPasswordOkID = NAMEKEY_INVALID;
  95. static GameWindow *badPasswordParent = NULL;
  96. static void updateLadderDetails( Int ladderID, GameWindow *staticTextLadderName, GameWindow *listboxLadderDetails );
  97. void PopulateQMLadderComboBox( void );
  98. void PopulateCustomLadderComboBox( void );
  99. void PopulateQMLadderListBox( GameWindow *win );
  100. void PopulateCustomLadderListBox( GameWindow *win );
  101. void HandleQMLadderSelection(Int ladderID);
  102. void HandleCustomLadderSelection(Int ladderID);
  103. void CustomMatchHideHostPopup(Bool hide);
  104. static void populateLadderComboBox( void )
  105. {
  106. // only one of these will do any work...
  107. PopulateQMLadderComboBox();
  108. PopulateCustomLadderComboBox();
  109. }
  110. static void populateLadderListBox( void )
  111. {
  112. // only one of these will do any work...
  113. PopulateQMLadderListBox(listboxLadderSelect);
  114. PopulateCustomLadderListBox(listboxLadderSelect);
  115. Int selIndex, selID;
  116. GadgetListBoxGetSelected(listboxLadderSelect, &selIndex);
  117. if (selIndex < 0)
  118. return;
  119. selID = (Int)GadgetListBoxGetItemData(listboxLadderSelect, selIndex);
  120. if (!selID)
  121. return;
  122. updateLadderDetails(selID, staticTextLadderName, listboxLadderDetails);
  123. }
  124. static void handleLadderSelection( Int ladderID )
  125. {
  126. // only one of these will do any work...
  127. HandleQMLadderSelection(ladderID);
  128. HandleCustomLadderSelection(ladderID);
  129. }
  130. enum PasswordMode
  131. {
  132. PASS_NONE,
  133. PASS_ENTRY,
  134. PASS_ERROR
  135. };
  136. static PasswordMode s_currentMode = PASS_NONE;
  137. static void setPasswordMode(PasswordMode mode)
  138. {
  139. s_currentMode = mode;
  140. switch(mode)
  141. {
  142. case PASS_NONE:
  143. if (passwordParent)
  144. passwordParent->winHide(TRUE);
  145. if (badPasswordParent)
  146. badPasswordParent->winHide(TRUE);
  147. if (buttonOk)
  148. buttonOk->winEnable(TRUE);
  149. if (buttonCancel)
  150. buttonCancel->winEnable(TRUE);
  151. if (textEntryPassword)
  152. textEntryPassword->winEnable(FALSE);
  153. if (listboxLadderSelect)
  154. listboxLadderSelect->winEnable(TRUE);
  155. TheWindowManager->winSetFocus(listboxLadderSelect);
  156. break;
  157. case PASS_ENTRY:
  158. if (passwordParent)
  159. passwordParent->winHide(FALSE);
  160. if (badPasswordParent)
  161. badPasswordParent->winHide(TRUE);
  162. if (buttonOk)
  163. buttonOk->winEnable(FALSE);
  164. if (buttonCancel)
  165. buttonCancel->winEnable(FALSE);
  166. if (textEntryPassword)
  167. {
  168. textEntryPassword->winEnable(TRUE);
  169. GadgetTextEntrySetText(textEntryPassword, UnicodeString::TheEmptyString);
  170. }
  171. if (listboxLadderSelect)
  172. listboxLadderSelect->winEnable(FALSE);
  173. TheWindowManager->winSetFocus(textEntryPassword);
  174. break;
  175. case PASS_ERROR:
  176. if (passwordParent)
  177. passwordParent->winHide(TRUE);
  178. if (badPasswordParent)
  179. badPasswordParent->winHide(FALSE);
  180. if (buttonOk)
  181. buttonOk->winEnable(FALSE);
  182. if (buttonCancel)
  183. buttonCancel->winEnable(FALSE);
  184. if (textEntryPassword)
  185. textEntryPassword->winEnable(FALSE);
  186. if (listboxLadderSelect)
  187. listboxLadderSelect->winEnable(FALSE);
  188. TheWindowManager->winSetFocus(parent);
  189. break;
  190. }
  191. }
  192. //-----------------------------------------------------------------------------
  193. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  194. //-----------------------------------------------------------------------------
  195. //-------------------------------------------------------------------------------------------------
  196. /** Initialize the menu */
  197. //-------------------------------------------------------------------------------------------------
  198. void PopupLadderSelectInit( WindowLayout *layout, void *userData )
  199. {
  200. parentID = NAMEKEY("PopupLadderSelect.wnd:Parent");
  201. parent = TheWindowManager->winGetWindowFromId(NULL, parentID);
  202. listboxLadderSelectID = NAMEKEY("PopupLadderSelect.wnd:ListBoxLadderSelect");
  203. listboxLadderSelect = TheWindowManager->winGetWindowFromId(parent, listboxLadderSelectID);
  204. listboxLadderDetailsID = NAMEKEY("PopupLadderSelect.wnd:ListBoxLadderDetails");
  205. listboxLadderDetails = TheWindowManager->winGetWindowFromId(parent, listboxLadderDetailsID);
  206. staticTextLadderNameID = NAMEKEY("PopupLadderSelect.wnd:StaticTextLadderName");
  207. staticTextLadderName = TheWindowManager->winGetWindowFromId(parent, staticTextLadderNameID);
  208. buttonOkID = NAMEKEY("PopupLadderSelect.wnd:ButtonOk");
  209. buttonCancelID = NAMEKEY("PopupLadderSelect.wnd:ButtonCancel");
  210. buttonOk = TheWindowManager->winGetWindowFromId(parent, buttonOkID);
  211. buttonCancel = TheWindowManager->winGetWindowFromId(parent, buttonCancelID);
  212. TheWindowManager->winSetFocus( parent );
  213. TheWindowManager->winSetModal( parent );
  214. // password entry popup
  215. passwordParentID = NAMEKEY("PopupLadderSelect.wnd:PasswordParent");
  216. passwordParent = TheWindowManager->winGetWindowFromId(parent, passwordParentID);
  217. buttonPasswordOkID = NAMEKEY("PopupLadderSelect.wnd:ButtonPasswordOk");
  218. buttonPasswordCancelID = NAMEKEY("PopupLadderSelect.wnd:ButtonPasswordCancel");
  219. textEntryPasswordID = NAMEKEY("PopupLadderSelect.wnd:PasswordEntry");
  220. textEntryPassword = TheWindowManager->winGetWindowFromId(parent, textEntryPasswordID);
  221. // bad password popup
  222. badPasswordParentID = NAMEKEY("PopupLadderSelect.wnd:BadPasswordParent");
  223. badPasswordParent = TheWindowManager->winGetWindowFromId(parent, badPasswordParentID);
  224. buttonBadPasswordOkID = NAMEKEY("PopupLadderSelect.wnd:ButtonBadPasswordOk");
  225. setPasswordMode(PASS_NONE);
  226. CustomMatchHideHostPopup(TRUE);
  227. // populate list box (based on whether we're in custom or quickmatch)
  228. populateLadderListBox();
  229. }
  230. //-------------------------------------------------------------------------------------------------
  231. /** Input callback */
  232. //-------------------------------------------------------------------------------------------------
  233. WindowMsgHandledType PopupLadderSelectInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 )
  234. {
  235. switch( msg )
  236. {
  237. // --------------------------------------------------------------------------------------------
  238. case GWM_CHAR:
  239. {
  240. UnsignedByte key = mData1;
  241. UnsignedByte state = mData2;
  242. // if (buttonPushed)
  243. // break;
  244. switch( key )
  245. {
  246. // ----------------------------------------------------------------------------------------
  247. case KEY_ESC:
  248. {
  249. //
  250. // send a simulated selected event to the parent window of the
  251. // back/exit button
  252. //
  253. if( BitTest( state, KEY_STATE_UP ) )
  254. {
  255. switch (s_currentMode)
  256. {
  257. case PASS_NONE:
  258. // re-select whatever was chosen before
  259. populateLadderComboBox();
  260. GameSpyCloseOverlay(GSOVERLAY_LADDERSELECT);
  261. break;
  262. case PASS_ENTRY:
  263. case PASS_ERROR:
  264. setPasswordMode(PASS_NONE);
  265. break;
  266. }
  267. } // end if
  268. // don't let key fall through anywhere else
  269. return MSG_HANDLED;
  270. } // end escape
  271. } // end switch( key )
  272. } // end char
  273. } // end switch( msg )
  274. return MSG_IGNORED;
  275. }
  276. static Int ladderIndex = 0;
  277. void ladderSelectedCallback(void)
  278. {
  279. handleLadderSelection( ladderIndex );
  280. // update combo box
  281. populateLadderComboBox();
  282. // tear down overlay
  283. GameSpyCloseOverlay( GSOVERLAY_LADDERSELECT );
  284. }
  285. //-------------------------------------------------------------------------------------------------
  286. /** System callback */
  287. //-------------------------------------------------------------------------------------------------
  288. WindowMsgHandledType PopupLadderSelectSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 )
  289. {
  290. switch( msg )
  291. {
  292. // --------------------------------------------------------------------------------------------
  293. case GWM_CREATE:
  294. {
  295. break;
  296. } // end create
  297. //---------------------------------------------------------------------------------------------
  298. case GWM_DESTROY:
  299. {
  300. parent = NULL;
  301. listboxLadderSelect = NULL;
  302. listboxLadderDetails = NULL;
  303. CustomMatchHideHostPopup(FALSE);
  304. break;
  305. } // end case
  306. //----------------------------------------------------------------------------------------------
  307. case GWM_INPUT_FOCUS:
  308. {
  309. // if we're given the opportunity to take the keyboard focus we must say we want it
  310. if( mData1 == TRUE )
  311. *(Bool *)mData2 = TRUE;
  312. break;
  313. } // end input
  314. //----------------------------------------------------------------------------------------------
  315. case GBM_SELECTED:
  316. {
  317. GameWindow *control = (GameWindow *)mData1;
  318. Int controlID = control->winGetWindowId();
  319. if (controlID == buttonOkID)
  320. {
  321. // save selection
  322. Int selectPos = -1;
  323. GadgetListBoxGetSelected( listboxLadderSelect, &selectPos );
  324. if (selectPos < 0)
  325. break;
  326. ladderIndex = (Int)GadgetListBoxGetItemData( listboxLadderSelect, selectPos, 0 );
  327. const LadderInfo *li = TheLadderList->findLadderByIndex( ladderIndex );
  328. if (li && li->cryptedPassword.isNotEmpty())
  329. {
  330. // need password asking
  331. setPasswordMode(PASS_ENTRY);
  332. }
  333. else
  334. {
  335. ladderSelectedCallback();
  336. }
  337. }
  338. else if (controlID == buttonCancelID)
  339. {
  340. // reset what had been
  341. populateLadderComboBox();
  342. // tear down overlay
  343. GameSpyCloseOverlay( GSOVERLAY_LADDERSELECT );
  344. }
  345. else if (controlID == buttonPasswordOkID)
  346. {
  347. const LadderInfo *li = TheLadderList->findLadderByIndex( ladderIndex );
  348. if (!li || li->cryptedPassword.isEmpty())
  349. {
  350. // eh? something's not right. just pretend they typed something wrong...
  351. setPasswordMode(PASS_ERROR);
  352. break;
  353. }
  354. AsciiString pass;
  355. pass.translate(GadgetTextEntryGetText(textEntryPassword));
  356. if ( pass.isNotEmpty() ) // password ok
  357. {
  358. AsciiString cryptPass = EncryptString(pass.str());
  359. DEBUG_LOG(("pass is %s, crypted pass is %s, comparing to %s\n",
  360. pass.str(), cryptPass.str(), li->cryptedPassword.str()));
  361. if (cryptPass == li->cryptedPassword)
  362. ladderSelectedCallback();
  363. else
  364. setPasswordMode(PASS_ERROR);
  365. }
  366. else
  367. {
  368. setPasswordMode(PASS_ERROR);
  369. }
  370. }
  371. else if (controlID == buttonPasswordCancelID)
  372. {
  373. setPasswordMode(PASS_NONE);
  374. }
  375. else if (controlID == buttonBadPasswordOkID)
  376. {
  377. setPasswordMode(PASS_NONE);
  378. }
  379. break;
  380. } // end input
  381. //---------------------------------------------------------------------------------------------
  382. case GLM_SELECTED:
  383. {
  384. Int selIndex, selID;
  385. GadgetListBoxGetSelected(listboxLadderSelect, &selIndex);
  386. if (selIndex < 0)
  387. break;
  388. selID = (Int)GadgetListBoxGetItemData(listboxLadderSelect, selIndex);
  389. if (!selID)
  390. break;
  391. updateLadderDetails(selID, staticTextLadderName, listboxLadderDetails);
  392. break;
  393. } // end GLM_DOUBLE_CLICKED
  394. //---------------------------------------------------------------------------------------------
  395. case GLM_DOUBLE_CLICKED:
  396. {
  397. GameWindow *control = (GameWindow *)mData1;
  398. Int controlID = control->winGetWindowId();
  399. Int selectPos = (Int)mData2;
  400. GadgetListBoxSetSelected(control, &selectPos);
  401. if( controlID == listboxLadderSelectID )
  402. {
  403. TheWindowManager->winSendSystemMsg( parent, GBM_SELECTED,
  404. (WindowMsgData)buttonOk, buttonOk->winGetWindowId() );
  405. }
  406. break;
  407. }
  408. //---------------------------------------------------------------------------------------------
  409. case GEM_EDIT_DONE:
  410. {
  411. GameWindow *control = (GameWindow *)mData1;
  412. Int controlID = control->winGetWindowId();
  413. if (controlID == textEntryPasswordID)
  414. {
  415. TheWindowManager->winSendSystemMsg( parent, GBM_SELECTED,
  416. (WindowMsgData)(TheWindowManager->winGetWindowFromId(passwordParent, buttonPasswordOkID)), buttonPasswordOkID );
  417. }
  418. break;
  419. }
  420. default:
  421. return MSG_IGNORED;
  422. } // end switch
  423. return MSG_HANDLED;
  424. }
  425. //-----------------------------------------------------------------------------
  426. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  427. //-----------------------------------------------------------------------------
  428. static void updateLadderDetails( Int selID, GameWindow *staticTextLadderName, GameWindow *listboxLadderDetails )
  429. {
  430. if (!staticTextLadderName || !listboxLadderDetails)
  431. return;
  432. GadgetStaticTextSetText(staticTextLadderName, UnicodeString::TheEmptyString);
  433. GadgetListBoxReset(listboxLadderDetails);
  434. const LadderInfo *info = TheLadderList->findLadderByIndex(selID);
  435. if (!info)
  436. return;
  437. UnicodeString line;
  438. Color color = GameMakeColor( 255, 255, 255, 255 );
  439. Color captionColor = GameMakeColor( 0, 255, 255, 255 );
  440. // name
  441. line.format(TheGameText->fetch("GUI:LadderNameAndSize"), info->name.str(), info->playersPerTeam, info->playersPerTeam);
  442. GadgetStaticTextSetText(staticTextLadderName, line);
  443. // location
  444. if (!info->location.isEmpty())
  445. GadgetListBoxAddEntryText(listboxLadderDetails, info->location, captionColor, -1);
  446. // homepage
  447. line.format(TheGameText->fetch("GUI:LadderURL"), info->homepageURL.str());
  448. GadgetListBoxAddEntryText(listboxLadderDetails, line, captionColor, -1);
  449. // description
  450. if (!info->description.isEmpty())
  451. GadgetListBoxAddEntryText(listboxLadderDetails, info->description, color, -1);
  452. // requires password?
  453. if (info->cryptedPassword.isNotEmpty())
  454. {
  455. GadgetListBoxAddEntryText(listboxLadderDetails, TheGameText->fetch("GUI:LadderHasPassword"), captionColor, -1);
  456. }
  457. // wins limits
  458. if (info->minWins)
  459. {
  460. line.format(TheGameText->fetch("GUI:LadderMinWins"), info->minWins);
  461. GadgetListBoxAddEntryText(listboxLadderDetails, line, captionColor, -1);
  462. }
  463. if (info->maxWins)
  464. {
  465. line.format(TheGameText->fetch("GUI:LadderMaxWins"), info->maxWins);
  466. GadgetListBoxAddEntryText(listboxLadderDetails, line, captionColor, -1);
  467. }
  468. // random factions?
  469. if (info->randomFactions)
  470. {
  471. GadgetListBoxAddEntryText(listboxLadderDetails, TheGameText->fetch("GUI:LadderRandomFactions"), captionColor, -1);
  472. }
  473. else
  474. {
  475. GadgetListBoxAddEntryText(listboxLadderDetails, TheGameText->fetch("GUI:LadderFactions"), captionColor, -1);
  476. }
  477. // factions
  478. AsciiStringList validFactions = info->validFactions;
  479. for (AsciiStringListIterator it = validFactions.begin(); it != validFactions.end(); ++it)
  480. {
  481. AsciiString marker;
  482. marker.format("INI:Faction%s", it->str());
  483. GadgetListBoxAddEntryText(listboxLadderDetails, TheGameText->fetch(marker), color, -1);
  484. }
  485. // random maps?
  486. if (info->randomMaps)
  487. {
  488. GadgetListBoxAddEntryText(listboxLadderDetails, TheGameText->fetch("GUI:LadderRandomMaps"), captionColor, -1);
  489. }
  490. else
  491. {
  492. GadgetListBoxAddEntryText(listboxLadderDetails, TheGameText->fetch("GUI:LadderMaps"), captionColor, -1);
  493. }
  494. // maps
  495. AsciiStringList validMaps = info->validMaps;
  496. for (it = validMaps.begin(); it != validMaps.end(); ++it)
  497. {
  498. const MapMetaData *md = TheMapCache->findMap(*it);
  499. if (md)
  500. {
  501. GadgetListBoxAddEntryText(listboxLadderDetails, md->m_displayName, color, -1);
  502. }
  503. }
  504. }
  505. static void closeRightClickMenu(GameWindow *win)
  506. {
  507. if(win)
  508. {
  509. WindowLayout *winLay = win->winGetLayout();
  510. if(!winLay)
  511. return;
  512. winLay->destroyWindows();
  513. winLay->deleteInstance();
  514. winLay = NULL;
  515. }
  516. }
  517. void RCGameDetailsMenuInit( WindowLayout *layout, void *userData )
  518. {
  519. }
  520. WindowMsgHandledType RCGameDetailsMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 )
  521. {
  522. static NameKeyType ladderInfoID = NAMEKEY_INVALID;
  523. static NameKeyType buttonOkID = NAMEKEY_INVALID;
  524. switch( msg )
  525. {
  526. case GWM_CREATE:
  527. {
  528. ladderInfoID = NAMEKEY("RCGameDetailsMenu.wnd:ButtonLadderDetails");
  529. buttonOkID = NAMEKEY("PopupLadderDetails.wnd:ButtonOk");
  530. break;
  531. } // case GWM_DESTROY:
  532. case GGM_CLOSE:
  533. {
  534. closeRightClickMenu(window);
  535. //rcMenu = NULL;
  536. break;
  537. }
  538. case GWM_DESTROY:
  539. {
  540. break;
  541. } // case GWM_DESTROY:
  542. case GBM_SELECTED:
  543. {
  544. GameWindow *control = (GameWindow *)mData1;
  545. Int controlID = control->winGetWindowId();
  546. Int selectedID = (Int)window->winGetUserData();
  547. if(!selectedID)
  548. break;
  549. closeRightClickMenu(window);
  550. if (controlID == ladderInfoID)
  551. {
  552. StagingRoomMap *srm = TheGameSpyInfo->getStagingRoomList();
  553. StagingRoomMap::iterator srmIt = srm->find(selectedID);
  554. if (srmIt != srm->end())
  555. {
  556. GameSpyStagingRoom *theRoom = srmIt->second;
  557. if (!theRoom)
  558. break;
  559. const LadderInfo *linfo = TheLadderList->findLadder(theRoom->getLadderIP(), theRoom->getLadderPort());
  560. if (linfo)
  561. {
  562. WindowLayout *rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/PopupLadderDetails.wnd"));
  563. if (!rcLayout)
  564. break;
  565. GameWindow *rcMenu = rcLayout->getFirstWindow();
  566. rcMenu->winGetLayout()->runInit();
  567. rcMenu->winBringToTop();
  568. rcMenu->winHide(FALSE);
  569. rcMenu->winSetUserData((void *)selectedID);
  570. TheWindowManager->winSetLoneWindow(rcMenu);
  571. GameWindow *st = TheWindowManager->winGetWindowFromId(NULL,
  572. NAMEKEY("PopupLadderDetails.wnd:StaticTextLadderName"));
  573. GameWindow *lb = TheWindowManager->winGetWindowFromId(NULL,
  574. NAMEKEY("PopupLadderDetails.wnd:ListBoxLadderDetails"));
  575. updateLadderDetails(selectedID, st, lb);
  576. }
  577. }
  578. }
  579. break;
  580. }
  581. default:
  582. return MSG_IGNORED;
  583. }//Switch
  584. return MSG_HANDLED;
  585. }