win32gui: adds a splash screen

The splash screen uses the VERSION_MAJOR,
VERSION_MINOR, and PATCHLEVEL macros, but there is no room in case one
of these goes into two digits.  That seems like a safe assumption to
make.

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.
This commit is contained in:
nethack.allison
2002-03-04 22:40:01 +00:00
parent 92684f0b7c
commit 5911621d9f
4 changed files with 7234 additions and 6 deletions

12
Files
View File

@@ -226,12 +226,12 @@ levstuff.dsp levstuff.mak makedefs.dsp mhaskyn.c mhaskyn.h
mhcmd.c mhcmd.h mhdlg.c mhdlg.h mhfont.c
mhfont.h mhinput.c mhinput.h mhmain.c mhmain.h
mhmap.c mhmap.h mhmenu.c mhmenu.h mhmsg.h
mhmsgwnd.c mhmsgwnd.h mhrip.c mhrip.h mhstatus.c
mhstatus.h mhtext.c mhtext.h mnsel.uu mnselcnt.uu
mnunsel.uu mswproc.c nethack.dsw nethackw.dsp petmark.uu
recover.dsp resource.h tile2bmp.c tile2bmp.dsp tilemap.dsp
tiles.dsp tiles.mak winhack.c winhack.h winhack.rc
winMS.h
mhmsgwnd.c mhmsgwnd.h mhrip.c mhrip.h mhsplash.h
mhsplash.c mhstatus.c mhstatus.h mhtext.c mhtext.h
mnsel.uu mnselcnt.uu mnunsel.uu mswproc.c nethack.dsw
nethackw.dsp petmark.uu recover.dsp resource.h splash.uu
tile2bmp.c tile2bmp.dsp tilemap.dsp tiles.dsp tiles.mak
winhack.c winhack.h winhack.rc winMS.h

170
win/win32/mhsplash.c Normal file
View File

@@ -0,0 +1,170 @@
/* Copyright (C) 2002 Yitzhak Sapir */
/* NetHack may be freely redistributed. See license for details. */
#include "winMS.h"
#include "resource.h"
#include "mhsplash.h"
#include "mhmsg.h"
#include "mhfont.h"
#include "patchlevel.h"
PNHWinApp GetNHApp(void);
BOOL CALLBACK NHSplashWndProc(HWND, UINT, WPARAM, LPARAM);
#define SPLASH_WIDTH 440
#define SPLASH_HEIGHT 240
#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 ()
{
MSG msg;
RECT rt;
HWND mapWnd;
RECT splashrt;
RECT clientrt;
RECT controlrt;
HWND hWnd;
hWnd = CreateDialog(GetNHApp()->hApp, MAKEINTRESOURCE(IDD_SPLASH),
GetNHApp()->hMainWnd, NHSplashWndProc);
if( !hWnd ) panic("Cannot create Splash window");
mswin_init_splashfonts(hWnd);
GetNHApp()->hPopupWnd = hWnd;
mapWnd = mswin_hwnd_from_winid(WIN_MAP);
if( !IsWindow(mapWnd) ) mapWnd = GetNHApp()->hMainWnd;
/* Get control size */
GetWindowRect (GetDlgItem(hWnd, IDOK), &controlrt);
controlrt.right -= controlrt.left;
controlrt.bottom -= controlrt.top;
/* Get current client area */
GetClientRect (hWnd, &clientrt);
/* Get window size */
GetWindowRect(hWnd, &splashrt);
splashrt.right -= splashrt.left;
splashrt.bottom -= splashrt.top;
/* Get difference between requested client area and current value */
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 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);
ShowWindow(hWnd, SW_SHOW);
while( IsWindow(hWnd) &&
GetMessage(&msg, NULL, 0, 0)!=0 ) {
if( !IsDialogMessage(hWnd, &msg) ) {
if (!TranslateAccelerator(msg.hwnd, GetNHApp()->hAccelTable, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
GetNHApp()->hPopupWnd = NULL;
mswin_destroy_splashfonts();
}
BOOL CALLBACK NHSplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
switch (message)
{
case WM_INITDIALOG:
/* set text control font */
hdc = GetDC(hWnd);
hdc = GetDC(hWnd);
SendMessage(hWnd, WM_SETFONT,
(WPARAM)mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE), 0);
ReleaseDC(hWnd, hdc);
ReleaseDC(hWnd, hdc);
SetFocus(GetDlgItem(hWnd, IDOK));
return FALSE;
case WM_PAINT:
{
char VersionString[BUFSZ];
char InfoString[BUFSZ];
RECT rt;
HDC hdcBitmap;
HANDLE OldBitmap;
HANDLE OldFont;
hdc = GetDC (hWnd);
/* Show splash graphic */
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);
SelectObject (hdcBitmap, OldBitmap);
DeleteDC (hdcBitmap);
SetBkMode (hdc, TRANSPARENT);
/* Print version number */
SetTextColor (hdc, RGB(0, 0, 0));
rt.right = rt.left = SPLASH_VERSION_X;
rt.bottom = rt.top = SPLASH_VERSION_Y;
Sprintf (VersionString, "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR,
PATCHLEVEL);
OldFont = SelectObject(hdc, version_splash_font);
DrawText (hdc, VersionString, strlen(VersionString), &rt,
DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
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);
ReleaseDC(hWnd, hdc);
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
mswin_window_mark_dead(mswin_winid_from_handle(hWnd));
if( GetNHApp()->hMainWnd==hWnd )
GetNHApp()->hMainWnd=NULL;
DestroyWindow(hWnd);
SetFocus(GetNHApp()->hMainWnd);
return TRUE;
}
break;
}
return FALSE;
}

13
win/win32/mhsplash.h Normal file
View File

@@ -0,0 +1,13 @@
/* Copyright (C) 2002 by Alex Kompel */
/* NetHack may be freely redistributed. See license for details. */
#ifndef MSWINSplashWindow_h
#define MSWINSplashWindow_h
#include "winMS.h"
#include "config.h"
#include "global.h"
void mswin_display_splash_window (void);
#endif /* MSWINSplashWindow_h */

7045
win/win32/splash.uu Normal file

File diff suppressed because it is too large Load Diff