Uniformselection
Added uniform selection of units. Uniform means you can select multiple units, but only of the same type. To make a unit uniform-selectable you need to add ```<uniform-selection value="true"/>``` to the ```<parameters>``` tag of a unit.
This commit is contained in:
parent
3639e111ef
commit
74ed3d73be
|
@ -81,6 +81,16 @@ bool Selection::select(Unit *unit) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check if multitypesel
|
||||||
|
if(selectedUnits.size() > 0) {
|
||||||
|
if(selectedUnits.front()->getType()->getUniformSelect() == true && selectedUnits.front()->getType() != unit->getType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(unit->getType()->getUniformSelect() == true && selectedUnits.front()->getType() != unit->getType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//check if enemy
|
//check if enemy
|
||||||
if(canSelectUnitFactionCheck(unit) == false && isEmpty() == false) {
|
if(canSelectUnitFactionCheck(unit) == false && isEmpty() == false) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -270,6 +280,19 @@ bool Selection::addUnitToGroup(int groupIndex,Unit *unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for uniformselect units
|
||||||
|
if((int)groups[groupIndex].size()>0 ){
|
||||||
|
Unit* unitInGroup=groups[groupIndex][0];
|
||||||
|
if( unit->getType()->getUniformSelect() && unitInGroup->getType() != unit->getType()) {
|
||||||
|
//dont add uniform selection unit
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if( unitInGroup->getType()->getUniformSelect() && unitInGroup->getType() != unit->getType()){
|
||||||
|
//dont add another unit to a group of uniform selection units
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(unit != NULL && !groupIsFull) {
|
if(unit != NULL && !groupIsFull) {
|
||||||
groups[groupIndex].push_back(unit);
|
groups[groupIndex].push_back(unit);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -93,6 +93,7 @@ UnitType::UnitType() : ProducibleType() {
|
||||||
healthbarthickness=-1.0f;
|
healthbarthickness=-1.0f;
|
||||||
healthbarVisible=hbvUndefined;
|
healthbarVisible=hbvUndefined;
|
||||||
multiSelect= false;
|
multiSelect= false;
|
||||||
|
uniformSelect= false;
|
||||||
commandable= true;
|
commandable= true;
|
||||||
armorType= NULL;
|
armorType= NULL;
|
||||||
rotatedBuildPos=0;
|
rotatedBuildPos=0;
|
||||||
|
@ -356,6 +357,11 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree,
|
||||||
//multi selection
|
//multi selection
|
||||||
multiSelect= parametersNode->getChild("multi-selection")->getAttribute("value")->getBoolValue();
|
multiSelect= parametersNode->getChild("multi-selection")->getAttribute("value")->getBoolValue();
|
||||||
|
|
||||||
|
//uniform selection
|
||||||
|
if(parametersNode->hasChild("uniform-selection")) {
|
||||||
|
uniformSelect= parametersNode->getChild("uniform-selection")->getAttribute("value")->getBoolValue();
|
||||||
|
}
|
||||||
|
|
||||||
//commandable
|
//commandable
|
||||||
if(parametersNode->hasChild("commandable")){
|
if(parametersNode->hasChild("commandable")){
|
||||||
commandable= parametersNode->getChild("commandable")->getAttribute("value")->getBoolValue();
|
commandable= parametersNode->getChild("commandable")->getAttribute("value")->getBoolValue();
|
||||||
|
@ -1307,6 +1313,7 @@ std::string UnitType::toString() const {
|
||||||
result += " light = " + intToStr(light);
|
result += " light = " + intToStr(light);
|
||||||
result += " lightColor = " + lightColor.getString();
|
result += " lightColor = " + lightColor.getString();
|
||||||
result += " multiSelect = " + intToStr(multiSelect);
|
result += " multiSelect = " + intToStr(multiSelect);
|
||||||
|
result += " uniformSelect = " + intToStr(uniformSelect);
|
||||||
result += " commandable = " + intToStr(commandable);
|
result += " commandable = " + intToStr(commandable);
|
||||||
result += " sight = " + intToStr(sight);
|
result += " sight = " + intToStr(sight);
|
||||||
result += " size = " + intToStr(size);
|
result += " size = " + intToStr(size);
|
||||||
|
|
|
@ -192,6 +192,7 @@ private:
|
||||||
float healthbarthickness;
|
float healthbarthickness;
|
||||||
int healthbarVisible;
|
int healthbarVisible;
|
||||||
bool multiSelect;
|
bool multiSelect;
|
||||||
|
bool uniformSelect;
|
||||||
bool commandable;
|
bool commandable;
|
||||||
int sight;
|
int sight;
|
||||||
int size; //size in cells
|
int size; //size in cells
|
||||||
|
@ -283,6 +284,7 @@ public:
|
||||||
inline float getHealthbarThickness() const {return healthbarthickness;}
|
inline float getHealthbarThickness() const {return healthbarthickness;}
|
||||||
inline int getHealthbarVisible() const {return healthbarVisible;}
|
inline int getHealthbarVisible() const {return healthbarVisible;}
|
||||||
inline bool getMultiSelect() const {return multiSelect;}
|
inline bool getMultiSelect() const {return multiSelect;}
|
||||||
|
inline bool getUniformSelect() const {return uniformSelect;}
|
||||||
inline bool isCommandable() const {return commandable;}
|
inline bool isCommandable() const {return commandable;}
|
||||||
inline int getSight() const {return sight;}
|
inline int getSight() const {return sight;}
|
||||||
inline int getSize() const {return size;}
|
inline int getSize() const {return size;}
|
||||||
|
|
Loading…
Reference in New Issue