| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456 |
- /*
- ** Command & Conquer Generals(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ////////////////////////////////////////////////////////////////////////////////
- // //
- // (c) 2001-2003 Electronic Arts Inc. //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- // FILE: LoadScreen.cpp /////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- //
- // Electronic Arts Pacific.
- //
- // Confidential Information
- // Copyright (C) 2002 - All Rights Reserved
- //
- //-----------------------------------------------------------------------------
- //
- // created: Mar 2002
- //
- // Filename: LoadScreen.cpp
- //
- // author: Chris Huybregts
- //
- // purpose: Contains each of the different derived LoadClasses for each of the
- // Different kind of games we can have.
- //
- //-----------------------------------------------------------------------------
- ///////////////////////////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
- #ifdef _INTERNAL
- // for occasional debugging...
- //#pragma optimize("", off)
- //#pragma message("************************************** WARNING, optimization disabled for debugging purposes")
- #endif
- //-----------------------------------------------------------------------------
- // USER INCLUDES //////////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- #include "Common/NameKeyGenerator.h"
- #include "Common/MultiplayerSettings.h"
- #include "Common/GameEngine.h"
- #include "Common/GameState.h"
- #include "Common/PlayerTemplate.h"
- #include "Common/PlayerList.h"
- #include "Common/Player.h"
- #include "Common/GameLOD.h"
- #include "Common/GameAudio.h"
- #include "Common/AudioEventRTS.h"
- #include "Common/AudioHandleSpecialValues.h"
- #include "Common/AudioAffect.h"
- #include "GameClient/LoadScreen.h"
- #include "GameClient/Shell.h"
- #include "GameClient/GameWindowManager.h"
- #include "GameClient/GadgetProgressBar.h"
- #include "GameClient/GadgetStaticText.h"
- #include "GameClient/GameText.h"
- #include "GameClient/Display.h"
- #include "GameClient/WindowLayout.h"
- #include "GameClient/Mouse.h"
- #include "GameClient/VideoPlayer.h"
- #include "GameClient/MapUtil.h"
- #include "GameLogic/FPUControl.h"
- #include "GameLogic/GameLogic.h"
- #include "GameNetwork/NetworkInterface.h"
- #include "GameNetwork/GameSpy/PeerDefs.h"
- #include "GameNetwork/GameSpy/PersistentStorageThread.h"
- #include "GameClient/CampaignManager.h"
- #include "GameNetwork/RankPointValue.h"
- #include "GameClient/GameWindowTransitions.h"
- //-----------------------------------------------------------------------------
- // DEFINES ////////////////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- #ifdef _INTERNAL
- // for occasional debugging...
- //#pragma optimize("", off)
- //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
- #endif
- //-----------------------------------------------------------------------------
- // PRIVATE TYPES //////////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- //-----------------------------------------------------------------------------
- // PRIVATE DATA ///////////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- //-----------------------------------------------------------------------------
- // PUBLIC DATA ////////////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- //-----------------------------------------------------------------------------
- // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- //-----------------------------------------------------------------------------
- // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- //-----------------------------------------------------------------------------
- // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- void positionStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[], GameWindow *mapWindow);
- void updateMapStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[], Bool onLoadScreen = FALSE );
- void positionAdditionalImages( MapMetaData *mmd, GameWindow *mapWindow, Bool force);
- enum{
- FRAME_FUDGE_ADD = 30,
- };
- //-----------------------------------------------------------------------------
- // LoadScreen Class
- //-----------------------------------------------------------------------------
- LoadScreen::LoadScreen( void )
- {
- m_loadScreen = NULL;
- }
- LoadScreen::~LoadScreen( void )
- {
- //if(m_loadScreen)
- // delete (m_loadScreen);
- if(m_loadScreen)
- TheWindowManager->winDestroy( m_loadScreen );
- m_loadScreen = NULL;
- }
- void LoadScreen::update( Int percent )
- {
- TheGameEngine->serviceWindowsOS();
- TheWindowManager->update();
- TheDisplay->update();
- // redraw all views, update the GUI
- TheDisplay->draw();
- setFPMode();
- }
- // SinglePlayerLoadScreen Class ///////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- SinglePlayerLoadScreen::SinglePlayerLoadScreen( void )
- {
- //Added By Sadullah Nader
- //Initialization(s) inserted
- m_currentObjectiveLine = 0;
- m_currentObjectiveLineCharacter = 0;
- m_finishedObjectiveText = NULL;
- m_currentObjectiveWidthOffset = 0;
- //
- m_progressBar = NULL;
- m_percent = NULL;
- m_videoStream = NULL;
- m_videoBuffer = NULL;
- m_objectiveWin = NULL;
- for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
- m_objectiveLines[i] = NULL;
- }
-
- SinglePlayerLoadScreen::~SinglePlayerLoadScreen( void )
- {
- m_progressBar = NULL;
- m_percent = NULL;
- m_objectiveWin = NULL;
- for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
- m_objectiveLines[i] = NULL;
- if(m_videoBuffer)
- delete m_videoBuffer;
- m_videoBuffer = NULL;
- if ( m_videoStream )
- m_videoStream->close();
- m_videoStream = NULL;
-
- TheAudio->removeAudioEvent( m_ambientLoopHandle );
- m_ambientLoopHandle = NULL;
-
- }
- void SinglePlayerLoadScreen::moveWindows( Int frame )
- {
- enum{
- STATE_BEGIN = 250,
- STATE_SHOW_LOCATION = 251,
- STATE_BEGIN_BREIFING = 255,
- // STATE_BEGIN_ANIMATING_TEXT = 250,
- STATE_SHOW_CAMEO_1 = 434,
- STATE_BEGIN_ANIMATING_TEXT = 356,
- STATE_HIDE_CAMEO_1 = 459,
- STATE_SHOW_CAMEO_2 = 464,
- STATE_HIDE_CAMEO_2 = 492,
- STATE_SHOW_CAMEO_3 = 497,
- STATE_HIDE_CAMEO_3 = 524,
- // STATE_END_ANIM_HEAD = 450,
- STATE_END_ANIMATING_TEXT = 730,
- STATE_END = 730
- };
- if(frame < STATE_BEGIN || frame > STATE_END)
- return;
-
- if( frame == STATE_BEGIN_BREIFING)
- {
- // add sound support here
- TheAudio->friend_forcePlayAudioEventRTS(&TheCampaignManager->getCurrentMission()->m_briefingVoice);
- }
- if( frame == STATE_BEGIN_ANIMATING_TEXT)
- {
- m_objectiveWin->winHide(FALSE);
- // animate the text and stuff
- }
-
- if( frame > STATE_BEGIN_ANIMATING_TEXT && frame <= STATE_END_ANIMATING_TEXT && !m_finishedObjectiveText)
- {
- if(m_currentObjectiveLineCharacter >= m_unicodeObjectiveLines[m_currentObjectiveLine].getLength() )
- {
- m_currentObjectiveLine++;
- m_currentObjectiveLineCharacter =0;
- }
- if(m_currentObjectiveLine >= MAX_OBJECTIVE_LINES || m_unicodeObjectiveLines[m_currentObjectiveLine].isEmpty())
- {
- m_finishedObjectiveText = TRUE;
- }
- else
- {
- WideChar wChar = m_unicodeObjectiveLines[m_currentObjectiveLine].getCharAt(m_currentObjectiveLineCharacter);
- UnicodeString text = GadgetStaticTextGetText(m_objectiveLines[m_currentObjectiveLine]);
- text.concat(wChar);
- GadgetStaticTextSetText(m_objectiveLines[m_currentObjectiveLine], text);
- }
- m_currentObjectiveLineCharacter++;
- }
- switch (frame) {
-
- case STATE_SHOW_LOCATION:
- m_location->winHide(FALSE);
- break;
- case STATE_SHOW_CAMEO_1:
- m_unitDesc[0]->winHide(FALSE);
- break;
- case STATE_HIDE_CAMEO_1:
- m_unitDesc[0]->winHide(TRUE);
- break;
- case STATE_SHOW_CAMEO_2:
- m_unitDesc[1]->winHide(FALSE);
- break;
- case STATE_HIDE_CAMEO_2:
- m_unitDesc[1]->winHide(TRUE);
- break;
- case STATE_SHOW_CAMEO_3:
- m_unitDesc[2]->winHide(FALSE);
- break;
- case STATE_HIDE_CAMEO_3:
- m_unitDesc[2]->winHide(TRUE);
- break;
- }
- }
- /*
- static Bool on = FALSE;
- static ICoord2D startPos, endPos;
- enum{
- STATE_BEGIN = 275,
- STATE_BEGIN_ANIM = 290,
- STATE_ANIM_CAMEO1 = 300,
- STATE_ANIM_CAMEO1_TRASITION_CAMEO2 = 350,
- STATE_ANIM_CAMEO2 = 400,
- STATE_ANIM_CAMEO2_TRASITION_CAMEO3 = 450,
- STATE_ANIM_CAMEO3 = 500,
- STATED_END_ANIM = 550,
- STATE_END = 800
- };
- if(frame < STATE_BEGIN)
- return;
- else if(frame == STATE_BEGIN )
- {
- m_cameoWindow1->winHide(FALSE);
- m_cameoWindow2->winHide(FALSE);
- m_cameoWindow3->winHide(FALSE);
- m_cameoFrame->winHide(FALSE);
- }
- else if( frame == STATE_ANIM_CAMEO1)
- {
- m_cameoWindow1->winEnable(TRUE);
- GadgetStaticTextSetText(m_cameoText, TheGameText->fetch(TheCampaignManager->getCurrentMission()->m_cameoImageName[0]));
- //save of positions
- }
- else if( frame == STATE_ANIM_CAMEO1_TRASITION_CAMEO2)
- {
- m_cameoWindow1->winEnable(FALSE);
- GadgetStaticTextSetText(m_cameoText, UnicodeString::TheEmptyString);
- ICoord2D tempPos;
- Int xOffset;
- m_cameoFrame->winGetPosition(&startPos.x, &startPos.y);
- m_cameoWindow1->winGetPosition(&tempPos.x, &tempPos.y);
- xOffset = tempPos.x - startPos.x;
- m_cameoWindow2->winGetPosition(&endPos.x, &endPos.y);
- endPos.x = endPos.x - xOffset;
- endPos.y = startPos.y;
-
- }
- else if( frame > STATE_ANIM_CAMEO1_TRASITION_CAMEO2 && frame < STATE_ANIM_CAMEO2)
- {
-
- //extrapolate between start and end pos
- Real percent = INT_TO_REAL((frame - STATE_ANIM_CAMEO1_TRASITION_CAMEO2)) / (STATE_ANIM_CAMEO2 - STATE_ANIM_CAMEO1_TRASITION_CAMEO2);
- m_cameoFrame->winSetPosition(startPos.x + (endPos.x - startPos.x) * percent, endPos.y);
- }
- else if( frame == STATE_ANIM_CAMEO2 )
- {
- m_cameoWindow2->winEnable(TRUE);
- m_cameoFrame->winSetPosition(endPos.x, endPos.y);
- GadgetStaticTextSetText(m_cameoText, TheGameText->fetch(TheCampaignManager->getCurrentMission()->m_cameoImageName[1]));
- }
- else if( frame == STATE_ANIM_CAMEO2_TRASITION_CAMEO3)
- {
- m_cameoWindow2->winEnable(FALSE);
- GadgetStaticTextSetText(m_cameoText, UnicodeString::TheEmptyString);
- ICoord2D tempPos;
- Int xOffset;
- m_cameoFrame->winGetPosition(&startPos.x, &startPos.y);
- m_cameoWindow2->winGetPosition(&tempPos.x, &tempPos.y);
- xOffset = tempPos.x - startPos.x;
- m_cameoWindow3->winGetPosition(&endPos.x, &endPos.y);
- endPos.x = endPos.x - xOffset;
- endPos.y = startPos.y;
-
- }
- else if( frame > STATE_ANIM_CAMEO2_TRASITION_CAMEO3 && frame < STATE_ANIM_CAMEO3)
- {
-
- //extrapolate between start and end pos
- Real percent = INT_TO_REAL((frame - STATE_ANIM_CAMEO2_TRASITION_CAMEO3)) / (STATE_ANIM_CAMEO3 - STATE_ANIM_CAMEO2_TRASITION_CAMEO3);
- m_cameoFrame->winSetPosition(startPos.x + (endPos.x - startPos.x) * percent, endPos.y);
- }
- else if( frame == STATE_ANIM_CAMEO3 )
- {
- m_cameoFrame->winSetPosition(endPos.x, endPos.y);
- m_cameoWindow3->winEnable(TRUE);
- GadgetStaticTextSetText(m_cameoText, TheGameText->fetch(TheCampaignManager->getCurrentMission()->m_cameoImageName[2]));
- }
- else if( frame ==STATED_END_ANIM)
- {
- m_cameoWindow3->winEnable(FALSE);
- GadgetStaticTextSetText(m_cameoText, UnicodeString::TheEmptyString);
- m_cameoFrame->winHide(TRUE);
-
- }
- }*/
-
- void SinglePlayerLoadScreen::init( GameInfo *game )
- {
- //No music in SinglePlayerLoadScreen
- // create the layout of the load screen
- m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/SinglePlayerLoadScreen.wnd" ) );
- DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the single player loadscreen"));
- m_loadScreen->winHide(FALSE);
- m_loadScreen->winBringToTop();
- // Mission *mission = TheCampaignManager->getCurrentMission();
- // Store the pointer to the progress bar on the loadscreen
- m_progressBar = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:ProgressLoad" ) ));
- DEBUG_ASSERTCRASH(m_progressBar, ("Can't initialize the progressbar for the single player loadscreen"));
- GadgetProgressBarSetProgress(m_progressBar, 0 );
- m_percent = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:Percent" ) ));
- DEBUG_ASSERTCRASH(m_percent, ("Can't initialize the m_percent for the single player loadscreen"));
- GadgetStaticTextSetText(m_percent,UnicodeString(L"0%"));
- m_percent->winHide(TRUE);
- m_objectiveWin = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:ObjectivesWin" ) ));
- DEBUG_ASSERTCRASH(m_objectiveWin, ("Can't initialize the m_objectiveWin for the single player loadscreen"));
- m_objectiveWin->winHide(TRUE);
-
- Mission *mission = TheCampaignManager->getCurrentMission();
- AsciiString lineName;
- for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
- {
- lineName.format("SinglePlayerLoadScreen.wnd:StaticTextLine%d",i);
- m_objectiveLines[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( lineName ));
- DEBUG_ASSERTCRASH(m_objectiveLines[i], ("Can't initialize the m_objectiveLines[%d] for the single player loadscreen", i));
- GadgetStaticTextSetText(m_objectiveLines[i],UnicodeString::TheEmptyString);
- // translate the objective lines
- if(mission->m_missionObjectivesLabel[i].isNotEmpty())
- m_unicodeObjectiveLines[i] = TheGameText->fetch(mission->m_missionObjectivesLabel[i]);
- }
- for(i = 0; i < MAX_DISPLAYED_UNITS; ++i)
- {
- lineName.format("SinglePlayerLoadScreen.wnd:StaticTextCameoText%d",i);
- m_unitDesc[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( lineName ));
- DEBUG_ASSERTCRASH(m_unitDesc[i], ("Can't initialize the m_objectiveLines[%d] for the single player loadscreen", i));
- GadgetStaticTextSetText(m_unitDesc[i],TheGameText->fetch(mission->m_unitNames[i]));
- m_unitDesc[i]->winHide(TRUE);
- }
- m_location = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:StaticTextCameoText3" ) ));
- DEBUG_ASSERTCRASH(m_location, ("Can't initialize the m_objectiveWin for the single player loadscreen"));
- m_location->winHide(TRUE);
- GadgetStaticTextSetText(m_location, TheGameText->fetch(mission->m_locationNameLabel));
-
-
- m_currentObjectiveLine = 0;
- m_currentObjectiveWidthOffset = 0;
- m_currentObjectiveLineCharacter = 0;
- m_finishedObjectiveText = FALSE;
- /*
- m_cameoWindow1 = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowCameo1" ) ));
- DEBUG_ASSERTCRASH(m_cameoWindow1, ("Can't initialize the m_cameoWindow1 for the single player loadscreen"));
- m_cameoWindow1->winHide(TRUE);
- m_cameoWindow1->winEnable(FALSE);
- m_cameoWindow1->winSetEnabledImage(0, mission->m_cameoImage[0]);
- m_cameoWindow1->winSetDisabledImage(0, mission->m_cameoDisabledImage[0]);
- m_cameoWindow2 = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowCameo2" ) ));
- DEBUG_ASSERTCRASH(m_cameoWindow2, ("Can't initialize the m_cameoWindow2 for the single player loadscreen"));
- m_cameoWindow2->winHide(TRUE);
- m_cameoWindow2->winEnable(FALSE);
- m_cameoWindow2->winSetEnabledImage(0, mission->m_cameoImage[1]);
- m_cameoWindow2->winSetDisabledImage(0, mission->m_cameoDisabledImage[1]);
- m_cameoWindow3 = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowCameo3" ) ));
- DEBUG_ASSERTCRASH(m_cameoWindow3, ("Can't initialize the m_cameoWindow3 for the single player loadscreen"));
- m_cameoWindow3->winHide(TRUE);
- m_cameoWindow3->winEnable(FALSE);
- m_cameoWindow3->winSetEnabledImage(0, mission->m_cameoImage[2]);
- m_cameoWindow3->winSetDisabledImage(0, mission->m_cameoDisabledImage[2]);
- m_headMovie = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowHead" ) ));
- DEBUG_ASSERTCRASH(m_headMovie, ("Can't initialize the m_headMovie for the single player loadscreen"));
- m_headMovie->winHide(TRUE);
- m_cameoFrame = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:WindowHiliteCameo" ) ));
- DEBUG_ASSERTCRASH(m_cameoFrame, ("Can't initialize the m_cameoFrame for the single player loadscreen"));
- m_cameoFrame->winHide(TRUE);
- m_cameoText = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "SinglePlayerLoadScreen.wnd:StaticTextCameoText" ) ));
- DEBUG_ASSERTCRASH(m_cameoText, ("Can't initialize the m_cameoText for the single player loadscreen"));
- */
- m_ambientLoop.setEventName("LoadScreenAmbient");
- // create the new stream
- m_videoStream = TheVideoPlayer->open( TheCampaignManager->getCurrentMission()->m_movieLabel );
- if ( m_videoStream == NULL )
- {
- m_percent->winHide(TRUE);
- return;
- }
- // Create the new buffer
- m_videoBuffer = TheDisplay->createVideoBuffer();
- if ( m_videoBuffer == NULL ||
- !m_videoBuffer->allocate( m_videoStream->width(),
- m_videoStream->height())
- )
- {
- delete m_videoBuffer;
- m_videoBuffer = NULL;
- if ( m_videoStream )
- m_videoStream->close();
- m_videoStream = NULL;
- return;
- }
-
- if(TheGameLODManager && TheGameLODManager->didMemPass())
- {
- Int progressUpdateCount = m_videoStream->frameCount() / FRAME_FUDGE_ADD;
- Int shiftedPercent = -FRAME_FUDGE_ADD + 1;
- while (m_videoStream->frameIndex() < m_videoStream->frameCount() - 1 )
- {
- TheGameEngine->serviceWindowsOS();
- if(!m_videoStream->isFrameReady())
- {
- Sleep(1);
- continue;
- }
- if (!TheGameEngine->isActive())
- { //we are alt-tabbed out, so just increment the frame
- m_videoStream->frameNext();
- m_videoStream->frameDecompress();
- continue;
- }
-
- m_videoStream->frameDecompress();
- m_videoStream->frameRender(m_videoBuffer);
- moveWindows( m_videoStream->frameIndex());
- m_videoStream->frameNext();
- if(m_videoBuffer)
- m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);
- if(m_videoStream->frameIndex() % progressUpdateCount == 0)
- {
- shiftedPercent++;
- if(shiftedPercent >0)
- shiftedPercent = 0;
- Int percent = (shiftedPercent + FRAME_FUDGE_ADD)/1.3;
- UnicodeString per;
- per.format(L"%d%%",percent);
- TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
- GadgetProgressBarSetProgress(m_progressBar, percent);
- GadgetStaticTextSetText(m_percent, per);
-
- }
- TheWindowManager->update();
- //TheShell->update();
- //TheDisplay->update();
- // redraw all views, update the GUI
- TheDisplay->draw();
- }
- }
- else
- {
- // if we're min speced
- m_videoStream->frameGoto(m_videoStream->frameCount()); // zero based
- while(!m_videoStream->isFrameReady())
- Sleep(1);
- m_videoStream->frameDecompress();
- m_videoStream->frameRender(m_videoBuffer);
- if(m_videoBuffer)
- m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);
- m_objectiveWin->winHide(FALSE);
- for(i = 0; i < MAX_DISPLAYED_UNITS; ++i)
- m_unitDesc[i]->winHide(FALSE);
- m_location->winHide(FALSE);
- // Audio was choppy so, I chopped it out!
- TheAudio->friend_forcePlayAudioEventRTS(&TheCampaignManager->getCurrentMission()->m_briefingVoice);
-
- for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
- {
- GadgetStaticTextSetText(m_objectiveLines[i], m_unicodeObjectiveLines[i]);
- }
-
- Int delay = mission->m_voiceLength * 1000;
- Int begin = timeGetTime();
- Int currTime = begin;
- Int fudgeFactor = 0;
- while(begin + delay > currTime )
- {
- fudgeFactor = 30 * ((currTime - begin)/ INT_TO_REAL(delay ));
- GadgetProgressBarSetProgress(m_progressBar, fudgeFactor);
- TheWindowManager->update();
- TheDisplay->draw();
- Sleep(100);
- currTime = timeGetTime();
- }
-
- TheWindowManager->update();
- TheDisplay->draw();
- }
- setFPMode();
- m_percent->winHide(TRUE);
- m_ambientLoopHandle = TheAudio->addAudioEvent(&m_ambientLoop);
-
- }
- void SinglePlayerLoadScreen::reset( void )
- {
- setLoadScreen(NULL);
- m_progressBar = NULL;
- }
- void SinglePlayerLoadScreen::update( Int percent )
- {
- percent = (percent + FRAME_FUDGE_ADD)/1.3;
- UnicodeString per;
- per.format(L"%d%%",percent);
- TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
- GadgetProgressBarSetProgress(m_progressBar, percent);
- GadgetStaticTextSetText(m_percent, per);
-
- // Do this last!
- LoadScreen::update( percent );
- }
- void SinglePlayerLoadScreen::setProgressRange( Int min, Int max )
- {
- }
- // ShellGameLoadScreen Class //////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- ShellGameLoadScreen::ShellGameLoadScreen( void )
- {
- m_progressBar = NULL;
- }
-
- ShellGameLoadScreen::~ShellGameLoadScreen( void )
- {
-
- m_progressBar = NULL;
- }
- void ShellGameLoadScreen::init( GameInfo *game )
- {
- static BOOL firstLoad = TRUE;
-
- // create the layout of the load screen
- m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/ShellGameLoadScreen.wnd" ) );
- DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the ShellGame loadscreen"));
- m_loadScreen->winHide(FALSE);
- m_loadScreen->winBringToTop();
- // Store the pointer to the progress bar on the loadscreen
- m_progressBar = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "ShellGameLoadScreen.wnd:ProgressLoad" ) ));
- DEBUG_ASSERTCRASH(m_progressBar, ("Can't initialize the progressbar for the single player loadscreen"));
- GadgetProgressBarSetProgress(m_progressBar, 0 );
- m_progressBar->winHide(TRUE);
-
- if(m_loadScreen && firstLoad && TheGameLODManager && TheGameLODManager->didMemPass())
- {
- m_loadScreen->winSetEnabledImage(0, TheMappedImageCollection->findImageByName("TitleScreen"));
- TheWritableGlobalData->m_breakTheMovie = FALSE;
- // m_videoStream = TheVideoPlayer->open( "Sizzle" );
- // if ( m_videoStream == NULL )
- // {
- // m_progressBar->winHide(FALSE);
- // return;
- // }
- //
- // // Create the new buffer
- // m_videoBuffer = TheDisplay->createVideoBuffer();
- // if ( m_videoBuffer == NULL ||
- // !m_videoBuffer->allocate( m_videoStream->width(),
- // m_videoStream->height())
- // )
- // {
- // delete m_videoBuffer;
- // m_videoBuffer = NULL;
- //
- // if ( m_videoStream )
- // m_videoStream->close();
- // m_videoStream = NULL;
- //
- // return;
- // }
- // TheGlobalData->m_isBreakableMovie = TRUE;
- // TheGlobalData->m_breakTheMovie = FALSE;
- // while (m_videoStream->frameIndex() < m_videoStream->frameCount() - 1 )
- // {
- // if(TheGlobalData->m_breakTheMovie)
- // {
- // TheGlobalData->m_breakTheMovie = FALSE;
- // m_videoStream->frameGoto(m_videoStream->frameCount() - 1);
- // }
- // if(m_videoStream->frameIndex() < m_videoStream->frameCount() - 1)
- // {
- // if(!m_videoStream->isFrameReady())
- // continue;
- //
- // m_videoStream->frameDecompress();
- // m_videoStream->frameRender(m_videoBuffer);
- // m_videoStream->frameNext();
- // if(m_videoBuffer)
- // m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);
- // }
- //
- // TheWindowManager->update();
- // // TheShell->update();
- // //TheDisplay->update();
- // // redraw all views, update the GUI
- // TheDisplay->draw();
- // }
- // TheGlobalData->m_isBreakableMovie = FALSE;
- // TheGlobalData->m_breakTheMovie = FALSE;
- // GameWindow *win = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "ShellGameLoadScreen.wnd:EAGamesLogo" ) ));
- // if(win)
- // win->winHide(FALSE);
- GameWindow *win = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( AsciiString( "ShellGameLoadScreen.wnd:StaticTextLegal" ) ));
- if(win)
- win->winHide(FALSE);
- firstLoad = FALSE;
- UnsignedInt showTime = timeGetTime();
- while(showTime + 3000 > timeGetTime())
- {
- LoadScreen::update(0);
- Sleep(100);
- }
- }
- m_progressBar->winHide(FALSE);
- }
- void ShellGameLoadScreen::reset( void )
- {
- setLoadScreen(NULL);
- m_progressBar = NULL;
- }
- void ShellGameLoadScreen::update( Int percent )
- {
- TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
- GadgetProgressBarSetProgress(m_progressBar, percent);
- // Do this last!
- LoadScreen::update( percent );
- }
- // MultiPlayerLoadScreen Class //////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- MultiPlayerLoadScreen::MultiPlayerLoadScreen( void )
- {
- //Added By Sadullah Nader
- //Initializations missing and needed
- m_mapPreview = NULL;
- //
- for(Int i = 0; i < MAX_SLOTS; ++i)
- {
- //Added By Sadullah Nader
- //Initializations missing and needed
- m_buttonMapStartPosition[i] = NULL;
- //
- m_progressBars[i] = NULL;
- m_playerNames[i] = NULL;
- m_playerSide[i]= NULL;
- m_playerLookup[i] = -1;
- }
- }
-
- MultiPlayerLoadScreen::~MultiPlayerLoadScreen( void )
- {
- for(Int i = 0; i < MAX_SLOTS; ++i)
- {
- m_progressBars[i] = NULL;
- m_playerNames[i] = NULL;
- m_playerSide[i]= NULL;
- m_playerLookup[i] = -1;
- }
- TheAudio->removeAudioEvent( AHSV_StopTheMusicFade );
- // TheAudio->stopAudio( AudioAffect_Music );
- }
- void MultiPlayerLoadScreen::init( GameInfo *game )
- {
- // create the layout of the load screen
- m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/MultiplayerLoadScreen.wnd" ) );
- DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the Multiplayer loadscreen"));
- m_loadScreen->winHide(FALSE);
- m_loadScreen->winBringToTop();
- m_mapPreview = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "MultiplayerLoadScreen.wnd:WinMapPreview"));
- GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
- const PlayerTemplate* pt;
- if (lSlot->getPlayerTemplate() >= 0)
- pt = ThePlayerTemplateStore->getNthPlayerTemplate(lSlot->getPlayerTemplate());
- else
- pt = ThePlayerTemplateStore->findPlayerTemplate( TheNameKeyGenerator->nameToKey("FactionObserver") );
- const Image *loadScreenImage = TheMappedImageCollection->findImageByName(pt->getLoadScreen());
- AsciiString musicName = pt->getLoadScreenMusic();
- if ( ! musicName.isEmpty() )
- {
- TheAudio->removeAudioEvent( AHSV_StopTheMusicFade );
- AudioEventRTS event( musicName );
- event.setShouldFade( TRUE );
- TheAudio->addAudioEvent( &event );
- TheAudio->update();//Since GameEngine::update() is suspended until after I am gone...
- }
- if(loadScreenImage)
- m_loadScreen->winSetEnabledImage(0, loadScreenImage);
- //DEBUG_ASSERTCRASH(TheNetwork, ("Where the Heck is the Network!!!!"));
- //DEBUG_LOG(("NumPlayers %d\n", TheNetwork->getNumPlayers()));
- GameWindow *teamWin[MAX_SLOTS];
- for (Int i = 0; i < MAX_SLOTS; ++i)
- {
- teamWin[i] = NULL;
- }
- Int netSlot = 0;
- // Loop through and make the loadscreen look all good.
- for (i = 0; i < MAX_SLOTS; ++i)
- {
- // Load the Progress Bar
- AsciiString winName;
- winName.format( "MultiplayerLoadScreen.wnd:ProgressLoad%d",i);
- m_progressBars[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_progressBars[i], ("Can't initialize the progressbars for the Multiplayer loadscreen"));
- // set the progressbar to zero
- GadgetProgressBarSetProgress(m_progressBars[i], 0 );
- // Load MapStart Positions
- winName.format( "MultiplayerLoadScreen.wnd:ButtonMapStartPosition%d",i);
- m_buttonMapStartPosition[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_buttonMapStartPosition[i], ("Can't initialize the MapStart Positions for the MultiplayerLoadScreen loadscreen"));
- // Load the Player's name
- winName.format( "MultiplayerLoadScreen.wnd:StaticTextPlayer%d",i);
- m_playerNames[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_playerNames[i], ("Can't initialize the Names for the Multiplayer loadscreen"));
-
- // Load the Player's Side
- winName.format( "MultiplayerLoadScreen.wnd:StaticTextSide%d",i);
- m_playerSide[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_playerSide[i], ("Can't initialize the Sides for the Multiplayer loadscreen"));
-
- winName.format( "MultiplayerLoadScreen.wnd:StaticTextTeam%d",i);
- teamWin[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- // get the slot man!
- GameSlot *slot = game->getSlot(i);
- if (!slot || !slot->isOccupied())
- continue;
- Color houseColor = TheMultiplayerSettings->getColor(slot->getApparentColor())->getColor();
- GadgetProgressBarSetEnabledBarColor(m_progressBars[netSlot],houseColor );
- UnicodeString name = slot->getName();
- GadgetStaticTextSetText(m_playerNames[netSlot], name );
- m_playerNames[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
- GadgetStaticTextSetText(m_playerSide[netSlot], slot->getApparentPlayerTemplateDisplayName() );
- m_playerSide[netSlot]->winSetEnabledTextColors(houseColor, m_playerSide[netSlot]->winGetEnabledTextBorderColor());
- if (slot->isAI() && m_progressBars[netSlot])
- m_progressBars[netSlot]->winHide(TRUE);
- if (teamWin[netSlot])
- {
- AsciiString teamStr;
- teamStr.format("Team:%d", slot->getTeamNumber() + 1);
- GadgetStaticTextSetText(teamWin[netSlot], TheGameText->fetch(teamStr));
- teamWin[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
- }
- m_playerLookup[i] = netSlot; // save our mapping so we can update progress correctly
- netSlot++;
- }
-
- for(i = netSlot; i < MAX_SLOTS; ++i)
- {
- m_progressBars[i]->winHide(TRUE);
- m_playerNames[i]->winHide(TRUE);
- m_playerSide[i]->winHide(TRUE);
- teamWin[i]->winHide(TRUE);
- }
- if(m_mapPreview)
- {
- const MapMetaData *mmd = TheMapCache->findMap(game->getMap());
- Image *image = getMapPreviewImage(game->getMap());
- m_mapPreview->winSetUserData((void *)mmd);
-
- positionStartSpots( game, m_buttonMapStartPosition, m_mapPreview);
- updateMapStartSpots( game, m_buttonMapStartPosition, TRUE );
- //positionAdditionalImages((MapMetaData *)mmd, m_mapPreview, TRUE);
- if(image)
- {
- m_mapPreview->winSetStatus(WIN_STATUS_IMAGE);
- m_mapPreview->winSetEnabledImage(0, image);
- }
- else
- {
- m_mapPreview->winClearStatus(WIN_STATUS_IMAGE);
- }
- }
-
- TheGameLogic->initTimeOutValues();
- }
- void MultiPlayerLoadScreen::reset( void )
- {
- setLoadScreen(NULL);
- for(Int i = 0; i < MAX_SLOTS; ++i)
- {
- m_progressBars[i] = NULL;
- m_playerNames[i] = NULL;
- m_playerSide[i]= NULL;
- }
- }
- void MultiPlayerLoadScreen::update( Int percent )
- {
- if (TheNetwork)
- {
- if(percent <= 100)
- TheNetwork->updateLoadProgress( percent );
- TheNetwork->liteupdate();
- }
- else
- {
- if (percent <= 100)
- TheGameLogic->processProgress( TheGameInfo->getLocalSlotNum(), percent );
- }
- //GadgetProgressBarSetProgress(m_progressBars[TheNetwork->getLocalPlayerID()], percent );
- TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
- // Do this last!
- LoadScreen::update( percent );
- }
- void MultiPlayerLoadScreen::processProgress(Int playerId, Int percentage)
- {
-
- if( percentage < 0 || percentage > 100 || playerId >= MAX_SLOTS || playerId < 0 || m_playerLookup[playerId] == -1)
- {
- DEBUG_ASSERTCRASH(FALSE, ("Percentage %d was passed in for Player %d\n", percentage, playerId));
- }
- //DEBUG_LOG(("Percentage %d was passed in for Player %d (in loadscreen position %d)\n", percentage, playerId, m_playerLookup[playerId]));
- if(m_progressBars[m_playerLookup[playerId]])
- GadgetProgressBarSetProgress(m_progressBars[m_playerLookup[playerId]], percentage );
- }
- // GameSpyLoadScreen Class //////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- GameSpyLoadScreen::GameSpyLoadScreen( void )
- {
- // Added By Sadullah Nader
- // Initializations missing and needed
- m_mapPreview = NULL;
- //
- for(Int i = 0; i < MAX_SLOTS; ++i)
- {
-
- // Added By Sadullah Nader
- // Initializations missing and needed
- m_buttonMapStartPosition[i] = NULL;
- m_playerRank[i] = NULL;
- //
- m_playerOfficerMedal[i] = NULL;
- m_progressBars[i] = NULL;
- m_playerNames[i] = NULL;
- m_playerSide[i]= NULL;
- m_playerLookup[i] = -1;
- m_playerFavoriteFactions[i]= NULL;
- m_playerTotalDisconnects[i]= NULL;
- m_playerWin[i]= NULL;
- m_playerWinLosses[i]= NULL;
- }
- }
-
- GameSpyLoadScreen::~GameSpyLoadScreen( void )
- {
- for(Int i = 0; i < MAX_SLOTS; ++i)
- {
- m_progressBars[i] = NULL;
- m_playerNames[i] = NULL;
- m_playerSide[i]= NULL;
- m_playerLookup[i] = -1;
- m_playerFavoriteFactions[i]= NULL;
- m_playerTotalDisconnects[i]= NULL;
- m_playerWin[i]= NULL;
- m_playerWinLosses[i]= NULL;
- }
- }
- extern Int GetAdditionalDisconnectsFromUserFile(Int playerID);
- void GameSpyLoadScreen::init( GameInfo *game )
- {
- // create the layout of the load screen
- m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/GameSpyLoadScreen.wnd" ) );
- DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the Multiplayer loadscreen"));
- m_loadScreen->winHide(FALSE);
- m_loadScreen->winBringToTop();
- m_mapPreview = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "GameSpyLoadScreen.wnd:WinMapPreview"));
- DEBUG_ASSERTCRASH(TheNetwork, ("Where the Heck is the Network!!!!"));
- DEBUG_LOG(("NumPlayers %d\n", TheNetwork->getNumPlayers()));
- GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
- const PlayerTemplate* pt;
- if (lSlot->getPlayerTemplate() >= 0)
- pt = ThePlayerTemplateStore->getNthPlayerTemplate(lSlot->getPlayerTemplate());
- else
- pt = ThePlayerTemplateStore->findPlayerTemplate( TheNameKeyGenerator->nameToKey("FactionObserver") );
- const Image *loadScreenImage = TheMappedImageCollection->findImageByName(pt->getLoadScreen());
- if(loadScreenImage)
- m_loadScreen->winSetEnabledImage(0, loadScreenImage);
- GameWindow *teamWin[MAX_SLOTS];
- for (Int i = 0; i < MAX_SLOTS; ++i)
- {
- teamWin[i] = NULL;
- }
- Int netSlot = 0;
- // Loop through and make the loadscreen look all good.
- for (i = 0; i < MAX_SLOTS; ++i)
- {
- // Load the Progress Bar
- AsciiString winName;
- winName.format( "GameSpyLoadScreen.wnd:ProgressLoad%d",i);
- m_progressBars[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_progressBars[i], ("Can't initialize the progressbars for the GameSpyLoadScreen loadscreen"));
- // set the progressbar to zero
- GadgetProgressBarSetProgress(m_progressBars[i], 0 );
- // Load the Player's name
- winName.format( "GameSpyLoadScreen.wnd:StaticTextPlayer%d",i);
- m_playerNames[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_playerNames[i], ("Can't initialize the Names for the GameSpyLoadScreen loadscreen"));
-
- // Load MapStart Positions
- winName.format( "GameSpyLoadScreen.wnd:ButtonMapStartPosition%d",i);
- m_buttonMapStartPosition[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_buttonMapStartPosition[i], ("Can't initialize the MapStart Positions for the GameSpyLoadScreen loadscreen"));
- // Load the Player's Side
- winName.format( "GameSpyLoadScreen.wnd:StaticTextSide%d",i);
- m_playerSide[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_playerSide[i], ("Can't initialize the Sides for the GameSpyLoadScreen loadscreen"));
-
- // Load the Player's window
- winName.format( "GameSpyLoadScreen.wnd:WinPlayer%d",i);
- m_playerWin[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_playerWin[i], ("Can't initialize the WinPlayer for the GameSpyLoadScreen loadscreen"));
-
- // Load the Player's m_playerTotalDisconnects
- winName.format( "GameSpyLoadScreen.wnd:StaticTextTotalDisconnects%d",i);
- m_playerTotalDisconnects[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_playerTotalDisconnects[i], ("Can't initialize the m_playerTotalDisconnects for the GameSpyLoadScreen loadscreen"));
- // // Load the Player's m_playerFavoriteFactions
- // winName.format( "GameSpyLoadScreen.wnd:StaticTextFavoriteFaction%d",i);
- // m_playerFavoriteFactions[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- // DEBUG_ASSERTCRASH(m_playerFavoriteFactions[i], ("Can't initialize the StaticTextFavoriteFaction for the GameSpyLoadScreen loadscreen"));
- // Load the Player's m_playerWinLosses
- winName.format( "GameSpyLoadScreen.wnd:StaticTextWinLoss%d",i);
- m_playerWinLosses[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_playerWinLosses[i], ("Can't initialize the m_playerWinLosses for the GameSpyLoadScreen loadscreen"));
- // Load the Player's m_playerWinLosses
- winName.format( "GameSpyLoadScreen.wnd:WinRank%d",i);
- m_playerRank[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_playerRank[i], ("Can't initialize the m_playerRank for the GameSpyLoadScreen loadscreen"));
- // Load the Player's m_playerOfficerMedal
- winName.format( "GameSpyLoadScreen.wnd:WinOfficer%d",i);
- m_playerOfficerMedal[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_playerOfficerMedal[i], ("Can't initialize the m_playerOfficerMedal for the GameSpyLoadScreen loadscreen"));
- winName.format( "MultiplayerLoadScreen.wnd:StaticTextTeam%d",i);
- teamWin[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- // get the slot man!
- GameSpyGameSlot *slot = (GameSpyGameSlot *)game->getSlot(i);
- if (!slot || !slot->isOccupied())
- continue;
- Color houseColor = TheMultiplayerSettings->getColor(slot->getApparentColor())->getColor();
- GadgetProgressBarSetEnabledBarColor(m_progressBars[netSlot],houseColor );
- UnicodeString name = slot->getName();
- GadgetStaticTextSetText(m_playerNames[netSlot], name );
- m_playerNames[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
- // Get the stats for the player
- PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(slot->getProfileID());
- DEBUG_LOG(("LoadScreen - populating info for %ls(%d) - stats returned id %d\n",
- slot->getName().str(), slot->getProfileID(), stats.id));
- Bool isPreorder = TheGameSpyInfo->didPlayerPreorder(stats.id);
- Int rankPoints = CalculateRank(stats);
- Int favSide = GetFavoriteSide(stats);
- const Image *preorderImg = TheMappedImageCollection->findImageByName("OfficersClubsmall");
- if (!isPreorder)
- preorderImg = NULL;
- const Image *rankImg = LookupSmallRankImage(favSide, rankPoints);
- m_playerOfficerMedal[i]->winSetEnabledImage(0, preorderImg);
- m_playerRank[i]->winSetEnabledImage(0, rankImg);
- UnicodeString formatString;
-
- // pop wins and losses
- Int numLosses = 0;
- PerGeneralMap::iterator it;
- for(it = stats.losses.begin(); it != stats.losses.end(); ++it)
- {
- numLosses += it->second;
- }
- Int numWins = 0;
- for(it =stats.wins.begin(); it != stats.wins.end(); ++it)
- {
- numWins += it->second;
- }
- formatString.format(L"%d/%d", numWins, numLosses);
- GadgetStaticTextSetText(m_playerWinLosses[netSlot], formatString);
- m_playerWinLosses[netSlot]->winSetEnabledTextColors(houseColor, m_playerWinLosses[netSlot]->winGetEnabledTextBorderColor());
- // favoriteFaction
- Int numGames = 0;
- Int favorite = 0;
- for(it =stats.games.begin(); it != stats.games.end(); ++it)
- {
- if(it->second >= numGames)
- {
- numGames = it->second;
- favorite = it->first;
- }
- }
- // if(numGames == 0)
- // GadgetStaticTextSetText(m_playerFavoriteFactions[netSlot], TheGameText->fetch("GUI:None"));
- // else if( stats.gamesAsRandom > numGames )
- // GadgetStaticTextSetText(m_playerFavoriteFactions[netSlot], TheGameText->fetch("GUI:Random"));
- // else
- // {
- // const PlayerTemplate *fac = ThePlayerTemplateStore->getNthPlayerTemplate(favorite);
- // if (fac)
- // {
- // AsciiString side;
- // side.format("SIDE:%s", fac->getSide().str());
- //
- // GadgetStaticTextSetText(m_playerFavoriteFactions[netSlot], TheGameText->fetch(side));
- // }
- // }
- // m_playerFavoriteFactions[netSlot]->winSetEnabledTextColors(houseColor, m_playerFavoriteFactions[netSlot]->winGetEnabledTextBorderColor());
- // disconnects
- numGames = 0;
- for(it =stats.discons.begin(); it != stats.discons.end(); ++it)
- {
- numGames += it->second;
- }
- for(it =stats.desyncs.begin(); it != stats.desyncs.end(); ++it)
- {
- numGames += it->second;
- }
- numGames += GetAdditionalDisconnectsFromUserFile(stats.id);
- formatString.format(L"%d", numGames);
- GadgetStaticTextSetText(m_playerTotalDisconnects[netSlot], formatString);
- m_playerTotalDisconnects[netSlot]->winSetEnabledTextColors(houseColor, m_playerTotalDisconnects[netSlot]->winGetEnabledTextBorderColor());
- GadgetStaticTextSetText(m_playerSide[netSlot], slot->getApparentPlayerTemplateDisplayName() );
- m_playerSide[netSlot]->winSetEnabledTextColors(houseColor, m_playerSide[netSlot]->winGetEnabledTextBorderColor());
- if (slot->isAI())
- {
- if (m_progressBars[netSlot])
- m_progressBars[netSlot]->winHide(TRUE);
- if (m_playerTotalDisconnects[netSlot])
- m_playerTotalDisconnects[netSlot]->winHide(TRUE);
- // if (m_playerFavoriteFactions[netSlot])
- // m_playerFavoriteFactions[netSlot]->winHide(TRUE);
- if (m_playerWinLosses[netSlot])
- m_playerWinLosses[netSlot]->winHide(TRUE);
- if (m_playerRank[netSlot])
- m_playerRank[netSlot]->winHide(TRUE);
- if (m_playerOfficerMedal[netSlot])
- m_playerOfficerMedal[netSlot]->winHide(TRUE);
- }
- if (teamWin[netSlot])
- {
- AsciiString teamStr;
- teamStr.format("Team:%d", slot->getTeamNumber() + 1);
- if (slot->isAI() && slot->getTeamNumber() == -1)
- teamStr = "Team:AI";
- GadgetStaticTextSetText(teamWin[netSlot], TheGameText->fetch(teamStr));
- teamWin[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
- }
- m_playerLookup[i] = netSlot; // save our mapping so we can update progress correctly
- netSlot++;
- }
-
- for(i = netSlot; i < MAX_SLOTS; ++i)
- {
- m_playerWin[i]->winHide(TRUE);
- //m_playerNames[i]->winHide(TRUE);
- //m_playerSide[i]->winHide(TRUE);
- }
- if(m_mapPreview)
- {
- const MapMetaData *mmd = TheMapCache->findMap(game->getMap());
- Image *image = getMapPreviewImage(game->getMap());
- m_mapPreview->winSetUserData((void *)mmd);
-
- positionStartSpots( game, m_buttonMapStartPosition, m_mapPreview);
- updateMapStartSpots( game, m_buttonMapStartPosition, TRUE );
- //positionAdditionalImages((MapMetaData *)mmd, m_mapPreview, TRUE);
- if(image)
- {
- m_mapPreview->winSetStatus(WIN_STATUS_IMAGE);
- m_mapPreview->winSetEnabledImage(0, image);
- }
- else
- {
- m_mapPreview->winClearStatus(WIN_STATUS_IMAGE);
- }
- }
- TheGameLogic->initTimeOutValues();
- }
- void GameSpyLoadScreen::reset( void )
- {
- setLoadScreen(NULL);
- for(Int i = 0; i < MAX_SLOTS; ++i)
- {
- m_progressBars[i] = NULL;
- m_playerNames[i] = NULL;
- m_playerSide[i]= NULL;
- }
- }
- void GameSpyLoadScreen::update( Int percent )
- {
- if(percent <= 100)
- TheNetwork->updateLoadProgress( percent );
- TheNetwork->liteupdate();
- //GadgetProgressBarSetProgress(m_progressBars[TheNetwork->getLocalPlayerID()], percent );
- TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
- // Do this last!
- LoadScreen::update( percent );
- }
- void GameSpyLoadScreen::processProgress(Int playerId, Int percentage)
- {
-
- if( percentage < 0 || percentage > 100 || playerId >= MAX_SLOTS || playerId < 0 || m_playerLookup[playerId] == -1)
- {
- DEBUG_ASSERTCRASH(FALSE, ("Percentage %d was passed in for Player %d\n", percentage, playerId));
- }
- //DEBUG_LOG(("Percentage %d was passed in for Player %d (in loadscreen position %d)\n", percentage, playerId, m_playerLookup[playerId]));
- if(m_progressBars[m_playerLookup[playerId]])
- GadgetProgressBarSetProgress(m_progressBars[m_playerLookup[playerId]], percentage );
- }
- // MapTransferLoadScreen Class //////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- MapTransferLoadScreen::MapTransferLoadScreen( void )
- {
- //Added By Sadullah Nader
- //Initializations missing and needed
- m_oldTimeout = 0;
- //
- for(Int i = 0; i < MAX_SLOTS; ++i)
- {
- m_progressBars[i] = NULL;
- m_playerNames[i] = NULL;
- m_progressText[i]= NULL;
- m_playerLookup[i] = -1;
- m_oldProgress[i] = -1;
- }
- m_fileNameText = NULL;
- m_timeoutText = NULL;
- }
-
- MapTransferLoadScreen::~MapTransferLoadScreen( void )
- {
- for(Int i = 0; i < MAX_SLOTS; ++i)
- {
- m_progressBars[i] = NULL;
- m_playerNames[i] = NULL;
- m_progressText[i]= NULL;
- m_playerLookup[i] = -1;
- m_oldProgress[i] = -1;
- }
- m_fileNameText = NULL;
- m_timeoutText = NULL;
- }
- void MapTransferLoadScreen::init( GameInfo *game )
- {
- // create the layout of the load screen
- m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/MapTransferScreen.wnd" ) );
- DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the map transfer loadscreen"));
- if (!m_loadScreen)
- return;
- m_loadScreen->winHide(FALSE);
- m_loadScreen->winBringToTop();
- DEBUG_ASSERTCRASH(TheNetwork, ("Where the Heck is the Network?!!!!"));
- DEBUG_LOG(("NumPlayers %d\n", TheNetwork->getNumPlayers()));
- AsciiString winName;
- Int i;
- // Load the Filename Text
- winName.format( "MapTransferScreen.wnd:StaticTextCurrentFile");
- m_fileNameText = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_fileNameText, ("Can't initialize the filename for the map transfer loadscreen"));
- // Load the Timeout Text
- winName.format( "MapTransferScreen.wnd:StaticTextTimeout");
- m_timeoutText = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_timeoutText, ("Can't initialize the timeout for the map transfer loadscreen"));
- Int netSlot = 0;
- // Loop through and make the loadscreen look all good.
- for (i = 0; i < MAX_SLOTS; ++i)
- {
- // Load the Progress Bar
- winName.format( "MapTransferScreen.wnd:ProgressLoad%d",i);
- m_progressBars[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_progressBars[i], ("Can't initialize the progressbars for the map transfer loadscreen"));
- // set the progressbar to zero
- GadgetProgressBarSetProgress(m_progressBars[i], 0 );
- // Load the Player's name
- winName.format( "MapTransferScreen.wnd:StaticTextPlayer%d",i);
- m_playerNames[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_playerNames[i], ("Can't initialize the Names for the map transfer loadscreen"));
- // Load the Progress Text
- winName.format( "MapTransferScreen.wnd:StaticTextProgress%d",i);
- m_progressText[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
- DEBUG_ASSERTCRASH(m_progressText[i], ("Can't initialize the progress text for the map transfer loadscreen"));
- // get the slot man!
- GameSlot *slot = game->getSlot(i);
- if (!slot || !slot->isHuman())
- continue;
- Color houseColor = TheMultiplayerSettings->getColor(slot->getApparentColor())->getColor();
- GadgetProgressBarSetEnabledBarColor(m_progressBars[netSlot], houseColor );
- UnicodeString name = slot->getName();
- GadgetStaticTextSetText(m_playerNames[netSlot], name );
- m_playerNames[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());
- GadgetStaticTextSetText(m_progressText[netSlot], UnicodeString::TheEmptyString );
- m_progressText[netSlot]->winSetEnabledTextColors(houseColor, m_progressText[netSlot]->winGetEnabledTextBorderColor());
- if ((i == 0 || (TheGameInfo->getConstSlot(i)->isHuman() && TheGameInfo->getConstSlot(i)->hasMap())) && m_progressBars[netSlot])
- m_progressBars[netSlot]->winHide(TRUE);
- m_playerLookup[i] = netSlot; // save our mapping so we can update progress correctly
- netSlot++;
- }
-
- for(i = netSlot; i < MAX_SLOTS; ++i)
- {
- m_progressBars[i]->winHide(TRUE);
- m_playerNames[i]->winHide(TRUE);
- m_progressText[i]->winHide(TRUE);
- }
- }
- void MapTransferLoadScreen::reset( void )
- {
- setLoadScreen(NULL);
- for(Int i = 0; i < MAX_SLOTS; ++i)
- {
- m_progressBars[i] = NULL;
- m_playerNames[i] = NULL;
- m_progressText[i]= NULL;
- m_playerLookup[i] = -1;
- m_oldProgress[i] = -1;
- }
- m_fileNameText = NULL;
- m_timeoutText = NULL;
- }
- void MapTransferLoadScreen::update( Int percent )
- {
- if (TheNetwork)
- {
- TheNetwork->liteupdate();
- }
- TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
- // Do this last!
- LoadScreen::update( percent );
- }
- void MapTransferLoadScreen::processProgress(Int playerId, Int percentage, AsciiString stateStr)
- {
-
- if( percentage < 0 || percentage > 100 || playerId >= MAX_SLOTS || playerId < 0 || m_playerLookup[playerId] == -1)
- {
- DEBUG_ASSERTCRASH(FALSE, ("Percentage %d was passed in for Player %d\n", percentage, playerId));
- }
- if (m_oldProgress[playerId] == percentage)
- return;
- m_oldProgress[playerId] = percentage;
- Int translatedSlot = m_playerLookup[playerId];
- if(m_progressBars[translatedSlot])
- GadgetProgressBarSetProgress(m_progressBars[translatedSlot], percentage );
- if (m_progressText[translatedSlot])
- GadgetStaticTextSetText(m_progressText[translatedSlot], TheGameText->fetch(stateStr));
- }
- void MapTransferLoadScreen::processTimeout(Int secondsLeft)
- {
- if (m_oldTimeout == secondsLeft)
- return;
- m_oldTimeout = secondsLeft;
- if (m_timeoutText)
- {
- UnicodeString txt;
- txt.format(TheGameText->fetch("MapTransfer:Timeout"), (secondsLeft/60), (secondsLeft%60));
- GadgetStaticTextSetText(m_timeoutText, txt);
- }
- }
- void MapTransferLoadScreen::setCurrentFilename(AsciiString filename)
- {
- if (m_fileNameText)
- {
- UnicodeString txt;
- txt.translate(TheGameState->getMapLeafName(filename));
- txt.format(TheGameText->fetch("MapTransfer:CurrentFile"), txt.str());
- GadgetStaticTextSetText(m_fileNameText, txt);
- }
- }
|