1 //  SuperTux
2 //  Copyright (C) 2004 Ingo Ruhnke <grumbel@gmail.com>
3 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
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_WORLDMAP_LEVEL_TILE_HPP
19 #define HEADER_SUPERTUX_WORLDMAP_LEVEL_TILE_HPP
20 
21 #include "math/vector.hpp"
22 #include "sprite/sprite_ptr.hpp"
23 #include "supertux/game_object.hpp"
24 #include "supertux/statistics.hpp"
25 
26 class ReaderMapping;
27 
28 namespace worldmap {
29 
30 class LevelTile final : public GameObject
31 {
32   friend class WorldMapParser;
33 
34 public:
35   LevelTile(const std::string& basedir, const ReaderMapping& mapping);
36   ~LevelTile() override;
37 
38   virtual void draw(DrawingContext& context) override;
39   virtual void update(float dt_sec) override;
40 
41   void set_solved(bool v);
is_solved() const42   bool is_solved() const { return m_solved; }
43 
44   void set_perfect(bool v);
is_perfect() const45   bool is_perfect() const { return m_perfect; }
46 
get_statistics()47   Statistics& get_statistics() { return m_statistics; }
get_statistics() const48   const Statistics& get_statistics() const { return m_statistics; }
49 
50   void update_sprite_action();
51 
get_pos() const52   Vector get_pos() const { return m_pos; }
53 
get_title() const54   std::string get_title() const { return m_title; }
get_level_filename() const55   std::string get_level_filename() const { return m_level_filename; }
get_basedir() const56   std::string get_basedir() const { return m_basedir; }
get_title_color() const57   Color get_title_color() const { return m_title_color; }
get_extro_script() const58   std::string get_extro_script() const { return m_extro_script; }
get_target_time() const59   float get_target_time() const { return m_target_time; }
is_auto_play() const60   bool is_auto_play() const { return m_auto_play; }
61 
62 private:
63   Vector m_pos;
64 
65   std::string m_basedir;
66   std::string m_level_filename;
67   std::string m_title;
68 
69   /** true if Tux should automatically enter this level if it's unfinished */
70   bool m_auto_play;
71 
72   float m_target_time;
73 
74   /** Script that is run when the level is successfully finished */
75   std::string m_extro_script;
76 
77   /** Level state */
78   bool m_solved;
79   bool m_perfect;
80 
81   Statistics m_statistics;
82 
83   SpritePtr m_sprite;
84   Color m_title_color;
85 
86 private:
87   LevelTile(const LevelTile&) = delete;
88   LevelTile& operator=(const LevelTile&) = delete;
89 };
90 
91 } // namespace worldmap
92 
93 #endif
94 
95 /* EOF */
96