2023-10-19 16:19:09 +02:00
|
|
|
/*
|
|
|
|
* CHeroWindow.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "StdInc.h"
|
|
|
|
#include "CHeroWindow.h"
|
|
|
|
|
|
|
|
#include "CCreatureWindow.h"
|
|
|
|
#include "CHeroBackpackWindow.h"
|
|
|
|
#include "CKingdomInterface.h"
|
2024-05-19 12:53:56 +02:00
|
|
|
#include "CExchangeWindow.h"
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
#include "../CGameInfo.h"
|
|
|
|
#include "../CPlayerInterface.h"
|
|
|
|
|
|
|
|
#include "../gui/CGuiHandler.h"
|
|
|
|
#include "../gui/TextAlignment.h"
|
|
|
|
#include "../gui/Shortcut.h"
|
|
|
|
#include "../gui/WindowHandler.h"
|
2024-05-19 12:53:56 +02:00
|
|
|
#include "../widgets/Images.h"
|
2023-10-19 16:19:09 +02:00
|
|
|
#include "../widgets/MiscWidgets.h"
|
|
|
|
#include "../widgets/CComponent.h"
|
|
|
|
#include "../widgets/CGarrisonInt.h"
|
|
|
|
#include "../widgets/TextControls.h"
|
|
|
|
#include "../widgets/Buttons.h"
|
|
|
|
#include "../render/IRenderHandler.h"
|
|
|
|
|
|
|
|
#include "../../CCallback.h"
|
|
|
|
|
|
|
|
#include "../lib/ArtifactUtils.h"
|
|
|
|
#include "../lib/CArtHandler.h"
|
|
|
|
#include "../lib/CConfigHandler.h"
|
2024-10-11 18:30:16 +02:00
|
|
|
#include "../lib/entities/hero/CHeroHandler.h"
|
2024-07-20 14:55:17 +02:00
|
|
|
#include "../lib/texts/CGeneralTextHandler.h"
|
2023-10-19 16:19:09 +02:00
|
|
|
#include "../lib/CSkillHandler.h"
|
|
|
|
#include "../lib/mapObjects/CGHeroInstance.h"
|
2024-10-11 18:30:16 +02:00
|
|
|
#include "../lib/networkPacks/ArtifactLocation.h"
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
void CHeroSwitcher::clickPressed(const Point & cursorPosition)
|
|
|
|
{
|
|
|
|
//TODO: do not recreate window
|
|
|
|
if (false)
|
|
|
|
{
|
2024-05-08 13:16:16 +02:00
|
|
|
owner->update();
|
2023-10-19 16:19:09 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const CGHeroInstance * buf = hero;
|
|
|
|
GH.windows().popWindows(1);
|
|
|
|
GH.windows().createAndPushWindow<CHeroWindow>(buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CHeroSwitcher::CHeroSwitcher(CHeroWindow * owner_, Point pos_, const CGHeroInstance * hero_)
|
|
|
|
: CIntObject(LCLICK),
|
|
|
|
owner(owner_),
|
|
|
|
hero(hero_)
|
|
|
|
{
|
2024-08-09 17:30:04 +02:00
|
|
|
OBJECT_CONSTRUCTION;
|
2023-10-19 16:19:09 +02:00
|
|
|
pos += pos_;
|
|
|
|
|
|
|
|
image = std::make_shared<CAnimImage>(AnimationPath::builtin("PortraitsSmall"), hero->getIconIndex());
|
|
|
|
pos.w = image->pos.w;
|
|
|
|
pos.h = image->pos.h;
|
|
|
|
}
|
|
|
|
|
|
|
|
CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
|
2024-04-23 15:21:45 +02:00
|
|
|
: CWindowObject(PLAYER_COLORED, ImagePath::builtin("HeroScr4"))
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
|
|
|
auto & heroscrn = CGI->generaltexth->heroscrn;
|
|
|
|
|
2024-08-09 17:30:04 +02:00
|
|
|
OBJECT_CONSTRUCTION;
|
2023-10-19 16:19:09 +02:00
|
|
|
curHero = hero;
|
|
|
|
|
|
|
|
banner = std::make_shared<CAnimImage>(AnimationPath::builtin("CREST58"), LOCPLINT->playerID.getNum(), 0, 606, 8);
|
|
|
|
name = std::make_shared<CLabel>(190, 38, EFonts::FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW);
|
|
|
|
title = std::make_shared<CLabel>(190, 65, EFonts::FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE);
|
|
|
|
|
|
|
|
statusbar = CGStatusBar::create(7, 559, ImagePath::builtin("ADROLLVR.bmp"), 660);
|
|
|
|
|
|
|
|
quitButton = std::make_shared<CButton>(Point(609, 516), AnimationPath::builtin("hsbtns.def"), CButton::tooltip(heroscrn[17]), [=](){ close(); }, EShortcut::GLOBAL_RETURN);
|
|
|
|
|
|
|
|
if(settings["general"]["enableUiEnhancements"].Bool())
|
|
|
|
{
|
|
|
|
questlogButton = std::make_shared<CButton>(Point(314, 429), AnimationPath::builtin("hsbtns4.def"), CButton::tooltip(heroscrn[0]), [=](){ LOCPLINT->showQuestLog(); }, EShortcut::ADVENTURE_QUEST_LOG);
|
2024-02-29 13:51:00 +02:00
|
|
|
backpackButton = std::make_shared<CButton>(Point(424, 429), AnimationPath::builtin("heroBackpack"), CButton::tooltipLocalized("vcmi.heroWindow.openBackpack"), [=](){ createBackpackWindow(); }, EShortcut::HERO_BACKPACK);
|
|
|
|
backpackButton->setOverlay(std::make_shared<CPicture>(ImagePath::builtin("heroWindow/backpackButtonIcon")));
|
2023-10-19 16:19:09 +02:00
|
|
|
dismissButton = std::make_shared<CButton>(Point(534, 429), AnimationPath::builtin("hsbtns2.def"), CButton::tooltip(heroscrn[28]), [=](){ dismissCurrent(); }, EShortcut::HERO_DISMISS);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dismissLabel = std::make_shared<CTextBox>(CGI->generaltexth->jktexts[8], Rect(370, 430, 65, 35), 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
|
|
|
questlogLabel = std::make_shared<CTextBox>(CGI->generaltexth->jktexts[9], Rect(510, 430, 65, 35), 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
|
|
|
dismissButton = std::make_shared<CButton>(Point(454, 429), AnimationPath::builtin("hsbtns2.def"), CButton::tooltip(heroscrn[28]), [=](){ dismissCurrent(); }, EShortcut::HERO_DISMISS);
|
|
|
|
questlogButton = std::make_shared<CButton>(Point(314, 429), AnimationPath::builtin("hsbtns4.def"), CButton::tooltip(heroscrn[0]), [=](){ LOCPLINT->showQuestLog(); }, EShortcut::ADVENTURE_QUEST_LOG);
|
|
|
|
}
|
|
|
|
|
|
|
|
formations = std::make_shared<CToggleGroup>(0);
|
|
|
|
formations->addToggle(0, std::make_shared<CToggleButton>(Point(481, 483), AnimationPath::builtin("hsbtns6.def"), std::make_pair(heroscrn[23], heroscrn[29]), 0, EShortcut::HERO_TIGHT_FORMATION));
|
|
|
|
formations->addToggle(1, std::make_shared<CToggleButton>(Point(481, 519), AnimationPath::builtin("hsbtns7.def"), std::make_pair(heroscrn[24], heroscrn[30]), 0, EShortcut::HERO_LOOSE_FORMATION));
|
|
|
|
|
|
|
|
if(hero->commander)
|
|
|
|
{
|
2024-02-29 13:51:00 +02:00
|
|
|
commanderButton = std::make_shared<CButton>(Point(317, 18), AnimationPath::builtin("heroCommander"), CButton::tooltipLocalized("vcmi.heroWindow.openCommander"), [&](){ commanderWindow(); }, EShortcut::HERO_COMMANDER);
|
|
|
|
commanderButton->setOverlay(std::make_shared<CPicture>(ImagePath::builtin("heroWindow/commanderButtonIcon")));
|
2023-10-19 16:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//right list of heroes
|
|
|
|
for(int i=0; i < std::min(LOCPLINT->cb->howManyHeroes(false), 8); i++)
|
|
|
|
heroList.push_back(std::make_shared<CHeroSwitcher>(this, Point(612, 87 + i * 54), LOCPLINT->cb->getHeroBySerial(i, false)));
|
|
|
|
|
|
|
|
//areas
|
|
|
|
portraitArea = std::make_shared<LRClickableAreaWText>(Rect(18, 18, 58, 64));
|
|
|
|
portraitImage = std::make_shared<CAnimImage>(AnimationPath::builtin("PortraitsLarge"), 0, 0, 19, 19);
|
|
|
|
|
|
|
|
for(int v = 0; v < GameConstants::PRIMARY_SKILLS; ++v)
|
|
|
|
{
|
2023-10-31 11:09:56 +02:00
|
|
|
auto area = std::make_shared<LRClickableAreaWTextComp>(Rect(30 + 70 * v, 109, 42, 64), ComponentType::PRIM_SKILL);
|
2023-10-19 16:19:09 +02:00
|
|
|
area->text = CGI->generaltexth->arraytxt[2+v];
|
2023-10-31 11:09:56 +02:00
|
|
|
area->component.subType = PrimarySkill(v);
|
2023-10-19 16:19:09 +02:00
|
|
|
area->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1]) % CGI->generaltexth->primarySkillNames[v]);
|
|
|
|
primSkillAreas.push_back(area);
|
|
|
|
|
|
|
|
auto value = std::make_shared<CLabel>(53 + 70 * v, 166, FONT_SMALL, ETextAlignment::CENTER);
|
|
|
|
primSkillValues.push_back(value);
|
|
|
|
}
|
|
|
|
|
2024-06-02 17:43:56 +02:00
|
|
|
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 0, 0, 32, 111));
|
|
|
|
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 1, 0, 102, 111));
|
|
|
|
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 2, 0, 172, 111));
|
|
|
|
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 3, 0, 162, 230));
|
|
|
|
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 4, 0, 20, 230));
|
|
|
|
primSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PSKIL42"), 5, 0, 242, 111));
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
specImage = std::make_shared<CAnimImage>(AnimationPath::builtin("UN44"), 0, 0, 18, 180);
|
|
|
|
specArea = std::make_shared<LRClickableAreaWText>(Rect(18, 180, 136, 42), CGI->generaltexth->heroscrn[27]);
|
|
|
|
specName = std::make_shared<CLabel>(69, 205);
|
|
|
|
|
|
|
|
expArea = std::make_shared<LRClickableAreaWText>(Rect(18, 228, 136, 42), CGI->generaltexth->heroscrn[9]);
|
|
|
|
morale = std::make_shared<MoraleLuckBox>(true, Rect(175, 179, 53, 45));
|
|
|
|
luck = std::make_shared<MoraleLuckBox>(false, Rect(233, 179, 53, 45));
|
|
|
|
spellPointsArea = std::make_shared<LRClickableAreaWText>(Rect(162,228, 136, 42), CGI->generaltexth->heroscrn[22]);
|
|
|
|
|
|
|
|
expValue = std::make_shared<CLabel>(68, 252);
|
|
|
|
manaValue = std::make_shared<CLabel>(211, 252);
|
|
|
|
|
|
|
|
for(int i = 0; i < std::min<size_t>(hero->secSkills.size(), 8u); ++i)
|
|
|
|
{
|
|
|
|
Rect r = Rect(i%2 == 0 ? 18 : 162, 276 + 48 * (i/2), 136, 42);
|
2024-11-03 17:24:08 +02:00
|
|
|
secSkills.emplace_back(std::make_shared<CSecSkillPlace>(r.topLeft(), CSecSkillPlace::ImageSize::MEDIUM));
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
int x = (i % 2) ? 212 : 68;
|
|
|
|
int y = 280 + 48 * (i/2);
|
|
|
|
|
|
|
|
secSkillValues.push_back(std::make_shared<CLabel>(x, y, FONT_SMALL, ETextAlignment::TOPLEFT));
|
|
|
|
secSkillNames.push_back(std::make_shared<CLabel>(x, y+20, FONT_SMALL, ETextAlignment::TOPLEFT));
|
|
|
|
}
|
|
|
|
|
|
|
|
// various texts
|
|
|
|
labels.push_back(std::make_shared<CLabel>(52, 99, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[1]));
|
|
|
|
labels.push_back(std::make_shared<CLabel>(123, 99, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[2]));
|
|
|
|
labels.push_back(std::make_shared<CLabel>(193, 99, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[3]));
|
|
|
|
labels.push_back(std::make_shared<CLabel>(262, 99, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[4]));
|
|
|
|
|
|
|
|
labels.push_back(std::make_shared<CLabel>(69, 183, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[5]));
|
|
|
|
labels.push_back(std::make_shared<CLabel>(69, 232, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[6]));
|
|
|
|
labels.push_back(std::make_shared<CLabel>(213, 232, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[7]));
|
|
|
|
|
2024-05-08 13:16:16 +02:00
|
|
|
CHeroWindow::update();
|
2023-10-19 16:19:09 +02:00
|
|
|
}
|
|
|
|
|
2024-05-08 13:16:16 +02:00
|
|
|
void CHeroWindow::update()
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
2024-05-08 13:16:16 +02:00
|
|
|
CWindowWithArtifacts::update();
|
2023-10-19 16:19:09 +02:00
|
|
|
auto & heroscrn = CGI->generaltexth->heroscrn;
|
2024-05-08 13:16:16 +02:00
|
|
|
assert(curHero);
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
name->setText(curHero->getNameTranslated());
|
2024-01-30 23:34:27 +02:00
|
|
|
title->setText((boost::format(CGI->generaltexth->allTexts[342]) % curHero->level % curHero->getClassNameTranslated()).str());
|
2023-10-19 16:19:09 +02:00
|
|
|
|
2024-10-05 21:37:52 +02:00
|
|
|
specArea->text = curHero->getHeroType()->getSpecialtyDescriptionTranslated();
|
|
|
|
specImage->setFrame(curHero->getHeroType()->imageIndex);
|
|
|
|
specName->setText(curHero->getHeroType()->getSpecialtyNameTranslated());
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
tacticsButton = std::make_shared<CToggleButton>(Point(539, 483), AnimationPath::builtin("hsbtns8.def"), std::make_pair(heroscrn[26], heroscrn[31]), 0, EShortcut::HERO_TOGGLE_TACTICS);
|
2024-02-27 22:19:09 +02:00
|
|
|
tacticsButton->addHoverText(EButtonState::HIGHLIGHTED, CGI->generaltexth->heroscrn[25]);
|
2023-10-19 16:19:09 +02:00
|
|
|
|
2024-02-27 22:19:09 +02:00
|
|
|
dismissButton->addHoverText(EButtonState::NORMAL, boost::str(boost::format(CGI->generaltexth->heroscrn[16]) % curHero->getNameTranslated() % curHero->getClassNameTranslated()));
|
2024-01-30 23:34:27 +02:00
|
|
|
portraitArea->hoverText = boost::str(boost::format(CGI->generaltexth->allTexts[15]) % curHero->getNameTranslated() % curHero->getClassNameTranslated());
|
2023-10-19 16:19:09 +02:00
|
|
|
portraitArea->text = curHero->getBiographyTranslated();
|
|
|
|
portraitImage->setFrame(curHero->getIconIndex());
|
|
|
|
|
|
|
|
{
|
2024-08-09 17:30:04 +02:00
|
|
|
OBJECT_CONSTRUCTION;
|
2023-10-19 16:19:09 +02:00
|
|
|
if(!garr)
|
|
|
|
{
|
2024-11-17 15:55:33 +02:00
|
|
|
bool removableTroops = curHero->getOwner() == LOCPLINT->playerID;
|
2023-10-19 16:19:09 +02:00
|
|
|
std::string helpBox = heroscrn[32];
|
|
|
|
boost::algorithm::replace_first(helpBox, "%s", CGI->generaltexth->allTexts[43]);
|
|
|
|
|
2024-11-17 15:55:33 +02:00
|
|
|
garr = std::make_shared<CGarrisonInt>(Point(15, 485), 8, Point(), curHero, nullptr, removableTroops);
|
2024-06-01 13:48:30 +02:00
|
|
|
auto split = std::make_shared<CButton>(Point(539, 519), AnimationPath::builtin("hsbtns9.def"), CButton::tooltip(CGI->generaltexth->allTexts[256], helpBox), [this](){ garr->splitClick(); }, EShortcut::HERO_ARMY_SPLIT);
|
2023-10-19 16:19:09 +02:00
|
|
|
garr->addSplitBtn(split);
|
|
|
|
}
|
|
|
|
if(!arts)
|
|
|
|
{
|
2024-04-19 16:14:41 +02:00
|
|
|
arts = std::make_shared<CArtifactsOfHeroMain>(Point(-65, -8));
|
2024-11-04 13:45:44 +02:00
|
|
|
arts->clickPressedCallback = [this](const CArtPlace & artPlace, const Point & cursorPosition){clickPressedOnArtPlace(curHero, artPlace.slot, true, false, false, cursorPosition);};
|
2024-05-20 14:31:07 +02:00
|
|
|
arts->showPopupCallback = [this](CArtPlace & artPlace, const Point & cursorPosition){showArtifactAssembling(*arts, artPlace, cursorPosition);};
|
|
|
|
arts->gestureCallback = [this](const CArtPlace & artPlace, const Point & cursorPosition){showQuickBackpackWindow(curHero, artPlace.slot, cursorPosition);};
|
2023-10-19 16:19:09 +02:00
|
|
|
arts->setHero(curHero);
|
2024-05-20 11:47:25 +02:00
|
|
|
addSet(arts);
|
|
|
|
enableKeyboardShortcuts();
|
2023-10-19 16:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int serial = LOCPLINT->cb->getHeroSerial(curHero, false);
|
|
|
|
|
|
|
|
listSelection.reset();
|
|
|
|
if(serial >= 0)
|
|
|
|
listSelection = std::make_shared<CPicture>(ImagePath::builtin("HPSYYY"), 612, 33 + serial * 54);
|
|
|
|
}
|
|
|
|
|
|
|
|
//primary skills support
|
|
|
|
for(size_t g=0; g<primSkillAreas.size(); ++g)
|
|
|
|
{
|
2023-10-31 11:09:56 +02:00
|
|
|
int value = curHero->getPrimSkillLevel(static_cast<PrimarySkill>(g));
|
|
|
|
primSkillAreas[g]->component.value = value;
|
|
|
|
primSkillValues[g]->setText(std::to_string(value));
|
2023-10-19 16:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//secondary skills support
|
2024-10-21 20:49:22 +02:00
|
|
|
for(size_t g=0; g< secSkills.size(); ++g)
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
2023-10-31 11:09:56 +02:00
|
|
|
SecondarySkill skill = curHero->secSkills[g].first;
|
|
|
|
int level = curHero->getSecSkillLevel(skill);
|
2023-10-19 16:19:09 +02:00
|
|
|
std::string skillName = CGI->skillh->getByIndex(skill)->getNameTranslated();
|
|
|
|
std::string skillValue = CGI->generaltexth->levels[level-1];
|
|
|
|
|
|
|
|
secSkillNames[g]->setText(skillName);
|
|
|
|
secSkillValues[g]->setText(skillValue);
|
2024-10-21 20:49:22 +02:00
|
|
|
secSkills[g]->setSkill(skill, level);
|
2023-10-19 16:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::ostringstream expstr;
|
|
|
|
expstr << curHero->exp;
|
|
|
|
expValue->setText(expstr.str());
|
|
|
|
|
|
|
|
std::ostringstream manastr;
|
|
|
|
manastr << curHero->mana << '/' << curHero->manaLimit();
|
|
|
|
manaValue->setText(manastr.str());
|
|
|
|
|
|
|
|
//printing experience - original format does not support ui64
|
|
|
|
expArea->text = CGI->generaltexth->allTexts[2];
|
|
|
|
boost::replace_first(expArea->text, "%d", std::to_string(curHero->level));
|
|
|
|
boost::replace_first(expArea->text, "%d", std::to_string(CGI->heroh->reqExp(curHero->level+1)));
|
|
|
|
boost::replace_first(expArea->text, "%d", std::to_string(curHero->exp));
|
|
|
|
|
|
|
|
//printing spell points, boost::format can't be used due to locale issues
|
|
|
|
spellPointsArea->text = CGI->generaltexth->allTexts[205];
|
|
|
|
boost::replace_first(spellPointsArea->text, "%s", curHero->getNameTranslated());
|
|
|
|
boost::replace_first(spellPointsArea->text, "%d", std::to_string(curHero->mana));
|
|
|
|
boost::replace_first(spellPointsArea->text, "%d", std::to_string(curHero->manaLimit()));
|
|
|
|
|
|
|
|
//if we have exchange window with this curHero open
|
|
|
|
bool noDismiss=false;
|
|
|
|
|
|
|
|
for(auto cew : GH.windows().findWindows<CExchangeWindow>())
|
|
|
|
{
|
2024-05-19 14:28:03 +02:00
|
|
|
if (cew->holdsGarrison(curHero))
|
|
|
|
noDismiss = true;
|
2023-10-19 16:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//if player only have one hero and no towns
|
|
|
|
if(!LOCPLINT->cb->howManyTowns() && LOCPLINT->cb->howManyHeroes() == 1)
|
|
|
|
noDismiss = true;
|
|
|
|
|
|
|
|
if(curHero->isMissionCritical())
|
|
|
|
noDismiss = true;
|
|
|
|
|
|
|
|
dismissButton->block(noDismiss);
|
|
|
|
|
|
|
|
if(curHero->valOfBonuses(Selector::type()(BonusType::BEFORE_BATTLE_REPOSITION)) == 0)
|
|
|
|
{
|
|
|
|
tacticsButton->block(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tacticsButton->block(false);
|
|
|
|
tacticsButton->addCallback([&](bool on){curHero->tacticFormationEnabled = on;});
|
|
|
|
}
|
|
|
|
|
|
|
|
formations->resetCallback();
|
|
|
|
//setting formations
|
|
|
|
formations->setSelected(curHero->formation == EArmyFormation::TIGHT ? 1 : 0);
|
2023-11-06 18:27:16 +02:00
|
|
|
formations->addCallback([=](int value){ LOCPLINT->cb->setFormation(curHero, static_cast<EArmyFormation>(value));});
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
morale->set(curHero);
|
|
|
|
luck->set(curHero);
|
|
|
|
|
2024-05-08 13:16:16 +02:00
|
|
|
redraw();
|
2023-10-19 16:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CHeroWindow::dismissCurrent()
|
|
|
|
{
|
2024-04-28 18:01:14 +02:00
|
|
|
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[22], [this]()
|
|
|
|
{
|
|
|
|
arts->putBackPickedArtifact();
|
|
|
|
close();
|
|
|
|
LOCPLINT->cb->dismissHero(curHero);
|
|
|
|
}, nullptr);
|
2023-10-19 16:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CHeroWindow::createBackpackWindow()
|
|
|
|
{
|
2024-04-16 16:45:31 +02:00
|
|
|
GH.windows().createAndPushWindow<CHeroBackpackWindow>(curHero, artSets);
|
2023-10-19 16:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CHeroWindow::commanderWindow()
|
|
|
|
{
|
|
|
|
const auto pickedArtInst = getPickedArtifact();
|
|
|
|
const auto hero = getHeroPickedArtifact();
|
|
|
|
|
|
|
|
if(pickedArtInst)
|
|
|
|
{
|
|
|
|
const auto freeSlot = ArtifactUtils::getArtAnyPosition(curHero->commander, pickedArtInst->getTypeId());
|
2023-07-24 18:09:17 +02:00
|
|
|
if(vstd::contains(ArtifactUtils::commanderSlots(), freeSlot)) // We don't want to put it in commander's backpack!
|
2023-10-19 16:19:09 +02:00
|
|
|
{
|
2023-10-14 21:00:39 +02:00
|
|
|
ArtifactLocation dst(curHero->id, freeSlot);
|
2023-10-23 18:37:18 +02:00
|
|
|
dst.creature = SlotID::COMMANDER_SLOT_PLACEHOLDER;
|
|
|
|
LOCPLINT->cb->swapArtifacts(ArtifactLocation(hero->id, ArtifactPosition::TRANSITION_POS), dst);
|
2023-10-19 16:19:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GH.windows().createAndPushWindow<CStackWindow>(curHero->commander, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CHeroWindow::updateGarrisons()
|
|
|
|
{
|
|
|
|
garr->recreateSlots();
|
|
|
|
morale->set(curHero);
|
|
|
|
}
|
2023-11-09 00:01:48 +02:00
|
|
|
|
|
|
|
bool CHeroWindow::holdsGarrison(const CArmedInstance * army)
|
|
|
|
{
|
|
|
|
return army == curHero;
|
|
|
|
}
|