Преглед изворни кода

Update unit growth in town screen UI when unequipping Legion pieces

Ivan Savenko пре 3 месеци
родитељ
комит
099053437a

+ 10 - 10
client/ArtifactsUIController.cpp

@@ -127,8 +127,8 @@ bool ArtifactsUIController::askToDisassemble(const CGHeroInstance * hero, const
 
 void ArtifactsUIController::artifactRemoved()
 {
-	for(const auto & artWin : ENGINE->windows().findWindows<CWindowWithArtifacts>())
-		artWin->update();
+	for(const auto & artWin : ENGINE->windows().findWindows<IArtifactsHolder>())
+		artWin->updateArtifacts();
 	GAME->interface()->waitWhileDialog();
 }
 
@@ -139,10 +139,10 @@ void ArtifactsUIController::artifactMoved()
 		numOfMovedArts--;
 
 	if(numOfMovedArts == 0)
-		for(const auto & artWin : ENGINE->windows().findWindows<CWindowWithArtifacts>())
-		{
-			artWin->update();
-		}
+	{
+		for(const auto & artWin : ENGINE->windows().findWindows<IArtifactsHolder>())
+			artWin->updateArtifacts();
+	}
 	GAME->interface()->waitWhileDialog();
 }
 
@@ -160,12 +160,12 @@ void ArtifactsUIController::bulkArtMovementStart(size_t totalNumOfArts, size_t p
 
 void ArtifactsUIController::artifactAssembled()
 {
-	for(const auto & artWin : ENGINE->windows().findWindows<CWindowWithArtifacts>())
-		artWin->update();
+	for(const auto & artWin : ENGINE->windows().findWindows<IArtifactsHolder>())
+		artWin->updateArtifacts();
 }
 
 void ArtifactsUIController::artifactDisassembled()
 {
-	for(const auto & artWin : ENGINE->windows().findWindows<CWindowWithArtifacts>())
-		artWin->update();
+	for(const auto & artWin : ENGINE->windows().findWindows<IArtifactsHolder>())
+		artWin->updateArtifacts();
 }

+ 6 - 0
client/gui/CIntObject.h

@@ -162,6 +162,12 @@ public:
 	virtual void updateGarrisons() = 0;
 };
 
+class IArtifactsHolder
+{
+public:
+	virtual void updateArtifacts() = 0;
+};
+
 class IMarketHolder
 {
 public:

+ 7 - 0
client/windows/CCastleInterface.cpp

@@ -1473,6 +1473,13 @@ CCastleInterface::~CCastleInterface()
 		GAME->interface()->castleInt = nullptr;
 }
 
+void CCastleInterface::updateArtifacts()
+{
+	// handle equipping / unequipping Legion pieces
+	for(auto creatureInfoBox : creainfo)
+		creatureInfoBox->update();
+}
+
 void CCastleInterface::updateGarrisons()
 {
 	garr->setArmy(town->getUpperArmy(), EGarrisonType::UPPER);

+ 2 - 1
client/windows/CCastleInterface.h

@@ -223,7 +223,7 @@ public:
 };
 
 /// Class which manages the castle window
-class CCastleInterface : public CStatusbarWindow, public IGarrisonHolder
+class CCastleInterface final : public CStatusbarWindow, public IGarrisonHolder, public IArtifactsHolder
 {
 	std::shared_ptr<CLabel> title;
 	std::shared_ptr<CLabel> income;
@@ -257,6 +257,7 @@ public:
 	CCastleInterface(const CGTownInstance * Town, const CGTownInstance * from = nullptr);
 	~CCastleInterface();
 
+	void updateArtifacts() override;
 	void updateGarrisons() override;
 	bool holdsGarrison(const CArmedInstance * army) override;
 

+ 4 - 4
client/windows/CExchangeWindow.cpp

@@ -261,7 +261,7 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
 		}
 	}
 
-	CExchangeWindow::update();
+	CExchangeWindow::updateArtifacts();
 }
 
 void CExchangeWindow::creatureArrowButtonCallback(bool leftToRight, SlotID slotId)
@@ -361,7 +361,7 @@ void CExchangeWindow::updateGarrisons()
 {
 	garr->recreateSlots();
 
-	update();
+	updateArtifacts();
 }
 
 bool CExchangeWindow::holdsGarrison(const CArmedInstance * army)
@@ -375,13 +375,13 @@ void CExchangeWindow::questLogShortcut()
 	GAME->interface()->showQuestLog();
 }
 
