diff options
| author | KiritoDv <kiritodev01@gmail.com> | 2023-08-19 23:55:59 -0600 |
|---|---|---|
| committer | KiritoDv <kiritodev01@gmail.com> | 2023-08-19 23:55:59 -0600 |
| commit | 15a0cf5498b60fa1442d049dbe5bb856022b5641 (patch) | |
| tree | 16299bd2cb1613297ffdc99ba0a992ebdd2aeac0 /src/Companion.cpp | |
| parent | f3402d8c9fe789d3f8a43edbd2a07e06b17a292b (diff) | |
Added support to extract skyboxes and cake
Diffstat (limited to 'src/Companion.cpp')
| -rw-r--r-- | src/Companion.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/Companion.cpp b/src/Companion.cpp index 2391ae2..9b38118 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -3,6 +3,7 @@ #include "storm/SWrapper.h" #include "utils/MIODecoder.h" #include "factories/RawFactory.h" +#include "factories/BlobFactory.h" #include "factories/TextureFactory.h" #include <fstream> @@ -14,7 +15,9 @@ using json = nlohmann::json; namespace fs = std::filesystem; static const std::unordered_map<std::string, RawFactory*> gFactories = { - { ".png", new TextureFactory() } + { ".png", new TextureFactory() }, + { ".bin", new BlobFactory(LUS::ResourceType::Blob) }, + { ".sbox", new BlobFactory(LUS::ResourceType::Blob, true) }, }; void Companion::Start() { @@ -48,14 +51,29 @@ void Companion::ProcessAssets() { { "path", path }, { "offsets", data } }; - if(!gFactories.at(extension)->process(&write, entry, this->gRomData)){ + RawFactory* factory = gFactories.at(extension); + + if(!factory->process(&write, entry, this->gRomData)){ std::cout << "Failed to process " << asset << '\n'; continue; } + std::cout << "Processed " << path << std::endl; + bool isTexture = typeid(*factory) == typeid(TextureFactory); + auto buffer = write.ToVector(); // TODO: Change this that we all know its going to crash with other assets - wrapper.CreateFile(path.substr(0, path.find_last_of('.')), buffer); + wrapper.CreateFile(isTexture ? path.substr(0, path.find_last_of('.')) : path, buffer); + + if(!isTexture) { + // Write to file too + std::string dpath = "debug/" + path; + fs::create_directories(fs::path(dpath).parent_path()); + std::ofstream output(dpath, std::ios::binary); + output.write((char*)buffer.data(), buffer.size()); + output.close(); + } + write.Close(); } |
