Files
@ r21195:3d7323eb72bb
Branch filter:
Location: cpp/openttd-patchpack/source/src/sprite.h - annotation
r21195:3d7323eb72bb
6.6 KiB
text/x-c
(svn r26282) -Update from WebTranslator v3.0:
belarusian - 1 changes by KorneySan
catalan - 1 changes by juanjo
finnish - 2 changes by jpx_
russian - 1 changes by KorneySan
belarusian - 1 changes by KorneySan
catalan - 1 changes by juanjo
finnish - 2 changes by jpx_
russian - 1 changes by KorneySan
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6420:01087f989fd1 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r8123:dde0a9a84019 r11085:c87a330fb4c2 r11085:c87a330fb4c2 r8113:7815c26d7612 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r10233:f4b6f7cfa2ac r6248:b940b09d7ab8 r10233:f4b6f7cfa2ac r5475:3f5cd13d1b63 r17350:ee624c6795a6 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r8570:8edf335fd1b4 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r17350:ee624c6795a6 r6248:b940b09d7ab8 r5475:3f5cd13d1b63 r17671:6321f2c5c4f2 r17671:6321f2c5c4f2 r17671:6321f2c5c4f2 r17671:6321f2c5c4f2 r17671:6321f2c5c4f2 r6248:b940b09d7ab8 r10233:f4b6f7cfa2ac r10233:f4b6f7cfa2ac r6248:b940b09d7ab8 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6248:b940b09d7ab8 r5668:e62c2fbafb7b r5668:e62c2fbafb7b r7606:fc4dbd7b3237 r7606:fc4dbd7b3237 r7606:fc4dbd7b3237 r7606:fc4dbd7b3237 r5475:3f5cd13d1b63 r11363:6906c490a00e r6248:b940b09d7ab8 r5475:3f5cd13d1b63 r6420:01087f989fd1 r17350:ee624c6795a6 r5475:3f5cd13d1b63 r14309:f445232b17f6 r14309:f445232b17f6 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14309:f445232b17f6 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14309:f445232b17f6 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14275:c027409d8afb r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14309:f445232b17f6 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14309:f445232b17f6 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r14309:f445232b17f6 r14284:8fe3cab84763 r14284:8fe3cab84763 r14284:8fe3cab84763 r5475:3f5cd13d1b63 r14275:c027409d8afb r15959:4236f491bc28 r15959:4236f491bc28 r15959:4236f491bc28 r15959:4236f491bc28 r15959:4236f491bc28 r15959:4236f491bc28 r15959:4236f491bc28 r15959:4236f491bc28 r15959:4236f491bc28 r14275:c027409d8afb r18847:c72a2915657e r18847:c72a2915657e r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14309:f445232b17f6 r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r18847:c72a2915657e r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14309:f445232b17f6 r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r5475:3f5cd13d1b63 | /* $Id$ */
/*
* This file is part of OpenTTD.
* 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.
* 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.
* 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/>.
*/
/** @file sprite.h Base for drawing complex sprites. */
#ifndef SPRITE_H
#define SPRITE_H
#include "transparency.h"
#include "table/sprites.h"
#define GENERAL_SPRITE_COLOUR(colour) ((colour) + PALETTE_RECOLOUR_START)
#define COMPANY_SPRITE_COLOUR(owner) (GENERAL_SPRITE_COLOUR(_company_colours[owner]))
/* The following describes bunch of sprites to be drawn together in a single 3D
* bounding box. Used especially for various multi-sprite buildings (like
* depots or stations): */
/** A tile child sprite and palette to draw for stations etc, with 3D bounding box */
struct DrawTileSeqStruct {
int8 delta_x; ///< \c 0x80 is sequence terminator
int8 delta_y;
int8 delta_z; ///< \c 0x80 identifies child sprites
byte size_x;
byte size_y;
byte size_z;
PalSpriteID image;
/** Make this struct a sequence terminator. */
void MakeTerminator()
{
this->delta_x = (int8)0x80;
}
/** Check whether this is a sequence terminator. */
bool IsTerminator() const
{
return (byte)this->delta_x == 0x80;
}
/** Check whether this is a parent sprite with a boundingbox. */
bool IsParentSprite() const
{
return (byte)this->delta_z != 0x80;
}
};
/**
* Ground palette sprite of a tile, together with its sprite layout.
* This struct is used for static sprite layouts in the code.
* For allocated ones from NewGRF see #NewGRFSpriteLayout.
*/
struct DrawTileSprites {
PalSpriteID ground; ///< Palette and sprite for the ground
const DrawTileSeqStruct *seq; ///< Array of child sprites. Terminated with a terminator entry
};
/**
* This structure is the same for both Industries and Houses.
* Buildings here reference a general type of construction
*/
struct DrawBuildingsTileStruct {
PalSpriteID ground;
PalSpriteID building;
byte subtile_x;
byte subtile_y;
byte width;
byte height;
byte dz;
byte draw_proc; // this allows to specify a special drawing procedure.
};
/** Iterate through all DrawTileSeqStructs in DrawTileSprites. */
#define foreach_draw_tile_seq(idx, list) for (idx = list; !idx->IsTerminator(); idx++)
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);
void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned);
/**
* Draw tile sprite sequence on tile with railroad specifics.
* @param total_offset Spriteoffset from normal rail to current railtype.
* @param newgrf_offset Startsprite of the Action1 to use.
*/
static inline void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
{
DrawCommonTileSeq(ti, dts, to, total_offset, newgrf_offset, default_palette, false);
}
/**
* Draw tile sprite sequence in GUI with railroad specifics.
* @param total_offset Spriteoffset from normal rail to current railtype.
* @param newgrf_offset Startsprite of the Action1 to use.
*/
static inline void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
{
DrawCommonTileSeqInGUI(x, y, dts, total_offset, newgrf_offset, default_palette, false);
}
/**
* Draw TTD sprite sequence on tile.
*/
static inline void DrawOrigTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, PaletteID default_palette)
{
DrawCommonTileSeq(ti, dts, to, 0, 0, default_palette, false);
}
/**
* Draw TTD sprite sequence in GUI.
*/
static inline void DrawOrigTileSeqInGUI(int x, int y, const DrawTileSprites *dts, PaletteID default_palette)
{
DrawCommonTileSeqInGUI(x, y, dts, 0, 0, default_palette, false);
}
/**
* Draw NewGRF industrytile or house sprite layout
* @param stage Sprite inside the Action1 spritesets to use, i.e. construction stage.
*/
static inline void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32 stage, PaletteID default_palette)
{
DrawCommonTileSeq(ti, dts, to, 0, stage, default_palette, true);
}
/**
* Draw NewGRF object in GUI
* @param stage Sprite inside the Action1 spritesets to use, i.e. construction stage.
*/
static inline void DrawNewGRFTileSeqInGUI(int x, int y, const DrawTileSprites *dts, uint32 stage, PaletteID default_palette)
{
DrawCommonTileSeqInGUI(x, y, dts, 0, stage, default_palette, true);
}
/**
* Applies PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOUR to a palette entry of a sprite layout entry
* @note for ground sprites use #GroundSpritePaletteTransform
* @note Not useable for OTTD internal spritelayouts from table/xxx_land.h as PALETTE_MODIFIER_TRANSPARENT is only set
* when to use the default palette.
*
* @param image The sprite to draw
* @param pal The palette from the sprite layout
* @param default_pal The default recolour sprite to use (typically company colour resp. random industry/house colour)
* @return The palette to use
*/
static inline PaletteID SpriteLayoutPaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
{
if (HasBit(image, PALETTE_MODIFIER_TRANSPARENT) || HasBit(image, PALETTE_MODIFIER_COLOUR)) {
return (pal != 0 ? pal : default_pal);
} else {
return PAL_NONE;
}
}
/**
* Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite
* @note Not useable for OTTD internal spritelayouts from table/xxx_land.h as PALETTE_MODIFIER_TRANSPARENT is only set
* when to use the default palette.
*
* @param image The sprite to draw
* @param pal The palette from the sprite layout
* @param default_pal The default recolour sprite to use (typically company colour resp. random industry/house colour)
* @return The palette to use
*/
static inline PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
{
if (HasBit(image, PALETTE_MODIFIER_COLOUR)) {
return (pal != 0 ? pal : default_pal);
} else {
return PAL_NONE;
}
}
#endif /* SPRITE_H */
|