2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-30 16:27:47 +00:00

chore: update usages of AddAsset for template asset struct api

This commit is contained in:
Jan
2024-04-23 00:06:48 +02:00
parent 931fe695e1
commit ae43a994b9
49 changed files with 66 additions and 84 deletions

View File

@@ -29,7 +29,7 @@ bool AssetLoaderLocalizeEntry::LoadFromRaw(
localizeEntry->name = memory->Dup(entry.m_key.c_str());
localizeEntry->value = memory->Dup(entry.m_value.c_str());
manager->AddAsset(ASSET_TYPE_LOCALIZE_ENTRY, entry.m_key, localizeEntry);
manager->AddAsset<AssetLocalize>(entry.m_key, localizeEntry);
});
return commonLoader.LoadLocalizeAsset(assetName, searchPath, manager, zone);

View File

@@ -57,12 +57,11 @@ namespace IW5
}
menus.push_back(menuAsset);
auto* menuAssetInfo =
manager->AddAsset(ASSET_TYPE_MENU, menu->m_name, menuAsset, std::move(converter.GetDependencies()), std::vector<scr_string_t>());
auto* menuAssetInfo = manager->AddAsset<AssetMenu>(menu->m_name, menuAsset, std::move(converter.GetDependencies()));
if (menuAssetInfo)
{
allMenusOfFile.push_back(reinterpret_cast<XAssetInfo<menuDef_t>*>(menuAssetInfo));
allMenusOfFile.push_back(menuAssetInfo);
menuListDependencies.push_back(menuAssetInfo);
}
@@ -223,7 +222,7 @@ bool AssetLoaderMenuList::LoadFromRaw(
auto* menuListAsset = MenuLoader::CreateMenuListAsset(assetName, memory, menus);
if (menuListAsset)
manager->AddAsset(ASSET_TYPE_MENULIST, assetName, menuListAsset, menuListDependencies, std::vector<scr_string_t>());
manager->AddAsset<AssetMenuList>(assetName, menuListAsset, menuListDependencies);
return true;
}

View File

@@ -74,7 +74,7 @@ bool AssetLoaderRawFile::LoadFromRaw(
deflateEnd(&zs);
manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile);
manager->AddAsset<AssetRawFile>(assetName, rawFile);
return true;
}

View File

@@ -72,7 +72,7 @@ bool AssetLoaderScriptFile::LoadFromRaw(
scriptFile->bytecode = memory->Alloc<unsigned char>(scriptFile->bytecodeLen);
memcpy(scriptFile->bytecode, fileBuffer.get() + offset, scriptFile->bytecodeLen);
manager->AddAsset(ASSET_TYPE_SCRIPTFILE, assetName, scriptFile);
manager->AddAsset<AssetScript>(assetName, scriptFile);
return true;
}

View File

@@ -34,7 +34,7 @@ bool AssetLoaderStringTable::LoadFromRaw(
string_table::StringTableLoaderV2<StringTable, Common::StringTable_HashString> loader;
auto* stringTable = loader.LoadFromStream(assetName, *memory, *file.m_stream);
manager->AddAsset(ASSET_TYPE_STRINGTABLE, assetName, stringTable);
manager->AddAsset<AssetStringTable>(assetName, stringTable);
return true;
}

View File

@@ -817,12 +817,8 @@ namespace
CalculateWeaponFields(weaponFullDef, memory);
manager->AddAsset(ASSET_TYPE_WEAPON,
assetName,
&weaponFullDef->weapCompleteDef,
converter.GetDependencies(),
converter.GetUsedScriptStrings(),
converter.GetIndirectAssetReferences());
manager->AddAsset<AssetWeapon>(
assetName, &weaponFullDef->weapCompleteDef, converter.GetDependencies(), converter.GetUsedScriptStrings(), converter.GetIndirectAssetReferences());
return true;
}

View File

@@ -37,8 +37,7 @@ bool AssetLoaderWeaponAttachment::LoadFromRaw(
std::vector<XAssetInfoGeneric*> dependencies;
std::vector<IndirectAssetReference> indirectAssetReferences;
if (LoadWeaponAttachmentAsJson(*file.m_stream, *attachment, memory, manager, dependencies, indirectAssetReferences))
manager->AddAsset(
ASSET_TYPE_ATTACHMENT, assetName, attachment, std::move(dependencies), std::vector<scr_string_t>(), std::move(indirectAssetReferences));
manager->AddAsset<AssetAttachment>(assetName, attachment, std::move(dependencies), std::vector<scr_string_t>(), std::move(indirectAssetReferences));
else
std::cerr << "Failed to load attachment \"" << assetName << "\"\n";