TurnTimerWidget.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 "../gui/InterfaceObjectConfigurable.h"
  13. #include "../render/Canvas.h"
  14. #include "../render/Colors.h"
  15. class CAnimImage;
  16. class CLabel;
  17. VCMI_LIB_NAMESPACE_BEGIN
  18. class PlayerColor;
  19. VCMI_LIB_NAMESPACE_END
  20. class TurnTimerWidget : public InterfaceObjectConfigurable
  21. {
  22. private:
  23. class DrawRect : public CIntObject
  24. {
  25. const Rect rect;
  26. const ColorRGBA color;
  27. public:
  28. DrawRect(const Rect &, const ColorRGBA &);
  29. void showAll(Canvas & to) override;
  30. };
  31. int turnTime;
  32. int lastTurnTime;
  33. int cachedTurnTime;
  34. PlayerColor lastPlayer;
  35. std::set<int> notifications;
  36. std::shared_ptr<DrawRect> buildDrawRect(const JsonNode & config) const;
  37. void updateTimer(PlayerColor player, uint32_t msPassed);
  38. public:
  39. void show(Canvas & to) override;
  40. void tick(uint32_t msPassed) override;
  41. void setTime(PlayerColor player, int time);
  42. TurnTimerWidget();
  43. };