From 321b394c397f826dbbda6e617aece10e732daadc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 24 Feb 2023 10:54:58 +0100 Subject: fix (?) wrong global_coords unsigned offset --- editor/draw.cpp | 2 +- editor/imgui.cpp | 10 ++++------ editor/update.cpp | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'editor') diff --git a/editor/draw.cpp b/editor/draw.cpp index 32319c1b..baf7f135 100644 --- a/editor/draw.cpp +++ b/editor/draw.cpp @@ -135,7 +135,7 @@ clickable_scenery* app::find_clickable_scenery(const Optional& pixel_) item = &c; } } - if (item && item->item.can_activate(item->atlas)) + if (item) return item; else return nullptr; diff --git a/editor/imgui.cpp b/editor/imgui.cpp index 6126dda0..4aca859e 100644 --- a/editor/imgui.cpp +++ b/editor/imgui.cpp @@ -5,6 +5,7 @@ #include "world.hpp" #include "scenery.hpp" #include "inspect.hpp" +#include "main/clickable.hpp" #include namespace floormat { @@ -155,12 +156,9 @@ void app::draw_inspector() auto b = push_id("inspector"); auto& w = M->world(); - if (cursor.tile) - { - auto [c, t] = w[*cursor.tile]; - if (auto s = t.scenery()) - tile = *cursor.tile; - } + if (cursor.pixel) + if (const auto* sc = find_clickable_scenery(cursor.pixel)) + tile = {InPlaceInit, sc->chunk, sc->pos}; if (tile) { auto [c, t] = w[*tile]; diff --git a/editor/update.cpp b/editor/update.cpp index 3c8f45fe..161f6869 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -58,7 +58,7 @@ void app::do_mouse_up_down(std::uint8_t button, bool is_down, int mods) default: case editor_mode::none: if (button == mouse_button_left) - if (auto* s = find_clickable_scenery(*cursor.pixel)) + if (auto* s = find_clickable_scenery(*cursor.pixel); s && s->item.can_activate(s->atlas)) return (void)s->item.activate(s->atlas); break; case editor_mode::floor: @@ -164,7 +164,7 @@ void app::update(float dt) do_camera(dt, keys, get_key_modifiers()); clear_non_repeated_keys(); - if ([[maybe_unused]] clickable_scenery* s = find_clickable_scenery(cursor.pixel)) + if (auto* s = find_clickable_scenery(cursor.pixel); s && s->item.can_activate(s->atlas)) M->set_cursor(std::uint32_t(Cursor::Hand)); else set_cursor_from_imgui(); -- cgit v1.2.3