From b82ebb0339a15cc05e26f9cdca646022e6b71ef4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 6 Nov 2022 19:20:03 +0100 Subject: a --- editor/editor.hpp | 25 +------------------------ editor/precomp.hpp | 5 +++-- editor/scenery-editor.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ editor/scenery-editor.hpp | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 26 deletions(-) create mode 100644 editor/scenery-editor.cpp create mode 100644 editor/scenery-editor.hpp (limited to 'editor') diff --git a/editor/editor.hpp b/editor/editor.hpp index 94cb7709..b25e6900 100644 --- a/editor/editor.hpp +++ b/editor/editor.hpp @@ -6,6 +6,7 @@ #include "scenery.hpp" #include "editor-enums.hpp" #include "tile-editor.hpp" +#include "scenery-editor.hpp" #include #include @@ -18,30 +19,6 @@ struct world; struct anim_atlas; struct tile_atlas; -struct scenery_editor final -{ - struct pair final { - std::shared_ptr atlas; - scenery s; - }; - - scenery_editor() noexcept; - - void set_rotation(rotation r); - void rotation() const; - void next_rotation(); - void prev_rotation(); - - void select_tile(const std::shared_ptr& atlas, enum rotation r, std::uint16_t frame); - void clear_selection(); - -private: - void load_atlases(); - - std::map> _atlases; - pair _selected_frame; -}; - struct editor final { [[nodiscard]] bool dirty() const noexcept { return _dirty; } diff --git a/editor/precomp.hpp b/editor/precomp.hpp index f309133a..93ff8164 100644 --- a/editor/precomp.hpp +++ b/editor/precomp.hpp @@ -8,6 +8,7 @@ #include #include #include -#include #include - +#if __has_include() +#include +#endif diff --git a/editor/scenery-editor.cpp b/editor/scenery-editor.cpp new file mode 100644 index 00000000..c3b29c9d --- /dev/null +++ b/editor/scenery-editor.cpp @@ -0,0 +1,40 @@ +#include "scenery-editor.hpp" +#include "src/anim-atlas.hpp" + +namespace floormat { + +using rotation_ = enum rotation; +using rotation_t = std::underlying_type_t; + +scenery_editor::scenery_editor() noexcept +{ +} + +void scenery_editor::set_rotation(enum rotation r) +{ + _selected.s.r = r; +} + +rotation scenery_editor::rotation() const +{ + return _selected.s.r; +} + +void scenery_editor::next_rotation() +{ + auto r_1 = (rotation_t)_selected.s.r + 1; + auto rot = (rotation_)r_1; + if (rot >= rotation_::COUNT) + rot = (rotation_)0; + _selected.s.r = rot; +} + +void scenery_editor::prev_rotation() +{ + if (_selected.s.r == (rotation_)0) + _selected.s.r = (rotation_)((rotation_t)rotation_::COUNT - 1); + else + _selected.s.r = (rotation_)((rotation_t)_selected.s.r - 1); +} + +} // namespace floormat diff --git a/editor/scenery-editor.hpp b/editor/scenery-editor.hpp new file mode 100644 index 00000000..f4b40c66 --- /dev/null +++ b/editor/scenery-editor.hpp @@ -0,0 +1,37 @@ +#pragma once +#include "src/scenery.hpp" +#include +#include +#include + +namespace floormat { + +struct anim_atlas; + +struct scenery_editor final +{ + struct pair final { + std::shared_ptr atlas; + scenery s; + }; + + scenery_editor() noexcept; + + void set_rotation(enum rotation r); + enum rotation rotation() const; + void next_rotation(); + void prev_rotation(); + + void select_tile(const std::shared_ptr& atlas, enum rotation r, std::uint16_t frame); + void clear_selection(); + bool is_atlas_selected() const; + bool is_item_selected(const std::shared_ptr& atlas, enum rotation r, std::uint16_t frame) const; + +private: + void load_atlases(); + + std::map> _atlases; + pair _selected; +}; + +} // namespace floormat -- cgit v1.2.3