SkirmishMapSelectMenu.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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. // FILE: SkirmishMapSelectMenu.cpp ////////////////////////////////////////////////////////////////////////
  24. // Author: Chris Brue, August 2002
  25. // Description: MapSelect menu window callbacks
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #include "Common/GameEngine.h"
  30. #include "Common/MessageStream.h"
  31. #include "Common/UserPreferences.h"
  32. #include "GameClient/WindowLayout.h"
  33. #include "GameClient/Gadget.h"
  34. #include "GameClient/GameText.h"
  35. #include "GameClient/Mouse.h"
  36. #include "GameClient/Shell.h"
  37. #include "GameClient/GameWindowManager.h"
  38. #include "GameClient/GadgetListBox.h"
  39. #include "GameClient/GadgetRadioButton.h"
  40. #include "GameClient/GadgetStaticText.h"
  41. #include "GameNetwork/LANAPICallbacks.h"
  42. #include "GameClient/MapUtil.h"
  43. // PRIVATE DATA ///////////////////////////////////////////////////////////////////////////////////
  44. static NameKeyType buttonBack = NAMEKEY_INVALID;
  45. static NameKeyType buttonOK = NAMEKEY_INVALID;
  46. static NameKeyType listboxMap = NAMEKEY_INVALID;
  47. static GameWindow *parent = NULL;
  48. static GameWindow *mapList = NULL;
  49. static NameKeyType radioButtonSystemMapsID = NAMEKEY_INVALID;
  50. static NameKeyType radioButtonUserMapsID = NAMEKEY_INVALID;
  51. static GameWindow *buttonMapStartPosition[MAX_SLOTS] = {NULL,NULL,NULL,NULL,
  52. NULL,NULL,NULL,NULL };
  53. static NameKeyType buttonMapStartPositionID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID,
  54. NAMEKEY_INVALID,NAMEKEY_INVALID,
  55. NAMEKEY_INVALID,NAMEKEY_INVALID,
  56. NAMEKEY_INVALID,NAMEKEY_INVALID };
  57. static GameWindow *winMapPreview = NULL;
  58. static NameKeyType winMapPreviewID = NAMEKEY_INVALID;
  59. static void NullifyControls()
  60. {
  61. mapList = NULL;
  62. winMapPreview = NULL;
  63. parent = NULL;
  64. for (Int i=0; i<MAX_SLOTS; ++i)
  65. {
  66. buttonMapStartPosition[i] = NULL;
  67. }
  68. }
  69. extern WindowLayout *skirmishMapSelectLayout;
  70. // Tooltips -------------------------------------------------------------------------------
  71. static void mapListTooltipFunc(GameWindow *window,
  72. WinInstanceData *instData,
  73. UnsignedInt mouse)
  74. {
  75. Int x, y, row, col;
  76. x = LOLONGTOSHORT(mouse);
  77. y = HILONGTOSHORT(mouse);
  78. GadgetListBoxGetEntryBasedOnXY(window, x, y, row, col);
  79. if (row == -1 || col == -1)
  80. {
  81. TheMouse->setCursorTooltip( UnicodeString::TheEmptyString);
  82. return;
  83. }
  84. Int imageItemData = (Int)GadgetListBoxGetItemData(window, row, 1);
  85. UnicodeString tooltip;
  86. switch (imageItemData)
  87. {
  88. case 0:
  89. tooltip = TheGameText->fetch("TOOLTIP:MapNoSuccess");
  90. break;
  91. case 1:
  92. tooltip = TheGameText->fetch("TOOLTIP:MapEasySuccess");
  93. break;
  94. case 2:
  95. tooltip = TheGameText->fetch("TOOLTIP:MapMediumSuccess");
  96. break;
  97. case 3:
  98. tooltip = TheGameText->fetch("TOOLTIP:MapHardSuccess");
  99. break;
  100. }
  101. TheMouse->setCursorTooltip( tooltip );
  102. }
  103. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////////////////////////
  104. void positionStartSpots( AsciiString mapName, GameWindow *buttonMapStartPositions[], GameWindow *mapWindow);
  105. void skirmishPositionStartSpots( void );
  106. void skirmishUpdateSlotList( void );
  107. void showSkirmishGameOptionsUnderlyingGUIElements( Bool show )
  108. {
  109. AsciiString parentName( "SkirmishGameOptionsMenu.wnd:SkirmishGameOptionsMenuParent" );
  110. NameKeyType parentID = TheNameKeyGenerator->nameToKey( parentName );
  111. GameWindow *parent = TheWindowManager->winGetWindowFromId( NULL, parentID );
  112. if (!parent)
  113. return;
  114. // hide some GUI elements of the screen underneath
  115. GameWindow *win;
  116. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:MapWindow") );
  117. win->winHide( !show );
  118. //win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:StaticTextTitle") );
  119. //win->winHide( !show );
  120. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:StaticTextTeam") );
  121. win->winHide( !show );
  122. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:StaticTextFaction") );
  123. win->winHide( !show );
  124. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:StaticTextColor") );
  125. win->winHide( !show );
  126. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxTeam0") );
  127. win->winHide( !show );
  128. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxTeam1") );
  129. win->winHide( !show );
  130. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxTeam2") );
  131. win->winHide( !show );
  132. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxTeam3") );
  133. win->winHide( !show );
  134. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxTeam4") );
  135. win->winHide( !show );
  136. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxTeam5") );
  137. win->winHide( !show );
  138. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxTeam6") );
  139. win->winHide( !show );
  140. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxTeam7") );
  141. win->winHide( !show );
  142. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxColor0") );
  143. win->winHide( !show );
  144. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxColor1") );
  145. win->winHide( !show );
  146. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxColor2") );
  147. win->winHide( !show );
  148. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxColor3") );
  149. win->winHide( !show );
  150. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxColor4") );
  151. win->winHide( !show );
  152. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxColor5") );
  153. win->winHide( !show );
  154. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxColor6") );
  155. win->winHide( !show );
  156. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxColor7") );
  157. win->winHide( !show );
  158. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxPlayerTemplate0") );
  159. win->winHide( !show );
  160. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxPlayerTemplate1") );
  161. win->winHide( !show );
  162. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxPlayerTemplate2") );
  163. win->winHide( !show );
  164. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxPlayerTemplate3") );
  165. win->winHide( !show );
  166. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxPlayerTemplate4") );
  167. win->winHide( !show );
  168. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxPlayerTemplate5") );
  169. win->winHide( !show );
  170. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxPlayerTemplate6") );
  171. win->winHide( !show );
  172. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ComboBoxPlayerTemplate7") );
  173. win->winHide( !show );
  174. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:TextEntryMapDisplay") );
  175. win->winHide( !show );
  176. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ButtonSelectMap") );
  177. win->winHide( !show );
  178. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ButtonStart") );
  179. win->winHide( !show );
  180. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:StaticTextMapPreview") );
  181. win->winHide( !show );
  182. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ButtonReset") );
  183. win->winEnable( show );
  184. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:ButtonBack") );
  185. win->winEnable( show );
  186. }
  187. //-------------------------------------------------------------------------------------------------
  188. /** Initialize the MapSelect menu */
  189. //-------------------------------------------------------------------------------------------------
  190. void SkirmishMapSelectMenuInit( WindowLayout *layout, void *userData )
  191. {
  192. // set keyboard focus to main parent
  193. AsciiString parentName( "SkirmishMapSelectMenu.wnd:SkrimishMapSelectMenuParent" );
  194. NameKeyType parentID = TheNameKeyGenerator->nameToKey( parentName );
  195. parent = TheWindowManager->winGetWindowFromId( NULL, parentID );
  196. TheWindowManager->winSetFocus( parent );
  197. LANPreferences pref;
  198. Bool usesSystemMapDir = pref.usesSystemMapDir();
  199. const MapMetaData *mmd = TheMapCache->findMap(TheSkirmishGameInfo->getMap());
  200. if (mmd)
  201. {
  202. usesSystemMapDir = mmd->m_isOfficial;
  203. }
  204. winMapPreviewID = TheNameKeyGenerator->nameToKey( AsciiString("SkirmishMapSelectMenu.wnd:WinMapPreview") );
  205. winMapPreview = TheWindowManager->winGetWindowFromId(parent, winMapPreviewID);
  206. buttonBack = TheNameKeyGenerator->nameToKey( AsciiString("SkirmishMapSelectMenu.wnd:ButtonBack") );
  207. buttonOK = TheNameKeyGenerator->nameToKey( AsciiString("SkirmishMapSelectMenu.wnd:ButtonOK") );
  208. listboxMap = TheNameKeyGenerator->nameToKey( AsciiString("SkirmishMapSelectMenu.wnd:ListboxMap") );
  209. radioButtonSystemMapsID = TheNameKeyGenerator->nameToKey( "SkirmishMapSelectMenu.wnd:RadioButtonSystemMaps" );
  210. radioButtonUserMapsID = TheNameKeyGenerator->nameToKey( "SkirmishMapSelectMenu.wnd:RadioButtonUserMaps" );
  211. GameWindow *radioButtonSystemMaps = TheWindowManager->winGetWindowFromId( parent, radioButtonSystemMapsID );
  212. GameWindow *radioButtonUserMaps = TheWindowManager->winGetWindowFromId( parent, radioButtonUserMapsID );
  213. if (usesSystemMapDir)
  214. GadgetRadioSetSelection( radioButtonSystemMaps, FALSE );
  215. else
  216. GadgetRadioSetSelection( radioButtonUserMaps, FALSE );
  217. AsciiString tmpString;
  218. for (Int i = 0; i < MAX_SLOTS; i++)
  219. {
  220. tmpString.format("SkirmishMapSelectMenu.wnd:ButtonMapStartPosition%d", i);
  221. buttonMapStartPositionID[i] = TheNameKeyGenerator->nameToKey( tmpString );
  222. buttonMapStartPosition[i] = TheWindowManager->winGetWindowFromId( winMapPreview, buttonMapStartPositionID[i] );
  223. DEBUG_ASSERTCRASH(buttonMapStartPosition[i], ("Could not find the ButtonMapStartPosition[%d]",i ));
  224. buttonMapStartPosition[i]->winHide(TRUE);
  225. buttonMapStartPosition[i]->winEnable(FALSE);
  226. }
  227. showSkirmishGameOptionsUnderlyingGUIElements(FALSE);
  228. // get the listbox window
  229. AsciiString listString( "SkirmishMapSelectMenu.wnd:ListboxMap" );
  230. NameKeyType mapListID = TheNameKeyGenerator->nameToKey( listString );
  231. mapList = TheWindowManager->winGetWindowFromId( parent, mapListID );
  232. if( mapList )
  233. {
  234. if (TheMapCache)
  235. TheMapCache->updateCache();
  236. if (usesSystemMapDir)
  237. {
  238. populateMapListbox( mapList, TRUE, TRUE, TheSkirmishGameInfo->getMap() );
  239. }
  240. else
  241. {
  242. populateMapListbox( mapList, FALSE, FALSE, TheSkirmishGameInfo->getMap() );
  243. populateMapListboxNoReset( mapList, FALSE, TRUE, TheSkirmishGameInfo->getMap() );
  244. }
  245. mapList->winSetTooltipFunc(mapListTooltipFunc);
  246. }
  247. } // end SkirmishMapSelectMenuInit
  248. //-------------------------------------------------------------------------------------------------
  249. /** MapSelect menu shutdown method */
  250. //-------------------------------------------------------------------------------------------------
  251. void SkirmishMapSelectMenuShutdown( WindowLayout *layout, void *userData )
  252. {
  253. // hide menu
  254. layout->hide( TRUE );
  255. NullifyControls();
  256. // our shutdown is complete
  257. TheShell->shutdownComplete( layout );
  258. } // end LanMapSelectMenuShutdown
  259. //-------------------------------------------------------------------------------------------------
  260. /** MapSelect menu update method */
  261. //-------------------------------------------------------------------------------------------------
  262. void SkirmishMapSelectMenuUpdate( WindowLayout *layout, void *userData )
  263. {
  264. } // end SkirmishMapSelectMenuUpdate
  265. //-------------------------------------------------------------------------------------------------
  266. /** Map select menu input callback */
  267. //-------------------------------------------------------------------------------------------------
  268. WindowMsgHandledType SkirmishMapSelectMenuInput( GameWindow *window, UnsignedInt msg,
  269. WindowMsgData mData1, WindowMsgData mData2 )
  270. {
  271. switch( msg )
  272. {
  273. // --------------------------------------------------------------------------------------------
  274. case GWM_CHAR:
  275. {
  276. UnsignedByte key = mData1;
  277. UnsignedByte state = mData2;
  278. switch( key )
  279. {
  280. // ----------------------------------------------------------------------------------------
  281. case KEY_ESC:
  282. {
  283. //
  284. // send a simulated selected event to the parent window of the
  285. // back/exit button
  286. //
  287. if( BitTest( state, KEY_STATE_UP ) )
  288. {
  289. AsciiString buttonName( "SkirmishMapSelectMenu.wnd:ButtonBack" );
  290. NameKeyType buttonID = TheNameKeyGenerator->nameToKey( buttonName );
  291. GameWindow *button = TheWindowManager->winGetWindowFromId( window, buttonID );
  292. TheWindowManager->winSendSystemMsg( window, GBM_SELECTED,
  293. (WindowMsgData)button, buttonID );
  294. } // end if
  295. // don't let key fall through anywhere else
  296. return MSG_HANDLED;
  297. } // end escape
  298. } // end switch( key )
  299. } // end char
  300. } // end switch( msg )
  301. return MSG_IGNORED;
  302. } // end SkirmishMapSelectMenuInput
  303. //-------------------------------------------------------------------------------------------------
  304. /** MapSelect menu window system callback */
  305. //-------------------------------------------------------------------------------------------------
  306. WindowMsgHandledType SkirmishMapSelectMenuSystem( GameWindow *window, UnsignedInt msg,
  307. WindowMsgData mData1, WindowMsgData mData2 )
  308. {
  309. switch( msg )
  310. {
  311. // --------------------------------------------------------------------------------------------
  312. case GWM_CREATE:
  313. {
  314. break;
  315. } // end create
  316. //---------------------------------------------------------------------------------------------
  317. case GWM_DESTROY:
  318. {
  319. NullifyControls();
  320. break;
  321. } // end case
  322. // --------------------------------------------------------------------------------------------
  323. case GWM_INPUT_FOCUS:
  324. {
  325. // if we're givin the opportunity to take the keyboard focus we must say we want it
  326. if( mData1 == TRUE )
  327. *(Bool *)mData2 = TRUE;
  328. return MSG_HANDLED;
  329. } // end input
  330. //---------------------------------------------------------------------------------------------
  331. case GLM_DOUBLE_CLICKED:
  332. {
  333. GameWindow *control = (GameWindow *)mData1;
  334. Int controlID = control->winGetWindowId();
  335. if( controlID == listboxMap )
  336. {
  337. int rowSelected = mData2;
  338. if (rowSelected >= 0)
  339. {
  340. GadgetListBoxSetSelected( control, rowSelected );
  341. GameWindow *button = TheWindowManager->winGetWindowFromId( window, buttonOK );
  342. TheWindowManager->winSendSystemMsg( window, GBM_SELECTED,
  343. (WindowMsgData)button, buttonOK );
  344. }
  345. }
  346. break;
  347. }
  348. //---------------------------------------------------------------------------------------------
  349. case GLM_SELECTED:
  350. {
  351. GameWindow *mapWindow = TheWindowManager->winGetWindowFromId( parent, listboxMap );
  352. GameWindow *control = (GameWindow *)mData1;
  353. Int controlID = control->winGetWindowId();
  354. if( controlID == listboxMap )
  355. {
  356. int rowSelected = mData2;
  357. if( rowSelected < 0 )
  358. {
  359. positionStartSpots( AsciiString::TheEmptyString, buttonMapStartPosition, winMapPreview);
  360. //winMapPreview->winClearStatus(WIN_STATUS_IMAGE);
  361. break;
  362. }
  363. winMapPreview->winSetStatus(WIN_STATUS_IMAGE);
  364. UnicodeString map;
  365. // get text of the map to load
  366. map = GadgetListBoxGetText( mapWindow, rowSelected, 0 );
  367. // set the map name in the global data map name
  368. AsciiString asciiMap;
  369. const char *mapFname = (const char *)GadgetListBoxGetItemData( mapWindow, rowSelected );
  370. DEBUG_ASSERTCRASH(mapFname, ("No map item data"));
  371. if (mapFname)
  372. asciiMap = mapFname;
  373. else
  374. asciiMap.translate( map );
  375. asciiMap.toLower();
  376. Image *image = getMapPreviewImage(asciiMap);
  377. winMapPreview->winSetUserData((void *)TheMapCache->findMap(asciiMap));
  378. if(image)
  379. {
  380. winMapPreview->winSetEnabledImage(0, image);
  381. }
  382. else
  383. {
  384. winMapPreview->winClearStatus(WIN_STATUS_IMAGE);
  385. }
  386. positionStartSpots( asciiMap, buttonMapStartPosition, winMapPreview);
  387. }
  388. break;
  389. }
  390. //---------------------------------------------------------------------------------------------
  391. case GBM_SELECTED:
  392. {
  393. // this isn't fixed yet
  394. GameWindow *control = (GameWindow *)mData1;
  395. Int controlID = control->winGetWindowId();
  396. if ( controlID == radioButtonSystemMapsID )
  397. {
  398. if (TheMapCache)
  399. TheMapCache->updateCache();
  400. populateMapListbox( mapList, TRUE, TRUE, TheSkirmishGameInfo->getMap() );
  401. //LANPreferences pref;
  402. //pref["UseSystemMapDir"] = "yes";
  403. //pref.write();
  404. }
  405. else if ( controlID == radioButtonUserMapsID )
  406. {
  407. if (TheMapCache)
  408. TheMapCache->updateCache();
  409. populateMapListbox( mapList, FALSE, FALSE, TheSkirmishGameInfo->getMap() );
  410. populateMapListboxNoReset( mapList, FALSE, TRUE, TheSkirmishGameInfo->getMap() );
  411. //LANPreferences pref;
  412. //pref["UseSystemMapDir"] = "no";
  413. //pref.write();
  414. }
  415. else if ( controlID == buttonBack )
  416. {
  417. showSkirmishGameOptionsUnderlyingGUIElements(TRUE);
  418. skirmishMapSelectLayout->destroyWindows();
  419. skirmishMapSelectLayout->deleteInstance();
  420. skirmishMapSelectLayout = NULL;
  421. skirmishPositionStartSpots();
  422. //TheShell->pop();
  423. //do you need this ??
  424. //PostToLanGameOptions( MAP_BACK );
  425. } // end if
  426. else if ( controlID == buttonOK )
  427. {
  428. Int selected;
  429. UnicodeString map;
  430. GameWindow *mapWindow = TheWindowManager->winGetWindowFromId( parent, listboxMap );
  431. // get the selected index
  432. GadgetListBoxGetSelected( mapWindow, &selected );
  433. if( selected != -1 )
  434. {
  435. //buttonPushed = true;
  436. // set the map name in the global data map name
  437. AsciiString asciiMap;
  438. const char *mapFname = (const char *)GadgetListBoxGetItemData( mapWindow, selected );
  439. DEBUG_ASSERTCRASH(mapFname, ("No map item data"));
  440. if (mapFname)
  441. asciiMap = mapFname;
  442. else
  443. asciiMap.translate( map );
  444. TheSkirmishGameInfo->setMap( asciiMap );
  445. const MapMetaData *md = TheMapCache->findMap(asciiMap);
  446. if (!md)
  447. {
  448. TheSkirmishGameInfo->setMapCRC(0);
  449. TheSkirmishGameInfo->setMapSize(0);
  450. }
  451. else
  452. {
  453. TheSkirmishGameInfo->setMapCRC(md->m_CRC);
  454. TheSkirmishGameInfo->setMapSize(md->m_filesize);
  455. }
  456. // reset the start positions
  457. for(Int i = 0; i < MAX_SLOTS; ++i)
  458. TheSkirmishGameInfo->getSlot(i)->setStartPos(-1);
  459. GameWindow *win;
  460. win = TheWindowManager->winGetWindowFromId( parent, TheNameKeyGenerator->nameToKey("SkirmishGameOptionsMenu.wnd:TextEntryMapDisplay") );
  461. if(win)
  462. {
  463. if (md)
  464. {
  465. GadgetStaticTextSetText(win, md->m_displayName);
  466. }
  467. }
  468. //if (mapFname)
  469. //setupGameStart(mapFname);
  470. showSkirmishGameOptionsUnderlyingGUIElements(TRUE);
  471. skirmishPositionStartSpots();
  472. skirmishUpdateSlotList();
  473. skirmishMapSelectLayout->destroyWindows();
  474. skirmishMapSelectLayout->deleteInstance();
  475. skirmishMapSelectLayout = NULL;
  476. //TheShell->pop();
  477. } // end if
  478. } // end else if
  479. break;
  480. } // end selected
  481. default:
  482. return MSG_IGNORED;
  483. } // end switch
  484. return MSG_HANDLED;
  485. } // end SkirmishMapSelectMenuSystem*/