Add new shortcuts for unit selection.

Ctrl+C: All cyborgs
Shift+C: All cyborgs with weapons
Shift+E: All cyborg engineers
Shift+G: All ground based attack units including hovers
Shift+M: All cyborg mechanics
Shift+P: All transporters
Shift+R: All tanks with repair turrets
Shift+S: All sensor units
Shift+T: All trucks

Original patches by JDW and Wolfbyte. Closes #3150.
master
cybersphinx 2012-02-09 23:12:25 +01:00
parent 8379fb2f8b
commit 37cf6b4d2a
5 changed files with 212 additions and 0 deletions

View File

@ -2234,6 +2234,48 @@ void kf_SelectAllHalfTracked( void )
selDroidSelection(selectedPlayer,DS_BY_TYPE,DST_HALF_TRACKED,false);
}
// --------------------------------------------------------------------------
void kf_SelectAllCyborgs()
{
selDroidSelection(selectedPlayer, DS_BY_TYPE, DST_CYBORG, false);
}
// --------------------------------------------------------------------------
void kf_SelectAllEngineers()
{
selDroidSelection(selectedPlayer, DS_BY_TYPE, DST_ENGINEER, false);
}
// --------------------------------------------------------------------------
void kf_SelectAllMechanics()
{
selDroidSelection(selectedPlayer, DS_BY_TYPE, DST_MECHANIC, false);
}
// --------------------------------------------------------------------------
void kf_SelectAllTransporters()
{
selDroidSelection(selectedPlayer, DS_BY_TYPE, DST_TRANSPORTER, false);
}
// --------------------------------------------------------------------------
void kf_SelectAllRepairTanks()
{
selDroidSelection(selectedPlayer, DS_BY_TYPE, DST_REPAIR_TANK, false);
}
// --------------------------------------------------------------------------
void kf_SelectAllSensorUnits()
{
selDroidSelection(selectedPlayer, DS_BY_TYPE, DST_SENSOR, false);
}
// --------------------------------------------------------------------------
void kf_SelectAllTrucks()
{
selDroidSelection(selectedPlayer, DS_BY_TYPE, DST_TRUCK, false);
}
// --------------------------------------------------------------------------
void kf_SelectAllDamaged( void )
{
@ -2246,6 +2288,18 @@ void kf_SelectAllCombatUnits( void )
selDroidSelection(selectedPlayer,DS_BY_TYPE,DST_ALL_COMBAT,false);
}
// --------------------------------------------------------------------------
void kf_SelectAllLandCombatUnits()
{
selDroidSelection(selectedPlayer, DS_BY_TYPE, DST_ALL_COMBAT_LAND, false);
}
// --------------------------------------------------------------------------
void kf_SelectAllCombatCyborgs()
{
selDroidSelection(selectedPlayer, DS_BY_TYPE, DST_ALL_COMBAT_CYBORG, false);
}
// --------------------------------------------------------------------------
// this is worst case (size of apsDroidLists[selectedPlayer] squared).
// --------------------------------------------------------------------------

View File

@ -133,7 +133,16 @@ extern void kf_SelectAllHovers( void );
extern void kf_SelectAllWheeled( void );
extern void kf_SelectAllTracked( void );
extern void kf_SelectAllHalfTracked( void );
void kf_SelectAllCyborgs();
void kf_SelectAllEngineers();
void kf_SelectAllMechanics();
void kf_SelectAllTransporters();
void kf_SelectAllRepairTanks();
void kf_SelectAllSensorUnits();
void kf_SelectAllTrucks();
extern void kf_SelectAllCombatUnits( void );
void kf_SelectAllLandCombatUnits();
void kf_SelectAllCombatCyborgs();
extern void kf_SelectAllSameType( void );
extern void kf_SetDroidRangeShort( void );

View File

