瀏覽代碼

town now updates

Laserlicht 2 年之前
父節點
當前提交
c96cc405ed
共有 4 個文件被更改,包括 16 次插入1 次删除
  1. 3 0
      client/CPlayerInterface.cpp
  2. 6 0
      client/gui/CIntObject.h
  3. 5 0
      client/windows/CKingdomInterface.cpp
  4. 2 1
      client/windows/CKingdomInterface.h

+ 3 - 0
client/CPlayerInterface.cpp

@@ -591,6 +591,9 @@ void CPlayerInterface::buildChanged(const CGTownInstance *town, BuildingID build
 		// Perform totalRedraw in order to force redraw of updated town list icon from adventure map
 		GH.windows().totalRedraw();
 	}
+
+	for (auto cgh : GH.windows().findWindows<ITownHolder>())
+		cgh->buildChanged(town);
 }
 
 void CPlayerInterface::battleStartBefore(const BattleID & battleID, const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2)

+ 6 - 0
client/gui/CIntObject.h

@@ -153,6 +153,12 @@ public:
 	virtual void updateGarrisons() = 0;
 };
 
+class ITownHolder
+{
+public:
+	virtual void buildChanged() = 0;
+};
+
 class IStatusBar
 {
 public:

+ 5 - 0
client/windows/CKingdomInterface.cpp

@@ -640,6 +640,11 @@ void CKingdomInterface::activateTab(size_t which)
 	tabArea->setActive(which);
 }
 
+void CKingdomInterface::buildChanged()
+{
+	tabArea->reset();
+}
+
 void CKingdomInterface::townChanged(const CGTownInstance *town)
 {
 	if(auto townList = std::dynamic_pointer_cast<CKingdTownList>(tabArea->getItem()))

+ 2 - 1
client/windows/CKingdomInterface.h

@@ -200,7 +200,7 @@ public:
 };
 
 /// Class which holds all parts of kingdom overview window
-class CKingdomInterface : public CWindowObject, public IGarrisonHolder, public CArtifactHolder
+class CKingdomInterface : public CWindowObject, public IGarrisonHolder, public CArtifactHolder, public ITownHolder
 {
 private:
 	struct OwnedObjectInfo
@@ -257,6 +257,7 @@ public:
 	void artifactMoved(const ArtifactLocation &artLoc, const ArtifactLocation &destLoc, bool withRedraw) override;
 	void artifactDisassembled(const ArtifactLocation &artLoc) override;
 	void artifactAssembled(const ArtifactLocation &artLoc) override;
+	void buildChanged() override;
 };
 
 /// List item with town