diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 3fedd06a0..b2a841ca2 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -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) { diff --git a/source/glest_game/gui/gui.cpp b/source/glest_game/gui/gui.cpp index 33128a60b..63bd276f6 100644 --- a/source/glest_game/gui/gui.cpp +++ b/source/glest_game/gui/gui.cpp @@ -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; } diff --git a/source/glest_game/gui/selection.cpp b/source/glest_game/gui/selection.cpp index 3429fff1b..46834a37d 100644 --- a/source/glest_game/gui/selection.cpp +++ b/source/glest_game/gui/selection.cpp @@ -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); } } diff --git a/source/glest_game/gui/selection.h b/source/glest_game/gui/selection.h index 5c2e6c65a..794d501c5 100644 --- a/source/glest_game/gui/selection.h +++ b/source/glest_game/gui/selection.h @@ -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();