Author Topic: Improved cursor drawing  (Read 6537 times)

Offline sir_nacnud

  • Captain
  • ***
  • Posts: 54
    • View Profile
Improved cursor drawing
« 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.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: Improved cursor drawing
« Reply #1 on: October 22, 2010, 04:56:12 pm »
Funny, I remember when I tried doing that it broke the cursor. Oh well, added.

Offline sir_nacnud

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Improved cursor drawing
« Reply #2 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.