sprite.h

Go to the documentation of this file.
00001 /* $Id: sprite.h 22178 2011-03-03 21:47:13Z 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 SPRITE_H
00013 #define SPRITE_H
00014 
00015 #include "transparency.h"
00016 
00017 #include "table/sprites.h"
00018 
00019 #define GENERAL_SPRITE_COLOUR(colour) ((colour) + PALETTE_RECOLOUR_START)
00020 #define COMPANY_SPRITE_COLOUR(owner) (GENERAL_SPRITE_COLOUR(_company_colours[owner]))
00021 
00022 /* The following describes bunch of sprites to be drawn together in a single 3D
00023  * bounding box. Used especially for various multi-sprite buildings (like
00024  * depots or stations): */
00025 
00027 struct DrawTileSeqStruct {
00028   int8 delta_x; 
00029   int8 delta_y;
00030   int8 delta_z;
00031   byte size_x;
00032   byte size_y;
00033   byte size_z;
00034   PalSpriteID image;
00035 };
00036 
00037 const DrawTileSeqStruct *CopyDrawTileSeqStruct(const DrawTileSeqStruct *dtss);
00038 
00040 struct DrawTileSprites {
00041   PalSpriteID ground;           
00042   const DrawTileSeqStruct *seq; 
00043 };
00044 
00049 struct DrawBuildingsTileStruct {
00050   PalSpriteID ground;
00051   PalSpriteID building;
00052   byte subtile_x;
00053   byte subtile_y;
00054   byte width;
00055   byte height;
00056   byte dz;
00057   byte draw_proc;  // this allows to specify a special drawing procedure.
00058 };
00059 
00061 #define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++)
00062 
00063 void DrawCommonTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned);
00064 void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned);
00065 
00071 static inline void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
00072 {
00073   DrawCommonTileSeq(ti, dts, to, total_offset, newgrf_offset, default_palette, false);
00074 }
00075 
00081 static inline void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
00082 {
00083   DrawCommonTileSeqInGUI(x, y, dts, total_offset, newgrf_offset, default_palette, false);
00084 }
00085 
00089 static inline void DrawOrigTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, PaletteID default_palette)
00090 {
00091   DrawCommonTileSeq(ti, dts, to, 0, 0, default_palette, false);
00092 }
00093 
00097 static inline void DrawOrigTileSeqInGUI(int x, int y, const DrawTileSprites *dts, PaletteID default_palette)
00098 {
00099   DrawCommonTileSeqInGUI(x, y, dts, 0, 0, default_palette, false);
00100 }
00101 
00106 static inline void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32 stage, PaletteID default_palette)
00107 {
00108   DrawCommonTileSeq(ti, dts, to, 0, stage, default_palette, true);
00109 }
00110 
00115 static inline void DrawNewGRFTileSeqInGUI(int x, int y, const DrawTileSprites *dts, uint32 stage, PaletteID default_palette)
00116 {
00117   DrawCommonTileSeqInGUI(x, y, dts, 0, stage, default_palette, true);
00118 }
00119 
00131 static inline PaletteID SpriteLayoutPaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
00132 {
00133   if (HasBit(image, PALETTE_MODIFIER_TRANSPARENT) || HasBit(image, PALETTE_MODIFIER_COLOUR)) {
00134     return (pal != 0 ? pal : default_pal);
00135   } else {
00136     return PAL_NONE;
00137   }
00138 }
00139 
00150 static inline PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
00151 {
00152   if (HasBit(image, PALETTE_MODIFIER_COLOUR)) {
00153     return (pal != 0 ? pal : default_pal);
00154   } else {
00155     return PAL_NONE;
00156   }
00157 }
00158 
00159 #endif /* SPRITE_H */

Generated on Sun May 15 19:20:15 2011 for OpenTTD by  doxygen 1.6.1