@ -254,6 +254,15 @@ _keymapsave keyMapSaveTable[] =
kf_SetDroidGoToTransport,
kf_SetDroidMoveGuard,
kf_toggleTrapCursor,
kf_SelectAllCyborgs,
kf_SelectAllCombatCyborgs,
kf_SelectAllEngineers,
kf_SelectAllLandCombatUnits,
kf_SelectAllMechanics,
kf_SelectAllTransporters,
kf_SelectAllRepairTanks,
kf_SelectAllSensorUnits,
kf_SelectAllTrucks,
NULL // last function!
};
@ -413,6 +422,7 @@ void keyInitMappings( bool bForceDefaults )
// **********************************
// In game mappings - COMBO (CTRL + LETTER) presses.
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LCTRL, KEY_A, KEYMAP_PRESSED, kf_SelectAllCombatUnits, N_("Select all Combat Units"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LCTRL, KEY_C, KEYMAP_PRESSED, kf_SelectAllCyborgs, N_("Select all Cyborgs"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LCTRL, KEY_D, KEYMAP_PRESSED, kf_SelectAllDamaged, N_("Select all Heavily Damaged Units"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LCTRL, KEY_F, KEYMAP_PRESSED, kf_SelectAllHalfTracked, N_("Select all Half-tracks"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LCTRL, KEY_H, KEYMAP_PRESSED, kf_SelectAllHovers, N_("Select all Hovers"));
@ -426,6 +436,17 @@ void keyInitMappings( bool bForceDefaults )
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LCTRL, KEY_Z, KEYMAP_PRESSED, kf_SelectAllSameType, N_("Select all Similar Units"));
// **********************************
// **********************************
// In game mappings - COMBO (SHIFT + LETTER) presses.
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LSHIFT, KEY_C, KEYMAP_PRESSED, kf_SelectAllCombatCyborgs, N_("Select all Combat Cyborgs"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LSHIFT, KEY_E, KEYMAP_PRESSED, kf_SelectAllEngineers, N_("Select all Engineers"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LSHIFT, KEY_G, KEYMAP_PRESSED, kf_SelectAllLandCombatUnits, N_("Select all Land Combat Units"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LSHIFT, KEY_M, KEYMAP_PRESSED, kf_SelectAllMechanics, N_("Select all Mechanics"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LSHIFT, KEY_P, KEYMAP_PRESSED, kf_SelectAllTransporters, N_("Select all Transporters"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LSHIFT, KEY_R, KEYMAP_PRESSED, kf_SelectAllRepairTanks, N_("Select all Repair Tanks"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LSHIFT, KEY_S, KEYMAP_PRESSED, kf_SelectAllSensorUnits, N_("Select all Sensor Units"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LSHIFT, KEY_T, KEYMAP_PRESSED, kf_SelectAllTrucks, N_("Select all Trucks"));
// **********************************
// **********************************
// SELECT PLAYERS - DEBUG ONLY
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE,(KEY_CODE)KEY_MAXSCAN, KEYMAP_PRESSED, kf_SelectNextFactory, N_("Select next Factory"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE,(KEY_CODE)KEY_MAXSCAN, KEYMAP_PRESSED, kf_SelectNextResearch, N_("Select next Research Facility"));

View File

@ -100,6 +100,32 @@ static unsigned int selSelectAllSameProp(unsigned int player, PROPULSION_TYPE pr
return count;
}
// ---------------------------------------------------------------------
// Selects all units owned by the player of a certain droid type.
// On Screen toggle.
static unsigned int selSelectAllSameDroid(unsigned int player, DROID_TYPE droidType, bool bOnScreen)
{
int count = 0;
selDroidDeselect(player);
/* Go thru' them all */
for (DROID *psDroid = apsDroidLists[player]; psDroid; psDroid = psDroid->psNext)
{
/* Is on screen important */
if (!bOnScreen || droidOnScreen(psDroid, 0))
{
/* Same as the droid type asked for*/
if (psDroid->droidType == droidType)
{
SelectDroid(psDroid);
count++;
}
}
}
return count;
}
// ---------------------------------------------------------------------
// Selects all units owned by the player that have a weapon. On screen
// toggle.
@ -130,6 +156,72 @@ static unsigned int selSelectAllCombat(unsigned int player, bool bOnScreen)
return count;
}
// ---------------------------------------------------------------------
// Selects all land-based units (Including Hover units) owned by the player that have a weapon. On screen
// toggle.
static unsigned int selSelectAllCombatLand(unsigned int player, bool bOnScreen)
{
int count = 0;
selDroidDeselect(player);
for (DROID *psDroid = apsDroidLists[player]; psDroid; psDroid = psDroid->psNext)
{
/* Does it have a weapon? */
if (psDroid->asWeaps[0].nStat > 0)
{
/* Is on screen relevant? */
if (!bOnScreen || droidOnScreen(psDroid, 0))
{
/* Get the propulsion type */
PROPULSION_STATS *psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat;
ASSERT(psPropStats != NULL, "invalid propulsion stats pointer");
if (psPropStats->propulsionType == PROPULSION_TYPE_WHEELED ||
psPropStats->propulsionType == PROPULSION_TYPE_HALF_TRACKED ||
psPropStats->propulsionType == PROPULSION_TYPE_TRACKED ||
psPropStats->propulsionType == PROPULSION_TYPE_HOVER ||
psPropStats->propulsionType == PROPULSION_TYPE_LEGGED)
{
SelectDroid(psDroid);
count++;
}
}
}
}
return count;
}
// ---------------------------------------------------------------------
// Selects all Cyborgs owned by the player that have a weapon. On screen
// toggle.
static unsigned int selSelectAllCombatCyborg(unsigned int player, bool bOnScreen)
{
int count = 0;
selDroidDeselect(player);
for (DROID *psDroid = apsDroidLists[player]; psDroid; psDroid = psDroid->psNext)
{
/* Does it have a weapon? */
if (psDroid->asWeaps[0].nStat > 0)
{
/* Is on screen relevant? */
if (!bOnScreen || droidOnScreen(psDroid, 0))
{
/* Get the propulsion type */
PROPULSION_STATS *psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat;
ASSERT(psPropStats != NULL, "invalid propulsion stats pointer");
/* Check if cyborg */
if (psPropStats->propulsionType == PROPULSION_TYPE_LEGGED)
{
SelectDroid(psDroid);
count++;
}
}
}
}
return count;
}
// ---------------------------------------------------------------------
// Selects all damaged units - on screen toggle.
static unsigned int selSelectAllDamaged(unsigned int player, bool bOnScreen)
@ -559,9 +651,36 @@ unsigned int selDroidSelection(unsigned int player, SELECTION_CLASS droidClass,
case DST_HALF_TRACKED:
retVal = selSelectAllSameProp(player, PROPULSION_TYPE_HALF_TRACKED, bOnScreen);
break;
case DST_CYBORG:
retVal = selSelectAllSameProp(player, PROPULSION_TYPE_LEGGED, bOnScreen);
break;
case DST_ENGINEER:
retVal = selSelectAllSameDroid(player, DROID_CYBORG_CONSTRUCT, bOnScreen);
break;
case DST_MECHANIC:
retVal = selSelectAllSameDroid(player, DROID_CYBORG_REPAIR, bOnScreen);
break;
case DST_TRANSPORTER:
retVal = selSelectAllSameDroid(player, DROID_TRANSPORTER, bOnScreen);
break;
case DST_REPAIR_TANK:
retVal = selSelectAllSameDroid(player, DROID_REPAIR, bOnScreen);
break;
case DST_SENSOR:
retVal = selSelectAllSameDroid(player, DROID_SENSOR, bOnScreen);
break;
case DST_TRUCK:
retVal = selSelectAllSameDroid(player, DROID_CONSTRUCT, bOnScreen);
break;
case DST_ALL_COMBAT:
retVal = selSelectAllCombat(player, bOnScreen);
break;
case DST_ALL_COMBAT_LAND:
retVal = selSelectAllCombatLand(player, bOnScreen);
break;
case DST_ALL_COMBAT_CYBORG:
retVal = selSelectAllCombatCyborg(player, bOnScreen);
break;
case DST_ALL_DAMAGED:
retVal = selSelectAllDamaged(player, bOnScreen);
break;

View File

@ -35,7 +35,16 @@ enum SELECTIONTYPE
DST_WHEELED,
DST_TRACKED,
DST_HALF_TRACKED,
DST_CYBORG,
DST_ENGINEER,
DST_MECHANIC,
DST_TRANSPORTER,
DST_REPAIR_TANK,
DST_SENSOR,
DST_TRUCK,
DST_ALL_COMBAT,
DST_ALL_COMBAT_LAND,
DST_ALL_COMBAT_CYBORG,
DST_ALL_DAMAGED,
DST_ALL_SAME
};