added showing mouse cursor for levels with mouse click custom elements
authorHolger Schemel <info@artsoft.org>
Fri, 15 Oct 2021 11:28:11 +0000 (13:28 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 22 Jan 2022 16:58:27 +0000 (17:58 +0100)
src/events.c
src/events.h
src/game.c

index 13723bfa514da9ff8f78e499946907ad7d4729bd..4a1ecbfee9df368244a8d26d596c7b677fcce925 100644 (file)
@@ -38,6 +38,7 @@ static boolean cursor_inside_playfield = FALSE;
 static int cursor_mode_last = CURSOR_DEFAULT;
 static unsigned int special_cursor_delay = 0;
 static unsigned int special_cursor_delay_value = 1000;
 static int cursor_mode_last = CURSOR_DEFAULT;
 static unsigned int special_cursor_delay = 0;
 static unsigned int special_cursor_delay_value = 1000;
+static boolean special_cursor_enabled = FALSE;
 
 static boolean stop_processing_events = FALSE;
 
 
 static boolean stop_processing_events = FALSE;
 
@@ -48,6 +49,11 @@ static void HandleNoEvent(void);
 static void HandleEventActions(void);
 
 
 static void HandleEventActions(void);
 
 
+void SetPlayfieldMouseCursorEnabled(boolean enabled)
+{
+  special_cursor_enabled = enabled;
+}
+
 // event filter to set mouse x/y position (for pointer class global animations)
 // (this is especially required to ensure smooth global animation mouse pointer
 // movement when the screen is updated without handling events; this can happen
 // event filter to set mouse x/y position (for pointer class global animations)
 // (this is especially required to ensure smooth global animation mouse pointer
 // movement when the screen is updated without handling events; this can happen
@@ -340,11 +346,10 @@ static void HandleMouseCursor(void)
 
     if (gfx.cursor_mode != CURSOR_PLAYFIELD &&
        cursor_inside_playfield &&
 
     if (gfx.cursor_mode != CURSOR_PLAYFIELD &&
        cursor_inside_playfield &&
+       special_cursor_enabled &&
        DelayReached(&special_cursor_delay, special_cursor_delay_value))
     {
        DelayReached(&special_cursor_delay, special_cursor_delay_value))
     {
-      if (level.game_engine_type != GAME_ENGINE_TYPE_MM ||
-         tile_cursor.enabled)
-       SetMouseCursor(CURSOR_PLAYFIELD);
+      SetMouseCursor(CURSOR_PLAYFIELD);
     }
   }
   else if (gfx.cursor_mode != CURSOR_DEFAULT)
     }
   }
   else if (gfx.cursor_mode != CURSOR_DEFAULT)
@@ -524,6 +529,10 @@ void HandleButtonEvent(ButtonEvent *event)
   // for any mouse button event, disable playfield tile cursor
   SetTileCursorEnabled(FALSE);
 
   // for any mouse button event, disable playfield tile cursor
   SetTileCursorEnabled(FALSE);
 
+  // for any mouse button event, disable playfield mouse cursor
+  if (cursor_inside_playfield)
+    SetPlayfieldMouseCursorEnabled(FALSE);
+
 #if defined(HAS_SCREEN_KEYBOARD)
   if (video.shifted_up)
     event->y += video.shifted_up_pos;
 #if defined(HAS_SCREEN_KEYBOARD)
   if (video.shifted_up)
     event->y += video.shifted_up_pos;
@@ -2156,6 +2165,10 @@ void HandleKey(Key key, int key_status)
       // for MM style levels, handle in-game keyboard input in HandleJoystick()
       if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
        joy |= key_action;
       // for MM style levels, handle in-game keyboard input in HandleJoystick()
       if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
        joy |= key_action;
+
+      // for any keyboard event, enable playfield mouse cursor
+      if (key_action && key_status == KEY_PRESSED)
+       SetPlayfieldMouseCursorEnabled(TRUE);
     }
   }
   else
     }
   }
   else
@@ -2599,6 +2612,10 @@ void HandleJoystick(void)
       SetTileCursorEnabled(TRUE);
   }
 
       SetTileCursorEnabled(TRUE);
   }
 
+  // for any joystick event, enable playfield mouse cursor
+  if (dx || dy || button)
+    SetPlayfieldMouseCursorEnabled(TRUE);
+
   if (joytest && !button && !DelayReached(&joytest_delay, joytest_delay_value))
   {
     // delay joystick/keyboard actions if axes/keys continually pressed
   if (joytest && !button && !DelayReached(&joytest_delay, joytest_delay_value))
   {
     // delay joystick/keyboard actions if axes/keys continually pressed
index 30a64877dc3b5a4411b5ceb7c2caa4ae60e1dd87..3887f3fdb5d1b4346fb13cb913d90ac325d94fc3 100644 (file)
@@ -21,6 +21,8 @@
 #define USEREVENT_GADGET_PRESSED       3
 
 
 #define USEREVENT_GADGET_PRESSED       3
 
 
+void SetPlayfieldMouseCursorEnabled(boolean);
+
 int FilterMouseMotionEvents(void *, Event *);
 boolean NextValidEvent(Event *);
 void StopProcessingEvents(void);
 int FilterMouseMotionEvents(void *, Event *);
 boolean NextValidEvent(Event *);
 void StopProcessingEvents(void);
index efc81e4e56214c58ac33a36004e828df3303d4e9..550c76e5fd5ef3b715cd47c1c0fa46b1d8b65f37 100644 (file)
@@ -4479,6 +4479,8 @@ void InitGame(void)
     if (setup.sound_music)
       PlayLevelMusic();
   }
     if (setup.sound_music)
       PlayLevelMusic();
   }
+
+  SetPlayfieldMouseCursorEnabled(!game.use_mouse_actions);
 }
 
 void UpdateEngineValues(int actual_scroll_x, int actual_scroll_y,
 }
 
 void UpdateEngineValues(int actual_scroll_x, int actual_scroll_y,