1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

* Right-click info window for castles and garrisons you do not own shows a rough amount of creatures instead of none.

I don't really know under which circumstances no information at all is shown in the original H3 so I haven't dealt with that.
This commit is contained in:
OnionKnight 2009-10-25 19:32:02 +00:00
parent 68c5bb63a4
commit 95808db933
5 changed files with 28 additions and 6 deletions

View File

@ -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<si32,std::pair<ui32,si32> >::iterator i = army.slots.begin(); i != army.slots.end(); ++i)
{
i->second.second = 0;
}
}
}*/
}

View File

@ -72,6 +72,7 @@ struct InfoAboutTown
} *details;
const CArmedInstance * obj;
char fortLevel; //0 - none
char owner;
std::string name;

View File

@ -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,

View File

@ -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);
}

View File

@ -4,6 +4,7 @@
#include "../global.h"
#include "FontBase.h"
#include "../hch/CObjectHandler.h"
/*
* Graphics.h, part of VCMI engine