ScummVM API documentation
esper.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 BLADERUNNER_ESPER_H
23 #define BLADERUNNER_ESPER_H
24 
25 #include "common/array.h"
26 #include "common/rect.h"
27 
28 #include "graphics/surface.h"
29 
30 namespace BladeRunner {
31 
32 class BladeRunnerEngine;
33 class Font;
34 class Shape;
35 class Shapes;
36 class VQAPlayer;
37 class UIImagePicker;
38 class ESPERScript;
39 
40 // CD-changing logic has been removed
41 
42 enum EsperMainStates {
43  kEsperMainStateOpening = 0,
44  kEsperMainStateList = 1,
45  kEsperMainStatePhotoOpening = 2,
46  kEsperMainStateClear = 3,
47  kEsperMainStatePhoto = 5
48 };
49 
50 enum EsperPhotoStates {
51  kEsperPhotoStateShow = 0,
52  kEsperPhotoStateOpening = 1,
53  kEsperPhotoStateScrolling = 2,
54  kEsperPhotoStateSelectionZooming = 3,
55  kEsperPhotoStateSelectionBlinking = 4,
56  kEsperPhotoStatePhotoZooming = 5,
57  kEsperPhotoStatePhotoSharpening = 6,
58  kEsperPhotoStatePhotoZoomOut = 7,
59  kEsperPhotoStateVideoZooming = 8,
60  kEsperPhotoStateVideoShow = 9,
61  kEsperPhotoStateVideoZoomOut = 10
62 };
63 
64 class ESPER {
65  static const int kPhotoCount = 12;
66  static const int kRegionCount = 6;
67  static const int kPhotoWidth = 1280;
68  static const int kPhotoHeight = 960;
69  static const int kSelectionZoomSteps = 6;
70 
71  static const Common::Rect kScreen;
72 
73  struct Photo {
74  bool isPresent;
75  int photoId;
76  int shapeId;
77  Common::String name;
78  };
79 
80  struct Region {
81  bool isPresent;
82  int regionId;
83  Common::Rect rectInner;
84  Common::Rect rectOuter;
85  Common::Rect rectSelection;
86  Common::String name;
87  };
88 
89  BladeRunnerEngine *_vm;
90  ESPERScript *_script;
91 
92  bool _isWaiting;
93  bool _isOpen;
94 
95  UIImagePicker *_buttons;
96 
97  Graphics::Surface _surfacePhoto;
98  Graphics::Surface _surfaceViewport;
99 
100  VQAPlayer *_vqaPlayerMain;
101  VQAPlayer *_vqaPlayerPhoto;
102  int _vqaLastFrame;
103 
104  Shapes *_shapesButtons;
105  Shapes *_shapesPhotos;
106  const Shape *_shapeThumbnail;
107 
108  Photo _photos[kPhotoCount];
109  int _photoIdSelected;
110 
111  Region _regions[kRegionCount];
112  int _regionSelected;
113  bool _regionSelectedAck;
114 
115  EsperMainStates _stateMain;
116  EsperPhotoStates _statePhoto;
117 
118  bool _isDrawingSelection;
119  bool _isMouseDown;
120  int _mouseOverScroll;
121 
122  float _zoomHorizontal;
123  float _zoomVertical;
124  float _zoom;
125  float _zoomMin;
126  float _zoomTarget;
127  float _zoomDelta;
128  float _blur;
129  int _zoomSteps;
130  int _zoomStep;
131  uint32 _timeZoomNextDiff;
132  uint32 _timeZoomNextStart;
133 
134  bool _isZoomingOut;
135  uint32 _timeZoomOutNextStart;
136 
137  Common::Rect _screen;
138 
139  Common::Rect _viewport;
140  Common::Rect _viewportNext;
141  int _viewportPositionX;
142  int _viewportPositionY;
143  float _viewportPositionXCurrent;
144  float _viewportPositionYCurrent;
145  int _viewportPositionXTarget;
146  int _viewportPositionYTarget;
147  float _viewportPositionXDelta;
148  float _viewportPositionYDelta;
149  int _viewportWidth;
150  int _viewportHeight;
151 
152  int _screenHalfWidth;
153  int _screenHalfHeight;
154 
155  int _flash;
156 
157  Common::Rect _selection;
158  Common::Rect _selectionTarget;
159  Common::Rect _selectionDelta;
160  int _selectionCrosshairX;
161  int _selectionCrosshairY;
162 
163  int _selectionBlinkingCounter;
164  int _selectionBlinkingStyle;
165  uint32 _timeSelectionBlinkingNextStart;
166 
167  int _selectionZoomStep;
168  uint32 _timeSelectionZoomNextStart;
169 
170  int _photoOpeningWidth;
171  int _photoOpeningHeight;
172  uint32 _timePhotoOpeningNextDiff;
173  uint32 _timePhotoOpeningNextStart;
174 
175  bool _isScrolling;
176  int _scrollingDirection;
177  uint32 _timeScrollNextStart;
178 
179  int _soundId1;
180  int _volume1; // should be in [0, 100]
181  int _soundId2;
182  int _volume2; // should be in [0, 100]
183  int _soundId3;
184  int _volume3; // should be in [0, 100]
185  int _ambientVolumeFactorOutsideEsper;
186 
187 public:
189  ~ESPER();
190 
191  void open(Graphics::Surface *surface);
192  void close();
193  bool isOpen() const;
194 
195  void handleMouseUp(int x, int y, bool buttonLeft);
196  void handleMouseDown(int x, int y, bool buttonLeft);
197 
198  void tick();
199 
200  void addPhoto(const char *name, int photoId, int shapeId);
201  void defineRegion(int regionId, Common::Rect inner, Common::Rect outer, Common::Rect selection, const char *name);
202 
203 private:
204  static void mouseDownCallback(int, void *);
205  static void mouseUpCallback(int, void *);
206 
207  void reset();
208  void resetData();
209  void resetPhotos();
210  void resetRegions();
211  void resetViewport();
212  void resetSelectionRect();
213  void resetSelectionBlinking();
214  void resetPhotoZooming();
215  void resetPhotoOpening();
216 
217  void updateViewport();
218 
219  void activate(bool withOpening);
220  void setStateMain(EsperMainStates state);
221  void setStatePhoto(EsperPhotoStates state);
222 
223  void wait(uint32 timeout);
224  void playSound(int soundId, int volume);
225 
226  void draw(Graphics::Surface &surface);
227 
228  void drawPhotoOpening(Graphics::Surface &surface);
229  bool drawSelectionZooming(Graphics::Surface &surface);
230  bool drawSelectionBlinking(Graphics::Surface &surface);
231  void drawPhotoZooming(Graphics::Surface &surface);
232  void drawPhotoSharpening(Graphics::Surface &surface);
233  void drawPhotoZoomOut(Graphics::Surface &surface);
234  void drawVideoZooming(Graphics::Surface &surface);
235  void drawVideoZoomOut(Graphics::Surface &surface);
236 
237  void drawPhoto(Graphics::Surface &surface);
238  void drawGrid(Graphics::Surface &surface);
239  void drawPhotoWithGrid(Graphics::Surface &surface);
240  void drawSelection(Graphics::Surface &surface, bool crosshair, int style);
241  void drawVideoFrame(Graphics::Surface &surface);
242  void drawTextCoords(Graphics::Surface &surface);
243  void drawMouse(Graphics::Surface &surface);
244 
245  void flashViewport();
246 
247  void copyImageScale(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect);
248  void copyImageBlur(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect, float u);
249  void copyImageBlit(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect);
250 
251  void tickSound();
252  void tickScroll();
253 
254  int findEmptyPhoto();
255  void selectPhoto(int photoId);
256  void unloadPhotos();
257 
258  int findEmptyRegion();
259  int findRegion(Common::Rect where);
260 
261  void zoomingStart();
262  void zoomOutStart();
263  void zoomOutStop();
264 
265  void scrollingStart(int direction);
266  void scrollingStop();
267  void scrollUpdate();
268  void scrollLeft();
269  void scrollUp();
270  void scrollRight();
271  void scrollDown();
272 
273  void goBack();
274 
275  void prepareZoom();
276  void updateSelection();
277 
278  int viewportXToScreenX(int x);
279  int viewportYToScreenY(int y);
280 };
281 
282 } // End of namespace BladeRunner
283 
284 #endif
Definition: esper.h:64
Definition: str.h:59
Definition: surface.h:66
Definition: actor.h:31
Definition: rect.h:144
Definition: esper_script.h:31
Definition: vqa_player.h:45
Definition: ui_image_picker.h:40
Definition: shape.h:41
Definition: bladerunner.h:113
Definition: shape.h:61