ScummVM API documentation
graphics.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 /*
23  * This code is based on the original source code of Lord Avalot d'Argent version 1.3.
24  * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
25  */
26 
27 #ifndef AVALANCHE_GRAPHICS_H
28 #define AVALANCHE_GRAPHICS_H
29 
30 #include "avalanche/enums.h"
31 
32 #include "common/file.h"
33 #include "common/rect.h"
34 #include "graphics/surface.h"
35 
36 namespace Avalanche {
37 class AvalancheEngine;
38 class AnimationType;
39 struct SpriteType;
40 struct ChunkBlock;
41 
42 typedef byte FontType[256][16];
43 typedef byte ManiType[2049];
44 typedef byte SilType[51][11]; // 35, 4
45 
47  int16 _horizontal, _vertical;
48 };
49 
51 public:
52  static const MouseHotspotType kMouseHotSpots[9];
53  Color _talkBackgroundColor, _talkFontColor;
54 
56  ~GraphicManager();
57  void init();
58  void loadDigits();
59  void loadMouse(byte which);
60 
61  void drawRectangle(Common::Rect rect, Color color);
62  void drawFilledRectangle(Common::Rect rect, Color color);
63  void blackOutScreen();
64  void drawDot(int x, int y, Color color);
65  void drawLine(int x1, int y1, int x2, int y2, int penX, int penY, Color color);
66  Common::Point drawScreenArc(int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
67  void drawPieSlice(int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
68  void drawTriangle(Common::Point *p, Color color);
69  void drawNormalText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
70  void drawScrollText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
71  void drawDigit(int index, int x, int y);
72  void drawDirection(int index, int x, int y);
73  void drawScrollShadow(int16 x1, int16 y1, int16 x2, int16 y2);
74  void drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Common::String text);
75  void drawScroll(int mx, int lx, int my, int ly);
76  void drawMenuBar(Color color);
77  void drawSpeedBar(int speed);
78  void drawBackgroundSprite(int16 x, int16 y, SpriteType &sprite);
79  void drawMenuBlock(int x1, int y1, int x2, int y2, Color color);
80  void drawMenuItem(int x1, int y1, int x2, int y2);
81  void wipeChar(int x, int y, Color color);
82  void drawChar(byte ander, int x, int y, Color color);
83  void drawDebugLines();
84 
85  // For the mini-game "Nim".
86  void nimLoad();
87  void nimDrawStone(int x, int y);
88  void nimDrawInitials();
89  void nimDrawLogo();
90  void nimFree();
91 
92  // Used in wobble()
93  void shiftScreen();
94 
95  // Used in winning()
96  void drawWinningPic();
97 
98  // Ghostroom's functions:
99  void ghostDrawMonster(byte ***picture, uint16 destX, int16 destY, MonsterType type);
100  Graphics::Surface ghostLoadPicture(Common::File &file, Common::Point &coord);
101  void ghostDrawPicture(const Graphics::Surface &picture, uint16 destX, uint16 destY);
102  void ghostDrawBackgroundItems(Common::File &file);
103 
104  // Help's function:
105  void helpDrawButton(int y, byte which);
106  void helpDrawHighlight(byte which, Color color);
107  void helpDrawBigText(const Common::String text, int16 x, int16 y, Color color);
108 
109  // Shoot em' up's functions:
110  void seuDrawTitle();
111  void seuLoad();
112  void seuFree();
113  void seuDrawPicture(int x, int y, byte which);
114  void seuDrawCameo(int destX, int destY, byte w1, byte w2);
115  uint16 seuGetPicWidth(int which);
116  uint16 seuGetPicHeight(int which);
117 
118  // Main Menu's functions:
119  // The main menu uses a different screen height (350) from the game itself (200 * 2)
120  // so it needs it's own graphic functions on that matter.
121  void menuRefreshScreen();
122  void menuInitialize();
123  void menuFree();
124  void menuRestoreScreen();
125  void menuLoadPictures();
126  void menuDrawBigText(FontType font, uint16 x, uint16 y, Common::String text, Color color);
127  void menuDrawIndicator(int x);
128 
129  void clearAlso();
130  void clearTextBar();
131  void setAlsoLine(int x1, int y1, int x2, int y2, Color color);
132  byte getAlsoColor(int x1, int y1, int x2, int y2);
133  byte getScreenColor(Common::Point pos);
134 
135  // Further information about this: https://moddingwiki.shikadi.net/wiki/Raw_EGA_data
136  Graphics::Surface loadPictureRaw(Common::File &file, uint16 width, uint16 height);
137 
138  void drawSprite(AnimationType *sprite, byte picnum, int16 x, int16 y);
139  void drawThinkPic(const Common::Path &filename, int id);
140  void drawToolbar();
141  void drawCursor(byte pos);
142  void drawReadyLight(Color color);
143  void drawSoundLight(bool state);
144  void drawErrorLight(bool state);
145  void drawSign(Common::String name, int16 xl, int16 yl, int16 y);
146  void drawIcon(int16 x, int16 y, byte which);
147  void drawScreenLine(int16 x, int16 y, int16 x2, int16 y2, Color color);
148  void prepareBubble(int xc, int xw, int my, Common::Point points[3]);
149  void refreshScreen();
150  void loadBackground(Common::File &file);
151  void refreshBackground();
152  void setBackgroundColor(Color newColor);
153  void setDialogColor(Color bg, Color text);
154 
155  void zoomOut(int16 x, int16 y);
156  void showScroll();
157  void getNaturalPicture(SpriteType &sprite);
158 
159  void saveScreen();
160  void restoreScreen();
161  void removeBackup();
162 
163 private:
164  static const int16 kMouseSize = 134;
165  static const uint16 kBackgroundWidth = kScreenWidth;
166  static const byte kEgaPaletteIndex[16];
167  static const byte kBackgroundHeight = 8 * 12080 / kScreenWidth; // With 640 width it's 151.
168  // The 8 = number of bits in a byte, and 12080 comes from Lucerna::load().
169  static const uint16 kMenuScreenHeight = 350;
170 
171  Graphics::Surface _background;
172  Graphics::Surface _backup;
173  Graphics::Surface _digits[10]; // digitsize and rwlitesize are defined in loadDigits() !!!
174  Graphics::Surface _directions[9]; // Maybe it will be needed to move them to the class itself instead.
175  Graphics::Surface _magics; // Lucerna::draw_also_lines() draws the "magical" lines here. Further information: https://github.com/marnanel/avalot/wiki/Also
176  Graphics::Surface _screen; // Only used in refreshScreen() to make it more optimized. (No recreation of it at every call of the function.)
177  Graphics::Surface _scrolls;
178  Graphics::Surface _surface;
179  Graphics::Surface _menu;
180 
181  // For the mini-game "Nim".
182  Graphics::Surface _nimStone;
183  Graphics::Surface _nimInitials[3];
184  Graphics::Surface _nimLogo;
185 
186  // For the mini-game "Shoot em' up".
187  Graphics::Surface _seuPictures[99];
188 
189  byte _egaPalette[64][3];
190 
191  AvalancheEngine *_vm;
192 
193  void skipDifference(int size, const Graphics::Surface &picture, Common::File &file);
194 
195  // Further information about these two: https://moddingwiki.shikadi.net/wiki/Raw_EGA_data
196  Graphics::Surface loadPictureGraphic(Common::File &file); // Reads Graphic-planar EGA data.
197  Graphics::Surface loadPictureSign(Common::File &file, uint16 width, uint16 height); // Reads a tricky type of picture used for the "game over"/"about" scrolls and in the mini-game Nim.
198 
199  void drawText(Graphics::Surface &surface, const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
200  void drawBigText(Graphics::Surface &surface, const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
201  void drawPicture(Graphics::Surface &target, const Graphics::Surface picture, uint16 destX, uint16 destY);
202 
203  // Taken from Free Pascal's Procedure InternalEllipseDefault. Used to replace Pascal's procedure arc.
204  // Returns the end point of the arc. (Needed in Clock.)
205  Common::Point drawArc(Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
206 };
207 
208 } // End of namespace Avalanche
209 
210 #endif // AVALANCHE_GRAPHICS_H
Definition: str.h:59
Definition: surface.h:67
Definition: animation.h:32
Definition: graphics.h:46
Definition: animation.h:42
Definition: rect.h:144
Definition: path.h:52
Definition: avalanche.h:74
Definition: graphics.h:50
Definition: file.h:47
Definition: rect.h:45
Definition: background.h:39