Merge branch 'NetHack-3.6.2'

This commit is contained in:
nhmall
2018-11-17 08:32:59 -05:00
26 changed files with 929 additions and 567 deletions

View File

@@ -1,4 +1,4 @@
! $NHDT-Date: 1524689294 2018/04/25 20:48:14 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.15 $
! $NHDT-Date: 1542244983 2018/11/15 01:23:03 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.20 $
! Copyright (c) 2017 by Pasi Kallinen
! NetHack may be freely redistributed. See license for details.
@@ -37,7 +37,7 @@ NetHack*text*borderWidth: 0
!
NetHack.tile_file: x11tiles
!NetHack.double_tile_size: True
!
! The annotation of pets.
!NetHack.pet_mark_bitmap: pet_mark.xbm
!NetHack.pet_mark_color: Red
@@ -57,30 +57,25 @@ NetHack.tile_file: x11tiles
! The color to use for the text on the hero's tombstone
NetHack*rip*foreground: black
! Translation tables. There are currently several actions in nethack, but
! the only one you should be using is "input()", which, with no parameters,
! uses XLookupString to translate your keypress into a command. You
! can optionally give it parameters to change the behavior, see the example
! below. Note that you have to specify the translations in every appropriate
! window.
NetHack*message*translations: <KeyPress>: input()
!
! Example extra translations for the map window.
!
!NetHack*map*translations: #override \
! !<Key>Left: input(h) \n\
! !<Key>Right: input(l) \n\
! !<Key>Up: input(k) \n\
! !<Key>Down: input(j)
!
! The icon to use; supported values are nh72, nh56, and nh32; nh72 is the
! default. Some window managers may not support the larger icon sizes.
! It is not guaranteed that the window manager will honor the icon selection.
!NetHack*icon: nh56
!
! If True, the default, a popup for single character prompts such as y/n
! questions is _not_ used.
NetHack*slow: True
! questions is _not_ used. Single-character prompts appear in a fixed
! position between the top of the map and the bottom of the messages.
! If False, popups appear near where the pointer is positioned so tend to
! meander around the screen depending upon where the last click ocurred.
! (The name 'slow' is misleading; this feature was originally necessitated
! by window managers which were slow putting up popup windows, but the
! fixed-position prompting can be just as useful for quick popups.)
!NetHack*slow: False
! If True, force keyboard to attach to popup windows. Some window managers
! enforce a click-to-focus-keyboard policy (e.g. the DECwindows wm). NetHack
! has a lot of popups and is almost unplayable without some kind of autofocus.
!NetHack*autofocus: True
! If 'slow' is True, setting 'highlight_prompt' to True will cause the line
! between map and message display that's used for prompting to be "hidden"
@@ -91,19 +86,33 @@ NetHack*highlight_prompt: False
! The number of lines the message window will show without scrolling.
!NetHack*message_lines: 12
!
! If True, the message window has a line that seperates old and new messages.
!NetHack*message_line: True
!
! If True, force keyboard to attach to popup windows. Some window managers
! enforce a click-to-focus-keyboard policy (e.g. the DECwindows wm). NetHack
! has a lot of popups and is almost unplayable without some kind of autofocus.
!NetHack*autofocus: True
!
! True, use a "fancy" style status area vs. TTY-style status lines
! If True, the default, use a "fancy" style status area below the map.
! Fancy status has some highlighting but does not honor HILITE_STATUS.
! If False, use TTY-style status lines (two text lines below the map).
! TTY status honors HILITE_STATUS thresholds and colors, but for
! attributes only supports inverse (not bold, dim, blink, or underline).
! (As of this writing, fancy status looks better with a tiles map and
! tty-style status looks good with a text map but not with a tiles one.)
!NetHack*fancy_status: False
! Translation tables. There are currently several actions in nethack, but
! the only one you should be using is "input()", which, with no parameters,
! uses XLookupString to translate your keypress into a command. You can
! optionally give it parameters to change the behavior, see the example below.
! Note that you have to specify the translations in every appropriate window.
NetHack*message*translations: <KeyPress>: input()
!
! Example extra translations for the map window.
!NetHack*map*translations: #override \
! !<Key>Left: input(h) \n\
! !<Key>Right: input(l) \n\
! !<Key>Up: input(k) \n\
! !<Key>Down: input(j)
! Specify the number of rows and columns of the map window. The default
! is the standard 80x21 window. Note: this _does_not_ change nethack's
! level size, only what you see of it.

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 winmenu.c $NHDT-Date: 1539812601 2018/10/17 21:43:21 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.28 $ */
/* NetHack 3.6 winmenu.c $NHDT-Date: 1542245161 2018/11/15 01:26:01 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.33 $ */
/* Copyright (c) Dean Luick, 1992 */
/* NetHack may be freely redistributed. See license for details. */
@@ -45,6 +45,7 @@ static void FDECL(menu_all, (Widget, XtPointer, XtPointer));
static void FDECL(menu_none, (Widget, XtPointer, XtPointer));
static void FDECL(menu_invert, (Widget, XtPointer, XtPointer));
static void FDECL(menu_search, (Widget, XtPointer, XtPointer));
static void FDECL(search_menu, (struct xwindow *));
static void FDECL(select_all, (struct xwindow *));
static void FDECL(select_none, (struct xwindow *));
static void FDECL(select_match, (struct xwindow *, char *));
@@ -285,25 +286,9 @@ Cardinal *num_params;
menu_info->counting = TRUE;
return;
} else if (ch == MENU_SEARCH) { /* search */
if (menu_info->how == PICK_ANY || menu_info->how == PICK_ONE) {
char buf[BUFSZ + 2], tmpbuf[BUFSZ];
X11_getlin("Search for:", tmpbuf);
if (!*tmpbuf || *tmpbuf == '\033')
return;
/* convert "string" into "*string*" for use with pmatch() */
Sprintf(buf, "*%s*", tmpbuf);
if (menu_info->how == PICK_ANY) {
invert_match(wp, buf);
return;
} else {
select_match(wp, buf);
}
} else {
X11_nhbell();
search_menu(wp);
if (menu_info->how == PICK_ANY)
return;
}
} else if (ch == MENU_SELECT_ALL || ch == MENU_SELECT_PAGE) {
if (menu_info->how == PICK_ANY)
select_all(wp);
@@ -471,26 +456,49 @@ XtPointer client_data, call_data;
{
struct xwindow *wp = (struct xwindow *) client_data;
struct menu_info_t *menu_info = wp->menu_information;
char buf[BUFSZ + 2], tmpbuf[BUFSZ];
nhUse(w);
nhUse(call_data);
X11_getlin("Search for:", tmpbuf);
if (!*tmpbuf || *tmpbuf == '\033')
return;
/* convert "string" into "*string*" for use with pmatch() */
Sprintf(buf, "*%s*", tmpbuf);
if (menu_info->how == PICK_ANY)
invert_match(wp, buf);
else
select_match(wp, buf);
search_menu(wp);
if (menu_info->how == PICK_ONE)
menu_popdown(wp);
}
/* common to menu_search and menu_key */
static void
search_menu(wp)
struct xwindow *wp;
{
char *pat, buf[BUFSZ + 2]; /* room for '*' + BUFSZ-1 + '*' + '\0' */
struct menu_info_t *menu_info = wp->menu_information;
buf[0] = buf[1] = '\0';
pat = &buf[1]; /* leave room to maybe insert '*' at front */
if (menu_info->how != PICK_NONE) {
X11_getlin("Search for:", pat);
if (!*pat || *pat == '\033')
return;
/* convert "string" into "*string*" for use with pmatch() */
if (*pat != '*')
*--pat = '*'; /* now points to &buf[0] */
if (*(eos(pat) - 1) != '*')
Strcat(pat, "*");
}
switch (menu_info->how) {
case PICK_ANY:
invert_match(wp, pat);
break;
case PICK_ONE:
select_match(wp, pat);
break;
default: /* PICK_NONE */
X11_nhbell();
break;
}
}
static void
select_all(wp)
struct xwindow *wp;

View File

@@ -4,6 +4,7 @@
/* font management and such */
#include "win10.h"
#include "winos.h"
#include "mhfont.h"
@@ -26,9 +27,10 @@ void
mswin_init_splashfonts(HWND hWnd)
{
HDC hdc = GetDC(hWnd);
double scale = win10_monitor_scale(hWnd);
LOGFONT lgfnt;
ZeroMemory(&lgfnt, sizeof(lgfnt));
lgfnt.lfHeight = -80; // height of font
lgfnt.lfHeight = -(int)(80 * scale); // height of font
lgfnt.lfWidth = 0; // average character width
lgfnt.lfEscapement = 0; // angle of escapement
lgfnt.lfOrientation = 0; // base-line orientation angle

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,7 @@ 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
#define ROGUE_LEVEL_MAP_MODE_FIT_TO_SCREEN MAP_MODE_ASCII_FIT_TO_SCREEN
#define DEF_CLIPAROUND_MARGIN 5
#define DEF_CLIPAROUND_AMOUNT 1

View File

@@ -2,6 +2,7 @@
/* Copyright (c) Alex Kompel, 2002 */
/* NetHack may be freely redistributed. See license for details. */
#include "win10.h"
#include "winMS.h"
#include <assert.h>
#include "resource.h"
@@ -22,6 +23,9 @@
#define DEFAULT_COLOR_BG_MENU COLOR_WINDOW
#define DEFAULT_COLOR_FG_MENU COLOR_WINDOWTEXT
#define CHECK_WIDTH 16
#define CHECK_HEIGHT 16
typedef struct mswin_menu_item {
int glyph;
ANY_P identifier;
@@ -61,6 +65,7 @@ typedef struct mswin_nethack_menu_window {
HBITMAP bmpChecked;
HBITMAP bmpCheckedCount;
HBITMAP bmpNotChecked;
HDC bmpDC;
BOOL is_active;
} NHMenuWindow, *PNHMenuWindow;
@@ -267,14 +272,14 @@ mswin_menu_window_select_menu(HWND hWnd, int how, MENU_ITEM_P **_selected,
INT_PTR CALLBACK
MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PNHMenuWindow data;
HWND control;
HDC hdc;
PNHMenuWindow data = (PNHMenuWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
HWND control = GetDlgItem(hWnd, IDC_MENU_TEXT);
TCHAR title[MAX_LOADSTRING];
data = (PNHMenuWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
switch (message) {
case WM_INITDIALOG:
case WM_INITDIALOG: {
HDC hdc = GetDC(control);
data = (PNHMenuWindow) malloc(sizeof(NHMenuWindow));
ZeroMemory(data, sizeof(NHMenuWindow));
data->type = MENU_TYPE_TEXT;
@@ -287,12 +292,11 @@ MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LoadBitmap(GetNHApp()->hApp, MAKEINTRESOURCE(IDB_MENU_SEL_COUNT));
data->bmpNotChecked =
LoadBitmap(GetNHApp()->hApp, MAKEINTRESOURCE(IDB_MENU_UNSEL));
data->bmpDC = CreateCompatibleDC(hdc);
data->is_active = FALSE;
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) data);
/* set font for the text cotrol */
control = GetDlgItem(hWnd, IDC_MENU_TEXT);
hdc = GetDC(control);
SendMessage(control, WM_SETFONT,
(WPARAM) mswin_get_font(NHW_MENU, ATR_NONE, hdc, FALSE),
(LPARAM) 0);
@@ -310,6 +314,7 @@ MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
/* set focus to text control for now */
SetFocus(control);
}
return FALSE;
case WM_MSNH_COMMAND:
@@ -500,6 +505,7 @@ MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_DESTROY:
if (data) {
DeleteDC(data->bmpDC);
DeleteObject(data->bmpChecked);
DeleteObject(data->bmpCheckedCount);
DeleteObject(data->bmpNotChecked);
@@ -862,9 +868,11 @@ SetMenuListType(HWND hWnd, int how)
SendMessage(control, WM_SETFONT, (WPARAM) fnt, (LPARAM) 0);
/* add column to the list view */
MonitorInfo monitorInfo;
win10_monitor_info(hWnd, &monitorInfo);
ZeroMemory(&lvcol, sizeof(lvcol));
lvcol.mask = LVCF_WIDTH | LVCF_TEXT;
lvcol.cx = GetSystemMetrics(SM_CXFULLSCREEN);
lvcol.cx = monitorInfo.width;
lvcol.pszText = NH_A2W(data->menu.prompt, wbuf, BUFSZ);
ListView_InsertColumn(control, 0, &lvcol);
@@ -975,6 +983,9 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
int color = NO_COLOR, attr;
boolean menucolr = FALSE;
double monitorScale = win10_monitor_scale(hWnd);
int tileXScaled = (int) (TILE_X * monitorScale);
int tileYScaled = (int) (TILE_Y * monitorScale);
UNREFERENCED_PARAMETER(wParam);
@@ -1009,30 +1020,29 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
if (NHMENU_IS_SELECTABLE(*item)) {
char buf[2];
if (data->how != PICK_NONE) {
HGDIOBJ saveBrush;
HBRUSH hbrCheckMark;
HBITMAP bmpCheck;
HBITMAP bmpSaved;
switch (item->count) {
case -1:
hbrCheckMark = CreatePatternBrush(data->bmpChecked);
bmpCheck = data->bmpChecked;
break;
case 0:
hbrCheckMark = CreatePatternBrush(data->bmpNotChecked);
bmpCheck = data->bmpNotChecked;
break;
default:
hbrCheckMark = CreatePatternBrush(data->bmpCheckedCount);
bmpCheck = data->bmpCheckedCount;
break;
}
y = (lpdis->rcItem.bottom + lpdis->rcItem.top - TILE_Y) / 2;
SetBrushOrgEx(lpdis->hDC, x, y, NULL);
saveBrush = SelectObject(lpdis->hDC, hbrCheckMark);
PatBlt(lpdis->hDC, x, y, TILE_X, TILE_Y, PATCOPY);
SelectObject(lpdis->hDC, saveBrush);
DeleteObject(hbrCheckMark);
y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tileYScaled) / 2;
bmpSaved = SelectBitmap(data->bmpDC, bmpCheck);
StretchBlt(lpdis->hDC, x, y, tileXScaled, tileYScaled,
data->bmpDC, 0, 0, CHECK_WIDTH, CHECK_HEIGHT, SRCCOPY);
SelectObject(data->bmpDC, bmpSaved);
}
x += TILE_X + spacing;
x += tileXScaled + spacing;
if (item->accelerator != 0) {
buf[0] = item->accelerator;
@@ -1053,13 +1063,14 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
}
x += tm.tmAveCharWidth + tm.tmOverhang + spacing;
} else {
x += TILE_X + tm.tmAveCharWidth + tm.tmOverhang + 2 * spacing;
x += tileXScaled + tm.tmAveCharWidth + tm.tmOverhang + 2 * spacing;
}
/* print glyph if present */
if (NHMENU_HAS_GLYPH(*item)) {
if (!IS_MAP_ASCII(iflags.wc_map_mode)) {
HGDIOBJ saveBmp;
double monitorScale = win10_monitor_scale(hWnd);
saveBmp = SelectObject(tileDC, GetNHApp()->bmpMapTiles);
ntile = glyph2tile[item->glyph];
@@ -1068,21 +1079,21 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
t_y =
(ntile / GetNHApp()->mapTilesPerLine) * GetNHApp()->mapTile_Y;
y = (lpdis->rcItem.bottom + lpdis->rcItem.top
- GetNHApp()->mapTile_Y) / 2;
y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tileYScaled) / 2;
if (GetNHApp()->bmpMapTiles == GetNHApp()->bmpTiles) {
/* using original nethack tiles - apply image transparently */
(*GetNHApp()->lpfnTransparentBlt)(lpdis->hDC, x, y, TILE_X, TILE_Y,
(*GetNHApp()->lpfnTransparentBlt)(lpdis->hDC, x, y,
tileXScaled, tileYScaled,
tileDC, t_x, t_y, TILE_X, TILE_Y,
TILE_BK_COLOR);
} else {
/* using custom tiles - simple blt */
BitBlt(lpdis->hDC, x, y, GetNHApp()->mapTile_X,
GetNHApp()->mapTile_Y, tileDC, t_x, t_y, SRCCOPY);
StretchBlt(lpdis->hDC, x, y, tileXScaled, tileYScaled,
tileDC, t_x, t_y, GetNHApp()->mapTile_X, GetNHApp()->mapTile_Y, SRCCOPY);
}
SelectObject(tileDC, saveBmp);
x += GetNHApp()->mapTile_X;
x += tileXScaled;
} else {
const char *sel_ind;
switch (item->count) {
@@ -1106,7 +1117,7 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
}
} else {
/* no glyph - need to adjust so help window won't look to cramped */
x += TILE_X;
x += tileXScaled;
}
x += spacing;

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2001 by Alex Kompel */
/* NetHack may be freely redistributed. See license for details. */
#include "win10.h"
#include "winMS.h"
#include "resource.h"
#include "mhrip.h"
@@ -25,6 +26,14 @@ typedef struct mswin_nethack_text_window {
HANDLE rip_bmp;
TCHAR *window_text;
TCHAR *rip_text;
int x;
int y;
int width;
int height;
int graveX;
int graveY;
int graveHeight;
int graveWidth;
} NHRIPWindow, *PNHRIPWindow;
INT_PTR CALLBACK NHRIPWndProc(HWND, UINT, WPARAM, LPARAM);
@@ -62,9 +71,21 @@ mswin_display_RIP_window(HWND hWnd)
RECT textrect;
HDC hdc;
HFONT OldFont;
MonitorInfo monitorInfo;
win10_monitor_info(hWnd, &monitorInfo);
data = (PNHRIPWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
data->x = (int)(RIP_OFFSET_X * monitorInfo.scale);
data->y = (int)(RIP_OFFSET_Y * monitorInfo.scale);
data->width = (int)(RIP_WIDTH * monitorInfo.scale);
data->height = (int)(RIP_HEIGHT * monitorInfo.scale);
data->graveX = (int)(RIP_GRAVE_X * monitorInfo.scale);
data->graveY = (int)(RIP_GRAVE_Y * monitorInfo.scale);
data->graveWidth = (int)(RIP_GRAVE_WIDTH * monitorInfo.scale);
data->graveHeight = (int)(RIP_GRAVE_HEIGHT * monitorInfo.scale);
GetNHApp()->hPopupWnd = hWnd;
mapWnd = mswin_hwnd_from_winid(WIN_MAP);
if (!IsWindow(mapWnd))
@@ -73,9 +94,9 @@ mswin_display_RIP_window(HWND hWnd)
GetWindowRect(hWnd, &riprt);
GetClientRect(hWnd, &clientrect);
textrect = clientrect;
textrect.top += RIP_OFFSET_Y;
textrect.left += RIP_OFFSET_X;
textrect.right -= RIP_OFFSET_X;
textrect.top += data->y;
textrect.left += data->x;
textrect.right -= data->x;
if (data->window_text) {
hdc = GetDC(hWnd);
OldFont = SelectObject(hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE));
@@ -84,17 +105,17 @@ mswin_display_RIP_window(HWND hWnd)
SelectObject(hdc, OldFont);
ReleaseDC(hWnd, hdc);
}
if (textrect.right - textrect.left > RIP_WIDTH)
clientrect.right = textrect.right + RIP_OFFSET_X - clientrect.right;
if (textrect.right - textrect.left > data->width)
clientrect.right = textrect.right + data->y - clientrect.right;
else
clientrect.right =
textrect.left + 2 * RIP_OFFSET_X + RIP_WIDTH - clientrect.right;
textrect.left + 2 * data->x + data->width - clientrect.right;
clientrect.bottom =
textrect.bottom + RIP_HEIGHT + RIP_OFFSET_Y - clientrect.bottom;
textrect.bottom + data->height + data->y - clientrect.bottom;
GetWindowRect(GetDlgItem(hWnd, IDOK), &textrect);
textrect.right -= textrect.left;
textrect.bottom -= textrect.top;
clientrect.bottom += textrect.bottom + RIP_OFFSET_Y;
clientrect.bottom += textrect.bottom + data->y;
riprt.right -= riprt.left;
riprt.bottom -= riprt.top;
riprt.right += clientrect.right;
@@ -106,7 +127,7 @@ mswin_display_RIP_window(HWND hWnd)
GetClientRect(hWnd, &clientrect);
MoveWindow(GetDlgItem(hWnd, IDOK),
(clientrect.right - clientrect.left - textrect.right) / 2,
clientrect.bottom - textrect.bottom - RIP_OFFSET_Y,
clientrect.bottom - textrect.bottom - data->y,
textrect.right, textrect.bottom, TRUE);
ShowWindow(hWnd, SW_SHOW);
@@ -158,9 +179,9 @@ NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
SetBkMode(hdc, TRANSPARENT);
GetClientRect(hWnd, &clientrect);
textrect = clientrect;
textrect.top += RIP_OFFSET_Y;
textrect.left += RIP_OFFSET_X;
textrect.right -= RIP_OFFSET_X;
textrect.top += data->y;
textrect.left += data->x;
textrect.right -= data->x;
if (data->window_text) {
DrawText(hdc, data->window_text, strlen(data->window_text),
&textrect, DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
@@ -169,15 +190,16 @@ NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
OldBitmap = SelectObject(hdcBitmap, GetNHApp()->bmpRip);
SetBkMode(hdc, OPAQUE);
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);
bitmap_offset = (textrect.right - textrect.left - data->width) / 2;
StretchBlt(hdc, textrect.left + bitmap_offset, textrect.bottom,
data->width, data->height,
hdcBitmap, 0, 0, RIP_WIDTH, RIP_HEIGHT, SRCCOPY);
SetBkMode(hdc, TRANSPARENT);
if (data->rip_text) {
textrect.left += RIP_GRAVE_X + bitmap_offset;
textrect.top = textrect.bottom + RIP_GRAVE_Y;
textrect.right = textrect.left + RIP_GRAVE_WIDTH;
textrect.bottom = textrect.top + RIP_GRAVE_HEIGHT;
textrect.left += data->graveX + bitmap_offset;
textrect.top = textrect.bottom + data->graveY;
textrect.right = textrect.left + data->graveWidth;
textrect.bottom = textrect.top + data->graveHeight;
DrawText(hdc, data->rip_text, strlen(data->rip_text), &textrect,
DT_CENTER | DT_VCENTER | DT_NOPREFIX | DT_WORDBREAK);
}

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2001 by Alex Kompel */
/* NetHack may be freely redistributed. See license for details. */
#include "win10.h"
#include "winMS.h"
#include "resource.h"
#include "mhsplash.h"
@@ -17,15 +18,24 @@ PNHWinApp GetNHApp(void);
INT_PTR CALLBACK NHSplashWndProc(HWND, UINT, WPARAM, LPARAM);
#define SPLASH_WIDTH 440
#define SPLASH_HEIGHT 322
#define SPLASH_VERSION_X 290
#define SPLASH_VERSION_Y 10
#define SPLASH_OFFSET_X 10
#define SPLASH_OFFSET_Y 10
#define SPLASH_WIDTH_96DPI 440
#define SPLASH_HEIGHT_96DPI 322
#define SPLASH_OFFSET_X_96DPI 10
#define SPLASH_OFFSET_Y_96DPI 10
#define SPLASH_VERSION_X_96DPI 280
#define SPLASH_VERSION_Y_96DPI 0
extern HFONT version_splash_font;
typedef struct {
int width;
int height;
int offsetX;
int offsetY;
int versionX;
int versionY;
} SplashData;
void
mswin_display_splash_window(BOOL show_ver)
{
@@ -34,16 +44,30 @@ mswin_display_splash_window(BOOL show_ver)
RECT splashrt;
RECT clientrt;
RECT controlrt;
HWND hWnd;
int buttop;
strbuf_t strbuf;
strbuf_init(&strbuf);
hWnd = CreateDialog(GetNHApp()->hApp, MAKEINTRESOURCE(IDD_SPLASH),
HWND hWnd = CreateDialog(GetNHApp()->hApp, MAKEINTRESOURCE(IDD_SPLASH),
GetNHApp()->hMainWnd, NHSplashWndProc);
if (!hWnd)
panic("Cannot create Splash window");
MonitorInfo monitorInfo;
win10_monitor_info(hWnd, &monitorInfo);
SplashData splashData;
splashData.width = (int) (monitorInfo.scale * SPLASH_WIDTH_96DPI);
splashData.height = (int) (monitorInfo.scale * SPLASH_HEIGHT_96DPI);
splashData.offsetX = (int) (monitorInfo.scale * SPLASH_OFFSET_X_96DPI);
splashData.offsetY = (int) (monitorInfo.scale * SPLASH_OFFSET_Y_96DPI);
splashData.versionX = (int) (monitorInfo.scale * SPLASH_VERSION_X_96DPI);
splashData.versionY = (int) (monitorInfo.scale * SPLASH_VERSION_Y_96DPI);
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) &splashData);
mswin_init_splashfonts(hWnd);
GetNHApp()->hPopupWnd = hWnd;
/* Get control size */
@@ -57,30 +81,32 @@ mswin_display_splash_window(BOOL show_ver)
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;
splashrt.right += splashData.width + splashData.offsetX * 2
- clientrt.right;
splashrt.bottom += splashData.height + controlrt.bottom
+ splashData.offsetY * 3
- clientrt.bottom;
/* Place the window centered */
/* On the screen, not on the parent window */
left = (GetSystemMetrics(SM_CXSCREEN) - splashrt.right) / 2;
top = (GetSystemMetrics(SM_CYSCREEN) - splashrt.bottom) / 2;
left = (monitorInfo.width - splashrt.right) / 2;
top = (monitorInfo.height - splashrt.bottom) / 2;
MoveWindow(hWnd, left, top, splashrt.right, splashrt.bottom, TRUE);
/* 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,
clientrt.bottom - controlrt.bottom - splashData.offsetY,
controlrt.right, controlrt.bottom, TRUE);
buttop = clientrt.bottom - controlrt.bottom - SPLASH_OFFSET_Y;
buttop = clientrt.bottom - controlrt.bottom - splashData.offsetY;
/* 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);
clientrt.left + splashData.offsetX,
buttop - controlrt.bottom - splashData.offsetY,
clientrt.right - 2 * splashData.offsetX, controlrt.bottom, TRUE);
/* Fill the text control */
strbuf_reserve(&strbuf, BUFSIZ);
@@ -168,16 +194,19 @@ NHSplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
HANDLE OldFont;
PAINTSTRUCT ps;
SplashData *splashData = (SplashData *) GetWindowLongPtr(hWnd, GWLP_USERDATA);
hdc = BeginPaint(hWnd, &ps);
/* Show splash graphic */
hdcBitmap = CreateCompatibleDC(hdc);
SetBkMode(hdc, OPAQUE);
OldBitmap = SelectObject(hdcBitmap, GetNHApp()->bmpSplash);
(*GetNHApp()->lpfnTransparentBlt)(hdc, SPLASH_OFFSET_X, SPLASH_OFFSET_Y,
SPLASH_WIDTH, SPLASH_HEIGHT, hdcBitmap, 0,
0, SPLASH_WIDTH, SPLASH_HEIGHT,
TILE_BK_COLOR);
(*GetNHApp()->lpfnTransparentBlt)(hdc,
splashData->offsetX, splashData->offsetY,
splashData->width, splashData->height, hdcBitmap,
0, 0, SPLASH_WIDTH_96DPI, SPLASH_HEIGHT_96DPI,
TILE_BK_COLOR);
SelectObject(hdcBitmap, OldBitmap);
DeleteDC(hdcBitmap);
@@ -186,8 +215,8 @@ NHSplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
/* Print version number */
SetTextColor(hdc, RGB(0, 0, 0));
rt.right = rt.left = SPLASH_VERSION_X;
rt.bottom = rt.top = SPLASH_VERSION_Y;
rt.right = rt.left = splashData->offsetX + splashData->versionX;
rt.bottom = rt.top = splashData->offsetY + splashData->versionY;
Sprintf(VersionString, "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR,
PATCHLEVEL);
OldFont = SelectObject(hdc, version_splash_font);

View File

@@ -813,8 +813,14 @@ mswin_clear_nhwindow(winid wid)
&& (GetNHApp()->windowlist[wid].win != NULL)) {
if (GetNHApp()->windowlist[wid].type == NHW_MAP) {
if (Is_rogue_level(&u.uz))
mswin_map_mode(mswin_hwnd_from_winid(WIN_MAP),
ROGUE_LEVEL_MAP_MODE);
if (iflags.wc_map_mode == MAP_MODE_ASCII_FIT_TO_SCREEN ||
iflags.wc_map_mode == MAP_MODE_TILES_FIT_TO_SCREEN)
mswin_map_mode(mswin_hwnd_from_winid(WIN_MAP),
ROGUE_LEVEL_MAP_MODE_FIT_TO_SCREEN);
else
mswin_map_mode(mswin_hwnd_from_winid(WIN_MAP),
ROGUE_LEVEL_MAP_MODE);
else
mswin_map_mode(mswin_hwnd_from_winid(WIN_MAP),
iflags.wc_map_mode);