fixed name of element 'polarisator' to 'polarizer'
[rocksndiamonds.git] / src / events.c
index 5dabff98e944b25fb815cf470f6e58c58b1011b2..7a3f9987d4b09a80ebdc48c970c8eb118f3b4727 100644 (file)
@@ -304,7 +304,8 @@ void HandleMouseCursor()
        cursor_inside_playfield &&
        DelayReached(&special_cursor_delay, special_cursor_delay_value))
     {
-      if (level.game_engine_type != GAME_ENGINE_TYPE_MM)
+      if (level.game_engine_type != GAME_ENGINE_TYPE_MM ||
+         tile_cursor.enabled)
        SetMouseCursor(CURSOR_PLAYFIELD);
     }
   }
@@ -400,6 +401,7 @@ void SetPlayerMouseAction(int mx, int my, int button)
 {
   int lx = getLevelFromScreenX(mx);
   int ly = getLevelFromScreenY(my);
+  int new_button = (!local_player->mouse_action.button && button);
 
   ClearPlayerMouseAction();
 
@@ -412,10 +414,12 @@ void SetPlayerMouseAction(int mx, int my, int button)
 
   if (tape.recording && tape.pausing && tape.use_mouse)
   {
-    /* prevent button release or motion events from un-pausing a paused game */
-    if (button && !motion_status)
-      TapeTogglePause(TAPE_TOGGLE_MANUAL);
+    /* un-pause a paused game only if mouse button was newly pressed down */
+    if (new_button)
+      TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
   }
+
+  SetTileCursorXY(lx, ly);
 }
 
 void SleepWhileUnmapped()
@@ -2242,6 +2246,8 @@ void HandleJoystick()
   static unsigned int joytest_delay = 0;
   static unsigned int joytest_delay_value = GADGET_FRAME_DELAY;
   static int joytest_last = 0;
+  int delay_value_first = GADGET_FRAME_DELAY_FIRST;
+  int delay_value       = GADGET_FRAME_DELAY;
   int joystick = HandleJoystickForAllPlayers();
   int keyboard = key_joystick_mapping;
   int joy      = (joystick | keyboard);
@@ -2254,6 +2260,7 @@ void HandleJoystick()
   int newbutton        = (AnyJoystickButton() == JOY_BUTTON_NEW_PRESSED);
   int dx       = (left ? -1    : right ? 1     : 0);
   int dy       = (up   ? -1    : down  ? 1     : 0);
+  boolean use_delay_value_first = (joytest != joytest_last);
 
   if (HandleGlobalAnimClicks(-1, -1, newbutton))
   {
@@ -2263,10 +2270,18 @@ void HandleJoystick()
 
   if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
   {
-    // when playing MM style levels, also use delay for keyboard events
     if (game_status == GAME_MODE_PLAYING)
+    {
+      // when playing MM style levels, also use delay for keyboard events
       joytest |= keyboard;
 
+      // only use first delay value for new events, but not for changed events
+      use_delay_value_first = (!joytest != !joytest_last);
+
+      // only use delay after the initial keyboard event
+      delay_value = 0;
+    }
+
     // for any joystick or keyboard event, enable playfield tile cursor
     if (dx || dy || button)
       SetTileCursorEnabled(TRUE);
@@ -2281,7 +2296,7 @@ void HandleJoystick()
   {
     /* first start with longer delay, then continue with shorter delay */
     joytest_delay_value =
-      (joytest != joytest_last ? GADGET_FRAME_DELAY_FIRST : GADGET_FRAME_DELAY);
+      (use_delay_value_first ? delay_value_first : delay_value);
   }
 
   joytest_last = joytest;
@@ -2328,7 +2343,12 @@ void HandleJoystick()
        return;
       }
 
-      if (tape.recording && tape.pausing && !tape.use_mouse)
+      if (tape.single_step && tape.recording && tape.pausing && !tape.use_mouse)
+      {
+       if (joystick & JOY_ACTION)
+         TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+      }
+      else if (tape.recording && tape.pausing && !tape.use_mouse)
       {
        if (joystick & JOY_ACTION)
          TapeTogglePause(TAPE_TOGGLE_MANUAL);