summaryrefslogtreecommitdiffhomepage
path: root/editor/imgui.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-16 18:14:23 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-17 23:23:11 +0100
commit73fc95bc7bbdfe24e535f390f79d33fb809c0151 (patch)
treeef7f60cd9269907d79073450935647d4150698de /editor/imgui.cpp
parentd330637351e8ede605351787f17fb46324089535 (diff)
fix popup
Diffstat (limited to 'editor/imgui.cpp')
-rw-r--r--editor/imgui.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/editor/imgui.cpp b/editor/imgui.cpp
index 652b33a5..6904f0f5 100644
--- a/editor/imgui.cpp
+++ b/editor/imgui.cpp
@@ -98,8 +98,7 @@ void app::draw_ui()
draw_tile_under_cursor();
if (_editor.mode() == editor_mode::none)
draw_inspector();
- if (_popup_target.target != popup_target_type::none)
- do_popup_menu();
+ do_popup_menu();
ImGui::EndFrame();
}
@@ -119,13 +118,7 @@ void app::draw_clickables()
const StringView app::SCENERY_POPUP_NAME = "##scenery-popup"_s;
-void app::do_open_popup()
-{
- fm_assert(_popup_target.target != popup_target_type::none);
- _pending_popup = true;
-}
-
-bool app::check_inspector_exists(popup_target p)
+bool app::check_inspector_exists(const popup_target& p)
{
if (p.target == popup_target_type::none) [[unlikely]]
return true;
@@ -137,7 +130,6 @@ bool app::check_inspector_exists(popup_target p)
void app::do_popup_menu()
{
- fm_assert(_popup_target.target != popup_target_type::none);
auto b0 = push_id(SCENERY_POPUP_NAME);
const auto [sc, target] = _popup_target;
//if (_popup_target.target != popup_target_type::scenery) {...}
@@ -145,19 +137,20 @@ void app::do_popup_menu()
if (_pending_popup)
{
_pending_popup = false;
- fm_assert(target != popup_target_type::none);
+ fm_assert(target != popup_target_type::none && sc != nullptr);
//if (type != popup_target_type::scenery) {...}
- if (sc)
- ImGui::OpenPopup(SCENERY_POPUP_NAME.data());
+ ImGui::OpenPopup(SCENERY_POPUP_NAME.data());
}
if (auto b1 = begin_popup(SCENERY_POPUP_NAME))
{
+ fm_assert(target != popup_target_type::none && sc != nullptr);
+
const auto i = sc->index();
if (ImGui::MenuItem("Activate", nullptr, false, sc->can_activate(i)))
sc->activate(i);
if (auto next_rot = sc->atlas->next_rotation_from(sc->r);
- ImGui::MenuItem("Rotate", nullptr, false, next_rot != sc->r))
+ next_rot != sc->r && ImGui::MenuItem("Rotate", nullptr, false, next_rot != sc->r))
sc->rotate(i, next_rot);
ImGui::Separator();