parent
de5135bfaf
commit
08806c5416
|
@ -5634,32 +5634,46 @@ void Renderer::renderOnTopBars(){
|
||||||
for(int visibleUnitIndex = 0;
|
for(int visibleUnitIndex = 0;
|
||||||
visibleUnitIndex < (int)qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
|
visibleUnitIndex < (int)qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
|
||||||
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
|
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
|
||||||
if(unit->isAlive() && unit->getType()->isHealthbarEnabled()
|
|
||||||
&& ((unit->getType()->getHealthbarVisible()&hbvAlways)
|
float healthbarheight;
|
||||||
|| ((unit->getType()->getHealthbarVisible()&hbvDamaged) && unit->getHp()!=unit->getType()->getMaxHp())
|
float healthbarthickness;
|
||||||
|| ((unit->getType()->getHealthbarVisible()&hbvSelected) && game->getGui()->isSelected(unit)))) {
|
int healthbarVisible;
|
||||||
|
|
||||||
|
//get settings of the faction
|
||||||
|
healthbarheight=unit->getFaction()->getType()->getHealthbarHeight();
|
||||||
|
healthbarthickness=unit->getFaction()->getType()->getHealthbarThickness();
|
||||||
|
healthbarVisible=unit->getFaction()->getType()->getHealthbarVisible();
|
||||||
|
|
||||||
|
//replace them by the ones from the unit if existent
|
||||||
|
if(unit->getType()->getHealthbarVisible()!=hbvOff && unit->getType()->getHealthbarVisible()!=hbvUndefined) {
|
||||||
|
if(unit->getType()->getHealthbarHeight()!=-100.0f) {
|
||||||
|
healthbarheight=unit->getType()->getHealthbarHeight();
|
||||||
|
}
|
||||||
|
if(unit->getType()->getHealthbarThickness()!=-1.0f) {
|
||||||
|
healthbarthickness=unit->getType()->getHealthbarThickness();
|
||||||
|
}
|
||||||
|
healthbarVisible=unit->getType()->getHealthbarVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(unit->isAlive() && !(healthbarVisible==hbvUndefined || (healthbarVisible&hbvOff))
|
||||||
|
&& ((healthbarVisible&hbvAlways)
|
||||||
|
|| ((healthbarVisible&hbvDamaged) && unit->getHp()!=unit->getType()->getMaxHp())
|
||||||
|
|| ((healthbarVisible&hbvSelected) && game->getGui()->isSelected(unit)))) {
|
||||||
Vec3f currVec= unit->getCurrVectorFlat();
|
Vec3f currVec= unit->getCurrVectorFlat();
|
||||||
float thickness;
|
if(healthbarheight==-100.0f) {
|
||||||
if(unit->getType()->getHealthbarHeight()==-100.0f) {
|
|
||||||
currVec.y+=unit->getType()->getHeight()+1;
|
currVec.y+=unit->getType()->getHeight()+1;
|
||||||
} else {
|
} else {
|
||||||
currVec.y+=unit->getType()->getHealthbarHeight();
|
currVec.y+=healthbarheight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unit->getType()->getHealthbarThickness()==-1.0f) {
|
if(unit->getType()->getMaxEp() > 0) {
|
||||||
if(unit->getType()->getMaxEp() > 0 && unit->getType()->isHealthbarShowEp()) {
|
healthbarthickness=healthbarthickness*2;
|
||||||
thickness=0.08f;
|
|
||||||
} else {
|
|
||||||
thickness=0.05f;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
thickness=unit->getType()->getHealthbarThickness();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unit->getType()->getMaxEp() > 0 && unit->getType()->isHealthbarShowEp()) {
|
if(unit->getType()->getMaxEp() > 0) {
|
||||||
renderSelectionHpBar(currVec,unit->getType()->getSize(),unit->getHpRatio(),thickness,unit->getEpRatio());
|
renderSelectionHpBar(currVec,unit->getType()->getSize(),unit->getHpRatio(),healthbarthickness,unit->getEpRatio());
|
||||||
} else {
|
} else {
|
||||||
renderSelectionHpBar(currVec,unit->getType()->getSize(),unit->getHpRatio(),thickness);
|
renderSelectionHpBar(currVec,unit->getType()->getSize(),unit->getHpRatio(),healthbarthickness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8293,6 +8307,7 @@ void Renderer::renderSelectionHpBar(Vec3f v, int size, float hp, float height, f
|
||||||
hp=hp*2-1;
|
hp=hp*2-1;
|
||||||
ep=ep*2-1;
|
ep=ep*2-1;
|
||||||
|
|
||||||
|
//from green to yellow to red
|
||||||
if(hp >= 0.0f) {
|
if(hp >= 0.0f) {
|
||||||
green=brightness;
|
green=brightness;
|
||||||
red=brightness-hp*brightness;
|
red=brightness-hp*brightness;
|
||||||
|
@ -8304,26 +8319,28 @@ void Renderer::renderSelectionHpBar(Vec3f v, int size, float hp, float height, f
|
||||||
glColor4f(red,green,0.0f,0.4f);
|
glColor4f(red,green,0.0f,0.4f);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
if(ep < -2.0f) {
|
if(ep < -2.0f) {
|
||||||
|
//hpbar
|
||||||
glVertex3fv((v - (rightVector*width - upVector*height)).ptr());
|
glVertex3fv((v - (rightVector*width - upVector*height)).ptr());
|
||||||
glVertex3fv((v - (rightVector*width + upVector*height)).ptr());
|
glVertex3fv((v - (rightVector*width + upVector*height)).ptr());
|
||||||
glVertex3fv((v + (rightVector*hp*width - upVector*height)).ptr());
|
glVertex3fv((v + (rightVector*hp*width - upVector*height)).ptr());
|
||||||
glVertex3fv((v + (rightVector*hp*width + upVector*height)).ptr());
|
glVertex3fv((v + (rightVector*hp*width + upVector*height)).ptr());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
//hpbar
|
||||||
glVertex3fv((v - (rightVector*width - upVector*height)).ptr());
|
glVertex3fv((v - (rightVector*width - upVector*height)).ptr());
|
||||||
glVertex3fv((v - (rightVector*width + upVector*height*0.0f)).ptr());
|
glVertex3fv((v - (rightVector*width + upVector*height*0.0f)).ptr());
|
||||||
glVertex3fv((v + (rightVector*hp*width - upVector*height*0.0f)).ptr());
|
glVertex3fv((v + (rightVector*hp*width - upVector*height*0.0f)).ptr());
|
||||||
glVertex3fv((v + (rightVector*hp*width + upVector*height)).ptr());
|
glVertex3fv((v + (rightVector*hp*width + upVector*height)).ptr());
|
||||||
|
//epbar
|
||||||
glColor4f(brightness,0,brightness,0.4f);
|
glColor4f(brightness,0,brightness,0.4f);
|
||||||
glVertex3fv((v - (rightVector*width + upVector*height*0.0f)).ptr());
|
glVertex3fv((v - (rightVector*width + upVector*height*0.0f)).ptr());
|
||||||
glVertex3fv((v - (rightVector*width + upVector*height)).ptr());
|
glVertex3fv((v - (rightVector*width + upVector*height)).ptr());
|
||||||
glVertex3fv((v + (rightVector*ep*width - upVector*height)).ptr());
|
glVertex3fv((v + (rightVector*ep*width - upVector*height)).ptr());
|
||||||
glVertex3fv((v + (rightVector*ep*width - upVector*height*0.0f)).ptr());
|
glVertex3fv((v + (rightVector*ep*width - upVector*height*0.0f)).ptr());
|
||||||
printf("Found Ep Unit\n");
|
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
//border
|
||||||
glColor4f(red+0.1f,green+0.1f,0.1f,0.5f);
|
glColor4f(red+0.1f,green+0.1f,0.1f,0.5f);
|
||||||
glBegin(GL_LINE_LOOP);
|
glBegin(GL_LINE_LOOP);
|
||||||
glVertex3fv((v - (rightVector*width - upVector*height)).ptr());
|
glVertex3fv((v - (rightVector*width - upVector*height)).ptr());
|
||||||
|
|
|
@ -34,6 +34,9 @@ FactionType::FactionType() {
|
||||||
music = NULL;
|
music = NULL;
|
||||||
personalityType = fpt_Normal;
|
personalityType = fpt_Normal;
|
||||||
isLinked = false;
|
isLinked = false;
|
||||||
|
healthbarheight= -100.0f;
|
||||||
|
healthbarthickness= 0.05f;
|
||||||
|
healthbarVisible=hbvUndefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
//load a faction, given a directory
|
//load a faction, given a directory
|
||||||
|
@ -272,6 +275,35 @@ void FactionType::load(const string &factionName, const TechTree *techTree, Chec
|
||||||
loadedFileList[musicNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(path,musicNode->getAttribute("path")->getRestrictedValue()));
|
loadedFileList[musicNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(path,musicNode->getAttribute("path")->getRestrictedValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//healthbar
|
||||||
|
if(factionNode->hasChild("healthbar")) {
|
||||||
|
const XmlNode *HealthbarNode= factionNode->getChild("healthbar");
|
||||||
|
if(HealthbarNode->hasChild("height")) {
|
||||||
|
healthbarheight= HealthbarNode->getChild("height")->getAttribute("value")->getFloatValue();
|
||||||
|
}
|
||||||
|
if(HealthbarNode->hasChild("thickness")) {
|
||||||
|
healthbarthickness= HealthbarNode->getChild("thickness")->getAttribute("value")->getFloatValue(0.f, 1.f);
|
||||||
|
}
|
||||||
|
if(HealthbarNode->hasChild("visible")) {
|
||||||
|
string healthbarVisibleString=HealthbarNode->getChild("visible")->getAttribute("value")->getValue();
|
||||||
|
vector<string> v=split(healthbarVisibleString,"|");
|
||||||
|
for (int i = 0; i < (int)v.size(); ++i) {
|
||||||
|
string current=trim(v[i]);
|
||||||
|
if(current=="always") {
|
||||||
|
healthbarVisible=healthbarVisible|hbvAlways;
|
||||||
|
} else if(current=="selected") {
|
||||||
|
healthbarVisible=healthbarVisible|hbvSelected;
|
||||||
|
} else if(current=="damaged") {
|
||||||
|
healthbarVisible=healthbarVisible|hbvDamaged;
|
||||||
|
} else if(current=="off") {
|
||||||
|
healthbarVisible=healthbarVisible|hbvOff;
|
||||||
|
} else {
|
||||||
|
throw megaglest_runtime_error("Unknown Healthbar Visible Option: " + current, validationMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//read ai behavior
|
//read ai behavior
|
||||||
if(factionNode->hasChild("ai-behavior") == true) {
|
if(factionNode->hasChild("ai-behavior") == true) {
|
||||||
const XmlNode *aiNode= factionNode->getChild("ai-behavior");
|
const XmlNode *aiNode= factionNode->getChild("ai-behavior");
|
||||||
|
|
|
@ -95,6 +95,10 @@ private:
|
||||||
std::map<AIBehaviorStaticValueCategory, int > mapAIBehaviorStaticOverrideValues;
|
std::map<AIBehaviorStaticValueCategory, int > mapAIBehaviorStaticOverrideValues;
|
||||||
|
|
||||||
bool isLinked;
|
bool isLinked;
|
||||||
|
float healthbarheight;
|
||||||
|
float healthbarthickness;
|
||||||
|
int healthbarVisible;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//init
|
//init
|
||||||
|
@ -120,6 +124,10 @@ public:
|
||||||
int getStartingUnitCount() const {return (int)startingUnits.size();}
|
int getStartingUnitCount() const {return (int)startingUnits.size();}
|
||||||
const UnitType *getStartingUnit(int i) const {return startingUnits[i].first;}
|
const UnitType *getStartingUnit(int i) const {return startingUnits[i].first;}
|
||||||
int getStartingUnitAmount(int i) const {return startingUnits[i].second;}
|
int getStartingUnitAmount(int i) const {return startingUnits[i].second;}
|
||||||
|
inline float getHealthbarHeight() const {return healthbarheight;}
|
||||||
|
inline float getHealthbarThickness() const {return healthbarthickness;}
|
||||||
|
inline int getHealthbarVisible() const {return healthbarVisible;}
|
||||||
|
|
||||||
|
|
||||||
const UnitType *getUnitType(const string &name) const;
|
const UnitType *getUnitType(const string &name) const;
|
||||||
const UnitType *getUnitTypeById(int id) const;
|
const UnitType *getUnitTypeById(int id) const;
|
||||||
|
|
|
@ -88,11 +88,9 @@ UnitType::UnitType() : ProducibleType() {
|
||||||
meetingPointImage = NULL;
|
meetingPointImage = NULL;
|
||||||
lightColor= Vec3f(0.f);
|
lightColor= Vec3f(0.f);
|
||||||
light= false;
|
light= false;
|
||||||
healthbar= false;
|
|
||||||
healthbarShowEp= true;
|
|
||||||
healthbarheight= -100.0f;
|
healthbarheight= -100.0f;
|
||||||
healthbarthickness=-1.0f;
|
healthbarthickness=-1.0f;
|
||||||
healthbarVisible=hbvUndefined; //TODO Implement default
|
healthbarVisible=hbvUndefined;
|
||||||
multiSelect= false;
|
multiSelect= false;
|
||||||
commandable= true;
|
commandable= true;
|
||||||
armorType= NULL;
|
armorType= NULL;
|
||||||
|
@ -454,20 +452,14 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree,
|
||||||
//healthbar
|
//healthbar
|
||||||
if(parametersNode->hasChild("healthbar")) {
|
if(parametersNode->hasChild("healthbar")) {
|
||||||
const XmlNode *HealthbarNode= parametersNode->getChild("healthbar");
|
const XmlNode *HealthbarNode= parametersNode->getChild("healthbar");
|
||||||
healthbar= HealthbarNode->getAttribute("enabled")->getBoolValue();
|
if(HealthbarNode->hasChild("height")) {
|
||||||
if(healthbar){
|
healthbarheight= HealthbarNode->getChild("height")->getAttribute("value")->getFloatValue();
|
||||||
if(HealthbarNode->hasAttribute("show-ep")) {
|
|
||||||
healthbarShowEp= HealthbarNode->getAttribute("show-ep")->getBoolValue();
|
|
||||||
}
|
}
|
||||||
if(HealthbarNode->hasAttribute("height")) {
|
if(HealthbarNode->hasChild("thickness")) {
|
||||||
healthbarheight= HealthbarNode->getAttribute("height")->getFloatValue();
|
healthbarthickness= HealthbarNode->getChild("thickness")->getAttribute("value")->getFloatValue(0.f, 1.f);
|
||||||
}
|
}
|
||||||
if(HealthbarNode->hasAttribute("thickness")) {
|
if(HealthbarNode->hasChild("visible")) {
|
||||||
healthbarthickness= HealthbarNode->getAttribute("thickness")->getFloatValue(0.f, 1.f);
|
string healthbarVisibleString=HealthbarNode->getChild("visible")->getAttribute("value")->getValue();
|
||||||
}
|
|
||||||
if(HealthbarNode->hasAttribute("visible")) {
|
|
||||||
string healthbarVisibleString=HealthbarNode->getAttribute("visible")->getValue();
|
|
||||||
healthbarVisible=hbvUndefined;
|
|
||||||
vector<string> v=split(healthbarVisibleString,"|");
|
vector<string> v=split(healthbarVisibleString,"|");
|
||||||
for (int i = 0; i < (int)v.size(); ++i) {
|
for (int i = 0; i < (int)v.size(); ++i) {
|
||||||
string current=trim(v[i]);
|
string current=trim(v[i]);
|
||||||
|
@ -477,13 +469,14 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree,
|
||||||
healthbarVisible=healthbarVisible|hbvSelected;
|
healthbarVisible=healthbarVisible|hbvSelected;
|
||||||
} else if(current=="damaged") {
|
} else if(current=="damaged") {
|
||||||
healthbarVisible=healthbarVisible|hbvDamaged;
|
healthbarVisible=healthbarVisible|hbvDamaged;
|
||||||
|
} else if(current=="off") {
|
||||||
|
healthbarVisible=healthbarVisible|hbvOff;
|
||||||
} else {
|
} else {
|
||||||
throw megaglest_runtime_error("Unknown Healthbar Visible Option: " + current, validationMode);
|
throw megaglest_runtime_error("Unknown Healthbar Visible Option: " + current, validationMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//light
|
//light
|
||||||
const XmlNode *lightNode= parametersNode->getChild("light");
|
const XmlNode *lightNode= parametersNode->getChild("light");
|
||||||
|
|
|
@ -118,9 +118,10 @@ typedef vector<UnitParticleSystemType*> DamageParticleSystemTypes;
|
||||||
|
|
||||||
enum HealthbarVisible {
|
enum HealthbarVisible {
|
||||||
hbvUndefined=0,
|
hbvUndefined=0,
|
||||||
hbvAlways=1,
|
hbvOff=1,
|
||||||
hbvDamaged=2,
|
hbvAlways=2,
|
||||||
hbvSelected=4
|
hbvDamaged=4,
|
||||||
|
hbvSelected=8
|
||||||
};
|
};
|
||||||
|
|
||||||
enum UnitCountsInVictoryConditions {
|
enum UnitCountsInVictoryConditions {
|
||||||
|
@ -177,8 +178,6 @@ private:
|
||||||
const ArmorType *armorType;
|
const ArmorType *armorType;
|
||||||
bool light;
|
bool light;
|
||||||
Vec3f lightColor;
|
Vec3f lightColor;
|
||||||
bool healthbar;
|
|
||||||
bool healthbarShowEp;
|
|
||||||
float healthbarheight;
|
float healthbarheight;
|
||||||
float healthbarthickness;
|
float healthbarthickness;
|
||||||
int healthbarVisible;
|
int healthbarVisible;
|
||||||
|
@ -268,8 +267,6 @@ public:
|
||||||
inline bool getLight() const {return light;}
|
inline bool getLight() const {return light;}
|
||||||
inline bool getRotationAllowed() const {return rotationAllowed;}
|
inline bool getRotationAllowed() const {return rotationAllowed;}
|
||||||
inline Vec3f getLightColor() const {return lightColor;}
|
inline Vec3f getLightColor() const {return lightColor;}
|
||||||
inline bool isHealthbarEnabled() const {return healthbar;}
|
|
||||||
inline bool isHealthbarShowEp() const {return healthbarShowEp;}
|
|
||||||
inline float getHealthbarHeight() const {return healthbarheight;}
|
inline float getHealthbarHeight() const {return healthbarheight;}
|
||||||
inline float getHealthbarThickness() const {return healthbarthickness;}
|
inline float getHealthbarThickness() const {return healthbarthickness;}
|
||||||
inline int getHealthbarVisible() const {return healthbarVisible;}
|
inline int getHealthbarVisible() const {return healthbarVisible;}
|
||||||
|
|
Loading…
Reference in New Issue