Started work to support per monitor DPI. Using DPI to scale tiles
appropriately. Renamed ntassert to nhassert. (Naming mistake caused by using ntassert at work). Re-ordered a few more includes to get window headers included before nethack headers.
This commit is contained in:
@@ -249,13 +249,13 @@ extern int FDECL(alternative_palette, (char *));
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define ntassert(expression) ((void)0)
|
||||
#define nhassert(expression) ((void)0)
|
||||
#else
|
||||
extern void FDECL(ntassert_failed, (const char * exp, const char * file,
|
||||
extern void FDECL(nhassert_failed, (const char * exp, const char * file,
|
||||
int line));
|
||||
|
||||
#define ntassert(expression) (void)((!!(expression)) || \
|
||||
(ntassert_failed(#expression, __FILE__, __LINE__), 0))
|
||||
#define nhassert(expression) (void)((!!(expression)) || \
|
||||
(nhassert_failed(#expression, __FILE__, __LINE__), 0))
|
||||
#endif
|
||||
|
||||
#define nethack_enter(argc, argv) nethack_enter_winnt()
|
||||
|
||||
@@ -242,8 +242,8 @@ static void back_buffer_flip()
|
||||
|
||||
void buffer_fill_to_end(cell_t * buffer, cell_t * fill, int x, int y)
|
||||
{
|
||||
ntassert(x >= 0 && x < console.width);
|
||||
ntassert(y >= 0 && ((y < console.height) || (y == console.height &&
|
||||
nhassert(x >= 0 && x < console.width);
|
||||
nhassert(y >= 0 && ((y < console.height) || (y == console.height &&
|
||||
x == 0)));
|
||||
|
||||
cell_t * dst = buffer + console.width * y + x;
|
||||
@@ -257,8 +257,8 @@ void buffer_fill_to_end(cell_t * buffer, cell_t * fill, int x, int y)
|
||||
|
||||
static void buffer_clear_to_end_of_line(cell_t * buffer, int x, int y)
|
||||
{
|
||||
ntassert(x >= 0 && x < console.width);
|
||||
ntassert(y >= 0 && ((y < console.height) || (y == console.height &&
|
||||
nhassert(x >= 0 && x < console.width);
|
||||
nhassert(y >= 0 && ((y < console.height) || (y == console.height &&
|
||||
x == 0)));
|
||||
cell_t * dst = buffer + console.width * y + x;
|
||||
cell_t *sentinel = buffer + console.width * (y + 1);
|
||||
@@ -272,8 +272,8 @@ static void buffer_clear_to_end_of_line(cell_t * buffer, int x, int y)
|
||||
|
||||
void buffer_write(cell_t * buffer, cell_t * cell, COORD pos)
|
||||
{
|
||||
ntassert(pos.X >= 0 && pos.X < console.width);
|
||||
ntassert(pos.Y >= 0 && pos.Y < console.height);
|
||||
nhassert(pos.X >= 0 && pos.X < console.width);
|
||||
nhassert(pos.Y >= 0 && pos.Y < console.height);
|
||||
|
||||
cell_t * dst = buffer + (console.width * pos.Y) + pos.X;
|
||||
*dst = *cell;
|
||||
@@ -465,8 +465,8 @@ int *x, *y, *mod;
|
||||
|
||||
static void set_console_cursor(int x, int y)
|
||||
{
|
||||
ntassert(x >= 0 && x < console.width);
|
||||
ntassert(y >= 0 && y < console.height);
|
||||
nhassert(x >= 0 && x < console.width);
|
||||
nhassert(y >= 0 && y < console.height);
|
||||
|
||||
console.cursor.X = max(0, min(console.width - 1, x));
|
||||
console.cursor.Y = max(0, min(console.height - 1, y));
|
||||
@@ -547,8 +547,8 @@ void
|
||||
xputc_core(ch)
|
||||
char ch;
|
||||
{
|
||||
ntassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
ntassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
|
||||
boolean inverse = FALSE;
|
||||
cell_t cell;
|
||||
@@ -596,8 +596,8 @@ char ch;
|
||||
}
|
||||
}
|
||||
|
||||
ntassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
ntassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -982,7 +982,7 @@ register char *op;
|
||||
|
||||
void unload_keyboard_handler()
|
||||
{
|
||||
ntassert(keyboard_handler.hLibrary != NULL);
|
||||
nhassert(keyboard_handler.hLibrary != NULL);
|
||||
|
||||
FreeLibrary(keyboard_handler.hLibrary);
|
||||
memset(&keyboard_handler, 0, sizeof(keyboard_handler_t));
|
||||
@@ -1619,10 +1619,10 @@ set_known_good_console_font()
|
||||
L"Consolas");
|
||||
|
||||
success = SetConsoleOutputCP(437);
|
||||
ntassert(success);
|
||||
nhassert(success);
|
||||
|
||||
success = SetCurrentConsoleFontEx(console.hConOut, FALSE, &console_font_info);
|
||||
ntassert(success);
|
||||
nhassert(success);
|
||||
}
|
||||
|
||||
/* restore_original_console_font will restore the console font and code page
|
||||
@@ -1665,7 +1665,7 @@ void set_cp_map()
|
||||
char c = (char)i;
|
||||
int count = MultiByteToWideChar(codePage, 0, &c, 1,
|
||||
&console.cpMap[i], 1);
|
||||
ntassert(count == 1);
|
||||
nhassert(count == 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1685,8 +1685,8 @@ void early_raw_print(const char *s)
|
||||
if (console.hConOut == NULL)
|
||||
return;
|
||||
|
||||
ntassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
ntassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
|
||||
WORD attribute = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE;
|
||||
DWORD unused;
|
||||
@@ -1725,8 +1725,8 @@ void early_raw_print(const char *s)
|
||||
s++;
|
||||
}
|
||||
|
||||
ntassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
ntassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
|
||||
SetConsoleCursorPosition(console.hConOut, console.cursor);
|
||||
|
||||
@@ -1762,7 +1762,7 @@ void nethack_enter_nttty()
|
||||
windowprocs.win_raw_print = early_raw_print;
|
||||
|
||||
console.hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
ntassert(console.hConOut != NULL); // NOTE: this assert will not print
|
||||
nhassert(console.hConOut != NULL); // NOTE: this assert will not print
|
||||
|
||||
GetConsoleScreenBufferInfo(console.hConOut, &console.origcsbi);
|
||||
|
||||
@@ -1803,7 +1803,7 @@ void nethack_enter_nttty()
|
||||
/* At this point early_raw_print will work */
|
||||
|
||||
console.hConIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||
ntassert(console.hConIn != NULL);
|
||||
nhassert(console.hConIn != NULL);
|
||||
|
||||
/* grow the size of the console buffer if it is not wide enough */
|
||||
if (console.origcsbi.dwSize.X < console.width) {
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
/* Copyright (C) 2018 by Bart House */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include <process.h>
|
||||
#include "winMS.h"
|
||||
#include "hack.h"
|
||||
#include "win10.h"
|
||||
#include <process.h>
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
Win10 gWin10 = { 0 };
|
||||
|
||||
void win10_init()
|
||||
@@ -27,6 +27,10 @@ void win10_init()
|
||||
if (gWin10.AreDpiAwarenessContextsEqual == NULL)
|
||||
panic("Unable to get address of AreDpiAwarenessContextsEqual");
|
||||
|
||||
gWin10.GetDpiForWindow = (GetDpiForWindowProc) GetProcAddress(hUser32, "GetDpiForWindow");
|
||||
if (gWin10.GetDpiForWindow == NULL)
|
||||
panic("Unable to get address of GetDpiForWindow");
|
||||
|
||||
FreeLibrary(hUser32);
|
||||
|
||||
gWin10.Valid = TRUE;
|
||||
@@ -35,7 +39,7 @@ void win10_init()
|
||||
if (gWin10.Valid) {
|
||||
if (!gWin10.AreDpiAwarenessContextsEqual(
|
||||
gWin10.GetThreadDpiAwarenessContext(),
|
||||
DPI_AWARENESS_CONTEXT_UNAWARE))
|
||||
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2))
|
||||
panic("Unexpected DpiAwareness state");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,16 +2,25 @@
|
||||
/* Copyright (C) 2018 by Bart House */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
typedef DPI_AWARENESS_CONTEXT(WINAPI * GetThreadDpiAwarenessContextProc)(VOID);
|
||||
typedef BOOL (WINAPI *AreDpiAwarenessContextsEqualProc)(DPI_AWARENESS_CONTEXT dpiContextA, DPI_AWARENESS_CONTEXT dpiContextB);
|
||||
#ifndef WIN10_H
|
||||
#define WIN10_H
|
||||
|
||||
#include "win32api.h"
|
||||
|
||||
typedef DPI_AWARENESS_CONTEXT(WINAPI *GetThreadDpiAwarenessContextProc)(VOID);
|
||||
typedef BOOL(WINAPI *AreDpiAwarenessContextsEqualProc)(
|
||||
DPI_AWARENESS_CONTEXT dpiContextA, DPI_AWARENESS_CONTEXT dpiContextB);
|
||||
typedef UINT(WINAPI *GetDpiForWindowProc)(HWND hwnd);
|
||||
|
||||
typedef struct {
|
||||
BOOL Valid;
|
||||
GetThreadDpiAwarenessContextProc GetThreadDpiAwarenessContext;
|
||||
AreDpiAwarenessContextsEqualProc AreDpiAwarenessContextsEqual;
|
||||
GetDpiForWindowProc GetDpiForWindow;
|
||||
} Win10;
|
||||
|
||||
extern Win10 gWin10;
|
||||
|
||||
void win10_init();
|
||||
|
||||
#endif // WIN10_H
|
||||
@@ -468,8 +468,8 @@ char *buf;
|
||||
}
|
||||
#endif /* RUNTIME_PORT_ID */
|
||||
|
||||
/* ntassert_failed is called when an ntassert's condition is false */
|
||||
void ntassert_failed(const char * exp, const char * file, int line)
|
||||
/* nhassert_failed is called when an nhassert's condition is false */
|
||||
void nhassert_failed(const char * exp, const char * file, int line)
|
||||
{
|
||||
char message[128];
|
||||
_snprintf(message, sizeof(message),
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "winos.h"
|
||||
#include "winMS.h"
|
||||
#include "win10.h"
|
||||
|
||||
#include "mhmap.h"
|
||||
#include "mhfont.h"
|
||||
#include "mhinput.h"
|
||||
#include "mhmsg.h"
|
||||
#include "resource.h"
|
||||
#include "winMS.h"
|
||||
|
||||
#include "color.h"
|
||||
#include "patchlevel.h"
|
||||
@@ -34,12 +36,18 @@ typedef struct mswin_nethack_map_window {
|
||||
boolean bFitToScreenMode; /* switch Fit map to screen mode on/off */
|
||||
int xPos, yPos; /* scroll position */
|
||||
int xPageSize, yPageSize; /* scroll page size */
|
||||
int xMin, xMax, yMin, yMax; /* scroll range */
|
||||
int xCur, yCur; /* position of the cursor */
|
||||
int xScrTile, yScrTile; /* size of display tile */
|
||||
int xScrTile, yScrTile; /* size of tile on screen in pixels */
|
||||
POINT map_orig; /* map origin point */
|
||||
|
||||
HFONT hMapFont; /* font for ASCII mode */
|
||||
boolean bUnicodeFont; /* font supports unicode page 437 */
|
||||
HFONT hMapFont; /* font for ASCII mode */
|
||||
boolean bUnicodeFont; /* font supports unicode page 437 */
|
||||
|
||||
int tileWidth; /* width of tile in pixels at 96 dpi */
|
||||
int tileHeight; /* height of tile in pixels at 96 dpi */
|
||||
double scale; /* scale factor */
|
||||
|
||||
} NHMapWindow, *PNHMapWindow;
|
||||
|
||||
static TCHAR szNHMapWindowClass[] = TEXT("MSNethackMapWndClass");
|
||||
@@ -101,29 +109,57 @@ mswin_init_map_window()
|
||||
}
|
||||
|
||||
void
|
||||
mswin_map_stretch(HWND hWnd, LPSIZE lpsz, BOOL redraw)
|
||||
mswin_map_stretch(HWND hWnd, LPSIZE map_size, BOOL redraw)
|
||||
{
|
||||
PNHMapWindow data;
|
||||
RECT client_rt;
|
||||
SCROLLINFO si;
|
||||
SIZE wnd_size;
|
||||
LOGFONT lgfnt;
|
||||
|
||||
/* check arguments */
|
||||
if (!IsWindow(hWnd) || !lpsz || lpsz->cx <= 0 || lpsz->cy <= 0)
|
||||
if (!IsWindow(hWnd) || !map_size || map_size->cx <= 0
|
||||
|| map_size->cy <= 0)
|
||||
return;
|
||||
|
||||
PNHMapWindow data = (PNHMapWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
||||
|
||||
/* calculate window size */
|
||||
RECT client_rt;
|
||||
GetClientRect(hWnd, &client_rt);
|
||||
|
||||
SIZE wnd_size;
|
||||
wnd_size.cx = client_rt.right - client_rt.left;
|
||||
wnd_size.cy = client_rt.bottom - client_rt.top;
|
||||
|
||||
if (wnd_size.cx > 0 && wnd_size.cy > 0 && data->bFitToScreenMode) {
|
||||
double windowAspectRatio =
|
||||
(double) wnd_size.cx / (double) wnd_size.cy;
|
||||
UINT mapWidth = COLNO * data->tileWidth;
|
||||
UINT mapHeight = ROWNO * data->tileHeight;
|
||||
|
||||
double mapAspectRatio = (double) mapWidth / (double) mapHeight;
|
||||
|
||||
if (windowAspectRatio > mapAspectRatio)
|
||||
data->scale = (double) wnd_size.cy / (double) mapHeight;
|
||||
else
|
||||
data->scale = (double) wnd_size.cx / (double) mapWidth;
|
||||
|
||||
} else {
|
||||
// Auto size window
|
||||
|
||||
UINT windowDpi = 96;
|
||||
|
||||
if (gWin10.Valid) {
|
||||
windowDpi = gWin10.GetDpiForWindow(hWnd);
|
||||
if (windowDpi == 0)
|
||||
windowDpi = 96;
|
||||
}
|
||||
|
||||
windowDpi = max(96, windowDpi);
|
||||
data->scale = (double) windowDpi / 96.0;
|
||||
}
|
||||
|
||||
/* set new screen tile size */
|
||||
data = (PNHMapWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
||||
data->xScrTile =
|
||||
max(1, (data->bFitToScreenMode ? wnd_size.cx : lpsz->cx) / COLNO);
|
||||
data->yScrTile =
|
||||
max(1, (data->bFitToScreenMode ? wnd_size.cy : lpsz->cy) / ROWNO);
|
||||
data->xScrTile = (int) (data->tileWidth * data->scale);
|
||||
data->yScrTile = (int) (data->tileHeight * data->scale);
|
||||
|
||||
data->xScrTile = max(1, data->xScrTile);
|
||||
data->yScrTile = max(1, data->yScrTile);
|
||||
|
||||
/* set map origin point */
|
||||
data->map_orig.x =
|
||||
@@ -134,55 +170,48 @@ mswin_map_stretch(HWND hWnd, LPSIZE lpsz, BOOL redraw)
|
||||
data->map_orig.x -= data->map_orig.x % data->xScrTile;
|
||||
data->map_orig.y -= data->map_orig.y % data->yScrTile;
|
||||
|
||||
/* adjust horizontal scroll bar */
|
||||
if (data->bFitToScreenMode)
|
||||
data->xPageSize = COLNO + 1; /* disable scroll bar */
|
||||
else
|
||||
data->xPageSize = wnd_size.cx / data->xScrTile;
|
||||
// Set horizontal scroll
|
||||
|
||||
if (data->xPageSize >= COLNO) {
|
||||
data->xPos = 0;
|
||||
GetNHApp()->bNoHScroll = TRUE;
|
||||
} else {
|
||||
GetNHApp()->bNoHScroll = FALSE;
|
||||
data->xPos = max(
|
||||
0, min(COLNO - data->xPageSize + 1, u.ux - data->xPageSize / 2));
|
||||
}
|
||||
data->xPageSize = min(COLNO, wnd_size.cx / data->xScrTile);
|
||||
|
||||
GetNHApp()->bNoHScroll = (data->xPageSize == COLNO);
|
||||
|
||||
data->xMin = 0;
|
||||
data->xMax = COLNO - data->xPageSize;
|
||||
data->xPos = max(0, min(data->xMax, u.ux - (data->xPageSize / 2)));
|
||||
|
||||
SCROLLINFO si;
|
||||
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
|
||||
si.nMin = 0;
|
||||
si.nMax = COLNO;
|
||||
si.nPage = data->xPageSize;
|
||||
si.nMin = data->xMin;
|
||||
si.nMax = data->xMax;
|
||||
si.nPage = 1;
|
||||
si.nPos = data->xPos;
|
||||
SetScrollInfo(hWnd, SB_HORZ, &si, TRUE);
|
||||
|
||||
/* adjust vertical scroll bar */
|
||||
if (data->bFitToScreenMode)
|
||||
data->yPageSize = ROWNO + 1; /* disable scroll bar */
|
||||
else
|
||||
data->yPageSize = wnd_size.cy / data->yScrTile;
|
||||
data->yPageSize = min(ROWNO, wnd_size.cy / data->yScrTile);
|
||||
|
||||
if (data->yPageSize >= ROWNO) {
|
||||
data->yPos = 0;
|
||||
GetNHApp()->bNoVScroll = TRUE;
|
||||
} else {
|
||||
GetNHApp()->bNoVScroll = FALSE;
|
||||
data->yPos = max(
|
||||
0, min(ROWNO - data->yPageSize + 1, u.uy - data->yPageSize / 2));
|
||||
}
|
||||
GetNHApp()->bNoVScroll = (data->yPageSize == ROWNO);
|
||||
|
||||
data->yMin = 0;
|
||||
data->yMax = ROWNO - data->yPageSize;
|
||||
data->yPos = max(0, min(data->yMax, u.uy - (data->yPageSize / 2)));
|
||||
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
|
||||
si.nMin = 0;
|
||||
si.nMax = ROWNO;
|
||||
si.nPage = data->yPageSize;
|
||||
si.nMin = data->yMin;
|
||||
si.nMax = data->yMax;
|
||||
si.nPage = 1;
|
||||
si.nPos = data->yPos;
|
||||
SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
|
||||
|
||||
/* create font */
|
||||
if (data->hMapFont)
|
||||
DeleteObject(data->hMapFont);
|
||||
|
||||
LOGFONT lgfnt;
|
||||
|
||||
ZeroMemory(&lgfnt, sizeof(lgfnt));
|
||||
lgfnt.lfHeight = -data->yScrTile; // height of font
|
||||
lgfnt.lfWidth = -data->xScrTile; // average character width
|
||||
@@ -231,95 +260,92 @@ mswin_map_mode(HWND hWnd, int mode)
|
||||
case MAP_MODE_ASCII4x6:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 4 * COLNO;
|
||||
mapSize.cy = 6 * ROWNO;
|
||||
data->tileWidth = 4;
|
||||
data->tileHeight = 6;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII6x8:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 6 * COLNO;
|
||||
mapSize.cy = 8 * ROWNO;
|
||||
data->tileWidth = 6;
|
||||
data->tileHeight = 8;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII8x8:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 8 * COLNO;
|
||||
mapSize.cy = 8 * ROWNO;
|
||||
data->tileWidth = 8;
|
||||
data->tileHeight = 8;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII16x8:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 16 * COLNO;
|
||||
mapSize.cy = 8 * ROWNO;
|
||||
data->tileWidth = 16;
|
||||
data->tileHeight = 8;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII7x12:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 7 * COLNO;
|
||||
mapSize.cy = 12 * ROWNO;
|
||||
data->tileWidth = 7;
|
||||
data->tileHeight = 12;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII8x12:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 8 * COLNO;
|
||||
mapSize.cy = 12 * ROWNO;
|
||||
data->tileWidth = 8;
|
||||
data->tileHeight = 12;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII16x12:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 16 * COLNO;
|
||||
mapSize.cy = 12 * ROWNO;
|
||||
data->tileWidth = 16;
|
||||
data->tileHeight = 12;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII12x16:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 12 * COLNO;
|
||||
mapSize.cy = 16 * ROWNO;
|
||||
data->tileWidth = 12;
|
||||
data->tileHeight = 16;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII10x18:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = 10 * COLNO;
|
||||
mapSize.cy = 18 * ROWNO;
|
||||
data->tileWidth = 10;
|
||||
data->tileHeight = 18;
|
||||
break;
|
||||
|
||||
case MAP_MODE_ASCII_FIT_TO_SCREEN: {
|
||||
RECT client_rt;
|
||||
GetClientRect(hWnd, &client_rt);
|
||||
mapSize.cx = client_rt.right - client_rt.left;
|
||||
mapSize.cy = client_rt.bottom - client_rt.top;
|
||||
|
||||
case MAP_MODE_ASCII_FIT_TO_SCREEN:
|
||||
data->bAsciiMode = TRUE;
|
||||
data->bFitToScreenMode = TRUE;
|
||||
} break;
|
||||
|
||||
case MAP_MODE_TILES_FIT_TO_SCREEN: {
|
||||
RECT client_rt;
|
||||
GetClientRect(hWnd, &client_rt);
|
||||
mapSize.cx = client_rt.right - client_rt.left;
|
||||
mapSize.cy = client_rt.bottom - client_rt.top;
|
||||
data->tileWidth = 12;
|
||||
data->tileHeight = 16;
|
||||
break;
|
||||
|
||||
case MAP_MODE_TILES_FIT_TO_SCREEN:
|
||||
data->bAsciiMode = FALSE;
|
||||
data->bFitToScreenMode = TRUE;
|
||||
} break;
|
||||
data->tileWidth = GetNHApp()->mapTile_X;
|
||||
data->tileHeight = GetNHApp()->mapTile_Y;
|
||||
break;
|
||||
|
||||
case MAP_MODE_TILES:
|
||||
default:
|
||||
data->bAsciiMode = FALSE;
|
||||
data->bFitToScreenMode = FALSE;
|
||||
mapSize.cx = GetNHApp()->mapTile_X * COLNO;
|
||||
mapSize.cy = GetNHApp()->mapTile_Y * ROWNO;
|
||||
data->tileWidth = GetNHApp()->mapTile_X;
|
||||
data->tileHeight = GetNHApp()->mapTile_Y;
|
||||
break;
|
||||
}
|
||||
|
||||
mapSize.cx = data->tileWidth * COLNO;
|
||||
mapSize.cy = data->tileHeight * ROWNO;
|
||||
|
||||
mswin_map_stretch(hWnd, &mapSize, TRUE);
|
||||
|
||||
mswin_update_inventory(); /* for perm_invent to hide/show tiles */
|
||||
@@ -618,6 +644,8 @@ onCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
data->xScrTile = GetNHApp()->mapTile_X;
|
||||
data->yScrTile = GetNHApp()->mapTile_Y;
|
||||
data->tileWidth = GetNHApp()->mapTile_X;
|
||||
data->tileHeight = GetNHApp()->mapTile_Y;
|
||||
|
||||
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) data);
|
||||
}
|
||||
@@ -712,10 +740,10 @@ onPaint(HWND hWnd)
|
||||
if (data->bUnicodeFont) {
|
||||
wch = winos_ascii_to_wide(ch);
|
||||
DrawTextW(hDC, &wch, 1, &glyph_rect,
|
||||
DT_CENTER | DT_VCENTER | DT_NOPREFIX);
|
||||
DT_CENTER | DT_VCENTER | DT_NOPREFIX);
|
||||
} else {
|
||||
DrawTextA(hDC, &ch, 1, &glyph_rect,
|
||||
DT_CENTER | DT_VCENTER | DT_NOPREFIX);
|
||||
DT_CENTER | DT_VCENTER | DT_NOPREFIX);
|
||||
}
|
||||
|
||||
SetTextColor(hDC, OldFg);
|
||||
@@ -887,7 +915,7 @@ onMSNH_VScroll(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
yNewPos = data->yPos;
|
||||
}
|
||||
|
||||
yNewPos = max(0, min(ROWNO - data->yPageSize + 1, yNewPos));
|
||||
yNewPos = max(0, min(data->yMax, yNewPos));
|
||||
if (yNewPos == data->yPos)
|
||||
return;
|
||||
|
||||
@@ -948,7 +976,7 @@ onMSNH_HScroll(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
xNewPos = data->xPos;
|
||||
}
|
||||
|
||||
xNewPos = max(0, min(COLNO - data->xPageSize + 1, xNewPos));
|
||||
xNewPos = max(0, min(data->xMax, xNewPos));
|
||||
if (xNewPos == data->xPos)
|
||||
return;
|
||||
|
||||
|
||||
2
win/win32/vs2017/.gitignore
vendored
2
win/win32/vs2017/.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
!NetHack.sln
|
||||
*.db-shm
|
||||
*.db-wal
|
||||
|
||||
paniclog
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">unaware</dpiAwareness>
|
||||
<!-- <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness> -->
|
||||
<!-- <gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling> -->
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
|
||||
@@ -5,14 +5,15 @@
|
||||
// winhack.cpp : Defines the entry point for the application.
|
||||
//
|
||||
|
||||
#include "win10.h"
|
||||
#include <process.h>
|
||||
|
||||
#include "winMS.h"
|
||||
#include "hack.h"
|
||||
#include "dlb.h"
|
||||
#include "resource.h"
|
||||
#include "mhmain.h"
|
||||
#include "mhmap.h"
|
||||
#include "win10.h"
|
||||
|
||||
/* Borland and MinGW redefine "boolean" in shlwapi.h,
|
||||
so just use the little bit we need */
|
||||
|
||||
Reference in New Issue
Block a user