1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef NANCY_ACTION_STATICBITMAPANIM_H
24 #define NANCY_ACTION_STATICBITMAPANIM_H
25 
26 #include "engines/nancy/commontypes.h"
27 #include "engines/nancy/renderobject.h"
28 
29 #include "engines/nancy/action/actionrecord.h"
30 
31 namespace Nancy {
32 namespace Action {
33 
34 // ActionRecord subclass describing a short "flipbook" animation from a single bitmap
35 // Also supports sound and getting interrupted by an event flag.
36 // This class covers both the PlayStaticBitmapAnimation and PlayIntStaticBitmapAnimation
37 // action record types, whose functionality is nearly identical
38 class PlayStaticBitmapAnimation : public ActionRecord, public RenderObject {
39 public:
PlayStaticBitmapAnimation(bool interruptible,RenderObject & redrawFrom)40 	PlayStaticBitmapAnimation(bool interruptible, RenderObject &redrawFrom) : RenderObject(redrawFrom, 7), _isInterruptible(interruptible) {}
~PlayStaticBitmapAnimation()41 	virtual ~PlayStaticBitmapAnimation() { _fullSurface.free(); }
42 
43 	virtual void init() override;
44 
45 	virtual void readData(Common::SeekableReadStream &stream) override;
46 	virtual void execute() override;
47 	virtual void onPause(bool pause) override;
48 
49 	Common::String _imageName;
50 
51 	NancyFlag _isTransparent = NancyFlag::kFalse; // 0xC
52 	NancyFlag _doNotChangeScene = NancyFlag::kFalse; // 0xE
53 	NancyFlag _isReverse = NancyFlag::kFalse; // 0x10
54 	NancyFlag _isLooping = NancyFlag::kFalse; // 0x12
55 	uint16 _firstFrame = 0; // 0x14
56 	uint16 _loopFirstFrame = 0; // 0x16
57 	uint16 _loopLastFrame = 0; // 0x18
58 	Time _frameTime;
59 	EventFlagDescription _interruptCondition; // 0x1E
60 	SceneChangeDescription _sceneChange;
61 	MultiEventFlagDescription _triggerFlags; // 0x2A
62 
63 	Nancy::SoundDescription _sound; // 0x52
64 
65 	// Describes a single frame in this animation
66 	Common::Array<Common::Rect> _srcRects;
67 	// Describes how the animation will be displayed on a single
68 	// frame of the viewport
69 	Common::Array<BitmapDescription> _bitmaps;
70 
71 	int16 _currentFrame = -1;
72 	int16 _currentViewportFrame = -1;
73 	Time _nextFrameTime;
74 	bool _isInterruptible;
75 
76 protected:
getRecordTypeName()77 	virtual Common::String getRecordTypeName() const override { return _isInterruptible ? "PlayIntStaticBitmapAnimation" : "PlayStaticBitmapAnimation"; }
isViewportRelative()78 	virtual bool isViewportRelative() const override { return true; }
79 
80 	void setFrame(uint frame);
81 
82 	Graphics::ManagedSurface _fullSurface;
83 };
84 
85 } // End of namespace Action
86 } // End of namespace Nancy
87 
88 #endif // NANCY_ACTION_STATICBITMAPANIM_H
89