Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/selection.js
Show First 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Deselect everything but entities of the chosen type. | * Deselect everything but entities of the chosen type. | ||||
*/ | */ | ||||
EntitySelection.prototype.makePrimarySelection = function(key) | EntitySelection.prototype.makePrimarySelection = function(key) | ||||
{ | { | ||||
const ents = this.groups.getEntsByKey(key); | const ents = this.groups.getEntsByKey(key); | ||||
this.reset(); | this.reset(); | ||||
this.addList(ents); | this.addList(ents, false, false, false); | ||||
}; | }; | ||||
/** | /** | ||||
* Deselect entities of the chosen type. | * Deselect entities of the chosen type. | ||||
*/ | */ | ||||
EntitySelection.prototype.removeGroupFromSelection = function(key) | EntitySelection.prototype.removeGroupFromSelection = function(key) | ||||
{ | { | ||||
this.removeList(this.groups.getEntsByKey(key)); | this.removeList(this.groups.getEntsByKey(key)); | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | for (let renamedEntity of renamedEntities) | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* Add entities to selection. Play selection sound unless quiet is true | * Add entities to selection. Play selection sound unless quiet is true | ||||
*/ | */ | ||||
EntitySelection.prototype.addList = function(ents, quiet, force = false) | EntitySelection.prototype.addList = function(ents, quiet, force = false, addFormationMembers = true) | ||||
{ | { | ||||
// If someone else's player is the sole selected unit, don't allow adding to the selection. | // If someone else's player is the sole selected unit, don't allow adding to the selection. | ||||
const firstEntState = this.selected.size == 1 && GetEntityState(this.getFirstSelected()); | const firstEntState = this.selected.size == 1 && GetEntityState(this.getFirstSelected()); | ||||
if (firstEntState && firstEntState.player != g_ViewedPlayer && !force) | if (firstEntState && firstEntState.player != g_ViewedPlayer && !force) | ||||
return; | return; | ||||
const added = []; | const added = []; | ||||
for (const ent of this.addFormationMembers(ents)) | for (const ent of addFormationMembers ? this.addFormationMembers(ents) : ents) | ||||
{ | { | ||||
if (this.selected.size >= g_MaxSelectionSize) | if (this.selected.size >= g_MaxSelectionSize) | ||||
break; | break; | ||||
if (this.selected.has(ent)) | if (this.selected.has(ent)) | ||||
continue; | continue; | ||||
const entState = GetEntityState(ent); | const entState = GetEntityState(ent); | ||||
▲ Show 20 Lines • Show All 276 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator