CSpellWindow.h 3.3 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. void activate();
  33. void deactivate();
  34. SpellbookInteractiveArea(const SDL_Rect & myRect, boost::function<void()> funcL, const std::string & textR,
  35. boost::function<void()> funcHon, boost::function<void()> funcHoff, CPlayerInterface * _myInt);//c-tor
  36. };
  37. class CSpellWindow : public CIntObject
  38. {
  39. private:
  40. class SpellArea : public CIntObject
  41. {
  42. public:
  43. int mySpell;
  44. CSpellWindow * owner;
  45. SpellArea(SDL_Rect pos, CSpellWindow * owner);
  46. void clickLeft(tribool down, bool previousState);
  47. void clickRight(tribool down, bool previousState);
  48. void hover(bool on);
  49. void activate();
  50. void deactivate();
  51. };
  52. SDL_Surface * background, * leftCorner, * rightCorner;
  53. CDefHandler * spells, //pictures of spells
  54. * spellTab, //school select
  55. * schools, //schools' pictures
  56. * schoolBorders [4]; //schools' 'borders': [0]: air, [1]: fire, [2]: water, [3]: earth
  57. SpellbookInteractiveArea * exitBtn, * battleSpells, * adventureSpells, * manaPoints;
  58. SpellbookInteractiveArea * selectSpellsA, * selectSpellsE, * selectSpellsF, * selectSpellsW, * selectSpellsAll;
  59. SpellbookInteractiveArea * lCorner, * rCorner;
  60. SpellArea * spellAreas[12];
  61. CStatusBar * statusBar;
  62. Uint8 sitesPerTabAdv[5];
  63. Uint8 sitesPerTabBattle[5];
  64. bool battleSpellsOnly; //if true, only battle spells are displayed; if false, only adventure map spells are displayed
  65. Uint8 selectedTab; // 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
  66. Uint8 spellSite; //changes when corners are clicked
  67. std::set<ui32> mySpells; //all spels in this spellbook
  68. 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
  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 fspellsAb();
  82. void fspellsEb();
  83. void fspellsFb();
  84. void fspellsWb();
  85. void fspellsAllb();
  86. void fLcornerb();
  87. void fRcornerb();
  88. void keyPressed(const SDL_KeyboardEvent & key);
  89. void activate();
  90. void deactivate();
  91. void show(SDL_Surface * to);
  92. };
  93. #endif // __CSPELLWINDOW_H__