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(gameclient): put type-selection on Ctrl+D, twice for the map

Olcay Seygan910949840f3d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4c4bf9511..412533dac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -115,6 +115,7 @@ found and fixed — EA's own, not port damage.**
- Your own right-click orders always win, however much fire is already inbound.
- A reservation lapses within half a second if the shot never arrives.
- Ctrl+Q now takes infantry only, not every armed thing you own.
+- Ctrl+D takes every unit of the kinds you have selected that is on the screen, and pressed twice inside half a second takes them across the whole map. One tank selected and two keystrokes is your whole armour, wherever it is standing. It was on Shift+Ctrl+E, which is three fingers for something you do in every fight, and it only ever reached across the map when the screen had nothing left to give - so the wide selection happened to you instead of being asked for.
## Aircraft, guards, and orders that used to be ignored
diff --git a/GeneralsMD/Code/Data/INI/CommandMap.ini b/GeneralsMD/Code/Data/INI/CommandMap.ini
index 543263b6b..bfff0ef22 100644
--- a/GeneralsMD/Code/Data/INI/CommandMap.ini
+++ b/GeneralsMD/Code/Data/INI/CommandMap.ini
@@ -257,16 +257,29 @@ CommandMap SELECT_ALL
DisplayName = GUI:SelectAll
End
+; Ctrl+D takes every unit of the selected types on the screen; pressed twice
+; inside half a second it takes them across the whole map. D sits under the
+; same hand as the category keys above and next to nothing else in this list.
CommandMap SELECT_MATCHING_UNITS
- Key = KEY_E
+ Key = KEY_D
Transition = DOWN
- Modifiers = SHIFT_CTRL
+ Modifiers = CTRL
UseableIn = GAME
Category = SELECTION
Description = GUI:TypeSelectDescription
DisplayName = GUI:TypeSelect
End
+; The retail map puts a debug command on Ctrl+D - dead in a release build, but
+; the meta map answers with the first record that matches a key, and that one
+; comes first. Moved out of the way rather than left to swallow the keystroke.
+CommandMap DEMO_DEBUG_SELECTION
+ Key = KEY_D
+ Transition = DOWN
+ Modifiers = SHIFT_ALT_CTRL
+ UseableIn = GAME
+End
+
CommandMap SCATTER
Key = KEY_X
Transition = DOWN
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index b0db9998e..c5cedb9ba 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -2431,8 +2431,25 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
//-----------------------------------------------------------------------------------------
case GameMessage::MSG_META_SELECT_MATCHING_UNITS:
{
+ //
+ // One press takes every unit of the selected types that is on the screen; pressed twice
+ // it takes them across the whole map. The same shape the category keys have - one press
+ // for what you can see, a second for everything you own - and it is a shape you can lean
+ // on: the wide selection is a decision, not something that happens to you because the
+ // screen happened to hold nothing new.
+ //
+ enum { SELECT_MATCHING_AGAIN_MS = 500 }; ///< real time: the client frame rate is uncapped
+ static UnsignedInt s_lastMatchingMs = 0;
- TheInGameUI->selectUnitsMatchingCurrentSelection();
+ const UnsignedInt now = timeGetTime();
+ const Bool again = ( s_lastMatchingMs != 0
+ && now - s_lastMatchingMs <= SELECT_MATCHING_AGAIN_MS );
+ s_lastMatchingMs = now;
+
+ if( again )
+ TheInGameUI->selectMatchingAcrossMap();
+ else
+ TheInGameUI->selectUnitsMatchingCurrentSelection();
disp = DESTROY_MESSAGE;
break;