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 SUPERNOVA_SCREEN_H
23 #define SUPERNOVA_SCREEN_H
24 
25 #include "common/array.h"
26 #include "common/rect.h"
27 #include "common/scummsys.h"
28 
29 #include "supernova/imageid.h"
30 #include "supernova/msn_def.h"
31 #include "supernova/resman.h"
32 
33 namespace Supernova {
34 
35 class SupernovaEngine;
36 class GameManager;
37 class ResourceManager;
38 class GuiElement;
39 class Room;
40 class MSNImage;
41 class Screen;
42 
43 const int kScreenWidth = 320;
44 const int kScreenHeight = 200;
45 const int kFontWidth = 5;
46 const int kFontWidth2 = 4;
47 const int kFontHeight = 8;
48 
49 enum Color {
50  kColorBlack = 0,
51  kColorWhite25 = 1,
52  kColorWhite35 = 2,
53  kColorWhite44 = 3,
54  kColorWhite99 = 4,
55  kColorDarkGreen = 5,
56  kColorGreen = 6,
57  kColorDarkRed = 7,
58  kColorRed = 8,
59  kColorDarkBlue = 9,
60  kColorBlue = 10,
61  kColorWhite63 = 11,
62  kColorLightBlue = 12,
63  kColorLightGreen = 13,
64  kColorLightYellow = 14,
65  kColorLightRed = 15,
66  kColorPurple = 16,
67  kColorCursorTransparent = kColorWhite25
68 };
69 
70 class ScreenBuffer {
71  friend class ScreenBufferStack;
72 
73 public:
74  ScreenBuffer();
75 
76 private:
77  byte *_pixels;
78  int _x;
79  int _y;
80  int _width;
81  int _height;
82 };
83 
85 public:
87 
88  void push(int x, int y, int width, int height);
89  void restore();
90 
91 private:
92  ScreenBuffer _buffer[8];
93  ScreenBuffer *_last;
94 };
95 
96 class Marquee {
97 public:
98  enum MarqueeId {
99  kMarqueeIntro,
100  kMarqueeOutro
101  };
102 
103  Marquee(Screen *screen, MarqueeId id, const char *text);
104  ~Marquee();
105 
106  bool renderCharacter();
107  void reset();
108 
109 private:
110  void clearText();
111 
112  Screen *_screen;
113  const char *const _textBegin;
114  const char *_text;
115  bool _loop;
116  int _delay;
117  int _color;
118  byte *_oldColor;
119  int _x;
120  int _y;
121  int _textWidth;
122 };
123 
124 class Screen {
125  friend class Marquee;
126 
127 public:
128  struct ImageInfo {
129  int filenumber;
130  int section;
131  };
132 
133 public:
134  static void initPalette();
135  static int textWidth(const uint16 key);
136  static int textWidth(const char *text);
137  static int textWidth(const Common::String &text);
138 
139 public:
140  Screen(SupernovaEngine *vm, ResourceManager *resMan);
141 
142  int getScreenWidth() const;
143  int getScreenHeight() const;
144  int getViewportBrightness() const;
145  void setViewportBrightness(int brightness);
146  int getGuiBrightness() const;
147  void setGuiBrightness(int brightness);
148  MSNImage *getCurrentImage();
149  const ImageInfo *getImageInfo(ImageId id) const;
150  bool isMessageShown() const;
151  void paletteFadeIn(int maxViewportBrightness);
152  void paletteFadeOut(int minBrightness);
153  void paletteBrightness();
154  void renderImage(ImageId id, bool removeImage = false);
155  void renderImage(int section);
156  bool setCurrentImage(int filenumber);
157  void saveScreen(int x, int y, int width, int height);
158  void saveScreen(const GuiElement &guiElement);
159  void restoreScreen();
160  void renderRoom(Room &room);
161  void renderMessage(const char *text, MessagePosition position = kMessageNormal, int positionX = -1, int positionY = -1);
162  void renderMessage(const Common::String &text, MessagePosition position = kMessageNormal);
163  void renderMessage(int stringId, MessagePosition position = kMessageNormal,
164  Common::String var1 = "", Common::String var2 = "");
165  void removeMessage();
166  void renderText(const uint16 character);
167  void renderText(const char *text);
168  void renderText(const Common::String &text);
169  void renderText(int stringId);
170  void renderText(const uint16 character, int x, int y, byte color);
171  void renderText(const char *text, int x, int y, byte color);
172  void renderText(const Common::String &text, int x, int y, byte color);
173  void renderText(int stringId, int x, int y, byte color);
174  void renderText(const GuiElement &guiElement);
175  void renderBox(int x, int y, int width, int height, byte color);
176  void renderBox(const GuiElement &guiElement);
177  void setColor63(byte value);
178  Common::Point getTextCursorPos();
179  void setTextCursorPos(int x, int y);
180  byte getTextCursorColor();
181  void setTextCursorColor(byte color);
182  void update();
183  void changeCursor(ResourceManager::CursorId);
184 
185 private:
186  void renderImageSection(const MSNImage *image, int section, bool invert);
187 
188 private:
189  SupernovaEngine *_vm;
190  ResourceManager *_resMan;
191  MSNImage *_currentImage;
192  ScreenBufferStack _screenBuffer;
193  int _screenWidth;
194  int _screenHeight;
195  int _textCursorX;
196  int _textCursorY;
197  int _textColor;
198  byte _viewportBrightness;
199  byte _guiBrightness;
200  bool _messageShown;
201 };
202 
203 }
204 
205 #endif
Definition: supernova.h:61
Definition: str.h:59
Definition: screen.h:128
Definition: console.h:27
Definition: resman.h:41
Definition: room.h:39
Definition: game-manager.h:63
Definition: screen.h:84
Definition: atari-screen.h:60
Definition: rect.h:45
Definition: screen.h:70
Definition: screen.h:124
Definition: graphics.h:40
Definition: screen.h:96