diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-06-10 13:20:04 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-06-10 13:20:04 +0200 |
commit | 2204f113710319ae6d735e3d511dd1d75d42a07d (patch) | |
tree | d21bb92cddf4c511239a773efc54f9aa94935b2b /editor | |
parent | 587d492a03275e95d518850d2e44949b73e1980e (diff) |
wip
Diffstat (limited to 'editor')
-rw-r--r-- | editor/imgui.cpp | 43 | ||||
-rw-r--r-- | editor/inspect-draw.cpp | 17 | ||||
-rw-r--r-- | editor/inspect-types.cpp | 15 |
3 files changed, 40 insertions, 35 deletions
diff --git a/editor/imgui.cpp b/editor/imgui.cpp index ddbbc918..b953a247 100644 --- a/editor/imgui.cpp +++ b/editor/imgui.cpp @@ -110,11 +110,13 @@ void app::draw_ui() draw_clickables(); if (_render_vobjs) draw_light_info(); + const float main_menu_height = draw_main_menu(); + + [[maybe_unused]] auto font = font_saver{ctx.FontSize*dpi}; + if (_tested_light) draw_lightmap_test(); - const float main_menu_height = draw_main_menu(); - [[maybe_unused]] auto font = font_saver{ctx.FontSize*dpi}; if (_editor.current_tile_editor() || _editor.current_scenery_editor() || _editor.current_vobj_editor()) draw_editor_pane(main_menu_height); draw_fps(); @@ -207,31 +209,32 @@ void app::draw_lightmap_test() ImGui::SetNextWindowSize({1024, 1024}); auto& w = M->world(); - auto L = w.find_entity(_tested_light); + auto e_ = w.find_entity(_tested_light); + + auto b1 = push_style_var(ImGuiStyleVar_WindowPadding, {0, 0}); - constexpr auto flags = - ImGuiWindowFlags_NoTitleBar | - ImGuiWindowFlags_NoResize | - ImGuiWindowFlags_NoMove | - ImGuiWindowFlags_NoScrollbar; + constexpr auto flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoScrollbar; + bool is_open = true; - if (L && ImGui::Begin("Lightmap", nullptr, flags)) + if (e_ && ImGui::Begin("Lightmap", &is_open, flags)) { - fm_assert(L->type() == entity_type::light); - auto& shader = M->lightmap_shader(); - light_s light { - .center = {8 * 64, 8 * 64}, - .dist = 4, - .color = {255, 255, 255}, - .falloff = light_falloff::linear, + constexpr auto chunk_size = TILE_SIZE2.sum()/2; + fm_assert(e_->type() == entity_type::light); + const auto& li = static_cast<const light&>(*e_); + light_s L { + .center = Vector2(li.coord.local()) * TILE_SIZE2 + Vector2(li.offset), + .dist = li.max_distance * chunk_size, + .color = li.color, + .falloff = li.falloff, }; - shader.begin({0, 0}, light); + auto& shader = M->lightmap_shader(); + shader.begin({0, 0}, L); shader.end(); - M->bind(); + M->bind(); // todo ImGui::Image(&shader.texture(), {1024, 1024}); - ImGui::End(); } - else + ImGui::End(); + if (!is_open) _tested_light = 0; } diff --git a/editor/inspect-draw.cpp b/editor/inspect-draw.cpp index d3c95e58..be32edf7 100644 --- a/editor/inspect-draw.cpp +++ b/editor/inspect-draw.cpp @@ -37,20 +37,21 @@ void app::draw_inspector() continue; } auto& e = *e_; - chunk_coords ch = e.coord.chunk(); - local_coords pos = e.coord.local(); - auto z = e.coord.z(); char buf[32]; - snformat(buf, "inspector-{:08x}"_cf, e.id); - - auto b1 = push_id(buf); ImGui::SetNextWindowSize({375*dpi[0], 0}); +#if 0 auto name = loader.strip_prefix(e.atlas->name()); + chunk_coords ch = e.coord.chunk(); + local_coords pos = e.coord.local(); +auto z = e.coord.z(); if (z == 0) - snformat(buf, "{} ({}x{} -> {}x{})"_cf, name, ch.x, ch.y, (int)pos.x, (int)pos.y); + snformat(buf, "{} ({}x{} -> {}x{})###inspector-{:08x}"_cf, name, ch.x, ch.y, (int)pos.x, (int)pos.y, e.id); else - snformat(buf, "{} ({}x{}:{} -> {}x{})"_cf, name, ch.x, ch.y, (int)z, (int)pos.x, (int)pos.y); + 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); +#endif bool is_open = true; if (auto b2 = begin_window(buf, &is_open)) diff --git a/editor/inspect-types.cpp b/editor/inspect-types.cpp index c7d4b494..fc60992e 100644 --- a/editor/inspect-types.cpp +++ b/editor/inspect-types.cpp @@ -42,10 +42,11 @@ struct entity_accessors<entity> { return constraints::range<uint16_t>{0, !x.atlas ? uint16_t(0) : uint16_t(x.atlas->info().nframes-1)}; }, }, - E::type<Vector2b>::field{"offset"_s, - [](const entity& x) { return x.offset; }, - [](entity& x, Vector2b value) { x.set_bbox(value, x.bbox_offset, x.bbox_size, x.pass); }, - constantly(constraints::range{Vector2b(iTILE_SIZE2/-2), Vector2b(iTILE_SIZE2/2)}), + E::type<Vector2i>::field{"offset"_s, + [](const entity& x) { return Vector2i(x.offset); }, + //[](entity& x, Vector2i value) { x.set_bbox(value, x.bbox_offset, x.bbox_size, x.pass); }, + [](entity& x, Vector2i value) { x.move_to(value - Vector2i(x.offset)); }, + //constantly(constraints::range{Vector2b(iTILE_SIZE2/-2), Vector2b(iTILE_SIZE2/2)}), }, E::type<pass_mode>::field{"pass-mode"_s, [](const entity& x) { return x.pass; }, @@ -210,10 +211,10 @@ struct entity_accessors<light> using E = Entity<light>; auto tuple0 = entity_accessors<entity>::accessors(); auto tuple = std::tuple{ - E::type<Color3ub>::field{"color"_s, + E::type<Color4ub>::field{"color"_s, [](const light& x) { return x.color; }, - [](light& x, Color3ub value) { x.color = value; }, - constantly(constraints::range<Color3ub>{{0, 0, 0}, {255, 255, 255}}), + [](light& x, Color4ub value) { x.color = value; }, + constantly(constraints::range<Color4ub>{{0, 0, 0, 0}, {255, 255, 255, 255}}), }, E::type<light_falloff>::field{"falloff"_s, [](const light& x) { return x.falloff; }, |