diff options
Diffstat (limited to 'editor/inspect-draw.cpp')
-rw-r--r-- | editor/inspect-draw.cpp | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/editor/inspect-draw.cpp b/editor/inspect-draw.cpp index e47ac692..7b2e5009 100644 --- a/editor/inspect-draw.cpp +++ b/editor/inspect-draw.cpp @@ -5,6 +5,9 @@ #include "floormat/main.hpp" #include "src/world.hpp" #include "src/object.hpp" +#include "src/scenery.hpp" +#include "src/critter.hpp" +#include "src/light.hpp" #include "src/anim-atlas.hpp" #include "imgui-raii.hpp" #include "loader/loader.hpp" @@ -31,7 +34,7 @@ void app::draw_inspector() } auto& e = *e_; - char buf[32]; + char buf[256], buf2[32], buf3[128]; ImGui::SetNextWindowSize({375*dpi[0], 0}); #if 0 auto name = loader.strip_prefix(e.atlas->name()); @@ -43,7 +46,9 @@ 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 - entity_inspector_name(buf, sizeof buf, e.id); + entity_inspector_name(buf2, sizeof buf2, e.id); + entity_friendly_name(buf3, sizeof buf3, e); + std::snprintf(buf, std::size(buf), "%s###%s", buf3, buf2); #endif bool is_open = true; @@ -66,4 +71,50 @@ void app::entity_inspector_name(char* buf, size_t len, object_id id) buf[result.size] = '\0'; } +void app::entity_friendly_name(char* buf, size_t len, const object& obj) +{ + switch (obj.type()) + { + default: + std::snprintf(buf, len, "(unknown?)"); + break; + case object_type::critter: { + const auto& c = static_cast<const critter&>(obj); + std::snprintf(buf, len, "critter %s", c.name.data()); + break; + } + case object_type::light: { + const auto& L = static_cast<const light&>(obj); + const char* type; + switch (L.falloff) + { + case light_falloff::constant: type = "constant"; break; + case light_falloff::linear: type = "linear"; break; + case light_falloff::quadratic: type = "quadratic"; break; + default: type = "(unknown?)"; break; + } + std::snprintf(buf, len, "light #%hhx%hhx%hhx%hhx %s:%.2f", + L.color.r(), L.color.g(), L.color.b(), L.color.a(), + type, + L.falloff == light_falloff::constant ? 0. : (double)L.max_distance); + break; + } + case object_type::scenery: { + const auto& sc = static_cast<const scenery&>(obj); + switch (sc.scenery_type()) + { + default: + std::snprintf(buf, len, "(unknown?)"); + break; + case scenery_type::door: + std::snprintf(buf, len, "door"); + break; + case scenery_type::generic: + std::snprintf(buf, len, "scenery %s", sc.atlas->name().data()); + break; + } + } + } +} + } // namespace floormat |