ObjWriting: Use proper extension when dumping image files

This commit is contained in:
Jan 2020-02-19 15:52:07 +01:00
parent 87d760f6d7
commit b436781632
2 changed files with 37 additions and 13 deletions

View File

@ -1,9 +1,30 @@
#include "AssetDumperGfxImage.h"
#include "Image/IwiWriter27.h"
#include "ObjWriting.h"
#include "Image/IwiWriter27.h"
using namespace T6;
AssetDumperGfxImage::AssetDumperGfxImage()
{
switch (ObjWriting::Configuration.ImageOutputFormat)
{
case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS:
break;
case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI:
m_writer = new IwiWriter27();
break;
default:
m_writer = nullptr;
break;
}
}
AssetDumperGfxImage::~AssetDumperGfxImage()
{
delete m_writer;
m_writer = nullptr;
}
bool AssetDumperGfxImage::ShouldDump(GfxImage* asset)
{
return asset->loadedSize > 0;
@ -11,19 +32,10 @@ bool AssetDumperGfxImage::ShouldDump(GfxImage* asset)
std::string AssetDumperGfxImage::GetFileNameForAsset(Zone* zone, GfxImage* asset)
{
return "images/" + std::string(asset->name) + ".iwi";
return "images/" + std::string(asset->name) + m_writer->GetFileExtension();
}
void AssetDumperGfxImage::DumpAsset(Zone* zone, GfxImage* asset, FileAPI::File* out)
{
switch(ObjWriting::Configuration.ImageOutputFormat)
{
case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS:
// TODO this is not yet supported
break;
case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI:
IwiWriter27 writer;
writer.DumpImage(out, asset->texture.texture);
break;
}
}
m_writer->DumpImage(out, asset->texture.texture);
}

View File

@ -2,11 +2,23 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/T6/T6.h"
#include "Image/IImageWriter.h"
class AssetDumperGfxImage final : public AbstractAssetDumper<T6::GfxImage>
{
IImageWriter* m_writer;
protected:
bool ShouldDump(T6::GfxImage* asset) override;
std::string GetFileNameForAsset(Zone* zone, T6::GfxImage* asset) override;
void DumpAsset(Zone* zone, T6::GfxImage* asset, FileAPI::File* out) override;
public:
AssetDumperGfxImage();
~AssetDumperGfxImage();
AssetDumperGfxImage(const AssetDumperGfxImage& other) = delete;
AssetDumperGfxImage(AssetDumperGfxImage&& other) noexcept = delete;
AssetDumperGfxImage& operator=(const AssetDumperGfxImage& other) = delete;
AssetDumperGfxImage& operator=(AssetDumperGfxImage&& other) noexcept = delete;
};