Fix for uniform-selection

This commit is contained in:
titiger 2016-10-17 03:00:37 +02:00
parent 4d99f5900d
commit 990df3b49b
4 changed files with 16 additions and 11 deletions

View File

@ -3341,7 +3341,7 @@ bool Game::addUnitToSelection(Unit *unit) {
try {
Selection *selection= gui.getSelectionPtr();
if(selection != NULL) {
result = selection->select(unit);
result = selection->select(unit,true);
}
}
catch(const exception &ex) {

View File

@ -588,7 +588,7 @@ void Gui::selectInterestingUnit(InterestingUnitType iut) {
if(previousFound == true) {
if(unit->isInteresting(iut)) {
selection.select(unit);
selection.select(unit,false);
break;
}
}
@ -605,7 +605,7 @@ void Gui::selectInterestingUnit(InterestingUnitType iut) {
Unit* unit = thisFaction->getUnit(index);
if(unit->isInteresting(iut)) {
selection.select(unit);
selection.select(unit,false);
break;
}
}
@ -1154,7 +1154,7 @@ void Gui::computeSelected(bool doubleClick, bool force){
if(!controlDown){
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to call selection.select(units)\n",__FILE__,__FUNCTION__,__LINE__);
selection.select(units);
selection.select(units,shiftDown);
if(!selection.isEmpty()){
selectedResourceObject=NULL;
}

View File

@ -51,7 +51,7 @@ bool Selection::canSelectUnitFactionCheck(const Unit *unit) const {
return true;
}
bool Selection::select(Unit *unit) {
bool Selection::select(Unit *unit, bool addToSelection) {
bool result = false;
if((int)selectedUnits.size() >= Config::getInstance().getInt("MaxUnitSelectCount",intToStr(maxUnits).c_str())) {
return result;
@ -84,8 +84,13 @@ bool Selection::select(Unit *unit) {
//check if multitypesel
if(selectedUnits.size() > 0) {
if(selectedUnits.front()->getType()->getUniformSelect() == true && selectedUnits.front()->getType() != unit->getType()) {
return false;
if(addToSelection)
return false;
else
clear();
}
}
if(selectedUnits.size() > 0) {
if(unit->getType()->getUniformSelect() == true && selectedUnits.front()->getType() != unit->getType()) {
return false;
}
@ -135,11 +140,11 @@ bool Selection::select(Unit *unit) {
return result;
}
void Selection::select(const UnitContainer &units){
void Selection::select(const UnitContainer &units, bool addToSelection){
//add units to gui
for(UnitIterator it = units.begin(); it != units.end(); ++it) {
select(*it);
select(*it,addToSelection);
}
}
@ -332,7 +337,7 @@ void Selection::recallGroup(int groupIndex,bool clearSelection){
clear();
}
for(int i = 0; i < (int)groups[groupIndex].size(); ++i) {
select(groups[groupIndex][i]);
select(groups[groupIndex][i],!clearSelection);
}
}

View File

@ -68,8 +68,8 @@ public:
void init(Gui *gui, int factionIndex, int teamIndex, bool allowSharedTeamUnits);
virtual ~Selection();
bool select(Unit *unit);
void select(const UnitContainer &units);
bool select(Unit *unit, bool addToSelection);
void select(const UnitContainer &units, bool addToSelection);
void unSelect(const UnitContainer &units);
void unSelect(int unitIndex);
void clear();