Don't disable b&w cursor when using colored cursors,

...just use a transparent one (SDL seems to have mouse problems when
hiding the cursor in fullscreen). And we now don't update the b&w
cursors when unused.
This commit is contained in:
Ali El Gariani 2007-04-02 19:46:32 +00:00
parent d497cfa973
commit 2c790e6d4f
3 changed files with 22 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

View file

@ -85,13 +85,13 @@ SDL_Cursor* create_cursor(surface surf)
return SDL_CreateCursor(&data[0],&mask[0],cursor_width,nsurf->h,0,0);
}
SDL_Cursor* cache[cursor::NUM_CURSORS] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
SDL_Cursor* cache[cursor::NUM_CURSORS] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
//this array must have members corresponding to cursor::CURSOR_TYPE enum members
#ifdef __APPLE__
const std::string images[cursor::NUM_CURSORS] = { "normal.png", "wait-alt.png", "move.png", "attack.png", "select.png", "move_drag_alt.png" , "attack_drag_alt.png" };
const std::string images[cursor::NUM_CURSORS] = { "normal.png", "wait-alt.png", "move.png", "attack.png", "select.png", "move_drag_alt.png" , "attack_drag_alt.png", "no_cursor.png"};
#else
const std::string images[cursor::NUM_CURSORS] = { "normal.png", "wait.png", "move.png", "attack.png", "select.png", "move_drag.png", "attack_drag.png" };
const std::string images[cursor::NUM_CURSORS] = { "normal.png", "wait.png", "move.png", "attack.png", "select.png", "move_drag.png", "attack_drag.png", "no_cursor.png"};
#endif
cursor::CURSOR_TYPE current_cursor = cursor::NUM_CURSORS;
@ -141,10 +141,19 @@ manager::~manager()
SDL_ShowCursor(SDL_ENABLE);
}
// Use a transparent cursor to hide it
void hide_cursor()
{
SDL_Cursor* const cursor = get_cursor(cursor::NO_CURSOR);
SDL_SetCursor(cursor);
}
void use_colour(bool value)
{
// NOTE: Disable the cursor seems to cause slow mouse in fullscreen.
if(game_config::editor == false) {
SDL_ShowCursor(value ? SDL_DISABLE : SDL_ENABLE);
//SDL_ShowCursor(value ? SDL_DISABLE : SDL_ENABLE);
value ? hide_cursor() : set(current_cursor);
}
}
@ -155,11 +164,15 @@ void set(CURSOR_TYPE type)
if(type == NUM_CURSORS) {
return;
}
SDL_Cursor* const cursor = get_cursor(type);
if(cursor != NULL) {
SDL_SetCursor(cursor);
if (use_colour_cursors()) {
hide_cursor();
} else {
SDL_Cursor* const cursor = get_cursor(type);
if(cursor != NULL) {
SDL_SetCursor(cursor);
}
}
}
void set_focus(bool focus)

View file

@ -26,7 +26,7 @@ struct manager
~manager();
};
enum CURSOR_TYPE { NORMAL, WAIT, MOVE, ATTACK, HYPERLINK, MOVE_DRAG, ATTACK_DRAG, NUM_CURSORS };
enum CURSOR_TYPE { NORMAL, WAIT, MOVE, ATTACK, HYPERLINK, MOVE_DRAG, ATTACK_DRAG, NO_CURSOR, NUM_CURSORS };
void use_colour(bool value);