summaryrefslogtreecommitdiffhomepage
path: root/editor/scenery-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/scenery-editor.cpp
parentcd1e7b6564e8508f84e84706557b89eb5471a978 (diff)
scenery wip
Diffstat (limited to 'editor/scenery-editor.cpp')
-rw-r--r--editor/scenery-editor.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/editor/scenery-editor.cpp b/editor/scenery-editor.cpp
index a6870180..d8f74f7d 100644
--- a/editor/scenery-editor.cpp
+++ b/editor/scenery-editor.cpp
@@ -2,12 +2,18 @@
#include "src/anim-atlas.hpp"
#include "loader/loader.hpp"
#include "compat/assert.hpp"
+#include "src/world.hpp"
namespace floormat {
using rotation_ = rotation;
using rotation_t = std::underlying_type_t<rotation_>;
+scenery_editor::scenery_::operator bool() const noexcept
+{
+ return proto;
+}
+
scenery_editor::scenery_editor() noexcept
{
load_atlases();
@@ -29,19 +35,19 @@ rotation_ scenery_editor::rotation() const
void scenery_editor::next_rotation()
{
- if (auto& proto = _selected.proto; proto.atlas)
- proto.frame.r = proto.atlas->next_rotation_from(proto.frame.r);
+ if (_selected)
+ set_rotation(_selected.proto.atlas->next_rotation_from(_selected.proto.frame.r));
}
void scenery_editor::prev_rotation()
{
- if (auto& proto = _selected.proto; proto.atlas)
- proto.frame.r = proto.atlas->prev_rotation_from(proto.frame.r);
+ if (_selected)
+ set_rotation(_selected.proto.atlas->next_rotation_from(_selected.proto.frame.r));
}
void scenery_editor::select_tile(const scenery_& s)
{
- const auto rot = is_anything_selected() && s.proto.atlas->check_rotation(_selected.proto.frame.r)
+ const auto rot = s.proto.atlas && s.proto.atlas->check_rotation(_selected.proto.frame.r)
? _selected.proto.frame.r
: s.proto.frame.r;
_selected = s;
@@ -53,7 +59,7 @@ void scenery_editor::clear_selection()
_selected = {};
}
-auto scenery_editor::get_selected() -> const scenery_&
+auto scenery_editor::get_selected() const -> const scenery_&
{
return _selected;
}
@@ -73,4 +79,11 @@ bool scenery_editor::is_anything_selected() const
return _selected.proto.atlas != nullptr;
}
+void scenery_editor::place_tile(world& w, global_coords pos, const scenery_& s)
+{
+ auto [c, t] = w[pos];
+ t.scenery() = s.proto;
+ c.mark_scenery_modified();
+}
+
} // namespace floormat