1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Update unit growth in town screen UI when unequipping Legion pieces

This commit is contained in:
Ivan Savenko
2025-06-25 11:50:33 +03:00
parent 9c2e49f95f
commit 099053437a
12 changed files with 42 additions and 27 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -46,7 +46,7 @@ void CHeroSwitcher::clickPressed(const Point & cursorPosition)
//TODO: do not recreate window //TODO: do not recreate window
if (false) if (false)
{ {
owner->update(); owner->updateArtifacts();
} }
else else
{ {
@@ -153,7 +153,7 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
{ {
auto divisionRoundUp = [](int x, int y){ return (x + (y - 1)) / y; }; auto divisionRoundUp = [](int x, int y){ return (x + (y - 1)) / y; };
int lines = divisionRoundUp(hero->secSkills.size(), 2); 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->setPanningStep(48);
secSkillSlider->setScrollBounds(Rect(-266, 0, secSkillSlider->pos.x - pos.x + secSkillSlider->pos.w, secSkillSlider->pos.h)); 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>(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])); 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; OBJECT_CONSTRUCTION;
CWindowWithArtifacts::update(); CWindowWithArtifacts::updateArtifacts();
auto & heroscrn = LIBRARY->generaltexth->heroscrn; auto & heroscrn = LIBRARY->generaltexth->heroscrn;
assert(curHero); assert(curHero);

View File

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

View File

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

View File

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

View File

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

View File

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