static void ghack_about_cb(GtkWidget *widget, gpointer data) { char buf[BUFSZ]="\0"; char buf1[BUFSZ]="\0"; const gchar *authors[] = {"Erik Andersen", "Anthony Taylor", "Jeff Garzik", "The Nethack Dev Team", NULL }; if (about) { gdk_window_raise (about->window); return; } getversionstring(buf); strcat( buf1, VERSION_STRING); strcat( buf, _("\nSend comments and bug reports to: [email protected]\n" "This game is free software. See License for details.")); about = gnome_about_new(_("Nethack"), buf1, "Copyright (C) 1985-2002 Mike Stephenson", (const char **)authors, buf, NULL); gtk_signal_connect (GTK_OBJECT (about), "destroy", (GtkSignalFunc) about_destroy_callback, NULL); gtk_widget_show(about); }
int doversion(void) { char buf[BUFSZ]; pline("%s", getversionstring(buf)); return 0; }
// Mesage handler for about box. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char buf[BUFSZ]; TCHAR wbuf[NHSTR_BUFSIZE]; RECT main_rt, dlg_rt; SIZE dlg_sz; switch (message) { case WM_INITDIALOG: getversionstring(buf); SetDlgItemText(hDlg, IDC_ABOUT_VERSION, NH_A2W(buf, wbuf, NHSTR_BUFSIZE)); SetDlgItemText(hDlg, IDC_ABOUT_COPYRIGHT, NH_A2W(COPYRIGHT_BANNER_A "\n" COPYRIGHT_BANNER_B "\n" COPYRIGHT_BANNER_C "\n" COPYRIGHT_BANNER_D, wbuf, NHSTR_BUFSIZE)); /* center dialog in the main window */ GetWindowRect(GetNHApp()->hMainWnd, &main_rt); GetWindowRect(hDlg, &dlg_rt); dlg_sz.cx = dlg_rt.right - dlg_rt.left; dlg_sz.cy = dlg_rt.bottom - dlg_rt.top; dlg_rt.left = (main_rt.left + main_rt.right - dlg_sz.cx) / 2; dlg_rt.right = dlg_rt.left + dlg_sz.cx; dlg_rt.top = (main_rt.top + main_rt.bottom - dlg_sz.cy) / 2; dlg_rt.bottom = dlg_rt.top + dlg_sz.cy; MoveWindow(hDlg, (main_rt.left + main_rt.right - dlg_sz.cx) / 2, (main_rt.top + main_rt.bottom - dlg_sz.cy) / 2, dlg_sz.cx, dlg_sz.cy, TRUE); return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; } break; } return FALSE; }
void mswin_display_splash_window(BOOL show_ver) { MSG msg; int left, top; RECT splashrt; RECT clientrt; RECT controlrt; HWND hWnd; int buttop; int strsize = 0; int bufsize = BUFSZ; char *buf = malloc(bufsize); if (buf == NULL) panic("out of memory"); buf[0] = '\0'; hWnd = CreateDialog(GetNHApp()->hApp, MAKEINTRESOURCE(IDD_SPLASH), GetNHApp()->hMainWnd, NHSplashWndProc); if (!hWnd) panic("Cannot create Splash window"); mswin_init_splashfonts(hWnd); GetNHApp()->hPopupWnd = hWnd; /* Get control size */ GetWindowRect(GetDlgItem(hWnd, IDOK), &controlrt); controlrt.right -= controlrt.left; controlrt.bottom -= controlrt.top; /* Get current client area */ GetClientRect(hWnd, &clientrt); /* Get window size */ GetWindowRect(hWnd, &splashrt); splashrt.right -= splashrt.left; splashrt.bottom -= splashrt.top; /* Get difference between requested client area and current value */ splashrt.right += SPLASH_WIDTH + SPLASH_OFFSET_X * 2 - clientrt.right; splashrt.bottom += SPLASH_HEIGHT + controlrt.bottom + SPLASH_OFFSET_Y * 3 - clientrt.bottom; /* Place the window centered */ /* On the screen, not on the parent window */ left = (GetSystemMetrics(SM_CXSCREEN) - splashrt.right) / 2; top = (GetSystemMetrics(SM_CYSCREEN) - splashrt.bottom) / 2; MoveWindow(hWnd, left, top, splashrt.right, splashrt.bottom, TRUE); /* Place the OK control */ GetClientRect(hWnd, &clientrt); MoveWindow(GetDlgItem(hWnd, IDOK), (clientrt.right - clientrt.left - controlrt.right) / 2, clientrt.bottom - controlrt.bottom - SPLASH_OFFSET_Y, controlrt.right, controlrt.bottom, TRUE); buttop = clientrt.bottom - controlrt.bottom - SPLASH_OFFSET_Y; /* Place the text control */ GetWindowRect(GetDlgItem(hWnd, IDC_EXTRAINFO), &controlrt); controlrt.right -= controlrt.left; controlrt.bottom -= controlrt.top; GetClientRect(hWnd, &clientrt); MoveWindow(GetDlgItem(hWnd, IDC_EXTRAINFO), clientrt.left + SPLASH_OFFSET_X, buttop - controlrt.bottom - SPLASH_OFFSET_Y, clientrt.right - 2 * SPLASH_OFFSET_X, controlrt.bottom, TRUE); /* Fill the text control */ Sprintf(buf, "%s\r\n%s\r\n%s\r\n%s\r\n\r\n", COPYRIGHT_BANNER_A, COPYRIGHT_BANNER_B, COPYRIGHT_BANNER_C, COPYRIGHT_BANNER_D); strsize = strlen(buf); if (show_ver) { /* Show complete version information */ dlb *f; char verbuf[BUFSZ]; int verstrsize = 0; getversionstring(verbuf); verstrsize = strlen(verbuf); if (verstrsize + strlen("\r\n\r\n") + 1 < BUFSZ - 1) strcat(verbuf, "\r\n\r\n"); verstrsize = strlen(verbuf); if (strsize + verstrsize + 1 > bufsize) { bufsize += BUFSZ; buf = realloc(buf, bufsize); if (buf == NULL) panic("out of memory"); } strcat(buf, verbuf); strsize = strlen(buf); /* Add compile options */ f = dlb_fopen(OPTIONS_USED, RDTMODE); if (f) { char line[LLEN + 1]; while (dlb_fgets(line, LLEN, f)) { size_t len; len = strlen(line); if (len > 0 && line[len - 1] == '\n') { line[len - 1] = '\r'; line[len] = '\n'; line[len + 1] = '\0'; len++; } if (strsize + (int) len + 1 > bufsize) { bufsize += BUFSZ; buf = realloc(buf, bufsize); if (buf == NULL) panic("out of memory"); } strcat(buf, line); strsize += len; } (void) dlb_fclose(f); } } else { /* Show news, if any */ if (iflags.news) { FILE *nf; iflags.news = 0; /* prevent newgame() from re-displaying news */ nf = fopen(NEWS, "r"); if (nf != NULL) { char line[LLEN + 1]; while (fgets(line, LLEN, nf)) { size_t len; len = strlen(line); if (len > 0 && line[len - 1] == '\n') { line[len - 1] = '\r'; line[len] = '\n'; line[len + 1] = '\0'; len++; } if (strsize + (int) len + 1 > bufsize) { bufsize += BUFSZ; buf = realloc(buf, bufsize); if (buf == NULL) panic("out of memory"); } strcat(buf, line); strsize += len; } (void) fclose(nf); } else { strcat(buf, "No news."); } } } SetWindowText(GetDlgItem(hWnd, IDC_EXTRAINFO), buf); free(buf); ShowWindow(hWnd, SW_SHOW); while (IsWindow(hWnd) && GetMessage(&msg, NULL, 0, 0) != 0) { if (!IsDialogMessage(hWnd, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } GetNHApp()->hPopupWnd = NULL; mswin_destroy_splashfonts(); }