diff --git a/CCallback.cpp b/CCallback.cpp index f41ab8404..d7917b870 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -923,6 +923,7 @@ InfoAboutTown::~InfoAboutTown() void InfoAboutTown::initFromTown( const CGTownInstance *t, bool detailed ) { + obj = t; army = t->army; built = t->builded; fortLevel = t->fortLevel(); @@ -939,12 +940,12 @@ void InfoAboutTown::initFromTown( const CGTownInstance *t, bool detailed ) details->hallLevel = t->hallLevel(); details->garrisonedHero = t->garrisonHero; } - else + /*else { //hide info about hero stacks counts for(std::map >::iterator i = army.slots.begin(); i != army.slots.end(); ++i) { i->second.second = 0; } - } + }*/ } diff --git a/CCallback.h b/CCallback.h index 372e004bf..d032e28ca 100644 --- a/CCallback.h +++ b/CCallback.h @@ -72,6 +72,7 @@ struct InfoAboutTown } *details; + const CArmedInstance * obj; char fortLevel; //0 - none char owner; std::string name; diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp index 06a37b407..120cca35c 100644 --- a/client/CAdvmapInterface.cpp +++ b/client/CAdvmapInterface.cpp @@ -640,14 +640,23 @@ void CTerrainRect::clickRight(tribool down, bool previousState) if (garr != NULL) { InfoAboutTown iah; + iah.obj = garr; iah.fortLevel = 0; iah.army = garr->army; - iah.name = std::string("Garrison"); + iah.name = VLC->generaltexth->names[33]; // "Garrison" iah.owner = garr->tempOwner; iah.built = false; - iah.details = NULL; // TODO: Find a suitable way to show detailed info. iah.tType = NULL; + // Show detailed info only to owning player. + if (garr->tempOwner == LOCPLINT->playerID) { + iah.details = new InfoAboutTown::Details; + iah.details->customRes = false; + iah.details->garrisonedHero = false; + iah.details->goldIncome = -1; + iah.details->hallLevel = -1; + } + SDL_Surface *iwin = graphics->drawTownInfoWin(iah); CInfoPopup * ip = new CInfoPopup(iwin, GH.current->motion.x - iwin->w/2, diff --git a/client/Graphics.cpp b/client/Graphics.cpp index 00e1b7bb1..adda5c12c 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -111,9 +111,17 @@ SDL_Surface * Graphics::drawTownInfoWin( const InfoAboutTown & curh ) blitAt(graphics->smallImgs[(*i).second.first],slotsPos[(*i).first].first+1,slotsPos[(*i).first].second+1,ret); if(curh.details) { + // Show exact creature amount. SDL_itoa((*i).second.second,buf,10); printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+39,GEORM,zwykly,ret); } + else + { + // Show only a rough amount for creature stacks. + // TODO: Deal with case when no information at all about size shold be presented. + std::string roughAmount = curh.obj->getRoughAmount(i->first); + printAtMiddle(roughAmount,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+39,GEORM,zwykly,ret); + } } //blit town icon @@ -132,8 +140,10 @@ SDL_Surface * Graphics::drawTownInfoWin( const InfoAboutTown & curh ) if((pom=curh.details->hallLevel) >= 0) blitAt(halls->ourImages[pom].bitmap, 77, 42, ret); - SDL_itoa(curh.details->goldIncome, buf, 10); //gold income - printAtMiddle(buf, 167, 70, GEORM, zwykly, ret); + if (curh.details->goldIncome >= 0) { + SDL_itoa(curh.details->goldIncome, buf, 10); //gold income + printAtMiddle(buf, 167, 70, GEORM, zwykly, ret); + } if(curh.details->garrisonedHero) //garrisoned hero icon blitAt(graphics->heroInGarrison,158,87,ret); } diff --git a/client/Graphics.h b/client/Graphics.h index 58ada63a4..220d02a11 100644 --- a/client/Graphics.h +++ b/client/Graphics.h @@ -4,6 +4,7 @@ #include "../global.h" #include "FontBase.h" +#include "../hch/CObjectHandler.h" /* * Graphics.h, part of VCMI engine