author | rubidium |
Sat, 21 Jun 2008 13:40:17 +0000 | |
branch | noai |
changeset 11044 | 097ea3e7ec56 |
parent 10455 | 22c441f5adf9 |
child 11126 | 72d4c9314c72 |
permissions | -rw-r--r-- |
9723 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file gfx_func.h Functions related to the gfx engine. */ |
|
4 |
||
5 |
/** |
|
6 |
* @defgroup dirty Dirty |
|
7 |
* |
|
8 |
* Handles the repaint of some part of the screen. |
|
9 |
* |
|
10 |
* Some places in the code are called functions which makes something "dirty". |
|
11 |
* This has nothing to do with making a Tile or Window darker or less visible. |
|
12 |
* This term comes from memory caching and is used to define an object must |
|
13 |
* be repaint. If some data of an object (like a Tile, Window, Vehicle, whatever) |
|
14 |
* are changed which are so extensive the object must be repaint its marked |
|
15 |
* as "dirty". The video driver repaint this object instead of the whole screen |
|
16 |
* (this is btw. also possible if needed). This is used to avoid a |
|
17 |
* flickering of the screen by the video driver constantly repainting it. |
|
18 |
* |
|
19 |
* This whole mechanism is controlled by an rectangle defined in #_invalid_rect. This |
|
20 |
* rectangle defines the area on the screen which must be repaint. If a new object |
|
21 |
* needs to be repainted this rectangle is extended to 'catch' the object on the |
|
22 |
* screen. At some point (which is normaly uninteressted for patch writers) this |
|
23 |
* rectangle is send to the video drivers method |
|
24 |
* VideoDriver::MakeDirty and it is truncated back to an empty rectangle. At some |
|
25 |
* later point (which is uninteressted, too) the video driver |
|
26 |
* repaints all these saved rectangle instead of the whole screen and drop the |
|
27 |
* rectangle informations. Then a new round begins by marking objects "dirty". |
|
28 |
* |
|
29 |
* @see VideoDriver::MakeDirty |
|
30 |
* @see _invalid_rect |
|
31 |
* @see _screen |
|
32 |
*/ |
|
33 |
||
34 |
||
35 |
#ifndef GFX_FUNC_H |
|
36 |
#define GFX_FUNC_H |
|
37 |
||
38 |
#include "gfx_type.h" |
|
39 |
#include "strings_type.h" |
|
40 |
||
41 |
void GameLoop(); |
|
42 |
||
43 |
void CreateConsole(); |
|
44 |
||
45 |
extern byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down |
|
46 |
extern bool _fullscreen; |
|
47 |
extern CursorVars _cursor; |
|
48 |
extern bool _ctrl_pressed; ///< Is Ctrl pressed? |
|
49 |
extern bool _shift_pressed; ///< Is Shift pressed? |
|
50 |
extern byte _fast_forward; |
|
51 |
||
52 |
extern bool _left_button_down; |
|
53 |
extern bool _left_button_clicked; |
|
54 |
extern bool _right_button_down; |
|
55 |
extern bool _right_button_clicked; |
|
56 |
||
57 |
extern DrawPixelInfo _screen; |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
58 |
extern bool _screen_disable_anim; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot) |
9723 | 59 |
|
60 |
extern int _pal_first_dirty; |
|
61 |
extern int _pal_count_dirty; |
|
62 |
extern int _num_resolutions; |
|
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
63 |
extern Dimension _resolutions[32]; |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
64 |
extern Dimension _cur_resolution; |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10455
diff
changeset
|
65 |
extern Colour _cur_palette[256]; ///< Current palette. Entry 0 has to be always fully transparent! |
9723 | 66 |
|
67 |
void HandleKeypress(uint32 key); |
|
9732 | 68 |
void HandleCtrlChanged(); |
9723 | 69 |
void HandleMouseEvents(); |
70 |
void CSleep(int milliseconds); |
|
71 |
void UpdateWindows(); |
|
72 |
||
73 |
void DrawMouseCursor(); |
|
74 |
void ScreenSizeChanged(); |
|
75 |
void GameSizeChanged(); |
|
76 |
void UndrawMouseCursor(); |
|
77 |
||
78 |
void RedrawScreenRect(int left, int top, int right, int bottom); |
|
79 |
void GfxScroll(int left, int top, int width, int height, int xo, int yo); |
|
80 |
||
81 |
void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub = NULL); |
|
82 |
||
83 |
int DrawStringCentered(int x, int y, StringID str, uint16 color); |
|
84 |
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color); |
|
85 |
int DoDrawStringCentered(int x, int y, const char *str, uint16 color); |
|
86 |
||
87 |
int DrawString(int x, int y, StringID str, uint16 color); |
|
88 |
int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw); |
|
89 |
||
90 |
int DoDrawString(const char *string, int x, int y, uint16 color); |
|
91 |
int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw); |
|
92 |
||
93 |
void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color); |
|
94 |
void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, uint16 color); |
|
95 |
||
96 |
int DrawStringRightAligned(int x, int y, StringID str, uint16 color); |
|
97 |
void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw); |
|
98 |
void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color); |
|
99 |
||
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
100 |
void DrawCharCentered(uint32 c, int x, int y, uint16 color); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
101 |
|
9723 | 102 |
void GfxFillRect(int left, int top, int right, int bottom, int color); |
103 |
void GfxDrawLine(int left, int top, int right, int bottom, int color); |
|
104 |
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3); |
|
105 |
||
106 |
Dimension GetStringBoundingBox(const char *str); |
|
107 |
uint32 FormatStringLinebreaks(char *str, int maxw); |
|
108 |
void LoadStringWidthTable(); |
|
109 |
void DrawStringMultiCenter(int x, int y, StringID str, int maxw); |
|
110 |
uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1); |
|
111 |
||
112 |
/** |
|
113 |
* Let the dirty blocks repainting by the video driver. |
|
114 |
* |
|
115 |
* @ingroup dirty |
|
116 |
*/ |
|
117 |
void DrawDirtyBlocks(); |
|
118 |
||
119 |
/** |
|
120 |
* Set a new dirty block. |
|
121 |
* |
|
122 |
* @ingroup dirty |
|
123 |
*/ |
|
124 |
void SetDirtyBlocks(int left, int top, int right, int bottom); |
|
125 |
||
126 |
/** |
|
127 |
* Marks the whole screen as dirty. |
|
128 |
* |
|
129 |
* @ingroup dirty |
|
130 |
*/ |
|
131 |
void MarkWholeScreenDirty(); |
|
132 |
||
133 |
void GfxInitPalettes(); |
|
134 |
||
135 |
bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height); |
|
136 |
||
137 |
/* window.cpp */ |
|
138 |
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom); |
|
139 |
||
140 |
void SetMouseCursor(SpriteID sprite, SpriteID pal); |
|
141 |
void SetAnimatedMouseCursor(const AnimCursor *table); |
|
142 |
void CursorTick(); |
|
143 |
bool ChangeResInGame(int w, int h); |
|
144 |
void SortResolutions(int count); |
|
145 |
bool ToggleFullScreen(bool fs); |
|
146 |
||
147 |
/* gfx.cpp */ |
|
148 |
#define ASCII_LETTERSTART 32 |
|
149 |
extern FontSize _cur_fontsize; |
|
150 |
||
151 |
byte GetCharacterWidth(FontSize size, uint32 key); |
|
152 |
||
153 |
static inline byte GetCharacterHeight(FontSize size) |
|
154 |
{ |
|
155 |
switch (size) { |
|
156 |
default: NOT_REACHED(); |
|
157 |
case FS_NORMAL: return 10; |
|
158 |
case FS_SMALL: return 6; |
|
159 |
case FS_LARGE: return 18; |
|
160 |
} |
|
161 |
} |
|
162 |
||
163 |
extern DrawPixelInfo *_cur_dpi; |
|
164 |
||
165 |
/** |
|
166 |
* All 16 colour gradients |
|
167 |
* 8 colours per gradient from darkest (0) to lightest (7) |
|
168 |
*/ |
|
169 |
extern byte _colour_gradient[16][8]; |
|
170 |
||
171 |
extern bool _use_dos_palette; |
|
172 |
||
173 |
#endif /* GFX_FUNC_H */ |