CHeroWindow.cpp 24 KB

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