2009-05-20 13:08:56 +03:00
|
|
|
#include "../stdafx.h"
|
2008-08-26 00:14:00 +03:00
|
|
|
#include "AdventureMapButton.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-20 09:57:53 +03:00
|
|
|
#include "CCastleInterface.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"
|
2008-08-26 00:14:00 +03:00
|
|
|
#include "SDL.h"
|
|
|
|
#include "SDL_Extensions.h"
|
2009-05-20 13:08:56 +03:00
|
|
|
#include "CBitmapHandler.h"
|
|
|
|
#include "Graphics.h"
|
|
|
|
#include "CSpellWindow.h"
|
|
|
|
#include "CConfigHandler.h"
|
|
|
|
#include "../global.h"
|
|
|
|
#include "../hch/CArtHandler.h"
|
|
|
|
#include "../hch/CDefHandler.h"
|
|
|
|
#include "../hch/CGeneralTextHandler.h"
|
|
|
|
#include "../hch/CHeroHandler.h"
|
|
|
|
#include "../hch/CLodHandler.h"
|
|
|
|
#include "../hch/CObjectHandler.h"
|
2008-08-28 20:36:34 +03:00
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
|
|
|
#include <boost/assign/list_of.hpp>
|
2008-08-26 00:14:00 +03:00
|
|
|
#include <boost/assign/std/vector.hpp>
|
|
|
|
#include <cstdlib>
|
2008-01-13 18:24:24 +02:00
|
|
|
#include <sstream>
|
2009-01-07 21:40:19 +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-01-19 15:19:58 +02:00
|
|
|
extern SDL_Surface * screen;
|
2008-01-15 20:50:52 +02:00
|
|
|
extern TTF_Font * GEOR16;
|
2008-08-26 00:14:00 +03:00
|
|
|
using namespace boost::assign;
|
2008-01-30 12:55:43 +02:00
|
|
|
CHeroWindow::CHeroWindow(int playerColor):
|
2008-01-19 20:58:24 +02:00
|
|
|
backpackPos(0), player(playerColor)
|
2008-01-10 21:01:25 +02:00
|
|
|
{
|
2008-01-30 12:55:43 +02:00
|
|
|
artWorn.resize(19);
|
2008-06-12 09:45:51 +03:00
|
|
|
background = BitmapHandler::loadBitmap("HEROSCR4.bmp");
|
2008-06-30 03:06:41 +03:00
|
|
|
graphics->blueToPlayersAdv(background, playerColor);
|
2008-11-28 03:36:34 +02:00
|
|
|
pos.x = screen->w/2 - background->w/2 - 65;
|
|
|
|
pos.y = screen->h/2 - background->h/2 - 8;
|
2008-01-10 21:01:25 +02:00
|
|
|
pos.h = background->h;
|
|
|
|
pos.w = background->w;
|
2008-01-15 20:50:52 +02:00
|
|
|
curBack = NULL;
|
|
|
|
curHero = NULL;
|
2008-01-30 12:55:43 +02:00
|
|
|
activeArtPlace = NULL;
|
2008-01-11 20:56:39 +02:00
|
|
|
|
2009-04-14 15:47:09 +03:00
|
|
|
garr = NULL;
|
2008-11-28 03:36:34 +02:00
|
|
|
ourBar = new CStatusBar(pos.x+72, pos.y+567, "ADROLLVR.bmp", 660);
|
2008-01-30 15:18:08 +02:00
|
|
|
|
2008-11-28 03:36:34 +02:00
|
|
|
quitButton = new AdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(), boost::function<void()>(), pos.x+674, pos.y+524, "hsbtns.def", SDLK_RETURN);
|
|
|
|
dismissButton = new AdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], boost::bind(&CHeroWindow::dismissCurrent,this), pos.x+519, pos.y+437, "hsbtns2.def", SDLK_d);
|
|
|
|
questlogButton = new AdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), boost::bind(&CHeroWindow::questlog,this), pos.x+379, pos.y+437, "hsbtns4.def", SDLK_q);
|
2008-01-12 14:55:45 +02:00
|
|
|
|
2008-09-24 11:15:49 +03:00
|
|
|
formations = new CHighlightableButtonsGroup(0);
|
2008-11-28 03:36:34 +02:00
|
|
|
formations->addButton(map_list_of(0,CGI->generaltexth->heroscrn[23]),CGI->generaltexth->heroscrn[29], "hsbtns6.def", pos.x+546, pos.y+491, 0, 0, SDLK_t);
|
|
|
|
formations->addButton(map_list_of(0,CGI->generaltexth->heroscrn[24]),CGI->generaltexth->heroscrn[30], "hsbtns7.def", pos.x+546, pos.y+527, 1, 0, SDLK_l);
|
2008-09-24 11:15:49 +03:00
|
|
|
|
2008-09-19 11:16:19 +03:00
|
|
|
|
2008-11-28 03:36:34 +02:00
|
|
|
gar2button = new CHighlightableButton(0, 0, map_list_of(0,CGI->generaltexth->heroscrn[26])(3,CGI->generaltexth->heroscrn[25]), CGI->generaltexth->heroscrn[31], false, "hsbtns8.def", NULL, pos.x+604, pos.y+491, SDLK_b);
|
|
|
|
gar4button = new AdventureMapButton(CGI->generaltexth->allTexts[256], CGI->generaltexth->heroscrn[32], boost::function<void()>(), pos.x+604, pos.y+527, "hsbtns9.def", false, NULL, false);
|
2008-08-28 20:36:34 +03:00
|
|
|
boost::algorithm::replace_first(gar4button->hoverTexts[0],"%s",CGI->generaltexth->allTexts[43]);
|
2009-04-04 01:34:31 +03:00
|
|
|
leftArtRoll = new AdventureMapButton(std::string(), std::string(), boost::bind(&CHeroWindow::scrollBackpack,this,-1), pos.x+379, pos.y+364, "hsbtns3.def", SDLK_LEFT);
|
|
|
|
rightArtRoll = new AdventureMapButton(std::string(), std::string(), boost::bind(&CHeroWindow::scrollBackpack,this,+1), pos.x+632, pos.y+364, "hsbtns5.def", SDLK_RIGHT);
|
2008-11-28 03:36:34 +02:00
|
|
|
|
2008-01-13 21:42:21 +02:00
|
|
|
|
|
|
|
for(int g=0; g<8; ++g)
|
|
|
|
{
|
2008-01-25 21:09:41 +02:00
|
|
|
//heroList.push_back(new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::switchHero, 677, 95+g*54, "hsbtns5.def", this));
|
|
|
|
heroListMi.push_back(new LClickableAreaHero());
|
2008-11-28 03:36:34 +02:00
|
|
|
heroListMi[g]->pos.x = pos.x+677;
|
|
|
|
heroListMi[g]->pos.y = pos.y + 95+g*54;
|
2008-01-25 21:09:41 +02:00
|
|
|
heroListMi[g]->pos.h = 32;
|
|
|
|
heroListMi[g]->pos.w = 48;
|
|
|
|
heroListMi[g]->owner = this;
|
|
|
|
heroListMi[g]->id = g;
|
2008-01-13 21:42:21 +02:00
|
|
|
}
|
|
|
|
|
2008-11-28 03:36:34 +02:00
|
|
|
|
2009-06-17 19:46:16 +03:00
|
|
|
flags = CDefHandler::giveDefEss("CREST58.DEF");
|
2008-01-19 20:58:24 +02:00
|
|
|
//areas
|
2008-01-27 18:07:27 +02:00
|
|
|
portraitArea = new LRClickableAreaWText();
|
2008-11-28 03:36:34 +02:00
|
|
|
portraitArea->pos.x = pos.x+83;
|
|
|
|
portraitArea->pos.y = pos.y + 26;
|
2008-01-19 20:58:24 +02:00
|
|
|
portraitArea->pos.w = 58;
|
|
|
|
portraitArea->pos.h = 64;
|
2008-01-27 18:07:27 +02:00
|
|
|
for(int v=0; v<4; ++v)
|
|
|
|
{
|
|
|
|
primSkillAreas.push_back(new LRClickableAreaWTextComp());
|
2008-11-28 03:36:34 +02:00
|
|
|
primSkillAreas[v]->pos.x = pos.x+95 + 70*v;
|
|
|
|
primSkillAreas[v]->pos.y = pos.y + 111;
|
2008-01-27 18:07:27 +02:00
|
|
|
primSkillAreas[v]->pos.w = 42;
|
|
|
|
primSkillAreas[v]->pos.h = 42;
|
2009-03-27 01:05:40 +02:00
|
|
|
primSkillAreas[v]->text = CGI->generaltexth->arraytxt[2+v];
|
2008-01-27 18:07:27 +02:00
|
|
|
primSkillAreas[v]->type = v;
|
|
|
|
primSkillAreas[v]->bonus = -1; // to be initilized when hero is being set
|
2008-01-28 14:28:18 +02:00
|
|
|
primSkillAreas[v]->baseType = 0;
|
2008-01-27 18:07:27 +02:00
|
|
|
}
|
|
|
|
expArea = new LRClickableAreaWText();
|
2008-11-28 03:36:34 +02:00
|
|
|
expArea->pos.x = pos.x+83;
|
|
|
|
expArea->pos.y = pos.y + 236;
|
2008-01-27 18:07:27 +02:00
|
|
|
expArea->pos.w = 136;
|
|
|
|
expArea->pos.h = 42;
|
2008-01-31 14:10:59 +02:00
|
|
|
expArea->hoverText = CGI->generaltexth->heroscrn[9];
|
2008-01-29 15:55:14 +02:00
|
|
|
|
2009-02-03 07:28:05 +02:00
|
|
|
morale = new LRClickableAreaWTextComp();
|
|
|
|
morale->pos = genRect(45,53,pos.x+240,pos.y+187);
|
|
|
|
|
|
|
|
luck = new LRClickableAreaWTextComp();
|
|
|
|
luck->pos = genRect(45,53,pos.x+298,pos.y+187);
|
|
|
|
|
2008-01-29 15:55:14 +02:00
|
|
|
spellPointsArea = new LRClickableAreaWText();
|
2008-11-28 03:36:34 +02:00
|
|
|
spellPointsArea->pos.x = pos.x+227;
|
|
|
|
spellPointsArea->pos.y = pos.y + 236;
|
2008-01-29 15:55:14 +02:00
|
|
|
spellPointsArea->pos.w = 136;
|
|
|
|
spellPointsArea->pos.h = 42;
|
2008-01-31 14:10:59 +02:00
|
|
|
spellPointsArea->hoverText = CGI->generaltexth->heroscrn[22];
|
2008-01-29 15:55:14 +02:00
|
|
|
|
2008-01-28 14:28:18 +02:00
|
|
|
for(int i=0; i<8; ++i)
|
|
|
|
{
|
|
|
|
secSkillAreas.push_back(new LRClickableAreaWTextComp());
|
2008-11-28 03:36:34 +02:00
|
|
|
secSkillAreas[i]->pos.x = pos.x + ((i%2==0) ? (83) : (227));
|
|
|
|
secSkillAreas[i]->pos.y = pos.y + (284 + 48 * (i/2));
|
2008-01-28 14:28:18 +02:00
|
|
|
secSkillAreas[i]->pos.w = 136;
|
|
|
|
secSkillAreas[i]->pos.h = 42;
|
|
|
|
secSkillAreas[i]->baseType = 1;
|
|
|
|
}
|
2008-11-28 03:36:34 +02:00
|
|
|
pos.x += 65;
|
|
|
|
pos.y += 8;
|
2008-01-10 21:01:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CHeroWindow::~CHeroWindow()
|
|
|
|
{
|
|
|
|
SDL_FreeSurface(background);
|
2008-01-11 20:56:39 +02:00
|
|
|
delete quitButton;
|
2008-01-12 14:55:45 +02:00
|
|
|
delete dismissButton;
|
|
|
|
delete questlogButton;
|
2008-09-24 11:15:49 +03:00
|
|
|
delete formations;
|
2008-01-13 18:24:24 +02:00
|
|
|
delete gar2button;
|
|
|
|
delete gar4button;
|
2008-01-13 21:42:21 +02:00
|
|
|
delete leftArtRoll;
|
|
|
|
delete rightArtRoll;
|
|
|
|
|
2008-12-23 15:59:03 +02:00
|
|
|
for(size_t g=0; g<heroListMi.size(); ++g)
|
|
|
|
{
|
2008-01-25 21:09:41 +02:00
|
|
|
delete heroListMi[g];
|
2008-12-23 15:59:03 +02:00
|
|
|
}
|
2008-01-12 14:55:45 +02:00
|
|
|
|
2008-12-23 15:59:03 +02:00
|
|
|
if(curBack)
|
|
|
|
{
|
2008-01-12 14:55:45 +02:00
|
|
|
SDL_FreeSurface(curBack);
|
2008-12-23 15:59:03 +02:00
|
|
|
}
|
2008-01-12 14:55:45 +02:00
|
|
|
|
2008-01-13 18:24:24 +02:00
|
|
|
delete flags;
|
2008-01-19 15:19:58 +02:00
|
|
|
|
2009-04-14 15:47:09 +03:00
|
|
|
delete garr;
|
2008-01-31 14:10:59 +02:00
|
|
|
delete ourBar;
|
2008-01-30 15:18:08 +02:00
|
|
|
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t g=0; g<artWorn.size(); ++g)
|
2008-01-30 12:55:43 +02:00
|
|
|
{
|
|
|
|
delete artWorn[g];
|
|
|
|
}
|
|
|
|
artWorn.clear();
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t g=0; g<backpack.size(); ++g)
|
2008-01-19 20:58:24 +02:00
|
|
|
{
|
|
|
|
delete backpack[g];
|
|
|
|
}
|
|
|
|
backpack.clear();
|
|
|
|
|
|
|
|
delete portraitArea;
|
2008-01-27 18:07:27 +02:00
|
|
|
delete expArea;
|
2009-02-03 07:28:05 +02:00
|
|
|
delete luck;
|
|
|
|
delete morale;
|
2008-01-29 15:55:14 +02:00
|
|
|
delete spellPointsArea;
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t v=0; v<primSkillAreas.size(); ++v)
|
2008-01-27 18:07:27 +02:00
|
|
|
{
|
|
|
|
delete primSkillAreas[v];
|
|
|
|
}
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t v=0; v<secSkillAreas.size(); ++v)
|
2008-01-28 14:28:18 +02:00
|
|
|
{
|
|
|
|
delete secSkillAreas[v];
|
|
|
|
}
|
2008-01-10 21:01:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CHeroWindow::show(SDL_Surface *to)
|
|
|
|
{
|
2008-01-26 21:36:31 +02:00
|
|
|
if(curBack)
|
|
|
|
blitAt(curBack,pos.x,pos.y,to);
|
2009-04-14 15:47:09 +03:00
|
|
|
quitButton->show(to);
|
|
|
|
dismissButton->show(to);
|
|
|
|
questlogButton->show(to);
|
|
|
|
formations->show(to);
|
|
|
|
gar2button->show(to);
|
|
|
|
gar4button->show(to);
|
|
|
|
leftArtRoll->show(to);
|
|
|
|
rightArtRoll->show(to);
|
|
|
|
|
|
|
|
garr->show(to);
|
|
|
|
ourBar->show(to);
|
2008-01-30 15:18:08 +02:00
|
|
|
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t d=0; d<artWorn.size(); ++d)
|
2008-01-30 12:55:43 +02:00
|
|
|
{
|
|
|
|
artWorn[d]->show(to);
|
|
|
|
}
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t d=0; d<backpack.size(); ++d)
|
2008-01-19 20:58:24 +02:00
|
|
|
{
|
|
|
|
backpack[d]->show(to);
|
|
|
|
}
|
2008-01-10 21:01:25 +02:00
|
|
|
}
|
|
|
|
|
2008-06-08 03:58:29 +03:00
|
|
|
void CHeroWindow::setHero(const CGHeroInstance *Hero)
|
2008-01-10 21:01:25 +02:00
|
|
|
{
|
2008-09-29 00:01:49 +03:00
|
|
|
char bufor[400];
|
2008-06-08 03:58:29 +03:00
|
|
|
CGHeroInstance *hero = const_cast<CGHeroInstance*>(Hero); //but don't modify hero! - it's only for easy map reading
|
2008-01-28 14:28:18 +02:00
|
|
|
if(!hero) //something strange... no hero? it shouldn't happen
|
2008-01-25 21:09:41 +02:00
|
|
|
{
|
2008-08-02 18:08:03 +03:00
|
|
|
return;
|
2008-01-25 21:09:41 +02:00
|
|
|
}
|
2008-01-10 21:01:25 +02:00
|
|
|
curHero = hero;
|
2008-01-31 14:10:59 +02:00
|
|
|
|
2009-06-17 12:38:03 +03:00
|
|
|
//pos temporarily switched, restored later
|
2008-11-28 03:36:34 +02:00
|
|
|
pos.x -= 65;
|
|
|
|
pos.y -= 8;
|
|
|
|
|
2008-08-28 20:36:34 +03:00
|
|
|
gar2button->callback.clear();
|
|
|
|
gar2button->callback2.clear();
|
|
|
|
|
2008-09-29 00:01:49 +03:00
|
|
|
sprintf(bufor, CGI->generaltexth->heroscrn[16].c_str(), curHero->name.c_str(), curHero->type->heroClass->name.c_str());
|
|
|
|
dismissButton->hoverTexts[0] = std::string(bufor);
|
2008-01-31 14:10:59 +02:00
|
|
|
|
2008-09-29 00:01:49 +03:00
|
|
|
sprintf(bufor, CGI->generaltexth->allTexts[15].c_str(), curHero->name.c_str(), curHero->type->heroClass->name.c_str());
|
|
|
|
portraitArea->hoverText = std::string(bufor);
|
2008-01-31 14:10:59 +02:00
|
|
|
|
2008-11-28 03:36:34 +02:00
|
|
|
portraitArea->text = hero->getBiography();
|
2008-01-19 15:19:58 +02:00
|
|
|
|
2009-04-14 15:47:09 +03:00
|
|
|
delete garr;
|
|
|
|
/*gar4button->owner = */garr = new CGarrisonInt(pos.x+80, pos.y+493, 8, 0, curBack, 15, 485, curHero);
|
|
|
|
garr->update = false;
|
|
|
|
gar4button->callback = boost::bind(&CGarrisonInt::splitClick,garr);//actualization of callback function
|
2008-06-21 16:27:52 +03:00
|
|
|
|
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
|
|
|
{
|
2008-09-29 14:03:30 +03:00
|
|
|
primSkillAreas[g]->bonus = hero->getPrimSkillLevel(g);
|
2008-01-27 18:07:27 +02:00
|
|
|
}
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t g=0; g<hero->secSkills.size(); ++g)
|
2008-01-28 14:28:18 +02:00
|
|
|
{
|
|
|
|
secSkillAreas[g]->type = hero->secSkills[g].first;
|
2008-09-28 16:29:37 +03:00
|
|
|
secSkillAreas[g]->bonus = hero->secSkills[g].second;
|
2009-01-11 00:08:18 +02:00
|
|
|
std::string hlp = CGI->generaltexth->skillInfoTexts[ hero->secSkills[g].first ][hero->secSkills[g].second-1];
|
2008-08-13 03:44:31 +03:00
|
|
|
secSkillAreas[g]->text = hlp.substr(1, hlp.size()-2);
|
2008-08-02 18:08:03 +03:00
|
|
|
|
2009-01-11 00:08:18 +02:00
|
|
|
sprintf(bufor, CGI->generaltexth->heroscrn[21].c_str(), CGI->generaltexth->levels[hero->secSkills[g].second-1].c_str(), CGI->generaltexth->skillName[hero->secSkills[g].first].c_str());
|
2008-09-29 00:01:49 +03:00
|
|
|
secSkillAreas[g]->hoverText = std::string(bufor);
|
2008-01-28 14:28:18 +02:00
|
|
|
}
|
2008-01-27 18:07:27 +02:00
|
|
|
|
2008-11-01 00:41:22 +02:00
|
|
|
sprintf(bufor, CGI->generaltexth->allTexts[2].c_str(), hero->level, CGI->heroh->reqExp(hero->level+1), hero->exp);
|
2008-09-29 00:01:49 +03:00
|
|
|
expArea->text = std::string(bufor);
|
|
|
|
|
2009-04-14 15:47:09 +03:00
|
|
|
sprintf(bufor, CGI->generaltexth->allTexts[205].c_str(), hero->name.c_str(), hero->mana, hero->manaLimit());
|
2008-09-29 00:01:49 +03:00
|
|
|
spellPointsArea->text = std::string(bufor);
|
2008-01-27 18:07:27 +02:00
|
|
|
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t g=0; g<artWorn.size(); ++g)
|
2008-01-30 12:55:43 +02:00
|
|
|
{
|
|
|
|
delete artWorn[g];
|
|
|
|
}
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t g=0; g<backpack.size(); ++g)
|
2008-01-19 20:58:24 +02:00
|
|
|
{
|
|
|
|
delete backpack[g];
|
|
|
|
}
|
|
|
|
backpack.clear();
|
2008-01-19 15:19:58 +02:00
|
|
|
|
2008-08-26 00:14:00 +03:00
|
|
|
std::vector<SDL_Rect> slotPos;
|
2009-04-04 01:34:31 +03:00
|
|
|
backpackPos = 0;
|
2008-08-26 00:14:00 +03:00
|
|
|
|
2008-11-28 03:36:34 +02:00
|
|
|
slotPos += genRect(44,44,pos.x+509,pos.y+30), genRect(44,44,pos.x+567,pos.y+240), genRect(44,44,pos.x+509,pos.y+80),
|
|
|
|
genRect(44,44,pos.x+383,pos.y+68), genRect(44,44,pos.x+564,pos.y+183), genRect(44,44,pos.x+509,pos.y+130),
|
|
|
|
genRect(44,44,pos.x+431,pos.y+68), genRect(44,44,pos.x+610,pos.y+183), genRect(44,44,pos.x+515,pos.y+295),
|
|
|
|
genRect(44,44,pos.x+383,pos.y+143), genRect(44,44,pos.x+399,pos.y+194), genRect(44,44,pos.x+415,pos.y+245),
|
|
|
|
genRect(44,44,pos.x+431,pos.y+296), genRect(44,44,pos.x+564,pos.y+30), genRect(44,44,pos.x+610,pos.y+30),
|
|
|
|
genRect(44,44,pos.x+610,pos.y+76), genRect(44,44,pos.x+610,pos.y+122), genRect(44,44,pos.x+610,pos.y+310),
|
|
|
|
genRect(44,44,pos.x+381,pos.y+296);
|
2008-08-26 00:14:00 +03:00
|
|
|
|
|
|
|
for (int g = 0; g < 19 ; g++)
|
|
|
|
{
|
|
|
|
artWorn[g] = new CArtPlace(hero->getArt(g));
|
|
|
|
artWorn[g]->pos = slotPos[g];
|
|
|
|
if(hero->getArt(g))
|
2008-11-30 02:15:38 +02:00
|
|
|
artWorn[g]->text = hero->getArt(g)->Description();
|
2008-08-26 00:14:00 +03:00
|
|
|
artWorn[g]->ourWindow = this;
|
|
|
|
}
|
2008-01-30 12:55:43 +02:00
|
|
|
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t g=0; g<artWorn.size(); ++g)
|
2008-01-30 12:55:43 +02:00
|
|
|
{
|
2008-08-20 22:02:48 +03:00
|
|
|
artWorn[g]->slotID = g;
|
2008-09-29 00:01:49 +03:00
|
|
|
if(artWorn[g]->ourArt)
|
|
|
|
{
|
2008-11-30 02:15:38 +02:00
|
|
|
sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), artWorn[g]->ourArt->Name().c_str());
|
2008-09-29 00:01:49 +03:00
|
|
|
artWorn[g]->hoverText = std::string(bufor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
artWorn[g]->hoverText = CGI->generaltexth->allTexts[507];
|
|
|
|
}
|
2008-01-30 12:55:43 +02:00
|
|
|
}
|
|
|
|
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t s=0; s<5; ++s)
|
2008-01-19 20:58:24 +02:00
|
|
|
{
|
2008-01-30 12:55:43 +02:00
|
|
|
CArtPlace * add;
|
|
|
|
if( s < curHero->artifacts.size() )
|
2008-09-29 00:01:49 +03:00
|
|
|
{
|
2008-06-11 04:53:57 +03:00
|
|
|
add = new CArtPlace(&CGI->arth->artifacts[curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ]]);
|
2008-11-30 02:15:38 +02:00
|
|
|
sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), add->ourArt->Name().c_str());
|
2008-09-29 00:01:49 +03:00
|
|
|
add->hoverText = bufor;
|
|
|
|
}
|
2008-01-30 12:55:43 +02:00
|
|
|
else
|
2008-09-29 00:01:49 +03:00
|
|
|
{
|
2008-01-30 12:55:43 +02:00
|
|
|
add = new CArtPlace(NULL);
|
2008-09-29 00:01:49 +03:00
|
|
|
add->hoverText = CGI->generaltexth->allTexts[507];
|
|
|
|
}
|
2008-11-28 03:36:34 +02:00
|
|
|
add->pos.x = pos.x + 403 + 46*s;
|
|
|
|
add->pos.y = pos.y + 365;
|
2008-01-29 15:55:14 +02:00
|
|
|
add->pos.h = add->pos.w = 44;
|
2008-12-23 15:59:03 +02:00
|
|
|
if(s<hero->artifacts.size() && hero->artifacts[s])
|
|
|
|
{
|
2008-11-30 02:15:38 +02:00
|
|
|
add->text = hero->getArt(19+s)->Description();
|
2008-12-23 15:59:03 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-01-29 15:55:14 +02:00
|
|
|
add->text = std::string();
|
2008-12-23 15:59:03 +02:00
|
|
|
}
|
2008-01-30 12:55:43 +02:00
|
|
|
add->ourWindow = this;
|
2008-08-20 22:02:48 +03:00
|
|
|
add->slotID = 19+s;
|
2008-01-19 20:58:24 +02:00
|
|
|
backpack.push_back(add);
|
|
|
|
}
|
2008-02-10 15:09:56 +02:00
|
|
|
activeArtPlace = NULL;
|
2009-02-09 18:18:48 +02:00
|
|
|
dismissButton->block(!!hero->visitedTown);
|
2008-08-28 20:36:34 +03:00
|
|
|
leftArtRoll->block(hero->artifacts.size()<6);
|
|
|
|
rightArtRoll->block(hero->artifacts.size()<6);
|
2008-09-28 16:29:37 +03:00
|
|
|
if(hero->getSecSkillLevel(19)==0)
|
2008-08-28 20:36:34 +03:00
|
|
|
gar2button->block(true);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gar2button->block(false);
|
2008-09-18 16:54:54 +03:00
|
|
|
gar2button->callback = vstd::assigno(hero->tacticFormationEnabled,true);
|
|
|
|
gar2button->callback2 = vstd::assigno(hero->tacticFormationEnabled,false);
|
2008-08-28 20:36:34 +03:00
|
|
|
}
|
2008-09-24 11:15:49 +03:00
|
|
|
|
2008-10-26 22:58:34 +02:00
|
|
|
formations->onChange = 0;
|
2008-09-24 11:15:49 +03:00
|
|
|
formations->select(hero->army.formation,true);
|
2008-10-26 22:58:34 +02:00
|
|
|
formations->onChange = boost::bind(&CCallback::setFormation, LOCPLINT->cb, Hero, _1);
|
2008-09-24 11:15:49 +03:00
|
|
|
|
2009-02-03 07:28:05 +02:00
|
|
|
std::vector<std::pair<int,std::string> > mrl = hero->getCurrentMoraleModifiers();
|
|
|
|
int mrlv = hero->getCurrentMorale();
|
|
|
|
int mrlt = (mrlv>0)-(mrlv<0); //signum: -1 - bad morale, 0 - neutral, 1 - good
|
|
|
|
morale->hoverText = CGI->generaltexth->heroscrn[4 - mrlt];
|
|
|
|
morale->baseType = SComponent::morale;
|
|
|
|
morale->bonus = mrlv;
|
|
|
|
morale->text = CGI->generaltexth->arraytxt[88];
|
|
|
|
boost::algorithm::replace_first(morale->text,"%s",CGI->generaltexth->arraytxt[86-mrlt]);
|
|
|
|
for(int it=0; it < mrl.size(); it++)
|
|
|
|
morale->text += mrl[it].second;
|
|
|
|
|
2009-02-04 15:40:54 +02:00
|
|
|
mrl = hero->getCurrentLuckModifiers();
|
|
|
|
mrlv = hero->getCurrentLuck();
|
|
|
|
mrlt = (mrlv>0)-(mrlv<0); //signum: -1 - bad luck, 0 - neutral, 1 - good
|
|
|
|
luck->hoverText = CGI->generaltexth->heroscrn[7 - mrlt];
|
|
|
|
luck->baseType = SComponent::luck;
|
|
|
|
luck->bonus = mrlv;
|
|
|
|
luck->text = CGI->generaltexth->arraytxt[62];
|
|
|
|
boost::algorithm::replace_first(luck->text,"%s",CGI->generaltexth->arraytxt[60-mrlt]);
|
|
|
|
for(int it=0; it < mrl.size(); it++)
|
|
|
|
luck->text += mrl[it].second;
|
2009-02-03 07:28:05 +02:00
|
|
|
|
2008-11-28 03:36:34 +02:00
|
|
|
pos.x += 65;
|
|
|
|
pos.y += 8;
|
|
|
|
|
2008-01-26 21:36:31 +02:00
|
|
|
redrawCurBack();
|
2008-01-11 20:56:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CHeroWindow::quit()
|
|
|
|
{
|
2009-04-14 15:47:09 +03:00
|
|
|
LOCPLINT->popInt(this);
|
2009-06-10 23:48:55 +03:00
|
|
|
dispose();
|
2008-01-11 20:56:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CHeroWindow::activate()
|
|
|
|
{
|
|
|
|
quitButton->activate();
|
2008-01-12 14:55:45 +02:00
|
|
|
dismissButton->activate();
|
|
|
|
questlogButton->activate();
|
2008-01-13 18:24:24 +02:00
|
|
|
gar2button->activate();
|
2008-09-24 11:15:49 +03:00
|
|
|
formations->activate();
|
2008-01-13 18:24:24 +02:00
|
|
|
gar4button->activate();
|
2008-01-13 21:42:21 +02:00
|
|
|
leftArtRoll->activate();
|
|
|
|
rightArtRoll->activate();
|
2008-01-19 20:58:24 +02:00
|
|
|
portraitArea->activate();
|
2008-01-27 18:07:27 +02:00
|
|
|
expArea->activate();
|
2008-01-29 15:55:14 +02:00
|
|
|
spellPointsArea->activate();
|
2009-02-03 07:28:05 +02:00
|
|
|
morale->activate();
|
|
|
|
luck->activate();
|
2008-01-30 15:18:08 +02:00
|
|
|
|
2009-04-14 15:47:09 +03:00
|
|
|
garr->activate();
|
2008-01-31 14:10:59 +02:00
|
|
|
LOCPLINT->statusbar = ourBar;
|
2008-01-30 15:18:08 +02:00
|
|
|
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t v=0; v<primSkillAreas.size(); ++v)
|
2008-01-27 18:07:27 +02:00
|
|
|
{
|
|
|
|
primSkillAreas[v]->activate();
|
|
|
|
}
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t v=0; v<curHero->secSkills.size(); ++v)
|
2008-01-13 21:42:21 +02:00
|
|
|
{
|
2008-01-28 14:28:18 +02:00
|
|
|
secSkillAreas[v]->activate();
|
2008-01-13 21:42:21 +02:00
|
|
|
}
|
2008-01-15 20:50:52 +02:00
|
|
|
redrawCurBack();
|
2008-01-20 15:53:11 +02:00
|
|
|
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t f=0; f<artWorn.size(); ++f)
|
2008-01-30 12:55:43 +02:00
|
|
|
{
|
|
|
|
if(artWorn[f])
|
|
|
|
artWorn[f]->activate();
|
|
|
|
}
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t f=0; f<backpack.size(); ++f)
|
2008-01-20 15:53:11 +02:00
|
|
|
{
|
2008-01-25 21:09:41 +02:00
|
|
|
if(backpack[f])
|
|
|
|
backpack[f]->activate();
|
2008-01-20 15:53:11 +02:00
|
|
|
}
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t e=0; e<heroListMi.size(); ++e)
|
2008-01-26 21:36:31 +02:00
|
|
|
{
|
|
|
|
heroListMi[e]->activate();
|
|
|
|
}
|
2008-01-15 20:50:52 +02:00
|
|
|
}
|
|
|
|
|
2008-01-20 14:34:39 +02:00
|
|
|
void CHeroWindow::deactivate()
|
|
|
|
{
|
|
|
|
quitButton->deactivate();
|
|
|
|
dismissButton->deactivate();
|
|
|
|
questlogButton->deactivate();
|
|
|
|
gar2button->deactivate();
|
2008-09-24 11:15:49 +03:00
|
|
|
formations->deactivate();
|
2008-01-20 14:34:39 +02:00
|
|
|
gar4button->deactivate();
|
|
|
|
leftArtRoll->deactivate();
|
|
|
|
rightArtRoll->deactivate();
|
|
|
|
portraitArea->deactivate();
|
2008-01-27 18:07:27 +02:00
|
|
|
expArea->deactivate();
|
2008-01-29 15:55:14 +02:00
|
|
|
spellPointsArea->deactivate();
|
2009-02-05 11:49:45 +02:00
|
|
|
morale->deactivate();
|
|
|
|
luck->deactivate();
|
2008-01-30 15:18:08 +02:00
|
|
|
|
2009-04-14 15:47:09 +03:00
|
|
|
garr->deactivate();
|
2008-01-30 15:18:08 +02:00
|
|
|
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t v=0; v<primSkillAreas.size(); ++v)
|
2008-01-27 18:07:27 +02:00
|
|
|
{
|
|
|
|
primSkillAreas[v]->deactivate();
|
|
|
|
}
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t v=0; v<curHero->secSkills.size(); ++v)
|
2008-01-25 21:09:41 +02:00
|
|
|
{
|
2008-01-28 14:28:18 +02:00
|
|
|
secSkillAreas[v]->deactivate();
|
2008-01-25 21:09:41 +02:00
|
|
|
}
|
|
|
|
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t f=0; f<artWorn.size(); ++f)
|
2008-08-02 18:08:03 +03:00
|
|
|
{
|
2008-01-30 12:55:43 +02:00
|
|
|
if(artWorn[f])
|
|
|
|
artWorn[f]->deactivate();
|
|
|
|
}
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t f=0; f<backpack.size(); ++f)
|
2008-08-02 18:08:03 +03:00
|
|
|
{
|
2008-01-25 21:09:41 +02:00
|
|
|
if(backpack[f])
|
|
|
|
backpack[f]->deactivate();
|
2008-01-20 15:53:11 +02:00
|
|
|
}
|
2008-12-21 21:17:35 +02:00
|
|
|
for(size_t e=0; e<heroListMi.size(); ++e)
|
2008-01-26 21:36:31 +02:00
|
|
|
{
|
|
|
|
heroListMi[e]->deactivate();
|
|
|
|
}
|
2008-01-20 14:34:39 +02:00
|
|
|
}
|
|
|
|
|
2008-01-15 20:50:52 +02:00
|
|
|
void CHeroWindow::dismissCurrent()
|
|
|
|
{
|
2008-08-27 13:19:18 +03:00
|
|
|
CFunctionList<void()> ony = boost::bind(&CHeroWindow::quit,this);
|
|
|
|
ony += boost::bind(&CCallback::dismissHero,LOCPLINT->cb,curHero);
|
2009-04-14 15:47:09 +03:00
|
|
|
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[22],std::vector<SComponent*>(), ony, 0, false);
|
2008-01-15 20:50:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CHeroWindow::questlog()
|
|
|
|
{
|
|
|
|
}
|
2009-04-04 01:34:31 +03:00
|
|
|
|
|
|
|
void CHeroWindow::scrollBackpack(int dir)
|
2008-01-15 20:50:52 +02:00
|
|
|
{
|
2009-04-04 01:34:31 +03:00
|
|
|
backpackPos += dir + curHero->artifacts.size();
|
|
|
|
backpackPos %= curHero->artifacts.size();
|
2008-01-19 20:58:24 +02:00
|
|
|
|
2008-01-15 20:50:52 +02:00
|
|
|
|
2009-04-04 01:34:31 +03:00
|
|
|
for(size_t s=0; s<5 && s<curHero->artifacts.size(); ++s) //set new data
|
2008-01-19 20:58:24 +02:00
|
|
|
{
|
2009-04-04 01:34:31 +03:00
|
|
|
CArtPlace *cur = backpack[s];
|
|
|
|
cur->slotID = 19+((s+backpackPos)%curHero->artifacts.size());
|
|
|
|
cur->ourArt = curHero->getArt(cur->slotID);
|
2008-01-19 20:58:24 +02:00
|
|
|
|
2009-04-04 01:34:31 +03:00
|
|
|
if(cur->ourArt)
|
|
|
|
cur->text = cur->ourArt->Description();
|
|
|
|
else
|
|
|
|
cur->text = std::string();
|
2008-01-19 20:58:24 +02:00
|
|
|
}
|
2008-01-15 20:50:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CHeroWindow::redrawCurBack()
|
|
|
|
{
|
|
|
|
if(curBack)
|
|
|
|
SDL_FreeSurface(curBack);
|
2008-02-10 15:09:56 +02:00
|
|
|
curBack = SDL_DisplayFormat(background);
|
2008-01-15 20:50:52 +02:00
|
|
|
|
2009-06-17 12:38:03 +03:00
|
|
|
//primary skills & morale and luck graphics
|
2008-08-13 03:44:31 +03:00
|
|
|
blitAt(graphics->pskillsm->ourImages[0].bitmap, 32, 111, curBack);
|
|
|
|
blitAt(graphics->pskillsm->ourImages[1].bitmap, 102, 111, curBack);
|
|
|
|
blitAt(graphics->pskillsm->ourImages[2].bitmap, 172, 111, curBack);
|
|
|
|
blitAt(graphics->pskillsm->ourImages[5].bitmap, 242, 111, curBack);
|
|
|
|
blitAt(graphics->pskillsm->ourImages[4].bitmap, 20, 230, curBack);
|
|
|
|
blitAt(graphics->pskillsm->ourImages[3].bitmap, 162, 230, curBack);
|
2008-01-13 18:24:24 +02:00
|
|
|
|
2009-06-17 12:38:03 +03:00
|
|
|
//blitting portrait
|
2008-08-02 18:08:03 +03:00
|
|
|
blitAt(graphics->portraitLarge[curHero->portrait], 19, 19, curBack);
|
2008-01-13 18:24:24 +02:00
|
|
|
|
2009-06-17 12:38:03 +03:00
|
|
|
//printing hero's name
|
2008-01-13 18:24:24 +02:00
|
|
|
CSDL_Ext::printAtMiddle(curHero->name, 190, 40, GEORXX, tytulowy, curBack);
|
|
|
|
|
2009-06-17 12:38:03 +03:00
|
|
|
//printing hero's level
|
2009-06-17 19:46:16 +03:00
|
|
|
std::ostringstream secondLine;
|
2008-01-13 18:24:24 +02:00
|
|
|
secondLine<<"Level "<<curHero->level<<" "<<curHero->type->heroClass->name;
|
|
|
|
CSDL_Ext::printAtMiddle(secondLine.str(), 190, 66, TNRB16, zwykly, curBack);
|
|
|
|
|
2009-06-01 06:04:50 +03:00
|
|
|
//primary skills names
|
2008-01-15 20:50:52 +02:00
|
|
|
CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[1], 53, 98, GEOR13, tytulowy, curBack);
|
|
|
|
CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[2], 123, 98, GEOR13, tytulowy, curBack);
|
|
|
|
CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[3], 193, 98, GEOR13, tytulowy, curBack);
|
|
|
|
CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[4], 263, 98, GEOR13, tytulowy, curBack);
|
2008-01-13 18:24:24 +02:00
|
|
|
|
2008-01-15 20:50:52 +02:00
|
|
|
//dismiss / quest log
|
|
|
|
std::vector<std::string> * toPrin = CMessage::breakText(CGI->generaltexth->jktexts[8].substr(1, CGI->generaltexth->jktexts[8].size()-2));
|
|
|
|
if(toPrin->size()==1)
|
|
|
|
{
|
|
|
|
CSDL_Ext::printAt((*toPrin)[0], 372, 440, GEOR13, zwykly, curBack);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CSDL_Ext::printAt((*toPrin)[0], 372, 431, GEOR13, zwykly, curBack);
|
|
|
|
CSDL_Ext::printAt((*toPrin)[1], 372, 447, GEOR13, zwykly, curBack);
|
|
|
|
}
|
|
|
|
delete toPrin;
|
|
|
|
|
|
|
|
toPrin = CMessage::breakText(CGI->generaltexth->jktexts[9].substr(1, CGI->generaltexth->jktexts[9].size()-2));
|
|
|
|
if(toPrin->size()==1)
|
|
|
|
{
|
|
|
|
CSDL_Ext::printAt((*toPrin)[0], 512, 440, GEOR13, zwykly, curBack);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CSDL_Ext::printAt((*toPrin)[0], 512, 431, GEOR13, zwykly, curBack);
|
|
|
|
CSDL_Ext::printAt((*toPrin)[1], 512, 447, GEOR13, zwykly, curBack);
|
|
|
|
}
|
|
|
|
delete toPrin;
|
|
|
|
|
|
|
|
//printing primary skills' amounts
|
2009-06-17 19:46:16 +03:00
|
|
|
for(int m=0; m<4; ++m)
|
|
|
|
{
|
|
|
|
std::ostringstream primarySkill;
|
|
|
|
primarySkill<<curHero->getPrimSkillLevel(m);
|
|
|
|
CSDL_Ext::printAtMiddle(primarySkill.str(), 53 + 70 * m, 165, TNRB16, zwykly, curBack);
|
|
|
|
}
|
2008-01-13 18:24:24 +02:00
|
|
|
|
2008-06-13 11:16:51 +03:00
|
|
|
blitAt(graphics->luck42->ourImages[curHero->getCurrentLuck()+3].bitmap, 239, 182, curBack);
|
|
|
|
blitAt(graphics->morale42->ourImages[curHero->getCurrentMorale()+3].bitmap, 181, 182, curBack);
|
2008-01-13 18:24:24 +02:00
|
|
|
|
|
|
|
blitAt(flags->ourImages[player].bitmap, 606, 8, curBack);
|
2008-01-13 21:42:21 +02:00
|
|
|
|
|
|
|
//hero list blitting
|
2009-06-10 04:23:17 +03:00
|
|
|
|
2009-06-11 20:21:06 +03:00
|
|
|
for(int pos=0, g=0; g<LOCPLINT->wanderingHeroes.size(); ++g)
|
2008-01-13 21:42:21 +02:00
|
|
|
{
|
2009-06-11 20:21:06 +03:00
|
|
|
const CGHeroInstance * cur = LOCPLINT->wanderingHeroes[g];
|
2009-06-10 04:23:17 +03:00
|
|
|
if (cur->inTownGarrison)
|
|
|
|
// Only display heroes that are not in garrison
|
|
|
|
continue;
|
|
|
|
|
|
|
|
blitAt(graphics->portraitSmall[cur->portrait], 611, 87+pos*54, curBack);
|
2008-01-13 21:42:21 +02:00
|
|
|
//printing yellow border
|
|
|
|
if(cur->name == curHero->name)
|
|
|
|
{
|
2008-08-02 18:08:03 +03:00
|
|
|
for(int f=0; f<graphics->portraitSmall[cur->portrait]->w; ++f)
|
2008-01-13 21:42:21 +02:00
|
|
|
{
|
2008-08-02 18:08:03 +03:00
|
|
|
for(int h=0; h<graphics->portraitSmall[cur->portrait]->h; ++h)
|
|
|
|
if(f==0 || h==0 || f==graphics->portraitSmall[cur->portrait]->w-1 || h==graphics->portraitSmall[cur->portrait]->h-1)
|
2008-01-13 21:42:21 +02:00
|
|
|
{
|
2009-06-10 04:23:17 +03:00
|
|
|
CSDL_Ext::SDL_PutPixelWithoutRefresh(curBack, 611+f, 87+pos*54+h, 240, 220, 120);
|
2008-01-13 21:42:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-06-10 04:23:17 +03:00
|
|
|
|
|
|
|
pos ++;
|
2008-01-13 21:42:21 +02:00
|
|
|
}
|
|
|
|
|
2008-01-15 20:50:52 +02:00
|
|
|
//secondary skills
|
2009-06-17 19:46:16 +03:00
|
|
|
for(int g=1; g<=8; ++g)
|
2008-01-15 20:50:52 +02:00
|
|
|
{
|
2009-06-17 19:46:16 +03:00
|
|
|
|
|
|
|
if(curHero->secSkills.size()>=g)
|
|
|
|
{
|
|
|
|
blitAt(graphics->abils44->ourImages[curHero->secSkills[g-1].first*3+3+curHero->secSkills[g-1].second-1].bitmap, g%2 ? 18 : 161, 276 + 48 * ((g-1)/2), curBack);
|
|
|
|
CSDL_Ext::printAt(CGI->generaltexth->levels[curHero->secSkills[g-1].second-1], g%2 ? 69 : 213, 279 + 48 * ((g-1)/2), GEOR13, zwykly, curBack);
|
|
|
|
CSDL_Ext::printAt(CGI->generaltexth->skillName[curHero->secSkills[g-1].first], g%2 ? 69 : 213, 299 + 48 * ((g-1)/2), GEOR13, zwykly, curBack);
|
|
|
|
}
|
2008-01-15 20:50:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//printing special ability
|
2008-06-13 11:16:51 +03:00
|
|
|
blitAt(graphics->un44->ourImages[curHero->subID].bitmap, 18, 180, curBack);
|
2008-01-15 20:50:52 +02:00
|
|
|
|
|
|
|
//printing necessery texts
|
|
|
|
CSDL_Ext::printAt(CGI->generaltexth->jktexts[6].substr(1, CGI->generaltexth->jktexts[6].size()-2), 69, 231, GEOR13, tytulowy, curBack);
|
2009-06-17 19:46:16 +03:00
|
|
|
std::ostringstream expstr;
|
2008-01-15 20:50:52 +02:00
|
|
|
expstr<<curHero->exp;
|
|
|
|
CSDL_Ext::printAt(expstr.str(), 69, 247, GEOR16, zwykly, curBack);
|
|
|
|
CSDL_Ext::printAt(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 212, 231, GEOR13, tytulowy, curBack);
|
2009-06-17 19:46:16 +03:00
|
|
|
std::ostringstream manastr;
|
2009-05-22 22:20:30 +03:00
|
|
|
manastr << curHero->mana << '/' << curHero->manaLimit();
|
2008-01-15 20:50:52 +02:00
|
|
|
CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack);
|
2008-01-19 15:19:58 +02:00
|
|
|
}
|
|
|
|
|
2009-06-10 23:48:55 +03:00
|
|
|
void CHeroWindow::dispose()
|
|
|
|
{
|
|
|
|
SDL_FreeSurface(curBack);
|
|
|
|
curBack = NULL;
|
|
|
|
curHero = NULL;
|
|
|
|
|
|
|
|
for(size_t g=0; g<artWorn.size(); ++g)
|
|
|
|
{
|
|
|
|
delete artWorn[g];
|
|
|
|
artWorn[g] = NULL;
|
|
|
|
}
|
|
|
|
for(size_t g=0; g<backpack.size(); ++g)
|
|
|
|
{
|
|
|
|
delete backpack[g];
|
|
|
|
backpack[g] = NULL;
|
|
|
|
}
|
|
|
|
backpack.clear();
|
|
|
|
activeArtPlace = NULL;
|
|
|
|
}
|
|
|
|
|
2008-12-21 21:17:35 +02:00
|
|
|
CArtPlace::CArtPlace(const CArtifact* Art): active(false), clicked(false), ourArt(Art)/*,
|
2008-01-30 12:55:43 +02:00
|
|
|
spellBook(false), warMachine1(false), warMachine2(false), warMachine3(false),
|
|
|
|
warMachine4(false),misc1(false), misc2(false), misc3(false), misc4(false),
|
|
|
|
misc5(false), feet(false), lRing(false), rRing(false), torso(false),
|
2008-08-26 00:14:00 +03:00
|
|
|
lHand(false), rHand(false), neck(false), shoulders(false), head(false) */{}
|
2008-01-19 15:19:58 +02:00
|
|
|
void CArtPlace::activate()
|
|
|
|
{
|
2008-01-20 17:26:34 +02:00
|
|
|
if(!active)
|
|
|
|
{
|
2008-01-29 15:55:14 +02:00
|
|
|
//ClickableL::activate();
|
|
|
|
LRClickableAreaWTextComp::activate();
|
2008-01-20 17:26:34 +02:00
|
|
|
active = true;
|
|
|
|
}
|
2008-01-19 15:19:58 +02:00
|
|
|
}
|
|
|
|
void CArtPlace::clickLeft(boost::logic::tribool down)
|
|
|
|
{
|
2008-01-29 15:55:14 +02:00
|
|
|
//LRClickableAreaWTextComp::clickLeft(down);
|
2008-09-12 16:06:53 +03:00
|
|
|
|
|
|
|
if(ourArt && !down) //we are spellbook
|
|
|
|
{
|
|
|
|
if(ourArt->id == 0)
|
|
|
|
{
|
2009-01-07 21:40:19 +02:00
|
|
|
CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), ourWindow->curHero);
|
2009-04-14 15:47:09 +03:00
|
|
|
LOCPLINT->pushInt(spellWindow);
|
2008-09-12 16:06:53 +03:00
|
|
|
}
|
|
|
|
}
|
2008-09-17 13:18:22 +03:00
|
|
|
if(!down && !clicked && pressedL) //not clicked before
|
2008-01-30 12:55:43 +02:00
|
|
|
{
|
2008-09-12 16:06:53 +03:00
|
|
|
if(ourArt && ourArt->id == 0)
|
|
|
|
return; //this is handled separately
|
2009-05-30 19:00:26 +03:00
|
|
|
if(!ourWindow->activeArtPlace) //nothing has bewn clicked
|
2008-01-30 12:55:43 +02:00
|
|
|
{
|
2008-02-12 19:40:01 +02:00
|
|
|
if(ourArt) //to prevent selecting empty slots (bugfix to what GrayFace reported)
|
|
|
|
{
|
|
|
|
clicked = true;
|
|
|
|
ourWindow->activeArtPlace = this;
|
|
|
|
}
|
2008-01-30 12:55:43 +02:00
|
|
|
}
|
|
|
|
else //perform artifact substitution
|
|
|
|
{
|
2009-05-30 19:00:26 +03:00
|
|
|
if(slotID >= 19) //we are an backpack slot - remove active artifact and put it to the last free pos in backpack
|
|
|
|
{ //TODO: putting artifacts in the middle of backpack (pushing following arts)
|
|
|
|
|
|
|
|
LOCPLINT->cb->swapArtifacts(ourWindow->curHero,ourWindow->activeArtPlace->slotID,ourWindow->curHero,ourWindow->curHero->artifacts.size()+19);
|
|
|
|
}
|
|
|
|
//check if swap is possible
|
|
|
|
else if(this->fitsHere(ourWindow->activeArtPlace->ourArt) && ourWindow->activeArtPlace->fitsHere(this->ourArt))
|
2008-01-30 12:55:43 +02:00
|
|
|
{
|
2009-04-04 01:34:31 +03:00
|
|
|
int destSlot = slotID,
|
|
|
|
srcSlot = ourWindow->activeArtPlace->slotID;
|
|
|
|
|
|
|
|
LOCPLINT->cb->swapArtifacts(ourWindow->curHero,destSlot,ourWindow->curHero,srcSlot);
|
2008-01-30 12:55:43 +02:00
|
|
|
|
|
|
|
ourWindow->activeArtPlace->clicked = false;
|
|
|
|
ourWindow->activeArtPlace = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(!down && clicked)
|
|
|
|
{
|
2008-09-12 16:06:53 +03:00
|
|
|
if(ourArt && ourArt->id == 0)
|
|
|
|
return; //this is handled separately
|
2008-01-30 12:55:43 +02:00
|
|
|
clicked = false;
|
|
|
|
ourWindow->activeArtPlace = NULL;
|
|
|
|
}
|
2008-09-17 13:18:22 +03:00
|
|
|
ClickableL::clickLeft(down);
|
2008-01-29 15:55:14 +02:00
|
|
|
}
|
|
|
|
void CArtPlace::clickRight(boost::logic::tribool down)
|
|
|
|
{
|
|
|
|
if(text.size()) //if there is no description, do nothing ;]
|
|
|
|
LRClickableAreaWTextComp::clickRight(down);
|
2008-01-19 15:19:58 +02:00
|
|
|
}
|
|
|
|
void CArtPlace::deactivate()
|
|
|
|
{
|
2008-01-20 17:26:34 +02:00
|
|
|
if(active)
|
|
|
|
{
|
|
|
|
active = false;
|
2008-01-29 15:55:14 +02:00
|
|
|
//ClickableL::deactivate();
|
|
|
|
LRClickableAreaWTextComp::deactivate();
|
2008-01-20 17:26:34 +02:00
|
|
|
}
|
2008-01-19 15:19:58 +02:00
|
|
|
}
|
|
|
|
void CArtPlace::show(SDL_Surface *to)
|
|
|
|
{
|
|
|
|
if(ourArt)
|
|
|
|
{
|
2008-06-13 11:16:51 +03:00
|
|
|
blitAt(graphics->artDefs->ourImages[ourArt->id].bitmap, pos.x, pos.y, to);
|
2008-01-19 15:19:58 +02:00
|
|
|
}
|
2008-01-30 12:55:43 +02:00
|
|
|
if(clicked && active)
|
|
|
|
{
|
|
|
|
for(int i=0; i<pos.h; ++i)
|
|
|
|
{
|
|
|
|
for(int j=0; j<pos.w; ++j)
|
|
|
|
{
|
|
|
|
if(i==0 || j==0 || i==pos.h-1 || j==pos.w-1)
|
|
|
|
{
|
2008-11-28 14:11:31 +02:00
|
|
|
CSDL_Ext::SDL_PutPixelWithoutRefresh(to, pos.x+j, pos.y+i, 240, 220, 120);
|
2008-01-30 12:55:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool CArtPlace::fitsHere(const CArtifact * art)
|
|
|
|
{
|
|
|
|
if(!art)
|
|
|
|
return true; //you can have no artifact somewhere
|
2008-08-26 00:14:00 +03:00
|
|
|
if(slotID > 18 || vstd::contains(art->possibleSlots,slotID)) //backpack or right slot
|
2008-01-30 12:55:43 +02:00
|
|
|
return true;
|
|
|
|
return false;
|
2008-01-19 15:19:58 +02:00
|
|
|
}
|
2008-01-20 15:53:11 +02:00
|
|
|
CArtPlace::~CArtPlace()
|
|
|
|
{
|
2008-01-20 17:26:34 +02:00
|
|
|
deactivate();
|
2008-01-20 15:53:11 +02:00
|
|
|
}
|
2008-01-19 20:58:24 +02:00
|
|
|
|
|
|
|
void LClickableArea::activate()
|
|
|
|
{
|
|
|
|
ClickableL::activate();
|
|
|
|
}
|
|
|
|
void LClickableArea::deactivate()
|
|
|
|
{
|
|
|
|
ClickableL::deactivate();
|
|
|
|
}
|
|
|
|
void LClickableArea::clickLeft(boost::logic::tribool down)
|
|
|
|
{
|
2008-07-31 00:27:15 +03:00
|
|
|
//if(!down)
|
|
|
|
//{
|
|
|
|
// LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector<SComponent*>());
|
|
|
|
//}
|
2008-01-19 20:58:24 +02:00
|
|
|
}
|
2008-01-20 15:53:11 +02:00
|
|
|
|
2008-01-27 18:07:27 +02:00
|
|
|
void RClickableArea::activate()
|
|
|
|
{
|
|
|
|
ClickableR::activate();
|
|
|
|
}
|
|
|
|
void RClickableArea::deactivate()
|
|
|
|
{
|
|
|
|
ClickableR::deactivate();
|
|
|
|
}
|
|
|
|
void RClickableArea::clickRight(boost::logic::tribool down)
|
|
|
|
{
|
2008-07-31 00:27:15 +03:00
|
|
|
//if(!down)
|
|
|
|
//{
|
|
|
|
// LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector<SComponent*>());
|
|
|
|
//}
|
2008-01-27 18:07:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void LRClickableAreaWText::clickLeft(boost::logic::tribool down)
|
2008-01-20 15:53:11 +02:00
|
|
|
{
|
2008-09-17 13:18:22 +03:00
|
|
|
if(!down && pressedL)
|
2008-01-20 15:53:11 +02:00
|
|
|
{
|
2009-04-22 21:48:56 +03:00
|
|
|
LOCPLINT->showInfoDialog(text, std::vector<SComponent*>(), soundBase::sound_todo);
|
2008-01-20 15:53:11 +02:00
|
|
|
}
|
2008-09-17 13:18:22 +03:00
|
|
|
ClickableL::clickLeft(down);
|
2008-01-20 15:53:11 +02:00
|
|
|
}
|
2008-01-27 18:07:27 +02:00
|
|
|
void LRClickableAreaWText::clickRight(boost::logic::tribool down)
|
|
|
|
{
|
|
|
|
LOCPLINT->adventureInt->handleRightClick(text, down, this);
|
|
|
|
}
|
|
|
|
void LRClickableAreaWText::activate()
|
|
|
|
{
|
|
|
|
LClickableArea::activate();
|
|
|
|
RClickableArea::activate();
|
2008-01-31 14:10:59 +02:00
|
|
|
Hoverable::activate();
|
2008-01-27 18:07:27 +02:00
|
|
|
}
|
|
|
|
void LRClickableAreaWText::deactivate()
|
|
|
|
{
|
|
|
|
LClickableArea::deactivate();
|
|
|
|
RClickableArea::deactivate();
|
2008-01-31 14:10:59 +02:00
|
|
|
Hoverable::deactivate();
|
|
|
|
}
|
|
|
|
void LRClickableAreaWText::hover(bool on)
|
|
|
|
{
|
|
|
|
Hoverable::hover(on);
|
|
|
|
if (on)
|
|
|
|
LOCPLINT->statusbar->print(hoverText);
|
|
|
|
else if (LOCPLINT->statusbar->getCurrent()==hoverText)
|
|
|
|
LOCPLINT->statusbar->clear();
|
2008-01-27 18:07:27 +02:00
|
|
|
}
|
2008-01-25 21:09:41 +02:00
|
|
|
|
|
|
|
void LClickableAreaHero::clickLeft(boost::logic::tribool down)
|
|
|
|
{
|
|
|
|
if(!down)
|
|
|
|
{
|
2008-01-26 21:36:31 +02:00
|
|
|
owner->deactivate();
|
2009-06-11 20:21:06 +03:00
|
|
|
const CGHeroInstance * buf = LOCPLINT->getWHero(id);
|
2008-01-25 21:09:41 +02:00
|
|
|
owner->setHero(buf);
|
|
|
|
owner->redrawCurBack();
|
2008-01-26 21:36:31 +02:00
|
|
|
owner->activate();
|
2008-01-25 21:09:41 +02:00
|
|
|
}
|
|
|
|
}
|
2008-01-27 18:07:27 +02:00
|
|
|
|
|
|
|
void LRClickableAreaWTextComp::clickLeft(boost::logic::tribool down)
|
|
|
|
{
|
2008-01-28 14:36:46 +02:00
|
|
|
if((!down) && pressedL)
|
2008-01-27 18:07:27 +02:00
|
|
|
{
|
2008-08-20 09:57:53 +03:00
|
|
|
std::vector<SComponent*> comp(1, new SComponent(SComponent::Etype(baseType), type, bonus));
|
2009-04-22 21:48:56 +03:00
|
|
|
LOCPLINT->showInfoDialog(text, comp, soundBase::sound_todo);
|
2008-01-27 18:07:27 +02:00
|
|
|
}
|
2008-01-28 14:36:46 +02:00
|
|
|
ClickableL::clickLeft(down);
|
2008-01-27 18:07:27 +02:00
|
|
|
}
|
|
|
|
void LRClickableAreaWTextComp::clickRight(boost::logic::tribool down)
|
|
|
|
{
|
|
|
|
LOCPLINT->adventureInt->handleRightClick(text, down, this);
|
|
|
|
}
|
|
|
|
void LRClickableAreaWTextComp::activate()
|
|
|
|
{
|
|
|
|
LClickableArea::activate();
|
|
|
|
RClickableArea::activate();
|
2008-01-31 14:10:59 +02:00
|
|
|
Hoverable::activate();
|
2008-01-27 18:07:27 +02:00
|
|
|
}
|
|
|
|
void LRClickableAreaWTextComp::deactivate()
|
|
|
|
{
|
|
|
|
LClickableArea::deactivate();
|
|
|
|
RClickableArea::deactivate();
|
2008-01-31 14:10:59 +02:00
|
|
|
Hoverable::deactivate();
|
|
|
|
}
|
|
|
|
void LRClickableAreaWTextComp::hover(bool on)
|
|
|
|
{
|
|
|
|
Hoverable::hover(on);
|
|
|
|
if (on)
|
|
|
|
LOCPLINT->statusbar->print(hoverText);
|
|
|
|
else if (LOCPLINT->statusbar->getCurrent()==hoverText)
|
|
|
|
LOCPLINT->statusbar->clear();
|
2008-01-27 18:07:27 +02:00
|
|
|
}
|