2010-01-25 23:25:14 +02:00
|
|
|
#include "CKingdomInterface.h"
|
|
|
|
#include "AdventureMapButton.h"
|
|
|
|
#include "CAdvmapInterface.h"
|
2010-01-31 14:10:13 +02:00
|
|
|
#include "../CCallback.h"
|
2010-02-01 01:30:47 +02:00
|
|
|
#include "../global.h"
|
2010-01-30 21:08:26 +02:00
|
|
|
#include "CConfigHandler.h"
|
2010-01-25 23:25:14 +02:00
|
|
|
#include "CGameInfo.h"
|
2010-01-31 14:10:13 +02:00
|
|
|
#include "CHeroWindow.h"
|
2010-01-30 21:08:26 +02:00
|
|
|
#include "CSpellWindow.h"
|
2010-01-25 23:25:14 +02:00
|
|
|
#include "CMessage.h"
|
|
|
|
#include "SDL_Extensions.h"
|
|
|
|
#include "Graphics.h"
|
|
|
|
#include "../hch/CArtHandler.h"
|
2010-02-01 01:30:47 +02:00
|
|
|
#include "../hch/CBuildingHandler.h"
|
2010-01-25 23:25:14 +02:00
|
|
|
#include "../hch/CDefHandler.h"
|
2010-02-01 19:07:46 +02:00
|
|
|
#include "../hch/CHeroHandler.h"
|
2010-01-25 23:25:14 +02:00
|
|
|
#include "../hch/CGeneralTextHandler.h"
|
|
|
|
#include "../hch/CObjectHandler.h"
|
2010-01-26 13:56:29 +02:00
|
|
|
#include "../hch/CTownHandler.h"
|
2010-12-08 22:17:05 +02:00
|
|
|
#include "../hch/CCreatureHandler.h"
|
2010-02-02 19:05:03 +02:00
|
|
|
#include "../hch/CHeroHandler.h"
|
2010-01-26 13:56:29 +02:00
|
|
|
#include "../lib/map.h"
|
2010-01-28 18:15:46 +02:00
|
|
|
#include "../lib/NetPacks.h"
|
2010-02-01 19:07:46 +02:00
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
2010-01-31 14:10:13 +02:00
|
|
|
#include <boost/assign/std/vector.hpp>
|
|
|
|
#include <boost/assign/list_of.hpp>
|
2010-02-01 19:07:46 +02:00
|
|
|
#include <boost/lexical_cast.hpp>
|
2010-01-30 21:08:26 +02:00
|
|
|
#include <boost/format.hpp>
|
2010-01-25 23:25:14 +02:00
|
|
|
#include <sstream>
|
2010-02-08 16:38:06 +02:00
|
|
|
#include <SDL.h>
|
2010-08-17 17:58:13 +03:00
|
|
|
#include "CBitmapHandler.h"
|
2010-02-08 16:38:06 +02:00
|
|
|
|
2010-01-25 23:25:14 +02:00
|
|
|
using namespace boost::assign;
|
|
|
|
using namespace CSDL_Ext;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CKingdomInterface.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
|
|
|
|
*
|
2010-01-26 13:56:29 +02:00
|
|
|
*/
|
2010-01-31 14:10:13 +02:00
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
#define ADVOPT (conf.go()->ac)
|
2010-01-26 13:56:29 +02:00
|
|
|
|
2010-01-25 23:25:14 +02:00
|
|
|
CKingdomInterface::CKingdomInterface()
|
2010-01-26 13:56:29 +02:00
|
|
|
{
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
2010-02-01 01:30:47 +02:00
|
|
|
defActions = SHARE_POS | DISPOSE;
|
2010-01-31 14:10:13 +02:00
|
|
|
PicCount = ADVOPT.overviewPics;
|
2010-02-01 01:30:47 +02:00
|
|
|
size = ADVOPT.overviewSize;
|
2010-01-25 23:25:14 +02:00
|
|
|
pos.x = screen->w/2 - 400;
|
2010-01-28 18:15:46 +02:00
|
|
|
pos.y = screen->h/2 - (68+58*size);
|
2010-01-31 14:10:13 +02:00
|
|
|
showHarrisoned = false;//set to true if you want to see garrisoned heroes
|
2010-02-01 01:30:47 +02:00
|
|
|
heroPos = townPos = objPos = state = 0;
|
2010-01-26 13:56:29 +02:00
|
|
|
|
2010-01-31 14:10:13 +02:00
|
|
|
bg = BitmapHandler::loadBitmap(ADVOPT.overviewBg);
|
2010-01-25 23:25:14 +02:00
|
|
|
graphics->blueToPlayersAdv(bg, LOCPLINT->playerID);
|
2010-02-01 01:30:47 +02:00
|
|
|
|
|
|
|
mines = CDefHandler::giveDefEss("OVMINES.DEF");
|
|
|
|
title = CDefHandler::giveDefEss("OVTITLE.DEF");
|
|
|
|
hall = CDefHandler::giveDefEss("ITMTL.DEF");
|
|
|
|
fort = CDefHandler::giveDefEss("ITMCL.DEF");
|
2010-01-31 14:10:13 +02:00
|
|
|
objPics = CDefHandler::giveDefEss("FLAGPORT.DEF");
|
2010-02-01 01:30:47 +02:00
|
|
|
slots = CDefHandler::giveDefEss("OVSLOT.DEF");
|
2010-01-25 23:25:14 +02:00
|
|
|
|
2010-01-26 13:56:29 +02:00
|
|
|
toHeroes = new AdventureMapButton (CGI->generaltexth->overview[11],"",
|
2010-02-04 17:50:59 +02:00
|
|
|
boost::bind(&CKingdomInterface::listToHeroes,this),748,28+size*116,"OVBUTN1.DEF", SDLK_h);
|
2010-01-26 13:56:29 +02:00
|
|
|
toHeroes->block(2);
|
2010-01-25 23:25:14 +02:00
|
|
|
|
2010-01-26 13:56:29 +02:00
|
|
|
toTowns = new AdventureMapButton (CGI->generaltexth->overview[12],"",
|
2010-02-04 17:50:59 +02:00
|
|
|
boost::bind(&CKingdomInterface::listToTowns,this),748,64+size*116,"OVBUTN6.DEF", SDLK_t);
|
2010-01-26 13:56:29 +02:00
|
|
|
toTowns->block(0);
|
2010-01-25 23:25:14 +02:00
|
|
|
|
2010-01-26 13:56:29 +02:00
|
|
|
exit = new AdventureMapButton (CGI->generaltexth->allTexts[600],"",
|
2010-02-04 17:50:59 +02:00
|
|
|
boost::bind(&CKingdomInterface::close,this),748,99+size*116,"OVBUTN1.DEF", SDLK_RETURN);
|
2010-01-26 13:56:29 +02:00
|
|
|
exit->bitmapOffset = 3;
|
2010-01-25 23:25:14 +02:00
|
|
|
|
2010-02-13 17:56:34 +02:00
|
|
|
statusbar = new CStatusBar(7, 91+size*116,"TSTATBAR.bmp",732);
|
2010-01-28 18:15:46 +02:00
|
|
|
resdatabar = new CResDataBar("KRESBAR.bmp",pos.x+3,pos.y+111+size*116,32,2,76,76);
|
2010-01-31 14:10:13 +02:00
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
for(size_t i=0;i<size;i++)//creating empty hero/town lists for input
|
2010-02-01 01:30:47 +02:00
|
|
|
{
|
|
|
|
heroes.push_back( new CHeroItem(i,this));
|
|
|
|
towns.push_back( new CTownItem(i,this));
|
|
|
|
}
|
2010-01-26 13:56:29 +02:00
|
|
|
|
2010-01-28 18:15:46 +02:00
|
|
|
slider = new CSlider(4, 4, size*116+19, boost::bind (&CKingdomInterface::sliderMoved, this, _1),
|
2010-01-26 13:56:29 +02:00
|
|
|
size, LOCPLINT->cb->howManyHeroes(showHarrisoned), 0, false, 0);
|
2010-01-28 18:15:46 +02:00
|
|
|
|
|
|
|
//creating objects list
|
|
|
|
ObjTop = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,0),
|
|
|
|
733,4,"OVBUTN4.DEF");
|
|
|
|
|
|
|
|
ObjUp = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,1),
|
|
|
|
733,24,"OVBUTN4.DEF");
|
|
|
|
ObjUp->bitmapOffset = 4;
|
|
|
|
|
|
|
|
ObjDown = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,2),
|
|
|
|
733,size*116-18,"OVBUTN4.DEF");
|
|
|
|
ObjDown->bitmapOffset = 6;
|
|
|
|
|
|
|
|
ObjBottom = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,3),
|
|
|
|
733,size*116+2,"OVBUTN4.DEF");
|
|
|
|
ObjBottom->bitmapOffset = 2;
|
|
|
|
|
2010-02-06 15:27:58 +02:00
|
|
|
for (size_t i=0; i<8; i++)
|
2010-02-01 01:30:47 +02:00
|
|
|
{
|
|
|
|
incomes.push_back(new HoverableArea());//bottom panel with mines
|
2010-02-04 17:50:59 +02:00
|
|
|
incomes[i]->pos = genRect(57,68,pos.x+20+i*80,pos.y+31+size*116);
|
2010-02-01 01:30:47 +02:00
|
|
|
incomes[i]->hoverText = CGI->generaltexth->mines[i].first;
|
|
|
|
}
|
|
|
|
incomes[7]->pos.w = 136;
|
|
|
|
incomes[7]->hoverText = CGI->generaltexth->allTexts[255];
|
|
|
|
incomesVal+=0,0,0,0,0,0,0,0;//for mines images
|
|
|
|
|
2010-01-28 18:15:46 +02:00
|
|
|
std::map<std::pair<int,int>,int> addObjects;//objects to print, except 17th dwelling
|
|
|
|
//format: (id,subID),image index
|
|
|
|
#define INSERT_MAP addObjects.insert(std::pair<std::pair<int,int>,int>(std::pair<int,int>
|
|
|
|
INSERT_MAP (20,1) ,81));//Golem factory
|
|
|
|
INSERT_MAP (42,0) ,82));//Lighthouse
|
|
|
|
INSERT_MAP (33,0) ,83));//Garrison
|
|
|
|
INSERT_MAP (219,0),83));//Garrison
|
|
|
|
INSERT_MAP (33,1) ,84));//Anti-magic Garrison
|
|
|
|
INSERT_MAP (219,1),84));//Anti-magic Garrison
|
|
|
|
INSERT_MAP (53,7) ,85));//Abandoned mine
|
|
|
|
INSERT_MAP (20,0) ,86));//Conflux
|
|
|
|
INSERT_MAP (87,0) ,87));//Harbor
|
|
|
|
#undef INSERT_MAP
|
2010-02-01 01:30:47 +02:00
|
|
|
|
2010-08-16 12:54:09 +03:00
|
|
|
std::vector<const CGObjectInstance * > myObjects = LOCPLINT->cb->getMyObjects();
|
|
|
|
for(size_t i = 0; i<myObjects.size(); i++)//getting mines and dwelling (in one pass to make it faster)
|
2010-01-28 18:15:46 +02:00
|
|
|
{
|
2010-08-16 12:54:09 +03:00
|
|
|
const CGObjectInstance* obj = myObjects[i];//current object
|
2010-01-28 18:15:46 +02:00
|
|
|
if (obj)
|
|
|
|
{
|
2010-08-16 12:54:09 +03:00
|
|
|
std::pair<int,int > curElm = std::pair<int,int >(obj->ID, obj->subID);
|
|
|
|
if ( obj->ID == 17 )//dwelling, text is a plural name of a creature
|
2010-01-28 18:15:46 +02:00
|
|
|
{
|
2010-08-16 12:54:09 +03:00
|
|
|
objList[obj->subID].first += 1;
|
|
|
|
objList[obj->subID].second = & CGI->creh->creatures[CGI->objh->cregens[obj->subID]]->namePl;
|
2010-01-28 18:15:46 +02:00
|
|
|
}
|
2010-08-16 12:54:09 +03:00
|
|
|
else if (addObjects.find(curElm) != addObjects.end())
|
|
|
|
{//object from addObjects map, text is name of the object
|
|
|
|
objList[addObjects[curElm]].first += 1;
|
|
|
|
objList[addObjects[curElm]].second = & obj->hoverName;
|
|
|
|
}
|
2010-08-30 02:12:34 +03:00
|
|
|
else if ( obj->ID == 53 )
|
2010-08-16 12:54:09 +03:00
|
|
|
incomesVal[obj->subID]+=1;
|
2010-01-28 18:15:46 +02:00
|
|
|
}
|
|
|
|
}
|
2010-02-01 01:30:47 +02:00
|
|
|
|
2010-01-28 18:15:46 +02:00
|
|
|
addObjects.clear();
|
|
|
|
objSize = (size*116-64)/57; //in object list will fit (height of panel)/(height of one element) items
|
|
|
|
ObjList.resize(objSize);
|
|
|
|
for(size_t i=0;i<objSize;i++)
|
|
|
|
{
|
|
|
|
ObjList[i] = new HoverableArea();
|
|
|
|
ObjList[i]->pos = genRect(50,50,pos.x+740,pos.y+44+i*57);
|
|
|
|
}
|
2010-02-01 01:30:47 +02:00
|
|
|
|
|
|
|
incomesVal[7] = incomesVal[6]*1000;//gold mines -> total income
|
|
|
|
std::vector<const CGHeroInstance*> heroes = LOCPLINT->cb->getHeroesInfo(true);
|
|
|
|
for(size_t i=0; i<heroes.size();i++)
|
|
|
|
switch(heroes[i]->getSecSkillLevel(13))//some heroes may have estates
|
|
|
|
{
|
|
|
|
case 1: //basic
|
|
|
|
incomesVal[7] += 125;
|
|
|
|
break;
|
|
|
|
case 2: //advanced
|
|
|
|
incomesVal[7] += 250;
|
|
|
|
break;
|
|
|
|
case 3: //expert
|
|
|
|
incomesVal[7] += 500;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
std::vector<const CGTownInstance*> towns = LOCPLINT->cb->getTownsInfo(true);
|
|
|
|
for(size_t i=0; i<towns.size();i++)
|
|
|
|
incomesVal[7] += towns[i]->dailyIncome();
|
2010-01-28 18:15:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::moveObjectList(int newPos)
|
|
|
|
{
|
|
|
|
int top = objList.size() > objSize ? 0 : objList.size() - objSize ;
|
|
|
|
int bottom = objList.size() > objSize ? objList.size() - objSize : 0 ;
|
|
|
|
switch (newPos)//checking what button was pressed
|
|
|
|
{
|
2010-01-30 21:08:26 +02:00
|
|
|
/* Top */ case 0: objPos = top;
|
2010-01-28 18:15:46 +02:00
|
|
|
break;
|
2010-01-30 21:08:26 +02:00
|
|
|
/* Up */ case 1: objPos = objPos==top?top:(objPos-1);
|
2010-01-28 18:15:46 +02:00
|
|
|
break;
|
2010-01-30 21:08:26 +02:00
|
|
|
/* Down */ case 2: objPos = objPos==bottom?bottom:(objPos+1);
|
2010-01-28 18:15:46 +02:00
|
|
|
break;
|
2010-01-30 21:08:26 +02:00
|
|
|
/*Bottom*/ case 3: objPos = bottom;
|
2010-01-28 18:15:46 +02:00
|
|
|
break;
|
|
|
|
}
|
2010-02-04 17:50:59 +02:00
|
|
|
showAll(screen2);
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CKingdomInterface::~CKingdomInterface()
|
2010-01-26 13:56:29 +02:00
|
|
|
{
|
|
|
|
SDL_FreeSurface(bg);
|
2010-01-25 23:25:14 +02:00
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
delete title;//deleting .def
|
2010-01-26 13:56:29 +02:00
|
|
|
delete slots;
|
|
|
|
delete fort;
|
|
|
|
delete hall;
|
2010-01-30 21:08:26 +02:00
|
|
|
delete objPics;
|
2010-02-01 01:30:47 +02:00
|
|
|
delete mines;
|
2010-01-26 13:56:29 +02:00
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
towns.clear();//deleting lists
|
2010-01-26 13:56:29 +02:00
|
|
|
heroes.clear();
|
2010-01-25 23:25:14 +02:00
|
|
|
incomes.clear();
|
2010-01-28 18:15:46 +02:00
|
|
|
ObjList.clear();
|
|
|
|
objList.clear();
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::close()
|
|
|
|
{
|
|
|
|
GH.popIntTotally(this);
|
|
|
|
}
|
|
|
|
|
2010-07-22 03:32:45 +03:00
|
|
|
void CKingdomInterface::updateGarrisons()
|
2010-02-06 15:27:58 +02:00
|
|
|
{
|
|
|
|
for (int i = 0; i<towns.size(); i++)
|
2010-02-13 17:56:34 +02:00
|
|
|
{
|
2010-02-06 15:27:58 +02:00
|
|
|
if (towns[i] && towns[i]->garr)
|
|
|
|
towns[i]->garr->recreateSlots();
|
|
|
|
}
|
|
|
|
for (int i = 0; i<heroes.size(); i++)
|
2010-02-13 17:56:34 +02:00
|
|
|
{
|
2010-02-06 15:27:58 +02:00
|
|
|
if (heroes[i] && heroes[i]->garr)
|
|
|
|
heroes[i]->garr->recreateSlots();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-25 23:25:14 +02:00
|
|
|
void CKingdomInterface::showAll( SDL_Surface * to/*=NULL*/)
|
|
|
|
{
|
2010-02-20 15:24:38 +02:00
|
|
|
adventureInt->resdatabar.draw(to);
|
2010-01-25 23:25:14 +02:00
|
|
|
blitAt(bg,pos,to);
|
|
|
|
resdatabar->draw(to);
|
|
|
|
toTowns->show(to);
|
2010-01-26 13:56:29 +02:00
|
|
|
toHeroes->show(to);
|
|
|
|
exit->show(to);
|
2010-01-28 18:15:46 +02:00
|
|
|
|
|
|
|
ObjTop->show(to);
|
|
|
|
ObjUp->show(to);
|
|
|
|
ObjDown->show(to);
|
|
|
|
ObjBottom->show(to);
|
|
|
|
|
|
|
|
for (size_t i=0; i<ObjList.size(); i++)//list may be moved, recreate hover text
|
|
|
|
ObjList[i]->hoverText = "";
|
|
|
|
|
|
|
|
int skipCount=0, curPos=objPos<0?(-objPos):0;
|
|
|
|
for (std::map<int,std::pair<int, std::string*> >::iterator it=objList.begin(); it!= objList.end(); it++)
|
|
|
|
{
|
2010-01-30 21:08:26 +02:00
|
|
|
if (skipCount<objPos)//we will show only objects from objPos
|
2010-01-28 18:15:46 +02:00
|
|
|
{
|
|
|
|
skipCount++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
blitAt(objPics->ourImages[(*it).first].bitmap,pos.x+740,pos.y+44+curPos*57,to);
|
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
std::ostringstream ostrs;//objects count
|
2010-01-28 18:15:46 +02:00
|
|
|
ostrs << (*it).second.first;
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printTo(ostrs.str(),pos.x+790,pos.y+94+curPos*57,FONT_SMALL,zwykly,to);
|
2010-01-28 18:15:46 +02:00
|
|
|
|
|
|
|
ObjList[curPos]->hoverText = * (*it).second.second;
|
|
|
|
curPos++;
|
|
|
|
if (curPos == objSize)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-01-25 23:25:14 +02:00
|
|
|
if (state == 1)
|
2010-01-26 13:56:29 +02:00
|
|
|
{//printing text "Town", "Harrisoned hero", "Visiting hero"
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[3],pos.x+144,pos.y+14,FONT_MEDIUM,zwykly,to);
|
|
|
|
CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[4],pos.x+373,pos.y+14,FONT_MEDIUM,zwykly,to);
|
|
|
|
CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[5],pos.x+606,pos.y+14,FONT_MEDIUM,zwykly,to);
|
2010-01-26 13:56:29 +02:00
|
|
|
for (size_t i=0; i<size; i++)
|
2010-01-30 21:08:26 +02:00
|
|
|
towns[i]->showAll(to);//show town list
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
else
|
2010-01-26 13:56:29 +02:00
|
|
|
{//text "Hero/stats" and "Skills"
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[0],pos.x+150,pos.y+14,FONT_MEDIUM,zwykly,to);
|
|
|
|
CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[1],pos.x+500,pos.y+14,FONT_MEDIUM,zwykly,to);
|
2010-01-26 13:56:29 +02:00
|
|
|
for (size_t i=0; i<size; i++)
|
2010-01-30 21:08:26 +02:00
|
|
|
heroes[i]->showAll(to);//show hero list
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
2010-02-01 01:30:47 +02:00
|
|
|
for (int i = 0; i<7; i++)
|
|
|
|
blitAt(mines->ourImages[i].bitmap,pos.x + 20 + i*80,pos.y + 31+size*116,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
|
|
|
|
for(size_t i=0;i<incomes.size();i++)
|
2010-02-01 01:30:47 +02:00
|
|
|
{
|
|
|
|
std::ostringstream oss;
|
|
|
|
oss << incomesVal[i];
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printAtMiddle(oss.str(),incomes[i]->pos.x+incomes[i]->pos.w/2,incomes[i]->pos.y+50,FONT_SMALL,zwykly,to);
|
2010-02-01 01:30:47 +02:00
|
|
|
}
|
2010-01-26 13:56:29 +02:00
|
|
|
|
2010-01-28 18:15:46 +02:00
|
|
|
slider->showAll(to);
|
2010-01-25 23:25:14 +02:00
|
|
|
if(screen->w != 800 || screen->h !=600)
|
2010-01-28 18:15:46 +02:00
|
|
|
CMessage::drawBorder(LOCPLINT->playerID,to,828,136+116*size+29,pos.x-14,pos.y-15);
|
2010-01-25 23:25:14 +02:00
|
|
|
show(to);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::show(SDL_Surface * to)
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
2010-01-25 23:25:14 +02:00
|
|
|
statusbar->show(to);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::activate()
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
2010-02-15 08:54:57 +02:00
|
|
|
GH.statusbar = statusbar;
|
2010-01-25 23:25:14 +02:00
|
|
|
exit->activate();
|
|
|
|
toTowns->activate();
|
2010-01-26 13:56:29 +02:00
|
|
|
toHeroes->activate();
|
2010-01-28 18:15:46 +02:00
|
|
|
|
|
|
|
ObjTop->activate();
|
|
|
|
ObjUp->activate();
|
|
|
|
ObjDown->activate();
|
|
|
|
ObjBottom->activate();
|
|
|
|
|
|
|
|
for (size_t i=0; i<ObjList.size(); i++)
|
|
|
|
ObjList[i]->activate();
|
|
|
|
|
|
|
|
for (size_t i=0; i<incomes.size(); i++)
|
|
|
|
incomes[i]->activate();
|
2010-01-25 23:25:14 +02:00
|
|
|
if (state == 1)
|
2010-01-30 21:08:26 +02:00
|
|
|
for (size_t i=0; i<size; i++)
|
2010-01-25 23:25:14 +02:00
|
|
|
towns[i]->activate();
|
|
|
|
else
|
2010-01-30 21:08:26 +02:00
|
|
|
for (size_t i=0; i<size; i++)
|
2010-01-26 13:56:29 +02:00
|
|
|
heroes[i]->activate();
|
|
|
|
|
2010-01-25 23:25:14 +02:00
|
|
|
slider->activate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::deactivate()
|
|
|
|
{
|
|
|
|
exit->deactivate();
|
|
|
|
toTowns->deactivate();
|
|
|
|
toHeroes->deactivate();
|
2010-01-28 18:15:46 +02:00
|
|
|
|
|
|
|
ObjTop->deactivate();
|
|
|
|
ObjUp->deactivate();
|
|
|
|
ObjDown->deactivate();
|
|
|
|
ObjBottom->deactivate();
|
|
|
|
|
|
|
|
for (size_t i=0; i<ObjList.size(); i++)
|
|
|
|
ObjList[i]->deactivate();
|
|
|
|
|
|
|
|
for (size_t i=0; i<incomes.size(); i++)
|
|
|
|
incomes[i]->deactivate();
|
2010-01-31 14:10:13 +02:00
|
|
|
|
2010-01-25 23:25:14 +02:00
|
|
|
if (state == 1)
|
2010-01-30 21:08:26 +02:00
|
|
|
for (size_t i=0; i<size; i++)
|
2010-01-25 23:25:14 +02:00
|
|
|
towns[i]->deactivate();
|
|
|
|
else
|
2010-01-30 21:08:26 +02:00
|
|
|
for (size_t i=0; i<size; i++)
|
2010-01-26 13:56:29 +02:00
|
|
|
heroes[i]->deactivate();
|
2010-01-25 23:25:14 +02:00
|
|
|
slider->deactivate();
|
|
|
|
}
|
|
|
|
|
2010-01-26 13:56:29 +02:00
|
|
|
void CKingdomInterface::recreateHeroList(int pos)
|
|
|
|
{
|
|
|
|
std::vector<const CGHeroInstance*> Heroes = LOCPLINT->cb->getHeroesInfo(true);
|
|
|
|
int i=0, cnt=0;
|
2010-01-30 21:08:26 +02:00
|
|
|
for (size_t j = 0; ((j<Heroes.size()) && (i<size));j++)
|
2010-01-26 13:56:29 +02:00
|
|
|
{
|
|
|
|
if (Heroes[j]->inTownGarrison && (!showHarrisoned))//if hero in garrison and we don't show them
|
|
|
|
continue;
|
|
|
|
if (cnt<pos)//skipping heroes
|
|
|
|
{
|
|
|
|
cnt++;
|
|
|
|
continue;
|
2010-01-31 14:10:13 +02:00
|
|
|
}//this hero will be added
|
2010-01-30 21:08:26 +02:00
|
|
|
heroes[i]->setHero(Heroes[j]);
|
2010-01-25 23:25:14 +02:00
|
|
|
i++;
|
2010-01-26 13:56:29 +02:00
|
|
|
}
|
2010-08-12 18:54:25 +03:00
|
|
|
for (;i<size;i++)//if we still have empty pieces
|
2010-01-30 21:08:26 +02:00
|
|
|
heroes[i]->setHero(NULL);//empty pic
|
2010-01-26 13:56:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::recreateTownList(int pos)
|
|
|
|
{
|
2010-02-04 17:50:59 +02:00
|
|
|
std::vector<const CGTownInstance*> Towns = LOCPLINT->cb->getTownsInfo(false);
|
2010-01-30 21:08:26 +02:00
|
|
|
for(size_t i=0;i<size;i++)
|
2010-01-26 13:56:29 +02:00
|
|
|
{
|
2010-02-04 17:50:59 +02:00
|
|
|
if (i+pos<LOCPLINT->cb->howManyTowns())
|
2010-01-30 21:08:26 +02:00
|
|
|
towns[i]->setTown(Towns[i+pos]);//replace town
|
2010-01-25 23:25:14 +02:00
|
|
|
else
|
2010-01-30 21:08:26 +02:00
|
|
|
towns[i]->setTown(NULL);//only empty pic
|
2010-01-26 13:56:29 +02:00
|
|
|
}
|
|
|
|
}
|
2010-01-25 23:25:14 +02:00
|
|
|
|
|
|
|
void CKingdomInterface::listToTowns()
|
|
|
|
{
|
|
|
|
state = 1;
|
|
|
|
toHeroes->block(0);
|
|
|
|
toTowns->block(2);
|
|
|
|
heroPos = slider->value;
|
2010-01-26 13:56:29 +02:00
|
|
|
slider->setAmount(LOCPLINT->cb->howManyTowns());
|
|
|
|
slider->value=townPos;//moving slider
|
2010-01-31 14:10:13 +02:00
|
|
|
recreateTownList(townPos);
|
|
|
|
for (size_t i=0;i<size;i++)
|
|
|
|
{
|
|
|
|
heroes[i]->deactivate();
|
|
|
|
towns[i]->activate();
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
2010-02-04 17:50:59 +02:00
|
|
|
showAll(screen2);
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::listToHeroes()
|
|
|
|
{
|
|
|
|
state = 2;
|
|
|
|
toHeroes->block(2);
|
|
|
|
toTowns->block(0);
|
2010-01-26 13:56:29 +02:00
|
|
|
townPos = slider->value;
|
2010-01-25 23:25:14 +02:00
|
|
|
slider->setAmount(LOCPLINT->cb->howManyHeroes(showHarrisoned));
|
|
|
|
slider->value=heroPos;//moving slider
|
2010-01-31 14:10:13 +02:00
|
|
|
recreateHeroList(heroPos);
|
|
|
|
for (size_t i=0;i<size;i++)
|
|
|
|
{
|
|
|
|
towns[i]->deactivate();
|
|
|
|
heroes[i]->activate();
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
2010-02-04 17:50:59 +02:00
|
|
|
showAll(screen2);
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::sliderMoved(int newpos)
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
|
|
|
if (state == 0)
|
2010-01-25 23:25:14 +02:00
|
|
|
{
|
2010-01-26 13:56:29 +02:00
|
|
|
townPos = newpos;
|
2010-01-31 14:10:13 +02:00
|
|
|
recreateHeroList(newpos);
|
2010-01-30 21:08:26 +02:00
|
|
|
state = 2;
|
|
|
|
}
|
|
|
|
else if ( state == 1 )//towns
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
2010-01-30 21:08:26 +02:00
|
|
|
for (size_t i=0; i<size; i++)
|
|
|
|
towns[i]->deactivate();
|
|
|
|
townPos = newpos;
|
2010-01-31 14:10:13 +02:00
|
|
|
recreateTownList(newpos);
|
2010-01-30 21:08:26 +02:00
|
|
|
for (size_t i=0; i<size; i++)
|
|
|
|
towns[i]->activate();
|
2010-02-04 17:50:59 +02:00
|
|
|
showAll(screen2);
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
2010-01-26 13:56:29 +02:00
|
|
|
else//heroes
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
2010-01-30 21:08:26 +02:00
|
|
|
for (size_t i=0; i<size; i++)
|
|
|
|
heroes[i]->deactivate();
|
2010-01-26 13:56:29 +02:00
|
|
|
heroPos = newpos;
|
2010-01-31 14:10:13 +02:00
|
|
|
recreateHeroList(newpos);
|
2010-01-30 21:08:26 +02:00
|
|
|
for (size_t i=0; i<size; i++)
|
|
|
|
heroes[i]->activate();
|
2010-02-04 17:50:59 +02:00
|
|
|
showAll(screen2);
|
2010-01-26 13:56:29 +02:00
|
|
|
}
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
|
2010-02-01 01:30:47 +02:00
|
|
|
CKingdomInterface::CTownItem::CTownItem(int num, CKingdomInterface * Owner)
|
2010-01-26 13:56:29 +02:00
|
|
|
{
|
2010-02-01 01:30:47 +02:00
|
|
|
recActions = DISPOSE | SHARE_POS;
|
2010-07-22 03:32:45 +03:00
|
|
|
parent = Owner;
|
2010-02-01 01:30:47 +02:00
|
|
|
numb = num;
|
|
|
|
pos.x += 23;
|
|
|
|
pos.y += 25+num*116;
|
|
|
|
pos.w = 702;
|
|
|
|
pos.h = 114;
|
|
|
|
town = NULL;
|
|
|
|
garr = NULL;
|
2010-01-28 18:15:46 +02:00
|
|
|
|
2010-07-22 03:32:45 +03:00
|
|
|
garrHero = new CHeroArea(pos.x+244, pos.y + 6, NULL);
|
|
|
|
visitHero = new CHeroArea(pos.x+476, pos.y + 6, NULL);
|
2010-01-25 23:25:14 +02:00
|
|
|
|
2010-02-01 01:30:47 +02:00
|
|
|
for (int i=0; i<CREATURES_PER_TOWN;i++)
|
|
|
|
{//creatures info
|
|
|
|
creaGrowth.push_back(new HoverableArea());
|
|
|
|
creaGrowth[i]->pos = genRect(32, 32, pos.x+56+i*37, pos.y + 78);
|
2010-01-25 23:25:14 +02:00
|
|
|
|
2010-02-01 01:30:47 +02:00
|
|
|
creaCount.push_back(new CCreaPlace());
|
|
|
|
creaCount[i]->pos = genRect(32, 32, pos.x+409+i*37, pos.y + 78);
|
|
|
|
creaCount[i]->type = i;
|
2010-01-28 18:15:46 +02:00
|
|
|
}
|
2010-02-28 12:01:36 +02:00
|
|
|
hallArea = new LRClickableAreaOpenTown();
|
2010-02-01 01:30:47 +02:00
|
|
|
hallArea->pos = genRect(38, 38, pos.x+69, pos.y + 31);
|
2010-02-28 12:01:36 +02:00
|
|
|
hallArea->type = 2;
|
2010-01-25 23:25:14 +02:00
|
|
|
|
2010-02-28 12:01:36 +02:00
|
|
|
fortArea = new LRClickableAreaOpenTown();
|
2010-02-01 01:30:47 +02:00
|
|
|
fortArea->pos = genRect(38, 38, pos.x+111, pos.y + 31);
|
2010-02-28 12:01:36 +02:00
|
|
|
fortArea->type = 3;
|
2010-01-26 13:56:29 +02:00
|
|
|
|
2010-02-04 17:50:59 +02:00
|
|
|
townImage = new LRClickableAreaOpenTown();
|
2010-02-01 01:30:47 +02:00
|
|
|
townImage->pos = genRect(64, 58, pos.x+5, pos.y + 6);
|
2010-02-28 12:01:36 +02:00
|
|
|
townImage->type = 1;
|
2010-01-25 23:25:14 +02:00
|
|
|
|
2010-02-01 01:30:47 +02:00
|
|
|
incomeArea = new HoverableArea();
|
|
|
|
incomeArea->pos = genRect(42, 64, pos.x+154, pos.y + 31);
|
|
|
|
incomeArea->hoverText = CGI->generaltexth->allTexts[255];
|
2010-01-25 23:25:14 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CKingdomInterface::CTownItem::~CTownItem()
|
|
|
|
{
|
2010-02-01 01:30:47 +02:00
|
|
|
creaGrowth.clear();
|
|
|
|
creaCount.clear();
|
|
|
|
delete garr;
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
2010-01-31 14:10:13 +02:00
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
void CKingdomInterface::CTownItem::setTown(const CGTownInstance * newTown)
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
2010-02-01 01:30:47 +02:00
|
|
|
BLOCK_CAPTURING;
|
|
|
|
delete garr;
|
2010-01-30 21:08:26 +02:00
|
|
|
town = newTown;
|
2010-02-01 01:30:47 +02:00
|
|
|
if (!town)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
garr = NULL;
|
|
|
|
}
|
2010-08-12 18:54:25 +03:00
|
|
|
garr = new CGarrisonInt(pos.x+313,pos.y+3,4,Point(232,0),parent->slots->ourImages[parent->PicCount+2].bitmap,Point(313,2),town,town->visitingHero,true,true, true);
|
2010-02-01 01:30:47 +02:00
|
|
|
|
2010-07-22 03:32:45 +03:00
|
|
|
garrHero->hero = town->garrisonHero;
|
|
|
|
visitHero->hero = town->visitingHero;
|
2010-02-01 01:30:47 +02:00
|
|
|
|
|
|
|
for (int i=0; i<CREATURES_PER_TOWN;i++)
|
|
|
|
{
|
|
|
|
creaCount[i]->town = NULL;
|
|
|
|
|
|
|
|
int crid = -1;
|
|
|
|
|
|
|
|
if (vstd::contains(town->builtBuildings,30+i+CREATURES_PER_TOWN))
|
|
|
|
crid = town->town->upgradedCreatures[i];
|
|
|
|
else
|
|
|
|
crid = town->town->basicCreatures[i];
|
|
|
|
|
|
|
|
std::string descr=CGI->generaltexth->allTexts[588];
|
2010-05-02 21:20:26 +03:00
|
|
|
boost::algorithm::replace_first(descr,"%s",CGI->creh->creatures[crid]->namePl);
|
2010-02-01 01:30:47 +02:00
|
|
|
creaGrowth[i]->hoverText = descr;
|
|
|
|
|
|
|
|
descr=CGI->generaltexth->heroscrn[1];
|
2010-05-02 21:20:26 +03:00
|
|
|
boost::algorithm::replace_first(descr,"%s",CGI->creh->creatures[crid]->namePl);
|
2010-02-01 01:30:47 +02:00
|
|
|
creaCount[i]->hoverText = descr;
|
|
|
|
creaCount[i]->town = town;
|
|
|
|
}
|
|
|
|
|
|
|
|
townImage->hoverText = town->name;
|
2010-02-04 17:50:59 +02:00
|
|
|
townImage->town = town;
|
2010-02-28 12:01:36 +02:00
|
|
|
hallArea->town = town;
|
2010-02-01 01:30:47 +02:00
|
|
|
|
|
|
|
hallArea->hoverText = CGI->buildh->buildings[town->subID][10+town->hallLevel()]->Name();
|
|
|
|
if (town->hasFort())
|
2010-02-28 12:01:36 +02:00
|
|
|
{
|
2010-02-01 01:30:47 +02:00
|
|
|
fortArea->hoverText = CGI->buildh->buildings[town->subID][6+town->fortLevel()]->Name();
|
2010-02-28 12:01:36 +02:00
|
|
|
fortArea->town = town;
|
|
|
|
}
|
2010-02-01 01:30:47 +02:00
|
|
|
else
|
|
|
|
fortArea->hoverText = "";
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
2010-01-25 23:25:14 +02:00
|
|
|
|
|
|
|
void CKingdomInterface::CTownItem::activate()
|
|
|
|
{
|
2010-02-01 01:30:47 +02:00
|
|
|
if (!town)
|
|
|
|
return;
|
2010-02-04 17:50:59 +02:00
|
|
|
|
|
|
|
setTown(town);
|
2010-02-01 01:30:47 +02:00
|
|
|
hallArea->activate();
|
|
|
|
fortArea->activate();
|
|
|
|
incomeArea->activate();
|
|
|
|
townImage->activate();
|
|
|
|
|
2010-07-22 03:32:45 +03:00
|
|
|
garrHero->activate();
|
|
|
|
visitHero->activate();
|
2010-02-01 01:30:47 +02:00
|
|
|
|
|
|
|
for (int i=0; i<CREATURES_PER_TOWN;i++)
|
|
|
|
if (vstd::contains(town->builtBuildings,30+i))
|
|
|
|
{
|
|
|
|
creaGrowth[i]->activate();
|
|
|
|
creaCount [i]->activate();
|
|
|
|
}
|
2010-02-04 17:50:59 +02:00
|
|
|
garr->activate();
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CTownItem::deactivate()
|
|
|
|
{
|
2010-02-01 01:30:47 +02:00
|
|
|
if (!town)
|
|
|
|
return;
|
2010-02-04 17:50:59 +02:00
|
|
|
|
2010-02-01 01:30:47 +02:00
|
|
|
hallArea->deactivate();
|
|
|
|
fortArea->deactivate();
|
|
|
|
incomeArea->deactivate();
|
|
|
|
townImage->deactivate();
|
|
|
|
|
2010-07-22 03:32:45 +03:00
|
|
|
garrHero->deactivate();
|
|
|
|
visitHero->deactivate();
|
2010-02-01 01:30:47 +02:00
|
|
|
|
|
|
|
for (int i=0; i<CREATURES_PER_TOWN;i++)
|
2010-02-28 12:01:36 +02:00
|
|
|
if (creaCount[i]->active)
|
2010-02-01 01:30:47 +02:00
|
|
|
{
|
|
|
|
creaGrowth[i]->deactivate();
|
|
|
|
creaCount [i]->deactivate();
|
2010-02-28 12:01:36 +02:00
|
|
|
}
|
|
|
|
garr->deactivate();
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
2010-01-31 14:10:13 +02:00
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
void CKingdomInterface::CTownItem::showAll(SDL_Surface * to)
|
2010-01-25 23:25:14 +02:00
|
|
|
{
|
|
|
|
if (!town)
|
|
|
|
{//if NULL - print background & exit
|
2010-07-22 03:32:45 +03:00
|
|
|
blitAt(parent->slots->ourImages[numb % parent->PicCount].bitmap,pos.x,pos.y,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
return;
|
|
|
|
}//background
|
2010-07-22 03:32:45 +03:00
|
|
|
blitAt(parent->slots->ourImages[parent->PicCount+2].bitmap,pos.x,pos.y,to); garr->show(to);
|
2010-01-25 23:25:14 +02:00
|
|
|
//town pic/name
|
|
|
|
int townPic = town->subID*2;
|
|
|
|
if (!town->hasFort())
|
|
|
|
townPic += F_NUMBER*2;
|
|
|
|
if(town->builded >= MAX_BUILDING_PER_TURN)
|
|
|
|
townPic++;
|
|
|
|
blitAt(graphics->bigTownPic->ourImages[townPic].bitmap,pos.x+5,pos.y+6,to);
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printAt(town->name,pos.x+73,pos.y+8,FONT_SMALL,zwykly,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
//fort pic
|
|
|
|
townPic = town->fortLevel()-1;
|
|
|
|
if (townPic==-1) townPic = 3;
|
2010-07-22 03:32:45 +03:00
|
|
|
blitAt(parent->fort->ourImages[townPic].bitmap,pos.x+111,pos.y+31,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
//hall pic
|
|
|
|
townPic = town->hallLevel();
|
2010-07-22 03:32:45 +03:00
|
|
|
blitAt(parent->hall->ourImages[townPic].bitmap,pos.x+69,pos.y+31,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
//income pic
|
|
|
|
std::ostringstream oss;
|
|
|
|
oss << town->dailyIncome();
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printAtMiddle(oss.str(),pos.x+189,pos.y+61,FONT_SMALL,zwykly,to);
|
2010-02-04 17:50:59 +02:00
|
|
|
|
2010-07-06 05:10:26 +03:00
|
|
|
std::vector<std::string> toPrin = CMessage::breakText(CGI->generaltexth->allTexts[265]);
|
2010-02-04 17:50:59 +02:00
|
|
|
|
2010-07-06 05:10:26 +03:00
|
|
|
CSDL_Ext::printAt(toPrin[0], pos.x+4, pos.y+76, FONT_SMALL, tytulowy, to);
|
|
|
|
if(toPrin.size()!=1)
|
|
|
|
CSDL_Ext::printAt(toPrin[1], pos.x+4, pos.y+92, FONT_SMALL, tytulowy, to);
|
2010-02-04 17:50:59 +02:00
|
|
|
|
|
|
|
toPrin = CMessage::breakText(CGI->generaltexth->allTexts[266]);
|
|
|
|
|
2010-07-06 05:10:26 +03:00
|
|
|
CSDL_Ext::printAt(toPrin[0], pos.x+351, pos.y+76, FONT_SMALL, tytulowy, to);
|
|
|
|
if(toPrin.size()!=1)
|
|
|
|
CSDL_Ext::printAt(toPrin[1], pos.x+351, pos.y+92, FONT_SMALL, tytulowy, to);
|
2010-02-04 17:50:59 +02:00
|
|
|
|
2010-01-25 23:25:14 +02:00
|
|
|
for (int i=0; i<CREATURES_PER_TOWN;i++)
|
|
|
|
{//creatures info
|
|
|
|
int crid = -1;
|
|
|
|
int bid = 30+i;
|
|
|
|
if (!vstd::contains(town->builtBuildings,bid))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (vstd::contains(town->builtBuildings,bid+CREATURES_PER_TOWN))
|
|
|
|
{
|
|
|
|
crid = town->town->upgradedCreatures[i];
|
|
|
|
bid += CREATURES_PER_TOWN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
crid = town->town->basicCreatures[i];
|
|
|
|
//creature growth
|
|
|
|
blitAt(graphics->smallImgs[crid],pos.x+56+i*37,pos.y+78,to);
|
|
|
|
std::ostringstream oss;
|
|
|
|
oss << '+' << town->creatureGrowth(i);
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printTo(oss.str(),pos.x+87+i*37,pos.y+110,FONT_TINY,zwykly,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
//creature available
|
|
|
|
blitAt(graphics->smallImgs[crid],pos.x+409+i*37,pos.y+78,to);
|
|
|
|
std::ostringstream ostrs;
|
|
|
|
ostrs << town->creatures[i].first;
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printTo(ostrs.str(),pos.x+440+i*37,pos.y+110,FONT_TINY,zwykly,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
2010-07-22 03:32:45 +03:00
|
|
|
|
|
|
|
garrHero->showAll(to);
|
|
|
|
visitHero->showAll(to);
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
CKingdomInterface::CHeroItem::CHeroItem(int num, CKingdomInterface * Owner)
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
|
recActions = DISPOSE | SHARE_POS;
|
|
|
|
defActions = SHARE_POS;
|
2010-07-22 03:32:45 +03:00
|
|
|
parent = Owner;
|
2010-01-25 23:25:14 +02:00
|
|
|
numb = num;
|
2010-01-28 18:15:46 +02:00
|
|
|
pos.x += 23;
|
2010-02-01 01:30:47 +02:00
|
|
|
pos.y += 25+num*116;
|
2010-01-25 23:25:14 +02:00
|
|
|
pos.w = 702;
|
|
|
|
pos.h = 114;
|
2010-01-31 14:10:13 +02:00
|
|
|
hero = NULL;
|
2010-01-30 21:08:26 +02:00
|
|
|
garr = NULL;
|
2010-01-31 14:10:13 +02:00
|
|
|
artGroup = 0;
|
|
|
|
backpackPos = 0;
|
|
|
|
artButtons = new CHighlightableButtonsGroup(0);
|
|
|
|
for (size_t it = 0; it<3; it++)
|
|
|
|
{
|
|
|
|
artButtons->addButton(boost::assign::map_list_of(0,CGI->generaltexth->overview[13+it]),
|
|
|
|
CGI->generaltexth->overview[8+it], "OVBUTN3.DEF",364+it*112, 46, it);
|
2010-02-06 15:27:58 +02:00
|
|
|
std::string str = CGI->generaltexth->overview[8+it];
|
|
|
|
str = str.substr(str.find_first_of("{")+1, str.find_first_of("}")-str.find_first_of("{"));
|
2010-01-30 21:08:26 +02:00
|
|
|
artButtons->buttons[it]->addTextOverlay(str, FONT_SMALL, tytulowy);
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
|
|
|
artButtons->onChange = boost::bind(&CKingdomInterface::CHeroItem::onArtChange, this, _1);
|
|
|
|
artButtons->select(0,0);
|
|
|
|
|
|
|
|
artLeft = new AdventureMapButton("", "", boost::bind
|
2010-01-30 21:08:26 +02:00
|
|
|
(&CKingdomInterface::CHeroItem::scrollArts,this,-1), 269, 66, "hsbtns3.def", SDLK_LEFT);
|
2010-01-31 14:10:13 +02:00
|
|
|
artRight = new AdventureMapButton("", "", boost::bind
|
|
|
|
(&CKingdomInterface::CHeroItem::scrollArts,this,+1), 675, 66, "hsbtns5.def", SDLK_RIGHT);
|
|
|
|
|
2010-07-22 03:32:45 +03:00
|
|
|
portrait = new CHeroArea(5,5,NULL);
|
2010-01-30 21:08:26 +02:00
|
|
|
char bufor[400];
|
2010-02-01 01:30:47 +02:00
|
|
|
for(int i=0; i<PRIMARY_SKILLS; i++)
|
2010-01-30 21:08:26 +02:00
|
|
|
{
|
|
|
|
primarySkills.push_back(new LRClickableAreaWTextComp());
|
|
|
|
primarySkills[i]->pos = genRect(45, 32, pos.x+77 + 36*i, pos.y+26);
|
|
|
|
primarySkills[i]->text = CGI->generaltexth->arraytxt[2+i];
|
|
|
|
primarySkills[i]->type = i;
|
2010-01-31 14:10:13 +02:00
|
|
|
primarySkills[i]->baseType = 0;
|
2010-01-30 21:08:26 +02:00
|
|
|
sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), CGI->generaltexth->primarySkillNames[i].c_str());
|
|
|
|
primarySkills[i]->hoverText = std::string(bufor);
|
2010-01-31 14:10:13 +02:00
|
|
|
};
|
2010-01-30 21:08:26 +02:00
|
|
|
experience = new LRClickableAreaWText();
|
2010-02-01 01:30:47 +02:00
|
|
|
experience->pos = genRect(33, 49, pos.x+322, pos.y+5);
|
2010-01-30 21:08:26 +02:00
|
|
|
experience->hoverText = CGI->generaltexth->heroscrn[9];
|
|
|
|
|
2010-07-13 08:25:40 +03:00
|
|
|
morale = new MoraleLuckBox(true);
|
2010-01-30 21:08:26 +02:00
|
|
|
morale->pos = genRect(20,32,pos.x+221,pos.y+52);
|
|
|
|
|
2010-07-13 08:25:40 +03:00
|
|
|
luck = new MoraleLuckBox(false);
|
2010-01-30 21:08:26 +02:00
|
|
|
luck->pos = genRect(20,32,pos.x+221,pos.y+28);
|
|
|
|
|
|
|
|
spellPoints = new LRClickableAreaWText();
|
2010-02-01 01:30:47 +02:00
|
|
|
spellPoints->pos = genRect(33, 49, pos.x+270, pos.y+5);
|
2010-01-31 14:10:13 +02:00
|
|
|
spellPoints->hoverText = CGI->generaltexth->heroscrn[22];
|
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
speciality = new LRClickableAreaWText();
|
2010-02-01 01:30:47 +02:00
|
|
|
speciality->pos = genRect(32, 32, pos.x+374, pos.y+5);
|
2010-01-31 14:10:13 +02:00
|
|
|
speciality->hoverText = CGI->generaltexth->heroscrn[27];
|
2010-01-30 21:08:26 +02:00
|
|
|
|
2010-02-01 01:30:47 +02:00
|
|
|
for(int i=0; i<SKILL_PER_HERO; ++i)
|
2010-01-30 21:08:26 +02:00
|
|
|
{
|
2010-01-31 14:10:13 +02:00
|
|
|
secondarySkills.push_back(new LRClickableAreaWTextComp());
|
2010-02-01 01:30:47 +02:00
|
|
|
secondarySkills[i]->pos = genRect(32, 32, pos.x+410+i*37, pos.y+5);
|
2010-01-30 21:08:26 +02:00
|
|
|
secondarySkills[i]->baseType = 1;
|
2010-01-31 14:10:13 +02:00
|
|
|
};
|
2011-01-01 22:26:39 +02:00
|
|
|
/*
|
2010-01-31 14:10:13 +02:00
|
|
|
for (int i=0; i<18;i++)
|
|
|
|
{
|
|
|
|
artifacts.push_back(new CArtPlace(this));
|
|
|
|
artifacts[i]->pos = genRect(44, 44, pos.x+268+(i%9)*48, pos.y+66);
|
|
|
|
artifacts[i]->baseType = SComponent::artifact;
|
|
|
|
};
|
|
|
|
|
|
|
|
for (int i=0; i<8;i++)
|
|
|
|
{
|
|
|
|
backpack.push_back(new CArtPlace(this));
|
|
|
|
backpack[i]->pos = genRect(44, 44, pos.x+293+(i%9)*48, pos.y+66);
|
|
|
|
backpack[i]->baseType = SComponent::artifact;
|
2011-01-01 22:26:39 +02:00
|
|
|
};*/
|
2010-01-31 14:10:13 +02:00
|
|
|
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CKingdomInterface::CHeroItem::~CHeroItem()
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
2010-02-01 01:30:47 +02:00
|
|
|
delete garr;
|
2010-01-31 14:10:13 +02:00
|
|
|
delete artButtons;
|
2010-02-01 01:30:47 +02:00
|
|
|
primarySkills.clear();
|
|
|
|
secondarySkills.clear();
|
|
|
|
artifacts.clear();
|
|
|
|
backpack.clear();
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CHeroItem::setHero(const CGHeroInstance * newHero)
|
|
|
|
{
|
|
|
|
BLOCK_CAPTURING;
|
|
|
|
delete garr;
|
|
|
|
hero = newHero;
|
|
|
|
if (!hero)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
garr = NULL;
|
|
|
|
}
|
2010-02-01 01:30:47 +02:00
|
|
|
char bufor[4000];
|
2010-01-31 14:10:13 +02:00
|
|
|
artLeft->block(hero->artifacts.size() <= 8);
|
|
|
|
artRight->block(hero->artifacts.size() <= 8);
|
2010-07-22 03:32:45 +03:00
|
|
|
garr = new CGarrisonInt(pos.x+6, pos.y+78, 4, Point(), parent->slots->ourImages[parent->PicCount].bitmap,
|
2010-08-13 13:46:08 +03:00
|
|
|
Point(6,78), hero, NULL, true, true, true);
|
2010-01-31 14:10:13 +02:00
|
|
|
|
|
|
|
for (int i=0; i<artifacts.size(); i++)
|
|
|
|
{
|
2010-11-10 02:06:25 +02:00
|
|
|
artifacts[i]->type = hero->getArtAtPos(i)->id;
|
2010-02-28 12:01:36 +02:00
|
|
|
if (artifacts[i]->type<0 || artifacts[i]->type == 145 )
|
2010-01-31 14:10:13 +02:00
|
|
|
artifacts[i]->hoverText = CGI->generaltexth->heroscrn[11];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
artifacts[i]->text = CGI->generaltexth->artifDescriptions[artifacts[i]->type];
|
2010-06-26 19:02:10 +03:00
|
|
|
artifacts[i]->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1].c_str()) % CGI->arth->artifacts[artifacts[i]->type]->Name());
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i=0; i<backpack.size(); i++)
|
|
|
|
{
|
2010-11-10 02:06:25 +02:00
|
|
|
backpack[i]->type = hero->getArtAtPos(19+i)->id;
|
2010-01-31 14:10:13 +02:00
|
|
|
if (backpack[i]->type<0)
|
|
|
|
backpack[i]->hoverText ="";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
backpack[i]->text = CGI->generaltexth->artifDescriptions[backpack[i]->type];
|
2010-06-26 19:02:10 +03:00
|
|
|
backpack[i]->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1].c_str()) % CGI->arth->artifacts[backpack[i]->type]->Name());
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-22 03:32:45 +03:00
|
|
|
//sprintf(bufor, CGI->generaltexth->allTexts[15].c_str(), hero->name.c_str(), hero->type->heroClass->name.c_str());
|
|
|
|
//portrait->hoverText = std::string(bufor);
|
2010-02-04 17:50:59 +02:00
|
|
|
portrait->hero = hero;
|
2010-01-30 21:08:26 +02:00
|
|
|
|
2010-02-01 01:30:47 +02:00
|
|
|
speciality->text = CGI->generaltexth->hTxts[hero->subID].longBonus;
|
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
//primary skills
|
|
|
|
for(size_t g=0; g<primarySkills.size(); ++g)
|
2010-07-13 08:25:40 +03:00
|
|
|
primarySkills[g]->bonusValue = hero->getPrimSkillLevel(g);
|
2010-01-30 21:08:26 +02:00
|
|
|
|
2010-01-31 14:10:13 +02:00
|
|
|
//secondary skills
|
2010-01-30 21:08:26 +02:00
|
|
|
for(size_t g=0; g<std::min(secondarySkills.size(),hero->secSkills.size()); ++g)
|
|
|
|
{
|
2010-02-28 12:01:36 +02:00
|
|
|
int skill = hero->secSkills[g].first,
|
2010-01-31 14:10:13 +02:00
|
|
|
level = hero->secSkills[g].second;
|
2010-01-30 21:08:26 +02:00
|
|
|
secondarySkills[g]->type = skill;
|
2010-07-13 08:25:40 +03:00
|
|
|
secondarySkills[g]->bonusValue = level;
|
2010-01-30 21:08:26 +02:00
|
|
|
secondarySkills[g]->text = CGI->generaltexth->skillInfoTexts[skill][level-1];
|
|
|
|
sprintf(bufor, CGI->generaltexth->heroscrn[21].c_str(), CGI->generaltexth->levels[level-1].c_str(), CGI->generaltexth->skillName[skill].c_str());
|
|
|
|
secondarySkills[g]->hoverText = std::string(bufor);
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
2010-01-30 21:08:26 +02:00
|
|
|
//experience
|
|
|
|
experience->text = CGI->generaltexth->allTexts[2].c_str();
|
|
|
|
boost::replace_first(experience->text, "%d", boost::lexical_cast<std::string>(hero->level));
|
|
|
|
boost::replace_first(experience->text, "%d", boost::lexical_cast<std::string>(CGI->heroh->reqExp(hero->level+1)));
|
|
|
|
boost::replace_first(experience->text, "%d", boost::lexical_cast<std::string>(hero->exp));
|
|
|
|
|
2010-01-31 14:10:13 +02:00
|
|
|
//spell points
|
2010-01-30 21:08:26 +02:00
|
|
|
sprintf(bufor, CGI->generaltexth->allTexts[205].c_str(), hero->name.c_str(), hero->mana, hero->manaLimit());
|
|
|
|
spellPoints->text = std::string(bufor);
|
|
|
|
|
2010-02-28 12:01:36 +02:00
|
|
|
//setting morale and luck
|
2010-07-13 08:25:40 +03:00
|
|
|
morale->set(hero);
|
|
|
|
luck->set(hero);
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CHeroItem::scrollArts(int move)
|
|
|
|
{
|
|
|
|
backpackPos = ( backpackPos + move + hero->artifacts.size()) % hero->artifacts.size();
|
|
|
|
for (int i=0; i<backpack.size(); i++)
|
|
|
|
{
|
2010-11-10 02:06:25 +02:00
|
|
|
backpack[i]->type = hero->getArtAtPos(19+(backpackPos + i)%hero->artifacts.size())->id;
|
2010-01-31 14:10:13 +02:00
|
|
|
if (backpack[i]->type<0)
|
|
|
|
backpack[i]->hoverText ="";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
backpack[i]->text = CGI->generaltexth->artifDescriptions[backpack[i]->type];
|
2010-06-26 19:02:10 +03:00
|
|
|
backpack[i]->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1].c_str()) % CGI->arth->artifacts[backpack[i]->type]->Name());
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
|
|
|
}
|
2010-02-04 17:50:59 +02:00
|
|
|
showAll(screen2);
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
void CKingdomInterface::CHeroItem::showAll(SDL_Surface * to)
|
2010-01-25 23:25:14 +02:00
|
|
|
{
|
|
|
|
if (!hero)
|
|
|
|
{//if we have no hero for this slot - print background & exit
|
2010-07-22 03:32:45 +03:00
|
|
|
blitAt(parent->slots->ourImages[numb % parent->PicCount].bitmap,pos.x,pos.y,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
return;
|
|
|
|
}//print background, different for arts view/backpack mode
|
2010-07-22 03:32:45 +03:00
|
|
|
blitAt(parent->slots->ourImages[(artGroup!=2)?parent->PicCount:(parent->PicCount+1)].bitmap,pos.x,pos.y,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
//text "Artifacts"
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[2],pos.x+320,pos.y+55,FONT_SMALL,zwykly,to);
|
2010-07-22 03:32:45 +03:00
|
|
|
portrait->showAll(to);
|
2010-01-31 14:10:13 +02:00
|
|
|
|
|
|
|
garr->show(to);
|
2010-01-30 21:08:26 +02:00
|
|
|
//hero name
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printAt(hero->name,pos.x+73,pos.y+7,FONT_SMALL,zwykly,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
for (int i = 0; i<6; i++)
|
|
|
|
{//primary skills, mana and exp. pics
|
|
|
|
blitAt(graphics->pskillst->ourImages[i].bitmap,(i<4)?(pos.x+78+36*i):(pos.x+539-52*i),
|
|
|
|
(i<4)?(pos.y+26):(pos.y+6),to);
|
|
|
|
if (i>3) continue;//primary skills text
|
|
|
|
std::ostringstream str;
|
2010-05-02 21:20:26 +03:00
|
|
|
str << (hero->getPrimSkillLevel(i));
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printAtMiddle(str.str(),pos.x+94+36*i,pos.y+66,FONT_SMALL,zwykly,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
{//luck and morale pics, experience and mana text
|
2010-05-02 21:20:26 +03:00
|
|
|
blitAt(graphics->luck30->ourImages[hero->LuckVal()+3].bitmap,pos.x+222,pos.y+30,to);
|
|
|
|
blitAt(graphics->morale30->ourImages[hero->MoraleVal()+3].bitmap,pos.x+222,pos.y+54,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
std::ostringstream str;
|
|
|
|
str << (hero->exp);
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printAtMiddle(str.str(),(pos.x+348),(pos.y+31),FONT_TINY,zwykly,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
std::ostringstream strnew;
|
|
|
|
strnew << (hero->mana)<<"/"<<(hero->manaLimit());
|
2010-02-02 18:24:53 +02:00
|
|
|
CSDL_Ext::printAtMiddle(strnew.str(),(pos.x+295),(pos.y+30),FONT_TINY,zwykly,to);
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
//hero speciality
|
2010-01-26 13:56:29 +02:00
|
|
|
blitAt(graphics->un32->ourImages[hero->subID].bitmap, pos.x+375, pos.y+6, to);
|
2010-01-25 23:25:14 +02:00
|
|
|
|
|
|
|
for(int i=0; i<hero->secSkills.size(); i++)
|
|
|
|
{//secondary skills
|
|
|
|
int skill = hero->secSkills[i].first,
|
2010-01-26 13:56:29 +02:00
|
|
|
level = hero->secSkills[i].second;
|
2010-01-25 23:25:14 +02:00
|
|
|
blitAt(graphics->abils32->ourImages[skill*3+level+2].bitmap,pos.x+411+i*36,pos.y+6,to);
|
|
|
|
}
|
2010-01-31 14:10:13 +02:00
|
|
|
|
|
|
|
artButtons->show(to);
|
2010-01-25 23:25:14 +02:00
|
|
|
|
|
|
|
int iter=0;
|
|
|
|
switch (artGroup)
|
|
|
|
{//arts
|
|
|
|
case 1:iter = 9;//misc. arts, spellbook, war machines
|
|
|
|
case 0://equipped arts
|
2011-01-01 22:26:39 +02:00
|
|
|
/*for (int i = iter ; i<iter+9;i++)
|
2010-01-25 23:25:14 +02:00
|
|
|
{
|
2010-11-10 02:06:25 +02:00
|
|
|
int artID = hero->getArtAtPos(i)->id;
|
2010-01-25 23:25:14 +02:00
|
|
|
if (artID>=0)
|
|
|
|
blitAt(graphics->artDefs->ourImages[artID].bitmap,pos.x+268+48*(i%9),pos.y+66,to);
|
2011-01-01 22:26:39 +02:00
|
|
|
}*/
|
2010-01-25 23:25:14 +02:00
|
|
|
break;
|
2010-01-31 14:10:13 +02:00
|
|
|
case 2:
|
|
|
|
artLeft->show(to);
|
|
|
|
artRight->show(to);
|
|
|
|
int max = hero->artifacts.size();
|
|
|
|
iter = std::min(8, max);
|
2011-01-01 22:26:39 +02:00
|
|
|
/*for (size_t it = 0 ; it<iter;it++)
|
2010-11-10 02:06:25 +02:00
|
|
|
blitAt(graphics->artDefs->ourImages[hero->artifacts[(it+backpackPos)%max]->id].bitmap,pos.x+293+48*it,pos.y+66,to);
|
2011-01-01 22:26:39 +02:00
|
|
|
*/break;
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
2010-01-30 21:08:26 +02:00
|
|
|
show(to);
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
2010-01-25 23:25:14 +02:00
|
|
|
|
|
|
|
void CKingdomInterface::CHeroItem::onArtChange(int newstate)
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
|
|
|
if (!hero)
|
|
|
|
return;
|
|
|
|
deactivate();
|
|
|
|
artGroup = newstate;
|
|
|
|
activate();
|
2010-02-04 17:50:59 +02:00
|
|
|
showAll(screen2);
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CHeroItem::activate()
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
2010-02-04 17:50:59 +02:00
|
|
|
setHero(hero);
|
2010-01-31 14:10:13 +02:00
|
|
|
if (!hero)
|
|
|
|
return;
|
|
|
|
artButtons->activate();
|
2011-01-01 22:26:39 +02:00
|
|
|
garr->activate();/*
|
2010-01-31 14:10:13 +02:00
|
|
|
if ( artGroup == 2 )
|
|
|
|
{
|
|
|
|
artLeft->activate();
|
|
|
|
artRight->activate();
|
|
|
|
for (size_t i=0; i<8;i++)
|
|
|
|
backpack[i]->activate();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (size_t i=artGroup*9; i<9+artGroup*9;i++)
|
|
|
|
artifacts[i]->activate();
|
2011-01-01 22:26:39 +02:00
|
|
|
}*/
|
2010-01-31 14:10:13 +02:00
|
|
|
portrait->activate();
|
|
|
|
experience->activate();
|
|
|
|
morale->activate();
|
|
|
|
luck->activate();
|
|
|
|
spellPoints->activate();
|
|
|
|
speciality->activate();
|
|
|
|
|
|
|
|
for (size_t i=0; i<primarySkills.size();i++)
|
|
|
|
primarySkills[i]->activate();
|
|
|
|
|
|
|
|
for (size_t i=0; i<std::min(secondarySkills.size(),hero->secSkills.size());i++)
|
|
|
|
secondarySkills[i]->activate();
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CHeroItem::deactivate()
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
|
|
|
if (!hero)
|
|
|
|
return;
|
|
|
|
artButtons->deactivate();
|
2011-01-01 22:26:39 +02:00
|
|
|
garr->deactivate();/*
|
2010-01-31 14:10:13 +02:00
|
|
|
if ( artGroup == 2 )
|
|
|
|
{
|
|
|
|
artLeft->deactivate();
|
|
|
|
artRight->deactivate();
|
|
|
|
for (size_t i=0; i<8;i++)
|
|
|
|
backpack[i]->deactivate();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (size_t i=artGroup*9; i<9+artGroup*9;i++)
|
|
|
|
artifacts[i]->deactivate();
|
2011-01-01 22:26:39 +02:00
|
|
|
}*/
|
2010-01-31 14:10:13 +02:00
|
|
|
|
|
|
|
portrait->deactivate();
|
|
|
|
experience->deactivate();
|
|
|
|
morale->deactivate();
|
|
|
|
luck->deactivate();
|
|
|
|
spellPoints->deactivate();
|
|
|
|
speciality->deactivate();
|
|
|
|
for (size_t i=0; i<primarySkills.size();i++)
|
|
|
|
primarySkills[i]->deactivate();
|
|
|
|
|
|
|
|
for (size_t i=0; i<std::min(secondarySkills.size(),hero->secSkills.size());i++)
|
|
|
|
secondarySkills[i]->deactivate();
|
|
|
|
}
|
|
|
|
|
2010-01-30 21:08:26 +02:00
|
|
|
CKingdomInterface::CHeroItem::CArtPlace::CArtPlace(CHeroItem * owner)
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
2010-07-22 03:32:45 +03:00
|
|
|
parent = owner;
|
2010-01-31 14:10:13 +02:00
|
|
|
used = LCLICK | RCLICK | HOVER;
|
2010-01-30 21:08:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CHeroItem::CArtPlace::activate()
|
2010-01-25 23:25:14 +02:00
|
|
|
{
|
2010-01-30 21:08:26 +02:00
|
|
|
LRClickableAreaWTextComp::activate();
|
2010-01-25 23:25:14 +02:00
|
|
|
}
|
2010-01-30 21:08:26 +02:00
|
|
|
|
|
|
|
void CKingdomInterface::CHeroItem::CArtPlace::clickLeft(tribool down, bool previousState)
|
2010-02-01 01:30:47 +02:00
|
|
|
{
|
2010-02-28 12:01:36 +02:00
|
|
|
if (!down && previousState && type>=0 && type < 145)
|
|
|
|
{tlog1<<type;
|
2010-01-30 21:08:26 +02:00
|
|
|
if(type == 0)
|
2010-01-31 14:10:13 +02:00
|
|
|
{
|
2010-07-22 03:32:45 +03:00
|
|
|
CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), parent->hero, LOCPLINT, false);
|
2010-01-30 21:08:26 +02:00
|
|
|
GH.pushInt(spellWindow);
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
2010-01-30 21:08:26 +02:00
|
|
|
else
|
|
|
|
LRClickableAreaWTextComp::clickLeft(down,previousState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CHeroItem::CArtPlace::clickRight(tribool down, bool previousState)
|
|
|
|
{
|
2010-02-28 12:01:36 +02:00
|
|
|
if (type>=0 && type < 145)
|
2010-01-30 21:08:26 +02:00
|
|
|
LRClickableAreaWTextComp::clickRight(down, previousState);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CHeroItem::CArtPlace::deactivate()
|
|
|
|
{
|
|
|
|
LRClickableAreaWTextComp::deactivate();
|
2010-01-31 14:10:13 +02:00
|
|
|
}
|
2010-02-01 01:30:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
CKingdomInterface::CTownItem::CCreaPlace::CCreaPlace()
|
|
|
|
{
|
|
|
|
town = NULL;
|
|
|
|
used = LCLICK | RCLICK | HOVER;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CTownItem::CCreaPlace::activate()
|
|
|
|
{
|
|
|
|
LRClickableAreaWTextComp::activate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CTownItem::CCreaPlace::clickLeft(tribool down, bool previousState)
|
|
|
|
{
|
|
|
|
if (!down && previousState && town)
|
|
|
|
{
|
|
|
|
GH.pushInt (new CRecruitmentWindow(town, type, town, boost::bind
|
2010-07-10 19:50:23 +03:00
|
|
|
(&CCallback::recruitCreatures,LOCPLINT->cb,town,_1,_2, type)));
|
2010-02-01 01:30:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CTownItem::CCreaPlace::clickRight(tribool down, bool previousState)
|
|
|
|
{
|
2010-02-04 17:50:59 +02:00
|
|
|
if (down && town)
|
|
|
|
{
|
|
|
|
int crid;
|
|
|
|
if (town->builtBuildings.find(30+type+CREATURES_PER_TOWN)!=town->builtBuildings.end())
|
|
|
|
crid = town->town->upgradedCreatures[type];
|
|
|
|
else
|
|
|
|
crid = town->town->basicCreatures[type];
|
2010-05-02 21:20:26 +03:00
|
|
|
GH.pushInt(new CCreInfoWindow(crid, 0, town->creatures[type].first));
|
2010-02-04 17:50:59 +02:00
|
|
|
}
|
2010-02-01 01:30:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CKingdomInterface::CTownItem::CCreaPlace::deactivate()
|
|
|
|
{
|
|
|
|
LRClickableAreaWTextComp::deactivate();
|
|
|
|
}
|