diff --git a/src/assets/AssetsLoader.cpp b/src/assets/AssetsLoader.cpp index 04bde9a6f..6e20f214a 100644 --- a/src/assets/AssetsLoader.cpp +++ b/src/assets/AssetsLoader.cpp @@ -224,6 +224,7 @@ void AssetsLoader::processPreloadList(AssetType tag, const dv::value& list) { void AssetsLoader::processPreloadConfig(const io::path& file) { auto root = io::read_json(file); + processPreloadList(AssetType::ANIMATION, root["animations"]); processPreloadList(AssetType::ANIMATION, root["animation"]); processPreloadList(AssetType::ATLAS, root["atlases"]); processPreloadList(AssetType::FONT, root["fonts"]); diff --git a/src/assets/assetload_funcs.cpp b/src/assets/assetload_funcs.cpp index f6080cd1c..e76e9fb38 100644 --- a/src/assets/assetload_funcs.cpp +++ b/src/assets/assetload_funcs.cpp @@ -44,6 +44,18 @@ static bool load_animated_texture( Atlas* dstAtlas ); +static io::path find_animation(const ResPaths& paths, const std::string& filename) { + auto path = paths.find(filename + ".vca"); + const auto prefix = ANIMATION_FOLDER + "/"; + if (io::is_regular_file(path) || filename.rfind(prefix, 0) != 0) { + return path; + } + auto alias = paths.find( + ANIMATION_FOLDER_ALIAS + "/" + filename.substr(prefix.length()) + ".vca" + ); + return io::is_regular_file(alias) ? alias : path; +} + assetload::postfunc assetload::animation( AssetsLoader& loader, const ResPaths& paths, @@ -51,7 +63,7 @@ assetload::postfunc assetload::animation( const std::string& name, const std::shared_ptr& ) { - auto path = paths.find(filename + ".vca"); + auto path = find_animation(paths, filename); loader.attachToFile(path, {name, AssetType::ANIMATION}); if (io::is_regular_file(path)) { diff --git a/src/constants.hpp b/src/constants.hpp index 826c2f1a8..4cc29bbdf 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -75,7 +75,8 @@ inline constexpr int DEFAULT_FONT_SIZE = 16; inline constexpr int DEFAULT_PRE_RENDER_FONT_PAGES = 1; // must be at least 1 -inline const std::string ANIMATION_FOLDER = "animation"; +inline const std::string ANIMATION_FOLDER = "animations"; +inline const std::string ANIMATION_FOLDER_ALIAS = "animation"; inline const std::string FONTS_FOLDER = "fonts"; inline const std::string LAYOUTS_FOLDER = "layouts"; inline const std::string MODELS_FOLDER = "models";