mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-21 20:27:52 -05:00
Make dumpers works as gdt dumpers and raw dumpers
This commit is contained in:
@ -1162,34 +1162,56 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFul
|
||||
}
|
||||
}
|
||||
|
||||
InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo<WeaponCompleteDef>* asset)
|
||||
{
|
||||
const auto fullDef = std::make_unique<WeaponFullDef>();
|
||||
memset(fullDef.get(), 0, sizeof(WeaponFullDef));
|
||||
CopyToFullDef(asset->Asset(), fullDef.get());
|
||||
|
||||
InfoStringFromWeaponConverter converter(fullDef.get(), weapon_fields, std::extent<decltype(weapon_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
assert(scrStr < asset->m_zone->m_script_strings.size());
|
||||
if (scrStr >= asset->m_zone->m_script_strings.size())
|
||||
return "";
|
||||
|
||||
return asset->m_zone->m_script_strings[scrStr];
|
||||
});
|
||||
|
||||
return converter.Convert();
|
||||
}
|
||||
|
||||
bool AssetDumperWeapon::ShouldDump(XAssetInfo<WeaponCompleteDef>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperWeapon::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperWeapon::CanDumpAsGdtEntry()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperWeapon::GetFileNameForAsset(Zone* zone, XAssetInfo<WeaponCompleteDef>* asset)
|
||||
{
|
||||
return "weapons/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream)
|
||||
GdtEntry AssetDumperWeapon::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset)
|
||||
{
|
||||
auto* fullDef = new WeaponFullDef;
|
||||
memset(fullDef, 0, sizeof(WeaponFullDef));
|
||||
CopyToFullDef(asset->Asset(), fullDef);
|
||||
const auto infoString = CreateInfoString(asset);
|
||||
GdtEntry gdtEntry(asset->m_name, GDF_NAME);
|
||||
infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry);
|
||||
|
||||
InfoStringFromWeaponConverter converter(fullDef, weapon_fields, std::extent<decltype(weapon_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
assert(scrStr < asset->m_zone->m_script_strings.size());
|
||||
if (scrStr >= asset->m_zone->m_script_strings.size())
|
||||
return "";
|
||||
|
||||
return asset->m_zone->m_script_strings[scrStr];
|
||||
});
|
||||
|
||||
const auto infoString = converter.Convert();
|
||||
const auto stringValue = infoString.ToString("WEAPONFILE");
|
||||
stream.write(stringValue.c_str(), stringValue.size());
|
||||
|
||||
delete fullDef;
|
||||
return gdtEntry;
|
||||
}
|
||||
|
||||
void AssetDumperWeapon::DumpRaw(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto infoString = CreateInfoString(asset);
|
||||
const auto stringValue = infoString.ToString(FILE_TYPE_STR);
|
||||
stream.write(stringValue.c_str(), stringValue.size());
|
||||
}
|
||||
|
Reference in New Issue
Block a user