ScummVM API documentation
location.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 #ifndef STARK_RESOURCES_LOCATION_H
23 #define STARK_RESOURCES_LOCATION_H
24 
25 #include "common/hashmap.h"
26 #include "common/rect.h"
27 #include "common/str.h"
28 
29 #include "engines/stark/gfx/renderentry.h"
30 #include "engines/stark/resources/object.h"
31 
32 namespace Stark {
33 
34 namespace Formats {
35 class XRCReadStream;
36 }
37 
38 namespace Resources {
39 
40 class ItemVisual;
41 class Layer;
42 class ModelItem;
43 class Sound;
44 
51 class Location : public Object {
52 public:
53  static const Type::ResourceType TYPE = Type::kLocation;
54 
55  Location(Object *parent, byte subType, uint16 index, const Common::String &name);
56  virtual ~Location();
57 
58  // Resource API
59  void onAllLoaded() override;
60  void onEnterLocation() override;
61  void onGameLoop() override;
62  void saveLoadCurrent(ResourceSerializer *serializer) override;
63 
65  bool has3DLayer();
66 
68  Gfx::RenderEntryArray listRenderEntries();
69 
71  Gfx::LightEntryArray listLightEntries();
72 
74  void initScroll(const Common::Point &maxScroll);
75 
77  Common::Point getScrollPosition() const;
78 
80  void setScrollPosition(const Common::Point &position);
81 
83  bool scrollToCoordinateSmooth(uint32 coordinate);
84 
86  void scrollToCharacterImmediate();
87 
89  void goToLayer(Layer *layer);
90 
96  void setHasActiveScroll();
97 
101  void stopAllScrolls();
102 
104  void startFollowingCharacter();
105 
107  void stopFollowingCharacter();
108 
109  void scrollToCoordinateImmediate(uint32 coordinate);
110 
112  ItemVisual *getCharacterItem(int32 character) const;
113 
115  void registerCharacterItem(int32 character, ItemVisual *item);
116 
118  const Common::Array<ModelItem *> &listModelItems() const;
119 
121  void resetAnimationBlending();
122 
124  Sound *findStockSound(uint32 stockSoundType) const;
125 
127  void startRumble(int32 rumbleDurationRemaining);
128 
130  void fadeInInit(int32 fadeDuration);
131  void fadeOutInit(int32 fadeDuration);
132 
134  void swayScene(int32 periodMs, const Math::Angle &angle, float amplitude, float offset);
135 
137  void floatScene(int32 periodMs, float amplitude, float offset);
138 
140  Layer *getLayerByName(const Common::String &name);
141 
143  Gfx::RenderEntry *getRenderEntryByName(const Common::String &name);
144 
146  Common::Array<Layer *> listLayers() { return _layers; }
147 
149  Common::Array<Common::Point> listExitPositions();
150 
151 protected:
152  void printData() override;
153 
154 private:
155  bool scrollToSmooth(const Common::Point &position, bool followCharacter);
156  bool scrollToCharacter(ModelItem *item);
157  Common::Point getCharacterScrollPosition(ModelItem *item);
158  uint getScrollStepFollow();
159  Common::Point getScrollPointFromCoordinate(uint32 coordinate) const;
160 
161  Sound *findStockSound(const Object *parent, uint32 stockSoundType) const;
162 
163  Common::Array<Layer *> _layers;
164  Layer *_currentLayer;
165 
166  bool _canScroll;
167  bool _hasActiveScroll;
168  bool _scrollFollowCharacter;
169  Common::Point _scroll;
170  Common::Point _maxScroll;
171 
172  uint getScrollStep();
173 
175  CharacterMap _characterItemMap;
176 
177  Common::Array<ModelItem *> _modelItems;
178 
179  int32 _rumbleDurationRemaining;
180 
181  bool _fadeOut;
182  int32 _fadeDuration;
183  float _fadePosition;
184 
185  int32 _swayPeriodMs;
186  Math::Angle _swayAngle;
187  float _swayAmplitude;
188  float _swayOffset;
189  float _swayPosition;
190 
191  int32 _idleActionWaitMs;
192 
193  int32 _floatPeriodMs;
194  float _floatAmplitude;
195  float _floatPosition;
196 };
197 
198 } // End of namespace Resources
199 } // End of namespace Stark
200 
201 #endif // STARK_RESOURCES_LOCATION_H
Definition: layer.h:46
Definition: location.h:51
Definition: str.h:59
Definition: array.h:52
Definition: item.h:413
Definition: sound.h:47
Definition: item.h:139
Definition: console.h:27
Definition: object.h:143
Definition: rect.h:45
Definition: renderentry.h:67
Definition: stateprovider.h:51
Common::Array< Layer * > listLayers()
Definition: location.h:146