diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-13 05:28:36 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-13 05:28:36 +0100 |
commit | 07a9588271d30c69353dbea840eddeb519c472c5 (patch) | |
tree | aa4ea68c5eb43e07210c8ccf76dc78d2ca29be99 | |
parent | 728d34aaaa4c993d4b1f2c0f508f3a33aa069cb0 (diff) |
d
-rw-r--r-- | editor/draw.cpp | 21 | ||||
-rw-r--r-- | editor/events.cpp | 7 | ||||
-rw-r--r-- | editor/imgui-editors.cpp | 11 | ||||
-rw-r--r-- | editor/imgui.cpp | 19 | ||||
-rw-r--r-- | editor/inspect-draw.cpp | 1 | ||||
-rw-r--r-- | editor/save.cpp | 1 | ||||
-rw-r--r-- | editor/update.cpp | 29 |
7 files changed, 48 insertions, 41 deletions
diff --git a/editor/draw.cpp b/editor/draw.cpp index 47655647..db8f4a28 100644 --- a/editor/draw.cpp +++ b/editor/draw.cpp @@ -3,6 +3,7 @@ #include "floormat/settings.hpp" #include "shaders/shader.hpp" #include "main/clickable.hpp" +#include "editor.hpp" #include "src/anim-atlas.hpp" #include "draw/anim.hpp" #include "draw/wireframe-meshes.hpp" @@ -26,7 +27,7 @@ void app::draw_cursor() const auto inactive_color = 0xff00ffff_rgbaf; global_coords tile; - if (auto pos = _editor.mouse_drag_pos()) + if (auto pos = _editor->mouse_drag_pos()) tile = *pos; else if (cursor.tile) tile = *cursor.tile; @@ -42,13 +43,13 @@ void app::draw_cursor() shader.set_tint({1, 0, 0, 1}); - if (const auto* ed = _editor.current_ground_editor()) + if (const auto* ed = _editor->current_ground_editor()) { if (!ed->is_anything_selected()) shader.set_tint(inactive_color); draw(_wireframe->quad, TILE_SIZE2); } - else if (const auto* ed = _editor.current_wall_editor()) + else if (const auto* ed = _editor->current_wall_editor()) { if (!ed->is_anything_selected()) shader.set_tint(inactive_color); @@ -59,7 +60,7 @@ void app::draw_cursor() default: std::unreachable(); } } - else if (const auto* ed = _editor.current_scenery_editor()) + else if (const auto* ed = _editor->current_scenery_editor()) { if (!ed->is_anything_selected()) shader.set_tint(inactive_color); @@ -77,7 +78,7 @@ void app::draw_cursor() anim_mesh.draw(shader, *sel.atlas, sel.r, sel.frame, Vector3(pos), 1); } } - else if (const auto* vo = _editor.current_vobj_editor()) + else if (const auto* vo = _editor->current_vobj_editor()) { if (!vo->is_anything_selected()) shader.set_tint(inactive_color); @@ -202,10 +203,10 @@ void app::draw() do_lightmap_test(); if (_render_bboxes) draw_collision_boxes(); - if (_editor.current_ground_editor() && _editor.current_ground_editor()->is_anything_selected() || - _editor.current_wall_editor() && _editor.current_wall_editor()->is_anything_selected() || - _editor.current_scenery_editor() && _editor.current_scenery_editor()->is_anything_selected() || - _editor.current_vobj_editor() && _editor.current_vobj_editor()->is_anything_selected()) + if (_editor->current_ground_editor() && _editor->current_ground_editor()->is_anything_selected() || + _editor->current_wall_editor() && _editor->current_wall_editor()->is_anything_selected() || + _editor->current_scenery_editor() && _editor->current_scenery_editor()->is_anything_selected() || + _editor->current_vobj_editor() && _editor->current_vobj_editor()->is_anything_selected()) draw_cursor(); draw_ui(); render_menu(); @@ -215,7 +216,7 @@ void app::draw() clickable* app::find_clickable_scenery(const Optional<Vector2i>& pixel) { - if (!pixel || _editor.mode() != editor_mode::none) + if (!pixel || _editor->mode() != editor_mode::none) return nullptr; clickable* item = nullptr; diff --git a/editor/events.cpp b/editor/events.cpp index 8823e7be..1ec52172 100644 --- a/editor/events.cpp +++ b/editor/events.cpp @@ -4,6 +4,7 @@ #include "floormat/events.hpp" #include "src/world.hpp" #include "keys.hpp" +#include "editor.hpp" #include <tuple> #include <Magnum/Platform/Sdl2Application.h> #include <Magnum/ImGuiIntegration/Context.hpp> @@ -60,7 +61,7 @@ void app::on_mouse_move(const mouse_move_event& event) noexcept if ((cursor.in_imgui = _imgui->handleMouseMoveEvent(e))) void(); - else if (_editor.mode() == editor_mode::tests && tests_handle_mouse_move(event)) + else if (_editor->mode() == editor_mode::tests && tests_handle_mouse_move(event)) void(); update_cursor_tile(event.position); do_mouse_move(fixup_mods(event.mods)); @@ -83,7 +84,7 @@ void app::on_mouse_up_down(const mouse_button_event& event, bool is_down) noexce if ((cursor.in_imgui = is_down ? _imgui->handleMousePressEvent(e) : _imgui->handleMouseReleaseEvent(e))) void(); - else if (_editor.mode() == editor_mode::tests && tests_handle_mouse_click(event, is_down)) + else if (_editor->mode() == editor_mode::tests && tests_handle_mouse_click(event, is_down)) void(); else do_mouse_up_down(event.button, is_down, fixup_mods(event.mods)); @@ -187,7 +188,7 @@ void app::on_key_up_down(const key_event& event, bool is_down) noexcept static_assert(key_GLOBAL >= key_NO_REPEAT); if (x == key_COUNT && (is_down ? _imgui->handleKeyPressEvent(e) : _imgui->handleKeyReleaseEvent(e)) || - (x == key_COUNT || x == key_escape) && _editor.mode() == editor_mode::tests && tests_handle_key(event, is_down)) + (x == key_COUNT || x == key_escape) && _editor->mode() == editor_mode::tests && tests_handle_key(event, is_down)) clear_non_global_keys(); else if (x >= key_NO_REPEAT) is_down && !event.is_repeated ? do_key(x, mods) : void(); diff --git a/editor/imgui-editors.cpp b/editor/imgui-editors.cpp index e2f4b5c1..0e098ae1 100644 --- a/editor/imgui-editors.cpp +++ b/editor/imgui-editors.cpp @@ -4,6 +4,7 @@ #include "src/anim-atlas.hpp" #include "src/ground-atlas.hpp" #include "src/wall-atlas.hpp" +#include "editor.hpp" #include "loader/loader.hpp" #include "floormat/main.hpp" #include <Magnum/Math/Color.h> @@ -229,10 +230,10 @@ template void impl_draw_editor_scenery_pane(wall_editor&, Vector2); void app::draw_editor_pane(float main_menu_height) { - auto* ed = _editor.current_ground_editor(); - auto* wa = _editor.current_wall_editor(); - auto* sc = _editor.current_scenery_editor(); - auto* vo = _editor.current_vobj_editor(); + auto* ed = _editor->current_ground_editor(); + auto* wa = _editor->current_wall_editor(); + auto* sc = _editor->current_scenery_editor(); + auto* vo = _editor->current_vobj_editor(); const auto window_size = M->window_size(); const auto dpi = M->dpi_scale(); @@ -275,7 +276,7 @@ void app::draw_editor_pane(float main_menu_height) impl_draw_editor_scenery_pane<vobj_editor>(*vo, dpi); else if (wa) impl_draw_editor_scenery_pane<wall_editor>(*wa, dpi); - else if (_editor.mode() == editor_mode::tests) + else if (_editor->mode() == editor_mode::tests) draw_tests_pane(); } } diff --git a/editor/imgui.cpp b/editor/imgui.cpp index 3021a338..2b768948 100644 --- a/editor/imgui.cpp +++ b/editor/imgui.cpp @@ -5,6 +5,7 @@ #include "src/anim-atlas.hpp" #include "shaders/shader.hpp" #include "shaders/lightmap.hpp" +#include "editor.hpp" #include "main/clickable.hpp" #include "imgui-raii.hpp" #include "src/light.hpp" @@ -61,11 +62,11 @@ float app::draw_main_menu() } if (auto b = begin_menu("Editor")) { - auto mode = _editor.mode(); + auto mode = _editor->mode(); using m = editor_mode; - const auto* ed_sc = _editor.current_scenery_editor(); - const auto* ed_gr = _editor.current_ground_editor(); - const auto* ed_wa = _editor.current_wall_editor(); + const auto* ed_sc = _editor->current_scenery_editor(); + const auto* ed_gr = _editor->current_ground_editor(); + const auto* ed_wa = _editor->current_wall_editor(); const bool b_rotate = ed_sc && ed_sc->is_anything_selected() || ed_gr && ed_gr->is_anything_selected() || ed_wa && ed_wa->is_anything_selected(); @@ -124,7 +125,7 @@ void app::draw_ui() draw_clickables(); if (_render_vobjs) draw_light_info(); - if (_editor.mode() == editor_mode::tests) + if (_editor->mode() == editor_mode::tests) draw_tests_overlay(); const float main_menu_height = draw_main_menu(); @@ -132,14 +133,14 @@ void app::draw_ui() draw_lightmap_test(main_menu_height); - if (_editor.current_ground_editor() || _editor.current_wall_editor() || - _editor.current_scenery_editor() || - _editor.current_vobj_editor() || _editor.mode() == editor_mode::tests) + if (_editor->current_ground_editor() || _editor->current_wall_editor() || + _editor->current_scenery_editor() || + _editor->current_vobj_editor() || _editor->mode() == editor_mode::tests) draw_editor_pane(main_menu_height); draw_fps(); draw_tile_under_cursor(); - if (_editor.mode() == editor_mode::none) + if (_editor->mode() == editor_mode::none) draw_inspector(); draw_z_level(); do_popup_menu(); diff --git a/editor/inspect-draw.cpp b/editor/inspect-draw.cpp index 48f49ca1..bc3237a5 100644 --- a/editor/inspect-draw.cpp +++ b/editor/inspect-draw.cpp @@ -4,6 +4,7 @@ #include "main/clickable.hpp" #include "floormat/main.hpp" #include "src/world.hpp" +#include "src/object.hpp" #include "src/anim-atlas.hpp" #include "imgui-raii.hpp" #include "loader/loader.hpp" diff --git a/editor/save.cpp b/editor/save.cpp index a665cada..e9ab39a8 100644 --- a/editor/save.cpp +++ b/editor/save.cpp @@ -2,6 +2,7 @@ #include "floormat/main.hpp" #include "src/world.hpp" #include "loader/loader.hpp" +#include <Corrade/Containers/String.h> #include <Corrade/Utility/Path.h> namespace floormat { diff --git a/editor/update.cpp b/editor/update.cpp index cde6059a..5d4c75cb 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -3,6 +3,7 @@ #include "src/ground-atlas.hpp" #include "src/anim-atlas.hpp" #include "main/clickable.hpp" +#include "editor.hpp" #include "floormat/events.hpp" #include "floormat/main.hpp" #include "src/critter.hpp" @@ -32,7 +33,7 @@ void app::maybe_initialize_chunk([[maybe_unused]] const chunk_coords_& pos, [[ma void app::do_mouse_move(int mods) { if (cursor.tile && !cursor.in_imgui) - _editor.on_mouse_move(M->world(), *cursor.tile, mods); + _editor->on_mouse_move(M->world(), *cursor.tile, mods); } void app::do_mouse_up_down(uint8_t button, bool is_down, int mods) @@ -45,7 +46,7 @@ void app::do_mouse_up_down(uint8_t button, bool is_down, int mods) if (is_down && cursor.tile && !cursor.in_imgui) { - switch (_editor.mode()) + switch (_editor->mode()) { default: break; @@ -75,17 +76,17 @@ void app::do_mouse_up_down(uint8_t button, bool is_down, int mods) switch (button) { case mouse_button_left: - return _editor.on_click(w, pos, mods, editor::button::place); + return _editor->on_click(w, pos, mods, editor::button::place); case mouse_button_middle: - return _editor.on_click(w, pos, mods, editor::button::remove); + return _editor->on_click(w, pos, mods, editor::button::remove); case mouse_button_right: - return _editor.clear_selection(); + return _editor->clear_selection(); default: break; } break; } } - _editor.on_release(); + _editor->on_release(); } void app::do_mouse_scroll(int offset) @@ -99,9 +100,9 @@ void app::do_mouse_scroll(int offset) void app::do_rotate(bool backward) { - if (auto* ed = _editor.current_wall_editor()) + if (auto* ed = _editor->current_wall_editor()) ed->toggle_rotation(); - else if (auto* ed = _editor.current_scenery_editor()) + else if (auto* ed = _editor->current_scenery_editor()) { if (ed->is_anything_selected()) backward ? ed->prev_rotation() : ed->next_rotation(); @@ -117,20 +118,20 @@ void app::do_rotate(bool backward) void app::do_set_mode(editor_mode mode) { - if (mode != _editor.mode()) + if (mode != _editor->mode()) kill_popups(false); - _editor.set_mode(mode); + _editor->set_mode(mode); } void app::do_escape() { - if (auto* ed = _editor.current_ground_editor()) + if (auto* ed = _editor->current_ground_editor()) ed->clear_selection(); - if (auto* ed = _editor.current_wall_editor()) + if (auto* ed = _editor->current_wall_editor()) ed->clear_selection(); - if (auto* sc = _editor.current_scenery_editor()) + if (auto* sc = _editor->current_scenery_editor()) sc->clear_selection(); - if (auto* vo = _editor.current_vobj_editor()) + if (auto* vo = _editor->current_vobj_editor()) vo->clear_selection(); kill_popups(false); } |