From 4994e732406ffa2942f9c9ea6ff14c424cd0b896 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Tue, 5 Oct 2021 13:55:55 -0300 Subject: 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 --- ZAPD/ZTextureAnimation.cpp | 58 ++++++---------------------------------------- 1 file changed, 7 insertions(+), 51 deletions(-) (limited to 'ZAPD/ZTextureAnimation.cpp') diff --git a/ZAPD/ZTextureAnimation.cpp b/ZAPD/ZTextureAnimation.cpp index deee4e3..cd2ca1b 100644 --- a/ZAPD/ZTextureAnimation.cpp +++ b/ZAPD/ZTextureAnimation.cpp @@ -125,32 +125,6 @@ ZTextureAnimationParams::GetDefaultName([[maybe_unused]] const std::string& pref return "ShouldNotBeVIsible"; } -void ZTextureAnimationParams::DeclareVar(const std::string& prefix, - const std::string& bodyStr) const -{ - std::string auxName = name; - - if (name == "") - auxName = GetDefaultName(prefix); - - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), auxName, bodyStr); -} - -std::string ZTextureAnimationParams::GetSourceOutputCode(const std::string& prefix) -{ - std::string bodyStr = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - - if (decl == nullptr) - DeclareVar(prefix, bodyStr); - else - decl->text = bodyStr; - - return ""; -} - ZResourceType ZTextureAnimationParams::GetResourceType() const { return ZResourceType::TextureAnimationParams; @@ -197,15 +171,16 @@ size_t TextureScrollingParams::GetRawDataSize() const /** * Overrides the parent version to declare an array of the params rather than just one entry. */ -void TextureScrollingParams::DeclareVar(const std::string& prefix, const std::string& bodyStr) const +Declaration* TextureScrollingParams::DeclareVar(const std::string& prefix, + const std::string& bodyStr) { std::string auxName = name; if (name == "") auxName = GetDefaultName(prefix); - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), - GetSourceTypeName(), auxName, count, bodyStr); + return parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), auxName, count, bodyStr); } std::string TextureScrollingParams::GetBodySourceCode() const @@ -537,12 +512,6 @@ ZTextureAnimation::ZTextureAnimation(ZFile* nParent) : ZResource(nParent) { } -void ZTextureAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) -{ - ZResource::ExtractFromXML(reader, nRawDataIndex); - DeclareVar("", ""); -} - /** * Builds the array of params */ @@ -688,7 +657,7 @@ std::string ZTextureAnimation::GetDefaultName(const std::string& prefix) const return StringHelper::Sprintf("%sTexAnim_%06X", prefix.c_str(), rawDataIndex); } -void ZTextureAnimation::DeclareVar(const std::string& prefix, const std::string& bodyStr) const +Declaration* ZTextureAnimation::DeclareVar(const std::string& prefix, const std::string& bodyStr) { std::string auxName = name; @@ -696,9 +665,10 @@ void ZTextureAnimation::DeclareVar(const std::string& prefix, const std::string& auxName = GetDefaultName(prefix); Declaration* decl = - parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), + parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), GetSourceTypeName(), auxName, entries.size(), bodyStr); decl->staticConf = staticConf; + return decl; } std::string ZTextureAnimation::GetBodySourceCode() const @@ -715,17 +685,3 @@ std::string ZTextureAnimation::GetBodySourceCode() const return bodyStr; } - -std::string ZTextureAnimation::GetSourceOutputCode(const std::string& prefix) -{ - std::string bodyStr = GetBodySourceCode(); - - Declaration* decl = parent->GetDeclaration(rawDataIndex); - - if (decl == nullptr) - DeclareVar(prefix, bodyStr); - else - decl->text = bodyStr; - - return ""; -} -- cgit v1.2.3