Changeset - r15707:d8c7fbf1db5d
[Not reviewed]
master
0 3 0
frosch - 14 years ago 2010-08-05 19:23:19
frosch@openttd.org
(svn r20384) -Fix: Update cursor dimensions when reloading grfs resp. changing base graphics, so the cursor does not glitch if it becomes bigger.
3 files changed with 36 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -1775,22 +1775,37 @@ bool FillDrawPixelInfo(DrawPixelInfo *n,
 
	return true;
 
}
 

	
 
static void SetCursorSprite(CursorID cursor, PaletteID pal)
 
/**
 
 * Update cursor dimension.
 
 * Called when changing cursor sprite resp. reloading grfs.
 
 */
 
void UpdateCursorSize()
 
{
 
	CursorVars *cv = &_cursor;
 
	const Sprite *p;
 

	
 
	if (cv->sprite == cursor) return;
 
	const Sprite *p = GetSprite(GB(cv->sprite, 0, SPRITE_WIDTH), ST_NORMAL);
 

	
 
	p = GetSprite(GB(cursor, 0, SPRITE_WIDTH), ST_NORMAL);
 
	cv->sprite = cursor;
 
	cv->pal    = pal;
 
	cv->size.y = p->height;
 
	cv->size.x = p->width;
 
	cv->offs.x = p->x_offs;
 
	cv->offs.y = p->y_offs;
 

	
 
	cv->dirty = true;
 
}
 

	
 
/**
 
 * Switch cursor to different sprite.
 
 * @param cursor Sprite to draw for the cursor.
 
 * @param pal Palette to use for recolouring.
 
 */
 
static void SetCursorSprite(CursorID cursor, PaletteID pal)
 
{
 
	CursorVars *cv = &_cursor;
 
	if (cv->sprite == cursor) return;
 

	
 
	cv->sprite = cursor;
 
	cv->pal    = pal;
 
	UpdateCursorSize();
 

	
 
	cv->short_vehicle_offset = 0;
 
}
 

	
 
@@ -1813,6 +1828,12 @@ void CursorTick()
 
	}
 
}
 

	
 
/**
 
 * Assign a single non-animated sprite to the cursor.
 
 * @param sprite Sprite to draw for the cursor.
 
 * @param pal Palette to use for recolouring.
 
 * @see SetAnimatedMouseCursor
 
 */
 
void SetMouseCursor(CursorID sprite, PaletteID pal)
 
{
 
	/* Turn off animation */
 
@@ -1821,6 +1842,11 @@ void SetMouseCursor(CursorID sprite, Pal
 
	SetCursorSprite(sprite, pal);
 
}
 

	
 
/**
 
 * Assign an animation to the cursor.
 
 * @param table Array of animation states.
 
 * @see SetMouseCursor
 
 */
 
void SetAnimatedMouseCursor(const AnimCursor *table)
 
{
 
	_cursor.animate_list = table;
src/gfx_func.h
Show inline comments
 
@@ -159,6 +159,7 @@ void DrawOverlappedWindowForAll(int left
 
void SetMouseCursor(CursorID cursor, PaletteID pal);
 
void SetAnimatedMouseCursor(const AnimCursor *table);
 
void CursorTick();
 
void UpdateCursorSize();
 
bool ChangeResInGame(int w, int h);
 
void SortResolutions(int count);
 
bool ToggleFullScreen(bool fs);
src/gfxinit.cpp
Show inline comments
 
@@ -207,6 +207,8 @@ void GfxLoadSprites()
 
	GfxInitSpriteMem();
 
	LoadSpriteTables();
 
	GfxInitPalettes();
 

	
 
	UpdateCursorSize();
 
}
 

	
 
bool GraphicsSet::FillSetDetails(IniFile *ini, const char *path, const char *full_filename)
0 comments (0 inline, 0 general)