2011-09-03 10:41:06 +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.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2011-09-03 10:41:06 +00:00
|
|
|
* 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.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2011-09-03 10:41:06 +00:00
|
|
|
* 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 GOB_ANIOBJECT_H
|
|
|
|
#define GOB_ANIOBJECT_H
|
|
|
|
|
|
|
|
#include "common/system.h"
|
|
|
|
|
2012-07-06 04:50:04 +00:00
|
|
|
#include "gob/backbuffer.h"
|
|
|
|
|
2011-09-03 10:41:06 +00:00
|
|
|
namespace Gob {
|
|
|
|
|
|
|
|
class ANIFile;
|
2012-03-11 19:41:57 +00:00
|
|
|
class CMPFile;
|
2011-09-03 10:41:06 +00:00
|
|
|
class Surface;
|
|
|
|
|
|
|
|
/** An ANI object, controlling an animation within an ANI file. */
|
2012-07-06 04:50:04 +00:00
|
|
|
class ANIObject : public BackBuffer {
|
2011-09-03 10:41:06 +00:00
|
|
|
public:
|
2011-09-12 15:11:31 +00:00
|
|
|
enum Mode {
|
|
|
|
kModeContinuous, ///< Play the animation continuously.
|
|
|
|
kModeOnce ///< Play the animation only once.
|
|
|
|
};
|
|
|
|
|
2012-03-11 19:41:57 +00:00
|
|
|
/** Create an animation object from an ANI file. */
|
2011-09-03 10:41:06 +00:00
|
|
|
ANIObject(const ANIFile &ani);
|
2012-03-11 19:41:57 +00:00
|
|
|
/** Create an animation object from a CMP sprite. */
|
|
|
|
ANIObject(const CMPFile &cmp);
|
2011-09-03 10:41:06 +00:00
|
|
|
virtual ~ANIObject();
|
|
|
|
|
|
|
|
/** Make the object visible/invisible. */
|
|
|
|
void setVisible(bool visible);
|
|
|
|
|
|
|
|
/** Is the object currently visible? */
|
|
|
|
bool isVisible() const;
|
|
|
|
|
2011-09-03 17:51:03 +00:00
|
|
|
/** Pause/Unpause the animation. */
|
|
|
|
void setPause(bool pause);
|
|
|
|
|
|
|
|
/** Is the animation currently paused? */
|
|
|
|
bool isPaused() const;
|
|
|
|
|
2011-09-12 15:11:31 +00:00
|
|
|
/** Set the animation mode. */
|
|
|
|
void setMode(Mode mode);
|
|
|
|
|
2011-09-03 10:41:06 +00:00
|
|
|
/** Set the current position to the animation's default. */
|
2012-06-05 14:18:05 +00:00
|
|
|
virtual void setPosition();
|
2011-09-03 10:41:06 +00:00
|
|
|
/** Set the current position. */
|
2012-06-05 14:18:05 +00:00
|
|
|
virtual void setPosition(int16 x, int16 y);
|
2011-09-03 10:41:06 +00:00
|
|
|
|
|
|
|
/** Return the current position. */
|
|
|
|
void getPosition(int16 &x, int16 &y) const;
|
|
|
|
|
2012-07-05 04:11:46 +00:00
|
|
|
/** Return the frame position after another n frames. */
|
|
|
|
void getFramePosition(int16 &x, int16 &y, uint16 n = 0) const;
|
|
|
|
/** Return the current frame size after another n frames. */
|
|
|
|
void getFrameSize(int16 &width, int16 &height, uint16 n = 0) const;
|
2011-09-03 10:41:06 +00:00
|
|
|
|
2012-01-28 18:45:02 +00:00
|
|
|
/** Are there coordinates within the animation sprite? */
|
|
|
|
bool isIn(int16 x, int16 y) const;
|
|
|
|
/** Is this object within the animation sprite? */
|
|
|
|
bool isIn(const ANIObject &obj) const;
|
|
|
|
|
2011-09-03 10:41:06 +00:00
|
|
|
/** Set the animation number. */
|
|
|
|
void setAnimation(uint16 animation);
|
|
|
|
|
2011-09-12 16:00:11 +00:00
|
|
|
/** Rewind the current animation to the first frame. */
|
|
|
|
void rewind();
|
|
|
|
|
2012-06-07 02:20:41 +00:00
|
|
|
/** Set the animation to a specific frame. */
|
|
|
|
void setFrame(uint16 frame);
|
|
|
|
|
2011-09-03 10:41:06 +00:00
|
|
|
/** Return the current animation number. */
|
|
|
|
uint16 getAnimation() const;
|
|
|
|
/** Return the current frame number. */
|
|
|
|
uint16 getFrame() const;
|
|
|
|
|
|
|
|
/** Is this the last frame within this animation cycle? */
|
|
|
|
bool lastFrame() const;
|
|
|
|
|
|
|
|
/** Draw the current frame onto the surface and return the affected rectangle. */
|
2012-06-05 14:18:05 +00:00
|
|
|
virtual bool draw(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom);
|
2011-09-03 10:41:06 +00:00
|
|
|
/** Draw the current frame from the surface and return the affected rectangle. */
|
2012-06-05 14:18:05 +00:00
|
|
|
virtual bool clear(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom);
|
2011-09-03 10:41:06 +00:00
|
|
|
|
|
|
|
/** Advance the animation to the next frame. */
|
|
|
|
virtual void advance();
|
|
|
|
|
|
|
|
private:
|
|
|
|
const ANIFile *_ani; ///< The managed ANI file.
|
2012-03-11 19:41:57 +00:00
|
|
|
const CMPFile *_cmp; ///< The managed CMP file.
|
2011-09-03 10:41:06 +00:00
|
|
|
|
|
|
|
uint16 _animation; ///< The current animation number
|
|
|
|
uint16 _frame; ///< The current frame.
|
|
|
|
|
|
|
|
bool _visible; ///< Is the object currently visible?
|
2011-09-03 17:51:03 +00:00
|
|
|
bool _paused; ///< Is the animation currently paused?
|
2011-09-03 10:41:06 +00:00
|
|
|
|
2011-09-12 15:11:31 +00:00
|
|
|
Mode _mode; ///< The animation mode.
|
|
|
|
|
2011-09-03 10:41:06 +00:00
|
|
|
int16 _x; ///< The current X position.
|
|
|
|
int16 _y; ///< The current Y position.
|
|
|
|
|
2012-03-11 19:41:57 +00:00
|
|
|
|
2012-06-03 16:58:03 +00:00
|
|
|
bool drawCMP(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom);
|
|
|
|
bool drawANI(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom);
|
2011-09-03 10:41:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Gob
|
|
|
|
|
|
|
|
#endif // GOB_ANIOBJECT_H
|