author | Darkvater |
Tue, 19 Jul 2005 22:12:04 +0000 | |
changeset 2134 | 7192d5266a96 |
parent 2113 | f228b399da01 |
child 2186 | 461a2aff3486 |
permissions | -rw-r--r-- |
0 | 1 |
#ifndef GFX_H |
2 |
#define GFX_H |
|
3 |
||
2062 | 4 |
typedef byte Pixel; |
0 | 5 |
|
6 |
typedef struct ColorList { |
|
7 |
byte unk0, unk1, unk2; |
|
8 |
byte window_color_1a, window_color_1b; |
|
9 |
byte window_color_bga, window_color_bgb; |
|
10 |
byte window_color_2; |
|
11 |
} ColorList; |
|
12 |
||
13 |
struct DrawPixelInfo { |
|
2062 | 14 |
Pixel *dst_ptr; |
0 | 15 |
int left, top, width, height; |
16 |
int pitch; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
17 |
uint16 zoom; |
0 | 18 |
}; |
19 |
||
20 |
||
21 |
typedef struct CursorVars { |
|
22 |
Point pos, size, offs, delta; |
|
23 |
Point draw_pos, draw_size; |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1829
diff
changeset
|
24 |
CursorID sprite; |
0 | 25 |
|
26 |
int wheel; // mouse wheel movement |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1829
diff
changeset
|
27 |
const CursorID *animate_list, *animate_cur; |
0 | 28 |
uint animate_timeout; |
29 |
||
30 |
bool visible; |
|
31 |
bool dirty; |
|
32 |
bool fix_at; |
|
33 |
} CursorVars; |
|
34 |
||
35 |
||
36 |
void RedrawScreenRect(int left, int top, int right, int bottom); |
|
37 |
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
|
38 |
|
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
39 |
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
|
40 |
int DrawStringCenteredTruncated(int xl, int xr, int y, StringID str, uint16 color); |
2134 | 41 |
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
|
42 |
|
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
43 |
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
|
44 |
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
|
45 |
|
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1093
diff
changeset
|
46 |
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
|
47 |
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
|
48 |
|
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
49 |
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
|
50 |
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
|
51 |
|
82b1e11883fd
(svn r2607) - Feature: add support for truncating strings to a given (pixel) length. Function courtesy of Ludde.
Darkvater
parents:
2062
diff
changeset
|
52 |
void DrawStringRightAligned(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
|
53 |
void DrawStringRightAlignedTruncated(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
|
54 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
55 |
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
|
56 |
void GfxDrawLine(int left, int top, int right, int bottom, int color); |
0 | 57 |
void DrawFrameRect(int left, int top, int right, int bottom, int color, int flags); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
298
diff
changeset
|
58 |
uint16 GetDrawStringPlayerColor(byte player); |
0 | 59 |
|
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1093
diff
changeset
|
60 |
int GetStringWidth(const char *str); |
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
|
61 |
void LoadStringWidthTable(void); |
0 | 62 |
void DrawStringMultiCenter(int x, int y, uint16 str, int maxw); |
63 |
void DrawStringMultiLine(int x, int y, uint16 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
|
64 |
void DrawDirtyBlocks(void); |
0 | 65 |
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
|
66 |
void MarkWholeScreenDirty(void); |
0 | 67 |
|
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
|
68 |
void GfxInitPalettes(void); |
0 | 69 |
|
70 |
bool FillDrawPixelInfo(DrawPixelInfo *n, DrawPixelInfo *o, int left, int top, int width, int height); |
|
71 |
||
72 |
/* window.c */ |
|
73 |
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom); |
|
74 |
||
75 |
void SetMouseCursor(uint cursor); |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1829
diff
changeset
|
76 |
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
|
77 |
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
|
78 |
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
|
79 |
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
|
80 |
void UndrawMouseCursor(void); |
0 | 81 |
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
|
82 |
void SortResolutions(int count); |
1829
0b6de3b4458a
(svn r2334) - Fix (regression): moved togglefullscreen into the video-driver, now windows works, dedicated works and sdl works. Also reverted the change to the makefile.
Darkvater
parents:
1806
diff
changeset
|
83 |
void ToggleFullScreen(bool fs); |
0 | 84 |
|
85 |
/* 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
|
86 |
#define ASCII_LETTERSTART 32 |
0 | 87 |
VARDEF int _stringwidth_base; |
88 |
VARDEF byte _stringwidth_table[0x2A0]; |
|
1391
1325047def14
(svn r1895) - Fix: add assert for charwidth getter just in case
Darkvater
parents:
1390
diff
changeset
|
89 |
static inline byte GetCharacterWidth(uint key) |
1325047def14
(svn r1895) - Fix: add assert for charwidth getter just in case
Darkvater
parents:
1390
diff
changeset
|
90 |
{ |
1325047def14
(svn r1895) - Fix: add assert for charwidth getter just in case
Darkvater
parents:
1390
diff
changeset
|
91 |
assert(key >= ASCII_LETTERSTART && key - ASCII_LETTERSTART < lengthof(_stringwidth_table)); |
1325047def14
(svn r1895) - Fix: add assert for charwidth getter just in case
Darkvater
parents:
1390
diff
changeset
|
92 |
return _stringwidth_table[key - ASCII_LETTERSTART]; |
1325047def14
(svn r1895) - Fix: add assert for charwidth getter just in case
Darkvater
parents:
1390
diff
changeset
|
93 |
} |
0 | 94 |
|
95 |
VARDEF DrawPixelInfo _screen; |
|
96 |
VARDEF DrawPixelInfo *_cur_dpi; |
|
97 |
VARDEF ColorList _color_list[16]; |
|
98 |
VARDEF CursorVars _cursor; |
|
99 |
||
100 |
VARDEF int _pal_first_dirty; |
|
101 |
VARDEF int _pal_last_dirty; |
|
102 |
||
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
103 |
VARDEF bool _use_dos_palette; |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
543
diff
changeset
|
104 |
|
0 | 105 |
/* spritecache.c */ |
106 |
//enum { NUM_SPRITES = 0x1320 }; |
|
107 |
//enum { NUM_SPRITES = 0x1500 }; |
|
108 |
enum { NUM_SPRITES = 0x3500 }; // 1500 + space for custom GRF sets |
|
109 |
||
1991
f3d5e35731a2
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1914
diff
changeset
|
110 |
typedef struct Colour { |
f3d5e35731a2
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1914
diff
changeset
|
111 |
byte r; |
f3d5e35731a2
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1914
diff
changeset
|
112 |
byte g; |
f3d5e35731a2
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1914
diff
changeset
|
113 |
byte b; |
f3d5e35731a2
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1914
diff
changeset
|
114 |
} Colour; |
f3d5e35731a2
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1914
diff
changeset
|
115 |
|
f3d5e35731a2
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1914
diff
changeset
|
116 |
extern Colour _cur_palette[256]; |
0 | 117 |
|
657
40a9032b454b
(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents:
614
diff
changeset
|
118 |
|
40a9032b454b
(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents:
614
diff
changeset
|
119 |
typedef enum StringColorFlags { |
40a9032b454b
(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents:
614
diff
changeset
|
120 |
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
|
121 |
} StringColorFlags; |
40a9032b454b
(svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents:
614
diff
changeset
|
122 |
|
0 | 123 |
#endif |