Skip to content
Snippets Groups Projects
Select Git revision
  • d8e9a56b3f4e8ab14ee2330cd10bbe457c24a540
  • master default
2 results

animation.cpp

Blame
  • 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();
        }
    
    }