LoadScreen.cpp 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456
  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: LoadScreen.cpp /////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // created: Mar 2002
  34. //
  35. // Filename: LoadScreen.cpp
  36. //
  37. // author: Chris Huybregts
  38. //
  39. // purpose: Contains each of the different derived LoadClasses for each of the
  40. // Different kind of games we can have.
  41. //
  42. //-----------------------------------------------------------------------------
  43. ///////////////////////////////////////////////////////////////////////////////
  44. //-----------------------------------------------------------------------------
  45. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  46. //-----------------------------------------------------------------------------
  47. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  48. #ifdef _INTERNAL
  49. // for occasional debugging...
  50. //#pragma optimize("", off)
  51. //#pragma message("************************************** WARNING, optimization disabled for debugging purposes")
  52. #endif
  53. //-----------------------------------------------------------------------------
  54. // USER INCLUDES //////////////////////////////////////////////////////////////
  55. //-----------------------------------------------------------------------------
  56. #include "Common/NameKeyGenerator.h"
  57. #include "Common/MultiplayerSettings.h"
  58. #include "Common/GameEngine.h"
  59. #include "Common/GameState.h"
  60. #include "Common/PlayerTemplate.h"
  61. #include "Common/PlayerList.h"
  62. #include "Common/Player.h"
  63. #include "Common/GameLOD.h"
  64. #include "Common/GameAudio.h"
  65. #include "Common/AudioEventRTS.h"
  66. #include "Common/AudioHandleSpecialValues.h"
  67. #include "Common/AudioAffect.h"
  68. #include "GameClient/LoadScreen.h"
  69. #include "GameClient/Shell.h"
  70. #include "GameClient/GameWindowManager.h"
  71. #include "GameClient/GadgetProgressBar.h"
  72. #include "GameClient/GadgetStaticText.h"
  73. #include "GameClient/GameText.h"
  74. #include "GameClient/Display.h"
  75. #include "GameClient/WindowLayout.h"
  76. #include "GameClient/Mouse.h"
  77. #include "GameClient/VideoPlayer.h"
  78. #include "GameClient/MapUtil.h"
  79. #include "GameLogic/FPUControl.h"
  80. #include "GameLogic/GameLogic.h"
  81. #include "GameNetwork/NetworkInterface.h"
  82. #include "GameNetwork/GameSpy/PeerDefs.h"
  83. #include "GameNetwork/GameSpy/PersistentStorageThread.h"
  84. #include "GameClient/CampaignManager.h"
  85. #include "GameNetwork/RankPointValue.h"
  86. #include "GameClient/GameWindowTransitions.h"
  87. //-----------------------------------------------------------------------------
  88. // DEFINES ////////////////////////////////////////////////////////////////////
  89. //-----------------------------------------------------------------------------
  90. #ifdef _INTERNAL
  91. // for occasional debugging...
  92. //#pragma optimize("", off)
  93. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  94. #endif
  95. //-----------------------------------------------------------------------------
  96. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  97. //-----------------------------------------------------------------------------
  98. //-----------------------------------------------------------------------------
  99. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  100. //-----------------------------------------------------------------------------
  101. //-----------------------------------------------------------------------------
  102. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  103. //-----------------------------------------------------------------------------
  104. //-----------------------------------------------------------------------------
  105. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  106. //-----------------------------------------------------------------------------
  107. //-----------------------------------------------------------------------------
  108. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  109. //-----------------------------------------------------------------------------
  110. //-----------------------------------------------------------------------------
  111. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  112. //-----------------------------------------------------------------------------
  113. void positionStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[], GameWindow *mapWindow);
  114. void updateMapStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[], Bool onLoadScreen = FALSE );
  115. void positionAdditionalImages( MapMetaData *mmd, GameWindow *mapWindow, Bool force);
  116. enum{
  117. FRAME_FUDGE_ADD = 30,
  118. };
  119. //-----------------------------------------------------------------------------
  120. // LoadScreen Class
  121. //-----------------------------------------------------------------------------
  122. LoadScreen::LoadScreen( void )
  123. {
  124. m_loadScreen = NULL;
  125. }
  126. LoadScreen::~LoadScreen( void )
  127. {
  128. //if(m_loadScreen)
  129. // delete (m_loadScreen);
  130. if(m_loadScreen)
  131. TheWindowManager->winDestroy( m_loadScreen );
  132. m_loadScreen = NULL;
  133. }
  134. void LoadScreen::update( Int percent )
  135. {
  136. TheGameEngine->serviceWindowsOS();
  137. TheWindowManager->update();
  138. TheDisplay->update();
  139. // redraw all views, update the GUI
  140. TheDisplay->draw();
  141. setFPMode();
  142. }
  143. // SinglePlayerLoadScreen Class ///////////////////////////////////////////////
  144. //-----------------------------------------------------------------------------
  145. SinglePlayerLoadScreen::SinglePlayerLoadScreen( void )
  146. {
  147. //Added By Sadullah Nader
  148. //Initialization(s) inserted
  149. m_currentObjectiveLine = 0;
  150. m_currentObjectiveLineCharacter = 0;
  151. m_finishedObjectiveText = NULL;
  152. m_currentObjectiveWidthOffset = 0;
  153. //
  154. m_progressBar = NULL;
  155. m_percent = NULL;
  156. m_videoStream = NULL;
  157. m_videoBuffer = NULL;
  158. m_objectiveWin = NULL;
  159. for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
  160. m_objectiveLines[i] = NULL;
  161. }
  162. SinglePlayerLoadScreen::~SinglePlayerLoadScreen( void )
  163. {
  164. m_progressBar = NULL;
  165. m_percent = NULL;
  166. m_objectiveWin = NULL;
  167. for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
  168. m_objectiveLines[i] = NULL;
  169. if(m_videoBuffer)
  170. delete m_videoBuffer;
  171. m_videoBuffer = NULL;
  172. if ( m_videoStream )
  173. m_videoStream->close();
  174. m_videoStream = NULL;
  175. TheAudio->removeAudioEvent( m_ambientLoopHandle );
  176. m_ambientLoopHandle = NULL;
  177. }
  178. void SinglePlayerLoadScreen::moveWindows( Int frame )
  179. {
  180. enum{
  181. STATE_BEGIN = 250,
  182. STATE_SHOW_LOCATION = 251,
  183. STATE_BEGIN_BREIFING = 255,
  184. // STATE_BEGIN_ANIMATING_TEXT = 250,
  185. STATE_SHOW_CAMEO_1 = 434,
  186. STATE_BEGIN_ANIMATING_TEXT = 356,
  187. STATE_HIDE_CAMEO_1 = 459,
  188. STATE_SHOW_CAMEO_2 = 464,
  189. STATE_HIDE_CAMEO_2 = 492,
  190. STATE_SHOW_CAMEO_3 = 497,
  191. STATE_HIDE_CAMEO_3 = 524,
  192. // STATE_END_ANIM_HEAD = 450,
  193. STATE_END_ANIMATING_TEXT = 730,
  194. STATE_END = 730
  195. };
  196. if(frame < STATE_BEGIN || frame > STATE_END)
  197. return;
  198. if( frame == STATE_BEGIN_BREIFING)
  199. {
  200. // add sound support here
  201. TheAudio->friend_forcePlayAudioEventRTS(&TheCampaignManager->getCurrentMission()->m_briefingVoice);
  202. }
  203. if( frame == STATE_BEGIN_ANIMATING_TEXT)
  204. {
  205. m_objectiveWin->winHide(FALSE);
  206. // animate the text and stuff
  207. }
  208. if( frame > STATE_BEGIN_ANIMATING_TEXT && frame <= STATE_END_ANIMATING_TEXT && !m_finishedObjectiveText)
  209. {
  210. if(m_currentObjectiveLineCharacter >= m_unicodeObjectiveLines[m_currentObjectiveLine].getLength() )
  211. {
  212. m_currentObjectiveLine++;
  213. m_currentObjectiveLineCharacter =0;
  214. }
  215. if(m_currentObjectiveLine >= MAX_OBJECTIVE_LINES || m_unicodeObjectiveLines[m_currentObjectiveLine].isEmpty())
  216. {
  217. m_finishedObjectiveText = TRUE;
  218. }
  219. else
  220. {
  221. WideChar wChar = m_unicodeObjectiveLines[m_currentObjectiveLine].getCharAt(m_currentObjectiveLineCharacter);
  222. UnicodeString text = GadgetStaticTextGetText(m_objectiveLines[m_currentObjectiveLine]);
  223. text.concat(wChar);
  224. GadgetStaticTextSetText(m_objectiveLines[m_currentObjectiveLine], text);
  225. }
  226. m_currentObjectiveLineCharacter++;
  227. }
  228. switch (frame) {
  229. case STATE_SHOW_LOCATION:
  230. m_location->winHide(FALSE);
  231. break;
  232. case STATE_SHOW_CAMEO_1:
  233. m_unitDesc[0]->winHide(FALSE);
  234. break;
  235. case STATE_HIDE_CAMEO_1:
  236. m_unitDesc[0]->winHide(TRUE);
  237. break;
  238. case STATE_SHOW_CAMEO_2:
  239. m_unitDesc[1]->winHide(FALSE);
  240. break;
  241. case STATE_HIDE_CAMEO_2:
  242. m_unitDesc[1]->winHide(TRUE);
  243. break;
  244. case STATE_SHOW_CAMEO_3:
  245. m_unitDesc[2]->winHide(FALSE);
  246. break;
  247. case STATE_HIDE_CAMEO_3:
  248. m_unitDesc[2]->winHide(TRUE);
  249. break;
  250. }
  251. }
  252. /*
  253. static Bool on = FALSE;
  254. static ICoord2D startPos, endPos;
  255. enum{
  256. STATE_BEGIN = 275,
  257. STATE_BEGIN_ANIM = 290,
  258. STATE_ANIM_CAMEO1 = 300,
  259. STATE_ANIM_CAMEO1_TRASITION_CAMEO2 = 350,
  260. STATE_ANIM_CAMEO2 = 400,
  261. STATE_ANIM_CAMEO2_TRASITION_CAMEO3 = 450,
  262. STATE_ANIM_CAMEO3 = 500,
  263. STATED_END_ANIM = 550,
  264. STATE_END = 800
  265. };
  266. if(frame < STATE_BEGIN)
  267. return;
  268. else if(frame == STATE_BEGIN )
  269. {
  270. m_cameoWindow1->winHide(FALSE);
  271. m_cameoWindow2->winHide(FALSE);
  272. m_cameoWindow3->winHide(FALSE);
  273. m_cameoFrame->winHide(FALSE);
  274. }
  275. else if( frame == STATE_ANIM_CAMEO1)
  276. {
  277. m_cameoWindow1->winEnable(TRUE);
  278. GadgetStaticTextSetText(m_cameoText, TheGameText->fetch(TheCampaignManager->getCurrentMission()->m_cameoImageName[0]));
  279. //save of positions
  280. }
  281. else if( frame == STATE_ANIM_CAMEO1_TRASITION_CAMEO2)
  282. {
  283. m_cameoWindow1->winEnable(FALSE);
  284. GadgetStaticTextSetText(m_cameoText, UnicodeString::TheEmptyString);
  285. ICoord2D tempPos;
  286. Int xOffset;
  287. m_cameoFrame->winGetPosition(&startPos.x, &startPos.y);
  288. m_cameoWindow1->winGetPosition(&tempPos.x, &tempPos.y);
  289. xOffset = tempPos.x - startPos.x;
  290. m_cameoWindow2->winGetPosition(&endPos.x, &endPos.y);
  291. endPos.x = endPos.x - xOffset;
  292. endPos.y = startPos.y;
  293. }
  294. else if( frame > STATE_ANIM_CAMEO1_TRASITION_CAMEO2 && frame < STATE_ANIM_CAMEO2)
  295. {
  296. //extrapolate between start and end pos
  297. Real percent = INT_TO_REAL((frame - STATE_ANIM_CAMEO1_TRASITION_CAMEO2)) / (STATE_ANIM_CAMEO2 - STATE_ANIM_CAMEO1_TRASITION_CAMEO2);
  298. m_cameoFrame->winSetPosition(startPos.x + (endPos.x - startPos.x) * percent, endPos.y);
  299. }
  300. else if( frame == STATE_ANIM_CAMEO2 )
  301. {
  302. m_cameoWindow2->winEnable(TRUE);
  303. m_cameoFrame->winSetPosition(endPos.x, endPos.y);
  304. GadgetStaticTextSetText(m_cameoText, TheGameText->fetch(TheCampaignManager->getCurrentMission()->m_cameoImageName[1]));
  305. }
  306. else if( frame == STATE_ANIM_CAMEO2_TRASITION_CAMEO3)
  307. {
  308. m_cameoWindow2->winEnable(FALSE);
  309. GadgetStaticTextSetText(m_cameoText, UnicodeString::TheEmptyString);
  310. ICoord2D tempPos;
  311. Int xOffset;
  312. m_cameoFrame->winGetPosition(&startPos.x, &startPos.y);
  313. m_cameoWindow2->winGetPosition(&tempPos.x, &tempPos.y);
  314. xOffset = tempPos.x - startPos.x;
  315. m_cameoWindow3->winGetPosition(&endPos.x, &endPos.y);
  316. endPos.x = endPos.x - xOffset;
  317. endPos.y = startPos.y;
  318. }
  319. else if( frame > STATE_ANIM_CAMEO2_TRASITION_CAMEO3 && frame < STATE_ANIM_CAMEO3)
  320. {
  321. //extrapolate between start and end pos
  322. Real percent = INT_TO_REAL((frame - STATE_ANIM_CAMEO2_TRASITION_CAMEO3)) / (STATE_ANIM_CAMEO3 - STATE_ANIM_CAMEO2_TRASITION_CAMEO3);
  323. m_cameoFrame->winSetPosition(startPos.x + (endPos.x - startPos.x) * percent, endPos.y);
  324. }
  325. else if( frame == STATE_ANIM_CAMEO3 )
  326. {
  327. m_cameoFrame->winSetPosition(endPos.x, endPos.y);
  328. m_cameoWindow3->winEnable(TRUE);
  329. GadgetStaticTextSetText(m_cameoText, TheGameText->fetch(TheCampaignManager->getCurrentMission()->m_cameoImageName[2]));
  330. }
  331. else if( frame ==STATED_END_ANIM)
  332. {
  333. m_cameoWindow3->winEnable(FALSE);
  334. GadgetStaticTextSetText(m_cameoText, UnicodeString::TheEmptyString);
  335. m_cameoFrame->winHide(TRUE);
  336. }
  337. }*/
  338. void SinglePlayerLoadScreen::init( GameInfo *game )
  339. {
  340. //No music in SinglePlayerLoadScreen
  341. // create the layout of the load screen
  342. m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/SinglePlayerLoadScreen.wnd" ) );
  343. DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the single player loadscreen"));
  344. m_loadScreen->winHide(FALSE);
  345. m_loadScreen->winBringToTop();
  346. // Mission *mission = TheCampaignManager->getCurrentMission();
  347. // Store the pointer to the progress bar on the loadscreen
  348. m_progressBar = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:ProgressLoad" ) ));
  349. DEBUG_ASSERTCRASH(m_progressBar, ("Can't initialize the progressbar for the single player loadscreen"));
  350. GadgetProgressBarSetProgress(m_progressBar, 0 );
  351. m_percent = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:Percent" ) ));
  352. DEBUG_ASSERTCRASH(m_percent, ("Can't initialize the m_percent for the single player loadscreen"));
  353. GadgetStaticTextSetText(m_percent,UnicodeString(L"0%"));
  354. m_percent->winHide(TRUE);
  355. m_objectiveWin = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:ObjectivesWin" ) ));
  356. DEBUG_ASSERTCRASH(m_objectiveWin, ("Can't initialize the m_objectiveWin for the single player loadscreen"));
  357. m_objectiveWin->winHide(TRUE);
  358. Mission *mission = TheCampaignManager->getCurrentMission();
  359. AsciiString lineName;
  360. for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
  361. {
  362. lineName.format("SinglePlayerLoadScreen.wnd:StaticTextLine%d",i);
  363. m_objectiveLines[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( lineName ));
  364. DEBUG_ASSERTCRASH(m_objectiveLines[i], ("Can't initialize the m_objectiveLines[%d] for the single player loadscreen", i));
  365. GadgetStaticTextSetText(m_objectiveLines[i],UnicodeString::TheEmptyString);
  366. // translate the objective lines
  367. if(mission->m_missionObjectivesLabel[i].isNotEmpty())
  368. m_unicodeObjectiveLines[i] = TheGameText->fetch(mission->m_missionObjectivesLabel[i]);
  369. }
  370. for(i = 0; i < MAX_DISPLAYED_UNITS; ++i)
  371. {
  372. lineName.format("SinglePlayerLoadScreen.wnd:StaticTextCameoText%d",i);
  373. m_unitDesc[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( lineName ));
  374. DEBUG_ASSERTCRASH(m_unitDesc[i], ("Can't initialize the m_objectiveLines[%d] for the single player loadscreen", i));
  375. GadgetStaticTextSetText(m_unitDesc[i],TheGameText->fetch(mission->m_unitNames[i]));
  376. m_unitDesc[i]->winHide(TRUE);
  377. }
  378. m_location = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:StaticTextCameoText3" ) ));
  379. DEBUG_ASSERTCRASH(m_location, ("Can't initialize the m_objectiveWin for the single player loadscreen"));
  380. m_location->winHide(TRUE);
  381. GadgetStaticTextSetText(m_location, TheGameText->fetch(mission->m_locationNameLabel));
  382. m_currentObjectiveLine = 0;
  383. m_currentObjectiveWidthOffset = 0;
  384. m_currentObjectiveLineCharacter = 0;
  385. m_finishedObjectiveText = FALSE;
  386. /*
  387. m_cameoWindow1 = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowCameo1" ) ));
  388. DEBUG_ASSERTCRASH(m_cameoWindow1, ("Can't initialize the m_cameoWindow1 for the single player loadscreen"));
  389. m_cameoWindow1->winHide(TRUE);
  390. m_cameoWindow1->winEnable(FALSE);
  391. m_cameoWindow1->winSetEnabledImage(0, mission->m_cameoImage[0]);
  392. m_cameoWindow1->winSetDisabledImage(0, mission->m_cameoDisabledImage[0]);
  393. m_cameoWindow2 = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowCameo2" ) ));
  394. DEBUG_ASSERTCRASH(m_cameoWindow2, ("Can't initialize the m_cameoWindow2 for the single player loadscreen"));
  395. m_cameoWindow2->winHide(TRUE);
  396. m_cameoWindow2->winEnable(FALSE);
  397. m_cameoWindow2->winSetEnabledImage(0, mission->m_cameoImage[1]);
  398. m_cameoWindow2->winSetDisabledImage(0, mission->m_cameoDisabledImage[1]);
  399. m_cameoWindow3 = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowCameo3" ) ));
  400. DEBUG_ASSERTCRASH(m_cameoWindow3, ("Can't initialize the m_cameoWindow3 for the single player loadscreen"));
  401. m_cameoWindow3->winHide(TRUE);
  402. m_cameoWindow3->winEnable(FALSE);
  403. m_cameoWindow3->winSetEnabledImage(0, mission->m_cameoImage[2]);
  404. m_cameoWindow3->winSetDisabledImage(0, mission->m_cameoDisabledImage[2]);
  405. m_headMovie = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowHead" ) ));
  406. DEBUG_ASSERTCRASH(m_headMovie, ("Can't initialize the m_headMovie for the single player loadscreen"));
  407. m_headMovie->winHide(TRUE);
  408. m_cameoFrame = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowHiliteCameo" ) ));
  409. DEBUG_ASSERTCRASH(m_cameoFrame, ("Can't initialize the m_cameoFrame for the single player loadscreen"));
  410. m_cameoFrame->winHide(TRUE);
  411. m_cameoText = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:StaticTextCameoText" ) ));
  412. DEBUG_ASSERTCRASH(m_cameoText, ("Can't initialize the m_cameoText for the single player loadscreen"));
  413. */
  414. m_ambientLoop.setEventName("LoadScreenAmbient");
  415. // create the new stream
  416. m_videoStream = TheVideoPlayer->open( TheCampaignManager->getCurrentMission()->m_movieLabel );
  417. if ( m_videoStream == NULL )
  418. {
  419. m_percent->winHide(TRUE);
  420. return;
  421. }
  422. // Create the new buffer
  423. m_videoBuffer = TheDisplay->createVideoBuffer();
  424. if ( m_videoBuffer == NULL ||
  425. !m_videoBuffer->allocate( m_videoStream->width(),
  426. m_videoStream->height())
  427. )
  428. {
  429. delete m_videoBuffer;
  430. m_videoBuffer = NULL;
  431. if ( m_videoStream )
  432. m_videoStream->close();
  433. m_videoStream = NULL;
  434. return;
  435. }
  436. if(TheGameLODManager && TheGameLODManager->didMemPass())
  437. {
  438. Int progressUpdateCount = m_videoStream->frameCount() / FRAME_FUDGE_ADD;
  439. Int shiftedPercent = -FRAME_FUDGE_ADD + 1;
  440. while (m_videoStream->frameIndex() < m_videoStream->frameCount() - 1 )
  441. {
  442. TheGameEngine->serviceWindowsOS();
  443. if(!m_videoStream->isFrameReady())
  444. {
  445. Sleep(1);
  446. continue;
  447. }
  448. if (!TheGameEngine->isActive())
  449. { //we are alt-tabbed out, so just increment the frame
  450. m_videoStream->frameNext();
  451. m_videoStream->frameDecompress();
  452. continue;
  453. }
  454. m_videoStream->frameDecompress();
  455. m_videoStream->frameRender(m_videoBuffer);
  456. moveWindows( m_videoStream->frameIndex());
  457. m_videoStream->frameNext();
  458. if(m_videoBuffer)
  459. m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);
  460. if(m_videoStream->frameIndex() % progressUpdateCount == 0)
  461. {
  462. shiftedPercent++;
  463. if(shiftedPercent >0)
  464. shiftedPercent = 0;
  465. Int percent = (shiftedPercent + FRAME_FUDGE_ADD)/1.3;
  466. UnicodeString per;
  467. per.format(L"%d%%",percent);
  468. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  469. GadgetProgressBarSetProgress(m_progressBar, percent);
  470. GadgetStaticTextSetText(m_percent, per);
  471. }
  472. TheWindowManager->update();
  473. //TheShell->update();
  474. //TheDisplay->update();
  475. // redraw all views, update the GUI
  476. TheDisplay->draw();
  477. }
  478. }
  479. else
  480. {
  481. // if we're min speced
  482. m_videoStream->frameGoto(m_videoStream->frameCount()); // zero based
  483. while(!m_videoStream->isFrameReady())
  484. Sleep(1);
  485. m_videoStream->frameDecompress();
  486. m_videoStream->frameRender(m_videoBuffer);
  487. if(m_videoBuffer)
  488. m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);
  489. m_objectiveWin->winHide(FALSE);
  490. for(i = 0; i < MAX_DISPLAYED_UNITS; ++i)
  491. m_unitDesc[i]->winHide(FALSE);
  492. m_location->winHide(FALSE);
  493. // Audio was choppy so, I chopped it out!
  494. TheAudio->friend_forcePlayAudioEventRTS(&TheCampaignManager->getCurrentMission()->m_briefingVoice);
  495. for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
  496. {
  497. GadgetStaticTextSetText(m_objectiveLines[i], m_unicodeObjectiveLines[i]);
  498. }
  499. Int delay = mission->m_voiceLength * 1000;
  500. Int begin = timeGetTime();
  501. Int currTime = begin;
  502. Int fudgeFactor = 0;
  503. while(begin + delay > currTime )
  504. {
  505. fudgeFactor = 30 * ((currTime - begin)/ INT_TO_REAL(delay ));
  506. GadgetProgressBarSetProgress(m_progressBar, fudgeFactor);
  507. TheWindowManager->update();
  508. TheDisplay->draw();
  509. Sleep(100);
  510. currTime = timeGetTime();
  511. }
  512. TheWindowManager->update();
  513. TheDisplay->draw();
  514. }
  515. setFPMode();
  516. m_percent->winHide(TRUE);
  517. m_ambientLoopHandle = TheAudio->addAudioEvent(&m_ambientLoop);
  518. }
  519. void SinglePlayerLoadScreen::reset( void )
  520. {
  521. setLoadScreen(NULL);
  522. m_progressBar = NULL;
  523. }
  524. void SinglePlayerLoadScreen::update( Int percent )
  525. {
  526. percent = (percent + FRAME_FUDGE_ADD)/1.3;
  527. UnicodeString per;
  528. per.format(L"%d%%",percent);
  529. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  530. GadgetProgressBarSetProgress(m_progressBar, percent);
  531. GadgetStaticTextSetText(m_percent, per);
  532. // Do this last!
  533. LoadScreen::update( percent );
  534. }
  535. void SinglePlayerLoadScreen::setProgressRange( Int min, Int max )
  536. {
  537. }
  538. // ShellGameLoadScreen Class //////////////////////////////////////////////////
  539. //-----------------------------------------------------------------------------
  540. ShellGameLoadScreen::ShellGameLoadScreen( void )
  541. {
  542. m_progressBar = NULL;
  543. }
  544. ShellGameLoadScreen::~ShellGameLoadScreen( void )
  545. {
  546. m_progressBar = NULL;
  547. }
  548. void ShellGameLoadScreen::init( GameInfo *game )
  549. {
  550. static BOOL firstLoad = TRUE;
  551. // create the layout of the load screen
  552. m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/ShellGameLoadScreen.wnd" ) );
  553. DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the ShellGame loadscreen"));
  554. m_loadScreen->winHide(FALSE);
  555. m_loadScreen->winBringToTop();
  556. // Store the pointer to the progress bar on the loadscreen
  557. m_progressBar = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "ShellGameLoadScreen.wnd:ProgressLoad" ) ));
  558. DEBUG_ASSERTCRASH(m_progressBar, ("Can't initialize the progressbar for the single player loadscreen"));
  559. GadgetProgressBarSetProgress(m_progressBar, 0 );
  560. m_progressBar->winHide(TRUE);
  561. if(m_loadScreen && firstLoad && TheGameLODManager && TheGameLODManager->didMemPass())
  562. {
  563. m_loadScreen->winSetEnabledImage(0, TheMappedImageCollection->findImageByName("TitleScreen"));
  564. TheWritableGlobalData->m_breakTheMovie = FALSE;
  565. // m_videoStream = TheVideoPlayer->open( "Sizzle" );
  566. // if ( m_videoStream == NULL )
  567. // {
  568. // m_progressBar->winHide(FALSE);
  569. // return;
  570. // }
  571. //
  572. // // Create the new buffer
  573. // m_videoBuffer = TheDisplay->createVideoBuffer();
  574. // if ( m_videoBuffer == NULL ||
  575. // !m_videoBuffer->allocate( m_videoStream->width(),
  576. // m_videoStream->height())
  577. // )
  578. // {
  579. // delete m_videoBuffer;
  580. // m_videoBuffer = NULL;
  581. //
  582. // if ( m_videoStream )
  583. // m_videoStream->close();
  584. // m_videoStream = NULL;
  585. //
  586. // return;
  587. // }
  588. // TheGlobalData->m_isBreakableMovie = TRUE;
  589. // TheGlobalData->m_breakTheMovie = FALSE;
  590. // while (m_videoStream->frameIndex() < m_videoStream->frameCount() - 1 )
  591. // {
  592. // if(TheGlobalData->m_breakTheMovie)
  593. // {
  594. // TheGlobalData->m_breakTheMovie = FALSE;
  595. // m_videoStream->frameGoto(m_videoStream->frameCount() - 1);
  596. // }
  597. // if(m_videoStream->frameIndex() < m_videoStream->frameCount() - 1)
  598. // {
  599. // if(!m_videoStream->isFrameReady())
  600. // continue;
  601. //
  602. // m_videoStream->frameDecompress();
  603. // m_videoStream->frameRender(m_videoBuffer);
  604. // m_videoStream->frameNext();
  605. // if(m_videoBuffer)
  606. // m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);
  607. // }
  608. //
  609. // TheWindowManager->update();
  610. // // TheShell->update();
  611. // //TheDisplay->update();
  612. // // redraw all views, update the GUI
  613. // TheDisplay->draw();
  614. // }
  615. // TheGlobalData->m_isBreakableMovie = FALSE;
  616. // TheGlobalData->m_breakTheMovie = FALSE;
  617. // GameWindow *win = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "ShellGameLoadScreen.wnd:EAGamesLogo" ) ));
  618. // if(win)
  619. // win->winHide(FALSE);
  620. GameWindow *win = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "ShellGameLoadScreen.wnd:StaticTextLegal" ) ));
  621. if(win)
  622. win->winHide(FALSE);
  623. firstLoad = FALSE;
  624. UnsignedInt showTime = timeGetTime();
  625. while(showTime + 3000 > timeGetTime())
  626. {
  627. LoadScreen::update(0);
  628. Sleep(100);
  629. }
  630. }
  631. m_progressBar->winHide(FALSE);
  632. }
  633. void ShellGameLoadScreen::reset( void )
  634. {
  635. setLoadScreen(NULL);
  636. m_progressBar = NULL;
  637. }
  638. void ShellGameLoadScreen::update( Int percent )
  639. {
  640. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  641. GadgetProgressBarSetProgress(m_progressBar, percent);
  642. // Do this last!
  643. LoadScreen::update( percent );
  644. }
  645. // MultiPlayerLoadScreen Class //////////////////////////////////////////////////
  646. //-----------------------------------------------------------------------------
  647. MultiPlayerLoadScreen::MultiPlayerLoadScreen( void )
  648. {
  649. //Added By Sadullah Nader
  650. //Initializations missing and needed
  651. m_mapPreview = NULL;
  652. //
  653. for(Int i = 0; i < MAX_SLOTS; ++i)
  654. {
  655. //Added By Sadullah Nader
  656. //Initializations missing and needed
  657. m_buttonMapStartPosition[i] = NULL;
  658. //
  659. m_progressBars[i] = NULL;
  660. m_playerNames[i] = NULL;
  661. m_playerSide[i]= NULL;
  662. m_playerLookup[i] = -1;
  663. }
  664. }
  665. MultiPlayerLoadScreen::~MultiPlayerLoadScreen( void )
  666. {
  667. for(Int i = 0; i < MAX_SLOTS; ++i)
  668. {
  669. m_progressBars[i] = NULL;
  670. m_playerNames[i] = NULL;
  671. m_playerSide[i]= NULL;
  672. m_playerLookup[i] = -1;
  673. }
  674. TheAudio->removeAudioEvent( AHSV_StopTheMusicFade );
  675. // TheAudio->stopAudio( AudioAffect_Music );
  676. }
  677. void MultiPlayerLoadScreen::init( GameInfo *game )
  678. {
  679. // create the layout of the load screen
  680. m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/MultiplayerLoadScreen.wnd" ) );
  681. DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the Multiplayer loadscreen"));
  682. m_loadScreen->winHide(FALSE);
  683. m_loadScreen->winBringToTop();
  684. m_mapPreview = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "MultiplayerLoadScreen.wnd:WinMapPreview"));
  685. GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
  686. const PlayerTemplate* pt;
  687. if (lSlot->getPlayerTemplate() >= 0)
  688. pt = ThePlayerTemplateStore->getNthPlayerTemplate(lSlot->getPlayerTemplate());
  689. else
  690. pt = ThePlayerTemplateStore->findPlayerTemplate( TheNameKeyGenerator->nameToKey("FactionObserver") );
  691. const Image *loadScreenImage = TheMappedImageCollection->findImageByName(pt->getLoadScreen());
  692. AsciiString musicName = pt->getLoadScreenMusic();
  693. if ( ! musicName.isEmpty() )
  694. {
  695. TheAudio->removeAudioEvent( AHSV_StopTheMusicFade );
  696. AudioEventRTS event( musicName );
  697. event.setShouldFade( TRUE );
  698. TheAudio->addAudioEvent( &event );
  699. TheAudio->update();//Since GameEngine::update() is suspended until after I am gone...
  700. }
  701. if(loadScreenImage)
  702. m_loadScreen->winSetEnabledImage(0, loadScreenImage);
  703. //DEBUG_ASSERTCRASH(TheNetwork, ("Where the Heck is the Network!!!!"));
  704. //DEBUG_LOG(("NumPlayers %d\n", TheNetwork->getNumPlayers()));
  705. GameWindow *teamWin[MAX_SLOTS];
  706. for (Int i = 0; i < MAX_SLOTS; ++i)
  707. {
  708. teamWin[i] = NULL;
  709. }
  710. Int netSlot = 0;
  711. // Loop through and make the loadscreen look all good.
  712. for (i = 0; i < MAX_SLOTS; ++i)
  713. {
  714. // Load the Progress Bar
  715. AsciiString winName;
  716. winName.format( "MultiplayerLoadScreen.wnd:ProgressLoad%d",i);
  717. m_progressBars[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  718. DEBUG_ASSERTCRASH(m_progressBars[i], ("Can't initialize the progressbars for the Multiplayer loadscreen"));
  719. // set the progressbar to zero
  720. GadgetProgressBarSetProgress(m_progressBars[i], 0 );
  721. // Load MapStart Positions
  722. winName.format( "MultiplayerLoadScreen.wnd:ButtonMapStartPosition%d",i);
  723. m_buttonMapStartPosition[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  724. DEBUG_ASSERTCRASH(m_buttonMapStartPosition[i], ("Can't initialize the MapStart Positions for the MultiplayerLoadScreen loadscreen"));
  725. // Load the Player's name
  726. winName.format( "MultiplayerLoadScreen.wnd:StaticTextPlayer%d",i);
  727. m_playerNames[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  728. DEBUG_ASSERTCRASH(m_playerNames[i], ("Can't initialize the Names for the Multiplayer loadscreen"));
  729. // Load the Player's Side
  730. winName.format( "MultiplayerLoadScreen.wnd:StaticTextSide%d",i);
  731. m_playerSide[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  732. DEBUG_ASSERTCRASH(m_playerSide[i], ("Can't initialize the Sides for the Multiplayer loadscreen"));
  733. winName.format( "MultiplayerLoadScreen.wnd:StaticTextTeam%d",i);
  734. teamWin[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  735. // get the slot man!
  736. GameSlot *slot = game->getSlot(i);
  737. if (!slot || !slot->isOccupied())
  738. continue;
  739. Color houseColor = TheMultiplayerSettings->getColor(slot->getApparentColor())->getColor();
  740. GadgetProgressBarSetEnabledBarColor(m_progressBars[netSlot],houseColor );
  741. UnicodeString name = slot->getName();
  742. GadgetStaticTextSetText(m_playerNames[netSlot], name );
  743. m_playerNames[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
  744. GadgetStaticTextSetText(m_playerSide[netSlot], slot->getApparentPlayerTemplateDisplayName() );
  745. m_playerSide[netSlot]->winSetEnabledTextColors(houseColor, m_playerSide[netSlot]->winGetEnabledTextBorderColor());
  746. if (slot->isAI() && m_progressBars[netSlot])
  747. m_progressBars[netSlot]->winHide(TRUE);
  748. if (teamWin[netSlot])
  749. {
  750. AsciiString teamStr;
  751. teamStr.format("Team:%d", slot->getTeamNumber() + 1);
  752. GadgetStaticTextSetText(teamWin[netSlot], TheGameText->fetch(teamStr));
  753. teamWin[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
  754. }
  755. m_playerLookup[i] = netSlot; // save our mapping so we can update progress correctly
  756. netSlot++;
  757. }
  758. for(i = netSlot; i < MAX_SLOTS; ++i)
  759. {
  760. m_progressBars[i]->winHide(TRUE);
  761. m_playerNames[i]->winHide(TRUE);
  762. m_playerSide[i]->winHide(TRUE);
  763. teamWin[i]->winHide(TRUE);
  764. }
  765. if(m_mapPreview)
  766. {
  767. const MapMetaData *mmd = TheMapCache->findMap(game->getMap());
  768. Image *image = getMapPreviewImage(game->getMap());
  769. m_mapPreview->winSetUserData((void *)mmd);
  770. positionStartSpots( game, m_buttonMapStartPosition, m_mapPreview);
  771. updateMapStartSpots( game, m_buttonMapStartPosition, TRUE );
  772. //positionAdditionalImages((MapMetaData *)mmd, m_mapPreview, TRUE);
  773. if(image)
  774. {
  775. m_mapPreview->winSetStatus(WIN_STATUS_IMAGE);
  776. m_mapPreview->winSetEnabledImage(0, image);
  777. }
  778. else
  779. {
  780. m_mapPreview->winClearStatus(WIN_STATUS_IMAGE);
  781. }
  782. }
  783. TheGameLogic->initTimeOutValues();
  784. }
  785. void MultiPlayerLoadScreen::reset( void )
  786. {
  787. setLoadScreen(NULL);
  788. for(Int i = 0; i < MAX_SLOTS; ++i)
  789. {
  790. m_progressBars[i] = NULL;
  791. m_playerNames[i] = NULL;
  792. m_playerSide[i]= NULL;
  793. }
  794. }
  795. void MultiPlayerLoadScreen::update( Int percent )
  796. {
  797. if (TheNetwork)
  798. {
  799. if(percent <= 100)
  800. TheNetwork->updateLoadProgress( percent );
  801. TheNetwork->liteupdate();
  802. }
  803. else
  804. {
  805. if (percent <= 100)
  806. TheGameLogic->processProgress( TheGameInfo->getLocalSlotNum(), percent );
  807. }
  808. //GadgetProgressBarSetProgress(m_progressBars[TheNetwork->getLocalPlayerID()], percent );
  809. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  810. // Do this last!
  811. LoadScreen::update( percent );
  812. }
  813. void MultiPlayerLoadScreen::processProgress(Int playerId, Int percentage)
  814. {
  815. if( percentage < 0 || percentage > 100 || playerId >= MAX_SLOTS || playerId < 0 || m_playerLookup[playerId] == -1)
  816. {
  817. DEBUG_ASSERTCRASH(FALSE, ("Percentage %d was passed in for Player %d\n", percentage, playerId));
  818. }
  819. //DEBUG_LOG(("Percentage %d was passed in for Player %d (in loadscreen position %d)\n", percentage, playerId, m_playerLookup[playerId]));
  820. if(m_progressBars[m_playerLookup[playerId]])
  821. GadgetProgressBarSetProgress(m_progressBars[m_playerLookup[playerId]], percentage );
  822. }
  823. // GameSpyLoadScreen Class //////////////////////////////////////////////////
  824. //-----------------------------------------------------------------------------
  825. GameSpyLoadScreen::GameSpyLoadScreen( void )
  826. {
  827. // Added By Sadullah Nader
  828. // Initializations missing and needed
  829. m_mapPreview = NULL;
  830. //
  831. for(Int i = 0; i < MAX_SLOTS; ++i)
  832. {
  833. // Added By Sadullah Nader
  834. // Initializations missing and needed
  835. m_buttonMapStartPosition[i] = NULL;
  836. m_playerRank[i] = NULL;
  837. //
  838. m_playerOfficerMedal[i] = NULL;
  839. m_progressBars[i] = NULL;
  840. m_playerNames[i] = NULL;
  841. m_playerSide[i]= NULL;
  842. m_playerLookup[i] = -1;
  843. m_playerFavoriteFactions[i]= NULL;
  844. m_playerTotalDisconnects[i]= NULL;
  845. m_playerWin[i]= NULL;
  846. m_playerWinLosses[i]= NULL;
  847. }
  848. }
  849. GameSpyLoadScreen::~GameSpyLoadScreen( void )
  850. {
  851. for(Int i = 0; i < MAX_SLOTS; ++i)
  852. {
  853. m_progressBars[i] = NULL;
  854. m_playerNames[i] = NULL;
  855. m_playerSide[i]= NULL;
  856. m_playerLookup[i] = -1;
  857. m_playerFavoriteFactions[i]= NULL;
  858. m_playerTotalDisconnects[i]= NULL;
  859. m_playerWin[i]= NULL;
  860. m_playerWinLosses[i]= NULL;
  861. }
  862. }
  863. extern Int GetAdditionalDisconnectsFromUserFile(Int playerID);
  864. void GameSpyLoadScreen::init( GameInfo *game )
  865. {
  866. // create the layout of the load screen
  867. m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/GameSpyLoadScreen.wnd" ) );
  868. DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the Multiplayer loadscreen"));
  869. m_loadScreen->winHide(FALSE);
  870. m_loadScreen->winBringToTop();
  871. m_mapPreview = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "GameSpyLoadScreen.wnd:WinMapPreview"));
  872. DEBUG_ASSERTCRASH(TheNetwork, ("Where the Heck is the Network!!!!"));
  873. DEBUG_LOG(("NumPlayers %d\n", TheNetwork->getNumPlayers()));
  874. GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
  875. const PlayerTemplate* pt;
  876. if (lSlot->getPlayerTemplate() >= 0)
  877. pt = ThePlayerTemplateStore->getNthPlayerTemplate(lSlot->getPlayerTemplate());
  878. else
  879. pt = ThePlayerTemplateStore->findPlayerTemplate( TheNameKeyGenerator->nameToKey("FactionObserver") );
  880. const Image *loadScreenImage = TheMappedImageCollection->findImageByName(pt->getLoadScreen());
  881. if(loadScreenImage)
  882. m_loadScreen->winSetEnabledImage(0, loadScreenImage);
  883. GameWindow *teamWin[MAX_SLOTS];
  884. for (Int i = 0; i < MAX_SLOTS; ++i)
  885. {
  886. teamWin[i] = NULL;
  887. }
  888. Int netSlot = 0;
  889. // Loop through and make the loadscreen look all good.
  890. for (i = 0; i < MAX_SLOTS; ++i)
  891. {
  892. // Load the Progress Bar
  893. AsciiString winName;
  894. winName.format( "GameSpyLoadScreen.wnd:ProgressLoad%d",i);
  895. m_progressBars[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  896. DEBUG_ASSERTCRASH(m_progressBars[i], ("Can't initialize the progressbars for the GameSpyLoadScreen loadscreen"));
  897. // set the progressbar to zero
  898. GadgetProgressBarSetProgress(m_progressBars[i], 0 );
  899. // Load the Player's name
  900. winName.format( "GameSpyLoadScreen.wnd:StaticTextPlayer%d",i);
  901. m_playerNames[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  902. DEBUG_ASSERTCRASH(m_playerNames[i], ("Can't initialize the Names for the GameSpyLoadScreen loadscreen"));
  903. // Load MapStart Positions
  904. winName.format( "GameSpyLoadScreen.wnd:ButtonMapStartPosition%d",i);
  905. m_buttonMapStartPosition[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  906. DEBUG_ASSERTCRASH(m_buttonMapStartPosition[i], ("Can't initialize the MapStart Positions for the GameSpyLoadScreen loadscreen"));
  907. // Load the Player's Side
  908. winName.format( "GameSpyLoadScreen.wnd:StaticTextSide%d",i);
  909. m_playerSide[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  910. DEBUG_ASSERTCRASH(m_playerSide[i], ("Can't initialize the Sides for the GameSpyLoadScreen loadscreen"));
  911. // Load the Player's window
  912. winName.format( "GameSpyLoadScreen.wnd:WinPlayer%d",i);
  913. m_playerWin[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  914. DEBUG_ASSERTCRASH(m_playerWin[i], ("Can't initialize the WinPlayer for the GameSpyLoadScreen loadscreen"));
  915. // Load the Player's m_playerTotalDisconnects
  916. winName.format( "GameSpyLoadScreen.wnd:StaticTextTotalDisconnects%d",i);
  917. m_playerTotalDisconnects[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  918. DEBUG_ASSERTCRASH(m_playerTotalDisconnects[i], ("Can't initialize the m_playerTotalDisconnects for the GameSpyLoadScreen loadscreen"));
  919. // // Load the Player's m_playerFavoriteFactions
  920. // winName.format( "GameSpyLoadScreen.wnd:StaticTextFavoriteFaction%d",i);
  921. // m_playerFavoriteFactions[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  922. // DEBUG_ASSERTCRASH(m_playerFavoriteFactions[i], ("Can't initialize the StaticTextFavoriteFaction for the GameSpyLoadScreen loadscreen"));
  923. // Load the Player's m_playerWinLosses
  924. winName.format( "GameSpyLoadScreen.wnd:StaticTextWinLoss%d",i);
  925. m_playerWinLosses[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  926. DEBUG_ASSERTCRASH(m_playerWinLosses[i], ("Can't initialize the m_playerWinLosses for the GameSpyLoadScreen loadscreen"));
  927. // Load the Player's m_playerWinLosses
  928. winName.format( "GameSpyLoadScreen.wnd:WinRank%d",i);
  929. m_playerRank[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  930. DEBUG_ASSERTCRASH(m_playerRank[i], ("Can't initialize the m_playerRank for the GameSpyLoadScreen loadscreen"));
  931. // Load the Player's m_playerOfficerMedal
  932. winName.format( "GameSpyLoadScreen.wnd:WinOfficer%d",i);
  933. m_playerOfficerMedal[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  934. DEBUG_ASSERTCRASH(m_playerOfficerMedal[i], ("Can't initialize the m_playerOfficerMedal for the GameSpyLoadScreen loadscreen"));
  935. winName.format( "MultiplayerLoadScreen.wnd:StaticTextTeam%d",i);
  936. teamWin[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  937. // get the slot man!
  938. GameSpyGameSlot *slot = (GameSpyGameSlot *)game->getSlot(i);
  939. if (!slot || !slot->isOccupied())
  940. continue;
  941. Color houseColor = TheMultiplayerSettings->getColor(slot->getApparentColor())->getColor();
  942. GadgetProgressBarSetEnabledBarColor(m_progressBars[netSlot],houseColor );
  943. UnicodeString name = slot->getName();
  944. GadgetStaticTextSetText(m_playerNames[netSlot], name );
  945. m_playerNames[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
  946. // Get the stats for the player
  947. PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(slot->getProfileID());
  948. DEBUG_LOG(("LoadScreen - populating info for %ls(%d) - stats returned id %d\n",
  949. slot->getName().str(), slot->getProfileID(), stats.id));
  950. Bool isPreorder = TheGameSpyInfo->didPlayerPreorder(stats.id);
  951. Int rankPoints = CalculateRank(stats);
  952. Int favSide = GetFavoriteSide(stats);
  953. const Image *preorderImg = TheMappedImageCollection->findImageByName("OfficersClubsmall");
  954. if (!isPreorder)
  955. preorderImg = NULL;
  956. const Image *rankImg = LookupSmallRankImage(favSide, rankPoints);
  957. m_playerOfficerMedal[i]->winSetEnabledImage(0, preorderImg);
  958. m_playerRank[i]->winSetEnabledImage(0, rankImg);
  959. UnicodeString formatString;
  960. // pop wins and losses
  961. Int numLosses = 0;
  962. PerGeneralMap::iterator it;
  963. for(it = stats.losses.begin(); it != stats.losses.end(); ++it)
  964. {
  965. numLosses += it->second;
  966. }
  967. Int numWins = 0;
  968. for(it =stats.wins.begin(); it != stats.wins.end(); ++it)
  969. {
  970. numWins += it->second;
  971. }
  972. formatString.format(L"%d/%d", numWins, numLosses);
  973. GadgetStaticTextSetText(m_playerWinLosses[netSlot], formatString);
  974. m_playerWinLosses[netSlot]->winSetEnabledTextColors(houseColor, m_playerWinLosses[netSlot]->winGetEnabledTextBorderColor());
  975. // favoriteFaction
  976. Int numGames = 0;
  977. Int favorite = 0;
  978. for(it =stats.games.begin(); it != stats.games.end(); ++it)
  979. {
  980. if(it->second >= numGames)
  981. {
  982. numGames = it->second;
  983. favorite = it->first;
  984. }
  985. }
  986. // if(numGames == 0)
  987. // GadgetStaticTextSetText(m_playerFavoriteFactions[netSlot], TheGameText->fetch("GUI:None"));
  988. // else if( stats.gamesAsRandom > numGames )
  989. // GadgetStaticTextSetText(m_playerFavoriteFactions[netSlot], TheGameText->fetch("GUI:Random"));
  990. // else
  991. // {
  992. // const PlayerTemplate *fac = ThePlayerTemplateStore->getNthPlayerTemplate(favorite);
  993. // if (fac)
  994. // {
  995. // AsciiString side;
  996. // side.format("SIDE:%s", fac->getSide().str());
  997. //
  998. // GadgetStaticTextSetText(m_playerFavoriteFactions[netSlot], TheGameText->fetch(side));
  999. // }
  1000. // }
  1001. // m_playerFavoriteFactions[netSlot]->winSetEnabledTextColors(houseColor, m_playerFavoriteFactions[netSlot]->winGetEnabledTextBorderColor());
  1002. // disconnects
  1003. numGames = 0;
  1004. for(it =stats.discons.begin(); it != stats.discons.end(); ++it)
  1005. {
  1006. numGames += it->second;
  1007. }
  1008. for(it =stats.desyncs.begin(); it != stats.desyncs.end(); ++it)
  1009. {
  1010. numGames += it->second;
  1011. }
  1012. numGames += GetAdditionalDisconnectsFromUserFile(stats.id);
  1013. formatString.format(L"%d", numGames);
  1014. GadgetStaticTextSetText(m_playerTotalDisconnects[netSlot], formatString);
  1015. m_playerTotalDisconnects[netSlot]->winSetEnabledTextColors(houseColor, m_playerTotalDisconnects[netSlot]->winGetEnabledTextBorderColor());
  1016. GadgetStaticTextSetText(m_playerSide[netSlot], slot->getApparentPlayerTemplateDisplayName() );
  1017. m_playerSide[netSlot]->winSetEnabledTextColors(houseColor, m_playerSide[netSlot]->winGetEnabledTextBorderColor());
  1018. if (slot->isAI())
  1019. {
  1020. if (m_progressBars[netSlot])
  1021. m_progressBars[netSlot]->winHide(TRUE);
  1022. if (m_playerTotalDisconnects[netSlot])
  1023. m_playerTotalDisconnects[netSlot]->winHide(TRUE);
  1024. // if (m_playerFavoriteFactions[netSlot])
  1025. // m_playerFavoriteFactions[netSlot]->winHide(TRUE);
  1026. if (m_playerWinLosses[netSlot])
  1027. m_playerWinLosses[netSlot]->winHide(TRUE);
  1028. if (m_playerRank[netSlot])
  1029. m_playerRank[netSlot]->winHide(TRUE);
  1030. if (m_playerOfficerMedal[netSlot])
  1031. m_playerOfficerMedal[netSlot]->winHide(TRUE);
  1032. }
  1033. if (teamWin[netSlot])
  1034. {
  1035. AsciiString teamStr;
  1036. teamStr.format("Team:%d", slot->getTeamNumber() + 1);
  1037. if (slot->isAI() && slot->getTeamNumber() == -1)
  1038. teamStr = "Team:AI";
  1039. GadgetStaticTextSetText(teamWin[netSlot], TheGameText->fetch(teamStr));
  1040. teamWin[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
  1041. }
  1042. m_playerLookup[i] = netSlot; // save our mapping so we can update progress correctly
  1043. netSlot++;
  1044. }
  1045. for(i = netSlot; i < MAX_SLOTS; ++i)
  1046. {
  1047. m_playerWin[i]->winHide(TRUE);
  1048. //m_playerNames[i]->winHide(TRUE);
  1049. //m_playerSide[i]->winHide(TRUE);
  1050. }
  1051. if(m_mapPreview)
  1052. {
  1053. const MapMetaData *mmd = TheMapCache->findMap(game->getMap());
  1054. Image *image = getMapPreviewImage(game->getMap());
  1055. m_mapPreview->winSetUserData((void *)mmd);
  1056. positionStartSpots( game, m_buttonMapStartPosition, m_mapPreview);
  1057. updateMapStartSpots( game, m_buttonMapStartPosition, TRUE );
  1058. //positionAdditionalImages((MapMetaData *)mmd, m_mapPreview, TRUE);
  1059. if(image)
  1060. {
  1061. m_mapPreview->winSetStatus(WIN_STATUS_IMAGE);
  1062. m_mapPreview->winSetEnabledImage(0, image);
  1063. }
  1064. else
  1065. {
  1066. m_mapPreview->winClearStatus(WIN_STATUS_IMAGE);
  1067. }
  1068. }
  1069. TheGameLogic->initTimeOutValues();
  1070. }
  1071. void GameSpyLoadScreen::reset( void )
  1072. {
  1073. setLoadScreen(NULL);
  1074. for(Int i = 0; i < MAX_SLOTS; ++i)
  1075. {
  1076. m_progressBars[i] = NULL;
  1077. m_playerNames[i] = NULL;
  1078. m_playerSide[i]= NULL;
  1079. }
  1080. }
  1081. void GameSpyLoadScreen::update( Int percent )
  1082. {
  1083. if(percent <= 100)
  1084. TheNetwork->updateLoadProgress( percent );
  1085. TheNetwork->liteupdate();
  1086. //GadgetProgressBarSetProgress(m_progressBars[TheNetwork->getLocalPlayerID()], percent );
  1087. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  1088. // Do this last!
  1089. LoadScreen::update( percent );
  1090. }
  1091. void GameSpyLoadScreen::processProgress(Int playerId, Int percentage)
  1092. {
  1093. if( percentage < 0 || percentage > 100 || playerId >= MAX_SLOTS || playerId < 0 || m_playerLookup[playerId] == -1)
  1094. {
  1095. DEBUG_ASSERTCRASH(FALSE, ("Percentage %d was passed in for Player %d\n", percentage, playerId));
  1096. }
  1097. //DEBUG_LOG(("Percentage %d was passed in for Player %d (in loadscreen position %d)\n", percentage, playerId, m_playerLookup[playerId]));
  1098. if(m_progressBars[m_playerLookup[playerId]])
  1099. GadgetProgressBarSetProgress(m_progressBars[m_playerLookup[playerId]], percentage );
  1100. }
  1101. // MapTransferLoadScreen Class //////////////////////////////////////////////////
  1102. //-----------------------------------------------------------------------------
  1103. MapTransferLoadScreen::MapTransferLoadScreen( void )
  1104. {
  1105. //Added By Sadullah Nader
  1106. //Initializations missing and needed
  1107. m_oldTimeout = 0;
  1108. //
  1109. for(Int i = 0; i < MAX_SLOTS; ++i)
  1110. {
  1111. m_progressBars[i] = NULL;
  1112. m_playerNames[i] = NULL;
  1113. m_progressText[i]= NULL;
  1114. m_playerLookup[i] = -1;
  1115. m_oldProgress[i] = -1;
  1116. }
  1117. m_fileNameText = NULL;
  1118. m_timeoutText = NULL;
  1119. }
  1120. MapTransferLoadScreen::~MapTransferLoadScreen( void )
  1121. {
  1122. for(Int i = 0; i < MAX_SLOTS; ++i)
  1123. {
  1124. m_progressBars[i] = NULL;
  1125. m_playerNames[i] = NULL;
  1126. m_progressText[i]= NULL;
  1127. m_playerLookup[i] = -1;
  1128. m_oldProgress[i] = -1;
  1129. }
  1130. m_fileNameText = NULL;
  1131. m_timeoutText = NULL;
  1132. }
  1133. void MapTransferLoadScreen::init( GameInfo *game )
  1134. {
  1135. // create the layout of the load screen
  1136. m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/MapTransferScreen.wnd" ) );
  1137. DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the map transfer loadscreen"));
  1138. if (!m_loadScreen)
  1139. return;
  1140. m_loadScreen->winHide(FALSE);
  1141. m_loadScreen->winBringToTop();
  1142. DEBUG_ASSERTCRASH(TheNetwork, ("Where the Heck is the Network?!!!!"));
  1143. DEBUG_LOG(("NumPlayers %d\n", TheNetwork->getNumPlayers()));
  1144. AsciiString winName;
  1145. Int i;
  1146. // Load the Filename Text
  1147. winName.format( "MapTransferScreen.wnd:StaticTextCurrentFile");
  1148. m_fileNameText = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1149. DEBUG_ASSERTCRASH(m_fileNameText, ("Can't initialize the filename for the map transfer loadscreen"));
  1150. // Load the Timeout Text
  1151. winName.format( "MapTransferScreen.wnd:StaticTextTimeout");
  1152. m_timeoutText = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1153. DEBUG_ASSERTCRASH(m_timeoutText, ("Can't initialize the timeout for the map transfer loadscreen"));
  1154. Int netSlot = 0;
  1155. // Loop through and make the loadscreen look all good.
  1156. for (i = 0; i < MAX_SLOTS; ++i)
  1157. {
  1158. // Load the Progress Bar
  1159. winName.format( "MapTransferScreen.wnd:ProgressLoad%d",i);
  1160. m_progressBars[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1161. DEBUG_ASSERTCRASH(m_progressBars[i], ("Can't initialize the progressbars for the map transfer loadscreen"));
  1162. // set the progressbar to zero
  1163. GadgetProgressBarSetProgress(m_progressBars[i], 0 );
  1164. // Load the Player's name
  1165. winName.format( "MapTransferScreen.wnd:StaticTextPlayer%d",i);
  1166. m_playerNames[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1167. DEBUG_ASSERTCRASH(m_playerNames[i], ("Can't initialize the Names for the map transfer loadscreen"));
  1168. // Load the Progress Text
  1169. winName.format( "MapTransferScreen.wnd:StaticTextProgress%d",i);
  1170. m_progressText[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1171. DEBUG_ASSERTCRASH(m_progressText[i], ("Can't initialize the progress text for the map transfer loadscreen"));
  1172. // get the slot man!
  1173. GameSlot *slot = game->getSlot(i);
  1174. if (!slot || !slot->isHuman())
  1175. continue;
  1176. Color houseColor = TheMultiplayerSettings->getColor(slot->getApparentColor())->getColor();
  1177. GadgetProgressBarSetEnabledBarColor(m_progressBars[netSlot], houseColor );
  1178. UnicodeString name = slot->getName();
  1179. GadgetStaticTextSetText(m_playerNames[netSlot], name );
  1180. m_playerNames[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
  1181. GadgetStaticTextSetText(m_progressText[netSlot], UnicodeString::TheEmptyString );
  1182. m_progressText[netSlot]->winSetEnabledTextColors(houseColor, m_progressText[netSlot]->winGetEnabledTextBorderColor());
  1183. if ((i == 0 || (TheGameInfo->getConstSlot(i)->isHuman() && TheGameInfo->getConstSlot(i)->hasMap())) && m_progressBars[netSlot])
  1184. m_progressBars[netSlot]->winHide(TRUE);
  1185. m_playerLookup[i] = netSlot; // save our mapping so we can update progress correctly
  1186. netSlot++;
  1187. }
  1188. for(i = netSlot; i < MAX_SLOTS; ++i)
  1189. {
  1190. m_progressBars[i]->winHide(TRUE);
  1191. m_playerNames[i]->winHide(TRUE);
  1192. m_progressText[i]->winHide(TRUE);
  1193. }
  1194. }
  1195. void MapTransferLoadScreen::reset( void )
  1196. {
  1197. setLoadScreen(NULL);
  1198. for(Int i = 0; i < MAX_SLOTS; ++i)
  1199. {
  1200. m_progressBars[i] = NULL;
  1201. m_playerNames[i] = NULL;
  1202. m_progressText[i]= NULL;
  1203. m_playerLookup[i] = -1;
  1204. m_oldProgress[i] = -1;
  1205. }
  1206. m_fileNameText = NULL;
  1207. m_timeoutText = NULL;
  1208. }
  1209. void MapTransferLoadScreen::update( Int percent )
  1210. {
  1211. if (TheNetwork)
  1212. {
  1213. TheNetwork->liteupdate();
  1214. }
  1215. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  1216. // Do this last!
  1217. LoadScreen::update( percent );
  1218. }
  1219. void MapTransferLoadScreen::processProgress(Int playerId, Int percentage, AsciiString stateStr)
  1220. {
  1221. if( percentage < 0 || percentage > 100 || playerId >= MAX_SLOTS || playerId < 0 || m_playerLookup[playerId] == -1)
  1222. {
  1223. DEBUG_ASSERTCRASH(FALSE, ("Percentage %d was passed in for Player %d\n", percentage, playerId));
  1224. }
  1225. if (m_oldProgress[playerId] == percentage)
  1226. return;
  1227. m_oldProgress[playerId] = percentage;
  1228. Int translatedSlot = m_playerLookup[playerId];
  1229. if(m_progressBars[translatedSlot])
  1230. GadgetProgressBarSetProgress(m_progressBars[translatedSlot], percentage );
  1231. if (m_progressText[translatedSlot])
  1232. GadgetStaticTextSetText(m_progressText[translatedSlot], TheGameText->fetch(stateStr));
  1233. }
  1234. void MapTransferLoadScreen::processTimeout(Int secondsLeft)
  1235. {
  1236. if (m_oldTimeout == secondsLeft)
  1237. return;
  1238. m_oldTimeout = secondsLeft;
  1239. if (m_timeoutText)
  1240. {
  1241. UnicodeString txt;
  1242. txt.format(TheGameText->fetch("MapTransfer:Timeout"), (secondsLeft/60), (secondsLeft%60));
  1243. GadgetStaticTextSetText(m_timeoutText, txt);
  1244. }
  1245. }
  1246. void MapTransferLoadScreen::setCurrentFilename(AsciiString filename)
  1247. {
  1248. if (m_fileNameText)
  1249. {
  1250. UnicodeString txt;
  1251. txt.translate(TheGameState->getMapLeafName(filename));
  1252. txt.format(TheGameText->fetch("MapTransfer:CurrentFile"), txt.str());
  1253. GadgetStaticTextSetText(m_fileNameText, txt);
  1254. }
  1255. }