Răsfoiți Sursa

* 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.

OnionKnight 16 ani în urmă
părinte
comite
95808db933
5 a modificat fișierele cu 28 adăugiri și 6 ștergeri
  1. 3 2
      CCallback.cpp
  2. 1 0
      CCallback.h
  3. 11 2
      client/CAdvmapInterface.cpp
  4. 12 2
      client/Graphics.cpp
  5. 1 0
      client/Graphics.h

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

+ 1 - 0
CCallback.h

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

+ 11 - 2
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,

+ 12 - 2
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);
 	}

+ 1 - 0
client/Graphics.h

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