21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_UIKIT 34 UIKit_ShowingMessageBox(
void)
36 return s_showingMessageBox;
40 UIKit_WaitUntilMessageBoxClosed(
const SDL_MessageBoxData *messageboxdata,
int *clickedindex)
48 while ((*clickedindex) == messageboxdata->
numbuttons) {
49 [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
56 UIKit_ShowMessageBoxAlertController(
const SDL_MessageBoxData *messageboxdata,
int *buttonid)
60 int __block clickedindex = messageboxdata->
numbuttons;
63 UIWindow *alertwindow = nil;
65 if (![UIAlertController
class]) {
69 UIAlertController *alert;
70 alert = [UIAlertController alertControllerWithTitle:@(messageboxdata->title)
71 message:@(messageboxdata->message)
72 preferredStyle:UIAlertControllerStyleAlert];
74 for (i = 0; i < messageboxdata->
numbuttons; i++) {
75 UIAlertAction *action;
76 UIAlertActionStyle style = UIAlertActionStyleDefault;
79 style = UIAlertActionStyleCancel;
82 action = [UIAlertAction actionWithTitle:@(buttons[i].text)
84 handler:^(UIAlertAction *action) {
87 [alert addAction:action];
90 if (messageboxdata->
window) {
91 SDL_WindowData *data = (__bridge SDL_WindowData *) messageboxdata->window->driverdata;
92 window = data.uiwindow;
95 if (window == nil || window.rootViewController == nil) {
96 alertwindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
97 alertwindow.rootViewController = [UIViewController new];
98 alertwindow.windowLevel = UIWindowLevelAlert;
100 window = alertwindow;
102 [alertwindow makeKeyAndVisible];
105 [window.rootViewController presentViewController:alert animated:YES completion:nil];
106 UIKit_WaitUntilMessageBoxClosed(messageboxdata, &clickedindex);
109 alertwindow.hidden = YES;
118 [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfHomeIndicatorAutoHidden) withObject:nil waitUntilDone:NO];
119 [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfScreenEdgesDeferringSystemGestures) withObject:nil waitUntilDone:NO];
132 #if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000 133 @interface SDLAlertViewDelegate : NSObject <UIAlertViewDelegate>
135 @property (nonatomic, assign)
int *clickedIndex;
139 @implementation SDLAlertViewDelegate
141 - (
void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
143 if (_clickedIndex !=
NULL) {
144 *_clickedIndex = (int) buttonIndex;
152 UIKit_ShowMessageBoxAlertView(
const SDL_MessageBoxData *messageboxdata,
int *buttonid)
155 #if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000 157 int clickedindex = messageboxdata->
numbuttons;
159 UIAlertView *alert = [[UIAlertView alloc] init];
160 SDLAlertViewDelegate *delegate = [[SDLAlertViewDelegate alloc] init];
162 alert.delegate = delegate;
163 alert.title = @(messageboxdata->
title);
164 alert.message = @(messageboxdata->
message);
166 for (i = 0; i < messageboxdata->
numbuttons; i++) {
167 [alert addButtonWithTitle:@(buttons[i].text)];
170 delegate.clickedIndex = &clickedindex;
174 UIKit_WaitUntilMessageBoxClosed(messageboxdata, &clickedindex);
176 alert.delegate = nil;
191 success = UIKit_ShowMessageBoxAlertController(messageboxdata, buttonid);
193 success = UIKit_ShowMessageBoxAlertView(messageboxdata, buttonid);
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
SDL_Window * SDL_GetFocusWindow(void)
const SDL_MessageBoxButtonData * buttons
MessageBox structure containing title, text, window, etc.
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
EGLSurface EGLNativeWindowType * window
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
The type used to identify a window.