supertux
worldmap_objects.hpp
1 // SuperTux
2 // Copyright (C) 2016 Hume2 <teratux.mail@gmail.com>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_EDITOR_WORLDMAP_OBJECTS_HPP
18 #define HEADER_SUPERTUX_EDITOR_WORLDMAP_OBJECTS_HPP
19 
20 #include "object/moving_sprite.hpp"
21 #include "video/color.hpp"
22 #include "worldmap/direction.hpp"
23 
24 namespace worldmap_editor {
25 
27 {
28 public:
29  WorldmapObject(const ReaderMapping& mapping, const std::string& default_sprite);
30  WorldmapObject(const ReaderMapping& mapping);
31  WorldmapObject(const Vector& pos, const std::string& default_sprite);
32 
33  virtual ObjectSettings get_settings() override;
34  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override { return FORCE_MOVE; }
35  virtual std::string get_class() const override { return "worldmap-object"; }
36  virtual void move_to(const Vector& pos) override;
37 
38 private:
39  // FIXME: purely used for saving, is not updated normally, don't use.
40  int m_tile_x;
41  int m_tile_y;
42 
43 private:
44  WorldmapObject(const WorldmapObject&) = delete;
45  WorldmapObject& operator=(const WorldmapObject&) = delete;
46 };
47 
48 class LevelDot final : public WorldmapObject
49 {
50 public:
51  LevelDot(const ReaderMapping& mapping);
52 
53  virtual void draw(DrawingContext& context) override;
54 
55  virtual std::string get_class() const override { return "level"; }
56  virtual std::string get_display_name() const override { return _("Level"); }
57  virtual ObjectSettings get_settings() override;
58  virtual void after_editor_set() override;
59 
60 private:
61  std::string m_level_filename;
62  std::string m_extro_script;
63  bool m_auto_play;
64  Color m_title_color;
65 
66 private:
67  LevelDot(const LevelDot&) = delete;
68  LevelDot& operator=(const LevelDot&) = delete;
69 };
70 
71 class Teleporter final : public WorldmapObject
72 {
73 public:
74  Teleporter(const ReaderMapping& mapping);
75 
76  virtual void draw(DrawingContext& context) override;
77 
78  virtual std::string get_class() const override { return "teleporter"; }
79  virtual std::string get_display_name() const override { return _("Teleporter"); }
80  virtual ObjectSettings get_settings() override;
81 
82 private:
83  std::string m_worldmap;
84  std::string m_spawnpoint;
85  std::string m_message;
86  bool m_automatic;
87  bool m_change_worldmap;
88 
89 private:
90  Teleporter(const Teleporter&) = delete;
91  Teleporter& operator=(const Teleporter&) = delete;
92 };
93 
94 class WorldmapSpawnPoint final : public WorldmapObject
95 {
96 public:
97  WorldmapSpawnPoint(const ReaderMapping& mapping);
98  WorldmapSpawnPoint(const std::string& name_, const Vector& pos);
99 
100  virtual std::string get_class() const override { return "worldmap-spawnpoint"; }
101  virtual std::string get_display_name() const override { return _("Spawn point"); }
102 
103  virtual ObjectSettings get_settings() override;
104 
105 private:
106  worldmap::Direction m_dir;
107 
108 private:
109  WorldmapSpawnPoint(const WorldmapSpawnPoint&) = delete;
110  WorldmapSpawnPoint& operator=(const WorldmapSpawnPoint&) = delete;
111 };
112 
113 class SpriteChange final : public WorldmapObject
114 {
115 public:
116  SpriteChange(const ReaderMapping& mapping);
117 
118  virtual std::string get_class() const override { return "sprite-change"; }
119  virtual std::string get_display_name() const override { return _("Sprite Change"); }
120  virtual ObjectSettings get_settings() override;
121 
122 private:
123  std::string m_target_sprite;
124  std::string m_stay_action;
125  bool m_initial_stay_action;
126  std::string m_stay_group;
127  bool m_change_on_touch;
128 
129 private:
130  SpriteChange(const SpriteChange&) = delete;
131  SpriteChange& operator=(const SpriteChange&) = delete;
132 };
133 
134 class SpecialTile final : public WorldmapObject
135 {
136 public:
137  SpecialTile(const ReaderMapping& mapping);
138 
139  virtual std::string get_class() const override { return "special-tile"; }
140  virtual std::string get_display_name() const override { return _("Special tile"); }
141  virtual ObjectSettings get_settings() override;
142 
143 private:
144  std::string m_map_message;
145  std::string m_script;
146  bool m_passive_message;
147  bool m_invisible_tile;
148 
149  std::string m_apply_to_directions;
150 
151 private:
152  SpecialTile(const SpecialTile&) = delete;
153  SpecialTile& operator=(const SpecialTile&) = delete;
154 };
155 
156 } // namespace worldmap_editor
157 
158 #endif
159 
160 /* EOF */
Simple two dimensional vector.
Definition: vector.hpp:24
Definition: worldmap_objects.hpp:26
Definition: worldmap_objects.hpp:71
Definition: worldmap_objects.hpp:134
Definition: worldmap_objects.hpp:113
Definition: object_settings.hpp:35
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: worldmap_objects.hpp:34
Definition: worldmap_objects.hpp:94
Definition: worldmap_objects.cpp:30
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: moving_sprite.cpp:101
Definition: worldmap_objects.hpp:48
Definition: color.hpp:25
Definition: reader_mapping.hpp:31
Abstract base class for MovingObjects that are represented by a Sprite.
Definition: moving_sprite.hpp:29
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
This class collects data about a collision.
Definition: collision_hit.hpp:44