From 7b3e068e43bcfeb38ce390d5d1c3b1a13c81cb55 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 2 Mar 2015 21:33:17 +0100 Subject: [PATCH] changed mouse cursor on title screens not being always invisible --- ChangeLog | 6 ++++++ src/events.c | 46 +++++++++++++++++++++++++++++++------------- src/init.c | 1 + src/libgame/system.c | 7 +++++++ src/libgame/system.h | 3 +++ 5 files changed, 50 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index c91f0820..d0f69ab6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-03-02 + * added classic graphics, sounds and music to git repository + * added classic level sets to git repository + * added element description files to git repository + * changed mouse cursor on title screens not being always invisible + 2015-02-27 * fixed using "background.TOOLBOX", which was simply ignored before diff --git a/src/events.c b/src/events.c index f89e5236..7a366aa7 100644 --- a/src/events.c +++ b/src/events.c @@ -33,9 +33,9 @@ static boolean cursor_inside_playfield = FALSE; -static boolean playfield_cursor_set = FALSE; -static unsigned int playfield_cursor_delay = 0; - +static int cursor_mode_last = CURSOR_DEFAULT; +static unsigned int special_cursor_delay = 0; +static unsigned int special_cursor_delay_value = 1000; /* event filter especially needed for SDL event filtering due to delay problems with lots of mouse motion events when mouse button @@ -64,11 +64,18 @@ static int FilterEventsExt(const Event *event) cursor_inside_playfield = (motion->x >= SX && motion->x < SX + SXSIZE && motion->y >= SY && motion->y < SY + SYSIZE); - if (game_status == GAME_MODE_PLAYING && playfield_cursor_set) + /* do no reset mouse cursor before all pending events have been processed */ + if (gfx.cursor_mode == cursor_mode_last && + ((effectiveGameStatus() == GAME_MODE_TITLE && + gfx.cursor_mode == CURSOR_NONE) || + (game_status == GAME_MODE_PLAYING && + gfx.cursor_mode == CURSOR_PLAYFIELD))) { SetMouseCursor(CURSOR_DEFAULT); - playfield_cursor_set = FALSE; - DelayReached(&playfield_cursor_delay, 0); + + DelayReached(&special_cursor_delay, 0); + + cursor_mode_last = CURSOR_DEFAULT; } /* skip mouse motion events without pressed button outside level editor */ @@ -202,21 +209,34 @@ void EventLoop(void) } else { - /* when playing, display a special mouse pointer inside the playfield */ - if (game_status == GAME_MODE_PLAYING && !tape.pausing) + if (effectiveGameStatus() == GAME_MODE_TITLE) + { + /* when showing title screens, hide mouse pointer (if not moved) */ + + if (gfx.cursor_mode != CURSOR_NONE && + DelayReached(&special_cursor_delay, special_cursor_delay_value)) + { + SetMouseCursor(CURSOR_NONE); + } + } + else if (game_status == GAME_MODE_PLAYING && !tape.pausing) { - if (!playfield_cursor_set && cursor_inside_playfield && - DelayReached(&playfield_cursor_delay, 1000)) + /* when playing, display a special mouse pointer inside the playfield */ + + if (gfx.cursor_mode != CURSOR_PLAYFIELD && + cursor_inside_playfield && + DelayReached(&special_cursor_delay, special_cursor_delay_value)) { SetMouseCursor(CURSOR_PLAYFIELD); - playfield_cursor_set = TRUE; } } - else if (playfield_cursor_set) + else if (gfx.cursor_mode != CURSOR_DEFAULT) { SetMouseCursor(CURSOR_DEFAULT); - playfield_cursor_set = FALSE; } + + /* this is set after all pending events have been processed */ + cursor_mode_last = gfx.cursor_mode; } /* also execute after pending events have been processed before */ diff --git a/src/init.c b/src/init.c index 38dd52b6..25e8c07a 100644 --- a/src/init.c +++ b/src/init.c @@ -5075,6 +5075,7 @@ void InitGfx() InitGfxBuffers(); InitGfxCustomArtworkInfo(); + InitGfxOtherSettings(); bitmap_font_initial = LoadCustomImage(filename_font_initial); diff --git a/src/libgame/system.c b/src/libgame/system.c index eec5d192..f45e87e8 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -247,6 +247,11 @@ void InitGfxCustomArtworkInfo() gfx.draw_init_text = TRUE; } +void InitGfxOtherSettings() +{ + gfx.cursor_mode = CURSOR_DEFAULT; +} + void SetDrawDeactivationMask(int draw_deactivation_mask) { gfx.draw_deactivation_mask = draw_deactivation_mask; @@ -1262,6 +1267,8 @@ void SetMouseCursor(int mode) mode == CURSOR_PLAYFIELD ? cursor_playfield : NULL); SDLSetMouseCursor(cursor_new); + + gfx.cursor_mode = mode; } diff --git a/src/libgame/system.h b/src/libgame/system.h index d5027aec..bb78fbe9 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -813,6 +813,8 @@ struct GfxInfo int anim_random_frame; void (*draw_busy_anim_function)(void); + + int cursor_mode; }; struct JoystickInfo @@ -1283,6 +1285,7 @@ void InitGfxScrollbufferInfo(int, int); void InitGfxClipRegion(boolean, int, int, int, int); void InitGfxDrawBusyAnimFunction(void (*draw_busy_anim_function)(void)); void InitGfxCustomArtworkInfo(); +void InitGfxOtherSettings(); void SetDrawDeactivationMask(int); void SetDrawBackgroundMask(int); void SetWindowBackgroundBitmap(Bitmap *); -- 2.34.1