Browse Source

* bug 652 fixed

mateuszb 14 years ago
parent
commit
0482195489
4 changed files with 25 additions and 10 deletions
  1. 9 0
      client/CAdvmapInterface.cpp
  2. 5 3
      client/CAdvmapInterface.h
  3. 10 6
      client/CPlayerInterface.cpp
  4. 1 1
      client/CPlayerInterface.h

+ 9 - 0
client/CAdvmapInterface.cpp

@@ -1070,6 +1070,11 @@ void CInfoBar::newDay(int Day)
 
 void CInfoBar::showComp(SComponent * comp, int time)
 {
+	if(comp->type != SComponent::hero)
+	{
+		curSel = NULL;
+	}
+
 	SDL_Surface * b = BitmapHandler::loadBitmap("ADSTATOT.bmp");
 	blitAt(b,pos.x+8,pos.y+11);
 	blitAt(comp->getImg(),pos.x+52,pos.y+54);
@@ -1126,6 +1131,10 @@ void CInfoBar::deactivate()
 
 void CInfoBar::updateSelection(const CGObjectInstance *obj)
 {
+	if(obj->ID == HEROI_TYPE)
+		curSel = static_cast<const CGHeroInstance*>(obj);
+	else
+		curSel = NULL;
 	if(selInfoWin)
 		SDL_FreeSurface(selInfoWin);
 	selInfoWin = LOCPLINT->infoWin(obj);

+ 5 - 3
client/CAdvmapInterface.h

@@ -120,12 +120,14 @@ public:
 /// Info box which shows next week/day information, hold the current date
 class CInfoBar : public CIntObject
 {
-public:
 	CDefHandler *day, *week1, *week2, *week3, *week4;
 	SComponent * current;
-	int mode;
 	int pom;
 	SDL_Surface *selInfoWin; //info box for selection
+	CDefHandler * getAnim(int mode);
+public:
+	int mode;
+	const CGHeroInstance * curSel;
 
 	CInfoBar();
 	~CInfoBar();
@@ -134,7 +136,7 @@ public:
 	void tick();
 	void showAll(SDL_Surface * to); // if specific==0 function draws info about selected hero/town
 	void blitAnim(int mode);//0 - day, 1 - week
-	CDefHandler * getAnim(int mode);
+
 	void show(SDL_Surface * to);
 	void activate();
 	void deactivate();

+ 10 - 6
client/CPlayerInterface.cpp

@@ -505,10 +505,11 @@ void CPlayerInterface::heroVisitsTown(const CGHeroInstance* hero, const CGTownIn
 	boost::unique_lock<boost::recursive_mutex> un(*pim);
 	openTownWindow(town);
 }
-void CPlayerInterface::garrisonChanged(const CGObjectInstance * obj)
+void CPlayerInterface::garrisonChanged( const CGObjectInstance * obj, bool updateInfobox /*= true*/ )
 {
 	boost::unique_lock<boost::recursive_mutex> un(*pim);
-	updateInfo(obj);
+	if(updateInfobox)
+		updateInfo(obj);
 
 	for(std::list<IShowActivable*>::iterator i = GH.listInt.begin(); i != GH.listInt.end(); i++)
 	{
@@ -2148,12 +2149,13 @@ void CPlayerInterface::stacksErased(const StackLocation &location)
 	garrisonChanged(location.army);
 }
 
+#define UPDATE_IF(LOC) static_cast<const CArmedInstance*>(adventureInt->infoBar.curSel) == LOC.army.get()
 void CPlayerInterface::stacksSwapped(const StackLocation &loc1, const StackLocation &loc2)
 {
 	boost::unique_lock<boost::recursive_mutex> un(*pim);
-	garrisonChanged(loc1.army);
+	garrisonChanged(loc1.army, UPDATE_IF(loc1));
 	if(loc2.army != loc1.army)
-		garrisonChanged(loc2.army);
+		garrisonChanged(loc2.army, UPDATE_IF(loc2));
 }
 
 void CPlayerInterface::newStackInserted(const StackLocation &location, const CStackInstance &stack)
@@ -2165,10 +2167,12 @@ void CPlayerInterface::newStackInserted(const StackLocation &location, const CSt
 void CPlayerInterface::stacksRebalanced(const StackLocation &src, const StackLocation &dst, TQuantity count)
 {
 	boost::unique_lock<boost::recursive_mutex> un(*pim);
-	garrisonChanged(src.army);
+	bool updateInfobox = true;
+	garrisonChanged(src.army, UPDATE_IF(src));
 	if(dst.army != src.army)
-		garrisonChanged(dst.army);
+		garrisonChanged(dst.army, UPDATE_IF(dst));
 }
+#undef UPDATE_IF
 
 void CPlayerInterface::artifactPut(const ArtifactLocation &al)
 {

+ 1 - 1
client/CPlayerInterface.h

@@ -234,7 +234,7 @@ public:
 
 	//-------------//
 	void showArtifactAssemblyDialog(ui32 artifactID, ui32 assembleTo, bool assemble, CFunctionList<void()> onYes, CFunctionList<void()> onNo);
-	void garrisonChanged(const CGObjectInstance * obj);
+	void garrisonChanged(const CGObjectInstance * obj, bool updateInfobox = true);
 	void heroKilled(const CGHeroInstance* hero);
 	void waitWhileDialog();
 	bool shiftPressed() const; //determines if shift key is pressed (left or right or both)