Skip to content

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.

fix(gameclient): multi-selection shows each type once on the portrait bar

Olcay Seygan2f563574c0a0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 933fa0c7f..3683d9e7c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -624,7 +624,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- Both are an ordinary web page with a stylesheet, in the game's Window folder. Change the colours, the sizes or the order there and the next match you watch draws it that way, and the page opens in a browser too.
- A minimised command bar stays minimised. Changing seats, or clicking another player's unit while watching, put the whole bar back up over the battlefield you had just cleared. A new match still opens with the bar up.
- The command bar's frame is drawn new, in the same steel as the boards. Each panel holds one thing and is exactly its size, the radar, the command grid, the portrait with the experience bar, and wears a steel border outside it. Grey for America, red for China, sand for GLA. It slides and minimises with the bar, and like the boards it is a page in the Window folder; take the page away and the old painted bar comes back.
-- The command bar is laid out anew, all of it running rightwards from the bottom left corner, and it is smaller: at 1920x1080 it stands 248 pixels tall where the old bar took 312, and it ends a third of the way across, so the rest of the screen's bottom edge is battlefield but for the general's powers in the corner. The radar sits in the corner with your general's experience bar standing beside it, and on its top edge the under-attack light, the skills key with your rank's stars on that, and over the stars the idle worker button whenever a worker stands idle. Next to it is one grid of eighteen buttons, six across and three down, and every button is its own key: Q W E R T Y over A S D F G H over Z X C V B N. No more two-key building shortcuts and no second bars: a dozer's buildings, a factory's units, a unit's abilities and upgrades and its orders all share the grid, each a single press. The orders stay put whatever you select. For a unit, A attacks, S stops, D attack-moves, Z ejects the passengers, X guards and C holds position; for a building, N sells it, B sets its rally point and Z empties its garrison. Everything else fills the free places from Q along the rows, what a building makes first and its upgrades after. Only the buttons your selection has are drawn, and the rest of the grid is bare steel. Its buttons are a fifth bigger than the rest of the bar's, so what you build stands out. Attack and hold position are buttons now, where no unit ever had one, with pictures painted to sit among the game's own: a crosshair on a red plate over a burning sky, a raised palm on a blue one. Over the grid runs a portrait bar only as long as what it holds. Select one unit and its upgrades follow its portrait; select a group and every kind of unit in it follows, each with how many you have. The power bar stands up at the grid's right end. Your money has moved to the middle of the screen's top edge. The Legacy mouse and keyboard and the W A S D camera are gone from the Options screen: there is one way to play, and an Options.ini that still names them loads as it always did.
+- The command bar is laid out anew, all of it running rightwards from the bottom left corner, and it is smaller: at 1920x1080 it stands 248 pixels tall where the old bar took 312, and it ends a third of the way across, so the rest of the screen's bottom edge is battlefield but for the general's powers in the corner. The radar sits in the corner with your general's experience bar standing beside it, and on its top edge the under-attack light, the skills key with your rank's stars on that, and over the stars the idle worker button whenever a worker stands idle. Next to it is one grid of eighteen buttons, six across and three down, and every button is its own key: Q W E R T Y over A S D F G H over Z X C V B N. No more two-key building shortcuts and no second bars: a dozer's buildings, a factory's units, a unit's abilities and upgrades and its orders all share the grid, each a single press. The orders stay put whatever you select. For a unit, A attacks, S stops, D attack-moves, Z ejects the passengers, X guards and C holds position; for a building, N sells it, B sets its rally point and Z empties its garrison. Everything else fills the free places from Q along the rows, what a building makes first and its upgrades after. Only the buttons your selection has are drawn, and the rest of the grid is bare steel. Its buttons are a fifth bigger than the rest of the bar's, so what you build stands out. Attack and hold position are buttons now, where no unit ever had one, with pictures painted to sit among the game's own: a crosshair on a red plate over a burning sky, a raised palm on a blue one. Over the grid runs a portrait bar only as long as what it holds. Select one unit and its upgrades follow its portrait; select a group and the bar holds every kind of unit in it once, each with how many you have, the one Tab has picked lit and the rest dimmed. The power bar stands up at the grid's right end. Your money has moved to the middle of the screen's top edge. The Legacy mouse and keyboard and the W A S D camera are gone from the Options screen: there is one way to play, and an Options.ini that still names them loads as it always did.
- Every panel of the bar is only as big as what it holds now, and stands on the bottom of the screen. The radar's border runs out to the screen's left edge. The power bar stands in a steel groove of its own at the right end of the command grid, twenty cells that light up from the bottom with your production and fill the groove when full, the consumption marked by a white needle across it. The money hangs from the top edge of the screen in a steel plate of its own, the figure in a dark well. Everything the old painting filled round them is battlefield again, and a click there lands on the battlefield.
- The bar's own buttons are drawn to match, steel caps lit gold under the pointer and pressed in when pushed. The menu is a small square with three bars in the screen's top left corner. The idle worker button is a key like the smoke signals', a hard hat on it, in a steel tab over your rank's stars, where it no longer hides the end of the power bar. Each button stands in its own dark cell with steel running between them, and the steel is laid over the edge of every picture the way a frame holds a card, the whole picture showing inside it. The production queue and the general's powers are framed the same way. The power bar is sunk into the same steel plate as the build grid, standing at its right end, and is as tall as the grid on every side, where it used to change length from one faction to the next. The build grid's panel no longer carries an empty strip down its left side. There is no chat button any more: Enter opens the chat as it always did. The beacon button is gone from the bar too; the smoke signals over the radar are how you point your team at a spot. The portrait sits in the radar's lit steel too. The experience bar beside it is ten gold rungs in a sunk groove, climbing from the bottom as you earn your way to the next rank, and your rank stands in a steel tab on the portrait's top right corner, a key sunk in it like the idle worker's with one star for every rank there is, gold up to the one you hold. A watcher has nothing to promote and no longer gets the tab, which used to hang half into the screen's corner. Its button goes with it: a watcher who clicked a unit used to find an empty patch of screen there that still showed the promotions tooltip and opened the promotion screen. The portrait's grid is steel between dark cells on every side, where America's was drawn in blue lines that matched nothing else on the bar. That key is the promotions button: point at it and it comes up with a gold rim, it blinks bright in your side's own steel while you have a promotion to spend, and a click opens the promotion screen. That screen is rebuilt in the same steel and half its old size: each rank's promotions stand in a grid of build-button cells five wide, like the command grid, an empty place a dark hole, each rank in a steel well of its own with its heading, the wells a plate's thickness apart, the grid's steel laid over the edge of every picture so the picture sits in its cell like a card in a frame, your rank and the points to spend on one line over the experience bar, and Done in the last row's spare place. A gold rim marks what you have bought and a light one what you can buy now. It comes up the way the Esc menu does, the battlefield behind it dimmed to 65% black and the screen fading in over an eighth of a second; the side's old painted screen no longer fades in over it for the first nine frames. The bar has no minimise arrow any more: it is only as big as what it holds. The radar sits sunk in a bezel of lit steel, bright along the top and shadowed down the right, and the build grid and the money wear the same steel, the figure in a dark window of its own, and the under-attack light is a long red lamp set in a steel tab on its top left corner, dark until you are hit and then blinking. No words on it, so it reads the same in any language.
- The general's powers you have bought and can fire, the column that climbed the right edge of the screen, stand in the bottom right corner now in a tray of the bar's own steel. The first sits in the corner against the right edge of the screen, and each one you gain takes the place to the left of the last, three to a row before a new row starts above, so the tray is only ever as big as what you hold and an empty one takes no room at all. Each power sits on a dark cell three quarters the size of a build button, where the side's old tray art used to frame it. It is always out; there is no button to fold it away.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cpp
index 91224021f..e535b8245 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cpp
@@ -182,9 +182,10 @@ void ControlBar::updateMultiSelectStrip( void )
return;
//
- // the portrait bar's rule, the owner's: the focused type's portrait first and the selected types
- // after it, and no upgrades, which belong to one unit. A selection of one type is one cell with
- // its count. setPortraitByObject hides the cells, so it goes first
+ // the portrait bar's rule, the owner's: each selected type once, its own tile with its count, and
+ // no upgrades, which belong to one unit. The portrait is still set to the focused type for the
+ // bar's own bookkeeping, and the page shrinks its window to nothing. setPortraitByObject hides the
+ // cells, so it goes first
//
Drawable *focused = TheGameClient->findDrawableByID( m_multiSelectGroupFirst[ m_multiSelectFocus ] );
setPortraitByObject( focused ? focused->getObject() : NULL );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 14e69f8a9..c7cf42df0 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -11638,27 +11638,32 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I
Int rows = 1;
while( (Int)tiles.size() > rows * rows * PORTRAIT_PLACES )
rows++;
- // a column of `rows` tiles is one cell wide
- const Int columns = tiles.empty() ? (Int)upgrades.size() : ( (Int)tiles.size() + rows - 1 ) / rows;
+ // a column of `rows` tiles is one cell wide. A multi-selection shows each type once, its own tile
+ // with its count, the focused one lit: the portrait of the focused type would be that type again,
+ // so the owner had it taken off and its window is shrunk to nothing
+ const Bool multi = !tiles.empty();
+ const Int columns = multi ? ( (Int)tiles.size() + rows - 1 ) / rows : (Int)upgrades.size();
+ const Int portraitWidth = multi ? 0 : PORTRAIT_WIDTH + CELL_GAP;
IRegion2D portraitBox;
portraitBox.lo.x = commandBox.lo.x;
portraitBox.hi.y = centreShown ? centreBox.lo.y - border : foot;
portraitBox.lo.y = portraitBox.hi.y - REAL_TO_INT( ( CELL_HEIGHT + CELL_GAP ) * scale );
- portraitBox.hi.x = portraitBox.lo.x + REAL_TO_INT( ( PORTRAIT_WIDTH + CELL_GAP + columns * ( CELL_WIDTH + CELL_GAP ) ) * scale );
+ portraitBox.hi.x = portraitBox.lo.x + REAL_TO_INT( ( portraitWidth + columns * ( CELL_WIDTH + CELL_GAP ) ) * scale );
IRegion2D portraitFrame = framed( portraitBox, border, FALSE, FALSE );
portraitFrame.hi.y = centreShown ? centreBox.lo.y : barBottom();
putFrame( values, "portrait", portraitBox, portraitFrame, portraitShown );
TheControlBar->placeWindowAt( controlBarWindow( "RightHUD" ), portraitBox );
TheControlBar->placeWindowAt( controlBarWindow( "WinUnitSelected" ), portraitBox );
IRegion2D portraitCell = gridCell( portraitBox, 0, 0, CELL_WIDTH, CELL_HEIGHT );
- portraitCell.hi.x = portraitCell.lo.x + REAL_TO_INT( PORTRAIT_WIDTH * scale );
+ portraitCell.hi.x = portraitCell.lo.x + ( multi ? 0 : REAL_TO_INT( PORTRAIT_WIDTH * scale ) );
TheControlBar->placeWindowAt( portraitWindow, portraitCell );
IRegion2D placesBox = portraitBox;
- placesBox.lo.x = portraitCell.hi.x + REAL_TO_INT( ring * scale );
+ if( !multi )
+ placesBox.lo.x = portraitCell.hi.x + REAL_TO_INT( ring * scale );
std::vector< HtmlValues > &portraitCells = lists[ "portraitcells" ];
- if( portraitShown )
+ if( portraitShown && !multi )
{
HtmlValues entry;
putCell( entry, portraitCell, ring, scale );