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