CSpellWindow.h 3.4 KB

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