17 #ifndef HEADER_SUPERTUX_EDITOR_OBJECT_OPTION_HPP 18 #define HEADER_SUPERTUX_EDITOR_OBJECT_OPTION_HPP 24 #include <sexp/value.hpp> 26 #include "gui/menu_action.hpp" 27 #include "object/path_walker.hpp" 28 #include "video/color.hpp" 30 enum ObjectOptionFlag {
33 OPTION_HIDDEN = (1 << 0),
36 OPTION_TRANSLATABLE = (1 << 1)
55 BaseObjectOption(
const std::string& text,
const std::string& key,
unsigned int flags);
58 virtual void save(
Writer& write)
const = 0;
59 virtual std::string to_string()
const = 0;
60 virtual void add_to_menu(
Menu& menu)
const = 0;
62 const std::string& get_key()
const {
return m_key; }
63 const std::string& get_text()
const {
return m_text; }
64 unsigned int get_flags()
const {
return m_flags; }
67 const std::string m_text;
68 const std::string m_key;
69 const unsigned int m_flags;
76 template <
typename T =
void>
80 ObjectOption(
const std::string& text,
const std::string& key,
unsigned int flags, T* pointer =
nullptr);
83 virtual T* get_value()
const {
return m_value_pointer; }
86 T*
const m_value_pointer;
96 BoolObjectOption(
const std::string& text,
bool* pointer,
const std::string& key,
97 std::optional<bool> default_value,
100 virtual void save(
Writer& write)
const override;
101 virtual std::string to_string()
const override;
102 virtual void add_to_menu(
Menu& menu)
const override;
105 const std::optional<bool> m_default_value;
115 IntObjectOption(
const std::string& text,
int* pointer,
const std::string& key,
116 std::optional<int> default_value,
119 virtual void save(
Writer& write)
const override;
120 virtual std::string to_string()
const override;
121 virtual void add_to_menu(
Menu& menu)
const override;
124 const std::optional<int> m_default_value;
137 virtual void save(
Writer& write)
const override;
138 virtual std::string to_string()
const override;
139 virtual void add_to_menu(
Menu& menu)
const override;
152 virtual void save(
Writer& write)
const override;
153 virtual std::string to_string()
const override;
154 virtual void add_to_menu(
Menu& menu)
const override;
168 FloatObjectOption(
const std::string& text,
float* pointer,
const std::string& key,
169 std::optional<float> default_value,
172 virtual void save(
Writer& write)
const override;
173 virtual std::string to_string()
const override;
174 virtual void add_to_menu(
Menu& menu)
const override;
177 const std::optional<float> m_default_value;
187 StringObjectOption(
const std::string& text, std::string* pointer,
const std::string& key,
188 std::optional<std::string> default_value,
191 virtual void save(
Writer& write)
const override;
192 virtual std::string to_string()
const override;
193 virtual void add_to_menu(
Menu& menu)
const override;
196 std::optional<std::string> m_default_value;
207 std::optional<std::string> default_value,
210 virtual void save(
Writer& write)
const override;
211 virtual std::string to_string()
const override;
212 virtual void add_to_menu(
Menu& menu)
const override;
215 std::optional<std::string> m_default_value;
226 std::optional<int> default_value,
227 const std::string& key,
unsigned int flags);
229 virtual void save(
Writer& write)
const override;
230 virtual std::string to_string()
const override;
231 virtual void add_to_menu(
Menu& menu)
const override;
234 const std::vector<std::string> m_select;
235 const std::optional<int> m_default_value;
246 const std::vector<std::string>& labels,
247 const std::vector<std::string>& symbols,
248 std::optional<int> default_value,
249 const std::string& key,
unsigned int flags);
251 virtual void save(
Writer& write)
const override;
252 virtual std::string to_string()
const override;
253 virtual void add_to_menu(
Menu& menu)
const override;
256 const std::vector<std::string> m_labels;
257 const std::vector<std::string> m_symbols;
258 const std::optional<int> m_default_value;
268 ScriptObjectOption(
const std::string& text, std::string* pointer,
const std::string& key,
271 virtual void save(
Writer& write)
const override;
272 virtual std::string to_string()
const override;
273 virtual void add_to_menu(
Menu& menu)
const override;
284 std::optional<std::string> default_value,
285 const std::string& key,
286 std::vector<std::string> filter,
287 const std::string& basedir,
288 bool path_relative_to_basedir,
291 virtual void save(
Writer& write)
const override;
292 virtual std::string to_string()
const override;
293 virtual void add_to_menu(
Menu& menu)
const override;
296 std::optional<std::string> m_default_value;
297 const std::vector<std::string> m_filter;
298 std::string m_basedir;
299 bool m_path_relative_to_basedir;
310 std::optional<Color> default_value,
bool use_alpha,
313 virtual void save(
Writer& write)
const override;
314 virtual std::string to_string()
const override;
315 virtual void add_to_menu(
Menu& menu)
const override;
318 const std::optional<Color> m_default_value;
330 uint8_t get_objects_param,
const std::function<
void (std::unique_ptr<GameObject>)>& add_object_func,
331 const std::string& key,
unsigned int flags);
333 virtual void save(
Writer& write)
const override;
334 virtual std::string to_string()
const override;
335 virtual void add_to_menu(
Menu& menu)
const override;
338 uint8_t m_get_objects_param;
339 const std::function<void (std::unique_ptr<GameObject>)> m_add_object_function;
352 virtual void save(
Writer& write)
const override;
353 virtual std::string to_string()
const override;
354 virtual void add_to_menu(
Menu& menu)
const override;
370 virtual void save(
Writer& write)
const override;
371 virtual std::string to_string()
const override;
372 virtual void add_to_menu(
Menu& menu)
const override;
383 const std::string& key,
unsigned int flags);
385 virtual void save(
Writer& write)
const override;
386 virtual std::string to_string()
const override;
387 virtual void add_to_menu(
Menu& menu)
const override;
390 std::string m_path_ref;
400 SExpObjectOption(
const std::string& text,
const std::string& key, sexp::Value& value,
unsigned int flags);
402 virtual void save(
Writer& write)
const override;
403 virtual std::string to_string()
const override;
404 virtual void add_to_menu(
Menu& menu)
const override;
415 const std::string& key,
unsigned int flags);
417 virtual void save(
Writer& write)
const override;
418 virtual std::string to_string()
const override;
419 virtual void add_to_menu(
Menu& menu)
const override;
434 virtual void save(
Writer& write)
const override {}
435 virtual std::string to_string()
const override;
436 virtual void add_to_menu(
Menu& menu)
const override;
448 virtual void save(
Writer& write)
const override {}
449 virtual std::string to_string()
const override;
450 virtual void add_to_menu(
Menu& menu)
const override;
462 virtual void save(
Writer& write)
const override {}
463 virtual std::string to_string()
const override;
464 virtual void add_to_menu(
Menu& menu)
const override;
474 ButtonOption(
const std::string& text, std::function<
void()> callback);
476 virtual void save(
Writer& write)
const override {}
477 virtual std::string to_string()
const override;
478 virtual void add_to_menu(
Menu& menu)
const override;
481 std::function<void()> m_callback;
491 StringArrayOption(
const std::string& text,
const std::string& key, std::vector<std::string>& items);
493 virtual void save(
Writer& write)
const override;
494 virtual std::string to_string()
const override {
return "text-area"; }
495 virtual void add_to_menu(
Menu& menu)
const override;
498 std::vector<std::string>& m_items;
508 ListOption(
const std::string& text,
const std::string& key,
const std::vector<std::string>& items, std::string* value_ptr);
510 virtual void save(
Writer& write)
const override;
511 virtual std::string to_string()
const override {
return *m_value_pointer; }
512 virtual void add_to_menu(
Menu& menu)
const override;
515 const std::vector<std::string>& m_items;
526 std::vector<Direction> possible_directions,
527 const std::string& key,
unsigned int flags);
529 virtual void save(
Writer& write)
const override;
530 virtual std::string to_string()
const override;
531 virtual void add_to_menu(
Menu& menu)
const override;
534 std::vector<Direction> m_possible_directions;
Definition: object_option.hpp:203
Definition: object_option.hpp:222
Definition: object_option.hpp:505
Definition: object_option.hpp:265
Definition: object_option.hpp:112
Definition: object_option.hpp:77
Definition: object_option.hpp:429
Definition: object_option.hpp:93
Definition: object_option.hpp:165
Definition: object_option.hpp:457
Helper class that allows to displace a handle on an object.
Definition: path_walker.hpp:35
Definition: object_option.hpp:306
Definition: object_option.hpp:146
Definition: object_option.hpp:379
Definition: object_option.hpp:184
Definition: object_option.hpp:522
Definition: object_option.hpp:52
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
Definition: object_option.hpp:364
Definition: object_option.hpp:397
Definition: object_option.hpp:346
Definition: object_option.hpp:411
Definition: object_option.hpp:488
Definition: object_option.hpp:280
Definition: object_option.hpp:39
Definition: object_option.hpp:326
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
Definition: object_option.hpp:242
Definition: object_option.hpp:443
Definition: object_option.hpp:131
Definition: writer.cpp:23