Don't run the game loop while a messagebox is up
authorSam Lantinga <slouken@libsdl.org>
Sun, 25 Nov 2012 10:03:22 -0800
changeset 668645014250760c
parent 6685 8faee8f46165
child 6687 d229ad942c89
Don't run the game loop while a messagebox is up
src/video/uikit/SDL_uikitmessagebox.h
src/video/uikit/SDL_uikitmessagebox.m
src/video/uikit/SDL_uikitopenglview.m
     1.1 --- a/src/video/uikit/SDL_uikitmessagebox.h	Mon Jul 23 00:14:07 2012 -0400
     1.2 +++ b/src/video/uikit/SDL_uikitmessagebox.h	Sun Nov 25 10:03:22 2012 -0800
     1.3 @@ -22,6 +22,8 @@
     1.4  
     1.5  #if SDL_VIDEO_DRIVER_UIKIT
     1.6  
     1.7 +extern SDL_bool UIKit_ShowingMessageBox();
     1.8 +
     1.9  extern int UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
    1.10  
    1.11  #endif /* SDL_VIDEO_DRIVER_UIKIT */
     2.1 --- a/src/video/uikit/SDL_uikitmessagebox.m	Mon Jul 23 00:14:07 2012 -0400
     2.2 +++ b/src/video/uikit/SDL_uikitmessagebox.m	Sun Nov 25 10:03:22 2012 -0800
     2.3 @@ -28,6 +28,7 @@
     2.4  
     2.5  /* Display a UIKit message box */
     2.6  
     2.7 +static SDL_bool s_showingMessageBox = SDL_FALSE;
     2.8  
     2.9  @interface UIKit_UIAlertViewDelegate : NSObject <UIAlertViewDelegate> {
    2.10  @private
    2.11 @@ -60,6 +61,12 @@
    2.12  @end // UIKit_UIAlertViewDelegate
    2.13  
    2.14  
    2.15 +SDL_bool
    2.16 +UIKit_ShowingMessageBox()
    2.17 +{
    2.18 +    return s_showingMessageBox;
    2.19 +}
    2.20 +
    2.21  int
    2.22  UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
    2.23  {
    2.24 @@ -86,9 +93,12 @@
    2.25      
    2.26      // Run the main event loop until the alert has finished
    2.27      // Note that this needs to be done on the main thread
    2.28 +    s_showingMessageBox = SDL_TRUE;
    2.29      while (clicked == messageboxdata->numbuttons) {
    2.30          [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
    2.31      }
    2.32 +    s_showingMessageBox = SDL_FALSE;
    2.33 +
    2.34      *buttonid = messageboxdata->buttons[clicked].buttonid;
    2.35  
    2.36      [pool release];
     3.1 --- a/src/video/uikit/SDL_uikitopenglview.m	Mon Jul 23 00:14:07 2012 -0400
     3.2 +++ b/src/video/uikit/SDL_uikitopenglview.m	Sun Nov 25 10:03:22 2012 -0800
     3.3 @@ -22,9 +22,10 @@
     3.4  
     3.5  #if SDL_VIDEO_DRIVER_UIKIT
     3.6  
     3.7 -#import <QuartzCore/QuartzCore.h>
     3.8 -#import <OpenGLES/EAGLDrawable.h>
     3.9 -#import "SDL_uikitopenglview.h"
    3.10 +#include <QuartzCore/QuartzCore.h>
    3.11 +#include <OpenGLES/EAGLDrawable.h>
    3.12 +#include "SDL_uikitopenglview.h"
    3.13 +#include "SDL_uikitmessagebox.h"
    3.14  
    3.15  
    3.16  @implementation SDL_uikitopenglview
    3.17 @@ -180,7 +181,10 @@
    3.18  
    3.19  - (void)doLoop:(id)sender
    3.20  {
    3.21 -    animationCallback(animationCallbackParam);
    3.22 +    // Don't run the game loop while a messagebox is up
    3.23 +    if (!UIKit_ShowingMessageBox()) {
    3.24 +        animationCallback(animationCallbackParam);
    3.25 +    }
    3.26  }
    3.27  
    3.28  - (void)setCurrentContext