TurnTimerWidget.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 TurnTimerWidget : public CIntObject
  22. {
  23. int lastSoundCheckSeconds;
  24. bool isBattleMode;
  25. const std::set<int> notificationThresholds = {0, 1, 2, 3, 4, 5, 10, 20, 30};
  26. std::map<PlayerColor, std::shared_ptr<CLabel>> playerLabelsMain;
  27. std::map<PlayerColor, std::shared_ptr<CLabel>> playerLabelsBattle;
  28. std::map<PlayerColor, std::shared_ptr<CLabel>> playerLabelsUnit;
  29. std::shared_ptr<CFilledTexture> backgroundTexture;
  30. std::shared_ptr<TransparentFilledRectangle> backgroundBorder;
  31. void updateTimer(PlayerColor player, uint32_t msPassed);
  32. void show(Canvas & to) override;
  33. void tick(uint32_t msPassed) override;
  34. void updateNotifications(PlayerColor player, int timeMs);
  35. void updateTextLabel(PlayerColor player, const TurnTimerInfo & timer);
  36. public:
  37. /// Activates adventure map mode in which widget will display timer for all players
  38. TurnTimerWidget(const Point & position);
  39. /// Activates battle mode in which timer displays only timer of specific player
  40. TurnTimerWidget(const Point & position, PlayerColor player);
  41. };