1
0
forked from 0ad/0ad

Add military only drag select (Alt modifier) by gerbilOFdoom. Closes #277

This was SVN commit r10873.
This commit is contained in:
Jonathan Waller 2012-01-05 13:31:54 +00:00
parent c5d62aff98
commit 1730dd6d8d
3 changed files with 35 additions and 1 deletions

View File

@ -142,6 +142,7 @@ hotkey.cut = "Ctrl+X" ; Cut selected text and copy to the clipboar
; > ENTITY SELECTION
hotkey.selection.add = Shift ; Add units to selection
hotkey.selection.milonly = Alt ; Add only military units to selection
hotkey.selection.remove = Ctrl ; Remove units from selection
hotkey.selection.idleworker = Period ; Select next idle worker
hotkey.selection.idlewarrior = Comma ; Select next idle warrior

View File

@ -444,6 +444,19 @@ function getPreferredEntities(ents)
return preferredEnts;
}
// Removes any support units from the passed list of entities
function getMilitaryEntities(ents)
{
var militaryEnts = [];
for each (var ent in ents)
{
var entState = GetEntityState(ent);
if (!isSupport(entState))
militaryEnts.push(ent);
}
return militaryEnts;
}
function handleInputBeforeGui(ev, hoveredObject)
{
// Capture mouse position so we can use it for displaying cursors,
@ -512,7 +525,16 @@ function handleInputBeforeGui(ev, hoveredObject)
var preferredEntities = getPreferredEntities(ents)
if (preferredEntities.length)
ents = preferredEntities;
{
ents = preferredEntities;
if(Engine.HotkeyIsPressed("selection.milonly"))
{
var militaryEntities = getMilitaryEntities(ents);
if(militaryEntities.length)
ents = militaryEntities;
}
}
// Remove the bandbox hover highlighting
g_Selection.setHighlightList([]);

View File

@ -127,6 +127,17 @@ function isDefensive(entState)
return false;
}
function isSupport(entState)
{
if(entState.identity)
{
var classes = entState.identity.classes;
if(classes && classes.length)
return (classes.indexOf("Support") != -1);
}
return false;
}
function damageTypesToTextStacked(dmg)
{
if (!dmg)