#include "xassetheader.h"
#include "zonefile.h"

XAssetHeader::XAssetHeader()
    : XAsset()
    , mRawType(0)
    , mAssetType()
    , mAssetPtr(0)
    , mZoneFile(nullptr)
{
    SetName("Asset Header");
}

XAssetHeader::XAssetHeader(ZoneFile *aZoneFile)
    : XAsset()
    , mRawType(0)
    , mAssetType()
    , mAssetPtr(0)
    , mZoneFile(aZoneFile)
{
    SetName("Asset Header");
}

void XAssetHeader::ParseData(XDataStream *aStream)
{
    mRawType = aStream->ParseUInt32(QString("%1 raw type").arg(GetName()));
    mAssetPtr = aStream->ParseInt32(QString("%1 asset ptr").arg(GetName()));

    mAssetType = mZoneFile->GetType(mRawType);

    qDebug() << "Found asset:" << XAssetTypeToString(mAssetType) << QString::number(mRawType, 16);
}

void XAssetHeader::Clear()
{
    mAssetType = ASSET_TYPE_NONE;
    mAssetPtr = 0;
    mRawType = 0;
}

XAssetType XAssetHeader::GetAssetType() const
{
    return mAssetType;
}

quint32 XAssetHeader::GetRawAssetType() const
{
    return mRawType;
}

qint32 XAssetHeader::GetAssetPtr() const
{
    return mAssetPtr;
}
