splash screen patches (from <Someone>)
- Show splash on "Help - About" with all version information - Show splash with news on startup (if show_splash is on of course). I made another small patch to the splash screen. Because the greenish background colour always seemed a little odd to me, I decided to make it transparent. Doing that, I found the following: - The splash picture was a 24-bit bitmap, although it had less than 256 colours. That makes the size of the final executable about 200K larger than necessary. I changed it to a 256-colour bitmap. I also changed the background colour to the default tile background colour, for consistency. The new bitmap is attached here. My excuses if the large file means a problem to anyone. - In Microsoft's documentation (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_2y9g.asp) is is stated that on Windows 95/98 "TransparentBlt contains a memory leak that can exhaust system resources." It is recommended to use different code to draw transparent bitmaps, to be precise: the alternative code that is already in nhapply_image_transparent(). I'm almost convinced that this is the cause for Betabug B08008 reported bij <Someone>. Can anyone confirm he is using 95/98? I decided for the easy way out and removed the code that uses TransparentBlt completely. I see not much reason to use it if it is a) buggy and b) we have an alternative that works perfectly. This is attached as trans.patch. - The rest of the patch only changes the BitBlt() in mhsplash.c to a nhapply_image_transparent().
This commit is contained in:
@@ -18,7 +18,7 @@ typedef struct mswin_nethack_main_window {
|
||||
|
||||
static TCHAR szMainWindowClass[] = TEXT("MSNHMainWndClass");
|
||||
static TCHAR szTitle[MAX_LOADSTRING];
|
||||
extern void mswin_display_splash_window(void);
|
||||
extern void mswin_display_splash_window(BOOL);
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
||||
@@ -702,7 +702,7 @@ LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
switch (wmId)
|
||||
{
|
||||
case IDM_ABOUT:
|
||||
mswin_display_splash_window();
|
||||
mswin_display_splash_window(TRUE);
|
||||
break;
|
||||
|
||||
case IDM_EXIT:
|
||||
|
||||
@@ -898,26 +898,7 @@ void nhapply_image_transparent(
|
||||
COLORREF cTransparent
|
||||
)
|
||||
{
|
||||
static BOOL MSIInit = FALSE;
|
||||
static HMODULE hMSIModule = NULL;
|
||||
static LPTRANSPARENTBLT pTransparentBlt = NULL;
|
||||
|
||||
if( !MSIInit ) {
|
||||
MSIInit = TRUE;
|
||||
hMSIModule = LoadLibrary(_T("Msimg32.dll"));
|
||||
if (hMSIModule) {
|
||||
pTransparentBlt = (LPTRANSPARENTBLT) GetProcAddress(hMSIModule, "TransparentBlt");
|
||||
}
|
||||
}
|
||||
|
||||
if ( pTransparentBlt )
|
||||
{
|
||||
(*pTransparentBlt)(
|
||||
hDC, x, y, width, height,
|
||||
sourceDC, s_x, s_y, s_width, s_height,
|
||||
cTransparent
|
||||
);
|
||||
} else {
|
||||
/* Don't use TransparentBlt; According to Microsoft, it contains a memory leak in Window 95/98. */
|
||||
HDC hdcMem, hdcBack, hdcObject, hdcSave;
|
||||
COLORREF cColor;
|
||||
HBITMAP bmAndBack, bmAndObject, bmAndMem, bmSave;
|
||||
@@ -992,5 +973,4 @@ void nhapply_image_transparent(
|
||||
DeleteDC(hdcBack);
|
||||
DeleteDC(hdcObject);
|
||||
DeleteDC(hdcSave);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,16 @@
|
||||
#include "mhmsg.h"
|
||||
#include "mhfont.h"
|
||||
#include "patchlevel.h"
|
||||
#include "dlb.h"
|
||||
|
||||
#define LLEN 128
|
||||
|
||||
PNHWinApp GetNHApp(void);
|
||||
|
||||
BOOL CALLBACK NHSplashWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
#define SPLASH_WIDTH 440
|
||||
#define SPLASH_HEIGHT 240
|
||||
#define SPLASH_HEIGHT 301
|
||||
#define SPLASH_VERSION_X 290
|
||||
#define SPLASH_VERSION_Y 10
|
||||
#define SPLASH_EXTRA_X_BEGIN 15
|
||||
@@ -25,7 +28,7 @@ BOOL CALLBACK NHSplashWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
extern HFONT version_splash_font;
|
||||
extern HFONT extrainfo_splash_font;
|
||||
|
||||
void mswin_display_splash_window ()
|
||||
void mswin_display_splash_window (BOOL show_ver)
|
||||
{
|
||||
MSG msg;
|
||||
RECT rt;
|
||||
@@ -34,6 +37,7 @@ void mswin_display_splash_window ()
|
||||
RECT clientrt;
|
||||
RECT controlrt;
|
||||
HWND hWnd;
|
||||
int buttop;
|
||||
|
||||
hWnd = CreateDialog(GetNHApp()->hApp, MAKEINTRESOURCE(IDD_SPLASH),
|
||||
GetNHApp()->hMainWnd, NHSplashWndProc);
|
||||
@@ -60,12 +64,74 @@ void mswin_display_splash_window ()
|
||||
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 control */
|
||||
/* 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);
|
||||
sprintf(eos(buf), "%s",
|
||||
#if defined(BETA) && defined(BETA_INFO)
|
||||
BETA_INFO);
|
||||
#else
|
||||
"");
|
||||
#endif
|
||||
SetWindowText(GetDlgItem(hWnd, IDC_EXTRAINFO), buf);
|
||||
|
||||
} else {
|
||||
/* Show news, if any */
|
||||
FILE *nf;
|
||||
|
||||
nf = fopen(NEWS, "r");
|
||||
if (nf != NULL) {
|
||||
char *buf = NULL;
|
||||
int bufsize = 0;
|
||||
int strsize = 0;
|
||||
char line[LLEN + 1];
|
||||
|
||||
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.");
|
||||
}
|
||||
ShowWindow(hWnd, SW_SHOW);
|
||||
|
||||
while( IsWindow(hWnd) &&
|
||||
@@ -111,8 +177,11 @@ BOOL CALLBACK NHSplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
hdcBitmap = CreateCompatibleDC(hdc);
|
||||
SetBkMode (hdc, OPAQUE);
|
||||
OldBitmap = SelectObject(hdcBitmap, GetNHApp()->bmpSplash);
|
||||
BitBlt (hdc, SPLASH_OFFSET_X, SPLASH_OFFSET_Y, SPLASH_WIDTH,
|
||||
SPLASH_HEIGHT, hdcBitmap, 0, 0, SRCCOPY);
|
||||
nhapply_image_transparent(hdc, SPLASH_OFFSET_X, SPLASH_OFFSET_Y,
|
||||
SPLASH_WIDTH, SPLASH_HEIGHT,
|
||||
hdcBitmap, 0, 0, SPLASH_WIDTH, SPLASH_HEIGHT,
|
||||
TILE_BK_COLOR);
|
||||
|
||||
SelectObject (hdcBitmap, OldBitmap);
|
||||
DeleteDC (hdcBitmap);
|
||||
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
#include "config.h"
|
||||
#include "global.h"
|
||||
|
||||
void mswin_display_splash_window (void);
|
||||
void mswin_display_splash_window (BOOL);
|
||||
|
||||
#endif /* MSWINSplashWindow_h */
|
||||
|
||||
@@ -241,7 +241,7 @@ void mswin_init_nhwindows(int* argc, char** argv)
|
||||
mswin_color_from_string(iflags.wc_backgrnd_status, &status_bg_brush, &status_bg_color);
|
||||
mswin_color_from_string(iflags.wc_backgrnd_text, &text_bg_brush, &text_bg_color);
|
||||
|
||||
if (iflags.wc_splash_screen) mswin_display_splash_window();
|
||||
if (iflags.wc_splash_screen) mswin_display_splash_window(FALSE);
|
||||
iflags.window_inited = TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
#define IDC_PLSEL_GENDER_LIST 1326
|
||||
#define IDC_ABOUT_VERSION 1327
|
||||
#define IDC_ABOUT_COPYRIGHT 1328
|
||||
#define IDC_EXTRAINFO 1331
|
||||
#define IDM_SAVE 32771
|
||||
#define IDM_HELP_LONG 32772
|
||||
#define IDM_HELP_COMMANDS 32773
|
||||
@@ -143,7 +144,7 @@
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 145
|
||||
#define _APS_NEXT_COMMAND_VALUE 32796
|
||||
#define _APS_NEXT_CONTROL_VALUE 1331
|
||||
#define _APS_NEXT_CONTROL_VALUE 1332
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
||||
|
||||
9411
win/win32/splash.uu
9411
win/win32/splash.uu
File diff suppressed because it is too large
Load Diff
@@ -117,7 +117,7 @@ END
|
||||
IDD_NHTEXT DIALOGEX 0, 0, 172, 178
|
||||
STYLE DS_SETFOREGROUND | WS_CHILD | WS_THICKFRAME
|
||||
EXSTYLE WS_EX_STATICEDGE
|
||||
FONT 8, "MS Sans Serif"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,54,163,50,14
|
||||
EDITTEXT IDC_TEXT_CONTROL,0,0,170,160,ES_MULTILINE |
|
||||
@@ -127,7 +127,7 @@ END
|
||||
IDD_MENU DIALOGEX 0, 0, 187, 153
|
||||
STYLE WS_CHILD | WS_CLIPSIBLINGS | WS_THICKFRAME
|
||||
EXSTYLE WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT | WS_EX_STATICEDGE
|
||||
FONT 8, "MS Sans Serif"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,7,132,50,14,BS_FLAT
|
||||
PUSHBUTTON "Cancel",IDCANCEL,130,132,50,14,BS_FLAT
|
||||
@@ -192,17 +192,19 @@ END
|
||||
IDD_NHRIP DIALOGEX 0, 0, 281, 209
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Here lies..."
|
||||
FONT 8, "MS Sans Serif"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,82,188,50,14
|
||||
END
|
||||
|
||||
IDD_SPLASH DIALOGEX 0, 0, 281, 209
|
||||
IDD_SPLASH DIALOG DISCARDABLE 0, 0, 281, 257
|
||||
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
|
||||
DEFPUSHBUTTON "OK",IDOK,224,236,50,14
|
||||
EDITTEXT IDC_EXTRAINFO,7,191,267,37,ES_MULTILINE | ES_READONLY |
|
||||
WS_VSCROLL
|
||||
END
|
||||
|
||||
|
||||
@@ -300,6 +302,13 @@ BEGIN
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 202
|
||||
END
|
||||
|
||||
IDD_SPLASH, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 274
|
||||
BOTTOMMARGIN, 250
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
Reference in New Issue
Block a user