Changeset - r14144:b9b789bba851
[Not reviewed]
master
0 6 0
frosch - 14 years ago 2010-01-03 20:55:00
frosch@openttd.org
(svn r18702) -Fix [FS#3467]: Enable DrawGroundSpriteAt() to deal with foundations as DrawGroundSprite() does, and use this for drawing one-way-road-signs and clear-land-fences.
6 files changed with 38 insertions and 26 deletions:
0 comments (0 inline, 0 general)
src/clear_cmd.cpp
Show inline comments
 
@@ -60,25 +60,20 @@ void DrawHillyLandTile(const TileInfo *t
 
		DrawGroundSprite(_landscape_clear_sprites_rough[GB(ti->x ^ ti->y, 4, 3)], PAL_NONE);
 
	}
 
}
 

	
 
void DrawClearLandFence(const TileInfo *ti)
 
{
 
	byte z = ti->z;
 

	
 
	if (ti->tileh & SLOPE_S) {
 
		z += TILE_HEIGHT;
 
		if (ti->tileh == SLOPE_STEEP_S) z += TILE_HEIGHT;
 
	}
 
	int z = GetSlopeZInCorner(ti->tileh, CORNER_S);
 

	
 
	if (GetFenceSW(ti->tile) != 0) {
 
		DrawGroundSpriteAt(_clear_land_fence_sprites[GetFenceSW(ti->tile) - 1] + _fence_mod_by_tileh_sw[ti->tileh], PAL_NONE, ti->x, ti->y, z);
 
		DrawGroundSpriteAt(_clear_land_fence_sprites[GetFenceSW(ti->tile) - 1] + _fence_mod_by_tileh_sw[ti->tileh], PAL_NONE, 0, 0, z);
 
	}
 

	
 
	if (GetFenceSE(ti->tile) != 0) {
 
		DrawGroundSpriteAt(_clear_land_fence_sprites[GetFenceSE(ti->tile) - 1] + _fence_mod_by_tileh_se[ti->tileh], PAL_NONE, ti->x, ti->y, z);
 
		DrawGroundSpriteAt(_clear_land_fence_sprites[GetFenceSE(ti->tile) - 1] + _fence_mod_by_tileh_se[ti->tileh], PAL_NONE, 0, 0, z);
 
	}
 
}
 

	
 
static void DrawTile_Clear(TileInfo *ti)
 
