--- hatari/src/gui-sdl/dlgAlert.c 2019/04/09 08:47:28 1.1.1.7 +++ hatari/src/gui-sdl/dlgAlert.c 2019/04/09 08:57:07 1.1.1.12 @@ -48,17 +48,17 @@ static SGOBJ alertdlg[] = { SGTEXT, 0, 0, 1,3, 50,1, dlglines[2] }, { SGTEXT, 0, 0, 1,4, 50,1, dlglines[3] }, { SGBUTTON, SG_DEFAULT, 0, 5,5, 8,1, "OK" }, - { SGBUTTON, SG_CANCEL, 0, 24,5, 8,1, "Cancel" }, - { -1, 0, 0, 0,0, 0,0, NULL } + { SGBUTTON, SG_CANCEL, 0, 24,5, 8,1, NULL }, + { SGSTOP, 0, 0, 0,0, 0,0, NULL } }; /*-----------------------------------------------------------------------*/ -/* - 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; @@ -119,9 +119,9 @@ 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; @@ -130,7 +130,12 @@ static int DlgAlert_ShowDlg(const char * int lines, i, len, offset; bool bOldMouseVisibility; int nOldMouseX, nOldMouseY; + bool bWasEmuActive; +#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,34 +161,47 @@ static int DlgAlert_ShowDlg(const char * return false; SDLGui_CenterDlg(alertdlg); + bWasEmuActive = Main_PauseEmulation(true); + 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 + + if (bWasEmuActive) + Main_UnPauseEmulation(); 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 - return HookedAlertNotice(text); +#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; @@ -193,13 +211,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 - return HookedAlertQuery(text); + if(!bInFullScreen) + return HookedAlertQuery(text); #endif /* Show "cancel" button: */