CAdvmapInterface.cpp 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  1. #include "stdafx.h"
  2. #include "CAdvmapInterface.h"
  3. #include "hch\CLodHandler.h"
  4. #include "hch\CPreGameTextHandler.h"
  5. #include "hch\CGeneralTextHandler.h"
  6. #include "hch\CTownHandler.h"
  7. #include "CPathfinder.h"
  8. #include "CGameInfo.h"
  9. #include "SDL_Extensions.h"
  10. #include "CCallback.h"
  11. #include <boost/assign/std/vector.hpp>
  12. #include "mapHandler.h"
  13. #include "CMessage.h"
  14. #include <boost/algorithm/string.hpp>
  15. #include <boost/algorithm/string/replace.hpp>
  16. extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX; //fonts
  17. using namespace boost::logic;
  18. using namespace boost::assign;
  19. using namespace CSDL_Ext;
  20. CAdvMapInt::~CAdvMapInt()
  21. {
  22. SDL_FreeSurface(bg);
  23. }
  24. AdventureMapButton::AdventureMapButton ()
  25. {
  26. type=2;
  27. abs=true;
  28. active=false;
  29. ourObj=NULL;
  30. state=0;
  31. }
  32. AdventureMapButton::AdventureMapButton
  33. ( std::string Name, std::string HelpBox, void(CAdvMapInt::*Function)(), int x, int y, std::string defName, bool activ, std::vector<std::string> * add )
  34. {
  35. type=2;
  36. abs=true;
  37. active=false;
  38. ourObj=NULL;
  39. state=0;
  40. name=Name;
  41. helpBox=HelpBox;
  42. int est = LOCPLINT->playerID;
  43. CDefHandler * temp = CGI->spriteh->giveDef(defName); //todo: moze cieknac
  44. for (int i=0;i<temp->ourImages.size();i++)
  45. {
  46. imgs.resize(1);
  47. imgs[0].push_back(temp->ourImages[i].bitmap);
  48. blueToPlayersAdv(imgs[curimg][i],LOCPLINT->playerID);
  49. }
  50. if (add)
  51. {
  52. imgs.resize(imgs.size()+add->size());
  53. for (int i=0; i<add->size();i++)
  54. {
  55. temp = CGI->spriteh->giveDef((*add)[i]);
  56. for (int j=0;j<temp->ourImages.size();j++)
  57. {
  58. imgs[i+1].push_back(temp->ourImages[j].bitmap);
  59. blueToPlayersAdv(imgs[1+i][j],LOCPLINT->playerID);
  60. }
  61. }
  62. delete add;
  63. }
  64. function = Function;
  65. pos.x=x;
  66. pos.y=y;
  67. pos.w = imgs[curimg][0]->w;
  68. pos.h = imgs[curimg][0]->h -1;
  69. if (activ)
  70. activate();
  71. }
  72. void AdventureMapButton::clickLeft (tribool down)
  73. {
  74. if (down)
  75. {
  76. state=1;
  77. }
  78. else
  79. {
  80. state=0;
  81. }
  82. show();
  83. if (pressedL && (down==false))
  84. (LOCPLINT->adventureInt->*function)();
  85. pressedL=state;
  86. }
  87. void AdventureMapButton::clickRight (tribool down)
  88. {
  89. LOCPLINT->adventureInt->handleRightClick(helpBox,down,this);
  90. }
  91. void AdventureMapButton::hover (bool on)
  92. {
  93. Hoverable::hover(on);
  94. if (on)
  95. LOCPLINT->adventureInt->statusbar.print(name);
  96. else if (LOCPLINT->adventureInt->statusbar.current==name)
  97. LOCPLINT->adventureInt->statusbar.clear();
  98. }
  99. void AdventureMapButton::activate()
  100. {
  101. if (active) return;
  102. active=true;
  103. ClickableL::activate();
  104. ClickableR::activate();
  105. Hoverable::activate();
  106. KeyInterested::activate();
  107. }
  108. void AdventureMapButton::keyPressed (SDL_KeyboardEvent & key)
  109. {
  110. //TODO: check if it's shortcut
  111. }
  112. void AdventureMapButton::deactivate()
  113. {
  114. if (!active) return;
  115. active=false;
  116. ClickableL::deactivate();
  117. Hoverable::deactivate();
  118. KeyInterested::deactivate();
  119. }
  120. void CList::activate()
  121. {
  122. ClickableL::activate();
  123. ClickableR::activate();
  124. Hoverable::activate();
  125. KeyInterested::activate();
  126. MotionInterested::activate();
  127. };
  128. void CList::deactivate()
  129. {
  130. ClickableL::deactivate();
  131. ClickableR::deactivate();
  132. Hoverable::deactivate();
  133. KeyInterested::deactivate();
  134. MotionInterested::deactivate();
  135. };
  136. void CList::clickLeft(tribool down)
  137. {
  138. };
  139. CHeroList::CHeroList()
  140. {
  141. pos = genRect(192,64,609,196);
  142. arrupp = genRect(16,64,609,196);
  143. arrdop = genRect(16,64,609,372);
  144. //32px per hero
  145. posmobx = 610;
  146. posmoby = 213;
  147. posporx = 617;
  148. pospory = 212;
  149. posmanx = 666;
  150. posmany = 213;
  151. arrup = CGI->spriteh->giveDef("IAM012.DEF");
  152. arrdo = CGI->spriteh->giveDef("IAM013.DEF");
  153. mobile = CGI->spriteh->giveDef("IMOBIL.DEF");
  154. mana = CGI->spriteh->giveDef("IMANA.DEF");
  155. empty = CGI->bitmaph->loadBitmap("HPSXXX.bmp");
  156. selection = CGI->bitmaph->loadBitmap("HPSYYY.bmp");
  157. SDL_SetColorKey(selection,SDL_SRCCOLORKEY,SDL_MapRGB(selection->format,0,255,255));
  158. from = 0;
  159. pressed = indeterminate;
  160. }
  161. void CHeroList::init()
  162. {
  163. bg = CSDL_Ext::newSurface(68,193,ekran);
  164. SDL_BlitSurface(LOCPLINT->adventureInt->bg,&genRect(193,68,607,196),bg,&genRect(193,68,0,0));
  165. }
  166. void CHeroList::genList()
  167. {
  168. int howMany = LOCPLINT->cb->howManyHeroes(LOCPLINT->playerID);
  169. for (int i=0;i<howMany;i++)
  170. {
  171. items.push_back(std::pair<const CHeroInstance *,CPath *>(LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,i,0),NULL));
  172. }
  173. }
  174. void CHeroList::select(int which)
  175. {
  176. selected = which;
  177. if (which>=items.size())
  178. return;
  179. LOCPLINT->adventureInt->centerOn(items[which].first->pos);
  180. LOCPLINT->adventureInt->selection.type = HEROI_TYPE;
  181. LOCPLINT->adventureInt->selection.selected = items[which].first;
  182. LOCPLINT->adventureInt->terrain.currentPath = items[which].second;
  183. draw();
  184. LOCPLINT->adventureInt->townList.draw();
  185. }
  186. void CHeroList::clickLeft(tribool down)
  187. {
  188. if (down)
  189. {
  190. /***************************ARROWS*****************************************/
  191. if(isItIn(&arrupp,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && from>0)
  192. {
  193. blitAtWR(arrup->ourImages[1].bitmap,arrupp.x,arrupp.y);
  194. pressed = true;
  195. return;
  196. }
  197. else if(isItIn(&arrdop,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && (items.size()-from>5))
  198. {
  199. blitAtWR(arrdo->ourImages[1].bitmap,arrdop.x,arrdop.y);
  200. pressed = false;
  201. return;
  202. }
  203. /***************************HEROES*****************************************/
  204. int hx = LOCPLINT->current->motion.x, hy = LOCPLINT->current->motion.y;
  205. hx-=pos.x;
  206. hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
  207. float ny = (float)hy/(float)32;
  208. if (ny>5 || ny<0)
  209. return;
  210. select(ny+from);
  211. }
  212. else
  213. {
  214. if (indeterminate(pressed))
  215. return;
  216. if (pressed) //up
  217. {
  218. blitAtWR(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y);
  219. pressed = indeterminate;
  220. if (!down)
  221. {
  222. from--;
  223. if (from<0)
  224. from=0;
  225. draw();
  226. }
  227. }
  228. else if (!pressed) //down
  229. {
  230. blitAtWR(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y);
  231. pressed = indeterminate;
  232. if (!down)
  233. {
  234. from++;
  235. if (from<items.size()-5)
  236. from=items.size()-5;
  237. draw();
  238. }
  239. }
  240. else
  241. throw 0;
  242. }
  243. }
  244. void CHeroList::mouseMoved (SDL_MouseMotionEvent & sEvent)
  245. {
  246. if(isItIn(&arrupp,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y))
  247. {
  248. if (from>0)
  249. LOCPLINT->adventureInt->statusbar.print(CGI->preth->advHListUp.first);
  250. else
  251. LOCPLINT->adventureInt->statusbar.clear();
  252. return;
  253. }
  254. else if(isItIn(&arrdop,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y))
  255. {
  256. if ((items.size()-from) > 5)
  257. LOCPLINT->adventureInt->statusbar.print(CGI->preth->advHListDown.first);
  258. else
  259. LOCPLINT->adventureInt->statusbar.clear();
  260. return;
  261. }
  262. //if not buttons then heroes
  263. int hx = LOCPLINT->current->motion.x, hy = LOCPLINT->current->motion.y;
  264. hx-=pos.x;
  265. hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
  266. float ny = (float)hy/(float)32;
  267. if ((ny>5 || ny<0) || (from+ny>=items.size()))
  268. {
  269. LOCPLINT->adventureInt->statusbar.clear();
  270. return;
  271. }
  272. std::vector<std::string> temp;
  273. temp+=(items[from+ny].first->name),(items[from+ny].first->type->heroClass->name);
  274. LOCPLINT->adventureInt->statusbar.print( processStr(CGI->generaltexth->allTexts[15],temp) );
  275. //select(ny+from);
  276. }
  277. void CHeroList::clickRight(tribool down)
  278. {
  279. }
  280. void CHeroList::hover (bool on)
  281. {
  282. }
  283. void CHeroList::keyPressed (SDL_KeyboardEvent & key)
  284. {
  285. }
  286. void CHeroList::draw()
  287. {
  288. for (int iT=0+from;iT<5+from;iT++)
  289. {
  290. int i = iT-from;
  291. if (iT>=items.size())
  292. {
  293. blitAtWR(mobile->ourImages[0].bitmap,posmobx,posmoby+i*32);
  294. blitAtWR(mana->ourImages[0].bitmap,posmanx,posmany+i*32);
  295. blitAtWR(empty,posporx,pospory+i*32);
  296. continue;
  297. }
  298. int pom = (LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->movement)/100;
  299. if (pom>25) pom=25;
  300. if (pom<0) pom=0;
  301. blitAtWR(mobile->ourImages[pom].bitmap,posmobx,posmoby+i*32); //move point
  302. pom = (LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->mana)/5; //bylo: .../10;
  303. if (pom>25) pom=25;
  304. if (pom<0) pom=0;
  305. blitAtWR(mana->ourImages[pom].bitmap,posmanx,posmany+i*32); //mana
  306. SDL_Surface * temp = LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->type->portraitSmall;
  307. blitAtWR(temp,posporx,pospory+i*32);
  308. if ((selected == iT) && (LOCPLINT->adventureInt->selection.type == HEROI_TYPE))
  309. {
  310. blitAtWR(selection,posporx,pospory+i*32);
  311. }
  312. //TODO: support for custom portraits
  313. }
  314. if (from>0)
  315. blitAtWR(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y);
  316. else
  317. blitAtWR(arrup->ourImages[2].bitmap,arrupp.x,arrupp.y);
  318. if (items.size()-from>5)
  319. blitAtWR(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y);
  320. else
  321. blitAtWR(arrdo->ourImages[2].bitmap,arrdop.x,arrdop.y);
  322. }
  323. CTownList::CTownList()
  324. {
  325. pos = genRect(192,48,747,196);
  326. arrup = CGI->spriteh->giveDef("IAM014.DEF");
  327. arrdo = CGI->spriteh->giveDef("IAM015.DEF");
  328. arrupp.x=747;
  329. arrupp.y=196;
  330. arrupp.w=arrup->ourImages[0].bitmap->w;
  331. arrupp.h=arrup->ourImages[0].bitmap->h;
  332. arrdop.x=747;
  333. arrdop.y=372;
  334. arrdop.w=arrdo->ourImages[0].bitmap->w;
  335. arrdop.h=arrdo->ourImages[0].bitmap->h;
  336. posporx = 747;
  337. pospory = 212;
  338. pressed = indeterminate;
  339. from = 0;
  340. }
  341. void CTownList::genList()
  342. {
  343. int howMany = LOCPLINT->cb->howManyTowns();
  344. for (int i=0;i<howMany;i++)
  345. {
  346. items.push_back(LOCPLINT->cb->getTownInfo(i,0));
  347. }
  348. }
  349. void CTownList::select(int which)
  350. {
  351. selected = which;
  352. if (which>=items.size())
  353. return;
  354. LOCPLINT->adventureInt->centerOn(items[which]->pos);
  355. LOCPLINT->adventureInt->selection.type = TOWNI_TYPE;
  356. LOCPLINT->adventureInt->selection.selected = items[which];
  357. LOCPLINT->adventureInt->terrain.currentPath = NULL;
  358. draw();
  359. LOCPLINT->adventureInt->heroList.draw();
  360. }
  361. void CTownList::mouseMoved (SDL_MouseMotionEvent & sEvent)
  362. {
  363. }
  364. void CTownList::clickLeft(tribool down)
  365. {
  366. if (down)
  367. {
  368. /***************************ARROWS*****************************************/
  369. if(isItIn(&arrupp,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && from>0)
  370. {
  371. blitAtWR(arrup->ourImages[1].bitmap,arrupp.x,arrupp.y);
  372. pressed = true;
  373. return;
  374. }
  375. else if(isItIn(&arrdop,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && (items.size()-from>5))
  376. {
  377. blitAtWR(arrdo->ourImages[1].bitmap,arrdop.x,arrdop.y);
  378. pressed = false;
  379. return;
  380. }
  381. /***************************HEROES*****************************************/
  382. int hx = LOCPLINT->current->motion.x, hy = LOCPLINT->current->motion.y;
  383. hx-=pos.x;
  384. hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
  385. float ny = (float)hy/(float)32;
  386. if (ny>5 || ny<0)
  387. return;
  388. select(ny+from);
  389. }
  390. else
  391. {
  392. if (indeterminate(pressed))
  393. return;
  394. if (pressed) //up
  395. {
  396. blitAtWR(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y);
  397. pressed = indeterminate;
  398. if (!down)
  399. {
  400. from--;
  401. if (from<0)
  402. from=0;
  403. draw();
  404. }
  405. }
  406. else if (!pressed) //down
  407. {
  408. blitAtWR(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y);
  409. pressed = indeterminate;
  410. if (!down)
  411. {
  412. from++;
  413. if (from<items.size()-5)
  414. from=items.size()-5;
  415. draw();
  416. }
  417. }
  418. else
  419. throw 0;
  420. }
  421. }
  422. void CTownList::clickRight(tribool down)
  423. {
  424. }
  425. void CTownList::hover (bool on)
  426. {
  427. }
  428. void CTownList::keyPressed (SDL_KeyboardEvent & key)
  429. {
  430. }
  431. void CTownList::draw()
  432. {
  433. for (int iT=0+from;iT<5+from;iT++)
  434. {
  435. int i = iT-from;
  436. if (iT>=items.size())
  437. {
  438. blitAtWR(CGI->townh->getPic(-1),posporx,pospory+i*32);
  439. continue;
  440. }
  441. blitAtWR(CGI->townh->getPic(items[i]->type),posporx,pospory+i*32);
  442. if ((selected == iT) && (LOCPLINT->adventureInt->selection.type == TOWNI_TYPE))
  443. {
  444. blitAtWR(CGI->townh->getPic(-2),posporx,pospory+i*32);
  445. }
  446. //TODO: dodac oznaczanie zbudowania w danej turze i posiadania fortu
  447. }
  448. if (from>0)
  449. blitAtWR(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y);
  450. else
  451. blitAtWR(arrup->ourImages[2].bitmap,arrupp.x,arrupp.y);
  452. if (items.size()-from>5)
  453. blitAtWR(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y);
  454. else
  455. blitAtWR(arrdo->ourImages[2].bitmap,arrdop.x,arrdop.y);
  456. }
  457. CStatusBar::CStatusBar(int x, int y)
  458. {
  459. bg=CGI->bitmaph->loadBitmap("ADROLLVR.bmp");
  460. SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
  461. pos.x=x;
  462. pos.y=y;
  463. pos.w=bg->w;
  464. pos.h=bg->h;
  465. middlex=(bg->w/2)+x;
  466. middley=(bg->h/2)+y;
  467. }
  468. CStatusBar::~CStatusBar()
  469. {
  470. SDL_FreeSurface(bg);
  471. }
  472. void CStatusBar::clear()
  473. {
  474. current="";
  475. blitAtWR(bg,pos.x,pos.y);
  476. }
  477. void CStatusBar::print(std::string text)
  478. {
  479. current=text;
  480. blitAtWR(bg,pos.x,pos.y);
  481. printAtMiddle(current,middlex,middley,GEOR13,zwykly);
  482. }
  483. void CStatusBar::show()
  484. {
  485. blitAtWR(bg,pos.x,pos.y);
  486. printAtMiddle(current,middlex,middley,GEOR13,zwykly);
  487. }
  488. CMinimap::CMinimap(bool draw)
  489. {
  490. statusbarTxt = CGI->preth->advWorldMap.first;
  491. rcText = CGI->preth->advWorldMap.second;
  492. pos.x=630;
  493. pos.y=26;
  494. pos.h=pos.w=144;
  495. radar = CGI->spriteh->giveDef("RADAR.DEF");
  496. std::ifstream is("config/minimap.txt",std::ifstream::in);
  497. for (int i=0;i<TERRAIN_TYPES;i++)
  498. {
  499. std::pair<int,SDL_Color> vinya;
  500. std::pair<int,SDL_Color> vinya2;
  501. int pom;
  502. is >> pom;
  503. vinya2.first=vinya.first=pom;
  504. is >> pom;
  505. vinya.second.r=pom;
  506. is >> pom;
  507. vinya.second.g=pom;
  508. is >> pom;
  509. vinya.second.b=pom;
  510. is >> pom;
  511. vinya2.second.r=pom;
  512. is >> pom;
  513. vinya2.second.g=pom;
  514. is >> pom;
  515. vinya2.second.b=pom;
  516. vinya.second.unused=vinya2.second.unused=255;
  517. colors.insert(vinya);
  518. colorsBlocked.insert(vinya2);
  519. }
  520. is.close();
  521. if (draw)
  522. redraw();
  523. }
  524. void CMinimap::draw()
  525. {
  526. blitAtWR(map[LOCPLINT->adventureInt->position.z],pos.x,pos.y);
  527. }
  528. void CMinimap::redraw(int level)// (level==-1) => redraw all levels
  529. {
  530. (CGameInfo::mainObj);
  531. for (int i=0; i<CGI->mh->sizes.z; i++)
  532. {
  533. SDL_Surface * pom ;
  534. if ((level>=0) && (i!=level))
  535. continue;
  536. if (map.size()<i+1)
  537. pom = CSDL_Ext::newSurface(pos.w,pos.h,ekran);
  538. else pom = map[i];
  539. for (int x=0;x<pos.w;x++)
  540. {
  541. for (int y=0;y<pos.h;y++)
  542. {
  543. int mx=(CGI->mh->sizes.x*x)/pos.w;
  544. int my=(CGI->mh->sizes.y*y)/pos.h;
  545. if (CGI->mh->ttiles[mx][my][i].blocked && (!CGI->mh->ttiles[mx][my][i].visitable))
  546. SDL_PutPixel(pom,x,y,colorsBlocked[CGI->mh->ttiles[mx][my][i].terType].r,colorsBlocked[CGI->mh->ttiles[mx][my][i].terType].g,colorsBlocked[CGI->mh->ttiles[mx][my][i].terType].b);
  547. else SDL_PutPixel(pom,x,y,colors[CGI->mh->ttiles[mx][my][i].terType].r,colors[CGI->mh->ttiles[mx][my][i].terType].g,colors[CGI->mh->ttiles[mx][my][i].terType].b);
  548. }
  549. }
  550. map.push_back(pom);
  551. }
  552. }
  553. void CMinimap::updateRadar()
  554. {}
  555. void CMinimap::clickRight (tribool down)
  556. {
  557. LOCPLINT->adventureInt->handleRightClick(rcText,down,this);
  558. }
  559. void CMinimap::clickLeft (tribool down)
  560. {
  561. if (down && (!pressedL))
  562. MotionInterested::activate();
  563. else if (!down)
  564. {
  565. if (std::find(LOCPLINT->motioninterested.begin(),LOCPLINT->motioninterested.end(),this)!=LOCPLINT->motioninterested.end())
  566. MotionInterested::deactivate();
  567. }
  568. ClickableL::clickLeft(down);
  569. if (!((bool)down))
  570. return;
  571. float dx=((float)(LOCPLINT->current->motion.x-pos.x))/((float)pos.w),
  572. dy=((float)(LOCPLINT->current->motion.y-pos.y))/((float)pos.h);
  573. int3 newCPos;
  574. newCPos.x = (CGI->mh->sizes.x*dx);
  575. newCPos.y = (CGI->mh->sizes.y*dy);
  576. newCPos.z = LOCPLINT->adventureInt->position.z;
  577. LOCPLINT->adventureInt->centerOn(newCPos);
  578. }
  579. void CMinimap::hover (bool on)
  580. {
  581. Hoverable::hover(on);
  582. if (on)
  583. LOCPLINT->adventureInt->statusbar.print(statusbarTxt);
  584. else if (LOCPLINT->adventureInt->statusbar.current==statusbarTxt)
  585. LOCPLINT->adventureInt->statusbar.clear();
  586. }
  587. void CMinimap::mouseMoved (SDL_MouseMotionEvent & sEvent)
  588. {
  589. if (pressedL)
  590. {
  591. clickLeft(true);
  592. }
  593. }
  594. void CMinimap::activate()
  595. {
  596. ClickableL::activate();
  597. ClickableR::activate();
  598. Hoverable::activate();
  599. if (pressedL)
  600. MotionInterested::activate();
  601. }
  602. void CMinimap::deactivate()
  603. {
  604. if (pressedL)
  605. MotionInterested::deactivate();
  606. ClickableL::deactivate();
  607. ClickableR::deactivate();
  608. Hoverable::deactivate();
  609. }
  610. CTerrainRect::CTerrainRect():currentPath(NULL)
  611. {
  612. tilesw=19;
  613. tilesh=18;
  614. pos.x=7;
  615. pos.y=6;
  616. pos.w=593;
  617. pos.h=547;
  618. arrows = CGI->spriteh->giveDef("ADAG.DEF");
  619. for(int y=0; y<arrows->ourImages.size(); ++y)
  620. {
  621. CSDL_Ext::fullAlphaTransform(arrows->ourImages[y].bitmap);
  622. }
  623. }
  624. void CTerrainRect::activate()
  625. {
  626. ClickableL::activate();
  627. ClickableR::activate();
  628. Hoverable::activate();
  629. KeyInterested::activate();
  630. MotionInterested::activate();
  631. };
  632. void CTerrainRect::deactivate()
  633. {
  634. ClickableL::deactivate();
  635. ClickableR::deactivate();
  636. Hoverable::deactivate();
  637. KeyInterested::deactivate();
  638. MotionInterested::deactivate();
  639. };
  640. void CTerrainRect::clickLeft(tribool down)
  641. {
  642. if ((down==false) || indeterminate(down))
  643. return;
  644. if (LOCPLINT->adventureInt->selection.type != HEROI_TYPE)
  645. {
  646. if (currentPath)
  647. {
  648. delete currentPath;
  649. currentPath = NULL;
  650. }
  651. return;
  652. }
  653. int3 mp = whichTileIsIt();
  654. if ((mp.x<0) || (mp.y<0))
  655. return;
  656. if (currentPath)
  657. {
  658. if ( (currentPath->endPos()) == mp)
  659. { //move
  660. CPath sended(*currentPath); //temporary path - engine will operate on it
  661. LOCPLINT->cb->moveHero( ((const CHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID,&sended,1,0);
  662. }
  663. else
  664. {
  665. delete currentPath;
  666. currentPath=NULL;
  667. }
  668. }
  669. const CHeroInstance * currentHero = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].first;
  670. int3 bufpos = currentHero->getPosition(false);
  671. //bufpos.x-=1;
  672. currentPath = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].second = CGI->pathf->getPath(bufpos,mp,currentHero,1);
  673. //if (LOCPLINT->objsToBlit.size()==0)
  674. //{
  675. // CSimpleWindow * temp = CMessage::genWindow(" Tutaj dlugi dlugo test Tutaj dlugi dlugi dlugo test Tutaj dlugi dlugi dlugo test Tutaj dlugi dlugi dlugo test {Tutaj tytul} Tutaj dlugi dlugi dlugo test",0);
  676. // temp->pos.x=temp->pos.y=0;temp->ID=3;
  677. // LOCPLINT->objsToBlit.push_back(temp);
  678. //}
  679. //SDL_Delay(5000);
  680. }
  681. void CTerrainRect::clickRight(tribool down)
  682. {
  683. }
  684. void CTerrainRect::mouseMoved (SDL_MouseMotionEvent & sEvent)
  685. {
  686. int3 pom=LOCPLINT->adventureInt->verifyPos(whichTileIsIt(sEvent.x,sEvent.y));
  687. if (pom!=curHoveredTile)
  688. curHoveredTile=pom;
  689. else
  690. return;
  691. std::vector<std::string> temp = LOCPLINT->cb->getObjDescriptions(pom);
  692. if (temp.size())
  693. {
  694. LOCPLINT->adventureInt->statusbar.print((*((temp.end())-1)));
  695. }
  696. else
  697. {
  698. LOCPLINT->adventureInt->statusbar.clear();
  699. }
  700. }
  701. void CTerrainRect::keyPressed (SDL_KeyboardEvent & key){}
  702. void CTerrainRect::hover(bool on)
  703. {
  704. if (!on)
  705. LOCPLINT->adventureInt->statusbar.clear();
  706. }
  707. void CTerrainRect::show()
  708. {
  709. SDL_Surface * teren = CGI->mh->terrainRect
  710. (LOCPLINT->adventureInt->position.x,LOCPLINT->adventureInt->position.y,
  711. tilesw,tilesh,LOCPLINT->adventureInt->position.z,LOCPLINT->adventureInt->anim);
  712. SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),ekran,&genRect(547,594,7,6));
  713. SDL_FreeSurface(teren);
  714. if (currentPath && LOCPLINT->adventureInt->position.z==currentPath->startPos().z) //drawing path
  715. {
  716. for (int i=0;i<currentPath->nodes.size()-1;i++)
  717. {
  718. int pn=-1;//number of picture
  719. if (i==0) //last tile
  720. {
  721. int x = 32*(currentPath->nodes[i].coord.x-LOCPLINT->adventureInt->position.x)+7,
  722. y = 32*(currentPath->nodes[i].coord.y-LOCPLINT->adventureInt->position.y)+6;
  723. if (x<0 || y<0 || x>pos.w || y>pos.h)
  724. continue;
  725. pn=0;
  726. }
  727. else
  728. {
  729. std::vector<CPathNode> & cv = currentPath->nodes;
  730. if (cv[i+1].coord.x == cv[i].coord.x-1 && cv[i+1].coord.y == cv[i].coord.y-1)
  731. {
  732. if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y)
  733. {
  734. pn = 3;
  735. }
  736. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
  737. {
  738. pn = 12;
  739. }
  740. else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y+1)
  741. {
  742. pn = 21;
  743. }
  744. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
  745. {
  746. pn = 22;
  747. }
  748. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
  749. {
  750. pn = 2;
  751. }
  752. }
  753. else if (cv[i+1].coord.x == cv[i].coord.x && cv[i+1].coord.y == cv[i].coord.y-1)
  754. {
  755. if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
  756. {
  757. pn = 4;
  758. }
  759. else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y+1)
  760. {
  761. pn = 13;
  762. }
  763. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
  764. {
  765. pn = 22;
  766. }
  767. }
  768. else if (cv[i+1].coord.x == cv[i].coord.x+1 && cv[i+1].coord.y == cv[i].coord.y-1)
  769. {
  770. if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y+1)
  771. {
  772. pn = 5;
  773. }
  774. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
  775. {
  776. pn = 14;
  777. }
  778. else if(cv[i-1].coord.x+1 == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y)
  779. {
  780. pn = 23;
  781. }
  782. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
  783. {
  784. pn = 24;
  785. }
  786. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
  787. {
  788. pn = 4;
  789. }
  790. }
  791. else if (cv[i+1].coord.x == cv[i].coord.x+1 && cv[i+1].coord.y == cv[i].coord.y)
  792. {
  793. if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
  794. {
  795. pn = 6;
  796. }
  797. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y)
  798. {
  799. pn = 15;
  800. }
  801. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
  802. {
  803. pn = 24;
  804. }
  805. }
  806. else if (cv[i+1].coord.x == cv[i].coord.x+1 && cv[i+1].coord.y == cv[i].coord.y+1)
  807. {
  808. if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y)
  809. {
  810. pn = 7;
  811. }
  812. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
  813. {
  814. pn = 16;
  815. }
  816. else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1)
  817. {
  818. pn = 17;
  819. }
  820. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
  821. {
  822. pn = 6;
  823. }
  824. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
  825. {
  826. pn = 18;
  827. }
  828. }
  829. else if (cv[i+1].coord.x == cv[i].coord.x && cv[i+1].coord.y == cv[i].coord.y+1)
  830. {
  831. if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
  832. {
  833. pn = 8;
  834. }
  835. else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1)
  836. {
  837. pn = 9;
  838. }
  839. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
  840. {
  841. pn = 18;
  842. }
  843. }
  844. else if (cv[i+1].coord.x == cv[i].coord.x-1 && cv[i+1].coord.y == cv[i].coord.y+1)
  845. {
  846. if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1)
  847. {
  848. pn = 1;
  849. }
  850. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
  851. {
  852. pn = 10;
  853. }
  854. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y)
  855. {
  856. pn = 19;
  857. }
  858. else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
  859. {
  860. pn = 8;
  861. }
  862. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
  863. {
  864. pn = 20;
  865. }
  866. }
  867. else if (cv[i+1].coord.x == cv[i].coord.x-1 && cv[i+1].coord.y == cv[i].coord.y)
  868. {
  869. if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
  870. {
  871. pn = 2;
  872. }
  873. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y)
  874. {
  875. pn = 11;
  876. }
  877. else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
  878. {
  879. pn = 20;
  880. }
  881. }
  882. }
  883. if (pn>=0)
  884. {
  885. int x = 32*(currentPath->nodes[i].coord.x-LOCPLINT->adventureInt->position.x)+7,
  886. y = 32*(currentPath->nodes[i].coord.y-LOCPLINT->adventureInt->position.y)+6;
  887. if (x<0 || y<0 || x>pos.w || y>pos.h)
  888. continue;
  889. int hvx = (x+arrows->ourImages[pn].bitmap->w)-(pos.x+pos.w),
  890. hvy = (y+arrows->ourImages[pn].bitmap->h)-(pos.y+pos.h);
  891. if (hvx<0 && hvy<0)
  892. blitAtWR(arrows->ourImages[pn].bitmap,x,y);
  893. else if(hvx<0)
  894. SDL_BlitSurface
  895. (arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w,0,0),
  896. ekran,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w,x,y));
  897. else if (hvy<0)
  898. {
  899. SDL_BlitSurface
  900. (arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h,arrows->ourImages[pn].bitmap->w-hvx,0,0),
  901. ekran,&genRect(arrows->ourImages[pn].bitmap->h,arrows->ourImages[pn].bitmap->w-hvx,x,y));
  902. }
  903. else
  904. SDL_BlitSurface
  905. (arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w-hvx,0,0),
  906. ekran,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w-hvx,x,y));
  907. }
  908. } //for (int i=0;i<currentPath->nodes.size()-1;i++)
  909. } // if (currentPath)
  910. }
  911. int3 CTerrainRect::whichTileIsIt(int x, int y)
  912. {
  913. int3 ret;
  914. ret.x = LOCPLINT->adventureInt->position.x + ((LOCPLINT->current->motion.x-pos.x)/32);
  915. ret.y = LOCPLINT->adventureInt->position.y + ((LOCPLINT->current->motion.y-pos.y)/32);
  916. ret.z = LOCPLINT->adventureInt->position.z;
  917. return ret;
  918. }
  919. int3 CTerrainRect::whichTileIsIt()
  920. {
  921. return whichTileIsIt(LOCPLINT->current->motion.x,LOCPLINT->current->motion.y);
  922. }
  923. void CResDataBar::clickRight (tribool down)
  924. {
  925. }
  926. void CResDataBar::activate()
  927. {
  928. ClickableR::activate();
  929. }
  930. void CResDataBar::deactivate()
  931. {
  932. ClickableR::deactivate();
  933. }
  934. CResDataBar::CResDataBar()
  935. {
  936. bg = CGI->bitmaph->loadBitmap("ZRESBAR.bmp");
  937. SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
  938. blueToPlayersAdv(bg,LOCPLINT->playerID);
  939. //blueToPlayersNice(bg,LOCPLINT->playerID);
  940. pos = genRect(bg->h,bg->w,3,575);
  941. txtpos += (std::pair<int,int>(35,577)),(std::pair<int,int>(120,577)),(std::pair<int,int>(205,577)),
  942. (std::pair<int,int>(290,577)),(std::pair<int,int>(375,577)),(std::pair<int,int>(460,577)),
  943. (std::pair<int,int>(545,577)),(std::pair<int,int>(620,577));
  944. datetext = CGI->generaltexth->allTexts[62]+": %s, " + CGI->generaltexth->allTexts[63] + ": %s, " +
  945. CGI->generaltexth->allTexts[64] + ": %s";
  946. }
  947. CResDataBar::~CResDataBar()
  948. {
  949. SDL_FreeSurface(bg);
  950. }
  951. void CResDataBar::draw()
  952. {
  953. blitAt(bg,pos.x,pos.y);
  954. char * buf = new char[15];
  955. for (int i=0;i<7;i++)
  956. {
  957. itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
  958. printAt(buf,txtpos[i].first,txtpos[i].second,GEOR13,zwykly);
  959. }
  960. std::vector<std::string> temp;
  961. itoa(LOCPLINT->cb->getDate(3),buf,10); temp+=std::string(buf);
  962. itoa(LOCPLINT->cb->getDate(2),buf,10); temp+=std::string(buf);
  963. itoa(LOCPLINT->cb->getDate(1),buf,10); temp+=std::string(buf);
  964. printAt(processStr(datetext,temp),txtpos[7].first,txtpos[7].second,GEOR13,zwykly);
  965. temp.clear();
  966. updateRect(&pos,ekran);
  967. delete buf;
  968. }
  969. CInfoBar::CInfoBar()
  970. {
  971. pos.x=604;
  972. pos.y=389;
  973. pos.w=194;
  974. pos.h=186;
  975. }
  976. void CInfoBar::draw(void * specific)
  977. {
  978. SDL_Surface * todr = LOCPLINT->infoWin(specific);
  979. blitAt(todr,pos.x,pos.y);
  980. SDL_FreeSurface(todr);
  981. }
  982. CAdvMapInt::CAdvMapInt(int Player)
  983. :player(Player),
  984. statusbar(7,556),
  985. kingOverview(CGI->preth->advKingdomOverview.first,CGI->preth->advKingdomOverview.second,
  986. &CAdvMapInt::fshowOverview, 679, 196, "IAM002.DEF"),
  987. underground(CGI->preth->advSurfaceSwitch.first,CGI->preth->advSurfaceSwitch.second,
  988. &CAdvMapInt::fswitchLevel, 711, 196, "IAM010.DEF", false, new std::vector<std::string>(1,std::string("IAM003.DEF"))),
  989. questlog(CGI->preth->advQuestlog.first,CGI->preth->advQuestlog.second,
  990. &CAdvMapInt::fshowQuestlog, 679, 228, "IAM004.DEF"),
  991. sleepWake(CGI->preth->advSleepWake.first,CGI->preth->advSleepWake.second,
  992. &CAdvMapInt::fsleepWake, 711, 228, "IAM005.DEF"),
  993. moveHero(CGI->preth->advMoveHero.first,CGI->preth->advMoveHero.second,
  994. &CAdvMapInt::fmoveHero, 679, 260, "IAM006.DEF"),
  995. spellbook(CGI->preth->advCastSpell.first,CGI->preth->advCastSpell.second,
  996. &CAdvMapInt::fshowSpellbok, 711, 260, "IAM007.DEF"),
  997. advOptions(CGI->preth->advAdvOptions.first,CGI->preth->advAdvOptions.second,
  998. &CAdvMapInt::fadventureOPtions, 679, 292, "IAM008.DEF"),
  999. sysOptions(CGI->preth->advSystemOptions.first,CGI->preth->advSystemOptions.second,
  1000. &CAdvMapInt::fsystemOptions, 711, 292, "IAM009.DEF"),
  1001. nextHero(CGI->preth->advNextHero.first,CGI->preth->advNextHero.second,
  1002. &CAdvMapInt::fnextHero, 679, 324, "IAM000.DEF"),
  1003. endTurn(CGI->preth->advEndTurn.first,CGI->preth->advEndTurn.second,
  1004. &CAdvMapInt::fendTurn, 679, 356, "IAM001.DEF")
  1005. {
  1006. LOCPLINT->adventureInt=this;
  1007. bg = CGI->bitmaph->loadBitmap("ADVMAP.bmp");
  1008. blueToPlayersAdv(bg,player);
  1009. scrollingLeft = false;
  1010. scrollingRight = false;
  1011. scrollingUp = false ;
  1012. scrollingDown = false ;
  1013. updateScreen = false;
  1014. anim=0;
  1015. animValHitCount=0; //animation frame
  1016. heroList.init();
  1017. heroList.genList();
  1018. //townList.init();
  1019. townList.genList();
  1020. gems.push_back(CGI->spriteh->giveDef("agemLL.def"));
  1021. gems.push_back(CGI->spriteh->giveDef("agemLR.def"));
  1022. gems.push_back(CGI->spriteh->giveDef("agemUL.def"));
  1023. gems.push_back(CGI->spriteh->giveDef("agemUR.def"));
  1024. }
  1025. void CAdvMapInt::fshowOverview()
  1026. {
  1027. }
  1028. void CAdvMapInt::fswitchLevel()
  1029. {
  1030. if(!CGI->ac->map.twoLevel)
  1031. return;
  1032. if (position.z)
  1033. {
  1034. position.z--;
  1035. underground.curimg=0;
  1036. underground.show();
  1037. }
  1038. else
  1039. {
  1040. underground.curimg=1;
  1041. position.z++;
  1042. underground.show();
  1043. }
  1044. updateScreen = true;
  1045. minimap.draw();
  1046. }
  1047. void CAdvMapInt::fshowQuestlog()
  1048. {
  1049. }
  1050. void CAdvMapInt::fsleepWake()
  1051. {
  1052. }
  1053. void CAdvMapInt::fmoveHero()
  1054. {
  1055. }
  1056. void CAdvMapInt::fshowSpellbok()
  1057. {
  1058. }
  1059. void CAdvMapInt::fadventureOPtions()
  1060. {
  1061. }
  1062. void CAdvMapInt::fsystemOptions()
  1063. {
  1064. }
  1065. void CAdvMapInt::fnextHero()
  1066. {
  1067. }
  1068. void CAdvMapInt::fendTurn()
  1069. {
  1070. }
  1071. void CAdvMapInt::show()
  1072. {
  1073. blitAt(bg,0,0);
  1074. kingOverview.show();
  1075. kingOverview.activate();
  1076. underground.show();
  1077. underground.activate();
  1078. questlog.show();
  1079. questlog.activate();
  1080. sleepWake.show();
  1081. sleepWake.activate();
  1082. moveHero.show();
  1083. moveHero.activate();
  1084. spellbook.show();
  1085. spellbook.activate();
  1086. advOptions.show();
  1087. advOptions.activate();
  1088. sysOptions.show();
  1089. sysOptions.activate();
  1090. nextHero.show();
  1091. nextHero.activate();
  1092. endTurn.show();
  1093. endTurn.activate();
  1094. minimap.activate();
  1095. minimap.draw();
  1096. heroList.activate();
  1097. heroList.draw();
  1098. townList.activate();
  1099. townList.draw();
  1100. terrain.activate();
  1101. resdatabar.draw();
  1102. statusbar.show();
  1103. SDL_Flip(ekran);
  1104. }
  1105. void CAdvMapInt::update()
  1106. {
  1107. terrain.show();
  1108. blitAt(gems[2]->ourImages[LOCPLINT->playerID].bitmap,6,6);
  1109. blitAt(gems[0]->ourImages[LOCPLINT->playerID].bitmap,6,508);
  1110. blitAt(gems[1]->ourImages[LOCPLINT->playerID].bitmap,556,508);
  1111. blitAt(gems[3]->ourImages[LOCPLINT->playerID].bitmap,556,6);
  1112. updateRect(&genRect(550,600,6,6));
  1113. }
  1114. void CAdvMapInt::centerOn(int3 on)
  1115. {
  1116. on.x -= (LOCPLINT->adventureInt->terrain.tilesw/2);
  1117. on.y -= (LOCPLINT->adventureInt->terrain.tilesh/2);
  1118. if (on.x<0)
  1119. on.x=-(Woff/2);
  1120. else if((on.x+LOCPLINT->adventureInt->terrain.tilesw) > (CGI->mh->sizes.x))
  1121. on.x=CGI->mh->sizes.x-LOCPLINT->adventureInt->terrain.tilesw+(Woff/2);
  1122. if (on.y<0)
  1123. on.y = -(Hoff/2);
  1124. else if((on.y+LOCPLINT->adventureInt->terrain.tilesh) > (CGI->mh->sizes.y))
  1125. on.y = CGI->mh->sizes.y-LOCPLINT->adventureInt->terrain.tilesh+(Hoff/2);
  1126. LOCPLINT->adventureInt->position.x=on.x;
  1127. LOCPLINT->adventureInt->position.y=on.y;
  1128. LOCPLINT->adventureInt->position.z=on.z;
  1129. LOCPLINT->adventureInt->updateScreen=true;
  1130. }
  1131. CAdvMapInt::CurrentSelection::CurrentSelection()
  1132. {
  1133. type=-1;
  1134. selected=NULL;
  1135. }
  1136. void CAdvMapInt::handleRightClick(std::string text, tribool down, CIntObject * client)
  1137. {
  1138. if (down)
  1139. {
  1140. boost::algorithm::erase_all(text,"\"");
  1141. CSimpleWindow * temp = CMessage::genWindow(text,LOCPLINT->playerID);
  1142. temp->pos.x=300-(temp->pos.w/2);
  1143. temp->pos.y=300-(temp->pos.h/2);
  1144. temp->owner = client;
  1145. LOCPLINT->objsToBlit.push_back(temp);
  1146. }
  1147. else
  1148. {
  1149. for (int i=0;i<LOCPLINT->objsToBlit.size();i++)
  1150. {
  1151. if (LOCPLINT->objsToBlit[i]->owner==client)
  1152. {
  1153. LOCPLINT->objsToBlit.erase(LOCPLINT->objsToBlit.begin()+(i));
  1154. }
  1155. }
  1156. }
  1157. }
  1158. int3 CAdvMapInt::verifyPos(int3 ver)
  1159. {
  1160. if (ver.x<0)
  1161. ver.x=0;
  1162. if (ver.y<0)
  1163. ver.y=0;
  1164. if (ver.z<0)
  1165. ver.z=0;
  1166. if (ver.x>=CGI->mh->sizes.x)
  1167. ver.x=CGI->mh->sizes.x-1;
  1168. if (ver.y>=CGI->mh->sizes.y)
  1169. ver.y=CGI->mh->sizes.y-1;
  1170. if (ver.z>=CGI->mh->sizes.z)
  1171. ver.z=CGI->mh->sizes.z-1;
  1172. return ver;
  1173. }