summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-30 19:54:20 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-10-30 19:54:20 +0100
commit7453d878cc1d7549d908414aefd31fb1ac360ccb (patch)
tree3e6d056a56a59bc54af52fc7bb3d744f1fdf5644
parentae91983d0a6166910f44e0dc9a151a80359e1908 (diff)
editor: random krap
-rw-r--r--editor/editor.cpp21
-rw-r--r--editor/editor.hpp18
-rw-r--r--editor/update.cpp2
3 files changed, 23 insertions, 18 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index dca7cfe0..d132574b 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -160,34 +160,33 @@ void tile_editor::place_tile(world& world, global_coords pos, tile_image& img)
break;
case editor_mode::select:
break;
- case editor_mode::floor: {
+ case editor_mode::floor:
t.ground = {atlas, variant };
break;
- }
- case editor_mode::walls: {
+ case editor_mode::walls:
break; // todo
}
- }
}
-void tile_editor::rotate_tile()
+void tile_editor::toggle_rotation()
{
- if (_rotation == rotation::rot_W)
- _rotation = rotation::rot_N;
+ if (_rotation == editor::rotation_W)
+ _rotation = editor::rotation_N;
else
- _rotation = rotation::rot_W;
+ _rotation = editor::rotation_W;
}
-void tile_editor::rotate_tile(rotation r)
+void tile_editor::set_rotation(editor_wall_rotation r)
{
switch (r)
{
default:
fm_warn_once("invalid rotation '0x%hhx", r);
return;
- case rotation::rot_W:
- case rotation::rot_N:
+ case editor::rotation_W:
+ case editor::rotation_N:
_rotation = r;
+ break;
}
}
diff --git a/editor/editor.hpp b/editor/editor.hpp
index e0fa85cb..2fc78892 100644
--- a/editor/editor.hpp
+++ b/editor/editor.hpp
@@ -19,6 +19,10 @@ enum class editor_mode : unsigned char {
select, floor, walls,
};
+enum class editor_wall_rotation : std::uint8_t {
+ N, W,
+};
+
struct world;
struct tile_editor final
@@ -27,9 +31,6 @@ private:
enum selection_mode : std::uint8_t {
sel_none, sel_tile, sel_perm,
};
- enum rotation : std::uint8_t {
- rot_N, rot_W,
- };
std::string _name;
std::map<std::string, std::shared_ptr<tile_atlas>> _atlases;
@@ -37,7 +38,7 @@ private:
std::tuple<std::shared_ptr<tile_atlas>, std::vector<decltype(tile_image::variant)>> _permutation;
selection_mode _selection_mode = sel_none;
editor_mode _mode;
- rotation _rotation{};
+ editor_wall_rotation _rotation = editor_wall_rotation::N;
void load_atlases();
tile_image get_selected_perm();
@@ -52,6 +53,7 @@ public:
auto end() const { return _atlases.cend(); }
StringView name() const { return _name; }
editor_mode mode() const { return _mode; }
+ editor_wall_rotation rotation() const { return _rotation; }
void clear_selection();
void select_tile(const std::shared_ptr<tile_atlas>& atlas, std::size_t variant);
@@ -61,8 +63,8 @@ public:
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);
+ void toggle_rotation();
+ void set_rotation(editor_wall_rotation r);
};
struct editor final
@@ -87,6 +89,10 @@ struct editor final
editor& operator=(editor&&) noexcept = default;
fm_DECLARE_DELETED_COPY_ASSIGNMENT(editor);
+ using rotation = editor_wall_rotation;
+ static constexpr inline auto rotation_N = editor_wall_rotation::N;
+ static constexpr inline auto rotation_W = editor_wall_rotation::W;
+
private:
tile_editor _floor{ editor_mode::floor, "floor"};
std::optional<global_coords> _last_pos;
diff --git a/editor/update.cpp b/editor/update.cpp
index 52011b73..468f89b1 100644
--- a/editor/update.cpp
+++ b/editor/update.cpp
@@ -85,7 +85,7 @@ void app::do_keys()
if (k[key::quickload])
do_quickload();
if (auto* ed = _editor.current(); ed && k[key::rotate_tile])
- ed->rotate_tile();
+ ed->toggle_rotation();
}
void app::update(float dt)