supertux
textscroller.hpp
1 // SuperTux
2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 // 2018 Ingo Ruhnke <grumbel@gmail.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_OBJECT_TEXTSCROLLER_HPP
19 #define HEADER_SUPERTUX_OBJECT_TEXTSCROLLER_HPP
20 
21 #include <memory>
22 #include <vector>
23 
24 #include "supertux/info_box_line.hpp"
25 #include "supertux/game_object.hpp"
26 
27 class DrawingContext;
28 class InfoBoxLine;
29 class ReaderCollection;
30 class ReaderMapping;
31 class ReaderObject;
32 
33 class TextScroller : public GameObject
34 {
35 public:
36  TextScroller(const ReaderMapping& mapping);
37  TextScroller(const ReaderObject& root);
38 
39  virtual void draw(DrawingContext& context) override;
40  virtual void update(float dt_sec) override;
41  virtual ObjectSettings get_settings() override;
42  virtual std::string get_class() const override { return "textscroller"; }
43  virtual std::string get_display_name() const override { return _("TextScroller"); }
44 
45  void set_speed(float speed);
46  void scroll(float offset);
47  bool is_finished() const { return m_finished; }
48 
49 private:
50  void parse_file(const std::string& filename);
51  void parse_root(const ReaderObject& root);
52  void parse_content(const ReaderCollection& collection);
53 
54 private:
55  std::string m_filename;
56  std::vector<std::unique_ptr<InfoBoxLine> > m_lines;
57  float m_scroll;
58  float m_speed;
59  bool m_finished;
60 
61 private:
62  TextScroller(const TextScroller&) = delete;
63  TextScroller& operator=(const TextScroller&) = delete;
64 };
65 
66 #endif
67 
68 /* EOF */
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it&#39;s state.
Definition: textscroller.cpp:230
Definition: reader_object.hpp:30
Definition: textscroller.hpp:33
Definition: object_settings.hpp:35
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: textscroller.cpp:199
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
Helper class for InfoBox: Represents a line of text.
Definition: info_box_line.hpp:34
Definition: reader_mapping.hpp:31
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
Definition: reader_collection.hpp:30