-void CExchangeWindow::update()
+void CExchangeWindow::updateArtifacts()
 {
 	const bool qeLayout = isQuickExchangeLayoutAvailable();
 
 	OBJECT_CONSTRUCTION;
 
-	CWindowWithArtifacts::update();
+	CWindowWithArtifacts::updateArtifacts();
 
 	for(size_t leftRight : {0, 1})
 	{

+ 1 - 1
client/windows/CExchangeWindow.h

@@ -75,7 +75,7 @@ public:
 
 	void keyPressed(EShortcut key) override;
 
-	void update() override;
+	void updateArtifacts() override;
 
 	// IGarrisonHolder impl
 	void updateGarrisons() override;

+ 5 - 5
client/windows/CHeroWindow.cpp

@@ -46,7 +46,7 @@ void CHeroSwitcher::clickPressed(const Point & cursorPosition)
 	//TODO: do not recreate window
 	if (false)
 	{
-		owner->update();
+		owner->updateArtifacts();
 	}
 	else
 	{
@@ -153,7 +153,7 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
 	{
 		auto divisionRoundUp = [](int x, int y){ return (x + (y - 1)) / y; };
 		int lines = divisionRoundUp(hero->secSkills.size(), 2);
-		secSkillSlider = std::make_shared<CSlider>(Point(284, 276), 189, [this](int val){ CHeroWindow::update(); }, 4, lines, 0, Orientation::VERTICAL, CSlider::BROWN);
+		secSkillSlider = std::make_shared<CSlider>(Point(284, 276), 189, [this](int val){ CHeroWindow::updateArtifacts(); }, 4, lines, 0, Orientation::VERTICAL, CSlider::BROWN);
 		secSkillSlider->setPanningStep(48);
 		secSkillSlider->setScrollBounds(Rect(-266, 0, secSkillSlider->pos.x - pos.x + secSkillSlider->pos.w, secSkillSlider->pos.h));
 	}
@@ -182,14 +182,14 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
 	labels.push_back(std::make_shared<CLabel>(69, 232, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, LIBRARY->generaltexth->jktexts[6]));
 	labels.push_back(std::make_shared<CLabel>(213, 232, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, LIBRARY->generaltexth->jktexts[7]));
 
-	CHeroWindow::update();
+	CHeroWindow::updateArtifacts();
 }
 
-void CHeroWindow::update()
+void CHeroWindow::updateArtifacts()
 {
 	OBJECT_CONSTRUCTION;
 
-	CWindowWithArtifacts::update();
+	CWindowWithArtifacts::updateArtifacts();
 	auto & heroscrn = LIBRARY->generaltexth->heroscrn;
 	assert(curHero);
 

+ 1 - 1
client/windows/CHeroWindow.h

@@ -101,7 +101,7 @@ public:
 
 	CHeroWindow(const CGHeroInstance * hero);
 
-	void update() override;
+	void updateArtifacts() override;
 
 	void dismissCurrent(); //dismissed currently displayed hero (curHero)
 	void commanderWindow();

+ 1 - 1
client/windows/CMarketWindow.cpp

@@ -85,7 +85,7 @@ void CMarketWindow::updateExperience()
 
 void CMarketWindow::update()
 {
-	CWindowWithArtifacts::update();
+	CWindowWithArtifacts::updateArtifacts();
 	assert(marketWidget);
 	marketWidget->update();
 }

+ 2 - 1
client/windows/CMarketWindow.h

@@ -20,7 +20,8 @@ public:
 	void updateArtifacts() override;
 	void updateGarrisons() override;
 	void updateExperience() override;
-	void update() override;
+
+	void update();
 	void close() override;
 	bool holdsGarrison(const CArmedInstance * army) override;
 

+ 1 - 1
client/windows/CWindowWithArtifacts.cpp

@@ -164,7 +164,7 @@ void CWindowWithArtifacts::enableKeyboardShortcuts() const
 		artSet->enableKeyboardShortcuts();
 }
 
-void CWindowWithArtifacts::update()
+void CWindowWithArtifacts::updateArtifacts()
 {
 	for(const auto & artSet : artSets)
 	{

+ 2 - 2
client/windows/CWindowWithArtifacts.h

@@ -16,7 +16,7 @@
 #include "../widgets/CArtifactsOfHeroBackpack.h"
 #include "CWindowObject.h"
 
-class CWindowWithArtifacts : virtual public CWindowObject
+class CWindowWithArtifacts : virtual public CWindowObject, public IArtifactsHolder
 {
 public:
 	using CArtifactsOfHeroPtr = std::shared_ptr<CArtifactsOfHeroBase>;
@@ -36,7 +36,7 @@ public:
 	void deactivate() override;
 	void enableKeyboardShortcuts() const;
 
-	virtual void update();
+	void updateArtifacts() override;
 
 protected:
 	void markPossibleSlots() const;