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 "graphics/screen.h"
26 #include "ultima/ultima4/core/config.h"
27 #include "ultima/ultima4/core/types.h"
28 #include "ultima/ultima4/gfx/scale.h"
29 #include "ultima/ultima4/map/direction.h"
30 #include "ultima/ultima4/map/map_tile.h"
31 #include "ultima/shared/core/file.h"
32 
33 namespace Ultima {
34 namespace 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 
61 enum LayoutType {
62  LAYOUT_STANDARD,
63  LAYOUT_GEM,
64  LAYOUT_DUNGEONGEM
65 };
66 
67 enum MouseCursor {
68  MC_DEFAULT,
69  MC_WEST,
70  MC_NORTH,
71  MC_EAST,
72  MC_SOUTH
73 };
74 
75 class Image;
76 class Map;
77 class Tile;
78 class TileView;
79 class Coords;
80 class TileAnimSet;
81 class ImageInfo;
82 
84  Common::Point _hotspot;
85 };
86 
87 struct MouseArea {
88  int _nPoints;
89  struct {
90  int x, y;
91  } _point[3];
92  MouseCursor _cursor;
93  Direction _direction;
94 };
95 
96 struct Layout {
97  Common::String _name;
98  LayoutType _type;
99  Common::Point _tileShape;
100  Common::Rect _viewport;
101 };
102 
103 class Screen : public Graphics::Screen {
104 private:
105  MouseCursorSurface *_mouseCursors[5];
106  int _currentMouseCursor;
107 
108  Std::vector<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 
122 public:
123  Std::vector<Common::String> _gemLayoutNames;
124  Std::vector<Common::String> _filterNames;
125  Std::vector<Common::String> _lineOfSightStyles;
126  int _currentCycle;
127  TileAnimSet *_tileAnims;
128 private:
132  void loadMouseCursors();
133 
137  MouseCursorSurface *loadMouseCursor(Shared::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(Std::vector<MapTile> viewportTiles[VIEWPORT_W][VIEWPORT_H]);
152 
157  void screenFindLineOfSightDOS(Std::vector<MapTile> viewportTiles[VIEWPORT_W][VIEWPORT_H]);
158 
177  void screenFindLineOfSightEnhanced(Std::vector<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);
196 public:
197  Std::vector<Layout *> _layouts;
198  Scaler _filterScaler;
199 
200 public:
201  Screen();
202  ~Screen();
203 
204  void init();
205 
209  void clear();
210 
214  void setMouseCursor(MouseCursor cursor);
215 
219  void screenReInit();
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 
242  void screenScrollMessageArea();
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  Std::vector<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 
296  Image *screenScaleDown(Image *src, int scale);
297 };
298 
299 extern Screen *g_screen;
300 
301 extern const Std::vector<Common::String> &screenGetGemLayoutNames();
302 extern const Std::vector<Common::String> &screenGetFilterNames();
303 extern const Std::vector<Common::String> &screenGetLineOfSightStyles();
304 
305 } // End of namespace Ultima4
306 } // End of namespace Ultima
307 
308 #endif
void clear(uint32 color=0)
Definition: managed_surface.h:51
Definition: str.h:59
Definition: map.h:134
Definition: coords.h:31
Definition: config.h:127
Definition: imagemgr.h:105
Definition: rect.h:144
Definition: tileanim.h:216
Definition: screen.h:50
Definition: detection.h:27
Definition: tileview.h:42
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: screen.h:96
Definition: map_tile.h:34
Definition: rect.h:45
Definition: file.h:34
Definition: screen.h:87
Definition: scalerplugin.h:28
Definition: movie_decoder.h:32
Definition: containers.h:38
Definition: screen.h:103