tron@2186: /* $Id$ */ tron@2186: rubidium@8619: /** @file gfx_type.h Types related to the graphics and/or input devices. */ belugas@6505: rubidium@8619: #ifndef GFX_TYPE_H rubidium@8619: #define GFX_TYPE_H rubidium@8041: rubidium@8619: #include "core/enum_type.hpp" rubidium@8619: #include "core/geometry_type.hpp" rubidium@8619: #include "zoom_type.h" truelight@0: rubidium@8619: typedef uint32 SpriteID; ///< The number of a sprite, without mapping bits and colortables rubidium@8619: struct PalSpriteID { rubidium@8619: SpriteID sprite; rubidium@8619: SpriteID pal; rubidium@8619: }; rubidium@8619: typedef int32 CursorID; KUDr@5887: KUDr@5887: enum WindowKeyCodes { KUDr@5887: WKC_SHIFT = 0x8000, KUDr@5887: WKC_CTRL = 0x4000, KUDr@5887: WKC_ALT = 0x2000, KUDr@5887: WKC_META = 0x1000, KUDr@5887: belugas@6505: /* Special ones */ KUDr@5887: WKC_NONE = 0, KUDr@5887: WKC_ESC = 1, KUDr@5887: WKC_BACKSPACE = 2, KUDr@5887: WKC_INSERT = 3, KUDr@5887: WKC_DELETE = 4, KUDr@5887: KUDr@5887: WKC_PAGEUP = 5, KUDr@5887: WKC_PAGEDOWN = 6, KUDr@5887: WKC_END = 7, KUDr@5887: WKC_HOME = 8, KUDr@5887: belugas@6505: /* Arrow keys */ KUDr@5887: WKC_LEFT = 9, KUDr@5887: WKC_UP = 10, KUDr@5887: WKC_RIGHT = 11, KUDr@5887: WKC_DOWN = 12, KUDr@5887: belugas@6505: /* Return & tab */ KUDr@5887: WKC_RETURN = 13, KUDr@5887: WKC_TAB = 14, KUDr@5887: belugas@6505: /* Space */ KUDr@5887: WKC_SPACE = 32, KUDr@5887: belugas@6505: /* Function keys */ KUDr@5887: WKC_F1 = 33, KUDr@5887: WKC_F2 = 34, KUDr@5887: WKC_F3 = 35, KUDr@5887: WKC_F4 = 36, KUDr@5887: WKC_F5 = 37, KUDr@5887: WKC_F6 = 38, KUDr@5887: WKC_F7 = 39, KUDr@5887: WKC_F8 = 40, KUDr@5887: WKC_F9 = 41, KUDr@5887: WKC_F10 = 42, KUDr@5887: WKC_F11 = 43, KUDr@5887: WKC_F12 = 44, KUDr@5887: truelight@7807: /* Backquote is the key left of "1" belugas@6505: * we only store this key here, no matter what character is really mapped to it rubidium@7225: * on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °) */ KUDr@5887: WKC_BACKQUOTE = 45, KUDr@5887: WKC_PAUSE = 46, KUDr@5887: belugas@6505: /* 0-9 are mapped to 48-57 belugas@6505: * A-Z are mapped to 65-90 belugas@6505: * a-z are mapped to 97-122 */ truelight@7806: glx@8037: /* Numerical keyboard */ glx@8037: WKC_NUM_0 = 128, glx@8037: WKC_NUM_1 = 129, glx@8037: WKC_NUM_2 = 130, glx@8037: WKC_NUM_3 = 131, glx@8037: WKC_NUM_4 = 132, glx@8037: WKC_NUM_5 = 133, glx@8037: WKC_NUM_6 = 134, glx@8037: WKC_NUM_7 = 135, glx@8037: WKC_NUM_8 = 136, glx@8037: WKC_NUM_9 = 137, glx@8037: WKC_NUM_DIV = 138, glx@8037: WKC_NUM_MUL = 139, glx@8037: WKC_NUM_MINUS = 140, glx@8037: WKC_NUM_PLUS = 141, glx@8037: WKC_NUM_ENTER = 142, glx@8037: WKC_NUM_DECIMAL = 143, truelight@7806: glx@8037: /* Other keys */ glx@8037: WKC_SLASH = 144, ///< / Forward slash glx@8037: WKC_SEMICOLON = 145, ///< ; Semicolon glx@8037: WKC_EQUALS = 146, ///< = Equals glx@8037: WKC_L_BRACKET = 147, ///< [ Left square bracket glx@8037: WKC_BACKSLASH = 148, ///< \ Backslash glx@8037: WKC_R_BRACKET = 149, ///< ] Right square bracket glx@8037: WKC_SINGLEQUOTE = 150, ///< ' Single quote glx@8037: WKC_COMMA = 151, ///< , Comma glx@8037: WKC_PERIOD = 152, ///< . Period glx@8037: WKC_MINUS = 153, ///< - Minus KUDr@5887: }; KUDr@5887: rubidium@6464: /** A single sprite of a list of animated cursors */ rubidium@6464: struct AnimCursor { rubidium@6472: static const CursorID LAST = MAX_UVALUE(CursorID); rubidium@6464: CursorID sprite; ///< Must be set to LAST_ANIM when it is the last sprite of the loop rubidium@6464: byte display_time; ///< Amount of ticks this sprite will be shown rubidium@6464: }; KUDr@5887: rubidium@6574: struct CursorVars { KUDr@5887: Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement KUDr@5887: Point draw_pos, draw_size; ///< position and size bounding-box for drawing peter1138@5919: SpriteID sprite; ///< current image of cursor peter1138@5919: SpriteID pal; KUDr@5887: KUDr@5887: int wheel; ///< mouse wheel movement bjarni@6615: bjarni@6615: /* We need two different vars to keep track of how far the scrollwheel moved. bjarni@6615: * OSX uses this for scrolling around the map. */ bjarni@6615: int v_wheel; bjarni@6615: int h_wheel; bjarni@6615: rubidium@6464: const AnimCursor *animate_list; ///< in case of animated cursor, list of frames rubidium@6464: const AnimCursor *animate_cur; ///< in case of animated cursor, current frame rubidium@6464: uint animate_timeout; ///< in case of animated cursor, number of ticks to show the current cursor KUDr@5887: KUDr@5887: bool visible; ///< cursor is visible KUDr@5887: bool dirty; ///< the rect occupied by the mouse is dirty (redraw) KUDr@5887: bool fix_at; ///< mouse is moving, but cursor is not (used for scrolling) KUDr@5887: bool in_window; ///< mouse inside this window, determines drawing logic rubidium@6574: }; KUDr@5887: rubidium@6574: struct DrawPixelInfo { truelight@7374: void *dst_ptr; KUDr@5887: int left, top, width, height; KUDr@5887: int pitch; truelight@7120: ZoomLevel zoom; rubidium@6574: }; KUDr@5887: rubidium@6574: struct Colour { KUDr@5887: byte r; KUDr@5887: byte g; KUDr@5887: byte b; rubidium@6574: }; KUDr@5887: rubidium@6574: enum FontSize { peter1138@3798: FS_NORMAL, peter1138@3798: FS_SMALL, peter1138@3798: FS_LARGE, peter1138@3798: FS_END, rubidium@6574: }; rubidium@5838: DECLARE_POSTFIX_INCREMENT(FontSize); peter1138@3798: rubidium@8177: /** rubidium@8177: * Used to only draw a part of the sprite. rubidium@8177: * Draw the subsprite in the rect (sprite_x_offset + left, sprite_y_offset + top) to (sprite_x_offset + right, sprite_y_offset + bottom). rubidium@8177: * Both corners are included in the drawing area. rubidium@8177: */ rubidium@8177: struct SubSprite { rubidium@8177: int left, top, right, bottom; rubidium@8177: }; rubidium@8177: tron@4444: enum { tron@4444: COLOUR_DARK_BLUE, tron@4444: COLOUR_PALE_GREEN, tron@4444: COLOUR_PINK, tron@4444: COLOUR_YELLOW, tron@4444: COLOUR_RED, tron@4444: COLOUR_LIGHT_BLUE, tron@4444: COLOUR_GREEN, tron@4444: COLOUR_DARK_GREEN, tron@4444: COLOUR_BLUE, tron@4444: COLOUR_CREAM, tron@4444: COLOUR_MAUVE, tron@4444: COLOUR_PURPLE, tron@4444: COLOUR_ORANGE, tron@4444: COLOUR_BROWN, tron@4444: COLOUR_GREY, tron@4444: COLOUR_WHITE tron@4444: }; tron@4444: belugas@8320: /** Colour of the strings, see _string_colormap in table/palettes.h or docs/ottd-colourtext-palette.png */ belugas@8320: enum TextColour { belugas@8320: TC_FROMSTRING = 0x00, belugas@8320: TC_BLUE = 0x00, belugas@8320: TC_SILVER = 0x01, belugas@8320: TC_GOLD = 0x02, belugas@8320: TC_RED = 0x03, belugas@8320: TC_PURPLE = 0x04, belugas@8320: TC_LIGHT_BROWN = 0x05, belugas@8320: TC_ORANGE = 0x06, belugas@8320: TC_GREEN = 0x07, belugas@8320: TC_YELLOW = 0x08, belugas@8320: TC_DARK_GREEN = 0x09, belugas@8320: TC_CREAM = 0x0A, belugas@8320: TC_BROWN = 0x0B, belugas@8320: TC_WHITE = 0x0C, belugas@8320: TC_LIGHT_BLUE = 0x0D, belugas@8320: TC_GREY = 0x0E, belugas@8320: TC_DARK_BLUE = 0x0F, belugas@8320: TC_BLACK = 0x10, belugas@8320: }; belugas@8320: rubidium@6574: enum StringColorFlags { belugas@6505: IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor rubidium@6574: }; dominik@657: rubidium@8619: #endif /* GFX_TYPE_H */