qtgui: minor include fiddling
[openc2e.git] / SFCFile.h
blobe703b7d5bbe56f2bfe471fd17682883ade1443c0
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;
41 class SFCMacro;
43 struct SFCScript {
44 uint8 genus, family;
45 uint16 species, eventno;
46 std::string data;
48 void read(class SFCFile *);
49 void install();
52 class SFCFile {
53 private:
54 bool reading_compound;
55 bool reading_scenery;
56 unsigned int ver;
58 std::vector<SFCClass *> storage;
59 std::map<unsigned int, unsigned int> types;
61 std::istream *ourStream;
63 public:
64 MapData *mapdata;
65 std::vector<SFCObject *> objects;
66 std::vector<SFCScenery *> scenery;
67 std::vector<SFCScript> scripts;
68 std::vector<SFCMacro *> macros;
70 uint32 scrollx, scrolly;
71 std::string favplacename;
72 uint32 favplacex, favplacey;
73 std::vector<std::string> speech_history;
75 SFCFile() : reading_compound(false), reading_scenery(false) { }
76 ~SFCFile();
77 void read(std::istream *i);
78 SFCClass *slurpMFC(unsigned int reqtype = 0);
80 uint8 read8();
81 uint16 read16();
82 uint32 read32();
83 signed int reads32() { return (signed int)read32(); }
84 std::string readBytes(unsigned int n);
85 std::string readstring();
87 bool readingScenery() { return reading_scenery; }
88 bool readingCompound() { return reading_compound; }
89 void setVersion(unsigned int v);
90 unsigned int version() { return ver; }
92 void copyToWorld();
95 class SFCClass {
96 protected:
97 friend class SFCFile;
99 SFCFile *parent;
100 SFCClass(SFCFile *p) : parent(p) { }
101 virtual ~SFCClass() { }
103 SFCClass *slurpMFC(unsigned int reqtype = 0) { return parent->slurpMFC(reqtype); }
104 uint8 read8() { return parent->read8(); }
105 uint16 read16() { return parent->read16(); }
106 uint32 read32() { return parent->read32(); }
107 signed int reads32() { return parent->reads32(); }
108 std::string readBytes(unsigned int n) { return parent->readBytes(n); }
109 std::string readstring() { return parent->readstring(); }
111 virtual void read() = 0;
113 public:
114 SFCFile *getParent() { return parent; }
117 class CGallery : public SFCClass {
118 public:
119 uint32 noframes;
120 uint32 firstimg;
121 std::string filename;
123 // no real need for sizes/offsets/etc..
125 CGallery(SFCFile *p) : SFCClass(p) { }
126 void read();
129 class CDoor : public SFCClass {
130 public:
131 uint8 openness;
132 uint16 otherroom;
134 CDoor(SFCFile *p) : SFCClass(p) { }
135 void read();
138 class CRoom : public SFCClass {
139 public:
140 uint32 id;
141 uint32 left, top, right, bottom;
142 std::vector<CDoor *> doors[4];
143 uint32 roomtype;
144 uint8 floorvalue;
145 uint8 inorganicnutrients, organicnutrients, temperature, pressure, lightlevel, radiation;
146 signed char heatsource, pressuresource, lightsource, radiationsource;
147 uint32 windx, windy;
148 std::vector<std::pair<uint32, uint32> > floorpoints;
149 std::string music;
150 uint32 dropstatus;
152 // TODO: misc data
154 CRoom(SFCFile *p) : SFCClass(p) { }
155 void read();
158 class MapData : public SFCClass {
159 public:
160 CGallery *background;
161 std::vector<CRoom *> rooms;
162 unsigned int groundlevels[261];
164 // TODO: misc data
166 MapData(SFCFile *p) : SFCClass(p) { }
167 void read();
168 void copyToWorld();
169 virtual ~MapData();
172 class SFCEntity : public SFCClass {
173 public:
174 CGallery *sprite;
176 uint8 currframe, imgoffset;
177 uint32 zorder;
178 uint32 x, y;
179 bool haveanim;
180 uint8 animframe;
181 std::string animstring;
183 uint32 relx, rely;
185 uint32 partzorder;
186 int bhvrclick[3];
187 uint8 bhvrtouch;
189 std::vector<std::pair<int, int> > pickup_handles;
190 std::vector<std::pair<int, int> > pickup_points;
192 // TODO: misc data/flags
193 SFCEntity(SFCFile *p) : SFCClass(p) { }
194 void read();
197 class SFCObject : public SFCClass {
198 protected:
199 SFCObject(SFCFile *p) : SFCClass(p) { }
201 public:
202 uint8 genus, family;
203 uint16 species;
205 uint32 unid; // needed?
206 uint16 attr;
207 uint32 left, top, right, bottom; // what is this?
208 uint8 actv;
210 std::string currentsound;
212 CGallery *sprite;
214 uint32 tickreset, tickstate;
216 uint32 variables[100];
218 uint8 size, threat;
219 uint32 range, accg, velx, vely, rest, aero;
220 uint32 gravdata;
222 bool frozen;
224 std::vector<SFCScript> scripts;
225 void read();
226 virtual void copyToWorld() = 0;
227 virtual class Agent *copiedAgent() = 0;
230 struct SFCHotspot {
231 int left, top, right, bottom;
232 int function;
233 uint16 message;
234 uint8 mask;
237 class SFCCompoundObject : public SFCObject {
238 protected:
239 class CompoundAgent *ourAgent;
241 public:
242 std::vector<SFCEntity *> parts;
244 SFCHotspot hotspots[6];
246 SFCCompoundObject(SFCFile *p) : SFCObject(p) { ourAgent = 0; }
247 void read();
248 void copyToWorld();
249 class Agent *copiedAgent() { return (Agent *)ourAgent; }
252 class SFCBlackboard : public SFCCompoundObject {
253 public:
254 uint32 textx, texty;
255 uint32 backgroundcolour, chalkcolour, aliascolour;
256 std::vector<std::pair<uint32, std::string> > strings;
258 SFCBlackboard(SFCFile *p) : SFCCompoundObject(p) { }
259 void read();
260 void copyToWorld();
263 class SFCVehicle : public SFCCompoundObject {
264 public:
265 uint32 cabinleft, cabintop, cabinright, cabinbottom;
266 int xvec, yvec;
267 uint8 bump;
269 // TODO: misc data
271 SFCVehicle(SFCFile *p) : SFCCompoundObject(p) { }
272 void read();
273 void copyToWorld();
276 class SFCLift : public SFCVehicle {
277 friend class SFCCallButton;
279 public:
280 uint32 nobuttons;
281 uint32 currentbutton;
282 uint32 callbuttony[8];
283 bool alignwithcabin;
284 // TODO: misc data
286 SFCLift(SFCFile *p) : SFCVehicle(p) { }
287 void read();
288 void copyToWorld();
291 class SFCSimpleObject : public SFCObject {
292 protected:
293 class SimpleAgent *ourAgent;
295 public:
296 SFCEntity *entity;
298 SFCSimpleObject(SFCFile *p) : SFCObject(p) { ourAgent = 0; }
299 void read();
300 void copyToWorld();
301 class Agent *copiedAgent() { return (Agent *)ourAgent; }
304 class SFCPointerTool : public SFCSimpleObject {
305 public:
306 // TODO: misc data
308 SFCPointerTool(SFCFile *p) : SFCSimpleObject(p) { }
309 void read();
310 void copyToWorld();
313 class SFCCallButton : public SFCSimpleObject {
314 public:
315 SFCLift *ourLift;
316 uint8 liftid;
318 SFCCallButton(SFCFile *p) : SFCSimpleObject(p) { }
319 void read();
320 void copyToWorld();
323 class SFCScenery : public SFCSimpleObject {
324 public:
325 SFCScenery(SFCFile *p) : SFCSimpleObject(p) { }
326 void copyToWorld();
329 class SFCMacro : public SFCClass {
330 protected:
331 SFCObject *owner, *from, *targ;
332 std::string script;
334 public:
335 SFCMacro(SFCFile *p) : SFCClass(p) { }
336 void read();
337 void activate();
340 #endif
342 /* vim: set noet: */