CCreatureWindow.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #pragma once
  2. #include "UIFramework/CIntObject.h"
  3. #include "../lib/HeroBonus.h"
  4. #include "GUIClasses.h"
  5. /*
  6. * CCreatureWindow.h, part of VCMI engine
  7. *
  8. * Authors: listed in file AUTHORS in main folder
  9. *
  10. * License: GNU General Public License v2.0 or later
  11. * Full text of license available in license.txt file, in main folder
  12. *
  13. */
  14. struct Bonus;
  15. class CCreature;
  16. class CStackInstance;
  17. class CStack;
  18. class CCreatureArtifactInstance;
  19. class CAdventureMapButton;
  20. class CBonusItem;
  21. class CGHeroInstance;
  22. class CComponent;
  23. class LRClickableAreaWText;
  24. class MoraleLuckBox;
  25. class CAdventureMapButton;
  26. struct UpgradeInfo;
  27. class CPicture;
  28. class CCreaturePic;
  29. class LRClickableAreaWTextComp;
  30. class CSlider;
  31. class CLabel;
  32. class CAnimImage;
  33. // New creature window
  34. class CCreatureWindow : public CIntObject
  35. {
  36. public:
  37. enum CreWinType {OTHER = 0, BATTLE = 1, ARMY = 2, HERO = 3}; //only last one should open permanently
  38. //bool active; //TODO: comment me
  39. int type;//0 - rclick popup; 1 - normal window
  40. int bonusRows; //height of skill window
  41. std::string count; //creature count in text format
  42. const CCreature *c; //related creature
  43. const CStackInstance *stack;
  44. const CBonusSystemNode *stackNode;
  45. const CGHeroInstance *heroOwner;
  46. const CArtifactInstance *creatureArtifact; //currently worn artifact
  47. std::vector<CComponent*> upgResCost; //cost of upgrade (if not possible then empty)
  48. std::vector<CBonusItem*> bonusItems;
  49. std::vector<LRClickableAreaWText*> spellEffects;
  50. CPicture *bitmap; //background
  51. CCreaturePic *anim; //related creature's animation
  52. MoraleLuckBox *luck, *morale;
  53. LRClickableAreaWTextComp * expArea; //displays exp details
  54. CSlider * slider; //Abilities
  55. CAdventureMapButton *dismiss, *upgrade, *ok;
  56. CAdventureMapButton * leftArtRoll, * rightArtRoll; //artifact selection
  57. CAdventureMapButton * passArtToHero;
  58. boost::function<void()> dsm; //dismiss button callback
  59. boost::function<void()> Upg; //upgrade button callback
  60. CCreatureWindow(const CStack & stack, int type); //battle c-tor
  61. CCreatureWindow (const CStackInstance &stack, int Type); //pop-up c-tor
  62. CCreatureWindow(const CStackInstance &st, int Type, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui); //full garrison window
  63. CCreatureWindow(int Cid, int Type, int creatureCount); //c-tor
  64. void init(const CStackInstance *stack, const CBonusSystemNode *stackNode, const CGHeroInstance *heroOwner);
  65. void showAll(SDL_Surface * to);
  66. void show(SDL_Surface * to);
  67. void printLine(int nr, const std::string &text, int baseVal, int val=-1, bool range=false);
  68. void close();
  69. void clickRight(tribool down, bool previousState); //call-in
  70. void sliderMoved(int newpos);
  71. ~CCreatureWindow(); //d-tor
  72. void recreateSkillList(int pos);
  73. void scrollArt(int dir);
  74. void passArtifactToHero();
  75. };
  76. class CBonusItem : public LRClickableAreaWTextComp //responsible for displaying creature skill, active or not
  77. {
  78. public:
  79. std::string name, description;
  80. CPicture * bonusGraphics;
  81. bool visible;
  82. CBonusItem();
  83. CBonusItem(const Rect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName);
  84. ~CBonusItem();
  85. void setBonus (const Bonus &bonus);
  86. void showAll (SDL_Surface * to);
  87. };
  88. /// original creature info window
  89. class CCreInfoWindow : public CIntObject
  90. {
  91. public:
  92. CPicture * background;
  93. CLabel * creatureCount;
  94. CLabel * creatureName;
  95. CLabel * abilityText;
  96. CCreaturePic * animation;
  97. std::vector<CComponent *> upgResCost; //cost of upgrade (if not possible then empty)
  98. std::vector<CAnimImage *> effects;
  99. std::map<size_t, std::pair<CLabel *, CLabel * > > infoTexts;
  100. MoraleLuckBox * luck, * morale;
  101. CAdventureMapButton * dismiss, * upgrade, * ok;
  102. CCreInfoWindow(const CStackInstance & st, bool LClicked, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo * ui = NULL);
  103. CCreInfoWindow(const CStack & st, bool LClicked = 0);
  104. CCreInfoWindow(int Cid, bool LClicked, int creatureCount);
  105. ~CCreInfoWindow();
  106. void init(const CCreature * cre, const CBonusSystemNode * stackNode, const CGHeroInstance * heroOwner, int creatureCount, bool LClicked);
  107. void printLine(int nr, const std::string & text, int baseVal, int val = -1, bool range = false);
  108. void clickRight(tribool down, bool previousState);
  109. void close();
  110. void show(SDL_Surface * to);
  111. };
  112. CIntObject *createCreWindow(const CStack *s, bool lclick = false);
  113. CIntObject *createCreWindow(int Cid, int Type, int creatureCount);
  114. CIntObject *createCreWindow(const CStackInstance *s, int type, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo *ui = NULL);