CSpellWindow.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #pragma once
  2. #include "CWindowObject.h"
  3. /*
  4. * CSpellWindow.h, part of VCMI engine
  5. *
  6. * Authors: listed in file AUTHORS in main folder
  7. *
  8. * License: GNU General Public License v2.0 or later
  9. * Full text of license available in license.txt file, in main folder
  10. *
  11. */
  12. struct SDL_Surface;
  13. class CDefHandler;
  14. struct SDL_Rect;
  15. class CGHeroInstance;
  16. class CGStatusBar;
  17. class CPlayerInterface;
  18. class CSpellWindow;
  19. /// The spell window
  20. class CSpellWindow : public CWindowObject
  21. {
  22. private:
  23. class SpellArea : public CIntObject
  24. {
  25. public:
  26. SpellID mySpell;
  27. int schoolLevel; //range: 0 none, 3 - expert
  28. int whichSchool; //0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
  29. int spellCost;
  30. CSpellWindow * owner;
  31. SpellArea(SDL_Rect pos, CSpellWindow * owner);
  32. void setSpell(SpellID spellID);
  33. void clickLeft(tribool down, bool previousState) override;
  34. void clickRight(tribool down, bool previousState) override;
  35. void hover(bool on) override;
  36. void showAll(SDL_Surface * to) override;
  37. };
  38. class InteractiveArea : public CIntObject
  39. {
  40. private:
  41. std::function<void()> onLeft;
  42. CSpellWindow * owner;
  43. std::string hoverText;
  44. std::string helpText;
  45. public:
  46. void clickLeft(tribool down, bool previousState) override;
  47. void clickRight(tribool down, bool previousState) override;
  48. void hover(bool on) override;
  49. InteractiveArea(const SDL_Rect & myRect, std::function<void()> funcL, int helpTextId, CSpellWindow * _owner);//c-tor
  50. };
  51. SDL_Surface * leftCorner, * rightCorner;
  52. CAnimation * spells; //pictures of spells
  53. CDefHandler * spellTab, //school select
  54. * schools, //schools' pictures
  55. * schoolBorders [4]; //schools' 'borders': [0]: air, [1]: fire, [2]: water, [3]: earth
  56. InteractiveArea * exitBtn, * battleSpells, * adventureSpells, * manaPoints;
  57. InteractiveArea * selectSpellsA, * selectSpellsE, * selectSpellsF, * selectSpellsW, * selectSpellsAll;
  58. InteractiveArea * lCorner, * rCorner;
  59. SpellArea * spellAreas[12];
  60. CGStatusBar * statusBar;
  61. int sitesPerTabAdv[5];
  62. int sitesPerTabBattle[5];
  63. bool battleSpellsOnly; //if true, only battle spells are displayed; if false, only adventure map spells are displayed
  64. Uint8 selectedTab; // 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
  65. int currentPage; //changes when corners are clicked
  66. std::set<SpellID> mySpells; //all spels in this spellbook
  67. const CGHeroInstance * myHero; //hero whose spells are presented
  68. void computeSpellsPerArea(); //recalculates spellAreas::mySpell
  69. void turnPageLeft();
  70. void turnPageRight();
  71. CPlayerInterface * myInt;
  72. public:
  73. CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _myInt, bool openOnBattleSpells = true); //c-tor
  74. ~CSpellWindow(); //d-tor
  75. void fexitb();
  76. void fadvSpellsb();
  77. void fbattleSpellsb();
  78. void fmanaPtsb();
  79. void fLcornerb();
  80. void fRcornerb();
  81. void selectSchool(int school); //schools: 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
  82. int pagesWithinCurrentTab();
  83. void keyPressed(const SDL_KeyboardEvent & key);
  84. void activate();
  85. void deactivate();
  86. void showAll(SDL_Surface * to);
  87. void show(SDL_Surface * to);
  88. };