summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--editor/app.hpp1
-rw-r--r--editor/imgui.cpp16
-rw-r--r--editor/inspect-draw.cpp11
3 files changed, 24 insertions, 4 deletions
diff --git a/editor/app.hpp b/editor/app.hpp
index 13407883..4aa82b8c 100644
--- a/editor/app.hpp
+++ b/editor/app.hpp
@@ -119,6 +119,7 @@ private:
void draw_editor_pane(float main_menu_height);
void draw_inspector();
+ static void entity_inspector_name(char* buf, object_id id, size_t len);
bool check_inspector_exists(const popup_target& p);
void draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const std::shared_ptr<tile_atlas>& atlas);
void draw_editor_scenery_pane(scenery_editor& ed);
diff --git a/editor/imgui.cpp b/editor/imgui.cpp
index 96eb940f..3c483265 100644
--- a/editor/imgui.cpp
+++ b/editor/imgui.cpp
@@ -347,9 +347,19 @@ void app::do_popup_menu()
const auto i = e.index();
if (ImGui::MenuItem("Activate", nullptr, false, e.can_activate(i)))
e.activate(i);
- if (bool b_ins = !check_inspector_exists(_popup_target);
- ImGui::MenuItem("Inspect", nullptr, !b_ins, b_ins))
- inspectors.push_back(std::exchange(_popup_target, {}));
+ if (bool exists = check_inspector_exists(_popup_target);
+ ImGui::MenuItem("Inspect", nullptr, exists))
+ {
+ if (!exists)
+ inspectors.push_back(std::exchange(_popup_target, {}));
+ else
+ {
+ char buf[32];
+ entity_inspector_name(buf, sizeof buf, e.id);
+ ImGui::SetWindowFocus(buf);
+ ImGui::SetWindowCollapsed(buf, false);
+ }
+ }
if (bool b_testing = tested_light_chunk == chunk_coords_(e.coord);
e.type() == object_type::light)
if (ImGui::MenuItem("Test", nullptr, b_testing))
diff --git a/editor/inspect-draw.cpp b/editor/inspect-draw.cpp
index fc5cbaab..f6d36e61 100644
--- a/editor/inspect-draw.cpp
+++ b/editor/inspect-draw.cpp
@@ -50,7 +50,7 @@ auto z = e.coord.z();
else
snformat(buf, "{} ({}x{}:{} -> {}x{})###inspector-{:08x}"_cf, name, ch.x, ch.y, (int)z, (int)pos.x, (int)pos.y, e.id);
#else
- snformat(buf, "inspector-{:08x}"_cf, e.id);
+ entity_inspector_name(buf, sizeof buf, e.id);
#endif
bool is_open = true;
@@ -64,4 +64,13 @@ auto z = e.coord.z();
}
}
+void app::entity_inspector_name(char* buf, size_t len, object_id id)
+{
+ constexpr auto min_len = sizeof "inspector-" + 8;
+ fm_debug_assert(len >= min_len);
+ auto result = fmt::format_to_n(buf, len, "inspector-{:08x}"_cf, id);
+ fm_assert(result.size < len);
+ buf[result.size] = '\0';
+}
+
} // namespace floormat