2010-10-08 22:30:39 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TOON_ANIM_H
|
|
|
|
#define TOON_ANIM_H
|
|
|
|
|
|
|
|
#include "common/stream.h"
|
|
|
|
#include "common/array.h"
|
|
|
|
#include "common/func.h"
|
|
|
|
#include "graphics/surface.h"
|
|
|
|
|
2010-10-08 22:45:28 +00:00
|
|
|
#include "toon/script.h"
|
2010-10-08 22:30:39 +00:00
|
|
|
|
|
|
|
namespace Toon {
|
|
|
|
|
|
|
|
class Picture;
|
|
|
|
class ToonEngine;
|
|
|
|
|
|
|
|
struct AnimationFrame {
|
2012-06-21 01:21:21 +00:00
|
|
|
int16 _x1;
|
|
|
|
int16 _y1;
|
|
|
|
int16 _x2;
|
|
|
|
int16 _y2;
|
2010-10-08 22:30:39 +00:00
|
|
|
int32 _ref;
|
|
|
|
uint8 *_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Animation {
|
|
|
|
public:
|
|
|
|
Animation(ToonEngine *vm);
|
|
|
|
~Animation();
|
|
|
|
|
2012-06-21 01:21:21 +00:00
|
|
|
int16 _x1;
|
|
|
|
int16 _y1;
|
|
|
|
int16 _x2;
|
|
|
|
int16 _y2;
|
2010-10-08 22:30:39 +00:00
|
|
|
int32 _numFrames;
|
|
|
|
int32 _fps;
|
|
|
|
AnimationFrame *_frames;
|
|
|
|
uint8 *_palette;
|
|
|
|
int32 _paletteEntries;
|
|
|
|
char _name[32];
|
|
|
|
|
2011-11-26 21:26:47 +00:00
|
|
|
bool loadAnimation(const Common::String &file);
|
2012-06-21 01:21:21 +00:00
|
|
|
void drawFrame(Graphics::Surface &surface, int32 frame, int16 x, int16 y);
|
|
|
|
void drawFontFrame(Graphics::Surface &surface, int32 frame, int16 x, int16 y, byte *colorMap);
|
|
|
|
void drawFrameOnPicture(int32 frame, int16 x, int16 y);
|
|
|
|
void drawFrameWithMask(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, int32 zz, Picture *mask);
|
|
|
|
void drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, int32 zz, Picture *mask, int32 scale);
|
2010-10-08 22:30:39 +00:00
|
|
|
void drawStrip(int32 offset = 0);
|
|
|
|
void applyPalette(int32 offset, int32 srcOffset, int32 numEntries);
|
2011-06-26 21:13:49 +00:00
|
|
|
Common::Rect getFrameRect(int32 frame);
|
2012-06-21 01:21:21 +00:00
|
|
|
int16 getFrameWidth(int32 frame);
|
|
|
|
int16 getFrameHeight(int32 frame);
|
|
|
|
int16 getWidth() const;
|
|
|
|
int16 getHeight() const;
|
2010-10-08 22:30:39 +00:00
|
|
|
Common::Rect getRect();
|
|
|
|
protected:
|
|
|
|
ToonEngine *_vm;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum AnimationInstanceType {
|
|
|
|
kAnimationCharacter = 1,
|
|
|
|
kAnimationScene = 2,
|
|
|
|
kAnimationCursor = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
class AnimationInstance {
|
|
|
|
public:
|
|
|
|
AnimationInstance(ToonEngine *vm, AnimationInstanceType type);
|
|
|
|
void update(int32 timeIncrement);
|
|
|
|
void render();
|
|
|
|
void renderOnPicture();
|
|
|
|
void setAnimation(Animation *animation, bool setRange = true);
|
|
|
|
void playAnimation();
|
2012-06-21 01:21:21 +00:00
|
|
|
void setAnimationRange(int32 rangeStart, int32 rangeEnd);
|
2010-10-08 22:30:39 +00:00
|
|
|
void setFps(int32 fps);
|
|
|
|
void setLooping(bool enable);
|
|
|
|
void stopAnimation();
|
|
|
|
void setFrame(int32 position);
|
|
|
|
void forceFrame(int32 position);
|
2012-06-21 01:21:21 +00:00
|
|
|
void setPosition(int16 x, int16 y, int32 z, bool relative = false);
|
2010-10-08 22:30:39 +00:00
|
|
|
Animation *getAnimation() const { return _animation; }
|
2010-10-26 22:18:14 +00:00
|
|
|
void setScale(int32 scale, bool align = false);
|
2010-10-08 22:30:39 +00:00
|
|
|
void setVisible(bool visible);
|
|
|
|
bool getVisible() const { return _visible; }
|
|
|
|
void setUseMask(bool useMask);
|
2012-06-21 01:21:21 +00:00
|
|
|
void moveRelative(int16 dx, int16 dy, int32 dz);
|
|
|
|
void getRect(int16 *x1, int16 *y1, int16 *x2, int16 *y2) const;
|
|
|
|
int16 getX() const { return _x; }
|
|
|
|
int16 getY() const { return _y; }
|
2010-10-09 10:29:11 +00:00
|
|
|
int32 getZ() const { return _z; }
|
2012-06-21 01:21:21 +00:00
|
|
|
int16 getX2() const;
|
|
|
|
int16 getY2() const;
|
2010-10-08 22:30:39 +00:00
|
|
|
int32 getZ2() const;
|
2010-10-09 10:29:11 +00:00
|
|
|
int32 getFrame() const { return _currentFrame; }
|
2010-10-08 22:30:39 +00:00
|
|
|
void reset();
|
|
|
|
void save(Common::WriteStream *stream);
|
|
|
|
void load(Common::ReadStream *stream);
|
|
|
|
|
2010-10-09 10:29:11 +00:00
|
|
|
void setId(int32 id) { _id = id; }
|
|
|
|
int32 getId() const { return _id; }
|
2010-10-08 22:30:39 +00:00
|
|
|
|
2012-06-21 01:21:21 +00:00
|
|
|
void setX(int16 x, bool relative = false);
|
|
|
|
void setY(int16 y, bool relative = false);
|
2010-10-08 22:30:39 +00:00
|
|
|
void setZ(int32 z, bool relative = false);
|
|
|
|
void setLayerZ(int32 layer);
|
|
|
|
int32 getLayerZ() const;
|
|
|
|
|
|
|
|
AnimationInstanceType getType() const { return _type; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int32 _currentFrame;
|
|
|
|
int32 _currentTime;
|
|
|
|
int32 _fps;
|
|
|
|
Animation *_animation;
|
2012-06-21 01:21:21 +00:00
|
|
|
int16 _x;
|
|
|
|
int16 _y;
|
2010-10-08 22:30:39 +00:00
|
|
|
int32 _z;
|
|
|
|
int32 _layerZ;
|
|
|
|
int32 _rangeStart;
|
|
|
|
int32 _rangeEnd;
|
|
|
|
int32 _scale;
|
|
|
|
int32 _id;
|
|
|
|
|
|
|
|
AnimationInstanceType _type;
|
|
|
|
|
|
|
|
bool _useMask;
|
|
|
|
bool _playing;
|
|
|
|
bool _looping;
|
|
|
|
bool _visible;
|
2010-10-26 22:18:14 +00:00
|
|
|
bool _alignBottom;
|
2010-10-08 22:30:39 +00:00
|
|
|
|
|
|
|
ToonEngine *_vm;
|
|
|
|
};
|
|
|
|
|
|
|
|
class AnimationManager {
|
|
|
|
public:
|
|
|
|
AnimationManager(ToonEngine *vm);
|
|
|
|
AnimationInstance *createNewInstance(AnimationInstanceType type);
|
|
|
|
void addInstance(AnimationInstance *instance);
|
|
|
|
void removeInstance(AnimationInstance *instance);
|
2011-03-09 23:25:29 +00:00
|
|
|
void updateInstance(AnimationInstance* instance);
|
2010-10-08 22:30:39 +00:00
|
|
|
void removeAllInstances(AnimationInstanceType type);
|
|
|
|
void render();
|
|
|
|
void update(int32 timeIncrement);
|
2011-01-30 02:18:53 +00:00
|
|
|
bool hasInstance(AnimationInstance* instance);
|
2010-10-08 22:30:39 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
ToonEngine *_vm;
|
|
|
|
Common::Array<AnimationInstance *> _instances;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SceneAnimation {
|
|
|
|
public:
|
2010-11-13 02:44:34 +00:00
|
|
|
AnimationInstance *_originalAnimInstance;
|
2010-10-08 22:30:39 +00:00
|
|
|
AnimationInstance *_animInstance;
|
|
|
|
Animation *_animation;
|
|
|
|
int32 _id;
|
|
|
|
bool _active;
|
|
|
|
|
2010-10-09 11:11:26 +00:00
|
|
|
void load(ToonEngine *vm, Common::ReadStream *stream);
|
|
|
|
void save(ToonEngine *vm, Common::WriteStream *stream);
|
2010-10-08 22:30:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SceneAnimationScript {
|
|
|
|
public:
|
|
|
|
EMCData *_data;
|
|
|
|
EMCState _state;
|
|
|
|
uint32 _lastTimer;
|
|
|
|
bool _frozen;
|
2010-10-22 21:42:48 +00:00
|
|
|
bool _frozenForConversation;
|
2010-10-08 22:30:39 +00:00
|
|
|
bool _active;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Toon
|
|
|
|
|
|
|
|
#endif
|