removed unnecessary screen redraws when waiting for events to continue
[rocksndiamonds.git] / src / tools.c
index a4199a14600fb5083b61ed92e6a45debb1beb0b9..af239591b40067a32c8fdd39cb0a1ae5ac229f6c 100644 (file)
@@ -1337,6 +1337,9 @@ static void RedrawGlobalBorderIfNeeded(void)
 
 #if ONLY_REDRAW_GLOBAL_BORDER_IF_NEEDED
   if (CheckIfGlobalBorderRedrawIsNeeded())
+#else
+  // determine and store new global border bitmap for current game status
+  global_border_bitmap = getGlobalBorderBitmapFromStatus(game_status);
 #endif
   {
     // redraw global screen border (or clear, if defined to be empty)
@@ -4193,6 +4196,7 @@ void DrawPlayerField(int x, int y)
 
 void WaitForEventToContinue(void)
 {
+  boolean first_wait = TRUE;
   boolean still_wait = TRUE;
 
   if (program.headless)
@@ -4205,6 +4209,7 @@ void WaitForEventToContinue(void)
   button_status = MB_RELEASED;
 
   ClearEventQueue();
+  ClearPlayerAction();
 
   while (still_wait)
   {
@@ -4214,17 +4219,22 @@ void WaitForEventToContinue(void)
     {
       switch (event.type)
       {
-       case EVENT_BUTTONRELEASE:
+       case EVENT_BUTTONPRESS:
+        case EVENT_FINGERPRESS:
+         first_wait = FALSE;
+         break;
+
+        case EVENT_BUTTONRELEASE:
+        case EVENT_FINGERRELEASE:
+         still_wait = first_wait;
+         break;
+
        case EVENT_KEYPRESS:
         case SDL_CONTROLLERBUTTONDOWN:
         case SDL_JOYBUTTONDOWN:
          still_wait = FALSE;
          break;
 
-       case EVENT_KEYRELEASE:
-         ClearPlayerAction();
-         break;
-
        default:
          HandleOtherEvents(&event);
          break;
@@ -4235,7 +4245,8 @@ void WaitForEventToContinue(void)
       still_wait = FALSE;
     }
 
-    BackToFront();
+    if (!PendingEvent())
+      BackToFront();
   }
 }
 
@@ -4447,6 +4458,7 @@ static int RequestHandleEvents(unsigned int req_state)
            break;
          }
 
+         case EVENT_FINGERRELEASE:
          case EVENT_KEYRELEASE:
            ClearPlayerAction();
            break;