author | celestar |
Sun, 11 Mar 2007 09:28:58 +0000 | |
branch | custombridgeheads |
changeset 5651 | 335d9bd345b0 |
parent 5650 | aefc131bf5ce |
child 5887 | 063ca43b682c |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#ifndef GFX_H |
4 |
#define GFX_H |
|
5 |
||
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5643
diff
changeset
|
6 |
#include "helpers.hpp" |
0 | 7 |
|
3798
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
8 |
typedef enum FontSizes { |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
9 |
FS_NORMAL, |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
10 |
FS_SMALL, |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
11 |
FS_LARGE, |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
12 |
FS_END, |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
13 |
} FontSize; |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
14 |
|
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5643
diff
changeset
|
15 |
DECLARE_POSTFIX_INCREMENT(FontSize); |
3798
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
16 |
|
0 | 17 |
void RedrawScreenRect(int left, int top, int right, int bottom); |
18 |
void GfxScroll(int left, int top, int width, int height, int xo, int yo); |
|
2097
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
19 |
|
2406
be5cfb8cd20d
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2187
diff
changeset
|
20 |
|
be5cfb8cd20d
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2187
diff
changeset
|
21 |
// XXX doesn't really belong here, but the only |
be5cfb8cd20d
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2187
diff
changeset
|
22 |
// consumers always use it in conjunction with DoDrawString() |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4954
diff
changeset
|
23 |
#define UPARROW "\xEE\x8A\x80" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4954
diff
changeset
|
24 |
#define DOWNARROW "\xEE\x8A\xAA" |
2406
be5cfb8cd20d
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2187
diff
changeset
|
25 |
|
be5cfb8cd20d
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2187
diff
changeset
|
26 |
|
2097
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
27 |
int DrawStringCentered(int x, int y, StringID str, uint16 color); |
2113
f228b399da01
(svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater
parents:
2097
diff
changeset
|
28 |
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color); |
2134 | 29 |
int DoDrawStringCentered(int x, int y, const char *str, uint16 color); |
2097
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
30 |
|
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
31 |
int DrawString(int x, int y, StringID str, uint16 color); |
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
32 |
int DrawStringTruncated(int x, int y, StringID str, uint16 color, uint maxw); |
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
33 |
|
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1093
diff
changeset
|
34 |
int DoDrawString(const char *string, int x, int y, uint16 color); |
2097
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
35 |
int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw); |
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
36 |
|
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
37 |
void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color); |
2113
f228b399da01
(svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater
parents:
2097
diff
changeset
|
38 |
void DrawStringCenterUnderlineTruncated(int xl, int xr, int y, StringID str, uint16 color); |
2097
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
39 |
|
4314
c7ded7546e7f
(svn r5967) -Change: use right alignment for the year in the player's balance window instead of centering (about) 'string width' / 2 from the right edge
rubidium
parents:
3798
diff
changeset
|
40 |
int DrawStringRightAligned(int x, int y, StringID str, uint16 color); |
2097
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
41 |
void DrawStringRightAlignedTruncated(int x, int y, StringID str, uint16 color, uint maxw); |
4314
c7ded7546e7f
(svn r5967) -Change: use right alignment for the year in the player's balance window instead of centering (about) 'string width' / 2 from the right edge
rubidium
parents:
3798
diff
changeset
|
42 |
void DrawStringRightAlignedUnderline(int x, int y, StringID str, uint16 color); |
2097
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
43 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
44 |
void GfxFillRect(int left, int top, int right, int bottom, int color); |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
45 |
void GfxDrawLine(int left, int top, int right, int bottom, int color); |
0 | 46 |
|
4609
6c337b3fbf4b
(svn r6462) -Codechange: Have GetStringWidth() return width as well as the height bounding
Darkvater
parents:
4444
diff
changeset
|
47 |
BoundingRect GetStringBoundingBox(const char *str); |
4954
d773d01b35f5
(svn r6953) -Codechange: Change FormatStringLinebreaks in such a way that if no whitespace was seen
Darkvater
parents:
4928
diff
changeset
|
48 |
uint32 FormatStringLinebreaks(char *str, int maxw); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
657
diff
changeset
|
49 |
void LoadStringWidthTable(void); |
2634
16334e1a4862
(svn r3176) Use proper types, not some variants of int
tron
parents:
2548
diff
changeset
|
50 |
void DrawStringMultiCenter(int x, int y, StringID str, int maxw); |
4928
4cdb51b5db7b
(svn r6908) - Codechange: Modify DrawStringMultiLine() to return the number of pixel lines used, and use it for drawing NewGRF additional text (mart3p)
peter1138
parents:
4609
diff
changeset
|
51 |
uint DrawStringMultiLine(int x, int y, StringID str, int maxw); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
657
diff
changeset
|
52 |
void DrawDirtyBlocks(void); |
0 | 53 |
void SetDirtyBlocks(int left, int top, int right, int bottom); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
657
diff
changeset
|
54 |
void MarkWholeScreenDirty(void); |
0 | 55 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
657
diff
changeset
|
56 |
void GfxInitPalettes(void); |
0 | 57 |
|
4429
1bb01569940c
(svn r6184) Remove the unused (because it was NULL in all callers) second parameter of FillDrawPixelInfo() and simplify some expressions
tron
parents:
4428
diff
changeset
|
58 |
bool FillDrawPixelInfo(DrawPixelInfo* n, int left, int top, int width, int height); |
0 | 59 |
|
60 |
/* window.c */ |
|
61 |
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom); |
|
62 |
||
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5643
diff
changeset
|
63 |
void SetMouseCursor(CursorID cursor); |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1829
diff
changeset
|
64 |
void SetAnimatedMouseCursor(const CursorID *table); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
657
diff
changeset
|
65 |
void CursorTick(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
657
diff
changeset
|
66 |
void DrawMouseCursor(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
657
diff
changeset
|
67 |
void ScreenSizeChanged(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
657
diff
changeset
|
68 |
void UndrawMouseCursor(void); |
0 | 69 |
bool ChangeResInGame(int w, int h); |
1806
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1391
diff
changeset
|
70 |
void SortResolutions(int count); |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5643
diff
changeset
|
71 |
extern "C" void ToggleFullScreen(bool fs); |
0 | 72 |
|
73 |
/* gfx.c */ |
|
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1350
diff
changeset
|
74 |
#define ASCII_LETTERSTART 32 |
3798
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
75 |
extern FontSize _cur_fontsize; |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
76 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4954
diff
changeset
|
77 |
byte GetCharacterWidth(FontSize size, uint32 key); |
3798
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
78 |
|
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
79 |
static inline byte GetCharacterHeight(FontSize size) |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
80 |
{ |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
81 |
switch (size) { |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
82 |
default: NOT_REACHED(); |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
83 |
case FS_NORMAL: return 10; |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
84 |
case FS_SMALL: return 6; |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
85 |
case FS_LARGE: return 18; |
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3312
diff
changeset
|
86 |
} |
1391
1325047def14
(svn r1895) - Fix: add assert for charwidth getter just in case
Darkvater
parents:
1390
diff
changeset
|
87 |
} |
0 | 88 |
|
89 |
VARDEF DrawPixelInfo *_cur_dpi; |
|
90 |
||
4444
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
91 |
enum { |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
92 |
COLOUR_DARK_BLUE, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
93 |
COLOUR_PALE_GREEN, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
94 |
COLOUR_PINK, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
95 |
COLOUR_YELLOW, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
96 |
COLOUR_RED, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
97 |
COLOUR_LIGHT_BLUE, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
98 |
COLOUR_GREEN, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
99 |
COLOUR_DARK_GREEN, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
100 |
COLOUR_BLUE, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
101 |
COLOUR_CREAM, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
102 |
COLOUR_MAUVE, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
103 |
COLOUR_PURPLE, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
104 |
COLOUR_ORANGE, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
105 |
COLOUR_BROWN, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
106 |
COLOUR_GREY, |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
107 |
COLOUR_WHITE |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
108 |
}; |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
109 |
|
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
110 |
/** |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
111 |
* All 16 colour gradients |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
112 |
* 8 colours per gradient from darkest (0) to lightest (7) |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
113 |
*/ |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
114 |
VARDEF byte _colour_gradient[16][8]; |
9c9c7f962482
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4437
diff
changeset
|
115 |
|
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
116 |
VARDEF bool _use_dos_palette; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
117 |
|
657
40a9032b454b
(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents:
614
diff
changeset
|
118 |
typedef enum StringColorFlags { |
40a9032b454b
(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents:
614
diff
changeset
|
119 |
IS_PALETTE_COLOR = 0x100, // color value is already a real palette color index, not an index of a StringColor |
40a9032b454b
(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents:
614
diff
changeset
|
120 |
} StringColorFlags; |
40a9032b454b
(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents:
614
diff
changeset
|
121 |
|
2649
7cd504bd4e51
(svn r3191) Move declaration and definition of _dbg_screen_rect to a place where it somewhat makes sense and wrap them in #ifdef _DEBUG
tron
parents:
2634
diff
changeset
|
122 |
#ifdef _DEBUG |
7cd504bd4e51
(svn r3191) Move declaration and definition of _dbg_screen_rect to a place where it somewhat makes sense and wrap them in #ifdef _DEBUG
tron
parents:
2634
diff
changeset
|
123 |
extern bool _dbg_screen_rect; |
7cd504bd4e51
(svn r3191) Move declaration and definition of _dbg_screen_rect to a place where it somewhat makes sense and wrap them in #ifdef _DEBUG
tron
parents:
2634
diff
changeset
|
124 |
#endif |
7cd504bd4e51
(svn r3191) Move declaration and definition of _dbg_screen_rect to a place where it somewhat makes sense and wrap them in #ifdef _DEBUG
tron
parents:
2634
diff
changeset
|
125 |
|
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2407
diff
changeset
|
126 |
#endif /* GFX_H */ |