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:
nethack.allison
2002-11-03 15:26:41 +00:00
parent 2b31ea2c96
commit 04f845f87b
8 changed files with 2465 additions and 7077 deletions
+74 -5
View File
@@ -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);