MainMenu.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  1. #define MAINMENU_CPP
  2. /*************************************************************************************************\
  3. MainMenu.cpp : Implementation of the MainMenu component.
  4. //---------------------------------------------------------------------------//
  5. // Copyright (C) Microsoft Corporation. All rights reserved. //
  6. //===========================================================================//
  7. \*************************************************************************************************/
  8. #include <windows.h>
  9. #include <ddraw.h>
  10. #include "MainMenu.h"
  11. #include "McLIb.h"
  12. #include "iniFile.h"
  13. #include "LogisticsData.h"
  14. #include "LogisticsDialog.h"
  15. #include "aButton.h"
  16. #include "OptionsScreenWrapper.h"
  17. #include <windows.h>
  18. #include "..\resource.h"
  19. #include "mechlopedia.h"
  20. #include "gameSound.h"
  21. #include "aAnimObject.h"
  22. #include "Multplyr.h"
  23. #include "prefs.h"
  24. extern CPrefs prefs;
  25. #define MM_MSG_NEW_CAMPAIGN 90
  26. #define MM_MSG_SAVE 92
  27. #define MM_MSG_LOAD 91
  28. #define MM_MSG_MULTIPLAYER 93
  29. #define MM_MSG_RETURN_TO_GAME 94
  30. #define MM_MSG_OPTIONS 95
  31. #define MM_MSG_ENCYCLOPEDIA 96
  32. #define MM_MSG_EXIT 97
  33. #define MM_MSG_SINGLE_MISSION 98
  34. #define MM_MSG_LEGAL 99
  35. extern volatile bool mc2IsInMouseTimer;
  36. extern volatile bool mc2IsInDisplayBackBuffer;
  37. void MouseTimerKill();
  38. extern void (*AsynFunc)(RECT& WinRect,DDSURFACEDESC2& mouseSurfaceDesc );
  39. extern bool bInvokeOptionsScreenFlag;
  40. bool MainMenu::bDrawMechlopedia = false;;
  41. void SplashIntro::init()
  42. {
  43. FullPathFileName path;
  44. path.init( artPath, "mcl_splashscreenintro", ".fit" );
  45. FitIniFile file;
  46. if ( NO_ERR != file.open( path ) )
  47. {
  48. char errorStr[256];
  49. sprintf( errorStr, "couldn't open file %s", (char*)path );
  50. Assert(0,0,errorStr );
  51. }
  52. LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" );
  53. }
  54. MainMenu::MainMenu( )
  55. {
  56. optionsScreenWrapper = NULL;
  57. bOptions = 0;
  58. bSave = bLoad = 0;
  59. helpTextArrayID = 0;
  60. mechlopedia = 0;
  61. bDrawMechlopedia = 0;
  62. tuneId = -1;
  63. bLoadSingle = 0;
  64. bLoadCampaign = 0;
  65. introOver = 0;
  66. bHostLeftDlg = 0;
  67. introMovie = 0;
  68. }
  69. //-------------------------------------------------------------------------------------------------
  70. MainMenu::~MainMenu()
  71. {
  72. if ( optionsScreenWrapper )
  73. delete optionsScreenWrapper;
  74. }
  75. int MainMenu::init( FitIniFile& file )
  76. {
  77. file.seekBlock("Tunes");
  78. file.readIdLong("TuneId",tuneId);
  79. LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" );
  80. FullPathFileName name;
  81. name.init( artPath, "mcl_sp", ".fit" );
  82. FitIniFile file2;
  83. if ( NO_ERR != file2.open( name ) )
  84. {
  85. char errorStr[256];
  86. sprintf( errorStr, "couldn't open file %s", (char*)name );
  87. Assert(0,0,errorStr );
  88. }
  89. background.init( file2, "Static", "Text", "Rect", "Button" );
  90. for ( int i = 0; i < buttonCount; i++ )
  91. {
  92. buttons[i].setMessageOnRelease();
  93. buttons[i].setPressFX(LOG_VIDEOBUTTONS);
  94. buttons[i].setHighlightFX(LOG_DIGITALHIGHLIGHT);
  95. }
  96. beginAnim.initWithBlockName( &file, "InAnim" );
  97. endAnim.initWithBlockName( &file, "OutAnim" );
  98. intro.init();
  99. FullPathFileName path;
  100. path.init( artPath, "mcl_mp_loadmap", ".fit" );
  101. FitIniFile mpFile;
  102. if ( NO_ERR != mpFile.open( path ) )
  103. {
  104. char error[256];
  105. sprintf( error, "couldn't open file %s", path );
  106. Assert( 0, 0, error );
  107. return -1;
  108. }
  109. singleLoadDlg.init( &mpFile );
  110. introMovie = 0;
  111. path.init( moviePath, "msft", ".bik" );
  112. RECT movieRect;
  113. movieRect.top = 0;
  114. movieRect.left = 0;
  115. movieRect.right = Environment.screenWidth;
  116. movieRect.bottom = Environment.screenHeight;
  117. introMovie = new MC2Movie;
  118. introMovie->init(path,movieRect,true);
  119. return 0;
  120. }
  121. void MainMenu::begin()
  122. {
  123. status = RUNNING;
  124. promptToQuit = 0;
  125. beginAnim.begin();
  126. beginFadeIn( 0 );
  127. endAnim.end();
  128. background.beginFadeIn( 0 );
  129. endResult = RUNNING;
  130. musicStarted = false;
  131. bLoadSingle = 0;
  132. bLoadCampaign = 0;
  133. promptToDisconnect = 0;
  134. bLegal = 0;
  135. // no host left dlg, sometimes we get this begin call 2x's due to netlib weirdness
  136. if ( !introMovie )
  137. {
  138. while (mc2IsInMouseTimer)
  139. ;
  140. //ONLY set the mouse BLT data at the end of each update. NO MORE FLICKERING THEN!!!
  141. // BLOCK THREAD WHILE THIS IS HAPPENING
  142. mc2IsInDisplayBackBuffer = true;
  143. mc2UseAsyncMouse = prefs.asyncMouse;
  144. if ( !mc2UseAsyncMouse)
  145. MouseTimerKill();
  146. mc2IsInDisplayBackBuffer = false;
  147. AsynFunc = NULL;
  148. //Force mouse Cursors to smaller or larger depending on new video mode.
  149. userInput->initMouseCursors("cursors");
  150. userInput->mouseOn();
  151. userInput->setMouseCursor( mState_LOGISTICS );
  152. DWORD localRenderer = prefs.renderer;
  153. if (prefs.renderer != 0 && prefs.renderer != 3)
  154. localRenderer = 0;
  155. bool localFullScreen = prefs.fullScreen;
  156. bool localWindow = !prefs.fullScreen;
  157. if (Environment.fullScreen && prefs.fullScreen)
  158. localFullScreen = false;
  159. // make sure we get into 800 x 600 mode
  160. if ( Environment.screenWidth != 800 )
  161. {
  162. if (prefs.renderer == 3)
  163. gos_SetScreenMode(800,600,16,0,0,0,true,localFullScreen,0,localWindow,0,localRenderer);
  164. else
  165. gos_SetScreenMode(800,600,16,prefs.renderer,0,0,0,localFullScreen ,0,localWindow,0,localRenderer);
  166. }
  167. }
  168. }
  169. void MainMenu::end()
  170. {
  171. endAnim.end();
  172. bHostLeftDlg = 0;
  173. }
  174. void MainMenu::setDrawBackground( bool bNewDrawBackground )
  175. {
  176. bDrawBackground = bNewDrawBackground;
  177. if ( bDrawBackground && !introOver)
  178. {
  179. intro.begin();
  180. }
  181. }
  182. int MainMenu::handleMessage( unsigned long what, unsigned long who )
  183. {
  184. switch ( who )
  185. {
  186. case MM_MSG_NEW_CAMPAIGN:
  187. if ( MPlayer )
  188. {
  189. LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
  190. LogisticsOKDialog::instance()->begin();
  191. endResult = MM_MSG_NEW_CAMPAIGN;
  192. promptToDisconnect = true;
  193. }
  194. else
  195. {
  196. endAnim.begin();
  197. beginAnim.end();
  198. bLoadCampaign = true;
  199. LogisticsSaveDialog::instance()->beginCampaign();
  200. if ( LogisticsSaveDialog::instance()->isDone() )
  201. {
  202. LogisticsData::instance->startNewCampaign( LogisticsSaveDialog::instance()->getFileName());
  203. status = RESTART;
  204. }
  205. }
  206. break;
  207. case MM_MSG_SAVE:
  208. if ( MPlayer )
  209. {
  210. LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
  211. LogisticsOKDialog::instance()->begin();
  212. endResult = who;
  213. promptToDisconnect = true;
  214. }
  215. else
  216. {
  217. // need to pop dialog here
  218. LogisticsSaveDialog::instance()->begin();
  219. endAnim.begin();
  220. beginAnim.end();
  221. bSave = true;
  222. }
  223. break;
  224. case MM_MSG_LOAD:
  225. if ( MPlayer )
  226. {
  227. LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
  228. LogisticsOKDialog::instance()->begin();
  229. endResult = who;
  230. promptToDisconnect = true;
  231. }
  232. else
  233. {
  234. // need to pop dialog here
  235. LogisticsSaveDialog::instance()->beginLoad();
  236. endAnim.begin();
  237. beginAnim.end();
  238. bLoad = true;
  239. }
  240. break;
  241. case MM_MSG_MULTIPLAYER:
  242. if ( MPlayer )
  243. {
  244. LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
  245. LogisticsOKDialog::instance()->begin();
  246. endResult = who;
  247. promptToDisconnect = true;
  248. }
  249. else
  250. {
  251. endAnim.begin();
  252. beginAnim.end();
  253. endResult = MULTIPLAYERRESTART;
  254. LogisticsData::instance->startMultiPlayer();
  255. }
  256. break;
  257. case MM_MSG_RETURN_TO_GAME:
  258. {
  259. if ( !bDrawBackground )
  260. {
  261. endAnim.begin();
  262. beginAnim.end();
  263. endResult = NEXT;
  264. soundSystem->playDigitalSample( LOG_MAINMENUBUTTON );
  265. soundSystem->playDigitalMusic(LogisticsData::instance->getCurrentMissionTune());
  266. }
  267. }
  268. break;
  269. case MM_MSG_OPTIONS:
  270. // need to throw up the options screen here...
  271. if (!optionsScreenWrapper)
  272. {
  273. optionsScreenWrapper = new OptionsScreenWrapper;
  274. optionsScreenWrapper->init();
  275. }
  276. optionsScreenWrapper->begin();
  277. bOptions = true;
  278. break;
  279. case MM_MSG_ENCYCLOPEDIA:
  280. bDrawMechlopedia = true;
  281. beginFadeOut(1.0);
  282. if ( !mechlopedia )
  283. {
  284. mechlopedia = new Mechlopedia;
  285. mechlopedia->init();
  286. }
  287. mechlopedia->begin();
  288. break;
  289. case MM_MSG_EXIT:
  290. promptToQuit = 1;
  291. // may need to set the text here
  292. LogisticsOKDialog::instance()->setText( IDS_DIALOG_QUIT_PROMPT,
  293. IDS_DIALOG_NO, IDS_DIALOG_YES );
  294. LogisticsOKDialog::instance()->begin();
  295. getButton( who )->press( 0 );
  296. break;
  297. case MM_MSG_SINGLE_MISSION:
  298. if ( MPlayer )
  299. {
  300. LogisticsOKDialog::instance()->setText( IDS_PROMPT_TO_DISCONNECT, IDS_DIALOG_NO, IDS_DIALOG_YES );
  301. LogisticsOKDialog::instance()->begin();
  302. endResult = who;
  303. promptToDisconnect = true;
  304. }
  305. else
  306. {
  307. bLoadSingle = true;
  308. endAnim.begin();
  309. beginAnim.end();
  310. singleLoadDlg.beginSingleMission();
  311. getButton( who )->press( 0 );
  312. }
  313. break;
  314. case MM_MSG_LEGAL:
  315. {
  316. bLegal = 1;
  317. // may need to set the text here
  318. if ( !LogisticsLegalDialog::instance() )
  319. {
  320. FullPathFileName path;
  321. path.init( artPath, "mcl_dialoglegal", ".fit" );
  322. FitIniFile file;
  323. file.open( path );
  324. LogisticsLegalDialog::init( file );
  325. }
  326. LogisticsLegalDialog::instance()->setText( IDS_DIALOG_OK,
  327. IDS_DIALOG_OK, IDS_DIALOG_OK );
  328. //Needs to be this long for LOC!
  329. // -fs
  330. char realText[2048];
  331. cLoadString(IDS_LAWYER_BABBLE, realText, 2047 );
  332. char lawyerBabble[2048];
  333. unsigned long pIDLen = 64;
  334. char pID[64];
  335. sprintf( pID, "INVALID ID" );
  336. gos_LoadDataFromRegistry("PID", pID, &pIDLen);
  337. sprintf( lawyerBabble, realText, pID );
  338. LogisticsLegalDialog::instance()->setText( lawyerBabble );
  339. LogisticsLegalDialog::instance()->begin();
  340. LogisticsLegalDialog::instance()->setFont( IDS_LAWYER_BABBLE_FONT );
  341. getButton( who )->press( 0 );
  342. }
  343. break;
  344. default:
  345. break;
  346. }
  347. return 0;
  348. }
  349. void MainMenu::skipIntro()
  350. {
  351. if ( introMovie )
  352. {
  353. introMovie->stop();
  354. delete introMovie;
  355. introMovie = NULL;
  356. }
  357. }
  358. void MainMenu::update()
  359. {
  360. if ( bDrawBackground || MPlayer || LogisticsData::instance->isSingleMission() )
  361. {
  362. getButton( MM_MSG_SAVE )->disable( true );
  363. }
  364. else
  365. getButton( MM_MSG_SAVE )->disable( false );
  366. getButton( MM_MSG_MULTIPLAYER )->disable( true );
  367. if ( introMovie )
  368. {
  369. userInput->mouseOff();
  370. if (userInput->getKeyDown(KEY_SPACE) || userInput->getKeyDown(KEY_ESCAPE) || userInput->getKeyDown(KEY_LMOUSE))
  371. {
  372. introMovie->stop();
  373. }
  374. bool result = introMovie->update();
  375. if (result)
  376. {
  377. //Movie's Over.
  378. //Whack it.
  379. delete introMovie;
  380. introMovie = NULL;
  381. }
  382. return;
  383. }
  384. if (!musicStarted)
  385. {
  386. musicStarted = true;
  387. soundSystem->setMusicVolume( prefs.MusicVolume );
  388. soundSystem->playDigitalMusic(tuneId);
  389. }
  390. if ( endAnim.isDone() )
  391. {
  392. status = endResult;
  393. }
  394. if ( bDrawMechlopedia )
  395. {
  396. mechlopedia->update();
  397. if ( mechlopedia->getStatus() == NEXT )
  398. {
  399. beginFadeIn( 0 );
  400. bDrawMechlopedia = 0;
  401. if ( !bDrawBackground )
  402. status = NEXT;
  403. }
  404. return;
  405. }
  406. if ( bOptions )
  407. {
  408. OptionsScreenWrapper::status_type result = optionsScreenWrapper->update();
  409. if (result == OptionsScreenWrapper::opt_DONE)
  410. {
  411. optionsScreenWrapper->end();
  412. bOptions = 0;
  413. }
  414. return;
  415. }
  416. if ( (bSave || bLoad || bLoadCampaign) && endAnim.isDone() )
  417. {
  418. LogisticsSaveDialog::instance()->update();
  419. if ( LogisticsSaveDialog::instance()->getStatus() == LogisticsScreen::YES
  420. && LogisticsSaveDialog::instance()->isDone() )
  421. {
  422. char name[1024];
  423. strcpy( name, savePath );
  424. strcat( name, LogisticsSaveDialog::instance()->getFileName() );
  425. int index = strlen( name ) - 4;
  426. if ( stricmp( &name[index], ".fit" ) !=0 )
  427. strcat( name, ".fit" );
  428. FitIniFile file;
  429. if ( bSave )
  430. {
  431. // make sure the save game directory exists, if not create it
  432. CreateDirectory( savePath, NULL );
  433. if ( NO_ERR != file.createWithCase( name ) )
  434. {
  435. char errorStr[1024];
  436. sprintf( errorStr, "couldn't open the file %s", name );
  437. Assert( 0, 0, errorStr );
  438. }
  439. else
  440. {
  441. LogisticsData::instance->save( file );
  442. LogisticsSaveDialog::instance()->end();
  443. file.close();
  444. }
  445. bSave = bLoad = 0;
  446. status = NEXT;
  447. }
  448. else if ( bLoadCampaign )
  449. {
  450. LogisticsData::instance->startNewCampaign( LogisticsSaveDialog::instance()->getFileName());
  451. status = endResult = RESTART;
  452. // background.beginFadeOut( 1.0f );
  453. // beginFadeOut( 1.0f );
  454. bLoadCampaign = 0;
  455. }
  456. else
  457. {
  458. if ( NO_ERR != file.open( name ) )
  459. {
  460. char errorStr[1024];
  461. sprintf( errorStr, "couldn't open the file %s", name );
  462. Assert( 0, 0, errorStr );
  463. }
  464. else
  465. LogisticsData::instance->load( file );
  466. LogisticsSaveDialog::instance()->end();
  467. bSave = bLoad = 0;
  468. status = RESTART;
  469. file.close();
  470. }
  471. }
  472. else if ( LogisticsSaveDialog::instance()->getStatus() == LogisticsScreen::NO &&
  473. LogisticsSaveDialog::instance()->isDone())
  474. {
  475. LogisticsSaveDialog::instance()->end();
  476. bSave = bLoad = bLoadCampaign = 0 ;
  477. if ( !bDrawBackground )
  478. status = NEXT;
  479. else
  480. {
  481. beginAnim.begin();
  482. endAnim.end();
  483. }
  484. }
  485. return;
  486. }
  487. else if ( bLoadSingle && endAnim.isDone())
  488. {
  489. singleLoadDlg.update();
  490. if ( singleLoadDlg.isDone() )
  491. {
  492. if ( singleLoadDlg.getStatus() == YES )
  493. {
  494. const char* pName = singleLoadDlg.getMapFileName();
  495. if (pName)
  496. {
  497. LogisticsData::instance->setSingleMission( pName );
  498. status = SKIPONENEXT;
  499. }
  500. }
  501. bLoadSingle = 0;
  502. beginAnim.begin();
  503. endAnim.end();
  504. }
  505. }
  506. else if ( promptToQuit )
  507. {
  508. LogisticsOKDialog::instance()->update();
  509. {
  510. if ( LogisticsOKDialog::instance()->getStatus() == LogisticsScreen::YES )
  511. {
  512. soundSystem->playDigitalSample( LOG_EXITGAME );
  513. gos_TerminateApplication();
  514. promptToQuit = 0;
  515. }
  516. else if ( LogisticsOKDialog::instance()->getStatus() == LogisticsScreen::NO)
  517. {
  518. if ( LogisticsOKDialog::instance()->isDone() )
  519. promptToQuit = 0;
  520. }
  521. }
  522. }
  523. else if ( bLegal )
  524. {
  525. LogisticsLegalDialog::instance()->update();
  526. if ( LogisticsLegalDialog::instance()->isDone() )
  527. {
  528. LogisticsLegalDialog::instance()->end();
  529. bLegal = 0;
  530. }
  531. }
  532. else if ( bHostLeftDlg )
  533. {
  534. LogisticsOneButtonDialog::instance()->update();
  535. if ( LogisticsOneButtonDialog::instance()->isDone() )
  536. {
  537. LogisticsOneButtonDialog::instance()->end();
  538. bHostLeftDlg = 0;
  539. }
  540. if ( MPlayer ) // has to be done, but can't be done when initialized
  541. {
  542. MPlayer->closeSession();
  543. delete MPlayer;
  544. MPlayer = NULL;
  545. }
  546. }
  547. else if ( promptToDisconnect )
  548. {
  549. LogisticsOKDialog::instance()->update();
  550. if ( LogisticsOKDialog::instance()->isDone() )
  551. {
  552. if ( YES == LogisticsOKDialog::instance()->getStatus() )
  553. {
  554. if ( MPlayer )
  555. {
  556. MPlayer->closeSession();
  557. delete MPlayer;
  558. MPlayer = NULL;
  559. }
  560. long oldRes = endResult;
  561. endResult = 0;
  562. handleMessage( oldRes, oldRes );
  563. setDrawBackground( true );
  564. }
  565. else
  566. handleMessage( NEXT, NEXT );
  567. promptToDisconnect = 0;
  568. }
  569. }
  570. else
  571. {
  572. if ( bDrawBackground )
  573. {
  574. if ( !intro.animObjects[0].isDone() )
  575. {
  576. intro.update();
  577. background.update();
  578. if (userInput->getKeyDown(KEY_ESCAPE) || (Environment.Renderer == 3))
  579. {
  580. introOver = true;
  581. userInput->mouseOn();
  582. soundSystem->playDigitalSample( LOG_MAINMENUBUTTON );
  583. }
  584. else if ( !introOver )
  585. return;
  586. }
  587. else
  588. {
  589. background.update();
  590. if ( !introOver )
  591. soundSystem->playDigitalSample( LOG_MAINMENUBUTTON );
  592. introOver = true;
  593. userInput->mouseOn();
  594. }
  595. }
  596. beginAnim.update();
  597. endAnim.update();
  598. LogisticsScreen::update();
  599. if ( (!bLoadSingle) && userInput->isLeftClick() && !inside( userInput->getMouseX(), userInput->getMouseY() ) )
  600. {
  601. handleMessage( 0, MM_MSG_RETURN_TO_GAME );
  602. }
  603. }
  604. }
  605. void MainMenu::render()
  606. {
  607. if (introMovie)
  608. {
  609. introMovie->render();
  610. return;
  611. }
  612. if ( bDrawMechlopedia && (fadeTime > fadeOutTime || !fadeOutTime) )
  613. {
  614. mechlopedia->render();
  615. return;
  616. }
  617. if ( bOptions )
  618. {
  619. optionsScreenWrapper->render();
  620. return;
  621. }
  622. //DO NOT play the splash screen animation in software.
  623. // WOW does it beat up the framerate!
  624. float xDelta = 0.f;
  625. float yDelta = 0.f;
  626. long color = 0xff000000;
  627. if (Environment.Renderer != 3)
  628. {
  629. if ( beginAnim.isAnimating() && !beginAnim.isDone() )
  630. {
  631. xDelta = beginAnim.getXDelta();
  632. yDelta = beginAnim.getYDelta();
  633. float time = beginAnim.getCurrentTime();
  634. float endTime = beginAnim.getMaxTime();
  635. if ( endTime )
  636. {
  637. color = interpolateColor( 0x00000000, 0x7f000000, time/endTime );
  638. }
  639. }
  640. else if (endAnim.isAnimating() /*&& !endAnim.isDone()*/)
  641. {
  642. xDelta = endAnim.getXDelta();
  643. yDelta = endAnim.getYDelta();
  644. float time = endAnim.getCurrentTime();
  645. float endTime = endAnim.getMaxTime();
  646. if ( endTime && (time <= endTime))
  647. {
  648. color = interpolateColor( 0x7f000000, 0x00000000, time/endTime );
  649. }
  650. }
  651. GUI_RECT rect = { 0, 0, Environment.screenWidth, Environment.screenHeight };
  652. drawRect( rect, color );
  653. if ( bDrawBackground )
  654. {
  655. background.render();
  656. intro.render();
  657. if ( !intro.animObjects[0].isDone() && !introOver && !bHostLeftDlg )
  658. return;
  659. }
  660. }
  661. else
  662. {
  663. GUI_RECT rect = { 0, 0, Environment.screenWidth, Environment.screenHeight };
  664. drawRect( rect, color );
  665. }
  666. if ( !xDelta && !yDelta )
  667. {
  668. drawShadowText( 0xffc66600, 0xff000000, textObjects[1].font.getTempHandle(),
  669. textObjects[1].globalX(), textObjects[1].globalTop(),
  670. textObjects[1].globalRight(), textObjects[1].globalBottom(),
  671. true, textObjects[1].text, false, textObjects[1].font.getSize(), 1, 1 );
  672. }
  673. textObjects[1].showGUIWindow( false );
  674. if ( (!bSave && !bLoad && !bLoadSingle && !bLoadCampaign) || (!endAnim.isDone() && endResult != RESTART ) )
  675. LogisticsScreen::render( xDelta, yDelta );
  676. else if ( bLoadSingle )
  677. singleLoadDlg.render();
  678. else
  679. LogisticsSaveDialog::instance()->render();
  680. if ( promptToQuit || promptToDisconnect )
  681. {
  682. LogisticsOKDialog::instance()->render();
  683. }
  684. if ( bLegal )
  685. {
  686. LogisticsLegalDialog::instance()->render();
  687. }
  688. if ( bHostLeftDlg )
  689. {
  690. LogisticsOneButtonDialog::instance()->render();
  691. }
  692. }
  693. void MainMenu::setHostLeftDlg( const char* playerName )
  694. {
  695. char leaveStr[256];
  696. char formatStr[256];
  697. cLoadString( IDS_PLAYER_LEFT, leaveStr, 255 );
  698. sprintf( formatStr, leaveStr, playerName );
  699. LogisticsOneButtonDialog::instance()->setText( IDS_PLAYER_LEFT,
  700. IDS_DIALOG_OK, IDS_DIALOG_OK );
  701. LogisticsOneButtonDialog::instance()->setText( formatStr );
  702. if ( MPlayer && MPlayer->playerInfo[MPlayer->commanderID].booted )
  703. {
  704. LogisticsOneButtonDialog::instance()->setText( IDS_MP_PLAYER_KICKED,
  705. IDS_DIALOG_OK, IDS_DIALOG_OK );
  706. }
  707. LogisticsOneButtonDialog::instance()->begin();
  708. bHostLeftDlg = true;
  709. }
  710. //*************************************************************************************************
  711. // end of file ( MainMenu.cpp )