CCreatureWindow.h 5.0 KB

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