CInfoBar.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * CInfoBar.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../gui/CIntObject.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class CGHeroInstance;
  14. class CGTownInstance;
  15. struct Component;
  16. class PlayerColor;
  17. VCMI_LIB_NAMESPACE_END
  18. class CAnimImage;
  19. class CShowableAnim;
  20. class CComponent;
  21. class CHeroTooltip;
  22. class CTownTooltip;
  23. class CLabel;
  24. class CTextBox;
  25. /// Info box which shows next week/day information, hold the current date
  26. class CInfoBar : public CIntObject
  27. {
  28. //all visible information located in one object - for ease of replacing
  29. class CVisibleInfo : public CIntObject
  30. {
  31. public:
  32. void show(SDL_Surface * to) override;
  33. protected:
  34. std::shared_ptr<CPicture> background;
  35. std::list<std::shared_ptr<CIntObject>> forceRefresh;
  36. CVisibleInfo();
  37. };
  38. class EmptyVisibleInfo : public CVisibleInfo
  39. {
  40. public:
  41. EmptyVisibleInfo();
  42. };
  43. class VisibleHeroInfo : public CVisibleInfo
  44. {
  45. std::shared_ptr<CHeroTooltip> heroTooltip;
  46. public:
  47. VisibleHeroInfo(const CGHeroInstance * hero);
  48. };
  49. class VisibleTownInfo : public CVisibleInfo
  50. {
  51. std::shared_ptr<CTownTooltip> townTooltip;
  52. public:
  53. VisibleTownInfo(const CGTownInstance * town);
  54. };
  55. class VisibleDateInfo : public CVisibleInfo
  56. {
  57. std::shared_ptr<CShowableAnim> animation;
  58. std::shared_ptr<CLabel> label;
  59. std::string getNewDayName();
  60. public:
  61. VisibleDateInfo();
  62. };
  63. class VisibleEnemyTurnInfo : public CVisibleInfo
  64. {
  65. std::shared_ptr<CAnimImage> banner;
  66. std::shared_ptr<CShowableAnim> glass;
  67. std::shared_ptr<CShowableAnim> sand;
  68. public:
  69. VisibleEnemyTurnInfo(PlayerColor player);
  70. };
  71. class VisibleGameStatusInfo : public CVisibleInfo
  72. {
  73. std::shared_ptr<CLabel> allyLabel;
  74. std::shared_ptr<CLabel> enemyLabel;
  75. std::vector<std::shared_ptr<CAnimImage>> flags;
  76. std::vector<std::shared_ptr<CAnimImage>> hallIcons;
  77. std::vector<std::shared_ptr<CLabel>> hallLabels;
  78. public:
  79. VisibleGameStatusInfo();
  80. };
  81. class VisibleComponentInfo : public CVisibleInfo
  82. {
  83. std::shared_ptr<CComponent> comp;
  84. std::shared_ptr<CTextBox> text;
  85. public:
  86. VisibleComponentInfo(const Component & compToDisplay, std::string message);
  87. };
  88. enum EState
  89. {
  90. EMPTY, HERO, TOWN, DATE, GAME, AITURN, COMPONENT
  91. };
  92. std::shared_ptr<CVisibleInfo> visibleInfo;
  93. EState state;
  94. //removes all information about current state, deactivates timer (if any)
  95. void reset();
  96. void tick() override;
  97. void clickLeft(tribool down, bool previousState) override;
  98. void clickRight(tribool down, bool previousState) override;
  99. void hover(bool on) override;
  100. void playNewDaySound();
  101. public:
  102. CInfoBar(const Rect & pos);
  103. /// show new day/week animation
  104. void showDate();
  105. /// show component for 3 seconds. Used to display picked up resources
  106. void showComponent(const Component & comp, std::string message);
  107. /// print enemy turn progress
  108. void startEnemyTurn(PlayerColor color);
  109. /// reset to default view - selected object
  110. void showSelection();
  111. /// show hero\town information
  112. void showHeroSelection(const CGHeroInstance * hero);
  113. void showTownSelection(const CGTownInstance * town);
  114. /// for 3 seconds shows amount of town halls and players status
  115. void showGameStatus();
  116. };