#include "TextureFactory.h" #include "utils/MIODecoder.h" #include "spdlog/spdlog.h" namespace fs = std::filesystem; static const std::unordered_map gTextureTypes = { { "RGBA16", TextureType::RGBA16bpp }, { "RGBA32", TextureType::RGBA32bpp }, { "IA1", TextureType::GrayscaleAlpha4bpp }, { "IA4", TextureType::GrayscaleAlpha4bpp }, { "IA8", TextureType::GrayscaleAlpha8bpp }, { "IA16", TextureType::GrayscaleAlpha16bpp }, }; bool TextureFactory::process(LUS::BinaryWriter* writer, YAML::Node& data, std::vector& buffer) { auto format = data["format"].as(); auto width = data["width"].as(); auto height = data["height"].as(); auto size = data["size"].as(); auto offset = data["offset"].as(); if(!gTextureTypes.contains(format)) { return false; } TextureType type = gTextureTypes.at(format); WRITE_HEADER(LUS::ResourceType::Texture, 0); WRITE_U32(type); WRITE_U32(width); WRITE_U32(height); if(data["mio0"]){ auto mio0 = data["mio0"].as(); auto decoded = MIO0Decoder::Decode(buffer, offset); WRITE_U32(size); WRITE_ARRAY(decoded.data() + mio0, size); } else { WRITE_U32(size); WRITE_ARRAY(buffer.data() + offset, size); } SPDLOG_INFO("Texture: {} {}x{} {}", format, width, height, size); SPDLOG_INFO("Offset: {}", offset); SPDLOG_INFO("Has MIO0: {}", data["mio0"] ? "true" : "false"); return true; }