/** * 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; int nOldMouseX, nOldMouseY; strcpy(t, text); lines = DlgAlert_FormatTextToBox(t, maxlen, &len); offset = (maxlen-len)/2; for(i=0; i<MAX_LINES; i++) { if (i < lines) { /* center text to current dlgline */ memset(dlglines[i], ' ', offset); strcpy(dlglines[i] + offset, t); t += strlen(t)+1; } else { dlglines[i][0] = '\0'; } } free(orig_t); if (SDLGui_SetScreen(sdlscrn)) return false; SDLGui_CenterDlg(alertdlg); SDL_GetMouseState(&nOldMouseX, &nOldMouseY); bOldMouseVisibility = SDL_ShowCursor(SDL_QUERY); SDL_ShowCursor(SDL_ENABLE); i = SDLGui_DoDialog(alertdlg, NULL); SDL_UpdateRect(sdlscrn, 0,0, 0,0); SDL_ShowCursor(bOldMouseVisibility); Main_WarpMouse(nOldMouseX, nOldMouseY); return (i == DLGALERT_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; int nOldMouseX, nOldMouseY; strcpy(t, text); lines = DlgAlert_FormatTextToBox(t, maxlen, &len); offset = (maxlen-len)/2; for(i=0; i<MAX_LINES; i++) { if (i < lines) { /* center text to current dlgline */ memset(dlglines[i], ' ', offset); strcpy(dlglines[i] + offset, t); t += strlen(t)+1; } else { dlglines[i][0] = '\0'; } } free(orig_t); if (SDLGui_SetScreen(/*sdlscrn*/)) return false; SDLGui_CenterDlg(alertdlg); do { i = SDLGui_DoDialog(alertdlg, NULL); gui_poll_events(); } while (i != DLGALERT_OK && i != DLGALERT_CANCEL && i != SDLGUI_QUIT && i != SDLGUI_ERROR && !bQuitProgram); return (i == DLGALERT_OK); }