mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Merge pull request #2390 from dydzio0614/hero-window-mana-fix
Fix for hero info window mana points not getting spent on spellcast - option 1
This commit is contained in:
commit
8dd1545e25
@ -476,6 +476,9 @@ void CPlayerInterface::heroManaPointsChanged(const CGHeroInstance * hero)
|
||||
adventureInt->onHeroChanged(hero);
|
||||
if (makingTurn && hero->tempOwner == playerID)
|
||||
adventureInt->onHeroChanged(hero);
|
||||
|
||||
for (auto window : GH.windows().findWindows<BattleWindow>())
|
||||
window->heroManaPointsChanged(hero);
|
||||
}
|
||||
void CPlayerInterface::heroMovePointsChanged(const CGHeroInstance * hero)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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,27 @@ 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::heroManaPointsChanged(const CGHeroInstance * hero)
|
||||
{
|
||||
if(hero == owner.attackingHeroInstance || hero == owner.defendingHeroInstance)
|
||||
{
|
||||
InfoAboutHero heroInfo = InfoAboutHero();
|
||||
heroInfo.initFromHero(hero, InfoAboutHero::INBATTLE);
|
||||
|
||||
updateHeroInfoWindow(hero == owner.attackingHeroInstance ? 0 : 1, heroInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
logGlobal->error("BattleWindow::heroManaPointsChanged: 'Mana points changed' called for hero not belonging to current battle window");
|
||||
}
|
||||
}
|
||||
|
||||
void BattleWindow::activate()
|
||||
{
|
||||
GH.setStatusbar(console);
|
||||
|
@ -79,15 +79,22 @@ public:
|
||||
void hideQueue();
|
||||
void showQueue();
|
||||
|
||||
/// Toggle permanent hero info windows visibility (HD mod feature)
|
||||
void hideStickyHeroWindows();
|
||||
void showStickyHeroWindows();
|
||||
|
||||
/// Event handler for netpack changing hero mana points
|
||||
void heroManaPointsChanged(const CGHeroInstance * hero);
|
||||
|
||||
/// block all UI elements when player is not allowed to act, e.g. during enemy turn
|
||||
void blockUI(bool on);
|
||||
|
||||
/// 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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user