mirror of
https://github.com/glest/glest-source.git
synced 2025-09-01 20:12:40 +02:00
Select only operative or non operative units with property "uniformSelecion"
This commit is contained in:
@@ -1156,7 +1156,7 @@ void Gui::computeSelected(bool doubleClick, bool force){
|
|||||||
for(int i=0; i<world->getFaction(factionIndex)->getUnitCount(); ++i){
|
for(int i=0; i<world->getFaction(factionIndex)->getUnitCount(); ++i){
|
||||||
Unit *unit= world->getFaction(factionIndex)->getUnit(i);
|
Unit *unit= world->getFaction(factionIndex)->getUnit(i);
|
||||||
if(unit->getPos().dist(refUnit->getPosNotThreadSafe())<doubleClickSelectionRadius &&
|
if(unit->getPos().dist(refUnit->getPosNotThreadSafe())<doubleClickSelectionRadius &&
|
||||||
unit->getType()==refUnit->getType())
|
unit->getType()==refUnit->getType() && unit->isOperative()==refUnit->isOperative() )
|
||||||
{
|
{
|
||||||
units.push_back(unit);
|
units.push_back(unit);
|
||||||
}
|
}
|
||||||
|
@@ -83,15 +83,16 @@ bool Selection::select(Unit *unit, bool addToSelection) {
|
|||||||
|
|
||||||
//check if multitypesel
|
//check if multitypesel
|
||||||
if(selectedUnits.size() > 0) {
|
if(selectedUnits.size() > 0) {
|
||||||
if(selectedUnits.front()->getType()->getUniformSelect() == true && selectedUnits.front()->getType() != unit->getType()) {
|
bool isUnifromSelectOK = ( selectedUnits.front()->getType() == unit->getType() && unit->isOperative() == selectedUnits.front()->isOperative());
|
||||||
|
if(selectedUnits.front()->getType()->getUniformSelect() == true && !isUnifromSelectOK ) {
|
||||||
if(addToSelection)
|
if(addToSelection)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(selectedUnits.size() > 0) {
|
if (unit->getType()->getUniformSelect() == true
|
||||||
if(unit->getType()->getUniformSelect() == true && selectedUnits.front()->getType() != unit->getType()) {
|
&& !isUnifromSelectOK ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -286,15 +287,17 @@ bool Selection::addUnitToGroup(int groupIndex,Unit *unit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check for uniformselect units
|
// check for uniformselect units
|
||||||
if((int)groups[groupIndex].size()>0 ){
|
if((int)groups[groupIndex].size()>0 ) {
|
||||||
Unit* unitInGroup=groups[groupIndex][0];
|
Unit* unitInGroup=groups[groupIndex][0];
|
||||||
if( unit->getType()->getUniformSelect() && unitInGroup->getType() != unit->getType()) {
|
if( unit->getType()->getUniformSelect() || unitInGroup->getType()->getUniformSelect() ) {
|
||||||
//dont add uniform selection unit
|
if( unit->isOperative() != unitInGroup->isOperative()) {
|
||||||
return false;
|
//dont add units that are not in same operative state
|
||||||
}
|
return false;
|
||||||
if( unitInGroup->getType()->getUniformSelect() && unitInGroup->getType() != unit->getType()){
|
}
|
||||||
//dont add another unit to a group of uniform selection units
|
if( unitInGroup->getType() != unit->getType()){
|
||||||
return false;
|
//dont add another unit to a group of uniform selection units
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user