text_area.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // SuperTux
  2. // Copyright (C) 2021 mrkubax10 <mrkubax10@onet.pl>
  3. // 2021 A. Semphris <semphris@protonmail.com>
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef HEADER_SUPERTUX_TRIGGER_TEXT_AREA_HPP
  18. #define HEADER_SUPERTUX_TRIGGER_TEXT_AREA_HPP
  19. #include "trigger/trigger_base.hpp"
  20. #include "supertux/timer.hpp"
  21. class TextArea final : public Trigger
  22. {
  23. private:
  24. enum class Status
  25. {
  26. NOT_STARTED,
  27. FADING_IN,
  28. WAITING,
  29. FADING_OUT,
  30. FINISHED
  31. };
  32. public:
  33. TextArea(const ReaderMapping& mapping);
  34. virtual void draw(DrawingContext& context) override;
  35. virtual void event(Player& player, EventType type) override;
  36. virtual void update(float dt_sec) override;
  37. virtual ObjectSettings get_settings() override;
  38. static std::string class_name() { return "text-area"; }
  39. virtual std::string get_class_name() const override { return class_name(); }
  40. static std::string display_name() { return _("Text Area"); }
  41. virtual std::string get_display_name() const override { return display_name(); }
  42. virtual bool has_variable_size() const override { return true; }
  43. private:
  44. bool m_once;
  45. std::vector<std::string> m_items;
  46. float m_delay;
  47. float m_fade_delay;
  48. size_t m_current_text;
  49. Status m_status;
  50. Timer m_timer;
  51. AnchorPoint m_anchor;
  52. Vector m_anchor_offset;
  53. private:
  54. TextArea(const TextArea&) = delete;
  55. TextArea& operator=(const TextArea&) = delete;
  56. };
  57. #endif
  58. /* EOF */