CSpellWindow.h 3.0 KB

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