CHeroWindow.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  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 "AdventureMapButton.h"
  11. #include "CMessage.h"
  12. #include <sstream>
  13. extern SDL_Surface * screen;
  14. extern TTF_Font * GEOR16;
  15. CHeroWindow::CHeroWindow(int playerColor): artFeet(0), artHead(0), artLHand(0),
  16. artLRing(0), artMach1(0), artMach2(0), artMach3(0), artMach4(0), artMisc1(0),
  17. artMisc2(0), artMisc3(0), artMisc4(0), artMisc5(0), artNeck(0), artRhand(0),
  18. artRRing(0), artShoulders(0), artSpellBook(0), artTorso(0),
  19. backpackPos(0), player(playerColor)
  20. {
  21. background = CGI->bitmaph->loadBitmap("HEROSCR4.bmp");
  22. CSDL_Ext::blueToPlayersAdv(background, playerColor);
  23. pos.x = 65;
  24. pos.y = 8;
  25. pos.h = background->h;
  26. pos.w = background->w;
  27. curBack = NULL;
  28. curHero = NULL;
  29. quitButton = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::quit, 674, 524, "hsbtns.def", this);
  30. dismissButton = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::dismissCurrent, 519, 437, "hsbtns2.def", this);
  31. questlogButton = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::questlog, 379, 437, "hsbtns4.def", this);
  32. gar1button = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::gar1, 546, 491, "hsbtns6.def", this);
  33. gar2button = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::gar2, 604, 491, "hsbtns8.def", this);
  34. gar3button = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::gar3, 546, 527, "hsbtns7.def", this);
  35. gar4button = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::gar4, 604, 527, "hsbtns9.def", this);
  36. leftArtRoll = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::leftArtRoller, 379, 364, "hsbtns3.def", this);
  37. rightArtRoll = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::rightArtRoller, 632, 364, "hsbtns5.def", this);
  38. for(int g=0; g<8; ++g)
  39. {
  40. //heroList.push_back(new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::switchHero, 677, 95+g*54, "hsbtns5.def", this));
  41. heroListMi.push_back(new LClickableAreaHero());
  42. heroListMi[g]->pos.x = 677;
  43. heroListMi[g]->pos.y = 95+g*54;
  44. heroListMi[g]->pos.h = 32;
  45. heroListMi[g]->pos.w = 48;
  46. heroListMi[g]->owner = this;
  47. heroListMi[g]->id = g;
  48. }
  49. skillpics = CGI->spriteh->giveDef("pskil42.def");
  50. flags = CGI->spriteh->giveDef("CREST58.DEF");
  51. //areas
  52. portraitArea = new LClickableAreaWText();
  53. portraitArea->pos.x = 83;
  54. portraitArea->pos.y = 26;
  55. portraitArea->pos.w = 58;
  56. portraitArea->pos.h = 64;
  57. }
  58. CHeroWindow::~CHeroWindow()
  59. {
  60. SDL_FreeSurface(background);
  61. delete quitButton;
  62. delete dismissButton;
  63. delete questlogButton;
  64. delete gar1button;
  65. delete gar2button;
  66. delete gar3button;
  67. delete gar4button;
  68. delete leftArtRoll;
  69. delete rightArtRoll;
  70. for(int g=0; g<heroListMi.size(); ++g)
  71. delete heroListMi[g];
  72. if(curBack)
  73. SDL_FreeSurface(curBack);
  74. delete skillpics;
  75. delete flags;
  76. delete artFeet;
  77. delete artHead;
  78. delete artLHand;
  79. delete artLRing;
  80. delete artMach1;
  81. delete artMach2;
  82. delete artMach3;
  83. delete artMach4;
  84. delete artMisc1;
  85. delete artMisc2;
  86. delete artMisc3;
  87. delete artMisc4;
  88. delete artMisc5;
  89. delete artNeck;
  90. delete artRhand;
  91. delete artRRing;
  92. delete artShoulders;
  93. delete artSpellBook;
  94. delete artTorso;
  95. for(int g=0; g<backpack.size(); ++g)
  96. {
  97. delete backpack[g];
  98. }
  99. backpack.clear();
  100. delete portraitArea;
  101. }
  102. void CHeroWindow::show(SDL_Surface *to)
  103. {
  104. if(!to)
  105. to=ekran;
  106. if(curBack)
  107. blitAt(curBack,pos.x,pos.y,to);
  108. quitButton->show();
  109. dismissButton->show();
  110. questlogButton->show();
  111. gar1button->show();
  112. gar2button->show();
  113. gar3button->show();
  114. gar4button->show();
  115. leftArtRoll->show();
  116. rightArtRoll->show();
  117. artFeet->show(to);
  118. artHead->show(to);
  119. artLHand->show(to);
  120. artLRing->show(to);
  121. artMach1->show(to);
  122. artMach2->show(to);
  123. artMach3->show(to);
  124. artMach4->show(to);
  125. artMisc1->show(to);
  126. artMisc2->show(to);
  127. artMisc3->show(to);
  128. artMisc4->show(to);
  129. artMisc5->show(to);
  130. artNeck->show(to);
  131. artRhand->show(to);
  132. artRRing->show(to);
  133. artShoulders->show(to);
  134. artSpellBook->show(to);
  135. artTorso->show(to);
  136. for(int d=0; d<backpack.size(); ++d)
  137. {
  138. backpack[d]->show(to);
  139. }
  140. }
  141. void CHeroWindow::setHero(const CGHeroInstance *hero)
  142. {
  143. if(!hero) //something strange... no hero? it should happen
  144. {
  145. return;
  146. }
  147. curHero = hero;
  148. portraitArea->text = hero->biography;
  149. delete artFeet;
  150. delete artHead;
  151. delete artLHand;
  152. delete artLRing;
  153. delete artMach1;
  154. delete artMach2;
  155. delete artMach3;
  156. delete artMach4;
  157. delete artMisc1;
  158. delete artMisc2;
  159. delete artMisc3;
  160. delete artMisc4;
  161. delete artMisc5;
  162. delete artNeck;
  163. delete artRhand;
  164. delete artRRing;
  165. delete artShoulders;
  166. delete artSpellBook;
  167. delete artTorso;
  168. for(int g=0; g<backpack.size(); ++g)
  169. {
  170. delete backpack[g];
  171. }
  172. backpack.clear();
  173. artFeet = new CArtPlace(hero->artFeet);
  174. artFeet->pos.x = 515;
  175. artFeet->pos.y = 295;
  176. artFeet->pos.h = artFeet->pos.w = 44;
  177. artHead = new CArtPlace(hero->artHead);
  178. artHead->pos.x = 509;
  179. artHead->pos.y = 30;
  180. artHead->pos.h = artHead->pos.h = 44;
  181. artLHand = new CArtPlace(hero->artLHand);
  182. artLHand->pos.x = 564;
  183. artLHand->pos.y = 183;
  184. artLHand->pos.h = artLHand->pos.h = 44;
  185. artLRing = new CArtPlace(hero->artLRing);
  186. artLRing->pos.x = 610;
  187. artLRing->pos.y = 183;
  188. artLRing->pos.h = artLRing->pos.h = 44;
  189. artMach1 = new CArtPlace(hero->artMach1);
  190. artMach1->pos.x = 564;
  191. artMach1->pos.y = 30;
  192. artMach1->pos.h = artMach1->pos.h = 44;
  193. artMach2 = new CArtPlace(hero->artMach2);
  194. artMach2->pos.x = 610;
  195. artMach2->pos.y = 30;
  196. artMach2->pos.h = artMach2->pos.h = 44;
  197. artMach3 = new CArtPlace(hero->artMach3);
  198. artMach3->pos.x = 610;
  199. artMach3->pos.y = 76;
  200. artMach3->pos.h = artMach3->pos.h = 44;
  201. artMach4 = new CArtPlace(hero->artMach4);
  202. artMach4->pos.x = 610;
  203. artMach4->pos.y = 122;
  204. artMach4->pos.h = artMach4->pos.h = 44;
  205. artMisc1 = new CArtPlace(hero->artMisc1);
  206. artMisc1->pos.x = 383;
  207. artMisc1->pos.y = 143;
  208. artMisc1->pos.h = artMisc1->pos.h = 44;
  209. artMisc2 = new CArtPlace(hero->artMisc2);
  210. artMisc2->pos.x = 399;
  211. artMisc2->pos.y = 194;
  212. artMisc2->pos.h = artMisc2->pos.h = 44;
  213. artMisc3 = new CArtPlace(hero->artMisc3);
  214. artMisc3->pos.x = 415;
  215. artMisc3->pos.y = 245;
  216. artMisc3->pos.h = artMisc3->pos.h = 44;
  217. artMisc4 = new CArtPlace(hero->artMisc4);
  218. artMisc4->pos.x = 431;
  219. artMisc4->pos.y = 296;
  220. artMisc4->pos.h = artMisc4->pos.h = 44;
  221. artMisc5 = new CArtPlace(hero->artMisc5);
  222. artMisc5->pos.x = 381;
  223. artMisc5->pos.y = 296;
  224. artMisc5->pos.h = artMisc5->pos.h = 44;
  225. artNeck = new CArtPlace(hero->artNeck);
  226. artNeck->pos.x = 508;
  227. artNeck->pos.y = 79;
  228. artNeck->pos.h = artNeck->pos.h = 44;
  229. artRhand = new CArtPlace(hero->artRhand);
  230. artRhand->pos.x = 383;
  231. artRhand->pos.y = 68;
  232. artRhand->pos.h = artRhand->pos.h = 44;
  233. artRRing = new CArtPlace(hero->artRRing);
  234. artRRing->pos.x = 431;
  235. artRRing->pos.y = 68;
  236. artRRing->pos.h = artRRing->pos.h = 44;
  237. artShoulders = new CArtPlace(hero->artShoulders);
  238. artShoulders->pos.x = 567;
  239. artShoulders->pos.y = 240;
  240. artShoulders->pos.h = artShoulders->pos.h = 44;
  241. artSpellBook = new CArtPlace(hero->artSpellBook);
  242. artSpellBook->pos.x = 610;
  243. artSpellBook->pos.y = 310;
  244. artSpellBook->pos.h = artSpellBook->pos.h = 44;
  245. artTorso = new CArtPlace(hero->artTorso);
  246. artTorso->pos.x = 509;
  247. artTorso->pos.y = 130;
  248. artTorso->pos.h = artTorso->pos.h = 44;
  249. for(int s=0; s<5 && s<curHero->artifacts.size(); ++s)
  250. {
  251. CArtPlace * add = new CArtPlace(curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ]);
  252. add->pos.x = 403 + 46*s;
  253. add->pos.y = 365;
  254. add->pos.h = add->pos.h = 44;
  255. backpack.push_back(add);
  256. }
  257. redrawCurBack();
  258. }
  259. void CHeroWindow::quit()
  260. {
  261. for(int i=0; i<LOCPLINT->objsToBlit.size(); ++i)
  262. {
  263. if( dynamic_cast<CHeroWindow*>( LOCPLINT->objsToBlit[i] ) )
  264. {
  265. LOCPLINT->objsToBlit.erase(LOCPLINT->objsToBlit.begin()+i);
  266. }
  267. }
  268. deactivate();
  269. LOCPLINT->adventureInt->show();
  270. SDL_FreeSurface(curBack);
  271. curBack = NULL;
  272. /*for(int v=0; v<LOCPLINT->lclickable.size(); ++v)
  273. {
  274. if(dynamic_cast<CArtPlace*>(LOCPLINT->lclickable[v]))
  275. LOCPLINT->lclickable.erase(LOCPLINT->lclickable.begin()+v);
  276. }*/
  277. delete artFeet;
  278. artFeet = 0;
  279. delete artHead;
  280. artHead = 0;
  281. delete artLHand;
  282. artLHand = 0;
  283. delete artLRing;
  284. artLRing = 0;
  285. delete artMach1;
  286. artMach1 = 0;
  287. delete artMach2;
  288. artMach2 = 0;
  289. delete artMach3;
  290. artMach3 = 0;
  291. delete artMach4;
  292. artMach4 = 0;
  293. delete artMisc1;
  294. artMisc1 = 0;
  295. delete artMisc2;
  296. artMisc2 = 0;
  297. delete artMisc3;
  298. artMisc3 = 0;
  299. delete artMisc4;
  300. artMisc4 = 0;
  301. delete artMisc5;
  302. artMisc5 = 0;
  303. delete artNeck;
  304. artNeck = 0;
  305. delete artRhand;
  306. artRhand = 0;
  307. delete artRRing;
  308. artRRing = 0;
  309. delete artShoulders;
  310. artShoulders = 0;
  311. delete artSpellBook;
  312. artSpellBook = 0;
  313. delete artTorso;
  314. artTorso = 0;
  315. for(int g=0; g<backpack.size(); ++g)
  316. {
  317. delete backpack[g];
  318. }
  319. backpack.clear();
  320. }
  321. void CHeroWindow::activate()
  322. {
  323. LOCPLINT->curint = this;
  324. quitButton->activate();
  325. dismissButton->activate();
  326. questlogButton->activate();
  327. gar1button->activate();
  328. gar2button->activate();
  329. gar3button->activate();
  330. gar4button->activate();
  331. leftArtRoll->activate();
  332. rightArtRoll->activate();
  333. portraitArea->activate();
  334. for(int g=0; g<heroListMi.size(); ++g)
  335. {
  336. heroListMi[g]->activate();
  337. }
  338. redrawCurBack();
  339. if(artFeet)
  340. artFeet->activate();
  341. if(artHead)
  342. artHead->activate();
  343. if(artLHand)
  344. artLHand->activate();
  345. if(artLRing)
  346. artLRing->activate();
  347. if(artMach1)
  348. artMach1->activate();
  349. if(artMach2)
  350. artMach2->activate();
  351. if(artMach3)
  352. artMach3->activate();
  353. if(artMach4)
  354. artMach4->activate();
  355. if(artMisc1)
  356. artMisc1->activate();
  357. if(artMisc2)
  358. artMisc2->activate();
  359. if(artMisc3)
  360. artMisc3->activate();
  361. if(artMisc4)
  362. artMisc4->activate();
  363. if(artMisc5)
  364. artMisc5->activate();
  365. if(artNeck)
  366. artNeck->activate();
  367. if(artRhand)
  368. artRhand->activate();
  369. if(artRRing)
  370. artRRing->activate();
  371. if(artShoulders)
  372. artShoulders->activate();
  373. if(artSpellBook)
  374. artSpellBook->activate();
  375. if(artTorso)
  376. artTorso->activate();
  377. for(int f=0; f<backpack.size(); ++f)
  378. {
  379. if(backpack[f])
  380. backpack[f]->activate();
  381. }
  382. for(int e=0; e<heroListMi.size(); ++e)
  383. {
  384. heroListMi[e]->activate();
  385. }
  386. //LOCPLINT->lclickable.push_back(artFeet);
  387. }
  388. void CHeroWindow::deactivate()
  389. {
  390. quitButton->deactivate();
  391. dismissButton->deactivate();
  392. questlogButton->deactivate();
  393. gar1button->deactivate();
  394. gar2button->deactivate();
  395. gar3button->deactivate();
  396. gar4button->deactivate();
  397. leftArtRoll->deactivate();
  398. rightArtRoll->deactivate();
  399. portraitArea->deactivate();
  400. for(int g=0; g<heroListMi.size(); ++g)
  401. {
  402. heroListMi[g]->deactivate();
  403. }
  404. if(artFeet)
  405. artFeet->deactivate();
  406. if(artHead)
  407. artHead->deactivate();
  408. if(artLHand)
  409. artLHand->deactivate();
  410. if(artLRing)
  411. artLRing->deactivate();
  412. if(artMach1)
  413. artMach1->deactivate();
  414. if(artMach2)
  415. artMach2->deactivate();
  416. if(artMach3)
  417. artMach3->deactivate();
  418. if(artMach4)
  419. artMach4->deactivate();
  420. if(artMisc1)
  421. artMisc1->deactivate();
  422. if(artMisc2)
  423. artMisc2->deactivate();
  424. if(artMisc3)
  425. artMisc3->deactivate();
  426. if(artMisc4)
  427. artMisc4->deactivate();
  428. if(artMisc5)
  429. artMisc5->deactivate();
  430. if(artNeck)
  431. artNeck->deactivate();
  432. if(artRhand)
  433. artRhand->deactivate();
  434. if(artRRing)
  435. artRRing->deactivate();
  436. if(artShoulders)
  437. artShoulders->deactivate();
  438. if(artSpellBook)
  439. artSpellBook->deactivate();
  440. if(artTorso)
  441. artTorso->deactivate();
  442. for(int f=0; f<backpack.size(); ++f)
  443. {
  444. if(backpack[f])
  445. backpack[f]->deactivate();
  446. }
  447. for(int e=0; e<heroListMi.size(); ++e)
  448. {
  449. heroListMi[e]->deactivate();
  450. }
  451. }
  452. void CHeroWindow::dismissCurrent()
  453. {
  454. }
  455. void CHeroWindow::questlog()
  456. {
  457. }
  458. void CHeroWindow::gar1()
  459. {
  460. }
  461. void CHeroWindow::gar2()
  462. {
  463. }
  464. void CHeroWindow::gar3()
  465. {
  466. }
  467. void CHeroWindow::gar4()
  468. {
  469. }
  470. void CHeroWindow::leftArtRoller()
  471. {
  472. if(curHero->artifacts.size()>5) //if it is <=5, we have nothing to scroll
  473. {
  474. backpackPos+=curHero->artifacts.size()-1; //set new offset
  475. for(int s=0; s<5 && s<curHero->artifacts.size(); ++s) //set new data
  476. {
  477. backpack[s]->ourArt = curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ];
  478. }
  479. }
  480. }
  481. void CHeroWindow::rightArtRoller()
  482. {
  483. if(curHero->artifacts.size()>5) //if it is <=5, we have nothing to scroll
  484. {
  485. backpackPos+=1; //set new offset
  486. for(int s=0; s<5 && s<curHero->artifacts.size(); ++s) //set new data
  487. {
  488. backpack[s]->ourArt = curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ];
  489. }
  490. }
  491. }
  492. void CHeroWindow::switchHero()
  493. {
  494. //int y;
  495. //SDL_GetMouseState(NULL, &y);
  496. //for(int g=0; g<heroListMi.size(); ++g)
  497. //{
  498. // if(y>=94+54*g)
  499. // {
  500. // //quit();
  501. // setHero(LOCPLINT->cb->getHeroInfo(player, g, false));
  502. // //LOCPLINT->openHeroWindow(curHero);
  503. // redrawCurBack();
  504. // }
  505. //}
  506. }
  507. void CHeroWindow::redrawCurBack()
  508. {
  509. if(curBack)
  510. SDL_FreeSurface(curBack);
  511. curBack = CSDL_Ext::copySurface(background);
  512. blitAt(skillpics->ourImages[0].bitmap, 32, 111, curBack);
  513. blitAt(skillpics->ourImages[1].bitmap, 102, 111, curBack);
  514. blitAt(skillpics->ourImages[2].bitmap, 172, 111, curBack);
  515. blitAt(skillpics->ourImages[5].bitmap, 242, 111, curBack);
  516. blitAt(skillpics->ourImages[4].bitmap, 20, 230, curBack);
  517. blitAt(skillpics->ourImages[3].bitmap, 162, 230, curBack);
  518. blitAt(curHero->type->portraitLarge, 19, 19, curBack);
  519. CSDL_Ext::printAtMiddle(curHero->name, 190, 40, GEORXX, tytulowy, curBack);
  520. std::stringstream secondLine;
  521. secondLine<<"Level "<<curHero->level<<" "<<curHero->type->heroClass->name;
  522. CSDL_Ext::printAtMiddle(secondLine.str(), 190, 66, TNRB16, zwykly, curBack);
  523. //primary skliis names
  524. CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[1], 53, 98, GEOR13, tytulowy, curBack);
  525. CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[2], 123, 98, GEOR13, tytulowy, curBack);
  526. CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[3], 193, 98, GEOR13, tytulowy, curBack);
  527. CSDL_Ext::printAtMiddle(CGI->generaltexth->jktexts[4], 263, 98, GEOR13, tytulowy, curBack);
  528. //dismiss / quest log
  529. std::vector<std::string> * toPrin = CMessage::breakText(CGI->generaltexth->jktexts[8].substr(1, CGI->generaltexth->jktexts[8].size()-2));
  530. if(toPrin->size()==1)
  531. {
  532. CSDL_Ext::printAt((*toPrin)[0], 372, 440, GEOR13, zwykly, curBack);
  533. }
  534. else
  535. {
  536. CSDL_Ext::printAt((*toPrin)[0], 372, 431, GEOR13, zwykly, curBack);
  537. CSDL_Ext::printAt((*toPrin)[1], 372, 447, GEOR13, zwykly, curBack);
  538. }
  539. delete toPrin;
  540. toPrin = CMessage::breakText(CGI->generaltexth->jktexts[9].substr(1, CGI->generaltexth->jktexts[9].size()-2));
  541. if(toPrin->size()==1)
  542. {
  543. CSDL_Ext::printAt((*toPrin)[0], 512, 440, GEOR13, zwykly, curBack);
  544. }
  545. else
  546. {
  547. CSDL_Ext::printAt((*toPrin)[0], 512, 431, GEOR13, zwykly, curBack);
  548. CSDL_Ext::printAt((*toPrin)[1], 512, 447, GEOR13, zwykly, curBack);
  549. }
  550. delete toPrin;
  551. //printing primary skills' amounts
  552. std::stringstream primarySkill1;
  553. primarySkill1<<curHero->primSkills[0];
  554. CSDL_Ext::printAtMiddle(primarySkill1.str(), 53, 165, TNRB16, zwykly, curBack);
  555. std::stringstream primarySkill2;
  556. primarySkill2<<curHero->primSkills[1];
  557. CSDL_Ext::printAtMiddle(primarySkill2.str(), 123, 165, TNRB16, zwykly, curBack);
  558. std::stringstream primarySkill3;
  559. primarySkill3<<curHero->primSkills[2];
  560. CSDL_Ext::printAtMiddle(primarySkill3.str(), 193, 165, TNRB16, zwykly, curBack);
  561. std::stringstream primarySkill4;
  562. primarySkill4<<curHero->primSkills[3];
  563. CSDL_Ext::printAtMiddle(primarySkill4.str(), 263, 165, TNRB16, zwykly, curBack);
  564. blitAt(LOCPLINT->luck42->ourImages[curHero->getCurrentLuck()+3].bitmap, 239, 182, curBack);
  565. blitAt(LOCPLINT->morale42->ourImages[curHero->getCurrentMorale()+3].bitmap, 181, 182, curBack);
  566. blitAt(flags->ourImages[player].bitmap, 606, 8, curBack);
  567. //hero list blitting
  568. for(int g=0; g<LOCPLINT->cb->howManyHeroes(); ++g)
  569. {
  570. const CGHeroInstance * cur = LOCPLINT->cb->getHeroInfo(player, g, false);
  571. blitAt(cur->type->portraitSmall, 611, 87+g*54, curBack);
  572. //printing yellow border
  573. if(cur->name == curHero->name)
  574. {
  575. for(int f=0; f<cur->type->portraitSmall->w; ++f)
  576. {
  577. for(int h=0; h<cur->type->portraitSmall->h; ++h)
  578. if(f==0 || h==0 || f==cur->type->portraitSmall->w-1 || h==cur->type->portraitSmall->h-1)
  579. {
  580. CSDL_Ext::SDL_PutPixel(curBack, 611+f, 87+g*54+h, 240, 220, 120);
  581. }
  582. }
  583. }
  584. }
  585. //secondary skills
  586. if(curHero->secSkills.size()>=1)
  587. {
  588. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[0].first*3+3+curHero->secSkills[0].second].bitmap, 18, 276, curBack);
  589. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[0].second], 69, 279, GEOR13, zwykly, curBack);
  590. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[0].first]->name, 69, 299, GEOR13, zwykly, curBack);
  591. }
  592. if(curHero->secSkills.size()>=2)
  593. {
  594. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[1].first*3+3+curHero->secSkills[1].second].bitmap, 161, 276, curBack);
  595. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[1].second], 213, 279, GEOR13, zwykly, curBack);
  596. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[1].first]->name, 213, 299, GEOR13, zwykly, curBack);
  597. }
  598. if(curHero->secSkills.size()>=3)
  599. {
  600. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[2].first*3+3+curHero->secSkills[2].second].bitmap, 18, 324, curBack);
  601. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[2].second], 69, 327, GEOR13, zwykly, curBack);
  602. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[2].first]->name, 69, 347, GEOR13, zwykly, curBack);
  603. }
  604. if(curHero->secSkills.size()>=4)
  605. {
  606. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[3].first*3+3+curHero->secSkills[3].second].bitmap, 161, 324, curBack);
  607. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[3].second], 213, 327, GEOR13, zwykly, curBack);
  608. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[3].first]->name, 213, 347, GEOR13, zwykly, curBack);
  609. }
  610. if(curHero->secSkills.size()>=5)
  611. {
  612. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[4].first*3+3+curHero->secSkills[4].second].bitmap, 18, 372, curBack);
  613. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[4].second], 69, 375, GEOR13, zwykly, curBack);
  614. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[4].first]->name, 69, 395, GEOR13, zwykly, curBack);
  615. }
  616. if(curHero->secSkills.size()>=6)
  617. {
  618. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[5].first*3+3+curHero->secSkills[5].second].bitmap, 161, 372, curBack);
  619. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[5].second], 213, 375, GEOR13, zwykly, curBack);
  620. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[5].first]->name, 213, 395, GEOR13, zwykly, curBack);
  621. }
  622. if(curHero->secSkills.size()>=7)
  623. {
  624. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[6].first*3+3+curHero->secSkills[6].second].bitmap, 18, 420, curBack);
  625. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[6].second], 69, 423, GEOR13, zwykly, curBack);
  626. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[6].first]->name, 69, 443, GEOR13, zwykly, curBack);
  627. }
  628. if(curHero->secSkills.size()>=8)
  629. {
  630. blitAt(CGI->abilh->abils44->ourImages[curHero->secSkills[7].first*3+3+curHero->secSkills[7].second].bitmap, 161, 420, curBack);
  631. CSDL_Ext::printAt(CGI->abilh->levels[curHero->secSkills[7].second], 213, 423, GEOR13, zwykly, curBack);
  632. CSDL_Ext::printAt(CGI->abilh->abilities[curHero->secSkills[7].first]->name, 213, 443, GEOR13, zwykly, curBack);
  633. }
  634. //printing special ability
  635. blitAt(CGI->heroh->un44->ourImages[curHero->subID].bitmap, 18, 180, curBack);
  636. //printing necessery texts
  637. CSDL_Ext::printAt(CGI->generaltexth->jktexts[6].substr(1, CGI->generaltexth->jktexts[6].size()-2), 69, 231, GEOR13, tytulowy, curBack);
  638. std::stringstream expstr;
  639. expstr<<curHero->exp;
  640. CSDL_Ext::printAt(expstr.str(), 69, 247, GEOR16, zwykly, curBack);
  641. CSDL_Ext::printAt(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 212, 231, GEOR13, tytulowy, curBack);
  642. std::stringstream manastr;
  643. manastr<<curHero->mana<<'/'<<curHero->primSkills[3]*10;
  644. CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack);
  645. }
  646. CArtPlace::CArtPlace(CArtifact *art): ourArt(art), active(false){}
  647. void CArtPlace::activate()
  648. {
  649. if(!active)
  650. {
  651. ClickableL::activate();
  652. active = true;
  653. }
  654. }
  655. void CArtPlace::clickLeft(boost::logic::tribool down)
  656. {
  657. }
  658. void CArtPlace::deactivate()
  659. {
  660. if(active)
  661. {
  662. active = false;
  663. ClickableL::deactivate();
  664. }
  665. }
  666. void CArtPlace::show(SDL_Surface *to)
  667. {
  668. if(ourArt)
  669. {
  670. blitAt(CGI->arth->artDefs->ourImages[ourArt->id].bitmap, pos.x, pos.y, to);
  671. }
  672. }
  673. CArtPlace::~CArtPlace()
  674. {
  675. deactivate();
  676. }
  677. void LClickableArea::activate()
  678. {
  679. ClickableL::activate();
  680. }
  681. void LClickableArea::deactivate()
  682. {
  683. ClickableL::deactivate();
  684. }
  685. void LClickableArea::clickLeft(boost::logic::tribool down)
  686. {
  687. if(!down)
  688. {
  689. LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector<SComponent*>());
  690. }
  691. }
  692. void LClickableAreaWText::clickLeft(boost::logic::tribool down)
  693. {
  694. if(!down)
  695. {
  696. LOCPLINT->showInfoDialog(text, std::vector<SComponent*>());
  697. }
  698. }
  699. void LClickableAreaHero::clickLeft(boost::logic::tribool down)
  700. {
  701. if(!down)
  702. {
  703. owner->deactivate();
  704. const CGHeroInstance * buf = LOCPLINT->cb->getHeroInfo(owner->player, id, false);
  705. owner->setHero(buf);
  706. owner->redrawCurBack();
  707. owner->activate();
  708. }
  709. }