--- hatari/src/gui-sdl/dlgAlert.c 2019/04/01 07:13:51 1.1.1.4 +++ hatari/src/gui-sdl/dlgAlert.c 2019/04/09 08:55:56 1.1.1.11 @@ -16,7 +16,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License (gpl.txt) for more details. */ -const char DlgAlert_rcsid[] = "Hatari $Id: dlgAlert.c,v 1.1.1.4 2019/04/01 07:13:51 root Exp $"; +const char DlgAlert_fileid[] = "Hatari dlgAlert.c : " __DATE__ " " __TIME__; #include @@ -32,11 +32,8 @@ static char dlglines[MAX_LINES][50+1]; #ifdef ALERT_HOOKS // The alert hook functions - extern int HookedAlertNotice(const char* szMessage); // Must return TRUE if OK clicked, FALSE otherwise - extern int HookedAlertQuery(const char* szMessage); // Must return TRUE if OK clicked, FALSE otherwise - - // Runtime switch to activate/deactivate alert hooks - BOOL useAlertHooks = FALSE; + extern int HookedAlertNotice(const char* szMessage); // Must return true if OK clicked, false otherwise + extern int HookedAlertQuery(const char* szMessage); // Must return true if OK clicked, false otherwise #endif #define DLGALERT_OK 5 @@ -57,11 +54,11 @@ static SGOBJ alertdlg[] = /*-----------------------------------------------------------------------*/ -/* - Breaks long string to several strings of max_width, divided by '\0', - sets text_width to the longest line width and returns the number of lines - you need to display the strings. -*/ +/** + * Breaks long string to several strings of max_width, divided by '\0', + * sets text_width to the longest line width and returns the number of lines + * you need to display the strings. + */ static int DlgAlert_FormatTextToBox(char *text, int max_width, int *text_width) { int columns = 0; @@ -122,18 +119,22 @@ static int DlgAlert_FormatTextToBox(char /*-----------------------------------------------------------------------*/ -/* - Show the "alert" dialog. Return TRUE if user pressed "OK". -*/ +/** + * Show the "alert" dialog. Return true if user pressed "OK". + */ static int DlgAlert_ShowDlg(const char *text) { static int maxlen = sizeof(dlglines[0])-1; char *t = (char *)malloc(strlen(text)+1); char *orig_t = t; int lines, i, len, offset; - BOOL bOldMouseVisibility; + bool bOldMouseVisibility; int nOldMouseX, nOldMouseY; +#if WITH_SDL2 + bool bOldMouseMode = SDL_GetRelativeMouseMode(); + SDL_SetRelativeMouseMode(SDL_FALSE); +#endif strcpy(t, text); lines = DlgAlert_FormatTextToBox(t, maxlen, &len); offset = (maxlen-len)/2; @@ -156,41 +157,45 @@ static int DlgAlert_ShowDlg(const char * free(orig_t); if (SDLGui_SetScreen(sdlscrn)) - return FALSE; + return false; SDLGui_CenterDlg(alertdlg); SDL_GetMouseState(&nOldMouseX, &nOldMouseY); bOldMouseVisibility = SDL_ShowCursor(SDL_QUERY); SDL_ShowCursor(SDL_ENABLE); - i = SDLGui_DoDialog(alertdlg, NULL); + i = SDLGui_DoDialog(alertdlg, NULL, false); SDL_UpdateRect(sdlscrn, 0,0, 0,0); SDL_ShowCursor(bOldMouseVisibility); - Main_WarpMouse(nOldMouseX, nOldMouseY); + Main_WarpMouse(nOldMouseX, nOldMouseY, true); + +#if WITH_SDL2 + SDL_SetRelativeMouseMode(bOldMouseMode); +#endif return (i == DLGALERT_OK); } /*-----------------------------------------------------------------------*/ -/* - Show a "notice" dialog: (only one button) -*/ +/** + * Show a "notice" dialog: (only one button) + */ int DlgAlert_Notice(const char *text) { -#ifdef ALERT_HOOKS - // If activated, used the hooked function instead - if (useAlertHooks) - { +#ifdef ALERT_HOOKS + if (!Main_UnPauseEmulation()) + Main_PauseEmulation(true); + if(!bInFullScreen) return HookedAlertNotice(text); - } #endif /* Hide "cancel" button: */ alertdlg[DLGALERT_CANCEL].type = SGTEXT; alertdlg[DLGALERT_CANCEL].txt = ""; - alertdlg[DLGALERT_CANCEL].w = alertdlg[DLGALERT_CANCEL].w = 0; + alertdlg[DLGALERT_CANCEL].w = 0; + alertdlg[DLGALERT_CANCEL].h = 0; /* Adjust button position: */ alertdlg[DLGALERT_OK].x = (alertdlg[0].w - alertdlg[DLGALERT_OK].w) / 2; @@ -200,17 +205,14 @@ int DlgAlert_Notice(const char *text) /*-----------------------------------------------------------------------*/ -/* - Show a "query" dialog: (two buttons), return true for OK -*/ +/** + * Show a "query" dialog: (two buttons), return true for OK + */ int DlgAlert_Query(const char *text) { #ifdef ALERT_HOOKS - // If activated, used the hooked function instead - if (useAlertHooks) - { + if(!bInFullScreen) return HookedAlertQuery(text); - } #endif /* Show "cancel" button: */