diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-08-27 11:11:33 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-08-27 13:13:57 +0200 |
commit | 312c6854324992572f4aa19976ca04d204705aad (patch) | |
tree | 52d63d4e2c042dc9f441b09fabc91a941ca1ef12 /loader | |
parent | 1c5eb68d2d791c87a2030e4b17fb26bdd7931888 (diff) |
loader: add atlas path maker function
Diffstat (limited to 'loader')
-rw-r--r-- | loader/atlas.cpp | 16 | ||||
-rw-r--r-- | loader/loader.hpp | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/loader/atlas.cpp b/loader/atlas.cpp index cf3d310e..50645579 100644 --- a/loader/atlas.cpp +++ b/loader/atlas.cpp @@ -13,6 +13,22 @@ #include <Corrade/Utility/Path.h> #include <Magnum/Trade/ImageData.h> +namespace floormat { + +StringView loader_::make_atlas_path(char(&buf)[FILENAME_MAX], StringView dir, StringView name) +{ + fm_soft_assert(!dir || dir[dir.size()-1] == '/'); + auto name_noext = Path::splitExtension(name).first(); + const auto dirsiz = dir.size(), namesiz = name_noext.size(); + fm_soft_assert(dirsiz + namesiz + 1 < FILENAME_MAX); + std::memcpy(buf, dir.data(), dirsiz); + std::memcpy(&buf[dirsiz], name_noext.data(), namesiz); + buf[dirsiz + namesiz] = '\0'; + return StringView{buf}; +} + +} // namespace floormat + namespace floormat::loader_detail { std::shared_ptr<tile_atlas> loader_impl::tile_atlas(StringView name, Vector2ub size, Optional<pass_mode> pass) noexcept(false) diff --git a/loader/loader.hpp b/loader/loader.hpp index 3ed519e9..937ef828 100644 --- a/loader/loader.hpp +++ b/loader/loader.hpp @@ -35,6 +35,7 @@ struct loader_ static StringView strip_prefix(StringView name); virtual const vobj_info& vobj(StringView name) = 0; virtual ArrayView<struct vobj_info> vobj_list() = 0; + static StringView make_atlas_path(char(&buf)[FILENAME_MAX], StringView dir, StringView name); loader_(const loader_&) = delete; loader_& operator=(const loader_&) = delete; |