Select Git revision
animation.cpp
animation.cpp 864 B
#include "animation.h"
#include <QTextStream>
Animation::Animation()
{
}
void Animation::openFile(const QString filepath)
{
QFile file(filepath);
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
frames.clear();
frameId = 0;
QString filestr = file.readAll();
int start = 0;
while (1) {
int begin = filestr.indexOf("frame(", start);
int end = filestr.indexOf(")", begin) + 1;
if (begin == -1 || end == -1)
break;
start = end;
frames.push_back(MxFrame(filestr.mid(begin, end - begin)));
}
file.close();
}
}
bool Animation::eof()
{
return frameId >= frames.size();
}
MxFrame Animation::nextFrame()
{
if (!eof()) {
return frames[frameId++];
}
else {
return MxFrame();
}
}