diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-26 21:06:03 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-26 21:07:47 +0200 |
commit | dded6652999447b6a56f6c00d07e439a4c5d678c (patch) | |
tree | 153d3bafd62afb8163bc2429048796aaf36ecc7b /editor | |
parent | 978a605ada755b0a02f8e8ea768c3af7e40b4cd7 (diff) |
add untested tile rotation
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor.cpp | 21 | ||||
-rw-r--r-- | editor/editor.hpp | 41 |
2 files changed, 43 insertions, 19 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index bea41116..ea48eb00 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -170,6 +170,27 @@ void tile_editor::place_tile(world& world, global_coords pos, tile_image& img) } } +void tile_editor::rotate_tile() +{ + if (_rotation == rotation::rot_W) + _rotation = rotation::rot_N; + else + _rotation = rotation::rot_W; +} + +void tile_editor::rotate_tile(rotation r) +{ + switch (r) + { + default: + fm_warn_once("invalid rotation '0x%hhx", r); + return; + case rotation::rot_W: + case rotation::rot_N: + _rotation = r; + } +} + editor::editor() { set_mode(editor_mode::floor); // TODO diff --git a/editor/editor.hpp b/editor/editor.hpp index e7f81305..4b1ba124 100644 --- a/editor/editor.hpp +++ b/editor/editor.hpp @@ -22,25 +22,6 @@ struct world; struct tile_editor final { - tile_editor(editor_mode mode, StringView name); - std::shared_ptr<tile_atlas> maybe_atlas(StringView str); - std::shared_ptr<tile_atlas> atlas(StringView str); - auto cbegin() const { return _atlases.cbegin(); } - auto cend() const { return _atlases.cend(); } - auto begin() const { return _atlases.cbegin(); } - auto end() const { return _atlases.cend(); } - StringView name() const { return _name; } - editor_mode mode() const { return _mode; } - - void clear_selection(); - void select_tile(const std::shared_ptr<tile_atlas>& atlas, std::size_t variant); - void select_tile_permutation(const std::shared_ptr<tile_atlas>& atlas); - bool is_tile_selected(const std::shared_ptr<const tile_atlas>& atlas, std::size_t variant) const; - bool is_permutation_selected(const std::shared_ptr<const tile_atlas>& atlas) const; - bool is_atlas_selected(const std::shared_ptr<const tile_atlas>& atlas) const; - tile_image get_selected(); - void place_tile(world& world, global_coords pos, tile_image& img); - private: enum selection_mode : std::uint8_t { sel_none, sel_tile, sel_perm, @@ -59,6 +40,28 @@ private: void load_atlases(); tile_image get_selected_perm(); + +public: + tile_editor(editor_mode mode, StringView name); + std::shared_ptr<tile_atlas> maybe_atlas(StringView str); + std::shared_ptr<tile_atlas> atlas(StringView str); + auto cbegin() const { return _atlases.cbegin(); } + auto cend() const { return _atlases.cend(); } + auto begin() const { return _atlases.cbegin(); } + auto end() const { return _atlases.cend(); } + StringView name() const { return _name; } + editor_mode mode() const { return _mode; } + + void clear_selection(); + void select_tile(const std::shared_ptr<tile_atlas>& atlas, std::size_t variant); + void select_tile_permutation(const std::shared_ptr<tile_atlas>& atlas); + bool is_tile_selected(const std::shared_ptr<const tile_atlas>& atlas, std::size_t variant) const; + bool is_permutation_selected(const std::shared_ptr<const tile_atlas>& atlas) const; + bool is_atlas_selected(const std::shared_ptr<const tile_atlas>& atlas) const; + tile_image get_selected(); + void place_tile(world& world, global_coords pos, tile_image& img); + void rotate_tile(); + void rotate_tile(rotation r); }; struct editor final |