supertux
object_settings.hpp
1 // SuperTux
2 // Copyright (C) 2015 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_OBJECT_SETTINGS_HPP
18 #define HEADER_SUPERTUX_EDITOR_OBJECT_SETTINGS_HPP
19 
20 #include <vector>
21 #include <memory>
22 
23 #include "editor/object_option.hpp"
24 
25 class Color;
26 enum class Direction;
27 enum class WalkMode;
28 namespace worldmap {
29 enum class Direction;
30 } // namespace worldmap
31 namespace sexp {
32 class Value;
33 } // namespace sexp
34 
35 class ObjectSettings final
36 {
37 public:
38  ObjectSettings(const std::string& name);
39  ObjectSettings(ObjectSettings&&) = default;
40 
41  const std::string& get_name() const { return m_name; }
42 
43  void add_bool(const std::string& text, bool* value_ptr,
44  const std::string& key = {},
45  boost::optional<bool> default_value = {},
46  unsigned int flags = 0);
47  void add_float(const std::string& text, float* value_ptr,
48  const std::string& key = {},
49  boost::optional<float> default_value = {},
50  unsigned int flags = 0);
51  void add_int(const std::string& text, int* value_ptr,
52  const std::string& key = {},
53  boost::optional<int> default_value = {},
54  unsigned int flags = 0);
55  void add_rectf(const std::string& text, Rectf* value_ptr,
56  const std::string& key = {},
57  unsigned int flags = 0);
58  void add_worldmap_direction(const std::string& text, worldmap::Direction* value_ptr,
59  boost::optional<worldmap::Direction> default_value = {},
60  const std::string& key = {}, unsigned int flags = 0);
61  void add_direction(const std::string& text, Direction* value_ptr,
62  boost::optional<Direction> default_value = {},
63  const std::string& key = {}, unsigned int flags = 0);
64  void add_walk_mode(const std::string& text, WalkMode* value_ptr,
65  boost::optional<WalkMode> default_value = {},
66  const std::string& key = {}, unsigned int flags = 0);
67  void add_badguy(const std::string& text, std::vector<std::string>* value_ptr,
68  const std::string& key = {}, unsigned int flags = 0);
69  void add_color(const std::string& text, Color* value_ptr,
70  const std::string& key = {},
71  boost::optional<Color> default_value = {},
72  unsigned int flags = 0);
73  void add_rgba(const std::string& text, Color* value_ptr,
74  const std::string& key = {},
75  boost::optional<Color> default_value = {},
76  unsigned int flags = 0);
77  void add_rgb(const std::string& text, Color* value_ptr,
78  const std::string& key = {},
79  boost::optional<Color> default_value = {},
80  unsigned int flags = 0);
81  void add_remove();
82  void add_script(const std::string& text, std::string* value_ptr,
83  const std::string& key = {}, unsigned int flags = 0);
84  void add_text(const std::string& text, std::string* value_ptr,
85  const std::string& key = {},
86  boost::optional<std::string> default_value = {},
87  unsigned int flags = 0);
88  void add_translatable_text(const std::string& text, std::string* value_ptr,
89  const std::string& key = {},
90  boost::optional<std::string> default_value = {},
91  unsigned int flags = 0);
92  void add_string_select(const std::string& text, int* value_ptr, const std::vector<std::string>& select,
93  boost::optional<int> default_value = {},
94  const std::string& key = {}, unsigned int flags = 0);
95  void add_enum(const std::string& text, int* value_ptr,
96  const std::vector<std::string>& labels,
97  const std::vector<std::string>& symbols,
98  boost::optional<int> default_value = {},
99  const std::string& key = {}, unsigned int flags = 0);
100 
101  void add_sprite(const std::string& text, std::string* value_ptr,
102  const std::string& key = {},
103  boost::optional<std::string> default_value = {},
104  unsigned int flags = 0);
105  void add_surface(const std::string& text, std::string* value_ptr,
106  const std::string& key = {},
107  boost::optional<std::string> default_value = {},
108  unsigned int flags = 0);
109  void add_sound(const std::string& text, std::string* value_ptr,
110  const std::string& key = {},
111  boost::optional<std::string> default_value = {},
112  unsigned int flags = 0);
113  void add_music(const std::string& text, std::string* value_ptr,
114  const std::string& key = {},
115  boost::optional<std::string> default_value = {},
116  unsigned int flags = 0);
117 
118  void add_worldmap(const std::string& text, std::string* value_ptr, const std::string& key = {},
119  unsigned int flags = 0);
120  void add_level(const std::string& text, std::string* value_ptr, const std::string& basedir,
121  const std::string& key = {}, unsigned int flags = 0);
122  void add_tiles(const std::string& text, TileMap* value_ptr, const std::string& key = {},
123  unsigned int flags = 0);
124  void add_path(const std::string& text, Path* path, const std::string& key = {},
125  unsigned int flags = 0);
126  void add_path_ref(const std::string& text, const std::string& path_ref, const std::string& key = {},
127  unsigned int flags = 0);
128  void add_file(const std::string& text, std::string* value_ptr,
129  const std::string& key = {},
130  boost::optional<std::string> default_value = {},
131  const std::vector<std::string>& filter = {},
132  const std::string& basedir = {},
133  unsigned int flags = 0);
134  void add_sexp(const std::string& text, const std::string& key,
135  sexp::Value& value, unsigned int flags = 0);
136 
137  const std::vector<std::unique_ptr<ObjectOption> >& get_options() const { return m_options; }
138 
141  void reorder(const std::vector<std::string>& order);
142 
144  void remove(const std::string& key);
145 
146 private:
147  void add_option(std::unique_ptr<ObjectOption> option);
148 
149 private:
150  std::string m_name;
151  std::vector<std::unique_ptr<ObjectOption> > m_options;
152 
153 private:
154  ObjectSettings(const ObjectSettings&) = delete;
155  ObjectSettings& operator=(const ObjectSettings&) = delete;
156 };
157 
158 #endif
159 
160 /* EOF */
Definition: object_settings.hpp:35
Definition: path.hpp:44
Definition: object_settings.hpp:28
Definition: rectf.hpp:29
Definition: object_option.hpp:38
Definition: color.hpp:25
This class is responsible for drawing the level tiles.
Definition: tilemap.hpp:39