ScummVM API documentation
livingbooks_item.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 MOHAWK_LIVINGBOOKS_ITEM_H
23 #define MOHAWK_LIVINGBOOKS_ITEM_H
24 
25 #include "livingbooks_code.h"
26 
27 #include "common/array.h"
28 #include "common/hash-str.h"
29 #include "common/hashmap.h"
30 #include "common/list.h"
31 #include "common/rect.h"
32 #include "common/str.h"
33 
34 namespace Common {
35  class SeekableReadStreamEndian;
36  class MemoryReadStreamEndian;
37 }
38 
39 namespace Mohawk {
40 
41 class MohawkEngine_LivingBooks;
42 class LBPage;
43 struct LBScriptEntry;
44 
45 class LBItem {
46  friend class LBCode;
47 
48 public:
50  virtual ~LBItem();
51 
52  void readFrom(Common::SeekableReadStreamEndian *stream);
53  void readData(uint16 type, uint16 size, byte *data);
54  virtual void readData(uint16 type, uint16 size, Common::MemoryReadStreamEndian *stream);
55 
56  virtual void destroySelf(); // 0x2
57  virtual void setEnabled(bool enabled); // 0x3
58  virtual void setGlobalEnabled(bool enabled);
59  virtual bool contains(Common::Point point); // 0x7
60  virtual void update(); // 0x8
61  virtual void draw() { } // 0x9
62  virtual void handleKeyChar(Common::Point pos) { } // 0xA
63  virtual void handleMouseDown(Common::Point pos); // 0xB
64  virtual void handleMouseMove(Common::Point pos); // 0xC
65  virtual void handleMouseUp(Common::Point pos); // 0xD
66  virtual bool togglePlaying(bool playing, bool restart = false); // 0xF
67  virtual void done(bool onlyNotify); // 0x10
68  virtual void init(); // 0x11
69  virtual void seek(uint16 pos) { } // 0x13
70  virtual void seekToTime(uint32 time) { }
71  virtual void setFocused(bool focused) { } // 0x14
72  virtual void setVisible(bool visible); // 0x17
73  virtual void setGlobalVisible(bool enabled);
74  virtual void startPhase(uint phase); // 0x18
75  virtual void stop(); // 0x19
76  virtual void notify(uint16 data, uint16 from); // 0x1A
77  virtual void load();
78  virtual void unload();
79  virtual void moveBy(const Common::Point &pos);
80  virtual void moveTo(const Common::Point &pos);
81 
82  LBItem *clone(uint16 newId, const Common::String &newName);
83 
84  uint16 getId() { return _itemId; }
85  const Common::String &getName() { return _desc; }
86  const Common::Rect &getRect() { return _rect; }
87  uint16 getSoundPriority() { return _soundMode; }
88  bool isLoaded() { return _loaded; }
89  bool isAmbient() { return _isAmbient; }
90 
92 
93  // TODO: make private
95 
96 protected:
98  LBPage *_page;
99 
100  void setNextTime(uint16 min, uint16 max);
101  void setNextTime(uint16 min, uint16 max, uint32 start);
102 
103  Common::Rect _rect;
104  Common::String _desc;
105  uint16 _resourceId;
106  uint16 _itemId;
107 
108  bool _loaded, _visible, _globalVisible, _playing, _enabled, _globalEnabled;
109 
110  uint32 _nextTime, _startTime;
111  uint16 _loops;
112 
113  uint16 _phase, _timingMode, _delayMin, _delayMax;
114  uint16 _loopMode, _periodMin, _periodMax;
115  uint16 _controlMode, _soundMode;
116  Common::Point _relocPoint;
117 
118  bool _isAmbient;
119  bool _doHitTest;
120 
121  virtual LBItem *createClone();
122 
123  Common::Array<LBScriptEntry *> _scriptEntries;
124  void runScript(uint event, uint16 data = 0, uint16 from = 0);
125  int runScriptEntry(LBScriptEntry *entry);
126 
127  void runCommand(const Common::String &command);
128  bool checkCondition(const Common::String &condition);
129 
130  LBScriptEntry *parseScriptEntry(uint16 type, uint16 &size, Common::MemoryReadStreamEndian *stream, bool isSubentry = false);
131 };
132 
133 } // End of namespace Mohawk
134 
135 #endif
Definition: str.h:59
Definition: livingbooks_code.h:212
Definition: array.h:52
Definition: rect.h:536
Definition: memstream.h:103
Definition: livingbooks_item.h:45
Definition: hashmap.h:85
Definition: algorithm.h:29
Definition: rect.h:144
Definition: livingbooks_itemscript.h:38
Definition: stream.h:944
Definition: list_intern.h:54
Definition: livingbooks_page.h:34
Definition: bitmap.h:32
Definition: livingbooks.h:84