#ifndef ANIMPARTS_H
#define ANIMPARTS_H

#include <QString>
#include <QDataStream>
#include <QDebug>

struct XAnimDynamicFrames
{
    quint32 framesPtr;
    quint8 frames[3];
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimDynamicFrames &aAnimDynamicFramesIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimDynamicFrames &aAnimDynamicFramesOut);

struct XAnimDynamicIndices
{
    quint8 indices[1];
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimDynamicIndices &aAnimDynamicIndicesIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimDynamicIndices &aAnimDynamicIndicesOut);

struct XAnimPartTransFrames
{
    float mins[3];
    float size[3];
    XAnimDynamicFrames frames;
    XAnimDynamicIndices indices;
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimPartTransFrames &aAnimPartTransFramesIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimPartTransFrames &aAnimPartTransFramesOut);

union XAnimPartTransData
{
    XAnimPartTransFrames frames;
    float frame0[3];
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimPartTransData &aAnimPartTransDataIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimPartTransData &aAnimPartTransDataOut);

struct XAnimPartTrans
{
    quint16 size;
    quint8 smallTrans;
    XAnimPartTransData data;
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimPartTrans &aAnimPartTransIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimPartTrans &aAnimPartTransOut);

struct XAnimDeltaPartQuatDataFrames
{
    quint32 framesPtr;
    qint16 frames[2];

    XAnimDynamicIndices indices;
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimDeltaPartQuatDataFrames &aAnimDeltaPartQuatDataFramesIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimDeltaPartQuatDataFrames &aAnimDeltaPartQuatDataFramesOut);

struct XAnimDeltaPartQuatData
{
    XAnimDeltaPartQuatDataFrames frames;
    qint16 frame0[2];
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimDeltaPartQuatData &aAnimDeltaPartQuatDataIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimDeltaPartQuatData &aAnimDeltaPartQuatDataOut);

struct XAnimDeltaPartQuat
{
    quint16 size;
    XAnimDeltaPartQuatData data;
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimDeltaPartQuat &aAnimDeltaPartQuatIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimDeltaPartQuat &aAnimDeltaPartQuatOut);

struct XAnimDeltaPart
{
    quint32 transPtr;
    XAnimPartTrans trans;

    quint32 quatPtr;
    XAnimDeltaPartQuat quat;
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimDeltaPart &aAnimDeltaPartIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimDeltaPart &aAnimDeltaPartOut);

struct XAnimNotifyInfo
{
    quint16 name;
    float time;
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimNotifyInfo &aAnimNotifyInfoIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimNotifyInfo &aAnimNotifyInfoOut);
QDebug operator<<(QDebug debug, const XAnimNotifyInfo &aAnimNotifyInfo);
QString XAnimNotifyInfoToString(const XAnimNotifyInfo &aAnimNotifyInfo);

struct XAnimIndices
{
    quint32 indexPtr;
    quint16 index;
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimIndices &aAnimIndicesIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimIndices &aAnimIndicesOut);
QDebug operator<<(QDebug debug, const XAnimIndices &aAnimIndices);
QString XAnimIndicesToString(const XAnimIndices &aAnimIndices);

struct XAnimParts
{
    QString name;
    quint32 namePtr;

    quint16 dataByteCount;
    quint16 dataShortCount;
    quint16 dataIntCount;
    quint16 randomDataByteCount;
    quint16 randomDataIntCount;
    quint16 numframes;

    bool bLoop;
    bool bDelta;

    quint8 boneCount[12];
    quint8 notifyCount;
    quint8 assetType;

    bool pad;

    quint16 randomDataShortCount;
    quint16 indexCount;

    float framerate;
    float frequency;

    quint32 namesPtr;
    quint16 names;

    quint32 dataBytePtr;
    quint8 dataByte;

    quint32 dataShortPtr;
    qint16 dataShort;

    quint32 dataIntPtr;
    int dataInt;

    quint32 randomDataShortPtr;
    qint16 randomDataShort;

    quint32 randomDataBytePtr;
    quint8 randomDataByte;

    quint32 randomDataIntPtr;
    int randomDataInt;

    XAnimIndices indices;

    qint32 notifyPtr;
    XAnimNotifyInfo notify;

    qint32 deltaPartPtr;
    XAnimDeltaPart deltaPart;
};
QDataStream &operator<<(QDataStream &aDataStream, const XAnimParts &aAnimPartIn);
QDataStream &operator>>(QDataStream &aDataStream, XAnimParts &aAnimPartOut);
QDebug operator<<(QDebug debug, const XAnimParts &xanimParts);
QString XAnimPartsToString(const XAnimParts &xAnimParts);

struct Animation {
    QString name;
    XAnimParts animParts;
};

#endif // ANIMPARTS_H
