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