CCreatureWindow.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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, COMMANDER_BATTLE = 6}; // > 3 are opened permanently
  41. //bool active; //TODO: comment me
  42. CreWinType type;
  43. int bonusRows; //height of skill window
  44. ArtifactPosition 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; //index for upgradeOptions
  65. std::vector<ui32> upgradeOptions; //value 0-5 - secondary skills, 100+ - special skills
  66. std::vector<CSelectableSkill *> selectableSkills, selectableBonuses;
  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, CreWinType type); //battle c-tor
  79. CCreatureWindow (const CStackInstance &stack, CreWinType Type); //pop-up c-tor
  80. CCreatureWindow(const CStackInstance &st, CreWinType Type, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui); //full garrison window
  81. CCreatureWindow(const CCommanderInstance * commander, const CStack * stack = NULL); //commander window
  82. CCreatureWindow(std::vector<ui32> &skills, const CCommanderInstance * commander, boost::function<void(ui32)> callback);
  83. CCreatureWindow(CreatureID Cid, CreWinType Type, int creatureCount); //c-tor
  84. void init(const CStackInstance *stack, const CBonusSystemNode *stackNode, const CGHeroInstance *heroOwner);
  85. void showAll();
  86. void show();
  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 showAll();
  105. };
  106. class CSelectableSkill : public LRClickableAreaWText
  107. {
  108. public:
  109. boost::function<void()> callback; //TODO: create more generic clickable class than AdvMapButton?
  110. virtual void clickLeft(tribool down, bool previousState);
  111. virtual void clickRight(tribool down, bool previousState){};
  112. };
  113. /// original creature info window
  114. class CCreInfoWindow : public CWindowObject
  115. {
  116. public:
  117. CLabel * creatureCount;
  118. CLabel * creatureName;
  119. CLabel * abilityText;
  120. CCreaturePic * animation;
  121. std::vector<CComponent *> upgResCost; //cost of upgrade (if not possible then empty)
  122. std::vector<CAnimImage *> effects;
  123. std::map<size_t, std::pair<CLabel *, CLabel * > > infoTexts;
  124. MoraleLuckBox * luck, * morale;
  125. CAdventureMapButton * dismiss, * upgrade, * ok;
  126. CCreInfoWindow(const CStackInstance & st, bool LClicked, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo * ui = NULL);
  127. CCreInfoWindow(const CStack & st, bool LClicked = 0);
  128. CCreInfoWindow(int Cid, bool LClicked, int creatureCount);
  129. ~CCreInfoWindow();
  130. void init(const CCreature * cre, const CBonusSystemNode * stackNode, const CGHeroInstance * heroOwner, int creatureCount, bool LClicked);
  131. void printLine(int nr, const std::string & text, int baseVal, int val = -1, bool range = false);
  132. void show();
  133. };
  134. CIntObject *createCreWindow(const CStack *s, bool lclick = false);
  135. CIntObject *createCreWindow(CreatureID Cid, CCreatureWindow::CreWinType Type, int creatureCount);
  136. CIntObject *createCreWindow(const CStackInstance *s, CCreatureWindow::CreWinType type, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo *ui = NULL);