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): idle hotkeys by unit kind and select all idle

Olcay Seygan6e0844ef4683
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aab90d8d8..c291e0bda 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -66,7 +66,7 @@ found and fixed — EA's own, not port damage.**
- The dark plate behind Exit, Restart and the options screen in a match covers the whole picture. It used to sit in a 4:3 frame in the middle, so a widescreen left the battlefield bright down both sides. The box itself keeps the shape it was drawn in.
- Buildings select together again, which the one interface had taken away. Shift-click them, drag a box over them, or double-click one for every building of its kind on the screen; select four War Factories and each tank you click goes to whichever has the shortest queue. Double-click a unit and every one of that kind whose feet sit in the picture is taken, including the ones sitting past the camera's far clip that used to be skipped. A building and a unit still never share a selection.
- Formation lines are back for everyone. With move, attack move or guard armed, a left drag spreads the selection along the line you draw again; since the one interface it drew a selection box instead, because the line was switched off for the Classic mouse that every player now runs. A drag with no order armed is still the selection box.
-- Every key is yours to move. The launcher's Hotkeys page draws the command bar of every building and unit each general can field, cameos and letters as the game shows them, and a click and a keypress gives any button a new letter or none. Two buttons on one bar that would share a letter are marked before you play. The keyboard commands are there too, from bookmarks and team keys to the camera, along with the ones Zero Hour never bound: select every fighting unit, vehicle or aircraft, every barracks, war factory or airfield, the next idle worker or unit, pause, the general's promotions, the three signals to your allies and the general's powers. Your keys are yours alone; the other players in a match keep theirs, and a match never refuses you for them. Every mod you install brings its own generals to the page, ShockWave's fifteen next to Zero Hour's thirteen, and a key you give a ShockWave button stays with ShockWave.
+- Every key is yours to move. The launcher's Hotkeys page draws the command bar of every building and unit each general can field, cameos and letters as the game shows them, and a click and a keypress gives any button a new letter or none. Two buttons on one bar that would share a letter are marked before you play. The keyboard commands are there too, from bookmarks and team keys to the camera, along with the ones Zero Hour never bound: select all your infantry, vehicles or aircraft, every barracks, war factory or airfield, the next idle worker or unit, pause, the general's promotions, the three signals to your allies and the general's powers. Your keys are yours alone; the other players in a match keep theirs, and a match never refuses you for them. Every mod you install brings its own generals to the page, ShockWave's fifteen next to Zero Hour's thirteen, and a key you give a ShockWave button stays with ShockWave.
- Some keys now mean one thing on every bar: A attack move, S stop, G guard, Y rally point, V evacuate, N sell, C combat drop, and H for land mines, camo netting and the GLA worker's switch to fake buildings. Sell sits on its own key, so emptying a bunker can never sell it. The 188 buttons Zero Hour had put on one of those letters take another, kept off the 18 letters under your left hand where the bar leaves room (the Avenger is J now), and no bar gained a clash doing it. Those letters are still yours to hand out: the Hotkeys page gives A or H to any other button you pick, and marks the clash. On a bar that has the order as well, the order keeps its key: a Barracks button on A fires from A, and a tank's A is still attack move.
- The Hotkeys page is in the game as well, as the last tab of the options screen, so a key can move without quitting to the launcher: from the main menu, or from Esc in the middle of a match. Every command sits on the left with its key. On the right you pick a general and one of his buildings or units, and its command bar is listed button by button, each with its cameo and its letter. Double-click a line, or press Enter or Change, and then the key; Esc lets go. Two buttons of one bar on one letter, or two commands on one key, turn red, and the line under the lists names them. Accept writes the file the launcher writes, so a key set in either place is there in the other, and a key changed in a match works from the next press.
- Export and Import on the Hotkeys page take your keys to a file and back, for another PC or a fresh install. Before an import the page tells you how many keys it changes and how many would clash; a file with a line it cannot read changes nothing and quotes that line. Keys for a mod you have not installed come along and wait for it.
@@ -359,7 +359,7 @@ found and fixed — EA's own, not port damage.**
## Selecting and ordering with the mouse
-- Ctrl+Q now takes infantry only, not every armed thing you own.
+- The key that took every armed thing you own takes infantry only now, and the Hotkeys page calls it Select all infantry.
- A box drawn with Ctrl held takes those units back out of your selection instead of replacing it, so a group is trimmed by dragging over the corner of it rather than picked again from scratch. Held with Alt the box keeps only what can shoot: drag across your base and you get the tanks, not the dozers and supply trucks standing among them. Both are drag-only, and a single click still means exactly what it always did. Hold Ctrl and Shift and drag and you draw a freehand attack line, red like the circle, and on release the enemies near it are shared out as targets. Ctrl alone still draws the fire circle. Shift alone and a drag draws the move line V draws, as long as something you have selected can walk it; with nothing like that selected, Shift and a drag is still the box that adds to your selection, and a Shift click still adds one unit. Pressing Shift used to let go of the Ctrl hold, so the pointer turned back into the ordinary one and the drag grew a selection box instead.
- A box dragged over your army and your economy together takes the army. The dozers, workers, supply trucks and hackers standing among the tanks stay where they are, and ambulances and troop carriers go with the soldiers they look after. A box with nobody military in it takes the workers the way it always did.
- The three buttons are split cleanly now. Left selects, and only selects. A right click gives the order, and a right drag scrolls the map the way it did in 2003: the spot you pressed on stays put, and the further you pull away from it the faster the map runs. The drag only starts once the pointer has really travelled, so a click your hand wobbles a pixel or two is still an order and the camera does not twitch. A pan never throws away the building on your cursor or the power you were about to aim. The middle button turns the view, with no key held, and a middle click without a drag puts the camera back where it started. The wheel zooms toward whatever the cursor is over and the screen edges still scroll. The classic scheme, where left both selected and commanded and right scrolled and deselected, is gone rather than switched off, and the two checkboxes that used to choose between them are out of the options screen.
@@ -379,7 +379,8 @@ found and fixed — EA's own, not port damage.**
- Attack move stays armed for as long as shift is down, whether you pressed its key or clicked its button on the bar, so every point you queue is an attack move. Orders given on the minimap are the orders they would be on the battlefield: an armed attack move is an attack move there too, and shift adds to the queue. Passing the pointer over the minimap no longer puts an armed attack move down.
- What the circle picks up is what you can see, and a stealthed unit is not that. Shroud was the only test, so a hidden tank parked in ground you had already cleared went on the list like anything else: drag a circle over open country and the group opened fire on air, one order per hidden unit, which is a stealth detector drawn with the mouse. An undetected unit is not in the circle.
- 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.
-- U takes you to the next combat unit standing with no orders: it is selected and the view centres on it. Press again for the one after. Idle workers stay on I.
+- Next idle unit selects the next combat unit standing with no orders, and the camera stays where you had it, so you can give it an order on the minimap without leaving the fight in front of you. Press again for the one after. It starts without a key; set one on the Hotkeys page. The idle worker key, I, no longer moves the camera either, while the idle worker button on the bar still takes you to the worker.
+- That key comes in one per arm as well, so finding the jet that landed and sat down no longer means paging past every idle tank first. Select all idle units takes every combat unit standing with no orders on the screen without moving the view, or across the whole map when the screen has none, and pressed twice inside half a second it takes the whole map anyway. An aircraft-only and a vehicles-only version sit beside it. All of them start without a key.
- Shift and a number puts what you have selected into that control group and keeps everyone already in it, the way StarCraft does it. Fresh tanks off the line join group 1 with one key, where you used to select group 1, shift-click the new tanks in and press Ctrl+1 again. The selection stays as it is. Retail used Shift and a number to pull a group into your selection instead; that is gone, and Alt and the number still centres the view on the group.
- Ordering a very large army works. A selection of more than 254 units reaches the game whole, and Ctrl+number groups keep all their units.
- Hold Alt and drag with the middle mouse button, or hold Alt and turn the wheel, to tilt the camera between 20 and 60 degrees. Home resets heading, tilt and zoom, the way Numpad 5 does.
diff --git a/GeneralsMD/Code/Data/German/Generals.str b/GeneralsMD/Code/Data/German/Generals.str
index c0f4451c1..af2705948 100644
--- a/GeneralsMD/Code/Data/German/Generals.str
+++ b/GeneralsMD/Code/Data/German/Generals.str
@@ -15202,7 +15202,7 @@ GUI:HotkeysCommandSELECT_ALL
END
GUI:HotkeysCommandSELECT_ALL_MILITARY
-"Alle Kampfeinheiten auswählen"
+"Alle Infanteristen auswählen"
END
GUI:HotkeysCommandSELECT_ALL_VEHICLES
@@ -15233,6 +15233,30 @@ GUI:HotkeysCommandSELECT_NEXT_IDLE_UNIT
"Nächste untätige Einheit"
END
+GUI:HotkeysCommandSELECT_NEXT_IDLE_AIRCRAFT
+"Nächstes untätiges Flugzeug"
+END
+
+GUI:HotkeysCommandSELECT_NEXT_IDLE_VEHICLE
+"Nächstes untätiges Fahrzeug"
+END
+
+GUI:HotkeysCommandSELECT_NEXT_IDLE_INFANTRY
+"Nächster untätiger Infanterist"
+END
+
+GUI:HotkeysCommandSELECT_ALL_IDLE_UNITS
+"Alle untätigen Einheiten auswählen"
+END
+
+GUI:HotkeysCommandSELECT_ALL_IDLE_AIRCRAFT
+"Alle untätigen Flugzeuge auswählen"
+END
+
+GUI:HotkeysCommandSELECT_ALL_IDLE_VEHICLES
+"Alle untätigen Fahrzeuge auswählen"
+END
+
GUI:HotkeysCommandTOGGLE_PAUSE
"Pause (Einzelspieler und Replays)"
END
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index 8bc1ecb0f..d88b15920 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -1557,7 +1557,7 @@ GUI:HotkeysCommandSELECT_ALL
END
GUI:HotkeysCommandSELECT_ALL_MILITARY
-"Select all fighting units"
+"Select all infantry"
END
GUI:HotkeysCommandSELECT_ALL_VEHICLES
@@ -1588,6 +1588,30 @@ GUI:HotkeysCommandSELECT_NEXT_IDLE_UNIT
"Next idle unit"
END
+GUI:HotkeysCommandSELECT_NEXT_IDLE_AIRCRAFT
+"Next idle aircraft"
+END
+
+GUI:HotkeysCommandSELECT_NEXT_IDLE_VEHICLE
+"Next idle vehicle"
+END
+
+GUI:HotkeysCommandSELECT_NEXT_IDLE_INFANTRY
+"Next idle infantry"
+END
+
+GUI:HotkeysCommandSELECT_ALL_IDLE_UNITS
+"Select all idle units"
+END
+
+GUI:HotkeysCommandSELECT_ALL_IDLE_AIRCRAFT
+"Select all idle aircraft"
+END
+
+GUI:HotkeysCommandSELECT_ALL_IDLE_VEHICLES
+"Select all idle vehicles"
+END
+
GUI:HotkeysCommandTOGGLE_PAUSE
"Pause (single player and replays)"
END
diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.str
index 867e0ee6c..5c661dd25 100644
--- a/GeneralsMD/Code/Data/Turkish/Generals.str
+++ b/GeneralsMD/Code/Data/Turkish/Generals.str
@@ -15954,7 +15954,7 @@ GUI:HotkeysCommandSELECT_ALL
END
GUI:HotkeysCommandSELECT_ALL_MILITARY
-"Bütün savaşan birlikleri seç"
+"Bütün piyadeleri seç"
END
GUI:HotkeysCommandSELECT_ALL_VEHICLES
@@ -15985,6 +15985,30 @@ GUI:HotkeysCommandSELECT_NEXT_IDLE_UNIT
"Sıradaki boştaki birlik"
END
+GUI:HotkeysCommandSELECT_NEXT_IDLE_AIRCRAFT
+"Sıradaki boştaki hava aracı"
+END
+
+GUI:HotkeysCommandSELECT_NEXT_IDLE_VEHICLE
+"Sıradaki boştaki araç"
+END
+
+GUI:HotkeysCommandSELECT_NEXT_IDLE_INFANTRY
+"Sıradaki boştaki piyade"
+END
+
+GUI:HotkeysCommandSELECT_ALL_IDLE_UNITS
+"Bütün boştaki birlikleri seç"
+END
+
+GUI:HotkeysCommandSELECT_ALL_IDLE_AIRCRAFT
+"Bütün boştaki hava araçlarını seç"
+END
+
+GUI:HotkeysCommandSELECT_ALL_IDLE_VEHICLES
+"Bütün boştaki araçları seç"
+END
+
GUI:HotkeysCommandTOGGLE_PAUSE
"Duraklat (tek oyunculu ve tekrarlar)"
END
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
index 271dd6ec6..eac06c73e 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
@@ -231,6 +231,9 @@ public:
MSG_META_SELECT_PREV_WORKER, ///< select 'prev' worker
MSG_META_SELECT_NEXT_IDLE_WORKER, ///< select 'next' idle worker
MSG_META_SELECT_NEXT_IDLE_UNIT, ///< select 'next' fighting unit standing with no order
+ MSG_META_SELECT_NEXT_IDLE_AIRCRAFT, ///< the same cycle over aircraft only
+ MSG_META_SELECT_NEXT_IDLE_VEHICLE, ///< the same cycle over ground vehicles only
+ MSG_META_SELECT_NEXT_IDLE_INFANTRY, ///< the same cycle over infantry only
// command-bar grid hot keys: one per place of the 6 x 3 command grid, read along the rows
// (01-06 the top row, 07-12 the middle one, 13-18 the bottom); see CommandPlace
@@ -268,11 +271,14 @@ public:
MSG_META_SELECT_HERO, ///< selects player's hero character, if exists...
MSG_META_SELECT_ALL, ///< selects all units across screen
MSG_META_SELECT_ALL_AIRCRAFT, ///< selects all air units just like select all
- MSG_META_SELECT_ALL_MILITARY, ///< selects foot soldiers (KINDOF_INFANTRY), screen first then map (Ctrl+Q)
+ MSG_META_SELECT_ALL_MILITARY, ///< selects infantry (KINDOF_INFANTRY), screen first then map
MSG_META_SELECT_ALL_VEHICLES, ///< selects ground vehicles (no dozers / harvesters), screen first then map (Ctrl+Q/W/Z/X/C)
MSG_META_SELECT_ALL_BARRACKS, ///< selects barracks, screen first then map (Ctrl+Q/W/Z/X/C)
MSG_META_SELECT_ALL_WARFACTORIES, ///< selects war factories, screen first then map (Ctrl+Q/W/Z/X/C)
MSG_META_SELECT_ALL_AIRFIELDS, ///< selects airfields, screen first then map (Ctrl+Q/W/Z/X/C)
+ MSG_META_SELECT_ALL_IDLE_UNITS, ///< selects fighting units standing with no order, screen first, pressed twice across the map
+ MSG_META_SELECT_ALL_IDLE_AIRCRAFT, ///< the same for idle aircraft
+ MSG_META_SELECT_ALL_IDLE_VEHICLES, ///< the same for idle ground vehicles
MSG_META_SCATTER, ///< selected units scatter
MSG_META_STOP, ///< selected units stop
MSG_META_DEPLOY, ///< selected units 'deploy'
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index d36d4db24..b3cda1099 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -1068,9 +1068,9 @@ public: // ********************************************************************
virtual Int selectMatchingAcrossRegion( IRegion2D *region ); // -1 = no locally-owned selection, 0+ = # of units selected
virtual Int selectAllUnitsByType(KindOfMaskType mustBeSet, KindOfMaskType mustBeClear);
- virtual Int selectAllUnitsByTypeAcrossScreen(KindOfMaskType mustBeSet, KindOfMaskType mustBeClear);
- virtual Int selectAllUnitsByTypeAcrossMap(KindOfMaskType mustBeSet, KindOfMaskType mustBeClear);
- virtual Int selectAllUnitsByTypeAcrossRegion( IRegion2D *region, KindOfMaskType mustBeSet, KindOfMaskType mustBeClear );
+ virtual Int selectAllUnitsByTypeAcrossScreen(KindOfMaskType mustBeSet, KindOfMaskType mustBeClear, Bool idleOnly);
+ virtual Int selectAllUnitsByTypeAcrossMap(KindOfMaskType mustBeSet, KindOfMaskType mustBeClear, Bool idleOnly);
+ virtual Int selectAllUnitsByTypeAcrossRegion( IRegion2D *region, KindOfMaskType mustBeSet, KindOfMaskType mustBeClear, Bool idleOnly ); ///< idleOnly: only isIdleCombatUnit
virtual void buildRegion( const ICoord2D *anchor, const ICoord2D *dest, IRegion2D *region ); ///< builds a region around the specified coordinates
@@ -1163,8 +1163,9 @@ public: // ********************************************************************
virtual void addIdleWorker( Object *obj );
virtual void removeIdleWorker( Object *obj, Int playerNumber );
- virtual void selectNextIdleWorker( void );
- void selectNextIdleUnit( void ); ///< the same cycle for fighting units standing with no order
+ virtual Object *selectNextIdleWorker( void ); ///< what it selected, NULL with no idle worker; never moves the camera
+ void selectNextIdleUnit( KindOfMaskType mustBeSet, KindOfMaskType mustBeClear ); ///< the same cycle for fighting units of those kinds standing with no order
+ static Bool isIdleCombatUnit( const Object *obj ); ///< the local player's fighting unit standing with no order
virtual void recreateControlBar( void );
virtual void notifyResolutionChange( void );
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
index 78d2204dc..fac5d1e9e 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
@@ -307,6 +307,9 @@ AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)
CHECK_IF(MSG_META_SELECT_PREV_WORKER)
CHECK_IF(MSG_META_SELECT_NEXT_IDLE_WORKER)
CHECK_IF(MSG_META_SELECT_NEXT_IDLE_UNIT)
+ CHECK_IF(MSG_META_SELECT_NEXT_IDLE_AIRCRAFT)
+ CHECK_IF(MSG_META_SELECT_NEXT_IDLE_VEHICLE)
+ CHECK_IF(MSG_META_SELECT_NEXT_IDLE_INFANTRY)
CHECK_IF(MSG_META_COMMAND_SLOT01)
CHECK_IF(MSG_META_COMMAND_SLOT02)
CHECK_IF(MSG_META_COMMAND_SLOT03)
@@ -346,6 +349,9 @@ AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)
CHECK_IF(MSG_META_SELECT_ALL_BARRACKS)
CHECK_IF(MSG_META_SELECT_ALL_WARFACTORIES)
CHECK_IF(MSG_META_SELECT_ALL_AIRFIELDS)
+ CHECK_IF(MSG_META_SELECT_ALL_IDLE_UNITS)
+ CHECK_IF(MSG_META_SELECT_ALL_IDLE_AIRCRAFT)
+ CHECK_IF(MSG_META_SELECT_ALL_IDLE_VEHICLES)
CHECK_IF(MSG_META_SCATTER)
CHECK_IF(MSG_META_STOP)
CHECK_IF(MSG_META_DEPLOY)
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp
index 1a3415b81..be4bf5837 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp
@@ -480,7 +480,9 @@ WindowMsgHandledType ControlBarSystem( GameWindow *window, UnsignedInt msg,
else if( controlID == buttonIdleWorker)
{
HideQuitMenu( );
- TheInGameUI->selectNextIdleWorker();
+ Object *worker = TheInGameUI->selectNextIdleWorker();
+ if( worker ) // every worker busy: nothing was selected
+ TheTacticalView->lookAt( worker->getPosition() );
}
else
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index e6a288be0..994db4400 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -229,6 +229,7 @@ struct KindOfSelectionData
{
KindOfMaskType m_mustbeSet;
KindOfMaskType m_mustbeClear;
+ Bool m_idleOnly;
DrawableList newlySelectedDrawables;
};
@@ -245,7 +246,8 @@ static Bool kindOfUnitSelection( Drawable *test, void *userData )
if (!object)
return FALSE;
- Bool isKindOfMatch = object->isKindOfMulti(data->m_mustbeSet, data->m_mustbeClear);
+ Bool isKindOfMatch = object->isKindOfMulti(data->m_mustbeSet, data->m_mustbeClear)
+ && ( !data->m_idleOnly || InGameUI::isIdleCombatUnit( object ) );
// only select objects if not already selected
if( object && isKindOfMatch
@@ -7405,7 +7407,7 @@ Bool InGameUI::canSelectedObjectsEffectivelyUseWeapon( const CommandButton *comm
}
// ------------------------------------------------------------------------------------------------
-Int InGameUI::selectAllUnitsByTypeAcrossRegion( IRegion2D *region, KindOfMaskType mustBeSet, KindOfMaskType mustBeClear )
+Int InGameUI::selectAllUnitsByTypeAcrossRegion( IRegion2D *region, KindOfMaskType mustBeSet, KindOfMaskType mustBeClear, Bool idleOnly )
{
KindOfSelectionData data;
Int newSelectionCount = 0;
@@ -7413,6 +7415,7 @@ Int InGameUI::selectAllUnitsByTypeAcrossRegion( IRegion2D *region, KindOfMaskTyp
data.m_mustbeSet = mustBeSet;
data.m_mustbeClear = mustBeClear;
+ data.m_idleOnly = idleOnly;
if (region)
{
@@ -7545,7 +7548,7 @@ Int InGameUI::selectMatchingAcrossRegion( IRegion2D *region )
}
// ------------------------------------------------------------------------------------------------
-Int InGameUI::selectAllUnitsByTypeAcrossScreen(KindOfMaskType mustBeSet, KindOfMaskType mustBeClear)
+Int InGameUI::selectAllUnitsByTypeAcrossScreen(KindOfMaskType mustBeSet, KindOfMaskType mustBeClear, Bool idleOnly)
{
/// When implementing this, obey TheInGameUI->getMaxSelectCount() if it is > 0
@@ -7559,7 +7562,7 @@ Int InGameUI::selectAllUnitsByTypeAcrossScreen(KindOfMaskType mustBeSet, KindOfM
buildRegion( &origin, &size, &region );
- Int numSelected = selectAllUnitsByTypeAcrossRegion(&region, mustBeSet, mustBeClear);
+ Int numSelected = selectAllUnitsByTypeAcrossRegion(&region, mustBeSet, mustBeClear, idleOnly);
if (numSelected == -1)
{
UnicodeString message = TheGameText->fetch( "GUI:NothingSelected" );
@@ -7611,10 +7614,10 @@ Int InGameUI::selectMatchingAcrossScreen( void )
}
//-------------------------------------------------------------------------------------------------
-Int InGameUI::selectAllUnitsByTypeAcrossMap(KindOfMaskType mustBeSet, KindOfMaskType mustBeClear)
+Int InGameUI::selectAllUnitsByTypeAcrossMap(KindOfMaskType mustBeSet, KindOfMaskType mustBeClear, Bool idleOnly)
{
/// When implementing this, obey TheInGameUI->getMaxSelectCount() if it is > 0
- Int numSelected = selectAllUnitsByTypeAcrossRegion(NULL, mustBeSet, mustBeClear);
+ Int numSelected = selectAllUnitsByTypeAcrossRegion(NULL, mustBeSet, mustBeClear, idleOnly);
if (numSelected == -1)
{
UnicodeString message = TheGameText->fetch( "GUI:NothingSelected" );
@@ -7670,7 +7673,7 @@ Int InGameUI::selectMatchingAcrossMap()
Int InGameUI::selectAllUnitsByType(KindOfMaskType mustBeSet, KindOfMaskType mustBeClear)
{
/// When implementing this, obey TheInGameUI->getMaxSelectCount() if it is > 0
- Int numSelected = selectAllUnitsByTypeAcrossScreen(mustBeSet, mustBeClear);
+ Int numSelected = selectAllUnitsByTypeAcrossScreen(mustBeSet, mustBeClear, FALSE);
if (numSelected == -1)
{
return numSelected;
@@ -7678,7 +7681,7 @@ Int InGameUI::selectAllUnitsByType(KindOfMaskType mustBeSet, KindOfMaskType must
if (numSelected == 0)
{
- Int numSelectedAcrossMap = selectAllUnitsByTypeAcrossMap(mustBeSet, mustBeClear);
+ Int numSelectedAcrossMap = selectAllUnitsByTypeAcrossMap(mustBeSet, mustBeClear, FALSE);
return numSelectedAcrossMap;
}
return numSelected;
@@ -10098,13 +10101,14 @@ void InGameUI::removeIdleWorker( Object *obj, Int playerNumber )
return;
}
-void InGameUI::selectNextIdleWorker( void )
+// The camera stays put; the idle worker buttons look at what this returns, the hotkey does not.
+Object *InGameUI::selectNextIdleWorker( void )
{
Int index = ThePlayerList->getLocalPlayer()->getPlayerIndex();
if(m_idleWorkers[index].empty())
{
DEBUG_ASSERTCRASH(FALSE, ("InGameUI::selectNextIdleWorker We're trying to select a worker when our list is empty for player %s", WideCharAsUtf8( ThePlayerList->getLocalPlayer()->getPlayerDisplayName().str() ).str()));
- return;
+ return NULL;
}
Object *selectThisObject = NULL;
@@ -10165,15 +10169,13 @@ void InGameUI::selectNextIdleWorker( void )
{
TheAudio->addAudioEvent( soundEvent );
}*/
-
- // center on the unit
- TheTacticalView->lookAt(selectThisObject->getPosition());
}
+ return selectThisObject;
}
// A unit of the local player's that is standing on the field with no order: not a dozer, a worker
// or a supply truck (those have the idle-worker key), not a structure, not riding in anything.
-static Bool isIdleCombatUnit( const Object *obj )
+Bool InGameUI::isIdleCombatUnit( const Object *obj )
{
if( !obj->isLocallyControlled() || obj->isEffectivelyDead() || obj->isContained() || !obj->isMobile() )
return FALSE;
@@ -10189,7 +10191,7 @@ static Bool isIdleCombatUnit( const Object *obj )
return ai && ai->isIdle();
}
-void InGameUI::selectNextIdleUnit( void )
+void InGameUI::selectNextIdleUnit( KindOfMaskType mustBeSet, KindOfMaskType mustBeClear )
{
// Nothing keeps a list of these the way the dozers keep m_idleWorkers, so the key walks the
// object list, which is in creation order and stays put between presses. A lone selected unit
@@ -10201,7 +10203,7 @@ void InGameUI::selectNextIdleUnit( void )
for( Object *obj = TheGameLogic->getFirstObject(); obj; obj = obj->getNextObject() )
{
- if( isIdleCombatUnit( obj ) )
+ if( isIdleCombatUnit( obj ) && obj->isKindOfMulti( mustBeSet, mustBeClear ) )
{
if( passedCurrent )
{
@@ -10228,10 +10230,8 @@ void InGameUI::selectNextIdleUnit( void )
teamMsg->appendBooleanArgument( TRUE );
teamMsg->appendObjectIDArgument( selectThisObject->getID() );
+ // the camera stays where the player has it
selectDrawable( selectThisObject->getDrawable() );
-
- // center on the unit
- TheTacticalView->lookAt(selectThisObject->getPosition());
}
Int InGameUI::getIdleWorkerCount( void )
@@ -10433,7 +10433,9 @@ WindowMsgHandledType IdleWorkerSystem( GameWindow *window, UnsignedInt msg,
static NameKeyType buttonSelectID = NAMEKEY( "IdleWorker.wnd:ButtonSelectNextIdleWorker" );
if (control && control->winGetWindowId() == buttonSelectID)
{
- TheInGameUI->selectNextIdleWorker( );
+ Object *worker = TheInGameUI->selectNextIdleWorker( );
+ if( worker ) // every worker busy: nothing was selected
+ TheTacticalView->lookAt( worker->getPosition() );
}
break;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index 53f6e707b..e0b1fc172 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -2897,8 +2897,26 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
} // end select next idle worker
case GameMessage::MSG_META_SELECT_NEXT_IDLE_UNIT:
- {
- TheInGameUI->selectNextIdleUnit();
+ case GameMessage::MSG_META_SELECT_NEXT_IDLE_AIRCRAFT:
+ case GameMessage::MSG_META_SELECT_NEXT_IDLE_VEHICLE:
+ case GameMessage::MSG_META_SELECT_NEXT_IDLE_INFANTRY:
+ {
+ // isIdleCombatUnit narrowed by kind; vehicles are ground vehicles only, as for the
+ // select-all vehicles key. The cycle keeps its own filter: no IGNORES_SELECT_ALL,
+ // mass-selectable or off-map test.
+ KindOfMaskType mustBeSet;
+ KindOfMaskType mustBeClear;
+ if( t == GameMessage::MSG_META_SELECT_NEXT_IDLE_AIRCRAFT )
+ mustBeSet.set( KINDOF_AIRCRAFT );
+ else if( t == GameMessage::MSG_META_SELECT_NEXT_IDLE_VEHICLE )
+ {
+ mustBeSet.set( KINDOF_VEHICLE );
+ mustBeClear.set( KINDOF_AIRCRAFT );
+ }
+ else if( t == GameMessage::MSG_META_SELECT_NEXT_IDLE_INFANTRY )
+ mustBeSet.set( KINDOF_INFANTRY );
+
+ TheInGameUI->selectNextIdleUnit( mustBeSet, mustBeClear );
disp = DESTROY_MESSAGE;
break;
@@ -3244,9 +3262,18 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
case GameMessage::MSG_META_SELECT_ALL_BARRACKS:
case GameMessage::MSG_META_SELECT_ALL_WARFACTORIES:
case GameMessage::MSG_META_SELECT_ALL_AIRFIELDS:
+ case GameMessage::MSG_META_SELECT_ALL_IDLE_UNITS:
+ case GameMessage::MSG_META_SELECT_ALL_IDLE_AIRCRAFT:
+ case GameMessage::MSG_META_SELECT_ALL_IDLE_VEHICLES:
{
// one category per key; selectAllUnitsByType takes the screen first and the
- // whole map when the screen has nothing new left, so a second press widens
+ // whole map when the screen has nothing new left, so a second press widens.
+ // The idle keys take only units standing with no order, the screen first; pressed
+ // twice inside half a second they take the whole map, the way SELECT_MATCHING_UNITS
+ // does.
+ const Bool idleOnly = t == GameMessage::MSG_META_SELECT_ALL_IDLE_UNITS
+ || t == GameMessage::MSG_META_SELECT_ALL_IDLE_AIRCRAFT
+ || t == GameMessage::MSG_META_SELECT_ALL_IDLE_VEHICLES;
KindOfMaskType requiredKindofs;
KindOfMaskType disqualifyingKindofs;
disqualifyingKindofs.set(KINDOF_IGNORES_SELECT_ALL);
@@ -3260,21 +3287,19 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
disqualifyingKindofs.set(KINDOF_DOZER);
disqualifyingKindofs.set(KINDOF_HARVESTER);
disqualifyingKindofs.set(KINDOF_STRUCTURE);
- if( t == GameMessage::MSG_META_SELECT_ALL_AIRCRAFT )
+ if( t == GameMessage::MSG_META_SELECT_ALL_AIRCRAFT || t == GameMessage::MSG_META_SELECT_ALL_IDLE_AIRCRAFT )
requiredKindofs.set(KINDOF_AIRCRAFT);
else if( t == GameMessage::MSG_META_SELECT_ALL_MILITARY )
{
//
- // Q W E under the left hand is infantry / vehicles / aircraft - one key per
- // arm, so each one narrows the selection to something you can give a single
- // order to. This used to be KINDOF_CAN_ATTACK, which is every armed unit
- // there is: it swept up the tanks and the aircraft the other two keys are
- // for and left no way to grab the foot soldiers on their own. Ctrl+A is
- // still there for everything at once.
+ // Infantry only. This used to be KINDOF_CAN_ATTACK, which is every armed
+ // unit there is: it swept up the tanks and the aircraft the vehicle and
+ // aircraft keys are for and left no way to grab the foot soldiers on their
+ // own. SELECT_ALL is still there for everything at once.
//
requiredKindofs.set(KINDOF_INFANTRY);
}
- else if( t == GameMessage::MSG_META_SELECT_ALL_VEHICLES )
+ else if( t == GameMessage::MSG_META_SELECT_ALL_VEHICLES || t == GameMessage::MSG_META_SELECT_ALL_IDLE_VEHICLES )
{
requiredKindofs.set(KINDOF_VEHICLE);
disqualifyingKindofs.set(KINDOF_AIRCRAFT);
@@ -3288,14 +3313,31 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
const DrawableList *drawList = TheInGameUI->getAllSelectedDrawables();
for( DrawableListCIt it = drawList->begin(); it != drawList->end(); ++it )
{
- if( !(*it)->isKindOfMulti( requiredKindofs, disqualifyingKindofs ) )
+ if( !(*it)->isKindOfMulti( requiredKindofs, disqualifyingKindofs )
+ || ( idleOnly && !InGameUI::isIdleCombatUnit( (*it)->getObject() ) ) )
{
TheInGameUI->deselectAllDrawables();
break;
}
}
- TheInGameUI->selectAllUnitsByType(requiredKindofs, disqualifyingKindofs);
+ if( idleOnly )
+ {
+ enum { SELECT_IDLE_AGAIN_MS = 500 }; ///< real time: the client frame rate is uncapped
+ static UnsignedInt s_lastIdleMs = 0;
+ static GameMessage::Type s_lastIdleType = GameMessage::MSG_INVALID;
+
+ const UnsignedInt now = Clock_Milliseconds();
+ const Bool again = ( s_lastIdleType == t && now - s_lastIdleMs <= SELECT_IDLE_AGAIN_MS );
+ s_lastIdleMs = now;
+ s_lastIdleType = t;
+
+ // a screen with none of them on it widens in the same press, as selectAllUnitsByType does
+ if( again || TheInGameUI->selectAllUnitsByTypeAcrossScreen(requiredKindofs, disqualifyingKindofs, TRUE) == 0 )
+ TheInGameUI->selectAllUnitsByTypeAcrossMap(requiredKindofs, disqualifyingKindofs, TRUE);
+ }
+ else
+ TheInGameUI->selectAllUnitsByType(requiredKindofs, disqualifyingKindofs);
disp = DESTROY_MESSAGE;
break;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp
index 18ada4f1b..c814ad41e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp
@@ -758,7 +758,9 @@ std::vector< HotkeyCommandRow > Hotkeys_commandRows( const std::string& commandM
// UNBOUND_COMMANDS in hotkeys.js: commands the engine knows that the shipped map binds to nothing
std::vector< HotkeyCommandRow > unbound;
static const char *const SELECTION[] = { "SELECT_ALL", "SELECT_ALL_MILITARY", "SELECT_ALL_VEHICLES", "SELECT_ALL_AIRCRAFT",
- "SELECT_ALL_BARRACKS", "SELECT_ALL_WARFACTORIES", "SELECT_ALL_AIRFIELDS", "SELECT_NEXT_IDLE_WORKER", "SELECT_NEXT_IDLE_UNIT" };
+ "SELECT_ALL_BARRACKS", "SELECT_ALL_WARFACTORIES", "SELECT_ALL_AIRFIELDS", "SELECT_NEXT_IDLE_WORKER", "SELECT_NEXT_IDLE_UNIT",
+ "SELECT_NEXT_IDLE_AIRCRAFT", "SELECT_NEXT_IDLE_VEHICLE", "SELECT_NEXT_IDLE_INFANTRY", "SELECT_ALL_IDLE_UNITS",
+ "SELECT_ALL_IDLE_AIRCRAFT", "SELECT_ALL_IDLE_VEHICLES" };
for( size_t each = 0; each < sizeof( SELECTION ) / sizeof( SELECTION[ 0 ] ); each++ )
unbound.push_back( commandRow( SELECTION[ each ], "SELECTION" ) );
unbound.push_back( commandRow( "TOGGLE_PAUSE", "INTERFACE" ) );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
index ad977328e..76668021b 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
@@ -142,6 +142,9 @@ static const LookupListRec GameMessageMetaTypeNames[] =
{ "SELECT_PREV_WORKER", GameMessage::MSG_META_SELECT_PREV_WORKER },
{ "SELECT_NEXT_IDLE_WORKER", GameMessage::MSG_META_SELECT_NEXT_IDLE_WORKER },
{ "SELECT_NEXT_IDLE_UNIT", GameMessage::MSG_META_SELECT_NEXT_IDLE_UNIT },
+ { "SELECT_NEXT_IDLE_AIRCRAFT", GameMessage::MSG_META_SELECT_NEXT_IDLE_AIRCRAFT },
+ { "SELECT_NEXT_IDLE_VEHICLE", GameMessage::MSG_META_SELECT_NEXT_IDLE_VEHICLE },
+ { "SELECT_NEXT_IDLE_INFANTRY", GameMessage::MSG_META_SELECT_NEXT_IDLE_INFANTRY },
{ "COMMAND_SLOT01", GameMessage::MSG_META_COMMAND_SLOT01 },
{ "COMMAND_SLOT02", GameMessage::MSG_META_COMMAND_SLOT02 },
{ "COMMAND_SLOT03", GameMessage::MSG_META_COMMAND_SLOT03 },
@@ -179,6 +182,9 @@ static const LookupListRec GameMessageMetaTypeNames[] =
{ "SELECT_ALL_BARRACKS", GameMessage::MSG_META_SELECT_ALL_BARRACKS },
{ "SELECT_ALL_WARFACTORIES", GameMessage::MSG_META_SELECT_ALL_WARFACTORIES },
{ "SELECT_ALL_AIRFIELDS", GameMessage::MSG_META_SELECT_ALL_AIRFIELDS },
+ { "SELECT_ALL_IDLE_UNITS", GameMessage::MSG_META_SELECT_ALL_IDLE_UNITS },
+ { "SELECT_ALL_IDLE_AIRCRAFT", GameMessage::MSG_META_SELECT_ALL_IDLE_AIRCRAFT },
+ { "SELECT_ALL_IDLE_VEHICLES", GameMessage::MSG_META_SELECT_ALL_IDLE_VEHICLES },
{ "VIEW_COMMAND_CENTER", GameMessage::MSG_META_VIEW_COMMAND_CENTER },
{ "VIEW_LAST_RADAR_EVENT", GameMessage::MSG_META_VIEW_LAST_RADAR_EVENT },
{ "SCATTER", GameMessage::MSG_META_SCATTER },
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index b71bb0cb7..4beb3b41e 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -1807,6 +1807,29 @@ TEST(hotkeys_file_reads_the_launchers_rows_and_leaves_its_defaults_out)
CHECK( mine.launcherPart.empty() );
}
+// the name lookup CommandMap.ini and Hotkeys.ini go through on their way to a message
+struct MetaNameProbe : public MetaMap
+{
+ using MetaMap::findGameMessageMetaType;
+};
+
+TEST(hotkeys_every_row_the_page_lists_is_a_command_the_game_knows)
+{
+ static const char *const IDLE[] = { "SELECT_NEXT_IDLE_AIRCRAFT", "SELECT_NEXT_IDLE_VEHICLE", "SELECT_NEXT_IDLE_INFANTRY",
+ "SELECT_ALL_IDLE_UNITS", "SELECT_ALL_IDLE_AIRCRAFT", "SELECT_ALL_IDLE_VEHICLES" };
+ const std::vector< HotkeyCommandRow > rows = Hotkeys_commandRows( HOTKEYS_COMMAND_MAP );
+ MetaNameProbe names;
+ Int idle = 0;
+ for( size_t each = 0; each < rows.size(); each++ )
+ {
+ CHECK( names.findGameMessageMetaType( rows[ each ].id.c_str() ) != GameMessage::MSG_INVALID );
+ for( size_t name = 0; name < sizeof( IDLE ) / sizeof( IDLE[ 0 ] ); name++ )
+ if( rows[ each ].id == IDLE[ name ] && rows[ each ].category == "SELECTION" && rows[ each ].binding.key.empty() )
+ idle++;
+ }
+ CHECK_EQ( idle, 6 );
+}
+
TEST(hotkeys_file_the_launcher_wrote_comes_back_byte_for_byte)
{
const std::vector< HotkeyCommandRow > rows = Hotkeys_commandRows( HOTKEYS_COMMAND_MAP );