CKingdomInterface.cpp 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. #include "CKingdomInterface.h"
  2. #include "AdventureMapButton.h"
  3. #include "CAdvmapInterface.h"
  4. #include "../CCallback.h"
  5. #include "../global.h"
  6. #include "CConfigHandler.h"
  7. #include "CGameInfo.h"
  8. #include "CHeroWindow.h"
  9. #include "CSpellWindow.h"
  10. #include "CMessage.h"
  11. #include "SDL_Extensions.h"
  12. #include "Graphics.h"
  13. #include "../hch/CArtHandler.h"
  14. #include "../hch/CBuildingHandler.h"
  15. #include "../hch/CDefHandler.h"
  16. #include "../hch/CHeroHandler.h"
  17. #include "../hch/CGeneralTextHandler.h"
  18. #include "../hch/CObjectHandler.h"
  19. #include "../hch/CTownHandler.h"
  20. #include "../hch/CHeroHandler.h"
  21. #include "../lib/map.h"
  22. #include "../lib/NetPacks.h"
  23. #include <boost/algorithm/string/replace.hpp>
  24. #include <boost/assign/std/vector.hpp>
  25. #include <boost/assign/list_of.hpp>
  26. #include <boost/lexical_cast.hpp>
  27. #include <boost/format.hpp>
  28. #include <sstream>
  29. using namespace boost::assign;
  30. using namespace CSDL_Ext;
  31. /*
  32. * CKingdomInterface.cpp, part of VCMI engine
  33. *
  34. * Authors: listed in file AUTHORS in main folder
  35. *
  36. * License: GNU General Public License v2.0 or later
  37. * Full text of license available in license.txt file, in main folder
  38. *
  39. */
  40. #define ADVOPT (conf.go()->ac)
  41. CDefEssential* CKingdomInterface::slots;
  42. CDefEssential* CKingdomInterface::fort;
  43. CDefEssential* CKingdomInterface::hall;
  44. CKingdomInterface::CKingdomInterface()
  45. {
  46. OBJ_CONSTRUCTION_CAPTURING_ALL;
  47. defActions = SHARE_POS | DISPOSE;
  48. PicCount = ADVOPT.overviewPics;
  49. size = ADVOPT.overviewSize;
  50. pos.x = screen->w/2 - 400;
  51. pos.y = screen->h/2 - (68+58*size);
  52. showHarrisoned = false;//set to true if you want to see garrisoned heroes
  53. heroPos = townPos = objPos = state = 0;
  54. bg = BitmapHandler::loadBitmap(ADVOPT.overviewBg);
  55. graphics->blueToPlayersAdv(bg, LOCPLINT->playerID);
  56. mines = CDefHandler::giveDefEss("OVMINES.DEF");
  57. title = CDefHandler::giveDefEss("OVTITLE.DEF");
  58. hall = CDefHandler::giveDefEss("ITMTL.DEF");
  59. fort = CDefHandler::giveDefEss("ITMCL.DEF");
  60. objPics = CDefHandler::giveDefEss("FLAGPORT.DEF");
  61. slots = CDefHandler::giveDefEss("OVSLOT.DEF");
  62. toHeroes = new AdventureMapButton (CGI->generaltexth->overview[11],"",
  63. boost::bind(&CKingdomInterface::listToHeroes,this),748,28+size*116,"OVBUTN1.DEF", SDLK_h);
  64. toHeroes->block(2);
  65. toTowns = new AdventureMapButton (CGI->generaltexth->overview[12],"",
  66. boost::bind(&CKingdomInterface::listToTowns,this),748,64+size*116,"OVBUTN6.DEF", SDLK_t);
  67. toTowns->block(0);
  68. exit = new AdventureMapButton (CGI->generaltexth->allTexts[600],"",
  69. boost::bind(&CKingdomInterface::close,this),748,99+size*116,"OVBUTN1.DEF", SDLK_RETURN);
  70. exit->bitmapOffset = 3;
  71. statusbar = new CStatusBar(pos.x+7,pos.y+91+size*116,"TSTATBAR.bmp",732);
  72. resdatabar = new CResDataBar("KRESBAR.bmp",pos.x+3,pos.y+111+size*116,32,2,76,76);
  73. for(size_t i=0;i<size;i++)//creating empty hero/town lists for input
  74. {
  75. heroes.push_back( new CHeroItem(i,this));
  76. towns.push_back( new CTownItem(i,this));
  77. }
  78. slider = new CSlider(4, 4, size*116+19, boost::bind (&CKingdomInterface::sliderMoved, this, _1),
  79. size, LOCPLINT->cb->howManyHeroes(showHarrisoned), 0, false, 0);
  80. //creating objects list
  81. ObjTop = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,0),
  82. 733,4,"OVBUTN4.DEF");
  83. ObjUp = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,1),
  84. 733,24,"OVBUTN4.DEF");
  85. ObjUp->bitmapOffset = 4;
  86. ObjDown = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,2),
  87. 733,size*116-18,"OVBUTN4.DEF");
  88. ObjDown->bitmapOffset = 6;
  89. ObjBottom = new AdventureMapButton ("","", boost::bind(&CKingdomInterface::moveObjectList,this,3),
  90. 733,size*116+2,"OVBUTN4.DEF");
  91. ObjBottom->bitmapOffset = 2;
  92. for (size_t i=0; i<SKILL_PER_HERO; i++)
  93. {
  94. incomes.push_back(new HoverableArea());//bottom panel with mines
  95. incomes[i]->pos = genRect(57,68,pos.x+20+i*80,pos.y+31+size*116);
  96. incomes[i]->hoverText = CGI->generaltexth->mines[i].first;
  97. }
  98. incomes[7]->pos.w = 136;
  99. incomes[7]->hoverText = CGI->generaltexth->allTexts[255];
  100. incomesVal+=0,0,0,0,0,0,0,0;//for mines images
  101. std::map<std::pair<int,int>,int> addObjects;//objects to print, except 17th dwelling
  102. //format: (id,subID),image index
  103. #define INSERT_MAP addObjects.insert(std::pair<std::pair<int,int>,int>(std::pair<int,int>
  104. INSERT_MAP (20,1) ,81));//Golem factory
  105. INSERT_MAP (42,0) ,82));//Lighthouse
  106. INSERT_MAP (33,0) ,83));//Garrison
  107. INSERT_MAP (219,0),83));//Garrison
  108. INSERT_MAP (33,1) ,84));//Anti-magic Garrison
  109. INSERT_MAP (219,1),84));//Anti-magic Garrison
  110. INSERT_MAP (53,7) ,85));//Abandoned mine
  111. INSERT_MAP (20,0) ,86));//Conflux
  112. INSERT_MAP (87,0) ,87));//Harbor
  113. #undef INSERT_MAP
  114. for(size_t i = 0; i<CGI->state->map->objects.size(); i++)//getting mines and dwelling (in one pass to make it faster)
  115. {
  116. CGObjectInstance* obj = CGI->state->map->objects[i];//current object
  117. if (obj)
  118. {
  119. if (obj->tempOwner == CGI->state->currentPlayer)//if object is our
  120. {
  121. std::pair<int,int > curElm = std::pair<int,int >(obj->ID, obj->subID);
  122. if ( obj->ID == 17 )//dwelling, text is a plural name of a creature
  123. {
  124. objList[obj->subID].first += 1;
  125. objList[obj->subID].second = & CGI->creh->creatures[CGI->objh->cregens[obj->subID]].namePl;
  126. }
  127. else if (addObjects.find(curElm) != addObjects.end())
  128. {//object from addObjects map, text is name of the object
  129. objList[addObjects[curElm]].first += 1;
  130. objList[addObjects[curElm]].second = & obj->hoverName;
  131. }
  132. else if ( obj->ID == 53 )//TODO: abandoned mines
  133. incomesVal[obj->subID]+=1;
  134. }
  135. }
  136. }
  137. addObjects.clear();
  138. objSize = (size*116-64)/57; //in object list will fit (height of panel)/(height of one element) items
  139. ObjList.resize(objSize);
  140. for(size_t i=0;i<objSize;i++)
  141. {
  142. ObjList[i] = new HoverableArea();
  143. ObjList[i]->pos = genRect(50,50,pos.x+740,pos.y+44+i*57);
  144. }
  145. incomesVal[7] = incomesVal[6]*1000;//gold mines -> total income
  146. std::vector<const CGHeroInstance*> heroes = LOCPLINT->cb->getHeroesInfo(true);
  147. for(size_t i=0; i<heroes.size();i++)
  148. switch(heroes[i]->getSecSkillLevel(13))//some heroes may have estates
  149. {
  150. case 1: //basic
  151. incomesVal[7] += 125;
  152. break;
  153. case 2: //advanced
  154. incomesVal[7] += 250;
  155. break;
  156. case 3: //expert
  157. incomesVal[7] += 500;
  158. break;
  159. }
  160. std::vector<const CGTownInstance*> towns = LOCPLINT->cb->getTownsInfo(true);
  161. for(size_t i=0; i<towns.size();i++)
  162. incomesVal[7] += towns[i]->dailyIncome();
  163. }
  164. void CKingdomInterface::moveObjectList(int newPos)
  165. {
  166. int top = objList.size() > objSize ? 0 : objList.size() - objSize ;
  167. int bottom = objList.size() > objSize ? objList.size() - objSize : 0 ;
  168. switch (newPos)//checking what button was pressed
  169. {
  170. /* Top */ case 0: objPos = top;
  171. break;
  172. /* Up */ case 1: objPos = objPos==top?top:(objPos-1);
  173. break;
  174. /* Down */ case 2: objPos = objPos==bottom?bottom:(objPos+1);
  175. break;
  176. /*Bottom*/ case 3: objPos = bottom;
  177. break;
  178. }
  179. showAll(screen2);
  180. }
  181. CKingdomInterface::~CKingdomInterface()
  182. {
  183. SDL_FreeSurface(bg);
  184. delete title;//deleting .def
  185. delete slots;
  186. delete fort;
  187. delete hall;
  188. delete objPics;
  189. delete mines;
  190. towns.clear();//deleting lists
  191. heroes.clear();
  192. incomes.clear();
  193. ObjList.clear();
  194. objList.clear();
  195. }
  196. void CKingdomInterface::close()
  197. {
  198. GH.popIntTotally(this);
  199. }
  200. void CKingdomInterface::showAll( SDL_Surface * to/*=NULL*/)
  201. {
  202. LOCPLINT->adventureInt->resdatabar.draw(to);
  203. blitAt(bg,pos,to);
  204. resdatabar->draw(to);
  205. toTowns->show(to);
  206. toHeroes->show(to);
  207. exit->show(to);
  208. ObjTop->show(to);
  209. ObjUp->show(to);
  210. ObjDown->show(to);
  211. ObjBottom->show(to);
  212. for (size_t i=0; i<ObjList.size(); i++)//list may be moved, recreate hover text
  213. ObjList[i]->hoverText = "";
  214. int skipCount=0, curPos=objPos<0?(-objPos):0;
  215. for (std::map<int,std::pair<int, std::string*> >::iterator it=objList.begin(); it!= objList.end(); it++)
  216. {
  217. if (skipCount<objPos)//we will show only objects from objPos
  218. {
  219. skipCount++;
  220. continue;
  221. }
  222. blitAt(objPics->ourImages[(*it).first].bitmap,pos.x+740,pos.y+44+curPos*57,to);
  223. std::ostringstream ostrs;//objects count
  224. ostrs << (*it).second.first;
  225. CSDL_Ext::printTo(ostrs.str(),pos.x+790,pos.y+94+curPos*57,FONT_SMALL,zwykly,to);
  226. ObjList[curPos]->hoverText = * (*it).second.second;
  227. curPos++;
  228. if (curPos == objSize)
  229. break;
  230. }
  231. if (state == 1)
  232. {//printing text "Town", "Harrisoned hero", "Visiting hero"
  233. CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[3],pos.x+144,pos.y+14,FONT_MEDIUM,zwykly,to);
  234. CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[4],pos.x+373,pos.y+14,FONT_MEDIUM,zwykly,to);
  235. CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[5],pos.x+606,pos.y+14,FONT_MEDIUM,zwykly,to);
  236. for (size_t i=0; i<size; i++)
  237. towns[i]->showAll(to);//show town list
  238. }
  239. else
  240. {//text "Hero/stats" and "Skills"
  241. CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[0],pos.x+150,pos.y+14,FONT_MEDIUM,zwykly,to);
  242. CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[1],pos.x+500,pos.y+14,FONT_MEDIUM,zwykly,to);
  243. for (size_t i=0; i<size; i++)
  244. heroes[i]->showAll(to);//show hero list
  245. }
  246. for (int i = 0; i<7; i++)
  247. blitAt(mines->ourImages[i].bitmap,pos.x + 20 + i*80,pos.y + 31+size*116,to);
  248. for(size_t i=0;i<incomes.size();i++)
  249. {
  250. std::ostringstream oss;
  251. oss << incomesVal[i];
  252. CSDL_Ext::printAtMiddle(oss.str(),incomes[i]->pos.x+incomes[i]->pos.w/2,incomes[i]->pos.y+50,FONT_SMALL,zwykly,to);
  253. }
  254. slider->showAll(to);
  255. if(screen->w != 800 || screen->h !=600)
  256. CMessage::drawBorder(LOCPLINT->playerID,to,828,136+116*size+29,pos.x-14,pos.y-15);
  257. show(to);
  258. }
  259. void CKingdomInterface::show(SDL_Surface * to)
  260. {
  261. statusbar->show(to);
  262. }
  263. void CKingdomInterface::activate()
  264. {
  265. LOCPLINT->statusbar = statusbar;
  266. exit->activate();
  267. toTowns->activate();
  268. toHeroes->activate();
  269. ObjTop->activate();
  270. ObjUp->activate();
  271. ObjDown->activate();
  272. ObjBottom->activate();
  273. for (size_t i=0; i<ObjList.size(); i++)
  274. ObjList[i]->activate();
  275. for (size_t i=0; i<incomes.size(); i++)
  276. incomes[i]->activate();
  277. if (state == 1)
  278. for (size_t i=0; i<size; i++)
  279. towns[i]->activate();
  280. else
  281. for (size_t i=0; i<size; i++)
  282. heroes[i]->activate();
  283. slider->activate();
  284. }
  285. void CKingdomInterface::deactivate()
  286. {
  287. exit->deactivate();
  288. toTowns->deactivate();
  289. toHeroes->deactivate();
  290. ObjTop->deactivate();
  291. ObjUp->deactivate();
  292. ObjDown->deactivate();
  293. ObjBottom->deactivate();
  294. for (size_t i=0; i<ObjList.size(); i++)
  295. ObjList[i]->deactivate();
  296. for (size_t i=0; i<incomes.size(); i++)
  297. incomes[i]->deactivate();
  298. if (state == 1)
  299. for (size_t i=0; i<size; i++)
  300. towns[i]->deactivate();
  301. else
  302. for (size_t i=0; i<size; i++)
  303. heroes[i]->deactivate();
  304. slider->deactivate();
  305. }
  306. void CKingdomInterface::recreateHeroList(int pos)
  307. {
  308. std::vector<const CGHeroInstance*> Heroes = LOCPLINT->cb->getHeroesInfo(true);
  309. int i=0, cnt=0;
  310. for (size_t j = 0; ((j<Heroes.size()) && (i<size));j++)
  311. {
  312. if (Heroes[j]->inTownGarrison && (!showHarrisoned))//if hero in garrison and we don't show them
  313. continue;
  314. if (cnt<pos)//skipping heroes
  315. {
  316. cnt++;
  317. continue;
  318. }//this hero will be added
  319. heroes[i]->setHero(Heroes[j]);
  320. i++;
  321. }
  322. for (i;i<size;i++)//if we still have empty pieces
  323. heroes[i]->setHero(NULL);//empty pic
  324. }
  325. void CKingdomInterface::recreateTownList(int pos)
  326. {
  327. std::vector<const CGTownInstance*> Towns = LOCPLINT->cb->getTownsInfo(false);
  328. for(size_t i=0;i<size;i++)
  329. {
  330. if (i+pos<LOCPLINT->cb->howManyTowns())
  331. towns[i]->setTown(Towns[i+pos]);//replace town
  332. else
  333. towns[i]->setTown(NULL);//only empty pic
  334. }
  335. }
  336. void CKingdomInterface::listToTowns()
  337. {
  338. state = 1;
  339. toHeroes->block(0);
  340. toTowns->block(2);
  341. heroPos = slider->value;
  342. slider->setAmount(LOCPLINT->cb->howManyTowns());
  343. slider->value=townPos;//moving slider
  344. recreateTownList(townPos);
  345. for (size_t i=0;i<size;i++)
  346. {
  347. heroes[i]->deactivate();
  348. towns[i]->activate();
  349. }
  350. showAll(screen2);
  351. }
  352. void CKingdomInterface::listToHeroes()
  353. {
  354. state = 2;
  355. toHeroes->block(2);
  356. toTowns->block(0);
  357. townPos = slider->value;
  358. slider->setAmount(LOCPLINT->cb->howManyHeroes(showHarrisoned));
  359. slider->value=heroPos;//moving slider
  360. recreateHeroList(heroPos);
  361. for (size_t i=0;i<size;i++)
  362. {
  363. towns[i]->deactivate();
  364. heroes[i]->activate();
  365. }
  366. showAll(screen2);
  367. }
  368. void CKingdomInterface::sliderMoved(int newpos)
  369. {
  370. if (state == 0)
  371. {
  372. townPos = newpos;
  373. recreateHeroList(newpos);
  374. state = 2;
  375. }
  376. else if ( state == 1 )//towns
  377. {
  378. for (size_t i=0; i<size; i++)
  379. towns[i]->deactivate();
  380. townPos = newpos;
  381. recreateTownList(newpos);
  382. for (size_t i=0; i<size; i++)
  383. towns[i]->activate();
  384. showAll(screen2);
  385. }
  386. else//heroes
  387. {
  388. for (size_t i=0; i<size; i++)
  389. heroes[i]->deactivate();
  390. heroPos = newpos;
  391. recreateHeroList(newpos);
  392. for (size_t i=0; i<size; i++)
  393. heroes[i]->activate();
  394. showAll(screen2);
  395. }
  396. }
  397. CKingdomInterface::CTownItem::CTownItem(int num, CKingdomInterface * Owner)
  398. {
  399. recActions = DISPOSE | SHARE_POS;
  400. owner = Owner;
  401. numb = num;
  402. pos.x += 23;
  403. pos.y += 25+num*116;
  404. pos.w = 702;
  405. pos.h = 114;
  406. town = NULL;
  407. garr = NULL;
  408. garrHero = new LRClickableAreaOpenHero();
  409. garrHero->pos = genRect(64, 58, pos.x+244, pos.y + 6);
  410. visitHero = new LRClickableAreaOpenHero();
  411. visitHero->pos = genRect(64, 58, pos.x+476, pos.y + 6);
  412. for (int i=0; i<CREATURES_PER_TOWN;i++)
  413. {//creatures info
  414. creaGrowth.push_back(new HoverableArea());
  415. creaGrowth[i]->pos = genRect(32, 32, pos.x+56+i*37, pos.y + 78);
  416. creaCount.push_back(new CCreaPlace());
  417. creaCount[i]->pos = genRect(32, 32, pos.x+409+i*37, pos.y + 78);
  418. creaCount[i]->type = i;
  419. }
  420. hallArea = new HoverableArea();
  421. hallArea->pos = genRect(38, 38, pos.x+69, pos.y + 31);
  422. fortArea = new HoverableArea();
  423. fortArea->pos = genRect(38, 38, pos.x+111, pos.y + 31);
  424. townImage = new LRClickableAreaOpenTown();
  425. townImage->pos = genRect(64, 58, pos.x+5, pos.y + 6);
  426. incomeArea = new HoverableArea();
  427. incomeArea->pos = genRect(42, 64, pos.x+154, pos.y + 31);
  428. incomeArea->hoverText = CGI->generaltexth->allTexts[255];
  429. }
  430. CKingdomInterface::CTownItem::~CTownItem()
  431. {
  432. creaGrowth.clear();
  433. creaCount.clear();
  434. delete garr;
  435. }
  436. void CKingdomInterface::CTownItem::setTown(const CGTownInstance * newTown)
  437. {
  438. BLOCK_CAPTURING;
  439. delete garr;
  440. town = newTown;
  441. if (!town)
  442. {
  443. return;
  444. garr = NULL;
  445. }
  446. garr = new CGarrisonInt(pos.x+313,pos.y+3,4,Point(232,0),slots->ourImages[owner->PicCount+2].bitmap,Point(313,2),town,town->visitingHero,true,true, 4,Point(-126,37));
  447. garr->update = true;
  448. char buf[400];
  449. if (town->garrisonHero)
  450. {
  451. garrHero->hero = town->garrisonHero;
  452. sprintf(buf, CGI->generaltexth->allTexts[15].c_str(), town->garrisonHero->name.c_str(), town->garrisonHero->type->heroClass->name.c_str());
  453. garrHero->hoverText = buf;
  454. }
  455. if (town->visitingHero)
  456. {
  457. visitHero->hero = town->visitingHero;
  458. sprintf(buf, CGI->generaltexth->allTexts[15].c_str(), town->visitingHero->name.c_str(), town->visitingHero->type->heroClass->name.c_str());
  459. visitHero->hoverText = buf;
  460. }
  461. for (int i=0; i<CREATURES_PER_TOWN;i++)
  462. {
  463. creaCount[i]->town = NULL;
  464. int crid = -1;
  465. if (vstd::contains(town->builtBuildings,30+i+CREATURES_PER_TOWN))
  466. crid = town->town->upgradedCreatures[i];
  467. else
  468. crid = town->town->basicCreatures[i];
  469. std::string descr=CGI->generaltexth->allTexts[588];
  470. boost::algorithm::replace_first(descr,"%s",CGI->creh->creatures[crid].namePl);
  471. creaGrowth[i]->hoverText = descr;
  472. descr=CGI->generaltexth->heroscrn[1];
  473. boost::algorithm::replace_first(descr,"%s",CGI->creh->creatures[crid].namePl);
  474. creaCount[i]->hoverText = descr;
  475. creaCount[i]->town = town;
  476. }
  477. townImage->hoverText = town->name;
  478. townImage->town = town;
  479. hallArea->hoverText = CGI->buildh->buildings[town->subID][10+town->hallLevel()]->Name();
  480. if (town->hasFort())
  481. fortArea->hoverText = CGI->buildh->buildings[town->subID][6+town->fortLevel()]->Name();
  482. else
  483. fortArea->hoverText = "";
  484. }
  485. void CKingdomInterface::CTownItem::activate()
  486. {
  487. if (!town)
  488. return;
  489. setTown(town);
  490. hallArea->activate();
  491. fortArea->activate();
  492. incomeArea->activate();
  493. townImage->activate();
  494. if (town->garrisonHero)
  495. garrHero->activate();
  496. if (town->visitingHero)
  497. visitHero->activate();
  498. for (int i=0; i<CREATURES_PER_TOWN;i++)
  499. if (vstd::contains(town->builtBuildings,30+i))
  500. {
  501. creaGrowth[i]->activate();
  502. creaCount [i]->activate();
  503. }
  504. garr->activate();
  505. }
  506. void CKingdomInterface::CTownItem::deactivate()
  507. {
  508. if (!town)
  509. return;
  510. hallArea->deactivate();
  511. fortArea->deactivate();
  512. incomeArea->deactivate();
  513. townImage->deactivate();
  514. if (town->garrisonHero)
  515. garrHero->deactivate();
  516. if (town->visitingHero)
  517. visitHero->deactivate();
  518. for (int i=0; i<CREATURES_PER_TOWN;i++)
  519. if (vstd::contains(town->builtBuildings,30+i))
  520. {
  521. creaGrowth[i]->deactivate();
  522. creaCount [i]->deactivate();
  523. } garr->deactivate();
  524. }
  525. void CKingdomInterface::CTownItem::showAll(SDL_Surface * to)
  526. {
  527. if (!town)
  528. {//if NULL - print background & exit
  529. blitAt(slots->ourImages[numb % owner->PicCount].bitmap,pos.x,pos.y,to);
  530. return;
  531. }//background
  532. blitAt(slots->ourImages[owner->PicCount+2].bitmap,pos.x,pos.y,to); garr->show(to);
  533. //town pic/name
  534. int townPic = town->subID*2;
  535. if (!town->hasFort())
  536. townPic += F_NUMBER*2;
  537. if(town->builded >= MAX_BUILDING_PER_TURN)
  538. townPic++;
  539. blitAt(graphics->bigTownPic->ourImages[townPic].bitmap,pos.x+5,pos.y+6,to);
  540. CSDL_Ext::printAt(town->name,pos.x+73,pos.y+8,FONT_SMALL,zwykly,to);
  541. //fort pic
  542. townPic = town->fortLevel()-1;
  543. if (townPic==-1) townPic = 3;
  544. blitAt(fort->ourImages[townPic].bitmap,pos.x+111,pos.y+31,to);
  545. //hall pic
  546. townPic = town->hallLevel();
  547. blitAt(hall->ourImages[townPic].bitmap,pos.x+69,pos.y+31,to);
  548. //income pic
  549. std::ostringstream oss;
  550. oss << town->dailyIncome();
  551. CSDL_Ext::printAtMiddle(oss.str(),pos.x+189,pos.y+61,FONT_SMALL,zwykly,to);
  552. std::vector<std::string> * toPrin = CMessage::breakText(CGI->generaltexth->allTexts[265]);
  553. CSDL_Ext::printAt((*toPrin)[0], pos.x+4, pos.y+76, FONT_SMALL, tytulowy, to);
  554. if(toPrin->size()!=1)
  555. CSDL_Ext::printAt((*toPrin)[1], pos.x+4, pos.y+92, FONT_SMALL, tytulowy, to);
  556. delete toPrin;
  557. toPrin = CMessage::breakText(CGI->generaltexth->allTexts[266]);
  558. CSDL_Ext::printAt((*toPrin)[0], pos.x+351, pos.y+76, FONT_SMALL, tytulowy, to);
  559. if(toPrin->size()!=1)
  560. CSDL_Ext::printAt((*toPrin)[1], pos.x+351, pos.y+92, FONT_SMALL, tytulowy, to);
  561. delete toPrin;
  562. for (int i=0; i<CREATURES_PER_TOWN;i++)
  563. {//creatures info
  564. int crid = -1;
  565. int bid = 30+i;
  566. if (!vstd::contains(town->builtBuildings,bid))
  567. continue;
  568. if (vstd::contains(town->builtBuildings,bid+CREATURES_PER_TOWN))
  569. {
  570. crid = town->town->upgradedCreatures[i];
  571. bid += CREATURES_PER_TOWN;
  572. }
  573. else
  574. crid = town->town->basicCreatures[i];
  575. //creature growth
  576. blitAt(graphics->smallImgs[crid],pos.x+56+i*37,pos.y+78,to);
  577. std::ostringstream oss;
  578. oss << '+' << town->creatureGrowth(i);
  579. CSDL_Ext::printTo(oss.str(),pos.x+87+i*37,pos.y+110,FONT_TINY,zwykly,to);
  580. //creature available
  581. blitAt(graphics->smallImgs[crid],pos.x+409+i*37,pos.y+78,to);
  582. std::ostringstream ostrs;
  583. ostrs << town->creatures[i].first;
  584. CSDL_Ext::printTo(ostrs.str(),pos.x+440+i*37,pos.y+110,FONT_TINY,zwykly,to);
  585. }
  586. if (town->garrisonHero)
  587. blitAt(graphics->portraitLarge[town->garrisonHero->portrait],pos.x+244,pos.y+6,to);
  588. if (town->visitingHero)
  589. blitAt(graphics->portraitLarge[town->visitingHero->portrait],pos.x+476,pos.y+6,to);
  590. }
  591. CKingdomInterface::CHeroItem::CHeroItem(int num, CKingdomInterface * Owner)
  592. {
  593. OBJ_CONSTRUCTION_CAPTURING_ALL;
  594. recActions = DISPOSE | SHARE_POS;
  595. defActions = SHARE_POS;
  596. owner = Owner;
  597. numb = num;
  598. pos.x += 23;
  599. pos.y += 25+num*116;
  600. pos.w = 702;
  601. pos.h = 114;
  602. hero = NULL;
  603. garr = NULL;
  604. artGroup = 0;
  605. backpackPos = 0;
  606. artButtons = new CHighlightableButtonsGroup(0);
  607. for (size_t it = 0; it<3; it++)
  608. {
  609. artButtons->addButton(boost::assign::map_list_of(0,CGI->generaltexth->overview[13+it]),
  610. CGI->generaltexth->overview[8+it], "OVBUTN3.DEF",364+it*112, 46, it);
  611. std::string str = CGI->generaltexth->overview[8+it];//TODO:find function for this if any
  612. str = str.substr(str.find_first_of("{"), str.find_first_of("}")-str.find_first_of("{"));
  613. artButtons->buttons[it]->addTextOverlay(str, FONT_SMALL, tytulowy);
  614. }
  615. artButtons->onChange = boost::bind(&CKingdomInterface::CHeroItem::onArtChange, this, _1);
  616. artButtons->select(0,0);
  617. artLeft = new AdventureMapButton("", "", boost::bind
  618. (&CKingdomInterface::CHeroItem::scrollArts,this,-1), 269, 66, "hsbtns3.def", SDLK_LEFT);
  619. artRight = new AdventureMapButton("", "", boost::bind
  620. (&CKingdomInterface::CHeroItem::scrollArts,this,+1), 675, 66, "hsbtns5.def", SDLK_RIGHT);
  621. portrait = new LRClickableAreaOpenHero();
  622. portrait->pos = genRect(64, 58, pos.x+5, pos.y + 5);
  623. char bufor[400];
  624. for(int i=0; i<PRIMARY_SKILLS; i++)
  625. {
  626. primarySkills.push_back(new LRClickableAreaWTextComp());
  627. primarySkills[i]->pos = genRect(45, 32, pos.x+77 + 36*i, pos.y+26);
  628. primarySkills[i]->text = CGI->generaltexth->arraytxt[2+i];
  629. primarySkills[i]->type = i;
  630. primarySkills[i]->baseType = 0;
  631. sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), CGI->generaltexth->primarySkillNames[i].c_str());
  632. primarySkills[i]->hoverText = std::string(bufor);
  633. };
  634. experience = new LRClickableAreaWText();
  635. experience->pos = genRect(33, 49, pos.x+322, pos.y+5);
  636. experience->hoverText = CGI->generaltexth->heroscrn[9];
  637. morale = new LRClickableAreaWTextComp();
  638. morale->pos = genRect(20,32,pos.x+221,pos.y+52);
  639. luck = new LRClickableAreaWTextComp();
  640. luck->pos = genRect(20,32,pos.x+221,pos.y+28);
  641. spellPoints = new LRClickableAreaWText();
  642. spellPoints->pos = genRect(33, 49, pos.x+270, pos.y+5);
  643. spellPoints->hoverText = CGI->generaltexth->heroscrn[22];
  644. speciality = new LRClickableAreaWText();
  645. speciality->pos = genRect(32, 32, pos.x+374, pos.y+5);
  646. speciality->hoverText = CGI->generaltexth->heroscrn[27];
  647. for(int i=0; i<SKILL_PER_HERO; ++i)
  648. {
  649. secondarySkills.push_back(new LRClickableAreaWTextComp());
  650. secondarySkills[i]->pos = genRect(32, 32, pos.x+410+i*37, pos.y+5);
  651. secondarySkills[i]->baseType = 1;
  652. };
  653. for (int i=0; i<18;i++)
  654. {
  655. artifacts.push_back(new CArtPlace(this));
  656. artifacts[i]->pos = genRect(44, 44, pos.x+268+(i%9)*48, pos.y+66);
  657. artifacts[i]->baseType = SComponent::artifact;
  658. };
  659. for (int i=0; i<8;i++)
  660. {
  661. backpack.push_back(new CArtPlace(this));
  662. backpack[i]->pos = genRect(44, 44, pos.x+293+(i%9)*48, pos.y+66);
  663. backpack[i]->baseType = SComponent::artifact;
  664. };
  665. }
  666. CKingdomInterface::CHeroItem::~CHeroItem()
  667. {
  668. delete garr;
  669. delete artButtons;
  670. primarySkills.clear();
  671. secondarySkills.clear();
  672. artifacts.clear();
  673. backpack.clear();
  674. }
  675. void CKingdomInterface::CHeroItem::setHero(const CGHeroInstance * newHero)
  676. {
  677. BLOCK_CAPTURING;
  678. delete garr;
  679. hero = newHero;
  680. if (!hero)
  681. {
  682. return;
  683. garr = NULL;
  684. }
  685. char bufor[4000];
  686. artLeft->block(hero->artifacts.size() <= 8);
  687. artRight->block(hero->artifacts.size() <= 8);
  688. garr = new CGarrisonInt(pos.x+6, pos.y+78, 4, Point(), slots->ourImages[owner->PicCount].bitmap,
  689. Point(6,78), hero, NULL, true, true);
  690. for (int i=0; i<artifacts.size(); i++)
  691. {
  692. artifacts[i]->type = hero->getArtAtPos(i);
  693. if (artifacts[i]->type<0)
  694. artifacts[i]->hoverText = CGI->generaltexth->heroscrn[11];
  695. else
  696. {
  697. artifacts[i]->text = CGI->generaltexth->artifDescriptions[artifacts[i]->type];
  698. artifacts[i]->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1].c_str()) % CGI->arth->artifacts[artifacts[i]->type].Name());
  699. }
  700. }
  701. for (int i=0; i<backpack.size(); i++)
  702. {
  703. backpack[i]->type = hero->getArtAtPos(19+i);
  704. if (backpack[i]->type<0)
  705. backpack[i]->hoverText ="";
  706. else
  707. {
  708. backpack[i]->text = CGI->generaltexth->artifDescriptions[backpack[i]->type];
  709. backpack[i]->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1].c_str()) % CGI->arth->artifacts[backpack[i]->type].Name());
  710. }
  711. }
  712. sprintf(bufor, CGI->generaltexth->allTexts[15].c_str(), hero->name.c_str(), hero->type->heroClass->name.c_str());
  713. portrait->hoverText = std::string(bufor);
  714. portrait->hero = hero;
  715. speciality->text = CGI->generaltexth->hTxts[hero->subID].longBonus;
  716. //primary skills
  717. for(size_t g=0; g<primarySkills.size(); ++g)
  718. primarySkills[g]->bonus = hero->getPrimSkillLevel(g);
  719. //secondary skills
  720. for(size_t g=0; g<std::min(secondarySkills.size(),hero->secSkills.size()); ++g)
  721. {
  722. int skill = hero->secSkills[g].first,
  723. level = hero->secSkills[g].second;
  724. secondarySkills[g]->type = skill;
  725. secondarySkills[g]->bonus = level;
  726. secondarySkills[g]->text = CGI->generaltexth->skillInfoTexts[skill][level-1];
  727. sprintf(bufor, CGI->generaltexth->heroscrn[21].c_str(), CGI->generaltexth->levels[level-1].c_str(), CGI->generaltexth->skillName[skill].c_str());
  728. secondarySkills[g]->hoverText = std::string(bufor);
  729. }
  730. //experience
  731. experience->text = CGI->generaltexth->allTexts[2].c_str();
  732. boost::replace_first(experience->text, "%d", boost::lexical_cast<std::string>(hero->level));
  733. boost::replace_first(experience->text, "%d", boost::lexical_cast<std::string>(CGI->heroh->reqExp(hero->level+1)));
  734. boost::replace_first(experience->text, "%d", boost::lexical_cast<std::string>(hero->exp));
  735. //spell points
  736. sprintf(bufor, CGI->generaltexth->allTexts[205].c_str(), hero->name.c_str(), hero->mana, hero->manaLimit());
  737. spellPoints->text = std::string(bufor);
  738. //setting morale
  739. std::vector<std::pair<int,std::string> > mrl = hero->getCurrentMoraleModifiers();
  740. int mrlv = hero->getCurrentMorale();
  741. int mrlt = (mrlv>0)-(mrlv<0); //signum: -1 - bad morale, 0 - neutral, 1 - good
  742. morale->hoverText = CGI->generaltexth->heroscrn[4 - mrlt];
  743. morale->baseType = SComponent::morale;
  744. morale->bonus = mrlv;
  745. morale->text = CGI->generaltexth->arraytxt[88];
  746. boost::algorithm::replace_first(morale->text,"%s",CGI->generaltexth->arraytxt[86-mrlt]);
  747. if (!mrl.size())
  748. morale->text += CGI->generaltexth->arraytxt[108];
  749. else
  750. for(int it=0; it < mrl.size(); it++)
  751. morale->text += mrl[it].second;
  752. //setting luck
  753. mrl = hero->getCurrentLuckModifiers();
  754. mrlv = hero->getCurrentLuck();
  755. mrlt = (mrlv>0)-(mrlv<0); //signum: -1 - bad luck, 0 - neutral, 1 - good
  756. luck->hoverText = CGI->generaltexth->heroscrn[7 - mrlt];
  757. luck->baseType = SComponent::luck;
  758. luck->bonus = mrlv;
  759. luck->text = CGI->generaltexth->arraytxt[62];
  760. boost::algorithm::replace_first(luck->text,"%s",CGI->generaltexth->arraytxt[60-mrlt]);
  761. if (!mrl.size())
  762. luck->text += CGI->generaltexth->arraytxt[77];
  763. else
  764. for(int it=0; it < mrl.size(); it++)
  765. luck->text += mrl[it].second;
  766. }
  767. void CKingdomInterface::CHeroItem::scrollArts(int move)
  768. {
  769. backpackPos = ( backpackPos + move + hero->artifacts.size()) % hero->artifacts.size();
  770. for (int i=0; i<backpack.size(); i++)
  771. {
  772. backpack[i]->type = hero->getArtAtPos(19+(backpackPos + i)%hero->artifacts.size());
  773. if (backpack[i]->type<0)
  774. backpack[i]->hoverText ="";
  775. else
  776. {
  777. backpack[i]->text = CGI->generaltexth->artifDescriptions[backpack[i]->type];
  778. backpack[i]->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1].c_str()) % CGI->arth->artifacts[backpack[i]->type].Name());
  779. }
  780. }
  781. showAll(screen2);
  782. }
  783. void CKingdomInterface::CHeroItem::showAll(SDL_Surface * to)
  784. {
  785. if (!hero)
  786. {//if we have no hero for this slot - print background & exit
  787. blitAt(slots->ourImages[numb % owner->PicCount].bitmap,pos.x,pos.y,to);
  788. return;
  789. }//print background, different for arts view/backpack mode
  790. blitAt(slots->ourImages[(artGroup!=2)?owner->PicCount:(owner->PicCount+1)].bitmap,pos.x,pos.y,to);
  791. //text "Artifacts"
  792. CSDL_Ext::printAtMiddle(CGI->generaltexth->overview[2],pos.x+320,pos.y+55,FONT_SMALL,zwykly,to);
  793. blitAt(graphics->portraitLarge[hero->portrait],pos.x+5,pos.y+6,to);
  794. garr->show(to);
  795. //hero name
  796. CSDL_Ext::printAt(hero->name,pos.x+73,pos.y+7,FONT_SMALL,zwykly,to);
  797. for (int i = 0; i<6; i++)
  798. {//primary skills, mana and exp. pics
  799. blitAt(graphics->pskillst->ourImages[i].bitmap,(i<4)?(pos.x+78+36*i):(pos.x+539-52*i),
  800. (i<4)?(pos.y+26):(pos.y+6),to);
  801. if (i>3) continue;//primary skills text
  802. std::ostringstream str;
  803. str << (hero->primSkills[i]);
  804. CSDL_Ext::printAtMiddle(str.str(),pos.x+94+36*i,pos.y+66,FONT_SMALL,zwykly,to);
  805. }
  806. {//luck and morale pics, experience and mana text
  807. blitAt(graphics->luck30->ourImages[hero->getCurrentLuck()+3].bitmap,pos.x+222,pos.y+30,to);
  808. blitAt(graphics->morale30->ourImages[hero->getCurrentMorale()+3].bitmap,pos.x+222,pos.y+54,to);
  809. std::ostringstream str;
  810. str << (hero->exp);
  811. CSDL_Ext::printAtMiddle(str.str(),(pos.x+348),(pos.y+31),FONT_TINY,zwykly,to);
  812. std::ostringstream strnew;
  813. strnew << (hero->mana)<<"/"<<(hero->manaLimit());
  814. CSDL_Ext::printAtMiddle(strnew.str(),(pos.x+295),(pos.y+30),FONT_TINY,zwykly,to);
  815. }
  816. //hero speciality
  817. blitAt(graphics->un32->ourImages[hero->subID].bitmap, pos.x+375, pos.y+6, to);
  818. for(int i=0; i<hero->secSkills.size(); i++)
  819. {//secondary skills
  820. int skill = hero->secSkills[i].first,
  821. level = hero->secSkills[i].second;
  822. blitAt(graphics->abils32->ourImages[skill*3+level+2].bitmap,pos.x+411+i*36,pos.y+6,to);
  823. }
  824. artButtons->show(to);
  825. int iter=0;
  826. switch (artGroup)
  827. {//arts
  828. case 1:iter = 9;//misc. arts, spellbook, war machines
  829. case 0://equipped arts
  830. for (int i = iter ; i<iter+9;i++)
  831. {
  832. int artID = hero->getArtAtPos(i);
  833. if (artID>=0)
  834. blitAt(graphics->artDefs->ourImages[artID].bitmap,pos.x+268+48*(i%9),pos.y+66,to);
  835. }
  836. break;
  837. case 2:
  838. artLeft->show(to);
  839. artRight->show(to);
  840. int max = hero->artifacts.size();
  841. iter = std::min(8, max);
  842. for (size_t it = 0 ; it<iter;it++)
  843. blitAt(graphics->artDefs->ourImages[hero->artifacts[(it+backpackPos)%max]].bitmap,pos.x+293+48*it,pos.y+66,to);
  844. break;
  845. }
  846. show(to);
  847. }
  848. void CKingdomInterface::CHeroItem::onArtChange(int newstate)
  849. {
  850. if (!hero)
  851. return;
  852. deactivate();
  853. artGroup = newstate;
  854. activate();
  855. showAll(screen2);
  856. }
  857. void CKingdomInterface::CHeroItem::activate()
  858. {
  859. setHero(hero);
  860. if (!hero)
  861. return;
  862. artButtons->activate();
  863. garr->activate();
  864. if ( artGroup == 2 )
  865. {
  866. artLeft->activate();
  867. artRight->activate();
  868. for (size_t i=0; i<8;i++)
  869. backpack[i]->activate();
  870. }
  871. else
  872. {
  873. for (size_t i=artGroup*9; i<9+artGroup*9;i++)
  874. artifacts[i]->activate();
  875. }
  876. portrait->activate();
  877. experience->activate();
  878. morale->activate();
  879. luck->activate();
  880. spellPoints->activate();
  881. speciality->activate();
  882. for (size_t i=0; i<primarySkills.size();i++)
  883. primarySkills[i]->activate();
  884. for (size_t i=0; i<std::min(secondarySkills.size(),hero->secSkills.size());i++)
  885. secondarySkills[i]->activate();
  886. }
  887. void CKingdomInterface::CHeroItem::deactivate()
  888. {
  889. if (!hero)
  890. return;
  891. artButtons->deactivate();
  892. garr->deactivate();
  893. if ( artGroup == 2 )
  894. {
  895. artLeft->deactivate();
  896. artRight->deactivate();
  897. for (size_t i=0; i<8;i++)
  898. backpack[i]->deactivate();
  899. }
  900. else
  901. {
  902. for (size_t i=artGroup*9; i<9+artGroup*9;i++)
  903. artifacts[i]->deactivate();
  904. }
  905. portrait->deactivate();
  906. experience->deactivate();
  907. morale->deactivate();
  908. luck->deactivate();
  909. spellPoints->deactivate();
  910. speciality->deactivate();
  911. for (size_t i=0; i<primarySkills.size();i++)
  912. primarySkills[i]->deactivate();
  913. for (size_t i=0; i<std::min(secondarySkills.size(),hero->secSkills.size());i++)
  914. secondarySkills[i]->deactivate();
  915. }
  916. CKingdomInterface::CHeroItem::CArtPlace::CArtPlace(CHeroItem * owner)
  917. {
  918. hero = owner;
  919. used = LCLICK | RCLICK | HOVER;
  920. }
  921. void CKingdomInterface::CHeroItem::CArtPlace::activate()
  922. {
  923. LRClickableAreaWTextComp::activate();
  924. }
  925. void CKingdomInterface::CHeroItem::CArtPlace::clickLeft(tribool down, bool previousState)
  926. {
  927. if (!down && previousState && type>=0)
  928. {
  929. if(type == 0)
  930. {
  931. CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), hero->hero);
  932. GH.pushInt(spellWindow);
  933. }
  934. else
  935. LRClickableAreaWTextComp::clickLeft(down,previousState);
  936. }
  937. }
  938. void CKingdomInterface::CHeroItem::CArtPlace::clickRight(tribool down, bool previousState)
  939. {
  940. if (type>=0)
  941. LRClickableAreaWTextComp::clickRight(down, previousState);
  942. }
  943. void CKingdomInterface::CHeroItem::CArtPlace::deactivate()
  944. {
  945. LRClickableAreaWTextComp::deactivate();
  946. }
  947. CKingdomInterface::CTownItem::CCreaPlace::CCreaPlace()
  948. {
  949. town = NULL;
  950. used = LCLICK | RCLICK | HOVER;
  951. }
  952. void CKingdomInterface::CTownItem::CCreaPlace::activate()
  953. {
  954. LRClickableAreaWTextComp::activate();
  955. }
  956. void CKingdomInterface::CTownItem::CCreaPlace::clickLeft(tribool down, bool previousState)
  957. {
  958. if (!down && previousState && town)
  959. {
  960. GH.pushInt (new CRecruitmentWindow(town, type, town, boost::bind
  961. (&CCallback::recruitCreatures,LOCPLINT->cb,town,_1,_2)));
  962. }
  963. }
  964. void CKingdomInterface::CTownItem::CCreaPlace::clickRight(tribool down, bool previousState)
  965. {
  966. if (down && town)
  967. {
  968. int crid;
  969. if (town->builtBuildings.find(30+type+CREATURES_PER_TOWN)!=town->builtBuildings.end())
  970. crid = town->town->upgradedCreatures[type];
  971. else
  972. crid = town->town->basicCreatures[type];
  973. GH.pushInt(new CCreInfoWindow(crid, 0, town->creatures[type].first, NULL, 0, 0, NULL));
  974. }
  975. }
  976. void CKingdomInterface::CTownItem::CCreaPlace::deactivate()
  977. {
  978. LRClickableAreaWTextComp::deactivate();
  979. }