{
 
	switch (GetClearGround(ti->tile)) {
src/dummy_land.cpp
Show inline comments
 
@@ -16,13 +16,13 @@
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
static void DrawTile_Dummy(TileInfo *ti)
 
{
 
	DrawGroundSpriteAt(SPR_SHADOW_CELL, PAL_NONE, ti->x, ti->y, ti->z);
 
	DrawGroundSprite(SPR_SHADOW_CELL, PAL_NONE);
 
}
 

	
 

	
 
static uint GetSlopeZ_Dummy(TileIndex tile, uint x, uint y)
 
{
 
	return TilePixelHeight(tile);
src/road_cmd.cpp
Show inline comments
 
@@ -1123,13 +1123,13 @@ static void DrawRoadBits(TileInfo *ti)
 
		DrawGroundSprite(image, pal);
 
	}
 

	
 
	if (road != ROAD_NONE) {
 
		DisallowedRoadDirections drd = GetDisallowedRoadDirections(ti->tile);
 
		if (drd != DRD_NONE) {
 
			DrawRoadDetail(SPR_ONEWAY_BASE + drd - 1 + ((road == ROAD_X) ? 0 : 3), ti, 8, 8, 0);
 
			DrawGroundSpriteAt(SPR_ONEWAY_BASE + drd - 1 + ((road == ROAD_X) ? 0 : 3), PAL_NONE, 8, 8, GetPartialZ(8, 8, ti->tileh));
 
		}
 
	}
 

	
 
	if (HasRoadWorks(ti->tile)) {
 
		/* Road works */
 
		DrawGroundSprite((road | tram) & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y, PAL_NONE);
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1181,13 +1181,13 @@ void DrawBridgeMiddle(const TileInfo *ti
 
			SpriteID pal   = psid->pal;
 
			if (IsTransparencySet(TO_BRIDGES)) {
 
				SetBit(image, PALETTE_MODIFIER_TRANSPARENT);
 
				pal = PALETTE_TO_TRANSPARENT;
 
			}
 

	
 
			DrawGroundSpriteAt(image, pal, x, y, z);
 
			DrawGroundSpriteAt(image, pal, x - ti->x, y - ti->y, z - ti->z);
 
		}
 
	} else if (_settings_client.gui.bridge_pillars) {
 
		/* draw pillars below for high bridges */
 
		DrawBridgePillars(psid, ti, axis, drawfarpillar, x, y, z);
 
	}
 
}
src/viewport.cpp
Show inline comments
 
@@ -464,25 +464,24 @@ void HandleZoomMessage(Window *w, const 
 

	
 
	w->SetWidgetDisabledState(widget_zoom_out, vp->zoom == ZOOM_LVL_MAX);
 
	w->SetWidgetDirty(widget_zoom_out);
 
}
 

	
 
/**
 
 * Draws a ground sprite at a specific world-coordinate.
 
 * Shedules a tile sprite for drawing.
 
 *
 
 * @param image the image to draw.
 
 * @param pal the provided palette.
 
 * @param x position x (world coordinates) of the sprite.
 
 * @param y position y (world coordinates) of the sprite.
 
 * @param z position z (world coordinates) of the sprite.
 
 * @param sub Only draw a part of the sprite.
 
 * @param extra_offs_x Pixel X offset for the sprite position.
 
 * @param extra_offs_y Pixel Y offset for the sprite position.
 
 *
 
 */
 
void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
 
static void AddTileSpriteToDraw(SpriteID image, SpriteID pal, int32 x, int32 y, int z, const SubSprite *sub = NULL, int extra_offs_x = 0, int extra_offs_y = 0)
 
{
 
	assert((image & SPRITE_MASK) < MAX_SPRITES);
 

	
 
	TileSpriteToDraw *ts = _vd.tile_sprites_to_draw.Append();
 
	ts->image = image;
 
	ts->pal = pal;
 
@@ -518,34 +517,52 @@ static void AddChildSpriteToFoundation(S
 

	
 
	/* Switch back to last ChildSprite list */
 
	_vd.last_child = old_child;
 
}
 

	
 
/**
 
 * Draws a ground sprite at a specific world-coordinate relative to the current tile.
 
 * If the current tile is drawn on top of a foundation the sprite is added as child sprite to the "foundation"-ParentSprite.
 
 *
 
 * @param image the image to draw.
 
 * @param pal the provided palette.
 
 * @param x position x (world coordinates) of the sprite relative to current tile.
 
 * @param y position y (world coordinates) of the sprite relative to current tile.
 
 * @param z position z (world coordinates) of the sprite relative to current tile.
 
 * @param sub Only draw a part of the sprite.
 
 * @param extra_offs_x Pixel X offset for the sprite position.
 
 * @param extra_offs_y Pixel Y offset for the sprite position.
 
 */
 
void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, int z, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
 
{
 
	/* Switch to first foundation part, if no foundation was drawn */
 
	if (_vd.foundation_part == FOUNDATION_PART_NONE) _vd.foundation_part = FOUNDATION_PART_NORMAL;
 

	
 
	if (_vd.foundation[_vd.foundation_part] != -1) {
 
		Point pt = RemapCoords(x, y, z);
 
		AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, pt.x + extra_offs_x, pt.y + extra_offs_y);
 
	} else {
 
		AddTileSpriteToDraw(image, pal, _cur_ti->x + x, _cur_ti->y + y, _cur_ti->z + z, sub, extra_offs_x, extra_offs_y);
 
	}
 
}
 

	
 
/**
 
 * Draws a ground sprite for the current tile.
 
 * If the current tile is drawn on top of a foundation the sprite is added as child sprite to the "foundation"-ParentSprite.
 
 *
 
 * @param image the image to draw.
 
 * @param pal the provided palette.
 
 * @param sub Only draw a part of the sprite.
 
 * @param extra_offs_x Pixel X offset for the sprite position.
 
 * @param extra_offs_y Pixel Y offset for the sprite position.
 
 */
 
void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
 
{
 
	/* Switch to first foundation part, if no foundation was drawn */
 
	if (_vd.foundation_part == FOUNDATION_PART_NONE) _vd.foundation_part = FOUNDATION_PART_NORMAL;
 

	
 
	if (_vd.foundation[_vd.foundation_part] != -1) {
 
		AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, extra_offs_x, extra_offs_y);
 
	} else {
 
		DrawGroundSpriteAt(image, pal, _cur_ti->x, _cur_ti->y, _cur_ti->z, sub, extra_offs_x, extra_offs_y);
 
	}
 
	DrawGroundSpriteAt(image, pal, 0, 0, 0, sub, extra_offs_x, extra_offs_y);
 
}
 

	
 

	
 
