112 lines
1.9 KiB
C
112 lines
1.9 KiB
C
|
#ifndef ANIMATION_H
|
||
|
#define ANIMATION_H
|
||
|
|
||
|
#include <QObject>
|
||
|
#include <QGraphicsScene>
|
||
|
#include <QPicture>
|
||
|
#include <QPainter>
|
||
|
#include <QMainWindow>
|
||
|
#include <QFileDialog>
|
||
|
#include <QMessageBox>
|
||
|
#include "boost/shared_ptr.hpp"
|
||
|
|
||
|
|
||
|
struct TFrame
|
||
|
{
|
||
|
boost::shared_ptr<QPixmap> Pixmap;
|
||
|
size_t TimeToPlay;
|
||
|
std::string FrameName;
|
||
|
int ShiftX;
|
||
|
int ShiftY;
|
||
|
|
||
|
TFrame(boost::shared_ptr<QPixmap> pixmap, size_t timeToPlay, const std::string& frameName)
|
||
|
: Pixmap(pixmap)
|
||
|
, TimeToPlay(timeToPlay)
|
||
|
, FrameName(frameName)
|
||
|
, ShiftX(0)
|
||
|
, ShiftY(0)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
TFrame(const TFrame& frame)
|
||
|
{
|
||
|
Pixmap = frame.Pixmap;
|
||
|
TimeToPlay = frame.TimeToPlay;
|
||
|
FrameName = frame.FrameName;
|
||
|
ShiftX = frame.ShiftX;
|
||
|
ShiftY = frame.ShiftY;
|
||
|
}
|
||
|
|
||
|
TFrame& operator=(const TFrame& frame)
|
||
|
{
|
||
|
if (&frame == this)
|
||
|
{
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
|
Pixmap = frame.Pixmap;
|
||
|
TimeToPlay = frame.TimeToPlay;
|
||
|
FrameName = frame.FrameName;
|
||
|
ShiftX = frame.ShiftX;
|
||
|
ShiftY = frame.ShiftY;
|
||
|
|
||
|
return *this;
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
|
||
|
struct TFrameData
|
||
|
{
|
||
|
float TexCoordFromX;
|
||
|
float TexCoordFromY;
|
||
|
float TexCoordToX;
|
||
|
float TexCoordToY;
|
||
|
size_t TimeToPlay;
|
||
|
};
|
||
|
|
||
|
class MainWindow;
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
class TAnimation : public QObject
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
protected:
|
||
|
|
||
|
std::vector<TFrame> FrameList;
|
||
|
|
||
|
MainWindow* Window;
|
||
|
|
||
|
|
||
|
public:
|
||
|
|
||
|
explicit TAnimation(QObject *parent = 0);
|
||
|
|
||
|
void SetMainWindow(MainWindow* window);
|
||
|
|
||
|
void AddFrame(const TFrame& frame);
|
||
|
|
||
|
TFrame& GetFrame(int i);
|
||
|
size_t GetFrameCount();
|
||
|
|
||
|
int GetMaxWidth();
|
||
|
int GetMaxHeight();
|
||
|
|
||
|
void FillSheet(boost::shared_ptr<QPixmap> sheetPixmap, std::vector<TFrameData>& frameDataArr);
|
||
|
|
||
|
|
||
|
public slots:
|
||
|
void LoadFrame();
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
};
|
||
|
|
||
|
|
||
|
#endif // ANIMATION_H
|