don't include OpenALBackend.h in qtgui/qtopenc2e.cpp
[openc2e.git] / SFCFile.h
blob9b5efdbaf3d44a09fe8ae65e54809ac630a68f77
1 /*
2 * SFCFile.h
3 * openc2e
5 * Created by Alyssa Milburn on Sat 21 Oct 2006.
6 * Copyright (c) 2006-2008 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #ifndef _SFCFILE_H
21 #define _SFCFILE_H
23 #include "endianlove.h"
24 #include <map>
25 #include <vector>
26 #include <string>
27 #include <istream>
30 * Note that we don't use shared_ptr here, everything is owned by the
31 * SFCFile. I couldn't find a way to cast downwards with shared_ptr,
32 * and since everything revolves around slurpMFC - which can only return
33 * the base SFCClass type - it seemed best to just use pointers, since
34 * ownership is clear. - fuzzie
37 class SFCClass;
38 class MapData;
39 class SFCObject;
40 class SFCScenery;
42 struct SFCScript {
43 uint8 genus, family;
44 uint16 species, eventno;
45 std::string data;
47 void read(class SFCFile *);
48 void install();
51 class SFCFile {
52 private:
53 bool reading_compound;
54 bool reading_scenery;
55 unsigned int ver;
57 std::vector<SFCClass *> storage;
58 std::map<unsigned int, unsigned int> types;
60 std::istream *ourStream;
62 public:
63 MapData *mapdata;
64 std::vector<SFCObject *> objects;
65 std::vector<SFCScenery *> scenery;
66 std::vector<SFCScript> scripts;
68 uint32 scrollx, scrolly;
69 // TODO: favourite places
71 SFCFile() : reading_compound(false), reading_scenery(false) { }
72 ~SFCFile();
73 void read(std::istream *i);
74 SFCClass *slurpMFC(unsigned int reqtype = 0);
76 uint8 read8();
77 uint16 read16();
78 uint32 read32();
79 signed int reads32() { return (signed int)read32(); }
80 std::string readBytes(unsigned int n);
81 std::string readstring();
83 bool readingScenery() { return reading_scenery; }
84 bool readingCompound() { return reading_compound; }
85 void setVersion(unsigned int v);
86 unsigned int version() { return ver; }
88 void copyToWorld();
91 class SFCClass {
92 protected:
93 friend class SFCFile;
95 SFCFile *parent;
96 SFCClass(SFCFile *p) : parent(p) { }
97 virtual ~SFCClass() { }
99 SFCClass *slurpMFC(unsigned int reqtype = 0) { return parent->slurpMFC(reqtype); }
100 uint8 read8() { return parent->read8(); }
101 uint16 read16() { return parent->read16(); }
102 uint32 read32() { return parent->read32(); }
103 signed int reads32() { return parent->reads32(); }
104 std::string readBytes(unsigned int n) { return parent->readBytes(n); }
105 std::string readstring() { return parent->readstring(); }
107 virtual void read() = 0;
110 class CGallery : public SFCClass {
111 public:
112 uint32 noframes;
113 uint32 firstimg;
114 std::string filename;
116 // no real need for sizes/offsets/etc..
118 CGallery(SFCFile *p) : SFCClass(p) { }
119 void read();
122 class CDoor : public SFCClass {
123 public:
124 uint8 openness;
125 uint16 otherroom;
127 CDoor(SFCFile *p) : SFCClass(p) { }
128 void read();
131 class CRoom : public SFCClass {
132 public:
133 uint32 id;
134 uint32 left, top, right, bottom;
135 std::vector<CDoor *> doors[4];
136 uint32 roomtype;
137 uint8 floorvalue;
138 uint8 inorganicnutrients, organicnutrients, temperature, pressure, lightlevel, radiation;
139 signed char heatsource, pressuresource, lightsource, radiationsource;
140 uint32 windx, windy;
141 std::vector<std::pair<uint32, uint32> > floorpoints;
142 std::string music;
143 uint32 dropstatus;
145 // TODO: misc data
147 CRoom(SFCFile *p) : SFCClass(p) { }
148 void read();
151 class MapData : public SFCClass {
152 public:
153 CGallery *background;
154 std::vector<CRoom *> rooms;
156 // TODO: misc data
158 MapData(SFCFile *p) : SFCClass(p) { }
159 void read();
160 void copyToWorld();
161 virtual ~MapData();
164 class SFCEntity : public SFCClass {
165 public:
166 CGallery *sprite;
168 uint8 currframe, imgoffset;
169 uint32 zorder;
170 uint32 x, y;
171 bool haveanim;
172 uint8 animframe;
173 std::string animstring;
175 uint32 relx, rely;
177 uint32 partzorder;
178 int bhvrclick[3];
179 uint8 bhvrtouch;
181 std::vector<std::pair<uint32, uint32> > pickup_handles;
182 std::vector<std::pair<uint32, uint32> > pickup_points;
184 // TODO: misc data/flags
185 SFCEntity(SFCFile *p) : SFCClass(p) { }
186 void read();
189 class SFCObject : public SFCClass {
190 protected:
191 SFCObject(SFCFile *p) : SFCClass(p) { }
193 public:
194 uint8 genus, family;
195 uint16 species;
197 uint32 unid; // needed?
198 uint16 attr;
199 uint32 left, top, right, bottom; // what is this?
200 uint8 actv;
202 std::string currentsound;
204 CGallery *sprite;
206 uint32 tickreset, tickstate;
208 uint32 variables[100];
210 uint8 size, threat;
211 uint32 range, accg, velx, vely, rest, aero;
212 uint32 gravdata;
214 bool frozen;
216 std::vector<SFCScript> scripts;
217 void read();
218 virtual void copyToWorld() = 0;
219 virtual class Agent *copiedAgent() = 0;
222 struct SFCHotspot {
223 int left, top, right, bottom;
224 int function;
225 uint16 message;
226 uint8 mask;
229 class SFCCompoundObject : public SFCObject {
230 protected:
231 class CompoundAgent *ourAgent;
233 public:
234 std::vector<SFCEntity *> parts;
236 SFCHotspot hotspots[6];
238 SFCCompoundObject(SFCFile *p) : SFCObject(p) { ourAgent = 0; }
239 void read();
240 void copyToWorld();
241 class Agent *copiedAgent() { return (Agent *)ourAgent; }
244 class SFCBlackboard : public SFCCompoundObject {
245 public:
246 uint32 textx, texty;
247 uint16 backgroundcolour, chalkcolour, aliascolour;
248 std::map<uint32, std::string> strings;
250 SFCBlackboard(SFCFile *p) : SFCCompoundObject(p) { }
251 void read();
252 void copyToWorld();
255 class SFCVehicle : public SFCCompoundObject {
256 public:
257 uint32 cabinleft, cabintop, cabinright, cabinbottom;
258 int xvec, yvec;
259 uint8 bump;
261 // TODO: misc data
263 SFCVehicle(SFCFile *p) : SFCCompoundObject(p) { }
264 void read();
265 void copyToWorld();
268 class SFCLift : public SFCVehicle {
269 friend class SFCCallButton;
271 public:
272 uint32 nobuttons;
273 uint32 currentbutton;
274 uint32 callbuttony[8];
275 // TODO: misc data
277 SFCLift(SFCFile *p) : SFCVehicle(p) { }
278 void read();
279 void copyToWorld();
282 class SFCSimpleObject : public SFCObject {
283 protected:
284 class SimpleAgent *ourAgent;
286 public:
287 SFCEntity *entity;
289 SFCSimpleObject(SFCFile *p) : SFCObject(p) { ourAgent = 0; }
290 void read();
291 void copyToWorld();
292 class Agent *copiedAgent() { return (Agent *)ourAgent; }
295 class SFCPointerTool : public SFCSimpleObject {
296 public:
297 // TODO: misc data
299 SFCPointerTool(SFCFile *p) : SFCSimpleObject(p) { }
300 void read();
301 void copyToWorld();
304 class SFCCallButton : public SFCSimpleObject {
305 public:
306 SFCLift *ourLift;
307 uint8 liftid;
309 SFCCallButton(SFCFile *p) : SFCSimpleObject(p) { }
310 void read();
311 void copyToWorld();
314 class SFCScenery : public SFCSimpleObject {
315 public:
316 SFCScenery(SFCFile *p) : SFCSimpleObject(p) { }
317 void copyToWorld();
320 #endif
322 /* vim: set noet: */