QuitMenu.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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: QuitMenu.cpp /////////////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, October 2001
  25. // Description: Quit 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/GameState.h"
  31. #include "Common/MessageStream.h"
  32. #include "Common/Player.h"
  33. #include "Common/PlayerList.h"
  34. #include "Common/RandomValue.h"
  35. #include "Common/Recorder.h"
  36. #include "GameClient/GUICallbacks.h"
  37. #include "GameClient/WindowLayout.h"
  38. #include "GameClient/GameWindowManager.h"
  39. #include "GameClient/Gadget.h"
  40. #include "GameClient/GadgetPushButton.h"
  41. #include "GameClient/GameText.h"
  42. #include "GameClient/MessageBox.h"
  43. #include "GameClient/Shell.h"
  44. #include "GameClient/InGameUI.h"
  45. #include "GameLogic/GameLogic.h"
  46. #include "GameLogic/VictoryConditions.h"
  47. #include "GameClient/ControlBar.h"
  48. #include "GameClient/GameWindowTransitions.h"
  49. #include "GameClient/DisconnectMenu.h"
  50. #include "GameLogic/ScriptEngine.h"
  51. #ifdef _INTERNAL
  52. // for occasional debugging...
  53. //#pragma optimize("", off)
  54. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  55. #endif
  56. // PRIVATE DATA ///////////////////////////////////////////////////////////////////////////////////
  57. static WindowLayout *quitMenuLayout = NULL;
  58. static WindowLayout *fullQuitMenuLayout = NULL;
  59. static WindowLayout *noSaveLoadQuitMenuLayout = NULL;
  60. static Bool isVisible = FALSE;
  61. static GameWindow *quitConfirmationWindow = NULL;
  62. //external declarations of the Gadgets the callbacks can use
  63. static WindowLayout *saveLoadMenuLayout = NULL;
  64. static GameWindow *buttonRestartWin = NULL;
  65. static GameWindow *buttonSaveLoadWin = NULL;
  66. static GameWindow *buttonOptionsWin = NULL;
  67. static GameWindow *buttonExitWin = NULL;
  68. static NameKeyType buttonExit = NAMEKEY_INVALID;
  69. static NameKeyType buttonRestart = NAMEKEY_INVALID;
  70. static NameKeyType buttonReturn = NAMEKEY_INVALID;
  71. static NameKeyType buttonOptions = NAMEKEY_INVALID;
  72. static NameKeyType buttonSaveLoad = NAMEKEY_INVALID;
  73. static void initGadgetsFullQuit( void )
  74. {
  75. buttonExit = TheNameKeyGenerator->nameToKey( AsciiString( "QuitMenu.wnd:ButtonExit" ) );
  76. buttonRestart = TheNameKeyGenerator->nameToKey( AsciiString( "QuitMenu.wnd:ButtonRestart" ) );
  77. buttonReturn = TheNameKeyGenerator->nameToKey( AsciiString( "QuitMenu.wnd:ButtonReturn" ) );
  78. buttonOptions = TheNameKeyGenerator->nameToKey( AsciiString( "QuitMenu.wnd:ButtonOptions" ) );
  79. buttonSaveLoad = TheNameKeyGenerator->nameToKey( AsciiString( "QuitMenu.wnd:ButtonSaveLoad" ) );
  80. buttonRestartWin = TheWindowManager->winGetWindowFromId( NULL, buttonRestart );
  81. buttonSaveLoadWin = TheWindowManager->winGetWindowFromId( NULL, buttonSaveLoad );
  82. buttonOptionsWin = TheWindowManager->winGetWindowFromId( NULL, buttonOptions );
  83. buttonExitWin = TheWindowManager->winGetWindowFromId( NULL, buttonExit );
  84. }
  85. static void initGadgetsNoSaveQuit( void )
  86. {
  87. buttonExit = TheNameKeyGenerator->nameToKey( AsciiString( "QuitNoSave.wnd:ButtonExit" ) );
  88. buttonRestart = TheNameKeyGenerator->nameToKey( AsciiString( "QuitNoSave.wnd:ButtonRestart" ) );
  89. buttonReturn = TheNameKeyGenerator->nameToKey( AsciiString( "QuitNoSave.wnd:ButtonReturn" ) );
  90. buttonOptions = TheNameKeyGenerator->nameToKey( AsciiString( "QuitNoSave.wnd:ButtonOptions" ) );
  91. buttonSaveLoad = NAMEKEY_INVALID;
  92. buttonRestartWin = TheWindowManager->winGetWindowFromId( NULL, buttonRestart );
  93. buttonOptionsWin = TheWindowManager->winGetWindowFromId( NULL, buttonOptions );
  94. buttonSaveLoadWin = NULL;
  95. buttonExitWin = TheWindowManager->winGetWindowFromId( NULL, buttonExit );
  96. }
  97. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////////////////////////
  98. void destroyQuitMenu()
  99. {
  100. // destroy the quit menu
  101. quitConfirmationWindow = NULL;
  102. if(fullQuitMenuLayout)
  103. {
  104. fullQuitMenuLayout->destroyWindows();
  105. fullQuitMenuLayout->deleteInstance();
  106. }
  107. fullQuitMenuLayout = NULL;
  108. if(noSaveLoadQuitMenuLayout)
  109. {
  110. noSaveLoadQuitMenuLayout->destroyWindows();
  111. noSaveLoadQuitMenuLayout->deleteInstance();
  112. }
  113. noSaveLoadQuitMenuLayout = NULL;
  114. quitMenuLayout = NULL;
  115. isVisible = FALSE;
  116. }
  117. /**
  118. * quits the program
  119. */
  120. static void exitQuitMenu()
  121. {
  122. // destroy the quit menu
  123. destroyQuitMenu();
  124. // clear out all the game data
  125. if ( TheGameLogic->isInMultiplayerGame() && !TheGameLogic->isInSkirmishGame() && !TheGameInfo->isSandbox() )
  126. {
  127. GameMessage *msg = TheMessageStream->appendMessage(GameMessage::MSG_SELF_DESTRUCT);
  128. msg->appendBooleanArgument(TRUE);
  129. }
  130. /*GameMessage *msg =*/ TheMessageStream->appendMessage( GameMessage::MSG_CLEAR_GAME_DATA );
  131. if ( !TheGameLogic->isInMultiplayerGame() )
  132. TheGameLogic->setGamePaused(FALSE);
  133. // TheGameLogic->clearGameData();
  134. // display the menu on top of the shell stack
  135. // TheShell->showShell();
  136. // this will trigger an exit
  137. // TheGameEngine->setQuitting( TRUE );
  138. TheInGameUI->setClientQuiet( TRUE );
  139. }
  140. static void noExitQuitMenu()
  141. {
  142. quitConfirmationWindow = NULL;
  143. }
  144. static void quitToDesktopQuitMenu()
  145. {
  146. // destroy the quit menu
  147. destroyQuitMenu();
  148. if (TheGameLogic->isInGame())
  149. {
  150. if (TheRecorder->getMode() == RECORDERMODETYPE_RECORD)
  151. {
  152. TheRecorder->stopRecording();
  153. }
  154. TheGameLogic->clearGameData();
  155. }
  156. TheGameEngine->setQuitting(TRUE);
  157. TheInGameUI->setClientQuiet( TRUE );
  158. }
  159. static void surrenderQuitMenu()
  160. {
  161. // destroy the quit menu
  162. destroyQuitMenu();
  163. if (TheVictoryConditions->isLocalAlliedVictory())
  164. return;
  165. GameMessage *msg = TheMessageStream->appendMessage(GameMessage::MSG_SELF_DESTRUCT);
  166. msg->appendBooleanArgument(TRUE);
  167. TheInGameUI->setClientQuiet( TRUE );
  168. }
  169. static void restartMissionMenu()
  170. {
  171. // destroy the quit menu
  172. destroyQuitMenu();
  173. Int gameMode = TheGameLogic->getGameMode();
  174. AsciiString mapName = TheGlobalData->m_mapName;
  175. //
  176. // if the map name was from a save game it will have "Save/" at the front of it,
  177. // we want to go back to the original pristine map string for the map name when restarting
  178. //
  179. if (TheGameState->isInSaveDirectory(mapName))
  180. mapName = TheGameState->getPristineMapName();
  181. // End the current game
  182. AsciiString replayFile = TheRecorder->getCurrentReplayFilename();
  183. if (TheRecorder->getMode() == RECORDERMODETYPE_RECORD)
  184. {
  185. TheRecorder->stopRecording();
  186. }
  187. Int rankPointsStartedWith = TheGameLogic->getRankPointsToAddAtGameStart();// must write down before reset
  188. GameDifficulty diff = TheScriptEngine->getGlobalDifficulty();
  189. Int fps = TheGameEngine->getFramesPerSecondLimit();
  190. TheGameLogic->clearGameData(FALSE);
  191. TheGameEngine->setQuitting(FALSE);
  192. if (replayFile.isNotEmpty())
  193. {
  194. TheRecorder->playbackFile(replayFile);
  195. }
  196. else
  197. {
  198. // send a message to the logic for a new game
  199. TheWritableGlobalData->m_pendingFile = mapName;
  200. GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_NEW_GAME );
  201. msg->appendIntegerArgument(gameMode);
  202. msg->appendIntegerArgument(diff);
  203. msg->appendIntegerArgument(rankPointsStartedWith);
  204. msg->appendIntegerArgument(fps);
  205. DEBUG_LOG(("Restarting game mode %d, Diff=%d, RankPoints=%d\n", gameMode,
  206. TheScriptEngine->getGlobalDifficulty(),
  207. rankPointsStartedWith)
  208. );
  209. //if (TheGlobalData->m_fixedSeed >= 0)
  210. //InitRandom(TheGlobalData->m_fixedSeed);
  211. InitRandom(0);
  212. //else
  213. // InitGameLogicRandom(GameClientRandomValue(0, INT_MAX - 1));
  214. }
  215. //TheTransitionHandler->remove("QuitFull"); //KRISMORNESS ADD
  216. //quitMenuLayout = NULL; //KRISMORNESS ADD
  217. //isVisible = TRUE; //KRISMORNESS ADD
  218. //HideQuitMenu(); //KRISMORNESS ADD
  219. TheInGameUI->setClientQuiet( TRUE );
  220. }
  221. //-------------------------------------------------------------------------------------------------
  222. //-------------------------------------------------------------------------------------------------
  223. void HideQuitMenu( void )
  224. {
  225. // Note: This is called as a safety a lot, without checking for the prescence of the quit menu.
  226. // So don't do anything that counts on that menu actually being here.
  227. if(!isVisible)
  228. return;
  229. if(quitMenuLayout && quitMenuLayout == noSaveLoadQuitMenuLayout)
  230. TheTransitionHandler->reverse("QuitNoSaveBack");
  231. else if( quitMenuLayout && quitMenuLayout == fullQuitMenuLayout)
  232. TheTransitionHandler->reverse("QuitFullBack");
  233. TheInGameUI->setQuitMenuVisible( FALSE );
  234. isVisible = FALSE;
  235. if (quitConfirmationWindow)
  236. TheWindowManager->winDestroy(quitConfirmationWindow);
  237. quitConfirmationWindow = NULL;
  238. if ( !TheGameLogic->isInMultiplayerGame() )
  239. TheGameLogic->setGamePaused(FALSE);
  240. }
  241. //-------------------------------------------------------------------------------------------------
  242. /** Toggle visibility of the quit menu */
  243. //-------------------------------------------------------------------------------------------------
  244. void ToggleQuitMenu()
  245. {
  246. //Added By Sadullah Nader
  247. //Added a check to see if we're not in game yet
  248. if (TheGameLogic->isIntroMoviePlaying() || TheGameLogic->isLoadingMap() ||TheScriptEngine->isGameEnding())
  249. return;
  250. //End Add
  251. // BGC- If we are currently in the disconnect screen, don't let the quit menu come up.
  252. if (TheDisconnectMenu != NULL) {
  253. if (TheDisconnectMenu->isScreenVisible() == TRUE) {
  254. return;
  255. }
  256. }
  257. // BGC- this is kind of hackish, but its the safest way to do it I think.
  258. // Basically we're seeing if either the save/load window or the options window is up
  259. // and if one of them is, we quit out of them rather than toggle the quit menu.
  260. if (TheShell->getOptionsLayout(FALSE) != FALSE) {
  261. WindowLayout *optLayout = TheShell->getOptionsLayout(FALSE);
  262. GameWindow *optionsParent = optLayout->getFirstWindow();
  263. DEBUG_ASSERTCRASH(optionsParent != NULL, ("Not able to get the options layout parent window"));
  264. GameWindow *optionsBack = TheWindowManager->winGetWindowFromId(optionsParent, TheNameKeyGenerator->nameToKey( AsciiString( "OptionsMenu.wnd:ButtonBack" ) ));
  265. DEBUG_ASSERTCRASH(optionsBack != NULL, ("Not able to get the back button window from the options menu"));
  266. TheWindowManager->winSendSystemMsg(optLayout->getFirstWindow(), GBM_SELECTED, (WindowMsgData)optionsBack, NULL);
  267. return;
  268. }
  269. if ((saveLoadMenuLayout != NULL) && (saveLoadMenuLayout->isHidden() == FALSE))
  270. {
  271. GameWindow *saveLoadParent = saveLoadMenuLayout->getFirstWindow();
  272. DEBUG_ASSERTCRASH(saveLoadParent != NULL, ("Not able to get the save/load layout parent window"));
  273. GameWindow *saveLoadBack = TheWindowManager->winGetWindowFromId(saveLoadParent, TheNameKeyGenerator->nameToKey( AsciiString( "PopupSaveLoad.wnd:ButtonBack" ) ));
  274. DEBUG_ASSERTCRASH(saveLoadBack != NULL, ("Not able to get the back button window from the save/load menu"));
  275. TheWindowManager->winSendSystemMsg(saveLoadMenuLayout->getFirstWindow(), GBM_SELECTED, (WindowMsgData)saveLoadBack, NULL);
  276. saveLoadMenuLayout = NULL;
  277. return;
  278. }
  279. // if we're visable hide our quit menu
  280. if(isVisible && quitMenuLayout)
  281. {
  282. isVisible = FALSE;
  283. //Added By Sadullah Nader
  284. //Bug: When Toggling the quit menu off, the quit confirmation should also go away
  285. if (quitConfirmationWindow)
  286. TheWindowManager->winDestroy(quitConfirmationWindow);
  287. quitConfirmationWindow = NULL;
  288. //
  289. if ( !TheGameLogic->isInMultiplayerGame() )
  290. TheGameLogic->setGamePaused(FALSE);
  291. if(quitMenuLayout && quitMenuLayout == noSaveLoadQuitMenuLayout)
  292. TheTransitionHandler->reverse("QuitNoSaveBack");
  293. else if( quitMenuLayout && quitMenuLayout == fullQuitMenuLayout )
  294. {
  295. TheTransitionHandler->reverse("QuitFullBack");
  296. //begin KRISMORNESS
  297. //TheTransitionHandler->reverse("QuitFull");
  298. //if( TheTransitionHandler->areTransitionsEnabled() )
  299. //else
  300. //{
  301. // TheTransitionHandler->remove("QuitFull");
  302. // quitMenuLayout = NULL;
  303. // isVisible = TRUE;
  304. // HideQuitMenu();
  305. //}
  306. //end KRISMORNESS
  307. }
  308. }
  309. else
  310. {
  311. //Added By Sadullah Nader
  312. //Added to compensate for the quit confirmation window pop-up
  313. TheMouse->setCursor( Mouse::ARROW );
  314. TheControlBar->hidePurchaseScience();
  315. if ( TheGameLogic->isInMultiplayerGame() || TheGameLogic->isInReplayGame() )
  316. {
  317. // we don't want to show the save load button.
  318. if(!noSaveLoadQuitMenuLayout)
  319. noSaveLoadQuitMenuLayout = TheWindowManager->winCreateLayout( AsciiString( "Menus/QuitNoSave.wnd" ) );
  320. quitMenuLayout = noSaveLoadQuitMenuLayout;
  321. initGadgetsNoSaveQuit();
  322. TheTransitionHandler->remove("QuitNoSave");
  323. TheTransitionHandler->setGroup("QuitNoSave");
  324. }
  325. else
  326. {
  327. if(!fullQuitMenuLayout)
  328. fullQuitMenuLayout= TheWindowManager->winCreateLayout( AsciiString( "Menus/QuitMenu.wnd" ) );
  329. quitMenuLayout = fullQuitMenuLayout;
  330. initGadgetsFullQuit();
  331. TheTransitionHandler->remove("QuitFull");
  332. TheTransitionHandler->setGroup("QuitFull");
  333. }
  334. // load the quit menu from the layout file if needed
  335. if( quitMenuLayout == NULL )
  336. {
  337. DEBUG_ASSERTCRASH(FALSE, ("Could not load a quit menu layout"));
  338. isVisible = FALSE;
  339. TheInGameUI->setQuitMenuVisible(FALSE);
  340. return;
  341. }
  342. //quitMenuLayout->hide(FALSE);
  343. // if we are watching a cinematic, we need to disable the save/load button
  344. // because the save load window doesn't fit in the screen in letterbox mode.
  345. if (TheInGameUI->getInputEnabled() == FALSE) {
  346. if(buttonSaveLoadWin)
  347. buttonSaveLoadWin->winEnable(FALSE);
  348. buttonOptionsWin->winEnable(FALSE);
  349. } else if (buttonSaveLoadWin)
  350. {
  351. if(buttonSaveLoadWin)
  352. buttonSaveLoadWin->winEnable(TRUE);
  353. buttonOptionsWin->winEnable(TRUE);
  354. }
  355. // Disable the restart, load, save, etc buttons in network games
  356. if ( TheGameLogic->isInMultiplayerGame() || TheGameLogic->isInSkirmishGame() )
  357. {
  358. buttonRestartWin->winEnable(TRUE);
  359. if (TheGameLogic->isInSkirmishGame() == FALSE) {
  360. GadgetButtonSetText(buttonRestartWin, TheGameText->fetch("GUI:Surrender"));
  361. }
  362. if (TheGameLogic->isInSkirmishGame() == TRUE) {
  363. TheGameLogic->setGamePaused(TRUE);
  364. }
  365. if ((!ThePlayerList->getLocalPlayer()->isPlayerActive() || TheVictoryConditions->isLocalAlliedVictory()) &&
  366. (TheGameLogic->isInSkirmishGame() == FALSE))
  367. {
  368. buttonRestartWin->winEnable(FALSE); // can't surrender when you're dead
  369. }
  370. }
  371. else
  372. {
  373. buttonRestartWin->winEnable(TRUE);
  374. if(!TheGameLogic->isInReplayGame())
  375. {
  376. GadgetButtonSetText(buttonRestartWin, TheGameText->fetch("GUI:RestartMission"));
  377. GadgetButtonSetText(buttonExitWin, TheGameText->fetch("GUI:ExitMission"));
  378. }
  379. //if we're not in a multiplayer game, pause the game
  380. TheGameLogic->setGamePaused(TRUE);
  381. }
  382. if (quitConfirmationWindow)
  383. TheWindowManager->winDestroy(quitConfirmationWindow);
  384. quitConfirmationWindow = NULL;
  385. HideDiplomacy();
  386. HideInGameChat();
  387. TheControlBar->hidePurchaseScience();
  388. isVisible = TRUE;
  389. }
  390. TheInGameUI->setQuitMenuVisible(isVisible);
  391. } // end ToggleQuitMenu
  392. //-------------------------------------------------------------------------------------------------
  393. /** Quit menu window system callback */
  394. //-------------------------------------------------------------------------------------------------
  395. WindowMsgHandledType QuitMenuSystem( GameWindow *window, UnsignedInt msg,
  396. WindowMsgData mData1, WindowMsgData mData2 )
  397. {
  398. switch( msg )
  399. {
  400. // --------------------------------------------------------------------------------------------
  401. case GWM_CREATE:
  402. {
  403. break;
  404. } // end create
  405. //---------------------------------------------------------------------------------------------
  406. case GWM_DESTROY:
  407. {
  408. break;
  409. } // end case
  410. //---------------------------------------------------------------------------------------------
  411. case GBM_SELECTED:
  412. {
  413. GameWindow *control = (GameWindow *)mData1;
  414. Int controlID = control->winGetWindowId();
  415. if( controlID == buttonSaveLoad )
  416. {
  417. //
  418. // these commented lines (12-11-2002) will allow access to load only when were
  419. // viewing an in-game cinema ... but it's brittle, so I'm disableing it for
  420. // now and just using the grey button for the whole save/load button for now
  421. // during a cinema
  422. //
  423. // SaveLoadLayoutType layoutType = SLLT_SAVE_AND_LOAD;
  424. //
  425. // if input is disabled we are in an in-game cinematic and can load only, since we
  426. // are in the quit menu we are paused and therefore input is disabled all
  427. // the time ... in order to figure out if the *game* has input disabled we need
  428. // to query for the input enabled memory in the game logic which represents the
  429. // input enabled status of the game if we were not currently paused
  430. //
  431. // if( TheGameLogic->getInputEnabledMemory() == FALSE )
  432. // layoutType = SLLT_LOAD_ONLY;
  433. saveLoadMenuLayout = TheShell->getSaveLoadMenuLayout();
  434. // saveLoadMenuLayout->runInit( &layoutType );
  435. saveLoadMenuLayout->runInit();
  436. saveLoadMenuLayout->hide( FALSE );
  437. saveLoadMenuLayout->bringForward();
  438. }
  439. else if( controlID == buttonExit )
  440. {
  441. quitConfirmationWindow = QuitMessageBoxYesNo(TheGameText->fetch("GUI:QuitPopupTitle"), TheGameText->fetch("GUI:QuitPopupMessage"),/*quitCallback*/exitQuitMenu,noExitQuitMenu);
  442. } // end if
  443. else if( controlID == buttonReturn )
  444. {
  445. // hide this menu
  446. ToggleQuitMenu();
  447. } // end else if
  448. else if( buttonOptions == controlID )
  449. {
  450. WindowLayout *optLayout = TheShell->getOptionsLayout(TRUE);
  451. DEBUG_ASSERTCRASH(optLayout != NULL, ("options menu layout is NULL"));
  452. optLayout->runInit();
  453. optLayout->hide(FALSE);
  454. optLayout->bringForward();
  455. }
  456. // else if( controlID == buttonQuitToDesktop )
  457. // {
  458. // quitConfirmationWindow = MessageBoxYesNo(TheGameText->fetch("GUI:QuitPopupTitle"), TheGameText->fetch("GUI:QuitToDesktopConf"),/*quitCallback*/quitToDesktopQuitMenu,noExitQuitMenu);
  459. //
  460. // } // end else if
  461. else if( controlID == buttonRestart )
  462. {
  463. if ( TheGameLogic->isInMultiplayerGame() )
  464. {
  465. // we really want to surrender
  466. quitConfirmationWindow = MessageBoxYesNo(TheGameText->fetch("GUI:SurrenderConfirmationTitle"),
  467. TheGameText->fetch("GUI:SurrenderConfirmation"),
  468. /*quitCallback*/surrenderQuitMenu,noExitQuitMenu);
  469. }
  470. else
  471. {
  472. //we really want to restart
  473. quitConfirmationWindow = MessageBoxYesNo(TheGameText->fetch("GUI:RestartConfirmationTitle"),
  474. TheGameText->fetch("GUI:RestartConfirmation"),
  475. /*quitCallback*/restartMissionMenu,noExitQuitMenu);
  476. }
  477. } // end else if
  478. break;
  479. } // end selected
  480. default:
  481. return MSG_IGNORED;
  482. } // end switch
  483. return MSG_HANDLED;
  484. } // end QuitMenuSystem