CSpellWindow.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma once
  2. #include "../global.h"
  3. #include "../CPlayerInterface.h"
  4. struct SDL_Surface;
  5. class CDefHandler;
  6. struct SDL_Rect;
  7. class CGHeroInstance;
  8. class SpellbookInteractiveArea : public ClickableL, public ClickableR, public Hoverable
  9. {
  10. private:
  11. boost::function<void()> onLeft;
  12. std::string textOnRclick;
  13. boost::function<void()> onHoverOn;
  14. boost::function<void()> onHoverOff;
  15. public:
  16. void clickLeft(boost::logic::tribool down);
  17. void clickRight(boost::logic::tribool down);
  18. void hover(bool on);
  19. void activate();
  20. void deactivate();
  21. SpellbookInteractiveArea(SDL_Rect & myRect, boost::function<void()> funcL, std::string textR, boost::function<void()> funcHon, boost::function<void()> funcHoff);//c-tor
  22. };
  23. class CSpellWindow : public IShowActivable, public CIntObject
  24. {
  25. private:
  26. class SpellArea : public ClickableL, public ClickableR, public Hoverable
  27. {
  28. public:
  29. int mySpell;
  30. CSpellWindow * owner;
  31. SpellArea(SDL_Rect pos, CSpellWindow * owner);
  32. void clickLeft(boost::logic::tribool down);
  33. void clickRight(boost::logic::tribool down);
  34. void hover(bool on);
  35. void activate();
  36. void deactivate();
  37. };
  38. SDL_Surface * background, * leftCorner, * rightCorner;
  39. CDefHandler * spells, //pictures of spells
  40. * spellTab, //school select
  41. * schools, //schools' pictures
  42. * schoolBorders [4]; //schools' 'borders': [0]: air, [1]: fire, [2]: water, [3]: earth
  43. SpellbookInteractiveArea * exitBtn, * battleSpells, * adventureSpells, * manaPoints;
  44. SpellbookInteractiveArea * selectSpellsA, * selectSpellsE, * selectSpellsF, * selectSpellsW, * selectSpellsAll;
  45. SpellbookInteractiveArea * lCorner, * rCorner;
  46. SpellArea * spellAreas[12];
  47. CStatusBar * statusBar;
  48. Uint8 sitesPerTabAdv[5];
  49. Uint8 sitesPerTabBattle[5];
  50. bool battleSpellsOnly; //if true, only battle spells are displayed; if false, only adventure map spells are displayed
  51. Uint8 selectedTab; // 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
  52. Uint8 spellSite; //changes when corners are clicked
  53. std::set<ui32> mySpells; //all spels in this spellbook
  54. Uint8 schoolLvls[4]; //levels of magic for different schools: [0]: air, [1]: fire, [2]: water, [3]: earth; 0 - none, 1 - beginner, 2 - medium, 3 - expert
  55. void computeSpellsPerArea(); //recalculates spellAreas::mySpell
  56. public:
  57. CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero); //c-tor
  58. ~CSpellWindow(); //d-tor
  59. void fexitb();
  60. void fadvSpellsb();
  61. void fbattleSpellsb();
  62. void fmanaPtsb();
  63. void fspellsAb();
  64. void fspellsEb();
  65. void fspellsFb();
  66. void fspellsWb();
  67. void fspellsAllb();
  68. void fLcornerb();
  69. void fRcornerb();
  70. void activate();
  71. void deactivate();
  72. void show(SDL_Surface * to = NULL);
  73. };