diff --git a/DataSpec/DNACommon/ParticleCommon.cpp b/DataSpec/DNACommon/ParticleCommon.cpp index d32462c9f..610d3e1f3 100644 --- a/DataSpec/DNACommon/ParticleCommon.cpp +++ b/DataSpec/DNACommon/ParticleCommon.cpp @@ -51,7 +51,7 @@ void RealElementFactory::read(Athena::io::YAMLDocReader& r) } else if (r.enterSubRecord("KEYP")) { - m_elem.reset(new struct REKeyframeEmitterP); + m_elem.reset(new struct REKeyframeEmitter); m_elem->read(r); r.leaveSubRecord(); } @@ -135,14 +135,12 @@ void RealElementFactory::read(Athena::io::IStreamReader& r) m_elem.reset(new struct REClamp); break; case SBIG('KEYE'): + case SBIG('KEYP'): m_elem.reset(new struct REKeyframeEmitter); break; case SBIG('IRND'): m_elem.reset(new struct REInitialRandom); break; - case SBIG('KEYP'): - m_elem.reset(new struct REKeyframeEmitterP); - break; case SBIG('RAND'): m_elem.reset(new struct RERandom); break; @@ -250,7 +248,7 @@ void IntElementFactory::read(Athena::io::YAMLDocReader& r) } else if (r.enterSubRecord("KEYP")) { - m_elem.reset(new struct IEKeyframeEmitterP); + m_elem.reset(new struct IEKeyframeEmitter); m_elem->read(r); r.leaveSubRecord(); } @@ -301,6 +299,7 @@ void IntElementFactory::read(Athena::io::IStreamReader& r) switch (clsId) { case SBIG('KEYE'): + case SBIG('KEYP'): m_elem.reset(new struct IEKeyframeEmitter); break; case SBIG('DETH'): @@ -333,9 +332,6 @@ void IntElementFactory::read(Athena::io::IStreamReader& r) case SBIG('MULT'): m_elem.reset(new struct IEMultiply); break; - case SBIG('KEYP'): - m_elem.reset(new struct IEKeyframeEmitterP); - break; case SBIG('SPAH'): m_elem.reset(new struct IESampleAndHold); break; @@ -363,5 +359,426 @@ void IntElementFactory::write(Athena::io::IStreamWriter& w) const w.writeBytes((atInt8*)"NONE", 4); } +void VectorElementFactory::read(Athena::io::YAMLDocReader& r) +{ + if (r.enterSubRecord("CONE")) + { + m_elem.reset(new struct VECone); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("CHAN")) + { + m_elem.reset(new struct VETimeChain); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("ANGC")) + { + m_elem.reset(new struct VEAngleCone); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("ADD_")) + { + m_elem.reset(new struct VEAdd); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("CCLU")) + { + m_elem.reset(new struct VECircleCluster); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("CNST")) + { + m_elem.reset(new struct VEConstant); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("CIRC")) + { + m_elem.reset(new struct VECircle); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("KEYE")) + { + m_elem.reset(new struct VEKeyframeEmitter); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("KEYP")) + { + m_elem.reset(new struct VEKeyframeEmitter); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("MULT")) + { + m_elem.reset(new struct VEMultiply); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("RTOV")) + { + m_elem.reset(new struct VERealToVector); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("PULS")) + { + m_elem.reset(new struct VEPulse); + m_elem->read(r); + r.leaveSubRecord(); + } + else + m_elem.reset(); +} + +void VectorElementFactory::write(Athena::io::YAMLDocWriter& w) const +{ + if (m_elem) + { + w.enterSubRecord(m_elem->ClassName()); + m_elem->write(w); + w.leaveSubRecord(); + } +} + +size_t VectorElementFactory::binarySize(size_t __isz) const +{ + if (m_elem) + return m_elem->binarySize(__isz + 4); + else + return __isz + 4; +} + +void VectorElementFactory::read(Athena::io::IStreamReader& r) +{ + uint32_t clsId; + r.readBytesToBuf(&clsId, 4); + switch (clsId) + { + case SBIG('CONE'): + m_elem.reset(new struct VECone); + break; + case SBIG('CHAN'): + m_elem.reset(new struct VETimeChain); + break; + case SBIG('ANGC'): + m_elem.reset(new struct VEAngleCone); + break; + case SBIG('ADD_'): + m_elem.reset(new struct VEAdd); + break; + case SBIG('CCLU'): + m_elem.reset(new struct VECircleCluster); + break; + case SBIG('CNST'): + m_elem.reset(new struct VEConstant); + break; + case SBIG('CIRC'): + m_elem.reset(new struct VECircle); + break; + case SBIG('KEYE'): + case SBIG('KEYP'): + m_elem.reset(new struct VEKeyframeEmitter); + break; + case SBIG('MULT'): + m_elem.reset(new struct VEMultiply); + break; + case SBIG('RTOV'): + m_elem.reset(new struct VERealToVector); + break; + case SBIG('PULS'): + m_elem.reset(new struct VEPulse); + break; + default: + m_elem.reset(); + return; + } + m_elem->read(r); +} + +void VectorElementFactory::write(Athena::io::IStreamWriter& w) const +{ + if (m_elem) + { + w.writeBytes((atInt8*)m_elem->ClassName(), 4); + m_elem->write(w); + } + else + w.writeBytes((atInt8*)"NONE", 4); +} + + +void ColorElementFactory::read(Athena::io::YAMLDocReader& r) +{ + if (r.enterSubRecord("KEYE")) + { + m_elem.reset(new struct CEKeyframeEmitter); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("CNST")) + { + m_elem.reset(new struct CEConstant); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("CHAN")) + { + m_elem.reset(new struct CETimeChain); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("CFDE")) + { + m_elem.reset(new struct CEFadeEnd); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("FADE")) + { + m_elem.reset(new struct CEFade); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("KEYP")) + { + m_elem.reset(new struct CEKeyframeEmitter); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("PULS")) + { + m_elem.reset(new struct CEPulse); + m_elem->read(r); + r.leaveSubRecord(); + } + else + m_elem.reset(); +} + +void ColorElementFactory::write(Athena::io::YAMLDocWriter& w) const +{ + if (m_elem) + { + w.enterSubRecord(m_elem->ClassName()); + m_elem->write(w); + w.leaveSubRecord(); + } +} + +size_t ColorElementFactory::binarySize(size_t __isz) const +{ + if (m_elem) + return m_elem->binarySize(__isz + 4); + else + return __isz + 4; +} + +void ColorElementFactory::read(Athena::io::IStreamReader& r) +{ + uint32_t clsId; + r.readBytesToBuf(&clsId, 4); + switch (clsId) + { + case SBIG('KEYE'): + case SBIG('KEYP'): + m_elem.reset(new struct CEKeyframeEmitter); + break; + case SBIG('CNST'): + m_elem.reset(new struct CEConstant); + break; + case SBIG('CHAN'): + m_elem.reset(new struct CETimeChain); + break; + case SBIG('CFDE'): + m_elem.reset(new struct CEFadeEnd); + break; + case SBIG('FADE'): + m_elem.reset(new struct CEFade); + break; + case SBIG('PULS'): + m_elem.reset(new struct CEPulse); + break; + default: + m_elem.reset(); + return; + } + m_elem->read(r); +} + +void ColorElementFactory::write(Athena::io::IStreamWriter& w) const +{ + if (m_elem) + { + w.writeBytes((atInt8*)m_elem->ClassName(), 4); + m_elem->write(w); + } + else + w.writeBytes((atInt8*)"NONE", 4); +} + + +void ModVectorElementFactory::read(Athena::io::YAMLDocReader& r) +{ + if (r.enterSubRecord("IMPL")) + { + m_elem.reset(new struct MVEImplosion); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("EMPL")) + { + m_elem.reset(new struct MVEExponentialImplosion); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("CHAN")) + { + m_elem.reset(new struct MVETimeChain); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("BNCE")) + { + m_elem.reset(new struct MVEBounce); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("CNST")) + { + m_elem.reset(new struct MVEConstant); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("GRAV")) + { + m_elem.reset(new struct MVEGravity); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("EXPL")) + { + m_elem.reset(new struct MVEExplode); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("SPOS")) + { + m_elem.reset(new struct MVESetPosition); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("LMPL")) + { + m_elem.reset(new struct MVELinearImplosion); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("PULS")) + { + m_elem.reset(new struct MVEPulse); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("WIND")) + { + m_elem.reset(new struct MVEWind); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("SWRL")) + { + m_elem.reset(new struct MVESwirl); + m_elem->read(r); + r.leaveSubRecord(); + } + else + m_elem.reset(); +} + +void ModVectorElementFactory::write(Athena::io::YAMLDocWriter& w) const +{ + if (m_elem) + { + w.enterSubRecord(m_elem->ClassName()); + m_elem->write(w); + w.leaveSubRecord(); + } +} + +size_t ModVectorElementFactory::binarySize(size_t __isz) const +{ + if (m_elem) + return m_elem->binarySize(__isz + 4); + else + return __isz + 4; +} + +void ModVectorElementFactory::read(Athena::io::IStreamReader& r) +{ + uint32_t clsId; + r.readBytesToBuf(&clsId, 4); + switch (clsId) + { + case SBIG('IMPL'): + m_elem.reset(new struct MVEImplosion); + break; + case SBIG('EMPL'): + m_elem.reset(new struct MVEExponentialImplosion); + break; + case SBIG('CHAN'): + m_elem.reset(new struct MVETimeChain); + break; + case SBIG('BNCE'): + m_elem.reset(new struct MVEBounce); + break; + case SBIG('CNST'): + m_elem.reset(new struct MVEConstant); + break; + case SBIG('GRAV'): + m_elem.reset(new struct MVEGravity); + break; + case SBIG('EXPL'): + m_elem.reset(new struct MVEExplode); + break; + case SBIG('SPOS'): + m_elem.reset(new struct MVESetPosition); + break; + case SBIG('LMPL'): + m_elem.reset(new struct MVELinearImplosion); + break; + case SBIG('PULS'): + m_elem.reset(new struct MVEPulse); + break; + case SBIG('WIND'): + m_elem.reset(new struct MVEWind); + break; + case SBIG('SWRL'): + m_elem.reset(new struct MVESwirl); + break; + default: + m_elem.reset(); + return; + } + m_elem->read(r); +} + +void ModVectorElementFactory::write(Athena::io::IStreamWriter& w) const +{ + if (m_elem) + { + w.writeBytes((atInt8*)m_elem->ClassName(), 4); + m_elem->write(w); + } + else + w.writeBytes((atInt8*)"NONE", 4); +} + } } diff --git a/DataSpec/DNACommon/ParticleCommon.hpp b/DataSpec/DNACommon/ParticleCommon.hpp index 40b20213b..5c6d304b6 100644 --- a/DataSpec/DNACommon/ParticleCommon.hpp +++ b/DataSpec/DNACommon/ParticleCommon.hpp @@ -10,6 +10,11 @@ namespace DNAParticle struct IElement : BigYAML { + enum class ClassID : uint32_t + { + NONE = 'NONE', + CNST = 'CNST' + }; Delete _d; virtual ~IElement() = default; virtual const char* ClassName() const=0; @@ -41,6 +46,47 @@ struct IntElementFactory : BigYAML void write(Athena::io::IStreamWriter& w) const; }; +struct IVectorElement : IElement {Delete _d;}; +struct VectorElementFactory : BigYAML +{ + Delete _d; + std::unique_ptr m_elem; + + void read(Athena::io::YAMLDocReader& r); + void write(Athena::io::YAMLDocWriter& w) const; + size_t binarySize(size_t __isz) const; + void read(Athena::io::IStreamReader& r); + void write(Athena::io::IStreamWriter& w) const; +}; + +struct IColorElement : IElement {Delete _d;}; +struct ColorElementFactory : BigYAML +{ + Delete _d; + std::unique_ptr m_elem; + + void read(Athena::io::YAMLDocReader& r); + void write(Athena::io::YAMLDocWriter& w) const; + size_t binarySize(size_t __isz) const; + void read(Athena::io::IStreamReader& r); + void write(Athena::io::IStreamWriter& w) const; +}; + +struct IModVectorElement : IElement {Delete _d;}; +struct ModVectorElementFactory : BigYAML +{ + Delete _d; + std::unique_ptr m_elem; + + void read(Athena::io::YAMLDocReader& r); + void write(Athena::io::YAMLDocWriter& w) const; + size_t binarySize(size_t __isz) const; + void read(Athena::io::IStreamReader& r); + void write(Athena::io::IStreamWriter& w) const; +}; + +struct IUVElement : IElement {Delete _d;}; + struct RELifetimeTween : IRealElement { DECL_YAML @@ -85,7 +131,7 @@ struct REClamp : IRealElement struct REKeyframeEmitter : IRealElement { DECL_YAML - Value a; + Value percentage; Value b; Value c; Value d; @@ -93,7 +139,7 @@ struct REKeyframeEmitter : IRealElement Value f; Value count; Vector keys; - const char* ClassName() const {return "KEYE";} + const char* ClassName() const {return percentage ? "KEYP" : "KEYE";} }; struct REInitialRandom : IRealElement @@ -104,12 +150,6 @@ struct REInitialRandom : IRealElement const char* ClassName() const {return "IRND";} }; -struct REKeyframeEmitterP : REKeyframeEmitter -{ - Delete _d; - const char* ClassName() const {return "KEYP";} -}; - struct RERandom : IRealElement { DECL_YAML @@ -162,7 +202,7 @@ struct RESineWave : IRealElement struct IEKeyframeEmitter : IIntElement { DECL_YAML - Value a; + Value percentage; Value b; Value c; Value d; @@ -170,7 +210,7 @@ struct IEKeyframeEmitter : IIntElement Value f; Value count; Vector keys; - const char* ClassName() const {return "KEYE";} + const char* ClassName() const {return percentage ? "KEYP" : "KEYE";} }; struct IEDeath : IIntElement @@ -254,12 +294,6 @@ struct IEMultiply : IIntElement const char* ClassName() const {return "MULT";} }; -struct IEKeyframeEmitterP : IEKeyframeEmitter -{ - Delete _d; - const char* ClassName() const {return "KEYP";} -}; - struct IESampleAndHold : IIntElement { DECL_YAML @@ -284,6 +318,556 @@ struct IETimeScale : IIntElement const char* ClassName() const {return "TSCL";} }; +struct VECone : IVectorElement +{ + DECL_YAML + VectorElementFactory a; + RealElementFactory b; + const char* ClassName() const {return "CONE";} +}; + +struct VETimeChain : IVectorElement +{ + DECL_YAML + VectorElementFactory a; + VectorElementFactory b; + IntElementFactory c; + const char* ClassName() const {return "CHAN";} +}; + +struct VEAngleCone : IVectorElement +{ + DECL_YAML + RealElementFactory a; + RealElementFactory b; + RealElementFactory c; + RealElementFactory d; + RealElementFactory e; + const char* ClassName() const {return "ANGC";} +}; + +struct VEAdd : IVectorElement +{ + DECL_YAML + VectorElementFactory a; + VectorElementFactory b; + const char* ClassName() const {return "ADD_";} +}; + +struct VECircleCluster : IVectorElement +{ + DECL_YAML + VectorElementFactory a; + VectorElementFactory b; + IntElementFactory c; + RealElementFactory d; + const char* ClassName() const {return "CCLU";} +}; + +struct VEConstant : IVectorElement +{ + DECL_YAML + RealElementFactory a; + RealElementFactory b; + RealElementFactory c; + const char* ClassName() const {return "CNST";} +}; + +struct VECircle : IVectorElement +{ + DECL_YAML + VectorElementFactory a; + VectorElementFactory b; + RealElementFactory c; + RealElementFactory d; + RealElementFactory e; + const char* ClassName() const {return "CIRC";} +}; + +struct VEKeyframeEmitter : IVectorElement +{ + DECL_YAML + Value percentage; + Value b; + Value c; + Value d; + Value e; + Value f; + Value count; + Vector keys; + const char* ClassName() const {return percentage ? "KEYP" : "KEYE";} +}; + +struct VEMultiply : IVectorElement +{ + DECL_YAML + VectorElementFactory a; + VectorElementFactory b; + const char* ClassName() const {return "MULT";} +}; + +struct VERealToVector : IVectorElement +{ + DECL_YAML + RealElementFactory a; + const char* ClassName() const {return "RTOV";} +}; + +struct VEPulse : IVectorElement +{ + DECL_YAML + IntElementFactory a; + IntElementFactory b; + VectorElementFactory c; + VectorElementFactory d; + const char* ClassName() const {return "PULS";} +}; + +struct CEKeyframeEmitter : IColorElement +{ + DECL_YAML + Value percentage; + Value b; + Value c; + Value d; + Value e; + Value f; + Value count; + Vector keys; + const char* ClassName() const {return percentage ? "KEYP" : "KEYE";} +}; + +struct CEConstant : IColorElement +{ + DECL_YAML + RealElementFactory a; + RealElementFactory b; + RealElementFactory c; + RealElementFactory d; + const char* ClassName() const {return "CNST";} +}; + +struct CETimeChain : IColorElement +{ + DECL_YAML + ColorElementFactory a; + ColorElementFactory b; + IntElementFactory c; + const char* ClassName() const {return "CHAN";} +}; + +struct CEFadeEnd : IColorElement +{ + DECL_YAML + ColorElementFactory a; + ColorElementFactory b; + RealElementFactory c; + RealElementFactory d; + const char* ClassName() const {return "CFDE";} +}; + +struct CEFade : IColorElement +{ + DECL_YAML + ColorElementFactory a; + ColorElementFactory b; + RealElementFactory c; + const char* ClassName() const {return "FADE";} +}; + +struct CEPulse : IColorElement +{ + DECL_YAML + IntElementFactory a; + IntElementFactory b; + ColorElementFactory c; + ColorElementFactory d; + const char* ClassName() const {return "PULS";} +}; + +struct MVEImplosion : IModVectorElement +{ + DECL_YAML + VectorElementFactory a; + RealElementFactory b; + RealElementFactory c; + RealElementFactory d; + Value boolCls = ClassID::CNST; + Value boolVal; + const char* ClassName() const {return "IMPL";} +}; + +struct MVEExponentialImplosion : IModVectorElement +{ + DECL_YAML + VectorElementFactory a; + RealElementFactory b; + RealElementFactory c; + RealElementFactory d; + Value boolCls = ClassID::CNST; + Value boolVal; + const char* ClassName() const {return "EMPL";} +}; + +struct MVETimeChain : IModVectorElement +{ + DECL_YAML + ModVectorElementFactory a; + ModVectorElementFactory b; + IntElementFactory c; + const char* ClassName() const {return "CHAN";} +}; + +struct MVEBounce : IModVectorElement +{ + DECL_YAML + VectorElementFactory a; + VectorElementFactory b; + RealElementFactory c; + RealElementFactory d; + Value boolCls = ClassID::CNST; + Value boolVal; + const char* ClassName() const {return "BNCE";} +}; + +struct MVEConstant : IModVectorElement +{ + DECL_YAML + RealElementFactory a; + RealElementFactory b; + RealElementFactory c; + const char* ClassName() const {return "CNST";} +}; + +struct MVEGravity : IModVectorElement +{ + DECL_YAML + VectorElementFactory a; + const char* ClassName() const {return "GRAV";} +}; + +struct MVEExplode : IModVectorElement +{ + DECL_YAML + RealElementFactory a; + RealElementFactory b; + const char* ClassName() const {return "EXPL";} +}; + +struct MVESetPosition : IModVectorElement +{ + DECL_YAML + VectorElementFactory a; + const char* ClassName() const {return "SPOS";} +}; + +struct MVELinearImplosion : IModVectorElement +{ + DECL_YAML + VectorElementFactory a; + RealElementFactory b; + RealElementFactory c; + RealElementFactory d; + Value boolCls = ClassID::CNST; + Value boolVal; + const char* ClassName() const {return "LMPL";} +}; + +struct MVEPulse : IModVectorElement +{ + DECL_YAML + IntElementFactory a; + IntElementFactory b; + ModVectorElementFactory c; + ModVectorElementFactory d; + const char* ClassName() const {return "PULS";} +}; + +struct MVEWind : IModVectorElement +{ + DECL_YAML + VectorElementFactory a; + RealElementFactory b; + const char* ClassName() const {return "WIND";} +}; + +struct MVESwirl : IModVectorElement +{ + DECL_YAML + VectorElementFactory a; + VectorElementFactory b; + RealElementFactory c; + RealElementFactory d; + const char* ClassName() const {return "SWRL";} +}; + +template +struct UVEConstant : IUVElement +{ + Delete _d; + IDType tex; + void read(Athena::io::YAMLDocReader& r) + { + tex.clear(); + if (r.enterSubRecord("tex")) + { + if (r.enterSubRecord("CNST")) + { + tex.read(r); + r.leaveSubRecord(); + } + r.leaveSubRecord(); + } + } + void write(Athena::io::YAMLDocWriter& w) const + { + if (tex) + { + w.enterSubRecord("CNST"); + tex.write(w); + w.leaveSubRecord(); + } + } + size_t binarySize(size_t __isz) const + { + if (tex) + return __isz + 8; + else + return __isz + 4; + } + void read(Athena::io::IStreamReader& r) + { + tex.clear(); + uint32_t clsId; + r.readBytesToBuf(&clsId, 4); + if (clsId == SBIG('CNST')) + tex.read(r); + } + void write(Athena::io::IStreamWriter& w) const + { + if (tex) + { + w.writeBytes((atInt8*)"CNST", 4); + tex.write(w); + } + else + w.writeBytes((atInt8*)"NONE", 4); + } +}; + +template +struct UVEAnimTexture : IUVElement +{ + Delete _d; + IDType tex; + IntElementFactory a; + IntElementFactory b; + IntElementFactory c; + IntElementFactory d; + IntElementFactory e; + Value boolCls = ClassID::CNST; + Value boolVal; + void read(Athena::io::YAMLDocReader& r) + { + tex.clear(); + if (r.enterSubRecord("tex")) + { + if (r.enterSubRecord("CNST")) + { + tex.read(r); + r.leaveSubRecord(); + } + r.leaveSubRecord(); + } + if (r.enterSubRecord("a")) + { + a.read(r); + r.leaveSubRecord(); + } + if (r.enterSubRecord("b")) + { + b.read(r); + r.leaveSubRecord(); + } + if (r.enterSubRecord("c")) + { + c.read(r); + r.leaveSubRecord(); + } + if (r.enterSubRecord("d")) + { + d.read(r); + r.leaveSubRecord(); + } + if (r.enterSubRecord("e")) + { + e.read(r); + r.leaveSubRecord(); + } + boolCls = ClassID::NONE; + if (r.enterSubRecord("bool")) + { + if (r.enterSubRecord("CNST")) + { + boolCls = ClassID::CNST; + boolVal = r.readBool(nullptr); + r.leaveSubRecord(); + } + r.leaveSubRecord(); + } + } + void write(Athena::io::YAMLDocWriter& w) const + { + if (tex) + { + w.enterSubRecord("CNST"); + tex.write(w); + w.leaveSubRecord(); + } + a.write(w); + b.write(w); + c.write(w); + d.write(w); + e.write(w); + w.enterSubRecord("bool"); + if (boolCls == ClassID::CNST) + { + w.enterSubRecord("CNST"); + w.writeBool(nullptr, boolVal); + w.leaveSubRecord(); + } + w.leaveSubRecord(); + } + size_t binarySize(size_t __isz) const + { + __isz += 8; + if (tex) + __isz += 4; + __isz = a.binarySize(__isz); + __isz = b.binarySize(__isz); + __isz = c.binarySize(__isz); + __isz = d.binarySize(__isz); + __isz = e.binarySize(__isz); + if (boolCls == ClassID::CNST) + __isz += 1; + return __isz; + } + void read(Athena::io::IStreamReader& r) + { + tex.clear(); + uint32_t clsId; + r.readBytesToBuf(&clsId, 4); + if (clsId == SBIG('CNST')) + tex.read(r); + a.read(r); + b.read(r); + c.read(r); + d.read(r); + e.read(r); + boolCls = ClassID::NONE; + r.readBytesToBuf(&clsId, 4); + if (clsId == SBIG('CNST')) + { + boolCls = ClassID::CNST; + boolVal = r.readBool(); + } + } + void write(Athena::io::IStreamWriter& w) const + { + if (tex) + { + w.writeBytes((atInt8*)"CNST", 4); + tex.write(w); + } + else + w.writeBytes((atInt8*)"NONE", 4); + a.write(w); + b.write(w); + c.write(w); + d.write(w); + e.write(w); + if (boolCls == ClassID::CNST) + { + w.writeBytes((atInt8*)"CNST", 4); + w.writeBool(boolVal); + } + else + w.writeBytes((atInt8*)"NONE", 4); + } +}; + +template +struct UVElementFactory : BigYAML +{ + Delete _d; + std::unique_ptr m_elem; + + void read(Athena::io::YAMLDocReader& r) + { + if (r.enterSubRecord("CNST")) + { + m_elem.reset(new struct UVEConstant); + m_elem->read(r); + r.leaveSubRecord(); + } + else if (r.enterSubRecord("ATEX")) + { + m_elem.reset(new struct UVEAnimTexture); + m_elem->read(r); + r.leaveSubRecord(); + } + else + m_elem.reset(); + } + + void write(Athena::io::YAMLDocWriter& w) const + { + if (m_elem) + { + w.enterSubRecord(m_elem->ClassName()); + m_elem->write(w); + w.leaveSubRecord(); + } + } + + size_t binarySize(size_t __isz) const + { + if (m_elem) + return m_elem->binarySize(__isz + 4); + else + return __isz + 4; + } + + void read(Athena::io::IStreamReader& r) + { + uint32_t clsId; + r.readBytesToBuf(&clsId, 4); + switch (clsId) + { + case SBIG('CNST'): + m_elem.reset(new struct UVEConstant); + break; + case SBIG('ATEX'): + m_elem.reset(new struct UVEAnimTexture); + break; + default: + m_elem.reset(); + return; + } + m_elem->read(r); + } + + void write(Athena::io::IStreamWriter& w) const + { + if (m_elem) + { + w.writeBytes((atInt8*)m_elem->ClassName(), 4); + m_elem->write(w); + } + else + w.writeBytes((atInt8*)"NONE", 4); + } +}; template struct ChildGeneratorDesc : BigYAML @@ -318,18 +902,20 @@ struct ChildGeneratorDesc : BigYAML void read(Athena::io::IStreamReader& r) { id.clear(); - if (r.readUint32Big() == 'CNST') + uint32_t clsId; + r.readBytesToBuf(&clsId, 4); + if (clsId == SBIG('CNST')) id.read(r); } void write(Athena::io::IStreamWriter& w) const { if (id) { - w.writeUint32Big('CNST'); + w.writeBytes((atInt8*)"CNST", 4); id.write(w); } else - w.writeUint32Big('NONE'); + w.writeBytes((atInt8*)"NONE", 4); } };