src/video/SDL_video.c
changeset 7452 fae80e5464e2
parent 7441 468877c2135a
child 7453 91c3bb321036
equal deleted inserted replaced
7451:2ce2d2c71156 7452:fae80e5464e2
  3055 int
  3055 int
  3056 SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
  3056 SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
  3057 {
  3057 {
  3058     int dummybutton;
  3058     int dummybutton;
  3059     int retval = -1;
  3059     int retval = -1;
  3060     SDL_bool relative_mode = SDL_GetRelativeMouseMode();
  3060     SDL_bool relative_mode;
  3061     int show_cursor_prev = SDL_ShowCursor( 1 );
  3061     int show_cursor_prev;
  3062 
  3062 
  3063     SDL_SetRelativeMouseMode( SDL_FALSE );
  3063     if (!messageboxdata) {
       
  3064         return SDL_InvalidParamError("messageboxdata");
       
  3065     }
       
  3066 
       
  3067     relative_mode = SDL_GetRelativeMouseMode();
       
  3068     SDL_SetRelativeMouseMode(SDL_FALSE);
       
  3069     show_cursor_prev = SDL_ShowCursor(1);
  3064 
  3070 
  3065     if (!buttonid) {
  3071     if (!buttonid) {
  3066         buttonid = &dummybutton;
  3072         buttonid = &dummybutton;
  3067     }
  3073     }
  3068     if (_this && _this->ShowMessageBox) {
  3074     if (_this && _this->ShowMessageBox) {
  3069         if (_this->ShowMessageBox(_this, messageboxdata, buttonid) == 0) {
  3075         retval = _this->ShowMessageBox(_this, messageboxdata, buttonid);
  3070             retval = 0;
  3076     } else {
  3071         }
  3077         /* It's completely fine to call this function before video is initialized */
  3072     }
  3078         if (messageboxdata->window == NULL) {
  3073 
       
  3074     /* It's completely fine to call this function before video is initialized */
       
  3075 #if SDL_VIDEO_DRIVER_WINDOWS
  3079 #if SDL_VIDEO_DRIVER_WINDOWS
  3076     if ((retval == -1) && (WIN_ShowMessageBox(messageboxdata, buttonid) == 0)) {
  3080             if ((retval == -1) && (WIN_ShowMessageBox(messageboxdata, buttonid) == 0)) {
  3077         retval = 0;
  3081                 retval = 0;
  3078     }
  3082             }
  3079 #endif
  3083 #endif
  3080 #if SDL_VIDEO_DRIVER_COCOA
  3084 #if SDL_VIDEO_DRIVER_COCOA
  3081     if ((retval == -1) && (Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0)) {
  3085             if ((retval == -1) && (Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0)) {
  3082         retval = 0;
  3086                 retval = 0;
  3083     }
  3087             }
  3084 #endif
  3088 #endif
  3085 #if SDL_VIDEO_DRIVER_UIKIT
  3089 #if SDL_VIDEO_DRIVER_UIKIT
  3086     if ((retval == -1) && (UIKit_ShowMessageBox(messageboxdata, buttonid) == 0)) {
  3090             if ((retval == -1) && (UIKit_ShowMessageBox(messageboxdata, buttonid) == 0)) {
  3087         retval = 0;
  3091                 retval = 0;
  3088     }
  3092             }
  3089 #endif
  3093 #endif
  3090 #if SDL_VIDEO_DRIVER_X11
  3094 #if SDL_VIDEO_DRIVER_X11
  3091     if ((retval == -1) && (X11_ShowMessageBox(messageboxdata, buttonid) == 0)) {
  3095             if ((retval == -1) && (X11_ShowMessageBox(messageboxdata, buttonid) == 0)) {
  3092         retval = 0;
  3096                 retval = 0;
  3093     }
  3097             }
  3094 #endif
  3098 #endif
  3095 
  3099         }
  3096     SDL_ShowCursor( show_cursor_prev );
  3100         if (retval == -1) {
  3097     SDL_SetRelativeMouseMode( relative_mode );
  3101             SDL_SetError("No message system available");
  3098 
  3102         }
  3099     if(retval == -1) {
  3103     }
  3100         SDL_SetError("No message system available");
  3104 
  3101     }
  3105     SDL_ShowCursor(show_cursor_prev);
       
  3106     SDL_SetRelativeMouseMode(relative_mode);
       
  3107 
  3102     return retval;
  3108     return retval;
  3103 }
  3109 }
  3104 
  3110 
  3105 int
  3111 int
  3106 SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window)
  3112 SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window)