diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-28 18:31:18 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-28 18:31:18 +0200 |
commit | 1b84fc144f77c4ebef6fdc0a476410420e0a95b3 (patch) | |
tree | 62d019065f4e704ca33b8808e6d76b2fec640da1 /editor | |
parent | 7c02d3b8f1e6ec4ee82bdf1220da431b1cd1231e (diff) |
refactoring work
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor.cpp | 7 | ||||
-rw-r--r-- | editor/editor.hpp | 4 | ||||
-rw-r--r-- | editor/update.cpp | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index b3e3aec6..0cd15d17 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -66,7 +66,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, variant % atlas->num_tiles() }; + _selected_tile = { atlas, decltype(tile_image::variant)(variant % atlas->num_tiles()) }; } void tile_editor::select_tile_permutation(const std::shared_ptr<tile_atlas>& atlas) @@ -118,12 +118,13 @@ void fisher_yates(T begin, T end) tile_image tile_editor::get_selected_perm() { auto& [atlas, vec] = _permutation; - const std::size_t N = atlas->num_tiles(); + using variant_t = decltype(tile_image::variant); + const auto N = (variant_t)atlas->num_tiles(); if (N == 0) return {}; if (vec.empty()) { - for (std::size_t i = 0; i < N; i++) + for (variant_t i = 0; i < N; i++) vec.push_back(i); fisher_yates(vec.begin(), vec.end()); } diff --git a/editor/editor.hpp b/editor/editor.hpp index 4b1ba124..9203cd6e 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.hpp" +#include "tile-image.hpp" #include <cstdint> #include <tuple> @@ -33,7 +33,7 @@ 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<std::size_t>> _permutation; + 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{}; diff --git a/editor/update.cpp b/editor/update.cpp index d4bfa2d5..f22ad522 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -18,7 +18,7 @@ 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_image = { atlas, k % atlas->num_tiles() }; + x.ground_image = { atlas, decltype(tile_image::variant)(k % atlas->num_tiles()) }; } #ifdef FM_NO_BINDINGS const auto& wall1 = floor1, wall2 = floor1; |