different rendering of resources in teammode
This commit is contained in:
parent
5099f19709
commit
47c181d2ab
|
@ -2405,10 +2405,42 @@ void Renderer::renderResourceStatus() {
|
||||||
|
|
||||||
int rowsRendered = 0;
|
int rowsRendered = 0;
|
||||||
int resourceCountRendered = 0;
|
int resourceCountRendered = 0;
|
||||||
|
bool twoRessourceLines=false;
|
||||||
|
|
||||||
|
// If we are in team mode, lets render team totals
|
||||||
|
if(renderResourcesInTeamMode() == true) {
|
||||||
|
resourceCountRendered = 0;
|
||||||
|
for(int techTreeResourceTypeIndex = 0;
|
||||||
|
techTreeResourceTypeIndex < world->getTechTree()->getResourceTypeCount();
|
||||||
|
++techTreeResourceTypeIndex) {
|
||||||
|
|
||||||
|
const ResourceType *rt = world->getTechTree()->getResourceType(techTreeResourceTypeIndex);
|
||||||
|
|
||||||
|
if ( rt->getDisplayInHud() == false ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Faction *factionForResourceView = thisFaction;
|
||||||
|
bool localFactionResourcesOnly = false;
|
||||||
|
|
||||||
|
bool showResource = world->showResourceTypeForFaction(rt, factionForResourceView, localFactionResourcesOnly);
|
||||||
|
if(showResource == true) {
|
||||||
|
twoRessourceLines=true;
|
||||||
|
rowsRendered = renderResource(factionForResourceView,
|
||||||
|
localFactionResourcesOnly, twoRessourceLines, rt, 0,
|
||||||
|
resourceCountRendered);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rowsRendered > 0 || resourceCountRendered > 0) {
|
||||||
|
rowsRendered++;
|
||||||
|
}
|
||||||
|
resourceCountRendered = 0;
|
||||||
|
|
||||||
for(int techTreeResourceTypeIndex = 0;
|
for(int techTreeResourceTypeIndex = 0;
|
||||||
techTreeResourceTypeIndex < world->getTechTree()->getResourceTypeCount();
|
techTreeResourceTypeIndex < world->getTechTree()->getResourceTypeCount();
|
||||||
++techTreeResourceTypeIndex) {
|
++techTreeResourceTypeIndex) {
|
||||||
|
|
||||||
const ResourceType *rt = world->getTechTree()->getResourceType(techTreeResourceTypeIndex);
|
const ResourceType *rt = world->getTechTree()->getResourceType(techTreeResourceTypeIndex);
|
||||||
|
|
||||||
if ( rt->getDisplayInHud() == false ) {
|
if ( rt->getDisplayInHud() == false ) {
|
||||||
|
@ -2452,68 +2484,45 @@ void Renderer::renderResourceStatus() {
|
||||||
//if any unit produces the resource
|
//if any unit produces the resource
|
||||||
bool showResource = world->showResourceTypeForFaction(rt, factionForResourceView, false);
|
bool showResource = world->showResourceTypeForFaction(rt, factionForResourceView, false);
|
||||||
if(showResource == true) {
|
if(showResource == true) {
|
||||||
rowsRendered = renderResource(factionForResourceView,localFactionResourcesOnly,
|
renderResource(factionForResourceView, localFactionResourcesOnly,
|
||||||
rt, 0, resourceCountRendered);
|
twoRessourceLines, rt, rowsRendered, resourceCountRendered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we rendered single player resources above and we are in team mode,
|
|
||||||
// lets render team totals next
|
|
||||||
if(renderResourcesInTeamMode() == true) {
|
|
||||||
if(rowsRendered > 0 || resourceCountRendered > 0) {
|
|
||||||
rowsRendered++;
|
|
||||||
}
|
|
||||||
resourceCountRendered = 0;
|
|
||||||
for(int techTreeResourceTypeIndex = 0;
|
|
||||||
techTreeResourceTypeIndex < world->getTechTree()->getResourceTypeCount();
|
|
||||||
++techTreeResourceTypeIndex) {
|
|
||||||
|
|
||||||
const ResourceType *rt = world->getTechTree()->getResourceType(techTreeResourceTypeIndex);
|
|
||||||
|
|
||||||
if ( rt->getDisplayInHud() == false ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Faction *factionForResourceView = thisFaction;
|
|
||||||
bool localFactionResourcesOnly = false;
|
|
||||||
|
|
||||||
bool showResource = world->showResourceTypeForFaction(rt, factionForResourceView, localFactionResourcesOnly);
|
|
||||||
if(showResource == true) {
|
|
||||||
renderResource(factionForResourceView,localFactionResourcesOnly,
|
|
||||||
rt, rowsRendered, resourceCountRendered);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
|
||||||
assertGl();
|
assertGl();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Renderer::renderResource(const Faction *factionForResourceView,bool localFactionResourcesOnly,
|
int Renderer::renderResource(const Faction *factionForResourceView,bool localFactionResourcesOnly,
|
||||||
const ResourceType *rt, int startRow, int &resourceCountRendered) {
|
bool twoResourceLines, const ResourceType *rt, int startRow, int &resourceCountRendered) {
|
||||||
|
|
||||||
const Metrics &metrics = Metrics::getInstance();
|
const Metrics &metrics = Metrics::getInstance();
|
||||||
|
const int MAX_RESOURCES_PER_ROW = 6;
|
||||||
|
|
||||||
|
int resourceRowHeigth=30;
|
||||||
|
int resourceYStart=metrics.getVirtualH()-30;
|
||||||
|
if(twoResourceLines){
|
||||||
|
// we need to save some space
|
||||||
|
resourceYStart=metrics.getVirtualH()-22;
|
||||||
|
resourceRowHeigth=16;
|
||||||
|
}
|
||||||
|
|
||||||
//draw resource status
|
//draw resource status
|
||||||
if(localFactionResourcesOnly == true) {
|
if(localFactionResourcesOnly == true) {
|
||||||
string str = "*";
|
|
||||||
Vec4f resourceFontColor = Vec4f(factionForResourceView->getTexture()->getPixmapConst()->getPixel3f(0,0));
|
Vec4f resourceFontColor = Vec4f(factionForResourceView->getTexture()->getPixmapConst()->getPixel3f(0,0));
|
||||||
int resourceCol = 0;
|
int resourceCol = 0;
|
||||||
int resourceRow = startRow;
|
int resourceRow = startRow;
|
||||||
|
|
||||||
if(renderText3DEnabled == true) {
|
int x=resourceCol * 100 + 190;
|
||||||
renderTextShadow3D(
|
int y=resourceYStart - (resourceRowHeigth * resourceRow);
|
||||||
str, CoreData::getInstance().getDisplayFontSmall3D(),
|
int h=16;
|
||||||
resourceFontColor,
|
int w=8;
|
||||||
resourceCol * 100 + 190, metrics.getVirtualH()-30 - (30 * resourceRow), false);
|
glColor3f(resourceFontColor.x,resourceFontColor.y,resourceFontColor.z);
|
||||||
}
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
else {
|
glVertex2i(x, y+h);
|
||||||
renderTextShadow(
|
glVertex2i(x, y);
|
||||||
str, CoreData::getInstance().getDisplayFontSmall(),
|
glVertex2i(x+w, y+h/2);
|
||||||
resourceFontColor,
|
glEnd();
|
||||||
resourceCol * 100 + 190, metrics.getVirtualH()-30 - (30 * resourceRow), false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Resource *r = factionForResourceView->getResource(rt,localFactionResourcesOnly);
|
const Resource *r = factionForResourceView->getResource(rt,localFactionResourcesOnly);
|
||||||
|
@ -2553,11 +2562,11 @@ int Renderer::renderResource(const Faction *factionForResourceView,bool localFac
|
||||||
if(isNegativeConsumableDisplayCycle == false) {
|
if(isNegativeConsumableDisplayCycle == false) {
|
||||||
glColor3f(1.f, 1.f, 1.f);
|
glColor3f(1.f, 1.f, 1.f);
|
||||||
}
|
}
|
||||||
const int MAX_RESOURCES_PER_ROW = 6;
|
|
||||||
int resourceRow = startRow + (resourceCountRendered > 0 ? resourceCountRendered / MAX_RESOURCES_PER_ROW : 0);
|
int resourceRow = startRow + (resourceCountRendered > 0 ? resourceCountRendered / MAX_RESOURCES_PER_ROW : 0);
|
||||||
int resourceCol = resourceCountRendered % MAX_RESOURCES_PER_ROW;
|
int resourceCol = resourceCountRendered % MAX_RESOURCES_PER_ROW;
|
||||||
|
|
||||||
renderQuad(resourceCol * 100 + 200, metrics.getVirtualH()-30 - (30 * resourceRow), 16, 16, rt->getImage());
|
renderQuad(resourceCol * 100 + 200, resourceYStart - (resourceRowHeigth * resourceRow), 16, 16, rt->getImage());
|
||||||
|
|
||||||
if(rt->getClass() != rcStatic) {
|
if(rt->getClass() != rcStatic) {
|
||||||
str+= "/" + intToStr(factionForResourceView->getStoreAmount(rt,localFactionResourcesOnly));
|
str+= "/" + intToStr(factionForResourceView->getStoreAmount(rt,localFactionResourcesOnly));
|
||||||
|
@ -2576,13 +2585,13 @@ int Renderer::renderResource(const Faction *factionForResourceView,bool localFac
|
||||||
renderTextShadow3D(
|
renderTextShadow3D(
|
||||||
str, CoreData::getInstance().getDisplayFontSmall3D(),
|
str, CoreData::getInstance().getDisplayFontSmall3D(),
|
||||||
resourceFontColor,
|
resourceFontColor,
|
||||||
resourceCol * 100 + 220, metrics.getVirtualH()-30 - (30 * resourceRow), false);
|
resourceCol * 100 + 220, resourceYStart - (resourceRowHeigth * resourceRow), false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
renderTextShadow(
|
renderTextShadow(
|
||||||
str, CoreData::getInstance().getDisplayFontSmall(),
|
str, CoreData::getInstance().getDisplayFontSmall(),
|
||||||
resourceFontColor,
|
resourceFontColor,
|
||||||
resourceCol * 100 + 220, metrics.getVirtualH()-30 - (30 * resourceRow), false);
|
resourceCol * 100 + 220, resourceYStart - (resourceRowHeigth * resourceRow), false);
|
||||||
}
|
}
|
||||||
++resourceCountRendered;
|
++resourceCountRendered;
|
||||||
|
|
||||||
|
|
|
@ -710,7 +710,7 @@ private:
|
||||||
|
|
||||||
bool renderResourcesInTeamMode();
|
bool renderResourcesInTeamMode();
|
||||||
int renderResource(const Faction *factionForResourceView,
|
int renderResource(const Faction *factionForResourceView,
|
||||||
bool localFactionResourcesOnly, const ResourceType *rt,
|
bool localFactionResourcesOnly,bool twoResourceLines, const ResourceType *rt,
|
||||||
int startRow, int &resourceCountRendered);
|
int startRow, int &resourceCountRendered);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue