author | rubidium |
Sun, 22 Jun 2008 21:41:03 +0000 | |
branch | noai |
changeset 11053 | d8d48e076a3f |
parent 11044 | 097ea3e7ec56 |
child 11126 | 72d4c9314c72 |
permissions | -rw-r--r-- |
9723 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file gfx_type.h Types related to the graphics and/or input devices. */ |
|
4 |
||
5 |
#ifndef GFX_TYPE_H |
|
6 |
#define GFX_TYPE_H |
|
7 |
||
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10355
diff
changeset
|
8 |
#include "core/endian_type.hpp" |
9723 | 9 |
#include "core/enum_type.hpp" |
10 |
#include "core/geometry_type.hpp" |
|
11 |
#include "zoom_type.h" |
|
12 |
||
13 |
typedef uint32 SpriteID; ///< The number of a sprite, without mapping bits and colortables |
|
14 |
struct PalSpriteID { |
|
15 |
SpriteID sprite; |
|
16 |
SpriteID pal; |
|
17 |
}; |
|
18 |
typedef int32 CursorID; |
|
19 |
||
20 |
enum WindowKeyCodes { |
|
21 |
WKC_SHIFT = 0x8000, |
|
22 |
WKC_CTRL = 0x4000, |
|
23 |
WKC_ALT = 0x2000, |
|
24 |
WKC_META = 0x1000, |
|
25 |
||
26 |
/* Special ones */ |
|
27 |
WKC_NONE = 0, |
|
28 |
WKC_ESC = 1, |
|
29 |
WKC_BACKSPACE = 2, |
|
30 |
WKC_INSERT = 3, |
|
31 |
WKC_DELETE = 4, |
|
32 |
||
33 |
WKC_PAGEUP = 5, |
|
34 |
WKC_PAGEDOWN = 6, |
|
35 |
WKC_END = 7, |
|
36 |
WKC_HOME = 8, |
|
37 |
||
38 |
/* Arrow keys */ |
|
39 |
WKC_LEFT = 9, |
|
40 |
WKC_UP = 10, |
|
41 |
WKC_RIGHT = 11, |
|
42 |
WKC_DOWN = 12, |
|
43 |
||
44 |
/* Return & tab */ |
|
45 |
WKC_RETURN = 13, |
|
46 |
WKC_TAB = 14, |
|
47 |
||
48 |
/* Space */ |
|
49 |
WKC_SPACE = 32, |
|
50 |
||
51 |
/* Function keys */ |
|
52 |
WKC_F1 = 33, |
|
53 |
WKC_F2 = 34, |
|
54 |
WKC_F3 = 35, |
|
55 |
WKC_F4 = 36, |
|
56 |
WKC_F5 = 37, |
|
57 |
WKC_F6 = 38, |
|
58 |
WKC_F7 = 39, |
|
59 |
WKC_F8 = 40, |
|
60 |
WKC_F9 = 41, |
|
61 |
WKC_F10 = 42, |
|
62 |
WKC_F11 = 43, |
|
63 |
WKC_F12 = 44, |
|
64 |
||
65 |
/* Backquote is the key left of "1" |
|
66 |
* we only store this key here, no matter what character is really mapped to it |
|
67 |
* on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °) */ |
|
68 |
WKC_BACKQUOTE = 45, |
|
69 |
WKC_PAUSE = 46, |
|
70 |
||
71 |
/* 0-9 are mapped to 48-57 |
|
72 |
* A-Z are mapped to 65-90 |
|
73 |
* a-z are mapped to 97-122 */ |
|
74 |
||
75 |
/* Numerical keyboard */ |
|
76 |
WKC_NUM_0 = 128, |
|
77 |
WKC_NUM_1 = 129, |
|
78 |
WKC_NUM_2 = 130, |
|
79 |
WKC_NUM_3 = 131, |
|
80 |
WKC_NUM_4 = 132, |
|
81 |
WKC_NUM_5 = 133, |
|
82 |
WKC_NUM_6 = 134, |
|
83 |
WKC_NUM_7 = 135, |
|
84 |
WKC_NUM_8 = 136, |
|
85 |
WKC_NUM_9 = 137, |
|
86 |
WKC_NUM_DIV = 138, |
|
87 |
WKC_NUM_MUL = 139, |
|
88 |
WKC_NUM_MINUS = 140, |
|
89 |
WKC_NUM_PLUS = 141, |
|
90 |
WKC_NUM_ENTER = 142, |
|
91 |
WKC_NUM_DECIMAL = 143, |
|
92 |
||
93 |
/* Other keys */ |
|
94 |
WKC_SLASH = 144, ///< / Forward slash |
|
95 |
WKC_SEMICOLON = 145, ///< ; Semicolon |
|
96 |
WKC_EQUALS = 146, ///< = Equals |
|
97 |
WKC_L_BRACKET = 147, ///< [ Left square bracket |
|
98 |
WKC_BACKSLASH = 148, ///< \ Backslash |
|
99 |
WKC_R_BRACKET = 149, ///< ] Right square bracket |
|
100 |
WKC_SINGLEQUOTE = 150, ///< ' Single quote |
|
101 |
WKC_COMMA = 151, ///< , Comma |
|
102 |
WKC_PERIOD = 152, ///< . Period |
|
103 |
WKC_MINUS = 153, ///< - Minus |
|
104 |
}; |
|
105 |
||
106 |
/** A single sprite of a list of animated cursors */ |
|
107 |
struct AnimCursor { |
|
108 |
static const CursorID LAST = MAX_UVALUE(CursorID); |
|
109 |
CursorID sprite; ///< Must be set to LAST_ANIM when it is the last sprite of the loop |
|
110 |
byte display_time; ///< Amount of ticks this sprite will be shown |
|
111 |
}; |
|
112 |
||
113 |
struct CursorVars { |
|
114 |
Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement |
|
115 |
Point draw_pos, draw_size; ///< position and size bounding-box for drawing |
|
116 |
SpriteID sprite; ///< current image of cursor |
|
117 |
SpriteID pal; |
|
118 |
||
119 |
int wheel; ///< mouse wheel movement |
|
120 |
||
121 |
/* We need two different vars to keep track of how far the scrollwheel moved. |
|
122 |
* OSX uses this for scrolling around the map. */ |
|
123 |
int v_wheel; |
|
124 |
int h_wheel; |
|
125 |
||
126 |
const AnimCursor *animate_list; ///< in case of animated cursor, list of frames |
|
127 |
const AnimCursor *animate_cur; ///< in case of animated cursor, current frame |
|
128 |
uint animate_timeout; ///< in case of animated cursor, number of ticks to show the current cursor |
|
129 |
||
130 |
bool visible; ///< cursor is visible |
|
131 |
bool dirty; ///< the rect occupied by the mouse is dirty (redraw) |
|
132 |
bool fix_at; ///< mouse is moving, but cursor is not (used for scrolling) |
|
133 |
bool in_window; ///< mouse inside this window, determines drawing logic |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9723
diff
changeset
|
134 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9723
diff
changeset
|
135 |
bool vehchain; ///< vehicle chain is dragged |
9723 | 136 |
}; |
137 |
||
138 |
struct DrawPixelInfo { |
|
139 |
void *dst_ptr; |
|
140 |
int left, top, width, height; |
|
141 |
int pitch; |
|
142 |
ZoomLevel zoom; |
|
143 |
}; |
|
144 |
||
145 |
struct Colour { |
|
11044
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10355
diff
changeset
|
146 |
#if TTD_ENDIAN == TTD_BIG_ENDIAN |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10355
diff
changeset
|
147 |
uint8 a, r, g, b; ///< colour channels in BE order |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10355
diff
changeset
|
148 |
#else |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10355
diff
changeset
|
149 |
uint8 b, g, r, a; ///< colour channels in LE order |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10355
diff
changeset
|
150 |
#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */ |
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10355
diff
changeset
|
151 |
|
097ea3e7ec56
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents:
10355
diff
changeset
|
152 |
operator uint32 () { return *(uint32 *)this; } |
9723 | 153 |
}; |
154 |
||
155 |
enum FontSize { |
|
156 |
FS_NORMAL, |
|
157 |
FS_SMALL, |
|
158 |
FS_LARGE, |
|
159 |
FS_END, |
|
160 |
}; |
|
161 |
DECLARE_POSTFIX_INCREMENT(FontSize); |
|
162 |
||
163 |
/** |
|
164 |
* Used to only draw a part of the sprite. |
|
165 |
* Draw the subsprite in the rect (sprite_x_offset + left, sprite_y_offset + top) to (sprite_x_offset + right, sprite_y_offset + bottom). |
|
166 |
* Both corners are included in the drawing area. |
|
167 |
*/ |
|
168 |
struct SubSprite { |
|
169 |
int left, top, right, bottom; |
|
170 |
}; |
|
171 |
||
10355
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
9869
diff
changeset
|
172 |
enum Colours { |
9723 | 173 |
COLOUR_DARK_BLUE, |
174 |
COLOUR_PALE_GREEN, |
|
175 |
COLOUR_PINK, |
|
176 |
COLOUR_YELLOW, |
|
177 |
COLOUR_RED, |
|
178 |
COLOUR_LIGHT_BLUE, |
|
179 |
COLOUR_GREEN, |
|
180 |
COLOUR_DARK_GREEN, |
|
181 |
COLOUR_BLUE, |
|
182 |
COLOUR_CREAM, |
|
183 |
COLOUR_MAUVE, |
|
184 |
COLOUR_PURPLE, |
|
185 |
COLOUR_ORANGE, |
|
186 |
COLOUR_BROWN, |
|
187 |
COLOUR_GREY, |
|
10355
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
9869
diff
changeset
|
188 |
COLOUR_WHITE, |
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
9869
diff
changeset
|
189 |
COLOUR_END, |
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
9869
diff
changeset
|
190 |
INVALID_COLOUR = 0xFF |
9723 | 191 |
}; |
192 |
||
193 |
/** Colour of the strings, see _string_colormap in table/palettes.h or docs/ottd-colourtext-palette.png */ |
|
194 |
enum TextColour { |
|
195 |
TC_FROMSTRING = 0x00, |
|
196 |
TC_BLUE = 0x00, |
|
197 |
TC_SILVER = 0x01, |
|
198 |
TC_GOLD = 0x02, |
|
199 |
TC_RED = 0x03, |
|
200 |
TC_PURPLE = 0x04, |
|
201 |
TC_LIGHT_BROWN = 0x05, |
|
202 |
TC_ORANGE = 0x06, |
|
203 |
TC_GREEN = 0x07, |
|
204 |
TC_YELLOW = 0x08, |
|
205 |
TC_DARK_GREEN = 0x09, |
|
206 |
TC_CREAM = 0x0A, |
|
207 |
TC_BROWN = 0x0B, |
|
208 |
TC_WHITE = 0x0C, |
|
209 |
TC_LIGHT_BLUE = 0x0D, |
|
210 |
TC_GREY = 0x0E, |
|
211 |
TC_DARK_BLUE = 0x0F, |
|
212 |
TC_BLACK = 0x10, |
|
213 |
}; |
|
214 |
||
215 |
enum StringColorFlags { |
|
216 |
IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor |
|
217 |
}; |
|
218 |
||
219 |
#endif /* GFX_TYPE_H */ |