ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sprite.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef MEDIASTATION_SPRITE_H
23 #define MEDIASTATION_SPRITE_H
24 
25 #include "common/rect.h"
26 #include "common/array.h"
27 
28 #include "mediastation/asset.h"
29 #include "mediastation/assetheader.h"
30 #include "mediastation/datafile.h"
31 #include "mediastation/bitmap.h"
32 #include "mediastation/mediascript/scriptvalue.h"
33 #include "mediastation/mediascript/scriptconstants.h"
34 
35 namespace MediaStation {
36 
38 public:
39  SpriteFrameHeader(Chunk &chunk);
40  virtual ~SpriteFrameHeader() override;
41 
42  uint _index;
43  Common::Point *_boundingBox;
44 };
45 
46 class SpriteFrame : public Bitmap {
47 public:
48  SpriteFrame(Chunk &chunk, SpriteFrameHeader *header);
49  virtual ~SpriteFrame() override;
50 
51  uint32 left();
52  uint32 top();
53  Common::Point topLeft();
54  Common::Rect boundingBox();
55  uint32 index();
56 
57 private:
58  SpriteFrameHeader *_bitmapHeader = nullptr;
59 };
60 
61 // Sprites are somewhat like movies, but they strictly show one frame at a time
62 // and don't have sound. They are intended for background/recurrent animations.
63 class Sprite : public Asset {
64 friend class Context;
65 
66 public:
67  Sprite(AssetHeader *header);
68  ~Sprite();
69 
70  virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
71  virtual void process() override;
72  virtual void redraw(Common::Rect &rect) override;
73 
74  virtual void readChunk(Chunk &chunk) override;
75 
76 private:
78  SpriteFrame *_activeFrame = nullptr;
79  bool _showFirstFrame = true;
80  bool _isShowing = false;
81  bool _isPlaying = false;
82  uint _currentFrameIndex = 0;
83  uint _nextFrameTime = 0;
84 
85  int _xAdjust = 0;
86  int _yAdjust = 0;
87 
88  // Method implementations.
89  void spatialShow();
90  void spatialHide();
91  void timePlay();
92  void timeStop();
93  void movieReset();
94  void setCurrentClip();
95 
96  void updateFrameState();
97  void showFrame(SpriteFrame *frame);
98  Common::Rect getActiveFrameBoundingBox();
99 };
100 
101 } // End of namespace MediaStation
102 
103 #endif
Definition: sprite.h:37
Definition: sprite.h:46
Definition: asset.h:33
Definition: context.h:56
Definition: datafile.h:39
Definition: bitmap.h:40
Definition: rect.h:144
Definition: asset.h:37
Definition: bitmap.h:52
Definition: rect.h:45
Definition: assetheader.h:162
Definition: sprite.h:63
Definition: scriptvalue.h:36