瀏覽代碼

* next part of thieves' guild window

mateuszb 15 年之前
父節點
當前提交
bc6cba565e
共有 4 個文件被更改,包括 76 次插入3 次删除
  1. 38 1
      client/GUIClasses.cpp
  2. 1 1
      client/GUIClasses.h
  3. 22 0
      lib/CGameState.cpp
  4. 15 1
      lib/CGameState.h

+ 38 - 1
client/GUIClasses.cpp

@@ -4843,7 +4843,12 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner)
 	exitb = new AdventureMapButton (std::string(), std::string(), boost::bind(&CThievesGuildWindow::bexitf,this), 748 + pos.x, 556 + pos.y, "HSBTNS.def", SDLK_RETURN);
 	statusBar = new CStatusBar(pos.x + 3, pos.y + 555, "TStatBar.bmp", 742);
 
-	resdatabar = new CResDataBar("ZRESBAR.bmp", pos.x+3, pos.y+575, 32, 2, 85, 85);
+	resdatabar = new CMinorResDataBar();
+	resdatabar->pos.y += pos.y;
+
+	static std::vector< std::list< ui8 > > SThievesGuildInfo::* fields[] = { &SThievesGuildInfo::numOfTowns, &SThievesGuildInfo::numOfHeroes, &SThievesGuildInfo::gold,
+		&SThievesGuildInfo::woodOre, &SThievesGuildInfo::mercSulfCrystGems, &SThievesGuildInfo::obelisks, &SThievesGuildInfo::artifacts, &SThievesGuildInfo::army,
+		&SThievesGuildInfo::income};
 
 	//printing texts & descriptions to background
 
@@ -4887,6 +4892,38 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner)
 
 	delete strips;
 
+	CDefHandler * flagPictures = CDefHandler::giveDef("itgflags.def");
+
+	//printing flags
+	for(int g=0; g<ARRAY_COUNT(fields); ++g) //by lines
+	{
+		for(int b=0; b<(tgi .* fields[g]).size(); ++b) //by places (1st, 2nd, ...)
+		{
+			std::list<ui8> players = (tgi .* fields[g])[b]; //get players with this place in this line
+			//std::sort(players.begin(), players.end());
+
+			int counter = 0;
+			for(std::list<ui8>::const_iterator it = players.begin(); it != players.end(); ++it)
+			{
+				int xpos = 259 + 66 * b + 12 * (counter % 4) + 6 * (counter / 4);
+				int ypos = 41 + 32 * g + 4 * (counter / 4);
+				blitAt(flagPictures->ourImages[*it].bitmap, xpos, ypos, background);
+				counter++;
+			}
+		}
+	}
+	delete flagPictures;
+	flagPictures = NULL;
+
+	//printing best hero
+
+	int counter = 0;
+	for(std::map<ui8, SThievesGuildInfo::InfoAboutHero>::const_iterator it = tgi.colorToBestHero.begin(); it !=  tgi.colorToBestHero.end(); ++it)
+	{
+		blitAt(graphics->portraitSmall[it->second.portrait], 260 + 66 * counter, 360, background);
+		counter++;
+	}
+
 }
 
 CThievesGuildWindow::~CThievesGuildWindow()

+ 1 - 1
client/GUIClasses.h

@@ -851,7 +851,7 @@ class CThievesGuildWindow : public CIntObject
 	CStatusBar * statusBar;
 	AdventureMapButton * exitb;
 	SDL_Surface * background;
-	CResDataBar * resdatabar;
+	CMinorResDataBar * resdatabar;
 
 public:
 	void activate();

+ 22 - 0
lib/CGameState.cpp

@@ -3160,6 +3160,28 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
 		FILL_FIELD(numOfTowns, g->second.towns.size())
 		//num of heroes
 		FILL_FIELD(numOfHeroes, g->second.heroes.size())
+		//best hero's portrait
+		for(std::map<ui8, PlayerState>::const_iterator g = players.begin(); g != players.end(); ++g)
+		{
+			if(g->second.color == 255)
+				continue;
+			//best hero will be that with highest exp
+			int best = 0;
+			for(int b=1; b<g->second.heroes.size(); ++b)
+			{
+				if(g->second.heroes[b]->exp > g->second.heroes[best]->exp)
+				{
+					best = b;
+				}
+			}
+			SThievesGuildInfo::InfoAboutHero iah;
+			iah.portrait = g->second.heroes[best]->portrait;
+			for(int c=0; c<PRIMARY_SKILLS; ++c)
+			{
+				iah.primSkills[c] = -1; //mark as unknown
+			}
+			tgi.colorToBestHero[g->second.color] = iah;
+		}
 	}
 	if(level >= 2) //gold
 	{

+ 15 - 1
lib/CGameState.h

@@ -64,11 +64,25 @@ struct DLL_EXPORT SThievesGuildInfo
 
 	std::vector< std::list< ui8 > > numOfTowns, numOfHeroes, gold, woodOre, mercSulfCrystGems, obelisks, artifacts, army, income; // [place] -> [colours of players]
 
-	//TODO: best hero, personality, best monster
+	//TODO: personality, best monster
+
+	struct InfoAboutHero
+	{
+		ui32 portrait;
+		si32 primSkills[PRIMARY_SKILLS]; //-1 if not available; otherwise values
+
+		template <typename Handler> void serialize(Handler &h, const int version)
+		{
+			h & portrait & primSkills;
+		}
+	};
+
+	std::map<ui8, InfoAboutHero> colorToBestHero; //maps player's color to his best heros' 
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 		h & playerColors & numOfTowns & numOfHeroes & gold & woodOre & mercSulfCrystGems & obelisks & artifacts & army & income;
+		h & colorToBestHero;
 	}
 
 };