diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.cpp index 39757864..7b945095 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.cpp @@ -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; - } -} \ No newline at end of file + m_writer->DumpImage(out, asset->texture.texture); +} diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.h index 0944dfe7..cec25771 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.h +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.h @@ -2,11 +2,23 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" +#include "Image/IImageWriter.h" class AssetDumperGfxImage final : public AbstractAssetDumper { + 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; }; \ No newline at end of file