TurnTimerWidget.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * TurnTimerWidget.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. #include "../render/Colors.h"
  13. #include "../../lib/TurnTimerInfo.h"
  14. class CAnimImage;
  15. class CLabel;
  16. class CFilledTexture;
  17. class TransparentFilledRectangle;
  18. VCMI_LIB_NAMESPACE_BEGIN
  19. class PlayerColor;
  20. VCMI_LIB_NAMESPACE_END
  21. class VerticalPercentBar : public CIntObject
  22. {
  23. std::shared_ptr<TransparentFilledRectangle> back;
  24. std::shared_ptr<TransparentFilledRectangle> fill;
  25. int percent;
  26. ColorRGBA barColor;
  27. ColorRGBA barColorBackground;
  28. ColorRGBA borderColor;
  29. public:
  30. void setPercent(int newPercent);
  31. void setFillColor(ColorRGBA fillColor);
  32. VerticalPercentBar(const Point & position, const Point & size, ColorRGBA barColor, ColorRGBA barColorBackground, ColorRGBA borderColor);
  33. };
  34. class TurnTimerWidget : public CIntObject
  35. {
  36. int lastSoundCheckSeconds;
  37. bool isBattleMode;
  38. const std::set<int> notificationThresholds = {1, 2, 3, 4, 5, 10, 20, 30};
  39. std::map<PlayerColor, std::shared_ptr<CLabel>> playerLabelsMain;
  40. std::map<PlayerColor, std::shared_ptr<CLabel>> playerLabelsBattle;
  41. std::map<PlayerColor, std::shared_ptr<CLabel>> playerLabelsUnit;
  42. std::map<PlayerColor, std::shared_ptr<VerticalPercentBar>> playerBarsMovement;
  43. std::map<PlayerColor, std::shared_ptr<VerticalPercentBar>> playerBarsBattle;
  44. std::shared_ptr<CFilledTexture> backgroundTexture;
  45. std::shared_ptr<TransparentFilledRectangle> backgroundBorder;
  46. void updateTimer(PlayerColor player, uint32_t msPassed);
  47. void show(Canvas & to) override;
  48. void tick(uint32_t msPassed) override;
  49. void updateNotifications(PlayerColor player, int timeMs);
  50. void updateTextLabel(PlayerColor player, const TurnTimerInfo & timer);
  51. public:
  52. /// Activates adventure map mode in which widget will display timer for all players
  53. TurnTimerWidget(const Point & position);
  54. /// Activates battle mode in which timer displays only timer of specific player
  55. TurnTimerWidget(const Point & position, PlayerColor player);
  56. };