double click selection for units standing near or in buildings
This commit is contained in:
parent
5b2a6bb45f
commit
5db11ec538
|
@ -928,8 +928,8 @@ void Gui::computeSelected(bool doubleClick, bool force){
|
||||||
activeCommandType= NULL;
|
activeCommandType= NULL;
|
||||||
|
|
||||||
//select all units of the same type if double click
|
//select all units of the same type if double click
|
||||||
if(doubleClick && units.size()==1){
|
if(doubleClick && units.size()>0){
|
||||||
const Unit *refUnit= units.front();
|
const Unit *refUnit= getRelevantObjectFromSelection(&units);
|
||||||
int factionIndex= refUnit->getFactionIndex();
|
int factionIndex= refUnit->getFactionIndex();
|
||||||
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);
|
||||||
|
@ -971,15 +971,8 @@ bool Gui::computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&t
|
||||||
validPosObjWorld= false;
|
validPosObjWorld= false;
|
||||||
|
|
||||||
if(uc.empty() == false) {
|
if(uc.empty() == false) {
|
||||||
|
targetUnit=getRelevantObjectFromSelection(&uc);
|
||||||
for(int i=0; i<uc.size(); ++i){
|
targetPos= targetUnit->getPos();
|
||||||
targetUnit= uc.at(i);
|
|
||||||
targetPos= targetUnit->getPos();
|
|
||||||
if(targetUnit->getType()->hasSkillClass(scMove))
|
|
||||||
{// moving units are more relevant than non moving ones
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(obj!=NULL) {
|
else if(obj!=NULL) {
|
||||||
|
@ -1000,6 +993,17 @@ bool Gui::computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Unit* Gui::getRelevantObjectFromSelection(Selection::UnitContainer *uc){
|
||||||
|
Unit *resultUnit=NULL;
|
||||||
|
for(int i= 0; i < uc->size(); ++i){
|
||||||
|
resultUnit= uc->at(i);
|
||||||
|
if(resultUnit->getType()->hasSkillClass(scMove)){// moving units are more relevant than non moving ones
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultUnit;
|
||||||
|
}
|
||||||
|
|
||||||
void Gui::removingObjectEvent(Object* o){
|
void Gui::removingObjectEvent(Object* o){
|
||||||
if(getSelectedResourceObject()==o){
|
if(getSelectedResourceObject()==o){
|
||||||
selectedResourceObject=NULL;
|
selectedResourceObject=NULL;
|
||||||
|
|
|
@ -211,6 +211,7 @@ private:
|
||||||
bool isSharedCommandClass(CommandClass commandClass);
|
bool isSharedCommandClass(CommandClass commandClass);
|
||||||
void computeSelected(bool doubleCkick,bool force);
|
void computeSelected(bool doubleCkick,bool force);
|
||||||
bool computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&targetUnit);
|
bool computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&targetUnit);
|
||||||
|
Unit* getRelevantObjectFromSelection(Selection::UnitContainer *uc);
|
||||||
};
|
};
|
||||||
|
|
||||||
}} //end namespace
|
}} //end namespace
|
||||||
|
|
Loading…
Reference in New Issue
Block a user