CCreatureWindow.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. class 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 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. std::string count; //creature count in text format
  44. const CCreature *c; //related creature
  45. const CStackInstance *stack;
  46. const CBonusSystemNode *stackNode;
  47. const CCommanderInstance * commander;
  48. const CGHeroInstance *heroOwner;
  49. const CArtifactInstance *creatureArtifact; //currently worn artifact
  50. std::vector<CComponent*> upgResCost; //cost of upgrade (if not possible then empty)
  51. std::vector<CBonusItem*> bonusItems;
  52. std::vector<LRClickableAreaWText*> spellEffects;
  53. CPicture *bitmap; //background
  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 close();
  79. void clickRight(tribool down, bool previousState); //call-in
  80. void sliderMoved(int newpos);
  81. ~CCreatureWindow(); //d-tor
  82. void recreateSkillList(int pos);
  83. void scrollArt(int dir);
  84. void passArtifactToHero();
  85. };
  86. class CBonusItem : public LRClickableAreaWTextComp //responsible for displaying creature skill, active or not
  87. {
  88. public:
  89. std::string name, description;
  90. CPicture * bonusGraphics;
  91. bool visible;
  92. CBonusItem();
  93. CBonusItem(const Rect &Pos, const std::string &Name, const std::string &Description, const std::string &graphicsName);
  94. ~CBonusItem();
  95. void setBonus (const Bonus &bonus);
  96. void showAll (SDL_Surface * to);
  97. };
  98. /// original creature info window
  99. class CCreInfoWindow : public CIntObject
  100. {
  101. public:
  102. CPicture * background;
  103. CLabel * creatureCount;
  104. CLabel * creatureName;
  105. CLabel * abilityText;
  106. CCreaturePic * animation;
  107. std::vector<CComponent *> upgResCost; //cost of upgrade (if not possible then empty)
  108. std::vector<CAnimImage *> effects;
  109. std::map<size_t, std::pair<CLabel *, CLabel * > > infoTexts;
  110. MoraleLuckBox * luck, * morale;
  111. CAdventureMapButton * dismiss, * upgrade, * ok;
  112. CCreInfoWindow(const CStackInstance & st, bool LClicked, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo * ui = NULL);
  113. CCreInfoWindow(const CStack & st, bool LClicked = 0);
  114. CCreInfoWindow(int Cid, bool LClicked, int creatureCount);
  115. ~CCreInfoWindow();
  116. void init(const CCreature * cre, const CBonusSystemNode * stackNode, const CGHeroInstance * heroOwner, int creatureCount, bool LClicked);
  117. void printLine(int nr, const std::string & text, int baseVal, int val = -1, bool range = false);
  118. void clickRight(tribool down, bool previousState);
  119. void close();
  120. void show(SDL_Surface * to);
  121. };
  122. CIntObject *createCreWindow(const CStack *s, bool lclick = false);
  123. CIntObject *createCreWindow(int Cid, int Type, int creatureCount);
  124. CIntObject *createCreWindow(const CStackInstance *s, int type, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo *ui = NULL);