ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
asset.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_ASSET_H
23 #define MEDIASTATION_ASSET_H
24 
25 #include "common/keyboard.h"
26 
27 #include "mediastation/mediastation.h"
28 #include "mediastation/datafile.h"
29 #include "mediastation/mediascript/scriptconstants.h"
30 #include "mediastation/mediascript/operand.h"
31 #include "mediastation/assetheader.h"
32 
33 namespace MediaStation {
34 
35 class AssetHeader;
36 
37 class Asset {
38 public:
39  Asset(AssetHeader *header) : _header(header) {};
40  virtual ~Asset();
41 
42  // Does any needed frame drawing, audio playing, event handlers, etc.
43  virtual void process() {
44  return;
45  }
46 
47  // For spatial assets, actually redraws the dirty area.
48  virtual void redraw(Common::Rect &rect) {
49  return;
50  }
51 
52  // Runs built-in bytecode methods.
53  virtual Operand callMethod(BuiltInMethod methodId, Common::Array<Operand> &args) = 0;
54  // Called to have the asset do any processing, like drawing new frames,
55  // handling time-based event handlers, and such. Some assets don't have any
56  // processing to do.
57  virtual bool isActive() const {
58  return _isActive;
59  }
60 
61  // These are not pure virtual so if an asset doesnʻt read any chunks or
62  // subfiles it doesnʻt need to just implement these with an error message.
63  virtual void readChunk(Chunk &chunk);
64  virtual void readSubfile(Subfile &subfile, Chunk &chunk);
65 
66  void setInactive();
67  void setActive();
68  void processTimeEventHandlers();
69  void runEventHandlerIfExists(EventType eventType);
70  void runKeyDownEventHandlerIfExists(Common::KeyState keyState);
71 
72  AssetType type() const;
73  int zIndex() const;
74  AssetHeader *getHeader() const {
75  return _header;
76  }
77  Common::Rect *getBbox();
78 
79 protected:
80  AssetHeader *_header = nullptr;
81  bool _isActive = false;
82  uint _startTime = 0;
83  uint _lastProcessedTime = 0;
84  // TODO: Rename this to indicate the time is in milliseconds.
85  uint _duration = 0;
86 };
87 
88 } // End of namespace MediaStation
89 
90 #endif
Definition: asset.h:33
Definition: datafile.h:39
Definition: rect.h:144
Definition: asset.h:37
Definition: operand.h:35
Definition: assetheader.h:162
Definition: datafile.h:65
Definition: keyboard.h:294