ScummVM API documentation
screen.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 MADS_SCREEN_H
23 #define MADS_SCREEN_H
24 
25 #include "common/scummsys.h"
26 #include "common/array.h"
27 #include "mads/core/msurface.h"
28 #include "mads/core/action.h"
29 
30 namespace MADS {
31 
32 #define MADS_SCREEN_WIDTH 320
33 #define MADS_SCREEN_HEIGHT 200
34 
35 enum ScreenMode {
36  SCREENMODE_VGA = 19
37 };
38 
39 enum ScreenTransition {
40  kTransitionNone = 0,
41  kTransitionFadeIn, kTransitionFadeOutIn,
42  kTransitionBoxInBottomLeft, kTransitionBoxInBottomRight,
43  kTransitionBoxInTopLeft, kTransitionBoxInTopRight,
44  kTransitionPanLeftToRight, kTransitionPanRightToLeft,
45  kTransitionCircleIn1, kTransitionCircleIn2,
46  kTransitionCircleIn3, kTransitionCircleIn4,
47  kVertTransition1, kVertTransition2, kVertTransition3,
48  kVertTransition4, kVertTransition5, kVertTransition6,
49  kVertTransition7, kNullPaletteCopy
50 };
51 
52 enum InputMode {
53  kInputBuildingSentences = 0, // Normal sentence building
54  kInputConversation = 1, // Conversation mode
55  kInputLimitedSentences = 2 // Use only scene hotspots
56 };
57 
58 enum ThroughBlack {
59  THROUGH_BLACK1 = 1,
60  THROUGH_BLACK2 = 2
61 };
62 
63 class RexNebularEngine;
64 class SpriteSlot;
65 class TextDisplay;
66 class UISlot;
67 
68 class DirtyArea {
69 private:
70  static RexNebularEngine *_vm;
71  friend class DirtyAreas;
72 public:
73  Common::Rect _bounds;
74  bool _textActive;
75  bool _active;
76  DirtyArea *_mergedArea;
77 
78  DirtyArea();
79 
80  void setArea(int width, int height, int maxWidth, int maxHeight);
81 
85  void setSpriteSlot(const SpriteSlot *spriteSlot);
86 
90  void setTextDisplay(const TextDisplay *textDisplay);
91 
95  void setUISlot(const UISlot *slot);
96 };
97 
98 class DirtyAreas : public Common::Array<DirtyArea> {
99 //private:
100 // RexNebularEngine *_vm;
101 public:
103 
109  void merge(int startIndex, int count);
110 
111  bool intersects(int idx1, int idx2);
112  void mergeAreas(int idx1, int idx2);
113 
120  void copy(BaseSurface *srcSurface, BaseSurface *destSurface, const Common::Point &posAdjust);
121 
126  void copyToScreen();
127 
128  void reset();
129 };
130 
132 public:
133  bool _active;
134  Common::Rect _bounds;
135  ScrCategory _category;
136  int _descId;
137  int _mode;
138 
139  ScreenObject();
140 };
141 
142 class ScreenObjects : public Common::Array<ScreenObject> {
143 private:
144  RexNebularEngine *_vm;
145  int _objectY;
146 
147  int scanBackwards(const Common::Point &pt, int layer);
148 public:
149  InputMode _inputMode;
150  int _v7FED6;
151  int _v8332A;
152  int _forceRescan;
153  int _selectedObject;
154  ScrCategory _category;
155  bool _released;
156  int _uiCount;
157  bool _eventFlag;
158  uint32 _baseTime;
159  int _spotId;
160 
161  /*
162  * Constructor
163  */
165 
169  ScreenObject *add(const Common::Rect &bounds, ScreenMode mode, ScrCategory category, int descId);
170 
174  void check(bool scanFlag);
175 
179  int scan(const Common::Point &pt, int layer);
180 
184  void elementHighlighted();
185 
191  assert(idx > 0);
193  }
194 
201  void setActive(ScrCategory category, int descId, bool active);
202 
206  void synchronize(Common::Serializer &s);
207 };
208 
209 class Screen : public BaseSurface {
210 private:
211  uint16 _random;
212  MSurface _rawSurface;
213 
214  void panTransition(MSurface &newScreen, byte *palData, int entrySide,
215  const Common::Point &srcPos, const Common::Point &destPos,
216  ThroughBlack throughBlack, bool setPalette, int numTicks);
217 
218  void swapForeground(byte newPalette[PALETTE_SIZE], byte *paletteMap);
219 
220  void swapPalette(const byte palData[PALETTE_SIZE], byte swapTable[PALETTE_COUNT], bool foreground);
221 public:
222  int _shakeCountdown;
223 public:
227  Screen();
228 
232  ~Screen() override {}
233 
237  void update() override;
238 
242  void transition(ScreenTransition transitionType, bool surfaceFlag);
243 
247  void setClipBounds(const Common::Rect &r);
248 
252  void resetClipBounds();
253 
257  const Common::Rect getClipBounds() const {
258  const Common::Point pt = getOffsetFromOwner();
259  return Common::Rect(pt.x, pt.y, pt.x + this->w, pt.y + this->h);
260  }
261 };
262 
263 } // namespace MADS
264 
265 #endif /* MADS_SCREEN_H */
Definition: screen.h:98
Definition: msurface.h:55
Definition: screen.h:142
~Screen() override
Definition: screen.h:232
Definition: array.h:52
T & operator[](size_type idx)
Definition: array.h:274
Definition: rect.h:524
ScreenObject & operator[](int idx)
Definition: screen.h:190
Definition: serializer.h:79
Definition: screen.h:209
Definition: nebular.h:50
Out copy(In first, In last, Out dst)
Definition: algorithm.h:52
T y
Definition: rect.h:49
Definition: sprites.h:133
void setSpriteSlot(const SpriteSlot *spriteSlot)
const Common::Rect getClipBounds() const
Definition: screen.h:257
T x
Definition: rect.h:48
Definition: rect.h:144
void setTextDisplay(const TextDisplay *textDisplay)
Definition: messages.h:134
Definition: action.h:28
Definition: screen.h:131
Definition: msurface.h:172
Definition: screen.h:68
Definition: user_interface.h:46
void setUISlot(const UISlot *slot)