From f143c6a42a94dde27d6769e6a6ee20016c4f908e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 25 Nov 2012 10:03:22 -0800 Subject: [PATCH] Don't run the game loop while a messagebox is up --- src/video/uikit/SDL_uikitmessagebox.h | 2 ++ src/video/uikit/SDL_uikitmessagebox.m | 10 ++++++++++ src/video/uikit/SDL_uikitopenglview.m | 12 ++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/video/uikit/SDL_uikitmessagebox.h b/src/video/uikit/SDL_uikitmessagebox.h index 2fd3fc145..8c61f790a 100644 --- a/src/video/uikit/SDL_uikitmessagebox.h +++ b/src/video/uikit/SDL_uikitmessagebox.h @@ -22,6 +22,8 @@ #if SDL_VIDEO_DRIVER_UIKIT +extern SDL_bool UIKit_ShowingMessageBox(); + extern int UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); #endif /* SDL_VIDEO_DRIVER_UIKIT */ diff --git a/src/video/uikit/SDL_uikitmessagebox.m b/src/video/uikit/SDL_uikitmessagebox.m index 6da90a176..9704b76a8 100644 --- a/src/video/uikit/SDL_uikitmessagebox.m +++ b/src/video/uikit/SDL_uikitmessagebox.m @@ -28,6 +28,7 @@ /* Display a UIKit message box */ +static SDL_bool s_showingMessageBox = SDL_FALSE; @interface UIKit_UIAlertViewDelegate : NSObject { @private @@ -60,6 +61,12 @@ - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger) @end // UIKit_UIAlertViewDelegate +SDL_bool +UIKit_ShowingMessageBox() +{ + return s_showingMessageBox; +} + int UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { @@ -86,9 +93,12 @@ - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger) // Run the main event loop until the alert has finished // Note that this needs to be done on the main thread + s_showingMessageBox = SDL_TRUE; while (clicked == messageboxdata->numbuttons) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; } + s_showingMessageBox = SDL_FALSE; + *buttonid = messageboxdata->buttons[clicked].buttonid; [pool release]; diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m index cef929646..afa4fe279 100644 --- a/src/video/uikit/SDL_uikitopenglview.m +++ b/src/video/uikit/SDL_uikitopenglview.m @@ -22,9 +22,10 @@ #if SDL_VIDEO_DRIVER_UIKIT -#import -#import -#import "SDL_uikitopenglview.h" +#include +#include +#include "SDL_uikitopenglview.h" +#include "SDL_uikitmessagebox.h" @implementation SDL_uikitopenglview @@ -180,7 +181,10 @@ - (void)stopAnimation - (void)doLoop:(id)sender { - animationCallback(animationCallbackParam); + // Don't run the game loop while a messagebox is up + if (!UIKit_ShowingMessageBox()) { + animationCallback(animationCallbackParam); + } } - (void)setCurrentContext