diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2021-10-05 13:55:55 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-05 12:55:55 -0400 |
| commit | 4994e732406ffa2942f9c9ea6ff14c424cd0b896 (patch) | |
| tree | 0b40b20db17139c58f5c205643940494c20cbc43 /ZAPD/ZBlob.cpp | |
| parent | 17fca1e0cdda5476c4158940ca405b7eb250ec72 (diff) | |
ZResource cleanup (#178)
* Add some general use methods to ZResource
* change zarray
* adapt ztexture
* Clean up ZCollision, ZPath, ZScalar and ZVector
* cleanup background
* cleanup zmtx
* Clean up skeleton and limb
* mark GetSourceTypeName as abstract
* Remove redundant ExtractFromXML
* Reorder stuff to minimize changes in github
* remove extra ZDisplayList constructor
* Remove using namespace tinyxml2;
* run formatter
* Add some brief descriptions, and remove some methods
* Remove trivials GetSourceOutputCode and a bit of cleanup
* Add more descriptions to methods
* Fix blob build
* improve descriptions a bit
* Run formatter
* Now builds
* Add attributes and fix some warnings
* format
* fix merge issues
* fix merge issues and some clang warnings
* format
* Run formatter
* Fix merge issues
* Format
* add SEGMENTED_NULL
* Fix merge issues
* Run format
* dumb fix
* whoops
* format
* whoops
Diffstat (limited to 'ZAPD/ZBlob.cpp')
| -rw-r--r-- | ZAPD/ZBlob.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/ZAPD/ZBlob.cpp b/ZAPD/ZBlob.cpp index 3c18733..1cdc226 100644 --- a/ZAPD/ZBlob.cpp +++ b/ZAPD/ZBlob.cpp @@ -1,12 +1,12 @@ #include "ZBlob.h" + +#include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/File.h" #include "Utils/Path.h" #include "Utils/StringHelper.h" #include "ZFile.h" -using namespace tinyxml2; - REGISTER_ZFILENODE(Blob, ZBlob); ZBlob::ZBlob(ZFile* nParent) : ZResource(nParent) @@ -14,19 +14,6 @@ ZBlob::ZBlob(ZFile* nParent) : ZResource(nParent) RegisterRequiredAttribute("Size"); } -// Build Source File Mode -ZBlob* ZBlob::BuildFromXML(XMLElement* reader, const std::string& inFolder, bool readFile) -{ - ZBlob* blob = new ZBlob(nullptr); - - blob->ParseXML(reader); - - if (readFile) - blob->blobData = File::ReadAllBytes(inFolder + "/" + blob->name + ".bin"); - - return blob; -} - ZBlob* ZBlob::FromFile(const std::string& filePath) { ZBlob* blob = new ZBlob(nullptr); @@ -49,14 +36,34 @@ void ZBlob::ParseRawData() parent->GetRawData().begin() + rawDataIndex + blobSize); } -std::string ZBlob::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) +Declaration* ZBlob::DeclareVar(const std::string& prefix, + [[maybe_unused]] const std::string& bodyStr) +{ + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + std::string path = Path::GetFileNameWithoutExtension(auxName); + + std::string assetOutDir = + (Globals::Instance->outputPath / Path::GetFileNameWithoutExtension(GetOutName())).string(); + + std::string incStr = + StringHelper::Sprintf("%s.%s.inc", assetOutDir.c_str(), GetExternalExtension().c_str()); + + return parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(), + GetSourceTypeName(), auxName, 0); +} + +std::string ZBlob::GetBodySourceCode() const { std::string sourceOutput = ""; for (size_t i = 0; i < blobData.size(); i += 1) { if (i % 16 == 0) - sourceOutput += " "; + sourceOutput += "\t"; sourceOutput += StringHelper::Sprintf("0x%02X, ", blobData[i]); |
