CSpellWindow.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. #include "CSpellWindow.h"
  2. #include "Graphics.h"
  3. #include "../hch/CDefHandler.h"
  4. #include "../hch/CObjectHandler.h"
  5. #include "../hch/CSpellHandler.h"
  6. #include "../hch/CPreGameTextHandler.h"
  7. #include "../hch/CGeneralTextHandler.h"
  8. #include "../CAdvmapInterface.h"
  9. #include "../CGameInfo.h"
  10. #include "../SDL_Extensions.h"
  11. #include "../CMessage.h"
  12. #include <boost/bind.hpp>
  13. #include <sstream>
  14. extern SDL_Surface * screen;
  15. extern SDL_Color tytulowy, zwykly ;
  16. extern TTF_Font *GEOR16;
  17. SpellbookInteractiveArea::SpellbookInteractiveArea(SDL_Rect & myRect, boost::function<void()> funcL, std::string textR, boost::function<void()> funcHon, boost::function<void()> funcHoff)
  18. {
  19. pos = myRect;
  20. onLeft = funcL;
  21. textOnRclick = textR;
  22. onHoverOn = funcHon;
  23. onHoverOff = funcHoff;
  24. }
  25. void SpellbookInteractiveArea::clickLeft(boost::logic::tribool down)
  26. {
  27. if(!down)
  28. {
  29. onLeft();
  30. }
  31. }
  32. void SpellbookInteractiveArea::clickRight(boost::logic::tribool down)
  33. {
  34. LOCPLINT->adventureInt->handleRightClick(textOnRclick, down, this);
  35. }
  36. void SpellbookInteractiveArea::hover(bool on)
  37. {
  38. Hoverable::hover(on);
  39. if(on)
  40. {
  41. onHoverOn();
  42. }
  43. else
  44. {
  45. onHoverOff();
  46. }
  47. }
  48. void SpellbookInteractiveArea::activate()
  49. {
  50. ClickableL::activate();
  51. ClickableR::activate();
  52. Hoverable::activate();
  53. }
  54. void SpellbookInteractiveArea::deactivate()
  55. {
  56. ClickableL::deactivate();
  57. ClickableR::deactivate();
  58. Hoverable::deactivate();
  59. }
  60. CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero): selectedTab(4), spellSite(0), battleSpellsOnly(true)
  61. {
  62. //for testing only
  63. //mySpells = myHero->spells;
  64. for(ui32 v=0; v<CGI->spellh->spells.size(); ++v)
  65. {
  66. if(!CGI->spellh->spells[v].creatureAbility)
  67. mySpells.insert(v);
  68. }
  69. for(int b=0; b<4; ++b) schoolLvls[b] = 0;
  70. for(int b=0; b<myHero->secSkills.size(); ++b)
  71. {
  72. switch(myHero->secSkills[b].first)
  73. {
  74. case 14: //fire magic
  75. schoolLvls[1] = myHero->secSkills[b].second;
  76. break;
  77. case 15: //air magic
  78. schoolLvls[0] = myHero->secSkills[b].second;
  79. break;
  80. case 16: //water magic
  81. schoolLvls[2] = myHero->secSkills[b].second;
  82. break;
  83. case 17: //earth magic
  84. schoolLvls[3] = myHero->secSkills[b].second;
  85. break;
  86. }
  87. }
  88. //initializing sizes of spellbook's parts
  89. for(int b=0; b<5; ++b)
  90. sitesPerTabAdv[b] = 0;
  91. for(int b=0; b<5; ++b)
  92. sitesPerTabBattle[b] = 0;
  93. for(std::set<ui32>::const_iterator g = mySpells.begin(); g!=mySpells.end(); ++g)
  94. {
  95. if(CGI->spellh->spells[*g].combatSpell)
  96. {
  97. ++(sitesPerTabBattle[4]);
  98. }
  99. else
  100. {
  101. ++(sitesPerTabAdv[4]);
  102. }
  103. if(CGI->spellh->spells[*g].air)
  104. {
  105. if(CGI->spellh->spells[*g].combatSpell)
  106. {
  107. ++(sitesPerTabBattle[0]);
  108. }
  109. else
  110. {
  111. ++(sitesPerTabAdv[0]);
  112. }
  113. }
  114. if(CGI->spellh->spells[*g].fire)
  115. {
  116. if(CGI->spellh->spells[*g].combatSpell)
  117. {
  118. ++(sitesPerTabBattle[1]);
  119. }
  120. else
  121. {
  122. ++(sitesPerTabAdv[1]);
  123. }
  124. }
  125. if(CGI->spellh->spells[*g].water)
  126. {
  127. if(CGI->spellh->spells[*g].combatSpell)
  128. {
  129. ++(sitesPerTabBattle[2]);
  130. }
  131. else
  132. {
  133. ++(sitesPerTabAdv[2]);
  134. }
  135. }
  136. if(CGI->spellh->spells[*g].earth)
  137. {
  138. if(CGI->spellh->spells[*g].combatSpell)
  139. {
  140. ++(sitesPerTabBattle[3]);
  141. }
  142. else
  143. {
  144. ++(sitesPerTabAdv[3]);
  145. }
  146. }
  147. }
  148. if(sitesPerTabAdv[4] % 12 == 0)
  149. sitesPerTabAdv[4]/=12;
  150. else
  151. sitesPerTabAdv[4] = sitesPerTabAdv[4]/12 + 1;
  152. for(int v=0; v<4; ++v)
  153. {
  154. if(sitesPerTabAdv[v] <= 10)
  155. sitesPerTabAdv[v] = 1;
  156. else
  157. {
  158. if((sitesPerTabAdv[v] - 10) % 12 == 0)
  159. sitesPerTabAdv[v] = (sitesPerTabAdv[v] - 10) / 12 + 1;
  160. else
  161. sitesPerTabAdv[v] = (sitesPerTabAdv[v] - 10) / 12 + 2;
  162. }
  163. }
  164. if(sitesPerTabBattle[4] % 12 == 0)
  165. sitesPerTabBattle[4]/=12;
  166. else
  167. sitesPerTabBattle[4] = sitesPerTabBattle[4]/12 + 1;
  168. for(int v=0; v<4; ++v)
  169. {
  170. if(sitesPerTabBattle[v] <= 10)
  171. sitesPerTabBattle[v] = 1;
  172. else
  173. {
  174. if((sitesPerTabBattle[v] - 10) % 12 == 0)
  175. sitesPerTabBattle[v] = (sitesPerTabBattle[v] - 10) / 12 + 1;
  176. else
  177. sitesPerTabBattle[v] = (sitesPerTabBattle[v] - 10) / 12 + 2;
  178. }
  179. }
  180. //numbers of spell pages computed
  181. pos = myRect;
  182. background = BitmapHandler::loadBitmap("SpelBack.bmp");
  183. graphics->blueToPlayersAdv(background, myHero->tempOwner);
  184. std::stringstream mana;
  185. mana<<myHero->mana;
  186. CSDL_Ext::printAtMiddle(mana.str(), 434, 425, GEOR16, tytulowy, background);
  187. leftCorner = BitmapHandler::loadBitmap("SpelTrnL.bmp", true);
  188. rightCorner = BitmapHandler::loadBitmap("SpelTrnR.bmp", true);
  189. spells = CDefHandler::giveDef("Spells.def");
  190. spellTab = CDefHandler::giveDef("SpelTab.def");
  191. schools = CDefHandler::giveDef("Schools.def");
  192. schoolBorders[0] = CDefHandler::giveDef("SplevA.def");
  193. schoolBorders[1] = CDefHandler::giveDef("SplevF.def");
  194. schoolBorders[2] = CDefHandler::giveDef("SplevW.def");
  195. schoolBorders[3] = CDefHandler::giveDef("SplevE.def");
  196. statusBar = new CStatusBar(97, 571, "Spelroll.bmp");
  197. SDL_Rect temp_rect = genRect(45, 35, 569, 407);
  198. exitBtn = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fexitb, this), CGI->preth->zelp[460].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[460].first)), boost::bind(&CStatusBar::clear, statusBar));
  199. temp_rect = genRect(45, 35, 311, 407);
  200. battleSpells = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fbattleSpellsb, this), CGI->preth->zelp[453].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[453].first)), boost::bind(&CStatusBar::clear, statusBar));
  201. temp_rect = genRect(45, 35, 445, 407);
  202. adventureSpells = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fadvSpellsb, this), CGI->preth->zelp[452].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[452].first)), boost::bind(&CStatusBar::clear, statusBar));
  203. temp_rect = genRect(45, 35, 508, 407);
  204. manaPoints = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fmanaPtsb, this), CGI->preth->zelp[459].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[459].first)), boost::bind(&CStatusBar::clear, statusBar));
  205. temp_rect = genRect(36, 56, 639, 96);
  206. selectSpellsA = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsAb, this), CGI->preth->zelp[454].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[454].first)), boost::bind(&CStatusBar::clear, statusBar));
  207. temp_rect = genRect(36, 56, 639, 153);
  208. selectSpellsE = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsEb, this), CGI->preth->zelp[457].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[457].first)), boost::bind(&CStatusBar::clear, statusBar));
  209. temp_rect = genRect(36, 56, 639, 212);
  210. selectSpellsF = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsFb, this), CGI->preth->zelp[455].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[455].first)), boost::bind(&CStatusBar::clear, statusBar));
  211. temp_rect = genRect(36, 56, 639, 272);
  212. selectSpellsW = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsWb, this), CGI->preth->zelp[456].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[456].first)), boost::bind(&CStatusBar::clear, statusBar));
  213. temp_rect = genRect(36, 56, 639, 332);
  214. selectSpellsAll = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsAllb, this), CGI->preth->zelp[458].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[458].first)), boost::bind(&CStatusBar::clear, statusBar));
  215. temp_rect = genRect(leftCorner->h, leftCorner->w, 187, 79);
  216. lCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fLcornerb, this), CGI->preth->zelp[450].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[450].first)), boost::bind(&CStatusBar::clear, statusBar));
  217. temp_rect = genRect(rightCorner->h, rightCorner->w, 577, 76);
  218. rCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fRcornerb, this), CGI->preth->zelp[451].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[451].first)), boost::bind(&CStatusBar::clear, statusBar));
  219. //areas for spells
  220. int xpos = 207, ypos = 92;
  221. for(int v=0; v<12; ++v)
  222. {
  223. temp_rect = genRect(65, 78, xpos, ypos);
  224. spellAreas[v] = new SpellArea(temp_rect, this);
  225. if(v == 5) //to right page
  226. {
  227. xpos = 426; ypos = 92;
  228. }
  229. else
  230. {
  231. if(v%2 == 0)
  232. {
  233. xpos+=85;
  234. }
  235. else
  236. {
  237. xpos -= 85; ypos+=97;
  238. }
  239. }
  240. }
  241. computeSpellsPerArea();
  242. }
  243. CSpellWindow::~CSpellWindow()
  244. {
  245. SDL_FreeSurface(background);
  246. SDL_FreeSurface(leftCorner);
  247. SDL_FreeSurface(rightCorner);
  248. delete spells;
  249. delete spellTab;
  250. delete schools;
  251. for(int b=0; b<4; ++b)
  252. delete schoolBorders[b];
  253. delete exitBtn;
  254. delete battleSpells;
  255. delete adventureSpells;
  256. delete manaPoints;
  257. delete statusBar;
  258. delete selectSpellsA;
  259. delete selectSpellsE;
  260. delete selectSpellsF;
  261. delete selectSpellsW;
  262. delete selectSpellsAll;
  263. delete lCorner;
  264. delete rCorner;
  265. for(int g=0; g<12; ++g)
  266. {
  267. delete spellAreas[g];
  268. }
  269. }
  270. void CSpellWindow::fexitb()
  271. {
  272. deactivate();
  273. for(int g=0; g<LOCPLINT->objsToBlit.size(); ++g)
  274. {
  275. if(dynamic_cast<CSpellWindow*>(LOCPLINT->objsToBlit[g]))
  276. {
  277. LOCPLINT->objsToBlit.erase(LOCPLINT->objsToBlit.begin()+g);
  278. break;
  279. }
  280. }
  281. delete this;
  282. LOCPLINT->curint->activate();
  283. }
  284. void CSpellWindow::fadvSpellsb()
  285. {
  286. battleSpellsOnly = false;
  287. spellSite = 0;
  288. computeSpellsPerArea();
  289. }
  290. void CSpellWindow::fbattleSpellsb()
  291. {
  292. battleSpellsOnly = true;
  293. spellSite = 0;
  294. computeSpellsPerArea();
  295. }
  296. void CSpellWindow::fmanaPtsb()
  297. {
  298. }
  299. void CSpellWindow::fspellsAb()
  300. {
  301. selectedTab = 0;
  302. spellSite = 0;
  303. computeSpellsPerArea();
  304. }
  305. void CSpellWindow::fspellsEb()
  306. {
  307. selectedTab = 3;
  308. spellSite = 0;
  309. computeSpellsPerArea();
  310. }
  311. void CSpellWindow::fspellsFb()
  312. {
  313. selectedTab = 1;
  314. spellSite = 0;
  315. computeSpellsPerArea();
  316. }
  317. void CSpellWindow::fspellsWb()
  318. {
  319. selectedTab = 2;
  320. spellSite = 0;
  321. computeSpellsPerArea();
  322. }
  323. void CSpellWindow::fspellsAllb()
  324. {
  325. selectedTab = 4;
  326. spellSite = 0;
  327. computeSpellsPerArea();
  328. }
  329. void CSpellWindow::fLcornerb()
  330. {
  331. if(spellSite>0)
  332. --spellSite;
  333. computeSpellsPerArea();
  334. }
  335. void CSpellWindow::fRcornerb()
  336. {
  337. if((spellSite + 1) < (battleSpellsOnly ? sitesPerTabBattle[selectedTab] : sitesPerTabAdv[selectedTab]))
  338. ++spellSite;
  339. computeSpellsPerArea();
  340. }
  341. void CSpellWindow::show(SDL_Surface *to)
  342. {
  343. if(to == NULL) //evaluating to
  344. to = screen;
  345. SDL_BlitSurface(background, NULL, to, &pos);
  346. blitAt(spellTab->ourImages[selectedTab].bitmap, 614, 96, to);
  347. statusBar->show();
  348. //printing school images
  349. if(selectedTab!=4 && spellSite == 0)
  350. {
  351. blitAt(schools->ourImages[selectedTab].bitmap, 207, 76, to);
  352. }
  353. //printing corners
  354. if(spellSite!=0)
  355. {
  356. blitAt(leftCorner, lCorner->pos.x, lCorner->pos.y, to);
  357. }
  358. if((spellSite+1) != (battleSpellsOnly ? sitesPerTabBattle[selectedTab] : sitesPerTabAdv[selectedTab]) )
  359. {
  360. blitAt(rightCorner, rCorner->pos.x, rCorner->pos.y, to);
  361. }
  362. //printing spell info
  363. for(int b=0; b<12; ++b)
  364. {
  365. if(spellAreas[b]->mySpell == -1)
  366. continue;
  367. int b2 = -1;
  368. blitAt(spells->ourImages[spellAreas[b]->mySpell].bitmap, spellAreas[b]->pos.x, spellAreas[b]->pos.y, to);
  369. Uint8 bestSchool = -1, bestslvl = 0;
  370. if(CGI->spellh->spells[spellAreas[b]->mySpell].air)
  371. if(schoolLvls[0] >= bestslvl)
  372. {
  373. bestSchool = 0;
  374. bestslvl = schoolLvls[0];
  375. }
  376. if(CGI->spellh->spells[spellAreas[b]->mySpell].fire)
  377. if(schoolLvls[1] >= bestslvl)
  378. {
  379. bestSchool = 1;
  380. bestslvl = schoolLvls[1];
  381. }
  382. if(CGI->spellh->spells[spellAreas[b]->mySpell].water)
  383. if(schoolLvls[2] >= bestslvl)
  384. {
  385. bestSchool = 2;
  386. bestslvl = schoolLvls[2];
  387. }
  388. if(CGI->spellh->spells[spellAreas[b]->mySpell].earth)
  389. if(schoolLvls[3] >= bestslvl)
  390. {
  391. bestSchool = 3;
  392. bestslvl = schoolLvls[3];
  393. }
  394. //printing border (indicates level of magic school)
  395. blitAt(schoolBorders[bestSchool]->ourImages[bestslvl].bitmap, spellAreas[b]->pos.x, spellAreas[b]->pos.y, to);
  396. //printing spell's name
  397. CSDL_Ext::printAtMiddle(CGI->spellh->spells[spellAreas[b]->mySpell].name, spellAreas[b]->pos.x + 39, spellAreas[b]->pos.y + 70, GEORM, tytulowy, to);
  398. //printing lvl
  399. CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[171 + CGI->spellh->spells[spellAreas[b]->mySpell].level], spellAreas[b]->pos.x + 39, spellAreas[b]->pos.y + 82, GEORM, zwykly, to);
  400. //printing cost
  401. std::stringstream ss;
  402. ss<<CGI->generaltexth->allTexts[387]<<": "<<CGI->spellh->spells[spellAreas[b]->mySpell].costs[bestslvl];
  403. CSDL_Ext::printAtMiddle(ss.str(), spellAreas[b]->pos.x + 39, spellAreas[b]->pos.y + 94, GEORM, zwykly, to);
  404. }
  405. }
  406. void CSpellWindow::computeSpellsPerArea()
  407. {
  408. std::vector<ui32> spellsCurSite;
  409. for(std::set<ui32>::const_iterator it = mySpells.begin(); it != mySpells.end(); ++it)
  410. {
  411. if(CGI->spellh->spells[*it].combatSpell ^ !battleSpellsOnly
  412. && ((CGI->spellh->spells[*it].air && selectedTab == 0) ||
  413. (CGI->spellh->spells[*it].fire && selectedTab == 1) ||
  414. (CGI->spellh->spells[*it].water && selectedTab == 2) ||
  415. (CGI->spellh->spells[*it].earth && selectedTab == 3) ||
  416. selectedTab == 4 )
  417. )
  418. {
  419. spellsCurSite.push_back(*it);
  420. }
  421. }
  422. if(selectedTab == 4)
  423. {
  424. if(spellsCurSite.size() > 12)
  425. {
  426. spellsCurSite = std::vector<ui32>(spellsCurSite.begin() + spellSite*12, spellsCurSite.end());
  427. if(spellsCurSite.size() > 12)
  428. {
  429. spellsCurSite.erase(spellsCurSite.begin()+12, spellsCurSite.end());
  430. }
  431. }
  432. }
  433. else //selectedTab == 0, 1, 2 or 3
  434. {
  435. if(spellsCurSite.size() > 10)
  436. {
  437. if(spellSite == 0)
  438. {
  439. spellsCurSite.erase(spellsCurSite.begin()+10, spellsCurSite.end());
  440. }
  441. else
  442. {
  443. spellsCurSite = std::vector<ui32>(spellsCurSite.begin() + (spellSite-1)*12 + 10, spellsCurSite.end());
  444. if(spellsCurSite.size() > 12)
  445. {
  446. spellsCurSite.erase(spellsCurSite.begin()+12, spellsCurSite.end());
  447. }
  448. }
  449. }
  450. }
  451. //applying
  452. if(selectedTab == 4 || spellSite != 0)
  453. {
  454. for(int c=0; c<12; ++c)
  455. {
  456. if(c<spellsCurSite.size())
  457. spellAreas[c]->mySpell = spellsCurSite[c];
  458. else
  459. spellAreas[c]->mySpell = -1;
  460. }
  461. }
  462. else
  463. {
  464. spellAreas[0]->mySpell = -1;
  465. spellAreas[1]->mySpell = -1;
  466. for(int c=0; c<10; ++c)
  467. {
  468. if(c<spellsCurSite.size())
  469. spellAreas[c+2]->mySpell = spellsCurSite[c];
  470. else
  471. spellAreas[c+2]->mySpell = -1;
  472. }
  473. }
  474. }
  475. void CSpellWindow::activate()
  476. {
  477. exitBtn->activate();
  478. battleSpells->activate();
  479. adventureSpells->activate();
  480. manaPoints->activate();
  481. selectSpellsA->activate();
  482. selectSpellsE->activate();
  483. selectSpellsF->activate();
  484. selectSpellsW->activate();
  485. selectSpellsAll->activate();
  486. lCorner->activate();
  487. rCorner->activate();
  488. for(int g=0; g<12; ++g)
  489. {
  490. spellAreas[g]->activate();
  491. }
  492. }
  493. void CSpellWindow::deactivate()
  494. {
  495. exitBtn->deactivate();
  496. battleSpells->deactivate();
  497. adventureSpells->deactivate();
  498. manaPoints->deactivate();
  499. selectSpellsA->deactivate();
  500. selectSpellsE->deactivate();
  501. selectSpellsF->deactivate();
  502. selectSpellsW->deactivate();
  503. selectSpellsAll->deactivate();
  504. lCorner->deactivate();
  505. rCorner->deactivate();
  506. for(int g=0; g<12; ++g)
  507. {
  508. spellAreas[g]->deactivate();
  509. }
  510. }
  511. CSpellWindow::SpellArea::SpellArea(SDL_Rect pos, CSpellWindow * owner)
  512. {
  513. this->pos = pos;
  514. this->owner = owner;
  515. }
  516. void CSpellWindow::SpellArea::clickLeft(boost::logic::tribool down)
  517. {
  518. }
  519. void CSpellWindow::SpellArea::clickRight(boost::logic::tribool down)
  520. {
  521. if(down)
  522. {
  523. CInfoPopup *vinya = new CInfoPopup();
  524. vinya->free = true;
  525. vinya->bitmap = CMessage::drawBoxTextBitmapSub
  526. (LOCPLINT->playerID,
  527. CGI->spellh->spells[mySpell].descriptions[0], this->owner->spells->ourImages[mySpell].bitmap
  528. ,
  529. CGI->spellh->spells[mySpell].name,30,30);
  530. vinya->pos.x = screen->w/2 - vinya->bitmap->w/2;
  531. vinya->pos.y = screen->h/2 - vinya->bitmap->h/2;
  532. vinya->activate();
  533. }
  534. }
  535. void CSpellWindow::SpellArea::hover(bool on)
  536. {
  537. Hoverable::hover(on);
  538. if(on)
  539. {
  540. std::stringstream ss;
  541. ss<<CGI->spellh->spells[mySpell].name<<" ("<<CGI->generaltexth->allTexts[171+CGI->spellh->spells[mySpell].level]<<")";
  542. owner->statusBar->print(ss.str());
  543. }
  544. else
  545. {
  546. owner->statusBar->clear();
  547. }
  548. }
  549. void CSpellWindow::SpellArea::activate()
  550. {
  551. ClickableL::activate();
  552. ClickableR::activate();
  553. Hoverable::activate();
  554. }
  555. void CSpellWindow::SpellArea::deactivate()
  556. {
  557. ClickableL::deactivate();
  558. ClickableR::deactivate();
  559. Hoverable::deactivate();
  560. }