supertux
text_area.hpp
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 
18 #ifndef HEADER_SUPERTUX_TRIGGER_TEXT_AREA_HPP
19 #define HEADER_SUPERTUX_TRIGGER_TEXT_AREA_HPP
20 
21 #include "trigger/trigger_base.hpp"
22 
23 #include "supertux/timer.hpp"
24 
25 class TextArea final : public Trigger
26 {
27 private:
28  enum class Status
29  {
30  NOT_STARTED,
31  FADING_IN,
32  WAITING,
33  FADING_OUT,
34  FINISHED
35  };
36 
37 public:
38  TextArea(const ReaderMapping& mapping);
39 
40  virtual void draw(DrawingContext& context) override;
41  virtual void event(Player& player, EventType type) override;
42  virtual void update(float dt_sec) override;
43 
44  virtual ObjectSettings get_settings() override;
45  static std::string class_name() { return "text-area"; }
46  virtual std::string get_class_name() const override { return class_name(); }
47  static std::string display_name() { return _("Text Area"); }
48  virtual std::string get_display_name() const override { return display_name(); }
49  virtual bool has_variable_size() const override { return true; }
50  virtual GameObjectClasses get_class_types() const override { return Trigger::get_class_types().add(typeid(TextArea)); }
51 
52 private:
53  bool m_once;
54  std::vector<std::string> m_items;
55  float m_delay;
56  float m_fade_delay;
57  size_t m_current_text;
58  Status m_status;
59  Timer m_timer;
60  AnchorPoint m_anchor;
61  Vector m_anchor_offset;
62 
63 private:
64  TextArea(const TextArea&) = delete;
65  TextArea& operator=(const TextArea&) = delete;
66 };
67 
68 #endif
69 /* EOF */
virtual void event(Player &player, EventType type) override
Receive trigger events.
Definition: text_area.cpp:61
EventType
Definition: trigger_base.hpp:34
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: text_area.hpp:50
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: text_area.cpp:54
Definition: text_area.hpp:25
Definition: object_settings.hpp:39
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: text_area.hpp:48
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: trigger_base.hpp:71
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
virtual bool has_variable_size() const override
Does this object have variable size (secret area trigger, wind, etc.)
Definition: text_area.hpp:49
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Definition: trigger_base.hpp:66
Definition: reader_mapping.hpp:32
This module contains methods controlling the player.
Definition: player.hpp:47
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42