OpenXcom Forum

Contributions => Programming => Topic started by: sir_nacnud on October 20, 2010, 03:35:20 am

Title: Improved cursor drawing
Post by: sir_nacnud on October 20, 2010, 03:35:20 am
The cursor was being rendered to its own surface every time its position changed.  This is unnecessary as the appearance of the cursor doesn't change when it is moved.  The only times it changes are either when its color is changed or it's palette is changed.  The color change case was already accounted for.  I added code to re-rendering the cursor when its palette changed.  See attached patch.
Title: Re: Improved cursor drawing
Post by: SupSuper on October 22, 2010, 04:56:12 pm
Funny, I remember when I tried doing that it broke the cursor. Oh well, added.
Title: Re: Improved cursor drawing
Post by: sir_nacnud on October 23, 2010, 01:39:16 am
If you just remove the draw() call from Cursor::handle() it will break the cursor.  This is because the draw() call would now only happen when Cursor::setColor() was called.  Cursor::setColor() is called in the Game constructor.  At this point none of the game data is loaded, ie no palettes, so the cursor won't get rendered properly.  This is why I overrode setPalette() and added a draw() call to update the cursor when the palette was set.