summaryrefslogtreecommitdiffhomepage
path: root/editor
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-27 17:27:56 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-27 17:27:56 +0100
commitbeb6685f605b89ce4b2dd99f87b9319e4f7f4d94 (patch)
treeb4db6babfa2a7c5518db59e1678ef4e434ae0d70 /editor
parentd2fcaad5425acb4a50138e793e3dcecc6600e4d3 (diff)
more WIP
Diffstat (limited to 'editor')
-rw-r--r--editor/scenery-editor.cpp30
-rw-r--r--editor/scenery-editor.hpp15
-rw-r--r--editor/update.cpp6
3 files changed, 21 insertions, 30 deletions
diff --git a/editor/scenery-editor.cpp b/editor/scenery-editor.cpp
index 482b2131..c8f9f910 100644
--- a/editor/scenery-editor.cpp
+++ b/editor/scenery-editor.cpp
@@ -8,8 +8,6 @@ namespace floormat {
using rotation_ = rotation;
using rotation_t = std::underlying_type_t<rotation_>;
-scenery_editor::pair::operator bool() const { return atlas != nullptr; }
-
scenery_editor::scenery_editor() noexcept
{
load_atlases();
@@ -17,45 +15,45 @@ scenery_editor::scenery_editor() noexcept
void scenery_editor::set_rotation(rotation_ r)
{
- _selected.r = r;
+ _selected.frame.r = r;
}
rotation_ scenery_editor::rotation() const
{
- return _selected.r;
+ return _selected.frame.r;
}
void scenery_editor::next_rotation()
{
- auto r_1 = (rotation_t)_selected.r + 1;
+ // todo
+ auto r_1 = (rotation_t)_selected.frame.r + 1;
auto rot = (rotation_)r_1;
if (rot >= rotation_COUNT)
rot = (rotation_)0;
- _selected.r = rot;
+ _selected.frame.r = rot;
}
void scenery_editor::prev_rotation()
{
- if (_selected.r == (rotation_)0)
- _selected.r = (rotation_)((rotation_t)rotation_COUNT - 1);
+ if (_selected.frame.r == (rotation_)0)
+ _selected.frame.r = (rotation_)((rotation_t)rotation_COUNT - 1);
else
- _selected.r = (rotation_)((rotation_t)_selected.r - 1);
+ _selected.frame.r = (rotation_)((rotation_t)_selected.frame.r - 1);
}
//return atlas == _selected.atlas && r == _selected.s.r && frame == _selected.s.frame;
-void scenery_editor::select_tile(const std::shared_ptr<anim_atlas>& atlas, rotation_ r, frame_t frame)
+void scenery_editor::select_tile(const scenery_proto& proto)
{
- fm_assert(frame < atlas->group(r).frames.size());
- _selected = { atlas, r, frame };
+ _selected = proto;
}
void scenery_editor::clear_selection()
{
- _selected = { nullptr, rotation_COUNT, scenery::NO_FRAME };
+ _selected = {};
}
-auto scenery_editor::get_selected() -> pair
+const scenery_proto& scenery_editor::get_selected()
{
return _selected;
}
@@ -65,9 +63,9 @@ bool scenery_editor::is_atlas_selected(const std::shared_ptr<anim_atlas>& atlas)
return _selected.atlas == atlas;
}
-bool scenery_editor::is_item_selected(const std::shared_ptr<anim_atlas>& atlas, rotation_ r, frame_t frame) const
+bool scenery_editor::is_item_selected(const scenery_proto& proto) const
{
- return is_atlas_selected(atlas) && _selected.r == r && _selected.frame == frame;
+ return _selected == proto;
}
void scenery_editor::load_atlases()
diff --git a/editor/scenery-editor.hpp b/editor/scenery-editor.hpp
index 85ccd3be..b461fd0c 100644
--- a/editor/scenery-editor.hpp
+++ b/editor/scenery-editor.hpp
@@ -12,13 +12,6 @@ struct scenery_editor final
{
using frame_t = scenery::frame_t;
- struct pair final {
- std::shared_ptr<anim_atlas> atlas;
- enum rotation r = rotation_COUNT;
- frame_t frame = scenery::NO_FRAME;
- operator bool() const;
- };
-
scenery_editor() noexcept;
void set_rotation(enum rotation r);
@@ -26,17 +19,17 @@ struct scenery_editor final
void next_rotation();
void prev_rotation();
- void select_tile(const std::shared_ptr<anim_atlas>& atlas, enum rotation r, frame_t frame);
+ void select_tile(const scenery_proto& proto);
void clear_selection();
- pair get_selected();
+ const scenery_proto& get_selected();
bool is_atlas_selected(const std::shared_ptr<anim_atlas>& atlas) const;
- bool is_item_selected(const std::shared_ptr<anim_atlas>& atlas, enum rotation r, frame_t frame) const;
+ bool is_item_selected(const scenery_proto& proto) const;
private:
void load_atlases();
std::map<StringView, std::shared_ptr<anim_atlas>> _atlases;
- pair _selected;
+ scenery_proto _selected;
};
} // namespace floormat
diff --git a/editor/update.cpp b/editor/update.cpp
index 0c347f1d..f2ac1bc6 100644
--- a/editor/update.cpp
+++ b/editor/update.cpp
@@ -30,9 +30,9 @@ void app::maybe_initialize_chunk_(const chunk_coords& pos, chunk& c)
c[{K, K }].wall_west() = { _wall2, 0 };
c[{K, K+1}].wall_north() = { _wall1, 0 };
c[{K+1, K }].wall_west() = { _wall2, 0 };
- c[{K+3, K+1}].scenery() = { scenery::door, rotation::N, _door, false };
- c[{ 3, 4 }].scenery() = { scenery::generic, rotation::W, _table };
- c[{K, K+1}].scenery() = { scenery::generic, rotation::N, _control_panel, true };
+ c[{K+3, K+1}].scenery() = { scenery::door, _door, rotation::N, };
+ c[{ 3, 4 }].scenery() = { scenery::generic, _table, rotation::W, };
+ c[{K, K+1}].scenery() = { scenery::generic, _control_panel, rotation::N, scenery::frame_t{0}, true };
c.mark_modified();
}