mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-22 18:39:46 +00:00
make 'animations' folder default, 'animation' an alias
This commit is contained in:
parent
0f71e1a152
commit
0954057636
3 changed files with 16 additions and 2 deletions
|
|
@ -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"]);
|
||||
|
|
|
|||
|
|
@ -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<AssetCfg>&
|
||||
) {
|
||||
auto path = paths.find(filename + ".vca");
|
||||
auto path = find_animation(paths, filename);
|
||||
loader.attachToFile(path, {name, AssetType::ANIMATION});
|
||||
|
||||
if (io::is_regular_file(path)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue