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