mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
overwrite assets in preload.json
This commit is contained in:
parent
8d7fab1f2f
commit
6f7aeb504f
2 changed files with 9 additions and 5 deletions
|
|
@ -47,9 +47,10 @@ void AssetsLoader::add(
|
|||
AssetType tag,
|
||||
const std::string& filename,
|
||||
const std::string& alias,
|
||||
std::shared_ptr<AssetCfg> settings
|
||||
std::shared_ptr<AssetCfg> settings,
|
||||
bool overwrite
|
||||
) {
|
||||
if (enqueued.find({tag, alias}) != enqueued.end()){
|
||||
if (!overwrite && enqueued.find({tag, alias}) != enqueued.end()){
|
||||
return;
|
||||
}
|
||||
entries.push(aloader_entry {tag, filename, alias, std::move(settings)});
|
||||
|
|
@ -154,11 +155,12 @@ void AssetsLoader::processPreload(
|
|||
std::string defFolder = assets_def_folder(tag);
|
||||
std::string path = defFolder + "/" + name;
|
||||
if (map == nullptr) {
|
||||
add(tag, path, name);
|
||||
add(tag, path, name, nullptr, true);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<AssetCfg> config = nullptr;
|
||||
map.at("path").get(path);
|
||||
logger.debug() << "processing preload " << util::quote(name) << " path: " << util::quote(path);
|
||||
switch (tag) {
|
||||
case AssetType::SOUND: {
|
||||
bool keepPCM = false;
|
||||
|
|
@ -196,7 +198,7 @@ void AssetsLoader::processPreload(
|
|||
default:
|
||||
break;
|
||||
}
|
||||
add(tag, path, name, std::move(config));
|
||||
add(tag, path, name, std::move(config), true);
|
||||
}
|
||||
|
||||
void AssetsLoader::processPreloadList(AssetType tag, const dv::value& list) {
|
||||
|
|
@ -218,6 +220,7 @@ void AssetsLoader::processPreloadList(AssetType tag, const dv::value& list) {
|
|||
}
|
||||
|
||||
void AssetsLoader::processPreloadConfig(const io::path& file) {
|
||||
logger.debug() << "===== PRELOAD FILE: " << file.string();
|
||||
auto root = io::read_json(file);
|
||||
processPreloadList(AssetType::ATLAS, root["atlases"]);
|
||||
processPreloadList(AssetType::FONT, root["fonts"]);
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@ public:
|
|||
AssetType tag,
|
||||
const std::string& filename,
|
||||
const std::string& alias,
|
||||
std::shared_ptr<AssetCfg> settings = nullptr
|
||||
std::shared_ptr<AssetCfg> settings = nullptr,
|
||||
bool overwrite = false
|
||||
);
|
||||
|
||||
bool hasNext() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue