# gfx_type.h

Go to the documentation of this file.

    00001 /* $Id: gfx_type.h 19665 2010-04-17 22:27:49Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef GFX_TYPE_H
    00013 #define GFX_TYPE_H
    00014
    00015 #include "core/endian_type.hpp"
    00016 #include "core/geometry_type.hpp"
    00017 #include "zoom_type.h"
    00018
    00019 typedef uint32 SpriteID;
    00020 typedef uint32 PaletteID;
    00021 typedef uint32 CursorID;
    00022
    00024 struct PalSpriteID {
    00025   SpriteID sprite;
    00026   PaletteID pal;
    00027 };
    00028
    00029 enum WindowKeyCodes {
    00030   WKC_SHIFT = 0x8000,
    00031   WKC_CTRL  = 0x4000,
    00032   WKC_ALT   = 0x2000,
    00033   WKC_META  = 0x1000,
    00034
    00035   /* Special ones */
    00036   WKC_NONE        =  0,
    00037   WKC_ESC         =  1,
    00038   WKC_BACKSPACE   =  2,
    00039   WKC_INSERT      =  3,
    00040   WKC_DELETE      =  4,
    00041
    00042   WKC_PAGEUP      =  5,
    00043   WKC_PAGEDOWN    =  6,
    00044   WKC_END         =  7,
    00045   WKC_HOME        =  8,
    00046
    00047   /* Arrow keys */
    00048   WKC_LEFT        =  9,
    00049   WKC_UP          = 10,
    00050   WKC_RIGHT       = 11,
    00051   WKC_DOWN        = 12,
    00052
    00053   /* Return & tab */
    00054   WKC_RETURN      = 13,
    00055   WKC_TAB         = 14,
    00056
    00057   /* Space */
    00058   WKC_SPACE       = 32,
    00059
    00060   /* Function keys */
    00061   WKC_F1          = 33,
    00062   WKC_F2          = 34,
    00063   WKC_F3          = 35,
    00064   WKC_F4          = 36,
    00065   WKC_F5          = 37,
    00066   WKC_F6          = 38,
    00067   WKC_F7          = 39,
    00068   WKC_F8          = 40,
    00069   WKC_F9          = 41,
    00070   WKC_F10         = 42,
    00071   WKC_F11         = 43,
    00072   WKC_F12         = 44,
    00073
    00074   /* Backquote is the key left of "1"
    00075    * we only store this key here, no matter what character is really mapped to it
    00076    * on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °) */
    00077   WKC_BACKQUOTE   = 45,
    00078   WKC_PAUSE       = 46,
    00079
    00080   /* 0-9 are mapped to 48-57
    00081    * A-Z are mapped to 65-90
    00082    * a-z are mapped to 97-122 */
    00083
    00084   /* Numerical keyboard */
    00085   WKC_NUM_DIV     = 138,
    00086   WKC_NUM_MUL     = 139,
    00087   WKC_NUM_MINUS   = 140,
    00088   WKC_NUM_PLUS    = 141,
    00089   WKC_NUM_ENTER   = 142,
    00090   WKC_NUM_DECIMAL = 143,
    00091
    00092   /* Other keys */
    00093   WKC_SLASH       = 144,
    00094   WKC_SEMICOLON   = 145,
    00095   WKC_EQUALS      = 146,
    00096   WKC_L_BRACKET   = 147,
    00097   WKC_BACKSLASH   = 148,
    00098   WKC_R_BRACKET   = 149,
    00099   WKC_SINGLEQUOTE = 150,
    00100   WKC_COMMA       = 151,
    00101   WKC_PERIOD      = 152,
    00102   WKC_MINUS       = 153,
    00103 };
    00104
    00106 struct AnimCursor {
    00107   static const CursorID LAST = MAX_UVALUE(CursorID);
    00108   CursorID sprite;
    00109   byte display_time;
    00110 };
    00111
    00113 struct CursorVars {
    00114   Point pos, size, offs, delta;
    00115   Point draw_pos, draw_size;
    00116   int short_vehicle_offset;
    00117   CursorID sprite;
    00118   PaletteID pal;
    00119
    00120   int wheel;
    00121
    00122   /* We need two different vars to keep track of how far the scrollwheel moved.
    00123    * OSX uses this for scrolling around the map. */
    00124   int v_wheel;
    00125   int h_wheel;
    00126
    00127   const AnimCursor *animate_list;
    00128   const AnimCursor *animate_cur;
    00129   uint animate_timeout;
    00130
    00131   bool visible;
    00132   bool dirty;
    00133   bool fix_at;
    00134   bool in_window;
    00135
    00136   bool vehchain;
    00137 };
    00138
    00140 struct DrawPixelInfo {
    00141   void *dst_ptr;
    00142   int left, top, width, height;
    00143   int pitch;
    00144   ZoomLevel zoom;
    00145 };
    00146
    00148 union Colour {
    00149   uint32 data;
    00150   struct {
    00151 #if TTD_ENDIAN == TTD_BIG_ENDIAN
    00152     uint8 a, r, g, b;
    00153 #else
    00154     uint8 b, g, r, a;
    00155 #endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */
    00156   };
    00157 };
    00158
    00160 enum FontSize {
    00161   FS_NORMAL,
    00162   FS_SMALL,
    00163   FS_LARGE,
    00164   FS_END,
    00165
    00166   FS_BEGIN = FS_NORMAL,
    00167 };
    00168 DECLARE_POSTFIX_INCREMENT(FontSize);
    00169
    00175 struct SubSprite {
    00176   int left, top, right, bottom;
    00177 };
    00178
    00179 enum Colours {
    00180   COLOUR_DARK_BLUE,
    00181   COLOUR_PALE_GREEN,
    00182   COLOUR_PINK,
    00183   COLOUR_YELLOW,
    00184   COLOUR_RED,
    00185   COLOUR_LIGHT_BLUE,
    00186   COLOUR_GREEN,
    00187   COLOUR_DARK_GREEN,
    00188   COLOUR_BLUE,
    00189   COLOUR_CREAM,
    00190   COLOUR_MAUVE,
    00191   COLOUR_PURPLE,
    00192   COLOUR_ORANGE,
    00193   COLOUR_BROWN,
    00194   COLOUR_GREY,
    00195   COLOUR_WHITE,
    00196   COLOUR_END,
    00197   INVALID_COLOUR = 0xFF,
    00198 };
    00199 template <> struct EnumPropsT<Colours> : MakeEnumPropsT<Colours, byte, COLOUR_DARK_BLUE, COLOUR_END, INVALID_COLOUR, 4> {};
    00200
    00202 enum TextColour {
    00203   TC_FROMSTRING  = 0x00,
    00204   TC_BLUE        = 0x00,
    00205   TC_SILVER      = 0x01,
    00206   TC_GOLD        = 0x02,
    00207   TC_RED         = 0x03,
    00208   TC_PURPLE      = 0x04,
    00209   TC_LIGHT_BROWN = 0x05,
    00210   TC_ORANGE      = 0x06,
    00211   TC_GREEN       = 0x07,
    00212   TC_YELLOW      = 0x08,
    00213   TC_DARK_GREEN  = 0x09,
    00214   TC_CREAM       = 0x0A,
    00215   TC_BROWN       = 0x0B,
    00216   TC_WHITE       = 0x0C,
    00217   TC_LIGHT_BLUE  = 0x0D,
    00218   TC_GREY        = 0x0E,
    00219   TC_DARK_BLUE   = 0x0F,
    00220   TC_BLACK       = 0x10,
    00221   TC_INVALID     = 0xFF,
    00222
    00223   IS_PALETTE_COLOUR = 0x100,
    00224 };
    00225 DECLARE_ENUM_AS_BIT_SET(TextColour);
    00226
    00228 enum PaletteAnimationSizes {
    00229   PALETTE_ANIM_SIZE_WIN   = 28,
    00230   PALETTE_ANIM_SIZE_DOS   = 38,
    00231   PALETTE_ANIM_SIZE_START = 217,
    00232 };
    00233
    00235 enum FillRectMode {
    00236   FILLRECT_OPAQUE,
    00237   FILLRECT_CHECKER,
    00238   FILLRECT_RECOLOUR,
    00239 };
    00240
    00242 enum PaletteType {
    00243   PAL_DOS,
    00244   PAL_WINDOWS,
    00245   PAL_AUTODETECT,
    00246   MAX_PAL = 2,
    00247 };
    00248
    00250 enum SpriteType {
    00251   ST_NORMAL   = 0,
    00252   ST_MAPGEN   = 1,
    00253   ST_FONT     = 2,
    00254   ST_RECOLOUR = 3,
    00255   ST_INVALID  = 4,
    00256 };
    00257
    00258 #endif /* GFX_TYPE_H */