diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/app.cpp | 1 | ||||
-rw-r--r-- | editor/draw.cpp | 29 | ||||
-rw-r--r-- | editor/events.cpp | 1 | ||||
-rw-r--r-- | editor/imgui.cpp | 4 | ||||
-rw-r--r-- | editor/keys.hpp | 2 | ||||
-rw-r--r-- | editor/update.cpp | 2 |
6 files changed, 23 insertions, 16 deletions
diff --git a/editor/app.cpp b/editor/app.cpp index 4293708d..e2632f32 100644 --- a/editor/app.cpp +++ b/editor/app.cpp @@ -90,6 +90,7 @@ void app::reset_world(struct world&& w_) const auto pixel = cursor.pixel; cursor = {}; _character_id = 0; + _render_all_z_levels = true; auto& w = M->reset_world(std::move(w_)); w.collect(true); diff --git a/editor/draw.cpp b/editor/draw.cpp index adbc7b60..c01c149d 100644 --- a/editor/draw.cpp +++ b/editor/draw.cpp @@ -72,12 +72,13 @@ void app::draw_collision_boxes() auto& world = M->world(); auto& shader = M->shader(); - shader.set_tint({0, .5f, 1, 1}); - using rtree_type = std::decay_t<decltype(*world[chunk_coords{}].rtree())>; using rect_type = typename rtree_type::Rect; for (int8_t z = z_min; z <= z_max; z++) + { + shader.set_tint({0, .5f, 1, 1}); + for (int16_t y = miny; y <= maxy; y++) for (int16_t x = minx; x <= maxx; x++) { @@ -103,19 +104,18 @@ void app::draw_collision_boxes() } } - shader.set_tint({1, 0, 1, 1}); + shader.set_tint({1, 0, 1, 1}); - if (cursor.tile) - { - constexpr auto eps = 1e-6f; - constexpr auto m = TILE_SIZE2 * Vector2(1- eps, 1- eps); - const auto tile_ = Vector2(M->pixel_to_tile_(Vector2d(*cursor.pixel))); - const auto tile = *cursor.tile; - const auto curchunk = Vector2(tile.chunk()), curtile = Vector2(tile.local()); - const auto subpixel_ = Vector2(std::fmod(tile_[0], 1.f), std::fmod(tile_[1], 1.f)); - const auto subpixel = m * Vector2(curchunk[0] < 0 ? 1 + subpixel_[0] : subpixel_[0], - curchunk[1] < 0 ? 1 + subpixel_[1] : subpixel_[1]); - for (int8_t z = z_min; z <= z_max; z++) + if (cursor.tile) + { + constexpr auto eps = 1e-6f; + constexpr auto m = TILE_SIZE2 * Vector2(1- eps, 1- eps); + const auto tile_ = Vector2(M->pixel_to_tile_(Vector2d(*cursor.pixel))); + const auto tile = *cursor.tile; + const auto curchunk = Vector2(tile.chunk()), curtile = Vector2(tile.local()); + const auto subpixel_ = Vector2(std::fmod(tile_[0], 1.f), std::fmod(tile_[1], 1.f)); + const auto subpixel = m * Vector2(curchunk[0] < 0 ? 1 + subpixel_[0] : subpixel_[0], + curchunk[1] < 0 ? 1 + subpixel_[1] : subpixel_[1]); for (int16_t y = miny; y <= maxy; y++) for (int16_t x = minx; x <= maxx; x++) { @@ -144,6 +144,7 @@ void app::draw_collision_boxes() }); } } + } } shader.set_tint({1, 1, 1, 1}); diff --git a/editor/events.cpp b/editor/events.cpp index 275ddf57..18e3a8f6 100644 --- a/editor/events.cpp +++ b/editor/events.cpp @@ -136,6 +136,7 @@ auto app::resolve_keybinding(int k_, int mods_) -> std::tuple<key, int> case SDLK_4: return { key_mode_scenery, mods }; case SDLK_c | ALT: return { key_render_collision_boxes, mods }; case SDLK_l | ALT: return { key_render_clickables, mods }; + case SDLK_t: return { key_render_all_z_levels, mods }; case SDLK_F5: return { key_quicksave, mods }; case SDLK_F9: return { key_quickload, mods }; case SDLK_q | CTRL: return { key_quit, mods }; diff --git a/editor/imgui.cpp b/editor/imgui.cpp index b3863f06..32b85cb8 100644 --- a/editor/imgui.cpp +++ b/editor/imgui.cpp @@ -55,7 +55,7 @@ float app::draw_main_menu() const auto* ed_w = _editor.current_tile_editor(); bool b_none = mode == m::none, b_floor = mode == m::floor, b_walls = mode == m::walls, b_scenery = mode == m::scenery, b_collisions = _render_bboxes, - b_clickables = _render_clickables; + b_clickables = _render_clickables, b_all_z_levels = _render_all_z_levels; const bool b_rotate = ed_sc && ed_sc->is_anything_selected() || mode == editor_mode::walls && ed_w && ed_w->is_anything_selected(); ImGui::SeparatorText("Mode"); @@ -75,6 +75,8 @@ float app::draw_main_menu() do_key(key_render_collision_boxes); if (ImGui::MenuItem("Show clickables", "Alt+L", b_clickables)) do_key(key_render_clickables); + if (ImGui::MenuItem("Show all Z levels", "T", b_all_z_levels)) + do_key(key_render_all_z_levels); } main_menu_height = ImGui::GetContentRegionMax().y; diff --git a/editor/keys.hpp b/editor/keys.hpp index 902b6c95..56f4e59e 100644 --- a/editor/keys.hpp +++ b/editor/keys.hpp @@ -18,7 +18,7 @@ enum key : unsigned { key_NO_REPEAT, key_rotate_tile, key_mode_none, key_mode_floor, key_mode_walls, key_mode_scenery, - key_render_collision_boxes, key_render_clickables, + key_render_collision_boxes, key_render_clickables, key_render_all_z_levels, key_GLOBAL, key_new_file, key_quit, diff --git a/editor/update.cpp b/editor/update.cpp index f36b2905..2ab34ccb 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -160,6 +160,8 @@ void app::do_key(key k, int mods) return void(_render_bboxes = !_render_bboxes); case key_render_clickables: return void(_render_clickables = !_render_clickables); + case key_render_all_z_levels: + return void(_render_all_z_levels = !_render_all_z_levels); case key_quicksave: return do_quicksave(); case key_quickload: |