/**
 
 * Called when a foundation has been drawn for the current tile.
 
 * Successive ground sprites for the current tile will be drawn as child sprites of the "foundation"-ParentSprite, not as TileSprites.
 
 *
 
 * @param x sprite x-offset (screen coordinates) of ground sprites relative to the "foundation"-ParentSprite.
 
 * @param y sprite y-offset (screen coordinates) of ground sprites relative to the "foundation"-ParentSprite.
 
@@ -802,13 +819,13 @@ static void AddStringToDraw(int x, int y
 
 */
 
static void DrawSelectionSprite(SpriteID image, SpriteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part)
 
{
 
	/* FIXME: This is not totally valid for some autorail highlights, that extent over the edges of the tile. */
 
	if (_vd.foundation[foundation_part] == -1) {
 
		/* draw on real ground */
 
		DrawGroundSpriteAt(image, pal, ti->x, ti->y, ti->z + z_offset);
 
		AddTileSpriteToDraw(image, pal, ti->x, ti->y, ti->z + z_offset);
 
	} else {
 
		/* draw on top of foundation */
 
		AddChildSpriteToFoundation(image, pal, NULL, foundation_part, 0, -z_offset);
 
	}
 
}
 

	
 
@@ -1021,13 +1038,13 @@ static void ViewportAddLandscape()
 
				TileIndex tile = TileVirtXY(x_cur, y_cur);
 

	
 
				if (!_settings_game.construction.freeform_edges || (TileX(tile) != 0 && TileY(tile) != 0)) {
 
					if (x_cur == ((int)MapMaxX() - 1) * TILE_SIZE || y_cur == ((int)MapMaxY() - 1) * TILE_SIZE) {
 
						uint maxh = max<uint>(TileHeight(tile), 1);
 
						for (uint h = 0; h < maxh; h++) {
 
							DrawGroundSpriteAt(SPR_SHADOW_CELL, PAL_NONE, ti.x, ti.y, h * TILE_HEIGHT);
 
							AddTileSpriteToDraw(SPR_SHADOW_CELL, PAL_NONE, ti.x, ti.y, h * TILE_HEIGHT);
 
						}
 
					}
 

	
 
					ti.tile = tile;
 
					ti.tileh = GetTileSlope(tile, &ti.z);
 
					tt = GetTileType(tile);
src/viewport_func.h
Show inline comments
 
@@ -43,13 +43,13 @@ static inline void MaxZoomInOut(int how,
 
	while (DoZoomInOutWindow(how, w)) {};
 
}
 

	
 
void OffsetGroundSprite(int x, int y);
 

	
 
void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub = NULL, int extra_offs_x = 0, int extra_offs_y = 0);
 
void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub = NULL, int extra_offs_x = 0, int extra_offs_y = 0);
 
void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, int z, const SubSprite *sub = NULL, int extra_offs_x = 0, int extra_offs_y = 0);
 
void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, int dz, int z, bool transparent = false, int bb_offset_x = 0, int bb_offset_y = 0, int bb_offset_z = 0, const SubSprite *sub = NULL);
 
void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL);
 
void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const ViewportSign *sign, StringID string_normal, StringID string_small, StringID string_small_shadow, uint64 params_1, uint64 params_2 = 0, Colours colour = INVALID_COLOUR);
 

	
 

	
 
void StartSpriteCombine();
0 comments (0 inline, 0 general)