From ed869b55411d51a829e5b502cbbf41cd450458e1 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 9 May 2013 03:42:43 +0200 Subject: fix pattern anims --- lsrlytexporter.cpp | 35 +++++++++++++++++++++++++++++++++-- lyt/animation.cpp | 3 ++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/lsrlytexporter.cpp b/lsrlytexporter.cpp index 42fb587..29338a4 100644 --- a/lsrlytexporter.cpp +++ b/lsrlytexporter.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include static void collectPanesForList(QList *list, LYTPane *pane) { @@ -1058,6 +1059,8 @@ void LSExportPackage(LYTPackageBase *pkg, QString dirStr) { thing.hermites.append(newKey); } } + + thing.refRes = anim->importedFiles; } } } @@ -1105,6 +1108,11 @@ void LSExportPackage(LYTPackageBase *pkg, QString dirStr) { "Image", "Palette" }; + // FOR TEXPATS + QStringList originalRes = tuIter.value().refRes; + QVector mappings; + QStringList newResList; + switch (type) { case LYTAnimPiece::PaneAnim: aw.writeStartElement("animPainSRTTarget"); @@ -1137,7 +1145,27 @@ void LSExportPackage(LYTPackageBase *pkg, QString dirStr) { aw.writeAttribute("id", QString::number(ak>>8)); aw.writeAttribute("target", PatTargets[ak&0xFF]); - //foreach (const QString &bee, ) + QBitArray whichUsed; + whichUsed.resize(originalRes.size()); + mappings.resize(originalRes.size()); + + foreach (const LYTAnimStepKey &key, tuIter.value().steps) + whichUsed.setBit(key.value); + + for (int i = 0; i < originalRes.size(); i++) { + if (whichUsed.testBit(i)) { + mappings.insert(i, newResList.count()); + newResList.append(originalRes.at(i)); + } + } + + foreach (const QString &bee, newResList) { + aw.writeEmptyElement("refRes"); + QString bee2 = bee; + bee2.replace(".tpl", ""); + aw.writeAttribute("name", bee2); + } + break; } @@ -1151,7 +1179,10 @@ void LSExportPackage(LYTPackageBase *pkg, QString dirStr) { foreach (const LYTAnimStepKey &key, tuIter.value().steps) { aw.writeEmptyElement("key"); aw.writeAttribute("frame", QString::number(key.frame)); - aw.writeAttribute("value", QString::number(key.value)); + int manipValue = key.value; + if (type == LYTAnimPiece::TexPatAnim) + manipValue = mappings.at(manipValue); + aw.writeAttribute("value", QString::number(manipValue)); aw.writeAttribute("slopeType", "Step"); } diff --git a/lyt/animation.cpp b/lyt/animation.cpp index d5e87d3..bcb6bc1 100644 --- a/lyt/animation.cpp +++ b/lyt/animation.cpp @@ -77,12 +77,13 @@ LYTAnimation::LYTAnimation(QByteArray data) { importedFiles.reserve(fileCount); + qint64 strTabBegin = in.device()->pos(); for (int i = 0; i < fileCount; i++) { quint32 offs; in >> offs; qint64 saveMe = in.device()->pos(); - in.device()->seek(offs-8); + in.device()->seek(strTabBegin + offs); importedFiles.append(ReadVariableLengthASCII(in)); in.device()->seek(saveMe); -- cgit v1.2.3