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()
{
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();
}

View File

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

View File

@@ -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);

View File

@@ -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;

View File

@@ -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})
{

View File

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

View File

@@ -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);

View File

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

View File

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

View File

@@ -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;

View File

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

View File

@@ -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;