ScummVM API documentation
scene.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 LASTEXPRESS_SCENE_H
23 #define LASTEXPRESS_SCENE_H
24 
25 /*
26  Scene format (CDTRAIN.DAT)
27 
28  (text:00484750)
29  header (24 bytes)
30  char {8} - entry name (null terminated)
31  byte {1} - 0xCD
32  uint16 {2} - number of scenes (for first entry - always 0 after?)
33  uint16 {2} - 11 ??
34  uint16 {2} - car
35  byte {1} - camera position (used to get the proper sequences to show)
36  byte {1} - type
37  byte {1} - param1
38  byte {1} - param2
39  byte {1} - param3
40  uint32 {4} - Offset to hotspot info struct
41 
42  probably contains cursor type too / scene index : 0 - 2500 (max)
43 
44  hotspot info (24 bytes)
45  uint16 {2} - left
46  uint16 {2} - right
47  uint16 {2} - top
48  uint16 {2} - bottom
49  uint32 {4} - scene coords data
50  uint16 {2} - scene
51  byte {1} - location;
52  byte {1} - action;
53  byte {1} - param1;
54  byte {1} - param2;
55  byte {1} - param3
56  byte {1} - cursor
57  uint32{4} - offset to next hotpost
58 
59  coords data (9 bytes)
60  uint32 {4} - ??
61  uint32 {4} - ??
62  byte {1} - ??
63  uint32 {4} - offset to next coords data structure
64 
65 */
66 
67 #include "lastexpress/drawable.h"
68 #include "lastexpress/shared.h"
69 
70 #include "common/array.h"
71 #include "common/rect.h"
72 
73 namespace Common {
74 class SeekableReadStream;
75 class String;
76 }
77 
78 namespace LastExpress {
79 
80 class Scene;
81 
82 class SceneHotspot {
83 public:
84  enum Action {
85  kActionNoneHS = 0,
86  kActionInventory = 1,
87  kActionSavePoint = 2,
88  kActionPlaySound = 3,
89  kActionPlayMusic = 4,
90  kActionKnockOnDoor = 5,
91  kActionCompartment = 6,
92  kActionPlaySounds = 7,
93  kActionPlayAnimation = 8,
94  kActionOpenCloseObject = 9,
95  kActionObjectUpdateLocation2 = 10,
96  kActionSetItemLocation = 11,
97  kAction12 = 12,
98  kActionPickItem = 13,
99  kActionDropItem = 14,
100  kAction15 = 15,
101  kActionEnterCompartment = 16,
102  kActionGetOutsideTrain = 18,
103  kActionSlip = 19,
104  kActionGetInsideTrain = 20,
105  kActionClimbUpTrain = 21,
106  kActionClimbDownTrain = 22,
107  kActionJumpUpDownTrain = 23,
108  kActionUnbound = 24,
109  kAction25 = 25,
110  kAction26 = 26,
111  kAction27 = 27,
112  kActionConcertSitCough = 28,
113  kAction29 = 29,
114  kActionCatchBeetleHS = 30,
115  kActionExitCompartmentHS = 31,
116  kAction32 = 32,
117  KActionUseWhistle = 33,
118  kActionOpenMatchBox = 34,
119  kActionOpenBed = 35,
120  kActionDialog = 37,
121  kActionEggBox = 38,
122  kAction39 = 39,
123  kActionBed = 40,
124  kAction41 = 41,
125  kAction42 = 42,
126  kActionSwitchChapter = 43,
127  kAction44 = 44
128  };
129 
130  struct SceneCoord {
131  int32 field_0;
132  int32 field_4;
133  byte field_8;
134  uint32 next;
135 
136  SceneCoord() {
137  field_0 = 0;
138  field_4 = 0;
139  field_8 = 0;
140  next = 0;
141  }
142  };
143 
144  Common::Rect rect;
145  uint32 coordsOffset;
146  SceneIndex scene;
147  byte location;
148  Action action;
149  byte param1;
150  byte param2;
151  byte param3;
152  byte cursor;
153  uint32 next;
154 
155  SceneHotspot() {
156  coordsOffset = 0;
157  scene = kSceneNone;
158  location = 0;
159  action = kActionNoneHS;
160  param1 = 0;
161  param2 = 0;
162  param3 = 0;
163  cursor = 0;
164  next = 0;
165  }
166  ~SceneHotspot();
167 
168  static SceneHotspot *load(Common::SeekableReadStream *stream);
169 
170  bool isInside(const Common::Point &point);
171 
172  Common::String toString() const;
173 
174 private:
176 };
177 
178 class SceneLoader {
179 public:
180  SceneLoader();
181  ~SceneLoader();
182 
183  bool load(Common::SeekableReadStream *stream);
184  Scene *get(SceneIndex index);
185 
186  uint32 count() const { return _scenes.size() - 1; }
187 
188 private:
190  Common::Array<Scene *> _scenes;
191 
192  void clear();
193 };
194 
195 class Scene : public Drawable {
196 public:
197  // Enumerations
198  enum Type {
199  // PreProcess
200  kTypeObject = 1,
201  kTypeItem = 2,
202  kTypeItem2 = 3,
203  kTypeObjectItem = 4,
204  kTypeItem3 = 5,
205  kTypeObjectLocation2 = 6,
206  kTypeCompartments = 7,
207  kTypeCompartmentsItem = 8,
208 
209  // PostProcess
210  kTypeList = 128,
211  kTypeSavePointChapter = 129,
212  kTypeLoadBeetleSequences = 130,
213  kTypeGameOver = 131,
214  kTypeReadText = 132,
215  kType133 = 133
216  };
217 
218  // Data
219  EntityPosition entityPosition;
220  Location location;
221  CarIndex car;
222  Position position;
223  Type type;
224  byte param1;
225  byte param2;
226  byte param3;
227 
228  ~Scene() override;
229 
230  Common::Rect draw(Graphics::Surface *surface) override;
231 
232  // Hotspots
233  Common::Array<SceneHotspot *> *getHotspots() { return &_hotspots; }
234  bool checkHotSpot(const Common::Point &coord, SceneHotspot **hotspot);
235  SceneHotspot *getHotspot(uint index = 0);
236 
237  Common::String toString();
238 
239 private:
240  char _name[8];
241  byte _sig;
242  uint32 _hotspot;
243 
244  Scene() {}
246 
247  static Scene *load(Common::SeekableReadStream *stream);
248  void loadHotspots(Common::SeekableReadStream *stream);
249 
250  void clear();
251 
252  // Only allow full access for loading the scene and the hotspots
253  friend bool SceneLoader::load(Common::SeekableReadStream *stream);
254  friend Scene *SceneLoader::get(SceneIndex index);
255 };
256 
257 } // End of namespace LastExpress
258 
259 #endif // LASTEXPRESS_SCENE_H
Definition: str.h:59
Definition: scene.h:195
Definition: surface.h:67
Definition: array.h:52
Definition: rect.h:144
Definition: stream.h:745
Definition: animation.h:45
Definition: scene.h:178
Definition: drawable.h:29
Definition: algorithm.h:29
Definition: rect.h:45
Definition: scene.h:82