diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-02-24 11:15:10 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-02-24 11:15:10 +0100 |
commit | e1b1538362d58145e8fcdf68537bcf9fa798f58b (patch) | |
tree | 38af4f9e9074b6257c80925126504defe5427e03 /editor | |
parent | a335d1efbde4f5415632666aaf8f4fd55a30a8bf (diff) |
a
Diffstat (limited to 'editor')
-rw-r--r-- | editor/app.hpp | 1 | ||||
-rw-r--r-- | editor/imgui.cpp | 8 | ||||
-rw-r--r-- | editor/inspect-types.cpp | 11 | ||||
-rw-r--r-- | editor/inspect.cpp | 5 |
4 files changed, 19 insertions, 6 deletions
diff --git a/editor/app.hpp b/editor/app.hpp index f6a2e842..d1d67ac8 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -129,6 +129,7 @@ private: key_set keys; std::array<int, key_set::COUNT> key_modifiers = {}; cursor_state cursor; + Optional<global_coords> inspected_scenery; bool _draw_collision_boxes : 1 = false; }; diff --git a/editor/imgui.cpp b/editor/imgui.cpp index 4aca859e..bb96d78f 100644 --- a/editor/imgui.cpp +++ b/editor/imgui.cpp @@ -152,16 +152,14 @@ void app::draw_tile_under_cursor() void app::draw_inspector() { - static Optional<global_coords> tile; - auto b = push_id("inspector"); auto& w = M->world(); if (cursor.pixel) if (const auto* sc = find_clickable_scenery(cursor.pixel)) - tile = {InPlaceInit, sc->chunk, sc->pos}; - if (tile) + inspected_scenery = {InPlaceInit, sc->chunk, sc->pos}; + if (inspected_scenery) { - auto [c, t] = w[*tile]; + auto [c, t] = w[*inspected_scenery]; if (auto s = t.scenery()) { char buf[32]; std::snprintf(buf, sizeof buf, "i_0x%p", (void*)&s); diff --git a/editor/inspect-types.cpp b/editor/inspect-types.cpp index c7c38398..4a3aa391 100644 --- a/editor/inspect-types.cpp +++ b/editor/inspect-types.cpp @@ -5,6 +5,7 @@ #include "src/tile-defs.hpp" #include "entity/types.hpp" #include "inspect.hpp" +#include "loader/loader.hpp" #include <Corrade/Containers/ArrayViewStl.h> #include <Corrade/Containers/String.h> @@ -22,6 +23,16 @@ template<> struct entity_accessors<scenery_ref> { using entity = Entity<scenery_ref>; using frame_t = scenery::frame_t; return std::tuple{ + entity::type<StringView>::field{"name"_s, + [](const scenery_ref& x) { + StringView name = x.atlas->name(); + if (name.hasPrefix(loader.SCENERY_PATH)) + name = name.exceptPrefix(loader.SCENERY_PATH.size()); + return name; + }, + [](scenery_ref&, StringView) {}, + constantly(field_status::readonly), + }, entity::type<scenery::frame_t>::field{"frame"_s, [](const scenery_ref& x) { return x.frame.frame; }, [](scenery_ref& x, frame_t value) { x.frame.frame = value; }, diff --git a/editor/inspect.cpp b/editor/inspect.cpp index d17ebf74..79aaaa03 100644 --- a/editor/inspect.cpp +++ b/editor/inspect.cpp @@ -85,7 +85,9 @@ void do_inspect_field(void* datum, const erased_accessor& accessor, field_repr r accessor.read_fun(datum, accessor.reader, &value); auto orig = value; - if constexpr(std::is_same_v<T, String>) + if constexpr(std::is_same_v<T, StringView>) + ret = ImGui::InputText(label, const_cast<char*>(value.data()), value.size(), ImGuiInputTextFlags_ReadOnly); + else if constexpr(std::is_same_v<T, String>) { ret = ImGui::InputText(label, value.begin(), value.size(), ImGuiInputTextFlags_CallbackResize, corrade_string_resize_callback, &value); if (auto max_len = accessor.get_max_length(datum); value.size() > max_len) @@ -202,5 +204,6 @@ MAKE_SPEC_REPRS2(std::int32_t) MAKE_SPEC_REPRS2(float) MAKE_SPEC(bool, field_repr::input) MAKE_SPEC(String, field_repr::input) +MAKE_SPEC(StringView, field_repr::input) } // namespace floormat::entities |