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 ULTIMA4_GFX_SCREEN_H
23#define ULTIMA4_GFX_SCREEN_H
24
25#include "common/file.h"
26#include "graphics/screen.h"
27#include "ultima/ultima4/core/config.h"
28#include "ultima/ultima4/core/types.h"
29#include "ultima/ultima4/gfx/scale.h"
30#include "ultima/ultima4/map/direction.h"
31#include "ultima/ultima4/map/map_tile.h"
32
33namespace Ultima {
34namespace Ultima4 {
35
36#define SCR_CYCLE_PER_SECOND 4
37#define SCR_CYCLE_MAX 16
38#define SCREEN_FRAME_TIME 50
39#define SCREEN_WIDTH 320
40#define SCREEN_HEIGHT 200
41
42/*
43 * bitmasks for LOS shadows
44 */
45#define ____H 0x01 // obscured along the horizontal face
46#define ___C_ 0x02 // obscured at the center
47#define __V__ 0x04 // obscured along the vertical face
48#define _N___ 0x80 // start of new raster
49
50#define ___CH 0x03
51#define __VCH 0x07
52#define __VC_ 0x06
53
54#define _N__H 0x81
55#define _N_CH 0x83
56#define _NVCH 0x87
57#define _NVC_ 0x86
58#define _NV__ 0x84
59
60
61enum LayoutType {
62 LAYOUT_STANDARD,
63 LAYOUT_GEM,
64 LAYOUT_DUNGEONGEM
65};
66
67enum MouseCursor {
68 MC_DEFAULT,
69 MC_WEST,
70 MC_NORTH,
71 MC_EAST,
72 MC_SOUTH
73};
74
75class Image;
76class Map;
77class Tile;
78class TileView;
79class Coords;
80class TileAnimSet;
81class ImageInfo;
82
84 Common::Point _hotspot;
85};
86
87struct MouseArea {
88 int _nPoints;
89 struct {
90 int x, y;
91 } _point[3];
92 MouseCursor _cursor;
93 Direction _direction;
94};
95
96struct Layout {
97 Common::String _name;
98 LayoutType _type;
99 Common::Point _tileShape;
100 Common::Rect _viewport;
101};
102
103class Screen : public Graphics::Screen {
104private:
105 MouseCursorSurface *_mouseCursors[5];
106 int _currentMouseCursor;
107
108 Common::Array<TileAnimSet *> _tileAnimSets;
109 Layout *_gemLayout;
110 Common::HashMap<Common::String, int> _dungeonTileChars;
111 ImageInfo *_charSetInfo;
112 ImageInfo *_gemTilesInfo;
113
114 int _needPrompt;
115 Common::Point _cursorPos;
116 int _cursorStatus;
117 int _cursorEnabled;
118 int _los[VIEWPORT_W][VIEWPORT_H];
119 //bool _continueScreenRefresh;
120 uint32 _priorFrameTime;
121
122public:
123 Common::Array<Common::String> _gemLayoutNames;
125 Common::Array<Common::String> _lineOfSightStyles;
126 int _currentCycle;
127 TileAnimSet *_tileAnims;
128private:
132 void loadMouseCursors();
133
137 MouseCursorSurface *loadMouseCursor(Common::File &src);
138
139 void screenLoadGraphicsFromConf();
140 Layout *screenLoadLayoutFromConf(const ConfigElement &conf);
141
145 void screenShowGemTile(Layout *layout, Map *map, MapTile &t, bool focus, int x, int y);
146
151 void screenFindLineOfSight(Common::Array<MapTile> viewportTiles[VIEWPORT_W][VIEWPORT_H]);
152
157 void screenFindLineOfSightDOS(Common::Array<MapTile> viewportTiles[VIEWPORT_W][VIEWPORT_H]);
158
177 void screenFindLineOfSightEnhanced(Common::Array<MapTile> viewportTiles[VIEWPORT_W][VIEWPORT_H]);
178
185 void screenGetLineTerms(int x1, int y1, int x2, int y2, double *a, double *b);
186
192 int screenPointsOnSameSideOfLine(int x1, int y1, int x2, int y2, double a, double b);
193
194 int screenPointInTriangle(int x, int y, int tx1, int ty1, int tx2, int ty2, int tx3, int ty3);
195 Layout *screenGetGemLayout(const Map *map);
196public:
198 Scaler _filterScaler;
199
200public:
201 Screen();
202 ~Screen();
203
204 void init();
205
209 void clear();
210
214 void setMouseCursor(MouseCursor cursor);
215
220 void screenWait(int numberOfAnimationFrames);
221
225 void screenDrawImage(const Common::String &name, int x = 0, int y = 0);
226 void screenDrawImageInMapArea(const Common::String &bkgd);
227
228 void screenFrame();
229 void screenCycle();
230 void screenEraseMapArea();
231 void screenEraseTextArea(int x, int y, int width, int height);
232 void screenGemUpdate();
233
234 void screenMessage(const char *fmt, ...);
235 void screenPrompt();
236 void screenRedrawMapArea();
237 void screenRedrawTextArea(int x, int y, int width, int height);
238
243
247 void screenShake(int iterations);
248
252 void screenShowChar(int chr, int x, int y);
253 void screenTextAt(int x, int y, const char *fmt, ...);
254
258 void screenTextColor(int color);
259 bool screenTileUpdate(TileView *view, const Coords &coords, bool redraw = true); //Returns true if the screen was affected
260
266 void screenUpdate(TileView *view, bool showmap, bool blackout);
267 void screenUpdateCursor();
268 void screenUpdateMoons();
269 void screenUpdateWind();
270 Common::Array<MapTile> screenViewportTile(uint width, uint height, int x, int y, bool &focus);
271
272 void screenShowCursor();
273 void screenHideCursor();
274 void screenEnableCursor();
275 void screenDisableCursor();
276 void screenSetCursorPos(int x, int y);
277
281 int screenPointInMouseArea(int x, int y, const MouseArea *area);
282
290 Image *screenScale(Image *src, int scale, int n, int filter);
291
297};
298
299extern Screen *g_screen;
300
301extern const Common::Array<Common::String> &screenGetGemLayoutNames();
302extern const Common::Array<Common::String> &screenGetFilterNames();
303extern const Common::Array<Common::String> &screenGetLineOfSightStyles();
304
305} // End of namespace Ultima4
306} // End of namespace Ultima
307
308#endif
Definition: array.h:52
Definition: file.h:47
Definition: str.h:59
Definition: managed_surface.h:51
ManagedSurface * scale(int16 newWidth, int16 newHeight, bool filtering=false, byte flip=0) const
Definition: screen.h:47
Definition: scalerplugin.h:28
Definition: config.h:126
Definition: coords.h:31
Definition: image.h:65
Definition: imagemgr.h:106
Definition: map.h:134
Definition: map_tile.h:34
Definition: screen.h:103
void screenUpdate(TileView *view, bool showmap, bool blackout)
void screenShowChar(int chr, int x, int y)
void setMouseCursor(MouseCursor cursor)
void screenDrawImage(const Common::String &name, int x=0, int y=0)
int screenPointInMouseArea(int x, int y, const MouseArea *area)
Image * screenScale(Image *src, int scale, int n, int filter)
void screenShake(int iterations)
void screenTextColor(int color)
Image * screenScaleDown(Image *src, int scale)
Definition: tileanim.h:216
Definition: tileview.h:42
Definition: rect.h:144
Definition: rect.h:536
Definition: screen.h:96
Definition: screen.h:87