File diff r27105:4235592d0ef1 → r27106:2d95beb51290
src/gfx.cpp
Show inline comments
 
@@ -74,7 +74,7 @@ int _gui_scale_cfg;                     
 
 */
 
static Rect _invalid_rect;
 
static const byte *_colour_remap_ptr;
 
static byte _string_colourremap[3]; ///< Recoloursprite for stringdrawing. The grf loader ensures that #ST_FONT sprites only use colours 0 to 2.
 
static byte _string_colourremap[3]; ///< Recoloursprite for stringdrawing. The grf loader ensures that #SpriteType::Font sprites only use colours 0 to 2.
 

	
 
static const uint DIRTY_BLOCK_HEIGHT   = 8;
 
static const uint DIRTY_BLOCK_WIDTH    = 64;
 
@@ -992,7 +992,7 @@ void DrawCharCentered(WChar c, const Rec
 
 */
 
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
 
{
 
	const Sprite *sprite = GetSprite(sprid, ST_NORMAL);
 
	const Sprite *sprite = GetSprite(sprid, SpriteType::Normal);
 

	
 
	if (offset != nullptr) {
 
		offset->x = UnScaleByZoom(sprite->x_offs, zoom);
 
@@ -1032,17 +1032,17 @@ void DrawSpriteViewport(SpriteID img, Pa
 
{
 
	SpriteID real_sprite = GB(img, 0, SPRITE_WIDTH);
 
	if (HasBit(img, PALETTE_MODIFIER_TRANSPARENT)) {
 
		_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
 
		GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, BM_TRANSPARENT, sub, real_sprite);
 
		_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
 
		GfxMainBlitterViewport(GetSprite(real_sprite, SpriteType::Normal), x, y, BM_TRANSPARENT, sub, real_sprite);
 
	} else if (pal != PAL_NONE) {
 
		if (HasBit(pal, PALETTE_TEXT_RECOLOUR)) {
 
			SetColourRemap((TextColour)GB(pal, 0, PALETTE_WIDTH));
 
		} else {
 
			_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
 
			_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
 
		}
 
		GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, GetBlitterMode(pal), sub, real_sprite);
 
		GfxMainBlitterViewport(GetSprite(real_sprite, SpriteType::Normal), x, y, GetBlitterMode(pal), sub, real_sprite);
 
	} else {
 
		GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite);
 
		GfxMainBlitterViewport(GetSprite(real_sprite, SpriteType::Normal), x, y, BM_NORMAL, sub, real_sprite);
 
	}
 
}
 

	
 
@@ -1059,17 +1059,17 @@ void DrawSprite(SpriteID img, PaletteID 
 
{
 
	SpriteID real_sprite = GB(img, 0, SPRITE_WIDTH);
 
	if (HasBit(img, PALETTE_MODIFIER_TRANSPARENT)) {
 
		_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
 
		GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, BM_TRANSPARENT, sub, real_sprite, zoom);
 
		_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
 
		GfxMainBlitter(GetSprite(real_sprite, SpriteType::Normal), x, y, BM_TRANSPARENT, sub, real_sprite, zoom);
 
	} else if (pal != PAL_NONE) {
 
		if (HasBit(pal, PALETTE_TEXT_RECOLOUR)) {
 
			SetColourRemap((TextColour)GB(pal, 0, PALETTE_WIDTH));
 
		} else {
 
			_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
 
			_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
 
		}
 
		GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, GetBlitterMode(pal), sub, real_sprite, zoom);
 
		GfxMainBlitter(GetSprite(real_sprite, SpriteType::Normal), x, y, GetBlitterMode(pal), sub, real_sprite, zoom);
 
	} else {
 
		GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite, zoom);
 
		GfxMainBlitter(GetSprite(real_sprite, SpriteType::Normal), x, y, BM_NORMAL, sub, real_sprite, zoom);
 
	}
 
}
 

	
 
@@ -1220,7 +1220,7 @@ std::unique_ptr<uint32[]> DrawSpriteToRg
 

	
 
	/* Gather information about the sprite to write, reserve memory */
 
	const SpriteID real_sprite = GB(spriteId, 0, SPRITE_WIDTH);
 
	const Sprite *sprite = GetSprite(real_sprite, ST_NORMAL);
 
	const Sprite *sprite = GetSprite(real_sprite, SpriteType::Normal);
 
	Dimension dim = GetSpriteSize(real_sprite, nullptr, zoom);
 
	size_t dim_size = static_cast<size_t>(dim.width) * dim.height;
 
	std::unique_ptr<uint32[]> result(new uint32[dim_size]);
 
@@ -1843,7 +1843,7 @@ void UpdateCursorSize()
 
	static_assert(lengthof(_cursor.sprite_seq) == lengthof(_cursor.sprite_pos));
 
	assert(_cursor.sprite_count <= lengthof(_cursor.sprite_seq));
 
	for (uint i = 0; i < _cursor.sprite_count; ++i) {
 
		const Sprite *p = GetSprite(GB(_cursor.sprite_seq[i].sprite, 0, SPRITE_WIDTH), ST_NORMAL);
 
		const Sprite *p = GetSprite(GB(_cursor.sprite_seq[i].sprite, 0, SPRITE_WIDTH), SpriteType::Normal);
 
		Point offs, size;
 
		offs.x = UnScaleGUI(p->x_offs) + _cursor.sprite_pos[i].x;
 
		offs.y = UnScaleGUI(p->y_offs) + _cursor.sprite_pos[i].y;