CHeroWindow.cpp 34 KB

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