CSpellWindow.h 2.7 KB

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