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 MADE_SCREEN_H
23 #define MADE_SCREEN_H
24 
25 #include "made/resource.h"
26 
27 #include "common/rect.h"
28 
29 #include "graphics/cursor.h"
30 
31 namespace Made {
32 
33 struct SpriteChannel {
34  int16 type;
35  int16 state;
36  uint16 index;
37  int16 x, y;
38  uint16 fontNum;
39  int16 textColor, outlineColor;
40  int16 frameNum;
41  int16 mask;
42  Common::String previousText;
43 };
44 
45 struct ClipInfo {
46  Common::Rect clipRect;
47  Graphics::Surface *destSurface;
48 };
49 
51  int16 index, xofs, yofs;
52 };
53 
54 class MadeEngine;
55 class ScreenEffects;
56 
57 static const byte defaultMouseCursor[256] = {
58  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
59  0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0,
60  0, 0, 0, 0, 0, 0, 0, 1, 15, 15, 1, 0, 0, 0, 0, 0,
61  0, 0, 0, 0, 0, 0, 0, 1, 15, 15, 1, 0, 0, 0, 0, 0,
62  0, 0, 0, 0, 0, 0, 0, 1, 15, 15, 1, 0, 0, 0, 0, 0,
63  0, 1, 1, 1, 1, 1, 1, 1, 15, 15, 1, 0, 0, 0, 0, 0,
64  1, 1, 15, 1, 15, 1, 15, 1, 15, 15, 1, 0, 0, 0, 0, 0,
65  1, 15, 15, 1, 15, 1, 15, 1, 15, 15, 1, 0, 0, 0, 0, 0,
66  1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 0, 1, 1, 1, 0,
67  1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 15, 15, 15, 1,
68  1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 1,
69  1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 0, 0,
70  1, 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 0, 0, 0,
71  0, 1, 1, 15, 15, 15, 15, 15, 15, 15, 1, 1, 0, 0, 0, 0,
72  0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
73  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
74 };
75 
76 class Screen {
77 public:
78  Screen(MadeEngine *vm);
79  ~Screen();
80 
81  void clearScreen();
82 
83  void drawSurface(Graphics::Surface *sourceSurface, int x, int y, int16 flipX, int16 flipY, int16 mask, const ClipInfo &clipInfo);
84 
85  void setRGBPalette(byte *palRGB, int start = 0, int count = 256);
86  bool isPaletteLocked() { return _paletteLock; }
87  void setPaletteLock(bool lock) { _paletteLock = lock; }
88  bool isScreenLocked() { return _screenLock; }
89  void setScreenLock(bool lock) { _screenLock = lock; }
90  void setVisualEffectNum(int visualEffectNum) { _visualEffectNum = visualEffectNum; }
91 
92  void setClipArea(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
93  _clipArea.clipRect = Common::Rect(x1, y1, x2, y2);
94  }
95 
96  void setExcludeArea(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
97 
98  void setClip(int16 clip) { _clip = clip; }
99  void setExclude(int16 exclude) { _exclude = exclude; }
100  void setGround(int16 ground) { _ground = ground; }
101  void setMask(int16 mask) { _mask = mask; }
102 
103  void setTextColor(int16 color) { _textColor = color; }
104 
105  void setTextRect(const Common::Rect &textRect) {
106  _textRect = textRect;
107  _textX = _textRect.left;
108  _textY = _textRect.top;
109  }
110 
111  void getTextRect(Common::Rect &textRect) {
112  textRect = _textRect;
113  }
114 
115  void setOutlineColor(int16 color) {
116  _outlineColor = color;
117  _dropShadowColor = -1;
118  }
119 
120  void setDropShadowColor(int16 color) {
121  _outlineColor = -1;
122  _dropShadowColor = color;
123  }
124 
125  void setTextXY(int16 x, int16 y) {
126  _textX = x;
127  _textY = y;
128  }
129 
130  void homeText() {
131  _textX = _textRect.left;
132  _textY = _textRect.top;
133  }
134 
135  void setQueueNextText(bool value) { _queueNextText = value; }
136  void setVoiceTimeText(bool value) { _voiceTimeText = value; }
137 
138  uint16 updateChannel(uint16 channelIndex);
139  void deleteChannel(uint16 channelIndex);
140  int16 getChannelType(uint16 channelIndex);
141  int16 getChannelState(uint16 channelIndex);
142  void setChannelState(uint16 channelIndex, int16 state);
143  uint16 setChannelLocation(uint16 channelIndex, int16 x, int16 y);
144  uint16 setChannelContent(uint16 channelIndex, uint16 index);
145  void setChannelUseMask(uint16 channelIndex);
146  void drawSpriteChannels(const ClipInfo &clipInfo, int16 includeStateMask, int16 excludeStateMask);
147  void updateSprites();
148  void clearChannels();
149 
150  uint16 drawFlex(uint16 flexIndex, int16 x, int16 y, int16 flipX, int16 flipY, int16 mask, const ClipInfo &clipInfo);
151 
152  void drawAnimFrame(uint16 animIndex, int16 x, int16 y, int16 frameNum, int16 flipX, int16 flipY, const ClipInfo &clipInfo);
153 
154  uint16 drawPic(uint16 index, int16 x, int16 y, int16 flipX, int16 flipY);
155  uint16 drawMask(uint16 index, int16 x, int16 y);
156 
157  uint16 drawAnimPic(uint16 animIndex, int16 x, int16 y, int16 frameNum, int16 flipX, int16 flipY);
158 
159  void addSprite(uint16 spriteIndex);
160 
161  uint16 drawSprite(uint16 flexIndex, int16 x, int16 y);
162  uint16 placeSprite(uint16 channelIndex, uint16 flexIndex, int16 x, int16 y);
163 
164  uint16 placeAnim(uint16 channelIndex, uint16 animIndex, int16 x, int16 y, int16 frameNum);
165  int16 setAnimFrame(uint16 channelIndex, int16 frameNum);
166  int16 getAnimFrame(uint16 channelIndex);
167 
168  uint16 placeText(uint16 channelIndex, uint16 textObjectIndex, int16 x, int16 y, uint16 fontNum, int16 textColor, int16 outlineColor);
169 #ifdef USE_TTS
170  void voiceChannelText(const char *text, uint16 channelIndex);
171 #endif
172 
173  void show();
174  void flash(int count);
175 
176  void setFont(int16 fontNum);
177  void printChar(uint c, int16 x, int16 y, byte color);
178  void printText(const char *text);
179  void printTextEx(const char *text, int16 x, int16 y, int16 fontNum, int16 textColor, int16 outlineColor, const ClipInfo &clipInfo);
180  void printObjectText(int16 objectIndex, int16 x, int16 y, int16 fontNum, int16 textColor, int16 outlineColor, const ClipInfo &clipInfo);
181  int16 getTextWidth(int16 fontNum, const char *text);
182 
183  // Interface functions for the screen effects class
184  Graphics::Surface *lockScreen();
185  void unlockScreen();
186  void showWorkScreen();
187  void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
188  void updateScreenAndWait(int delay);
189 
190  int16 addToSpriteList(int16 index, int16 xofs, int16 yofs);
191  SpriteListItem getFromSpriteList(int16 index);
192  void clearSpriteList();
193 
194  void setMouseCursor(const Graphics::Cursor *cursor);
195  void setDefaultMouseCursor();
196 
197 protected:
198  MadeEngine *_vm;
199  ScreenEffects *_fx;
200 
201  bool _screenLock;
202  bool _paletteLock;
203 
204  byte *_palette, *_newPalette;
205  int _paletteColorCount, _oldPaletteColorCount;
206  bool _paletteInitialized, _needPalette;
207  int16 _textColor;
208  int16 _outlineColor;
209  int16 _dropShadowColor;
210 
211  int16 _textX, _textY;
212  Common::Rect _textRect;
213  int16 _currentFontNum;
214  FontResource *_font;
215  ClipInfo _fontDrawCtx;
216 
217  int16 _clip, _exclude, _ground, _mask;
218  int _visualEffectNum;
219 
220  Graphics::Surface *_backgroundScreen, *_workScreen, *_screenMask;
221  ClipInfo _clipArea, _backgroundScreenDrawCtx, _workScreenDrawCtx, _maskDrawCtx;
222 
223  ClipInfo _excludeClipArea[4];
224  bool _excludeClipAreaEnabled[4];
225 
226  uint16 _channelsUsedCount;
227  SpriteChannel _channels[100];
228 
229  bool _queueNextText;
230  bool _voiceTimeText;
231 
232  Common::Array<SpriteListItem> _spriteList;
233 
234 };
235 
236 } // End of namespace Made
237 
238 #endif /* MADE_H */
Definition: screen.h:45
Definition: str.h:59
Definition: surface.h:67
Definition: screen.h:33
T left
Definition: rect.h:170
Definition: array.h:52
Definition: screen.h:76
Definition: made.h:69
Definition: rect.h:524
Definition: cursor.h:42
Definition: screenfx.h:42
Definition: console.h:27
Definition: resource.h:150
Definition: screen.h:50