2011-12-14 00:23:17 +03:00
|
|
|
#include "StdInc.h"
|
|
|
|
|
2012-05-13 18:04:21 +03:00
|
|
|
#include "CAnimation.h"
|
2008-01-11 20:56:39 +02:00
|
|
|
#include "CAdvmapInterface.h"
|
2009-05-20 13:08:56 +03:00
|
|
|
#include "../CCallback.h"
|
2008-08-26 00:14:00 +03:00
|
|
|
#include "CGameInfo.h"
|
|
|
|
#include "CHeroWindow.h"
|
2008-01-15 20:50:52 +02:00
|
|
|
#include "CMessage.h"
|
2010-02-04 17:50:59 +02:00
|
|
|
#include "CKingdomInterface.h"
|
2012-05-16 20:29:05 +03:00
|
|
|
#include "CCreatureWindow.h"
|
2011-07-02 19:49:22 +03:00
|
|
|
#include "SDL.h"
|
2013-04-07 14:52:07 +03:00
|
|
|
#include "gui/SDL_Extensions.h"
|
2009-05-20 13:08:56 +03:00
|
|
|
#include "CBitmapHandler.h"
|
|
|
|
#include "Graphics.h"
|
|
|
|
#include "CSpellWindow.h"
|
2012-09-29 13:59:43 +03:00
|
|
|
#include "../lib/CConfigHandler.h"
|
2011-02-06 19:26:27 +02:00
|
|
|
#include "CPlayerInterface.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "../lib/CArtHandler.h"
|
|
|
|
#include "CDefHandler.h"
|
|
|
|
#include "../lib/CGeneralTextHandler.h"
|
|
|
|
#include "../lib/CHeroHandler.h"
|
2014-06-05 19:52:14 +03:00
|
|
|
#include "../lib/mapObjects/CGHeroInstance.h"
|
2014-01-16 23:24:06 +03:00
|
|
|
#include "../lib/NetPacksBase.h"
|
2009-01-07 21:40:19 +02:00
|
|
|
|
2013-04-07 14:52:07 +03:00
|
|
|
#include "gui/CGuiHandler.h"
|
|
|
|
#include "gui/CIntObjectClasses.h"
|
2013-04-04 17:58:54 +03:00
|
|
|
#include "CMT.h"
|
2011-12-17 21:59:59 +03:00
|
|
|
|
2009-11-29 04:46:30 +02:00
|
|
|
#undef min
|
2009-11-21 00:35:18 +02:00
|
|
|
|
2009-04-15 17:03:31 +03: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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-08-26 00:14:00 +03:00
|
|
|
using namespace boost::assign;
|
2010-07-13 08:25:40 +03:00
|
|
|
|
2013-06-26 14:18:27 +03:00
|
|
|
const TBonusListPtr CHeroWithMaybePickedArtifact::getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= nullptr*/, const std::string &cachingStr /*= ""*/) const
|
2011-02-27 21:58:14 +02:00
|
|
|
{
|
2011-09-06 16:59:26 +03:00
|
|
|
TBonusListPtr out(new BonusList);
|
|
|
|
TBonusListPtr heroBonuses = hero->getAllBonuses(selector, limit, hero);
|
|
|
|
TBonusListPtr bonusesFromPickedUpArtifact;
|
2011-02-27 21:58:14 +02:00
|
|
|
|
2013-06-26 14:18:27 +03:00
|
|
|
CArtifactsOfHero::SCommonPart *cp = cww->artSets.size() ? cww->artSets.front()->commonInfo : nullptr;
|
2011-07-02 18:12:35 +03:00
|
|
|
if(cp && cp->src.art && cp->src.valid() && cp->src.AOH && cp->src.AOH->getHero() == hero)
|
2011-02-27 21:58:14 +02:00
|
|
|
{
|
2011-06-25 16:53:15 +03:00
|
|
|
bonusesFromPickedUpArtifact = cp->src.art->getAllBonuses(selector, limit, hero);
|
2011-02-27 21:58:14 +02:00
|
|
|
}
|
2011-06-25 16:53:15 +03:00
|
|
|
else
|
2011-09-06 16:59:26 +03:00
|
|
|
bonusesFromPickedUpArtifact = TBonusListPtr(new BonusList);
|
2011-02-27 21:58:14 +02:00
|
|
|
|
2013-06-29 16:05:48 +03:00
|
|
|
for(Bonus *b : *bonusesFromPickedUpArtifact)
|
2011-06-25 16:53:15 +03:00
|
|
|
*heroBonuses -= b;
|
2013-06-29 16:05:48 +03:00
|
|
|
for(Bonus *b : *heroBonuses)
|
2011-06-25 16:53:15 +03:00
|
|
|
out->push_back(b);
|
|
|
|
return out;
|
2011-02-27 21:58:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CHeroWithMaybePickedArtifact::CHeroWithMaybePickedArtifact(CWindowWithArtifacts *Cww, const CGHeroInstance *Hero)
|
2011-02-28 17:14:26 +02:00
|
|
|
: hero(Hero), cww(Cww)
|
2011-02-27 21:58:14 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-07-13 08:25:40 +03:00
|
|
|
void CHeroSwitcher::clickLeft(tribool down, bool previousState)
|
|
|
|
{
|
|
|
|
if(!down)
|
|
|
|
{
|
2012-05-13 18:04:21 +03:00
|
|
|
const CGHeroInstance * buf = hero;
|
|
|
|
GH.popIntTotally(parent);
|
2011-01-06 22:00:19 +02:00
|
|
|
GH.pushInt(new CHeroWindow(buf));
|
2010-07-13 08:25:40 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-13 18:04:21 +03:00
|
|
|
CHeroSwitcher::CHeroSwitcher(Point _pos, const CGHeroInstance * _hero):
|
|
|
|
hero(_hero)
|
2010-07-13 08:25:40 +03:00
|
|
|
{
|
2012-05-13 18:04:21 +03:00
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
|
pos += _pos;
|
2012-06-02 18:16:54 +03:00
|
|
|
addUsedEvents(LCLICK);
|
2012-05-13 18:04:21 +03:00
|
|
|
|
|
|
|
image = new CAnimImage("PortraitsSmall", hero->portrait);
|
|
|
|
pos.w = image->pos.w;
|
|
|
|
pos.h = image->pos.h;
|
2010-07-13 08:25:40 +03:00
|
|
|
}
|
|
|
|
|
2012-06-15 20:08:19 +03:00
|
|
|
CHeroWindow::CHeroWindow(const CGHeroInstance *hero):
|
|
|
|
CWindowObject(PLAYER_COLORED, "HeroScr4"),
|
|
|
|
heroWArt(this, hero)
|
2008-01-10 21:01:25 +02:00
|
|
|
{
|
2010-12-17 00:32:53 +02:00
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
2012-05-13 18:04:21 +03:00
|
|
|
garr = nullptr;
|
2011-01-06 22:00:19 +02:00
|
|
|
curHero = hero;
|
2012-05-13 18:04:21 +03:00
|
|
|
listSelection = nullptr;
|
2009-06-18 18:05:00 +03:00
|
|
|
|
2013-03-03 20:06:03 +03:00
|
|
|
new CAnimImage("CREST58", LOCPLINT->playerID.getNum(), 0, 606, 8);
|
2008-01-30 15:18:08 +02:00
|
|
|
|
2010-12-17 00:32:53 +02:00
|
|
|
//artifs = new CArtifactsOfHero(pos.topLeft(), true);
|
|
|
|
ourBar = new CGStatusBar(7, 559, "ADROLLVR.bmp", 660); // new CStatusBar(pos.x+72, pos.y+567, "ADROLLVR.bmp", 660);
|
2008-01-12 14:55:45 +02:00
|
|
|
|
2014-08-04 21:33:59 +03:00
|
|
|
quitButton = new CAdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(),std::bind(&CHeroWindow::close,this), 609, 516, "hsbtns.def", SDLK_RETURN);
|
2011-09-22 17:21:53 +03:00
|
|
|
quitButton->assignedKeys.insert(SDLK_ESCAPE);
|
2014-08-04 21:33:59 +03:00
|
|
|
dismissButton = new CAdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], std::bind(&CHeroWindow::dismissCurrent,this), 454, 429, "hsbtns2.def", SDLK_d);
|
|
|
|
questlogButton = new CAdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), std::bind(&CHeroWindow::questlog,this), 314, 429, "hsbtns4.def", SDLK_q);
|
2008-09-24 11:15:49 +03:00
|
|
|
|
2010-12-17 00:32:53 +02:00
|
|
|
formations = new CHighlightableButtonsGroup(0);
|
2011-02-20 11:24:53 +02:00
|
|
|
formations->addButton(map_list_of(0,CGI->generaltexth->heroscrn[23]),CGI->generaltexth->heroscrn[29], "hsbtns6.def", 481, 483, 0, 0, SDLK_t);
|
|
|
|
formations->addButton(map_list_of(0,CGI->generaltexth->heroscrn[24]),CGI->generaltexth->heroscrn[30], "hsbtns7.def", 481, 519, 1, 0, SDLK_l);
|
2008-09-19 11:16:19 +03:00
|
|
|
|
2013-06-26 14:18:27 +03:00
|
|
|
tacticsButton = new CHighlightableButton(0, 0, map_list_of(0,CGI->generaltexth->heroscrn[26])(3,CGI->generaltexth->heroscrn[25]), CGI->generaltexth->heroscrn[31], false, "hsbtns8.def", nullptr, 539, 483, SDLK_b);
|
2008-11-28 03:36:34 +02:00
|
|
|
|
2012-05-16 20:29:05 +03:00
|
|
|
if (hero->commander)
|
|
|
|
{
|
2014-08-04 21:33:59 +03:00
|
|
|
commanderButton = new CAdventureMapButton ("Commander", "Commander info", std::bind(&CHeroWindow::commanderWindow, this), 317, 18, "chftke.def", SDLK_c, nullptr, false);
|
2012-05-16 20:29:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-19 15:10:36 +03:00
|
|
|
//right list of heroes
|
2012-05-13 18:04:21 +03:00
|
|
|
for(int i=0; i < std::min(LOCPLINT->cb->howManyHeroes(false), 8); i++)
|
|
|
|
heroList.push_back(new CHeroSwitcher(Point(612, 87 + i * 54), LOCPLINT->cb->getHeroBySerial(i, false)));
|
2010-12-17 00:32:53 +02:00
|
|
|
|
2008-01-19 20:58:24 +02:00
|
|
|
//areas
|
2011-12-22 16:05:19 +03:00
|
|
|
portraitArea = new LRClickableAreaWText(Rect(18, 18, 58, 64));
|
2012-05-13 18:04:21 +03:00
|
|
|
portraitImage = new CAnimImage("PortraitsLarge", 0, 0, 19, 19);
|
2009-06-19 15:10:36 +03:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
for(int v=0; v<GameConstants::PRIMARY_SKILLS; ++v)
|
2008-01-27 18:07:27 +02:00
|
|
|
{
|
2013-06-29 16:05:48 +03:00
|
|
|
auto area = new LRClickableAreaWTextComp(Rect(30 + 70*v, 109, 42, 64), CComponent::primskill);
|
2010-12-17 00:32:53 +02:00
|
|
|
area->text = CGI->generaltexth->arraytxt[2+v];
|
|
|
|
area->type = v;
|
|
|
|
area->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1]) % CGI->generaltexth->primarySkillNames[v]);
|
|
|
|
primSkillAreas.push_back(area);
|
2010-02-01 01:30:47 +02:00
|
|
|
}
|
|
|
|
|
2012-05-13 18:04:21 +03:00
|
|
|
specImage = new CAnimImage("UN44", 0, 0, 18, 180);
|
|
|
|
|
2011-12-22 16:05:19 +03:00
|
|
|
specArea = new LRClickableAreaWText(Rect(18, 180, 136, 42), CGI->generaltexth->heroscrn[27]);
|
|
|
|
expArea = new LRClickableAreaWText(Rect(18, 228, 136, 42), CGI->generaltexth->heroscrn[9]);
|
|
|
|
morale = new MoraleLuckBox(true, Rect(175,179,53,45));
|
|
|
|
luck = new MoraleLuckBox(false, Rect(233,179,53,45));
|
|
|
|
spellPointsArea = new LRClickableAreaWText(Rect(162,228, 136, 42), CGI->generaltexth->heroscrn[22]);
|
2008-01-29 15:55:14 +02:00
|
|
|
|
2011-02-23 17:51:33 +02:00
|
|
|
for(int i = 0; i < std::min<size_t>(hero->secSkills.size(), 8u); ++i)
|
2008-01-28 14:28:18 +02:00
|
|
|
{
|
2011-12-22 16:05:19 +03:00
|
|
|
Rect r = Rect(i%2 == 0 ? 18 : 162, 276 + 48 * (i/2), 136, 42);
|
|
|
|
secSkillAreas.push_back(new LRClickableAreaWTextComp(r, CComponent::secskill));
|
2012-05-13 18:04:21 +03:00
|
|
|
secSkillImages.push_back(new CAnimImage("SECSKILL", 0, 0, r.x, r.y));
|
2008-01-28 14:28:18 +02:00
|
|
|
}
|
2010-12-17 00:32:53 +02:00
|
|
|
|
2013-03-14 23:44:00 +03:00
|
|
|
//dismiss / quest log
|
|
|
|
new CTextBox(CGI->generaltexth->jktexts[8], Rect(370, 430, 65, 35), 0, FONT_SMALL, TOPLEFT, Colors::WHITE);
|
|
|
|
new CTextBox(CGI->generaltexth->jktexts[9], Rect(510, 430, 65, 35), 0, FONT_SMALL, TOPLEFT, Colors::WHITE);
|
|
|
|
|
2010-12-17 00:32:53 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////////???????????????
|
2012-05-13 18:04:21 +03:00
|
|
|
|
2010-12-17 00:32:53 +02:00
|
|
|
//primary skills & exp and mana
|
2012-05-13 18:04:21 +03:00
|
|
|
new CAnimImage("PSKIL42", 0, 0, 32, 111, false);
|
|
|
|
new CAnimImage("PSKIL42", 1, 0, 102, 111, false);
|
|
|
|
new CAnimImage("PSKIL42", 2, 0, 172, 111, false);
|
|
|
|
new CAnimImage("PSKIL42", 3, 0, 162, 230, false);
|
|
|
|
new CAnimImage("PSKIL42", 4, 0, 20, 230, false);
|
|
|
|
new CAnimImage("PSKIL42", 5, 0, 242, 111, false);
|
2010-12-17 00:32:53 +02:00
|
|
|
|
2013-06-23 22:35:54 +03:00
|
|
|
// various texts
|
|
|
|
new CLabel( 52, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[1]);
|
|
|
|
new CLabel(123, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[2]);
|
|
|
|
new CLabel(193, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[3]);
|
|
|
|
new CLabel(262, 99, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[4]);
|
|
|
|
|
|
|
|
new CLabel( 69, 183, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[5]);
|
|
|
|
new CLabel( 69, 232, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[6]);
|
|
|
|
new CLabel(213, 232, FONT_SMALL, TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[7]);
|
|
|
|
|
2011-01-06 22:00:19 +02:00
|
|
|
update(hero);
|
2008-01-10 21:01:25 +02:00
|
|
|
}
|
|
|
|
|
2011-01-06 22:00:19 +02:00
|
|
|
void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= false*/)
|
2010-12-17 00:32:53 +02:00
|
|
|
{
|
2008-01-28 14:28:18 +02:00
|
|
|
if(!hero) //something strange... no hero? it shouldn't happen
|
2010-12-17 00:32:53 +02:00
|
|
|
{
|
2013-06-26 14:18:27 +03:00
|
|
|
logGlobal->errorStream() << "Set nullptr hero? no way...";
|
2010-12-17 00:32:53 +02:00
|
|
|
return;
|
|
|
|
}
|
2010-07-21 22:50:15 +03:00
|
|
|
|
2011-01-06 22:00:19 +02:00
|
|
|
assert(hero == curHero);
|
2012-05-13 18:04:21 +03:00
|
|
|
|
2012-12-16 16:47:53 +03:00
|
|
|
specArea->text = curHero->type->specDescr;
|
|
|
|
specImage->setFrame(curHero->type->imageIndex);
|
2008-11-28 03:36:34 +02:00
|
|
|
|
2010-12-17 00:32:53 +02:00
|
|
|
tacticsButton->callback.clear();
|
|
|
|
tacticsButton->callback2.clear();
|
2008-01-31 14:10:59 +02:00
|
|
|
|
2010-12-17 00:32:53 +02:00
|
|
|
dismissButton->hoverTexts[0] = boost::str(boost::format(CGI->generaltexth->heroscrn[16]) % curHero->name % curHero->type->heroClass->name);
|
|
|
|
portraitArea->hoverText = boost::str(boost::format(CGI->generaltexth->allTexts[15]) % curHero->name % curHero->type->heroClass->name);
|
2011-02-27 21:58:14 +02:00
|
|
|
portraitArea->text = curHero->getBiography();
|
2012-05-13 18:04:21 +03:00
|
|
|
portraitImage->setFrame(curHero->portrait);
|
2008-01-19 15:19:58 +02:00
|
|
|
|
2010-12-17 00:32:53 +02:00
|
|
|
{
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
2011-01-06 22:00:19 +02:00
|
|
|
if(!garr)
|
|
|
|
{
|
2011-12-22 16:05:19 +03:00
|
|
|
garr = new CGarrisonInt(15, 485, 8, Point(), background->bg, Point(15,485), curHero);
|
2013-11-07 15:48:41 +03:00
|
|
|
auto split = new CAdventureMapButton(CGI->generaltexth->allTexts[256], CGI->generaltexth->heroscrn[32],
|
2014-08-04 21:33:59 +03:00
|
|
|
std::bind(&CGarrisonInt::splitClick,garr), 539, 519, "hsbtns9.def", false, nullptr, false); //deleted by garrison destructor
|
2012-02-21 17:08:42 +03:00
|
|
|
boost::algorithm::replace_first(split->hoverTexts[0],"%s",CGI->generaltexth->allTexts[43]);
|
|
|
|
|
2011-01-06 22:00:19 +02:00
|
|
|
garr->addSplitBtn(split);
|
|
|
|
}
|
|
|
|
if(!artSets.size())
|
|
|
|
{
|
2013-06-29 16:05:48 +03:00
|
|
|
auto arts = new CArtifactsOfHero(Point(-65, -8), true);
|
2011-02-27 21:58:14 +02:00
|
|
|
arts->setHero(curHero);
|
2011-01-06 22:00:19 +02:00
|
|
|
artSets.push_back(arts);
|
|
|
|
}
|
2009-09-09 09:04:42 +03:00
|
|
|
|
2012-05-13 18:04:21 +03:00
|
|
|
int serial = LOCPLINT->cb->getHeroSerial(curHero, false);
|
2012-06-02 18:16:54 +03:00
|
|
|
|
|
|
|
vstd::clear_pointer(listSelection);
|
2012-05-13 18:04:21 +03:00
|
|
|
if (serial >= 0)
|
|
|
|
listSelection = new CPicture("HPSYYY", 612, 33 + serial * 54);
|
|
|
|
}
|
2008-06-21 16:27:52 +03:00
|
|
|
|
2009-06-19 15:10:36 +03:00
|
|
|
//primary skills support
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t g=0; g<primSkillAreas.size(); ++g)
|
2008-01-27 18:07:27 +02:00
|
|
|
{
|
2013-02-06 13:16:44 +03:00
|
|
|
primSkillAreas[g]->bonusValue = heroWArt.getPrimSkillLevel(static_cast<PrimarySkill::PrimarySkill>(g));
|
2008-01-27 18:07:27 +02:00
|
|
|
}
|
2009-07-03 22:57:14 +03:00
|
|
|
|
2009-06-19 15:10:36 +03:00
|
|
|
//secondary skills support
|
2011-01-06 22:00:19 +02:00
|
|
|
for(size_t g=0; g< secSkillAreas.size(); ++g)
|
2008-01-28 14:28:18 +02:00
|
|
|
{
|
2011-02-27 21:58:14 +02:00
|
|
|
int skill = curHero->secSkills[g].first,
|
2013-02-12 22:49:40 +03:00
|
|
|
level = curHero->getSecSkillLevel(SecondarySkill(curHero->secSkills[g].first));
|
2009-07-03 22:57:14 +03:00
|
|
|
secSkillAreas[g]->type = skill;
|
2010-07-13 08:25:40 +03:00
|
|
|
secSkillAreas[g]->bonusValue = level;
|
2009-07-03 22:57:14 +03:00
|
|
|
secSkillAreas[g]->text = CGI->generaltexth->skillInfoTexts[skill][level-1];
|
2010-12-17 00:32:53 +02:00
|
|
|
secSkillAreas[g]->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[21]) % CGI->generaltexth->levels[level-1] % CGI->generaltexth->skillName[skill]);
|
2012-05-13 18:04:21 +03:00
|
|
|
secSkillImages[g]->setFrame(skill*3 + level + 2);
|
2008-01-28 14:28:18 +02:00
|
|
|
}
|
2008-01-27 18:07:27 +02:00
|
|
|
|
2009-10-28 12:45:45 +02:00
|
|
|
//printing experience - original format does not support ui64
|
2010-12-17 00:32:53 +02:00
|
|
|
expArea->text = CGI->generaltexth->allTexts[2];
|
2011-02-27 21:58:14 +02:00
|
|
|
boost::replace_first(expArea->text, "%d", boost::lexical_cast<std::string>(curHero->level));
|
|
|
|
boost::replace_first(expArea->text, "%d", boost::lexical_cast<std::string>(CGI->heroh->reqExp(curHero->level+1)));
|
|
|
|
boost::replace_first(expArea->text, "%d", boost::lexical_cast<std::string>(curHero->exp));
|
2008-09-29 00:01:49 +03:00
|
|
|
|
2011-02-28 17:14:26 +02:00
|
|
|
//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", boost::lexical_cast<std::string>(curHero->name));
|
|
|
|
boost::replace_first(spellPointsArea->text, "%d", boost::lexical_cast<std::string>(curHero->mana));
|
|
|
|
boost::replace_first(spellPointsArea->text, "%d", boost::lexical_cast<std::string>(heroWArt.manaLimit()));
|
2008-01-30 12:55:43 +02:00
|
|
|
|
2011-02-27 21:58:14 +02:00
|
|
|
//if we have exchange window with this curHero open
|
2010-02-04 17:50:59 +02:00
|
|
|
bool noDismiss=false;
|
2013-06-29 16:05:48 +03:00
|
|
|
for(IShowActivatable *isa : GH.listInt)
|
2010-02-04 17:50:59 +02:00
|
|
|
{
|
2010-12-17 00:32:53 +02:00
|
|
|
if(CExchangeWindow * cew = dynamic_cast<CExchangeWindow*>(isa))
|
|
|
|
for(int g=0; g < ARRAY_COUNT(cew->heroInst); ++g)
|
2011-02-27 21:58:14 +02:00
|
|
|
if(cew->heroInst[g] == curHero)
|
2010-12-17 00:32:53 +02:00
|
|
|
noDismiss = true;
|
|
|
|
|
2011-02-20 11:24:53 +02:00
|
|
|
if (dynamic_cast<CKingdomInterface*>(isa))
|
2010-12-17 00:32:53 +02:00
|
|
|
noDismiss = true;
|
2010-02-04 17:50:59 +02:00
|
|
|
}
|
2011-02-27 21:58:14 +02:00
|
|
|
dismissButton->block(!!curHero->visitedTown || noDismiss);
|
2010-12-17 00:32:53 +02:00
|
|
|
|
2013-02-04 22:43:16 +03:00
|
|
|
if(curHero->getSecSkillLevel(SecondarySkill::TACTICS) == 0)
|
2010-12-17 00:32:53 +02:00
|
|
|
tacticsButton->block(true);
|
2008-08-28 20:36:34 +03:00
|
|
|
else
|
|
|
|
{
|
2010-12-17 00:32:53 +02:00
|
|
|
tacticsButton->block(false);
|
2011-02-27 21:58:14 +02:00
|
|
|
tacticsButton->callback = vstd::assigno(curHero->tacticFormationEnabled,true);
|
|
|
|
tacticsButton->callback2 = vstd::assigno(curHero->tacticFormationEnabled,false);
|
2008-08-28 20:36:34 +03:00
|
|
|
}
|
2008-09-24 11:15:49 +03:00
|
|
|
|
2009-06-19 15:10:36 +03:00
|
|
|
//setting formations
|
2008-10-26 22:58:34 +02:00
|
|
|
formations->onChange = 0;
|
2011-02-27 21:58:14 +02:00
|
|
|
formations->select(curHero->formation,true);
|
2014-08-04 21:33:59 +03:00
|
|
|
formations->onChange = std::bind(&CCallback::setFormation, LOCPLINT->cb.get(), curHero, _1);
|
2008-09-24 11:15:49 +03:00
|
|
|
|
2011-02-27 21:58:14 +02:00
|
|
|
morale->set(&heroWArt);
|
|
|
|
luck->set(&heroWArt);
|
2011-01-06 22:00:19 +02:00
|
|
|
|
|
|
|
if(redrawNeeded)
|
|
|
|
redraw();
|
2008-01-11 20:56:39 +02:00
|
|
|
}
|
|
|
|
|
2008-01-15 20:50:52 +02:00
|
|
|
void CHeroWindow::dismissCurrent()
|
|
|
|
{
|
2014-08-04 21:33:59 +03:00
|
|
|
CFunctionList<void()> ony = std::bind(&CHeroWindow::close,this);
|
|
|
|
ony += std::bind(&CCallback::dismissHero, LOCPLINT->cb.get(), curHero);
|
2012-04-09 05:53:50 +03:00
|
|
|
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[22], ony, 0, false);
|
2008-01-15 20:50:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CHeroWindow::questlog()
|
|
|
|
{
|
|
|
|
}
|
2011-02-27 21:58:14 +02:00
|
|
|
|
2012-05-16 20:29:05 +03:00
|
|
|
void CHeroWindow::commanderWindow()
|
|
|
|
{
|
2012-05-19 21:27:23 +03:00
|
|
|
//TODO: allow equipping commander artifacts by drag / drop
|
2012-05-28 22:29:32 +03:00
|
|
|
//bool artSelected = false;
|
2012-05-20 11:39:19 +03:00
|
|
|
const CArtifactsOfHero::SCommonPart *commonInfo = artSets.front()->commonInfo;
|
|
|
|
|
|
|
|
if (const CArtifactInstance *art = commonInfo->src.art)
|
|
|
|
{
|
|
|
|
const CGHeroInstance *srcHero = commonInfo->src.AOH->getHero();
|
2012-05-28 22:29:32 +03:00
|
|
|
//artSelected = true;
|
2013-02-12 22:49:40 +03:00
|
|
|
ArtifactPosition freeSlot = art->firstAvailableSlot (curHero->commander);
|
2012-05-25 18:10:38 +03:00
|
|
|
if (freeSlot < ArtifactPosition::COMMANDER_AFTER_LAST) //we don't want to put it in commander's backpack!
|
|
|
|
{
|
|
|
|
ArtifactLocation src (srcHero, commonInfo->src.slotID);
|
|
|
|
ArtifactLocation dst (curHero->commander.get(), freeSlot);
|
|
|
|
|
|
|
|
if (art->canBePutAt(dst, true))
|
|
|
|
{ //equip clicked stack
|
|
|
|
if(dst.getArt())
|
|
|
|
{
|
|
|
|
LOCPLINT->cb->swapArtifacts (dst, ArtifactLocation(srcHero, dst.getArt()->firstBackpackSlot(srcHero)));
|
|
|
|
}
|
|
|
|
LOCPLINT->cb->swapArtifacts(src, dst);
|
2012-05-20 11:39:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2012-05-19 21:27:23 +03:00
|
|
|
GH.pushInt(new CCreatureWindow (curHero->commander));
|
|
|
|
|
2012-05-16 20:29:05 +03:00
|
|
|
}
|
|
|
|
|
2010-12-17 00:32:53 +02:00
|
|
|
void CHeroWindow::showAll(SDL_Surface * to)
|
2008-01-15 20:50:52 +02:00
|
|
|
{
|
2010-12-17 00:32:53 +02:00
|
|
|
CIntObject::showAll(to);
|
|
|
|
|
2009-06-17 12:38:03 +03:00
|
|
|
//printing hero's name
|
2012-11-11 15:23:31 +03:00
|
|
|
printAtMiddleLoc(curHero->name, 190, 38, FONT_BIG, Colors::YELLOW, to);
|
2010-12-17 00:32:53 +02:00
|
|
|
|
2009-06-17 12:38:03 +03:00
|
|
|
//printing hero's level
|
2010-08-25 17:57:58 +03:00
|
|
|
std::string secondLine= CGI->generaltexth->allTexts[342];
|
|
|
|
boost::algorithm::replace_first(secondLine,"%d",boost::lexical_cast<std::string>(curHero->level));
|
|
|
|
boost::algorithm::replace_first(secondLine,"%s",curHero->type->heroClass->name);
|
2012-11-11 15:23:31 +03:00
|
|
|
printAtMiddleLoc(secondLine, 190, 65, FONT_MEDIUM, Colors::WHITE, to);
|
2012-12-19 20:24:53 +03:00
|
|
|
|
2008-01-15 20:50:52 +02:00
|
|
|
//printing primary skills' amounts
|
2009-06-17 19:46:16 +03:00
|
|
|
for(int m=0; m<4; ++m)
|
|
|
|
{
|
2010-12-17 00:32:53 +02:00
|
|
|
std::ostringstream primarySkill;
|
2011-02-27 21:58:14 +02:00
|
|
|
primarySkill << primSkillAreas[m]->bonusValue;
|
2012-11-11 15:23:31 +03:00
|
|
|
printAtMiddleLoc(primarySkill.str(), 53 + 70 * m, 166, FONT_SMALL, Colors::WHITE, to);
|
2009-06-17 19:46:16 +03:00
|
|
|
}
|
2010-12-17 00:32:53 +02:00
|
|
|
|
2008-01-15 20:50:52 +02:00
|
|
|
//secondary skills
|
2010-07-31 16:18:40 +03:00
|
|
|
for(size_t v=0; v<std::min(secSkillAreas.size(), curHero->secSkills.size()); ++v)
|
2008-01-15 20:50:52 +02:00
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
printAtLoc(CGI->generaltexth->levels[curHero->secSkills[v].second-1], (v%2) ? 212 : 68, 280 + 48 * (v/2), FONT_SMALL, Colors::WHITE, to);
|
|
|
|
printAtLoc(CGI->generaltexth->skillName[curHero->secSkills[v].first], (v%2) ? 212 : 68, 300 + 48 * (v/2), FONT_SMALL, Colors::WHITE, to);
|
2008-01-15 20:50:52 +02:00
|
|
|
}
|
2010-12-17 00:32:53 +02:00
|
|
|
|
2008-01-15 20:50:52 +02:00
|
|
|
//printing special ability
|
2012-12-16 16:47:53 +03:00
|
|
|
printAtLoc(curHero->type->specName, 69, 205, FONT_SMALL, Colors::WHITE, to);
|
2009-06-17 19:46:16 +03:00
|
|
|
std::ostringstream expstr;
|
2011-02-27 21:58:14 +02:00
|
|
|
expstr << curHero->exp;
|
2012-11-11 15:23:31 +03:00
|
|
|
printAtLoc(expstr.str(), 68, 252, FONT_SMALL, Colors::WHITE, to);
|
2013-06-23 22:35:54 +03:00
|
|
|
|
2009-06-17 19:46:16 +03:00
|
|
|
std::ostringstream manastr;
|
2011-02-27 21:58:14 +02:00
|
|
|
manastr << curHero->mana << '/' << heroWArt.manaLimit();
|
2012-11-11 15:23:31 +03:00
|
|
|
printAtLoc(manastr.str(), 211, 252, FONT_SMALL, Colors::WHITE, to);
|
2013-04-09 17:31:36 +03:00
|
|
|
}
|