CAdvmapInterface.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. #include "stdafx.h"
  2. #include "CAdvmapInterface.h"
  3. CAdvMapInt::~CAdvMapInt()
  4. {
  5. SDL_FreeSurface(bg);
  6. }
  7. AdventureMapButton::AdventureMapButton ()
  8. {
  9. type=2;
  10. abs=true;
  11. active=false;
  12. ourObj=NULL;
  13. state=0;
  14. }
  15. AdventureMapButton::AdventureMapButton
  16. ( std::string Name, std::string HelpBox, void(CAdvMapInt::*Function)(), int x, int y, std::string defName, bool activ )
  17. {
  18. type=2;
  19. abs=true;
  20. active=false;
  21. ourObj=NULL;
  22. state=0;
  23. int est = LOCPLINT->playerID;
  24. CDefHandler * temp = CGI->spriteh->giveDef(defName); //todo: moze cieknac
  25. for (int i=0;i<temp->ourImages.size();i++)
  26. {
  27. imgs.push_back(temp->ourImages[i].bitmap);
  28. blueToPlayersAdv(imgs[i],LOCPLINT->playerID);
  29. }
  30. function = Function;
  31. pos.x=x;
  32. pos.y=y;
  33. pos.w = imgs[0]->w;
  34. pos.h = imgs[0]->h;
  35. if (activ)
  36. activate();
  37. }
  38. void AdventureMapButton::clickLeft (tribool down)
  39. {
  40. if (down)
  41. {
  42. state=1;
  43. }
  44. else
  45. {
  46. state=0;
  47. }
  48. show();
  49. if (pressedL && (down==false))
  50. (LOCPLINT->adventureInt->*function)();
  51. pressedL=state;
  52. }
  53. void AdventureMapButton::clickRight (tribool down)
  54. {
  55. //TODO: show/hide infobox
  56. }
  57. void AdventureMapButton::hover (bool on)
  58. {
  59. //TODO: print info in statusbar
  60. }
  61. void AdventureMapButton::activate()
  62. {
  63. if (active) return;
  64. active=true;
  65. ClickableL::activate();
  66. Hoverable::activate();
  67. KeyInterested::activate();
  68. }
  69. void AdventureMapButton::keyPressed (SDL_KeyboardEvent & key)
  70. {
  71. //TODO: check if it's shortcut
  72. }
  73. void AdventureMapButton::deactivate()
  74. {
  75. if (!active) return;
  76. active=false;
  77. ClickableL::deactivate();
  78. Hoverable::deactivate();
  79. KeyInterested::deactivate();
  80. }
  81. void CList::activate()
  82. {
  83. ClickableL::activate();
  84. ClickableR::activate();
  85. Hoverable::activate();
  86. KeyInterested::activate();
  87. };
  88. void CList::deactivate()
  89. {
  90. ClickableL::deactivate();
  91. ClickableR::deactivate();
  92. Hoverable::deactivate();
  93. KeyInterested::deactivate();
  94. };
  95. void CList::clickLeft(tribool down)
  96. {
  97. };
  98. void CStatusBar::print(std::string text)
  99. {
  100. }
  101. void CStatusBar::show()
  102. {
  103. }
  104. void CTerrainRect::activate()
  105. {
  106. ClickableL::activate();
  107. ClickableR::activate();
  108. Hoverable::activate();
  109. KeyInterested::activate();
  110. };
  111. void CTerrainRect::deactivate()
  112. {
  113. ClickableL::deactivate();
  114. ClickableR::deactivate();
  115. Hoverable::deactivate();
  116. KeyInterested::deactivate();
  117. };
  118. void CTerrainRect::clickLeft(tribool down){}
  119. void CTerrainRect::clickRight(tribool down){}
  120. void CTerrainRect::hover(bool on){}
  121. void CTerrainRect::keyPressed (SDL_KeyboardEvent & key){}
  122. void CTerrainRect::show()
  123. {
  124. SDL_Surface * teren = CGI->mh->terrainRect
  125. (LOCPLINT->adventureInt->position.x,LOCPLINT->adventureInt->position.y,
  126. 19,18,LOCPLINT->adventureInt->position.z,LOCPLINT->adventureInt->anim);
  127. SDL_BlitSurface(teren,&genRect(547,594,0,0),ekran,&genRect(547,594,7,6));
  128. SDL_FreeSurface(teren);
  129. }
  130. CAdvMapInt::CAdvMapInt(int Player)
  131. :player(Player),
  132. statusbar(8,556),
  133. kingOverview(CGI->preth->advKingdomOverview.first,CGI->preth->advKingdomOverview.second,
  134. &CAdvMapInt::fshowOverview, 679, 196, "IAM002.DEF"),
  135. undeground(CGI->preth->advSurfaceSwitch.first,CGI->preth->advSurfaceSwitch.second,
  136. &CAdvMapInt::fswitchLevel, 711, 196, "IAM003.DEF"),
  137. questlog(CGI->preth->advQuestlog.first,CGI->preth->advQuestlog.second,
  138. &CAdvMapInt::fshowQuestlog, 679, 228, "IAM004.DEF"),
  139. sleepWake(CGI->preth->advSleepWake.first,CGI->preth->advSleepWake.second,
  140. &CAdvMapInt::fsleepWake, 711, 228, "IAM005.DEF"),
  141. moveHero(CGI->preth->advMoveHero.first,CGI->preth->advMoveHero.second,
  142. &CAdvMapInt::fmoveHero, 679, 260, "IAM006.DEF"),
  143. spellbook(CGI->preth->advCastSpell.first,CGI->preth->advCastSpell.second,
  144. &CAdvMapInt::fshowSpellbok, 711, 260, "IAM007.DEF"),
  145. advOptions(CGI->preth->advAdvOptions.first,CGI->preth->advAdvOptions.second,
  146. &CAdvMapInt::fadventureOPtions, 679, 292, "IAM008.DEF"),
  147. sysOptions(CGI->preth->advSystemOptions.first,CGI->preth->advSystemOptions.second,
  148. &CAdvMapInt::fsystemOptions, 711, 292, "IAM009.DEF"),
  149. nextHero(CGI->preth->advNextHero.first,CGI->preth->advNextHero.second,
  150. &CAdvMapInt::fnextHero, 679, 324, "IAM000.DEF"),
  151. endTurn(CGI->preth->advEndTurn.first,CGI->preth->advEndTurn.second,
  152. &CAdvMapInt::fendTurn, 679, 356, "IAM001.DEF")
  153. {
  154. bg = CGI->bitmaph->loadBitmap("ADVMAP.bmp");
  155. blueToPlayersAdv(bg,player);
  156. scrollingLeft = false;
  157. scrollingRight = false;
  158. scrollingUp = false ;
  159. scrollingDown = false ;
  160. updateScreen = false;
  161. anim=0;
  162. animValHitCount=0; //animation frame
  163. gems.push_back(CGI->spriteh->giveDef("agemLL.def"));
  164. gems.push_back(CGI->spriteh->giveDef("agemLR.def"));
  165. gems.push_back(CGI->spriteh->giveDef("agemUL.def"));
  166. gems.push_back(CGI->spriteh->giveDef("agemUR.def"));
  167. }
  168. void CAdvMapInt::fshowOverview()
  169. {
  170. }
  171. void CAdvMapInt::fswitchLevel()
  172. {
  173. if(!CGI->ac->map.twoLevel)
  174. return;
  175. if (position.z)
  176. position.z--;
  177. else position.z++;
  178. updateScreen = true;
  179. }
  180. void CAdvMapInt::fshowQuestlog()
  181. {
  182. }
  183. void CAdvMapInt::fsleepWake()
  184. {
  185. }
  186. void CAdvMapInt::fmoveHero()
  187. {
  188. }
  189. void CAdvMapInt::fshowSpellbok()
  190. {
  191. }
  192. void CAdvMapInt::fadventureOPtions()
  193. {
  194. }
  195. void CAdvMapInt::fsystemOptions()
  196. {
  197. }
  198. void CAdvMapInt::fnextHero()
  199. {
  200. }
  201. void CAdvMapInt::fendTurn()
  202. {
  203. }
  204. void CAdvMapInt::show()
  205. {
  206. blitAt(bg,0,0);
  207. kingOverview.show();
  208. kingOverview.activate();
  209. undeground.show();
  210. undeground.activate();
  211. questlog.show();
  212. questlog.activate();
  213. sleepWake.show();
  214. sleepWake.activate();
  215. moveHero.show();
  216. moveHero.activate();
  217. spellbook.show();
  218. spellbook.activate();
  219. advOptions.show();
  220. advOptions.activate();
  221. sysOptions.show();
  222. sysOptions.activate();
  223. nextHero.show();
  224. nextHero.activate();
  225. endTurn.show();
  226. endTurn.activate();
  227. SDL_Flip(ekran);
  228. }
  229. void CAdvMapInt::update()
  230. {
  231. terrain.show();
  232. blitAt(gems[2]->ourImages[LOCPLINT->playerID].bitmap,6,6);
  233. blitAt(gems[0]->ourImages[LOCPLINT->playerID].bitmap,6,508);
  234. blitAt(gems[1]->ourImages[LOCPLINT->playerID].bitmap,556,508);
  235. blitAt(gems[3]->ourImages[LOCPLINT->playerID].bitmap,556,6);
  236. updateRect(&genRect(550,600,6,6));
  237. }