CHeroWindow.cpp 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. #include "stdafx.h"
  2. #include <cstdlib>
  3. #include "global.h"
  4. #include "CHeroWindow.h"
  5. #include "CGameInfo.h"
  6. #include "hch/CHeroHandler.h"
  7. #include "hch/CGeneralTextHandler.h"
  8. #include "SDL.h"
  9. #include "SDL_Extensions.h"
  10. #include "CAdvmapInterface.h"
  11. #include "CCastleInterface.h"
  12. #include "hch/CLodHandler.h"
  13. #include "AdventureMapButton.h"
  14. #include "hch/CObjectHandler.h"
  15. #include "CMessage.h"
  16. #include "CCallback.h"
  17. #include "hch/CArtHandler.h"
  18. #include "hch/CAbilityHandler.h"
  19. #include "hch/CDefHandler.h"
  20. #include "client/CBitmapHandler.h"
  21. #include <sstream>
  22. #include "client/Graphics.h"
  23. extern SDL_Surface * screen;
  24. extern TTF_Font * GEOR16;
  25. CHeroWindow::CHeroWindow(int playerColor):
  26. backpackPos(0), player(playerColor)
  27. {
  28. artWorn.resize(19);
  29. background = BitmapHandler::loadBitmap("HEROSCR4.bmp");
  30. graphics->blueToPlayersAdv(background, playerColor);
  31. pos.x = 65;
  32. pos.y = 8;
  33. pos.h = background->h;
  34. pos.w = background->w;
  35. curBack = NULL;
  36. curHero = NULL;
  37. activeArtPlace = NULL;
  38. garInt = NULL;
  39. ourBar = new CStatusBar(72, 567, "ADROLLVR.bmp", 660);
  40. quitButton = new AdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(), boost::function<void()>(), 674, 524, "hsbtns.def", false, NULL, false);
  41. dismissButton = new AdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], boost::bind(&CHeroWindow::dismissCurrent,this), 519, 437, "hsbtns2.def", false, NULL, false);
  42. questlogButton = new AdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), boost::bind(&CHeroWindow::questlog,this), 379, 437, "hsbtns4.def", false, NULL, false);
  43. gar1button = new AdventureMapButton(CGI->generaltexth->heroscrn[23], CGI->generaltexth->heroscrn[29], boost::bind(&CHeroWindow::gar1,this), 546, 491, "hsbtns6.def", false, NULL, false);
  44. gar2button = new AdventureMapButton(std::string(), std::string(), boost::bind(&CHeroWindow::gar2,this), 604, 491, "hsbtns8.def", false, NULL, false);
  45. gar3button = new AdventureMapButton(CGI->generaltexth->heroscrn[24], CGI->generaltexth->heroscrn[30], boost::bind(&CHeroWindow::gar3,this), 546, 527, "hsbtns7.def", false, NULL, false);
  46. gar4button = new AdventureMapButton(std::string(), CGI->generaltexth->heroscrn[32], boost::function<void()>(), 604, 527, "hsbtns9.def", false, NULL, false);
  47. leftArtRoll = new AdventureMapButton(std::string(), std::string(), boost::bind(&CHeroWindow::leftArtRoller,this), 379, 364, "hsbtns3.def", false, NULL, false);
  48. rightArtRoll = new AdventureMapButton(std::string(), std::string(), boost::bind(&CHeroWindow::rightArtRoller,this), 632, 364, "hsbtns5.def", false, NULL, false);
  49. for(int g=0; g<8; ++g)
  50. {
  51. //heroList.push_back(new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::switchHero, 677, 95+g*54, "hsbtns5.def", this));
  52. heroListMi.push_back(new LClickableAreaHero());
  53. heroListMi[g]->pos.x = 677;
  54. heroListMi[g]->pos.y = 95+g*54;
  55. heroListMi[g]->pos.h = 32;
  56. heroListMi[g]->pos.w = 48;
  57. heroListMi[g]->owner = this;
  58. heroListMi[g]->id = g;
  59. }
  60. flags = CDefHandler::giveDef("CREST58.DEF");
  61. //areas
  62. portraitArea = new LRClickableAreaWText();
  63. portraitArea->pos.x = 83;
  64. portraitArea->pos.y = 26;
  65. portraitArea->pos.w = 58;
  66. portraitArea->pos.h = 64;
  67. for(int v=0; v<4; ++v)
  68. {
  69. primSkillAreas.push_back(new LRClickableAreaWTextComp());
  70. primSkillAreas[v]->pos.x = 95 + 70*v;
  71. primSkillAreas[v]->pos.y = 111;
  72. primSkillAreas[v]->pos.w = 42;
  73. primSkillAreas[v]->pos.h = 42;
  74. primSkillAreas[v]->text = CGI->generaltexth->arraytxt[2+v].substr(1, CGI->generaltexth->arraytxt[2+v].size()-2);
  75. primSkillAreas[v]->type = v;
  76. primSkillAreas[v]->bonus = -1; // to be initilized when hero is being set
  77. primSkillAreas[v]->baseType = 0;
  78. }
  79. expArea = new LRClickableAreaWText();
  80. expArea->pos.x = 83;
  81. expArea->pos.y = 236;
  82. expArea->pos.w = 136;
  83. expArea->pos.h = 42;
  84. expArea->hoverText = CGI->generaltexth->heroscrn[9];
  85. spellPointsArea = new LRClickableAreaWText();
  86. spellPointsArea->pos.x = 227;
  87. spellPointsArea->pos.y = 236;
  88. spellPointsArea->pos.w = 136;
  89. spellPointsArea->pos.h = 42;
  90. spellPointsArea->hoverText = CGI->generaltexth->heroscrn[22];
  91. for(int i=0; i<8; ++i)
  92. {
  93. secSkillAreas.push_back(new LRClickableAreaWTextComp());
  94. secSkillAreas[i]->pos.x = (i%2==0) ? (83) : (227);
  95. secSkillAreas[i]->pos.y = 284 + 48 * (i/2);
  96. secSkillAreas[i]->pos.w = 136;
  97. secSkillAreas[i]->pos.h = 42;
  98. secSkillAreas[i]->baseType = 1;
  99. }
  100. }
  101. CHeroWindow::~CHeroWindow()
  102. {
  103. SDL_FreeSurface(background);
  104. delete quitButton;
  105. delete dismissButton;
  106. delete questlogButton;
  107. delete gar1button;
  108. delete gar2button;
  109. delete gar3button;
  110. delete gar4button;
  111. delete leftArtRoll;
  112. delete rightArtRoll;
  113. for(int g=0; g<heroListMi.size(); ++g)
  114. delete heroListMi[g];
  115. if(curBack)
  116. SDL_FreeSurface(curBack);
  117. delete flags;
  118. delete garInt;
  119. delete ourBar;
  120. for(int g=0; g<artWorn.size(); ++g)
  121. {
  122. delete artWorn[g];
  123. }
  124. artWorn.clear();
  125. for(int g=0; g<backpack.size(); ++g)
  126. {
  127. delete backpack[g];
  128. }
  129. backpack.clear();
  130. delete portraitArea;
  131. delete expArea;
  132. delete spellPointsArea;
  133. for(int v=0; v<primSkillAreas.size(); ++v)
  134. {
  135. delete primSkillAreas[v];
  136. }
  137. for(int v=0; v<secSkillAreas.size(); ++v)
  138. {
  139. delete secSkillAreas[v];
  140. }
  141. }
  142. void CHeroWindow::show(SDL_Surface *to)
  143. {
  144. if(!to)
  145. to=screen;
  146. if(curBack)
  147. blitAt(curBack,pos.x,pos.y,to);
  148. quitButton->show();
  149. dismissButton->show();
  150. questlogButton->show();
  151. gar1button->show();
  152. gar2button->show();
  153. gar3button->show();
  154. gar4button->show();
  155. leftArtRoll->show();
  156. rightArtRoll->show();
  157. garInt->show();
  158. ourBar->show();
  159. for(int d=0; d<artWorn.size(); ++d)
  160. {
  161. artWorn[d]->show(to);
  162. }
  163. for(int d=0; d<backpack.size(); ++d)
  164. {
  165. backpack[d]->show(to);
  166. }
  167. }
  168. void CHeroWindow::setHero(const CGHeroInstance *Hero)
  169. {
  170. CGHeroInstance *hero = const_cast<CGHeroInstance*>(Hero); //but don't modify hero! - it's only for easy map reading
  171. if(!hero) //something strange... no hero? it shouldn't happen
  172. {
  173. return;
  174. }
  175. curHero = hero;
  176. char * prhlp = new char[200];
  177. sprintf(prhlp, CGI->generaltexth->heroscrn[16].c_str(), curHero->name.c_str(), curHero->type->heroClass->name.c_str());
  178. dismissButton->name = std::string(prhlp);
  179. delete [] prhlp;
  180. prhlp = new char[200];
  181. sprintf(prhlp, CGI->generaltexth->allTexts[15].c_str(), curHero->name.c_str(), curHero->type->heroClass->name.c_str());
  182. portraitArea->hoverText = std::string(prhlp);
  183. delete [] prhlp;
  184. portraitArea->text = hero->biography;
  185. delete garInt;
  186. /*gar4button->owner = */garInt = new CGarrisonInt(80, 493, 8, 0, curBack, 13, 482, curHero);
  187. garInt->update = false;
  188. gar4button->callback = boost::bind(&CGarrisonInt::splitClick,garInt);//actualization of callback function
  189. for(int g=0; g<primSkillAreas.size(); ++g)
  190. {
  191. primSkillAreas[g]->bonus = hero->primSkills[g];
  192. }
  193. for(int g=0; g<hero->secSkills.size(); ++g)
  194. {
  195. secSkillAreas[g]->type = hero->secSkills[g].first;
  196. secSkillAreas[g]->bonus = hero->secSkills[g].second;
  197. std::string hlp = CGI->abilh->abilities[ hero->secSkills[g].first ]->infoTexts[hero->secSkills[g].second];
  198. secSkillAreas[g]->text = hlp.substr(1, hlp.size()-2);
  199. char * hlpp = new char[200];
  200. sprintf(hlpp, CGI->generaltexth->heroscrn[21].c_str(), CGI->abilh->levels[hero->secSkills[g].second].c_str(), CGI->abilh->abilities[hero->secSkills[g].first]->name.c_str());
  201. secSkillAreas[g]->hoverText = std::string(hlpp);
  202. delete [] hlpp;
  203. }
  204. char * th = new char[200];
  205. sprintf(th, CGI->generaltexth->allTexts[2].substr(1, CGI->generaltexth->allTexts[2].size()-2).c_str(), hero->level, CGI->heroh->reqExp(hero->level+1), hero->exp);
  206. expArea->text = std::string(th);
  207. delete [] th;
  208. th = new char[400];
  209. sprintf(th, CGI->generaltexth->allTexts[205].substr(1, CGI->generaltexth->allTexts[205].size()-2).c_str(), hero->name.c_str(), hero->mana, hero->primSkills[3]*10);
  210. spellPointsArea->text = std::string(th);
  211. delete [] th;
  212. for(int g=0; g<artWorn.size(); ++g)
  213. {
  214. delete artWorn[g];
  215. }
  216. for(int g=0; g<backpack.size(); ++g)
  217. {
  218. delete backpack[g];
  219. }
  220. backpack.clear();
  221. artWorn[8] = new CArtPlace(hero->getArt(8));
  222. artWorn[8]->pos.x = 515;
  223. artWorn[8]->pos.y = 295;
  224. artWorn[8]->pos.h = artWorn[8]->pos.w = 44;
  225. if(hero->getArt(8))
  226. artWorn[8]->text = hero->getArt(8)->description;
  227. else
  228. artWorn[8]->text = std::string();
  229. artWorn[8]->ourWindow = this;
  230. artWorn[8]->feet = true;
  231. artWorn[0] = new CArtPlace(hero->getArt(0));
  232. artWorn[0]->pos.x = 509;
  233. artWorn[0]->pos.y = 30;
  234. artWorn[0]->pos.h = artWorn[0]->pos.w = 44;
  235. if(hero->getArt(0))
  236. artWorn[0]->text = hero->getArt(0)->description;
  237. else
  238. artWorn[0]->text = std::string();
  239. artWorn[0]->ourWindow = this;
  240. artWorn[0]->head = true;
  241. artWorn[4] = new CArtPlace(hero->getArt(4));
  242. artWorn[4]->pos.x = 564;
  243. artWorn[4]->pos.y = 183;
  244. artWorn[4]->pos.h = artWorn[4]->pos.w = 44;
  245. if(hero->getArt(4))
  246. artWorn[4]->text = hero->getArt(4)->description;
  247. else
  248. artWorn[4]->text = std::string();
  249. artWorn[4]->ourWindow = this;
  250. artWorn[4]->lHand = true;
  251. artWorn[7] = new CArtPlace(hero->getArt(7));
  252. artWorn[7]->pos.x = 610;
  253. artWorn[7]->pos.y = 183;
  254. artWorn[7]->pos.h = artWorn[7]->pos.w = 44;
  255. if(hero->getArt(7))
  256. artWorn[7]->text = hero->getArt(7)->description;
  257. else
  258. artWorn[7]->text = std::string();
  259. artWorn[7]->ourWindow = this;
  260. artWorn[7]->lRing = true;
  261. artWorn[13] = new CArtPlace(hero->getArt(13));
  262. artWorn[13]->pos.x = 564;
  263. artWorn[13]->pos.y = 30;
  264. artWorn[13]->pos.h = artWorn[13]->pos.w = 44;
  265. if(hero->getArt(13))
  266. artWorn[13]->text = hero->getArt(13)->description;
  267. else
  268. artWorn[13]->text = std::string();
  269. artWorn[13]->ourWindow = this;
  270. artWorn[13]->warMachine1 = true;
  271. artWorn[14] = new CArtPlace(hero->getArt(14));
  272. artWorn[14]->pos.x = 610;
  273. artWorn[14]->pos.y = 30;
  274. artWorn[14]->pos.h = artWorn[14]->pos.w = 44;
  275. if(hero->getArt(14))
  276. artWorn[14]->text = hero->getArt(14)->description;
  277. else
  278. artWorn[14]->text = std::string();
  279. artWorn[14]->ourWindow = this;
  280. artWorn[14]->warMachine2 = true;
  281. artWorn[15] = new CArtPlace(hero->getArt(15));
  282. artWorn[15]->pos.x = 610;
  283. artWorn[15]->pos.y = 76;
  284. artWorn[15]->pos.h = artWorn[15]->pos.w = 44;
  285. if(hero->getArt(15))
  286. artWorn[15]->text = hero->getArt(15)->description;
  287. else
  288. artWorn[15]->text = std::string();
  289. artWorn[15]->ourWindow = this;
  290. artWorn[15]->warMachine3 = true;
  291. artWorn[16] = new CArtPlace(hero->getArt(16));
  292. artWorn[16]->pos.x = 610;
  293. artWorn[16]->pos.y = 122;
  294. artWorn[16]->pos.h = artWorn[16]->pos.w = 44;
  295. if(hero->getArt(16))
  296. artWorn[16]->text = hero->getArt(16)->description;
  297. else
  298. artWorn[16]->text = std::string();
  299. artWorn[16]->ourWindow = this;
  300. artWorn[16]->warMachine4 = true;
  301. artWorn[9] = new CArtPlace(hero->getArt(9));
  302. artWorn[9]->pos.x = 383;
  303. artWorn[9]->pos.y = 143;
  304. artWorn[9]->pos.h = artWorn[9]->pos.w = 44;
  305. if(hero->getArt(9))
  306. artWorn[9]->text = hero->getArt(9)->description;
  307. else
  308. artWorn[9]->text = std::string();
  309. artWorn[9]->ourWindow = this;
  310. artWorn[9]->misc1 = true;
  311. artWorn[10] = new CArtPlace(hero->getArt(10));
  312. artWorn[10]->pos.x = 399;
  313. artWorn[10]->pos.y = 194;
  314. artWorn[10]->pos.h = artWorn[10]->pos.w = 44;
  315. if(hero->getArt(10))
  316. artWorn[10]->text = hero->getArt(10)->description;
  317. else
  318. artWorn[10]->text = std::string();
  319. artWorn[10]->ourWindow = this;
  320. artWorn[10]->misc1 = true;
  321. artWorn[11] = new CArtPlace(hero->getArt(11));
  322. artWorn[11]->pos.x = 415;
  323. artWorn[11]->pos.y = 245;
  324. artWorn[11]->pos.h = artWorn[11]->pos.w = 44;
  325. if(hero->getArt(11))
  326. artWorn[11]->text = hero->getArt(11)->description;
  327. else
  328. artWorn[11]->text = std::string();
  329. artWorn[11]->ourWindow = this;
  330. artWorn[11]->misc3 = true;
  331. artWorn[12] = new CArtPlace(hero->getArt(12));
  332. artWorn[12]->pos.x = 431;
  333. artWorn[12]->pos.y = 296;
  334. artWorn[12]->pos.h = artWorn[12]->pos.w = 44;
  335. if(hero->getArt(12))
  336. artWorn[12]->text = hero->getArt(12)->description;
  337. else
  338. artWorn[12]->text = std::string();
  339. artWorn[12]->ourWindow = this;
  340. artWorn[12]->misc4 = true;
  341. artWorn[18] = new CArtPlace(hero->getArt(18));
  342. artWorn[18]->pos.x = 381;
  343. artWorn[18]->pos.y = 296;
  344. artWorn[18]->pos.h = artWorn[18]->pos.w = 44;
  345. if(hero->getArt(18))
  346. artWorn[18]->text = hero->getArt(18)->description;
  347. else
  348. artWorn[18]->text = std::string();
  349. artWorn[18]->ourWindow = this;
  350. artWorn[18]->misc5 = true;
  351. artWorn[2] = new CArtPlace(hero->getArt(2));
  352. artWorn[2]->pos.x = 508;
  353. artWorn[2]->pos.y = 79;
  354. artWorn[2]->pos.h = artWorn[2]->pos.w = 44;
  355. if(hero->getArt(2))
  356. artWorn[2]->text = hero->getArt(2)->description;
  357. else
  358. artWorn[2]->text = std::string();
  359. artWorn[2]->ourWindow = this;
  360. artWorn[2]->neck = true;
  361. artWorn[3] = new CArtPlace(hero->getArt(3));
  362. artWorn[3]->pos.x = 383;
  363. artWorn[3]->pos.y = 68;
  364. artWorn[3]->pos.h = artWorn[3]->pos.w = 44;
  365. if(hero->getArt(3))
  366. artWorn[3]->text = hero->getArt(3)->description;
  367. else
  368. artWorn[3]->text = std::string();
  369. artWorn[3]->ourWindow = this;
  370. artWorn[3]->rHand = true;
  371. artWorn[6] = new CArtPlace(hero->getArt(6));
  372. artWorn[6]->pos.x = 431;
  373. artWorn[6]->pos.y = 68;
  374. artWorn[6]->pos.h = artWorn[6]->pos.w = 44;
  375. if(hero->getArt(6))
  376. artWorn[6]->text = hero->getArt(6)->description;
  377. else
  378. artWorn[6]->text = std::string();
  379. artWorn[6]->ourWindow = this;
  380. artWorn[6]->rRing = true;
  381. artWorn[1] = new CArtPlace(hero->getArt(1));
  382. artWorn[1]->pos.x = 567;
  383. artWorn[1]->pos.y = 240;
  384. artWorn[1]->pos.h = artWorn[1]->pos.w = 44;
  385. if(hero->getArt(1))
  386. artWorn[1]->text = hero->getArt(1)->description;
  387. else
  388. artWorn[1]->text = std::string();
  389. artWorn[1]->ourWindow = this;
  390. artWorn[1]->shoulders = true;
  391. artWorn[17] = new CArtPlace(hero->getArt(17));
  392. artWorn[17]->pos.x = 610;
  393. artWorn[17]->pos.y = 310;
  394. artWorn[17]->pos.h = artWorn[17]->pos.w = 44;
  395. if(hero->getArt(17))
  396. artWorn[17]->text = hero->getArt(17)->description;
  397. else
  398. artWorn[17]->text = std::string();
  399. artWorn[17]->ourWindow = this;
  400. artWorn[17]->spellBook = true;
  401. artWorn[5] = new CArtPlace(hero->getArt(5));
  402. artWorn[5]->pos.x = 509;
  403. artWorn[5]->pos.y = 130;
  404. artWorn[5]->pos.h = artWorn[5]->pos.w = 44;
  405. if(hero->getArt(5))
  406. artWorn[5]->text = hero->getArt(5)->description;
  407. else
  408. artWorn[5]->text = std::string();
  409. artWorn[5]->ourWindow = this;
  410. artWorn[5]->torso = true;
  411. for(int g=0; g<artWorn.size(); ++g)
  412. {
  413. artWorn[g]->myNumber = g;
  414. artWorn[g]->backNumber = -1;
  415. char * hll = new char[200];
  416. sprintf(hll, CGI->generaltexth->heroscrn[1].c_str(), (artWorn[g]->ourArt ? artWorn[g]->ourArt->name.c_str() : ""));
  417. artWorn[g]->hoverText = std::string(hll);
  418. delete [] hll;
  419. }
  420. for(int s=0; s<5; ++s)
  421. {
  422. CArtPlace * add;
  423. if( s < curHero->artifacts.size() )
  424. add = new CArtPlace(&CGI->arth->artifacts[curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ]]);
  425. else
  426. add = new CArtPlace(NULL);
  427. add->pos.x = 403 + 46*s;
  428. add->pos.y = 365;
  429. add->pos.h = add->pos.w = 44;
  430. if(s<hero->artifacts.size() && hero->artifacts[s])
  431. add->text = hero->getArt(s)->description;
  432. else
  433. add->text = std::string();
  434. add->ourWindow = this;
  435. add->spellBook = true;
  436. add->warMachine1 = true;
  437. add->warMachine2 = true;
  438. add->warMachine3 = true;
  439. add->warMachine4 = true;
  440. add->misc1 = true;
  441. add->misc2 = true;
  442. add->misc3 = true;
  443. add->misc4 = true;
  444. add->misc5 = true;
  445. add->feet = true;
  446. add->lRing = true;
  447. add->rRing = true;
  448. add->torso = true;
  449. add->lHand = true;
  450. add->rHand = true;
  451. add->neck = true;
  452. add->shoulders = true;
  453. add->head = true;
  454. add->myNumber = -1;
  455. add->backNumber = s;
  456. backpack.push_back(add);
  457. }
  458. activeArtPlace = NULL;
  459. redrawCurBack();
  460. }
  461. void CHeroWindow::quit()
  462. {
  463. LOCPLINT->objsToBlit -= this;
  464. deactivate();
  465. if(LOCPLINT->curint == LOCPLINT->castleInt)
  466. LOCPLINT->castleInt->subInt = NULL;
  467. LOCPLINT->curint->activate();
  468. SDL_FreeSurface(curBack);
  469. curBack = NULL;
  470. for(int g=0; g<artWorn.size(); ++g)
  471. {
  472. delete artWorn[g];
  473. artWorn[g] = NULL;
  474. }
  475. for(int g=0; g<backpack.size(); ++g)
  476. {
  477. delete backpack[g];
  478. backpack[g] = NULL;
  479. }
  480. backpack.clear();
  481. activeArtPlace = NULL;
  482. }
  483. void CHeroWindow::activate()
  484. {
  485. //LOCPLINT->curint = this;
  486. quitButton->activate();
  487. dismissButton->activate();
  488. questlogButton->activate();
  489. gar1button->activate();
  490. gar2button->activate();
  491. gar3button->activate();
  492. gar4button->activate();
  493. leftArtRoll->activate();
  494. rightArtRoll->activate();
  495. portraitArea->activate();
  496. expArea->activate();
  497. spellPointsArea->activate();
  498. garInt->activate();
  499. LOCPLINT->statusbar = ourBar;
  500. for(int v=0; v<primSkillAreas.size(); ++v)
  501. {
  502. primSkillAreas[v]->activate();
  503. }
  504. for(int v=0; v<curHero->secSkills.size(); ++v)
  505. {
  506. secSkillAreas[v]->activate();
  507. }
  508. redrawCurBack();
  509. for(int f=0; f<artWorn.size(); ++f)
  510. {
  511. if(artWorn[f])
  512. artWorn[f]->activate();
  513. }
  514. for(int f=0; f<backpack.size(); ++f)
  515. {
  516. if(backpack[f])
  517. backpack[f]->activate();
  518. }
  519. for(int e=0; e<heroListMi.size(); ++e)
  520. {
  521. heroListMi[e]->activate();
  522. }
  523. //LOCPLINT->lclickable.push_back(artFeet);
  524. }
  525. void CHeroWindow::deactivate()
  526. {
  527. quitButton->deactivate();
  528. dismissButton->deactivate();
  529. questlogButton->deactivate();
  530. gar1button->deactivate();
  531. gar2button->deactivate();
  532. gar3button->deactivate();
  533. gar4button->deactivate();
  534. leftArtRoll->deactivate();
  535. rightArtRoll->deactivate();
  536. portraitArea->deactivate();
  537. expArea->deactivate();
  538. spellPointsArea->deactivate();
  539. garInt->deactivate();
  540. for(int v=0; v<primSkillAreas.size(); ++v)
  541. {
  542. primSkillAreas[v]->deactivate();
  543. }
  544. for(int v=0; v<curHero->secSkills.size(); ++v)
  545. {
  546. secSkillAreas[v]->deactivate();
  547. }
  548. for(int f=0; f<artWorn.size(); ++f)
  549. {
  550. if(artWorn[f])
  551. artWorn[f]->deactivate();
  552. }
  553. for(int f=0; f<backpack.size(); ++f)
  554. {
  555. if(backpack[f])
  556. backpack[f]->deactivate();
  557. }
  558. for(int e=0; e<heroListMi.size(); ++e)
  559. {
  560. heroListMi[e]->deactivate();
  561. }
  562. }
  563. void CHeroWindow::dismissCurrent()
  564. {
  565. const CGHeroInstance * ch = curHero;
  566. quit();
  567. LOCPLINT->cb->dismissHero(ch);
  568. }
  569. void CHeroWindow::questlog()
  570. {
  571. }
  572. void CHeroWindow::gar1()
  573. {
  574. }
  575. void CHeroWindow::gar2()
  576. {
  577. }
  578. void CHeroWindow::gar3()
  579. {
  580. }
  581. void CHeroWindow::gar4()
  582. {
  583. }
  584. void CHeroWindow::leftArtRoller()
  585. {
  586. if(curHero->artifacts.size()>5) //if it is <=5, we have nothing to scroll
  587. {
  588. backpackPos+=curHero->artifacts.size()-1; //set new offset
  589. for(int s=0; s<5 && s<curHero->artifacts.size(); ++s) //set new data
  590. {
  591. backpack[s]->ourArt = &CGI->arth->artifacts[curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ]];
  592. if(backpack[s]->ourArt)
  593. backpack[s]->text = backpack[s]->ourArt->description;
  594. else
  595. backpack[s]->text = std::string();
  596. }
  597. }
  598. }
  599. void CHeroWindow::rightArtRoller()
  600. {
  601. if(curHero->artifacts.size()>5) //if it is <=5, we have nothing to scroll
  602. {
  603. backpackPos+=1; //set new offset
  604. for(int s=0; s<5 && s<curHero->artifacts.size(); ++s) //set new data
  605. {
  606. backpack[s]->ourArt = &CGI->arth->artifacts[curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ] ];
  607. if(backpack[s]->ourArt)
  608. backpack[s]->text = backpack[s]->ourArt->description;
  609. else
  610. backpack[s]->text = std::string();
  611. }
  612. }
  613. }
  614. void CHeroWindow::switchHero()
  615. {
  616. //int y;
  617. //SDL_GetMouseState(NULL, &y);
  618. //for(int g=0; g<heroListMi.size(); ++g)
  619. //{
  620. // if(y>=94+54*g)
  621. // {
  622. // //quit();
  623. // setHero(LOCPLINT->cb->getHeroInfo(player, g, false));
  624. // //LOCPLINT->openHeroWindow(curHero);
  625. // redrawCurBack();
  626. // }
  627. //}
  628. }
  629. void CHeroWindow::redrawCurBack()
  630. {
  631. if(curBack)
  632. SDL_FreeSurface(curBack);
  633. curBack = SDL_DisplayFormat(background);
  634. blitAt(graphics->pskillsm->ourImages[0].bitmap, 32, 111, curBack);
  635. blitAt(graphics->pskillsm->ourImages[1].bitmap, 102, 111, curBack);
  636. blitAt(graphics->pskillsm->ourImages[2].bitmap, 172, 111, curBack);
  637. blitAt(graphics->pskillsm->ourImages[5].bitmap, 242, 111, curBack);
  638. blitAt(graphics->pskillsm->ourImages[4].bitmap, 20, 230, curBack);
  639. blitAt(graphics->pskillsm->ourImages[3].bitmap, 162, 230, curBack);
  640. blitAt(graphics->portraitLarge[curHero->portrait], 19, 19, curBack);
  641. CSDL_Ext::printAtMiddle(curHero->name, 190, 40, GEORXX, tytulowy, curBack);
  642. std::stringstream secondLine;
  643. secondLine<<"Level "<<curHero->level<<" "<<curHero->type->heroClass->name;
  644. CSDL_Ext::printAtMiddle(secondLine.str(), 190, 66, TNRB16, zwykly, curBack);
  645. //primary skliis names
  646. CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[1], 53, 98, GEOR13, tytulowy, curBack);
  647. CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[2], 123, 98, GEOR13, tytulowy, curBack);
  648. CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[3], 193, 98, GEOR13, tytulowy, curBack);
  649. CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[4], 263, 98, GEOR13, tytulowy, curBack);
  650. //dismiss / quest log
  651. std::vector<std::string> * toPrin = CMessage::breakText(CGI->generaltexth->jktexts[8].substr(1, CGI->generaltexth->jktexts[8].size()-2));
  652. if(toPrin->size()==1)
  653. {
  654. CSDL_Ext::printAt((*toPrin)[0], 372, 440, GEOR13, zwykly, curBack);
  655. }
  656. else
  657. {
  658. CSDL_Ext::printAt((*toPrin)[0], 372, 431, GEOR13, zwykly, curBack);
  659. CSDL_Ext::printAt((*toPrin)[1], 372, 447, GEOR13, zwykly, curBack);
  660. }
  661. delete toPrin;
  662. toPrin = CMessage::breakText(CGI->generaltexth->jktexts[9].substr(1, CGI->generaltexth->jktexts[9].size()-2));
  663. if(toPrin->size()==1)
  664. {
  665. CSDL_Ext::printAt((*toPrin)[0], 512, 440, GEOR13, zwykly, curBack);
  666. }
  667. else
  668. {
  669. CSDL_Ext::printAt((*toPrin)[0], 512, 431, GEOR13, zwykly, curBack);
  670. CSDL_Ext::printAt((*toPrin)[1], 512, 447, GEOR13, zwykly, curBack);
  671. }
  672. delete toPrin;
  673. //printing primary skills' amounts
  674. std::stringstream primarySkill1;
  675. primarySkill1<<curHero->primSkills[0];
  676. CSDL_Ext::printAtMiddle(primarySkill1.str(), 53, 165, TNRB16, zwykly, curBack);
  677. std::stringstream primarySkill2;
  678. primarySkill2<<curHero->primSkills[1];
  679. CSDL_Ext::printAtMiddle(primarySkill2.str(), 123, 165, TNRB16, zwykly, curBack);
  680. std::stringstream primarySkill3;
  681. primarySkill3<<curHero->primSkills[2];
  682. CSDL_Ext::printAtMiddle(primarySkill3.str(), 193, 165, TNRB16, zwykly, curBack);
  683. std::stringstream primarySkill4;
  684. primarySkill4<<curHero->primSkills[3];
  685. CSDL_Ext::printAtMiddle(primarySkill4.str(), 263, 165, TNRB16, zwykly, curBack);
  686. blitAt(graphics->luck42->ourImages[curHero->getCurrentLuck()+3].bitmap, 239, 182, curBack);
  687. blitAt(graphics->morale42->ourImages[curHero->getCurrentMorale()+3].bitmap, 181, 182, curBack);
  688. blitAt(flags->ourImages[player].bitmap, 606, 8, curBack);
  689. //hero list blitting
  690. for(int g=0; g<LOCPLINT->cb->howManyHeroes(); ++g)
  691. {
  692. const CGHeroInstance * cur = LOCPLINT->cb->getHeroInfo(player, g, false);
  693. blitAt(graphics->portraitSmall[cur->portrait], 611, 87+g*54, curBack);
  694. //printing yellow border
  695. if(cur->name == curHero->name)
  696. {
  697. for(int f=0; f<graphics->portraitSmall[cur->portrait]->w; ++f)
  698. {
  699. for(int h=0; h<graphics->portraitSmall[cur->portrait]->h; ++h)
  700. if(f==0 || h==0 || f==graphics->portraitSmall[cur->portrait]->w-1 || h==graphics->portraitSmall[cur->portrait]->h-1)
  701. {
  702. CSDL_Ext::SDL_PutPixel(curBack, 611+f, 87+g*54+h, 240, 220, 120);
  703. }
  704. }
  705. }
  706. }
  707. //secondary skills
  708. if(curHero->secSkills.size()>=1)
  709. {
  710. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[0].first*3+3+curHero->secSkills[0].second].bitmap, 18, 276, curBack);
  711. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[0].second], 69, 279, GEOR13, zwykly, curBack);
  712. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[0].first]->name, 69, 299, GEOR13, zwykly, curBack);
  713. }
  714. if(curHero->secSkills.size()>=2)
  715. {
  716. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[1].first*3+3+curHero->secSkills[1].second].bitmap, 161, 276, curBack);
  717. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[1].second], 213, 279, GEOR13, zwykly, curBack);
  718. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[1].first]->name, 213, 299, GEOR13, zwykly, curBack);
  719. }
  720. if(curHero->secSkills.size()>=3)
  721. {
  722. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[2].first*3+3+curHero->secSkills[2].second].bitmap, 18, 324, curBack);
  723. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[2].second], 69, 327, GEOR13, zwykly, curBack);
  724. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[2].first]->name, 69, 347, GEOR13, zwykly, curBack);
  725. }
  726. if(curHero->secSkills.size()>=4)
  727. {
  728. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[3].first*3+3+curHero->secSkills[3].second].bitmap, 161, 324, curBack);
  729. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[3].second], 213, 327, GEOR13, zwykly, curBack);
  730. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[3].first]->name, 213, 347, GEOR13, zwykly, curBack);
  731. }
  732. if(curHero->secSkills.size()>=5)
  733. {
  734. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[4].first*3+3+curHero->secSkills[4].second].bitmap, 18, 372, curBack);
  735. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[4].second], 69, 375, GEOR13, zwykly, curBack);
  736. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[4].first]->name, 69, 395, GEOR13, zwykly, curBack);
  737. }
  738. if(curHero->secSkills.size()>=6)
  739. {
  740. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[5].first*3+3+curHero->secSkills[5].second].bitmap, 161, 372, curBack);
  741. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[5].second], 213, 375, GEOR13, zwykly, curBack);
  742. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[5].first]->name, 213, 395, GEOR13, zwykly, curBack);
  743. }
  744. if(curHero->secSkills.size()>=7)
  745. {
  746. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[6].first*3+3+curHero->secSkills[6].second].bitmap, 18, 420, curBack);
  747. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[6].second], 69, 423, GEOR13, zwykly, curBack);
  748. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[6].first]->name, 69, 443, GEOR13, zwykly, curBack);
  749. }
  750. if(curHero->secSkills.size()>=8)
  751. {
  752. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[7].first*3+3+curHero->secSkills[7].second].bitmap, 161, 420, curBack);
  753. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[7].second], 213, 423, GEOR13, zwykly, curBack);
  754. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[7].first]->name, 213, 443, GEOR13, zwykly, curBack);
  755. }
  756. //printing special ability
  757. blitAt(graphics->un44->ourImages[curHero->subID].bitmap, 18, 180, curBack);
  758. //printing necessery texts
  759. CSDL_Ext::printAt(CGI->generaltexth->jktexts[6].substr(1, CGI->generaltexth->jktexts[6].size()-2), 69, 231, GEOR13, tytulowy, curBack);
  760. std::stringstream expstr;
  761. expstr<<curHero->exp;
  762. CSDL_Ext::printAt(expstr.str(), 69, 247, GEOR16, zwykly, curBack);
  763. CSDL_Ext::printAt(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 212, 231, GEOR13, tytulowy, curBack);
  764. std::stringstream manastr;
  765. manastr<<curHero->mana<<'/'<<curHero->primSkills[3]*10;
  766. CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack);
  767. }
  768. CArtPlace::CArtPlace(const CArtifact* Art): ourArt(Art), active(false), clicked(false),
  769. spellBook(false), warMachine1(false), warMachine2(false), warMachine3(false),
  770. warMachine4(false),misc1(false), misc2(false), misc3(false), misc4(false),
  771. misc5(false), feet(false), lRing(false), rRing(false), torso(false),
  772. lHand(false), rHand(false), neck(false), shoulders(false), head(false) {}
  773. void CArtPlace::activate()
  774. {
  775. if(!active)
  776. {
  777. //ClickableL::activate();
  778. LRClickableAreaWTextComp::activate();
  779. active = true;
  780. }
  781. }
  782. void CArtPlace::clickLeft(boost::logic::tribool down)
  783. {
  784. //LRClickableAreaWTextComp::clickLeft(down);
  785. if(!down && !clicked) //not clicked before
  786. {
  787. if(!ourWindow->activeArtPlace) //nothing has benn clicked
  788. {
  789. if(ourArt) //to prevent selecting empty slots (bugfix to what GrayFace reported)
  790. {
  791. clicked = true;
  792. ourWindow->activeArtPlace = this;
  793. }
  794. }
  795. else //perform artifact substitution
  796. {
  797. //chceck if swap is possible
  798. if(this->fitsHere(ourWindow->activeArtPlace->ourArt) && ourWindow->activeArtPlace->fitsHere(this->ourArt))
  799. {
  800. //swap artifacts
  801. LOCPLINT->cb->swapArifacts(
  802. ourWindow->curHero,
  803. this->myNumber>=0,
  804. this->myNumber>=0 ? this->myNumber : (this->backNumber + ourWindow->backpackPos)%ourWindow->curHero->artifacts.size(),
  805. ourWindow->curHero,
  806. ourWindow->activeArtPlace->myNumber>=0,
  807. ourWindow->activeArtPlace->myNumber>=0 ? ourWindow->activeArtPlace->myNumber : (ourWindow->activeArtPlace->backNumber + ourWindow->backpackPos)%ourWindow->curHero->artifacts.size());
  808. const CArtifact * pmh = ourArt;
  809. ourArt = ourWindow->activeArtPlace->ourArt;
  810. ourWindow->activeArtPlace->ourArt = pmh;
  811. //set texts
  812. if(pmh)
  813. ourWindow->activeArtPlace->text = pmh->description;
  814. else
  815. ourWindow->activeArtPlace->text = std::string();
  816. if(ourArt)
  817. text = ourArt->description;
  818. else
  819. text = std::string();
  820. ourWindow->activeArtPlace->clicked = false;
  821. ourWindow->activeArtPlace = NULL;
  822. }
  823. else
  824. {
  825. int backID = -1;
  826. for(int g=0; g<ourWindow->backpack.size(); ++g)
  827. {
  828. if(ourWindow->backpack[g]==this) //if user wants to put something to backpack
  829. {
  830. backID = g;
  831. break;
  832. }
  833. }
  834. if(backID>=0) //put to backpack
  835. {
  836. /*ourWindow->activeArtPlace->ourArt = NULL;
  837. ourWindow->activeArtPlace->clicked = false;
  838. ourWindow->activeArtPlace = NULL;*/
  839. }
  840. }
  841. }
  842. }
  843. else if(!down && clicked)
  844. {
  845. clicked = false;
  846. ourWindow->activeArtPlace = NULL;
  847. }
  848. }
  849. void CArtPlace::clickRight(boost::logic::tribool down)
  850. {
  851. if(text.size()) //if there is no description, do nothing ;]
  852. LRClickableAreaWTextComp::clickRight(down);
  853. }
  854. void CArtPlace::deactivate()
  855. {
  856. if(active)
  857. {
  858. active = false;
  859. //ClickableL::deactivate();
  860. LRClickableAreaWTextComp::deactivate();
  861. }
  862. }
  863. void CArtPlace::show(SDL_Surface *to)
  864. {
  865. if(ourArt)
  866. {
  867. blitAt(graphics->artDefs->ourImages[ourArt->id].bitmap, pos.x, pos.y, to);
  868. }
  869. if(clicked && active)
  870. {
  871. for(int i=0; i<pos.h; ++i)
  872. {
  873. for(int j=0; j<pos.w; ++j)
  874. {
  875. if(i==0 || j==0 || i==pos.h-1 || j==pos.w-1)
  876. {
  877. CSDL_Ext::SDL_PutPixel(to, pos.x+j, pos.y+i, 240, 220, 120);
  878. }
  879. }
  880. }
  881. }
  882. }
  883. bool CArtPlace::fitsHere(const CArtifact * art)
  884. {
  885. if(!art)
  886. return true; //you can have no artifact somewhere
  887. if( this->spellBook && art->spellBook || this->warMachine1 && art->warMachine1 ||
  888. this->warMachine2 && art->warMachine2 || this->warMachine3 && art->warMachine3 ||
  889. this->warMachine4 && art->warMachine4 || this->misc1 && art->misc1 ||
  890. this->misc2 && art->misc2 || this->misc3 && art->misc3 ||
  891. this->misc4 && art->misc4 || this->misc5 && art->misc5 ||
  892. this->feet && art->feet || this->lRing && art->lRing ||
  893. this->rRing && art->rRing || this->torso && art->torso ||
  894. this->lHand && art->lHand || this->rHand && art->rHand ||
  895. this->neck && art->neck || this->shoulders && art->shoulders ||
  896. this->head && art->head )
  897. {
  898. return true;
  899. }
  900. return false;
  901. }
  902. CArtPlace::~CArtPlace()
  903. {
  904. deactivate();
  905. }
  906. void LClickableArea::activate()
  907. {
  908. ClickableL::activate();
  909. }
  910. void LClickableArea::deactivate()
  911. {
  912. ClickableL::deactivate();
  913. }
  914. void LClickableArea::clickLeft(boost::logic::tribool down)
  915. {
  916. //if(!down)
  917. //{
  918. // LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector<SComponent*>());
  919. //}
  920. }
  921. void RClickableArea::activate()
  922. {
  923. ClickableR::activate();
  924. }
  925. void RClickableArea::deactivate()
  926. {
  927. ClickableR::deactivate();
  928. }
  929. void RClickableArea::clickRight(boost::logic::tribool down)
  930. {
  931. //if(!down)
  932. //{
  933. // LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector<SComponent*>());
  934. //}
  935. }
  936. void LRClickableAreaWText::clickLeft(boost::logic::tribool down)
  937. {
  938. if(!down)
  939. {
  940. LOCPLINT->showInfoDialog(text, std::vector<SComponent*>());
  941. }
  942. }
  943. void LRClickableAreaWText::clickRight(boost::logic::tribool down)
  944. {
  945. LOCPLINT->adventureInt->handleRightClick(text, down, this);
  946. }
  947. void LRClickableAreaWText::activate()
  948. {
  949. LClickableArea::activate();
  950. RClickableArea::activate();
  951. Hoverable::activate();
  952. }
  953. void LRClickableAreaWText::deactivate()
  954. {
  955. LClickableArea::deactivate();
  956. RClickableArea::deactivate();
  957. Hoverable::deactivate();
  958. }
  959. void LRClickableAreaWText::hover(bool on)
  960. {
  961. Hoverable::hover(on);
  962. if (on)
  963. LOCPLINT->statusbar->print(hoverText);
  964. else if (LOCPLINT->statusbar->getCurrent()==hoverText)
  965. LOCPLINT->statusbar->clear();
  966. }
  967. void LClickableAreaHero::clickLeft(boost::logic::tribool down)
  968. {
  969. if(!down)
  970. {
  971. owner->deactivate();
  972. const CGHeroInstance * buf = LOCPLINT->cb->getHeroInfo(owner->player, id, false);
  973. owner->setHero(buf);
  974. owner->redrawCurBack();
  975. owner->activate();
  976. }
  977. }
  978. void LRClickableAreaWTextComp::clickLeft(boost::logic::tribool down)
  979. {
  980. if((!down) && pressedL)
  981. {
  982. std::vector<SComponent*> comp(1, new SComponent(SComponent::Etype(baseType), type, bonus));
  983. LOCPLINT->showInfoDialog(text, comp);
  984. }
  985. ClickableL::clickLeft(down);
  986. }
  987. void LRClickableAreaWTextComp::clickRight(boost::logic::tribool down)
  988. {
  989. LOCPLINT->adventureInt->handleRightClick(text, down, this);
  990. }
  991. void LRClickableAreaWTextComp::activate()
  992. {
  993. LClickableArea::activate();
  994. RClickableArea::activate();
  995. Hoverable::activate();
  996. }
  997. void LRClickableAreaWTextComp::deactivate()
  998. {
  999. LClickableArea::deactivate();
  1000. RClickableArea::deactivate();
  1001. Hoverable::deactivate();
  1002. }
  1003. void LRClickableAreaWTextComp::hover(bool on)
  1004. {
  1005. Hoverable::hover(on);
  1006. if (on)
  1007. LOCPLINT->statusbar->print(hoverText);
  1008. else if (LOCPLINT->statusbar->getCurrent()==hoverText)
  1009. LOCPLINT->statusbar->clear();
  1010. }