CAdvmapInterface.cpp 31 KB

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