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): load screen start spots drawn as the room's rings
Olcay Seygan14f6baf6dcd9
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 840500577..fb65e43fc 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,7 +10,7 @@ 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.+- 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 between them, its start spots drawn as the room draws them: the blue ring, filled with the player's colour and his seat number where the others may see who starts there. 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.diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.hindex 4427f1ce4..7cbf0250f 100644--- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.h+++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.h@@ -140,6 +140,9 @@ Color LobbyTeamColor(Int team);Color LobbySeatColor(const GameSlot *slot);// Black or white, whichever has the higher WCAG contrast on this fill.Color LobbyTextColorOn(Color fill);+// A taken start spot's colour, laid in the dark middle of EA's PlayerStart ring drawn over this+// rectangle; the room's spot buttons and the load screen's map both draw it.+void LobbyStartSpotFill(Int x, Int y, Int width, Int height, Color fill);void EnableSlotListUpdates( Bool val );Bool AreSlotListUpdatesEnabled( void );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cppindex 784b19e00..13308781d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp@@ -912,13 +912,8 @@ static void drawStartSpot( GameWindow *window, WinInstanceData *instData )Int x, y, width, height;window->winGetScreenPosition( &x, &y );window->winGetSize( &width, &height );- // Colour only the stock spot's dark middle, inside its blue ring. EA's PlayerStart art is 25 pixels- // square with a drop shadow to the lower right, so the middle is not centred in it: it covers source- // pixels 3 to 18 both ways. Those bounds scale with the button and round to the nearest pixel.- const Int artSize = 25, holeStart = 3, holeEnd = 19;- TheDisplay->drawImage( TheMappedImageCollection->findImageByName( "ReforgedLobbySpot" ),- x + (width * holeStart + artSize / 2) / artSize, y + (height * holeStart + artSize / 2) / artSize,- x + (width * holeEnd + artSize / 2) / artSize, y + (height * holeEnd + artSize / 2) / artSize, fill );+ // colour only the stock spot's dark middle, inside its blue ring+ LobbyStartSpotFill( x, y, width, height, fill );DisplayString *number = instData->getTextDisplayString();// the number in the bold of the button's own face, so it holds up on a bright discGameFont *font = number->getFont();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cppindex 189150cdb..2fda0fbf1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp@@ -209,6 +209,10 @@ static const WideChar BOARD_SEPARATOR[] = { ' ', ' ', ' ', 0x00B7, ' ', ' ', ' 'static const Real BOARD_COLUMN_WIDTH = 600.0f;static const Real BOARD_BAND_TOP = 176.0f;static const Real BOARD_BAND_BOTTOM = 866.0f;+/// the rooms' start spot button against their map preview (SkirmishGameOptionsMenu.wnd), so the spots+/// keep the room's size on a preview of another size+static const Int LOBBY_START_SPOT = 28;+static const Int LOBBY_MAP_PREVIEW = 410;/// one player's cardstruct BoardCard@@ -230,10 +234,12 @@ struct BoardCardIRegion2D box;};+/// one of the map's start spots, drawn as the room draws itstruct BoardSpot{ICoord2D pos;- Color color;+ Color color; ///< the player's on it, 0 for a spot open or hidden+ DisplayString *number; ///< the player's seat, NULL with the colour};class LoadScreenBoard@@ -598,24 +604,36 @@ GameWindow *LoadScreenBoard::create( GameInfo *game, const char *modeLabel, Boolm_observersPos.y = y;}- // the preview the lobby showed, at the map's own shape, and every start spot that is not hidden+ // the preview the lobby showed, at the map's own shape, and every start spot as the room shows it:+ // the player's colour and seat on a spot the others may see, the ring alone on the restm_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++ )+ GameFont *numberFont = UIStyle::font( UIStyle::TEXT_SMALL, TRUE );+ for( Int start = 0; start < map->m_numPlayers && map->m_isMultiplayer; start++ ){AsciiString waypoint;- waypoint.format( "Player_%d_Start", m_cards[ each ].startSpot + 1 );+ waypoint.format( "Player_%d_Start", start + 1 );WaypointMap::const_iterator it = map->m_waypoints.find( waypoint );- if( m_cards[ each ].startSpot < 0 || it == map->m_waypoints.end() )+ if( 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;+ spot.color = 0;+ spot.number = NULL;+ for( size_t each = 0; each < m_cards.size(); each++ )+ {+ if( m_cards[ each ].startSpot != start )+ continue;+ AsciiString seat;+ seat.format( "NUMBER:%d", m_cards[ each ].slot + 1 );+ spot.color = m_cards[ each ].color;+ spot.number = text( TheGameText->fetch( seat ), numberFont );+ }m_spots.push_back( spot );}}@@ -925,13 +943,21 @@ void LoadScreenBoard::drawMatch( void )TheDisplay->drawImage( m_mapImage, m_mapDrawn.lo.x, m_mapDrawn.lo.y, m_mapDrawn.hi.x, m_mapDrawn.hi.y );// the lobby's map preview wears a button's edgeUIStyle::edge( m_mapBox.lo.x - 3, m_mapBox.lo.y - 3, mapSize + 6, mapSize + 6 );- const Int spot = max( 8, scaled( 18 ) );- const Int ring = max( 2, scaled( 3 ) );+ // the room's start spot: EA's ring (a mod's archives may leave it out), the colour in its middle+ const Int spot = mapSize * LOBBY_START_SPOT / LOBBY_MAP_PREVIEW;+ const Image *ring = TheMappedImageCollection->findImageByName( "PlayerStart" );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, UIStyle::GROUND );- TheDisplay->drawFillRect( mark.pos.x - spot / 2, mark.pos.y - spot / 2, spot, spot, mark.color );+ const Int x = mark.pos.x - spot / 2;+ const Int y = mark.pos.y - spot / 2;+ if( ring )+ TheDisplay->drawImage( ring, x, y, x + spot, y + spot );+ if( mark.number == NULL )+ continue;+ LobbyStartSpotFill( x, y, spot, spot, mark.color );+ mark.number->draw( x + ( spot - stringWidth( mark.number ) ) / 2, y + ( spot - stringHeight( mark.number ) ) / 2,+ LobbyTextColorOn( mark.color ), 0 );}if( m_observers )m_observers->draw( m_observersPos.x, m_observersPos.y, UIStyle::MUTED, UIStyle::SHADOW );diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cppindex e6dfcf0cc..7dc232d0b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp@@ -955,6 +955,17 @@ Color LobbyTextColorOn(Color fill)return blackContrast > whiteContrast ? GameMakeColor(0, 0, 0, 255) : GameMakeColor(255, 255, 255, 255);}+void LobbyStartSpotFill(Int x, Int y, Int width, Int height, Color fill)+{+ // EA's PlayerStart art is 25 pixels square with a drop shadow to the lower right, so its dark middle+ // is not centred in it: it covers source pixels 3 to 18 both ways. Those bounds scale with the+ // rectangle and round to the nearest pixel.+ const Int artSize = 25, holeStart = 3, holeEnd = 19;+ TheDisplay->drawImage(TheMappedImageCollection->findImageByName("ReforgedLobbySpot"),+ x + (width * holeStart + artSize / 2) / artSize, y + (height * holeStart + artSize / 2) / artSize,+ x + (width * holeEnd + artSize / 2) / artSize, y + (height * holeEnd + artSize / 2) / artSize, fill);+}+// A colour swatch drawn as one of the rules page's check boxes: their own empty box, and the colour// inside its bevel with a little room between.static void drawSwatch(GameWindow *window, WinInstanceData *instData)