CSpellWindow.h 3.2 KB

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