From ec7be88fbb4062af20b77198007d815c321c2850 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 18 May 2023 16:26:01 +0200 Subject: wip vobj --- editor/editor.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'editor/editor.cpp') diff --git a/editor/editor.cpp b/editor/editor.cpp index 99a3cf96..b744f03c 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -20,6 +20,8 @@ void editor::clear_selection() ed->clear_selection(); else if (auto* ed = current_scenery_editor()) ed->clear_selection(); + else if (auto* vo = current_vobj_editor()) + vo->clear_selection(); } auto editor::get_snap_value(snap_mode snap, int mods) const -> snap_mode @@ -115,6 +117,23 @@ void editor::on_click_(world& world, global_coords pos, button b) } } } + else if (auto* mode = current_vobj_editor()) + { + if (const auto* opt = mode->get_selected(); opt || b == button::remove) + { + switch (b) + { + default: break; + case button::place: + if (const auto& sel = mode->get_selected()) + mode->place_tile(world, pos, sel); + break; + case button::remove: + mode->place_tile(world, pos, {}); + break; + } + } + } on_release(); } @@ -161,6 +180,14 @@ const scenery_editor* editor::current_scenery_editor() const noexcept return nullptr; } +const vobj_editor* editor::current_vobj_editor() const noexcept +{ + if (_mode == editor_mode::vobj) + return &_vobj; + else + return nullptr; +} + tile_editor* editor::current_tile_editor() noexcept { return const_cast(static_cast(*this).current_tile_editor()); @@ -171,4 +198,9 @@ scenery_editor* editor::current_scenery_editor() noexcept return const_cast(static_cast(*this).current_scenery_editor()); } +vobj_editor* editor::current_vobj_editor() noexcept +{ + return const_cast(static_cast(*this).current_vobj_editor()); +} + } // namespace floormat -- cgit v1.2.3