ScummVM API documentation
ad_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/*
23 * This file is based on WME Lite.
24 * http://dead-code.org/redir.php?target=wmelite
25 * Copyright (c) 2011 Jan Nedoma
26 */
27
28#ifndef WINTERMUTE_ADSCENE_H
29#define WINTERMUTE_ADSCENE_H
30
31#include "engines/wintermute/base/base_fader.h"
32
33namespace Wintermute {
34
35class UIWindow;
36class AdObject;
37class AdRegion;
38class BaseViewport;
39class AdLayer;
40class BasePoint;
41class Light3D;
42class AdWaypointGroup;
43class AdPath;
44class AdScaleLevel;
45class AdRotLevel;
46class AdPathPoint;
47#ifdef ENABLE_WME3D
48class AdSceneGeometry;
49#endif
50class AdScene : public BaseObject {
51public:
52
53#ifdef ENABLE_WME3D
54 uint32 _ambientLightColor;
55 TShadowType _maxShadowType;
56 bool _scroll3DCompatibility;
57
58 bool _fogEnabled;
59 uint32 _fogColor;
60 float _fogStart;
61 float _fogEnd;
62#endif
63
64 BaseObject *getNextAccessObject(BaseObject *currObject);
65 BaseObject *getPrevAccessObject(BaseObject *currObject);
66 bool getSceneObjects(BaseArray<AdObject *> &objects, bool interactiveOnly);
67 bool getRegionObjects(AdRegion *region, BaseArray<AdObject *> &objects, bool interactiveOnly);
68#ifdef ENABLE_WME3D
69 bool display3DContent(DXMatrix &viewMat, DXMatrix &projMat);
70#endif
71
72#ifdef ENABLE_WME3D
73 bool _2DPathfinding;
74#endif
75 bool afterLoad();
76
77#ifdef ENABLE_WME3D
78 float _nearClipPlane;
79 float _farClipPlane;
80 float _fov;
81#endif
82 int32 _editorResolutionWidth;
83 int32 _editorResolutionHeight;
84#ifdef ENABLE_WME3D
85 Light3D *getActiveLight();
86#endif
87 bool getRegionsAt(int x, int y, AdRegion **regionList, int numRegions);
88 bool handleItemAssociations(const char *itemName, bool show);
89 UIWindow *_shieldWindow;
90 float getRotationAt(int x, int y);
91 bool loadState();
92 bool saveState();
93 bool _persistentState;
94 bool _persistentStateSprites;
95 BaseObject *getNodeByName(const char *name);
96 void setOffset(int offsetLeft, int offsetTop);
97 bool pointInViewport(int x, int y);
98 int getOffsetTop();
99 int getOffsetLeft();
100 bool getViewportSize(int32 *width = nullptr, int32 *height = nullptr);
101 bool getViewportOffset(int32 *offsetX = nullptr, int32 *offsetY = nullptr);
102 BaseViewport *_viewport;
103 BaseFader *_fader;
104 int32 _pfPointsNum;
105 void pfPointsAdd(int x, int y, int distance);
106 void pfPointsStart();
107 bool _initialized;
108 bool correctTargetPoint(int32 startX, int32 startY, int32 *x, int32 *y, bool checkFreeObjects = false, BaseObject *requester = nullptr);
109 bool correctTargetPoint2(int32 startX, int32 startY, int32 *targetX, int32 *targetY, bool checkFreeObjects, BaseObject *requester);
110 DECLARE_PERSISTENT(AdScene, BaseObject)
111 bool displayRegionContent(AdRegion *region = nullptr, bool display3DOnly = false);
112 bool displayRegionContentOld(AdRegion *region = nullptr);
113 static int32 compareObjs(const void *obj1, const void *obj2);
114
115 bool updateFreeObjects();
116 bool traverseNodes(bool update = false);
117 float getScaleAt(int y);
118 bool sortScaleLevels();
119 bool sortRotLevels();
120 bool saveAsText(BaseDynamicBuffer *buffer, int indent) override;
121#ifdef ENABLE_WME3D
122 bool _showGeometry;
123 AdSceneGeometry *_geom;
124#endif
125 uint32 getAlphaAt(int x, int y, bool colorCheck = false);
126 bool _paralaxScrolling;
127 void skipTo(int offsetX, int offsetY);
128 void setDefaults();
129 void cleanup();
130 void skipToObject(BaseObject *object);
131 void scrollToObject(BaseObject *object);
132 void scrollTo(int offsetX, int offsetY);
133 bool update() override;
134 bool _autoScroll;
135 int32 _targetOffsetTop;
136 int32 _targetOffsetLeft;
137
138 int32 _scrollPixelsV;
139 uint32 _scrollTimeV;
140 uint32 _lastTimeV;
141
142 int32 _scrollPixelsH;
143 uint32 _scrollTimeH;
144 uint32 _lastTimeH;
145
146 bool display() override;
147 uint32 _pfMaxTime;
148 bool initLoop();
149 void pathFinderStep();
150 /*
151 * Added the possibility to configure the default behaviour of this function. If neither free objects nor a main layer
152 * exist, the function used to return "blocked". This results in all actors being "blocked" shortly after load.
153 * The default behaviour is unchanged to avoid strange side effects. The actor class is now able to override this default.
154 *
155 */
156 bool isBlockedAt(int x, int y, bool checkFreeObjects = false, BaseObject *requester = nullptr, bool defaultBlock = true);
157 bool isWalkableAt(int x, int y, bool checkFreeObjects = false, BaseObject *requester = nullptr);
158 AdLayer *_mainLayer;
159 float getZoomAt(int x, int y);
160 bool getPath(BasePoint source, BasePoint target, AdPath *path, BaseObject *requester = nullptr);
161 AdScene(BaseGame *inGame);
162 ~AdScene() override;
163 BaseArray<AdLayer *> _layers;
164 BaseArray<AdObject *> _objects;
165 BaseArray<AdWaypointGroup *> _waypointGroups;
166 bool loadFile(const char *filename);
167 bool loadBuffer(char *buffer, bool complete = true);
168 int32 _width{};
169 int32 _height{};
170 bool addObject(AdObject *object);
171 bool removeObject(AdObject *object);
172 int32 _editorMarginH;
173 int32 _editorMarginV;
174 uint32 _editorColFrame;
175 uint32 _editorColEntity;
176 uint32 _editorColRegion;
177 uint32 _editorColBlocked;
178 uint32 _editorColWaypoints;
179 uint32 _editorColEntitySel;
180 uint32 _editorColRegionSel;
181 uint32 _editorColBlockedSel;
182 uint32 _editorColWaypointsSel;
183 uint32 _editorColScale;
184 uint32 _editorColDecor;
185 uint32 _editorColDecorSel;
186
187 bool _editorShowRegions;
188 bool _editorShowBlocked;
189 bool _editorShowDecor;
190 bool _editorShowEntities;
191 bool _editorShowScale;
192 BaseArray<AdScaleLevel *> _scaleLevels;
193 BaseArray<AdRotLevel *> _rotLevels;
194
195 bool restoreDeviceObjects() override;
196 void setMaxShadowType(TShadowType shadowType);
197 int getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester = nullptr);
198
199 void onLayerResized(AdLayer *layer);
200
201 // scripting interface
202 ScValue *scGetProperty(const char *name) override;
203 bool scSetProperty(const char *name, ScValue *value) override;
204 bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
205 const char *scToString() override;
206
207 Common::String debuggerToString() const override;
208
209private:
210 bool persistState(bool saving = true);
211 void pfAddWaypointGroup(AdWaypointGroup *wpt, BaseObject *requester = nullptr);
212 bool _pfReady;
213 BasePoint *_pfTarget;
214 AdPath *_pfTargetPath;
215 BaseObject *_pfRequester;
217
218 int32 _offsetTop;
219 int32 _offsetLeft;
220};
221
222} // End of namespace Wintermute
223
224#endif
Definition: str.h:59
Definition: ad_layer.h:33
Definition: ad_object.h:46
Definition: ad_path.h:37
Definition: ad_region.h:35
Definition: ad_scene_geometry.h:47
Definition: ad_scene.h:50
Definition: ad_waypoint_group.h:35
Definition: coll_templ.h:345
Definition: base_dynamic_buffer.h:35
Definition: base_fader.h:36
Definition: base_game.h:79
Definition: base_object.h:49
Definition: base_point.h:36
Definition: base_viewport.h:37
Definition: 3dlight.h:38
Definition: script.h:44
Definition: script_stack.h:41
Definition: script_value.h:42
Definition: ui_window.h:39
Definition: xmath.h:139