diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2023-02-24 10:54:58 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-02-24 11:00:57 +0100 |
| commit | 321b394c397f826dbbda6e617aece10e732daadc (patch) | |
| tree | 224da7e085ced9773ab86128b9249a01c7186623 /editor | |
| parent | e9311fe8a12d7834b0d910edd65eacc5e732a0ff (diff) | |
fix (?) wrong global_coords unsigned offset
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/draw.cpp | 2 | ||||
| -rw-r--r-- | editor/imgui.cpp | 10 | ||||
| -rw-r--r-- | editor/update.cpp | 4 |
3 files changed, 7 insertions, 9 deletions
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<Vector2i>& 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 <Magnum/Math/Color.h> 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(); |
