mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 21:33:59 +02:00
initial attempt to add a visual food low warning (consumable falls to 25% and balance is ticking down)
This commit is contained in:
@@ -1605,16 +1605,35 @@ void Renderer::renderResourceStatus() {
|
||||
|
||||
//draw resource status
|
||||
if(showResource) {
|
||||
|
||||
string str= intToStr(r->getAmount());
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
Vec4f resourceFontColor = fontColor;
|
||||
|
||||
bool isNegativeConsumableDisplayCycle = false;
|
||||
if(rt->getClass() == rcConsumable) {
|
||||
// Show in red font if negative
|
||||
const double minWarnPercent = 25.0;
|
||||
//if(r->getBalance() < 0) {
|
||||
if(r->getBalance() < 0 &&
|
||||
((thisFaction->getStoreAmount(rt) > 0 && (double)r->getAmount() / (double)thisFaction->getStoreAmount(rt) * 100.0 <= minWarnPercent) ||
|
||||
(thisFaction->getStoreAmount(rt) <= 0 && (double)r->getAmount() <= minWarnPercent))) {
|
||||
if(time(NULL) % 2 == 0) {
|
||||
isNegativeConsumableDisplayCycle = true;
|
||||
glColor3f(RED.x,RED.y,RED.z);
|
||||
resourceFontColor = RED;
|
||||
}
|
||||
//printf("Balance is negative!");
|
||||
}
|
||||
}
|
||||
if(isNegativeConsumableDisplayCycle == false) {
|
||||
glColor3f(1.f, 1.f, 1.f);
|
||||
}
|
||||
|
||||
renderQuad(j*100+200, metrics.getVirtualH()-30, 16, 16, rt->getImage());
|
||||
|
||||
if(rt->getClass() != rcStatic)
|
||||
{
|
||||
if(rt->getClass() != rcStatic) {
|
||||
str+= "/" + intToStr(thisFaction->getStoreAmount(rt));
|
||||
}
|
||||
if(rt->getClass() == rcConsumable) {
|
||||
@@ -1630,18 +1649,17 @@ void Renderer::renderResourceStatus() {
|
||||
if(renderText3DEnabled == true) {
|
||||
renderTextShadow3D(
|
||||
str, CoreData::getInstance().getDisplayFontSmall3D(),
|
||||
fontColor,
|
||||
resourceFontColor,
|
||||
j*100+220, metrics.getVirtualH()-30, false);
|
||||
}
|
||||
else {
|
||||
renderTextShadow(
|
||||
str, CoreData::getInstance().getDisplayFontSmall(),
|
||||
fontColor,
|
||||
resourceFontColor,
|
||||
j*100+220, metrics.getVirtualH()-30, false);
|
||||
}
|
||||
++j;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
glPopAttrib();
|
||||
|
@@ -407,6 +407,13 @@ public:
|
||||
Vec4() {
|
||||
};
|
||||
|
||||
explicit Vec4(const T *p){
|
||||
this->x= p[0];
|
||||
this->y= p[1];
|
||||
this->z= p[2];
|
||||
this->w= p[3];
|
||||
}
|
||||
|
||||
explicit Vec4(T *p){
|
||||
this->x= p[0];
|
||||
this->y= p[1];
|
||||
|
Reference in New Issue
Block a user