diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-11 13:54:53 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-11 14:11:47 +0100 |
commit | 7867213a01fcabb1f05b1836c2ca59dc3bb2132f (patch) | |
tree | 44af754bed0278c8bf3435df6278bd291c3043e5 /editor | |
parent | 74cf06b6b217eff32a547cf73f051f27e6b80919 (diff) |
rename tile_atlas -> ground_atlas
Diffstat (limited to 'editor')
-rw-r--r-- | editor/app.hpp | 2 | ||||
-rw-r--r-- | editor/editor.cpp | 6 | ||||
-rw-r--r-- | editor/editor.hpp | 10 | ||||
-rw-r--r-- | editor/ground-editor.cpp (renamed from editor/tile-editor.cpp) | 38 | ||||
-rw-r--r-- | editor/ground-editor.hpp (renamed from editor/tile-editor.hpp) | 22 | ||||
-rw-r--r-- | editor/imgui-editors.cpp | 4 | ||||
-rw-r--r-- | editor/update.cpp | 10 |
7 files changed, 46 insertions, 46 deletions
diff --git a/editor/app.hpp b/editor/app.hpp index 45735400..09198c36 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -21,7 +21,7 @@ namespace floormat { struct chunk; struct floormat_main; -class tile_atlas; +class ground_atlas; struct fm_settings; class anim_atlas; struct critter; diff --git a/editor/editor.cpp b/editor/editor.cpp index de2e690e..86a180b5 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -191,7 +191,7 @@ void editor::set_mode(editor_mode mode) on_release(); } -const tile_editor* editor::current_ground_editor() const noexcept +const ground_editor* editor::current_ground_editor() const noexcept { switch (_mode) { @@ -229,9 +229,9 @@ const vobj_editor* editor::current_vobj_editor() const noexcept return nullptr; } -tile_editor* editor::current_ground_editor() noexcept +ground_editor* editor::current_ground_editor() noexcept { - return const_cast<tile_editor*>(static_cast<const editor&>(*this).current_ground_editor()); + return const_cast<ground_editor*>(static_cast<const editor&>(*this).current_ground_editor()); } wall_editor* editor::current_wall_editor() noexcept diff --git a/editor/editor.hpp b/editor/editor.hpp index dc897bc3..fae85c2f 100644 --- a/editor/editor.hpp +++ b/editor/editor.hpp @@ -4,7 +4,7 @@ #include "src/tile-image.hpp" #include "src/scenery.hpp" #include "editor-enums.hpp" -#include "tile-editor.hpp" +#include "ground-editor.hpp" #include "wall-editor.hpp" #include "scenery-editor.hpp" #include "vobj-editor.hpp" @@ -16,7 +16,7 @@ namespace floormat { struct world; class anim_atlas; -class tile_atlas; +class ground_atlas; struct app; struct editor final @@ -26,8 +26,8 @@ struct editor final [[nodiscard]] editor_mode mode() const noexcept { return _mode; } void set_mode(editor_mode mode); - tile_editor* current_ground_editor() noexcept; - const tile_editor* current_ground_editor() const noexcept; + ground_editor* current_ground_editor() noexcept; + const ground_editor* current_ground_editor() const noexcept; wall_editor* current_wall_editor() noexcept; const wall_editor* current_wall_editor() const noexcept; scenery_editor* current_scenery_editor() noexcept; @@ -57,7 +57,7 @@ private: app* _app; - tile_editor _floor; + ground_editor _floor; wall_editor _wall; scenery_editor _scenery; vobj_editor _vobj; diff --git a/editor/tile-editor.cpp b/editor/ground-editor.cpp index 1b766208..0f67853e 100644 --- a/editor/tile-editor.cpp +++ b/editor/ground-editor.cpp @@ -1,5 +1,5 @@ -#include "tile-editor.hpp" -#include "src/tile-atlas.hpp" +#include "ground-editor.hpp" +#include "src/ground-atlas.hpp" #include "src/world.hpp" #include "src/random.hpp" #include "keys.hpp" @@ -10,14 +10,14 @@ namespace floormat { -tile_editor::tile_editor() +ground_editor::ground_editor() { load_atlases(); } -void tile_editor::load_atlases() +void ground_editor::load_atlases() { - for (const auto& atlas : loader.tile_atlases("floor.json"_s)) + for (const auto& atlas : loader.ground_atlases("floor.json"_s)) { auto& [_, vec] = _permutation; vec.reserve(atlas->num_tiles()); @@ -25,7 +25,7 @@ void tile_editor::load_atlases() } } -std::shared_ptr<tile_atlas> tile_editor::maybe_atlas(StringView str) +std::shared_ptr<ground_atlas> ground_editor::maybe_atlas(StringView str) { if (auto it = _atlases.find(str); it != _atlases.end()) return it->second; @@ -33,7 +33,7 @@ std::shared_ptr<tile_atlas> tile_editor::maybe_atlas(StringView str) return nullptr; } -std::shared_ptr<tile_atlas> tile_editor::atlas(StringView str) +std::shared_ptr<ground_atlas> ground_editor::atlas(StringView str) { if (auto ptr = maybe_atlas(str)) return ptr; @@ -41,16 +41,16 @@ std::shared_ptr<tile_atlas> tile_editor::atlas(StringView str) fm_throw("no such atlas: {}"_cf, str); } -StringView tile_editor::name() const noexcept { return "floor"_s; } +StringView ground_editor::name() const noexcept { return "floor"_s; } -void tile_editor::clear_selection() +void ground_editor::clear_selection() { _selected_tile = {}; _permutation = {}; _selection_mode = sel_none; } -void tile_editor::select_tile(const std::shared_ptr<tile_atlas>& atlas, size_t variant) +void ground_editor::select_tile(const std::shared_ptr<ground_atlas>& atlas, size_t variant) { fm_assert(atlas); clear_selection(); @@ -58,7 +58,7 @@ void tile_editor::select_tile(const std::shared_ptr<tile_atlas>& atlas, size_t v _selected_tile = { atlas, variant_t(variant % atlas->num_tiles()) }; } -void tile_editor::select_tile_permutation(const std::shared_ptr<tile_atlas>& atlas) +void ground_editor::select_tile_permutation(const std::shared_ptr<ground_atlas>& atlas) { fm_assert(atlas); clear_selection(); @@ -66,19 +66,19 @@ void tile_editor::select_tile_permutation(const std::shared_ptr<tile_atlas>& atl _permutation = { atlas, {} }; } -bool tile_editor::is_tile_selected(const std::shared_ptr<const tile_atlas>& atlas, size_t variant) const +bool ground_editor::is_tile_selected(const std::shared_ptr<const ground_atlas>& atlas, size_t variant) const { return atlas && _selection_mode == sel_tile && _selected_tile && atlas == _selected_tile.atlas && variant == _selected_tile.variant; } -bool tile_editor::is_permutation_selected(const std::shared_ptr<const tile_atlas>& atlas) const +bool ground_editor::is_permutation_selected(const std::shared_ptr<const ground_atlas>& atlas) const { const auto& [perm, _] = _permutation; return atlas && _selection_mode == sel_perm && perm == atlas; } -bool tile_editor::is_atlas_selected(const std::shared_ptr<const tile_atlas>& atlas) const +bool ground_editor::is_atlas_selected(const std::shared_ptr<const ground_atlas>& atlas) const { switch (_selection_mode) { @@ -92,7 +92,7 @@ bool tile_editor::is_atlas_selected(const std::shared_ptr<const tile_atlas>& atl } } -bool tile_editor::is_anything_selected() const +bool ground_editor::is_anything_selected() const { return _selection_mode != sel_none; } @@ -109,7 +109,7 @@ void fisher_yates(T begin, T end) } } -tile_image_proto tile_editor::get_selected_perm() +tile_image_proto ground_editor::get_selected_perm() { auto& [atlas, vec] = _permutation; const auto N = (variant_t)atlas->num_tiles(); @@ -126,7 +126,7 @@ tile_image_proto tile_editor::get_selected_perm() return {atlas, idx}; } -tile_image_proto tile_editor::get_selected() +tile_image_proto ground_editor::get_selected() { switch (_selection_mode) { @@ -142,14 +142,14 @@ tile_image_proto tile_editor::get_selected() } } -void tile_editor::place_tile(world& world, global_coords pos, const tile_image_proto& img) +void ground_editor::place_tile(world& world, global_coords pos, const tile_image_proto& img) { auto [c, t] = world[pos]; c.mark_ground_modified(); t.ground() = img; } -auto tile_editor::check_snap(int mods) const -> editor_snap_mode +auto ground_editor::check_snap(int mods) const -> editor_snap_mode { const bool ctrl = mods & kmod_ctrl, shift = mods & kmod_shift; diff --git a/editor/tile-editor.hpp b/editor/ground-editor.hpp index a33ed848..46c9dc3a 100644 --- a/editor/tile-editor.hpp +++ b/editor/ground-editor.hpp @@ -12,18 +12,18 @@ namespace floormat { struct world; -class tile_editor final +class ground_editor final { enum selection_mode : unsigned char { sel_none, sel_tile, sel_perm, }; struct tuple final { - std::shared_ptr<tile_atlas> atlas; + std::shared_ptr<ground_atlas> atlas; std::vector<decltype(tile_image_proto::variant)> variant; }; - std::map<StringView, std::shared_ptr<tile_atlas>> _atlases; + std::map<StringView, std::shared_ptr<ground_atlas>> _atlases; tile_image_proto _selected_tile; tuple _permutation; selection_mode _selection_mode = sel_none; @@ -32,9 +32,9 @@ class tile_editor final tile_image_proto get_selected_perm(); public: - tile_editor(); - std::shared_ptr<tile_atlas> maybe_atlas(StringView str); - std::shared_ptr<tile_atlas> atlas(StringView str); + ground_editor(); + std::shared_ptr<ground_atlas> maybe_atlas(StringView str); + std::shared_ptr<ground_atlas> atlas(StringView str); auto cbegin() const noexcept { return _atlases.cbegin(); } auto cend() const noexcept { return _atlases.cend(); } auto begin() const noexcept { return _atlases.cbegin(); } @@ -42,11 +42,11 @@ public: StringView name() const noexcept; void clear_selection(); - void select_tile(const std::shared_ptr<tile_atlas>& atlas, 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, 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; + void select_tile(const std::shared_ptr<ground_atlas>& atlas, size_t variant); + void select_tile_permutation(const std::shared_ptr<ground_atlas>& atlas); + bool is_tile_selected(const std::shared_ptr<const ground_atlas>& atlas, size_t variant) const; + bool is_permutation_selected(const std::shared_ptr<const ground_atlas>& atlas) const; + bool is_atlas_selected(const std::shared_ptr<const ground_atlas>& atlas) const; bool is_anything_selected() const; tile_image_proto get_selected(); void place_tile(world& world, global_coords pos, const tile_image_proto& img); diff --git a/editor/imgui-editors.cpp b/editor/imgui-editors.cpp index 4ffb74ba..2e585d6b 100644 --- a/editor/imgui-editors.cpp +++ b/editor/imgui-editors.cpp @@ -2,7 +2,7 @@ #include "compat/format.hpp" #include "imgui-raii.hpp" #include "src/anim-atlas.hpp" -#include "src/tile-atlas.hpp" +#include "src/ground-atlas.hpp" #include "src/wall-atlas.hpp" #include "loader/loader.hpp" #include "floormat/main.hpp" @@ -51,7 +51,7 @@ void select_tile(wall_editor& wa, const wall_info* sc) { wa.select_atlas(sc->atl auto get_texcoords(const auto&, anim_atlas& atlas) { return atlas.texcoords_for_frame(atlas.first_rotation(), 0, !atlas.group(atlas.first_rotation()).mirror_from.isEmpty()); } auto get_texcoords(const wall_info* w, wall_atlas& atlas) { auto sz = get_size(w, atlas); return Quads::texcoords_at({}, sz, atlas.image_size()); }; -void draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const std::shared_ptr<tile_atlas>& atlas, Vector2 dpi) +void draw_editor_tile_pane_atlas(ground_editor& ed, StringView name, const std::shared_ptr<ground_atlas>& atlas, Vector2 dpi) { const auto b = push_id("tile-pane"); diff --git a/editor/update.cpp b/editor/update.cpp index e80a5318..1140ad47 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -1,6 +1,6 @@ #include "app.hpp" #include "src/world.hpp" -#include "src/tile-atlas.hpp" +#include "src/ground-atlas.hpp" #include "src/anim-atlas.hpp" #include "main/clickable.hpp" #include "floormat/events.hpp" @@ -17,10 +17,10 @@ namespace floormat { void app::maybe_initialize_chunk_(const chunk_coords_& pos, chunk& c) { - auto floor1 = loader.tile_atlas("floor-tiles", {44, 4}, pass_mode::pass); - auto floor2 = loader.tile_atlas("metal1", {2, 2}, pass_mode::pass); - auto wall1 = loader.tile_atlas("wood2", {2, 1}, pass_mode::blocked); - auto wall2 = loader.tile_atlas("wood1", {2, 1}, pass_mode::blocked); + auto floor1 = loader.ground_atlas("floor-tiles", { 44, 4 }, pass_mode::pass); + auto floor2 = loader.ground_atlas("metal1", { 2, 2 }, pass_mode::pass); + auto wall1 = loader.ground_atlas("wood2", { 2, 1 }, pass_mode::blocked); + auto wall2 = loader.ground_atlas("wood1", { 2, 1 }, pass_mode::blocked); auto door = loader.anim_atlas("door-close", loader.SCENERY_PATH); auto table = loader.anim_atlas("table", loader.SCENERY_PATH); auto control_panel = loader.anim_atlas("control-panel", loader.SCENERY_PATH); |