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