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
fix(gameclient): keep radar height fixed, map shape widens it right
Olcay Seygan6c54be98a080
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d52f98826..791fa9581 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,7 +10,7 @@ found and fixed, EA's own, not port damage.**## The command bar fits the map-- The radar takes the map's shape. A long map draws as a long strip in a frame of the same shape, a tall map as a tall one, and the black bands beside it are gone. A click on the radar still lands where it always did.+- The radar takes the map's shape at a height that never changes: a long map widens it to the right, a tall map narrows it, and the frame's top stays level with the bar beside it. The black bands beside the map are gone; only a map too long for the room before the command buttons keeps thin ones above and below. A click on the radar still lands where it always did.- Four idle buttons stand at the right end of the command grid, top to bottom: worker, infantry, vehicle and aircraft. Each picks the next unit of its kind standing with no order and turns the camera to it, as the idle worker button always did; that button has moved there from the column on the left. A button stays dark while nothing of its kind is idle, and its tooltip names the key that does the same. The worker button used to light two to five seconds after the other three, because it waited on the worker to report itself idle; all four now look at your army on the same frame, and the worker button and its key cycle through the same workers that lit it.- The general's powers stand three to a row again, on the right edge above the general's tab. When the top row is short it leaves a step on the inside, and the tray's plate follows that outline.- The promotion window's close button is your side's own now, cut to fit the window's corner. It was the last piece of the old bar's art left on any side's screen.diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex fc64e8858..1deaee0a5 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -2344,8 +2344,8 @@ static void shiftWindowTree( GameWindow *window, Int dx )}//--------------------------------------------------------------------------------------------------/** layoutPanels stands the radar in its square box. A scheme with a radar frame then shrinks the- * window to the map's own shape inside that box, pinned to the box's bottom left where the bar+/** layoutPanels stands the radar in its square box. A scheme with a radar frame then gives the+ * window the map's own shape at a fixed height, pinned to the box's bottom left where the bar* meets the corner of the screen: Radar::findDrawPositions then finds nothing to letterbox and a* click maps to the world through the same arithmetic as before. The blocker becomes the frame* round it, which ControlBarSchemeManager::drawPainting draws, and the under-attack lamp at the@@ -2420,18 +2420,42 @@ void ControlBar::fitRadarToMap( Bool fromLayout )box[ i ].hi.y += origin.y;}+ //+ // The radar's height never changes with the map: the frame stands on the scheme's radar block+ // (BlockRadar, or ControlBar.wnd's blocker where the scheme names none, the observer's 740 that+ // its column starts at), and never above the square. The map's shape only sets the width, which+ // grows right from the square's left edge. It stops where what rides on its right meets the next+ // piece of the bar: a side's frame at the command plate's blocker, the observer's player panel at+ // the selection's. A map wider than that room is letterboxed by Radar::findDrawPositions inside+ // the frame instead.+ //// W3DLeftHUDDraw paints the radar a pixel inside the window, so it is the inside that takes the// map's shape; rounded, so Radar::findDrawPositions finds under a pixel to letterbox and draws none+ //enum { RADAR_BEZEL = 1 };+ static NameKeyType productionID = NAMEKEY( "ControlBar.wnd:ControlBarProBlockInputProduction" );+ static NameKeyType upgradesID = NAMEKEY( "ControlBar.wnd:ControlBarProBlockInputUpgrades" );+ const Bool observer = m_controlBarSchemeManager->getCurrentSide().compareNoCase( "Observer" ) == 0;const IRegion2D &square = box[ RADAR_FIT_RADAR ];- const Int insideWidth = square.hi.x - square.lo.x - 2 * RADAR_BEZEL;- const Int insideHeight = square.hi.y - square.lo.y - 2 * RADAR_BEZEL;- const Real scale = MIN( insideWidth / m_radarFitWidth, insideHeight / m_radarFitHeight );+ IRegion2D squareOuter;+ ControlBarSchemeManager::radarFrameRect( frame, square, &squareOuter );IRegion2D fit;fit.lo.x = square.lo.x;- fit.hi.x = square.lo.x + REAL_TO_INT( m_radarFitWidth * scale + 0.5f ) + 2 * RADAR_BEZEL;- fit.lo.y = square.hi.y - REAL_TO_INT( m_radarFitHeight * scale + 0.5f ) - 2 * RADAR_BEZEL;+ fit.lo.y = MAX( square.lo.y, box[ RADAR_FIT_BLOCK ].lo.y + square.lo.y - squareOuter.lo.y );fit.hi.y = square.hi.y;+ const Int insideHeight = fit.hi.y - fit.lo.y - 2 * RADAR_BEZEL;++ Int room = 0;+ GameWindow *next = TheWindowManager->winGetWindowFromId( NULL, observer ? upgradesID : productionID );+ if( next != NULL && ( !observer || windows[ RADAR_FIT_INFO ] != NULL ) )+ {+ ICoord2D at;+ next->winGetScreenPosition( &at.x, &at.y );+ room = MAX( 0, at.x - ( observer ? box[ RADAR_FIT_INFO ].hi.x : squareOuter.hi.x ) );+ }+ const Int insideWidth = MIN( REAL_TO_INT( insideHeight * m_radarFitWidth / m_radarFitHeight + 0.5f ),+ square.hi.x - square.lo.x - 2 * RADAR_BEZEL + room );+ fit.hi.x = square.lo.x + insideWidth + 2 * RADAR_BEZEL;placeWindowAt( windows[ RADAR_FIT_RADAR ], fit );IRegion2D outer;@@ -2448,15 +2472,12 @@ void ControlBar::fitRadarToMap( Bool fromLayout )//// The observer's column stands against the frame's right edge, so a tall map's narrower frame- // takes the column, its plate (drawPainting) and everything on it left with it. Its height is- // the square's and it ends at the screen's foot, so a wide map's lower frame leaves it standing:- // moved down it would run off the screen. A side's Options and Chat stand in the middle plate- // and stay.+ // takes the column, its plate (drawPainting) and everything on it left with it, and a wide map's+ // wider one right. The frame's top is the column's, so it only ever moves across. A side's+ // Options and Chat stand in the middle plate and stay.//- if( m_controlBarSchemeManager->getCurrentSide().compareNoCase( "Observer" ) != 0 )+ if( !observer )return;- IRegion2D squareOuter;- ControlBarSchemeManager::radarFrameRect( frame, square, &squareOuter );m_radarColumnShift = outer.hi.x - squareOuter.hi.x;for( Int i = RADAR_FIT_COLUMN_FIRST; i < RADAR_FIT_COUNT; i++ ){diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex e10eb332b..8f9fe2838 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -4033,9 +4033,9 @@ static Int controlBarTop( void )}//--------------------------------------------------------------------------------------------------/** The top of the radar's frame as it stands, fitted to this map's shape: a wide map's radar is- * shorter and its frame starts lower than the bar's left piece. A scheme with no frame, or a- * hidden radar, gives controlBarTop. */+/** The top of the radar's frame as it stands. The map's shape only widens or narrows it, so this is+ * the scheme's radar block for every map. A scheme with no frame, or a hidden radar, gives+ * controlBarTop. *///-------------------------------------------------------------------------------------------------static Int radarFrameTop( void ){diff --git a/GeneralsMD/Code/Tools/hud_command_bar.py b/GeneralsMD/Code/Tools/hud_command_bar.pyindex c3ce59fd4..33690e4c3 100644--- a/GeneralsMD/Code/Tools/hud_command_bar.py+++ b/GeneralsMD/Code/Tools/hud_command_bar.py@@ -1065,8 +1065,9 @@ def promotion_banner(size):# map-shaped radar, so the left panel of the bar is empty. The corners' sizes are the frame's thickness# (ControlBarSchemeManager::radarFrameRect): 5 at the screen's left and bottom edges, 29 over the top# and 45 down the right, which at the square map is exactly the old left panel, 0..372 x 724..1080.-# The edges and the glass stretch (in practice they only ever shrink: the square is the largest the-# radar gets), so they are drawn even along their length and every ornament sits in a corner.+# The edges and the glass stretch: the height is fixed at the scheme's radar block, never above the+# square, and the top and bottom grow along a long map, so they are drawn even along their length+# and every ornament sits in a corner.RADAR_EDGE = (5, 29, 45, 5) # left, top, right, bottomRADAR_INSIDE = 322 # LeftHUD's square, 5..327 x 753..1075RADAR_GLASS = 64 # the centre piece, the glass, shrunk from the square