1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Fix for hero info window mana points not getting spent on spellcast

This commit is contained in:
Dydzio
2023-07-22 15:32:00 +02:00
parent 0be3d6911c
commit 05735a20e1
5 changed files with 36 additions and 2 deletions

View File

@@ -584,7 +584,15 @@ void BattleInterface::endAction(const BattleAction* action)
//we have activated next stack after sending request that has been just realized -> blockmap due to movement has changed
if(action->actionType == EActionType::HERO_SPELL)
{
fieldController->redrawBackgroundWithHexes();
//update casting hero info window
auto hero = action->side == 0 ? attackingHero : defendingHero;
InfoAboutHero heroInfo = InfoAboutHero();
heroInfo.initFromHero(hero->instance(), InfoAboutHero::INBATTLE);
windowObject->updateHeroInfoWindow(action->side, heroInfo);
}
}
void BattleInterface::appendBattleLog(const std::string & newEntry)

View File

@@ -389,6 +389,12 @@ HeroInfoBasicPanel::HeroInfoBasicPanel(const InfoAboutHero & hero, Point * posit
background->colorize(hero.owner);
}
initializeData(hero);
}
void HeroInfoBasicPanel::initializeData(const InfoAboutHero & hero)
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
auto attack = hero.details->primskills[0];
auto defense = hero.details->primskills[1];
auto power = hero.details->primskills[2];
@@ -423,6 +429,14 @@ HeroInfoBasicPanel::HeroInfoBasicPanel(const InfoAboutHero & hero, Point * posit
labels.push_back(std::make_shared<CLabel>(39, 186, EFonts::FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, std::to_string(currentSpellPoints) + "/" + std::to_string(maxSpellPoints)));
}
void HeroInfoBasicPanel::update(const InfoAboutHero & updatedInfo)
{
icons.clear();
labels.clear();
initializeData(updatedInfo);
}
void HeroInfoBasicPanel::show(Canvas & to)
{
showAll(to);

View File

@@ -137,6 +137,9 @@ public:
HeroInfoBasicPanel(const InfoAboutHero & hero, Point * position, bool initializeBackground = true);
void show(Canvas & to) override;
void initializeData(const InfoAboutHero & hero);
void update(const InfoAboutHero & updatedInfo);
};
class HeroInfoWindow : public CWindowObject

View File

@@ -237,8 +237,8 @@ void BattleWindow::showStickyHeroWindows()
if(settings["battle"]["stickyHeroInfoWindows"].Bool() == true)
return;
Settings showStickyHeroInfoWIndows = settings.write["battle"]["stickyHeroInfoWindows"];
showStickyHeroInfoWIndows->Bool() = true;
Settings showStickyHeroInfoWindows = settings.write["battle"]["stickyHeroInfoWindows"];
showStickyHeroInfoWindows->Bool() = true;
createStickyHeroInfoWindows();
@@ -250,6 +250,12 @@ void BattleWindow::updateQueue()
queue->update();
}
void BattleWindow::updateHeroInfoWindow(uint8_t side, const InfoAboutHero & hero)
{
std::shared_ptr<HeroInfoBasicPanel> panelToUpdate = side == 0 ? attackerHeroWindow : defenderHeroWindow;
panelToUpdate->update(hero);
}
void BattleWindow::activate()
{
GH.setStatusbar(console);

View File

@@ -88,6 +88,9 @@ public:
/// Refresh queue after turn order changes
void updateQueue();
/// Refresh sticky variant of hero info window after spellcast, side same as in BattleSpellCast::side
void updateHeroInfoWindow(uint8_t side, const InfoAboutHero & hero);
/// Get mouse-hovered battle queue unit ID if any found
std::optional<uint32_t> getQueueHoveredUnitId();