src/gfx_type.h
branchNewGRF_ports
changeset 6872 1c4a4a609f85
child 9869 6404afe43575
equal deleted inserted replaced
6871:5a9dc001e1ad 6872:1c4a4a609f85
       
     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
       
   133 };
       
   134 
       
   135 struct DrawPixelInfo {
       
   136 	void *dst_ptr;
       
   137 	int left, top, width, height;
       
   138 	int pitch;
       
   139 	ZoomLevel zoom;
       
   140 };
       
   141 
       
   142 struct Colour {
       
   143 	byte r;
       
   144 	byte g;
       
   145 	byte b;
       
   146 };
       
   147 
       
   148 enum FontSize {
       
   149 	FS_NORMAL,
       
   150 	FS_SMALL,
       
   151 	FS_LARGE,
       
   152 	FS_END,
       
   153 };
       
   154 DECLARE_POSTFIX_INCREMENT(FontSize);
       
   155 
       
   156 /**
       
   157  * Used to only draw a part of the sprite.
       
   158  * Draw the subsprite in the rect (sprite_x_offset + left, sprite_y_offset + top) to (sprite_x_offset + right, sprite_y_offset + bottom).
       
   159  * Both corners are included in the drawing area.
       
   160  */
       
   161 struct SubSprite {
       
   162 	int left, top, right, bottom;
       
   163 };
       
   164 
       
   165 enum {
       
   166 	COLOUR_DARK_BLUE,
       
   167 	COLOUR_PALE_GREEN,
       
   168 	COLOUR_PINK,
       
   169 	COLOUR_YELLOW,
       
   170 	COLOUR_RED,
       
   171 	COLOUR_LIGHT_BLUE,
       
   172 	COLOUR_GREEN,
       
   173 	COLOUR_DARK_GREEN,
       
   174 	COLOUR_BLUE,
       
   175 	COLOUR_CREAM,
       
   176 	COLOUR_MAUVE,
       
   177 	COLOUR_PURPLE,
       
   178 	COLOUR_ORANGE,
       
   179 	COLOUR_BROWN,
       
   180 	COLOUR_GREY,
       
   181 	COLOUR_WHITE
       
   182 };
       
   183 
       
   184 /** Colour of the strings, see _string_colormap in table/palettes.h or docs/ottd-colourtext-palette.png */
       
   185 enum TextColour {
       
   186 	TC_FROMSTRING  = 0x00,
       
   187 	TC_BLUE        = 0x00,
       
   188 	TC_SILVER      = 0x01,
       
   189 	TC_GOLD        = 0x02,
       
   190 	TC_RED         = 0x03,
       
   191 	TC_PURPLE      = 0x04,
       
   192 	TC_LIGHT_BROWN = 0x05,
       
   193 	TC_ORANGE      = 0x06,
       
   194 	TC_GREEN       = 0x07,
       
   195 	TC_YELLOW      = 0x08,
       
   196 	TC_DARK_GREEN  = 0x09,
       
   197 	TC_CREAM       = 0x0A,
       
   198 	TC_BROWN       = 0x0B,
       
   199 	TC_WHITE       = 0x0C,
       
   200 	TC_LIGHT_BLUE  = 0x0D,
       
   201 	TC_GREY        = 0x0E,
       
   202 	TC_DARK_BLUE   = 0x0F,
       
   203 	TC_BLACK       = 0x10,
       
   204 };
       
   205 
       
   206 enum StringColorFlags {
       
   207 	IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor
       
   208 };
       
   209 
       
   210 #endif /* GFX_TYPE_H */