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.

feat(gameengine): empty bar hides its stand-in worker, type tiles trim the selection

Olcay Seygan0febfbebfc71
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8ca9c4055..0e411b574 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,7 +24,7 @@ found and fixed — EA's own, not port damage.**
- The command bar is one console standing in the middle of the bottom edge: a taller radar, your selection and the build grid side by side, with the power bar over the grid. The idle worker and rank keys sit in a row over your selection, and in multiplayer the smoke signals join them. The red under-attack lamp is gone: the ping on the radar, the voice and the line in the event feed already tell you where you are hit, and the lamp only blinked about it a second time.
- Your general's powers grow out of the console's right end, a column for each F key with its powers stacked up it, and only the powers you have take any room.
-- A single unit's name and health stand beside its portrait, and a veteran gets his gold stars there too. Under them sit its main weapon's damage, damage a second and range, and what its armour does to gunfire, tank shells and rockets: green for less damage taken, red for more. Your own units and your allies' show as they stand, so a veteran's bonus, a Composite Armor upgrade or Hold the Line shows the moment it lands. An enemy's show only what his veterancy stars already tell you, never his upgrades or battle plans. Click an enemy and his health reads as a share, 64%, because 512/800 would tell you he bought Composite Armor; the upgrade icons under his portrait stay grey for everything his side researched, where retail lit Composite Armor or Supply Lines for anyone who clicked, and light only for what the unit visibly carries, a drone or an Overlord's turret. A group shows every type it holds in the same box, five to a row. Watching a match with nothing selected, the empty portrait box is gone and the console is the radar alone; click a unit and the box comes back. Following nobody, the experience bar beside the radar is gone too, since there is no general's rank to fill it.
+- A single unit's name and health stand beside its portrait, and a veteran gets his gold stars there too. Under them sit its main weapon's damage, damage a second and range, and what its armour does to gunfire, tank shells and rockets: green for less damage taken, red for more. Your own units and your allies' show as they stand, so a veteran's bonus, a Composite Armor upgrade or Hold the Line shows the moment it lands. An enemy's show only what his veterancy stars already tell you, never his upgrades or battle plans. Click an enemy and his health reads as a share, 64%, because 512/800 would tell you he bought Composite Armor; the upgrade icons under his portrait stay grey for everything his side researched, where retail lit Composite Armor or Supply Lines for anyone who clicked, and light only for what the unit visibly carries, a drone or an Overlord's turret. A group shows every type it holds in the same box, five to a row. Click a type there and only those stay selected; shift-click it and they leave the selection, so the two Rangers that tagged along with your tanks are one click from gone. Watching a match with nothing selected, the empty portrait box is gone and the console is the radar alone; click a unit and the box comes back. Following nobody, the experience bar beside the radar is gone too, since there is no general's rank to fill it.
- The match clock hangs from the middle of the top edge with your money in its own box under it. Superweapon countdowns in the top right corner are as big as your general's power buttons. Hold Tab and the scoreboard drops down from it.
- Peace time has its own plate under your money, so the truce clock never pushes the match clock aside. When the last ten seconds start, the countdown hangs straight off that plate.
- A superweapon built, charged or fired anywhere on the map flashes its name in big letters under the clock: "Nuclear Missile launched". Yours are white, an ally's blue, an enemy's red. Each line stays four seconds and fades out. When several land at once they queue and hurry through, two seconds each with one more waiting and one second with a pile behind it, so the last news never sits stale.
@@ -796,7 +796,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- Hold shift and drag, and the row is one stroke. Press where the first building goes, drag the way the row runs, and a ghost appears for every building that fits end to end along the line, all facing the way the first one was turned. The row runs exactly the way you drag it, at 20 degrees as happily as along the map's edge, and packs the buildings as close as their shape allows: one turned onto the line of the row stands wall to wall with the next, and a factory keeps its door lane clear. A row of Power Plants turned square to the map packs 44 apart; it used to go down on whole grid squares, 50 apart, with a strip of dirt at every joint. It stops at the last building your bank can pay for. A ghost that lands on a rock or someone's tank turns red and is left out when you let go; the rest go up. With two or three workers selected the buildings are shared out to the nearest free one, and the ones nobody is free for wait as plans until a worker comes off its job. A plain drag still turns the building, and walls still tile the way they always did.
- While that row is on the cursor, the wheel opens and closes the space between the buildings, one grid square a notch. The one where you pressed and the one under the cursor stay put; what changes is how many stand between them and how far apart those are. It will not pack them any tighter than they already sit against each other, and it will not take either end away to make the gap. Letting go places the row and takes the building off the cursor, so the next click is not another one. Holding shift and clicking them out one at a time still keeps the ghost up.
- Hold Alt and drag while placing a building, and you lay out a block of them instead of a row. Ghosts stand for as many as your money covers, a blocked spot is skipped, and your builders work through the block in order.
-- With nothing selected the command bar shows your builders' buildings again, and only those: clearing mines and the Demolition worker's suicide charge stay on a worker you actually select. Put one down and the idle worker nearest the spot walks over and builds it; when every worker is busy, the nearest one takes it on after the job in hand. A shift-dragged row placed this way is shared out among your idle workers. The bar keeps showing the same worker while you place, so a GLA worker switched to fake buildings stays on that page, and a fake is only ever handed to a worker who is on it. That last part holds with workers selected too: select a real-page and a fake-page worker together and a building goes to the one that can build it, where it used to go to the nearest and be refused. A replay with such a mixed selection in it plays back differently.
+- With nothing selected the command bar shows your builders' buildings again, and only those: clearing mines and the Demolition worker's suicide charge stay on a worker you actually select. Put one down and the idle worker nearest the spot walks over and builds it; when every worker is busy, the nearest one takes it on after the job in hand. A shift-dragged row placed this way is shared out among your idle workers. The bar keeps showing the same worker while you place, so a GLA worker switched to fake buildings stays on that page, and a fake is only ever handed to a worker who is on it. That last part holds with workers selected too: select a real-page and a fake-page worker together and a building goes to the one that can build it, where it used to go to the nearest and be refused. A replay with such a mixed selection in it plays back differently. The worker lending the bar its buildings no longer shows up beside them: its portrait, name and health filled the selection box, and players took the empty bar for a selected worker. The box stays empty until you select something.
- Turning a building no longer turns everything you build afterwards. A wheeled heading still carries from one wall to the next, but the next supply centre comes out facing the way it was designed to.
- A building you point at blocked ground slides to the nearest spot it fits, and lands there.
- The pointer keeps its build cursor while you place, even passing over your own buildings.
diff --git a/GeneralsMD/Code/Data/German/Generals.str b/GeneralsMD/Code/Data/German/Generals.str
index 5c4d2616e..ee3135f9c 100644
--- a/GeneralsMD/Code/Data/German/Generals.str
+++ b/GeneralsMD/Code/Data/German/Generals.str
@@ -14233,6 +14233,10 @@ GUI:OrderMoveDescription
"Der nächste Klick auf den Boden schickt die ausgewählten Einheiten dorthin. Ziehe stattdessen, und sie verteilen sich entlang der gezogenen Linie."
END
+GUI:SelectionTypeDescription
+"Klicke, um nur diese ausgewählt zu lassen. Mit Umschalt und Klick nimmst du sie aus der Auswahl."
+END
+
GUI:OrderStanceDefensive
"Haltung: Defensiv"
END
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index 6ddd1ca9d..eaf0a8f5a 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -220,6 +220,10 @@ GUI:OrderMoveDescription
"The next click on the ground sends the selected units there. Drag instead and they spread out along the line you draw."
END
+GUI:SelectionTypeDescription
+"Click to keep only these selected. Shift-click to take them out of the selection."
+END
+
GUI:OrderStanceDefensive
"Stance: Defensive"
END
diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.str
index 386c66cf4..0001b88f1 100644
--- a/GeneralsMD/Code/Data/Turkish/Generals.str
+++ b/GeneralsMD/Code/Data/Turkish/Generals.str
@@ -14829,6 +14829,10 @@ GUI:OrderMoveDescription
"Zemine bir sonraki tıklama seçili birlikleri oraya gönderir. Bunun yerine sürüklerseniz birlikler çizdiğiniz çizgi boyunca dizilir."
END
+GUI:SelectionTypeDescription
+"Tıklayın, seçimde yalnızca bunlar kalsın. Shift ile tıklayın, bunlar seçimden çıksın."
+END
+
GUI:OrderStanceDefensive
"Tutum: Savunmacı"
END
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
index b3559b4a6..f9560ffc1 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
@@ -967,6 +967,10 @@ public:
Shift-Tab (-1) walk the focus between them */
void cycleMultiSelectFocus( Int direction );
+ /** a left click at screen (x, y) on one of those type tiles keeps only that type selected, and
+ with shift drops that type from the selection; FALSE when (x, y) is on no tile */
+ Bool clickMultiSelectTile( Int x, Int y );
+
/** how long a half-finished two key press waits for its second key, the powers tray's row and
the promotion screen's marked column */
enum { CHORD_TIMEOUT_MS = 4000 }; ///< real time, not frames: the client frame rate is uncapped
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h b/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h
index 720089c36..6f97d0d87 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h
@@ -83,6 +83,7 @@ public:
//changes the mode of drag selecting to it's opposite
void setDragSelecting(Bool dragSelect);
void setLeftMouseButton(Bool state);
+ Bool isLeftMouseButtonDown( void ) const { return m_leftMouseButtonIsDown; } ///< the left button went down on the world, not on a window
void forgetPendingSquads(); ///< a match is over: what its team keys sent will never land
#if defined(_DEBUG) || defined(_INTERNAL) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index f0c2f1bc9..67da7c0c0 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -5471,6 +5471,11 @@ void ControlBar::setPortraitByImage( const Image *image )
//-------------------------------------------------------------------------------------------------
void ControlBar::setPortraitByObject( Object *obj )
{
+ // a builder standing in for an empty selection lends the bar its buildings and nothing else: its
+ // portrait, name and health beside it read as that worker being selected, so the well stays empty
+ if( obj && m_standInBuilderID != INVALID_DRAWABLE_ID && obj->getDrawable()
+ && obj->getDrawable()->getID() == m_standInBuilderID )
+ obj = NULL;
// the multi-select unit grid lives over this same HUD; a plain portrait means it must
// go, and so must the selection-count badge a one-type selection put on the portrait.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cpp
index 39009a648..b90f02cc8 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cpp
@@ -33,6 +33,7 @@
// USER INCLUDES //////////////////////////////////////////////////////////////////////////////////
#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
+#include "Common/MessageStream.h"
#include "Common/ThingTemplate.h"
#include "Common/Upgrade.h"
#include "GameClient/GameText.h"
@@ -43,6 +44,9 @@
#include "GameClient/GameWindow.h"
#include "GameClient/GameWindowManager.h"
#include "GameClient/InGameUI.h"
+#include "GameClient/Keyboard.h"
+#include "GameClient/Mouse.h"
+#include "GameClient/SelectionXlat.h"
#include "GameLogic/Object.h"
#ifdef _INTERNAL
@@ -225,6 +229,61 @@ static void portraitBarTooltip( GameWindow *window, WinInstanceData *instData, U
TheControlBar->showBuildTooltipLayout( window );
}
+//-------------------------------------------------------------------------------------------------
+/** The right HUD's input. A tile that is not the focused type is disabled to wear its darkened
+ * look, so its clicks land here on the parent and never on the tile; the focused tile ignores
+ * them and they come here too. A press that went down in the world is the selection translator's,
+ * which holds it until some release lets it go, so while it holds one the release here ends a box
+ * dragged onto the HUD and is no click on a tile. Nothing is kept here between a press and its
+ * release, so nothing can go stale. Everything else goes on to the wall the .wnd gave the HUD,
+ * which lets go of that world press. */
+//-------------------------------------------------------------------------------------------------
+static WindowMsgHandledType portraitBarInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 )
+{
+ if( msg == GWM_LEFT_UP && !TheSelectionTranslator->isLeftMouseButtonDown() )
+ {
+ const ICoord2D &mouse = TheMouse->getMouseStatus()->pos;
+ TheControlBar->clickMultiSelectTile( mouse.x, mouse.y );
+ }
+ return GameWinBlockInput( window, msg, mData1, mData2 );
+}
+
+//-------------------------------------------------------------------------------------------------
+/** Takes units out of the selection the way a shift-click on a selected unit in the world does:
+ * MSG_REMOVE_FROM_SELECTED_GROUP for the logic's group and deselectDrawable for the client's.
+ * A plain click removes every other type, shift and a click removes the clicked one. */
+//-------------------------------------------------------------------------------------------------
+Bool ControlBar::clickMultiSelectTile( Int x, Int y )
+{
+ if( m_currContext != CB_CONTEXT_MULTI_SELECT )
+ return FALSE;
+
+ for( Int group = 0; group < m_multiSelectGroupCount && group < (Int)m_multiSelectTiles.size(); group++ )
+ {
+ GameWindow *tile = m_multiSelectTiles[ group ];
+ if( tile == NULL || tile->winIsHidden() || !tile->winPointInWindow( x, y ) )
+ continue;
+
+ const ThingTemplate *clicked = m_multiSelectGroupTemplate[ group ];
+ const Bool dropClicked = TheKeyboard->isShift();
+ // a copy: deselectDrawable takes each one out of the list being walked
+ const DrawableList selected = *TheInGameUI->getAllSelectedDrawables();
+ GameMessage *remove = NULL;
+ for( DrawableListCIt it = selected.begin(); it != selected.end(); ++it )
+ {
+ Drawable *draw = *it;
+ if( ( draw->getTemplate() == clicked ) != dropClicked )
+ continue;
+ if( remove == NULL )
+ remove = TheMessageStream->appendMessage( GameMessage::MSG_REMOVE_FROM_SELECTED_GROUP );
+ remove->appendObjectIDArgument( draw->getObject()->getID() );
+ TheInGameUI->deselectDrawable( draw );
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
//-------------------------------------------------------------------------------------------------
Bool ControlBar::describePortraitBarWindow( GameWindow *window, UnicodeString &name, UnicodeString &description ) const
{
@@ -254,7 +313,7 @@ Bool ControlBar::describePortraitBarWindow( GameWindow *window, UnicodeString &n
continue;
name.format( u"%ls (%d)", m_multiSelectGroupTemplate[ tile ]->getDisplayName().str(), m_multiSelectGroupSize[ tile ] );
- description.clear();
+ description = TheGameText->fetch( "GUI:SelectionTypeDescription" );
return TRUE;
}
return FALSE;
@@ -281,6 +340,9 @@ void ControlBar::layoutMultiSelectTiles( Int count )
Int cellW = hudSize.x / n;
Int cellH = hudSize.y / n;
+ // the tiles' clicks reach the HUD itself, see portraitBarInput
+ m_rightHUDWindow->winSetInputFunc( portraitBarInput );
+
for( Int i = 0; i < count; i++ )
{
if( (Int)m_multiSelectTiles.size() <= i )