]> granicus.if.org Git - nethack/commitdiff
From Yitzhak
authornethack.allison <nethack.allison>
Sun, 23 Mar 2003 19:03:08 +0000 (19:03 +0000)
committernethack.allison <nethack.allison>
Sun, 23 Mar 2003 19:03:08 +0000 (19:03 +0000)
(2 troublesome bands removed
and will follow later)
Here's the new patch with the Windows improvements; this should apply to the
3.4.2 tree. Note the changed filename in the diff lines.
What's in it:
> some MessageBox tidbits:
> - Let all MessageBoxes display an icon
> - Introduced NHMessageBox to have messageboxes display a consistent title
> - Change icon in mswin_display_file from MB_ICONERROR to MB_ICONEXCLAMATION
> for non-fatal error
>
> And to solve #U355: NetHackW won't run on Win2K OS:
> - Avoid a crash when closing the main window while the splash screen is
> displayed.
> - Make sure NetHack starts normal when closed minimized
> - Center the splash screen on the screen, not on the parent window (which may
> be off-screen)
What's new in it:
- Show copyright banner in textbox in splash screen instead of over the picture
- Show news in splash screen only if iflags.news (solves W341-6)
- show complete version information in splash screen when it is used as about
box

sys/winnt/Makefile.gcc
sys/winnt/Makefile.msc
win/win32/mhdlg.c
win/win32/mhfont.c
win/win32/mhmain.c
win/win32/mswproc.c
win/win32/resource.h
win/win32/winMS.h

index 38a01fb6abf7e0a4f978e801ca233f640e05cf54..65d2302650be2c4af464598881bef991b2449405 100644 (file)
@@ -346,7 +346,7 @@ RECOVOBJS      = $(O)recover.o
 TILEFILES      = $(WSHR)/monsters.txt $(WSHR)/objects.txt $(WSHR)/other.txt
 
 #
-# These are not invoked during a normal game build in 3.4.1
+# These are not invoked during a normal game build in 3.4
 #
 TEXT_IO        = $(O)tiletext.o  $(O)tiletxt.o   $(O)drawing.o \
        $(O)decl.o    $(O)monst.o     $(O)objects.o
index a67598eb1111d547c4ccc3e8743f76cc301bdfbd..95933af4c746adab53b0d1db0418c9d6f7f11cbd 100644 (file)
@@ -324,7 +324,7 @@ RECOVOBJS      = $(O)recover.o
 TILEFILES      = $(WSHR)\monsters.txt $(WSHR)\objects.txt $(WSHR)\other.txt
 
 #
-# These are not invoked during a normal game build in 3.4.1
+# These are not invoked during a normal game build in 3.4
 #
 TEXT_IO        = $(O)tiletext.o        $(O)tiletxt.o   $(O)drawing.o \
                 $(O)decl.o     $(O)monst.o     $(O)objects.o
index 325535be53935e9b23f3ddc41015140cfbd54190..e3defb4f34e0a98276ae605319a5a890c8d71fb7 100644 (file)
@@ -354,7 +354,7 @@ BOOL CALLBACK PlayerSelectorDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
                        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;
 
@@ -677,7 +677,7 @@ int plselFinalSelection(HWND hWnd, int* selection)
        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 +691,7 @@ int plselFinalSelection(HWND hWnd, int* selection)
                }
                
                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 +707,7 @@ int plselFinalSelection(HWND hWnd, int* selection)
                }
                
                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 +720,7 @@ int plselFinalSelection(HWND hWnd, int* selection)
                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;
                }
        }
index ecbb4776a5f7d8faaee6a4e78617aebcc7f3d7eb..5f05e7633f680670bd0bfa7c50716ac0a71e5270 100644 (file)
@@ -14,7 +14,6 @@ static struct font_table_entry {
 } 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 @@ void mswin_init_splashfonts(HWND hWnd)
        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
index 5b4e9a68eec355ba36abece1031e4026eaf1c27d..ccb9811aa6b7582197ce8a567def35755a48aaa4 100644 (file)
@@ -438,7 +438,8 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
             
             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;
@@ -472,9 +473,15 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
                            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;
@@ -761,9 +768,9 @@ LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
         {
             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;
         }
 
index ce27794ee943715a1fe43f713d40d8e23e5831c1..e4e99a47b15b82b0e984481472813a5f83e8044a 100644 (file)
@@ -23,6 +23,7 @@
 #include "mhrip.h"
 #include "mhmain.h"
 #include "mhfont.h"
+#include "resource.h"
 
 #define LLEN 128
 
@@ -333,8 +334,8 @@ void prompt_for_player_selection(void)
 
            /* 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 {
@@ -998,7 +999,7 @@ void mswin_display_file(const char *filename,BOOLEAN_P must_exist)
                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;
@@ -1275,7 +1276,8 @@ void mswin_raw_print(const char *str)
        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 );
 }
 
 /*
@@ -1288,7 +1290,8 @@ void mswin_raw_print_bold(const char *str)
        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 );
 }
 
 /*
@@ -1405,10 +1408,9 @@ char mswin_yn_function(const char *question, const char *choices,
                        + 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);
@@ -2400,6 +2402,15 @@ static void mswin_color_from_string(char *colorstring, HBRUSH* brushptr, COLORRE
        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);
+}
+
 void mswin_get_window_placement(int type, LPRECT rt)
 {
     switch (type) {
index c9c06af375009b92464903101f20ce4b6e32bc57..8cc7dd4b466349858bc7e64fb7d6f62cd653c52e 100644 (file)
@@ -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
index 684be30cdac5232f4431ab15838b20263facfb82..a37ec8ed4dff31305161ac5ea473c1a7752609b7 100644 (file)
@@ -164,6 +164,8 @@ void mswin_write_reg(void);
 void mswin_get_window_placement(int type, LPRECT rt);
 void mswin_update_window_placement(int type, LPRECT rt);
 
+int NHMessageBox(HWND hWnd, LPCTSTR text, UINT type);
+
 extern HBRUSH menu_bg_brush;
 extern HBRUSH menu_fg_brush;
 extern HBRUSH text_bg_brush;