MainMenu.cpp 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735
  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: MainMenu.cpp /////////////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, October 2001
  25. // Description: Main menu window callbacks
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #include "GameSpy/ghttp/ghttp.h"
  30. #include "Lib/BaseType.h"
  31. #include "Common/GameEngine.h"
  32. #include "Common/GameState.h"
  33. #include "Common/GlobalData.h"
  34. #include "Common/NameKeyGenerator.h"
  35. #include "Common/RandomValue.h"
  36. #include "Common/UserPreferences.h"
  37. #include "Common/Version.h"
  38. #include "Common/GameLOD.h"
  39. #include "GameClient/AnimateWindowManager.h"
  40. #include "GameClient/ExtendedMessageBox.h"
  41. #include "GameClient/MessageBox.h"
  42. #include "GameClient/Display.h"
  43. #include "GameClient/WindowLayout.h"
  44. #include "GameClient/Gadget.h"
  45. #include "GameClient/GameText.h"
  46. #include "GameClient/HeaderTemplate.h"
  47. #include "GameClient/MapUtil.h"
  48. #include "GameClient/Shell.h"
  49. #include "GameClient/ShellHooks.h"
  50. #include "GameClient/KeyDefs.h"
  51. #include "GameClient/GameWindowManager.h"
  52. #include "GameClient/GadgetStaticText.h"
  53. #include "GameClient/Mouse.h"
  54. #include "GameClient/WindowVideoManager.h"
  55. #include "GameClient/CampaignManager.h"
  56. #include "GameClient/HotKey.h"
  57. #include "GameClient/GameClient.h"
  58. #include "GameLogic/GameLogic.h"
  59. #include "GameLogic/ScriptEngine.h"
  60. #include "GameNetwork/GameSpyOverlay.h"
  61. #include "GameClient/GameWindowTransitions.h"
  62. #include "GameClient/ChallengeGenerals.h"
  63. #include "GameNetwork/GameSpy/PeerDefs.h"
  64. #include "GameNetwork/GameSpy/PeerThread.h"
  65. #include "GameNetwork/GameSpy/BuddyThread.h"
  66. #include "GameNetwork/DownloadManager.h"
  67. #include "GameNetwork/GameSpy/MainMenuUtils.h"
  68. #include "GameClient/CDCheck.h"
  69. //Added By Saad
  70. //for accessing the InGameUI
  71. #include "GameClient/InGameUI.h"
  72. #ifdef _INTERNAL
  73. // for occasional debugging...
  74. //#pragma optimize("", off)
  75. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  76. #endif
  77. // PRIVATE DATA ///////////////////////////////////////////////////////////////////////////////////
  78. enum
  79. {
  80. DROPDOWN_NONE = 0,
  81. DROPDOWN_SINGLE,
  82. DROPDOWN_MULTIPLAYER,
  83. DROPDOWN_MAIN,
  84. DROPDOWN_LOADREPLAY,
  85. DROPDOWN_DIFFICULTY,
  86. DROPDOWN_COUNT // keep last
  87. };
  88. static Bool raiseMessageBoxes = TRUE;
  89. static Bool campaignSelected = FALSE;
  90. #if defined _DEBUG || defined _INTERNAL || defined _PROFILE
  91. static NameKeyType campaignID = NAMEKEY_INVALID;
  92. static GameWindow *buttonCampaign = NULL;
  93. #ifdef TEST_COMPRESSION
  94. static GameWindow *buttonCompressTest = NULL;
  95. void DoCompressTest( void );
  96. #endif // TEST_COMPRESSION
  97. #endif
  98. // window ids -------------------------------------------------------------------------------------
  99. static NameKeyType mainMenuID = NAMEKEY_INVALID;
  100. static NameKeyType skirmishID = NAMEKEY_INVALID;
  101. static NameKeyType onlineID = NAMEKEY_INVALID;
  102. static NameKeyType networkID = NAMEKEY_INVALID;
  103. static NameKeyType optionsID = NAMEKEY_INVALID;
  104. static NameKeyType exitID = NAMEKEY_INVALID;
  105. static NameKeyType motdID = NAMEKEY_INVALID;
  106. static NameKeyType worldBuilderID = NAMEKEY_INVALID;
  107. static NameKeyType getUpdateID = NAMEKEY_INVALID;
  108. static NameKeyType buttonTRAININGID = NAMEKEY_INVALID;
  109. static NameKeyType buttonChallengeID = NAMEKEY_INVALID;
  110. static NameKeyType buttonUSAID = NAMEKEY_INVALID;
  111. static NameKeyType buttonGLAID = NAMEKEY_INVALID;
  112. static NameKeyType buttonChinaID = NAMEKEY_INVALID;
  113. static NameKeyType buttonUSARecentSaveID = NAMEKEY_INVALID;
  114. static NameKeyType buttonUSALoadGameID = NAMEKEY_INVALID;
  115. static NameKeyType buttonGLARecentSaveID = NAMEKEY_INVALID;
  116. static NameKeyType buttonGLALoadGameID = NAMEKEY_INVALID;
  117. static NameKeyType buttonChinaRecentSaveID = NAMEKEY_INVALID;
  118. static NameKeyType buttonChinaLoadGameID = NAMEKEY_INVALID;
  119. static NameKeyType buttonSinglePlayerID = NAMEKEY_INVALID;
  120. static NameKeyType buttonMultiPlayerID = NAMEKEY_INVALID;
  121. static NameKeyType buttonMultiBackID = NAMEKEY_INVALID;
  122. static NameKeyType buttonSingleBackID = NAMEKEY_INVALID;
  123. static NameKeyType buttonLoadReplayBackID = NAMEKEY_INVALID;
  124. static NameKeyType buttonReplayID = NAMEKEY_INVALID;
  125. static NameKeyType buttonLoadReplayID = NAMEKEY_INVALID;
  126. static NameKeyType buttonLoadID = NAMEKEY_INVALID;
  127. static NameKeyType buttonCreditsID = NAMEKEY_INVALID;
  128. static NameKeyType buttonEasyID = NAMEKEY_INVALID;
  129. static NameKeyType buttonMediumID = NAMEKEY_INVALID;
  130. static NameKeyType buttonHardID = NAMEKEY_INVALID;
  131. static NameKeyType buttonDiffBackID = NAMEKEY_INVALID;
  132. // window pointers --------------------------------------------------------------------------------
  133. static GameWindow *parentMainMenu = NULL;
  134. static GameWindow *buttonSinglePlayer = NULL;
  135. static GameWindow *buttonMultiPlayer = NULL;
  136. static GameWindow *buttonSkirmish = NULL;
  137. static GameWindow *buttonOnline = NULL;
  138. static GameWindow *buttonNetwork = NULL;
  139. static GameWindow *buttonOptions = NULL;
  140. static GameWindow *buttonExit = NULL;
  141. static GameWindow *buttonMOTD = NULL;
  142. static GameWindow *buttonWorldBuilder = NULL;
  143. static GameWindow *mainMenuMovie = NULL;
  144. static GameWindow *getUpdate = NULL;
  145. static GameWindow *buttonTRAINING = NULL;
  146. static GameWindow *buttonChallenge = NULL;
  147. static GameWindow *buttonUSA = NULL;
  148. static GameWindow *buttonGLA = NULL;
  149. static GameWindow *buttonChina = NULL;
  150. static GameWindow *buttonUSARecentSave = NULL;
  151. static GameWindow *buttonUSALoadGame = NULL;
  152. static GameWindow *buttonGLARecentSave = NULL;
  153. static GameWindow *buttonGLALoadGame = NULL;
  154. static GameWindow *buttonChinaRecentSave = NULL;
  155. static GameWindow *buttonChinaLoadGame = NULL;
  156. static GameWindow *buttonReplay = NULL;
  157. static GameWindow *buttonLoadReplay = NULL;
  158. static GameWindow *buttonLoad = NULL;
  159. static GameWindow *buttonCredits = NULL;
  160. static GameWindow *buttonEasy = NULL;
  161. static GameWindow *buttonMedium = NULL;
  162. static GameWindow *buttonHard = NULL;
  163. static GameWindow *buttonDiffBack = NULL;
  164. static GameWindow *dropDownWindows[DROPDOWN_COUNT];
  165. static Bool buttonPushed = FALSE;
  166. static Bool isShuttingDown = FALSE;
  167. static Bool startGame = FALSE;
  168. static Int initialGadgetDelay = 210;
  169. enum
  170. {
  171. SHOW_NONE = 0,
  172. SHOW_TRAINING,
  173. SHOW_USA,
  174. SHOW_GLA,
  175. SHOW_CHINA,
  176. SHOW_SKIRMISH,
  177. SHOW_FRAMES_LIMIT = 20
  178. };
  179. static showFade = FALSE;
  180. static Int dropDown = DROPDOWN_NONE;
  181. static Int pendingDropDown = DROPDOWN_NONE;
  182. static AnimateWindowManager *localAnimateWindowManager = NULL;
  183. static Bool notShown = TRUE;
  184. static Bool FirstTimeRunningTheGame = TRUE;
  185. static Bool showLogo = FALSE;
  186. static Int showFrames = 0;
  187. static Int showSide = SHOW_NONE;
  188. static Bool logoIsShown = FALSE;
  189. static Bool justEntered = FALSE;
  190. static Bool launchChallengeMenu = FALSE;
  191. static Bool dontAllowTransitions = FALSE;
  192. //Added by Saad
  193. const /*Int TIME_OUT = 15,*/ CORNER = 10;
  194. void AcceptResolution();
  195. void DeclineResolution();
  196. GameWindow *resAcceptMenu = NULL;
  197. extern DisplaySettings oldDispSettings, newDispSettings;
  198. extern Bool dispChanged;
  199. //static time_t timeStarted = 0, currentTime = 0;
  200. //
  201. void diffReverseSide( void );
  202. void HandleCanceledDownload( Bool resetDropDown )
  203. {
  204. buttonPushed = FALSE;
  205. if (resetDropDown)
  206. {
  207. dropDownWindows[DROPDOWN_MAIN]->winHide(FALSE);
  208. TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade");
  209. }
  210. }
  211. //-------------------------------------------------------------------------------------------------
  212. /** This is called when a shutdown is complete for this menu */
  213. //-------------------------------------------------------------------------------------------------
  214. static void showSelectiveButtons( Int show )
  215. {
  216. buttonUSARecentSave->winHide(!(show == SHOW_USA ));
  217. buttonUSALoadGame->winHide(!(show == SHOW_USA ));
  218. buttonGLARecentSave->winHide(!(show == SHOW_GLA ));
  219. buttonGLALoadGame->winHide(!(show == SHOW_GLA ));
  220. buttonChinaRecentSave->winHide(!(show == SHOW_CHINA ));
  221. buttonChinaLoadGame->winHide(!(show == SHOW_CHINA ));
  222. }
  223. static void quitCallback( void )
  224. {
  225. buttonPushed = TRUE;
  226. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_EXIT_SELECTED]);
  227. TheShell->pop();
  228. TheGameEngine->setQuitting( TRUE );
  229. //if (!TheGameLODManager->didMemPass())
  230. { //GIANT CRAPTACULAR HACK ALERT!!!! On sytems with little memory, we skip all normal exit code
  231. // //and let Windows clean up the mess. This reduces exit times from minutes to seconds.
  232. // //8-19-03. MW
  233. // delete TheGameClient;
  234. // _exit(EXIT_SUCCESS);
  235. // THE CRAP IS NOW EVEN MORE TACULAR
  236. // NOW WE PERSUADE THE MEMORYPOOLMANAGER TO RETURN STUPID FROM ITS FREE()
  237. // if (TheMemoryPoolFactory) TheMemoryPoolFactory->prepareForMinSpecShutDown();
  238. }
  239. if (TheGameLogic->isInGame())
  240. TheMessageStream->appendMessage( GameMessage::MSG_CLEAR_GAME_DATA );
  241. }
  242. void setupGameStart(AsciiString mapName, GameDifficulty diff)
  243. {
  244. TheCampaignManager->setGameDifficulty(diff);
  245. if (launchChallengeMenu)
  246. {
  247. if (TheChallengeGenerals)
  248. TheChallengeGenerals->setCurrentDifficulty(diff);
  249. campaignSelected = TRUE;
  250. TheShell->push( AsciiString("Menus/ChallengeMenu.wnd") );
  251. TheTransitionHandler->reverse("MainMenuDifficultyMenuTraining");
  252. }
  253. else
  254. {
  255. startGame = TRUE;
  256. TheWritableGlobalData->m_pendingFile = mapName;
  257. TheShell->reverseAnimatewindow();
  258. TheTransitionHandler->setGroup("FadeWholeScreen");
  259. }
  260. }
  261. void prepareCampaignGame(GameDifficulty diff)
  262. {
  263. dontAllowTransitions = TRUE;
  264. OptionPreferences pref;
  265. pref.setCampaignDifficulty(diff);
  266. pref.write();
  267. TheScriptEngine->setGlobalDifficulty(diff);
  268. buttonPushed = FALSE;
  269. TheTransitionHandler->reverse("MainMenuDifficultyMenuBack");
  270. setupGameStart(TheCampaignManager->getCurrentMap(), diff );
  271. }
  272. static MessageBoxReturnType cancelStartBecauseOfNoCD( void *userData )
  273. {
  274. return MB_RETURN_CLOSE;
  275. }
  276. static MessageBoxReturnType checkCDCallback( void *userData )
  277. {
  278. if (!IsFirstCDPresent())
  279. {
  280. return MB_RETURN_KEEPOPEN;
  281. }
  282. else
  283. {
  284. prepareCampaignGame((GameDifficulty)(Int)(Int *)userData);
  285. return MB_RETURN_CLOSE;
  286. }
  287. }
  288. static void doGameStart( void )
  289. {
  290. startGame = FALSE;
  291. if (TheGameLogic->isInGame())
  292. TheGameLogic->clearGameData();
  293. // send a message to the logic for a new game
  294. GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_NEW_GAME );
  295. msg->appendIntegerArgument(GAME_SINGLE_PLAYER);
  296. msg->appendIntegerArgument(TheCampaignManager->getGameDifficulty());
  297. msg->appendIntegerArgument(TheCampaignManager->getRankPoints());
  298. InitRandom(0);
  299. isShuttingDown = TRUE;
  300. }
  301. static void checkCDBeforeCampaign(GameDifficulty diff)
  302. {
  303. if (!IsFirstCDPresent())
  304. {
  305. // popup a dialog asking for a CD
  306. ExMessageBoxOkCancel(TheGameText->fetch("GUI:InsertCDPrompt"), TheGameText->fetch("GUI:InsertCDMessage"),
  307. (void *)diff, checkCDCallback, cancelStartBecauseOfNoCD);
  308. }
  309. else
  310. {
  311. prepareCampaignGame(diff);
  312. }
  313. }
  314. static void shutdownComplete( WindowLayout *layout )
  315. {
  316. isShuttingDown = FALSE;
  317. // hide the layout
  318. layout->hide( TRUE );
  319. // our shutdown is complete
  320. TheShell->shutdownComplete( layout );
  321. } // end if
  322. /*
  323. static void TimetToFileTime( time_t t, LPFILETIME pft )
  324. {
  325. LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000;
  326. pft->dwLowDateTime = (DWORD) ll;
  327. pft->dwHighDateTime = ll >>32;
  328. }
  329. */
  330. void initialHide( void )
  331. {
  332. GameWindow *win = NULL;
  333. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionGLA"));
  334. if(win)
  335. win->winHide(TRUE);
  336. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionChina"));
  337. if(win)
  338. win->winHide(TRUE);
  339. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionUS"));
  340. if(win)
  341. win->winHide(TRUE);
  342. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinGrowMarker"));
  343. if(win)
  344. win->winHide(TRUE);
  345. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionTraining"));
  346. if(win)
  347. win->winHide(TRUE);
  348. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionTrainingSmall"));
  349. if(win)
  350. win->winHide(TRUE);
  351. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionTrainingMedium"));
  352. if(win)
  353. win->winHide(TRUE);
  354. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionSkirmish"));
  355. if(win)
  356. win->winHide(TRUE);
  357. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionSkirmishSmall"));
  358. if(win)
  359. win->winHide(TRUE);
  360. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionSkirmishMedium"));
  361. if(win)
  362. win->winHide(TRUE);
  363. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionUS"));
  364. if(win)
  365. win->winHide(TRUE);
  366. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionUSSmall"));
  367. if(win)
  368. win->winHide(TRUE);
  369. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionUSMedium"));
  370. if(win)
  371. win->winHide(TRUE);
  372. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionGLA"));
  373. if(win)
  374. win->winHide(TRUE);
  375. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionGLASmall"));
  376. if(win)
  377. win->winHide(TRUE);
  378. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionGLAMedium"));
  379. if(win)
  380. win->winHide(TRUE);
  381. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionChina"));
  382. if(win)
  383. win->winHide(TRUE);
  384. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionChinaSmall"));
  385. if(win)
  386. win->winHide(TRUE);
  387. win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionChinaMedium"));
  388. if(win)
  389. win->winHide(TRUE);
  390. }
  391. //-------------------------------------------------------------------------------------------------
  392. /** Initialize the main menu */
  393. //-------------------------------------------------------------------------------------------------
  394. void MainMenuInit( WindowLayout *layout, void *userData )
  395. {
  396. TheWritableGlobalData->m_breakTheMovie = FALSE;
  397. TheShell->showShellMap(TRUE);
  398. TheMouse->setVisibility(TRUE);
  399. //winVidManager = NEW WindowVideoManager;
  400. buttonPushed = FALSE;
  401. isShuttingDown = FALSE;
  402. startGame = FALSE;
  403. dropDown = DROPDOWN_NONE;
  404. pendingDropDown = DROPDOWN_NONE;
  405. for(Int i = 0; i < DROPDOWN_COUNT; ++i)
  406. dropDownWindows[i] = NULL;
  407. // get ids for our windows
  408. mainMenuID = TheNameKeyGenerator->nameToKey( AsciiString( "MainMenu.wnd:MainMenuParent" ) );
  409. // campaignID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonCampaign") );
  410. skirmishID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonSkirmish") );
  411. onlineID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonOnline") );
  412. networkID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonNetwork") );
  413. optionsID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonOptions") );
  414. exitID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonExit") );
  415. motdID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonMOTD") );
  416. worldBuilderID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonWorldBuilder") );
  417. // NameKeyType versionID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:LabelVersion") );
  418. getUpdateID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonGetUpdate") );
  419. // buttonTRAININGID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonTRAINING") );
  420. buttonChallengeID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonChallenge") );
  421. buttonUSAID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonUSA") );
  422. buttonGLAID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonGLA") );
  423. buttonChinaID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonChina") );
  424. buttonUSARecentSaveID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonUSARecentSave") );
  425. buttonUSALoadGameID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonUSALoadGame") );
  426. buttonGLARecentSaveID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonGLARecentSave") );
  427. buttonGLALoadGameID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonGLALoadGame") );
  428. buttonChinaRecentSaveID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonChinaRecentSave") );
  429. buttonChinaLoadGameID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonChinaLoadGame") );
  430. buttonSinglePlayerID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonSinglePlayer") );
  431. buttonMultiPlayerID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonMultiplayer") );
  432. buttonMultiBackID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonMultiBack") );
  433. buttonSingleBackID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonSingleBack") );
  434. buttonLoadReplayBackID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonLoadReplayBack") );
  435. buttonReplayID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonReplay") );
  436. buttonLoadReplayID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonLoadReplay") );
  437. buttonLoadID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonLoadGame") );
  438. buttonCreditsID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonCredits") );
  439. buttonEasyID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonEasy") );
  440. buttonMediumID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonMedium") );
  441. buttonHardID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonHard") );
  442. buttonDiffBackID = TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:ButtonDiffBack") );
  443. // get pointers to the window buttons
  444. parentMainMenu = TheWindowManager->winGetWindowFromId( NULL, mainMenuID );
  445. //buttonCampaign = TheWindowManager->winGetWindowFromId( parentMainMenu, campaignID );
  446. buttonSinglePlayer = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonSinglePlayerID );
  447. buttonMultiPlayer = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonMultiPlayerID );
  448. buttonSkirmish = TheWindowManager->winGetWindowFromId( parentMainMenu, skirmishID );
  449. buttonOnline = TheWindowManager->winGetWindowFromId( parentMainMenu, onlineID );
  450. buttonNetwork = TheWindowManager->winGetWindowFromId( parentMainMenu, networkID );
  451. buttonOptions = TheWindowManager->winGetWindowFromId( parentMainMenu, optionsID );
  452. buttonExit = TheWindowManager->winGetWindowFromId( parentMainMenu, exitID );
  453. buttonMOTD = TheWindowManager->winGetWindowFromId( parentMainMenu, motdID );
  454. buttonWorldBuilder = TheWindowManager->winGetWindowFromId( parentMainMenu, worldBuilderID );
  455. buttonReplay = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonReplayID );
  456. buttonLoadReplay = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonLoadReplayID );
  457. buttonLoad = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonLoadID );
  458. buttonCredits = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonCreditsID );
  459. buttonEasy = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonEasyID );
  460. buttonMedium = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonMediumID );
  461. buttonHard = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonHardID );
  462. buttonDiffBack = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonDiffBackID );
  463. // GameWindow *labelVersion = TheWindowManager->winGetWindowFromId( parentMainMenu, versionID );
  464. getUpdate = TheWindowManager->winGetWindowFromId( parentMainMenu, getUpdateID );
  465. // buttonTRAINING = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonTRAININGID );
  466. buttonChallenge = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonChallengeID );
  467. buttonUSA = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonUSAID );
  468. buttonGLA = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonGLAID );
  469. buttonChina = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonChinaID );
  470. buttonUSARecentSave = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonUSARecentSaveID );
  471. buttonUSALoadGame = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonUSALoadGameID );
  472. buttonGLARecentSave = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonGLARecentSaveID );
  473. buttonGLALoadGame = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonGLALoadGameID );
  474. buttonChinaRecentSave = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonChinaRecentSaveID );
  475. buttonChinaLoadGame = TheWindowManager->winGetWindowFromId( parentMainMenu, buttonChinaLoadGameID );
  476. dropDownWindows[DROPDOWN_SINGLE] = TheWindowManager->winGetWindowFromId( parentMainMenu, TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:MapBorder") ));
  477. dropDownWindows[DROPDOWN_MULTIPLAYER] = TheWindowManager->winGetWindowFromId( parentMainMenu, TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:MapBorder1") ) );
  478. dropDownWindows[DROPDOWN_MAIN] = TheWindowManager->winGetWindowFromId( parentMainMenu, TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:MapBorder2") ) );
  479. dropDownWindows[DROPDOWN_LOADREPLAY] = TheWindowManager->winGetWindowFromId( parentMainMenu, TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:MapBorder3") ) );
  480. dropDownWindows[DROPDOWN_DIFFICULTY] = TheWindowManager->winGetWindowFromId( parentMainMenu, TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:MapBorder4") ) );
  481. for(i = 1; i < DROPDOWN_COUNT; ++i)
  482. dropDownWindows[i]->winHide(TRUE);
  483. initialHide();
  484. showSelectiveButtons(SHOW_NONE);
  485. // Set up the version number
  486. #if defined _DEBUG || defined _INTERNAL || defined _PROFILE
  487. WinInstanceData instData;
  488. #ifdef TEST_COMPRESSION
  489. instData.init();
  490. BitSet( instData.m_style, GWS_PUSH_BUTTON | GWS_MOUSE_TRACK );
  491. instData.m_textLabelString = "Debug: Compress/Decompress Maps";
  492. instData.setTooltipText(UnicodeString(L"Only Used in Debug and Internal!"));
  493. buttonCompressTest = TheWindowManager->gogoGadgetPushButton( parentMainMenu,
  494. WIN_STATUS_ENABLED | WIN_STATUS_IMAGE,
  495. 25, 175,
  496. 400, 400,
  497. &instData, NULL, TRUE );
  498. #endif // TEST_COMPRESSION
  499. instData.init();
  500. BitSet( instData.m_style, GWS_PUSH_BUTTON | GWS_MOUSE_TRACK );
  501. instData.m_textLabelString = "Debug: Load Map";
  502. instData.setTooltipText(UnicodeString(L"Only Used in Debug and Internal!"));
  503. buttonCampaign = TheWindowManager->gogoGadgetPushButton( parentMainMenu,
  504. WIN_STATUS_ENABLED,
  505. 25, 54,
  506. 180, 26,
  507. &instData, NULL, TRUE );
  508. // if (TheVersion)
  509. // {
  510. // UnicodeString version;
  511. // version.format(L"%s\n%s", TheVersion->getUnicodeVersion().str(), TheVersion->getUnicodeBuildTime().str());
  512. // GadgetStaticTextSetText( labelVersion, version );
  513. // }
  514. // else
  515. // {
  516. // labelVersion->winHide( TRUE );
  517. // }
  518. //#else
  519. // GadgetStaticTextSetText( labelVersion, TheVersion->getUnicodeVersion() );
  520. #endif
  521. //TheShell->registerWithAnimateManager(buttonCampaign, WIN_ANIMATION_SLIDE_LEFT, TRUE, 800);
  522. //TheShell->registerWithAnimateManager(buttonSkirmish, WIN_ANIMATION_SLIDE_LEFT, TRUE, 600);
  523. // TheShell->registerWithAnimateManager(buttonSinglePlayer, WIN_ANIMATION_SLIDE_LEFT, TRUE, 400);
  524. // TheShell->registerWithAnimateManager(buttonMultiPlayer, WIN_ANIMATION_SLIDE_LEFT, TRUE, 200);
  525. // TheShell->registerWithAnimateManager(buttonOptions, WIN_ANIMATION_SLIDE_LEFT, TRUE, 1);
  526. // TheShell->registerWithAnimateManager(buttonExit, WIN_ANIMATION_SLIDE_RIGHT, TRUE, 1);
  527. //
  528. layout->hide( FALSE );
  529. /*
  530. if (!checkedForUpdate)
  531. {
  532. DWORD state = 0;
  533. Bool isConnected = InternetGetConnectedState(&state, 0);
  534. if (isConnected && !(state & INTERNET_CONNECTION_MODEM_BUSY))
  535. {
  536. // wohoo - we're connected! fire off a check for updates
  537. checkedForUpdate = TRUE;
  538. DEBUG_LOG(("Looking for a patch for productID=%d, versionStr=%s, distribution=%d\n",
  539. gameProductID, gameVersionUniqueIDStr, gameDistributionID));
  540. ptCheckForPatch( gameProductID, gameVersionUniqueIDStr, gameDistributionID, patchAvailableCallback, PTFalse, NULL );
  541. //ptCheckForPatch( productID, versionUniqueIDStr, distributionID, mapPackAvailableCallback, PTFalse, NULL );
  542. }
  543. }
  544. if (getUpdate != NULL)
  545. {
  546. getUpdate->winHide( TRUE );
  547. //getUpdate->winEnable( FALSE );
  548. }
  549. /**/
  550. if (TheGameSpyPeerMessageQueue && !TheGameSpyPeerMessageQueue->isConnected())
  551. {
  552. DEBUG_LOG(("Tearing down GameSpy from MainMenuInit()\n"));
  553. TearDownGameSpy();
  554. }
  555. if (TheMapCache)
  556. TheMapCache->updateCache();
  557. /*
  558. if (MOTDBuffer && buttonMOTD)
  559. {
  560. buttonMOTD->winHide(FALSE);
  561. }
  562. */
  563. TheShell->loadScheme("MainMenu");
  564. raiseMessageBoxes = TRUE;
  565. // if(!localAnimateWindowManager)
  566. // localAnimateWindowManager = NEW AnimateWindowManager;
  567. //pendingDropDown =DROPDOWN_MAIN;
  568. GameWindow *rule = TheWindowManager->winGetWindowFromId( parentMainMenu, TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:MainMenuRuler") ) );
  569. if(rule)
  570. rule->winHide(TRUE);
  571. campaignSelected = FALSE;
  572. // dropDownWindows[DROPDOWN_MAIN]->winHide(FALSE);
  573. if(FirstTimeRunningTheGame)
  574. {
  575. TheMouse->setVisibility(FALSE);
  576. TheTransitionHandler->reverse("FadeWholeScreen");
  577. FirstTimeRunningTheGame = FALSE;
  578. }
  579. else
  580. {
  581. showFade = TRUE;
  582. justEntered = TRUE;
  583. initialGadgetDelay = 2;
  584. if(rule)
  585. rule->winHide(FALSE);
  586. }
  587. layout->bringForward();
  588. // set keyboard focus to main parent
  589. TheWindowManager->winSetFocus( parentMainMenu );
  590. } // end MainMenuInit
  591. //-------------------------------------------------------------------------------------------------
  592. /** Main menu shutdown method */
  593. //-------------------------------------------------------------------------------------------------
  594. void MainMenuShutdown( WindowLayout *layout, void *userData )
  595. {
  596. if (!startGame)
  597. isShuttingDown = TRUE;
  598. CancelPatchCheckCallback();
  599. // if we are shutting down for an immediate pop, skip the animations
  600. Bool popImmediate = *(Bool *)userData;
  601. // if(winVidManager)
  602. // delete winVidManager;
  603. // winVidManager = NULL;
  604. if( popImmediate )
  605. {
  606. // if(localAnimateWindowManager)
  607. // {
  608. // delete localAnimateWindowManager;
  609. // localAnimateWindowManager = NULL;
  610. // }
  611. shutdownComplete( layout );
  612. return;
  613. } //end if
  614. if (!startGame)
  615. TheShell->reverseAnimatewindow();
  616. //TheShell->reverseAnimatewindow();
  617. // if(localAnimateWindowManager && dropDown != DROPDOWN_NONE)
  618. // localAnimateWindowManager->reverseAnimateWindow();
  619. } // end MainMenuShutdown
  620. extern Bool DontShowMainMenu;
  621. ////////////////////////////////////////////////////////////////////////////
  622. //Added By Sadullah Nader
  623. //Added as a fix to the resolution change
  624. //Allows the user to confirm the change, goes back to the previous mode
  625. //if the time to change expires.
  626. ////////////////////////////////////////////////////////////////////////////
  627. //-------------------------------------------------------------------------------------------------
  628. // Accept Resolution callback method
  629. //-------------------------------------------------------------------------------------------------
  630. void AcceptResolution()
  631. {
  632. //Keep new settings and bail with setting the display changed flag
  633. //set to off
  634. oldDispSettings = newDispSettings;
  635. dispChanged = FALSE;
  636. }
  637. //-------------------------------------------------------------------------------------------------
  638. // Decline Resolution callback method
  639. //-------------------------------------------------------------------------------------------------
  640. void DeclineResolution()
  641. {
  642. //Revert back to old resolution and reset all necessary
  643. //parts of the shell
  644. if (TheDisplay->setDisplayMode(oldDispSettings.xRes, oldDispSettings.yRes,
  645. oldDispSettings.bitDepth, oldDispSettings.windowed))
  646. {
  647. dispChanged = FALSE;
  648. newDispSettings = oldDispSettings;
  649. TheWritableGlobalData->m_xResolution = newDispSettings.xRes;
  650. TheWritableGlobalData->m_yResolution = newDispSettings.yRes;
  651. TheHeaderTemplateManager->headerNotifyResolutionChange();
  652. TheMouse->mouseNotifyResolutionChange();
  653. AsciiString prefString;
  654. prefString.format("%d %d", newDispSettings.xRes, newDispSettings.yRes);
  655. OptionPreferences optionPref;
  656. optionPref["Resolution"] = prefString;
  657. optionPref.write();
  658. // delete the shell
  659. delete TheShell;
  660. TheShell = NULL;
  661. // create the shell
  662. TheShell = MSGNEW("GameClientSubsystem") Shell;
  663. if( TheShell )
  664. TheShell->init();
  665. TheInGameUI->recreateControlBar();
  666. TheShell->push( AsciiString("Menus/MainMenu.wnd") );
  667. }
  668. }
  669. //-------------------------------------------------------------------------------------------------
  670. // Accept/Decline Resolution dialog method
  671. //-------------------------------------------------------------------------------------------------
  672. void DoResolutionDialog()
  673. {
  674. //Bring up a dialog to accept the resolution chosen in the options menu
  675. UnicodeString resolutionNew;
  676. UnicodeString resTimerString = TheGameText->fetch("GUI:Resolution");
  677. resolutionNew.format(L": %dx%d\n", newDispSettings.xRes , newDispSettings.yRes);
  678. resTimerString.concat(resolutionNew);
  679. resAcceptMenu = TheWindowManager->gogoMessageBox( CORNER, CORNER, -1, -1,MSG_BOX_OK | MSG_BOX_CANCEL ,
  680. TheGameText->fetch("GUI:Resolution"),
  681. resTimerString, NULL, NULL, AcceptResolution,
  682. DeclineResolution);
  683. }
  684. /* This function is not being currently used because we do not need a timer on the
  685. // dialog box.
  686. //-------------------------------------------------------------------------------------------------
  687. //ResolutionDialogUpdate() - if resolution dialog box is shown, this must count 10 seconds for
  688. // accepting resolution changes otherwise we go back to previous display settings
  689. //-------------------------------------------------------------------------------------------------
  690. void ResolutionDialogUpdate()
  691. {
  692. if (timeStarted == 0 && currentTime == 0)
  693. {
  694. timeStarted = currentTime = time(NULL);
  695. }
  696. else
  697. {
  698. currentTime = time(NULL);
  699. }
  700. if ( ( currentTime - timeStarted ) >= TIME_OUT)
  701. {
  702. currentTime = timeStarted = 0;
  703. DeclineResolution();
  704. }
  705. //------------------------------------------------------------------------------------------------------
  706. // Used for debugging purposes
  707. //------------------------------------------------------------------------------------------------------
  708. DEBUG_LOG(("Resolution Timer : started at %d, current time at %d, frameTicker is %d\n", timeStarted,
  709. time(NULL) , currentTime));
  710. }
  711. */
  712. //-------------------------------------------------------------------------------------------------
  713. /** Main menu update method */
  714. //-------------------------------------------------------------------------------------------------
  715. void DownloadMenuUpdate( WindowLayout *layout, void *userData );
  716. void MainMenuUpdate( WindowLayout *layout, void *userData )
  717. {
  718. if( TheGameLogic->isInGame() && !TheGameLogic->isInShellGame() )
  719. {
  720. return;
  721. }
  722. if(DontShowMainMenu && justEntered)
  723. justEntered = FALSE;
  724. if (TheDownloadManager && !TheDownloadManager->isDone())
  725. {
  726. TheDownloadManager->update();
  727. DownloadMenuUpdate(layout, userData);
  728. }
  729. // Added by Saad to the confirmation or decline of the resoluotion change
  730. // dialog box.
  731. /* This is also commented for the same reason as the top
  732. if (dispChanged)
  733. {
  734. ResolutionDialogUpdate();
  735. return;
  736. }
  737. */
  738. if(justEntered)
  739. {
  740. if(initialGadgetDelay == 1)
  741. {
  742. TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade");
  743. TheWindowManager->winSetFocus( parentMainMenu );
  744. initialGadgetDelay = 2;
  745. justEntered = FALSE;
  746. }
  747. else
  748. initialGadgetDelay--;
  749. }
  750. if(dontAllowTransitions && TheTransitionHandler->isFinished())
  751. dontAllowTransitions = FALSE;
  752. if(showLogo && dontAllowTransitions == FALSE)
  753. {
  754. // if(showFrames == SHOW_FRAMES_LIMIT)
  755. // {
  756. // TheTransitionHandler->remove("MainMenuSinglePlayerMenu");
  757. switch (showSide) {
  758. case SHOW_TRAINING:
  759. TheTransitionHandler->setGroup("MainMenuFactionTraining");
  760. break;
  761. case SHOW_CHINA:
  762. TheTransitionHandler->setGroup("MainMenuFactionChina");
  763. break;
  764. case SHOW_GLA:
  765. TheTransitionHandler->setGroup("MainMenuFactionGLA");
  766. break;
  767. case SHOW_USA:
  768. TheTransitionHandler->setGroup("MainMenuFactionUS");
  769. break;
  770. case SHOW_SKIRMISH:
  771. TheTransitionHandler->setGroup("MainMenuFactionSkirmish");
  772. break;
  773. }
  774. showLogo = FALSE;
  775. // showFrames = 0;
  776. // logoIsShown = TRUE;
  777. // }
  778. // else
  779. // showFrames++;
  780. }
  781. // if(showFade)
  782. // {
  783. // showFade = FALSE;
  784. // TheTransitionHandler->reverse("FadeWholeScreen");
  785. // }
  786. ////
  787. // if (notShown)
  788. // {
  789. // if(initialGadgetDelay == 1)
  790. // {
  791. // dropDownWindows[DROPDOWN_MAIN]->winHide(FALSE);
  792. // TheTransitionHandler->setGroup("MainMenuFade", TRUE);
  793. // TheTransitionHandler->setGroup("MainMenuDefaultMenu");
  794. // TheMouse->setVisibility(TRUE);
  795. // initialGadgetDelay = 2;
  796. // notShown = FALSE;
  797. // }
  798. // else
  799. // initialGadgetDelay--;
  800. // }
  801. if (raiseMessageBoxes)
  802. {
  803. RaiseGSMessageBox();
  804. raiseMessageBoxes = FALSE;
  805. }
  806. HTTPThinkWrapper();
  807. GameSpyUpdateOverlays();
  808. // if(localAnimateWindowManager)
  809. // localAnimateWindowManager->update();
  810. // if(localAnimateWindowManager && pendingDropDown != DROPDOWN_NONE && localAnimateWindowManager->isFinished())
  811. // {
  812. // localAnimateWindowManager->reset();
  813. // if(dropDown != DROPDOWN_NONE)
  814. // dropDownWindows[dropDown]->winHide(TRUE);
  815. // dropDown = pendingDropDown;
  816. // dropDownWindows[dropDown]->winHide(FALSE);
  817. // localAnimateWindowManager->registerGameWindow(dropDownWindows[dropDown],WIN_ANIMATION_SLIDE_TOP_FAST,TRUE,1,1);
  818. // //buttonPushed = FALSE;
  819. // pendingDropDown = DROPDOWN_NONE;
  820. // }
  821. // else if(localAnimateWindowManager && dropDown == DROPDOWN_NONE && pendingDropDown == DROPDOWN_NONE && localAnimateWindowManager->isReversed() && localAnimateWindowManager->isFinished())
  822. // {
  823. // localAnimateWindowManager->reset();
  824. // for(Int i = 1; i < DROPDOWN_COUNT; ++i)
  825. // dropDownWindows[i]->winHide(TRUE);
  826. // }
  827. if (startGame && TheShell->isAnimFinished() && TheTransitionHandler->isFinished())
  828. {
  829. doGameStart();
  830. }
  831. // We'll only be successful if we've requested to
  832. if(isShuttingDown && TheShell->isAnimFinished() && TheTransitionHandler->isFinished())
  833. {
  834. shutdownComplete(layout);
  835. }
  836. // We'll only be successful if we've requested to
  837. // if(TheShell->isAnimReversed() && TheShell->isAnimFinished())
  838. // shutdownComplete( layout );
  839. // if(winVidManager)
  840. // winVidManager->update();
  841. } // end MainMenuUpdate
  842. //-------------------------------------------------------------------------------------------------
  843. /** Main menu input callback */
  844. //-------------------------------------------------------------------------------------------------
  845. WindowMsgHandledType MainMenuInput( GameWindow *window, UnsignedInt msg,
  846. WindowMsgData mData1, WindowMsgData mData2 )
  847. {
  848. if(!notShown)
  849. return MSG_IGNORED;
  850. switch( msg )
  851. {
  852. // --------------------------------------------------------------------------------------------
  853. case GWM_MOUSE_POS:
  854. {
  855. ICoord2D mouse;
  856. mouse.x = mData1 & 0xFFFF;
  857. mouse.y = mData1 >> 16;
  858. if( mouse.x == 0 && mouse.y == 0)
  859. break;
  860. static Int mousePosX = mouse.x;
  861. static Int mousePosY = mouse.y;
  862. if(abs(mouse.x - mousePosX) > 20 || abs(mouse.y - mousePosY) > 20)
  863. {
  864. DEBUG_LOG(("Mouse X:%d, Y:%d\n", mouse.x, mouse.y));
  865. if(notShown)
  866. {
  867. initialGadgetDelay = 1;
  868. dropDownWindows[DROPDOWN_MAIN]->winHide(FALSE);
  869. TheTransitionHandler->setGroup("MainMenuFade", TRUE);
  870. TheTransitionHandler->setGroup("MainMenuDefaultMenu");
  871. TheMouse->setVisibility(TRUE);
  872. notShown = FALSE;
  873. return MSG_HANDLED;
  874. }
  875. }
  876. } // end char
  877. break;
  878. case GWM_CHAR:
  879. {
  880. if(notShown)
  881. {
  882. initialGadgetDelay = 1;
  883. dropDownWindows[DROPDOWN_MAIN]->winHide(FALSE);
  884. TheTransitionHandler->setGroup("MainMenuFade", TRUE);
  885. TheTransitionHandler->setGroup("MainMenuDefaultMenu");
  886. TheMouse->setVisibility(TRUE);
  887. notShown = FALSE;
  888. return MSG_HANDLED;
  889. }
  890. } // end char
  891. } // end switch( msg )
  892. return MSG_IGNORED;
  893. } // end MainMenuInput
  894. void PrintOffsetsFromControlBarParent( void );
  895. //-------------------------------------------------------------------------------------------------
  896. /** Main menu window system callback */
  897. //-------------------------------------------------------------------------------------------------
  898. WindowMsgHandledType MainMenuSystem( GameWindow *window, UnsignedInt msg,
  899. WindowMsgData mData1, WindowMsgData mData2 )
  900. {
  901. static Bool triedToInitWOLAPI = FALSE;
  902. static Bool canInitWOLAPI = FALSE;
  903. switch( msg )
  904. {
  905. //---------------------------------------------------------------------------------------------
  906. case GWM_CREATE:
  907. {
  908. ghttpStartup();
  909. break;
  910. } // end case
  911. //---------------------------------------------------------------------------------------------
  912. case GWM_DESTROY:
  913. {
  914. ghttpCleanup();
  915. DEBUG_LOG(("Tearing down GameSpy from MainMenuSystem(GWM_DESTROY)\n"));
  916. TearDownGameSpy();
  917. StopAsyncDNSCheck(); // kill off the async DNS check thread in case it is still running
  918. break;
  919. } // end case
  920. // --------------------------------------------------------------------------------------------
  921. case GWM_INPUT_FOCUS:
  922. {
  923. // if we're givin the opportunity to take the keyboard focus we must say we want it
  924. if( mData1 == TRUE )
  925. *(Bool *)mData2 = TRUE;
  926. break;
  927. } // end input
  928. //---------------------------------------------------------------------------------------------
  929. case GBM_MOUSE_ENTERING:
  930. {
  931. GameWindow *control = (GameWindow *)mData1;
  932. Int controlID = control->winGetWindowId();
  933. if(controlID == onlineID)
  934. {
  935. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_ONLINE_HIGHLIGHTED]);
  936. }
  937. else if(controlID == networkID)
  938. {
  939. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_NETWORK_HIGHLIGHTED]);
  940. }
  941. else if(controlID == optionsID)
  942. {
  943. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_OPTIONS_HIGHLIGHTED]);
  944. }
  945. else if(controlID == exitID)
  946. {
  947. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_EXIT_HIGHLIGHTED]);
  948. }
  949. else if(controlID == buttonChallengeID)
  950. {
  951. if(dontAllowTransitions && !campaignSelected)
  952. {
  953. showLogo = TRUE;
  954. showSide = SHOW_TRAINING;
  955. }
  956. if(campaignSelected || dontAllowTransitions)
  957. break;
  958. TheTransitionHandler->setGroup("MainMenuFactionTraining");
  959. }
  960. /* else if(controlID == buttonTRAININGID)
  961. {
  962. if(dontAllowTransitions && !campaignSelected)
  963. {
  964. showLogo = TRUE;
  965. showSide = SHOW_TRAINING;
  966. }
  967. if(campaignSelected || dontAllowTransitions)
  968. break;
  969. //TheTransitionHandler->remove("MainMenuSinglePlayerMenu");
  970. TheTransitionHandler->setGroup("MainMenuFactionTraining");
  971. //showSelectiveButtons(SHOW_NONE);
  972. }
  973. */ else if(controlID == skirmishID)
  974. {
  975. if(dontAllowTransitions && !campaignSelected)
  976. {
  977. showLogo = TRUE;
  978. showSide = SHOW_SKIRMISH;
  979. }
  980. if(campaignSelected || dontAllowTransitions)
  981. break;
  982. //TheTransitionHandler->remove("MainMenuSinglePlayerMenu");
  983. TheTransitionHandler->setGroup("MainMenuFactionSkirmish");
  984. //showSelectiveButtons(SHOW_NONE);
  985. }
  986. else if(controlID == buttonUSAID)
  987. {
  988. if(dontAllowTransitions && !campaignSelected)
  989. {
  990. showLogo = TRUE;
  991. showSide = SHOW_USA;
  992. }
  993. if(campaignSelected || dontAllowTransitions)
  994. break;
  995. //TheTransitionHandler->remove("MainMenuSinglePlayerMenu");
  996. TheTransitionHandler->setGroup("MainMenuFactionUS");
  997. // showLogo = TRUE;
  998. // showFrames = 0;
  999. // showSide = SHOW_USA;
  1000. }
  1001. else if(controlID == buttonGLAID)
  1002. {
  1003. if(dontAllowTransitions && !campaignSelected)
  1004. {
  1005. showLogo = TRUE;
  1006. showSide = SHOW_GLA;
  1007. }
  1008. if(campaignSelected || dontAllowTransitions)
  1009. break;
  1010. //TheTransitionHandler->remove("MainMenuSinglePlayerMenu");
  1011. TheTransitionHandler->setGroup("MainMenuFactionGLA");
  1012. // showLogo = TRUE;
  1013. // showFrames = 0;
  1014. // showSide = SHOW_GLA;
  1015. }
  1016. else if(controlID == buttonChinaID)
  1017. {
  1018. if(dontAllowTransitions && !campaignSelected)
  1019. {
  1020. showLogo = TRUE;
  1021. showSide = SHOW_CHINA;
  1022. }
  1023. if(campaignSelected || dontAllowTransitions)
  1024. break;
  1025. //TheTransitionHandler->remove("MainMenuSinglePlayerMenu");
  1026. TheTransitionHandler->setGroup("MainMenuFactionChina");
  1027. // showLogo = TRUE;
  1028. // showFrames = 0;
  1029. // showSide = SHOW_CHINA;
  1030. }
  1031. break;
  1032. }
  1033. //---------------------------------------------------------------------------------------------
  1034. case GBM_MOUSE_LEAVING:
  1035. {
  1036. GameWindow *control = (GameWindow *)mData1;
  1037. Int controlID = control->winGetWindowId();
  1038. if(controlID == onlineID)
  1039. {
  1040. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_ONLINE_UNHIGHLIGHTED]);
  1041. }
  1042. else if(controlID == networkID)
  1043. {
  1044. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_NETWORK_UNHIGHLIGHTED]);
  1045. }
  1046. else if(controlID == optionsID)
  1047. {
  1048. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_OPTIONS_UNHIGHLIGHTED]);
  1049. }
  1050. else if(controlID == exitID)
  1051. {
  1052. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_EXIT_UNHIGHLIGHTED]);
  1053. }
  1054. else if(controlID == buttonChallengeID)
  1055. {
  1056. if(dontAllowTransitions && !campaignSelected && showLogo)
  1057. {
  1058. showLogo = FALSE;
  1059. showSide = SHOW_NONE;
  1060. }
  1061. if(campaignSelected || dontAllowTransitions)
  1062. break;
  1063. // we'll just use the training logo anim for now
  1064. TheTransitionHandler->reverse("MainMenuFactionTraining");
  1065. }
  1066. /* else if(controlID == buttonTRAININGID)
  1067. {
  1068. if(dontAllowTransitions && !campaignSelected && showLogo)
  1069. {
  1070. showLogo = FALSE;
  1071. showSide = SHOW_NONE;
  1072. }
  1073. if(campaignSelected || dontAllowTransitions)
  1074. break;
  1075. TheTransitionHandler->reverse("MainMenuFactionTraining");
  1076. //showSelectiveButtons(SHOW_NONE);
  1077. }
  1078. */ else if(controlID == skirmishID)
  1079. {
  1080. if(dontAllowTransitions && !campaignSelected && showLogo)
  1081. {
  1082. showLogo = FALSE;
  1083. showSide = SHOW_NONE;
  1084. }
  1085. if(campaignSelected || dontAllowTransitions)
  1086. break;
  1087. TheTransitionHandler->reverse("MainMenuFactionSkirmish");
  1088. //showSelectiveButtons(SHOW_NONE);
  1089. }
  1090. else if(controlID == buttonUSAID)
  1091. {
  1092. if(dontAllowTransitions && !campaignSelected && showLogo)
  1093. {
  1094. showLogo = FALSE;
  1095. showSide = SHOW_NONE;
  1096. }
  1097. if(campaignSelected || dontAllowTransitions)
  1098. break;
  1099. TheTransitionHandler->reverse("MainMenuFactionUS");
  1100. //showSelectiveButtons(SHOW_NONE);
  1101. }
  1102. else if(controlID == buttonGLAID)
  1103. {
  1104. if(dontAllowTransitions && !campaignSelected && showLogo)
  1105. {
  1106. showLogo = FALSE;
  1107. showSide = SHOW_NONE;
  1108. }
  1109. if(campaignSelected || dontAllowTransitions)
  1110. break;
  1111. TheTransitionHandler->reverse("MainMenuFactionGLA");
  1112. //showSelectiveButtons(SHOW_NONE);
  1113. }
  1114. else if(controlID == buttonChinaID)
  1115. {
  1116. if(dontAllowTransitions && !campaignSelected && showLogo)
  1117. {
  1118. showLogo = FALSE;
  1119. showSide = SHOW_NONE;
  1120. }
  1121. if(campaignSelected || dontAllowTransitions)
  1122. break;
  1123. TheTransitionHandler->reverse("MainMenuFactionChina");
  1124. //showSelectiveButtons(SHOW_NONE);
  1125. }
  1126. break;
  1127. }
  1128. //---------------------------------------------------------------------------------------------
  1129. case GBM_SELECTED:
  1130. {
  1131. GameWindow *control = (GameWindow *)mData1;
  1132. Int controlID = control->winGetWindowId();
  1133. if(buttonPushed)
  1134. break;
  1135. #if defined _DEBUG || defined _INTERNAL || defined _PROFILE
  1136. if( control == buttonCampaign )
  1137. {
  1138. buttonPushed = TRUE;
  1139. TheShell->push(AsciiString( "Menus/MapSelectMenu.wnd" ));
  1140. // As soon as we have a campaign, add it in here!;
  1141. }
  1142. #ifdef TEST_COMPRESSION
  1143. else if( control == buttonCompressTest )
  1144. {
  1145. DoCompressTest();
  1146. }
  1147. #endif // TEST_COMPRESSION
  1148. else
  1149. #endif
  1150. // don't allow mouse click slop that occurs during transitions to unset this flag
  1151. if (TheTransitionHandler->isFinished()
  1152. && controlID != buttonEasyID && controlID != buttonMediumID && controlID != buttonHardID)
  1153. {
  1154. // this toggle must only be reset if one of these buttons have not been pressed
  1155. // ...the difficulty selection behavior must have a chance to act upon this toggle
  1156. launchChallengeMenu = FALSE;
  1157. }
  1158. if( controlID == buttonSinglePlayerID )
  1159. {
  1160. if(dontAllowTransitions)
  1161. break;
  1162. dontAllowTransitions = TRUE;
  1163. //buttonPushed = TRUE;
  1164. buttonPushed = FALSE;
  1165. dropDownWindows[DROPDOWN_SINGLE]->winHide(FALSE);
  1166. TheTransitionHandler->remove("MainMenuDefaultMenu");
  1167. TheTransitionHandler->reverse("MainMenuDefaultMenuBack");
  1168. TheTransitionHandler->setGroup("MainMenuSinglePlayerMenu");
  1169. } // end if
  1170. else if( controlID == buttonSingleBackID )
  1171. {
  1172. if(campaignSelected || dontAllowTransitions)
  1173. break;
  1174. buttonPushed = FALSE;
  1175. dropDownWindows[DROPDOWN_MAIN]->winHide(FALSE);
  1176. TheTransitionHandler->remove("MainMenuSinglePlayerMenu");
  1177. TheTransitionHandler->reverse("MainMenuSinglePlayerMenuBack");
  1178. TheTransitionHandler->setGroup("MainMenuDefaultMenu");
  1179. dontAllowTransitions = TRUE;
  1180. } // end if
  1181. else if( controlID == buttonMultiBackID )
  1182. {
  1183. if(dontAllowTransitions)
  1184. break;
  1185. dontAllowTransitions = TRUE;
  1186. buttonPushed = FALSE;
  1187. dropDownWindows[DROPDOWN_MAIN]->winHide(FALSE);
  1188. TheTransitionHandler->remove("MainMenuMultiPlayerMenu");
  1189. TheTransitionHandler->reverse("MainMenuMultiPlayerMenuReverse");
  1190. TheTransitionHandler->setGroup("MainMenuDefaultMenu");
  1191. } // end if
  1192. else if( controlID == buttonLoadReplayBackID )
  1193. {
  1194. if(dontAllowTransitions)
  1195. break;
  1196. dontAllowTransitions = TRUE;
  1197. buttonPushed = FALSE;
  1198. dropDownWindows[DROPDOWN_MAIN]->winHide(FALSE);
  1199. TheTransitionHandler->remove("MainMenuLoadReplayMenu");
  1200. TheTransitionHandler->reverse("MainMenuLoadReplayMenuBack");
  1201. TheTransitionHandler->setGroup("MainMenuDefaultMenu");
  1202. } // end if
  1203. else if( control == buttonCredits )
  1204. {
  1205. if(dontAllowTransitions)
  1206. break;
  1207. dontAllowTransitions = TRUE;
  1208. buttonPushed = TRUE;
  1209. TheShell->push("Menus/CreditsMenu.wnd" );
  1210. dropDownWindows[DROPDOWN_MAIN]->winHide(FALSE);
  1211. TheTransitionHandler->reverse("MainMenuDefaultMenu");
  1212. }
  1213. else if( controlID == buttonMultiPlayerID)
  1214. {
  1215. if(dontAllowTransitions)
  1216. break;
  1217. dontAllowTransitions = TRUE;
  1218. //buttonPushed = TRUE;
  1219. buttonPushed = FALSE;
  1220. dropDownWindows[DROPDOWN_MULTIPLAYER]->winHide(FALSE);
  1221. TheTransitionHandler->remove("MainMenuDefaultMenu");
  1222. TheTransitionHandler->reverse("MainMenuDefaultMenuBack");
  1223. TheTransitionHandler->setGroup("MainMenuMultiPlayerMenu");
  1224. }
  1225. else if( controlID == buttonLoadReplayID)
  1226. {
  1227. if(dontAllowTransitions)
  1228. break;
  1229. dontAllowTransitions = TRUE;
  1230. //buttonPushed = TRUE;
  1231. buttonPushed = FALSE;
  1232. dropDownWindows[DROPDOWN_LOADREPLAY]->winHide(FALSE);
  1233. TheTransitionHandler->remove("MainMenuDefaultMenu");
  1234. TheTransitionHandler->reverse("MainMenuDefaultMenuBack");
  1235. TheTransitionHandler->setGroup("MainMenuLoadReplayMenu");
  1236. }
  1237. else if( controlID == buttonLoadID )
  1238. {
  1239. if(dontAllowTransitions)
  1240. break;
  1241. dontAllowTransitions = TRUE;
  1242. // SaveLoadLayoutType layoutType = SLLT_LOAD_ONLY;
  1243. // WindowLayout *saveLoadMenuLayout = TheShell->getSaveLoadMenuLayout();
  1244. // DEBUG_ASSERTCRASH( saveLoadMenuLayout, ("Unable to get save load menu layout.\n") );
  1245. // saveLoadMenuLayout->runInit( &layoutType );
  1246. // saveLoadMenuLayout->hide( FALSE );
  1247. // saveLoadMenuLayout->bringForward();
  1248. buttonPushed = TRUE;
  1249. dropDownWindows[DROPDOWN_LOADREPLAY]->winHide(FALSE);
  1250. TheTransitionHandler->reverse("MainMenuLoadReplayMenuBackTransition");
  1251. TheShell->push(AsciiString("Menus/SaveLoad.wnd"));
  1252. }
  1253. else if( controlID == buttonReplayID )
  1254. {
  1255. if(dontAllowTransitions)
  1256. break;
  1257. dontAllowTransitions = TRUE;
  1258. buttonPushed = TRUE;
  1259. dropDownWindows[DROPDOWN_LOADREPLAY]->winHide(FALSE);
  1260. TheTransitionHandler->reverse("MainMenuLoadReplayMenuBackTransition");
  1261. TheShell->push(AsciiString("Menus/ReplayMenu.wnd"));
  1262. }
  1263. else if( controlID == skirmishID )
  1264. {
  1265. if(campaignSelected || dontAllowTransitions)
  1266. break;
  1267. buttonPushed = TRUE;
  1268. campaignSelected = TRUE;
  1269. dropDownWindows[DROPDOWN_SINGLE]->winHide(FALSE);
  1270. TheTransitionHandler->remove("MainMenuFactionSkirmish");
  1271. TheTransitionHandler->reverse("MainMenuSinglePlayerMenuBackSkirmish");
  1272. #ifdef _CAMPEA_DEMO
  1273. TheCampaignManager->setCampaign( "MD_CAMPEA_DEMO" );
  1274. /*
  1275. TheTransitionHandler->setGroup("MainMenuDifficultyMenuUS");
  1276. logoIsShown = FALSE;
  1277. showLogo = FALSE;
  1278. showSide = SHOW_USA;
  1279. */
  1280. checkCDBeforeCampaign(DIFFICULTY_NORMAL);
  1281. break;
  1282. #endif
  1283. TheShell->push( AsciiString("Menus/SkirmishGameOptionsMenu.wnd") );
  1284. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_SKIRMISH_SELECTED]);
  1285. }
  1286. else if( controlID == onlineID )
  1287. {
  1288. if(dontAllowTransitions)
  1289. break;
  1290. dontAllowTransitions = TRUE;
  1291. buttonPushed = TRUE;
  1292. dropDownWindows[DROPDOWN_MULTIPLAYER]->winHide(FALSE);
  1293. TheTransitionHandler->reverse("MainMenuMultiPlayerMenuTransitionToNext");
  1294. StartPatchCheck();
  1295. // localAnimateWindowManager->reverseAnimateWindow();
  1296. dropDown = DROPDOWN_NONE;
  1297. } // end else if
  1298. else if( controlID == networkID )
  1299. {
  1300. if(dontAllowTransitions)
  1301. break;
  1302. dontAllowTransitions = TRUE;
  1303. buttonPushed = TRUE;
  1304. dropDownWindows[DROPDOWN_MULTIPLAYER]->winHide(FALSE);
  1305. TheTransitionHandler->reverse("MainMenuMultiPlayerMenuTransitionToNext");
  1306. TheShell->push( AsciiString("Menus/LanLobbyMenu.wnd") );
  1307. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_NETWORK_SELECTED]);
  1308. } // end else if
  1309. else if( controlID == optionsID )
  1310. {
  1311. if(dontAllowTransitions)
  1312. break;
  1313. dontAllowTransitions = TRUE;
  1314. //buttonPushed = TRUE;
  1315. TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_OPTIONS_SELECTED]);
  1316. // load the options menu
  1317. WindowLayout *optLayout = TheShell->getOptionsLayout(TRUE);
  1318. DEBUG_ASSERTCRASH(optLayout != NULL, ("unable to get options menu layout"));
  1319. optLayout->runInit();
  1320. optLayout->hide(FALSE);
  1321. optLayout->bringForward();
  1322. } // end else if
  1323. else if( controlID == worldBuilderID )
  1324. {
  1325. #if defined _DEBUG
  1326. if(_spawnl(_P_NOWAIT,"WorldBuilderD.exe","WorldBuilderD.exe", NULL) < 0)
  1327. MessageBoxOk(TheGameText->fetch("GUI:WorldBuilder"), TheGameText->fetch("GUI:WorldBuilderLoadFailed"),NULL);
  1328. #elif defined _INTERNAL
  1329. if(_spawnl(_P_NOWAIT,"WorldBuilderI.exe","WorldBuilderI.exe", NULL) < 0)
  1330. MessageBoxOk(TheGameText->fetch("GUI:WorldBuilder"), TheGameText->fetch("GUI:WorldBuilderLoadFailed"),NULL);
  1331. #else
  1332. if(_spawnl(_P_NOWAIT,"WorldBuilder.exe","WorldBuilder.exe", NULL) < 0)
  1333. MessageBoxOk(TheGameText->fetch("GUI:WorldBuilder"), TheGameText->fetch("GUI:WorldBuilderLoadFailed"),NULL);
  1334. #endif
  1335. }
  1336. else if( controlID == getUpdateID )
  1337. {
  1338. StartDownloadingPatches();
  1339. }
  1340. else if( controlID == exitID )
  1341. {
  1342. // If we ever want to add a dialog before we exit out of the game, uncomment this line and kill the quitCallback() line below.
  1343. //#if defined(_DEBUG) || defined(_INTERNAL)
  1344. //Added By Sadullah Nader
  1345. //Changed the preprocessing code to normal code
  1346. if (TheGlobalData->m_windowed)
  1347. {
  1348. quitCallback();
  1349. //#else
  1350. }
  1351. else
  1352. {
  1353. QuitMessageBoxYesNo(TheGameText->fetch("GUI:QuitPopupTitle"), TheGameText->fetch("GUI:QuitPopupMessage"),quitCallback,NULL);
  1354. }
  1355. //
  1356. //#endif
  1357. } // end else if
  1358. else if(controlID == buttonChallengeID)
  1359. {
  1360. if(campaignSelected || dontAllowTransitions)
  1361. break;
  1362. // set up for the difficulty select into challenge menu
  1363. TheTransitionHandler->setGroup("MainMenuFactionTraining");
  1364. GameWindow *win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionTraining"));
  1365. if(win)
  1366. win->winHide(TRUE);
  1367. TheTransitionHandler->reverse("MainMenuSinglePlayerMenuBackTraining");
  1368. TheTransitionHandler->setGroup("MainMenuDifficultyMenuTraining");
  1369. campaignSelected = TRUE;
  1370. showLogo = FALSE;
  1371. showSide = SHOW_TRAINING;
  1372. launchChallengeMenu = TRUE;
  1373. }
  1374. // This button has been removed for the mission disk -June 2003
  1375. /* else if(controlID == buttonTRAININGID)
  1376. {
  1377. if(campaignSelected || dontAllowTransitions)
  1378. break;
  1379. TheCampaignManager->setCampaign( "TRAINING" );
  1380. TheTransitionHandler->setGroup("MainMenuFactionTraining");
  1381. TheTransitionHandler->remove("MainMenuFactionTraining", TRUE);
  1382. GameWindow *win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionTraining"));
  1383. if(win)
  1384. win->winHide(TRUE);
  1385. TheTransitionHandler->reverse("MainMenuSinglePlayerMenuBackTraining");
  1386. TheTransitionHandler->setGroup("MainMenuDifficultyMenuTraining");
  1387. campaignSelected = TRUE;
  1388. showLogo = FALSE;
  1389. showSide = SHOW_TRAINING;
  1390. // setupGameStart(TheCampaignManager->getCurrentMap());
  1391. }
  1392. */ else if(controlID == buttonUSAID)
  1393. {
  1394. if(campaignSelected || dontAllowTransitions)
  1395. break;
  1396. TheCampaignManager->setCampaign( "USA" );
  1397. #ifdef _CAMPEA_DEMO
  1398. TheCampaignManager->setCampaign( "MD_USA_1_DEMO" );
  1399. #endif
  1400. TheTransitionHandler->setGroup("MainMenuFactionUS");
  1401. TheTransitionHandler->remove("MainMenuFactionUS", TRUE);
  1402. GameWindow *win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionUS"));
  1403. if(win)
  1404. win->winHide(TRUE);
  1405. TheTransitionHandler->reverse("MainMenuSinglePlayerMenuBackUS");
  1406. TheTransitionHandler->setGroup("MainMenuDifficultyMenuUS");
  1407. campaignSelected = TRUE;
  1408. logoIsShown = FALSE;
  1409. showLogo = FALSE;
  1410. showSide = SHOW_USA;
  1411. // launchChallengeMenu = FALSE;
  1412. // WindowLayout *layout = NULL;
  1413. // layout = TheWindowManager->winCreateLayout( AsciiString( "Menus/DifficultySelect.wnd" ) );
  1414. // layout->runInit();
  1415. // layout->hide( FALSE );
  1416. // layout->bringForward();
  1417. // setupGameStart(TheCampaignManager->getCurrentMap());
  1418. }
  1419. else if(controlID == buttonGLAID)
  1420. {
  1421. if(campaignSelected || dontAllowTransitions)
  1422. break;
  1423. TheCampaignManager->setCampaign( "GLA" );
  1424. #ifdef _CAMPEA_DEMO
  1425. TheCampaignManager->setCampaign( "MD_USA_2_DEMO" );
  1426. #endif
  1427. TheTransitionHandler->setGroup("MainMenuFactionGLA");
  1428. TheTransitionHandler->remove("MainMenuFactionGLA", TRUE);
  1429. GameWindow *win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionGLA"));
  1430. if(win)
  1431. win->winHide(TRUE);
  1432. TheTransitionHandler->reverse("MainMenuSinglePlayerMenuBackGLA");
  1433. TheTransitionHandler->setGroup("MainMenuDifficultyMenuGLA");
  1434. campaignSelected = TRUE;
  1435. logoIsShown = FALSE;
  1436. showLogo = FALSE;
  1437. showSide = SHOW_GLA;
  1438. // launchChallengeMenu = FALSE;
  1439. // WindowLayout *layout = NULL;
  1440. // layout = TheWindowManager->winCreateLayout( AsciiString( "Menus/DifficultySelect.wnd" ) );
  1441. // layout->runInit();
  1442. // layout->hide( FALSE );
  1443. // layout->bringForward();
  1444. // setupGameStart(TheCampaignManager->getCurrentMap());
  1445. }
  1446. else if(controlID == buttonChinaID)
  1447. {
  1448. if(campaignSelected || dontAllowTransitions)
  1449. break;
  1450. TheCampaignManager->setCampaign( "China" );
  1451. #ifdef _CAMPEA_DEMO
  1452. TheCampaignManager->setCampaign( "MD_GLA_3_DEMO" );
  1453. #endif
  1454. TheTransitionHandler->setGroup("MainMenuFactionChina");
  1455. TheTransitionHandler->remove("MainMenuFactionChina", TRUE);
  1456. GameWindow *win = TheWindowManager->winGetWindowFromId(parentMainMenu, TheNameKeyGenerator->nameToKey("MainMenu.wnd:WinFactionChina"));
  1457. if(win)
  1458. win->winHide(TRUE);
  1459. TheTransitionHandler->reverse("MainMenuSinglePlayerMenuBackChina");
  1460. TheTransitionHandler->setGroup("MainMenuDifficultyMenuChina");
  1461. campaignSelected = TRUE;
  1462. logoIsShown = FALSE;
  1463. showLogo = FALSE;
  1464. showSide = SHOW_CHINA;
  1465. // launchChallengeMenu = FALSE;
  1466. // WindowLayout *layout = NULL;
  1467. // layout = TheWindowManager->winCreateLayout( AsciiString( "Menus/DifficultySelect.wnd" ) );
  1468. // layout->runInit();
  1469. // layout->hide( FALSE );
  1470. // layout->bringForward();
  1471. // setupGameStart(TheCampaignManager->getCurrentMap());
  1472. }// end else if
  1473. else if(controlID == buttonEasyID)
  1474. {
  1475. if(dontAllowTransitions)
  1476. break;
  1477. checkCDBeforeCampaign(DIFFICULTY_EASY);
  1478. }
  1479. else if(controlID == buttonMediumID)
  1480. {
  1481. if(dontAllowTransitions)
  1482. break;
  1483. checkCDBeforeCampaign(DIFFICULTY_NORMAL);
  1484. }
  1485. else if(controlID == buttonHardID)
  1486. {
  1487. if(dontAllowTransitions)
  1488. break;
  1489. checkCDBeforeCampaign(DIFFICULTY_HARD);
  1490. }
  1491. else if(controlID == buttonDiffBackID)
  1492. {
  1493. if(dontAllowTransitions)
  1494. break;
  1495. dontAllowTransitions = TRUE;
  1496. TheCampaignManager->setCampaign( AsciiString::TheEmptyString );
  1497. diffReverseSide();
  1498. campaignSelected = FALSE;
  1499. }
  1500. break;
  1501. } // end selected
  1502. //---------------------------------------------------------------------------------------------
  1503. default:
  1504. return MSG_IGNORED;
  1505. } // end switch
  1506. return MSG_HANDLED;
  1507. } // end MainMenuSystem
  1508. void diffReverseSide( void )
  1509. {
  1510. switch (showSide) {
  1511. case SHOW_TRAINING:
  1512. TheTransitionHandler->reverse("MainMenuDifficultyMenuTrainingBack");
  1513. TheTransitionHandler->setGroup("MainMenuSinglePlayerTrainingMenuFromDiff");
  1514. break;
  1515. case SHOW_USA:
  1516. TheTransitionHandler->reverse("MainMenuDifficultyMenuUSBack");
  1517. TheTransitionHandler->setGroup("MainMenuSinglePlayerUSAMenuFromDiff");
  1518. break;
  1519. case SHOW_GLA:
  1520. TheTransitionHandler->reverse("MainMenuDifficultyMenuGLABack");
  1521. TheTransitionHandler->setGroup("MainMenuSinglePlayerGLAMenuFromDiff");
  1522. break;
  1523. case SHOW_CHINA:
  1524. TheTransitionHandler->reverse("MainMenuDifficultyMenuChinaBack");
  1525. TheTransitionHandler->setGroup("MainMenuSinglePlayerChinaMenuFromDiff");
  1526. break;
  1527. }
  1528. }