MainMenu.cpp 56 KB

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