Merge pull request #31 from titison/feature/hp-bars
Work on Healthbars Coop work of titi and son
This commit is contained in:
commit
f095a96be3
|
@ -236,7 +236,7 @@ void Game::resetMembers() {
|
||||||
|
|
||||||
scrollSpeed = Config::getInstance().getFloat("UiScrollSpeed","1.5");
|
scrollSpeed = Config::getInstance().getFloat("UiScrollSpeed","1.5");
|
||||||
photoModeEnabled = Config::getInstance().getBool("PhotoMode","false");
|
photoModeEnabled = Config::getInstance().getBool("PhotoMode","false");
|
||||||
healthbarMode = Config::getInstance().getInt("HealthbarMode","0");
|
healthbarMode = Config::getInstance().getInt("HealthBarMode","0");
|
||||||
visibleHUD = Config::getInstance().getBool("VisibleHud","true");
|
visibleHUD = Config::getInstance().getBool("VisibleHud","true");
|
||||||
timeDisplay = Config::getInstance().getBool("TimeDisplay","true");
|
timeDisplay = Config::getInstance().getBool("TimeDisplay","true");
|
||||||
withRainEffect = Config::getInstance().getBool("RainEffect","true");
|
withRainEffect = Config::getInstance().getBool("RainEffect","true");
|
||||||
|
@ -4669,16 +4669,20 @@ void Game::keyDown(SDL_KeyboardEvent key) {
|
||||||
console.addLine(lang.getString("HealthBar")+": "+lang.getString("HealthbarsAlways"));
|
console.addLine(lang.getString("HealthBar")+": "+lang.getString("HealthbarsAlways"));
|
||||||
break;
|
break;
|
||||||
case hbvAlways:
|
case hbvAlways:
|
||||||
healthbarMode=hbvDamaged;
|
healthbarMode=hbvIfNeeded;
|
||||||
console.addLine(lang.getString("HealthBar")+": "+lang.getString("HealthbarsDamaged"));
|
console.addLine(lang.getString("HealthBar")+": "+lang.getString("HealthbarsIfNeeded"));
|
||||||
break;
|
break;
|
||||||
case hbvDamaged:
|
case hbvIfNeeded:
|
||||||
healthbarMode=hbvSelected;
|
healthbarMode=hbvSelected;
|
||||||
console.addLine(lang.getString("HealthBar")+": "+lang.getString("HealthbarsSelected"));
|
console.addLine(lang.getString("HealthBar")+": "+lang.getString("HealthbarsSelected"));
|
||||||
break;
|
break;
|
||||||
case hbvSelected:
|
case hbvSelected:
|
||||||
|
healthbarMode=hbvSelected | hbvIfNeeded;
|
||||||
|
console.addLine(lang.getString("HealthBar")+": "+lang.getString("HealthbarsSelectedOrNeeded"));
|
||||||
|
break;
|
||||||
|
case (hbvSelected | hbvIfNeeded):
|
||||||
healthbarMode=hbvUndefined;
|
healthbarMode=hbvUndefined;
|
||||||
console.addLine(lang.getString("HealthBar")+": "+lang.getString("HealthbarsDefault"));
|
console.addLine(lang.getString("HealthBar")+": "+lang.getString("HealthbarsFactionDefault"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("In [%s::%s Line: %d] Toggle Healthbars Hotkey - Invalid Value. Setting to default.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
printf("In [%s::%s Line: %d] Toggle Healthbars Hotkey - Invalid Value. Setting to default.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
@ -5236,7 +5240,7 @@ void Game::render3d(){
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||||
|
|
||||||
//selection circles
|
//selection circles
|
||||||
renderer.renderSelectionEffects();
|
renderer.renderSelectionEffects(healthbarMode);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderSelectionEffects]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderSelectionEffects]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||||
|
|
||||||
|
|
|
@ -429,7 +429,7 @@ Texture2D *CoreData::getGameWinnerTexture() {
|
||||||
Texture2D *CoreData::getHealthbarTexture() {
|
Texture2D *CoreData::getHealthbarTexture() {
|
||||||
string data_path = getDataPath();
|
string data_path = getDataPath();
|
||||||
loadTextureIfRequired(&healthbarTexture,data_path,
|
loadTextureIfRequired(&healthbarTexture,data_path,
|
||||||
CORE_MISC_TEXTURES_PATH + "healthbar.*", tsyst_healthbarTexture,
|
CORE_MISC_TEXTURES_PATH + "healthbar.png", tsyst_healthbarTexture,
|
||||||
true, false, false, true);
|
true, false, false, true);
|
||||||
|
|
||||||
return healthbarTexture;
|
return healthbarTexture;
|
||||||
|
@ -438,7 +438,7 @@ Texture2D *CoreData::getHealthbarTexture() {
|
||||||
Texture2D *CoreData::getHealthbarBackgroundTexture() {
|
Texture2D *CoreData::getHealthbarBackgroundTexture() {
|
||||||
string data_path = getDataPath();
|
string data_path = getDataPath();
|
||||||
loadTextureIfRequired(&healthbarBackgroundTexture,data_path,
|
loadTextureIfRequired(&healthbarBackgroundTexture,data_path,
|
||||||
CORE_MISC_TEXTURES_PATH + "healthbarBackground.*", tsyst_healthbarBackgroundTexture,
|
CORE_MISC_TEXTURES_PATH + "healthbarBackground.png", tsyst_healthbarBackgroundTexture,
|
||||||
true, false, false, true);
|
true, false, false, true);
|
||||||
|
|
||||||
return healthbarBackgroundTexture;
|
return healthbarBackgroundTexture;
|
||||||
|
|
|
@ -5424,7 +5424,7 @@ void Renderer::renderMorphEffects(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Renderer::renderSelectionEffects() {
|
void Renderer::renderSelectionEffects(int healthbarMode) {
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5458,24 +5458,39 @@ void Renderer::renderSelectionEffects() {
|
||||||
currVec.y+= 0.3f;
|
currVec.y+= 0.3f;
|
||||||
|
|
||||||
//selection circle
|
//selection circle
|
||||||
|
int finalHealthbarMode=hbvUndefined;
|
||||||
|
if(healthbarMode==hbvUndefined) {
|
||||||
|
finalHealthbarMode=unit->getFaction()->getType()->getHealthbarVisible();
|
||||||
|
} else {
|
||||||
|
finalHealthbarMode=healthbarMode;
|
||||||
|
}
|
||||||
|
bool healthbarsVisible=((finalHealthbarMode&hbvAlways)||(finalHealthbarMode&hbvSelected)||(finalHealthbarMode&hbvIfNeeded));
|
||||||
|
float selectionCircleThickness=0.2f;
|
||||||
|
float hpRatio;
|
||||||
|
if(healthbarsVisible) {
|
||||||
|
hpRatio=unit->getHpRatio();
|
||||||
|
selectionCircleThickness=0.05f;
|
||||||
|
hpRatio=1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
if(world->getThisFactionIndex() == unit->getFactionIndex()) {
|
if(world->getThisFactionIndex() == unit->getFactionIndex()) {
|
||||||
if( showDebugUI == true &&
|
if( showDebugUI == true &&
|
||||||
((showDebugUILevel & debugui_unit_titles) == debugui_unit_titles) &&
|
((showDebugUILevel & debugui_unit_titles) == debugui_unit_titles) &&
|
||||||
unit->getCommandSize() > 0 &&
|
unit->getCommandSize() > 0 &&
|
||||||
dynamic_cast<const BuildCommandType *>(unit->getCurrCommand()->getCommandType()) != NULL) {
|
dynamic_cast<const BuildCommandType *>(unit->getCurrCommand()->getCommandType()) != NULL) {
|
||||||
glColor4f(unit->getHpRatio(), unit->getHpRatio(), unit->getHpRatio(), 0.3f);
|
glColor4f(hpRatio, hpRatio, hpRatio, 0.3f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
glColor4f(0, unit->getHpRatio(), 0, 0.3f);
|
glColor4f(0, hpRatio, 0, 0.3f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( world->getThisTeamIndex() == unit->getTeam()) {
|
else if ( world->getThisTeamIndex() == unit->getTeam()) {
|
||||||
glColor4f(unit->getHpRatio(), unit->getHpRatio(), 0, 0.3f);
|
glColor4f(hpRatio, hpRatio, 0, 0.3f);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
glColor4f(unit->getHpRatio(), 0, 0, 0.3f);
|
glColor4f(hpRatio, 0, 0, 0.3f);
|
||||||
}
|
}
|
||||||
renderSelectionCircle(currVec, unit->getType()->getSize(), selectionCircleRadius);
|
renderSelectionCircle(currVec, unit->getType()->getSize(), selectionCircleRadius,selectionCircleThickness);
|
||||||
|
|
||||||
if( showDebugUI == true &&
|
if( showDebugUI == true &&
|
||||||
(showDebugUILevel & debugui_unit_titles) == debugui_unit_titles) {
|
(showDebugUILevel & debugui_unit_titles) == debugui_unit_titles) {
|
||||||
|
@ -5499,7 +5514,7 @@ void Renderer::renderSelectionEffects() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//magic circle
|
//magic circle
|
||||||
if(world->getThisFactionIndex() == unit->getFactionIndex() && unit->getType()->getMaxEp() > 0) {
|
if(!healthbarsVisible && world->getThisFactionIndex() == unit->getFactionIndex() && unit->getType()->getMaxEp() > 0) {
|
||||||
glColor4f(unit->getEpRatio()/2.f, unit->getEpRatio(), unit->getEpRatio(), 0.5f);
|
glColor4f(unit->getEpRatio()/2.f, unit->getEpRatio(), unit->getEpRatio(), 0.5f);
|
||||||
renderSelectionCircle(currVec, unit->getType()->getSize(), magicCircleRadius);
|
renderSelectionCircle(currVec, unit->getType()->getSize(), magicCircleRadius);
|
||||||
}
|
}
|
||||||
|
@ -5669,81 +5684,88 @@ void Renderer::renderHealthBars(int healthbarMode){
|
||||||
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(isHealthBarVisible(unit,healthbarMode)) {
|
||||||
|
float healthbarheight;
|
||||||
|
float healthbarthickness;
|
||||||
|
const Texture2D *healthbarTexture;
|
||||||
|
const Texture2D *healthbarBackgroundTexture;
|
||||||
|
bool healthbarLineBorder;
|
||||||
|
|
||||||
float healthbarheight;
|
//get settings of the faction
|
||||||
float healthbarthickness;
|
healthbarheight=unit->getFaction()->getType()->getHealthbarHeight();
|
||||||
int healthbarVisible=hbvUndefined;
|
healthbarthickness=unit->getFaction()->getType()->getHealthbarThickness();
|
||||||
const Texture2D *healthbarTexture;
|
healthbarLineBorder=unit->getFaction()->getType()->isHealthbarLineBorder();
|
||||||
const Texture2D *healthbarBackgroundTexture;
|
CoreData &coreData= CoreData::getInstance();
|
||||||
bool healthbarLineBorder;
|
//First try faction texture then use core Texture
|
||||||
|
if(unit->getFaction()->getType()->isHealthbarBorderTextureEnabled()) {
|
||||||
|
healthbarTexture=unit->getFaction()->getType()->getHealthbarTexture();
|
||||||
|
if(healthbarTexture==NULL) {
|
||||||
|
healthbarTexture=coreData.getHealthbarTexture();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
healthbarTexture=NULL;
|
||||||
|
}
|
||||||
|
if(unit->getFaction()->getType()->isHealthbarBackgroundTextureEnabled()) {
|
||||||
|
healthbarBackgroundTexture=unit->getFaction()->getType()->getHealthbarBackgroundTexture();
|
||||||
|
if(healthbarBackgroundTexture==NULL) {
|
||||||
|
healthbarBackgroundTexture=coreData.getHealthbarBackgroundTexture();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
healthbarBackgroundTexture=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
//get settings of the faction
|
//replace them by the ones from the unit if existent
|
||||||
healthbarheight=unit->getFaction()->getType()->getHealthbarHeight();
|
if(unit->getType()->getHealthbarVisible()!=hbvOff && unit->getType()->getHealthbarVisible()!=hbvUndefined) {
|
||||||
healthbarthickness=unit->getFaction()->getType()->getHealthbarThickness();
|
if(unit->getType()->getHealthbarHeight()!=-100.0f) {
|
||||||
//check options (hotkey)
|
healthbarheight=unit->getType()->getHealthbarHeight();
|
||||||
if(healthbarMode==hbvUndefined) {
|
}
|
||||||
healthbarVisible=unit->getFaction()->getType()->getHealthbarVisible();
|
if(unit->getType()->getHealthbarThickness()!=-1.0f) {
|
||||||
} else {
|
healthbarthickness=unit->getType()->getHealthbarThickness();
|
||||||
healthbarVisible=healthbarMode;
|
}
|
||||||
}
|
|
||||||
healthbarLineBorder=unit->getFaction()->getType()->isHealthbarLineBorder();
|
|
||||||
CoreData &coreData= CoreData::getInstance();
|
|
||||||
//First try faction texture then use core Texture
|
|
||||||
if(unit->getFaction()->getType()->isHealthbarBorderTextureEnabled()) {
|
|
||||||
healthbarTexture=unit->getFaction()->getType()->getHealthbarTexture();
|
|
||||||
if(healthbarTexture==NULL) {
|
|
||||||
healthbarTexture=coreData.getHealthbarTexture();
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
healthbarTexture=NULL;
|
|
||||||
}
|
|
||||||
if(unit->getFaction()->getType()->isHealthbarBackgroundTextureEnabled()) {
|
|
||||||
healthbarBackgroundTexture=unit->getFaction()->getType()->getHealthbarBackgroundTexture();
|
|
||||||
if(healthbarBackgroundTexture==NULL) {
|
|
||||||
healthbarBackgroundTexture=coreData.getHealthbarBackgroundTexture();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
healthbarBackgroundTexture=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//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();
|
|
||||||
}
|
|
||||||
if(healthbarMode==hbvUndefined) { //don't override the visible setting when hotkey is not hbvUndefined
|
|
||||||
healthbarVisible=unit->getType()->getHealthbarVisible();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool settingsWantToRenderThem=!(healthbarVisible==hbvUndefined || (healthbarVisible&hbvOff))
|
|
||||||
&& ((healthbarVisible&hbvAlways)
|
|
||||||
|| ((healthbarVisible&hbvDamaged) && unit->getHp()!=unit->getType()->getMaxHp())
|
|
||||||
|| ((healthbarVisible&hbvSelected) && game->getGui()->isSelected(unit)));
|
|
||||||
|
|
||||||
if(unit->isAlive() && (settingsWantToRenderThem)) {
|
|
||||||
Vec3f currVec= unit->getCurrVectorFlat();
|
Vec3f currVec= unit->getCurrVectorFlat();
|
||||||
if(healthbarheight==-100.0f) {
|
if(healthbarheight==-100.0f) {
|
||||||
currVec.y+=unit->getType()->getHeight();
|
currVec.y+=unit->getType()->getHeight();
|
||||||
} else {
|
} else {
|
||||||
currVec.y+=healthbarheight;
|
currVec.y+=healthbarheight;
|
||||||
}
|
}
|
||||||
|
renderHealthBar(currVec,unit,healthbarthickness,healthbarLineBorder,healthbarTexture,healthbarBackgroundTexture);
|
||||||
if(unit->getType()->getMaxEp() > 0) {
|
|
||||||
healthbarthickness=healthbarthickness*2;
|
|
||||||
renderHealthBar(currVec,unit->getType()->getSize(),unit->getHpRatio(),healthbarthickness,healthbarLineBorder,healthbarTexture,healthbarBackgroundTexture,unit->getEpRatio());
|
|
||||||
} else {
|
|
||||||
renderHealthBar(currVec,unit->getType()->getSize(),unit->getHpRatio(),healthbarthickness,healthbarLineBorder,healthbarTexture,healthbarBackgroundTexture);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Renderer::isHealthBarVisible(const Unit *unit,int healthbarMode){
|
||||||
|
int healthbarVisible=hbvUndefined;
|
||||||
|
//check options (hotkey)
|
||||||
|
if(healthbarMode==hbvUndefined) {
|
||||||
|
healthbarVisible=unit->getFaction()->getType()->getHealthbarVisible();
|
||||||
|
} else {
|
||||||
|
healthbarVisible=healthbarMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
//replace them by the ones from the unit if existent
|
||||||
|
if(unit->getType()->getHealthbarVisible()!=hbvOff && unit->getType()->getHealthbarVisible()!=hbvUndefined) {
|
||||||
|
if(healthbarMode==hbvUndefined) { //don't override the visible setting when hotkey is not hbvUndefined
|
||||||
|
healthbarVisible=unit->getType()->getHealthbarVisible();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool settingsWantToRenderThem=!(healthbarVisible==hbvUndefined || (healthbarVisible&hbvOff))
|
||||||
|
&& ((healthbarVisible&hbvAlways)
|
||||||
|
|| ((healthbarVisible&hbvIfNeeded) && unit->getHp()!=unit->getType()->getMaxHp())
|
||||||
|
|| ((healthbarVisible&hbvIfNeeded) && unit->getType()->getMaxEp() > 0 && unit->getEp()!=unit->getType()->getMaxEp())
|
||||||
|
|| ((healthbarVisible&hbvIfNeeded) && unit->getProductionPercent() > 0)
|
||||||
|
|| ((healthbarVisible&hbvSelected) && game->getGui()->isSelected(unit)));
|
||||||
|
|
||||||
|
if(unit->isAlive() && (settingsWantToRenderThem)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::renderWaterEffects(){
|
void Renderer::renderWaterEffects(){
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||||
return;
|
return;
|
||||||
|
@ -8349,11 +8371,26 @@ void Renderer::enableProjectiveTexturing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== private aux drawing ====================
|
// ==================== private aux drawing ====================
|
||||||
void Renderer::renderHealthBar(Vec3f v, int size, float hp, float height, bool lineBorder, const Texture2D *texture, const Texture2D *backgroundTexture , float ep) {
|
void Renderer::renderHealthBar(Vec3f v, Unit *unit, float height, bool lineBorder, const Texture2D *texture, const Texture2D *backgroundTexture) {
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int numberOfBars=1;
|
||||||
|
int barCount=0;
|
||||||
|
float hp=unit->getHpRatio();
|
||||||
|
float ep=-1.f;
|
||||||
|
if(unit->getType()->getMaxEp()!=0){
|
||||||
|
ep=unit->getEpRatio();
|
||||||
|
numberOfBars++;
|
||||||
|
}
|
||||||
|
int productionPercent=unit->getProductionPercent();
|
||||||
|
if(productionPercent!=-1) {
|
||||||
|
numberOfBars++;
|
||||||
|
}
|
||||||
|
int size=unit->getType()->getSize();
|
||||||
|
|
||||||
|
|
||||||
Vec3f rightVector;
|
Vec3f rightVector;
|
||||||
Vec3f upVector;
|
Vec3f upVector;
|
||||||
Vec3f rightVectorTexture;
|
Vec3f rightVectorTexture;
|
||||||
|
@ -8363,7 +8400,7 @@ void Renderer::renderHealthBar(Vec3f v, int size, float hp, float height, bool l
|
||||||
float width=(float)size/6+0.25f;
|
float width=(float)size/6+0.25f;
|
||||||
float red;
|
float red;
|
||||||
float green;
|
float green;
|
||||||
float brightness=0.7f;
|
float brightness=0.8f;
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -8375,18 +8412,20 @@ void Renderer::renderHealthBar(Vec3f v, int size, float hp, float height, bool l
|
||||||
rightVectorTexture=rightVector*2;
|
rightVectorTexture=rightVector*2;
|
||||||
upVectorTexture=upVector*4;
|
upVectorTexture=upVector*4;
|
||||||
|
|
||||||
hp=hp*2-1;
|
|
||||||
ep=ep*2-1;
|
|
||||||
|
|
||||||
//from green to yellow to red
|
//from green to yellow to red
|
||||||
if(hp >= 0.5f) {
|
|
||||||
green=brightness;
|
if(hp >= 0.75f) {
|
||||||
red=brightness-(hp-0.5f)*brightness;
|
green=1;
|
||||||
|
red=1-((2*hp-1)-0.5f);
|
||||||
} else {
|
} else {
|
||||||
red=brightness;
|
red=1;
|
||||||
green=brightness+(hp-0.5f)*brightness;
|
green=0.5f+(2*hp-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(red>1.0f) red=1.0f;
|
||||||
|
if(green>1.0f) green=1.0f;
|
||||||
|
float yOffset=(float)numberOfBars/2.f;
|
||||||
|
|
||||||
if(backgroundTexture!=NULL) {
|
if(backgroundTexture!=NULL) {
|
||||||
//backgroundTexture
|
//backgroundTexture
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
@ -8395,50 +8434,70 @@ void Renderer::renderHealthBar(Vec3f v, int size, float hp, float height, bool l
|
||||||
//glColor4f(red+0.1f,green+0.1f,0.1f,0.5f);
|
//glColor4f(red+0.1f,green+0.1f,0.1f,0.5f);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2i(0,1);
|
glTexCoord2i(0,1);
|
||||||
glVertex3fv((v - (rightVectorTexture*width - upVectorTexture*height)).ptr());
|
glVertex3fv((v - (rightVectorTexture*width - upVectorTexture*height*yOffset)).ptr());
|
||||||
glTexCoord2i(0,0);
|
glTexCoord2i(0,0);
|
||||||
glVertex3fv((v - (rightVectorTexture*width + upVectorTexture*height)).ptr());
|
glVertex3fv((v - (rightVectorTexture*width + upVectorTexture*height*yOffset)).ptr());
|
||||||
glTexCoord2i(1,0);
|
glTexCoord2i(1,0);
|
||||||
glVertex3fv((v + (rightVectorTexture*width - upVectorTexture*height)).ptr());
|
glVertex3fv((v + (rightVectorTexture*width - upVectorTexture*height*yOffset)).ptr());
|
||||||
glTexCoord2i(1,1);
|
glTexCoord2i(1,1);
|
||||||
glVertex3fv((v + (rightVectorTexture*width + upVectorTexture*height)).ptr());
|
glVertex3fv((v + (rightVectorTexture*width + upVectorTexture*height*yOffset)).ptr());
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
//healthbar
|
//healthbar
|
||||||
glColor4f(red,green,0.0f,0.4f);
|
glColor4f(red*brightness,green*brightness,0.0f,0.4f);
|
||||||
glBegin(GL_QUADS);
|
//hpbar
|
||||||
if(ep < -2.0f) {
|
barCount++;
|
||||||
//hpbar
|
internalRenderHp(numberOfBars,barCount,hp,v,width,height,rightVector,upVector);
|
||||||
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());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//hpbar
|
if(ep > -1.0f) {
|
||||||
glVertex3fv((v - (rightVector*width - upVector*height)).ptr());
|
//epbar
|
||||||
glVertex3fv((v - (rightVector*width + upVector*height*0.0f)).ptr());
|
barCount++;
|
||||||
glVertex3fv((v + (rightVector*hp*width - upVector*height*0.0f)).ptr());
|
//glColor4f(brightness,0,brightness,0.5f);
|
||||||
glVertex3fv((v + (rightVector*hp*width + upVector*height)).ptr());
|
glColor4f(.15f*brightness,0.3f*brightness,0.8f*brightness,0.7f);
|
||||||
//epbar
|
internalRenderHp(numberOfBars,barCount,ep,v,width,height,rightVector,upVector);
|
||||||
glColor4f(brightness,0,brightness,0.4f);
|
}
|
||||||
glVertex3fv((v - (rightVector*width + upVector*height*0.0f)).ptr());
|
if(productionPercent!=-1) {
|
||||||
glVertex3fv((v - (rightVector*width + upVector*height)).ptr());
|
barCount++;
|
||||||
glVertex3fv((v + (rightVector*ep*width - upVector*height)).ptr());
|
glColor4f(brightness,0,brightness,0.6f);
|
||||||
glVertex3fv((v + (rightVector*ep*width - upVector*height*0.0f)).ptr());
|
//glColor4f(0.0f*brightness,0.4f*brightness,0.2f*brightness,0.8f);
|
||||||
}
|
internalRenderHp(numberOfBars,barCount,(float)productionPercent/100,v,width,height,rightVector,upVector);
|
||||||
glEnd();
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// glBegin(GL_QUADS);
|
||||||
|
// if(ep < -2.0f) {
|
||||||
|
// //hpbar
|
||||||
|
// 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());
|
||||||
|
//
|
||||||
|
// } else {
|
||||||
|
// //hpbar
|
||||||
|
// glVertex3fv((v - (rightVector*width - upVector*height)).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)).ptr());
|
||||||
|
// //epbar
|
||||||
|
// glColor4f(brightness,0,brightness,0.4f);
|
||||||
|
// glVertex3fv((v - (rightVector*width + upVector*height*0.0f)).ptr());
|
||||||
|
// glVertex3fv((v - (rightVector*width + upVector*height)).ptr());
|
||||||
|
// glVertex3fv((v + (rightVector*ep*width - upVector*height)).ptr());
|
||||||
|
// glVertex3fv((v + (rightVector*ep*width - upVector*height*0.0f)).ptr());
|
||||||
|
// }
|
||||||
|
// glEnd();
|
||||||
|
|
||||||
if(lineBorder) {
|
if(lineBorder) {
|
||||||
//border
|
//border
|
||||||
glColor4f(red+0.1f,green+0.1f,0.1f,0.5f);
|
glColor4f(red*brightness,green*brightness,0.1f*brightness,0.5f);
|
||||||
glBegin(GL_LINE_LOOP);
|
glBegin(GL_LINE_LOOP);
|
||||||
glVertex3fv((v - (rightVector*width - upVector*height)).ptr());
|
glVertex3fv((v - (rightVector*width - upVector*height*yOffset)).ptr());
|
||||||
glVertex3fv((v - (rightVector*width + upVector*height)).ptr());
|
glVertex3fv((v - (rightVector*width + upVector*height*yOffset)).ptr());
|
||||||
glVertex3fv((v + (rightVector*width - upVector*height)).ptr());
|
glVertex3fv((v + (rightVector*width - upVector*height*yOffset)).ptr());
|
||||||
glVertex3fv((v + (rightVector*width + upVector*height)).ptr());
|
glVertex3fv((v + (rightVector*width + upVector*height*yOffset)).ptr());
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8450,13 +8509,13 @@ void Renderer::renderHealthBar(Vec3f v, int size, float hp, float height, bool l
|
||||||
//glColor4f(red+0.1f,green+0.1f,0.1f,0.5f);
|
//glColor4f(red+0.1f,green+0.1f,0.1f,0.5f);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2i(0,1);
|
glTexCoord2i(0,1);
|
||||||
glVertex3fv((v - (rightVectorTexture*width - upVectorTexture*height)).ptr());
|
glVertex3fv((v - (rightVectorTexture*width - upVectorTexture*height*yOffset)).ptr());
|
||||||
glTexCoord2i(0,0);
|
glTexCoord2i(0,0);
|
||||||
glVertex3fv((v - (rightVectorTexture*width + upVectorTexture*height)).ptr());
|
glVertex3fv((v - (rightVectorTexture*width + upVectorTexture*height*yOffset)).ptr());
|
||||||
glTexCoord2i(1,0);
|
glTexCoord2i(1,0);
|
||||||
glVertex3fv((v + (rightVectorTexture*width - upVectorTexture*height)).ptr());
|
glVertex3fv((v + (rightVectorTexture*width - upVectorTexture*height*yOffset)).ptr());
|
||||||
glTexCoord2i(1,1);
|
glTexCoord2i(1,1);
|
||||||
glVertex3fv((v + (rightVectorTexture*width + upVectorTexture*height)).ptr());
|
glVertex3fv((v + (rightVectorTexture*width + upVectorTexture*height*yOffset)).ptr());
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
@ -8464,6 +8523,23 @@ void Renderer::renderHealthBar(Vec3f v, int size, float hp, float height, bool l
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::internalRenderHp(int numberOfBars, int barNumber, float hp,
|
||||||
|
Vec3f posVector, float width, float singleHPheight, Vec3f rightVector, Vec3f upVector) {
|
||||||
|
|
||||||
|
float yOffset=(float)numberOfBars*singleHPheight/2;
|
||||||
|
float offsetTop=yOffset-singleHPheight*(barNumber-1);
|
||||||
|
float offsetBottom=yOffset-singleHPheight*barNumber;
|
||||||
|
offsetBottom=offsetBottom*-1;
|
||||||
|
hp=hp*2-1;
|
||||||
|
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glVertex3fv((posVector - (rightVector*width - upVector*offsetTop)).ptr());
|
||||||
|
glVertex3fv((posVector - (rightVector*width + upVector*offsetBottom)).ptr());
|
||||||
|
glVertex3fv((posVector + (rightVector*hp*width - upVector*offsetBottom)).ptr());
|
||||||
|
glVertex3fv((posVector + (rightVector*hp*width + upVector*offsetTop)).ptr());
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::renderSelectionCircle(Vec3f v, int size, float radius, float thickness) {
|
void Renderer::renderSelectionCircle(Vec3f v, int size, float radius, float thickness) {
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -557,8 +557,8 @@ public:
|
||||||
void renderUnits(bool airUnits, const int renderFps);
|
void renderUnits(bool airUnits, const int renderFps);
|
||||||
void renderUnitsToBuild(const int renderFps);
|
void renderUnitsToBuild(const int renderFps);
|
||||||
|
|
||||||
void renderSelectionEffects();
|
void renderSelectionEffects(int healthbarMode);
|
||||||
void renderHealthBars(int forceHealthbars=hbvUndefined);
|
void renderHealthBars(int healthbarMode);
|
||||||
void renderWaterEffects();
|
void renderWaterEffects();
|
||||||
void renderHud();
|
void renderHud();
|
||||||
void renderMinimap();
|
void renderMinimap();
|
||||||
|
@ -690,7 +690,9 @@ private:
|
||||||
|
|
||||||
//private aux drawing
|
//private aux drawing
|
||||||
void renderSelectionCircle(Vec3f v, int size, float radius, float thickness=0.2f);
|
void renderSelectionCircle(Vec3f v, int size, float radius, float thickness=0.2f);
|
||||||
void renderHealthBar(Vec3f v, int size, float hp, float height, bool lineBorder, const Texture2D *texture=NULL, const Texture2D *backgroundTexture=NULL , float ep=-1.0f);
|
bool isHealthBarVisible(const Unit *unit,int healthbarMode);
|
||||||
|
void renderHealthBar(Vec3f v, Unit *unit, float height, bool lineBorder, const Texture2D *texture=NULL, const Texture2D *backgroundTexture=NULL);
|
||||||
|
void internalRenderHp(int numberOfBars, int barNumber, float hp, Vec3f posVector, float width, float singleHPheight, Vec3f rightVector, Vec3f upVector);
|
||||||
void renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture);
|
void renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture);
|
||||||
void renderArrow(const Vec3f &pos1, const Vec3f &pos2, const Vec3f &color, float width);
|
void renderArrow(const Vec3f &pos1, const Vec3f &pos2, const Vec3f &color, float width);
|
||||||
void renderTile(const Vec2i &pos);
|
void renderTile(const Vec2i &pos);
|
||||||
|
|
|
@ -233,11 +233,12 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu, Program
|
||||||
|
|
||||||
listBoxHealthBars.registerGraphicComponent(containerName,"lisBoxtHealthBars");
|
listBoxHealthBars.registerGraphicComponent(containerName,"lisBoxtHealthBars");
|
||||||
listBoxHealthBars.init(currentColumnStart ,currentLine, 300 );
|
listBoxHealthBars.init(currentColumnStart ,currentLine, 300 );
|
||||||
listBoxHealthBars.pushBackItem(lang.getString("HealthbarsDefault"));
|
listBoxHealthBars.pushBackItem(lang.getString("HealthbarsFactionDefault"));
|
||||||
listBoxHealthBars.pushBackItem(lang.getString("HealthbarsOff"));
|
listBoxHealthBars.pushBackItem(lang.getString("HealthbarsOff"));
|
||||||
listBoxHealthBars.pushBackItem(lang.getString("HealthbarsAlways"));
|
listBoxHealthBars.pushBackItem(lang.getString("HealthbarsAlways"));
|
||||||
listBoxHealthBars.pushBackItem(lang.getString("HealthbarsDamaged"));
|
listBoxHealthBars.pushBackItem(lang.getString("HealthbarsIfNeeded"));
|
||||||
listBoxHealthBars.pushBackItem(lang.getString("HealthbarsSelected"));
|
listBoxHealthBars.pushBackItem(lang.getString("HealthbarsSelected"));
|
||||||
|
listBoxHealthBars.pushBackItem(lang.getString("HealthbarsSelectedOrNeeded"));
|
||||||
|
|
||||||
int hpMode=config.getInt("HealthBarMode","0");
|
int hpMode=config.getInt("HealthBarMode","0");
|
||||||
int hpIndex=0;
|
int hpIndex=0;
|
||||||
|
@ -251,12 +252,15 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu, Program
|
||||||
case hbvAlways:
|
case hbvAlways:
|
||||||
hpIndex = 2;
|
hpIndex = 2;
|
||||||
break;
|
break;
|
||||||
case hbvDamaged:
|
case hbvIfNeeded:
|
||||||
hpIndex = 3;
|
hpIndex = 3;
|
||||||
break;
|
break;
|
||||||
case hbvSelected:
|
case hbvSelected:
|
||||||
hpIndex = 4;
|
hpIndex = 4;
|
||||||
break;
|
break;
|
||||||
|
case hbvSelected | hbvIfNeeded:
|
||||||
|
hpIndex = 5;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
hpIndex = 0;
|
hpIndex = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -1121,11 +1125,34 @@ void MenuStateOptions::saveConfig(){
|
||||||
config.setBool("DisableScreenshotConsoleText", !checkBoxDisableScreenshotConsoleText.getValue());
|
config.setBool("DisableScreenshotConsoleText", !checkBoxDisableScreenshotConsoleText.getValue());
|
||||||
config.setBool("MouseMoveScrollsWorld", checkBoxMouseMoveScrollsWorld.getValue());
|
config.setBool("MouseMoveScrollsWorld", checkBoxMouseMoveScrollsWorld.getValue());
|
||||||
config.setString("CameraMoveSpeed", listCameraMoveSpeed.getSelectedItem());
|
config.setString("CameraMoveSpeed", listCameraMoveSpeed.getSelectedItem());
|
||||||
int hpModeHelp=0;
|
|
||||||
if(listBoxHealthBars.getSelectedItemIndex()!=0){
|
int hpIndex=listBoxHealthBars.getSelectedItemIndex();
|
||||||
hpModeHelp=pow(2,listBoxHealthBars.getSelectedItemIndex()-1);
|
int hpMode=hbvUndefined;
|
||||||
|
switch (hpIndex) {
|
||||||
|
case 0:
|
||||||
|
hpMode = hbvUndefined;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
hpMode = hbvOff;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
hpMode = hbvAlways;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
hpMode = hbvIfNeeded;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
hpMode = hbvSelected;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
hpMode = hbvSelected | hbvIfNeeded;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
hpMode = hbvUndefined;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
config.setInt("HealthBarMode",hpModeHelp );
|
|
||||||
|
config.setInt("HealthBarMode",hpMode );
|
||||||
config.setBool("VisibleHud", checkBoxVisibleHud.getValue());
|
config.setBool("VisibleHud", checkBoxVisibleHud.getValue());
|
||||||
config.setBool("ChatStaysActive", checkBoxChatStaysActive.getValue());
|
config.setBool("ChatStaysActive", checkBoxChatStaysActive.getValue());
|
||||||
config.setBool("TimeDisplay", checkBoxTimeDisplay.getValue());
|
config.setBool("TimeDisplay", checkBoxTimeDisplay.getValue());
|
||||||
|
|
|
@ -36,7 +36,7 @@ FactionType::FactionType() {
|
||||||
personalityType = fpt_Normal;
|
personalityType = fpt_Normal;
|
||||||
isLinked = false;
|
isLinked = false;
|
||||||
healthbarheight= -100.0f;
|
healthbarheight= -100.0f;
|
||||||
healthbarthickness= 0.05f;
|
healthbarthickness= 0.11f;
|
||||||
healthbarVisible=hbvUndefined;
|
healthbarVisible=hbvUndefined;
|
||||||
healthbarBorderTextureEnabled=false;
|
healthbarBorderTextureEnabled=false;
|
||||||
healthbarBackgroundTextureEnabled=false;
|
healthbarBackgroundTextureEnabled=false;
|
||||||
|
@ -299,8 +299,8 @@ void FactionType::load(const string &factionName, const TechTree *techTree, Chec
|
||||||
healthbarVisible=healthbarVisible|hbvAlways;
|
healthbarVisible=healthbarVisible|hbvAlways;
|
||||||
} else if(current=="selected") {
|
} else if(current=="selected") {
|
||||||
healthbarVisible=healthbarVisible|hbvSelected;
|
healthbarVisible=healthbarVisible|hbvSelected;
|
||||||
} else if(current=="damaged") {
|
} else if(current=="ifNeeded") {
|
||||||
healthbarVisible=healthbarVisible|hbvDamaged;
|
healthbarVisible=healthbarVisible|hbvIfNeeded;
|
||||||
} else if(current=="off") {
|
} else if(current=="off") {
|
||||||
healthbarVisible=healthbarVisible|hbvOff;
|
healthbarVisible=healthbarVisible|hbvOff;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -467,8 +467,8 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree,
|
||||||
healthbarVisible=healthbarVisible|hbvAlways;
|
healthbarVisible=healthbarVisible|hbvAlways;
|
||||||
} else if(current=="selected") {
|
} else if(current=="selected") {
|
||||||
healthbarVisible=healthbarVisible|hbvSelected;
|
healthbarVisible=healthbarVisible|hbvSelected;
|
||||||
} else if(current=="damaged") {
|
} else if(current=="ifNeeded") {
|
||||||
healthbarVisible=healthbarVisible|hbvDamaged;
|
healthbarVisible=healthbarVisible|hbvIfNeeded;
|
||||||
} else if(current=="off") {
|
} else if(current=="off") {
|
||||||
healthbarVisible=healthbarVisible|hbvOff;
|
healthbarVisible=healthbarVisible|hbvOff;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -120,7 +120,7 @@ enum HealthbarVisible {
|
||||||
hbvUndefined=0,
|
hbvUndefined=0,
|
||||||
hbvOff=1,
|
hbvOff=1,
|
||||||
hbvAlways=2,
|
hbvAlways=2,
|
||||||
hbvDamaged=4,
|
hbvIfNeeded=4,
|
||||||
hbvSelected=8
|
hbvSelected=8
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue