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#include "control/controller.hpp"
27
28class DrawingContext;
29class InfoBoxLine;
30class ReaderCollection;
31class ReaderMapping;
32class ReaderObject;
33
34class TextScroller : public GameObject
35{
36public:
37 TextScroller(const ReaderMapping& mapping);
38 TextScroller(const ReaderObject& root);
39
40 virtual void draw(DrawingContext& context) override;
41 virtual void update(float dt_sec) override;
42 virtual ObjectSettings get_settings() override;
43 virtual std::string get_class() const override { return "textscroller"; }
44 virtual std::string get_display_name() const override { return _("TextScroller"); }
45
46 void set_speed(float speed);
47 void scroll(float offset);
48 bool is_finished() const { return m_finished; }
49
50protected:
51 Controller controller;
52
53private:
54 void parse_file(const std::string& filename);
55 void parse_root(const ReaderObject& root);
56 void parse_content(const ReaderCollection& collection);
57
58private:
59 std::string m_filename;
60 std::vector<std::unique_ptr<InfoBoxLine> > m_lines;
61 float m_scroll;
62 float m_speed;
63 bool m_finished;
64 bool m_fading;
65
66private:
67 TextScroller(const TextScroller&) = delete;
68 TextScroller& operator=(const TextScroller&) = delete;
69};
70
71#endif
72
73/* EOF */
74