LoadScreen.cpp 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: 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. //-----------------------------------------------------------------------------
  49. // USER INCLUDES //////////////////////////////////////////////////////////////
  50. //-----------------------------------------------------------------------------
  51. #include "Common/NameKeyGenerator.h"
  52. #include "Common/AudioAffect.h"
  53. #include "Common/AudioEventRTS.h"
  54. #include "Common/AudioHandleSpecialValues.h"
  55. #include "Common/GameAudio.h"
  56. #include "Common/GameEngine.h"
  57. #include "Common/GameLOD.h"
  58. #include "Common/GameState.h"
  59. #include "Common/MultiplayerSettings.h"
  60. #include "Common/Player.h"
  61. #include "Common/PlayerList.h"
  62. #include "Common/PlayerTemplate.h"
  63. #include "GameClient/CampaignManager.h"
  64. #include "GameClient/Display.h"
  65. #include "GameClient/GadgetProgressBar.h"
  66. #include "GameClient/GadgetStaticText.h"
  67. #include "GameClient/GameText.h"
  68. #include "GameClient/GameWindowManager.h"
  69. #include "GameClient/GameWindowTransitions.h"
  70. #include "GameClient/LoadScreen.h"
  71. #include "GameClient/MapUtil.h"
  72. #include "GameClient/Mouse.h"
  73. #include "GameClient/Shell.h"
  74. #include "GameClient/VideoPlayer.h"
  75. #include "GameClient/WindowLayout.h"
  76. #include "GameClient/WindowVideoManager.h"
  77. #include "GameClient/ChallengeGenerals.h"
  78. #include "GameLogic/FPUControl.h"
  79. #include "GameLogic/GameLogic.h"
  80. #include "GameNetwork/GameSpy/PeerDefs.h"
  81. #include "GameNetwork/GameSpy/PersistentStorageThread.h"
  82. #include "GameNetwork/NetworkInterface.h"
  83. #include "GameNetwork/RankPointValue.h"
  84. //-----------------------------------------------------------------------------
  85. // DEFINES ////////////////////////////////////////////////////////////////////
  86. //-----------------------------------------------------------------------------
  87. #ifdef _INTERNAL
  88. // for occasional debugging...
  89. //#pragma optimize("", off)
  90. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  91. #endif
  92. //-----------------------------------------------------------------------------
  93. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  94. //-----------------------------------------------------------------------------
  95. //-----------------------------------------------------------------------------
  96. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  97. //-----------------------------------------------------------------------------
  98. //-----------------------------------------------------------------------------
  99. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  100. //-----------------------------------------------------------------------------
  101. //-----------------------------------------------------------------------------
  102. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  103. //-----------------------------------------------------------------------------
  104. //-----------------------------------------------------------------------------
  105. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  106. //-----------------------------------------------------------------------------
  107. //-----------------------------------------------------------------------------
  108. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  109. //-----------------------------------------------------------------------------
  110. void positionStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[], GameWindow *mapWindow);
  111. void updateMapStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[], Bool onLoadScreen = FALSE );
  112. void positionAdditionalImages( MapMetaData *mmd, GameWindow *mapWindow, Bool force);
  113. enum{
  114. FRAME_TITLES_START = 20,
  115. FRAME_TELETYPE_START = 24,
  116. FRAME_FUDGE_ADD = 30,
  117. FRAME_PORTRAITS_START = 35,
  118. FRAME_OUTER_CIRCLE_LINE_SHOW = 50,
  119. FRAME_INNER_CIRCLE_LINE_SHOW = 52,
  120. FRAME_OUTER_CIRCLE_ALPHA_SHOW = 63,
  121. FRAME_INNER_CIRCLE_ALPHA_SHOW = 74,
  122. FRAME_OUTER_CIRCLE_LINE_HIDE = 75,
  123. FRAME_INNER_BACKDROP_ALPHA_SHOW = 80,
  124. FRAME_INNER_CIRCLE_LINE_HIDE = 81,
  125. FRAME_VS_ANIM_START = 98,
  126. FRAME_RIGHT_VOICE = 140,
  127. };
  128. static const Int TELETYPE_UPDATE_FREQ = 2; // how many frames between teletype updates
  129. //-----------------------------------------------------------------------------
  130. // LoadScreen Class
  131. //-----------------------------------------------------------------------------
  132. LoadScreen::LoadScreen( void )
  133. {
  134. m_loadScreen = NULL;
  135. }
  136. LoadScreen::~LoadScreen( void )
  137. {
  138. //if(m_loadScreen)
  139. // delete (m_loadScreen);
  140. if(m_loadScreen)
  141. TheWindowManager->winDestroy( m_loadScreen );
  142. m_loadScreen = NULL;
  143. }
  144. void LoadScreen::update( Int percent )
  145. {
  146. TheGameEngine->serviceWindowsOS();
  147. if (TheGameEngine->getQuitting())
  148. return; //don't bother with any of this if the player is exiting game.
  149. TheWindowManager->update();
  150. TheDisplay->update();
  151. // redraw all views, update the GUI
  152. TheDisplay->draw();
  153. setFPMode();
  154. }
  155. // SinglePlayerLoadScreen Class ///////////////////////////////////////////////
  156. //-----------------------------------------------------------------------------
  157. SinglePlayerLoadScreen::SinglePlayerLoadScreen( void )
  158. {
  159. //Added By Sadullah Nader
  160. //Initialization(s) inserted
  161. m_currentObjectiveLine = 0;
  162. m_currentObjectiveLineCharacter = 0;
  163. m_finishedObjectiveText = NULL;
  164. m_currentObjectiveWidthOffset = 0;
  165. //
  166. m_progressBar = NULL;
  167. m_percent = NULL;
  168. m_videoStream = NULL;
  169. m_videoBuffer = NULL;
  170. m_objectiveWin = NULL;
  171. for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
  172. m_objectiveLines[i] = NULL;
  173. }
  174. SinglePlayerLoadScreen::~SinglePlayerLoadScreen( void )
  175. {
  176. m_progressBar = NULL;
  177. m_percent = NULL;
  178. m_objectiveWin = NULL;
  179. for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
  180. m_objectiveLines[i] = NULL;
  181. if(m_videoBuffer)
  182. delete m_videoBuffer;
  183. m_videoBuffer = NULL;
  184. if ( m_videoStream )
  185. m_videoStream->close();
  186. m_videoStream = NULL;
  187. TheAudio->removeAudioEvent( m_ambientLoopHandle );
  188. m_ambientLoopHandle = NULL;
  189. }
  190. void SinglePlayerLoadScreen::moveWindows( Int frame )
  191. {
  192. enum{
  193. STATE_BEGIN = 250,
  194. STATE_SHOW_LOCATION = 251,
  195. STATE_BEGIN_BREIFING = 255,
  196. // STATE_BEGIN_ANIMATING_TEXT = 250,
  197. STATE_SHOW_CAMEO_1 = 434,
  198. STATE_BEGIN_ANIMATING_TEXT = 356,
  199. STATE_HIDE_CAMEO_1 = 459,
  200. STATE_SHOW_CAMEO_2 = 464,
  201. STATE_HIDE_CAMEO_2 = 492,
  202. STATE_SHOW_CAMEO_3 = 497,
  203. STATE_HIDE_CAMEO_3 = 524,
  204. // STATE_END_ANIM_HEAD = 450,
  205. STATE_END_ANIMATING_TEXT = 730,
  206. STATE_END = 730
  207. };
  208. if(frame < STATE_BEGIN || frame > STATE_END)
  209. return;
  210. if( frame == STATE_BEGIN_BREIFING)
  211. {
  212. // add sound support here
  213. TheAudio->friend_forcePlayAudioEventRTS(&TheCampaignManager->getCurrentMission()->m_briefingVoice);
  214. }
  215. if( frame == STATE_BEGIN_ANIMATING_TEXT)
  216. {
  217. m_objectiveWin->winHide(FALSE);
  218. // animate the text and stuff
  219. }
  220. if( frame > STATE_BEGIN_ANIMATING_TEXT && frame <= STATE_END_ANIMATING_TEXT && !m_finishedObjectiveText)
  221. {
  222. if(m_currentObjectiveLineCharacter >= m_unicodeObjectiveLines[m_currentObjectiveLine].getLength() )
  223. {
  224. m_currentObjectiveLine++;
  225. m_currentObjectiveLineCharacter =0;
  226. }
  227. if(m_currentObjectiveLine >= MAX_OBJECTIVE_LINES || m_unicodeObjectiveLines[m_currentObjectiveLine].isEmpty())
  228. {
  229. m_finishedObjectiveText = TRUE;
  230. }
  231. else
  232. {
  233. WideChar wChar = m_unicodeObjectiveLines[m_currentObjectiveLine].getCharAt(m_currentObjectiveLineCharacter);
  234. UnicodeString text = GadgetStaticTextGetText(m_objectiveLines[m_currentObjectiveLine]);
  235. text.concat(wChar);
  236. GadgetStaticTextSetText(m_objectiveLines[m_currentObjectiveLine], text);
  237. }
  238. m_currentObjectiveLineCharacter++;
  239. }
  240. switch (frame) {
  241. case STATE_SHOW_LOCATION:
  242. m_location->winHide(FALSE);
  243. break;
  244. case STATE_SHOW_CAMEO_1:
  245. m_unitDesc[0]->winHide(FALSE);
  246. break;
  247. case STATE_HIDE_CAMEO_1:
  248. m_unitDesc[0]->winHide(TRUE);
  249. break;
  250. case STATE_SHOW_CAMEO_2:
  251. m_unitDesc[1]->winHide(FALSE);
  252. break;
  253. case STATE_HIDE_CAMEO_2:
  254. m_unitDesc[1]->winHide(TRUE);
  255. break;
  256. case STATE_SHOW_CAMEO_3:
  257. m_unitDesc[2]->winHide(FALSE);
  258. break;
  259. case STATE_HIDE_CAMEO_3:
  260. m_unitDesc[2]->winHide(TRUE);
  261. break;
  262. }
  263. }
  264. /*
  265. static Bool on = FALSE;
  266. static ICoord2D startPos, endPos;
  267. enum{
  268. STATE_BEGIN = 275,
  269. STATE_BEGIN_ANIM = 290,
  270. STATE_ANIM_CAMEO1 = 300,
  271. STATE_ANIM_CAMEO1_TRASITION_CAMEO2 = 350,
  272. STATE_ANIM_CAMEO2 = 400,
  273. STATE_ANIM_CAMEO2_TRASITION_CAMEO3 = 450,
  274. STATE_ANIM_CAMEO3 = 500,
  275. STATED_END_ANIM = 550,
  276. STATE_END = 800
  277. };
  278. if(frame < STATE_BEGIN)
  279. return;
  280. else if(frame == STATE_BEGIN )
  281. {
  282. m_cameoWindow1->winHide(FALSE);
  283. m_cameoWindow2->winHide(FALSE);
  284. m_cameoWindow3->winHide(FALSE);
  285. m_cameoFrame->winHide(FALSE);
  286. }
  287. else if( frame == STATE_ANIM_CAMEO1)
  288. {
  289. m_cameoWindow1->winEnable(TRUE);
  290. GadgetStaticTextSetText(m_cameoText, TheGameText->fetch(TheCampaignManager->getCurrentMission()->m_cameoImageName[0]));
  291. //save of positions
  292. }
  293. else if( frame == STATE_ANIM_CAMEO1_TRASITION_CAMEO2)
  294. {
  295. m_cameoWindow1->winEnable(FALSE);
  296. GadgetStaticTextSetText(m_cameoText, UnicodeString::TheEmptyString);
  297. ICoord2D tempPos;
  298. Int xOffset;
  299. m_cameoFrame->winGetPosition(&startPos.x, &startPos.y);
  300. m_cameoWindow1->winGetPosition(&tempPos.x, &tempPos.y);
  301. xOffset = tempPos.x - startPos.x;
  302. m_cameoWindow2->winGetPosition(&endPos.x, &endPos.y);
  303. endPos.x = endPos.x - xOffset;
  304. endPos.y = startPos.y;
  305. }
  306. else if( frame > STATE_ANIM_CAMEO1_TRASITION_CAMEO2 && frame < STATE_ANIM_CAMEO2)
  307. {
  308. //extrapolate between start and end pos
  309. Real percent = INT_TO_REAL((frame - STATE_ANIM_CAMEO1_TRASITION_CAMEO2)) / (STATE_ANIM_CAMEO2 - STATE_ANIM_CAMEO1_TRASITION_CAMEO2);
  310. m_cameoFrame->winSetPosition(startPos.x + (endPos.x - startPos.x) * percent, endPos.y);
  311. }
  312. else if( frame == STATE_ANIM_CAMEO2 )
  313. {
  314. m_cameoWindow2->winEnable(TRUE);
  315. m_cameoFrame->winSetPosition(endPos.x, endPos.y);
  316. GadgetStaticTextSetText(m_cameoText, TheGameText->fetch(TheCampaignManager->getCurrentMission()->m_cameoImageName[1]));
  317. }
  318. else if( frame == STATE_ANIM_CAMEO2_TRASITION_CAMEO3)
  319. {
  320. m_cameoWindow2->winEnable(FALSE);
  321. GadgetStaticTextSetText(m_cameoText, UnicodeString::TheEmptyString);
  322. ICoord2D tempPos;
  323. Int xOffset;
  324. m_cameoFrame->winGetPosition(&startPos.x, &startPos.y);
  325. m_cameoWindow2->winGetPosition(&tempPos.x, &tempPos.y);
  326. xOffset = tempPos.x - startPos.x;
  327. m_cameoWindow3->winGetPosition(&endPos.x, &endPos.y);
  328. endPos.x = endPos.x - xOffset;
  329. endPos.y = startPos.y;
  330. }
  331. else if( frame > STATE_ANIM_CAMEO2_TRASITION_CAMEO3 && frame < STATE_ANIM_CAMEO3)
  332. {
  333. //extrapolate between start and end pos
  334. Real percent = INT_TO_REAL((frame - STATE_ANIM_CAMEO2_TRASITION_CAMEO3)) / (STATE_ANIM_CAMEO3 - STATE_ANIM_CAMEO2_TRASITION_CAMEO3);
  335. m_cameoFrame->winSetPosition(startPos.x + (endPos.x - startPos.x) * percent, endPos.y);
  336. }
  337. else if( frame == STATE_ANIM_CAMEO3 )
  338. {
  339. m_cameoFrame->winSetPosition(endPos.x, endPos.y);
  340. m_cameoWindow3->winEnable(TRUE);
  341. GadgetStaticTextSetText(m_cameoText, TheGameText->fetch(TheCampaignManager->getCurrentMission()->m_cameoImageName[2]));
  342. }
  343. else if( frame ==STATED_END_ANIM)
  344. {
  345. m_cameoWindow3->winEnable(FALSE);
  346. GadgetStaticTextSetText(m_cameoText, UnicodeString::TheEmptyString);
  347. m_cameoFrame->winHide(TRUE);
  348. }
  349. }*/
  350. void SinglePlayerLoadScreen::init( GameInfo *game )
  351. {
  352. //No music in SinglePlayerLoadScreen
  353. // create the layout of the load screen
  354. m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/SinglePlayerLoadScreen.wnd" ) );
  355. DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the single player loadscreen"));
  356. m_loadScreen->winHide(FALSE);
  357. m_loadScreen->winBringToTop();
  358. // Mission *mission = TheCampaignManager->getCurrentMission();
  359. // Store the pointer to the progress bar on the loadscreen
  360. m_progressBar = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:ProgressLoad" ) ));
  361. DEBUG_ASSERTCRASH(m_progressBar, ("Can't initialize the progressbar for the single player loadscreen"));
  362. GadgetProgressBarSetProgress(m_progressBar, 0 );
  363. m_percent = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:Percent" ) ));
  364. DEBUG_ASSERTCRASH(m_percent, ("Can't initialize the m_percent for the single player loadscreen"));
  365. GadgetStaticTextSetText(m_percent,UnicodeString(L"0%"));
  366. m_percent->winHide(TRUE);
  367. m_objectiveWin = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:ObjectivesWin" ) ));
  368. DEBUG_ASSERTCRASH(m_objectiveWin, ("Can't initialize the m_objectiveWin for the single player loadscreen"));
  369. m_objectiveWin->winHide(TRUE);
  370. Mission *mission = TheCampaignManager->getCurrentMission();
  371. AsciiString lineName;
  372. for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
  373. {
  374. lineName.format("SinglePlayerLoadScreen.wnd:StaticTextLine%d",i);
  375. m_objectiveLines[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( lineName ));
  376. DEBUG_ASSERTCRASH(m_objectiveLines[i], ("Can't initialize the m_objectiveLines[%d] for the single player loadscreen", i));
  377. GadgetStaticTextSetText(m_objectiveLines[i],UnicodeString::TheEmptyString);
  378. // translate the objective lines
  379. if(mission->m_missionObjectivesLabel[i].isNotEmpty())
  380. m_unicodeObjectiveLines[i] = TheGameText->fetch(mission->m_missionObjectivesLabel[i]);
  381. }
  382. for(i = 0; i < MAX_DISPLAYED_UNITS; ++i)
  383. {
  384. lineName.format("SinglePlayerLoadScreen.wnd:StaticTextCameoText%d",i);
  385. m_unitDesc[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( lineName ));
  386. DEBUG_ASSERTCRASH(m_unitDesc[i], ("Can't initialize the m_objectiveLines[%d] for the single player loadscreen", i));
  387. GadgetStaticTextSetText(m_unitDesc[i],TheGameText->fetch(mission->m_unitNames[i]));
  388. m_unitDesc[i]->winHide(TRUE);
  389. }
  390. m_location = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:StaticTextCameoText3" ) ));
  391. DEBUG_ASSERTCRASH(m_location, ("Can't initialize the m_objectiveWin for the single player loadscreen"));
  392. m_location->winHide(TRUE);
  393. GadgetStaticTextSetText(m_location, TheGameText->fetch(mission->m_locationNameLabel));
  394. m_currentObjectiveLine = 0;
  395. m_currentObjectiveWidthOffset = 0;
  396. m_currentObjectiveLineCharacter = 0;
  397. m_finishedObjectiveText = FALSE;
  398. /*
  399. m_cameoWindow1 = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowCameo1" ) ));
  400. DEBUG_ASSERTCRASH(m_cameoWindow1, ("Can't initialize the m_cameoWindow1 for the single player loadscreen"));
  401. m_cameoWindow1->winHide(TRUE);
  402. m_cameoWindow1->winEnable(FALSE);
  403. m_cameoWindow1->winSetEnabledImage(0, mission->m_cameoImage[0]);
  404. m_cameoWindow1->winSetDisabledImage(0, mission->m_cameoDisabledImage[0]);
  405. m_cameoWindow2 = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowCameo2" ) ));
  406. DEBUG_ASSERTCRASH(m_cameoWindow2, ("Can't initialize the m_cameoWindow2 for the single player loadscreen"));
  407. m_cameoWindow2->winHide(TRUE);
  408. m_cameoWindow2->winEnable(FALSE);
  409. m_cameoWindow2->winSetEnabledImage(0, mission->m_cameoImage[1]);
  410. m_cameoWindow2->winSetDisabledImage(0, mission->m_cameoDisabledImage[1]);
  411. m_cameoWindow3 = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowCameo3" ) ));
  412. DEBUG_ASSERTCRASH(m_cameoWindow3, ("Can't initialize the m_cameoWindow3 for the single player loadscreen"));
  413. m_cameoWindow3->winHide(TRUE);
  414. m_cameoWindow3->winEnable(FALSE);
  415. m_cameoWindow3->winSetEnabledImage(0, mission->m_cameoImage[2]);
  416. m_cameoWindow3->winSetDisabledImage(0, mission->m_cameoDisabledImage[2]);
  417. m_headMovie = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowHead" ) ));
  418. DEBUG_ASSERTCRASH(m_headMovie, ("Can't initialize the m_headMovie for the single player loadscreen"));
  419. m_headMovie->winHide(TRUE);
  420. m_cameoFrame = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowHiliteCameo" ) ));
  421. DEBUG_ASSERTCRASH(m_cameoFrame, ("Can't initialize the m_cameoFrame for the single player loadscreen"));
  422. m_cameoFrame->winHide(TRUE);
  423. m_cameoText = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:StaticTextCameoText" ) ));
  424. DEBUG_ASSERTCRASH(m_cameoText, ("Can't initialize the m_cameoText for the single player loadscreen"));
  425. */
  426. m_ambientLoop.setEventName("LoadScreenAmbient");
  427. // create the new stream
  428. m_videoStream = TheVideoPlayer->open( TheCampaignManager->getCurrentMission()->m_movieLabel );
  429. if ( m_videoStream == NULL )
  430. {
  431. m_percent->winHide(TRUE);
  432. return;
  433. }
  434. // Create the new buffer
  435. m_videoBuffer = TheDisplay->createVideoBuffer();
  436. if ( m_videoBuffer == NULL ||
  437. !m_videoBuffer->allocate( m_videoStream->width(),
  438. m_videoStream->height())
  439. )
  440. {
  441. delete m_videoBuffer;
  442. m_videoBuffer = NULL;
  443. if ( m_videoStream )
  444. m_videoStream->close();
  445. m_videoStream = NULL;
  446. return;
  447. }
  448. // format the progress bar: USA to blue, GLA to green, China to red
  449. // and set the background image
  450. AsciiString campaignName = TheCampaignManager->getCurrentCampaign()->m_name;
  451. GameWindow *backgroundWin = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:ParentSinglePlayerLoadScreen" ) ));
  452. if (campaignName.compareNoCase("USA") == 0)
  453. {
  454. backgroundWin->winSetEnabledImage( 0, TheMappedImageCollection->findImageByName("MissionLoad_USA") );
  455. m_progressBar->winSetEnabledImage( 6, TheMappedImageCollection->findImageByName("LoadingBar_ProgressCenter2") );
  456. }
  457. else if (campaignName.compareNoCase("GLA") == 0)
  458. {
  459. backgroundWin->winSetEnabledImage( 0, TheMappedImageCollection->findImageByName("MissionLoad_GLA") );
  460. m_progressBar->winSetEnabledImage( 6, TheMappedImageCollection->findImageByName("LoadingBar_ProgressCenter3") );
  461. }
  462. else if (campaignName.compareNoCase("China") == 0)
  463. {
  464. backgroundWin->winSetEnabledImage( 0, TheMappedImageCollection->findImageByName("MissionLoad_China") );
  465. m_progressBar->winSetEnabledImage( 6, TheMappedImageCollection->findImageByName("LoadingBar_ProgressCenter1") );
  466. }
  467. // else leave the default background screen
  468. if(TheGameLODManager && TheGameLODManager->didMemPass())
  469. {
  470. Int progressUpdateCount = m_videoStream->frameCount() / FRAME_FUDGE_ADD;
  471. Int shiftedPercent = -FRAME_FUDGE_ADD + 1;
  472. while (m_videoStream->frameIndex() < m_videoStream->frameCount() - 1 )
  473. {
  474. TheGameEngine->serviceWindowsOS();
  475. if(!m_videoStream->isFrameReady())
  476. {
  477. Sleep(1);
  478. continue;
  479. }
  480. if (!TheGameEngine->isActive())
  481. {/* //we are alt-tabbed out, so just increment the frame
  482. m_videoStream->frameNext();
  483. m_videoStream->frameDecompress();*/
  484. //Changing for MissionDisk, just skip to end.
  485. break;
  486. }
  487. m_videoStream->frameDecompress();
  488. m_videoStream->frameRender(m_videoBuffer);
  489. // PULLED FROM THE MISSION DISK
  490. // moveWindows( m_videoStream->frameIndex());
  491. m_videoStream->frameNext();
  492. if(m_videoBuffer)
  493. m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);
  494. if(m_videoStream->frameIndex() % progressUpdateCount == 0)
  495. {
  496. shiftedPercent++;
  497. if(shiftedPercent >0)
  498. shiftedPercent = 0;
  499. Int percent = (shiftedPercent + FRAME_FUDGE_ADD)/1.3;
  500. UnicodeString per;
  501. per.format(L"%d%%",percent);
  502. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  503. GadgetProgressBarSetProgress(m_progressBar, percent);
  504. GadgetStaticTextSetText(m_percent, per);
  505. }
  506. TheWindowManager->update();
  507. // redraw all views, update the GUI
  508. TheDisplay->draw();
  509. }
  510. // let the background image show through
  511. m_videoStream->close();
  512. m_videoStream = NULL;
  513. m_loadScreen->winGetInstanceData()->setVideoBuffer( NULL );
  514. TheDisplay->draw();
  515. }
  516. else
  517. {
  518. // if we're min spec'ed don't play a movie
  519. Int delay = mission->m_voiceLength * 1000;
  520. Int begin = timeGetTime();
  521. Int currTime = begin;
  522. Int fudgeFactor = 0;
  523. while(begin + delay > currTime )
  524. {
  525. fudgeFactor = 30 * ((currTime - begin)/ INT_TO_REAL(delay ));
  526. GadgetProgressBarSetProgress(m_progressBar, fudgeFactor);
  527. TheWindowManager->update();
  528. TheDisplay->draw();
  529. Sleep(100);
  530. currTime = timeGetTime();
  531. }
  532. TheWindowManager->update();
  533. TheDisplay->draw();
  534. }
  535. setFPMode();
  536. m_percent->winHide(TRUE);
  537. m_ambientLoopHandle = TheAudio->addAudioEvent(&m_ambientLoop);
  538. }
  539. void SinglePlayerLoadScreen::reset( void )
  540. {
  541. setLoadScreen(NULL);
  542. m_progressBar = NULL;
  543. }
  544. void SinglePlayerLoadScreen::update( Int percent )
  545. {
  546. percent = (percent + FRAME_FUDGE_ADD)/1.3;
  547. UnicodeString per;
  548. per.format(L"%d%%",percent);
  549. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  550. GadgetProgressBarSetProgress(m_progressBar, percent);
  551. GadgetStaticTextSetText(m_percent, per);
  552. // Do this last!
  553. LoadScreen::update( percent );
  554. }
  555. void SinglePlayerLoadScreen::setProgressRange( Int min, Int max )
  556. {
  557. }
  558. // ChallengeLoadScreen Class ///////////////////////////////////////////////
  559. //-----------------------------------------------------------------------------
  560. ChallengeLoadScreen::ChallengeLoadScreen( void )
  561. {
  562. m_progressBar = NULL;
  563. m_videoStream = NULL;
  564. m_videoBuffer = NULL;
  565. m_bioNameLeft = NULL;
  566. m_bioAgeLeft = NULL;
  567. m_bioBirthplaceLeft = NULL;
  568. m_bioStrategyLeft = NULL;
  569. m_bioBigNameEntryLeft = NULL;
  570. m_bioNameEntryLeft = NULL;
  571. m_bioAgeEntryLeft = NULL;
  572. m_bioBirthplaceEntryLeft = NULL;
  573. m_bioStrategyEntryLeft = NULL;
  574. m_bioBigNameEntryRight = NULL;
  575. m_bioNameRight = NULL;
  576. m_bioAgeRight = NULL;
  577. m_bioBirthplaceRight = NULL;
  578. m_bioStrategyRight = NULL;
  579. m_bioNameEntryRight = NULL;
  580. m_bioAgeEntryRight = NULL;
  581. m_bioBirthplaceEntryRight = NULL;
  582. m_bioStrategyEntryRight = NULL;
  583. m_portraitLeft = NULL;
  584. m_portraitRight = NULL;
  585. m_portraitMovieLeft = NULL;
  586. m_portraitMovieRight = NULL;
  587. // m_overlayReticleCrosshairs = NULL;
  588. // m_overlayReticleCircleLineOuter = NULL;
  589. // m_overlayReticleCircleLineInner = NULL;
  590. m_overlayReticleCircleAlphaOuter = NULL;
  591. m_overlayReticleCircleAlphaInner = NULL;
  592. m_overlayVsBackdrop = NULL;
  593. m_overlayVs = NULL;
  594. m_wndVideoManager = NULL;
  595. }
  596. ChallengeLoadScreen::~ChallengeLoadScreen( void )
  597. {
  598. m_progressBar = NULL;
  599. if(m_videoBuffer)
  600. delete m_videoBuffer;
  601. m_videoBuffer = NULL;
  602. if ( m_videoStream )
  603. m_videoStream->close();
  604. m_videoStream = NULL;
  605. m_bioNameLeft = NULL;
  606. m_bioAgeLeft = NULL;
  607. m_bioBirthplaceLeft = NULL;
  608. m_bioStrategyLeft = NULL;
  609. m_bioBigNameEntryLeft = NULL;
  610. m_bioNameEntryLeft = NULL;
  611. m_bioAgeEntryLeft = NULL;
  612. m_bioBirthplaceEntryLeft = NULL;
  613. m_bioStrategyEntryLeft = NULL;
  614. m_bioBigNameEntryRight = NULL;
  615. m_bioNameRight = NULL;
  616. m_bioAgeRight = NULL;
  617. m_bioBirthplaceRight = NULL;
  618. m_bioStrategyRight = NULL;
  619. m_bioNameEntryRight = NULL;
  620. m_bioAgeEntryRight = NULL;
  621. m_bioBirthplaceEntryRight = NULL;
  622. m_bioStrategyEntryRight = NULL;
  623. m_portraitLeft = NULL;
  624. m_portraitRight = NULL;
  625. m_portraitMovieLeft = NULL;
  626. m_portraitMovieRight = NULL;
  627. // m_overlayReticleCrosshairs = NULL;
  628. // m_overlayReticleCircleLineOuter = NULL;
  629. // m_overlayReticleCircleLineInner = NULL;
  630. m_overlayReticleCircleAlphaOuter = NULL;
  631. m_overlayReticleCircleAlphaInner = NULL;
  632. m_overlayVsBackdrop = NULL;
  633. m_overlayVs = NULL;
  634. if(m_wndVideoManager)
  635. delete m_wndVideoManager;
  636. m_wndVideoManager = NULL;
  637. TheAudio->removeAudioEvent( m_ambientLoopHandle );
  638. m_ambientLoopHandle = NULL;
  639. }
  640. // accepts the number of chars to advance, the window we're concerned with, the total text for final display, and the current position of the readout
  641. // returns the updated position of the readout
  642. Int updateTeletypeText( Int num_chars, GameWindow* window, UnicodeString full_text, Int current_text_pos )
  643. {
  644. DEBUG_ASSERTCRASH(window, ("No window for teletype text update"));
  645. UnicodeString currentText = GadgetStaticTextGetText(window);
  646. WideChar wChar;
  647. for (Int i = 0; i < num_chars; i++)
  648. {
  649. if (current_text_pos < full_text.getLength())
  650. {
  651. wChar = full_text.getCharAt(current_text_pos);
  652. currentText.concat(wChar);
  653. current_text_pos++;
  654. }
  655. }
  656. GadgetStaticTextSetText(window, currentText);
  657. return current_text_pos;
  658. }
  659. void ChallengeLoadScreen::activatePieces( Int frame, const GeneralPersona *generalPlayer, const GeneralPersona *generalOpponent )
  660. {
  661. static Int textPosBigNameRight = 0;
  662. static Int textPosNameRight = 0;
  663. static Int textPosAgeRight = 0;
  664. static Int textPosBirthplaceRight = 0;
  665. static Int textPosStrategyRight = 0;
  666. static Int textPosBigNameLeft = 0;
  667. static Int textPosNameLeft = 0;
  668. static Int textPosAgeLeft = 0;
  669. static Int textPosBirthplaceLeft = 0;
  670. static Int textPosStrategyLeft = 0;
  671. AudioEventRTS eventLeftGeneral( generalPlayer->getNameSound() );
  672. AudioEventRTS eventVS("Taunts_GCAnnouncer12");
  673. AudioEventRTS eventRightGeneral( generalOpponent->getNameSound() );
  674. switch (frame)
  675. {
  676. case FRAME_TITLES_START:
  677. m_bioNameLeft->winHide(FALSE);
  678. // m_bioAgeLeft->winHide(FALSE);
  679. m_bioBirthplaceLeft->winHide(FALSE);
  680. m_bioStrategyLeft->winHide(FALSE);
  681. m_bioNameRight->winHide(FALSE);
  682. // m_bioAgeRight->winHide(FALSE);
  683. m_bioBirthplaceRight->winHide(FALSE);
  684. m_bioStrategyRight->winHide(FALSE);
  685. break;
  686. case FRAME_TELETYPE_START:
  687. // reinit the statics for each new load screen
  688. textPosBigNameRight = 0;
  689. textPosNameRight = 0;
  690. textPosAgeRight = 0;
  691. textPosBirthplaceRight = 0;
  692. textPosStrategyRight = 0;
  693. textPosBigNameLeft = 0;
  694. textPosNameLeft = 0;
  695. textPosAgeLeft = 0;
  696. textPosBirthplaceLeft = 0;
  697. textPosStrategyLeft = 0;
  698. m_bioBigNameEntryLeft->winHide(FALSE);
  699. m_bioNameEntryLeft->winHide(FALSE);
  700. // m_bioAgeEntryLeft->winHide(FALSE);
  701. m_bioBirthplaceEntryLeft->winHide(FALSE);
  702. m_bioStrategyEntryLeft->winHide(FALSE);
  703. GadgetStaticTextSetText( m_bioBigNameEntryLeft, UnicodeString::TheEmptyString );
  704. GadgetStaticTextSetText( m_bioNameEntryLeft, UnicodeString::TheEmptyString );
  705. // GadgetStaticTextSetText( m_bioAgeEntryLeft, UnicodeString::TheEmptyString );
  706. GadgetStaticTextSetText( m_bioBirthplaceEntryLeft, UnicodeString::TheEmptyString );
  707. GadgetStaticTextSetText( m_bioStrategyEntryLeft, UnicodeString::TheEmptyString );
  708. m_bioBigNameEntryRight->winHide(FALSE);
  709. m_bioNameEntryRight->winHide(FALSE);
  710. // m_bioAgeEntryRight->winHide(FALSE);
  711. m_bioBirthplaceEntryRight->winHide(FALSE);
  712. m_bioStrategyEntryRight->winHide(FALSE);
  713. GadgetStaticTextSetText( m_bioBigNameEntryRight, UnicodeString::TheEmptyString );
  714. GadgetStaticTextSetText( m_bioNameEntryRight, UnicodeString::TheEmptyString );
  715. // GadgetStaticTextSetText( m_bioAgeEntryRight, UnicodeString::TheEmptyString );
  716. GadgetStaticTextSetText( m_bioBirthplaceEntryRight, UnicodeString::TheEmptyString );
  717. GadgetStaticTextSetText( m_bioStrategyEntryRight, UnicodeString::TheEmptyString );
  718. break;
  719. case FRAME_PORTRAITS_START:
  720. m_wndVideoManager->playMovie( m_portraitMovieLeft, generalPlayer->getPortraitMovieLeftName(), WINDOW_PLAY_MOVIE_SHOW_LAST_FRAME);
  721. m_wndVideoManager->playMovie( m_portraitMovieRight, generalOpponent->getPortraitMovieRightName(), WINDOW_PLAY_MOVIE_SHOW_LAST_FRAME);
  722. m_portraitMovieLeft->winHide(FALSE);
  723. m_portraitMovieRight->winHide(FALSE);
  724. TheAudio->addAudioEvent( &eventLeftGeneral );
  725. break;
  726. case FRAME_OUTER_CIRCLE_LINE_SHOW:
  727. // m_overlayReticleCircleLineOuter->winHide(FALSE);
  728. break;
  729. case FRAME_INNER_CIRCLE_LINE_SHOW:
  730. // m_overlayReticleCircleLineInner->winHide(FALSE);
  731. break;
  732. case FRAME_OUTER_CIRCLE_ALPHA_SHOW:
  733. m_overlayReticleCircleAlphaOuter->winHide(FALSE);
  734. break;
  735. case FRAME_INNER_CIRCLE_ALPHA_SHOW:
  736. m_overlayReticleCircleAlphaInner->winHide(FALSE);
  737. break;
  738. case FRAME_OUTER_CIRCLE_LINE_HIDE:
  739. // m_overlayReticleCircleLineOuter->winHide(TRUE);
  740. break;
  741. case FRAME_INNER_BACKDROP_ALPHA_SHOW:
  742. m_overlayVsBackdrop->winHide(FALSE);
  743. break;
  744. case FRAME_INNER_CIRCLE_LINE_HIDE:
  745. // m_overlayReticleCircleLineInner->winHide(TRUE);
  746. break;
  747. case FRAME_VS_ANIM_START:
  748. // it's time to start the overlay movie
  749. // m_overlayVsBackdrop->winSetEnabledImage( 0, TheMappedImageCollection->findImageByFilename("))
  750. m_overlayVsBackdrop->winHide(FALSE);
  751. m_overlayVs->winHide(FALSE);
  752. m_wndVideoManager->playMovie( m_overlayVs, AsciiString("VSSmall"), WINDOW_PLAY_MOVIE_SHOW_LAST_FRAME);
  753. // "Verses"
  754. TheAudio->addAudioEvent( &eventVS );
  755. break;
  756. case FRAME_RIGHT_VOICE:
  757. TheAudio->addAudioEvent( &eventRightGeneral );
  758. break;
  759. }
  760. // update the teletype readout
  761. if (frame > FRAME_TELETYPE_START && (frame % TELETYPE_UPDATE_FREQ) == 0)
  762. {
  763. textPosNameLeft = updateTeletypeText( 1, m_bioNameEntryLeft, TheGameText->fetch(generalPlayer->getBioName()), textPosNameLeft);
  764. textPosBigNameLeft = updateTeletypeText( 1, m_bioBigNameEntryLeft, TheGameText->fetch(generalPlayer->getBioName()), textPosBigNameLeft);
  765. // textPosAgeLeft = updateTeletypeText( 1, m_bioAgeEntryLeft, TheGameText->fetch(generalPlayer->getBioDOB()), textPosAgeLeft);
  766. textPosBirthplaceLeft = updateTeletypeText( 1, m_bioBirthplaceEntryLeft, TheGameText->fetch(generalPlayer->getBioRank()), textPosBirthplaceLeft);
  767. textPosStrategyLeft = updateTeletypeText( 1, m_bioStrategyEntryLeft, TheGameText->fetch(generalPlayer->getBioStrategy()), textPosStrategyLeft);
  768. textPosNameRight = updateTeletypeText( 1, m_bioNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()), textPosNameRight);
  769. textPosBigNameRight = updateTeletypeText( 1, m_bioBigNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()), textPosBigNameRight);
  770. // textPosAgeRight = updateTeletypeText( 1, m_bioAgeEntryRight, TheGameText->fetch(generalOpponent->getBioDOB()), textPosAgeRight);
  771. textPosBirthplaceRight = updateTeletypeText( 1, m_bioBirthplaceEntryRight, TheGameText->fetch(generalOpponent->getBioRank()), textPosBirthplaceRight);
  772. textPosStrategyRight = updateTeletypeText( 1, m_bioStrategyEntryRight, TheGameText->fetch(generalOpponent->getBioStrategy()), textPosStrategyRight);
  773. }
  774. }
  775. void ChallengeLoadScreen::activatePiecesMinSpec(const GeneralPersona *generalPlayer, const GeneralPersona *generalOpponent)
  776. {
  777. m_bioNameLeft->winHide(FALSE);
  778. // m_bioAgeLeft->winHide(FALSE);
  779. m_bioBirthplaceLeft->winHide(FALSE);
  780. m_bioStrategyLeft->winHide(FALSE);
  781. m_bioNameRight->winHide(FALSE);
  782. // m_bioAgeRight->winHide(FALSE);
  783. m_bioBirthplaceRight->winHide(FALSE);
  784. m_bioStrategyRight->winHide(FALSE);
  785. m_bioBigNameEntryLeft->winHide(FALSE);
  786. m_bioNameEntryLeft->winHide(FALSE);
  787. // m_bioAgeEntryLeft->winHide(FALSE);
  788. m_bioBirthplaceEntryLeft->winHide(FALSE);
  789. m_bioStrategyEntryLeft->winHide(FALSE);
  790. GadgetStaticTextSetText( m_bioBigNameEntryLeft, TheGameText->fetch(generalPlayer->getBioName()) );
  791. GadgetStaticTextSetText( m_bioNameEntryLeft, TheGameText->fetch(generalPlayer->getBioName()) );
  792. // GadgetStaticTextSetText( m_bioAgeEntryLeft, TheGameText->fetch(generalPlayer->getBioDOB()) );
  793. GadgetStaticTextSetText( m_bioBirthplaceEntryLeft, TheGameText->fetch(generalPlayer->getBioRank()) );
  794. GadgetStaticTextSetText( m_bioStrategyEntryLeft, TheGameText->fetch(generalPlayer->getBioStrategy()) );
  795. m_bioBigNameEntryRight->winHide(FALSE);
  796. m_bioNameEntryRight->winHide(FALSE);
  797. // m_bioAgeEntryRight->winHide(FALSE);
  798. m_bioBirthplaceEntryRight->winHide(FALSE);
  799. m_bioStrategyEntryRight->winHide(FALSE);
  800. GadgetStaticTextSetText( m_bioBigNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()) );
  801. GadgetStaticTextSetText( m_bioNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()) );
  802. // GadgetStaticTextSetText( m_bioAgeEntryRight, TheGameText->fetch(generalOpponent->getBioDOB()) );
  803. GadgetStaticTextSetText( m_bioBirthplaceEntryRight, TheGameText->fetch(generalOpponent->getBioRank()) );
  804. GadgetStaticTextSetText( m_bioStrategyEntryRight, TheGameText->fetch(generalOpponent->getBioStrategy()) );
  805. m_portraitLeft->winSetEnabledImage(0, generalPlayer->getBioPortraitLarge() );
  806. m_portraitRight->winSetEnabledImage(0, generalOpponent->getBioPortraitLarge() );
  807. m_portraitLeft->winHide(FALSE);
  808. m_portraitRight->winHide(FALSE);
  809. m_overlayReticleCircleAlphaOuter->winHide(FALSE);
  810. m_overlayReticleCircleAlphaInner->winHide(FALSE);
  811. m_overlayVsBackdrop->winHide(FALSE);
  812. m_overlayVsBackdrop->winHide(FALSE);
  813. m_overlayVs->winHide(FALSE);
  814. m_wndVideoManager->playMovie( m_overlayVs, AsciiString("VSSmall"), WINDOW_PLAY_MOVIE_SHOW_LAST_FRAME);
  815. }
  816. void ChallengeLoadScreen::init( GameInfo *game )
  817. {
  818. const Campaign *campaign = TheCampaignManager->getCurrentCampaign();
  819. const Mission *mission = TheCampaignManager->getCurrentMission();
  820. // the player general is tied to the campaign
  821. const GeneralPersona* generalPlayer = TheChallengeGenerals->getPlayerGeneralByCampaignName( campaign->m_name );
  822. // the opponent general is tied to the mission
  823. DEBUG_ASSERTCRASH(mission->m_generalName.isNotEmpty(), ("No GeneralName associated with this mission, check Campaign.ini"));
  824. const GeneralPersona* generalOpponent = TheChallengeGenerals->getGeneralByGeneralName( mission->m_generalName );
  825. // create the layout of the load screen
  826. m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/ChallengeLoadScreen.wnd" ) );
  827. DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the single player loadscreen"));
  828. m_loadScreen->winHide(FALSE);
  829. m_loadScreen->winBringToTop();
  830. // Store the pointer to the progress bar on the loadscreen
  831. m_progressBar = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "ChallengeLoadScreen.wnd:ProgressLoad" ) ));
  832. DEBUG_ASSERTCRASH(m_progressBar, ("Can't initialize the progressbar for the single player loadscreen"));
  833. GadgetProgressBarSetProgress(m_progressBar, 0 );
  834. m_ambientLoop.setEventName("LoadScreenAmbient");
  835. // create the new background video stream
  836. m_videoStream = TheVideoPlayer->open( TheCampaignManager->getCurrentMission()->m_movieLabel );
  837. // Create the new buffer
  838. m_videoBuffer = TheDisplay->createVideoBuffer();
  839. if (m_videoBuffer == NULL || !m_videoBuffer->allocate( m_videoStream->width(), m_videoStream->height() ))
  840. {
  841. delete m_videoBuffer;
  842. m_videoBuffer = NULL;
  843. if ( m_videoStream )
  844. m_videoStream->close();
  845. m_videoStream = NULL;
  846. return;
  847. }
  848. // init overlays
  849. NameKeyType namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:PortraitLeft"));
  850. m_portraitLeft = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  851. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:PortraitRight"));
  852. m_portraitRight = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  853. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:PortraitMovieLeft"));
  854. m_portraitMovieLeft = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  855. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:PortraitMovieRight"));
  856. m_portraitMovieRight = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  857. // namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:ReticleCrosshairs"));
  858. // m_overlayReticleCrosshairs = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  859. /*
  860. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:OuterCircleLine"));
  861. m_overlayReticleCircleLineOuter = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  862. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:InnerCircleLine"));
  863. m_overlayReticleCircleLineInner = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  864. */
  865. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:CircleAlphaOuter"));
  866. m_overlayReticleCircleAlphaOuter = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  867. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:CircleAlphaInner"));
  868. m_overlayReticleCircleAlphaInner = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  869. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:VersusBackdrop"));
  870. m_overlayVsBackdrop = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  871. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:OverlayVs"));
  872. m_overlayVs = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  873. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioNameLeft"));
  874. m_bioNameLeft = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  875. // namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioDOBLeft"));
  876. // m_bioAgeLeft = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  877. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioBirthplaceLeft"));
  878. m_bioBirthplaceLeft = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  879. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioStrategyLeft"));
  880. m_bioStrategyLeft = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  881. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BigNameEntryLeft"));
  882. m_bioBigNameEntryLeft = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  883. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioNameEntryLeft"));
  884. m_bioNameEntryLeft = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  885. // namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioDOBEntryLeft"));
  886. // m_bioAgeEntryLeft = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  887. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioBirthplaceEntryLeft"));
  888. m_bioBirthplaceEntryLeft = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  889. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioStrategyEntryLeft"));
  890. m_bioStrategyEntryLeft = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  891. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioNameRight"));
  892. m_bioNameRight = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  893. // namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioDOBRight"));
  894. // m_bioAgeRight = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  895. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioBirthplaceRight"));
  896. m_bioBirthplaceRight = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  897. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioStrategyRight"));
  898. m_bioStrategyRight = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  899. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BigNameEntryRight"));
  900. m_bioBigNameEntryRight = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  901. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioNameEntryRight"));
  902. m_bioNameEntryRight = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  903. // namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioDOBEntryRight"));
  904. // m_bioAgeEntryRight = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  905. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioBirthplaceEntryRight"));
  906. m_bioBirthplaceEntryRight = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  907. namekey = TheNameKeyGenerator->nameToKey( AsciiString("ChallengeLoadScreen.wnd:BioStrategyEntryRight"));
  908. m_bioStrategyEntryRight = TheWindowManager->winGetWindowFromId( m_loadScreen, namekey );
  909. // make sure reticle stuff starts out hidden
  910. // m_overlayReticleCircleLineOuter->winHide(TRUE);
  911. // m_overlayReticleCircleLineInner->winHide(TRUE);
  912. m_overlayReticleCircleAlphaOuter->winHide(TRUE);
  913. m_overlayReticleCircleAlphaInner->winHide(TRUE);
  914. m_overlayVsBackdrop->winHide(TRUE);
  915. m_overlayVs->winHide(TRUE);
  916. m_wndVideoManager = NEW WindowVideoManager;
  917. m_wndVideoManager->init();
  918. if(TheGameLODManager && TheGameLODManager->didMemPass())
  919. {
  920. Int progressUpdateCount = m_videoStream->frameCount() / FRAME_FUDGE_ADD;
  921. Int shiftedPercent = -FRAME_FUDGE_ADD + 1;
  922. while (m_videoStream->frameIndex() < m_videoStream->frameCount() - 1 )
  923. {
  924. TheGameEngine->serviceWindowsOS();
  925. if(!m_videoStream->isFrameReady())
  926. {
  927. Sleep(1);
  928. continue;
  929. }
  930. if (!TheGameEngine->isActive())
  931. { //we are alt-tabbed out, so just increment the frame
  932. m_videoStream->frameNext();
  933. m_videoStream->frameDecompress();
  934. continue;
  935. }
  936. m_videoStream->frameDecompress();
  937. m_videoStream->frameRender(m_videoBuffer);
  938. m_videoStream->frameNext();
  939. if(m_videoBuffer)
  940. m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);
  941. Int frame = m_videoStream->frameIndex();
  942. if(frame % progressUpdateCount == 0)
  943. {
  944. shiftedPercent++;
  945. if(shiftedPercent >0)
  946. shiftedPercent = 0;
  947. Int percent = (shiftedPercent + FRAME_FUDGE_ADD)/1.3;
  948. UnicodeString per;
  949. per.format(L"%d%%",percent);
  950. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  951. GadgetProgressBarSetProgress(m_progressBar, percent);
  952. }
  953. TheWindowManager->update();
  954. activatePieces(frame, generalPlayer, generalOpponent);
  955. m_wndVideoManager->update();
  956. // redraw all views, update the GUI
  957. TheDisplay->draw();
  958. TheAudio->update();
  959. }
  960. }
  961. else
  962. {
  963. // if we're min speced
  964. m_videoStream->frameGoto(m_videoStream->frameCount()); // zero based
  965. while(!m_videoStream->isFrameReady())
  966. Sleep(1);
  967. m_videoStream->frameDecompress();
  968. m_videoStream->frameRender(m_videoBuffer);
  969. if(m_videoBuffer)
  970. m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);
  971. activatePiecesMinSpec(generalPlayer, generalOpponent);
  972. Int delay = mission->m_voiceLength * 1000;
  973. Int begin = timeGetTime();
  974. Int currTime = begin;
  975. Int fudgeFactor = 0;
  976. while(begin + delay > currTime )
  977. {
  978. fudgeFactor = 30 * ((currTime - begin)/ INT_TO_REAL(delay ));
  979. GadgetProgressBarSetProgress(m_progressBar, fudgeFactor);
  980. TheWindowManager->update();
  981. TheDisplay->draw();
  982. Sleep(100);
  983. currTime = timeGetTime();
  984. }
  985. m_wndVideoManager->update();
  986. TheWindowManager->update();
  987. TheDisplay->draw();
  988. }
  989. setFPMode();
  990. AudioEventRTS event( generalOpponent->getRandomTauntSound() );
  991. TheAudio->addAudioEvent( &event );
  992. m_ambientLoopHandle = TheAudio->addAudioEvent(&m_ambientLoop);
  993. TheAudio->update();
  994. }
  995. void ChallengeLoadScreen::reset( void )
  996. {
  997. setLoadScreen(NULL);
  998. m_progressBar = NULL;
  999. }
  1000. void ChallengeLoadScreen::update( Int percent )
  1001. {
  1002. percent = (percent + FRAME_FUDGE_ADD)/1.3;
  1003. UnicodeString per;
  1004. per.format(L"%d%%",percent);
  1005. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  1006. GadgetProgressBarSetProgress(m_progressBar, percent);
  1007. // Do this last!
  1008. LoadScreen::update( percent );
  1009. }
  1010. void ChallengeLoadScreen::setProgressRange( Int min, Int max )
  1011. {
  1012. }
  1013. // ShellGameLoadScreen Class //////////////////////////////////////////////////
  1014. //-----------------------------------------------------------------------------
  1015. ShellGameLoadScreen::ShellGameLoadScreen( void )
  1016. {
  1017. m_progressBar = NULL;
  1018. }
  1019. ShellGameLoadScreen::~ShellGameLoadScreen( void )
  1020. {
  1021. m_progressBar = NULL;
  1022. }
  1023. void ShellGameLoadScreen::init( GameInfo *game )
  1024. {
  1025. static BOOL firstLoad = TRUE;
  1026. // create the layout of the load screen
  1027. m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/ShellGameLoadScreen.wnd" ) );
  1028. DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the ShellGame loadscreen"));
  1029. m_loadScreen->winHide(FALSE);
  1030. m_loadScreen->winBringToTop();
  1031. // Store the pointer to the progress bar on the loadscreen
  1032. m_progressBar = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "ShellGameLoadScreen.wnd:ProgressLoad" ) ));
  1033. DEBUG_ASSERTCRASH(m_progressBar, ("Can't initialize the progressbar for the single player loadscreen"));
  1034. GadgetProgressBarSetProgress(m_progressBar, 0 );
  1035. m_progressBar->winHide(TRUE);
  1036. if(m_loadScreen && firstLoad && TheGameLODManager && TheGameLODManager->didMemPass())
  1037. {
  1038. m_loadScreen->winSetEnabledImage(0, TheMappedImageCollection->findImageByName("TitleScreen"));
  1039. TheWritableGlobalData->m_breakTheMovie = FALSE;
  1040. // m_videoStream = TheVideoPlayer->open( "Sizzle" );
  1041. // if ( m_videoStream == NULL )
  1042. // {
  1043. // m_progressBar->winHide(FALSE);
  1044. // return;
  1045. // }
  1046. //
  1047. // // Create the new buffer
  1048. // m_videoBuffer = TheDisplay->createVideoBuffer();
  1049. // if ( m_videoBuffer == NULL ||
  1050. // !m_videoBuffer->allocate( m_videoStream->width(),
  1051. // m_videoStream->height())
  1052. // )
  1053. // {
  1054. // delete m_videoBuffer;
  1055. // m_videoBuffer = NULL;
  1056. //
  1057. // if ( m_videoStream )
  1058. // m_videoStream->close();
  1059. // m_videoStream = NULL;
  1060. //
  1061. // return;
  1062. // }
  1063. // TheGlobalData->m_isBreakableMovie = TRUE;
  1064. // TheGlobalData->m_breakTheMovie = FALSE;
  1065. // while (m_videoStream->frameIndex() < m_videoStream->frameCount() - 1 )
  1066. // {
  1067. // if(TheGlobalData->m_breakTheMovie)
  1068. // {
  1069. // TheGlobalData->m_breakTheMovie = FALSE;
  1070. // m_videoStream->frameGoto(m_videoStream->frameCount() - 1);
  1071. // }
  1072. // if(m_videoStream->frameIndex() < m_videoStream->frameCount() - 1)
  1073. // {
  1074. // if(!m_videoStream->isFrameReady())
  1075. // continue;
  1076. //
  1077. // m_videoStream->frameDecompress();
  1078. // m_videoStream->frameRender(m_videoBuffer);
  1079. // m_videoStream->frameNext();
  1080. // if(m_videoBuffer)
  1081. // m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);
  1082. // }
  1083. //
  1084. // TheWindowManager->update();
  1085. // // TheShell->update();
  1086. // //TheDisplay->update();
  1087. // // redraw all views, update the GUI
  1088. // TheDisplay->draw();
  1089. // }
  1090. // TheGlobalData->m_isBreakableMovie = FALSE;
  1091. // TheGlobalData->m_breakTheMovie = FALSE;
  1092. // GameWindow *win = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "ShellGameLoadScreen.wnd:EAGamesLogo" ) ));
  1093. // if(win)
  1094. // win->winHide(FALSE);
  1095. GameWindow *win = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "ShellGameLoadScreen.wnd:StaticTextLegal" ) ));
  1096. if(win)
  1097. win->winHide(FALSE);
  1098. firstLoad = FALSE;
  1099. UnsignedInt showTime = timeGetTime();
  1100. while(showTime + 3000 > timeGetTime())
  1101. {
  1102. LoadScreen::update(0);
  1103. Sleep(100);
  1104. }
  1105. }
  1106. m_progressBar->winHide(FALSE);
  1107. }
  1108. void ShellGameLoadScreen::reset( void )
  1109. {
  1110. setLoadScreen(NULL);
  1111. m_progressBar = NULL;
  1112. }
  1113. void ShellGameLoadScreen::update( Int percent )
  1114. {
  1115. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  1116. GadgetProgressBarSetProgress(m_progressBar, percent);
  1117. // Do this last!
  1118. LoadScreen::update( percent );
  1119. }
  1120. // MultiPlayerLoadScreen Class //////////////////////////////////////////////////
  1121. //-----------------------------------------------------------------------------
  1122. MultiPlayerLoadScreen::MultiPlayerLoadScreen( void )
  1123. {
  1124. //Added By Sadullah Nader
  1125. //Initializations missing and needed
  1126. m_mapPreview = NULL;
  1127. //
  1128. for(Int i = 0; i < MAX_SLOTS; ++i)
  1129. {
  1130. //Added By Sadullah Nader
  1131. //Initializations missing and needed
  1132. m_buttonMapStartPosition[i] = NULL;
  1133. //
  1134. m_progressBars[i] = NULL;
  1135. m_playerNames[i] = NULL;
  1136. m_playerSide[i]= NULL;
  1137. m_playerLookup[i] = -1;
  1138. }
  1139. }
  1140. MultiPlayerLoadScreen::~MultiPlayerLoadScreen( void )
  1141. {
  1142. for(Int i = 0; i < MAX_SLOTS; ++i)
  1143. {
  1144. m_progressBars[i] = NULL;
  1145. m_playerNames[i] = NULL;
  1146. m_playerSide[i]= NULL;
  1147. m_playerLookup[i] = -1;
  1148. }
  1149. m_portraitLocalGeneral = NULL;
  1150. m_featuresLocalGeneral = NULL;
  1151. m_nameLocalGeneral = NULL;
  1152. TheAudio->removeAudioEvent( AHSV_StopTheMusicFade );
  1153. // TheAudio->stopAudio( AudioAffect_Music );
  1154. }
  1155. void MultiPlayerLoadScreen::init( GameInfo *game )
  1156. {
  1157. // create the layout of the load screen
  1158. m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/MultiplayerLoadScreen.wnd" ) );
  1159. DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the Multiplayer loadscreen"));
  1160. m_loadScreen->winHide(FALSE);
  1161. m_loadScreen->winBringToTop();
  1162. m_mapPreview = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "MultiplayerLoadScreen.wnd:WinMapPreview"));
  1163. GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
  1164. const PlayerTemplate* pt;
  1165. if (lSlot->getPlayerTemplate() >= 0)
  1166. pt = ThePlayerTemplateStore->getNthPlayerTemplate(lSlot->getPlayerTemplate());
  1167. else
  1168. pt = ThePlayerTemplateStore->findPlayerTemplate( TheNameKeyGenerator->nameToKey("FactionObserver") );
  1169. // const Image *loadScreenImage = TheMappedImageCollection->findImageByName(pt->getLoadScreen());
  1170. // add portrait, features, and name for the local player's general
  1171. const GeneralPersona *localGeneral = TheChallengeGenerals->getGeneralByTemplateName( pt->getName() );
  1172. const Image *portrait = NULL;
  1173. UnicodeString localName;
  1174. if (localGeneral)
  1175. {
  1176. portrait = localGeneral->getBioPortraitLarge();
  1177. localName = TheGameText->fetch( localGeneral->getBioName() );
  1178. }
  1179. else
  1180. {
  1181. // the main original factions don't have associated generals
  1182. AsciiString imageName;
  1183. if (pt->getName() == "FactionAmerica")
  1184. portrait = TheMappedImageCollection->findImageByName("SAFactionLogoLg_US");
  1185. else if (pt->getName() == "FactionGLA")
  1186. portrait = TheMappedImageCollection->findImageByName("SUFactionLogoLg_GLA");
  1187. else if (pt->getName() == "FactionChina")
  1188. portrait = TheMappedImageCollection->findImageByName("SNFactionLogoLg_China");
  1189. else
  1190. DEBUG_ASSERTCRASH(NULL, ("Unexpected player template"));
  1191. localName = pt->getDisplayName();
  1192. }
  1193. m_portraitLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "MultiplayerLoadScreen.wnd:LocalGeneralPortrait"));
  1194. m_portraitLocalGeneral->winSetEnabledImage( 0, portrait);
  1195. m_featuresLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "MultiplayerLoadScreen.wnd:LocalGeneralFeatures"));
  1196. AsciiString features = pt->getGeneralFeatures();
  1197. GadgetStaticTextSetText( m_featuresLocalGeneral, TheGameText->fetch( features.isEmpty() ? AsciiString( "GUI:PlayerObserver" ) : pt->getGeneralFeatures() ) );
  1198. m_nameLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "MultiplayerLoadScreen.wnd:LocalGeneralName"));
  1199. GadgetStaticTextSetText( m_nameLocalGeneral, localName );
  1200. AsciiString musicName = pt->getLoadScreenMusic();
  1201. if ( ! musicName.isEmpty() )
  1202. {
  1203. TheAudio->removeAudioEvent( AHSV_StopTheMusicFade );
  1204. AudioEventRTS event( musicName );
  1205. event.setShouldFade( TRUE );
  1206. TheAudio->addAudioEvent( &event );
  1207. TheAudio->update();//Since GameEngine::update() is suspended until after I am gone...
  1208. }
  1209. // if(loadScreenImage)
  1210. // m_loadScreen->winSetEnabledImage(0, loadScreenImage);
  1211. //DEBUG_ASSERTCRASH(TheNetwork, ("Where the Heck is the Network!!!!"));
  1212. //DEBUG_LOG(("NumPlayers %d\n", TheNetwork->getNumPlayers()));
  1213. GameWindow *teamWin[MAX_SLOTS];
  1214. for (Int i = 0; i < MAX_SLOTS; ++i)
  1215. {
  1216. teamWin[i] = NULL;
  1217. }
  1218. Int netSlot = 0;
  1219. // Loop through and make the loadscreen look all good.
  1220. for (i = 0; i < MAX_SLOTS; ++i)
  1221. {
  1222. // Load the Progress Bar
  1223. AsciiString winName;
  1224. winName.format( "MultiplayerLoadScreen.wnd:ProgressLoad%d",i);
  1225. m_progressBars[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1226. DEBUG_ASSERTCRASH(m_progressBars[i], ("Can't initialize the progressbars for the Multiplayer loadscreen"));
  1227. // set the progressbar to zero
  1228. GadgetProgressBarSetProgress(m_progressBars[i], 0 );
  1229. // Load MapStart Positions
  1230. winName.format( "MultiplayerLoadScreen.wnd:ButtonMapStartPosition%d",i);
  1231. m_buttonMapStartPosition[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1232. DEBUG_ASSERTCRASH(m_buttonMapStartPosition[i], ("Can't initialize the MapStart Positions for the MultiplayerLoadScreen loadscreen"));
  1233. // Load the Player's name
  1234. winName.format( "MultiplayerLoadScreen.wnd:StaticTextPlayer%d",i);
  1235. m_playerNames[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1236. DEBUG_ASSERTCRASH(m_playerNames[i], ("Can't initialize the Names for the Multiplayer loadscreen"));
  1237. // Load the Player's Side
  1238. winName.format( "MultiplayerLoadScreen.wnd:StaticTextSide%d",i);
  1239. m_playerSide[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1240. DEBUG_ASSERTCRASH(m_playerSide[i], ("Can't initialize the Sides for the Multiplayer loadscreen"));
  1241. winName.format( "MultiplayerLoadScreen.wnd:StaticTextTeam%d",i);
  1242. teamWin[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1243. // get the slot man!
  1244. GameSlot *slot = game->getSlot(i);
  1245. if (!slot || !slot->isOccupied())
  1246. continue;
  1247. Color houseColor = TheMultiplayerSettings->getColor(slot->getApparentColor())->getColor();
  1248. // format the progress bar to house colors
  1249. AsciiString imageName;
  1250. imageName.format("LoadingBar_ProgressCenter%d", slot->getApparentColor());
  1251. const Image *houseImage = TheMappedImageCollection->findImageByName(imageName);
  1252. if (! houseImage)
  1253. houseImage = TheMappedImageCollection->findImageByName("LoadingBar_Progress");
  1254. m_progressBars[netSlot]->winSetEnabledImage( 6, houseImage );
  1255. UnicodeString name = slot->getName();
  1256. GadgetStaticTextSetText(m_playerNames[netSlot], name );
  1257. m_playerNames[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
  1258. GadgetStaticTextSetText(m_playerSide[netSlot], slot->getApparentPlayerTemplateDisplayName() );
  1259. m_playerSide[netSlot]->winSetEnabledTextColors(houseColor, m_playerSide[netSlot]->winGetEnabledTextBorderColor());
  1260. if (slot->isAI() && m_progressBars[netSlot])
  1261. m_progressBars[netSlot]->winHide(TRUE);
  1262. if (teamWin[netSlot])
  1263. {
  1264. AsciiString teamStr;
  1265. teamStr.format("Team:%d", slot->getTeamNumber() + 1);
  1266. GadgetStaticTextSetText(teamWin[netSlot], TheGameText->fetch(teamStr));
  1267. teamWin[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
  1268. }
  1269. m_playerLookup[i] = netSlot; // save our mapping so we can update progress correctly
  1270. netSlot++;
  1271. }
  1272. for(i = netSlot; i < MAX_SLOTS; ++i)
  1273. {
  1274. m_progressBars[i]->winHide(TRUE);
  1275. m_playerNames[i]->winHide(TRUE);
  1276. m_playerSide[i]->winHide(TRUE);
  1277. teamWin[i]->winHide(TRUE);
  1278. }
  1279. if(m_mapPreview)
  1280. {
  1281. const MapMetaData *mmd = TheMapCache->findMap(game->getMap());
  1282. Image *image = getMapPreviewImage(game->getMap());
  1283. m_mapPreview->winSetUserData((void *)mmd);
  1284. positionStartSpots( game, m_buttonMapStartPosition, m_mapPreview);
  1285. updateMapStartSpots( game, m_buttonMapStartPosition, TRUE );
  1286. //positionAdditionalImages((MapMetaData *)mmd, m_mapPreview, TRUE);
  1287. if(image)
  1288. {
  1289. m_mapPreview->winSetStatus(WIN_STATUS_IMAGE);
  1290. m_mapPreview->winSetEnabledImage(0, image);
  1291. }
  1292. else
  1293. {
  1294. m_mapPreview->winClearStatus(WIN_STATUS_IMAGE);
  1295. }
  1296. }
  1297. TheGameLogic->initTimeOutValues();
  1298. }
  1299. void MultiPlayerLoadScreen::reset( void )
  1300. {
  1301. setLoadScreen(NULL);
  1302. for(Int i = 0; i < MAX_SLOTS; ++i)
  1303. {
  1304. m_progressBars[i] = NULL;
  1305. m_playerNames[i] = NULL;
  1306. m_playerSide[i]= NULL;
  1307. }
  1308. }
  1309. void MultiPlayerLoadScreen::update( Int percent )
  1310. {
  1311. if (TheNetwork)
  1312. {
  1313. if(percent <= 100)
  1314. TheNetwork->updateLoadProgress( percent );
  1315. TheNetwork->liteupdate();
  1316. }
  1317. else
  1318. {
  1319. if (percent <= 100)
  1320. TheGameLogic->processProgress( TheGameInfo->getLocalSlotNum(), percent );
  1321. }
  1322. //GadgetProgressBarSetProgress(m_progressBars[TheNetwork->getLocalPlayerID()], percent );
  1323. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  1324. // Do this last!
  1325. LoadScreen::update( percent );
  1326. }
  1327. void MultiPlayerLoadScreen::processProgress(Int playerId, Int percentage)
  1328. {
  1329. if( percentage < 0 || percentage > 100 || playerId >= MAX_SLOTS || playerId < 0 || m_playerLookup[playerId] == -1)
  1330. {
  1331. DEBUG_ASSERTCRASH(FALSE, ("Percentage %d was passed in for Player %d\n", percentage, playerId));
  1332. }
  1333. //DEBUG_LOG(("Percentage %d was passed in for Player %d (in loadscreen position %d)\n", percentage, playerId, m_playerLookup[playerId]));
  1334. if(m_progressBars[m_playerLookup[playerId]])
  1335. GadgetProgressBarSetProgress(m_progressBars[m_playerLookup[playerId]], percentage );
  1336. }
  1337. // GameSpyLoadScreen Class //////////////////////////////////////////////////
  1338. //-----------------------------------------------------------------------------
  1339. GameSpyLoadScreen::GameSpyLoadScreen( void )
  1340. {
  1341. // Added By Sadullah Nader
  1342. // Initializations missing and needed
  1343. m_mapPreview = NULL;
  1344. //
  1345. for(Int i = 0; i < MAX_SLOTS; ++i)
  1346. {
  1347. // Added By Sadullah Nader
  1348. // Initializations missing and needed
  1349. m_buttonMapStartPosition[i] = NULL;
  1350. m_playerRank[i] = NULL;
  1351. //
  1352. m_playerOfficerMedal[i] = NULL;
  1353. m_progressBars[i] = NULL;
  1354. m_playerNames[i] = NULL;
  1355. m_playerSide[i]= NULL;
  1356. m_playerLookup[i] = -1;
  1357. m_playerFavoriteFactions[i]= NULL;
  1358. m_playerTotalDisconnects[i]= NULL;
  1359. m_playerWin[i]= NULL;
  1360. m_playerWinLosses[i]= NULL;
  1361. }
  1362. }
  1363. GameSpyLoadScreen::~GameSpyLoadScreen( void )
  1364. {
  1365. for(Int i = 0; i < MAX_SLOTS; ++i)
  1366. {
  1367. m_progressBars[i] = NULL;
  1368. m_playerNames[i] = NULL;
  1369. m_playerSide[i]= NULL;
  1370. m_playerLookup[i] = -1;
  1371. m_playerFavoriteFactions[i]= NULL;
  1372. m_playerTotalDisconnects[i]= NULL;
  1373. m_playerWin[i]= NULL;
  1374. m_playerWinLosses[i]= NULL;
  1375. }
  1376. }
  1377. extern Int GetAdditionalDisconnectsFromUserFile(Int playerID);
  1378. void GameSpyLoadScreen::init( GameInfo *game )
  1379. {
  1380. // create the layout of the load screen
  1381. m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/GameSpyLoadScreen.wnd" ) );
  1382. DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the Multiplayer loadscreen"));
  1383. m_loadScreen->winHide(FALSE);
  1384. m_loadScreen->winBringToTop();
  1385. m_mapPreview = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "GameSpyLoadScreen.wnd:WinMapPreview"));
  1386. DEBUG_ASSERTCRASH(TheNetwork, ("Where the Heck is the Network!!!!"));
  1387. DEBUG_LOG(("NumPlayers %d\n", TheNetwork->getNumPlayers()));
  1388. GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
  1389. const PlayerTemplate* pt;
  1390. if (lSlot->getPlayerTemplate() >= 0)
  1391. pt = ThePlayerTemplateStore->getNthPlayerTemplate(lSlot->getPlayerTemplate());
  1392. else
  1393. pt = ThePlayerTemplateStore->findPlayerTemplate( TheNameKeyGenerator->nameToKey("FactionObserver") );
  1394. // const Image *loadScreenImage = TheMappedImageCollection->findImageByName(pt->getLoadScreen());
  1395. // if(loadScreenImage)
  1396. // m_loadScreen->winSetEnabledImage(0, loadScreenImage);
  1397. // add portrait, features, and name for the local player's general
  1398. const GeneralPersona *localGeneral = TheChallengeGenerals->getGeneralByTemplateName( pt->getName() );
  1399. const Image *portrait = NULL;
  1400. UnicodeString localName;
  1401. if (localGeneral)
  1402. {
  1403. portrait = localGeneral->getBioPortraitLarge();
  1404. localName = TheGameText->fetch( localGeneral->getBioName() );
  1405. }
  1406. else
  1407. {
  1408. // the main original factions don't have associated generals
  1409. AsciiString imageName;
  1410. if (pt->getName() == "FactionAmerica")
  1411. portrait = TheMappedImageCollection->findImageByName("SAFactionLogo144_US");
  1412. else if (pt->getName() == "FactionGLA")
  1413. portrait = TheMappedImageCollection->findImageByName("SUFactionLogo144_GLA");
  1414. else if (pt->getName() == "FactionChina")
  1415. portrait = TheMappedImageCollection->findImageByName("SNFactionLogo144_China");
  1416. else
  1417. DEBUG_ASSERTCRASH(NULL, ("Unexpected player template"));
  1418. localName = pt->getDisplayName();
  1419. }
  1420. m_portraitLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "GameSpyLoadScreen.wnd:LocalGeneralPortrait"));
  1421. m_portraitLocalGeneral->winSetEnabledImage( 0, portrait);
  1422. m_featuresLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "GameSpyLoadScreen.wnd:LocalGeneralFeatures"));
  1423. AsciiString features = pt->getGeneralFeatures();
  1424. GadgetStaticTextSetText( m_featuresLocalGeneral, TheGameText->fetch( features.isEmpty() ? AsciiString( "GUI:PlayerObserver" ) : pt->getGeneralFeatures() ) );
  1425. m_nameLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "GameSpyLoadScreen.wnd:LocalGeneralName"));
  1426. GadgetStaticTextSetText( m_nameLocalGeneral, localName );
  1427. GameWindow *teamWin[MAX_SLOTS];
  1428. for (Int i = 0; i < MAX_SLOTS; ++i)
  1429. {
  1430. teamWin[i] = NULL;
  1431. }
  1432. Int netSlot = 0;
  1433. // Loop through and make the loadscreen look all good.
  1434. for (i = 0; i < MAX_SLOTS; ++i)
  1435. {
  1436. // Load the Progress Bar
  1437. AsciiString winName;
  1438. winName.format( "GameSpyLoadScreen.wnd:ProgressLoad%d",i);
  1439. m_progressBars[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1440. DEBUG_ASSERTCRASH(m_progressBars[i], ("Can't initialize the progressbars for the GameSpyLoadScreen loadscreen"));
  1441. // set the progressbar to zero
  1442. GadgetProgressBarSetProgress(m_progressBars[i], 0 );
  1443. // Load the Player's name
  1444. winName.format( "GameSpyLoadScreen.wnd:StaticTextPlayer%d",i);
  1445. m_playerNames[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1446. DEBUG_ASSERTCRASH(m_playerNames[i], ("Can't initialize the Names for the GameSpyLoadScreen loadscreen"));
  1447. // Load MapStart Positions
  1448. winName.format( "GameSpyLoadScreen.wnd:ButtonMapStartPosition%d",i);
  1449. m_buttonMapStartPosition[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1450. DEBUG_ASSERTCRASH(m_buttonMapStartPosition[i], ("Can't initialize the MapStart Positions for the GameSpyLoadScreen loadscreen"));
  1451. // Load the Player's Side
  1452. winName.format( "GameSpyLoadScreen.wnd:StaticTextSide%d",i);
  1453. m_playerSide[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1454. DEBUG_ASSERTCRASH(m_playerSide[i], ("Can't initialize the Sides for the GameSpyLoadScreen loadscreen"));
  1455. // Load the Player's window
  1456. winName.format( "GameSpyLoadScreen.wnd:WinPlayer%d",i);
  1457. m_playerWin[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1458. DEBUG_ASSERTCRASH(m_playerWin[i], ("Can't initialize the WinPlayer for the GameSpyLoadScreen loadscreen"));
  1459. // Load the Player's m_playerTotalDisconnects
  1460. winName.format( "GameSpyLoadScreen.wnd:StaticTextTotalDisconnects%d",i);
  1461. m_playerTotalDisconnects[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1462. DEBUG_ASSERTCRASH(m_playerTotalDisconnects[i], ("Can't initialize the m_playerTotalDisconnects for the GameSpyLoadScreen loadscreen"));
  1463. // // Load the Player's m_playerFavoriteFactions
  1464. // winName.format( "GameSpyLoadScreen.wnd:StaticTextFavoriteFaction%d",i);
  1465. // m_playerFavoriteFactions[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1466. // DEBUG_ASSERTCRASH(m_playerFavoriteFactions[i], ("Can't initialize the StaticTextFavoriteFaction for the GameSpyLoadScreen loadscreen"));
  1467. // Load the Player's m_playerWinLosses
  1468. winName.format( "GameSpyLoadScreen.wnd:StaticTextWinLoss%d",i);
  1469. m_playerWinLosses[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1470. DEBUG_ASSERTCRASH(m_playerWinLosses[i], ("Can't initialize the m_playerWinLosses for the GameSpyLoadScreen loadscreen"));
  1471. // Load the Player's m_playerWinLosses
  1472. winName.format( "GameSpyLoadScreen.wnd:WinRank%d",i);
  1473. m_playerRank[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1474. DEBUG_ASSERTCRASH(m_playerRank[i], ("Can't initialize the m_playerRank for the GameSpyLoadScreen loadscreen"));
  1475. // Load the Player's m_playerOfficerMedal
  1476. winName.format( "GameSpyLoadScreen.wnd:WinOfficer%d",i);
  1477. m_playerOfficerMedal[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1478. DEBUG_ASSERTCRASH(m_playerOfficerMedal[i], ("Can't initialize the m_playerOfficerMedal for the GameSpyLoadScreen loadscreen"));
  1479. winName.format( "MultiplayerLoadScreen.wnd:StaticTextTeam%d",i);
  1480. teamWin[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1481. // get the slot man!
  1482. GameSpyGameSlot *slot = (GameSpyGameSlot *)game->getSlot(i);
  1483. if (!slot || !slot->isOccupied())
  1484. continue;
  1485. Color houseColor = TheMultiplayerSettings->getColor(slot->getApparentColor())->getColor();
  1486. // format the progress bar to house colors
  1487. AsciiString imageName;
  1488. imageName.format("LoadingBar_ProgressCenter%d", slot->getApparentColor());
  1489. const Image *houseImage = TheMappedImageCollection->findImageByName(imageName);
  1490. if (! houseImage)
  1491. houseImage = TheMappedImageCollection->findImageByName("LoadingBar_Progress");
  1492. m_progressBars[netSlot]->winSetEnabledImage( 6, houseImage );
  1493. UnicodeString name = slot->getName();
  1494. GadgetStaticTextSetText(m_playerNames[netSlot], name );
  1495. m_playerNames[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
  1496. // Get the stats for the player
  1497. PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(slot->getProfileID());
  1498. DEBUG_LOG(("LoadScreen - populating info for %ls(%d) - stats returned id %d\n",
  1499. slot->getName().str(), slot->getProfileID(), stats.id));
  1500. Bool isPreorder = TheGameSpyInfo->didPlayerPreorder(stats.id);
  1501. Int rankPoints = CalculateRank(stats);
  1502. Int favSide = GetFavoriteSide(stats);
  1503. const Image *preorderImg = TheMappedImageCollection->findImageByName("OfficersClubsmall");
  1504. if (!isPreorder)
  1505. preorderImg = NULL;
  1506. const Image *rankImg = LookupSmallRankImage(favSide, rankPoints);
  1507. m_playerOfficerMedal[i]->winSetEnabledImage(0, preorderImg);
  1508. m_playerRank[i]->winSetEnabledImage(0, rankImg);
  1509. UnicodeString formatString;
  1510. // pop wins and losses
  1511. Int numLosses = 0;
  1512. PerGeneralMap::iterator it;
  1513. for(it = stats.losses.begin(); it != stats.losses.end(); ++it)
  1514. {
  1515. numLosses += it->second;
  1516. }
  1517. Int numWins = 0;
  1518. for(it =stats.wins.begin(); it != stats.wins.end(); ++it)
  1519. {
  1520. numWins += it->second;
  1521. }
  1522. formatString.format(L"%d/%d", numWins, numLosses);
  1523. GadgetStaticTextSetText(m_playerWinLosses[netSlot], formatString);
  1524. m_playerWinLosses[netSlot]->winSetEnabledTextColors(houseColor, m_playerWinLosses[netSlot]->winGetEnabledTextBorderColor());
  1525. // favoriteFaction
  1526. Int numGames = 0;
  1527. Int favorite = 0;
  1528. for(it =stats.games.begin(); it != stats.games.end(); ++it)
  1529. {
  1530. if(it->second >= numGames)
  1531. {
  1532. numGames = it->second;
  1533. favorite = it->first;
  1534. }
  1535. }
  1536. // if(numGames == 0)
  1537. // GadgetStaticTextSetText(m_playerFavoriteFactions[netSlot], TheGameText->fetch("GUI:None"));
  1538. // else if( stats.gamesAsRandom > numGames )
  1539. // GadgetStaticTextSetText(m_playerFavoriteFactions[netSlot], TheGameText->fetch("GUI:Random"));
  1540. // else
  1541. // {
  1542. // const PlayerTemplate *fac = ThePlayerTemplateStore->getNthPlayerTemplate(favorite);
  1543. // if (fac)
  1544. // {
  1545. // AsciiString side;
  1546. // side.format("SIDE:%s", fac->getSide().str());
  1547. //
  1548. // GadgetStaticTextSetText(m_playerFavoriteFactions[netSlot], TheGameText->fetch(side));
  1549. // }
  1550. // }
  1551. // m_playerFavoriteFactions[netSlot]->winSetEnabledTextColors(houseColor, m_playerFavoriteFactions[netSlot]->winGetEnabledTextBorderColor());
  1552. // disconnects
  1553. numGames = 0;
  1554. for(it =stats.discons.begin(); it != stats.discons.end(); ++it)
  1555. {
  1556. numGames += it->second;
  1557. }
  1558. for(it =stats.desyncs.begin(); it != stats.desyncs.end(); ++it)
  1559. {
  1560. numGames += it->second;
  1561. }
  1562. numGames += GetAdditionalDisconnectsFromUserFile(stats.id);
  1563. formatString.format(L"%d", numGames);
  1564. GadgetStaticTextSetText(m_playerTotalDisconnects[netSlot], formatString);
  1565. m_playerTotalDisconnects[netSlot]->winSetEnabledTextColors(houseColor, m_playerTotalDisconnects[netSlot]->winGetEnabledTextBorderColor());
  1566. GadgetStaticTextSetText(m_playerSide[netSlot], slot->getApparentPlayerTemplateDisplayName() );
  1567. m_playerSide[netSlot]->winSetEnabledTextColors(houseColor, m_playerSide[netSlot]->winGetEnabledTextBorderColor());
  1568. if (slot->isAI())
  1569. {
  1570. if (m_progressBars[netSlot])
  1571. m_progressBars[netSlot]->winHide(TRUE);
  1572. if (m_playerTotalDisconnects[netSlot])
  1573. m_playerTotalDisconnects[netSlot]->winHide(TRUE);
  1574. // if (m_playerFavoriteFactions[netSlot])
  1575. // m_playerFavoriteFactions[netSlot]->winHide(TRUE);
  1576. if (m_playerWinLosses[netSlot])
  1577. m_playerWinLosses[netSlot]->winHide(TRUE);
  1578. if (m_playerRank[netSlot])
  1579. m_playerRank[netSlot]->winHide(TRUE);
  1580. if (m_playerOfficerMedal[netSlot])
  1581. m_playerOfficerMedal[netSlot]->winHide(TRUE);
  1582. }
  1583. if (teamWin[netSlot])
  1584. {
  1585. AsciiString teamStr;
  1586. teamStr.format("Team:%d", slot->getTeamNumber() + 1);
  1587. if (slot->isAI() && slot->getTeamNumber() == -1)
  1588. teamStr = "Team:AI";
  1589. GadgetStaticTextSetText(teamWin[netSlot], TheGameText->fetch(teamStr));
  1590. teamWin[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
  1591. }
  1592. m_playerLookup[i] = netSlot; // save our mapping so we can update progress correctly
  1593. netSlot++;
  1594. }
  1595. for(i = netSlot; i < MAX_SLOTS; ++i)
  1596. {
  1597. m_playerWin[i]->winHide(TRUE);
  1598. //m_playerNames[i]->winHide(TRUE);
  1599. //m_playerSide[i]->winHide(TRUE);
  1600. }
  1601. if(m_mapPreview)
  1602. {
  1603. const MapMetaData *mmd = TheMapCache->findMap(game->getMap());
  1604. Image *image = getMapPreviewImage(game->getMap());
  1605. m_mapPreview->winSetUserData((void *)mmd);
  1606. positionStartSpots( game, m_buttonMapStartPosition, m_mapPreview);
  1607. updateMapStartSpots( game, m_buttonMapStartPosition, TRUE );
  1608. //positionAdditionalImages((MapMetaData *)mmd, m_mapPreview, TRUE);
  1609. if(image)
  1610. {
  1611. m_mapPreview->winSetStatus(WIN_STATUS_IMAGE);
  1612. m_mapPreview->winSetEnabledImage(0, image);
  1613. }
  1614. else
  1615. {
  1616. m_mapPreview->winClearStatus(WIN_STATUS_IMAGE);
  1617. }
  1618. }
  1619. TheGameLogic->initTimeOutValues();
  1620. }
  1621. void GameSpyLoadScreen::reset( void )
  1622. {
  1623. setLoadScreen(NULL);
  1624. for(Int i = 0; i < MAX_SLOTS; ++i)
  1625. {
  1626. m_progressBars[i] = NULL;
  1627. m_playerNames[i] = NULL;
  1628. m_playerSide[i]= NULL;
  1629. }
  1630. }
  1631. void GameSpyLoadScreen::update( Int percent )
  1632. {
  1633. if(percent <= 100)
  1634. TheNetwork->updateLoadProgress( percent );
  1635. TheNetwork->liteupdate();
  1636. //GadgetProgressBarSetProgress(m_progressBars[TheNetwork->getLocalPlayerID()], percent );
  1637. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  1638. // Do this last!
  1639. LoadScreen::update( percent );
  1640. }
  1641. void GameSpyLoadScreen::processProgress(Int playerId, Int percentage)
  1642. {
  1643. if( percentage < 0 || percentage > 100 || playerId >= MAX_SLOTS || playerId < 0 || m_playerLookup[playerId] == -1)
  1644. {
  1645. DEBUG_ASSERTCRASH(FALSE, ("Percentage %d was passed in for Player %d\n", percentage, playerId));
  1646. }
  1647. //DEBUG_LOG(("Percentage %d was passed in for Player %d (in loadscreen position %d)\n", percentage, playerId, m_playerLookup[playerId]));
  1648. if(m_progressBars[m_playerLookup[playerId]])
  1649. GadgetProgressBarSetProgress(m_progressBars[m_playerLookup[playerId]], percentage );
  1650. }
  1651. // MapTransferLoadScreen Class //////////////////////////////////////////////////
  1652. //-----------------------------------------------------------------------------
  1653. MapTransferLoadScreen::MapTransferLoadScreen( void )
  1654. {
  1655. //Added By Sadullah Nader
  1656. //Initializations missing and needed
  1657. m_oldTimeout = 0;
  1658. //
  1659. for(Int i = 0; i < MAX_SLOTS; ++i)
  1660. {
  1661. m_progressBars[i] = NULL;
  1662. m_playerNames[i] = NULL;
  1663. m_progressText[i]= NULL;
  1664. m_playerLookup[i] = -1;
  1665. m_oldProgress[i] = -1;
  1666. }
  1667. m_fileNameText = NULL;
  1668. m_timeoutText = NULL;
  1669. }
  1670. MapTransferLoadScreen::~MapTransferLoadScreen( void )
  1671. {
  1672. for(Int i = 0; i < MAX_SLOTS; ++i)
  1673. {
  1674. m_progressBars[i] = NULL;
  1675. m_playerNames[i] = NULL;
  1676. m_progressText[i]= NULL;
  1677. m_playerLookup[i] = -1;
  1678. m_oldProgress[i] = -1;
  1679. }
  1680. m_fileNameText = NULL;
  1681. m_timeoutText = NULL;
  1682. }
  1683. void MapTransferLoadScreen::init( GameInfo *game )
  1684. {
  1685. // create the layout of the load screen
  1686. m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/MapTransferScreen.wnd" ) );
  1687. DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the map transfer loadscreen"));
  1688. if (!m_loadScreen)
  1689. return;
  1690. m_loadScreen->winHide(FALSE);
  1691. m_loadScreen->winBringToTop();
  1692. DEBUG_ASSERTCRASH(TheNetwork, ("Where the Heck is the Network?!!!!"));
  1693. DEBUG_LOG(("NumPlayers %d\n", TheNetwork->getNumPlayers()));
  1694. AsciiString winName;
  1695. Int i;
  1696. // Load the Filename Text
  1697. winName.format( "MapTransferScreen.wnd:StaticTextCurrentFile");
  1698. m_fileNameText = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1699. DEBUG_ASSERTCRASH(m_fileNameText, ("Can't initialize the filename for the map transfer loadscreen"));
  1700. // Load the Timeout Text
  1701. winName.format( "MapTransferScreen.wnd:StaticTextTimeout");
  1702. m_timeoutText = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1703. DEBUG_ASSERTCRASH(m_timeoutText, ("Can't initialize the timeout for the map transfer loadscreen"));
  1704. Int netSlot = 0;
  1705. // Loop through and make the loadscreen look all good.
  1706. for (i = 0; i < MAX_SLOTS; ++i)
  1707. {
  1708. // Load the Progress Bar
  1709. winName.format( "MapTransferScreen.wnd:ProgressLoad%d",i);
  1710. m_progressBars[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1711. DEBUG_ASSERTCRASH(m_progressBars[i], ("Can't initialize the progressbars for the map transfer loadscreen"));
  1712. // set the progressbar to zero
  1713. GadgetProgressBarSetProgress(m_progressBars[i], 0 );
  1714. // Load the Player's name
  1715. winName.format( "MapTransferScreen.wnd:StaticTextPlayer%d",i);
  1716. m_playerNames[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1717. DEBUG_ASSERTCRASH(m_playerNames[i], ("Can't initialize the Names for the map transfer loadscreen"));
  1718. // Load the Progress Text
  1719. winName.format( "MapTransferScreen.wnd:StaticTextProgress%d",i);
  1720. m_progressText[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
  1721. DEBUG_ASSERTCRASH(m_progressText[i], ("Can't initialize the progress text for the map transfer loadscreen"));
  1722. // get the slot man!
  1723. GameSlot *slot = game->getSlot(i);
  1724. if (!slot || !slot->isHuman())
  1725. continue;
  1726. Color houseColor = TheMultiplayerSettings->getColor(slot->getApparentColor())->getColor();
  1727. GadgetProgressBarSetEnabledBarColor(m_progressBars[netSlot], houseColor );
  1728. UnicodeString name = slot->getName();
  1729. GadgetStaticTextSetText(m_playerNames[netSlot], name );
  1730. m_playerNames[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
  1731. GadgetStaticTextSetText(m_progressText[netSlot], UnicodeString::TheEmptyString );
  1732. m_progressText[netSlot]->winSetEnabledTextColors(houseColor, m_progressText[netSlot]->winGetEnabledTextBorderColor());
  1733. if ((i == 0 || (TheGameInfo->getConstSlot(i)->isHuman() && TheGameInfo->getConstSlot(i)->hasMap())) && m_progressBars[netSlot])
  1734. m_progressBars[netSlot]->winHide(TRUE);
  1735. m_playerLookup[i] = netSlot; // save our mapping so we can update progress correctly
  1736. netSlot++;
  1737. }
  1738. for(i = netSlot; i < MAX_SLOTS; ++i)
  1739. {
  1740. m_progressBars[i]->winHide(TRUE);
  1741. m_playerNames[i]->winHide(TRUE);
  1742. m_progressText[i]->winHide(TRUE);
  1743. }
  1744. }
  1745. void MapTransferLoadScreen::reset( void )
  1746. {
  1747. setLoadScreen(NULL);
  1748. for(Int i = 0; i < MAX_SLOTS; ++i)
  1749. {
  1750. m_progressBars[i] = NULL;
  1751. m_playerNames[i] = NULL;
  1752. m_progressText[i]= NULL;
  1753. m_playerLookup[i] = -1;
  1754. m_oldProgress[i] = -1;
  1755. }
  1756. m_fileNameText = NULL;
  1757. m_timeoutText = NULL;
  1758. }
  1759. void MapTransferLoadScreen::update( Int percent )
  1760. {
  1761. if (TheNetwork)
  1762. {
  1763. TheNetwork->liteupdate();
  1764. }
  1765. TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
  1766. // Do this last!
  1767. LoadScreen::update( percent );
  1768. }
  1769. void MapTransferLoadScreen::processProgress(Int playerId, Int percentage, AsciiString stateStr)
  1770. {
  1771. if( percentage < 0 || percentage > 100 || playerId >= MAX_SLOTS || playerId < 0 || m_playerLookup[playerId] == -1)
  1772. {
  1773. DEBUG_ASSERTCRASH(FALSE, ("Percentage %d was passed in for Player %d\n", percentage, playerId));
  1774. }
  1775. if (m_oldProgress[playerId] == percentage)
  1776. return;
  1777. m_oldProgress[playerId] = percentage;
  1778. Int translatedSlot = m_playerLookup[playerId];
  1779. if(m_progressBars[translatedSlot])
  1780. GadgetProgressBarSetProgress(m_progressBars[translatedSlot], percentage );
  1781. if (m_progressText[translatedSlot])
  1782. GadgetStaticTextSetText(m_progressText[translatedSlot], TheGameText->fetch(stateStr));
  1783. }
  1784. void MapTransferLoadScreen::processTimeout(Int secondsLeft)
  1785. {
  1786. if (m_oldTimeout == secondsLeft)
  1787. return;
  1788. m_oldTimeout = secondsLeft;
  1789. if (m_timeoutText)
  1790. {
  1791. UnicodeString txt;
  1792. txt.format(TheGameText->fetch("MapTransfer:Timeout"), (secondsLeft/60), (secondsLeft%60));
  1793. GadgetStaticTextSetText(m_timeoutText, txt);
  1794. }
  1795. }
  1796. void MapTransferLoadScreen::setCurrentFilename(AsciiString filename)
  1797. {
  1798. if (m_fileNameText)
  1799. {
  1800. UnicodeString txt;
  1801. txt.translate(TheGameState->getMapLeafName(filename));
  1802. txt.format(TheGameText->fetch("MapTransfer:CurrentFile"), txt.str());
  1803. GadgetStaticTextSetText(m_fileNameText, txt);
  1804. }
  1805. }