CCreatureWindow.h 5.9 KB

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