ScummVM API documentation
world.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/*
23 * Based on
24 * WebVenture (c) 2010, Sean Kasun
25 * https://github.com/mrkite/webventure, http://seancode.com/webventure/
26 *
27 * Used with explicit permission from the author
28 */
29
30#ifndef MACVENTURE_WORLD_H
31#define MACVENTURE_WORLD_H
32
33#include "macventure/container.h"
34#include "macventure/text.h"
35
36namespace MacVenture {
37
38typedef uint32 ObjID;
39typedef uint16 Attribute;
40typedef Common::Array<Attribute> AttributeGroup;
41class TextAsset;
42
43enum ObjectAttributeID {
44 kAttrParentObject = 0,
45 kAttrPosX = 1,
46 kAttrPosY = 2,
47 kAttrInvisible = 3,
48 kAttrUnclickable = 4,
49 kAttrUndraggable = 5,
50 kAttrContainerOpen = 6,
51 kAttrPrefixes = 7,
52 kAttrIsExit = 8,
53 kAttrExitX = 9,
54 kAttrExitY = 10,
55 kAttrHiddenExit = 11,
56 kAttrOtherDoor = 12,
57 kAttrIsOpen = 13,
58 kAttrIsLocked = 14,
59 kAttrWeight = 16,
60 kAttrSize = 17,
61 kAttrHasDescription = 19,
62 kAttrIsDoor = 20,
63 kAttrIsContainer = 22,
64 kAttrIsOperable = 23,
65 kAttrIsEnterable = 24,
66 kAttrIsEdible = 25
67};
68
69class SaveGame {
70public:
72 ~SaveGame();
73
74 Attribute getAttr(ObjID objID, uint32 attrID);
75 void setAttr(uint32 attrID, ObjID objID, Attribute value);
76
77 void setGlobal(uint32 attrID, Attribute value);
78 const Common::Array<uint16> &getGlobals();
79
80 const Common::Array<AttributeGroup> &getGroups();
81 const AttributeGroup *getGroup(uint32 groupID);
82 const Common::String &getText();
83
84 void saveInto(MacVentureEngine *engine, Common::OutSaveFile *file);
85
86private:
87 void loadGroups(MacVentureEngine *engine, Common::SeekableReadStream *res);
88 void loadGlobals(MacVentureEngine *engine, Common::SeekableReadStream *res);
89 void loadText(MacVentureEngine *engine, Common::SeekableReadStream *res);
90
91private:
93 Common::Array<uint16> _globals;
94 Common::String _text;
95};
96
97class World {
98public:
100 ~World();
101
102 void startNewGame();
103
104 void setObjAttr(ObjID objID, uint32 attrID, Attribute value);
105 void setGlobal(uint32 attrID, Attribute value);
106 void updateObj(ObjID objID);
107 void captureChildren(ObjID objID);
108 void releaseChildren(ObjID objID);
109
110 uint32 getObjAttr(ObjID objID, uint32 attrID);
111 Attribute getGlobal(uint32 attrID);
112 Common::String getText(ObjID objID, ObjID source, ObjID target);
113
114 bool isObjActive(ObjID objID);
115 bool isObjDraggable(ObjID objID);
116
117 ObjID getAncestor(ObjID objID);
118 Common::Array<ObjID> getFamily(ObjID objID, bool recursive);
119 Common::Array<ObjID> getChildren(ObjID objID, bool recursive);
120
121 void loadGameFrom(Common::InSaveFile *file);
122 void saveGameInto(Common::OutSaveFile *file);
123
124private:
125 bool intersects(ObjID objID, Common::Rect rect);
126
127 void calculateObjectRelations();
128 void setParent(ObjID child, ObjID newParent);
129
130private:
131 MacVentureEngine *_engine;
132 Common::MacResManager *_resourceManager;
133
134 Common::Path _startGameFileName;
135
136 SaveGame *_saveGame;
137
138 Container *_objectConstants;
139 Container *_gameText;
140
141 Common::Array<ObjID> _relations; // Parent-child relations, stored in Williams Heap format
142};
143
144} // End of namespace MacVenture
145
146#endif
Definition: array.h:52
Definition: macresman.h:126
Definition: savefile.h:54
Definition: path.h:52
Definition: stream.h:745
Definition: str.h:59
Definition: container.h:48
Definition: macventure.h:218
Definition: world.h:69
Definition: world.h:97
Definition: rect.h:536