Skip to content

Commit

Permalink
Added blob modding
Browse files Browse the repository at this point in the history
  • Loading branch information
KiritoDv committed Oct 12, 2024
1 parent bca2ea5 commit 0a3be4e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/factories/BlobFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ void BlobBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData
writer.Finish(write);
}

void BlobModdingExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
auto writer = LUS::BinaryWriter();

*replacement += ".bin";

auto data = std::static_pointer_cast<RawBuffer>(raw)->mBuffer;
writer.Write((char*) data.data(), data.size());
writer.Finish(write);
}

std::optional<std::shared_ptr<IParsedData>> BlobFactory::parse(std::vector<uint8_t>& buffer, YAML::Node& node) {
auto size = GetSafeNode<size_t>(node, "size");
auto [_, segment] = Decompressor::AutoDecode(node, buffer);
Expand Down
9 changes: 7 additions & 2 deletions src/factories/BlobFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class BlobCodeExporter : public BaseExporter {
void Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class BlobModdingExporter : public BaseExporter {
void Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class BlobFactory : public BaseFactory {
public:
std::optional<std::shared_ptr<IParsedData>> parse(std::vector<uint8_t>& buffer, YAML::Node& data) override;
Expand All @@ -20,7 +24,8 @@ class BlobFactory : public BaseFactory {
return {
REGISTER(Binary, BlobBinaryExporter)
REGISTER(Code, BlobCodeExporter)
REGISTER(Modding, BlobModdingExporter)
};
}
bool SupportModdedAssets() override { return false; }
};
bool SupportModdedAssets() override { return true; }
};

0 comments on commit 0a3be4e

Please sign in to comment.