CSpellWindow.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. /// Spellbook button is used by the spell window class
  21. class SpellbookInteractiveArea : public CIntObject
  22. {
  23. private:
  24. boost::function<void()> onLeft;
  25. std::string textOnRclick;
  26. boost::function<void()> onHoverOn;
  27. boost::function<void()> onHoverOff;
  28. CPlayerInterface * myInt;
  29. public:
  30. void clickLeft(tribool down, bool previousState);
  31. void clickRight(tribool down, bool previousState);
  32. void hover(bool on);
  33. SpellbookInteractiveArea(const SDL_Rect & myRect, boost::function<void()> funcL, const std::string & textR,
  34. boost::function<void()> funcHon, boost::function<void()> funcHoff, CPlayerInterface * _myInt);//c-tor
  35. };
  36. /// The spell window
  37. class CSpellWindow : public CIntObject
  38. {
  39. private:
  40. class SpellArea : public CIntObject
  41. {
  42. public:
  43. int mySpell;
  44. int schoolLevel; //range: 0 none, 3 - expert
  45. int whichSchool; //0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
  46. int spellCost;
  47. CSpellWindow * owner;
  48. SpellArea(SDL_Rect pos, CSpellWindow * owner);
  49. void setSpell(int spellID);
  50. void clickLeft(tribool down, bool previousState);
  51. void clickRight(tribool down, bool previousState);
  52. void hover(bool on);
  53. void showAll(SDL_Surface *to);
  54. };
  55. SDL_Surface * background, * leftCorner, * rightCorner;
  56. CDefHandler * spells, //pictures of spells
  57. * spellTab, //school select
  58. * schools, //schools' pictures
  59. * schoolBorders [4]; //schools' 'borders': [0]: air, [1]: fire, [2]: water, [3]: earth
  60. SpellbookInteractiveArea * exitBtn, * battleSpells, * adventureSpells, * manaPoints;
  61. SpellbookInteractiveArea * selectSpellsA, * selectSpellsE, * selectSpellsF, * selectSpellsW, * selectSpellsAll;
  62. SpellbookInteractiveArea * lCorner, * rCorner;
  63. SpellArea * spellAreas[12];
  64. CStatusBar * statusBar;
  65. Uint8 sitesPerTabAdv[5];
  66. Uint8 sitesPerTabBattle[5];
  67. bool battleSpellsOnly; //if true, only battle spells are displayed; if false, only adventure map spells are displayed
  68. Uint8 selectedTab; // 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
  69. Uint8 currentPage; //changes when corners are clicked
  70. std::set<ui32> mySpells; //all spels in this spellbook
  71. const CGHeroInstance * myHero; //hero whose spells are presented
  72. void computeSpellsPerArea(); //recalculates spellAreas::mySpell
  73. void turnPageLeft();
  74. void turnPageRight();
  75. CPlayerInterface * myInt;
  76. public:
  77. CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * _myHero, CPlayerInterface * _myInt, bool openOnBattleSpells = true); //c-tor
  78. ~CSpellWindow(); //d-tor
  79. void fexitb();
  80. void fadvSpellsb();
  81. void fbattleSpellsb();
  82. void fmanaPtsb();
  83. void fLcornerb();
  84. void fRcornerb();
  85. void selectSchool(int school); //schools: 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
  86. Uint8 pagesWithinCurrentTab();
  87. void keyPressed(const SDL_KeyboardEvent & key);
  88. void activate();
  89. void deactivate();
  90. void showAll(SDL_Surface * to);
  91. void teleportTo(int town, const CGHeroInstance * hero);
  92. };
  93. #endif // __CSPELLWINDOW_H__