gfx_type.h

Go to the documentation of this file.
00001 /* $Id: gfx_type.h 21897 2011-01-23 00:11:15Z 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   WKC_GLOBAL_HOTKEY = 0x0800, 
00036 
00037   WKC_SPECIAL_KEYS = WKC_SHIFT | WKC_CTRL | WKC_ALT | WKC_META | WKC_GLOBAL_HOTKEY,
00038 
00039   /* Special ones */
00040   WKC_NONE        =  0,
00041   WKC_ESC         =  1,
00042   WKC_BACKSPACE   =  2,
00043   WKC_INSERT      =  3,
00044   WKC_DELETE      =  4,
00045 
00046   WKC_PAGEUP      =  5,
00047   WKC_PAGEDOWN    =  6,
00048   WKC_END         =  7,
00049   WKC_HOME        =  8,
00050 
00051   /* Arrow keys */
00052   WKC_LEFT        =  9,
00053   WKC_UP          = 10,
00054   WKC_RIGHT       = 11,
00055   WKC_DOWN        = 12,
00056 
00057   /* Return & tab */
00058   WKC_RETURN      = 13,
00059   WKC_TAB         = 14,
00060 
00061   /* Space */
00062   WKC_SPACE       = 32,
00063 
00064   /* Function keys */
00065   WKC_F1          = 33,
00066   WKC_F2          = 34,
00067   WKC_F3          = 35,
00068   WKC_F4          = 36,
00069   WKC_F5          = 37,
00070   WKC_F6          = 38,
00071   WKC_F7          = 39,
00072   WKC_F8          = 40,
00073   WKC_F9          = 41,
00074   WKC_F10         = 42,
00075   WKC_F11         = 43,
00076   WKC_F12         = 44,
00077 
00078   /* Backquote is the key left of "1"
00079    * we only store this key here, no matter what character is really mapped to it
00080    * on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °) */
00081   WKC_BACKQUOTE   = 45,
00082   WKC_PAUSE       = 46,
00083 
00084   /* 0-9 are mapped to 48-57
00085    * A-Z are mapped to 65-90
00086    * a-z are mapped to 97-122 */
00087 
00088   /* Numerical keyboard */
00089   WKC_NUM_DIV     = 138,
00090   WKC_NUM_MUL     = 139,
00091   WKC_NUM_MINUS   = 140,
00092   WKC_NUM_PLUS    = 141,
00093   WKC_NUM_ENTER   = 142,
00094   WKC_NUM_DECIMAL = 143,
00095 
00096   /* Other keys */
00097   WKC_SLASH       = 144, 
00098   WKC_SEMICOLON   = 145, 
00099   WKC_EQUALS      = 146, 
00100   WKC_L_BRACKET   = 147, 
00101   WKC_BACKSLASH   = 148, 
00102   WKC_R_BRACKET   = 149, 
00103   WKC_SINGLEQUOTE = 150, 
00104   WKC_COMMA       = 151, 
00105   WKC_PERIOD      = 152, 
00106   WKC_MINUS       = 153, 
00107 };
00108 
00110 struct AnimCursor {
00111   static const CursorID LAST = MAX_UVALUE(CursorID);
00112   CursorID sprite;   
00113   byte display_time; 
00114 };
00115 
00117 struct CursorVars {
00118   Point pos, size, offs, delta; 
00119   Point draw_pos, draw_size;    
00120   int short_vehicle_offset;     
00121   CursorID sprite; 
00122   PaletteID pal;
00123 
00124   int wheel;       
00125 
00126   /* We need two different vars to keep track of how far the scrollwheel moved.
00127    * OSX uses this for scrolling around the map. */
00128   int v_wheel;
00129   int h_wheel;
00130 
00131   const AnimCursor *animate_list; 
00132   const AnimCursor *animate_cur;  
00133   uint animate_timeout;           
00134 
00135   bool visible;    
00136   bool dirty;      
00137   bool fix_at;     
00138   bool in_window;  
00139 
00140   bool vehchain;   
00141 };
00142 
00144 struct DrawPixelInfo {
00145   void *dst_ptr;
00146   int left, top, width, height;
00147   int pitch;
00148   ZoomLevel zoom;
00149 };
00150 
00152 union Colour {
00153   uint32 data; 
00154   struct {
00155 #if TTD_ENDIAN == TTD_BIG_ENDIAN
00156     uint8 a, r, g, b; 
00157 #else
00158     uint8 b, g, r, a; 
00159 #endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */
00160   };
00161 };
00162 
00164 enum FontSize {
00165   FS_NORMAL, 
00166   FS_SMALL,  
00167   FS_LARGE,  
00168   FS_END,
00169 
00170   FS_BEGIN = FS_NORMAL, 
00171 };
00172 DECLARE_POSTFIX_INCREMENT(FontSize)
00173 
00174 
00179 struct SubSprite {
00180   int left, top, right, bottom;
00181 };
00182 
00183 enum Colours {
00184   COLOUR_BEGIN,
00185   COLOUR_DARK_BLUE = COLOUR_BEGIN,
00186   COLOUR_PALE_GREEN,
00187   COLOUR_PINK,
00188   COLOUR_YELLOW,
00189   COLOUR_RED,
00190   COLOUR_LIGHT_BLUE,
00191   COLOUR_GREEN,
00192   COLOUR_DARK_GREEN,
00193   COLOUR_BLUE,
00194   COLOUR_CREAM,
00195   COLOUR_MAUVE,
00196   COLOUR_PURPLE,
00197   COLOUR_ORANGE,
00198   COLOUR_BROWN,
00199   COLOUR_GREY,
00200   COLOUR_WHITE,
00201   COLOUR_END,
00202   INVALID_COLOUR = 0xFF,
00203 };
00204 template <> struct EnumPropsT<Colours> : MakeEnumPropsT<Colours, byte, COLOUR_BEGIN, COLOUR_END, INVALID_COLOUR, 4> {};
00205 
00207 enum TextColour {
00208   TC_BEGIN       = 0x00,
00209   TC_FROMSTRING  = 0x00,
00210   TC_BLUE        = 0x00,
00211   TC_SILVER      = 0x01,
00212   TC_GOLD        = 0x02,
00213   TC_RED         = 0x03,
00214   TC_PURPLE      = 0x04,
00215   TC_LIGHT_BROWN = 0x05,
00216   TC_ORANGE      = 0x06,
00217   TC_GREEN       = 0x07,
00218   TC_YELLOW      = 0x08,
00219   TC_DARK_GREEN  = 0x09,
00220   TC_CREAM       = 0x0A,
00221   TC_BROWN       = 0x0B,
00222   TC_WHITE       = 0x0C,
00223   TC_LIGHT_BLUE  = 0x0D,
00224   TC_GREY        = 0x0E,
00225   TC_DARK_BLUE   = 0x0F,
00226   TC_BLACK       = 0x10,
00227   TC_END,
00228   TC_INVALID     = 0xFF,
00229 
00230   TC_IS_PALETTE_COLOUR = 0x100, 
00231   TC_NO_SHADE          = 0x200, 
00232 };
00233 DECLARE_ENUM_AS_BIT_SET(TextColour)
00234 
00235 
00236 enum PaletteAnimationSizes {
00237   PALETTE_ANIM_SIZE_WIN   = 28,   
00238   PALETTE_ANIM_SIZE_DOS   = 38,   
00239   PALETTE_ANIM_SIZE_START = 217,  
00240 };
00241 
00243 enum FillRectMode {
00244   FILLRECT_OPAQUE,  
00245   FILLRECT_CHECKER, 
00246   FILLRECT_RECOLOUR, 
00247 };
00248 
00250 enum PaletteType {
00251   PAL_DOS,        
00252   PAL_WINDOWS,    
00253   PAL_AUTODETECT, 
00254   MAX_PAL = 2,    
00255 };
00256 
00258 enum SpriteType {
00259   ST_NORMAL   = 0,      
00260   ST_MAPGEN   = 1,      
00261   ST_FONT     = 2,      
00262   ST_RECOLOUR = 3,      
00263   ST_INVALID  = 4,      
00264 };
00265 
00267 static const uint MILLISECONDS_PER_TICK = 30;
00268 
00269 #endif /* GFX_TYPE_H */

Generated on Fri Mar 4 21:36:59 2011 for OpenTTD by  doxygen 1.6.1