summaryrefslogtreecommitdiffhomepage
path: root/editor/update.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-03 15:24:33 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-03 15:24:33 +0100
commit235078bae4ada8b7aed3c1cdf95d8288aaf81df4 (patch)
treeda2979408771be5e496d0ffaf5af3634cd61e4a3 /editor/update.cpp
parent4e5cdeaa32fd73f160ee0d599ce958169082eeac (diff)
flush scenery popup work
Diffstat (limited to 'editor/update.cpp')
-rw-r--r--editor/update.cpp45
1 files changed, 41 insertions, 4 deletions
diff --git a/editor/update.cpp b/editor/update.cpp
index 62dcc977..3c8f9777 100644
--- a/editor/update.cpp
+++ b/editor/update.cpp
@@ -53,6 +53,11 @@ void app::do_mouse_up_down(std::uint8_t button, bool is_down, int mods)
auto& w = M->world();
update_cursor_tile(cursor.pixel);
+ if (is_down && !cursor.in_imgui)
+ {
+ _popup_target = {};
+ }
+
if (is_down && cursor.tile && !cursor.in_imgui)
{
switch (_editor.mode())
@@ -69,6 +74,22 @@ void app::do_mouse_up_down(std::uint8_t button, bool is_down, int mods)
return (void)s.activate();
}
}
+ // TODO it should open on mouseup if still on the same item as on mousedown
+ else if (button == mouse_button_right)
+ {
+ if (auto* cl = find_clickable_scenery(*cursor.pixel))
+ {
+ auto [c, t] = w[{cl->chunk, cl->pos}];
+ if (auto s = t.scenery())
+ {
+ _popup_target = {
+ .c = cl->chunk, .pos = cl->pos,
+ .target = popup_target_type::scenery,
+ };
+ do_open_popup();
+ }
+ }
+ }
break;
case editor_mode::floor:
case editor_mode::walls:
@@ -115,6 +136,22 @@ void app::do_rotate(bool backward)
}
}
+void app::do_set_mode(editor_mode mode)
+{
+ if (mode != _editor.mode())
+ kill_popups(true);
+ _editor.set_mode(mode);
+}
+
+void app::do_escape()
+{
+ if (auto* ed = _editor.current_scenery_editor())
+ ed->clear_selection();
+ if (auto* ed = _editor.current_tile_editor())
+ ed->clear_selection();
+ kill_popups(false);
+}
+
void app::do_key(key k, int mods)
{
(void)mods;
@@ -127,13 +164,13 @@ void app::do_key(key k, int mods)
case key_rotate_tile:
return do_rotate(false);
case key_mode_none:
- return _editor.set_mode(editor_mode::none);
+ return do_set_mode(editor_mode::none);
case key_mode_floor:
- return _editor.set_mode(editor_mode::floor);
+ return do_set_mode(editor_mode::floor);
case key_mode_walls:
- return _editor.set_mode(editor_mode::walls);
+ return do_set_mode(editor_mode::walls);
case key_mode_scenery:
- return _editor.set_mode(editor_mode::scenery);
+ return do_set_mode(editor_mode::scenery);
case key_mode_collisions:
return void(_enable_render_bboxes = !_enable_render_bboxes);
case key_quicksave: