diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-01 16:35:03 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-01 16:35:03 +0100 |
commit | 704e9bd3ac58484a5209e186798076f1cbd432ef (patch) | |
tree | 511479ebd088d5c9524803c6f3fe4641009b58bc /editor | |
parent | 7ff1f0911e0b0c314d6e639887b705d6fc0d78aa (diff) |
wip
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor.cpp | 28 | ||||
-rw-r--r-- | editor/editor.hpp | 12 | ||||
-rw-r--r-- | editor/update.cpp | 10 |
3 files changed, 25 insertions, 25 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index fc2d1a1f..3d2ee3a6 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -68,7 +68,7 @@ void tile_editor::select_tile(const std::shared_ptr<tile_atlas>& atlas, std::siz fm_assert(atlas); clear_selection(); _selection_mode = sel_tile; - _selected_tile = { atlas, decltype(tile_image::variant)(variant % atlas->num_tiles()) }; + _selected_tile = { atlas, variant_t(variant % atlas->num_tiles()) }; } void tile_editor::select_tile_permutation(const std::shared_ptr<tile_atlas>& atlas) @@ -117,10 +117,9 @@ void fisher_yates(T begin, T end) } } -tile_image tile_editor::get_selected_perm() +tile_image_proto tile_editor::get_selected_perm() { auto& [atlas, vec] = _permutation; - using variant_t = decltype(tile_image::variant); const auto N = (variant_t)atlas->num_tiles(); if (N == 0) return {}; @@ -135,7 +134,7 @@ tile_image tile_editor::get_selected_perm() return {atlas, idx}; } -tile_image tile_editor::get_selected() +tile_image_proto tile_editor::get_selected() { switch (_selection_mode) { @@ -151,25 +150,26 @@ tile_image tile_editor::get_selected() } } -void tile_editor::place_tile(world& world, global_coords pos, tile_image& img) +void tile_editor::place_tile(world& world, global_coords pos, const tile_image_proto& img) { - const auto& [c, t] = world[pos]; + auto [c, t] = world[pos]; const auto& [atlas, variant] = img; switch (_mode) { - default: - fm_warn_once("invalid editor mode '%u'", (unsigned)_mode); - break; case editor_mode::none: break; case editor_mode::floor: - t.ground = { atlas, variant }; + t.ground() = img; break; case editor_mode::walls: - switch (tile_image x = { atlas, variant }; _rotation) + switch (_rotation) { - case editor_wall_rotation::N: t.wall_north = x; break; - case editor_wall_rotation::W: t.wall_west = x; break; + case editor_wall_rotation::N: + t.wall_north() = img; + break; + case editor_wall_rotation::W: + t.wall_west() = img; + break; } break; } @@ -307,7 +307,7 @@ void editor::on_click(world& world, global_coords pos, int mods, button b) if (auto opt = mode->get_selected(); opt) { _last_pos = { pos, mode->check_snap(mods), _last_pos ? _last_pos->btn : b }; - switch (tile_image empty; b) + switch (tile_image_proto empty; b) { case button::place: return mode->place_tile(world, pos, opt); case button::remove: return mode->place_tile(world, pos, empty); diff --git a/editor/editor.hpp b/editor/editor.hpp index 460bb8c8..dda13567 100644 --- a/editor/editor.hpp +++ b/editor/editor.hpp @@ -2,7 +2,7 @@ #include "compat/defs.hpp" #include "tile-atlas.hpp" #include "global-coords.hpp" -#include "tile-image.hpp" +#include "tile.hpp" #include <cstdint> #include <tuple> @@ -34,14 +34,14 @@ private: std::string _name; std::map<std::string, std::shared_ptr<tile_atlas>> _atlases; - tile_image _selected_tile; - std::tuple<std::shared_ptr<tile_atlas>, std::vector<decltype(tile_image::variant)>> _permutation; + tile_image_proto _selected_tile; + std::tuple<std::shared_ptr<tile_atlas>, std::vector<decltype(tile_image_proto::variant)>> _permutation; selection_mode _selection_mode = sel_none; editor_mode _mode; editor_wall_rotation _rotation = editor_wall_rotation::W; void load_atlases(); - tile_image get_selected_perm(); + tile_image_proto get_selected_perm(); public: enum class snap_mode : std::uint8_t { @@ -68,8 +68,8 @@ public: 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); + tile_image_proto get_selected(); + void place_tile(world& world, global_coords pos, const tile_image_proto& img); void toggle_rotation(); void set_rotation(editor_wall_rotation r); snap_mode check_snap(int mods) const; diff --git a/editor/update.cpp b/editor/update.cpp index b96d80fe..adca9492 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -18,16 +18,16 @@ void app::maybe_initialize_chunk_(const chunk_coords& pos, chunk& c) #else const auto& atlas = pt.x == N/2 || pt.y == N/2 ? _floor2 : _floor1; #endif - x.ground = { atlas, decltype(tile_image::variant)(k % atlas->num_tiles()) }; + x.ground() = { atlas, variant_t(k % atlas->num_tiles()) }; } #ifdef FM_NO_BINDINGS const auto& wall1 = floor1, wall2 = floor1; #endif constexpr auto K = N/2; - c[{K, K }].wall_north = { _wall1, 0 }; - 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, K }].wall_north() = { _wall1, 0 }; + c[{K, K }].wall_west() = { _wall2, 0 }; + c[{K, K+1}].wall_north() = { _wall1, 0 }; + c[{K+1, K }].wall_west() = { _wall2, 0 }; } void app::maybe_initialize_chunk([[maybe_unused]] const chunk_coords& pos, [[maybe_unused]] chunk& c) |