summaryrefslogtreecommitdiffhomepage
path: root/editor/editor.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-29 19:35:25 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-29 19:35:25 +0100
commitca6ff463979d5c250ab04e940bead875f11e7352 (patch)
tree479b06c90e1af3652c30e5554c3cada57ac81975 /editor/editor.cpp
parentcd1e7b6564e8508f84e84706557b89eb5471a978 (diff)
scenery wip
Diffstat (limited to 'editor/editor.cpp')
-rw-r--r--editor/editor.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index 3400f5af..11d26fdd 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -16,6 +16,14 @@ void editor::on_release()
_last_pos = NullOpt;
}
+void editor::clear_selection()
+{
+ if (auto* ed = current_tile_editor())
+ ed->clear_selection();
+ else if (auto* ed = current_scenery_editor())
+ ed->clear_selection();
+}
+
auto editor::get_snap_value(snap_mode snap, int mods) const -> snap_mode
{
@@ -81,6 +89,7 @@ void editor::on_mouse_move(world& world, global_coords& pos, int mods)
void editor::on_click_(world& world, global_coords pos, button b)
{
if (auto* mode = current_tile_editor(); mode != nullptr)
+ {
if (auto opt = mode->get_selected(); opt || b == button::remove)
{
switch (b)
@@ -90,16 +99,39 @@ void editor::on_click_(world& world, global_coords pos, button b)
default: break;
}
}
+ }
+ else if (auto* mode = current_scenery_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();
}
void editor::on_click(world& world, global_coords pos, int mods, button b)
{
- if (auto* mode = current_tile_editor(); mode != nullptr)
+ if (auto* mode = current_tile_editor())
{
_last_pos = { InPlaceInit, pos, pos, mode->check_snap(mods), b };
on_click_(world, pos, b);
}
+ else if (current_scenery_editor())
+ {
+ _last_pos = {};
+ on_click_(world, pos, b);
+ }
}
editor::editor() = default;
@@ -117,7 +149,7 @@ const tile_editor* editor::current_tile_editor() const noexcept
case editor_mode::floor:
return &_floor;
case editor_mode::walls:
- return &_wall; // todo
+ return &_wall;
default:
return nullptr;
}