1 /* $Id$ */ |
1 /* $Id$ */ |
2 |
2 |
3 /** @file gfx.h */ |
3 /** @file gfx.h */ |
|
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 |
4 |
34 |
5 #ifndef GFX_H |
35 #ifndef GFX_H |
6 #define GFX_H |
36 #define GFX_H |
7 |
37 |
8 #include "openttd.h" |
38 #include "openttd.h" |
79 |
91 |
80 /* 0-9 are mapped to 48-57 |
92 /* 0-9 are mapped to 48-57 |
81 * A-Z are mapped to 65-90 |
93 * A-Z are mapped to 65-90 |
82 * a-z are mapped to 97-122 */ |
94 * a-z are mapped to 97-122 */ |
83 |
95 |
84 /* Other keys, corresponding to their ascii values */ |
96 /* Numerical keyboard */ |
85 WKC_SLASH = 47, ///< / Forward slash |
97 WKC_NUM_0 = 128, |
86 WKC_SEMICOLON = 59, ///< ; Semicolon |
98 WKC_NUM_1 = 129, |
87 WKC_EQUALS = 61, ///< = Equals |
99 WKC_NUM_2 = 130, |
88 WKC_L_BRACKET = 91, ///< [ Left square bracket |
100 WKC_NUM_3 = 131, |
89 WKC_BACKSLASH = 92, ///< \ Backslash |
101 WKC_NUM_4 = 132, |
90 WKC_R_BRACKET = 93, ///< ] Right square bracket |
102 WKC_NUM_5 = 133, |
91 |
103 WKC_NUM_6 = 134, |
92 /* Other keys of which their ascii value is already taken |
104 WKC_NUM_7 = 135, |
93 * - use unused ascii value not present on keyboard directly */ |
105 WKC_NUM_8 = 136, |
94 WKC_SINGLEQUOTE = 58, ///< ' Single quote |
106 WKC_NUM_9 = 137, |
95 WKC_COMMA = 60, ///< , Comma |
107 WKC_NUM_DIV = 138, |
96 WKC_PERIOD = 62, ///< . Period |
108 WKC_NUM_MUL = 139, |
97 WKC_MINUS = 95, ///< - Minus |
109 WKC_NUM_MINUS = 140, |
|
110 WKC_NUM_PLUS = 141, |
|
111 WKC_NUM_ENTER = 142, |
|
112 WKC_NUM_DECIMAL = 143, |
|
113 |
|
114 /* Other keys */ |
|
115 WKC_SLASH = 144, ///< / Forward slash |
|
116 WKC_SEMICOLON = 145, ///< ; Semicolon |
|
117 WKC_EQUALS = 146, ///< = Equals |
|
118 WKC_L_BRACKET = 147, ///< [ Left square bracket |
|
119 WKC_BACKSLASH = 148, ///< \ Backslash |
|
120 WKC_R_BRACKET = 149, ///< ] Right square bracket |
|
121 WKC_SINGLEQUOTE = 150, ///< ' Single quote |
|
122 WKC_COMMA = 151, ///< , Comma |
|
123 WKC_PERIOD = 152, ///< . Period |
|
124 WKC_MINUS = 153, ///< - Minus |
98 }; |
125 }; |
99 |
126 |
100 enum GameModes { |
127 enum GameModes { |
101 GM_MENU, |
128 GM_MENU, |
102 GM_NORMAL, |
129 GM_NORMAL, |
245 BoundingRect GetStringBoundingBox(const char *str); |
272 BoundingRect GetStringBoundingBox(const char *str); |
246 uint32 FormatStringLinebreaks(char *str, int maxw); |
273 uint32 FormatStringLinebreaks(char *str, int maxw); |
247 void LoadStringWidthTable(); |
274 void LoadStringWidthTable(); |
248 void DrawStringMultiCenter(int x, int y, StringID str, int maxw); |
275 void DrawStringMultiCenter(int x, int y, StringID str, int maxw); |
249 uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1); |
276 uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh = -1); |
|
277 |
|
278 /** |
|
279 * Let the dirty blocks repainting by the video driver. |
|
280 * |
|
281 * @ingroup dirty |
|
282 */ |
250 void DrawDirtyBlocks(); |
283 void DrawDirtyBlocks(); |
|
284 |
|
285 /** |
|
286 * Set a new dirty block. |
|
287 * |
|
288 * @ingroup dirty |
|
289 */ |
251 void SetDirtyBlocks(int left, int top, int right, int bottom); |
290 void SetDirtyBlocks(int left, int top, int right, int bottom); |
|
291 |
|
292 /** |
|
293 * Marks the whole screen as dirty. |
|
294 * |
|
295 * @ingroup dirty |
|
296 */ |
252 void MarkWholeScreenDirty(); |
297 void MarkWholeScreenDirty(); |
253 |
298 |
254 void GfxInitPalettes(); |
299 void GfxInitPalettes(); |
255 |
300 |
256 bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height); |
301 bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height); |