Add a function to use b&w cursor...
...when the display is too busy to draw colour ones (b&w it's better than invisible or freeze cursor). Must be call before doing heavy stuff, but already works for the starting screen.
This commit is contained in:
parent
acc0069d5b
commit
b85798ea5c
2 changed files with 19 additions and 1 deletions
|
@ -103,6 +103,7 @@ int cursor_x = -1, cursor_y = -1;
|
|||
surface cursor_buf = NULL;
|
||||
bool have_focus = true;
|
||||
bool hide_bw = false;
|
||||
bool colour_ready = false;
|
||||
|
||||
SDL_Cursor* get_cursor(cursor::CURSOR_TYPE type)
|
||||
{
|
||||
|
@ -156,6 +157,12 @@ void use_colour(bool value)
|
|||
}
|
||||
}
|
||||
|
||||
void temporary_use_bw()
|
||||
{
|
||||
colour_ready = false;
|
||||
set(current_cursor);
|
||||
}
|
||||
|
||||
void set(CURSOR_TYPE type)
|
||||
{
|
||||
current_cursor = type;
|
||||
|
@ -163,7 +170,7 @@ void set(CURSOR_TYPE type)
|
|||
if(type == NUM_CURSORS) {
|
||||
return;
|
||||
}
|
||||
SDL_Cursor* cursor = get_cursor(hide_bw ? cursor::NO_CURSOR : type);
|
||||
SDL_Cursor* cursor = get_cursor(hide_bw && colour_ready ? cursor::NO_CURSOR : type);
|
||||
if (cursor != NULL) {
|
||||
SDL_SetCursor(cursor);
|
||||
}
|
||||
|
@ -209,6 +216,14 @@ void draw(surface screen)
|
|||
if(use_colour_cursors() == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!colour_ready) {
|
||||
// display start to draw cursor
|
||||
// so it can now display colour cursor
|
||||
colour_ready = true;
|
||||
// just reset the cursor will hide the b&w
|
||||
set(current_cursor);
|
||||
}
|
||||
|
||||
if(current_cursor == NUM_CURSORS) {
|
||||
return;
|
||||
|
|
|
@ -29,6 +29,9 @@ struct manager
|
|||
enum CURSOR_TYPE { NORMAL, WAIT, MOVE, ATTACK, HYPERLINK, MOVE_DRAG, ATTACK_DRAG, NO_CURSOR, NUM_CURSORS };
|
||||
|
||||
void use_colour(bool value);
|
||||
// This function use temporary the b&w cursors while the display is busy
|
||||
// If used, the colours ones will be reused when display is ready again
|
||||
void temporary_use_bw();
|
||||
|
||||
void set(CURSOR_TYPE type);
|
||||
void set_dragging(bool drag);
|
||||
|
|
Loading…
Add table
Reference in a new issue