|
@@ -1,39 +1,22 @@
|
|
|
#include "CKingdomInterface.h"
|
|
|
-#include "AdventureMapButton.h"
|
|
|
-#include "CAdvmapInterface.h"
|
|
|
-#include "CPlayerInterface.h"
|
|
|
-#include "CCreatureWindow.h"
|
|
|
-#include "../CCallback.h"
|
|
|
-#include "../global.h"
|
|
|
-#include "CConfigHandler.h"
|
|
|
-#include "CGameInfo.h"
|
|
|
-#include "CHeroWindow.h"
|
|
|
-#include "CSpellWindow.h"
|
|
|
-#include "CMessage.h"
|
|
|
-#include "SDL_Extensions.h"
|
|
|
-#include "Graphics.h"
|
|
|
-#include "../lib/CArtHandler.h"
|
|
|
-#include "../lib/CBuildingHandler.h"
|
|
|
-#include "CDefHandler.h"
|
|
|
-#include "../lib/CHeroHandler.h"
|
|
|
-#include "../lib/CGeneralTextHandler.h"
|
|
|
-#include "../lib/CObjectHandler.h"
|
|
|
-#include "../lib/CTownHandler.h"
|
|
|
-#include "../lib/CCreatureHandler.h"
|
|
|
-#include "../lib/CHeroHandler.h"
|
|
|
-#include "../lib/map.h"
|
|
|
-#include "../lib/NetPacks.h"
|
|
|
+
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
|
|
-#include <boost/assign/std/vector.hpp>
|
|
|
-#include <boost/assign/list_of.hpp>
|
|
|
+#include <boost/bind.hpp>
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
+#include <boost/foreach.hpp>
|
|
|
#include <boost/format.hpp>
|
|
|
-#include <sstream>
|
|
|
-#include <SDL.h>
|
|
|
-#include "CBitmapHandler.h"
|
|
|
|
|
|
-using namespace boost::assign;
|
|
|
-using namespace CSDL_Ext;
|
|
|
+#include "../CCallback.h"
|
|
|
+#include "../lib/CCreatureHandler.h" //creatures name for objects list
|
|
|
+#include "../lib/CGeneralTextHandler.h"
|
|
|
+#include "../lib/CObjectHandler.h" //Hero/Town objects
|
|
|
+#include "AdventureMapButton.h"
|
|
|
+#include "CAnimation.h" //CAnimImage
|
|
|
+#include "CAdvmapInterface.h" //CResDataBar
|
|
|
+#include "CCastleInterface.h" //various town-specific classes
|
|
|
+#include "CConfigHandler.h"
|
|
|
+#include "CGameInfo.h"
|
|
|
+#include "CPlayerInterface.h" //LOCPLINT
|
|
|
|
|
|
/*
|
|
|
* CKingdomInterface.cpp, part of VCMI engine
|
|
@@ -45,1021 +28,1191 @@ using namespace CSDL_Ext;
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
-#define ADVOPT (conf.go()->ac)
|
|
|
+extern SDL_Surface *screenBuf;
|
|
|
|
|
|
-CKingdomInterface::CKingdomInterface()
|
|
|
+InfoBox::InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data):
|
|
|
+ size(Size),
|
|
|
+ infoPos(Pos),
|
|
|
+ data(Data),
|
|
|
+ value(NULL),
|
|
|
+ name(NULL)
|
|
|
{
|
|
|
+ assert(data);
|
|
|
+ used = LCLICK | RCLICK;
|
|
|
+ EFonts font = (size < SIZE_MEDIUM)? FONT_SMALL: FONT_MEDIUM;
|
|
|
+
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
- defActions = SHARE_POS | DISPOSE;
|
|
|
- PicCount = ADVOPT.overviewPics;
|
|
|
- size = ADVOPT.overviewSize;
|
|
|
- pos.x = screen->w/2 - 400;
|
|
|
- pos.y = screen->h/2 - (68+58*size);
|
|
|
- showHarrisoned = false;//set to true if you want to see garrisoned heroes
|
|
|
- heroPos = townPos = objPos = state = 0;
|
|
|
-
|
|
|
- bg = BitmapHandler::loadBitmap(ADVOPT.overviewBg);
|
|
|
- graphics->blueToPlayersAdv(bg, LOCPLINT->playerID);
|
|
|
-
|
|
|
- mines = CDefHandler::giveDefEss("OVMINES.DEF");
|
|
|
- title = CDefHandler::giveDefEss("OVTITLE.DEF");
|
|
|
- hall = CDefHandler::giveDefEss("ITMTL.DEF");
|
|
|
- fort = CDefHandler::giveDefEss("ITMCL.DEF");
|
|
|
- objPics = CDefHandler::giveDefEss("FLAGPORT.DEF");
|
|
|
- slots = CDefHandler::giveDefEss("OVSLOT.DEF");
|
|
|
-
|
|
|
- toHeroes = new AdventureMapButton (CGI->generaltexth->overview[11],"",
|
|
|
- boost::bind(&CKingdomInterface::listToHeroes,this),748,28+size*116,"OVBUTN1.DEF", SDLK_h);
|
|
|
- toHeroes->block(2);
|
|
|
-
|
|
|
- toTowns = new AdventureMapButton (CGI->generaltexth->overview[12],"",
|
|
|
- boost::bind(&CKingdomInterface::listToTowns,this),748,64+size*116,"OVBUTN6.DEF", SDLK_t);
|
|
|
- toTowns->block(0);
|
|
|
-
|
|
|
- exit = new AdventureMapButton (CGI->generaltexth->allTexts[600],"",
|
|
|
- boost::bind(&CKingdomInterface::close,this),748,99+size*116,"OVBUTN1.DEF", SDLK_RETURN);
|
|
|
- exit->setOffset(3);
|
|
|
-
|
|
|
- statusbar = new CStatusBar(7, 91+size*116,"TSTATBAR.bmp",732);
|
|
|
- resdatabar = new CResDataBar("KRESBAR.bmp",pos.x+3,pos.y+111+size*116,32,2,76,76);
|
|
|
-
|
|
|
- for(size_t i=0;i<size;i++)//creating empty hero/town lists for input
|
|
|
- {
|
|
|
- heroes.push_back( new CHeroItem(i,this));
|
|
|
- towns.push_back( new CTownItem(i,this));
|
|
|
- }
|
|
|
+ pos+=position;
|
|
|
|
|
|
- slider = new CSlider(4, 4, size*116+19, boost::bind (&CKingdomInterface::sliderMoved, this, _1),
|
|
|
- size, LOCPLINT->cb->howManyHeroes(showHarrisoned), 0, false, 0);
|
|
|
+ image = new CAnimImage(data->getImageName(size), data->getImageIndex());
|
|
|
+ pos = image->pos;
|
|
|
|
|
|
- //creating objects list
|
|
|
- ObjTop = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,0),
|
|
|
- 733,4,"OVBUTN4.DEF");
|
|
|
+ if (infoPos == POS_CORNER)
|
|
|
+ value = new CLabel(pos.w, pos.h, font, BOTTOMRIGHT, zwykly, data->getValueText());
|
|
|
|
|
|
- ObjUp = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,1),
|
|
|
- 733,24,"OVBUTN4.DEF");
|
|
|
- ObjUp->setOffset(4);
|
|
|
+ if (infoPos == POS_INSIDE)
|
|
|
+ value = new CLabel(pos.w/2, pos.h-6, font, CENTER, zwykly, data->getValueText());
|
|
|
|
|
|
- ObjDown = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,2),
|
|
|
- 733,size*116-18,"OVBUTN4.DEF");
|
|
|
- ObjDown->setOffset(6);
|
|
|
+ if (infoPos == POS_UP_DOWN || infoPos == POS_DOWN)
|
|
|
+ value = new CLabel(pos.w/2, pos.h+8, font, CENTER, zwykly, data->getValueText());
|
|
|
|
|
|
- ObjBottom = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,3),
|
|
|
- 733,size*116+2,"OVBUTN4.DEF");
|
|
|
- ObjBottom->setOffset(2);
|
|
|
+ if (infoPos == POS_UP_DOWN)
|
|
|
+ name = new CLabel(pos.w/2, -12, font, CENTER, zwykly, data->getNameText());
|
|
|
|
|
|
- for (size_t i=0; i<8; i++)
|
|
|
+ if (infoPos == POS_RIGHT)
|
|
|
{
|
|
|
- incomes.push_back(new HoverableArea());//bottom panel with mines
|
|
|
- incomes[i]->pos = genRect(57,68,pos.x+20+i*80,pos.y+31+size*116);
|
|
|
- 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
|
|
|
-
|
|
|
- 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
|
|
|
-
|
|
|
- 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)
|
|
|
- {
|
|
|
- const CGObjectInstance* obj = myObjects[i];//current object
|
|
|
- if (obj)
|
|
|
- {
|
|
|
- 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
|
|
|
- {
|
|
|
- objList[obj->subID].first += 1;
|
|
|
- objList[obj->subID].second = & CGI->creh->creatures[CGI->objh->cregens[obj->subID]]->namePl;
|
|
|
- }
|
|
|
- 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;
|
|
|
- }
|
|
|
- else if ( obj->ID == 53 )
|
|
|
- incomesVal[obj->subID]+=1;
|
|
|
- }
|
|
|
+ name = new CLabel(pos.w+6, 6, font, TOPLEFT, zwykly, data->getNameText());
|
|
|
+ value = new CLabel(pos.w+6, pos.h-16, font, TOPLEFT, zwykly, data->getValueText());
|
|
|
}
|
|
|
+ pos = image->pos;
|
|
|
+ if (name)
|
|
|
+ pos = pos | name->pos;
|
|
|
+ if (value)
|
|
|
+ pos = pos | value->pos;
|
|
|
+
|
|
|
+ hover = new HoverableArea;
|
|
|
+ hover->hoverText = data->getHoverText();
|
|
|
+ hover->pos = pos;
|
|
|
+}
|
|
|
|
|
|
- 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);
|
|
|
- }
|
|
|
+InfoBox::~InfoBox()
|
|
|
+{
|
|
|
+ delete data;
|
|
|
+}
|
|
|
|
|
|
- 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++)
|
|
|
- { //TODO: what about artifacts generating resources?
|
|
|
- incomesVal[7] += heroes[i]->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::ESTATES));
|
|
|
- incomesVal[7] += heroes[i]->valOfBonuses(Selector::typeSubtype(Bonus::GENERATE_RESOURCE, Res::GOLD));
|
|
|
+void InfoBox::clickRight(tribool down, bool previousState)
|
|
|
+{
|
|
|
+ if (down)
|
|
|
+ {
|
|
|
+ SComponent *comp;
|
|
|
+ std::string text;
|
|
|
+ data->prepareMessage(text, &comp);
|
|
|
+ if (comp)
|
|
|
+ CRClickPopup::createAndPush(text, CInfoWindow::TCompsInfo(1, comp));
|
|
|
+ else
|
|
|
+ adventureInt->handleRightClick(text, down);
|
|
|
}
|
|
|
- std::vector<const CGTownInstance*> towns = LOCPLINT->cb->getTownsInfo(true);
|
|
|
- for(size_t i=0; i<towns.size();i++)
|
|
|
- incomesVal[7] += towns[i]->dailyIncome();
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::moveObjectList(int newPos)
|
|
|
+void InfoBox::clickLeft(tribool down, bool previousState)
|
|
|
{
|
|
|
- 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
|
|
|
+ if((!down) && previousState)
|
|
|
{
|
|
|
-/* Top */ case 0: objPos = top;
|
|
|
- break;
|
|
|
-/* Up */ case 1: objPos = objPos==top?top:(objPos-1);
|
|
|
- break;
|
|
|
-/* Down */ case 2: objPos = objPos==bottom?bottom:(objPos+1);
|
|
|
- break;
|
|
|
-/*Bottom*/ case 3: objPos = bottom;
|
|
|
- break;
|
|
|
+ SComponent *comp;
|
|
|
+ std::string text;
|
|
|
+ data->prepareMessage(text, &comp);
|
|
|
+
|
|
|
+ std::vector<SComponent*> compVector;
|
|
|
+ if (comp)
|
|
|
+ compVector.push_back(comp);
|
|
|
+ LOCPLINT->showInfoDialog(text, compVector);
|
|
|
}
|
|
|
- showAll(screen2);
|
|
|
}
|
|
|
|
|
|
-CKingdomInterface::~CKingdomInterface()
|
|
|
+//TODO?
|
|
|
+/*
|
|
|
+void InfoBox::update()
|
|
|
{
|
|
|
- SDL_FreeSurface(bg);
|
|
|
|
|
|
- delete title;//deleting .def
|
|
|
- delete slots;
|
|
|
- delete fort;
|
|
|
- delete hall;
|
|
|
- delete objPics;
|
|
|
- delete mines;
|
|
|
+}
|
|
|
+*/
|
|
|
|
|
|
- towns.clear();//deleting lists
|
|
|
- heroes.clear();
|
|
|
- incomes.clear();
|
|
|
- ObjList.clear();
|
|
|
- objList.clear();
|
|
|
+IInfoBoxData::IInfoBoxData(InfoType Type):
|
|
|
+ type(Type)
|
|
|
+{
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::close()
|
|
|
+InfoBoxAbstractHeroData::InfoBoxAbstractHeroData(InfoType Type):
|
|
|
+ IInfoBoxData(Type)
|
|
|
{
|
|
|
- GH.popIntTotally(this);
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::updateGarrisons()
|
|
|
+std::string InfoBoxAbstractHeroData::getValueText()
|
|
|
{
|
|
|
- for (int i = 0; i<towns.size(); i++)
|
|
|
- {
|
|
|
- if (towns[i] && towns[i]->garr)
|
|
|
- towns[i]->garr->recreateSlots();
|
|
|
- }
|
|
|
- for (int i = 0; i<heroes.size(); i++)
|
|
|
+ switch (type)
|
|
|
{
|
|
|
- if (heroes[i] && heroes[i]->garr)
|
|
|
- heroes[i]->garr->recreateSlots();
|
|
|
+ case HERO_MANA:
|
|
|
+ case HERO_EXPERIENCE:
|
|
|
+ case HERO_PRIMARY_SKILL:
|
|
|
+ return boost::lexical_cast<std::string>(getValue());
|
|
|
+ case HERO_SPECIAL:
|
|
|
+ {
|
|
|
+ std::string text = CGI->generaltexth->jktexts[5];
|
|
|
+ size_t begin = text.find('{');
|
|
|
+ size_t end = text.find('}', begin);
|
|
|
+ return text.substr(begin, end-begin);
|
|
|
+ }
|
|
|
+ case HERO_SECONDARY_SKILL:
|
|
|
+ {
|
|
|
+ si64 value = getValue();
|
|
|
+ if (value)
|
|
|
+ return CGI->generaltexth->levels[value];
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ assert(0);
|
|
|
}
|
|
|
+ return "";
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::showAll( SDL_Surface * to/*=NULL*/)
|
|
|
+std::string InfoBoxAbstractHeroData::getNameText()
|
|
|
{
|
|
|
- adventureInt->resdatabar.draw(to);
|
|
|
- blitAt(bg,pos,to);
|
|
|
- resdatabar->draw(to);
|
|
|
- toTowns->showAll(to);
|
|
|
- toHeroes->showAll(to);
|
|
|
- exit->showAll(to);
|
|
|
-
|
|
|
- ObjTop->showAll(to);
|
|
|
- ObjUp->showAll(to);
|
|
|
- ObjDown->showAll(to);
|
|
|
- ObjBottom->showAll(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, const std::string*> >::iterator it=objList.begin(); it!= objList.end(); it++)
|
|
|
+ switch (type)
|
|
|
{
|
|
|
- if (skipCount<objPos)//we will show only objects from objPos
|
|
|
+ case HERO_PRIMARY_SKILL:
|
|
|
+ return CGI->generaltexth->primarySkillNames[getSubID()];
|
|
|
+ case HERO_MANA:
|
|
|
+ return CGI->generaltexth->allTexts[387];
|
|
|
+ case HERO_EXPERIENCE:
|
|
|
{
|
|
|
- skipCount++;
|
|
|
- continue;
|
|
|
+ std::string text = CGI->generaltexth->jktexts[6];
|
|
|
+ size_t begin = text.find('{');
|
|
|
+ size_t end = text.find('}', begin);
|
|
|
+ return text.substr(begin, end-begin);
|
|
|
}
|
|
|
- blitAt(objPics->ourImages[(*it).first].bitmap,pos.x+740,pos.y+44+curPos*57,to);
|
|
|
-
|
|
|
- std::ostringstream ostrs;//objects count
|
|
|
- ostrs << (*it).second.first;
|
|
|
- CSDL_Ext::printTo(ostrs.str(),pos.x+790,pos.y+94+curPos*57,FONT_SMALL,zwykly,to);
|
|
|
-
|
|
|
- ObjList[curPos]->hoverText = * (*it).second.second;
|
|
|
- curPos++;
|
|
|
- if (curPos == objSize)
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (state == 1)
|
|
|
- {//printing text "Town", "Harrisoned hero", "Visiting hero"
|
|
|
- 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);
|
|
|
- for (size_t i=0; i<size; i++)
|
|
|
- towns[i]->showAll(to);//show town list
|
|
|
- }
|
|
|
- else
|
|
|
- {//text "Hero/stats" and "Skills"
|
|
|
- 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);
|
|
|
- for (size_t i=0; i<size; i++)
|
|
|
- heroes[i]->showAll(to);//show hero list
|
|
|
+ case HERO_SPECIAL:
|
|
|
+ return CGI->generaltexth->hTxts[getSubID()].bonusName;
|
|
|
+ case HERO_SECONDARY_SKILL:
|
|
|
+ if (getValue())
|
|
|
+ return CGI->generaltexth->skillName[getSubID()];
|
|
|
+ else
|
|
|
+ return "";
|
|
|
+ default:
|
|
|
+ assert(0);
|
|
|
}
|
|
|
- for (int i = 0; i<7; i++)
|
|
|
- blitAt(mines->ourImages[i].bitmap,pos.x + 20 + i*80,pos.y + 31+size*116,to);
|
|
|
+ return "";
|
|
|
+}
|
|
|
|
|
|
- for(size_t i=0;i<incomes.size();i++)
|
|
|
+std::string InfoBoxAbstractHeroData::getImageName(InfoBox::InfoSize size)
|
|
|
+{
|
|
|
+ //TODO: sizes
|
|
|
+ switch(size)
|
|
|
{
|
|
|
- std::ostringstream oss;
|
|
|
- oss << incomesVal[i];
|
|
|
- CSDL_Ext::printAtMiddle(oss.str(),incomes[i]->pos.x+incomes[i]->pos.w/2,incomes[i]->pos.y+50,FONT_SMALL,zwykly,to);
|
|
|
+ case InfoBox::SIZE_SMALL:
|
|
|
+ {
|
|
|
+ switch(type)
|
|
|
+ {
|
|
|
+ case HERO_PRIMARY_SKILL:
|
|
|
+ case HERO_MANA:
|
|
|
+ case HERO_EXPERIENCE:
|
|
|
+ return "PSKIL32";
|
|
|
+ case HERO_SPECIAL:
|
|
|
+ return "UN32";
|
|
|
+ case HERO_SECONDARY_SKILL:
|
|
|
+ return "SECSK32";
|
|
|
+ default:
|
|
|
+ assert(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ case InfoBox::SIZE_BIG:
|
|
|
+ {
|
|
|
+ switch(type)
|
|
|
+ {
|
|
|
+ case HERO_PRIMARY_SKILL:
|
|
|
+ case HERO_MANA:
|
|
|
+ case HERO_EXPERIENCE:
|
|
|
+ return "PSKIL42";
|
|
|
+ case HERO_SPECIAL:
|
|
|
+ return "UN44";
|
|
|
+ case HERO_SECONDARY_SKILL:
|
|
|
+ return "SECSKILL";
|
|
|
+ default:
|
|
|
+ assert(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ assert(0);
|
|
|
}
|
|
|
-
|
|
|
- slider->showAll(to);
|
|
|
- if(screen->w != 800 || screen->h !=600)
|
|
|
- CMessage::drawBorder(LOCPLINT->playerID,to,828,136+116*size+29,pos.x-14,pos.y-15);
|
|
|
- show(to);
|
|
|
+ return "";
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::show(SDL_Surface * to)
|
|
|
+std::string InfoBoxAbstractHeroData::getHoverText()
|
|
|
{
|
|
|
- statusbar->show(to);
|
|
|
+ //TODO: any texts here?
|
|
|
+ return "";
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::activate()
|
|
|
+size_t InfoBoxAbstractHeroData::getImageIndex()
|
|
|
{
|
|
|
- GH.statusbar = statusbar;
|
|
|
- exit->activate();
|
|
|
- toTowns->activate();
|
|
|
- toHeroes->activate();
|
|
|
-
|
|
|
- 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();
|
|
|
- if (state == 1)
|
|
|
- for (size_t i=0; i<size; i++)
|
|
|
- towns[i]->activate();
|
|
|
- else
|
|
|
- for (size_t i=0; i<size; i++)
|
|
|
- heroes[i]->activate();
|
|
|
-
|
|
|
- slider->activate();
|
|
|
+ switch (type)
|
|
|
+ {
|
|
|
+ case HERO_SPECIAL:
|
|
|
+ case HERO_PRIMARY_SKILL:
|
|
|
+ return getSubID();
|
|
|
+ case HERO_MANA:
|
|
|
+ return 5;
|
|
|
+ case HERO_EXPERIENCE:
|
|
|
+ return 4;
|
|
|
+ case HERO_SECONDARY_SKILL:
|
|
|
+ {
|
|
|
+ si64 value = getValue();
|
|
|
+ if (value)
|
|
|
+ return getSubID()*3 + value + 2;
|
|
|
+ else
|
|
|
+ return 0;//FIXME: Should be transparent instead of empty
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ assert(0);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::deactivate()
|
|
|
+bool InfoBoxAbstractHeroData::prepareMessage(std::string &text, SComponent **comp)
|
|
|
{
|
|
|
- exit->deactivate();
|
|
|
- toTowns->deactivate();
|
|
|
- toHeroes->deactivate();
|
|
|
-
|
|
|
- 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();
|
|
|
+ switch (type)
|
|
|
+ {
|
|
|
+ case HERO_SPECIAL:
|
|
|
+ text = CGI->generaltexth->hTxts[getSubID()].longBonus;
|
|
|
+ *comp = NULL;
|
|
|
+ return true;
|
|
|
+ case HERO_PRIMARY_SKILL:
|
|
|
+ text = CGI->generaltexth->arraytxt[2+getSubID()];
|
|
|
+ *comp =new SComponent(SComponent::primskill, getSubID(), getValue());
|
|
|
+ return true;
|
|
|
+ case HERO_MANA:
|
|
|
+ text = CGI->generaltexth->allTexts[149];
|
|
|
+ *comp = NULL;
|
|
|
+ return true;
|
|
|
+ case HERO_EXPERIENCE:
|
|
|
+ text = CGI->generaltexth->allTexts[241];
|
|
|
+ *comp = NULL;
|
|
|
+ return true;
|
|
|
+ case HERO_SECONDARY_SKILL:
|
|
|
+ {
|
|
|
+ si64 value = getValue();
|
|
|
+ int subID = getSubID();
|
|
|
+ if (!value)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ text = CGI->generaltexth->skillInfoTexts[subID][value-1];
|
|
|
+ *comp = new SComponent(SComponent::secskill, subID, value);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ assert(0);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- if (state == 1)
|
|
|
- for (size_t i=0; i<size; i++)
|
|
|
- towns[i]->deactivate();
|
|
|
- else
|
|
|
- for (size_t i=0; i<size; i++)
|
|
|
- heroes[i]->deactivate();
|
|
|
- slider->deactivate();
|
|
|
+InfoBoxHeroData::InfoBoxHeroData(InfoType Type, const CGHeroInstance * Hero, int Index):
|
|
|
+ InfoBoxAbstractHeroData(Type),
|
|
|
+ hero(Hero),
|
|
|
+ index(Index)
|
|
|
+{
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::recreateHeroList(int pos)
|
|
|
+int InfoBoxHeroData::getSubID()
|
|
|
{
|
|
|
- std::vector<const CGHeroInstance*> Heroes = LOCPLINT->cb->getHeroesInfo(true);
|
|
|
- int i=0, cnt=0;
|
|
|
- for (size_t j = 0; ((j<Heroes.size()) && (i<size));j++)
|
|
|
+ switch(type)
|
|
|
{
|
|
|
- if (Heroes[j]->inTownGarrison && (!showHarrisoned))//if hero in garrison and we don't show them
|
|
|
- continue;
|
|
|
- if (cnt<pos)//skipping heroes
|
|
|
- {
|
|
|
- cnt++;
|
|
|
- continue;
|
|
|
- }//this hero will be added
|
|
|
- heroes[i]->setHero(Heroes[j]);
|
|
|
- i++;
|
|
|
+ case HERO_PRIMARY_SKILL:
|
|
|
+ return index;
|
|
|
+ case HERO_SECONDARY_SKILL:
|
|
|
+ if (hero->secSkills.size() > index)
|
|
|
+ return hero->secSkills[index].first;
|
|
|
+ case HERO_MANA:
|
|
|
+ case HERO_EXPERIENCE:
|
|
|
+ case HERO_SPECIAL:
|
|
|
+ return 0;
|
|
|
+ default:
|
|
|
+ assert(0);
|
|
|
+ return 0;
|
|
|
}
|
|
|
- for (;i<size;i++)//if we still have empty pieces
|
|
|
- heroes[i]->setHero(NULL);//empty pic
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::recreateTownList(int pos)
|
|
|
+si64 InfoBoxHeroData::getValue()
|
|
|
{
|
|
|
- std::vector<const CGTownInstance*> Towns = LOCPLINT->cb->getTownsInfo(false);
|
|
|
- for(size_t i=0;i<size;i++)
|
|
|
+ switch(type)
|
|
|
{
|
|
|
- if (i+pos<LOCPLINT->cb->howManyTowns())
|
|
|
- towns[i]->setTown(Towns[i+pos]);//replace town
|
|
|
- else
|
|
|
- towns[i]->setTown(NULL);//only empty pic
|
|
|
+ case HERO_PRIMARY_SKILL:
|
|
|
+ return hero->getPrimSkillLevel(index);
|
|
|
+ case HERO_MANA:
|
|
|
+ return hero->mana;
|
|
|
+ case HERO_EXPERIENCE:
|
|
|
+ return hero->exp;
|
|
|
+ case HERO_SECONDARY_SKILL:
|
|
|
+ if (hero->secSkills.size() > index)
|
|
|
+ return hero->secSkills[index].second;
|
|
|
+ case HERO_SPECIAL:
|
|
|
+ return 0;
|
|
|
+ default:
|
|
|
+ assert(0);
|
|
|
+ return 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::listToTowns()
|
|
|
+std::string InfoBoxHeroData::getHoverText()
|
|
|
{
|
|
|
- state = 1;
|
|
|
- toHeroes->block(0);
|
|
|
- toTowns->block(2);
|
|
|
- heroPos = slider->value;
|
|
|
- slider->setAmount(LOCPLINT->cb->howManyTowns());
|
|
|
- slider->value=townPos;//moving slider
|
|
|
- recreateTownList(townPos);
|
|
|
- for (size_t i=0;i<size;i++)
|
|
|
+ switch (type)
|
|
|
{
|
|
|
- heroes[i]->deactivate();
|
|
|
- towns[i]->activate();
|
|
|
+ case HERO_PRIMARY_SKILL:
|
|
|
+ return boost::str(boost::format(CGI->generaltexth->heroscrn[1]) % CGI->generaltexth->primarySkillNames[index]);
|
|
|
+ case HERO_MANA:
|
|
|
+ return CGI->generaltexth->heroscrn[22];
|
|
|
+ case HERO_EXPERIENCE:
|
|
|
+ return CGI->generaltexth->heroscrn[9];
|
|
|
+ case HERO_SPECIAL:
|
|
|
+ return CGI->generaltexth->heroscrn[27];
|
|
|
+ case HERO_SECONDARY_SKILL:
|
|
|
+ {
|
|
|
+ if (hero->secSkills.size() > index)
|
|
|
+ {
|
|
|
+ std::string level = CGI->generaltexth->levels[hero->secSkills[index].second-1];
|
|
|
+ std::string skill = CGI->generaltexth->skillName[hero->secSkills[index].first];
|
|
|
+ return boost::str(boost::format(CGI->generaltexth->heroscrn[21]) % level % skill);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ return InfoBoxAbstractHeroData::getHoverText();
|
|
|
}
|
|
|
- showAll(screen2);
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::listToHeroes()
|
|
|
+std::string InfoBoxHeroData::getValueText()
|
|
|
{
|
|
|
- state = 2;
|
|
|
- toHeroes->block(2);
|
|
|
- toTowns->block(0);
|
|
|
- townPos = slider->value;
|
|
|
- slider->setAmount(LOCPLINT->cb->howManyHeroes(showHarrisoned));
|
|
|
- slider->value=heroPos;//moving slider
|
|
|
- recreateHeroList(heroPos);
|
|
|
- for (size_t i=0;i<size;i++)
|
|
|
+ switch (type)
|
|
|
{
|
|
|
- towns[i]->deactivate();
|
|
|
- heroes[i]->activate();
|
|
|
+ case HERO_MANA:
|
|
|
+ if (hero)
|
|
|
+ return boost::lexical_cast<std::string>(hero->mana) + '/' +
|
|
|
+ boost::lexical_cast<std::string>(hero->manaLimit());
|
|
|
+ case HERO_EXPERIENCE:
|
|
|
+ return boost::lexical_cast<std::string>(hero->exp);
|
|
|
+ default:
|
|
|
+ return InfoBoxAbstractHeroData::getValueText();
|
|
|
}
|
|
|
- showAll(screen2);
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::sliderMoved(int newpos)
|
|
|
+bool InfoBoxHeroData::prepareMessage(std::string &text, SComponent**comp)
|
|
|
{
|
|
|
- if (state == 0)
|
|
|
+ switch(type)
|
|
|
{
|
|
|
- townPos = newpos;
|
|
|
- recreateHeroList(newpos);
|
|
|
- state = 2;
|
|
|
- }
|
|
|
- else if ( state == 1 )//towns
|
|
|
- {
|
|
|
- for (size_t i=0; i<size; i++)
|
|
|
- towns[i]->deactivate();
|
|
|
- townPos = newpos;
|
|
|
- recreateTownList(newpos);
|
|
|
- for (size_t i=0; i<size; i++)
|
|
|
- towns[i]->activate();
|
|
|
- showAll(screen2);
|
|
|
- }
|
|
|
- else//heroes
|
|
|
- {
|
|
|
- for (size_t i=0; i<size; i++)
|
|
|
- heroes[i]->deactivate();
|
|
|
- heroPos = newpos;
|
|
|
- recreateHeroList(newpos);
|
|
|
- for (size_t i=0; i<size; i++)
|
|
|
- heroes[i]->activate();
|
|
|
- showAll(screen2);
|
|
|
+ case HERO_MANA:
|
|
|
+ text = CGI->generaltexth->allTexts[205];
|
|
|
+ boost::replace_first(text, "%s", boost::lexical_cast<std::string>(hero->name));
|
|
|
+ boost::replace_first(text, "%d", boost::lexical_cast<std::string>(hero->mana));
|
|
|
+ boost::replace_first(text, "%d", boost::lexical_cast<std::string>(hero->manaLimit()));
|
|
|
+ *comp = NULL;
|
|
|
+ return true;
|
|
|
+
|
|
|
+ case HERO_EXPERIENCE:
|
|
|
+ text = CGI->generaltexth->allTexts[2];
|
|
|
+ boost::replace_first(text, "%d", boost::lexical_cast<std::string>(hero->level));
|
|
|
+ boost::replace_first(text, "%d", boost::lexical_cast<std::string>(CGI->heroh->reqExp(hero->level+1)));
|
|
|
+ boost::replace_first(text, "%d", boost::lexical_cast<std::string>(hero->exp));
|
|
|
+ *comp = NULL;
|
|
|
+ return true;
|
|
|
+
|
|
|
+ default:
|
|
|
+ return InfoBoxAbstractHeroData::prepareMessage(text, comp);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-CKingdomInterface::CTownItem::CTownItem(int num, CKingdomInterface * Owner)
|
|
|
+InfoBoxCustomHeroData::InfoBoxCustomHeroData(InfoType Type, int SubID, si64 Value):
|
|
|
+ InfoBoxAbstractHeroData(Type),
|
|
|
+ subID(SubID),
|
|
|
+ value(Value)
|
|
|
{
|
|
|
- recActions = DISPOSE | SHARE_POS;
|
|
|
- parent = Owner;
|
|
|
- numb = num;
|
|
|
- pos.x += 23;
|
|
|
- pos.y += 25+num*116;
|
|
|
- pos.w = 702;
|
|
|
- pos.h = 114;
|
|
|
- town = NULL;
|
|
|
- garr = NULL;
|
|
|
-
|
|
|
- garrHero = new CHeroArea(pos.x+244, pos.y + 6, NULL);
|
|
|
- visitHero = new CHeroArea(pos.x+476, pos.y + 6, NULL);
|
|
|
+}
|
|
|
|
|
|
- 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);
|
|
|
+int InfoBoxCustomHeroData::getSubID()
|
|
|
+{
|
|
|
+ return subID;
|
|
|
+}
|
|
|
|
|
|
- creaCount.push_back(new CCreaPlace());
|
|
|
- creaCount[i]->pos = genRect(32, 32, pos.x+409+i*37, pos.y + 78);
|
|
|
- creaCount[i]->type = i;
|
|
|
- }
|
|
|
- hallArea = new LRClickableAreaOpenTown();
|
|
|
- hallArea->pos = genRect(38, 38, pos.x+69, pos.y + 31);
|
|
|
- hallArea->type = 2;
|
|
|
+si64 InfoBoxCustomHeroData::getValue()
|
|
|
+{
|
|
|
+ return value;
|
|
|
+}
|
|
|
|
|
|
- fortArea = new LRClickableAreaOpenTown();
|
|
|
- fortArea->pos = genRect(38, 38, pos.x+111, pos.y + 31);
|
|
|
- fortArea->type = 3;
|
|
|
+InfoBoxCustom::InfoBoxCustom(std::string ValueText, std::string NameText, std::string ImageName, size_t ImageIndex, std::string HoverText):
|
|
|
+ IInfoBoxData(CUSTOM),
|
|
|
+ valueText(ValueText),
|
|
|
+ nameText(NameText),
|
|
|
+ imageName(ImageName),
|
|
|
+ hoverText(HoverText),
|
|
|
+ imageIndex(ImageIndex)
|
|
|
+{
|
|
|
+}
|
|
|
|
|
|
- townImage = new LRClickableAreaOpenTown();
|
|
|
- townImage->pos = genRect(64, 58, pos.x+5, pos.y + 6);
|
|
|
- townImage->type = 1;
|
|
|
+std::string InfoBoxCustom::getHoverText()
|
|
|
+{
|
|
|
+ return hoverText;
|
|
|
+}
|
|
|
+
|
|
|
+size_t InfoBoxCustom::getImageIndex()
|
|
|
+{
|
|
|
+ return imageIndex;
|
|
|
+}
|
|
|
+
|
|
|
+std::string InfoBoxCustom::getImageName(InfoBox::InfoSize size)
|
|
|
+{
|
|
|
+ return imageName;
|
|
|
+}
|
|
|
+
|
|
|
+std::string InfoBoxCustom::getNameText()
|
|
|
+{
|
|
|
+ return nameText;
|
|
|
+}
|
|
|
+
|
|
|
+std::string InfoBoxCustom::getValueText()
|
|
|
+{
|
|
|
+ return valueText;
|
|
|
+}
|
|
|
|
|
|
- incomeArea = new HoverableArea();
|
|
|
- incomeArea->pos = genRect(42, 64, pos.x+154, pos.y + 31);
|
|
|
- incomeArea->hoverText = CGI->generaltexth->allTexts[255];
|
|
|
+bool InfoBoxCustom::prepareMessage(std::string &text, SComponent **comp)
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
|
|
|
+CObjectList::CObjectList(IGuiObjectListManager *Manager):
|
|
|
+ manager(Manager)
|
|
|
+{
|
|
|
}
|
|
|
|
|
|
-CKingdomInterface::CTownItem::~CTownItem()
|
|
|
+CObjectList::~CObjectList()
|
|
|
{
|
|
|
- creaGrowth.clear();
|
|
|
- creaCount.clear();
|
|
|
- delete garr;
|
|
|
+ delete manager;
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CTownItem::setTown(const CGTownInstance * newTown)
|
|
|
+void CObjectList::deleteItem(CIntObject* item)
|
|
|
{
|
|
|
- BLOCK_CAPTURING;
|
|
|
- delete garr;
|
|
|
- town = newTown;
|
|
|
- if (!town)
|
|
|
- {
|
|
|
+ if (!item)
|
|
|
return;
|
|
|
- garr = NULL;
|
|
|
- }
|
|
|
- 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);
|
|
|
-
|
|
|
- garrHero->hero = town->garrisonHero;
|
|
|
- visitHero->hero = town->visitingHero;
|
|
|
+ if (active)
|
|
|
+ item->deactivate();
|
|
|
+ removeChild(item);
|
|
|
+ manager->removeObject(item);
|
|
|
+}
|
|
|
|
|
|
- for (int i=0; i<CREATURES_PER_TOWN;i++)
|
|
|
- {
|
|
|
- creaCount[i]->town = NULL;
|
|
|
+CIntObject* CObjectList::createItem(size_t index)
|
|
|
+{
|
|
|
+ OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
+ CIntObject * item = manager->getObject(index);
|
|
|
+ if (item == NULL)
|
|
|
+ item = new CIntObject();
|
|
|
|
|
|
- int crid = -1;
|
|
|
+ item->recActions = defActions;
|
|
|
|
|
|
- if (vstd::contains(town->builtBuildings,30+i+CREATURES_PER_TOWN))
|
|
|
- crid = town->town->upgradedCreatures[i];
|
|
|
+ //May happen if object was created before call to getObject()
|
|
|
+ if(item->parent != this)
|
|
|
+ {
|
|
|
+ if (item->parent)
|
|
|
+ moveChild(item, item->parent, this);
|
|
|
else
|
|
|
- crid = town->town->basicCreatures[i];
|
|
|
-
|
|
|
- std::string descr=CGI->generaltexth->allTexts[588];
|
|
|
- boost::algorithm::replace_first(descr,"%s",CGI->creh->creatures[crid]->namePl);
|
|
|
- creaGrowth[i]->hoverText = descr;
|
|
|
-
|
|
|
- descr=CGI->generaltexth->heroscrn[1];
|
|
|
- boost::algorithm::replace_first(descr,"%s",CGI->creh->creatures[crid]->namePl);
|
|
|
- creaCount[i]->hoverText = descr;
|
|
|
- creaCount[i]->town = town;
|
|
|
+ addChild(item);
|
|
|
}
|
|
|
|
|
|
- townImage->hoverText = town->name;
|
|
|
- townImage->town = town;
|
|
|
- hallArea->town = town;
|
|
|
+ if (item && active)
|
|
|
+ item->activate();
|
|
|
+ return item;
|
|
|
+}
|
|
|
+
|
|
|
+CTabbedInt::CTabbedInt(IGuiObjectListManager *Manager, Point position, size_t ActiveID):
|
|
|
+ CObjectList(Manager),
|
|
|
+ activeTab(NULL),
|
|
|
+ activeID(ActiveID)
|
|
|
+{
|
|
|
+ pos += position;
|
|
|
+ reset();
|
|
|
+}
|
|
|
|
|
|
- hallArea->hoverText = CGI->buildh->buildings[town->subID][10+town->hallLevel()]->Name();
|
|
|
- if (town->hasFort())
|
|
|
+void CTabbedInt::setActive(size_t which)
|
|
|
+{
|
|
|
+ if (which != activeID)
|
|
|
{
|
|
|
- fortArea->hoverText = CGI->buildh->buildings[town->subID][6+town->fortLevel()]->Name();
|
|
|
- fortArea->town = town;
|
|
|
+ activeID = which;
|
|
|
+ reset();
|
|
|
}
|
|
|
- else
|
|
|
- fortArea->hoverText = "";
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CTownItem::activate()
|
|
|
+void CTabbedInt::reset()
|
|
|
{
|
|
|
- if (!town)
|
|
|
- return;
|
|
|
-
|
|
|
- setTown(town);
|
|
|
- hallArea->activate();
|
|
|
- fortArea->activate();
|
|
|
- incomeArea->activate();
|
|
|
- townImage->activate();
|
|
|
-
|
|
|
- garrHero->activate();
|
|
|
- visitHero->activate();
|
|
|
+ deleteItem(activeTab);
|
|
|
+ activeTab = createItem(activeID);
|
|
|
+ activeTab->moveTo(pos.topLeft());
|
|
|
|
|
|
- for (int i=0; i<CREATURES_PER_TOWN;i++)
|
|
|
- if (vstd::contains(town->builtBuildings,30+i))
|
|
|
- {
|
|
|
- creaGrowth[i]->activate();
|
|
|
- creaCount [i]->activate();
|
|
|
- }
|
|
|
- garr->activate();
|
|
|
+ if (active)
|
|
|
+ redraw();
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CTownItem::deactivate()
|
|
|
+CIntObject * CTabbedInt::getItem()
|
|
|
{
|
|
|
- if (!town)
|
|
|
- return;
|
|
|
-
|
|
|
- hallArea->deactivate();
|
|
|
- fortArea->deactivate();
|
|
|
- incomeArea->deactivate();
|
|
|
- townImage->deactivate();
|
|
|
+ return activeTab;
|
|
|
+}
|
|
|
|
|
|
- garrHero->deactivate();
|
|
|
- visitHero->deactivate();
|
|
|
+CListBox::CListBox(IGuiObjectListManager *Manager, Point Pos, Point ItemOffset, size_t VisibleSize,
|
|
|
+ size_t TotalSize, size_t InitialPos, int Slider, Rect SliderPos):
|
|
|
+ CObjectList(Manager),
|
|
|
+ first(InitialPos),
|
|
|
+ totalSize(TotalSize),
|
|
|
+ itemOffset(ItemOffset)
|
|
|
+{
|
|
|
+ pos += Pos;
|
|
|
+ items.resize(VisibleSize, NULL);
|
|
|
|
|
|
- for (int i=0; i<CREATURES_PER_TOWN;i++)
|
|
|
- if (creaCount[i]->active)
|
|
|
- {
|
|
|
- creaGrowth[i]->deactivate();
|
|
|
- creaCount [i]->deactivate();
|
|
|
- }
|
|
|
- garr->deactivate();
|
|
|
+ if (Slider & 1)
|
|
|
+ {
|
|
|
+ OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
+ slider = new CSlider(SliderPos.x, SliderPos.y, SliderPos.w, boost::bind(&CListBox::moveToPos, this, _1),
|
|
|
+ VisibleSize, TotalSize, InitialPos, Slider & 2, Slider & 4);
|
|
|
+ }
|
|
|
+ reset();
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CTownItem::showAll(SDL_Surface * to)
|
|
|
+// Used to move active items after changing list position
|
|
|
+void CListBox::updatePositions()
|
|
|
{
|
|
|
- if (!town)
|
|
|
- {//if NULL - print background & exit
|
|
|
- blitAt(parent->slots->ourImages[numb % parent->PicCount].bitmap,pos.x,pos.y,to);
|
|
|
- return;
|
|
|
- }//background
|
|
|
- blitAt(parent->slots->ourImages[parent->PicCount+2].bitmap,pos.x,pos.y,to); garr->show(to);
|
|
|
- //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);
|
|
|
- CSDL_Ext::printAt(town->name,pos.x+73,pos.y+8,FONT_SMALL,zwykly,to);
|
|
|
- //fort pic
|
|
|
- townPic = town->fortLevel()-1;
|
|
|
- if (townPic==-1) townPic = 3;
|
|
|
- blitAt(parent->fort->ourImages[townPic].bitmap,pos.x+111,pos.y+31,to);
|
|
|
- //hall pic
|
|
|
- townPic = town->hallLevel();
|
|
|
- blitAt(parent->hall->ourImages[townPic].bitmap,pos.x+69,pos.y+31,to);
|
|
|
- //income pic
|
|
|
- std::ostringstream oss;
|
|
|
- oss << town->dailyIncome();
|
|
|
- CSDL_Ext::printAtMiddle(oss.str(),pos.x+189,pos.y+61,FONT_SMALL,zwykly,to);
|
|
|
-
|
|
|
- std::vector<std::string> toPrin = CMessage::breakText(CGI->generaltexth->allTexts[265]);
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- toPrin = CMessage::breakText(CGI->generaltexth->allTexts[266]);
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- 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);
|
|
|
- CSDL_Ext::printTo(oss.str(),pos.x+87+i*37,pos.y+110,FONT_TINY,zwykly,to);
|
|
|
- //creature available
|
|
|
- blitAt(graphics->smallImgs[crid],pos.x+409+i*37,pos.y+78,to);
|
|
|
- std::ostringstream ostrs;
|
|
|
- ostrs << town->creatures[i].first;
|
|
|
- CSDL_Ext::printTo(ostrs.str(),pos.x+440+i*37,pos.y+110,FONT_TINY,zwykly,to);
|
|
|
+ Point itemPos = pos.topLeft();
|
|
|
+ for (std::list<CIntObject*>::iterator it = items.begin(); it!=items.end(); it++)
|
|
|
+ {
|
|
|
+ (*it)->moveTo(itemPos);
|
|
|
+ itemPos += itemOffset;
|
|
|
+ }
|
|
|
+ if (active)
|
|
|
+ {
|
|
|
+ redraw();
|
|
|
+ if (slider)
|
|
|
+ slider->moveTo(first);
|
|
|
}
|
|
|
-
|
|
|
- garrHero->showAll(to);
|
|
|
- visitHero->showAll(to);
|
|
|
}
|
|
|
|
|
|
-CKingdomInterface::CHeroItem::CHeroItem(int num, CKingdomInterface * Owner)
|
|
|
+void CListBox::reset()
|
|
|
{
|
|
|
- OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
- recActions = DISPOSE | SHARE_POS;
|
|
|
- defActions = SHARE_POS;
|
|
|
- parent = Owner;
|
|
|
- numb = num;
|
|
|
- pos.x += 23;
|
|
|
- pos.y += 25+num*116;
|
|
|
- pos.w = 702;
|
|
|
- pos.h = 114;
|
|
|
- hero = NULL;
|
|
|
- garr = NULL;
|
|
|
- artGroup = 0;
|
|
|
- backpackPos = 0;
|
|
|
- artButtons = new CHighlightableButtonsGroup(0);
|
|
|
- for (size_t it = 0; it<3; it++)
|
|
|
+ size_t current = first;
|
|
|
+ for (std::list<CIntObject*>::iterator it = items.begin(); it!=items.end(); 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);
|
|
|
- std::string str = CGI->generaltexth->overview[8+it];
|
|
|
- str = str.substr(str.find_first_of("{")+1, str.find_first_of("}")-str.find_first_of("{"));
|
|
|
- artButtons->buttons[it]->addTextOverlay(str, FONT_SMALL, tytulowy);
|
|
|
+ deleteItem(*it);
|
|
|
+ *it = createItem(current++);
|
|
|
}
|
|
|
- artButtons->onChange = boost::bind(&CKingdomInterface::CHeroItem::onArtChange, this, _1);
|
|
|
- artButtons->select(0,0);
|
|
|
+ updatePositions();
|
|
|
+}
|
|
|
+
|
|
|
+void CListBox::moveToPos(size_t which)
|
|
|
+{
|
|
|
+ //Calculate new position
|
|
|
+ size_t maxPossible;
|
|
|
+ if (totalSize > items.size())
|
|
|
+ maxPossible = totalSize - items.size();
|
|
|
+ else
|
|
|
+ maxPossible = 0;
|
|
|
|
|
|
- artLeft = new AdventureMapButton("", "", boost::bind
|
|
|
- (&CKingdomInterface::CHeroItem::scrollArts,this,-1), 269, 66, "hsbtns3.def", SDLK_LEFT);
|
|
|
- artRight = new AdventureMapButton("", "", boost::bind
|
|
|
- (&CKingdomInterface::CHeroItem::scrollArts,this,+1), 675, 66, "hsbtns5.def", SDLK_RIGHT);
|
|
|
+ size_t newPos = std::min(which, maxPossible);
|
|
|
|
|
|
- portrait = new CHeroArea(5,5,NULL);
|
|
|
- char bufor[400];
|
|
|
- for(int i=0; i<PRIMARY_SKILLS; i++)
|
|
|
- {
|
|
|
- primarySkills.push_back(new LRClickableAreaWTextComp(genRect(45, 32, pos.x+77 + 36*i, pos.y+26), SComponent::primskill));
|
|
|
- primarySkills[i]->text = CGI->generaltexth->arraytxt[2+i];
|
|
|
- primarySkills[i]->type = i;
|
|
|
- sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), CGI->generaltexth->primarySkillNames[i].c_str());
|
|
|
- primarySkills[i]->hoverText = std::string(bufor);
|
|
|
- };
|
|
|
- experience = new LRClickableAreaWText();
|
|
|
- experience->pos = genRect(33, 49, pos.x+322, pos.y+5);
|
|
|
- experience->hoverText = CGI->generaltexth->heroscrn[9];
|
|
|
-
|
|
|
- morale = new MoraleLuckBox(true, genRect(20,32,pos.x+221,pos.y+52));
|
|
|
- luck = new MoraleLuckBox(false, genRect(20,32,pos.x+221,pos.y+28));
|
|
|
-
|
|
|
- spellPoints = new LRClickableAreaWText();
|
|
|
- spellPoints->pos = genRect(33, 49, pos.x+270, pos.y+5);
|
|
|
- spellPoints->hoverText = CGI->generaltexth->heroscrn[22];
|
|
|
-
|
|
|
- speciality = new LRClickableAreaWText();
|
|
|
- speciality->pos = genRect(32, 32, pos.x+374, pos.y+5);
|
|
|
- speciality->hoverText = CGI->generaltexth->heroscrn[27];
|
|
|
-
|
|
|
- for(int i=0; i<SKILL_PER_HERO; ++i)
|
|
|
+ //If move distance is 1 (most of calls from Slider) - use faster shifts instead of resetting all items
|
|
|
+ if (first - newPos == 1)
|
|
|
+ moveToPrev();
|
|
|
+ else if (newPos - first == 1)
|
|
|
+ moveToNext();
|
|
|
+ else if (newPos != first)
|
|
|
{
|
|
|
- secondarySkills.push_back(new LRClickableAreaWTextComp(genRect(32, 32, pos.x+410+i*37, pos.y+5), SComponent::secskill));
|
|
|
+ first = newPos;
|
|
|
+ reset();
|
|
|
}
|
|
|
-/*
|
|
|
- for (int i=0; i<18;i++)
|
|
|
+}
|
|
|
+
|
|
|
+void CListBox::moveToNext()
|
|
|
+{
|
|
|
+ //Remove front item and insert new one to end
|
|
|
+ if (first + items.size() < totalSize)
|
|
|
{
|
|
|
- artifacts.push_back(new CArtPlace(this, genRect(44, 44, pos.x+268+(i%9)*48, pos.y+66)));
|
|
|
+ first++;
|
|
|
+ deleteItem(items.front());
|
|
|
+ items.pop_front();
|
|
|
+ items.push_back(createItem(first+items.size()));
|
|
|
+ updatePositions();
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- for (int i=0; i<8;i++)
|
|
|
+void CListBox::moveToPrev()
|
|
|
+{
|
|
|
+ //Remove last item and insert new one at start
|
|
|
+ if (first)
|
|
|
{
|
|
|
- backpack.push_back(new CArtPlace(this, genRect(44, 44, pos.x+293+(i%9)*48, pos.y+66)));
|
|
|
- }*/
|
|
|
+ first--;
|
|
|
+ deleteItem(items.back());
|
|
|
+ items.pop_back();
|
|
|
+ items.push_front(createItem(first));
|
|
|
+ updatePositions();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-CKingdomInterface::CHeroItem::~CHeroItem()
|
|
|
+std::list<CIntObject*> CListBox::getItems()
|
|
|
{
|
|
|
- delete garr;
|
|
|
- delete artButtons;
|
|
|
- primarySkills.clear();
|
|
|
- secondarySkills.clear();
|
|
|
- artifacts.clear();
|
|
|
- backpack.clear();
|
|
|
+ return items;
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CHeroItem::setHero(const CGHeroInstance * newHero)
|
|
|
+struct OwnedObjectInfo
|
|
|
{
|
|
|
- BLOCK_CAPTURING;
|
|
|
- delete garr;
|
|
|
- hero = newHero;
|
|
|
- if (!hero)
|
|
|
- {
|
|
|
- return;
|
|
|
- garr = NULL;
|
|
|
- }
|
|
|
- char bufor[4000];
|
|
|
- artLeft->block(hero->artifactsInBackpack.size() <= 8);
|
|
|
- artRight->block(hero->artifactsInBackpack.size() <= 8);
|
|
|
- garr = new CGarrisonInt(pos.x+6, pos.y+78, 4, Point(), parent->slots->ourImages[parent->PicCount].bitmap,
|
|
|
- Point(6,78), hero, NULL, true, true, true);
|
|
|
+ int imageID;
|
|
|
+ unsigned int count;
|
|
|
+ std::string hoverText;
|
|
|
+};
|
|
|
|
|
|
- for (int i=0; i<artifacts.size(); i++)
|
|
|
+class OwnedObjectsListManager : public IGuiObjectListManager
|
|
|
+{
|
|
|
+ std::vector<OwnedObjectInfo> objects;
|
|
|
+public:
|
|
|
+ virtual CIntObject * getObject(size_t position)
|
|
|
{
|
|
|
- artifacts[i]->type = hero->getArtTypeId(i);
|
|
|
- if (artifacts[i]->type<0 || artifacts[i]->type == 145 )
|
|
|
- artifacts[i]->hoverText = CGI->generaltexth->heroscrn[11];
|
|
|
- else
|
|
|
+ if (position < objects.size())
|
|
|
{
|
|
|
- artifacts[i]->text = CGI->generaltexth->artifDescriptions[artifacts[i]->type];
|
|
|
- artifacts[i]->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1].c_str()) % CGI->arth->artifacts[artifacts[i]->type]->Name());
|
|
|
+ OwnedObjectInfo &obj = objects[position];
|
|
|
+ std::string value = boost::lexical_cast<std::string>(obj.count);
|
|
|
+ return new InfoBox(Point(), InfoBox::POS_CORNER, InfoBox::SIZE_SMALL,
|
|
|
+ new InfoBoxCustom(value,"", "FLAGPORT", obj.imageID, obj.hoverText));
|
|
|
}
|
|
|
+ return NULL;
|
|
|
}
|
|
|
|
|
|
- for (int i=0; i<backpack.size(); i++)
|
|
|
+ OwnedObjectsListManager(std::vector<OwnedObjectInfo> Objects):
|
|
|
+ objects(Objects)
|
|
|
{
|
|
|
- backpack[i]->type = hero->getArtTypeId(19+i);
|
|
|
- if (backpack[i]->type<0)
|
|
|
- backpack[i]->hoverText ="";
|
|
|
- else
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+class TownHeroListManager : public IGuiObjectListManager
|
|
|
+{
|
|
|
+public:
|
|
|
+ CIntObject *currentItem;
|
|
|
+
|
|
|
+ CIntObject *getObject(size_t position)
|
|
|
+ {
|
|
|
+ size_t size = conf.go()->ac.overviewSize;
|
|
|
+ switch (position)
|
|
|
{
|
|
|
- backpack[i]->text = CGI->generaltexth->artifDescriptions[backpack[i]->type];
|
|
|
- backpack[i]->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1].c_str()) % CGI->arth->artifacts[backpack[i]->type]->Name());
|
|
|
+ case 0:
|
|
|
+ return new CKingdHeroList(size);
|
|
|
+ case 1:
|
|
|
+ return new CKingdTownList(size);
|
|
|
+ default:
|
|
|
+ return NULL;
|
|
|
}
|
|
|
}
|
|
|
+};
|
|
|
+
|
|
|
+CKingdomInterface::CKingdomInterface()
|
|
|
+{
|
|
|
+ OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
+ background = new CPicture(conf.go()->ac.overviewBg);
|
|
|
+ background->colorize(LOCPLINT->playerID);
|
|
|
+ pos = background->center();
|
|
|
+ unsigned int footerPos = conf.go()->ac.overviewSize * 116;
|
|
|
|
|
|
- //sprintf(bufor, CGI->generaltexth->allTexts[15].c_str(), hero->name.c_str(), hero->type->heroClass->name.c_str());
|
|
|
- //portrait->hoverText = std::string(bufor);
|
|
|
- portrait->hero = hero;
|
|
|
+ tabArea = new CTabbedInt(new TownHeroListManager, Point(4,4));
|
|
|
|
|
|
- speciality->text = CGI->generaltexth->hTxts[hero->subID].longBonus;
|
|
|
+ std::vector<const CGObjectInstance * > ownedObjects = LOCPLINT->cb->getMyObjects();
|
|
|
+ generateObjectsList(ownedObjects);
|
|
|
+ generateMinesList(ownedObjects);
|
|
|
+ generateButtons();
|
|
|
|
|
|
- //primary skills
|
|
|
- for(size_t g=0; g<primarySkills.size(); ++g)
|
|
|
- primarySkills[g]->bonusValue = hero->getPrimSkillLevel(g);
|
|
|
+ statusbar = new CGStatusBar(new CPicture("KSTATBAR", 10,pos.h - 45));
|
|
|
+ resdatabar= new CResDataBar("KRESBAR", 3, 111+footerPos, 32, 2, 76, 76);
|
|
|
+}
|
|
|
|
|
|
- //secondary skills
|
|
|
- for(size_t g=0; g<std::min(secondarySkills.size(),hero->secSkills.size()); ++g)
|
|
|
+void CKingdomInterface::generateObjectsList(const std::vector<const CGObjectInstance * > &ownedObjects)
|
|
|
+{
|
|
|
+ unsigned int footerPos = conf.go()->ac.overviewSize * 116;
|
|
|
+ size_t dwellSize = (footerPos - 64)/57;
|
|
|
+
|
|
|
+ //Map used to determine image number for several objects
|
|
|
+ std::map<std::pair<int,int>,int> idToImage;
|
|
|
+ idToImage[std::make_pair( 20, 1)] = 81;//Golem factory
|
|
|
+ idToImage[std::make_pair( 42, 0)] = 82;//Lighthouse
|
|
|
+ idToImage[std::make_pair( 33, 0)] = 83;//Garrison
|
|
|
+ idToImage[std::make_pair(219, 0)] = 83;//Garrison
|
|
|
+ idToImage[std::make_pair( 33, 1)] = 84;//Anti-magic Garrison
|
|
|
+ idToImage[std::make_pair(219, 1)] = 84;//Anti-magic Garrison
|
|
|
+ idToImage[std::make_pair( 53, 7)] = 85;//Abandoned mine
|
|
|
+ idToImage[std::make_pair( 20, 0)] = 86;//Conflux
|
|
|
+ idToImage[std::make_pair( 87, 0)] = 87;//Harbor
|
|
|
+
|
|
|
+ std::map<int, OwnedObjectInfo> visibleObjects;
|
|
|
+ BOOST_FOREACH(const CGObjectInstance * object, ownedObjects)
|
|
|
{
|
|
|
- int skill = hero->secSkills[g].first,
|
|
|
- level = hero->secSkills[g].second;
|
|
|
- secondarySkills[g]->type = skill;
|
|
|
- secondarySkills[g]->bonusValue = level;
|
|
|
- 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);
|
|
|
+ //Dwellings
|
|
|
+ if ( object->ID == 17 )
|
|
|
+ {
|
|
|
+ OwnedObjectInfo &info = visibleObjects[object->subID];
|
|
|
+ if (info.count++ == 0)
|
|
|
+ {
|
|
|
+ info.hoverText = CGI->creh->creatures[CGI->objh->cregens[object->subID]]->namePl;
|
|
|
+ info.imageID = object->subID;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //Special objects from idToImage map that should be displayed in objects list
|
|
|
+ std::map<std::pair<int,int>,int>::iterator iter = idToImage.find(std::make_pair(object->ID, object->subID));
|
|
|
+ if (iter != idToImage.end())
|
|
|
+ {
|
|
|
+ OwnedObjectInfo &info = visibleObjects[iter->second];
|
|
|
+ if (info.count++ == 0)
|
|
|
+ {
|
|
|
+ info.hoverText = object->hoverName;
|
|
|
+ info.imageID = iter->second;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- //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));
|
|
|
+ std::vector<OwnedObjectInfo> objectsVector;
|
|
|
+ objectsVector.reserve(visibleObjects.size());
|
|
|
|
|
|
- //spell points
|
|
|
- sprintf(bufor, CGI->generaltexth->allTexts[205].c_str(), hero->name.c_str(), hero->mana, hero->manaLimit());
|
|
|
- spellPoints->text = std::string(bufor);
|
|
|
-
|
|
|
- //setting morale and luck
|
|
|
- morale->set(hero);
|
|
|
- luck->set(hero);
|
|
|
+ std::pair<int, OwnedObjectInfo> element;
|
|
|
+ BOOST_FOREACH(element, visibleObjects)
|
|
|
+ {
|
|
|
+ objectsVector.push_back(element.second);
|
|
|
+ }
|
|
|
+ dwellingsList = new CListBox(new OwnedObjectsListManager(objectsVector), Point(740,44), Point(0,57), dwellSize, visibleObjects.size());
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CHeroItem::scrollArts(int move)
|
|
|
+void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstance * > &ownedObjects)
|
|
|
{
|
|
|
- backpackPos = ( backpackPos + move + hero->artifactsInBackpack.size()) % hero->artifactsInBackpack.size();
|
|
|
- for (int i=0; i<backpack.size(); i++)
|
|
|
+ unsigned int footerPos = conf.go()->ac.overviewSize * 116;
|
|
|
+ std::vector<int> minesCount(RESOURCE_QUANTITY, 0);
|
|
|
+ int totalIncome=0;
|
|
|
+
|
|
|
+ BOOST_FOREACH(const CGObjectInstance * object, ownedObjects)
|
|
|
{
|
|
|
- backpack[i]->type = hero->getArtTypeId(19+(backpackPos + i)%hero->artifactsInBackpack.size());
|
|
|
- if (backpack[i]->type<0)
|
|
|
- backpack[i]->hoverText ="";
|
|
|
- else
|
|
|
+ //Mines
|
|
|
+ if ( object->ID == 53 )
|
|
|
{
|
|
|
- backpack[i]->text = CGI->generaltexth->artifDescriptions[backpack[i]->type];
|
|
|
- backpack[i]->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1].c_str()) % CGI->arth->artifacts[backpack[i]->type]->Name());
|
|
|
+ const CGMine *mine = dynamic_cast<const CGMine*>(object);
|
|
|
+ assert(mine);
|
|
|
+ minesCount[mine->producedResource]++;
|
|
|
+
|
|
|
+ if (mine->producedResource == Res::GOLD)
|
|
|
+ totalIncome += mine->producedQuantity;
|
|
|
}
|
|
|
}
|
|
|
- showAll(screen2);
|
|
|
-}
|
|
|
|
|
|
-void CKingdomInterface::CHeroItem::showAll(SDL_Surface * to)
|
|
|
-{
|
|
|
- if (!hero)
|
|
|
- {//if we have no hero for this slot - print background & exit
|
|
|
- blitAt(parent->slots->ourImages[numb % parent->PicCount].bitmap,pos.x,pos.y,to);
|
|
|
- return;
|
|
|
- }//print background, different for arts view/backpack mode
|
|
|
- blitAt(parent->slots->ourImages[(artGroup!=2)?parent->PicCount:(parent->PicCount+1)].bitmap,pos.x,pos.y,to);
|
|
|
- //text "Artifacts"
|
|
|
- CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[2],pos.x+320,pos.y+55,FONT_SMALL,zwykly,to);
|
|
|
- portrait->showAll(to);
|
|
|
-
|
|
|
- garr->show(to);
|
|
|
- //hero name
|
|
|
- CSDL_Ext::printAt(hero->name,pos.x+73,pos.y+7,FONT_SMALL,zwykly,to);
|
|
|
- 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;
|
|
|
- str << (hero->getPrimSkillLevel(i));
|
|
|
- CSDL_Ext::printAtMiddle(str.str(),pos.x+94+36*i,pos.y+66,FONT_SMALL,zwykly,to);
|
|
|
+ //Heroes can produce gold as well - skill, speciality or arts
|
|
|
+ std::vector<const CGHeroInstance*> heroes = LOCPLINT->cb->getHeroesInfo(true);
|
|
|
+ for(size_t i=0; i<heroes.size(); i++)
|
|
|
+ {
|
|
|
+ totalIncome += heroes[i]->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::ESTATES));
|
|
|
+ totalIncome += heroes[i]->valOfBonuses(Selector::typeSubtype(Bonus::GENERATE_RESOURCE, Res::GOLD));
|
|
|
}
|
|
|
- {//luck and morale pics, experience and mana text
|
|
|
- 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);
|
|
|
- std::ostringstream str;
|
|
|
- str << (hero->exp);
|
|
|
- CSDL_Ext::printAtMiddle(str.str(),(pos.x+348),(pos.y+31),FONT_TINY,zwykly,to);
|
|
|
- std::ostringstream strnew;
|
|
|
- strnew << (hero->mana)<<"/"<<(hero->manaLimit());
|
|
|
- CSDL_Ext::printAtMiddle(strnew.str(),(pos.x+295),(pos.y+30),FONT_TINY,zwykly,to);
|
|
|
+
|
|
|
+ //Add town income of all towns
|
|
|
+ std::vector<const CGTownInstance*> towns = LOCPLINT->cb->getTownsInfo(true);
|
|
|
+ for(size_t i=0; i<towns.size(); i++)
|
|
|
+ {
|
|
|
+ totalIncome += towns[i]->dailyIncome();
|
|
|
}
|
|
|
- //hero speciality
|
|
|
- blitAt(graphics->un32->ourImages[hero->subID].bitmap, pos.x+375, pos.y+6, to);
|
|
|
-
|
|
|
- for(int i=0; i<hero->secSkills.size(); i++)
|
|
|
- {//secondary skills
|
|
|
- int skill = hero->secSkills[i].first,
|
|
|
- level = hero->secSkills[i].second;
|
|
|
- blitAt(graphics->abils32->ourImages[skill*3+level+2].bitmap,pos.x+411+i*36,pos.y+6,to);
|
|
|
+ for (int i=0; i<7; i++)
|
|
|
+ {
|
|
|
+ std::string value = boost::lexical_cast<std::string>(minesCount[i]);
|
|
|
+ minesBox[i] = new InfoBox(Point(20+i*80, 31+footerPos), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
|
|
+ new InfoBoxCustom(value, "", "OVMINES", i, CGI->generaltexth->mines[i].first));
|
|
|
}
|
|
|
+ incomeArea = new HoverableArea;
|
|
|
+ incomeArea->pos = Rect(pos.x+580, pos.y+31+footerPos, 136, 68);
|
|
|
+ incomeArea->hoverText = CGI->generaltexth->allTexts[255];
|
|
|
+ incomeAmount = new CLabel(628, footerPos + 70, FONT_SMALL, TOPLEFT, zwykly, boost::lexical_cast<std::string>(totalIncome));
|
|
|
+}
|
|
|
|
|
|
- artButtons->show(to);
|
|
|
+void CKingdomInterface::generateButtons()
|
|
|
+{
|
|
|
+ unsigned int footerPos = conf.go()->ac.overviewSize * 116;
|
|
|
|
|
|
- int iter=0;
|
|
|
- switch (artGroup)
|
|
|
- {//arts
|
|
|
- case 1:iter = 9;//misc. arts, spellbook, war machines
|
|
|
- case 0://equipped arts
|
|
|
- /*for (int i = iter ; i<iter+9;i++)
|
|
|
- {
|
|
|
- int artID = hero->getArtTypeId(i);
|
|
|
- if (artID>=0)
|
|
|
- blitAt(graphics->artDefs->ourImages[artID].bitmap,pos.x+268+48*(i%9),pos.y+66,to);
|
|
|
- }*/
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- artLeft->show(to);
|
|
|
- artRight->show(to);
|
|
|
- int max = hero->artifactsInBackpack.size();
|
|
|
- iter = std::min(8, max);
|
|
|
- /*for (size_t it = 0 ; it<iter;it++)
|
|
|
- blitAt(graphics->artDefs->ourImages[hero->artifacts[(it+backpackPos)%max]->id].bitmap,pos.x+293+48*it,pos.y+66,to);
|
|
|
- */break;
|
|
|
- }
|
|
|
- show(to);
|
|
|
+ //Main control buttons
|
|
|
+ btnHeroes = new AdventureMapButton (CGI->generaltexth->overview[11], CGI->generaltexth->overview[6],
|
|
|
+ boost::bind(&CKingdomInterface::activateTab, this, 0),748,28+footerPos,"OVBUTN1.DEF", SDLK_h);
|
|
|
+ btnHeroes->block(true);
|
|
|
+
|
|
|
+ btnTowns = new AdventureMapButton (CGI->generaltexth->overview[12], CGI->generaltexth->overview[7],
|
|
|
+ boost::bind(&CKingdomInterface::activateTab, this, 1),748,64+footerPos,"OVBUTN6.DEF", SDLK_t);
|
|
|
+
|
|
|
+ btnExit = new AdventureMapButton (CGI->generaltexth->allTexts[600],"",
|
|
|
+ boost::bind(&CGuiHandler::popIntTotally,&GH, this),748,99+footerPos,"OVBUTN1.DEF", SDLK_RETURN);
|
|
|
+ btnExit->assignedKeys.insert(SDLK_ESCAPE);
|
|
|
+ btnExit->setOffset(3);
|
|
|
+
|
|
|
+ //Object list control buttons
|
|
|
+ dwellTop = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, 0),
|
|
|
+ 733, 4, "OVBUTN4.DEF");
|
|
|
+
|
|
|
+ dwellBottom = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, -1),
|
|
|
+ 733, footerPos+2, "OVBUTN4.DEF");
|
|
|
+ dwellBottom->setOffset(2);
|
|
|
+
|
|
|
+ dwellUp = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToPrev, dwellingsList),
|
|
|
+ 733, 24, "OVBUTN4.DEF");
|
|
|
+ dwellUp->setOffset(4);
|
|
|
+
|
|
|
+ dwellDown = new AdventureMapButton ("", "", boost::bind(&CListBox::moveToNext, dwellingsList),
|
|
|
+ 733, footerPos-18, "OVBUTN4.DEF");
|
|
|
+ dwellDown->setOffset(6);
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CHeroItem::onArtChange(int newstate)
|
|
|
+void CKingdomInterface::activateTab(size_t which)
|
|
|
{
|
|
|
- if (!hero)
|
|
|
- return;
|
|
|
- deactivate();
|
|
|
- artGroup = newstate;
|
|
|
- activate();
|
|
|
- showAll(screen2);
|
|
|
+ btnHeroes->block(which == 0);
|
|
|
+ btnTowns->block(which == 1);
|
|
|
+ tabArea->setActive(which);
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CHeroItem::activate()
|
|
|
+void CKingdomInterface::townChanged(const CGTownInstance *town)
|
|
|
{
|
|
|
- setHero(hero);
|
|
|
- if (!hero)
|
|
|
- return;
|
|
|
- artButtons->activate();
|
|
|
- garr->activate();/*
|
|
|
- if ( artGroup == 2 )
|
|
|
+ if (CKingdTownList * townList = dynamic_cast<CKingdTownList*>(tabArea->getItem()))
|
|
|
+ townList->townChanged(town);
|
|
|
+}
|
|
|
+
|
|
|
+void CKingdomInterface::updateGarrisons()
|
|
|
+{
|
|
|
+ if (CGarrisonHolder * garrison = dynamic_cast<CGarrisonHolder*>(tabArea->getItem()))
|
|
|
+ garrison->updateGarrisons();
|
|
|
+}
|
|
|
+
|
|
|
+void CKingdomInterface::artifactAssembled(const ArtifactLocation& artLoc)
|
|
|
+{
|
|
|
+ if (CArtifactHolder * arts = dynamic_cast<CArtifactHolder*>(tabArea->getItem()))
|
|
|
+ arts->artifactAssembled(artLoc);
|
|
|
+}
|
|
|
+
|
|
|
+void CKingdomInterface::artifactDisassembled(const ArtifactLocation& artLoc)
|
|
|
+{
|
|
|
+ if (CArtifactHolder * arts = dynamic_cast<CArtifactHolder*>(tabArea->getItem()))
|
|
|
+ arts->artifactDisassembled(artLoc);
|
|
|
+}
|
|
|
+
|
|
|
+void CKingdomInterface::artifactMoved(const ArtifactLocation& artLoc, const ArtifactLocation& destLoc)
|
|
|
+{
|
|
|
+ if (CArtifactHolder * arts = dynamic_cast<CArtifactHolder*>(tabArea->getItem()))
|
|
|
+ arts->artifactMoved(artLoc, destLoc);
|
|
|
+}
|
|
|
+
|
|
|
+void CKingdomInterface::artifactRemoved(const ArtifactLocation& artLoc)
|
|
|
+{
|
|
|
+ if (CArtifactHolder * arts = dynamic_cast<CArtifactHolder*>(tabArea->getItem()))
|
|
|
+ arts->artifactRemoved(artLoc);
|
|
|
+}
|
|
|
+
|
|
|
+class HeroListManager : public IGuiObjectListManager
|
|
|
+{
|
|
|
+ CWindowWithArtifacts * arts;
|
|
|
+ CArtifactsOfHero::SCommonPart * artsCommonPart;
|
|
|
+public:
|
|
|
+ HeroListManager(CWindowWithArtifacts * parent);
|
|
|
+ ~HeroListManager();
|
|
|
+ CIntObject * getObject(size_t position);
|
|
|
+ void removeObject(CIntObject *object);
|
|
|
+};
|
|
|
+
|
|
|
+HeroListManager::HeroListManager(CWindowWithArtifacts * parent)
|
|
|
+{
|
|
|
+ arts = parent;
|
|
|
+ artsCommonPart = new CArtifactsOfHero::SCommonPart;
|
|
|
+}
|
|
|
+
|
|
|
+HeroListManager::~HeroListManager()
|
|
|
+{
|
|
|
+ delete artsCommonPart;
|
|
|
+}
|
|
|
+
|
|
|
+CIntObject * HeroListManager::getObject(size_t position)
|
|
|
+{
|
|
|
+ unsigned int picCount = conf.go()->ac.overviewPics;
|
|
|
+ size_t heroesCount = LOCPLINT->cb->howManyHeroes(false);
|
|
|
+
|
|
|
+ if (position < heroesCount)
|
|
|
{
|
|
|
- artLeft->activate();
|
|
|
- artRight->activate();
|
|
|
- for (size_t i=0; i<8;i++)
|
|
|
- backpack[i]->activate();
|
|
|
+ CHeroItem * hero = new CHeroItem(LOCPLINT->cb->getHeroBySerial(position, false), artsCommonPart);
|
|
|
+ artsCommonPart->participants.insert(hero->heroArts);
|
|
|
+ arts->artSets.push_back(hero->heroArts);
|
|
|
+ return hero;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- for (size_t i=artGroup*9; i<9+artGroup*9;i++)
|
|
|
- artifacts[i]->activate();
|
|
|
- }*/
|
|
|
- portrait->activate();
|
|
|
- experience->activate();
|
|
|
- morale->activate();
|
|
|
- luck->activate();
|
|
|
- spellPoints->activate();
|
|
|
- speciality->activate();
|
|
|
+ return new CAnimImage("OVSLOT", (position-2) % picCount );
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
- for (size_t i=0; i<primarySkills.size();i++)
|
|
|
- primarySkills[i]->activate();
|
|
|
+void HeroListManager::removeObject(CIntObject *object)
|
|
|
+{
|
|
|
+ if (CHeroItem * hero = dynamic_cast<CHeroItem*>(object))
|
|
|
+ {
|
|
|
+ arts->artSets.erase(std::find(arts->artSets.begin(), arts->artSets.end(), hero->heroArts));
|
|
|
+ artsCommonPart->participants.erase(hero->heroArts);
|
|
|
+ }
|
|
|
+ delete object;
|
|
|
+}
|
|
|
|
|
|
- for (size_t i=0; i<std::min(secondarySkills.size(),hero->secSkills.size());i++)
|
|
|
- secondarySkills[i]->activate();
|
|
|
+CKingdHeroList::CKingdHeroList(size_t maxSize)
|
|
|
+{
|
|
|
+ OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
+ title = new CPicture("OVTITLE",16,0);
|
|
|
+ title->colorize(LOCPLINT->playerID);
|
|
|
+ heroLabel = new CLabel(150, 10, FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[0]);
|
|
|
+ skillsLabel = new CLabel(500, 10, FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[1]);
|
|
|
+
|
|
|
+ unsigned int townCount = LOCPLINT->cb->howManyHeroes(false);
|
|
|
+ unsigned int size = conf.go()->ac.overviewSize*116 + 19;
|
|
|
+ heroes = new CListBox(new HeroListManager(this), Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size) );
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CHeroItem::deactivate()
|
|
|
+void CKingdHeroList::updateGarrisons()
|
|
|
{
|
|
|
- if (!hero)
|
|
|
- return;
|
|
|
- artButtons->deactivate();
|
|
|
- garr->deactivate();/*
|
|
|
- if ( artGroup == 2 )
|
|
|
+ std::list<CIntObject*> list = heroes->getItems();
|
|
|
+ BOOST_FOREACH(CIntObject* object, list)
|
|
|
{
|
|
|
- artLeft->deactivate();
|
|
|
- artRight->deactivate();
|
|
|
- for (size_t i=0; i<8;i++)
|
|
|
- backpack[i]->deactivate();
|
|
|
+ if (CGarrisonHolder * garrison = dynamic_cast<CGarrisonHolder*>(object) )
|
|
|
+ garrison->updateGarrisons();
|
|
|
}
|
|
|
- else
|
|
|
+}
|
|
|
+
|
|
|
+class TownListManager : public IGuiObjectListManager
|
|
|
+{
|
|
|
+public:
|
|
|
+ CIntObject * getObject(size_t position)
|
|
|
{
|
|
|
- for (size_t i=artGroup*9; i<9+artGroup*9;i++)
|
|
|
- artifacts[i]->deactivate();
|
|
|
- }*/
|
|
|
+ unsigned int picCount = conf.go()->ac.overviewPics;
|
|
|
+ size_t townsCount = LOCPLINT->cb->howManyTowns();
|
|
|
|
|
|
- portrait->deactivate();
|
|
|
- experience->deactivate();
|
|
|
- morale->deactivate();
|
|
|
- luck->deactivate();
|
|
|
- spellPoints->deactivate();
|
|
|
- speciality->deactivate();
|
|
|
- for (size_t i=0; i<primarySkills.size();i++)
|
|
|
- primarySkills[i]->deactivate();
|
|
|
+ if (position < townsCount)
|
|
|
+ return new CTownItem(LOCPLINT->cb->getTownBySerial(position));
|
|
|
+ else
|
|
|
+ return new CAnimImage("OVSLOT", (position-2) % picCount );
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
- for (size_t i=0; i<std::min(secondarySkills.size(),hero->secSkills.size());i++)
|
|
|
- secondarySkills[i]->deactivate();
|
|
|
+CKingdTownList::CKingdTownList(size_t maxSize)
|
|
|
+{
|
|
|
+ OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
+ title = new CPicture("OVTITLE",16,0);
|
|
|
+ title->colorize(LOCPLINT->playerID);
|
|
|
+ townLabel = new CLabel(146,10,FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[3]);
|
|
|
+ garrHeroLabel = new CLabel(375,10,FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[4]);
|
|
|
+ visitHeroLabel = new CLabel(608,10,FONT_MEDIUM, CENTER, zwykly, CGI->generaltexth->overview[5]);
|
|
|
+
|
|
|
+ unsigned int townCount = LOCPLINT->cb->howManyTowns();
|
|
|
+ unsigned int size = conf.go()->ac.overviewSize*116 + 19;
|
|
|
+ towns = new CListBox(new TownListManager, Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size) );
|
|
|
}
|
|
|
|
|
|
-CKingdomInterface::CHeroItem::CArtPlace::CArtPlace(CHeroItem * owner, const Rect &r)
|
|
|
- : LRClickableAreaWTextComp(r, SComponent::artifact)
|
|
|
+void CKingdTownList::townChanged(const CGTownInstance *town)
|
|
|
{
|
|
|
- parent = owner;
|
|
|
- used = LCLICK | RCLICK | HOVER;
|
|
|
+ std::list<CIntObject*> list = towns->getItems();
|
|
|
+ BOOST_FOREACH(CIntObject* object, list)
|
|
|
+ {
|
|
|
+ CTownItem * townItem = dynamic_cast<CTownItem*>(object);
|
|
|
+ if ( townItem && townItem->town == town)
|
|
|
+ townItem->update();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CHeroItem::CArtPlace::activate()
|
|
|
+void CKingdTownList::updateGarrisons()
|
|
|
{
|
|
|
- LRClickableAreaWTextComp::activate();
|
|
|
+ std::list<CIntObject*> list = towns->getItems();
|
|
|
+ BOOST_FOREACH(CIntObject* object, list)
|
|
|
+ {
|
|
|
+ if (CGarrisonHolder * garrison = dynamic_cast<CGarrisonHolder*>(object) )
|
|
|
+ garrison->updateGarrisons();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CHeroItem::CArtPlace::clickLeft(tribool down, bool previousState)
|
|
|
+CTownItem::CTownItem(const CGTownInstance* Town):
|
|
|
+ town(Town)
|
|
|
{
|
|
|
- if (!down && previousState && type>=0 && type < 145)
|
|
|
- {tlog1<<type;
|
|
|
- if(type == 0)
|
|
|
- {
|
|
|
- CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), parent->hero, LOCPLINT, false);
|
|
|
- GH.pushInt(spellWindow);
|
|
|
- }
|
|
|
- else
|
|
|
- LRClickableAreaWTextComp::clickLeft(down,previousState);
|
|
|
+ OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
+ background = new CAnimImage("OVSLOT", 6);
|
|
|
+ name = new CLabel(74, 8, FONT_SMALL, TOPLEFT, zwykly, town->name);
|
|
|
+
|
|
|
+ income = new CLabel( 190, 60, FONT_SMALL, CENTER, zwykly, boost::lexical_cast<std::string>(town->dailyIncome()));
|
|
|
+ hall = new CTownInfo( 69, 31, town, true);
|
|
|
+ fort = new CTownInfo(111, 31, town, false);
|
|
|
+
|
|
|
+ garr = new CGarrisonInt(313, 3, 4, Point(232,0), NULL, Point(313,2), town->getUpperArmy(), town->visitingHero, true, true, true);
|
|
|
+ heroes = new HeroSlots(town, Point(244,6), Point(475,6), garr, false);
|
|
|
+
|
|
|
+ size_t iconIndex = town->subID*2;
|
|
|
+ if (!town->hasFort())
|
|
|
+ iconIndex += F_NUMBER*2;
|
|
|
+
|
|
|
+ if(town->builded >= MAX_BUILDING_PER_TURN)
|
|
|
+ iconIndex++;
|
|
|
+
|
|
|
+ picture = new CAnimImage("ITPT", iconIndex, 0, 5, 6);
|
|
|
+ townArea = new LRClickableAreaOpenTown;
|
|
|
+ townArea->pos = Rect(pos.x+5, pos.y+6, 58, 64);
|
|
|
+ townArea->town = town;
|
|
|
+
|
|
|
+ for (size_t i=0; i<town->creatures.size(); i++)
|
|
|
+ {
|
|
|
+ growth.push_back(new CCreaInfo(Point(401+37*i, 78), town, i, true, true));
|
|
|
+ available.push_back(new CCreaInfo(Point(48+37*i, 78), town, i, true, false));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CHeroItem::CArtPlace::clickRight(tribool down, bool previousState)
|
|
|
+void CTownItem::updateGarrisons()
|
|
|
{
|
|
|
- if (type>=0 && type < 145)
|
|
|
- LRClickableAreaWTextComp::clickRight(down, previousState);
|
|
|
+ garr->highlighted = NULL;
|
|
|
+ garr->setArmy(town->getUpperArmy(), 0);
|
|
|
+ garr->setArmy(town->visitingHero, 1);
|
|
|
+ garr->recreateSlots();
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CHeroItem::CArtPlace::deactivate()
|
|
|
+void CTownItem::update()
|
|
|
{
|
|
|
- LRClickableAreaWTextComp::deactivate();
|
|
|
+ std::string incomeVal = boost::lexical_cast<std::string>(town->dailyIncome());
|
|
|
+ if (incomeVal != income->text)
|
|
|
+ income->setTxt(incomeVal);
|
|
|
+
|
|
|
+ heroes->update();
|
|
|
+
|
|
|
+ for (size_t i=0; i<town->creatures.size(); i++)
|
|
|
+ {
|
|
|
+ growth[i]->update();
|
|
|
+ available[i]->update();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+class ArtSlotsTab : public CIntObject
|
|
|
+{
|
|
|
+public:
|
|
|
+ CAnimImage * background;
|
|
|
+ std::vector<CArtPlace*> arts;
|
|
|
+
|
|
|
+ ArtSlotsTab()
|
|
|
+ {
|
|
|
+ OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
+ background = new CAnimImage("OVSLOT", 4);
|
|
|
+ pos = background->pos;
|
|
|
+ for (size_t i=0; i<9; i++)
|
|
|
+ arts.push_back(new CArtPlace(Point(270+i*48, 65)));
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
-CKingdomInterface::CTownItem::CCreaPlace::CCreaPlace()
|
|
|
- : LRClickableAreaWTextComp(Rect(0,0,0,0), -1)
|
|
|
+class BackpackTab : public CIntObject
|
|
|
{
|
|
|
- town = NULL;
|
|
|
- used = LCLICK | RCLICK | HOVER;
|
|
|
-}
|
|
|
+public:
|
|
|
+ CAnimImage * background;
|
|
|
+ std::vector<CArtPlace*> arts;
|
|
|
+ AdventureMapButton *btnLeft;
|
|
|
+ AdventureMapButton *btnRight;
|
|
|
+
|
|
|
+ BackpackTab()
|
|
|
+ {
|
|
|
+ OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
+ background = new CAnimImage("OVSLOT", 5);
|
|
|
+ pos = background->pos;
|
|
|
+ btnLeft = new AdventureMapButton(std::string(), std::string(), CFunctionList<void()>(), 269, 66, "HSBTNS3");
|
|
|
+ btnRight = new AdventureMapButton(std::string(), std::string(), CFunctionList<void()>(), 675, 66, "HSBTNS5");
|
|
|
+ for (size_t i=0; i<8; i++)
|
|
|
+ arts.push_back(new CArtPlace(Point(295+i*48, 65)));
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+class HeroItemManager : public CIntObject, public IGuiObjectListManager
|
|
|
+{
|
|
|
+public:
|
|
|
+ ArtSlotsTab* tab1;
|
|
|
+ ArtSlotsTab* tab2;
|
|
|
+ BackpackTab* tab3;
|
|
|
+
|
|
|
+ HeroItemManager(const CGHeroInstance* Hero);
|
|
|
+ CIntObject * getObject(size_t position);
|
|
|
+ void removeObject(CIntObject * object);
|
|
|
+};
|
|
|
|
|
|
-void CKingdomInterface::CTownItem::CCreaPlace::activate()
|
|
|
+HeroItemManager::HeroItemManager(const CGHeroInstance* Hero)
|
|
|
{
|
|
|
- LRClickableAreaWTextComp::activate();
|
|
|
+ OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
+ recActions = 0;
|
|
|
+ defActions = DISPOSE | SHARE_POS;
|
|
|
+
|
|
|
+ tab1 = new ArtSlotsTab;
|
|
|
+ tab2 = new ArtSlotsTab;
|
|
|
+ tab3 = new BackpackTab;
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CTownItem::CCreaPlace::clickLeft(tribool down, bool previousState)
|
|
|
+CIntObject * HeroItemManager::getObject(size_t position)
|
|
|
{
|
|
|
- if (!down && previousState && town)
|
|
|
+ switch (position)
|
|
|
{
|
|
|
- GH.pushInt (new CRecruitmentWindow(town, type, town, boost::bind
|
|
|
- (&CCallback::recruitCreatures,LOCPLINT->cb,town,_1,_2, type)));
|
|
|
+ case 0: return tab1;
|
|
|
+ case 1: return tab2;
|
|
|
+ case 2: return tab3;
|
|
|
+ default: assert(0);
|
|
|
+ return NULL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CTownItem::CCreaPlace::clickRight(tribool down, bool previousState)
|
|
|
+void HeroItemManager::removeObject(CIntObject * object)
|
|
|
+{
|
|
|
+ addChild(object, false);
|
|
|
+}
|
|
|
+
|
|
|
+CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart * artsCommonPart):
|
|
|
+ hero(Hero)
|
|
|
{
|
|
|
- if (down && town)
|
|
|
+ OBJ_CONSTRUCTION_CAPTURING_ALL;
|
|
|
+
|
|
|
+ name = new CLabel(75, 7, FONT_SMALL, TOPLEFT, zwykly, hero->name);
|
|
|
+
|
|
|
+ HeroItemManager *manager = new HeroItemManager(hero);
|
|
|
+
|
|
|
+ std::vector<CArtPlace*> arts;
|
|
|
+ arts.insert(arts.end(), manager->tab1->arts.begin(), manager->tab1->arts.end());
|
|
|
+ arts.insert(arts.end(), manager->tab2->arts.begin(), manager->tab2->arts.end());
|
|
|
+
|
|
|
+ heroArts = new CArtifactsOfHero(arts, manager->tab3->arts, manager->tab3->btnLeft, manager->tab3->btnRight, false);
|
|
|
+ heroArts->commonInfo = artsCommonPart;
|
|
|
+ heroArts->setHero(hero);
|
|
|
+
|
|
|
+ artsTabs = new CTabbedInt(manager);
|
|
|
+
|
|
|
+ artButtons = new CHighlightableButtonsGroup(0);
|
|
|
+ for (size_t it = 0; it<3; it++)
|
|
|
{
|
|
|
- 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];
|
|
|
- GH.pushInt(createCreWindow(crid, 0, town->creatures[type].first));
|
|
|
+ std::map<int,std::string> tooltip;
|
|
|
+ tooltip[0] = CGI->generaltexth->overview[13+it];
|
|
|
+ std::string overlay = CGI->generaltexth->overview[8+it];
|
|
|
+
|
|
|
+ artButtons->addButton(tooltip, overlay, "OVBUTN3",364+it*112, 46, it);
|
|
|
+
|
|
|
+ size_t begin = overlay.find('{');
|
|
|
+ size_t end = overlay.find('}', begin);
|
|
|
+ overlay = overlay.substr(begin+1, end - begin);
|
|
|
+ artButtons->buttons[it]->addTextOverlay(overlay, FONT_SMALL, tytulowy);
|
|
|
}
|
|
|
+ artButtons->onChange += boost::bind(&CTabbedInt::setActive, artsTabs, _1);
|
|
|
+ artButtons->onChange += boost::bind(&CHeroItem::onArtChange, this, _1);
|
|
|
+ artButtons->select(0,0);
|
|
|
+
|
|
|
+ garr = new CGarrisonInt(6, 78, 4, Point(), NULL, Point(), hero, NULL, true, true);
|
|
|
+
|
|
|
+ portrait = new CAnimImage("PortraitsLarge", hero->subID, 0, 5, 6);
|
|
|
+ heroArea = new CHeroArea(5, 6, hero);
|
|
|
+
|
|
|
+ name = new CLabel(73, 7, FONT_SMALL, TOPLEFT, zwykly, hero->name);
|
|
|
+ artsText = new CLabel(320, 55, FONT_SMALL, CENTER, zwykly, CGI->generaltexth->overview[2]);
|
|
|
+
|
|
|
+ for (size_t i=0; i<PRIMARY_SKILLS; i++)
|
|
|
+ heroInfo.push_back(new InfoBox(Point(78+i*36, 26), InfoBox::POS_DOWN, InfoBox::SIZE_SMALL,
|
|
|
+ new InfoBoxHeroData(IInfoBoxData::HERO_PRIMARY_SKILL, hero, i)));
|
|
|
+
|
|
|
+ for (size_t i=0; i<SKILL_PER_HERO; i++)
|
|
|
+ heroInfo.push_back(new InfoBox(Point(410+i*36, 5), InfoBox::POS_NONE, InfoBox::SIZE_SMALL,
|
|
|
+ new InfoBoxHeroData(IInfoBoxData::HERO_SECONDARY_SKILL, hero, i)));
|
|
|
+
|
|
|
+ heroInfo.push_back(new InfoBox(Point(375, 5), InfoBox::POS_NONE, InfoBox::SIZE_SMALL,
|
|
|
+ new InfoBoxHeroData(IInfoBoxData::HERO_SPECIAL, hero)));
|
|
|
+
|
|
|
+ heroInfo.push_back(new InfoBox(Point(330, 5), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
|
|
+ new InfoBoxHeroData(IInfoBoxData::HERO_EXPERIENCE, hero)));
|
|
|
+
|
|
|
+ heroInfo.push_back(new InfoBox(Point(280, 5), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL,
|
|
|
+ new InfoBoxHeroData(IInfoBoxData::HERO_MANA, hero)));
|
|
|
+
|
|
|
+ morale = new MoraleLuckBox(true, Rect(225, 53, 30, 22), true);
|
|
|
+ luck = new MoraleLuckBox(false, Rect(225, 28, 30, 22), true);
|
|
|
+
|
|
|
+ morale->set(hero);
|
|
|
+ luck->set(hero);
|
|
|
}
|
|
|
|
|
|
-void CKingdomInterface::CTownItem::CCreaPlace::deactivate()
|
|
|
+void CHeroItem::onArtChange(int tabIndex)
|
|
|
{
|
|
|
- LRClickableAreaWTextComp::deactivate();
|
|
|
+ //redraw item after background change
|
|
|
+ if (active)
|
|
|
+ redraw();
|
|
|
}
|