Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameclient): player cards, map and tips on the match load screen
Olcay Seygan862fc1d488ae
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4a240cdea..a7a9624d0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,14 @@ found and fixed — EA's own, not port damage.**---+## A new loading screen++- Skirmish, LAN, online and replay loads show every player on a card: the general's portrait, or the side's crest for a plain side, the name in the player's colour, the army, and for a computer seat its difficulty and personality. Teams face each other in two columns with the map and its start spots between them. Three teams or more share the columns, and a game where everyone plays alone says Free for all.+- In a LAN or online game each player's card carries his own load bar, so you see who the match is waiting for.+- The map's name, the kind of game, the team sizes and the starting cash head the screen. Along the bottom a tip changes every eight seconds over the load's bar and percentage.+- Enemies who picked a random side, colour or start stay hidden as they were in the lobby. Observers and replays see every side as it is.+- A campaign mission keeps its own picture and briefing movie. Once the movie ends, the mission number, campaign and difficulty sit above it and the same tip and bar sit below it. Generals' Challenge is unchanged.+## A summary and graphs on the score screen- The old score table with its rows of icons and the Tactical Analysis box is gone. Every score screen, skirmish, LAN, online, replay and campaign mission alike, opens on its Summary page: a large row per player with its side, units built, lost and destroyed, buildings built, lost and destroyed, and money earned. The winners carry a gold Winner tag, and the best number in each column is gold too, the fewest where fewer is better. In a campaign mission your enemies share one row per side, as they did in the old table. Generals' Challenge keeps the general's portrait and verdict it always had.diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 70821bac9..42b7892ea 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -1668,6 +1668,91 @@ GUI:HotkeysCommandBEGIN_PREFER_SELECTION"Add to selection (hold)"END+// The match load screen (LoadScreenBoard in LoadScreen.cpp)+GUI:LoadModeSkirmish+"Skirmish"+END++GUI:LoadModeLAN+"LAN game"+END++GUI:LoadModeOnline+"Online game"+END++GUI:LoadModeReplay+"Replay"+END++GUI:LoadMission+"Mission %d"+END++GUI:LoadBriefing+"BRIEFING"+END++GUI:LoadFreeForAll+"Free for all"+END++GUI:LoadObservers+"Observers:"+END++GUI:LoadTeam+"Team %d"+END++GUI:LoadWaiting+"Waiting for the other players"+END++GUI:LoadTip+"TIP"+END++GUI:LoadTip1+"Hold Shift while you give orders and the group works down the list by itself: move, attack, capture, guard."+END++GUI:LoadTip2+"Shift and a number adds your selection to that control group and keeps everyone already in it."+END++GUI:LoadTip3+"Ctrl+D selects every unit of the kinds you have selected on the screen. Press it twice for the whole map."+END++GUI:LoadTip4+"Hold Shift and drag to draw a line. The selection spreads along it as a firing line."+END++GUI:LoadTip5+"On a build button, Shift queues five and Ctrl twenty."+END++GUI:LoadTip6+"Hold Ctrl and Alt on a unit's button and the factory builds it on repeat."+END++GUI:LoadTip7+"A beacon you place asks your computer allies to attack there."+END++GUI:LoadTip8+"Type help, attack or money in chat and your computer allies come to help, attack there or send cash."+END++GUI:LoadTip9+"Hold Ctrl while placing a building to flip grid placement for as long as the key is down."+END++GUI:LoadTip10+"Double-click a building to select every building of its kind on the screen."+END+// Computer player personalities, picked per seat in the lobby (AIPersonality)GUI:AIPersonaNormal"Normal"diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex be467004c..8de26c014 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -16065,6 +16065,91 @@ GUI:HotkeysCommandBEGIN_PREFER_SELECTION"Seçime ekle (basılı tut)"END+// Maç yükleme ekranı (LoadScreen.cpp içindeki LoadScreenBoard)+GUI:LoadModeSkirmish+"Çatışma"+END++GUI:LoadModeLAN+"LAN oyunu"+END++GUI:LoadModeOnline+"Çevrimiçi oyun"+END++GUI:LoadModeReplay+"Tekrar"+END++GUI:LoadMission+"Görev %d"+END++GUI:LoadBriefing+"BRİFİNG"+END++GUI:LoadFreeForAll+"Herkes herkese karşı"+END++GUI:LoadObservers+"Gözlemciler:"+END++GUI:LoadTeam+"Takım %d"+END++GUI:LoadWaiting+"Diğer oyuncular bekleniyor"+END++GUI:LoadTip+"İPUCU"+END++GUI:LoadTip1+"Emir verirken Shift'i basılı tutun, grup listeyi kendi başına sırayla yapar: yürü, saldır, ele geçir, koru."+END++GUI:LoadTip2+"Shift ve bir rakam seçtiklerinizi o kontrol grubuna ekler, gruptakiler de yerinde kalır."+END++GUI:LoadTip3+"Ctrl+D seçtiğiniz türlerden ekrandaki bütün birlikleri seçer. İki kez basarsanız bütün haritadakileri alır."+END++GUI:LoadTip4+"Shift'i basılı tutup sürükleyerek bir çizgi çizin. Seçtikleriniz onun boyunca ateş hattı olarak dizilir."+END++GUI:LoadTip5+"Bir üretim düğmesinde Shift beş, Ctrl yirmi birliği sıraya koyar."+END++GUI:LoadTip6+"Bir birliğin düğmesine Ctrl ve Alt ile basın, fabrika onu durmadan üretir."+END++GUI:LoadTip7+"Koyduğunuz bir işaret, bilgisayar müttefiklerinizden oraya saldırmalarını ister."+END++GUI:LoadTip8+"Sohbete yardim, saldir ya da para yazın: bilgisayar müttefikleriniz yardıma gelir, oraya saldırır ya da para gönderir."+END++GUI:LoadTip9+"Bina yerleştirirken Ctrl'yi basılı tutun, tuş basılı kaldıkça ızgaraya oturtma tersine döner."+END++GUI:LoadTip10+"Bir binaya çift tıklayın, ekrandaki aynı türden bütün binalar seçilir."+END+// Bilgisayar oyuncusu kişilikleri, lobide koltuk başına seçilir (AIPersonality)GUI:AIPersonaNormal"Normal"diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/LoadScreen.h b/GeneralsMD/Code/GameEngine/Include/GameClient/LoadScreen.hindex 4b0bbe457..059f06412 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/LoadScreen.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/LoadScreen.h@@ -48,6 +48,7 @@class VideoBuffer;class VideoStreamInterface;class WindowVideoManager;+class LoadScreenBoard;@@ -115,6 +116,7 @@ private:VideoBuffer *m_videoBuffer;VideoStreamInterface *m_videoStream;+ LoadScreenBoard *m_board; ///< the mission's name, briefing and tip, over the picture once the movie is donevoid moveWindows( Int frame );@@ -220,6 +222,7 @@ public:private:GameWindow *m_progressBar ; ///< Pointer to the Progress Bar on the window+ LoadScreenBoard *m_board; ///< a replay's players, map and tip; NULL for a boot or a saved game};@@ -243,15 +246,7 @@ public:void processProgress(Int playerId, Int percentage);virtual void setProgressRange( Int min, Int max ) { }private:- GameWindow *m_progressBars[MAX_SLOTS]; ///< pointer array to all the progress bars on the window- GameWindow *m_playerNames[MAX_SLOTS]; ///< pointer array to all the static text player names on the window- GameWindow *m_playerSide[MAX_SLOTS]; ///< pointer array to all the static text player sides- Int m_playerLookup[MAX_SLOTS]; ///< lookup table to translate network slot info screen slot (to account for holes in the slot list)- GameWindow *m_mapPreview;- GameWindow *m_buttonMapStartPosition[MAX_SLOTS];- GameWindow *m_portraitLocalGeneral;- GameWindow *m_featuresLocalGeneral;- GameWindow *m_nameLocalGeneral;+ LoadScreenBoard *m_board;};@@ -274,23 +269,7 @@ public:void processProgress(Int playerId, Int percentage);virtual void setProgressRange( Int min, Int max ) { }private:- GameWindow *m_progressBars[MAX_SLOTS]; ///< pointer array to all the progress bars on the window- GameWindow *m_playerNames[MAX_SLOTS]; ///< pointer array to all the static text player names on the window- GameWindow *m_playerSide[MAX_SLOTS]; ///< pointer array to all the static text player sides- GameWindow *m_playerFavoriteFactions[MAX_SLOTS]; ///< pointer array to all the static text player sides- GameWindow *m_playerTotalDisconnects[MAX_SLOTS]; ///< pointer array to all the static text player sides- GameWindow *m_playerWin[MAX_SLOTS]; ///< pointer array to all the static text player sides- GameWindow *m_playerWinLosses[MAX_SLOTS]; ///< pointer array to all the static text player sides- GameWindow *m_playerRank[MAX_SLOTS]; ///< pointer array to all the static text player sides- GameWindow *m_playerOfficerMedal[MAX_SLOTS]; ///< pointer array to all the static text player munkees- GameWindow *m_mapPreview;- GameWindow *m_buttonMapStartPosition[MAX_SLOTS];-- Int m_playerLookup[MAX_SLOTS]; ///< lookup table to translate network slot info screen slot (to account for holes in the slot list)-- GameWindow *m_portraitLocalGeneral;- GameWindow *m_featuresLocalGeneral;- GameWindow *m_nameLocalGeneral;+ LoadScreenBoard *m_board;};///////////////////////////////////////////////////////////////////////////////////////////////////diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cppindex 4943dbbb6..785202b39 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp@@ -72,10 +72,13 @@#include "Common/PlayerTemplate.h"#include "GameClient/CampaignManager.h"#include "GameClient/Display.h"+#include "GameClient/DisplayStringManager.h"#include "GameClient/GadgetProgressBar.h"#include "GameClient/GadgetStaticText.h"+#include "GameClient/GameFont.h"#include "GameClient/GameText.h"#include "GameClient/GameWindowManager.h"+#include "GameClient/Image.h"#include "GameClient/GameWindowTransitions.h"#include "GameClient/LoadScreen.h"#include "GameClient/MapUtil.h"@@ -85,8 +88,10 @@#include "GameClient/WindowLayout.h"#include "GameClient/WindowVideoManager.h"#include "GameClient/ChallengeGenerals.h"+#include "GameLogic/AI.h" // aiPersonalityName, for a computer seat's card#include "GameLogic/FPUControl.h"#include "GameLogic/GameLogic.h"+#include "GameNetwork/GUIUtil.h"#include "GameNetwork/GameSpy/PeerDefs.h"#include "GameNetwork/GameSpy/PersistentStorageThread.h"#include "GameNetwork/NetworkInterface.h"@@ -125,10 +130,6 @@//-----------------------------------------------------------------------------// 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_TITLES_START = 20,FRAME_TELETYPE_START = 24,@@ -181,6 +182,838 @@ void LoadScreen::update( Int percent )setFPMode();}+// LoadScreenBoard ////////////////////////////////////////////////////////////+//-----------------------------------------------------------------------------+/* A match's load, skirmish, LAN, online or replay, as one board drawn in code: a card per player with+ the general's portrait or the side's crest, the name in the player's colour, the army and, for a+ computer seat, its level and personality; the teams in two columns facing each other across the+ map, or the players shared between the columns in a free-for-all; the map's name, its preview+ with the start spots, a tip and the load's progress along the bottom. In a network game every+ human's card carries his own bar.++ Everything is laid out once, when the board is made, against a 1920x1080 picture scaled to the+ screen; a pass draws flat fills, the images the lobby and the challenge menu already load (the+ portraits share one 512 page, the crests another) and display strings made up front. The+ colours are zerohour.gg's, as the -directorrecord broadcast's are, and so are its fonts' Windows+ stand-ins. */++static const Color BOARD_GROUND = GameMakeColor( 0x0c, 0x12, 0x20, 255 );+static const Color BOARD_PANEL = GameMakeColor( 0x12, 0x1a, 0x2b, 255 );+static const Color BOARD_LINE = GameMakeColor( 0x1f, 0x29, 0x40, 255 );+static const Color BOARD_EDGE = GameMakeColor( 0x2f, 0x3b, 0x57, 255 );+static const Color BOARD_INK = GameMakeColor( 0xe8, 0xea, 0xf0, 255 );+static const Color BOARD_MUTED = GameMakeColor( 0x8e, 0x97, 0xad, 255 );+static const Color BOARD_BLUE = GameMakeColor( 0x80, 0x95, 0xea, 255 );+static const Color BOARD_SHADOW = GameMakeColor( 0, 0, 0, 255 );+static const char *const BOARD_WORDS = "Segoe UI";+static const char *const BOARD_NUMBERS = "Consolas";+/// the picture the sizes below are given for; a smaller screen scales them down, 12 pixels the floor+static const Real BOARD_WIDTH = 1920.0f;+static const Real BOARD_HEIGHT = 1080.0f;+static const Int BOARD_SMALLEST_TEXT = 12;+static const Int BOARD_TIP_COUNT = 10;+static const UnsignedInt BOARD_TIP_MILLISECONDS = 8000;+static const Int BOARD_WASH_STRIPS = 48;+/// a middle dot between spaces, spelled out: the source is read in the machine's code page+static const WideChar BOARD_SEPARATOR[] = { ' ', ' ', ' ', 0x00B7, ' ', ' ', ' ', 0 };++/// one player's card+struct BoardCard+{+ Int slot;+ Color color;+ Color nameColor; ///< the colour, lifted toward white where it is too dark to read on the panel+ Int team;+ Int startSpot; ///< the start position the others may see, -1 when hidden+ Int percent; ///< this player's own load, -1 on a card without a bar+ Bool mirrored; ///< the right column's cards face left+ const Image *emblem; ///< the general's portrait or the side's crest, NULL for a hidden or random side+ const Image *watermark; ///< the side's flag, faint behind the words+ const Image *badge; ///< an online player's rank+ DisplayString *name;+ DisplayString *army;+ DisplayString *detail; ///< a computer seat's level and personality+ DisplayString *teamText; ///< the team on a card in a free-for-all layout+ DisplayString *percentText;+ IRegion2D box;+};++struct BoardSpot+{+ ICoord2D pos;+ Color color;+};++class LoadScreenBoard+{+public:+ LoadScreenBoard( void );+ ~LoadScreenBoard( void );++ /// lays the board out for this game and makes the window that draws it+ GameWindow *create( GameInfo *game, const char *modeLabel, Bool cardBars );+ /// a campaign mission's: the header, the briefing and the foot over the mission's own picture+ GameWindow *createMission( GameWindow *parent, const UnicodeString &title, const UnicodeString &subtitle,+ const UnicodeString *briefing, Int briefingLines );+ void setBadge( Int slot, const Image *badge );+ void setProgress( Int slot, Int percent );+ void setLocalProgress( Int percent );++private:+ static void drawWindow( GameWindow *window, WinInstanceData *instData );+ void prepare( const UnicodeString &title, const UnicodeString &subtitle );+ GameWindow *makeWindow( GameWindow *parent );+ void draw( void );+ void drawMatch( void );+ void drawBriefing( void );+ void drawCard( const BoardCard &card );+ Int scaled( Real pixels ) const { return REAL_TO_INT( pixels * m_scale + 0.5f ); }+ GameFont *font( const char *name, Real pixels, Bool bold ) const;+ DisplayString *text( const UnicodeString &words, GameFont *font );+ BoardCard *cardFor( Int slot );+ void layoutColumn( std::vector< Int > &column, Int left, Int top, Int bottom, Bool mirrored );++ Real m_scale;+ Int m_left; ///< the 16:9 picture's corner, inset on a squarer screen+ Int m_top;+ Int m_width; ///< the screen+ Int m_height;+ std::vector< BoardCard > m_cards;+ std::vector< BoardSpot > m_spots;+ std::vector< DisplayString * > m_strings;+ Bool m_mission;+ DisplayString *m_briefingHead;+ std::vector< DisplayString * > m_briefing;+ IRegion2D m_briefingBox;+ DisplayString *m_title;+ DisplayString *m_subtitle;+ DisplayString *m_wordmark[ 2 ];+ DisplayString *m_columnHead[ 2 ];+ const Image *m_backdrop[ 2 ];+ IRegion2D m_backdropBox[ 2 ];+ Color m_columnTeam[ 2 ];+ ICoord2D m_columnHeadPos[ 2 ];+ DisplayString *m_centerLabel;+ ICoord2D m_centerLabelPos;+ DisplayString *m_observers;+ ICoord2D m_observersPos;+ DisplayString *m_unknown;+ const Image *m_mapImage;+ IRegion2D m_mapBox;+ IRegion2D m_mapDrawn;+ DisplayString *m_tipLabel;+ DisplayString *m_tip;+ Int m_tipIndex;+ UnsignedInt m_tipSince;+ DisplayString *m_percent;+ DisplayString *m_waiting;+ Int m_localPercent;+ Bool m_network;+};++LoadScreenBoard::LoadScreenBoard( void )+{+ m_width = TheDisplay->getWidth();+ m_height = TheDisplay->getHeight();+ m_scale = min( m_width / BOARD_WIDTH, m_height / BOARD_HEIGHT );+ m_left = ( m_width - scaled( BOARD_WIDTH ) ) / 2;+ m_top = ( m_height - scaled( BOARD_HEIGHT ) ) / 2;+ m_mission = FALSE;+ m_briefingHead = NULL;+ m_title = m_subtitle = m_centerLabel = m_observers = m_unknown = NULL;+ m_wordmark[ 0 ] = m_wordmark[ 1 ] = NULL;+ m_columnHead[ 0 ] = m_columnHead[ 1 ] = NULL;+ m_backdrop[ 0 ] = m_backdrop[ 1 ] = NULL;+ m_mapImage = NULL;+ m_tipLabel = m_tip = m_percent = m_waiting = NULL;+ m_tipIndex = 0;+ m_tipSince = 0;+ m_localPercent = 0;+ m_network = FALSE;+}++LoadScreenBoard::~LoadScreenBoard( void )+{+ for( size_t each = 0; each < m_strings.size(); each++ )+ TheDisplayStringManager->freeDisplayString( m_strings[ each ] );+}++GameFont *LoadScreenBoard::font( const char *name, Real pixels, Bool bold ) const+{+ // a point is 4/3 of a pixel at the 96 dots an inch the glyphs are drawn at+ const Int height = max( BOARD_SMALLEST_TEXT, scaled( pixels ) );+ return TheFontLibrary->getFont( AsciiString( name ), max( 1, height * 3 / 4 ), bold );+}++DisplayString *LoadScreenBoard::text( const UnicodeString &words, GameFont *font )+{+ DisplayString *string = TheDisplayStringManager->newDisplayString();+ string->setFont( font );+ string->setText( words );+ m_strings.push_back( string );+ return string;+}++BoardCard *LoadScreenBoard::cardFor( Int slot )+{+ for( size_t each = 0; each < m_cards.size(); each++ )+ {+ if( m_cards[ each ].slot == slot )+ return &m_cards[ each ];+ }+ return NULL;+}++static Int stringWidth( DisplayString *string )+{+ Int width, height;+ string->getSize( &width, &height );+ return width;+}++static Int stringHeight( DisplayString *string )+{+ Int width, height;+ string->getSize( &width, &height );+ return height;+}++static Color withAlpha( Color color, Int alpha )+{+ UnsignedByte r, g, b, a;+ GameGetColorComponents( color, &r, &g, &b, &a );+ return GameMakeColor( r, g, b, alpha );+}++/** Blue and purple house colours are too dark for words on the panel; they are lifted part of the+ * way to white, the bar and the map spot keep the colour itself. */+static Color readableColor( Color color )+{+ UnsignedByte r, g, b, a;+ GameGetColorComponents( color, &r, &g, &b, &a );+ const Int luma = ( 54 * r + 183 * g + 19 * b ) / 256;+ if( luma >= 120 )+ return color;+ const Int lift = 110; // of 256+ return GameMakeColor( r + ( 255 - r ) * lift / 256, g + ( 255 - g ) * lift / 256, b + ( 255 - b ) * lift / 256, 255 );+}++/** The side's crest from the lobby: the three 144 pixel logos on one page. A mod's side brings its+ * own lobby glyph or nothing. */+static const Image *sideCrest( const PlayerTemplate *side )+{+ const AsciiString base = side->getBaseSide();+ if( base.compareNoCase( "USA" ) == 0 )+ return TheMappedImageCollection->findImageByName( "SAFactionLogo144_US" );+ if( base.compareNoCase( "China" ) == 0 )+ return TheMappedImageCollection->findImageByName( "SNFactionLogo144_China" );+ if( base.compareNoCase( "GLA" ) == 0 )+ return TheMappedImageCollection->findImageByName( "SUFactionLogo144_GLA" );+ return side->getGeneralImage();+}++/** A general's face from the challenge menu, all ten on one page; a plain side shows its crest. */+static const Image *sideEmblem( const PlayerTemplate *side )+{+ const GeneralPersona *general = TheChallengeGenerals->getGeneralByTemplateName( side->getName() );+ if( general && general->getBioPortraitSmall() )+ return general->getBioPortraitSmall();+ return sideCrest( side );+}++/** One tip at random to start, the next every eight seconds; the clock is the wall's, never the+ * logic's dice. */+static UnicodeString tipText( Int index )+{+ AsciiString label;+ label.format( "GUI:LoadTip%d", index + 1 );+ return TheGameText->fetch( label );+}++GameWindow *LoadScreenBoard::create( GameInfo *game, const char *modeLabel, Bool cardBars )+{+ m_network = cardBars;+ GameFont *labelFont = font( BOARD_NUMBERS, 16, TRUE );+ GameFont *centerFont = font( BOARD_WORDS, 64, TRUE );+ GameFont *centerSmallFont = font( BOARD_WORDS, 24, TRUE );+ GameFont *observerFont = font( BOARD_WORDS, 16, FALSE );+ GameFont *nameFont = font( BOARD_WORDS, 26, TRUE );+ GameFont *armyFont = font( BOARD_WORDS, 18, FALSE );+ GameFont *detailFont = font( BOARD_WORDS, 16, FALSE );++ // a watcher, a replay's viewer among them, sees every side as it is; a player sees what the+ // lobby let him see of his enemies+ // (a director's recording has no local seat at all)+ const Bool seeAll = TheGameLogic->isInReplayGame() || game->getLocalSlotNum() < 0+ || game->getConstSlot( game->getLocalSlotNum() )->getOriginalPlayerTemplate() == PLAYERTEMPLATE_OBSERVER;++ // the cards, with each team's players together in the order the lobby lists them+ UnicodeString observerNames;+ std::vector< Int > teamOf; // a team number, or -100 - slot for a player alone+ std::vector< std::vector< Int > > groups;+ for( Int i = 0; i < MAX_SLOTS; ++i )+ {+ const GameSlot *slot = game->getConstSlot( i );+ if( slot == NULL || !slot->isOccupied() )+ continue;+ if( slot->getOriginalPlayerTemplate() == PLAYERTEMPLATE_OBSERVER )+ {+ if( !observerNames.isEmpty() )+ observerNames.concat( u", " );+ observerNames.concat( slot->getName() );+ continue;+ }++ BoardCard card;+ card.slot = i;+ const Int colorIndex = seeAll ? slot->getColor() : slot->getApparentColor();+ card.color = TheMultiplayerSettings->getColor( colorIndex )->getColor();+ card.nameColor = readableColor( card.color );+ card.team = slot->getTeamNumber();+ card.startSpot = seeAll ? slot->getStartPos() : slot->getApparentStartPos();+ card.percent = cardBars && slot->isHuman() ? 0 : -1;+ card.mirrored = FALSE;+ card.badge = NULL;+ card.emblem = NULL;+ card.watermark = NULL;+ const Int sideIndex = seeAll ? slot->getPlayerTemplate() : slot->getApparentPlayerTemplate();+ UnicodeString army = TheGameText->fetch( "GUI:Random" );+ if( sideIndex >= 0 )+ {+ const PlayerTemplate *side = ThePlayerTemplateStore->getNthPlayerTemplate( sideIndex );+ card.emblem = sideEmblem( side );+ // a plain side's emblem is its crest already+ card.watermark = card.emblem == sideCrest( side ) ? NULL : sideCrest( side );+ army = side->getDisplayName();+ }+ card.name = text( slot->getName(), nameFont );+ card.army = text( army, armyFont );++ UnicodeString detail;+ if( slot->isAI() )+ {+ const UnicodeString level = SlotStateName( slot->getState() );+ if( slot->getName().compare( level ) != 0 )+ detail = level;+ if( slot->getAIPersonality() != AIPERSONA_NORMAL )+ {+ AsciiString label;+ label.format( "GUI:AIPersona%s", aiPersonalityName( (AIPersonality)slot->getAIPersonality() ) );+ if( !detail.isEmpty() )+ detail.concat( BOARD_SEPARATOR );+ detail.concat( TheGameText->fetch( label ) );+ }+ }+ card.detail = text( detail, detailFont );+ UnicodeString teamWords;+ if( card.team >= 0 )+ teamWords.format( TheGameText->fetch( "GUI:LoadTeam" ), card.team + 1 );+ card.teamText = text( teamWords, labelFont );+ card.percentText = text( UnicodeString( u"0%" ), labelFont );+ m_cards.push_back( card );++ const Int key = card.team >= 0 ? card.team : -100 - i;+ size_t group = 0;+ while( group < teamOf.size() && teamOf[ group ] != key )+ group++;+ if( group == teamOf.size() )+ {+ teamOf.push_back( key );+ groups.push_back( std::vector< Int >() );+ }+ groups[ group ].push_back( (Int)m_cards.size() - 1 );+ }++ // two sides face each other across the map; more share the two columns, a whole team to a side+ const Bool versus = groups.size() == 2;+ Bool everyoneAlone = TRUE;+ std::vector< Int > columns[ 2 ];+ UnicodeString makeup;+ for( size_t group = 0; group < groups.size(); group++ )+ {+ if( groups[ group ].size() > 1 )+ everyoneAlone = FALSE;+ const Int side = versus ? (Int)group : ( columns[ 1 ].size() < columns[ 0 ].size() ? 1 : 0 );+ for( size_t each = 0; each < groups[ group ].size(); each++ )+ columns[ side ].push_back( groups[ group ][ each ] );+ UnicodeString count;+ count.format( u"%d", (Int)groups[ group ].size() );+ if( !makeup.isEmpty() )+ makeup.concat( u" vs " );+ makeup.concat( count );+ }+ const Bool freeForAll = everyoneAlone && groups.size() > 2;+ if( freeForAll )+ makeup = TheGameText->fetch( "GUI:LoadFreeForAll" );++ // the header: the map, then what kind of game, how many a side and the starting cash+ const MapMetaData *map = TheMapCache->findMap( game->getMap() );+ UnicodeString mapName;+ if( map )+ mapName = map->m_displayName;+ else+ mapName.translate( TheGameState->getMapLeafName( game->getMap() ) );+ const Int margin = scaled( 64 );+ UnicodeString subtitle = TheGameText->fetch( modeLabel );+ if( !makeup.isEmpty() )+ {+ subtitle.concat( BOARD_SEPARATOR );+ subtitle.concat( makeup );+ }+ UnicodeString cash;+ cash.format( u"$%u", game->getStartingCash().countMoney() );+ subtitle.concat( BOARD_SEPARATOR );+ subtitle.concat( cash );+ prepare( mapName, subtitle );++ // the cards: two columns with the map between, as tall as four cards a side allow+ m_unknown = text( UnicodeString( u"?" ), centerFont );++ const Int columnWidth = scaled( 640 );+ const Int bandTop = m_top + scaled( 200 );+ const Int bandBottom = m_top + scaled( 920 );+ Int cardsTop = bandTop;+ for( Int side = 0; side < 2; side++ )+ {+ m_columnHead[ side ] = NULL;+ if( !versus || teamOf[ side ] < 0 )+ continue;+ UnicodeString label;+ label.format( TheGameText->fetch( "GUI:LoadTeam" ), teamOf[ side ] + 1 );+ m_columnHead[ side ] = text( label, labelFont );+ m_columnTeam[ side ] = LobbyTeamColor( teamOf[ side ] );+ cardsTop = bandTop + stringHeight( m_columnHead[ side ] ) + scaled( 12 );+ }+ const Int leftX = m_left + margin;+ const Int rightX = m_left + scaled( BOARD_WIDTH ) - margin - columnWidth;+ layoutColumn( columns[ 0 ], leftX, cardsTop, bandBottom, FALSE );+ layoutColumn( columns[ 1 ], rightX, cardsTop, bandBottom, TRUE );+ // behind each column, large and faint, the crest of the side its first card plays+ for( Int side = 0; side < 2; side++ )+ {+ m_backdrop[ side ] = NULL;+ if( columns[ side ].empty() )+ continue;+ const BoardCard &first = m_cards[ columns[ side ][ 0 ] ];+ m_backdrop[ side ] = first.watermark ? first.watermark : first.emblem;+ const Int size = scaled( 760 );+ const Int centerX = ( side == 0 ? leftX : rightX ) + columnWidth / 2;+ m_backdropBox[ side ].lo.x = centerX - size / 2;+ m_backdropBox[ side ].lo.y = ( bandTop + bandBottom - size ) / 2;+ m_backdropBox[ side ].hi.x = centerX + size / 2;+ m_backdropBox[ side ].hi.y = m_backdropBox[ side ].lo.y + size;+ }+ // a team's name sits over its first card, the swatch on the outer edge+ for( Int side = 0; side < 2; side++ )+ {+ if( m_columnHead[ side ] == NULL )+ continue;+ const Int swatch = stringHeight( m_columnHead[ side ] ) - scaled( 4 );+ m_columnHeadPos[ side ].y = m_cards[ columns[ side ][ 0 ] ].box.lo.y - stringHeight( m_columnHead[ side ] ) - scaled( 12 );+ m_columnHeadPos[ side ].x = side == 0 ? leftX + swatch + scaled( 10 ) : rightX + columnWidth - stringWidth( m_columnHead[ side ] ) - swatch - scaled( 10 );+ }++ // the middle: VS or free for all over the map, the watchers under it+ m_centerLabel = NULL;+ if( versus )+ m_centerLabel = text( UnicodeString( u"VS" ), centerFont );+ else if( freeForAll )+ m_centerLabel = text( TheGameText->fetch( "GUI:LoadFreeForAll" ), centerSmallFont );+ m_observers = NULL;+ const Int mapSize = min( scaled( 384 ), rightX - leftX - columnWidth - 2 * scaled( 48 ) );+ if( !observerNames.isEmpty() )+ {+ UnicodeString line = TheGameText->fetch( "GUI:LoadObservers" );+ line.concat( u" " );+ line.concat( observerNames );+ m_observers = text( line, observerFont );+ m_observers->setWordWrap( mapSize );+ m_observers->setWordWrapCentered( TRUE );+ }+ const Int gap = scaled( 28 );+ Int stack = mapSize;+ if( m_centerLabel )+ stack += stringHeight( m_centerLabel ) + gap;+ if( m_observers )+ stack += gap + stringHeight( m_observers );+ const Int middle = m_left + scaled( BOARD_WIDTH ) / 2;+ Int y = ( bandTop + bandBottom - stack ) / 2;+ if( m_centerLabel )+ {+ m_centerLabelPos.x = middle - stringWidth( m_centerLabel ) / 2;+ m_centerLabelPos.y = y;+ y += stringHeight( m_centerLabel ) + gap;+ }+ m_mapBox.lo.x = middle - mapSize / 2;+ m_mapBox.lo.y = y;+ m_mapBox.hi.x = m_mapBox.lo.x + mapSize;+ m_mapBox.hi.y = y + mapSize;+ m_mapDrawn = m_mapBox;+ y += mapSize + gap;+ if( m_observers )+ {+ m_observersPos.x = middle - mapSize / 2;+ m_observersPos.y = y;+ }++ // the preview the lobby showed, at the map's own shape, and every start spot that is not hidden+ m_mapImage = getMapPreviewImage( game->getMap() );+ if( map )+ {+ findDrawPositions( m_mapBox.lo.x, m_mapBox.lo.y, mapSize, mapSize, map->m_extent, &m_mapDrawn.lo, &m_mapDrawn.hi );+ for( size_t each = 0; each < m_cards.size(); each++ )+ {+ AsciiString waypoint;+ waypoint.format( "Player_%d_Start", m_cards[ each ].startSpot + 1 );+ WaypointMap::const_iterator it = map->m_waypoints.find( waypoint );+ if( m_cards[ each ].startSpot < 0 || it == map->m_waypoints.end() )+ continue;+ const Real across = ( it->second.x - map->m_extent.lo.x ) / map->m_extent.width();+ const Real down = 1.0f - ( it->second.y - map->m_extent.lo.y ) / map->m_extent.height();+ BoardSpot spot;+ spot.pos.x = m_mapDrawn.lo.x + REAL_TO_INT( across * ( m_mapDrawn.hi.x - m_mapDrawn.lo.x ) );+ spot.pos.y = m_mapDrawn.lo.y + REAL_TO_INT( down * ( m_mapDrawn.hi.y - m_mapDrawn.lo.y ) );+ spot.color = m_cards[ each ].color;+ m_spots.push_back( spot );+ }+ }++ return makeWindow( NULL );+}++/** The header's and the foot's words, the same on every board. */+void LoadScreenBoard::prepare( const UnicodeString &title, const UnicodeString &subtitle )+{+ GameFont *wordmarkFont = font( BOARD_WORDS, 24, TRUE );+ GameFont *tipFont = font( BOARD_WORDS, 18, FALSE );+ m_title = text( title, font( BOARD_WORDS, 40, TRUE ) );+ m_subtitle = text( subtitle, font( BOARD_WORDS, 18, FALSE ) );+ m_wordmark[ 0 ] = text( UnicodeString( u"Zero Hour" ), wordmarkFont );+ m_wordmark[ 1 ] = text( UnicodeString( u" Reforged" ), wordmarkFont );++ // the foot: a tip, the load's percentage and its bar+ m_tipLabel = text( TheGameText->fetch( "GUI:LoadTip" ), font( BOARD_NUMBERS, 16, TRUE ) );+ m_tipIndex = (Int)( Clock_Milliseconds() % BOARD_TIP_COUNT );+ m_tipSince = Clock_Milliseconds();+ m_tip = text( tipText( m_tipIndex ), tipFont );+ m_percent = text( UnicodeString( u"0%" ), font( BOARD_NUMBERS, 20, TRUE ) );+ m_waiting = text( TheGameText->fetch( "GUI:LoadWaiting" ), tipFont );+ m_localPercent = 0;+}++GameWindow *LoadScreenBoard::makeWindow( GameWindow *parent )+{+ GameWindow *window = TheWindowManager->winCreate( parent, WIN_STATUS_ENABLED, 0, 0, m_width, m_height, GameWinDefaultSystem );+ window->winSetUserData( this );+ window->winSetDrawFunc( drawWindow );+ window->winBringToTop();+ return window;+}++/** A mission keeps its own picture behind; the header names it, a panel on the left carries the+ * briefing the mission's load always had and never showed, and the foot is a match's. */+GameWindow *LoadScreenBoard::createMission( GameWindow *parent, const UnicodeString &title, const UnicodeString &subtitle,+ const UnicodeString *briefing, Int briefingLines )+{+ m_mission = TRUE;+ prepare( title, subtitle );++ const Int pad = scaled( 28 );+ const Int width = scaled( 640 );+ m_briefingBox.lo.x = m_left + scaled( 64 );+ m_briefingBox.lo.y = m_top + scaled( 216 );+ m_briefingBox.hi.x = m_briefingBox.lo.x + width;+ m_briefingHead = text( TheGameText->fetch( "GUI:LoadBriefing" ), font( BOARD_NUMBERS, 16, TRUE ) );+ Int bottom = m_briefingBox.lo.y + pad + stringHeight( m_briefingHead ) + scaled( 8 );+ GameFont *lineFont = font( BOARD_WORDS, 22, FALSE );+ for( Int line = 0; line < briefingLines; line++ )+ {+ if( briefing[ line ].isEmpty() )+ continue;+ DisplayString *words = text( briefing[ line ], lineFont );+ words->setWordWrap( width - 2 * pad );+ m_briefing.push_back( words );+ bottom += scaled( 10 ) + stringHeight( words );+ }+ m_briefingBox.hi.y = bottom + pad;+ return makeWindow( parent );+}++/** One column's cards, as tall as the column allows up to a 1v1's, centred in it. */+void LoadScreenBoard::layoutColumn( std::vector< Int > &column, Int left, Int top, Int bottom, Bool mirrored )+{+ if( column.empty() )+ return;+ const Int count = (Int)column.size();+ const Int gap = scaled( 16 );+ const Int height = min( scaled( 220 ), ( bottom - top - gap * ( count - 1 ) ) / count );+ Int y = top + ( bottom - top - ( height * count + gap * ( count - 1 ) ) ) / 2;+ for( Int each = 0; each < count; each++ )+ {+ BoardCard &card = m_cards[ column[ each ] ];+ card.mirrored = mirrored;+ card.box.lo.x = left;+ card.box.lo.y = y;+ card.box.hi.x = left + scaled( 640 );+ card.box.hi.y = y + height;+ y += height + gap;+ }+}++void LoadScreenBoard::setBadge( Int slot, const Image *badge )+{+ cardFor( slot )->badge = badge;+}++void LoadScreenBoard::setProgress( Int slot, Int percent )+{+ BoardCard *card = cardFor( slot );+ if( card == NULL || card->percent < 0 || card->percent == percent )+ return;+ card->percent = percent;+ UnicodeString words;+ words.format( u"%d%%", percent );+ card->percentText->setText( words );+}++void LoadScreenBoard::setLocalProgress( Int percent )+{+ if( percent == m_localPercent )+ return;+ m_localPercent = percent;+ UnicodeString words;+ words.format( u"%d%%", min( percent, 100 ) );+ m_percent->setText( words );+}++void LoadScreenBoard::drawWindow( GameWindow *window, WinInstanceData *instData )+{+ ( (LoadScreenBoard *)window->winGetUserData() )->draw();+}++void LoadScreenBoard::drawCard( const BoardCard &card )+{+ const Int x0 = card.box.lo.x;+ const Int y0 = card.box.lo.y;+ const Int width = card.box.hi.x - x0;+ const Int height = card.box.hi.y - y0;+ TheDisplay->drawFillRect( x0, y0, width, height, BOARD_PANEL );++ // the player's colour washes in from the outer edge, under a solid stripe of it+ const Int stripe = max( 3, scaled( 6 ) );+ const Int wash = width * 9 / 20;+ for( Int strip = 0; strip < BOARD_WASH_STRIPS; strip++ )+ {+ const Int from = wash * strip / BOARD_WASH_STRIPS;+ const Int to = wash * ( strip + 1 ) / BOARD_WASH_STRIPS;+ const Int alpha = 64 * ( BOARD_WASH_STRIPS - strip ) / BOARD_WASH_STRIPS;+ const Int x = card.mirrored ? x0 + width - to : x0 + from;+ TheDisplay->drawFillRect( x, y0, to - from, height, withAlpha( card.color, alpha ) );+ }++ // the side's crest, faint, at the inner end+ if( card.watermark )+ {+ const Int size = height - scaled( 16 );+ const Int x = card.mirrored ? x0 + scaled( 24 ) : x0 + width - scaled( 24 ) - size;+ TheDisplay->drawImage( card.watermark, x, y0 + ( height - size ) / 2, x + size, y0 + ( height + size ) / 2, GameMakeColor( 255, 255, 255, 30 ) );+ }+ TheDisplay->drawFillRect( card.mirrored ? x0 + width - stripe : x0, y0, stripe, height, card.color );+ TheDisplay->drawOpenRect( x0, y0, width, height, 1.0f, BOARD_EDGE );++ // the portrait, in a frame of the player's colour+ const Int pad = scaled( 16 );+ const Int emblem = min( height - 2 * pad, scaled( 168 ) );+ const Int emblemX = card.mirrored ? x0 + width - stripe - pad - emblem : x0 + stripe + pad;+ const Int emblemY = y0 + ( height - emblem ) / 2;+ TheDisplay->drawFillRect( emblemX, emblemY, emblem, emblem, BOARD_GROUND );+ if( card.emblem )+ TheDisplay->drawImage( card.emblem, emblemX + 2, emblemY + 2, emblemX + emblem - 2, emblemY + emblem - 2 );+ else+ m_unknown->draw( emblemX + ( emblem - stringWidth( m_unknown ) ) / 2, emblemY + ( emblem - stringHeight( m_unknown ) ) / 2, BOARD_MUTED, BOARD_SHADOW );+ TheDisplay->drawOpenRect( emblemX, emblemY, emblem, emblem, 1.0f, withAlpha( card.color, 200 ) );++ // the words, on the portrait's far side, aligned away from it+ const Int textGap = scaled( 24 );+ const Int textLeft = card.mirrored ? x0 + pad : emblemX + emblem + textGap;+ const Int textRight = card.mirrored ? emblemX - textGap : x0 + width - pad;+ const Int lineGap = scaled( 4 );+ // seven cards to a column leave no room for the third line beside a bar+ Int block = stringHeight( card.name ) + lineGap + stringHeight( card.army );+ const Int barRoom = card.percent >= 0 ? scaled( 24 ) : 0;+ const Bool hasDetail = card.detail->getTextLength() > 0+ && block + lineGap + stringHeight( card.detail ) + barRoom <= height - 2 * scaled( 8 );+ if( hasDetail )+ block += lineGap + stringHeight( card.detail );+ Int y = y0 + ( height - block ) / 2;+ if( card.percent >= 0 )+ y -= scaled( 8 );+ DisplayString *lines[ 3 ] = { card.name, card.army, card.detail };+ const Color colors[ 3 ] = { card.nameColor, BOARD_INK, BOARD_MUTED };+ for( Int line = 0; line < ( hasDetail ? 3 : 2 ); line++ )+ {+ const Int w = stringWidth( lines[ line ] );+ lines[ line ]->draw( card.mirrored ? textRight - w : textLeft, y, colors[ line ], BOARD_SHADOW );+ if( line == 0 && card.badge )+ {+ const Int size = stringHeight( card.name ) * 3 / 4;+ const Int bx = card.mirrored ? textRight - w - scaled( 10 ) - size : textLeft + w + scaled( 10 );+ TheDisplay->drawImage( card.badge, bx, y + ( stringHeight( card.name ) - size ) / 2, bx + size, y + ( stringHeight( card.name ) + size ) / 2 );+ }+ y += stringHeight( lines[ line ] ) + lineGap;+ }++ // a team chip in the inner top corner where the columns are not the teams+ if( card.teamText->getTextLength() > 0 && m_columnHead[ 0 ] == NULL && m_columnHead[ 1 ] == NULL )+ {+ const Int swatch = stringHeight( card.teamText ) - scaled( 4 );+ const Int w = stringWidth( card.teamText );+ const Int ty = y0 + scaled( 10 );+ const Int tx = card.mirrored ? x0 + scaled( 14 ) : x0 + width - scaled( 14 ) - w;+ const Int sx = card.mirrored ? tx + w + scaled( 8 ) : tx - scaled( 8 ) - swatch;+ TheDisplay->drawFillRect( sx, ty + scaled( 2 ), swatch, swatch, LobbyTeamColor( card.team ) );+ TheDisplay->drawOpenRect( sx, ty + scaled( 2 ), swatch, swatch, 1.0f, BOARD_EDGE );+ card.teamText->draw( tx, ty, BOARD_MUTED, BOARD_SHADOW );+ }++ // a network player's own load+ if( card.percent >= 0 )+ {+ const Int barHeight = max( 3, scaled( 5 ) );+ const Int barY = y0 + height - pad - barHeight;+ const Int label = stringWidth( card.percentText ) + scaled( 12 );+ const Int barLeft = card.mirrored ? textLeft + label : textLeft;+ const Int barRight = card.mirrored ? textRight : textRight - label;+ TheDisplay->drawFillRect( barLeft, barY, barRight - barLeft, barHeight, BOARD_LINE );+ const Int filled = ( barRight - barLeft ) * card.percent / 100;+ TheDisplay->drawFillRect( card.mirrored ? barRight - filled : barLeft, barY, filled, barHeight, card.color );+ const Int labelY = barY + barHeight / 2 - stringHeight( card.percentText ) / 2;+ card.percentText->draw( card.mirrored ? textLeft : textRight - stringWidth( card.percentText ), labelY,+ card.percent >= 100 ? BOARD_INK : BOARD_MUTED, BOARD_SHADOW );+ }+}++void LoadScreenBoard::draw( void )+{+ if( Clock_Milliseconds() - m_tipSince > BOARD_TIP_MILLISECONDS )+ {+ m_tipIndex = ( m_tipIndex + 1 ) % BOARD_TIP_COUNT;+ m_tipSince = Clock_Milliseconds();+ m_tip->setText( tipText( m_tipIndex ) );+ }++ const Int margin = scaled( 64 );+ const Int left = m_left + margin;+ const Int right = m_left + scaled( BOARD_WIDTH ) - margin;+ const Int headerBottom = m_top + scaled( 168 );+ const Int footTop = m_top + scaled( 952 );+ if( m_mission )+ {+ const Color band = withAlpha( BOARD_GROUND, 224 );+ TheDisplay->drawFillRect( 0, 0, m_width, headerBottom, band );+ TheDisplay->drawFillRect( 0, footTop, m_width, m_height - footTop, band );+ drawBriefing();+ }+ else+ {+ TheDisplay->drawFillRect( 0, 0, m_width, m_height, BOARD_GROUND );+ drawMatch();+ }++ // the header+ const Int titleY = m_top + scaled( 52 );+ m_title->draw( left, titleY, BOARD_INK, BOARD_SHADOW );+ m_subtitle->draw( left, titleY + stringHeight( m_title ) + scaled( 4 ), BOARD_MUTED, BOARD_SHADOW );+ const Int markWidth = stringWidth( m_wordmark[ 0 ] ) + stringWidth( m_wordmark[ 1 ] );+ const Int markY = titleY + ( stringHeight( m_title ) - stringHeight( m_wordmark[ 0 ] ) ) / 2;+ m_wordmark[ 0 ]->draw( right - markWidth, markY, BOARD_INK, BOARD_SHADOW );+ m_wordmark[ 1 ]->draw( right - stringWidth( m_wordmark[ 1 ] ), markY, BOARD_BLUE, BOARD_SHADOW );+ TheDisplay->drawFillRect( left, headerBottom, right - left, 1, BOARD_LINE );++ // the foot+ const Int barHeight = max( 4, scaled( 8 ) );+ const Int barY = m_top + scaled( 1016 );+ const Int rowY = barY - scaled( 18 ) - stringHeight( m_tip );+ TheDisplay->drawFillRect( left, footTop, right - left, 1, BOARD_LINE );+ const Int chipPad = scaled( 8 );+ const Int chipHeight = stringHeight( m_tipLabel ) + scaled( 4 );+ const Int chipY = rowY + ( stringHeight( m_tip ) - chipHeight ) / 2;+ TheDisplay->drawOpenRect( left, chipY, stringWidth( m_tipLabel ) + 2 * chipPad, chipHeight, 1.0f, BOARD_BLUE );+ m_tipLabel->draw( left + chipPad, chipY + scaled( 2 ), BOARD_BLUE, BOARD_SHADOW );+ m_tip->draw( left + stringWidth( m_tipLabel ) + 2 * chipPad + scaled( 16 ), rowY, BOARD_INK, BOARD_SHADOW );+ if( m_network && m_localPercent > 100 )+ m_waiting->draw( right - stringWidth( m_waiting ), rowY, BOARD_MUTED, BOARD_SHADOW );+ else+ m_percent->draw( right - stringWidth( m_percent ), rowY + stringHeight( m_tip ) - stringHeight( m_percent ), BOARD_INK, BOARD_SHADOW );+ TheDisplay->drawFillRect( left, barY, right - left, barHeight, BOARD_LINE );+ TheDisplay->drawFillRect( left, barY, ( right - left ) * min( m_localPercent, 100 ) / 100, barHeight, BOARD_BLUE );+}++void LoadScreenBoard::drawBriefing( void )+{+ if( m_briefing.empty() )+ return;+ const IRegion2D &box = m_briefingBox;+ const Int width = box.hi.x - box.lo.x;+ const Int height = box.hi.y - box.lo.y;+ const Int pad = scaled( 28 );+ TheDisplay->drawFillRect( box.lo.x, box.lo.y, width, height, withAlpha( BOARD_GROUND, 216 ) );+ TheDisplay->drawFillRect( box.lo.x, box.lo.y, max( 3, scaled( 6 ) ), height, BOARD_BLUE );+ TheDisplay->drawOpenRect( box.lo.x, box.lo.y, width, height, 1.0f, BOARD_EDGE );+ Int y = box.lo.y + pad;+ m_briefingHead->draw( box.lo.x + pad, y, BOARD_BLUE, BOARD_SHADOW );+ y += stringHeight( m_briefingHead ) + scaled( 8 );+ for( size_t each = 0; each < m_briefing.size(); each++ )+ {+ y += scaled( 10 );+ m_briefing[ each ]->draw( box.lo.x + pad, y, BOARD_INK, BOARD_SHADOW );+ y += stringHeight( m_briefing[ each ] );+ }+}++void LoadScreenBoard::drawMatch( void )+{+ for( Int side = 0; side < 2; side++ )+ {+ const IRegion2D &box = m_backdropBox[ side ];+ if( m_backdrop[ side ] )+ TheDisplay->drawImage( m_backdrop[ side ], box.lo.x, box.lo.y, box.hi.x, box.hi.y, GameMakeColor( 255, 255, 255, 14 ) );+ }++ for( Int side = 0; side < 2; side++ )+ {+ if( m_columnHead[ side ] == NULL )+ continue;+ const Int swatch = stringHeight( m_columnHead[ side ] ) - scaled( 4 );+ const Int sx = side == 0 ? m_columnHeadPos[ side ].x - scaled( 10 ) - swatch : m_columnHeadPos[ side ].x + stringWidth( m_columnHead[ side ] ) + scaled( 10 );+ TheDisplay->drawFillRect( sx, m_columnHeadPos[ side ].y + scaled( 2 ), swatch, swatch, m_columnTeam[ side ] );+ TheDisplay->drawOpenRect( sx, m_columnHeadPos[ side ].y + scaled( 2 ), swatch, swatch, 1.0f, BOARD_EDGE );+ m_columnHead[ side ]->draw( m_columnHeadPos[ side ].x, m_columnHeadPos[ side ].y, BOARD_MUTED, BOARD_SHADOW );+ }++ for( size_t each = 0; each < m_cards.size(); each++ )+ drawCard( m_cards[ each ] );++ // the middle+ if( m_centerLabel )+ m_centerLabel->draw( m_centerLabelPos.x, m_centerLabelPos.y, BOARD_INK, BOARD_SHADOW );+ const Int mapSize = m_mapBox.hi.x - m_mapBox.lo.x;+ TheDisplay->drawFillRect( m_mapBox.lo.x, m_mapBox.lo.y, mapSize, mapSize, BOARD_PANEL );+ if( m_mapImage )+ TheDisplay->drawImage( m_mapImage, m_mapDrawn.lo.x, m_mapDrawn.lo.y, m_mapDrawn.hi.x, m_mapDrawn.hi.y );+ TheDisplay->drawOpenRect( m_mapBox.lo.x - 1, m_mapBox.lo.y - 1, mapSize + 2, mapSize + 2, 1.0f, BOARD_EDGE );+ const Int spot = max( 8, scaled( 18 ) );+ const Int ring = max( 2, scaled( 3 ) );+ for( size_t each = 0; each < m_spots.size(); each++ )+ {+ const BoardSpot &mark = m_spots[ each ];+ TheDisplay->drawFillRect( mark.pos.x - spot / 2 - ring, mark.pos.y - spot / 2 - ring, spot + 2 * ring, spot + 2 * ring, BOARD_GROUND );+ TheDisplay->drawFillRect( mark.pos.x - spot / 2, mark.pos.y - spot / 2, spot, spot, mark.color );+ }+ if( m_observers )+ m_observers->draw( m_observersPos.x, m_observersPos.y, BOARD_MUTED, BOARD_SHADOW );+}+// SinglePlayerLoadScreen Class /////////////////////////////////////////////////-----------------------------------------------------------------------------@@ -200,11 +1033,14 @@ SinglePlayerLoadScreen::SinglePlayerLoadScreen( void )m_objectiveWin = NULL;for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)m_objectiveLines[i] = NULL;+ m_board = NULL;}-+SinglePlayerLoadScreen::~SinglePlayerLoadScreen( void ){+ // the board's window is a child of the load screen's, gone with it in ~LoadScreen+ delete m_board;m_progressBar = NULL;m_percent = NULL;m_objectiveWin = NULL;@@ -631,13 +1467,33 @@ void SinglePlayerLoadScreen::reset( void )void SinglePlayerLoadScreen::update( Int percent ){+ // the briefing movie has the whole screen; the board comes with the load after it+ if( m_board == NULL )+ {+ // Zero Hour's missions name no place, so the number is the title there+ static const char *const difficultyLabels[ DIFFICULTY_COUNT ] = { "GUI:Easy", "GUI:Medium", "GUI:Hard" };+ const Mission *mission = TheCampaignManager->getCurrentMission();+ UnicodeString number;+ number.format( TheGameText->fetch( "GUI:LoadMission" ), TheCampaignManager->getCurrentMissionNumber() + 1 );+ UnicodeString title = number;+ UnicodeString subtitle = TheGameText->fetch( TheCampaignManager->getCurrentCampaign()->m_campaignNameLabel );+ if( !mission->m_locationNameLabel.isEmpty() )+ {+ title = TheGameText->fetch( mission->m_locationNameLabel );+ subtitle.concat( BOARD_SEPARATOR );+ subtitle.concat( number );+ }+ subtitle.concat( BOARD_SEPARATOR );+ subtitle.concat( TheGameText->fetch( difficultyLabels[ TheCampaignManager->getGameDifficulty() ] ) );+ m_board = NEW LoadScreenBoard;+ m_board->createMission( m_loadScreen, title, subtitle, m_unicodeObjectiveLines, MAX_OBJECTIVE_LINES );+ m_progressBar->winHide( TRUE );+ m_percent->winHide( TRUE );+ }percent = (percent + FRAME_FUDGE_ADD)/1.3;- UnicodeString per;- per.format(u"%d%%",percent);TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);- GadgetProgressBarSetProgress(m_progressBar, percent);- GadgetStaticTextSetText(m_percent, per);-+ m_board->setLocalProgress( percent );+// Do this last!LoadScreen::update( percent );}@@ -1176,19 +2032,28 @@ void ChallengeLoadScreen::setProgressRange( Int min, Int max )ShellGameLoadScreen::ShellGameLoadScreen( void ){m_progressBar = NULL;+ m_board = NULL;}-+ShellGameLoadScreen::~ShellGameLoadScreen( void ){-+m_progressBar = NULL;+ delete m_board;}void ShellGameLoadScreen::init( GameInfo *game ){static Bool firstLoad = TRUE;-+ // a replay loads on the board a played match loads on, its players as they really were+ if( game && TheGameLogic->getGameMode() == GAME_REPLAY )+ {+ m_board = NEW LoadScreenBoard;+ m_loadScreen = m_board->create( game, "GUI:LoadModeReplay", FALSE );+ return;+ }+// create the layout of the load screenm_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/ShellGameLoadScreen.wnd" ) );DEBUG_ASSERTCRASH(m_loadScreen, ("Can't initialize the ShellGame loadscreen"));@@ -1287,7 +2152,10 @@ void ShellGameLoadScreen::reset( void )void ShellGameLoadScreen::update( Int percent ){TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);- GadgetProgressBarSetProgress(m_progressBar, percent);+ if( m_board )+ m_board->setLocalProgress( percent );+ else+ GadgetProgressBarSetProgress(m_progressBar, percent);// Do this last!LoadScreen::update( percent );@@ -1297,43 +2165,12 @@ void ShellGameLoadScreen::update( Int percent )//-----------------------------------------------------------------------------MultiPlayerLoadScreen::MultiPlayerLoadScreen( void ){- //Added By Sadullah Nader- //Initializations missing and needed- m_mapPreview = NULL;-- // ...and these three, which init() only fills in when it finds the windows and the destructor- // and update() both read- m_portraitLocalGeneral = NULL;- m_featuresLocalGeneral = NULL;- m_nameLocalGeneral = 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;- }+ m_board = NULL;}-+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;- }-- m_portraitLocalGeneral = NULL;- m_featuresLocalGeneral = NULL;- m_nameLocalGeneral = NULL;+ delete m_board;TheAudio->removeAudioEvent( AHSV_StopTheMusicFade );// TheAudio->stopAudio( AudioAffect_Music );@@ -1341,12 +2178,11 @@ MultiPlayerLoadScreen::~MultiPlayerLoadScreen( void )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"));+ // a skirmish has one machine loading and one bar; a LAN game gives every human his own+ const Bool network = TheGameLogic->getGameMode() == GAME_LAN;+ m_board = NEW LoadScreenBoard;+ m_loadScreen = m_board->create( game, network ? "GUI:LoadModeLAN" : "GUI:LoadModeSkirmish", network );+// getLocalSlotNum() is -1 when no slot in the list is the local player - a game watched from// the observer camera rather than played - and getSlot(-1) hands back NULL. Same guard the// score screen already has.@@ -1356,39 +2192,6 @@ void MultiPlayerLoadScreen::init( GameInfo *game )pt = ThePlayerTemplateStore->getNthPlayerTemplate(lSlot->getPlayerTemplate());elsept = ThePlayerTemplateStore->findPlayerTemplate( TheNameKeyGenerator->nameToKey("FactionObserver") );-// const Image *loadScreenImage = TheMappedImageCollection->findImageByName(pt->getLoadScreen());-- // add portrait, features, and name for the local player's general- const GeneralPersona *localGeneral = TheChallengeGenerals->getGeneralByTemplateName( pt->getName() );- const Image *portrait = NULL;- UnicodeString localName;- if (localGeneral)- {- portrait = localGeneral->getBioPortraitLarge();- localName = TheGameText->fetch( localGeneral->getBioName() );- }- else- {- // the main original factions don't have associated generals- AsciiString imageName;- if (pt->getName() == "FactionAmerica")- portrait = TheMappedImageCollection->findImageByName("SAFactionLogoLg_US");- else if (pt->getName() == "FactionGLA")- portrait = TheMappedImageCollection->findImageByName("SUFactionLogoLg_GLA");- else if (pt->getName() == "FactionChina")- portrait = TheMappedImageCollection->findImageByName("SNFactionLogoLg_China");- else- DEBUG_ASSERTCRASH(NULL, ("Unexpected player template"));-- localName = pt->getDisplayName();- }- m_portraitLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "MultiplayerLoadScreen.wnd:LocalGeneralPortrait"));- m_portraitLocalGeneral->winSetEnabledImage( 0, portrait);- m_featuresLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "MultiplayerLoadScreen.wnd:LocalGeneralFeatures"));- AsciiString features = pt->getGeneralFeatures();- GadgetStaticTextSetText( m_featuresLocalGeneral, TheGameText->fetch( features.isEmpty() ? AsciiString( "GUI:PlayerObserver" ) : pt->getGeneralFeatures() ) );- m_nameLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "MultiplayerLoadScreen.wnd:LocalGeneralName"));- GadgetStaticTextSetText( m_nameLocalGeneral, localName );AsciiString musicName = pt->getLoadScreenMusic();if ( ! musicName.isEmpty() )@@ -1402,134 +2205,17 @@ void MultiPlayerLoadScreen::init( GameInfo *game )}--// 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];- // i is used after the loop; VC6 for-scope let it escape.- Int i;- for (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();-- // format the progress bar to house colors- AsciiString imageName;- imageName.format("LoadingBar_ProgressCenter%d", slot->getApparentColor());- const Image *houseImage = TheMappedImageCollection->findImageByName(imageName);- if (! houseImage)- houseImage = TheMappedImageCollection->findImageByName("LoadingBar_Progress");- m_progressBars[netSlot]->winSetEnabledImage( 6, houseImage );-- 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 ){+ m_board->setLocalProgress( percent );if (TheNetwork){if(percent <= 100)@@ -1560,342 +2246,34 @@ void MultiPlayerLoadScreen::processProgress(Int playerId, Int percentage)DEBUG_ASSERTCRASH(FALSE, ("Percentage %d was passed in for Player %d\n", percentage, playerId));return;}- if( m_playerLookup[playerId] == -1)- return;- //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 );+ m_board->setProgress( 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;- }-- // the three the loop does not cover, for the same reason as MultiPlayerLoadScreen above- m_portraitLocalGeneral = NULL;- m_featuresLocalGeneral = NULL;- m_nameLocalGeneral = NULL;+ m_board = 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;- }+ delete m_board;}-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()));- // getLocalSlotNum() is -1 when no slot in the list is the local player - a game watched from- // the observer camera rather than played - and getSlot(-1) hands back NULL. Same guard the- // score screen already has.- GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());- const PlayerTemplate* pt;- if (lSlot && 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);-- // add portrait, features, and name for the local player's general- const GeneralPersona *localGeneral = TheChallengeGenerals->getGeneralByTemplateName( pt->getName() );- const Image *portrait = NULL;- UnicodeString localName;- if (localGeneral)- {- portrait = localGeneral->getBioPortraitLarge();- localName = TheGameText->fetch( localGeneral->getBioName() );- }- else- {- // the main original factions don't have associated generals- AsciiString imageName;- if (pt->getName() == "FactionAmerica")- portrait = TheMappedImageCollection->findImageByName("SAFactionLogo144_US");- else if (pt->getName() == "FactionGLA")- portrait = TheMappedImageCollection->findImageByName("SUFactionLogo144_GLA");- else if (pt->getName() == "FactionChina")- portrait = TheMappedImageCollection->findImageByName("SNFactionLogo144_China");- else- DEBUG_ASSERTCRASH(NULL, ("Unexpected player template"));+ m_board = NEW LoadScreenBoard;+ m_loadScreen = m_board->create( game, "GUI:LoadModeOnline", TRUE );- localName = pt->getDisplayName();- }- m_portraitLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "GameSpyLoadScreen.wnd:LocalGeneralPortrait"));- m_portraitLocalGeneral->winSetEnabledImage( 0, portrait);- m_featuresLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "GameSpyLoadScreen.wnd:LocalGeneralFeatures"));- AsciiString features = pt->getGeneralFeatures();- GadgetStaticTextSetText( m_featuresLocalGeneral, TheGameText->fetch( features.isEmpty() ? AsciiString( "GUI:PlayerObserver" ) : pt->getGeneralFeatures() ) );- m_nameLocalGeneral = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( "GameSpyLoadScreen.wnd:LocalGeneralName"));- GadgetStaticTextSetText( m_nameLocalGeneral, localName );-- GameWindow *teamWin[MAX_SLOTS];- // i is used after the loop; VC6 for-scope let it escape.- Int i;- for (i = 0; i < MAX_SLOTS; ++i)+ // a player's rank beside his name, from the stats the lobby fetched+ 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())+ if( !slot || !slot->isHuman() || slot->getOriginalPlayerTemplate() == PLAYERTEMPLATE_OBSERVER )continue;-- Color houseColor = TheMultiplayerSettings->getColor(slot->getApparentColor())->getColor();-- // format the progress bar to house colors- AsciiString imageName;- imageName.format("LoadingBar_ProgressCenter%d", slot->getApparentColor());- const Image *houseImage = TheMappedImageCollection->findImageByName(imageName);- if (! houseImage)- houseImage = TheMappedImageCollection->findImageByName("LoadingBar_Progress");- m_progressBars[netSlot]->winSetEnabledImage( 6, houseImage );-- UnicodeString name = slot->getName();- GadgetStaticTextSetText(m_playerNames[netSlot], name );- m_playerNames[netSlot]->winSetEnabledTextColors(houseColor, m_playerNames[netSlot]->winGetEnabledTextBorderColor());-- // Get the stats for the playerPSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(slot->getProfileID());- DEBUG_LOG(("LoadScreen - populating info for %s(%d) - stats returned id %d\n",- WideCharAsUtf8( slot->getName().str() ).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(u"%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(u"%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);- }+ m_board->setBadge( i, LookupSmallRankImage( GetFavoriteSide(stats), CalculateRank(stats) ) );}TheGameLogic->initTimeOutValues();@@ -1904,16 +2282,11 @@ void GameSpyLoadScreen::init( GameInfo *game )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 ){+ m_board->setLocalProgress( percent );if(percent <= 100)TheNetwork->updateLoadProgress( percent );TheNetwork->liteupdate();@@ -1936,11 +2309,7 @@ void GameSpyLoadScreen::processProgress(Int playerId, Int percentage)DEBUG_ASSERTCRASH(FALSE, ("Percentage %d was passed in for Player %d\n", percentage, playerId));return;}- if( m_playerLookup[playerId] == -1)- return;- //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 );+ m_board->setProgress( playerId, percentage );}// MapTransferLoadScreen Class //////////////////////////////////////////////////