17 #ifndef HEADER_SUPERTUX_EDITOR_EDITOR_HPP 18 #define HEADER_SUPERTUX_EDITOR_EDITOR_HPP 26 #include "editor/overlay_widget.hpp" 27 #include "editor/tilebox.hpp" 28 #include "editor/toolbox_widget.hpp" 29 #include "editor/layers_widget.hpp" 30 #include "editor/scroller_widget.hpp" 31 #include "supertux/screen.hpp" 32 #include "supertux/world.hpp" 33 #include "util/currenton.hpp" 34 #include "util/file_system.hpp" 35 #include "util/log.hpp" 36 #include "util/string_util.hpp" 37 #include "video/surface_ptr.hpp" 53 static bool is_active();
55 static PHYSFS_EnumerateCallbackResult foreach_recurse(
void *data,
60 static bool is_autosave_file(
const std::string& filename) {
61 return StringUtil::has_suffix(filename,
"~");
63 static std::string get_levelname_from_autosave(
const std::string& filename) {
64 return is_autosave_file(filename) ? filename.substr(0, filename.size() - 1) : filename;
66 static std::string get_autosave_from_levelname(
const std::string& filename) {
67 return is_autosave_file(filename) ? filename : filename +
"~";
71 static bool s_resaving_in_progress;
80 virtual void setup()
override;
81 virtual void leave()
override;
85 void event(
const SDL_Event& ev);
88 void disable_keyboard() { m_enabled =
false; }
90 Level* get_level()
const {
return m_level.get(); }
92 void set_world(std::unique_ptr<World> w);
93 World* get_world()
const {
return m_world.get(); }
95 TileSet* get_tileset()
const {
return m_tileset; }
96 TileSelection* get_tiles()
const {
return m_toolbox_widget->get_tilebox().get_tiles(); }
97 std::string get_tileselect_object()
const {
return m_toolbox_widget->get_tilebox().get_object(); }
99 EditorTilebox::InputType get_tileselect_input_type()
const {
return m_toolbox_widget->get_tilebox().get_input_type(); }
101 bool has_active_toolbox_tip()
const {
return m_toolbox_widget->get_tilebox().has_active_object_tip(); }
103 int get_tileselect_select_mode()
const;
104 int get_tileselect_move_mode()
const;
106 const std::string& get_levelfile()
const {
return m_levelfile; }
108 void set_level(
const std::string& levelfile_) {
109 m_levelfile = levelfile_;
110 m_reload_request =
true;
113 std::string get_level_directory()
const;
115 void open_level_directory();
117 bool is_testing_level()
const {
return m_leveltested; }
119 void remove_autosave_file();
124 void check_deprecated_tiles(
bool focus =
false);
125 bool has_deprecated_tiles()
const {
return m_has_deprecated_tiles; }
131 void check_unsaved_changes(
const std::function<
void ()>& action);
133 void load_sector(
const std::string& name);
134 void delete_current_sector();
136 void update_node_iterators();
138 void delete_markers();
141 void select_tilegroup(
int id);
142 const std::vector<Tilegroup>& get_tilegroups()
const;
143 void change_tileset();
145 void select_objectgroup(
int id);
146 const std::vector<ObjectGroup>& get_objectgroups()
const;
148 void scroll(
const Vector& velocity);
150 bool is_level_loaded()
const {
return m_levelloaded; }
153 m_overlay_widget->edit_path(path, new_marked_object);
156 void add_layer(
GameObject* layer) { m_layers_widget->add_layer(layer); }
158 TileMap* get_selected_tilemap()
const {
return m_layers_widget->get_selected_tilemap(); }
160 Sector* get_sector() {
return m_sector; }
162 void retoggle_undo_tracking();
163 void undo_stack_cleanup();
171 void set_sector(
Sector* sector);
172 void set_level(std::unique_ptr<Level> level,
bool reset =
true);
181 void save_level(
const std::string& filename =
"",
bool switch_file =
false);
182 void test_level(
const std::optional<std::pair<std::string, Vector>>& test_pos);
183 void update_keyboard(
const Controller& controller);
185 void keep_camera_in_bounds();
187 void post_undo_redo_actions();
190 std::unique_ptr<Level> m_level;
191 std::unique_ptr<World> m_world;
193 std::string m_levelfile;
194 std::string m_autosave_levelfile;
198 bool m_newlevel_request;
199 bool m_reload_request;
200 bool m_reactivate_request;
201 bool m_deactivate_request;
203 std::string m_save_request_filename;
204 bool m_save_request_switch;
206 bool m_particle_editor_request;
207 std::optional<std::pair<std::string, Vector>> m_test_pos;
209 std::string* m_particle_editor_filename;
219 bool m_has_deprecated_tiles;
221 std::vector<std::unique_ptr<Widget> > m_widgets;
229 SurfacePtr m_bgr_surface;
231 float m_time_since_last_save;
233 float m_scroll_speed;
Definition: controller.hpp:57
void convert_tiles_by_file(const std::string &file)
Convert tiles on every tilemap in the level, according to a tile conversion file. ...
Definition: editor.cpp:722
Abstract base class for code the MainLoop runs exclusively and full-screen.
Definition: screen.hpp:31
void check_save_prerequisites(const std::function< void()> &callback) const
Checks whether the level can be saved and does not contain obvious issues (currently: check if main s...
Definition: editor.cpp:992
Represents one of (potentially) multiple, separate parts of a Level.
Definition: sector.hpp:61
virtual void leave() override
gets called when the current screen is temporarily suspended
Definition: editor.cpp:781
A 'Currenton' allows access to the currently active instance of a class via the static current() func...
Definition: currenton.hpp:30
virtual void setup() override
gets called before this screen gets activated (which is at least once before the first draw or update...
Definition: editor.cpp:789
Represents a collection of Sectors running in a single GameSession.
Definition: level.hpp:30
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
Definition: tile_selection.hpp:24
Definition: compositor.hpp:29
Definition: integration.hpp:26
Definition: savegame.hpp:69
Definition: object_group.hpp:27
Definition: editor.hpp:49
virtual void draw(Compositor &) override
gets called once per frame.
Definition: editor.cpp:151
This class is responsible for managing an array of tiles.
Definition: tilemap.hpp:49
virtual void update(float dt_sec, const Controller &controller) override
gets called for once (per logical) frame.
Definition: editor.cpp:203
Definition: tile_set.hpp:44
Definition: path_gameobject.hpp:32
virtual IntegrationStatus get_status() const override
Gives details about what the user is doing right now.
Definition: editor.cpp:1105