CHeroWindow.cpp 34 KB

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