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 #include <algorithm>
23 
24 #include "editor/object_option.hpp"
25 #include "object/path_walker.hpp"
26 
27 class Color;
28 enum class Direction;
29 class GameObject;
30 class PathObject;
31 enum class WalkMode;
32 namespace worldmap {
33 enum class Direction;
34 } // namespace worldmap
35 namespace sexp {
36 class Value;
37 } // namespace sexp
38 
39 class ObjectSettings final
40 {
41 public:
42  ObjectSettings(const std::string& name);
43  ObjectSettings(ObjectSettings&&) = default;
44 
45  const std::string& get_name() const { return m_name; }
46 
47  void add_bool(const std::string& text, bool* value_ptr,
48  const std::string& key = {},
49  const std::optional<bool>& default_value = {},
50  unsigned int flags = 0);
51  void add_float(const std::string& text, float* value_ptr,
52  const std::string& key = {},
53  const std::optional<float>& default_value = {},
54  unsigned int flags = 0);
55  void add_int(const std::string& text, int* value_ptr,
56  const std::string& key = {},
57  const std::optional<int>& default_value = {},
58  unsigned int flags = 0);
59  void add_label(const std::string& text, unsigned int flags = 0);
60  void add_rectf(const std::string& text, Rectf* value_ptr,
61  const std::string& key = {},
62  unsigned int flags = 0);
63  void add_worldmap_direction(const std::string& text, worldmap::Direction* value_ptr,
64  std::optional<worldmap::Direction> default_value = {},
65  const std::string& key = {}, unsigned int flags = 0);
66  void add_direction(const std::string& text, Direction* value_ptr,
67  std::vector<Direction> possible_directions = {},
68  const std::string& key = {}, unsigned int flags = 0);
69  void add_walk_mode(const std::string& text, WalkMode* value_ptr,
70  const std::optional<WalkMode>& default_value = {},
71  const std::string& key = {}, unsigned int flags = 0);
72  void add_objects(const std::string& text, std::vector<std::unique_ptr<GameObject>>* value_ptr,
73  uint8_t get_objects_param = 0, const std::function<void (std::unique_ptr<GameObject>)>& add_object_func = {},
74  const std::string& key = {}, unsigned int flags = 0);
75  void add_color(const std::string& text, Color* value_ptr,
76  const std::string& key = {},
77  const std::optional<Color>& default_value = {},
78  unsigned int flags = 0);
79  void add_rgba(const std::string& text, Color* value_ptr,
80  const std::string& key = {},
81  const std::optional<Color>& default_value = {},
82  unsigned int flags = 0);
83  void add_rgb(const std::string& text, Color* value_ptr,
84  const std::string& key = {},
85  const std::optional<Color>& default_value = {},
86  unsigned int flags = 0);
87  void add_remove();
88  void add_script(const std::string& text, std::string* value_ptr,
89  const std::string& key = {}, unsigned int flags = 0);
90  void add_text(const std::string& text, std::string* value_ptr,
91  const std::string& key = {},
92  const std::optional<std::string>& default_value = {},
93  unsigned int flags = 0);
94  void add_translatable_text(const std::string& text, std::string* value_ptr,
95  const std::string& key = {},
96  const std::optional<std::string>& default_value = {},
97  unsigned int flags = 0);
98  void add_multiline_text(const std::string& text, std::string* value_ptr,
99  const std::string& key = {},
100  const std::optional<std::string>& default_value = {},
101  unsigned int flags = 0);
102  void add_multiline_translatable_text(const std::string& text, std::string* value_ptr,
103  const std::string& key = {},
104  const std::optional<std::string>& default_value = {},
105  unsigned int flags = 0);
106  void add_string_select(const std::string& text, int* value_ptr, const std::vector<std::string>& select,
107  const std::optional<int>& default_value = {},
108  const std::string& key = {}, unsigned int flags = 0);
109  void add_enum(const std::string& text, int* value_ptr,
110  const std::vector<std::string>& labels,
111  const std::vector<std::string>& symbols,
112  const std::optional<int>& default_value = {},
113  const std::string& key = {}, unsigned int flags = 0);
114 
115  void add_sprite(const std::string& text, std::string* value_ptr,
116  const std::string& key = {},
117  std::optional<std::string> default_value = {},
118  unsigned int flags = 0);
119  void add_surface(const std::string& text, std::string* value_ptr,
120  const std::string& key = {},
121  std::optional<std::string> default_value = {},
122  unsigned int flags = 0);
123  void add_sound(const std::string& text, std::string* value_ptr,
124  const std::string& key = {},
125  std::optional<std::string> default_value = {},
126  unsigned int flags = 0);
127  void add_music(const std::string& text, std::string* value_ptr,
128  const std::string& key = {},
129  std::optional<std::string> default_value = {},
130  unsigned int flags = 0);
131 
132  void add_worldmap(const std::string& text, std::string* value_ptr, const std::string& key = {},
133  unsigned int flags = 0);
134  void add_level(const std::string& text, std::string* value_ptr, const std::string& basedir,
135  const std::string& key = {}, unsigned int flags = 0);
136  void add_tiles(const std::string& text, TileMap* value_ptr, const std::string& key = {},
137  unsigned int flags = 0);
138  void add_path(const std::string& text, Path* path, const std::string& key = {},
139  unsigned int flags = 0);
140  void add_path_ref(const std::string& text, PathObject& target, const std::string& path_ref,
141  const std::string& key = {}, unsigned int flags = 0);
142  void add_file(const std::string& text, std::string* value_ptr,
143  const std::string& key = {},
144  const std::optional<std::string>& default_value = {},
145  const std::vector<std::string>& filter = {},
146  const std::string& basedir = {},
147  bool path_relative_to_basedir = true,
148  unsigned int flags = 0);
149  void add_sexp(const std::string& text, const std::string& key,
150  sexp::Value& value, unsigned int flags = 0);
151  void add_string_array(const std::string& text, const std::string& key, std::vector<std::string>& items);
152  void add_test_from_here();
153  void add_particle_editor();
154  void add_path_handle(const std::string& text, PathWalker::Handle& handle,
155  const std::string& key = {}, unsigned int flags = 0);
156  void add_list(const std::string& text, const std::string& key, const std::vector<std::string>& items, std::string* value_ptr);
157 
158  // VERY UNSTABLE - use with care ~ Semphris (author of that option)
159  void add_button(const std::string& text, const std::function<void()>& callback);
160 
161  const std::vector<std::unique_ptr<BaseObjectOption> >& get_options() const { return m_options; }
162 
165  void reorder(const std::vector<std::string>& order);
166 
168  void remove(const std::string& key);
169 
170 private:
171  void add_option(std::unique_ptr<BaseObjectOption> option);
172 
173 private:
174  std::string m_name;
175  std::vector<std::unique_ptr<BaseObjectOption> > m_options;
176 
177 private:
178  ObjectSettings(const ObjectSettings&) = delete;
179  ObjectSettings& operator=(const ObjectSettings&) = delete;
180 };
181 
182 #endif
183 
184 /* EOF */
Helper class that allows to displace a handle on an object.
Definition: path_walker.hpp:35
Definition: object_settings.hpp:39
Definition: path.hpp:48
Definition: object_settings.hpp:32
Definition: rectf.hpp:31
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
Definition: object_option.hpp:39
Definition: color.hpp:26
A base class for all objects that contain, or make use of a path.
Definition: path_object.hpp:36
This class is responsible for managing an array of tiles.
Definition: tilemap.hpp:49