Merge branch 'win-minor' into win-fontmap

# Conflicts:
#	win/win32/mhmap.c
This commit is contained in:
Bart House
2018-12-09 14:02:57 -08:00
55 changed files with 2013 additions and 641 deletions
+3
View File
@@ -9,6 +9,9 @@
#include "winMS.h"
#define MIN_FONT_WIDTH 9
#define MIN_FONT_HEIGHT 12
typedef struct cached_font {
int code;
HFONT hFont;
+6 -8
View File
@@ -160,7 +160,8 @@ mswin_map_stretch(HWND hWnd, LPSIZE map_size, BOOL redraw)
// calculate back buffer scale
data->monitorScale = win10_monitor_scale(hWnd);
boolean bText = data->bAsciiMode || (u.uz.dlevel != 0 && Is_rogue_level(&u.uz));
boolean bText = data->bAsciiMode ||
(u.uz.dlevel != 0 && Is_rogue_level(&u.uz));
if (bText && !data->bFitToScreenMode)
data->backScale = data->monitorScale;
@@ -217,12 +218,9 @@ mswin_map_stretch(HWND hWnd, LPSIZE map_size, BOOL redraw)
GetTextMetrics(data->backBufferDC, &textMetrics);
if (textMetrics.tmHeight > data->yBackTile) {
lgfnt.lfHeight++;
continue;
}
if (textMetrics.tmAveCharWidth > data->xBackTile) {
if ((textMetrics.tmHeight > data->yBackTile ||
textMetrics.tmAveCharWidth > data->xBackTile) &&
lgfnt.lfHeight < -MIN_FONT_HEIGHT) {
lgfnt.lfHeight++;
continue;
}
@@ -283,7 +281,7 @@ mswin_map_stretch(HWND hWnd, LPSIZE map_size, BOOL redraw)
} else {
if (data->bAsciiMode || Is_rogue_level(&u.uz)) {
if (bText) {
data->frontScale = 1.0;
} else {
data->frontScale = data->monitorScale;
+7
View File
@@ -718,6 +718,13 @@ mswin_exit_nhwindows(const char *str)
/* Write Window settings to the registry */
mswin_write_reg();
/* set things back to failsafes */
windowprocs = *get_safe_procs(0);
/* and make sure there is still a way to communicate something */
windowprocs.win_raw_print = mswin_raw_print;
windowprocs.win_raw_print_bold = mswin_raw_print_bold;
windowprocs.win_wait_synch = mswin_wait_synch;
}
/* Prepare the window to be suspended. */
+4 -3
View File
@@ -34,7 +34,7 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>$(WinWin32Dir);$(IncDir);$(SysWinntDir);$(SysShareDir);$(WinShareDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>TILES;WIN32CON;DLB;MSWIN_GRAPHICS;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TILES;WIN32CON;DLB;MSWIN_GRAPHICS;SAFEPROCS;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -151,7 +151,6 @@
<ClCompile Include="$(SrcDir)zap.c" />
<ClCompile Include="$(SysShareDir)cppregex.cpp" />
<ClCompile Include="$(SysShareDir)nhlan.c" />
<ClCompile Include="$(SysShareDir)pcmain.c" />
<ClCompile Include="$(SysShareDir)pcsys.c" />
<ClCompile Include="$(SysShareDir)pcunix.c" />
<ClCompile Include="$(SysShareDir)random.c" />
@@ -160,7 +159,9 @@
<ClCompile Include="$(SysWinntDir)stubs.c">
<PreprocessorDefinitions>GUISTUB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="$(SysWinntDir)windmain.c" />
<ClCompile Include="$(SysWinntDir)winnt.c" />
<ClCompile Include="$(WinShareDir)safeproc.c" />
<ClCompile Include="$(WinTtyDir)getline.c" />
<ClCompile Include="$(WinTtyDir)topl.c" />
<ClCompile Include="$(WinTtyDir)wintty.c" />
@@ -254,4 +255,4 @@
<Target Name="AfterRebuild">
<MSBuild Projects="afternethack.proj" Targets="Build" Properties="Configuration=$(Configuration)" />
</Target>
</Project>
</Project>
+4 -3
View File
@@ -20,7 +20,7 @@
<Optimization>Disabled</Optimization>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>$(WinWin32Dir);$(IncDir);$(SysWinntDir);$(SysShareDir);$(WinShareDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>TILES;_WINDOWS;DLB;MSWIN_GRAPHICS;NOTTYGRAPHICS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TILES;_WINDOWS;DLB;MSWIN_GRAPHICS;SAFEPROCS;NOTTYGRAPHICS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -146,7 +146,6 @@
<ClCompile Include="$(SrcDir)zap.c" />
<ClCompile Include="$(SysShareDir)cppregex.cpp" />
<ClCompile Include="$(SysShareDir)nhlan.c" />
<ClCompile Include="$(SysShareDir)pcmain.c" />
<ClCompile Include="$(SysShareDir)pcsys.c" />
<ClCompile Include="$(SysShareDir)pcunix.c" />
<ClCompile Include="$(SysShareDir)random.c" />
@@ -154,8 +153,10 @@
<ClCompile Include="$(SysWinntDir)stubs.c">
<PreprocessorDefinitions>TTYSTUB;</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="$(SysWinntDir)windmain.c" />
<ClCompile Include="$(SysWinntDir)winnt.c" />
<ClCompile Include="$(SysWinntDir)win10.c" />
<ClCompile Include="$(WinShareDir)safeproc.c" />
<ClCompile Include="$(WinWin32Dir)mhaskyn.c" />
<ClCompile Include="$(WinWin32Dir)mhdlg.c" />
<ClCompile Include="$(WinWin32Dir)mhfont.c" />
@@ -200,4 +201,4 @@
<Target Name="AfterRebuild">
<MSBuild Projects="afternethack.proj" Targets="Build" Properties="Configuration=$(Configuration)" />
</Target>
</Project>
</Project>
+34 -9
View File
@@ -15,6 +15,10 @@
#include "mhmain.h"
#include "mhmap.h"
#if !defined(SAFEPROCS)
#error You must #define SAFEPROCS to build winhack.c
#endif
/* Borland and MinGW redefine "boolean" in shlwapi.h,
so just use the little bit we need */
typedef struct _DLLVERSIONINFO {
@@ -59,6 +63,8 @@ _nhapply_image_transparent(HDC hDC, int x, int y, int width, int height,
// Global Variables:
NHWinApp _nethack_app;
extern int GUILaunched; /* We tell shared startup code in windmain.c
that the GUI was launched via this */
#ifdef __BORLANDC__
#define _stricmp(s1, s2) stricmp(s1, s2)
@@ -66,7 +72,7 @@ NHWinApp _nethack_app;
#endif
// Foward declarations of functions included in this code module:
extern boolean FDECL(pcmain, (int, char **));
extern boolean FDECL(main, (int, char **));
static void __cdecl mswin_moveloop(void *);
#define MAX_CMDLINE_PARAM 255
@@ -82,24 +88,44 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
TCHAR *p;
TCHAR wbuf[BUFSZ];
char buf[BUFSZ];
DWORD major, minor;
boolean resuming;
/* OSVERSIONINFO osvi; */
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
UNREFERENCED_PARAMETER(nCmdShow);
/* We must initialize state sufficiently to support calls to panic */
/*
* Get a set of valid safe windowport function
* pointers during early startup initialization.
*
* When get_safe_procs is called with 0 as the param,
* non-functional, but safe function pointers are set
* for all windowport routines.
*
* When get_safe_procs is called with 1 as the param,
* raw_print, raw_print_bold, and wait_synch, and nhgetch
* are set to use C stdio routines via stdio_raw_print,
* stdio_raw_print_bold, stdio_wait_synch, and
* stdio_nhgetch.
*/
windowprocs = *get_safe_procs(0);
/*
* Now we are going to override a couple
* of the windowprocs functions so that
* error messages are handled in a suitable
* way for the graphical version.
*/
windowprocs.win_raw_print = mswin_raw_print;
windowprocs.win_raw_print_bold = mswin_raw_print_bold;
windowprocs.win_wait_synch = mswin_wait_synch;
win10_init();
sys_early_init();
/* init applicatio structure */
/* init application structure */
_nethack_app.hApp = hInstance;
_nethack_app.hAccelTable =
LoadAccelerators(hInstance, (LPCTSTR) IDC_NETHACKW);
@@ -209,10 +235,9 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
}
free(savefile);
}
resuming = pcmain(argc, argv);
moveloop(resuming);
GUILaunched = 1;
/* let main do the argument processing */
(void) main(argc, argv);
return 0;
}