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