Make dumpers works as gdt dumpers and raw dumpers

This commit is contained in:
Jan
2021-03-06 13:25:08 +01:00
parent fc59a09d02
commit ea7b1eadae
46 changed files with 783 additions and 449 deletions

View File

@ -13,10 +13,10 @@ AssetDumperGfxImage::AssetDumperGfxImage()
switch (ObjWriting::Configuration.ImageOutputFormat)
{
case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS:
m_writer = new DdsWriter();
m_writer = std::make_unique<DdsWriter>();
break;
case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI:
m_writer = new iwi8::IwiWriter();
m_writer = std::make_unique<iwi8::IwiWriter>();
break;
default:
assert(false);
@ -25,24 +25,23 @@ AssetDumperGfxImage::AssetDumperGfxImage()
}
}
AssetDumperGfxImage::~AssetDumperGfxImage()
{
delete m_writer;
m_writer = nullptr;
}
bool AssetDumperGfxImage::ShouldDump(XAssetInfo<GfxImage>* asset)
{
const auto* image = asset->Asset();
return image->cardMemory.platform[0] > 0;
}
bool AssetDumperGfxImage::CanDumpAsRaw()
{
return true;
}
std::string AssetDumperGfxImage::GetFileNameForAsset(Zone* zone, XAssetInfo<GfxImage>* asset)
{
return "images/" + asset->m_name + m_writer->GetFileExtension();
}
void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream)
void AssetDumperGfxImage::DumpRaw(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream)
{
const auto* image = asset->Asset();
m_writer->DumpImage(stream, image->texture.texture);