Don't ask SDL to reload the same b&w cursor.

This commit is contained in:
Ali El Gariani 2007-04-05 22:35:33 +00:00
parent ca5c16c0d8
commit 3be8b5ad6e

View file

@ -96,8 +96,10 @@ const std::string bw_images[cursor::NUM_CURSORS] = { "normal.png", "wait.png", "
const std::string colour_images[cursor::NUM_CURSORS] = { "normal.png", "wait.png", "move.png", "attack.png", "select.png", "move_drag.png", "attack_drag.png", "no_cursor.png"};
// The cursor wanted
cursor::CURSOR_TYPE current_cursor = cursor::NUM_CURSORS;
// The cursor used by SDL
cursor::CURSOR_TYPE current_SDL_cursor = cursor::NUM_CURSORS;
int cursor_x = -1, cursor_y = -1;
surface cursor_buf = NULL;
@ -170,9 +172,13 @@ void set(CURSOR_TYPE type)
if(type == NUM_CURSORS) {
return;
}
SDL_Cursor* cursor = get_cursor(hide_bw && colour_ready ? cursor::NO_CURSOR : type);
if (cursor != NULL) {
SDL_SetCursor(cursor);
const CURSOR_TYPE new_cursor = hide_bw && colour_ready ? cursor::NO_CURSOR : type;
if (new_cursor != current_SDL_cursor) {
SDL_Cursor * cursor_image = get_cursor(new_cursor);
if (cursor_image != NULL) {
SDL_SetCursor(cursor_image);
current_SDL_cursor = new_cursor;
}
}
}