diff options
author | frosch <frosch@openttd.org> | 2010-01-16 22:25:44 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-01-16 22:25:44 +0000 |
commit | d27999e4463edfb46158687343cd0e4f339a81a1 (patch) | |
tree | 81958834fbc08b062066858b039cf8e4ecdb83ec /src/sprite.cpp | |
parent | 199091600a9040f25c99b20431b5a2e072d19049 (diff) | |
download | openttd-d27999e4463edfb46158687343cd0e4f339a81a1.tar.xz |
(svn r18837) -Codechange: Rename DrawStationTileSeq() to DrawCommonTileSeq() and move it to separate file.
Diffstat (limited to 'src/sprite.cpp')
-rw-r--r-- | src/sprite.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/sprite.cpp b/src/sprite.cpp new file mode 100644 index 000000000..1edaa2909 --- /dev/null +++ b/src/sprite.cpp @@ -0,0 +1,58 @@ +/* $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.cpp Handling of sprites */ + +#include "stdafx.h" +#include "sprite.h" +#include "tile_cmd.h" +#include "viewport_func.h" + +#include "table/sprites.h" + +/** + * Draws a tile sprite sequence. + * @param ti The tile to draw on + * @param dts Sprite and subsprites to draw + * @param to The transparancy bit that toggles drawing of these sprites + * @param orig_offset Sprite-Offset for original sprites + * @param newgrf_offset Sprite-Offset for NewGRF defined sprites + * @param default_palette The default recolour sprite to use (typically company colour) + */ +void DrawCommonTileSeq(const TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 orig_offset, uint32 newgrf_offset, SpriteID default_palette) +{ + const DrawTileSeqStruct *dtss; + foreach_draw_tile_seq(dtss, dts->seq) { + SpriteID image = dtss->image.sprite; + + /* Stop drawing sprite sequence once we meet a sprite that doesn't have to be opaque */ + if (IsInvisibilitySet(to) && !HasBit(image, SPRITE_MODIFIER_OPAQUE)) return; + + if (newgrf_offset == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { + image += orig_offset; + } else { + image += newgrf_offset; + } + + SpriteID pal = SpriteLayoutPaletteTransform(image, dtss->image.pal, default_palette); + + if ((byte)dtss->delta_z != 0x80) { + AddSortableSpriteToDraw( + image, pal, + ti->x + dtss->delta_x, ti->y + dtss->delta_y, + dtss->size_x, dtss->size_y, + dtss->size_z, ti->z + dtss->delta_z, + !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(to) + ); + } else { + /* For stations and original spritelayouts delta_x and delta_y are signed */ + AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y, !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(to)); + } + } +} |