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/msurface.h"
28 #include "mads/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 SpriteSlot;
64 class TextDisplay;
65 class UISlot;
66 
67 class DirtyArea {
68 private:
69  static MADSEngine *_vm;
70  friend class DirtyAreas;
71 public:
72  Common::Rect _bounds;
73  bool _textActive;
74  bool _active;
75  DirtyArea *_mergedArea;
76 
77  DirtyArea();
78 
79  void setArea(int width, int height, int maxWidth, int maxHeight);
80 
84  void setSpriteSlot(const SpriteSlot *spriteSlot);
85 
89  void setTextDisplay(const TextDisplay *textDisplay);
90 
94  void setUISlot(const UISlot *slot);
95 };
96 
97 class DirtyAreas : public Common::Array<DirtyArea> {
98 //private:
99 // MADSEngine *_vm;
100 public:
101  DirtyAreas(MADSEngine *vm);
102 
108  void merge(int startIndex, int count);
109 
110  bool intersects(int idx1, int idx2);
111  void mergeAreas(int idx1, int idx2);
112 
119  void copy(BaseSurface *srcSurface, BaseSurface *destSurface, const Common::Point &posAdjust);
120 
125  void copyToScreen();
126 
127  void reset();
128 };
129 
131 public:
132  bool _active;
133  Common::Rect _bounds;
134  ScrCategory _category;
135  int _descId;
136  int _mode;
137 
138  ScreenObject();
139 };
140 
141 class ScreenObjects : public Common::Array<ScreenObject> {
142 private:
143  MADSEngine *_vm;
144  int _objectY;
145 
146  int scanBackwards(const Common::Point &pt, int layer);
147 public:
148  InputMode _inputMode;
149  int _v7FED6;
150  int _v8332A;
151  int _forceRescan;
152  int _selectedObject;
153  ScrCategory _category;
154  bool _released;
155  int _uiCount;
156  bool _eventFlag;
157  uint32 _baseTime;
158  int _spotId;
159 
160  /*
161  * Constructor
162  */
164 
168  ScreenObject *add(const Common::Rect &bounds, ScreenMode mode, ScrCategory category, int descId);
169 
173  void check(bool scanFlag);
174 
178  int scan(const Common::Point &pt, int layer);
179 
183  void elementHighlighted();
184 
190  assert(idx > 0);
192  }
193 
200  void setActive(ScrCategory category, int descId, bool active);
201 
205  void synchronize(Common::Serializer &s);
206 };
207 
208 class Screen : public BaseSurface {
209 private:
210  uint16 _random;
211  MSurface _rawSurface;
212 
213  void panTransition(MSurface &newScreen, byte *palData, int entrySide,
214  const Common::Point &srcPos, const Common::Point &destPos,
215  ThroughBlack throughBlack, bool setPalette, int numTicks);
216 
217  void swapForeground(byte newPalette[PALETTE_SIZE], byte *paletteMap);
218 
219  void swapPalette(const byte palData[PALETTE_SIZE], byte swapTable[PALETTE_COUNT], bool foreground);
220 public:
221  int _shakeCountdown;
222 public:
226  Screen();
227 
231  ~Screen() override {}
232 
236  void update() override;
237 
241  void transition(ScreenTransition transitionType, bool surfaceFlag);
242 
246  void setClipBounds(const Common::Rect &r);
247 
251  void resetClipBounds();
252 
256  const Common::Rect getClipBounds() const {
257  const Common::Point pt = getOffsetFromOwner();
258  return Common::Rect(pt.x, pt.y, pt.x + this->w, pt.y + this->h);
259  }
260 };
261 
262 } // End of namespace MADS
263 
264 #endif /* MADS_SCREEN_H */
Definition: screen.h:97
Definition: msurface.h:55
Definition: screen.h:141
~Screen() override
Definition: screen.h:231
Definition: array.h:52
T & operator[](size_type idx)
Definition: array.h:273
Definition: rect.h:144
ScreenObject & operator[](int idx)
Definition: screen.h:189
Definition: serializer.h:79
Definition: screen.h:208
Out copy(In first, In last, Out dst)
Definition: algorithm.h:52
Definition: sprites.h:133
void setSpriteSlot(const SpriteSlot *spriteSlot)
const Common::Rect getClipBounds() const
Definition: screen.h:256
Definition: rect.h:45
void setTextDisplay(const TextDisplay *textDisplay)
Definition: mads.h:87
int16 x
Definition: rect.h:46
Definition: messages.h:134
int16 y
Definition: rect.h:47
Definition: action.h:28
Definition: screen.h:130
Definition: msurface.h:172
Definition: screen.h:67
Definition: user_interface.h:46
void setUISlot(const UISlot *slot)