diff -Naurd ../nethack-3.4.1/win/win32/mhdlg.c ./win/win32/mhdlg.c --- ../nethack-3.4.1/win/win32/mhdlg.c Sun Feb 23 16:51:52 2003 +++ ./win/win32/mhdlg.c Mon Sep 1 14:33:32 2003 @@ -354,7 +354,7 @@ if( plselFinalSelection(hWnd, data->selection) ) { EndDialog(hWnd, wParam); } else { - MessageBox(hWnd, TEXT("Cannot match this role. Try something else."), TEXT("STOP"), MB_OK ); + NHMessageBox(hWnd, TEXT("Cannot match this role. Try something else."), MB_ICONSTOP | MB_OK ); } return TRUE; @@ -446,6 +446,22 @@ /* set player name */ SetDlgItemText(hWnd, IDC_PLSEL_NAME, NH_A2W(plname, wbuf, sizeof(wbuf))); + /* check flags for consistency */ + if( flags.initrole>=0 ) { + if (flags.initrace>=0 && !validrace(flags.initrole, flags.initrace)) { + flags.initrace = ROLE_NONE; + } + + if (flags.initgend>=0 && !validgend(flags.initrole, flags.initrace, flags.initgend)) { + flags.initgend = ROLE_NONE; + } + + if (flags.initalign>=0 && !validalign(flags.initrole, flags.initrace, flags.initalign)) { + flags.initalign = ROLE_NONE; + } + } + + /* populate select boxes */ plselAdjustLists(hWnd, -1); /* intialize roles list */ @@ -511,16 +527,16 @@ /* get current selections */ ind = SendMessage(control_role, CB_GETCURSEL, 0, 0); - initrole = (ind==LB_ERR)? ROLE_NONE : SendMessage(control_role, CB_GETITEMDATA, ind, 0); + initrole = (ind==LB_ERR)? flags.initrole : SendMessage(control_role, CB_GETITEMDATA, ind, 0); ind = SendMessage(control_race, CB_GETCURSEL, 0, 0); - initrace = (ind==LB_ERR)? ROLE_NONE : SendMessage(control_race, CB_GETITEMDATA, ind, 0); + initrace = (ind==LB_ERR)? flags.initrace : SendMessage(control_race, CB_GETITEMDATA, ind, 0); ind = SendMessage(control_gender, CB_GETCURSEL, 0, 0); - initgend = (ind==LB_ERR)? ROLE_NONE : SendMessage(control_gender, CB_GETITEMDATA, ind, 0); + initgend = (ind==LB_ERR)? flags.initgend : SendMessage(control_gender, CB_GETITEMDATA, ind, 0); ind = SendMessage(control_align, CB_GETCURSEL, 0, 0); - initalign = (ind==LB_ERR)? ROLE_NONE : SendMessage(control_align, CB_GETITEMDATA, ind, 0); + initalign = (ind==LB_ERR)? flags.initalign : SendMessage(control_align, CB_GETITEMDATA, ind, 0); /* intialize roles list */ if( changed_sel==-1 ) { @@ -598,6 +614,7 @@ SendMessage(control_gender, CB_SETITEMDATA, (WPARAM)ind, (LPARAM)i ); if( i==initgend ) { SendMessage(control_gender, CB_SETCURSEL, (WPARAM)ind, (LPARAM)0 ); + valid_opt = 1; } } @@ -677,7 +694,7 @@ if( flags.initrole==ROLE_RANDOM ) { flags.initrole = pick_role(flags.initrace, flags.initgend, flags.initalign, PICK_RANDOM); if (flags.initrole < 0) { - MessageBox(hWnd, TEXT("Incompatible role!"), TEXT("STOP"), MB_OK); + NHMessageBox(hWnd, TEXT("Incompatible role!"), MB_ICONSTOP | MB_OK); return FALSE; } } @@ -691,7 +708,7 @@ } if (flags.initrace < 0) { - MessageBox(hWnd, TEXT("Incompatible race!"), TEXT("STOP"), MB_OK); + NHMessageBox(hWnd, TEXT("Incompatible race!"), MB_ICONSTOP | MB_OK); return FALSE; } } @@ -707,7 +724,7 @@ } if (flags.initgend < 0) { - MessageBox(hWnd, TEXT("Incompatible gender!"), TEXT("STOP"), MB_OK); + NHMessageBox(hWnd, TEXT("Incompatible gender!"), MB_ICONSTOP | MB_OK); return FALSE; } } @@ -720,7 +737,7 @@ if (flags.initalign == ROLE_RANDOM) { flags.initalign = pick_align(flags.initrole, flags.initrace, flags.initgend, PICK_RANDOM); } else { - MessageBox(hWnd, TEXT("Incompatible alignment!"), TEXT("STOP"), MB_OK); + NHMessageBox(hWnd, TEXT("Incompatible alignment!"), MB_ICONSTOP | MB_OK); return FALSE; } } diff -Naurd ../nethack-3.4.1/win/win32/mhfont.c ./win/win32/mhfont.c --- ../nethack-3.4.1/win/win32/mhfont.c Sun Feb 23 14:43:47 2003 +++ ./win/win32/mhfont.c Mon Sep 1 14:33:32 2003 @@ -14,7 +14,6 @@ } font_table[MAXFONTS] ; static int font_table_size = 0; HFONT version_splash_font; -HFONT extrainfo_splash_font; #define NHFONT_CODE(win, attr) (((attr&0xFF)<<8)|(win_type&0xFF)) @@ -41,15 +40,12 @@ lgfnt.lfPitchAndFamily = DEFAULT_PITCH; // pitch and family NH_A2W( "Times New Roman", lgfnt.lfFaceName, LF_FACESIZE); version_splash_font = CreateFontIndirect(&lgfnt); - lgfnt.lfHeight = -16; // height of font - extrainfo_splash_font = CreateFontIndirect(&lgfnt); ReleaseDC(hWnd, hdc); } void mswin_destroy_splashfonts() { DeleteObject (version_splash_font); - DeleteObject (extrainfo_splash_font); } /* create font based on window type, charater attributes and diff -Naurd ../nethack-3.4.1/win/win32/mhmain.c ./win/win32/mhmain.c --- ../nethack-3.4.1/win/win32/mhmain.c Sun Feb 23 14:43:47 2003 +++ ./win/win32/mhmain.c Mon Sep 1 14:33:32 2003 @@ -137,13 +137,13 @@ {'9', M('9'), '9'}, /* 9 */ {'m', C('p'), C('p')}, /* - */ {'4', M('4'), '4'}, /* 4 */ - {'g', 'G', 'g'}, /* 5 */ + {'5', M('5'), '5'}, /* 5 */ {'6', M('6'), '6'}, /* 6 */ {'+', 'P', C('p')}, /* + */ {'1', M('1'), '1'}, /* 1 */ {'2', M('2'), '2'}, /* 2 */ {'3', M('3'), '3'}, /* 3 */ - {'i', 'I', C('i')}, /* Ins */ + {'0', M('0'), '0'}, /* Ins */ {'.', ':', ':'} /* Del */ }; @@ -437,7 +437,8 @@ wp.length = sizeof(wp); if (GetWindowPlacement(hWnd, &wp)) { - GetNHApp()->regMainShowState = wp.showCmd; + GetNHApp()->regMainShowState = (wp.showCmd == SW_SHOWMAXIMIZED + ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL); GetNHApp()->regMainMinX = wp.ptMinPosition.x; GetNHApp()->regMainMinY = wp.ptMinPosition.y; @@ -471,9 +472,15 @@ NHEVENT_KBD('\033'); /* and send keyboard input as if user pressed ESC */ /* additional code for this is done in menu and rip windows */ } + else if (!program_state.something_worth_saving) + { + /* User exited before the game started, e.g. during splash display */ + /* Just get out. */ + bail((char *)0); + } else { - switch(MessageBox(hWnd, TEXT("Save?"), TEXT("NetHack for Windows"), MB_YESNOCANCEL | MB_ICONQUESTION)) { + switch (NHMessageBox(hWnd, TEXT("Save?"), MB_YESNOCANCEL | MB_ICONQUESTION)) { case IDYES: NHEVENT_KBD('y'); dosave(); break; case IDNO: NHEVENT_KBD('q'); done(QUIT); break; case IDCANCEL: break; @@ -753,9 +760,9 @@ { mswin_destroy_reg(); /* Notify the user that windows settings will not be saved this time. */ - MessageBox(GetNHApp()->hMainWnd, + NHMessageBox(GetNHApp()->hMainWnd, "Your Windows Settings will not be stored when you exit this time.", - "NetHack", MB_OK | MB_ICONINFORMATION); + MB_OK | MB_ICONINFORMATION); break; } case IDM_HELP_LONG: diff -Naurd ../nethack-3.4.1/win/win32/mhsplash.c ./win/win32/mhsplash.c --- ../nethack-3.4.1/win/win32/mhsplash.c Sun Feb 23 14:43:47 2003 +++ ./win/win32/mhsplash.c Mon Sep 1 14:33:32 2003 @@ -16,28 +16,31 @@ BOOL CALLBACK NHSplashWndProc(HWND, UINT, WPARAM, LPARAM); #define SPLASH_WIDTH 440 -#define SPLASH_HEIGHT 301 +#define SPLASH_HEIGHT 322 #define SPLASH_VERSION_X 290 #define SPLASH_VERSION_Y 10 -#define SPLASH_EXTRA_X_BEGIN 15 -#define SPLASH_EXTRA_X_END 415 -#define SPLASH_EXTRA_Y 150 #define SPLASH_OFFSET_X 10 #define SPLASH_OFFSET_Y 10 extern HFONT version_splash_font; -extern HFONT extrainfo_splash_font; void mswin_display_splash_window (BOOL show_ver) { MSG msg; - RECT rt; HWND mapWnd; + int left, top; RECT splashrt; RECT clientrt; RECT controlrt; HWND hWnd; - int buttop; + 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); @@ -60,83 +63,114 @@ 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 */ - GetWindowRect(mapWnd, &rt); - rt.left += (rt.right - rt.left - splashrt.right) / 2; - rt.top += (rt.bottom - rt.top - splashrt.bottom) / 2; - MoveWindow(hWnd, rt.left, rt.top, splashrt.right, splashrt.bottom, TRUE); - /* Place the OK control */ + /* 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); - if (show_ver) { - /* Show complete version informatoin */ - char buf[BUFSZ]; - - getversionstring(buf); - SetWindowText(GetDlgItem(hWnd, IDC_EXTRAINFO), buf); - - } else { - /* Show news, if any */ - FILE *nf; + 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\r\n", COPYRIGHT_BANNER_A, COPYRIGHT_BANNER_B, + COPYRIGHT_BANNER_C); + strsize = strlen(buf); + + if (show_ver) { + /* Show complete version information */ + dlb *f; - iflags.news = 0; /* prevent newgame() from re-displaying news */ - nf = fopen(NEWS, "r"); - if (nf != NULL) { - char *buf = NULL; - int bufsize = 0; - int strsize = 0; - char line[LLEN + 1]; + getversionstring(buf + strsize); + strcat(buf, "\r\n\r\n"); + strsize = strlen(buf); - while (fgets(line, LLEN, nf)) { - size_t len; - len = strlen(line); - if (line[len - 1] == '\n') { - line[len - 1] = '\r'; - line[len] = '\n'; - line[len + 1] = '\0'; - len++; - } - if (strsize + (int)len > bufsize) - { - bufsize += BUFSZ; - buf = realloc(buf, bufsize); - if (buf == NULL) - panic("out of memory"); - if (strsize == 0) - buf[0] = '\0'; - } - strcat(buf, line); - strsize += len; - } - (void) fclose(nf); - SetWindowText(GetDlgItem(hWnd, IDC_EXTRAINFO), buf); - free(buf); - } - else - SetWindowText(GetDlgItem(hWnd, IDC_EXTRAINFO), "No news."); - } + /* 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); - } + GetMessage(&msg, NULL, 0, 0)!=0 ) { + if( !IsDialogMessage(hWnd, &msg) ) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } } - + GetNHApp()->hPopupWnd = NULL; mswin_destroy_splashfonts(); } @@ -159,7 +193,6 @@ case WM_PAINT: { char VersionString[BUFSZ]; - char InfoString[BUFSZ]; RECT rt; HDC hdcBitmap; HANDLE OldBitmap; @@ -194,21 +227,6 @@ DrawText (hdc, VersionString, strlen(VersionString), &rt, DT_LEFT | DT_NOPREFIX); - /* Print copyright banner */ - - SetTextColor (hdc, RGB(255, 255, 255)); - Sprintf (InfoString, "%s\n%s\n%s\n", COPYRIGHT_BANNER_A, COPYRIGHT_BANNER_B, - COPYRIGHT_BANNER_C); - SelectObject(hdc, extrainfo_splash_font); - rt.left = SPLASH_EXTRA_X_BEGIN; - rt.right = SPLASH_EXTRA_X_END; - rt.bottom = rt.top = SPLASH_EXTRA_Y; - DrawText (hdc, InfoString, strlen(InfoString), &rt, - DT_LEFT | DT_NOPREFIX | DT_LEFT | DT_VCENTER | DT_CALCRECT); - DrawText (hdc, InfoString, strlen(InfoString), &rt, - DT_LEFT | DT_NOPREFIX | DT_LEFT | DT_VCENTER); - - SelectObject(hdc, OldFont); EndPaint (hWnd, &ps); } break; diff -Naurd ../nethack-3.4.1/win/win32/mswproc.c ./win/win32/mswproc.c --- ../nethack-3.4.1/win/win32/mswproc.c Sun Feb 23 14:43:47 2003 +++ ./win/win32/mswproc.c Mon Sep 1 14:33:32 2003 @@ -23,6 +23,7 @@ #include "mhrip.h" #include "mhmain.h" #include "mhfont.h" +#include "resource.h" #define LLEN 128 @@ -70,6 +71,7 @@ WC_FONTSIZ_MESSAGE|WC_FONTSIZ_STATUS|WC_FONTSIZ_MENU|WC_FONTSIZ_TEXT| WC_TILE_WIDTH|WC_TILE_HEIGHT|WC_TILE_FILE|WC_VARY_MSGCOUNT| WC_WINDOWCOLORS|WC_PLAYER_SELECTION|WC_SPLASH_SCREEN|WC_POPUP_DIALOG, + 0L, mswin_init_nhwindows, mswin_player_selection, mswin_askname, @@ -332,8 +334,8 @@ /* tty_putstr(BASE_WINDOW, 0, ""); */ /* echoline = wins[BASE_WINDOW]->cury; */ - box_result = MessageBox(NULL, prompt, TEXT("NetHack for Windows"), - MB_YESNOCANCEL | MB_DEFBUTTON1); + box_result = NHMessageBox(NULL, prompt, + MB_ICONQUESTION | MB_YESNOCANCEL | MB_DEFBUTTON1); pick4u = (box_result == IDYES) ? 'y' : (box_result == IDNO) ? 'n' : '\033'; /* tty_putstr(BASE_WINDOW, 0, prompt); */ do { @@ -996,7 +998,7 @@ if (must_exist) { TCHAR message[90]; _stprintf(message, TEXT("Warning! Could not find file: %s\n"), NH_A2W(filename, wbuf, sizeof(wbuf))); - MessageBox(GetNHApp()->hMainWnd, message, TEXT("ERROR"), MB_OK | MB_ICONERROR ); + NHMessageBox(GetNHApp()->hMainWnd, message, MB_OK | MB_ICONEXCLAMATION ); } } else { winid text; @@ -1263,7 +1265,8 @@ TCHAR wbuf[255]; logDebug("mswin_raw_print(%s)\n", str); if( str && *str ) - MessageBox(GetNHApp()->hMainWnd, NH_A2W(str, wbuf, sizeof(wbuf)), TEXT("NetHack"), MB_OK ); + NHMessageBox(GetNHApp()->hMainWnd, NH_A2W(str, wbuf, sizeof(wbuf)), + MB_ICONINFORMATION | MB_OK ); } /* @@ -1276,7 +1279,8 @@ TCHAR wbuf[255]; logDebug("mswin_raw_print_bold(%s)\n", str); if( str && *str ) - MessageBox(GetNHApp()->hMainWnd, NH_A2W(str, wbuf, sizeof(wbuf)), TEXT("NetHack"), MB_OK ); + NHMessageBox(GetNHApp()->hMainWnd, NH_A2W(str, wbuf, sizeof(wbuf)), + MB_ICONINFORMATION | MB_OK ); } /* @@ -1379,12 +1383,12 @@ char mswin_yn_function(const char *question, const char *choices, CHAR_P def) { - int result=-1; char ch; char yn_esc_map='\033'; char message[BUFSZ]; char res_ch[2]; int createcaret; + boolean digit_ok, allow_num; logDebug("mswin_yn_function(%s, %s, %d)\n", question, choices, def); @@ -1393,10 +1397,9 @@ + strlen(GetNHApp()->saved_text) + 1); DWORD box_result; strcat(text, question); - box_result = MessageBox(NULL, + box_result = NHMessageBox(NULL, NH_W2A(text, message, sizeof(message)), - TEXT("NetHack for Windows"), - MB_YESNOCANCEL | + MB_YESNOCANCEL | MB_ICONQUESTION | ((def == 'y') ? MB_DEFBUTTON1 : (def == 'n') ? MB_DEFBUTTON2 : MB_DEFBUTTON3)); free(text); @@ -1405,20 +1408,23 @@ } if (choices) { - char *cb, choicebuf[QBUFSZ]; - Strcpy(choicebuf, choices); - if ((cb = index(choicebuf, '\033')) != 0) { - /* anything beyond is hidden */ - *cb = '\0'; - } - sprintf(message, "%s [%s] ", question, choicebuf); - if (def) sprintf(eos(message), "(%c) ", def); - /* escape maps to 'q' or 'n' or default, in that order */ - yn_esc_map = (index(choices, 'q') ? 'q' : - (index(choices, 'n') ? 'n' : def)); + char *cb, choicebuf[QBUFSZ]; + + allow_num = (index(choices, '#') != 0); + + Strcpy(choicebuf, choices); + if ((cb = index(choicebuf, '\033')) != 0) { + /* anything beyond is hidden */ + *cb = '\0'; + } + sprintf(message, "%s [%s] ", question, choicebuf); + if (def) sprintf(eos(message), "(%c) ", def); + /* escape maps to 'q' or 'n' or default, in that order */ + yn_esc_map = (index(choices, 'q') ? 'q' : + (index(choices, 'n') ? 'n' : def)); } else { - Strcpy(message, question); - Strcat(message, " "); + Strcpy(message, question); + Strcat(message, " "); } createcaret = 1; @@ -1429,38 +1435,83 @@ mswin_putstr(WIN_MESSAGE, ATR_BOLD, message); /* Only here if main window is not present */ - while (result<0) { - ShowCaret(mswin_hwnd_from_winid(WIN_MESSAGE)); - ch=mswin_nhgetch(); - if (choices) - ch = lowc(ch); - HideCaret(mswin_hwnd_from_winid(WIN_MESSAGE)); - if (ch=='\033') { - result=yn_esc_map; - } else if (choices && !index(choices,ch)) { - /* FYI: ch==-115 is for KP_ENTER */ - if (def && (ch==' ' || ch=='\r' || ch=='\n' || ch==-115)) { - result=def; - } else { - mswin_nhbell(); - /* and try again... */ - } - } else { - result=ch; - } - } + ch = 0; + do { + ShowCaret(mswin_hwnd_from_winid(WIN_MESSAGE)); + ch=mswin_nhgetch(); + HideCaret(mswin_hwnd_from_winid(WIN_MESSAGE)); + if (choices) ch = lowc(ch); + else break; /* If choices is NULL, all possible inputs are accepted and returned. */ + + digit_ok = allow_num && digit(ch); + if (ch=='\033') { + if (index(choices, 'q')) + ch = 'q'; + else if (index(choices, 'n')) + ch = 'n'; + else + ch = def; + break; + } else if (index(quitchars, ch)) { + ch = def; + break; + } else if (!index(choices, ch) && !digit_ok) { + mswin_nhbell(); + ch = (char)0; + /* and try again... */ + } else if (ch == '#' || digit_ok) { + char z, digit_string[2]; + int n_len = 0; + long value = 0; + mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, ("#"), 1); n_len++; + digit_string[1] = '\0'; + if (ch != '#') { + digit_string[0] = ch; + mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, digit_string, 1); n_len++; + value = ch - '0'; + ch = '#'; + } + do { /* loop until we get a non-digit */ + z = lowc(readchar()); + if (digit(z)) { + value = (10 * value) + (z - '0'); + if (value < 0) break; /* overflow: try again */ + digit_string[0] = z; + mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, digit_string, 1); + n_len++; + } else if (z == 'y' || index(quitchars, z)) { + if (z == '\033') value = -1; /* abort */ + z = '\n'; /* break */ + } else if (z == '\b') { + if (n_len <= 1) { value = -1; break; } + else { value /= 10; mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, digit_string, -1); n_len--; } + } else { + value = -1; /* abort */ + mswin_nhbell(); + break; + } + } while (z != '\n'); + if (value > 0) yn_number = value; + else if (value == 0) ch = 'n'; /* 0 => "no" */ + else { /* remove number from top line, then try again */ + mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, digit_string, -n_len); n_len = 0; + ch = (char)0; + } + } + } while( !ch ); createcaret = 0; SendMessage(mswin_hwnd_from_winid(WIN_MESSAGE), WM_MSNH_COMMAND, (WPARAM)MSNH_MSG_CARET, (LPARAM)&createcaret ); + /* display selection in the message window */ - if( isprint(ch) ) { + if( isprint(ch) && ch!='#' ) { res_ch[0] = ch; res_ch[1] = '\x0'; mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, res_ch, 1); } - return result; + return ch; } /* @@ -2056,7 +2107,7 @@ /* Reading and writing settings from the registry. */ #define CATEGORYKEY "Software" #define COMPANYKEY "NetHack" -#define PRODUCTKEY "NetHack 3.4.1" +#define PRODUCTKEY "NetHack 3.4.2" #define SETTINGSKEY "Settings" #define MAINSHOWSTATEKEY "MainShowState" #define MAINMINXKEY "MainMinX" @@ -2291,3 +2342,12 @@ *brushptr = CreateSolidBrush(*colorptr); brush_table[max_brush++] = *brushptr; } + +int NHMessageBox(HWND hWnd, LPCTSTR text, UINT type) +{ + TCHAR title[MAX_LOADSTRING]; + + LoadString(GetNHApp()->hApp, IDS_APP_TITLE_SHORT, title, MAX_LOADSTRING); + + return MessageBox(hWnd, text, title, type); +} diff -Naurd ../nethack-3.4.1/win/win32/resource.h ./win/win32/resource.h --- ../nethack-3.4.1/win/win32/resource.h Sun Feb 23 14:43:48 2003 +++ ./win/win32/resource.h Mon Sep 1 14:33:32 2003 @@ -11,6 +11,7 @@ #define IDS_HELLO 106 #define IDI_NETHACKW 107 #define IDC_NETHACKW 109 +#define IDS_APP_TITLE_SHORT 110 #define IDR_MAINFRAME 128 #define IDB_TILES 129 #define IDD_TEXT 130 diff -Naurd ../nethack-3.4.1/win/win32/winhack.rc ./win/win32/winhack.rc --- ../nethack-3.4.1/win/win32/winhack.rc Sun Feb 23 14:43:48 2003 +++ ./win/win32/winhack.rc Mon Sep 1 14:33:32 2003 @@ -203,7 +203,7 @@ FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "OK",IDOK,224,236,50,14 - EDITTEXT IDC_EXTRAINFO,7,191,267,37,ES_MULTILINE | ES_READONLY | + EDITTEXT IDC_EXTRAINFO,7,176,267,52,ES_MULTILINE | ES_READONLY | WS_VSCROLL END @@ -315,6 +315,44 @@ ///////////////////////////////////////////////////////////////////////////// // +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 3,4,2,0 + PRODUCTVERSION 3,4,2,0 + FILEFLAGSMASK 0x1fL +#ifdef _DEBUG + FILEFLAGS 0x9L +#else + FILEFLAGS 0x8L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "NetHack for Windows - Graphical Interface\0" + VALUE "FileVersion", "3.4.2\0" + VALUE "InternalName", "NetHackW\0" + VALUE "LegalCopyright", "Copyright (C) 1985 - 2003. By Stichting Mathematisch Centrum and M. Stephenson. See license for details.\0" + VALUE "OriginalFilename", "NetHackW.exe\0" + VALUE "PrivateBuild", "030825\0" + VALUE "ProductName", "NetHack\0" + VALUE "ProductVersion", "3.4.2\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +///////////////////////////////////////////////////////////////////////////// +// // String Table // @@ -322,6 +360,7 @@ BEGIN IDS_APP_TITLE "NetHack for Windows - Graphical Interface" IDC_NETHACKW "NETHACKW" + IDS_APP_TITLE_SHORT "NetHack for Windows" END #endif // English (U.S.) resources diff -Naurd ../nethack-3.4.1/win/win32/winMS.h ./win/win32/winMS.h --- ../nethack-3.4.1/win/win32/winMS.h Sun Feb 23 14:43:48 2003 +++ ./win/win32/winMS.h Mon Sep 1 14:33:32 2003 @@ -151,6 +151,8 @@ void mswin_destroy_reg(void); void mswin_write_reg(void); +int NHMessageBox(HWND hWnd, LPCTSTR text, UINT type); + extern HBRUSH menu_bg_brush; extern HBRUSH menu_fg_brush; extern HBRUSH text_bg_brush; diff -Naurd ../nethack-3.4.1/sys/share/pcmain.c ./sys/share/pcmain.c --- ../nethack-3.4.1/sys/share/pcmain.c Sun Feb 23 14:43:38 2003 +++ ./sys/share/pcmain.c Mon Sep 1 14:33:32 2003 @@ -59,6 +59,10 @@ #define nethack_exit exit #endif +#if defined(MSWIN_GRAPHICS) +extern void NDECL(mswin_destroy_reg); +#endif + #ifdef EXEPATH STATIC_DCL char *FDECL(exepath,(char *)); #endif @@ -236,7 +240,13 @@ #endif /*MSWIN_GRAPHICS*/ nethack_exit(EXIT_SUCCESS); } - + +#ifdef MSWIN_GRAPHICS + if (!strncmpi(argv[1], "-clearreg", 6)) { /* clear registry */ + mswin_destroy_reg(); + nethack_exit(EXIT_SUCCESS); + } +#endif /* Don't initialize the window system just to print usage */ if (!strncmp(argv[1], "-?", 2) || !strncmp(argv[1], "/?", 2)) { nhusage();