CCreatureWindow.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 CCommanderInstance;
  18. class CStack;
  19. struct ArtifactLocation;
  20. class CCreatureArtifactInstance;
  21. class CAdventureMapButton;
  22. class CBonusItem;
  23. class CGHeroInstance;
  24. class CComponent;
  25. class LRClickableAreaWText;
  26. class MoraleLuckBox;
  27. class CAdventureMapButton;
  28. struct UpgradeInfo;
  29. class CPicture;
  30. class CCreaturePic;
  31. class LRClickableAreaWTextComp;
  32. class CSlider;
  33. class CLabel;
  34. class CAnimImage;
  35. // New creature window
  36. class CCreatureWindow : public CWindowObject, public CArtifactHolder
  37. {
  38. public:
  39. enum CreWinType {OTHER = 0, BATTLE = 1, ARMY = 2, HERO = 3, COMMANDER = 4, COMMANDER_LEVEL_UP = 5}; // > 3 are opened permanently
  40. //bool active; //TODO: comment me
  41. int type;//0 - rclick popup; 1 - normal window
  42. int bonusRows; //height of skill window
  43. int displayedArtifact;
  44. std::string count; //creature count in text format
  45. const CCreature *c; //related creature
  46. const CStackInstance *stack;
  47. const CBonusSystemNode *stackNode;
  48. const CCommanderInstance * commander;
  49. const CGHeroInstance *heroOwner;
  50. const CArtifactInstance *creatureArtifact; //currently worn artifact
  51. std::vector<CComponent*> upgResCost; //cost of upgrade (if not possible then empty)
  52. std::vector<CBonusItem*> bonusItems;
  53. std::vector<LRClickableAreaWText*> spellEffects;
  54. CCreaturePic *anim; //related creature's animation
  55. MoraleLuckBox *luck, *morale;
  56. LRClickableAreaWTextComp * expArea; //displays exp details
  57. CSlider * slider; //Abilities
  58. CAdventureMapButton *dismiss, *upgrade, *ok;
  59. CAdventureMapButton * leftArtRoll, * rightArtRoll; //artifact selection
  60. CAdventureMapButton * passArtToHero;
  61. CAnimImage *artifactImage;
  62. void setArt(const CArtifactInstance *creatureArtifact);
  63. void artifactRemoved (const ArtifactLocation &artLoc);
  64. void artifactMoved (const ArtifactLocation &artLoc, const ArtifactLocation &destLoc);
  65. void artifactDisassembled (const ArtifactLocation &artLoc) {return;};
  66. void artifactAssembled (const ArtifactLocation &artLoc) {return;};
  67. boost::function<void()> dsm; //dismiss button callback
  68. boost::function<void()> Upg; //upgrade button callback
  69. CCreatureWindow(const CStack & stack, int type); //battle c-tor
  70. CCreatureWindow (const CStackInstance &stack, int Type); //pop-up c-tor
  71. CCreatureWindow(const CStackInstance &st, int Type, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui); //full garrison window
  72. CCreatureWindow(const CCommanderInstance * commander); //commander window
  73. CCreatureWindow(int Cid, int Type, int creatureCount); //c-tor
  74. void init(const CStackInstance *stack, const CBonusSystemNode *stackNode, const CGHeroInstance *heroOwner);
  75. void showAll(SDL_Surface * to);
  76. void show(SDL_Surface * to);
  77. void printLine(int nr, const std::string &text, int baseVal, int val=-1, bool range=false);
  78. void sliderMoved(int newpos);
  79. ~CCreatureWindow(); //d-tor
  80. void recreateSkillList(int pos);
  81. void scrollArt(int dir);
  82. void passArtifactToHero();
  83. };
  84. class CBonusItem : public LRClickableAreaWTextComp //responsible for displaying creature skill, active or not
  85. {
  86. public:
  87. std::string name, description;
  88. CPicture * bonusGraphics;
  89. bool visible;
  90. CBonusItem();
  91. CBonusItem(const Rect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName);
  92. ~CBonusItem();
  93. void setBonus (const Bonus &bonus);
  94. void showAll (SDL_Surface * to);
  95. };
  96. /// original creature info window
  97. class CCreInfoWindow : public CWindowObject
  98. {
  99. public:
  100. CLabel * creatureCount;
  101. CLabel * creatureName;
  102. CLabel * abilityText;
  103. CCreaturePic * animation;
  104. std::vector<CComponent *> upgResCost; //cost of upgrade (if not possible then empty)
  105. std::vector<CAnimImage *> effects;
  106. std::map<size_t, std::pair<CLabel *, CLabel * > > infoTexts;
  107. MoraleLuckBox * luck, * morale;
  108. CAdventureMapButton * dismiss, * upgrade, * ok;
  109. CCreInfoWindow(const CStackInstance & st, bool LClicked, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo * ui = NULL);
  110. CCreInfoWindow(const CStack & st, bool LClicked = 0);
  111. CCreInfoWindow(int Cid, bool LClicked, int creatureCount);
  112. ~CCreInfoWindow();
  113. void init(const CCreature * cre, const CBonusSystemNode * stackNode, const CGHeroInstance * heroOwner, int creatureCount, bool LClicked);
  114. void printLine(int nr, const std::string & text, int baseVal, int val = -1, bool range = false);
  115. void show(SDL_Surface * to);
  116. };
  117. CIntObject *createCreWindow(const CStack *s, bool lclick = false);
  118. CIntObject *createCreWindow(int Cid, int Type, int creatureCount);
  119. CIntObject *createCreWindow(const CStackInstance *s, int type, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo *ui = NULL);