From: nethack.allison Date: Mon, 4 Mar 2002 22:55:45 +0000 (+0000) Subject: (from Yitzhak) X-Git-Tag: MOVE2GIT~3066 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4494593c30f4ae1ce49473bff3034f277b2e614f;p=nethack (from Yitzhak) win32gui: more splash screen integration The Makefile have rip.uu/splash.uu added to them. However, this won't work if you don't have splash.uu. Instead, just copy rip.uu or another .uu and name it splash.uu. Make expects to have splash.uu present (at least Borland's make). It doesn't add splash.uu decoding to the IDE framework. It does a bit in winhack.rc and Makefile.bcc to bring winhack.rc up to sync with Borland's compiler. If you don't like the splash screen, then I'll have to redo that part of the patch apart from the others. --- diff --git a/sys/winnt/Makefile.bcc b/sys/winnt/Makefile.bcc index a96d4c804..23569748e 100644 --- a/sys/winnt/Makefile.bcc +++ b/sys/winnt/Makefile.bcc @@ -193,7 +193,7 @@ PRECOMPHEAD = N # set to Y if you want to use precomp. headers !IF "$(GRAPHICAL)" == "Y" WINPORT = $(O)tile.o $(O)mhaskyn.o $(O)mhdlg.o \ $(O)mhfont.o $(O)mhinput.o $(O)mhmain.o $(O)mhmap.o \ - $(O)mhmenu.o $(O)mhmsgwnd.o $(O)mhrip.o \ + $(O)mhmenu.o $(O)mhmsgwnd.o $(O)mhrip.o $(O)mhsplash.o \ $(O)mhstatus.o $(O)mhtext.o $(O)mswproc.o $(O)winhack.o WINPFLAG = -DTILES -DMSWIN_GRAPHICS NHRES = $(O)winhack.res @@ -583,10 +583,13 @@ tileutil: $(U)gif2txt.exe $(U)txt2ppm.exe @echo Optional tile development utilities are up to date. !IF "$(GRAPHICAL)"=="Y" -$(NHRES): $(TILEBMP16) $(WIN32)\winhack.rc +$(NHRES): $(TILEBMP16) $(WIN32)\winhack.rc $(WIN32)\mnsel.bmp \ + $(WIN32)\mnselcnt.bmp $(WIN32)\mnunsel.bmp \ + $(WIN32)\petmark.bmp $(WIN32)\NetHack.ico $(WIN32)\rip.bmp \ + $(WIN32)\splash.bmp @$(rc) -r -fo$@ -i$(WIN32) -dNDEBUG $(WIN32)\winhack.rc !ELSE -$(NHRES): $(NTSYS)\console.rc +$(NHRES): $(NTSYS)\console.rc $(NTSYS)\NetHack.ico @$(rc) -r -fo$@ -i$(NTSYS) -dNDEBUG $(NTSYS)\console.rc !ENDIF @@ -670,6 +673,55 @@ $(INCL)\vis_tab.h: $(U)makedefs.exe $(SRC)\vis_tab.c: $(U)makedefs.exe $(U)makedefs -z +#========================================== +# uudecode utility and uuencoded targets +#========================================== + +$(U)uudecode.exe: $(O)uudecode.o + @$(link) $(LFLAGSU) $(startobj) $(O)\uudecode.o, $@,,$(libsmt) + +$(O)uudecode.o: $(SSYS)\uudecode.c + +$(NTSYS)\NetHack.ico : $(U)uudecode.exe $(NTSYS)\nhico.uu + chdir $(NTSYS) + ..\..\util\uudecode.exe nhico.uu + chdir ..\..\src + +$(WIN32)\NetHack.ico : $(U)uudecode.exe $(NTSYS)\nhico.uu + chdir $(WIN32) + ..\..\util\uudecode.exe ../../sys/winnt/nhico.uu + chdir ..\..\src + +$(WIN32)\mnsel.bmp: $(U)uudecode.exe $(WIN32)\mnsel.uu + chdir $(WIN32) + ..\..\util\uudecode.exe mnsel.uu + chdir ..\..\src + +$(WIN32)\mnselcnt.bmp: $(U)uudecode.exe $(WIN32)\mnselcnt.uu + chdir $(WIN32) + ..\..\util\uudecode.exe mnselcnt.uu + chdir ..\..\src + +$(WIN32)\mnunsel.bmp: $(U)uudecode.exe $(WIN32)\mnunsel.uu + chdir $(WIN32) + ..\..\util\uudecode.exe mnunsel.uu + chdir ..\..\src + +$(WIN32)\petmark.bmp: $(U)uudecode.exe $(WIN32)\petmark.uu + chdir $(WIN32) + ..\..\util\uudecode.exe petmark.uu + chdir ..\..\src + +$(WIN32)\rip.bmp: $(U)uudecode.exe $(WIN32)\rip.uu + chdir $(WIN32) + ..\..\util\uudecode.exe rip.uu + chdir ..\..\src + +$(WIN32)\splash.bmp: $(U)uudecode.exe $(WIN32)\splash.uu + chdir $(WIN32) + ..\..\util\uudecode.exe splash.uu + chdir ..\..\src + #========================================== # Level Compiler Stuff #========================================== diff --git a/sys/winnt/Makefile.nt b/sys/winnt/Makefile.nt index 415011d65..efa62f0b5 100644 --- a/sys/winnt/Makefile.nt +++ b/sys/winnt/Makefile.nt @@ -139,7 +139,7 @@ PRECOMPHEAD = N # set to Y if you want to use precomp. headers !IF "$(GRAPHICAL)" == "Y" WINPORT = $(O)tile.o $(O)mhaskyn.o $(O)mhdlg.o \ $(O)mhfont.o $(O)mhinput.o $(O)mhmain.o $(O)mhmap.o \ - $(O)mhmenu.o $(O)mhmsgwnd.o $(O)mhrip.o \ + $(O)mhmenu.o $(O)mhmsgwnd.o $(O)mhrip.o $(O)mhsplash.o \ $(O)mhstatus.o $(O)mhtext.o $(O)mswproc.o $(O)winhack.o WINPFLAG = -DTILES -DMSWIN_GRAPHICS NHRES = $(O)winhack.res @@ -533,8 +533,9 @@ tileutil: $(U)gif2txt.exe $(U)gif2tx32.exe $(U)txt2ppm.exe !IF "$(GRAPHICAL)"=="Y" $(NHRES): $(TILEBMP16) $(WIN32)\winhack.rc $(WIN32)\mnsel.bmp \ - $(WIN32)\mnselcnt.bmp $(WIN32)\mnunsel.bmp $(WIN32)\petmark.bmp \ - $(WIN32)\NetHack.ico + $(WIN32)\mnselcnt.bmp $(WIN32)\mnunsel.bmp \ + $(WIN32)\petmark.bmp $(WIN32)\NetHack.ico $(WIN32)\rip.bmp \ + $(WIN32)\splash.bmp @$(rc) -r -fo$@ -i$(WIN32) -dNDEBUG $(WIN32)\winhack.rc !ELSE $(NHRES): $(NTSYS)\console.rc $(NTSYS)\NetHack.ico @@ -663,6 +664,16 @@ $(WIN32)\petmark.bmp: $(U)uudecode.exe $(WIN32)\petmark.uu ..\..\util\uudecode.exe petmark.uu chdir ..\..\src +$(WIN32)\rip.bmp: $(U)uudecode.exe $(WIN32)\rip.uu + chdir $(WIN32) + ..\..\util\uudecode.exe rip.uu + chdir ..\..\src + +$(WIN32)\splash.bmp: $(U)uudecode.exe $(WIN32)\splash.uu + chdir $(WIN32) + ..\..\util\uudecode.exe splash.uu + chdir ..\..\src + #========================================== # Level Compiler Stuff #========================================== diff --git a/win/win32/mhfont.c b/win/win32/mhfont.c index 3e3d86eca..473889ecf 100644 --- a/win/win32/mhfont.c +++ b/win/win32/mhfont.c @@ -13,11 +13,45 @@ static struct font_table_entry { HFONT hFont; } 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)) static void __cdecl font_table_cleanup(void); +void mswin_init_splashfonts(HWND hWnd) +{ + HDC hdc = GetDC(hWnd); + HFONT fnt = NULL; + LOGFONT lgfnt; + ZeroMemory( &lgfnt, sizeof(lgfnt) ); + lgfnt.lfHeight = -60*GetDeviceCaps(hdc, LOGPIXELSY)/72; // height of font + lgfnt.lfWidth = 0; // average character width + lgfnt.lfEscapement = 0; // angle of escapement + lgfnt.lfOrientation = 0; // base-line orientation angle + lgfnt.lfWeight = FW_BOLD; // font weight + lgfnt.lfItalic = FALSE; // italic attribute option + lgfnt.lfUnderline = FALSE; // underline attribute option + lgfnt.lfStrikeOut = FALSE; // strikeout attribute option + lgfnt.lfCharSet = OEM_CHARSET; // character set identifier + lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision + lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision + lgfnt.lfQuality = DEFAULT_QUALITY; // output quality + lgfnt.lfPitchAndFamily = DEFAULT_PITCH; // pitch and family + NH_A2W( "Times New Roman", lgfnt.lfFaceName, LF_FACESIZE); + version_splash_font = CreateFontIndirect(&lgfnt); + lgfnt.lfHeight = -12*GetDeviceCaps(hdc, LOGPIXELSY)/72; // 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 window device context */ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace) diff --git a/win/win32/mhfont.h b/win/win32/mhfont.h index 31888df1b..b9cc23404 100644 --- a/win/win32/mhfont.h +++ b/win/win32/mhfont.h @@ -9,5 +9,7 @@ #include "winMS.h" HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace); +void mswin_init_splashfonts(HWND hWnd); +void mswin_destroy_splashfonts(void); #endif /* MSWINFont_h */ diff --git a/win/win32/mhmap.h b/win/win32/mhmap.h index 4490ca018..c7d7d3a00 100644 --- a/win/win32/mhmap.h +++ b/win/win32/mhmap.h @@ -11,7 +11,6 @@ HWND mswin_init_map_window (void); void mswin_map_stretch(HWND hWnd, LPSIZE lpsz, BOOL redraw); - int mswin_map_mode(HWND hWnd, int mode); #define ROGUE_LEVEL_MAP_MODE MAP_MODE_ASCII12x16 diff --git a/win/win32/mhrip.c b/win/win32/mhrip.c index 37099832b..321a73374 100644 --- a/win/win32/mhrip.c +++ b/win/win32/mhrip.c @@ -7,6 +7,8 @@ #include "mhmsg.h" #include "mhfont.h" +#define RIP_WIDTH 400 +#define RIP_HEIGHT 200 PNHWinApp GetNHApp(void); @@ -16,12 +18,8 @@ typedef struct mswin_nethack_text_window { TCHAR* rip_text; } NHRIPWindow, *PNHRIPWindow; -static WNDPROC editControlWndProc = 0; - -BOOL CALLBACK NHRIPWndProc(HWND, UINT, WPARAM, LPARAM); -LRESULT CALLBACK NHEditHookWndProc(HWND, UINT, WPARAM, LPARAM); +BOOL CALLBACK NHRIPWndProc(HWND, UINT, WPARAM, LPARAM); static void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam); -static void LayoutText(HWND hwnd); HWND mswin_init_RIP_window () { HWND ret; @@ -50,7 +48,6 @@ void mswin_display_RIP_window (HWND hWnd) PNHRIPWindow data; HWND mapWnd; RECT riprt; - SIZE bmpDims; RECT clientrect; RECT textrect; HDC hdc; @@ -74,13 +71,11 @@ void mswin_display_RIP_window (HWND hWnd) DT_LEFT | DT_NOPREFIX | DT_CALCRECT); ReleaseDC(hWnd, hdc); } - bmpDims.cx = 400; - bmpDims.cy = 200; - if (textrect.right - textrect.left > bmpDims.cx) + if (textrect.right - textrect.left > RIP_WIDTH) clientrect.right = textrect.right + 10 - clientrect.right; else - clientrect.right = textrect.left + 20 + bmpDims.cx - clientrect.right; - clientrect.bottom = textrect.bottom + bmpDims.cy + 10 - clientrect.bottom; + clientrect.right = textrect.left + 20 + RIP_WIDTH - clientrect.right; + clientrect.bottom = textrect.bottom + RIP_HEIGHT + 10 - clientrect.bottom; GetWindowRect (GetDlgItem(hWnd, IDOK), &textrect); textrect.right -= textrect.left; textrect.bottom -= textrect.top; @@ -136,7 +131,6 @@ BOOL CALLBACK NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam case WM_PAINT: { - SIZE bmpDims; int bitmap_offset; RECT clientrect; RECT textrect; @@ -159,11 +153,9 @@ BOOL CALLBACK NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam } OldBitmap = SelectObject(hdcBitmap, GetNHApp()->bmpRip); SetBkMode (hdc, OPAQUE); - bmpDims.cx = 400; - bmpDims.cy = 200; - bitmap_offset = (textrect.right - textrect.left - bmpDims.cx) / 2; - BitBlt (hdc, textrect.left + bitmap_offset, textrect.bottom, bmpDims.cx, - bmpDims.cy, hdcBitmap, 0, 0, SRCCOPY); + bitmap_offset = (textrect.right - textrect.left - RIP_WIDTH) / 2; + BitBlt (hdc, textrect.left + bitmap_offset, textrect.bottom, RIP_WIDTH, + RIP_HEIGHT, hdcBitmap, 0, 0, SRCCOPY); SetBkMode (hdc, TRANSPARENT); if (data->rip_text) { diff --git a/win/win32/mswproc.c b/win/win32/mswproc.c index 5b5d7e48c..f1f230e29 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -14,6 +14,7 @@ #include "mhtext.h" #include "mhmsgwnd.h" #include "mhmenu.h" +#include "mhsplash.h" #include "mhmsg.h" #include "mhinput.h" #include "mhaskyn.h" @@ -177,6 +178,7 @@ void mswin_init_nhwindows(int* argc, char** argv) SET_IN_GAME ); + mswin_display_splash_window(); iflags.window_inited = TRUE; } diff --git a/win/win32/nethackw.dsp b/win/win32/nethackw.dsp index 91fb03fa5..e3ab108f6 100644 --- a/win/win32/nethackw.dsp +++ b/win/win32/nethackw.dsp @@ -1049,10 +1049,18 @@ SOURCE=..\win\win32\mhmsgwnd.h # End Source File # Begin Source File +SOURCE=..\win\win32\mhsplash.c +# End Source File +# Begin Source File + SOURCE=..\win\win32\mhrip.c # End Source File # Begin Source File +SOURCE=..\win\win32\mhsplash.h +# End Source File +# Begin Source File + SOURCE=..\win\win32\mhrip.h # End Source File # Begin Source File diff --git a/win/win32/resource.h b/win/win32/resource.h index 0e6decc78..31bc6d081 100644 --- a/win/win32/resource.h +++ b/win/win32/resource.h @@ -25,6 +25,9 @@ #define IDB_PETMARK 143 #define IDB_MENU_SEL_COUNT 144 #define IDD_NHRIP 145 +#define IDB_SPLASH 146 +#define IDB_RIP 147 +#define IDD_SPLASH 148 #define IDC_TEXT_VIEW 1000 #define IDC_TEXT_CONTROL 1000 #define IDC_CMD_MOVE_NW 1001 @@ -108,7 +111,6 @@ #define IDC_PLSEL_GENDER_LIST 1326 #define IDC_ABOUT_VERSION 1327 #define IDC_ABOUT_COPYRIGHT 1328 -#define IDB_RIP 1329 #define IDM_SAVE 32771 #define IDM_HELP_LONG 32772 #define IDM_HELP_COMMANDS 32773 diff --git a/win/win32/winMS.h b/win/win32/winMS.h index 0d80936f7..48366dae3 100644 --- a/win/win32/winMS.h +++ b/win/win32/winMS.h @@ -51,6 +51,7 @@ typedef struct mswin_nhwindow_app { HBITMAP bmpPetMark; HBITMAP bmpMapTiles; /* custom tiles bitmap */ HBITMAP bmpRip; + HBITMAP bmpSplash; int mapTile_X; /* tile width */ int mapTile_Y; /* tile height */ int mapTilesPerLine; /* number of tile per row in the bitmap */ diff --git a/win/win32/winhack.c b/win/win32/winhack.c index 253c6115f..c36549ecc 100644 --- a/win/win32/winhack.c +++ b/win/win32/winhack.c @@ -59,6 +59,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, if( _nethack_app.bmpPetMark==NULL ) panic("cannot load pet mark bitmap"); _nethack_app.bmpRip = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_RIP)); if ( _nethack_app.bmpRip == NULL ) panic("cannot load rip bitmap"); + _nethack_app.bmpSplash = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_SPLASH)); + if ( _nethack_app.bmpSplash == NULL ) panic("cannot load splash bitmap"); _nethack_app.bmpMapTiles = _nethack_app.bmpTiles; _nethack_app.mapTile_X = TILE_X; _nethack_app.mapTile_Y = TILE_Y; diff --git a/win/win32/winhack.rc b/win/win32/winhack.rc index 4ae1370e9..dfd7b661b 100644 --- a/win/win32/winhack.rc +++ b/win/win32/winhack.rc @@ -110,7 +110,7 @@ END IDD_NHTEXT DIALOGEX 0, 0, 172, 178 STYLE DS_SETFOREGROUND | WS_POPUP | WS_THICKFRAME EXSTYLE WS_EX_STATICEDGE -FONT 8, "MS Sans Serif", 0, 0, 0x1 +FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "OK",IDOK,54,163,50,14 EDITTEXT IDC_TEXT_CONTROL,0,0,170,160,ES_MULTILINE | @@ -189,6 +189,13 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,82,188,50,14 END +IDD_SPLASH DIALOGEX 0, 0, 281, 209 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Welcome to NetHack" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,82,188,50,14 +END #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -233,6 +240,7 @@ IDB_MENU_UNSEL BITMAP DISCARDABLE "mnunsel.bmp" IDB_PETMARK BITMAP DISCARDABLE "petmark.bmp" IDB_MENU_SEL_COUNT BITMAP DISCARDABLE "mnselcnt.bmp" IDB_RIP BITMAP DISCARDABLE "rip.bmp" +IDB_SPLASH BITMAP DISCARDABLE "splash.bmp" ///////////////////////////////////////////////////////////////////////////// //