Mercurial > hg > openttd
annotate src/gfx_func.h @ 18692:90d395fc678d draft
(svn r23540) -Codechange: unify and document vehicle widgets
author | rubidium <rubidium@openttd.org> |
---|---|
date | Fri, 16 Dec 2011 16:58:55 +0000 |
parents | 48c2c81d300e |
children | 51721ad3085a |
rev | line source |
---|---|
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12257
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12257
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12257
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12257
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12257
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12257
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12257
diff
changeset
|
9 |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
10 /** @file gfx_func.h Functions related to the gfx engine. */ |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
11 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
12 /** |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
13 * @defgroup dirty Dirty |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
14 * |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
15 * Handles the repaint of some part of the screen. |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
16 * |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
17 * Some places in the code are called functions which makes something "dirty". |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
18 * This has nothing to do with making a Tile or Window darker or less visible. |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
19 * This term comes from memory caching and is used to define an object must |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
20 * be repaint. If some data of an object (like a Tile, Window, Vehicle, whatever) |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
21 * are changed which are so extensive the object must be repaint its marked |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
22 * as "dirty". The video driver repaint this object instead of the whole screen |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
23 * (this is btw. also possible if needed). This is used to avoid a |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
24 * flickering of the screen by the video driver constantly repainting it. |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
25 * |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
26 * This whole mechanism is controlled by an rectangle defined in #_invalid_rect. This |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
27 * rectangle defines the area on the screen which must be repaint. If a new object |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
28 * needs to be repainted this rectangle is extended to 'catch' the object on the |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
29 * screen. At some point (which is normaly uninteressted for patch writers) this |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
30 * rectangle is send to the video drivers method |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
31 * VideoDriver::MakeDirty and it is truncated back to an empty rectangle. At some |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
32 * later point (which is uninteressted, too) the video driver |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
33 * repaints all these saved rectangle instead of the whole screen and drop the |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
34 * rectangle informations. Then a new round begins by marking objects "dirty". |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
35 * |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
36 * @see VideoDriver::MakeDirty |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
37 * @see _invalid_rect |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
38 * @see _screen |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
39 */ |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
40 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
41 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
42 #ifndef GFX_FUNC_H |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
43 #define GFX_FUNC_H |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
44 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
45 #include "gfx_type.h" |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
46 #include "strings_type.h" |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
47 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
48 void GameLoop(); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
49 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
50 void CreateConsole(); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
51 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
52 extern byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
53 extern bool _fullscreen; |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
54 extern CursorVars _cursor; |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
55 extern bool _ctrl_pressed; ///< Is Ctrl pressed? |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
56 extern bool _shift_pressed; ///< Is Shift pressed? |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
57 extern byte _fast_forward; |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
58 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
59 extern bool _left_button_down; |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
60 extern bool _left_button_clicked; |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
61 extern bool _right_button_down; |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
62 extern bool _right_button_clicked; |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
63 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
64 extern DrawPixelInfo _screen; |
8249
f495acdca6b5
(svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch <frosch@openttd.org>
parents:
8171
diff
changeset
|
65 extern bool _screen_disable_anim; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot) |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
66 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
67 extern int _num_resolutions; |
9533
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9117
diff
changeset
|
68 extern Dimension _resolutions[32]; |
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9117
diff
changeset
|
69 extern Dimension _cur_resolution; |
18599
8ac2645a140c
(svn r23446) -Codechange: move _cur_palette and it's related first/count dirty variables into a single structure
rubidium <rubidium@openttd.org>
parents:
18472
diff
changeset
|
70 extern Palette _cur_palette; ///< Current palette |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
71 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
72 void HandleKeypress(uint32 key); |
8586
5f272b02ff37
(svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz <smatz@openttd.org>
parents:
8433
diff
changeset
|
73 void HandleCtrlChanged(); |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
74 void HandleMouseEvents(); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
75 void CSleep(int milliseconds); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
76 void UpdateWindows(); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
77 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
78 void DrawMouseCursor(); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
79 void ScreenSizeChanged(); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
80 void GameSizeChanged(); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
81 void UndrawMouseCursor(); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
82 |
15183
43a5d37b45c4
(svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents:
14910
diff
changeset
|
83 /** Size of the buffer used for drawing strings. */ |
43a5d37b45c4
(svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
rubidium <rubidium@openttd.org>
parents:
14910
diff
changeset
|
84 static const int DRAW_STRING_BUFFER = 2048; |
9901
8f22efcc1dcc
(svn r14051) -Codechange: enumify the DrawString buffer length.
rubidium <rubidium@openttd.org>
parents:
9882
diff
changeset
|
85 |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
86 void RedrawScreenRect(int left, int top, int right, int bottom); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
87 void GfxScroll(int left, int top, int width, int height, int xo, int yo); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
88 |
18472
11637619aa76
(svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
peter1138 <peter1138@openttd.org>
parents:
18432
diff
changeset
|
89 Dimension GetSpriteSize(SpriteID sprid, Point *offset = NULL, ZoomLevel zoom = ZOOM_LVL_GUI); |
11637619aa76
(svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
peter1138 <peter1138@openttd.org>
parents:
18432
diff
changeset
|
90 void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = NULL); |
11637619aa76
(svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
peter1138 <peter1138@openttd.org>
parents:
18432
diff
changeset
|
91 void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = NULL, ZoomLevel zoom = ZOOM_LVL_GUI); |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
92 |
11421
d869783cce0d
(svn r15779) -Codechange: unify (most) of the text drawing "API".
rubidium <rubidium@openttd.org>
parents:
11082
diff
changeset
|
93 /** How to align the to-be drawn text. */ |
11426
38844e2f76fd
(svn r15784) -Fix (r15779): TextAlignment and TA_* already exist on windows
glx <glx@openttd.org>
parents:
11424
diff
changeset
|
94 enum StringAlignment { |
15400
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
95 SA_LEFT = 0 << 0, ///< Left align the text. |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
96 SA_HOR_CENTER = 1 << 0, ///< Horizontally center the text. |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
97 SA_RIGHT = 2 << 0, ///< Right align the text (must be a single bit). |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
98 SA_HOR_MASK = 3 << 0, ///< Mask for horizontal alignment. |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
99 |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
100 SA_TOP = 0 << 2, ///< Top align the text. |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
101 SA_VERT_CENTER = 1 << 2, ///< Vertically center the text. |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
102 SA_BOTTOM = 2 << 2, ///< Bottom align the text. |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
103 SA_VERT_MASK = 3 << 2, ///< Mask for vertical alignment. |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
104 |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
105 SA_CENTER = SA_HOR_CENTER | SA_VERT_CENTER, ///< Center both horizontally and vertically. |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
106 |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
107 SA_FORCE = 1 << 4, ///< Force the alignment, i.e. don't swap for RTL languages. |
821c26b30fd9
(svn r20043) -Codechange: Introduce vertical alignment for DrawStringMultiLine().
alberth <alberth@openttd.org>
parents:
15276
diff
changeset
|
108 SA_STRIP = 1 << 5, ///< Strip the SETX/SETXY commands from the string |
11421
d869783cce0d
(svn r15779) -Codechange: unify (most) of the text drawing "API".
rubidium <rubidium@openttd.org>
parents:
11082
diff
changeset
|
109 }; |
14910
bd99e52e5aa2
(svn r19507) -Codechange: remove semicolon after DECLARE_POSTFIX_INCREMENT and DECLARE_ENUM_AS_BIT_SET
smatz <smatz@openttd.org>
parents:
14319
diff
changeset
|
110 DECLARE_ENUM_AS_BIT_SET(StringAlignment) |
11421
d869783cce0d
(svn r15779) -Codechange: unify (most) of the text drawing "API".
rubidium <rubidium@openttd.org>
parents:
11082
diff
changeset
|
111 |
18430
c537badd5588
(svn r23272) -Codechange: pass the initial font size to DrawString and friends
rubidium <rubidium@openttd.org>
parents:
17828
diff
changeset
|
112 int DrawString(int left, int right, int top, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL); |
c537badd5588
(svn r23272) -Codechange: pass the initial font size to DrawString and friends
rubidium <rubidium@openttd.org>
parents:
17828
diff
changeset
|
113 int DrawString(int left, int right, int top, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL); |
c537badd5588
(svn r23272) -Codechange: pass the initial font size to DrawString and friends
rubidium <rubidium@openttd.org>
parents:
17828
diff
changeset
|
114 int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL); |
c537badd5588
(svn r23272) -Codechange: pass the initial font size to DrawString and friends
rubidium <rubidium@openttd.org>
parents:
17828
diff
changeset
|
115 int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL); |
11421
d869783cce0d
(svn r15779) -Codechange: unify (most) of the text drawing "API".
rubidium <rubidium@openttd.org>
parents:
11082
diff
changeset
|
116 |
11082
9ec1f7eac0a0
(svn r15425) -Codechange: some color->colour changes and type safety.
rubidium <rubidium@openttd.org>
parents:
10793
diff
changeset
|
117 void DrawCharCentered(uint32 c, int x, int y, TextColour colour); |
8737
b62e473a9029
(svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium <rubidium@openttd.org>
parents:
8586
diff
changeset
|
118 |
11082
9ec1f7eac0a0
(svn r15425) -Codechange: some color->colour changes and type safety.
rubidium <rubidium@openttd.org>
parents:
10793
diff
changeset
|
119 void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE); |
17527
3850026e0159
(svn r22291) -Add: a linewidth argument to GfxDrawLine() and Blitter::DrawLine().
frosch <frosch@openttd.org>
parents:
17108
diff
changeset
|
120 void GfxDrawLine(int left, int top, int right, int bottom, int colour, int width = 1); |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
121 void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
122 |
15276
04ac3a270667
(svn r19911) -Codechange: Simplify text drawing by eliminating global variables and side effects. This also fixes the 'colour' parameter of DrawStringMultiLine().
frosch <frosch@openttd.org>
parents:
15183
diff
changeset
|
123 Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize = FS_NORMAL); |
12257
01788afd7180
(svn r16672) -Codechange: Add functions to compute size of strings and sprites.
alberth <alberth@openttd.org>
parents:
12193
diff
changeset
|
124 Dimension GetStringBoundingBox(StringID strid); |
15276
04ac3a270667
(svn r19911) -Codechange: Simplify text drawing by eliminating global variables and side effects. This also fixes the 'colour' parameter of DrawStringMultiLine().
frosch <frosch@openttd.org>
parents:
15183
diff
changeset
|
125 uint32 FormatStringLinebreaks(char *str, const char *last, int maxw, FontSize start_fontsize = FS_NORMAL); |
9682
ed50c006a790
(svn r13787) -Codechange: resize the red error message box if needed
smatz <smatz@openttd.org>
parents:
9607
diff
changeset
|
126 int GetStringHeight(StringID str, int maxw); |
12899
85086de37f39
(svn r17391) -Codechange: Add string box calculation routine for multi-line strings.
alberth <alberth@openttd.org>
parents:
12778
diff
changeset
|
127 Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion); |
18625
48c2c81d300e
(svn r23472) -Fix [FS#4877]: the monospace font broke the bootstrap GUI's ability to find a font
rubidium <rubidium@openttd.org>
parents:
18599
diff
changeset
|
128 void LoadStringWidthTable(bool monospace = false); |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
129 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
130 void DrawDirtyBlocks(); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
131 void SetDirtyBlocks(int left, int top, int right, int bottom); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
132 void MarkWholeScreenDirty(); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
133 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
134 void GfxInitPalettes(); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
135 |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10062
diff
changeset
|
136 bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height); |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
137 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
138 /* window.cpp */ |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
139 void DrawOverlappedWindowForAll(int left, int top, int right, int bottom); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
140 |
14319
72cb3c72d619
(svn r18872) -Codechange: introduce PaletteID and use it
rubidium <rubidium@openttd.org>
parents:
14032
diff
changeset
|
141 void SetMouseCursor(CursorID cursor, PaletteID pal); |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
142 void SetAnimatedMouseCursor(const AnimCursor *table); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
143 void CursorTick(); |
15717
9801d1b69c4e
(svn r20384) -Fix: Update cursor dimensions when reloading grfs resp. changing base graphics, so the cursor does not glitch if it becomes bigger.
frosch <frosch@openttd.org>
parents:
15596
diff
changeset
|
144 void UpdateCursorSize(); |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
145 bool ChangeResInGame(int w, int h); |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
146 void SortResolutions(int count); |
8171
df1e18335376
(svn r11734) -Change: Allow ToggleFullScreen to return the result of the operation' attempt. Previously, only visual clues were available.
belugas <belugas@openttd.org>
parents:
8123
diff
changeset
|
147 bool ToggleFullScreen(bool fs); |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
148 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
149 /* gfx.cpp */ |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
150 byte GetCharacterWidth(FontSize size, uint32 key); |
14032
0a874c3b0514
(svn r18575) -Fix [FS#3393]: unit numbers weren't always fully shown in the depot
rubidium <rubidium@openttd.org>
parents:
13619
diff
changeset
|
151 byte GetDigitWidth(FontSize size = FS_NORMAL); |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
152 |
9773
fcce76c3bb3d
(svn r13910) -Document: string drawing related functions and types (Alberth)
rubidium <rubidium@openttd.org>
parents:
9682
diff
changeset
|
153 /** |
fcce76c3bb3d
(svn r13910) -Document: string drawing related functions and types (Alberth)
rubidium <rubidium@openttd.org>
parents:
9682
diff
changeset
|
154 * Get height of a character for a given font size. |
fcce76c3bb3d
(svn r13910) -Document: string drawing related functions and types (Alberth)
rubidium <rubidium@openttd.org>
parents:
9682
diff
changeset
|
155 * @param size Font size to get height of |
fcce76c3bb3d
(svn r13910) -Document: string drawing related functions and types (Alberth)
rubidium <rubidium@openttd.org>
parents:
9682
diff
changeset
|
156 * @return Height of characters in the given font (pixels) |
fcce76c3bb3d
(svn r13910) -Document: string drawing related functions and types (Alberth)
rubidium <rubidium@openttd.org>
parents:
9682
diff
changeset
|
157 */ |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
158 static inline byte GetCharacterHeight(FontSize size) |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
159 { |
11488
0395660bac3b
(svn r15849) -Codechange: provide easy access to the real height of the used fonts
rubidium <rubidium@openttd.org>
parents:
11483
diff
changeset
|
160 assert(size < FS_END); |
0395660bac3b
(svn r15849) -Codechange: provide easy access to the real height of the used fonts
rubidium <rubidium@openttd.org>
parents:
11483
diff
changeset
|
161 extern int _font_height[FS_END]; |
0395660bac3b
(svn r15849) -Codechange: provide easy access to the real height of the used fonts
rubidium <rubidium@openttd.org>
parents:
11483
diff
changeset
|
162 return _font_height[size]; |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
163 } |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
164 |
12193
649406fd0b87
(svn r16606) -Doc: Added/fixed doxygen comments.
alberth <alberth@openttd.org>
parents:
12192
diff
changeset
|
165 /** Height of characters in the small (#FS_SMALL) font. */ |
11488
0395660bac3b
(svn r15849) -Codechange: provide easy access to the real height of the used fonts
rubidium <rubidium@openttd.org>
parents:
11483
diff
changeset
|
166 #define FONT_HEIGHT_SMALL (GetCharacterHeight(FS_SMALL)) |
12193
649406fd0b87
(svn r16606) -Doc: Added/fixed doxygen comments.
alberth <alberth@openttd.org>
parents:
12192
diff
changeset
|
167 |
649406fd0b87
(svn r16606) -Doc: Added/fixed doxygen comments.
alberth <alberth@openttd.org>
parents:
12192
diff
changeset
|
168 /** Height of characters in the normal (#FS_NORMAL) font. */ |
11488
0395660bac3b
(svn r15849) -Codechange: provide easy access to the real height of the used fonts
rubidium <rubidium@openttd.org>
parents:
11483
diff
changeset
|
169 #define FONT_HEIGHT_NORMAL (GetCharacterHeight(FS_NORMAL)) |
12193
649406fd0b87
(svn r16606) -Doc: Added/fixed doxygen comments.
alberth <alberth@openttd.org>
parents:
12192
diff
changeset
|
170 |
649406fd0b87
(svn r16606) -Doc: Added/fixed doxygen comments.
alberth <alberth@openttd.org>
parents:
12192
diff
changeset
|
171 /** Height of characters in the large (#FS_LARGE) font. */ |
11488
0395660bac3b
(svn r15849) -Codechange: provide easy access to the real height of the used fonts
rubidium <rubidium@openttd.org>
parents:
11483
diff
changeset
|
172 #define FONT_HEIGHT_LARGE (GetCharacterHeight(FS_LARGE)) |
0395660bac3b
(svn r15849) -Codechange: provide easy access to the real height of the used fonts
rubidium <rubidium@openttd.org>
parents:
11483
diff
changeset
|
173 |
18432
91f57bc199b4
(svn r23274) -Add: internal support for a monospaced sprite font
rubidium <rubidium@openttd.org>
parents:
18430
diff
changeset
|
174 /** Height of characters in the large (#FS_MONO) font. */ |
91f57bc199b4
(svn r23274) -Add: internal support for a monospaced sprite font
rubidium <rubidium@openttd.org>
parents:
18430
diff
changeset
|
175 #define FONT_HEIGHT_MONO (GetCharacterHeight(FS_MONO)) |
91f57bc199b4
(svn r23274) -Add: internal support for a monospaced sprite font
rubidium <rubidium@openttd.org>
parents:
18430
diff
changeset
|
176 |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
177 extern DrawPixelInfo *_cur_dpi; |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
178 |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
179 /** |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
180 * All 16 colour gradients |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
181 * 8 colours per gradient from darkest (0) to lightest (7) |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
182 */ |
9850
00c8758ef6b8
(svn r13994) -Codechange: replace a few rogue magic numbers with Colours enum values
belugas <belugas@openttd.org>
parents:
9773
diff
changeset
|
183 extern byte _colour_gradient[COLOUR_END][8]; |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
184 |
10062
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
185 extern bool _palette_remap_grf[]; |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
186 |
17649
2b51d78fc404
(svn r22421) -Fix: Replace various references to Windows palette greyscale indices with the DOS palette indices.
frosch <frosch@openttd.org>
parents:
17647
diff
changeset
|
187 /** |
2b51d78fc404
(svn r22421) -Fix: Replace various references to Windows palette greyscale indices with the DOS palette indices.
frosch <frosch@openttd.org>
parents:
17647
diff
changeset
|
188 * Return the colour for a particular greyscale level. |
2b51d78fc404
(svn r22421) -Fix: Replace various references to Windows palette greyscale indices with the DOS palette indices.
frosch <frosch@openttd.org>
parents:
17647
diff
changeset
|
189 * @param level Intensity, 0 = black, 15 = white |
2b51d78fc404
(svn r22421) -Fix: Replace various references to Windows palette greyscale indices with the DOS palette indices.
frosch <frosch@openttd.org>
parents:
17647
diff
changeset
|
190 * @return colour |
2b51d78fc404
(svn r22421) -Fix: Replace various references to Windows palette greyscale indices with the DOS palette indices.
frosch <frosch@openttd.org>
parents:
17647
diff
changeset
|
191 */ |
2b51d78fc404
(svn r22421) -Fix: Replace various references to Windows palette greyscale indices with the DOS palette indices.
frosch <frosch@openttd.org>
parents:
17647
diff
changeset
|
192 #define GREY_SCALE(level) (level) |
2b51d78fc404
(svn r22421) -Fix: Replace various references to Windows palette greyscale indices with the DOS palette indices.
frosch <frosch@openttd.org>
parents:
17647
diff
changeset
|
193 |
17657
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
194 static const uint8 PC_BLACK = GREY_SCALE(1); ///< Black palette colour. |
17661
66a93b6078c3
(svn r22433) -Add/Fix: Add constants for the palette colours used in the smallmap and fix some windows palette indices.
frosch <frosch@openttd.org>
parents:
17657
diff
changeset
|
195 static const uint8 PC_DARK_GREY = GREY_SCALE(6); ///< Dark grey palette colour. |
17657
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
196 static const uint8 PC_GREY = GREY_SCALE(10); ///< Grey palette colour. |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
197 static const uint8 PC_WHITE = GREY_SCALE(15); ///< White palette colour. |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
198 |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
199 static const uint8 PC_VERY_DARK_RED = 0xB2; ///< Almost-black red palette colour. |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
200 static const uint8 PC_DARK_RED = 0xB4; ///< Dark red palette colour. |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
201 static const uint8 PC_RED = 0xB8; ///< Red palette colour. |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
202 |
17661
66a93b6078c3
(svn r22433) -Add/Fix: Add constants for the palette colours used in the smallmap and fix some windows palette indices.
frosch <frosch@openttd.org>
parents:
17657
diff
changeset
|
203 static const uint8 PC_VERY_DARK_BROWN = 0x56; ///< Almost-black brown palette colour. |
66a93b6078c3
(svn r22433) -Add/Fix: Add constants for the palette colours used in the smallmap and fix some windows palette indices.
frosch <frosch@openttd.org>
parents:
17657
diff
changeset
|
204 |
66a93b6078c3
(svn r22433) -Add/Fix: Add constants for the palette colours used in the smallmap and fix some windows palette indices.
frosch <frosch@openttd.org>
parents:
17657
diff
changeset
|
205 static const uint8 PC_ORANGE = 0xC2; ///< Orange palette colour. |
66a93b6078c3
(svn r22433) -Add/Fix: Add constants for the palette colours used in the smallmap and fix some windows palette indices.
frosch <frosch@openttd.org>
parents:
17657
diff
changeset
|
206 |
17657
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
207 static const uint8 PC_YELLOW = 0xBF; ///< Yellow palette colour. |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
208 static const uint8 PC_LIGHT_YELLOW = 0x44; ///< Light yellow palette colour. |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
209 static const uint8 PC_VERY_LIGHT_YELLOW = 0x45; ///< Almost-white yellow palette colour. |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
210 |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
211 static const uint8 PC_GREEN = 0xD0; ///< Green palette colour. |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
212 |
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
213 static const uint8 PC_DARK_BLUE = 0x9D; ///< Dark blue palette colour. |
17661
66a93b6078c3
(svn r22433) -Add/Fix: Add constants for the palette colours used in the smallmap and fix some windows palette indices.
frosch <frosch@openttd.org>
parents:
17657
diff
changeset
|
214 static const uint8 PC_LIGHT_BLUE = 0x98; ///< Light blue palette colour. |
17657
c2a2cda37d1b
(svn r22429) -Add: some constants for specific palette colours used in the GUI.
frosch <frosch@openttd.org>
parents:
17649
diff
changeset
|
215 |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
216 #endif /* GFX_FUNC_H */ |