diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 949691dad..9f76fc3e8 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -114,6 +114,7 @@ add window port status_update() value BL_RESET to use as a flag to for hilite_status of string status fields (title, dungeon-level, alignment), the types value-goes-up and -down aren't meaningful; treat them as value-changed if from config file and don't offer as choices with 'O' +spiders will occasionally spin webs when moving around Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository @@ -130,7 +131,8 @@ Platform- and/or Interface-Specific Fixes ----------------------------------------- windows-gui: In nethackw, there could be conflicts between menu accelerators and an extra choice accelerator to fix H7132. -windows-gui: recognize new BL_RESET in status_update; behavior currently the same +windows-gui: recognize new BL_RESET in status_update; no change in behavior yet +windows-gui: align hpbar behavior at zero hit points with tty behavior windows-tty: Specify both width and height when creating font for width testing windows-tty: To counter lag problems that were occuring with the Win32 console port, implement a console back buffer to reduce the number of calls @@ -146,6 +148,7 @@ windows-tty: Use nhraykey by default if the players keyboard layout is non-english as reported in H4216 windows-tty: We now support changing altkeyhandler in game windows: Added ntassert() mechanism for Windows based port use +windows: heed OPTIONS=symset:default in config file if it is present tty: significant optimizations for performance and per field rendering tty: use WC2_FLUSH_STATUS to buffer changes until BL_FLUSH is received tty: support BL_RESET in status_update to force an update to all status fields @@ -156,6 +159,9 @@ unix: Makefile.src and Makefile.utl inadvertently relied on a 'gnu make' verbose so doesn't use '$<' for multi-prerequisite targets unless specifically requested; use 'make QUIETCC=1 ' to get the 3.6.1 behavior back +Qt: add Qt5 specific hints file for linux and Mac OS X (Ray Chason) +Qt: enable compiling Qt5 on Windows (Ray Chason) +Qt: entering extended commands, hide non-matching ones General New Features diff --git a/include/.gitignore b/include/.gitignore index cb5a92532..4906e6ce8 100644 --- a/include/.gitignore +++ b/include/.gitignore @@ -6,3 +6,4 @@ vis_tab.h dgn_comp.h lev_comp.h tile.h +win32api.h diff --git a/include/global.h b/include/global.h index 407d7f721..633dea271 100644 --- a/include/global.h +++ b/include/global.h @@ -60,9 +60,14 @@ * since otherwise comparisons with signed quantities are done incorrectly */ typedef schar xchar; +#if defined(__GNUC__) && defined(WIN32) && defined(__cplusplus) +/* Resolve conflict with Qt 5 and MinGW-w32 */ +typedef uchar boolean; /* 0 or 1 */ +#else #ifndef SKIP_BOOLEAN typedef xchar boolean; /* 0 or 1 */ #endif +#endif #ifndef TRUE /* defined in some systems' native include files */ #define TRUE ((boolean) 1) diff --git a/src/.gitignore b/src/.gitignore index 04325af79..df4310a30 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -7,3 +7,7 @@ Sysunix nethack *.o tiles.bmp +*.moc +graphicschk +nhdat +o diff --git a/src/monmove.c b/src/monmove.c index 0abf63b6d..90b4f33c1 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -14,8 +14,10 @@ STATIC_DCL int FDECL(disturb, (struct monst *)); STATIC_DCL void FDECL(release_hero, (struct monst *)); STATIC_DCL void FDECL(distfleeck, (struct monst *, int *, int *, int *)); STATIC_DCL int FDECL(m_arrival, (struct monst *)); +STATIC_DCL int FDECL(count_webbing_walls, (XCHAR_P, XCHAR_P)); STATIC_DCL boolean FDECL(stuff_prevents_passage, (struct monst *)); -STATIC_DCL int FDECL(vamp_shift, (struct monst *, struct permonst *, BOOLEAN_P)); +STATIC_DCL int FDECL(vamp_shift, (struct monst *, struct permonst *, + BOOLEAN_P)); /* True if mtmp died */ boolean @@ -742,6 +744,24 @@ xchar nix,niy; return FALSE; } +/* returns the number of walls in the four cardinal directions that could + hold up a web */ +STATIC_OVL int +count_webbing_walls(x, y) +xchar x, y; +{ +#define holds_up_web(X, Y) ((!isok((X), (Y)) \ + || IS_ROCK(levl[X][Y].typ) \ + || (levl[X][Y].typ == STAIRS \ + && (X) == xupstair && (Y) == yupstair) \ + || (levl[X][Y].typ == LADDER \ + && (X) == xupladder && (Y) == yupladder) \ + || levl[X][Y].typ == IRONBARS) ? 1 : 0) + return (holds_up_web(x, y - 1) + holds_up_web(x + 1, y) + + holds_up_web(x, y + 1) + holds_up_web(x - 1, y)); +#undef holds_up_web +} + /* Return values: * 0: did not move, but can still attack and do other stuff. * 1: moved, possibly can attack. @@ -1436,6 +1456,27 @@ postmov: } } + /* maybe spin a web -- this needs work; if the spider is far away, + it might spin a lot of webs before hero encounters it */ + if (webmaker(ptr) && !mtmp->mspec_used && !t_at(mtmp->mx, mtmp->my)) { + struct trap *trap; + int prob = ((ptr == &mons[PM_GIANT_SPIDER]) ? 15 : 5) + * (count_webbing_walls(mtmp->mx, mtmp->my) + 1); + + if (rn2(1000) < prob + && (trap = maketrap(mtmp->mx, mtmp->my, WEB)) != 0) { + mtmp->mspec_used = d(4, 4); /* 4..16 */ + if (cansee(mtmp->mx, mtmp->my)) { + char mbuf[BUFSZ]; + + Strcpy(mbuf, + canspotmon(mtmp) ? y_monnam(mtmp) : something); + pline("%s spins a web.", upstart(mbuf)); + trap->tseen = 1; + } + } + } + if (hides_under(ptr) || ptr->mlet == S_EEL) { /* Always set--or reset--mundetected if it's already hidden (just in case the object it was hiding under went away); diff --git a/src/options.c b/src/options.c index b07c7b818..a283f4283 100644 --- a/src/options.c +++ b/src/options.c @@ -778,6 +778,15 @@ initoptions_init() #endif #endif /* UNIX || VMS */ +#if defined(MSDOS) || defined(WIN32) + /* Use IBM defaults. Can be overridden via config file */ + if (!symset[PRIMARY].name) { + load_symset("IBMGraphics_2", PRIMARY); + } + if (!symset[ROGUESET].name) { + load_symset("RogueEpyx", ROGUESET); + } +#endif #ifdef MAC_GRAPHICS_ENV if (!symset[PRIMARY].name) load_symset("MACGraphics", PRIMARY); diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index cfb7dbf8a..c55805b09 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -497,16 +497,6 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ #endif #endif -#if defined(MSDOS) || defined(WIN32) - /* Player didn't specify any symbol set so use IBM defaults */ - if (!symset[PRIMARY].name) { - load_symset("IBMGraphics_2", PRIMARY); - } - if (!symset[ROGUESET].name) { - load_symset("RogueEpyx", ROGUESET); - } -#endif - #if defined(MSDOS) || defined(WIN32) init_nhwindows(&argc, argv); #else diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index 98c80a2fd..4f9fa874e 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -163,7 +163,8 @@ GNOMEINC=-I/usr/lib/glib/include -I/usr/lib/gnome-libs/include -I../win/gnome # NetHack is standard C. If using Qt, uncomment the LINK line here to get # the C++ libraries linked in. CXXFLAGS = $(CFLAGS) -I. -I$(QTDIR)/include -CXX=g++ +CXX ?= g++ +MOC ?= moc #LINK=g++ # For cross-compiling, eg. with gcc on Linux (see also CC further up): #CXX=arm-linux-g++ @@ -277,6 +278,9 @@ WINQTLIB = -L$(QTDIR)/lib -lqt # libraries for Qt 4 WINQT4LIB = `pkg-config QtGui --libs` # +# libraries for Qt 5 (use with WINQT4SRC and WINQT4OBJ) +WINQT5LIB = `pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --libs` +# # libraries for KDE (with Qt) WINKDELIB = -lkdecore -lkdeui -lXext # @@ -566,25 +570,25 @@ qttableview.moc: ../include/qttableview.h # Qt 4 windowport meta-object-compiler output qt4kde0.moc : ../win/Qt4/qt4kde0.h - $(QTDIR)/bin/moc -o qt4kde0.moc ../win/Qt4/qt4kde0.h + $(QTDIR)/bin/$(MOC) -o qt4kde0.moc ../win/Qt4/qt4kde0.h qt4main.moc : ../win/Qt4/qt4main.h - $(QTDIR)/bin/moc -o qt4main.moc ../win/Qt4/qt4main.h + $(QTDIR)/bin/$(MOC) -o qt4main.moc ../win/Qt4/qt4main.h qt4map.moc : ../win/Qt4/qt4map.h - $(QTDIR)/bin/moc -o qt4map.moc ../win/Qt4/qt4map.h + $(QTDIR)/bin/$(MOC) -o qt4map.moc ../win/Qt4/qt4map.h qt4menu.moc : ../win/Qt4/qt4menu.h - $(QTDIR)/bin/moc -o qt4menu.moc ../win/Qt4/qt4menu.h + $(QTDIR)/bin/$(MOC) -o qt4menu.moc ../win/Qt4/qt4menu.h qt4msg.moc : ../win/Qt4/qt4msg.h - $(QTDIR)/bin/moc -o qt4msg.moc ../win/Qt4/qt4msg.h + $(QTDIR)/bin/$(MOC) -o qt4msg.moc ../win/Qt4/qt4msg.h qt4plsel.moc : ../win/Qt4/qt4plsel.h - $(QTDIR)/bin/moc -o qt4plsel.moc ../win/Qt4/qt4plsel.h + $(QTDIR)/bin/$(MOC) -o qt4plsel.moc ../win/Qt4/qt4plsel.h qt4set.moc : ../win/Qt4/qt4set.h - $(QTDIR)/bin/moc -o qt4set.moc ../win/Qt4/qt4set.h + $(QTDIR)/bin/$(MOC) -o qt4set.moc ../win/Qt4/qt4set.h qt4stat.moc : ../win/Qt4/qt4stat.h - $(QTDIR)/bin/moc -o qt4stat.moc ../win/Qt4/qt4stat.h + $(QTDIR)/bin/$(MOC) -o qt4stat.moc ../win/Qt4/qt4stat.h qt4xcmd.moc : ../win/Qt4/qt4xcmd.h - $(QTDIR)/bin/moc -o qt4xcmd.moc ../win/Qt4/qt4xcmd.h + $(QTDIR)/bin/$(MOC) -o qt4xcmd.moc ../win/Qt4/qt4xcmd.h qt4yndlg.moc : ../win/Qt4/qt4yndlg.h - $(QTDIR)/bin/moc -o qt4yndlg.moc ../win/Qt4/qt4yndlg.h + $(QTDIR)/bin/$(MOC) -o qt4yndlg.moc ../win/Qt4/qt4yndlg.h # build monst.o and objects.o before executing '$(MAKE) makedefs' $(MAKEDEFS): $(FIRSTOBJ) \ diff --git a/sys/unix/hints/linux-qt4 b/sys/unix/hints/linux-qt4 index 34c8863d5..804118562 100644 --- a/sys/unix/hints/linux-qt4 +++ b/sys/unix/hints/linux-qt4 @@ -31,11 +31,12 @@ CFLAGS+=-DQT_GRAPHICS -DDEFAULT_WINDOW_SYS=\"Qt\" -DNOTTYGRAPHICS CFLAGS+=`pkg-config QtGui --cflags` LINK=g++ -CXX=g++ +CXX=g++ -std=gnu++11 WINSRC = $(WINQT4SRC) WINOBJ = $(WINQT4OBJ) WINLIB = $(WINQT4LIB) +MOC = moc-qt4 VARDATND = nhtiles.bmp rip.xpm nhsplash.xpm pet_mark.xbm pilemark.xbm diff --git a/sys/unix/hints/linux-qt5 b/sys/unix/hints/linux-qt5 new file mode 100644 index 000000000..8532cc207 --- /dev/null +++ b/sys/unix/hints/linux-qt5 @@ -0,0 +1,52 @@ +# +# NetHack 3.6 linux-qt5 $NHDT-Date: 1432512814 2015/05/25 00:13:34 $ $NHDT-Branch: master $:$NHDT-Revision: 1.12 $ +# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007. +# NetHack may be freely redistributed. See license for details. +# +#-PRE +# Linux hints file +# This hints file provides a single-user Qt5 build for Linux, specifically +# for Fedora 26. + + +#PREFIX=/usr +PREFIX=$(wildcard ~)/nh/install +HACKDIR=$(PREFIX)/games/lib/$(GAME)dir +SHELLDIR = $(PREFIX)/games +INSTDIR=$(HACKDIR) +VARDIR = $(HACKDIR) + + +POSTINSTALL= cp -n sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; chmod $(VARFILEPERM) $(INSTDIR)/sysconf; +POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; (cd $(INSTDIR); mkfontdir); + +CFLAGS=-g -O -I../include -DNOTPARMDECL +CFLAGS+=-DHACKDIR=\"$(HACKDIR)\" +CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" +CFLAGS+=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\" +CFLAGS+=-DTIMED_DELAY +CFLAGS+=-DDUMPLOG +CFLAGS+=-DCONFIG_ERROR_SECURE=FALSE +CFLAGS+=-DQT_GRAPHICS -DDEFAULT_WINDOW_SYS=\"Qt\" -DNOTTYGRAPHICS +CFLAGS+=`pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --cflags` -fPIC + +LINK=g++ +CXX=g++ -std=gnu++11 + +WINSRC = $(WINQT4SRC) +WINOBJ = $(WINQT4OBJ) +WINLIB = $(WINQT5LIB) +#MOC = moc +MOC = moc-qt5 + +VARDATND = nhtiles.bmp rip.xpm nhsplash.xpm pet_mark.xbm pilemark.xbm + +QTDIR=/usr + +CHOWN=true +CHGRP=true +VARDIRPERM = 0755 +VARFILEPERM = 0600 +GAMEPERM = 0755 + +# note: needs libxt-dev libxaw7-dev libx11-dev bdftopcf diff --git a/sys/unix/hints/macosx10.10-qt b/sys/unix/hints/macosx10.10-qt new file mode 100644 index 000000000..3d9747649 --- /dev/null +++ b/sys/unix/hints/macosx10.10-qt @@ -0,0 +1,343 @@ +# +# NetHack 3.6 macosx10.11 $NHDT-Date: 1515549543 2018/01/10 01:59:03 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.48 $ +# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. +# NetHack may be freely redistributed. See license for details. +# +#-PRE +# Mac OS X (Darwin) hints file +# This is for Mac OS X 10.10 or later, and has been tested on 10.11 +# (El Capitan). If this doesn't work for some other +# version of Mac OS X, make a new file for that OS, don't change this one. +# And let us know about it. +# Useful info: http://www.opensource.apple.com/darwinsource/index.html + +# You'll need to obtain and install XQuartz if you want X11 support. +# (Attempting to run X11.app will describe where to get it.) + +# This hints file can build several different types of installations. +# Edit the next section to match the type of build you need. + +# 1. Which window system(s) should be included in this binary? +WANT_WIN_TTY=1 +#WANT_WIN_X11=1 +WANT_WIN_QT=1 + +# 1a. What is the default window system? +#WANT_DEFAULT=tty +#WANT_DEFAULT=x11 +WANT_DEFAULT=Qt + +# 1b. If you set WANT_WIN_QT, you need to +# A) set QTDIR either here or in the environment to point to the Qt5 +# library installation root. (Qt2 or Qt3 will not work.) +ifdef WANT_WIN_QT +QTDIR=$(shell brew --prefix)/opt/qt +endif # WANT_WIN_QT + +# 2. Is this a build for a binary that will be shared among different users +# or will it be private to you? +# If it is shared: +# - it will be owned by the user and group listed +# - if the user does not exist, you MUST create it before installing +# NetHack +# - if the group does not exist, it will be created. +# NB: if the group already exists and is being used for something +# besides games, you probably want to specify a new group instead +# NB: the group will be created locally; if your computer is centrally +# administered this may not be what you (or your admin) want. +# Consider a non-shared install (WANT_SHARE_INSTALL=0) instead. +# - 'make install' must be run as "sudo make install" +#WANT_SHARE_INSTALL=1 +GAMEUID = $(USER) +GAMEGRP = games +# build to run in the source tree - primarily for development. Build with "make all" +#WANT_SOURCE_INSTALL=1 + +CC=clang +CXX=clang++ -std=gnu++11 + +# At the moment this is just for debugging, but in the future it could be +# useful for other things. Requires SYSCF and an ANSI compiler. +#WANT_WIN_CHAIN=1 + +# +# You shouldn't need to change anything below here. +# + +#CFLAGS+=-W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN +CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN +# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so +# leave it out by default. +#CFLAGS+=-Wunreachable-code + +# XXX -g vs -O should go here, -I../include goes in the makefile +CFLAGS+=-g -I../include +# older binaries use NOCLIPPING, but that disables SIGWINCH +#CFLAGS+=-DNOCLIPPING +CFLAGS+= -DNOMAIL -DNOTPARMDECL -DHACKDIR=\"$(HACKDIR)\" +CFLAGS+= -DDEFAULT_WINDOW_SYS=\"$(WANT_DEFAULT)\" -DDLB + +CFLAGS+= -DGREPPATH=\"/usr/bin/grep\" + +ifdef WANT_WIN_CHAIN +CFLAGS+= -DWINCHAIN +HINTSRC=$(CHAINSRC) +HINTOBJ=$(CHAINOBJ) +endif + +WINSRC = +WINOBJ0 = +WINLIB = +LINK = $(CC) +VARDATND = + +ifdef WANT_WIN_TTY +WINSRC += $(WINTTYSRC) +WINOBJ0 += $(WINTTYOBJ) +WINLIB += $(WINTTYLIB) +WINTTYLIB=-lncurses +else # !WANT_WIN_TTY +CFLAGS += -DNOTTYGRAPHICS +endif # !WANT_WIN_TTY + +ifdef WANT_WIN_X11 +WINSRC += $(WINX11SRC) +WINOBJ0 += $(WINX11OBJ) +WINLIB += $(WINX11LIB) +LFLAGS += -L/opt/X11/lib +VARDATND += x11tiles NetHack.ad pet_mark.xbm pilemark.xbm +POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; (cd $(HACKDIR); mkfontdir); +CFLAGS += -DX11_GRAPHICS -I/opt/X11/include +# avoid repeated complaints about _X_NONNULL(args...) in +CFLAGS += -Wno-variadic-macros +endif # WANT_WIN_X11 + +ifdef WANT_WIN_QT +CFLAGS += -DQT_GRAPHICS -DNOUSER_SOUNDS +CFLAGS += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --cflags) +WINLIB += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --libs) +LINK=$(CXX) +WINSRC += $(WINQT4SRC) +WINOBJ0 += $(WINQT4OBJ) +VARDATND += rip.xpm +MOC = moc + +# XXX if /Developer/qt exists and QTDIR not set, use that +ifndef QTDIR +$(error QTDIR not defined in the environment or Makefile) +endif # QTDIR +# XXX make sure QTDIR points to something reasonable +endif # WANT_WIN_QT + +# prevent duplicate tile.o in WINOBJ +WINOBJ = $(sort $(WINOBJ0)) + +ifdef WANT_SHARE_INSTALL +# if $GAMEUID is root, we install into roughly proper Mac locations, otherwise +# we install into ~/nethackdir +ifeq ($(GAMEUID),root) +PREFIX:=/Library/NetHack +SHELLDIR=/usr/local/bin +HACKDIR=$(PREFIX)/nethackdir +CHOWN=chown +CHGRP=chgrp +# We run sgid so the game has access to both HACKDIR and user preferences. +GAMEPERM = 02755 +else # ! root +PREFIX:=/Users/$(GAMEUID) +SHELLDIR=$(PREFIX)/bin +HACKDIR=$(PREFIX)/Library/NetHack/nethackdir +CHOWN=/usr/bin/true +CHGRP=/usr/bin/true +GAMEPERM = 0500 +endif # ! root +VARFILEPERM = 0664 +VARDIRPERM = 0775 +ROOTCHECK= [[ `id -u` == 0 ]] || ( echo "Must run install with sudo."; exit 1) +# XXX it's nice we don't write over sysconf, but we've already erased it +# make sure we have group GAMEUID and group GAMEGRP +PREINSTALL= . sys/unix/hints/macosx.sh user2 $(GAMEUID); . sys/unix/hints/macosx.sh group2 $(GAMEGRP); mkdir $(SHELLDIR); chown $(GAMEUID) $(SHELLDIR) +POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; $(CHOWN) $(GAMEUID) $(HACKDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; chmod $(VARFILEPERM) $(HACKDIR)/sysconf; +CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE +else ifdef WANT_SOURCE_INSTALL +PREFIX=$(abspath $(NHSROOT)) +# suppress nethack.sh +#SHELLDIR= +HACKDIR=$(PREFIX)/playground +CHOWN=/usr/bin/true +CHGRP=/usr/bin/true +GAMEPERM = 0700 +VARFILEPERM = 0600 +VARDIRPERM = 0700 +POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; +# We can use "make all" to build the whole thing - but it misses some things: +MOREALL=$(MAKE) install +CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE +else # !WANT_SOURCE_INSTALL +PREFIX:=$(wildcard ~) +SHELLDIR=$(PREFIX)/bin +HACKDIR=$(PREFIX)/nethackdir +CHOWN=/usr/bin/true +CHGRP=/usr/bin/true +GAMEPERM = 0700 +VARFILEPERM = 0600 +VARDIRPERM = 0700 +ifdef WANT_WIN_X11 +# install nethack.rc as ~/.nethackrc if no ~/.nethackrc exists +PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc +endif # WANT_WIN_X11 +POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; $(CHOWN) $(GAMEUID) $(HACKDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; chmod $(VARFILEPERM) $(HACKDIR)/sysconf; +CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE +endif # !WANT_SOURCE_INSTALL + +INSTDIR=$(HACKDIR) +VARDIR=$(HACKDIR) + + +# ~/Library/Preferences/NetHack Defaults +# OPTIONS=name:player,number_pad,menustyle:partial,!time,showexp +# OPTIONS=hilite_pet,toptenwin,msghistory:200,windowtype:Qt +# +# Install.Qt mentions a patch for macos - it's not there (it seems to be in the Qt binary +# package under the docs directory). + +#-POST +ifdef MAKEFILE_TOP +### +### Packaging +### +# Notes: +# 1) The Apple developer utilities must be installed in the default location. +# 2) Do a normal build before trying to package the game. +# 3) This matches the 3.4.3 Term package, but there are some things that should +# be changed. + +ifdef WANT_WIN_TTY +DEVUTIL=/Developer/Applications/Utilities +SVS=$(shell $(NHSROOT)/util/makedefs --svs) +SVSDOT=$(shell $(NHSROOT)/util/makedefs --svs .) + +PKGROOT_UG = PKGROOT/$(PREFIX) +PKGROOT_UGLN = PKGROOT/$(HACKDIR) +PKGROOT_BIN = PKGROOT/$(SHELLDIR) +build_tty_pkg: +ifneq (,$(WANT_WIN_X11)$(WANT_WIN_QT)) + -echo build_tty_pkg only works for a tty-only build + exit 1 +else + rm -rf NetHack-$(SVS)-mac-Term.pkg NetHack-$(SVS)-mac-Term.dmg + $(MAKE) build_package_root + rm -rf RESOURCES + mkdir RESOURCES + #enscript --language=rtf -o - < dat/license >RESOURCES/License.rtf + sys/unix/hints/macosx.sh descplist > RESOURCES/Description.plist + sys/unix/hints/macosx.sh infoplist > Info.plist + + mkdir PKGROOT/Applications + #osacompile -o NetHackQt/NetHackQt.app/nethackdir/NetHackRecover.app \ + # win/macosx/NetHackRecover.applescript + #cp win/macosx/recover.pl NetHackQt/NetHackQt.app/nethackdir + osacompile -o PKGROOT/Applications/NetHackRecover.app \ + win/macosx/NetHackRecover.applescript + cp win/macosx/recover.pl $(PKGROOT_UGLN) + + osacompile -o PKGROOT/Applications/NetHackTerm.app \ + win/macosx/NetHackTerm.applescript + + # XXX integrate into Makefile.doc + (cd doc; cat Guidebook.mn | ../util/makedefs --grep --input - --output - \ + | tbl tmac.n - | groff | pstopdf -i -o Guidebook.pdf) + cp doc/Guidebook.pdf $(PKGROOT_UG)/doc/NetHackGuidebook.pdf + + osacompile -o PKGROOT/Applications/NetHackGuidebook.app \ + win/macosx/NetHackGuidebook.applescript + + mkdir -p PKG + pkgbuild --root PKGROOT --identifier org.nethack.term --scripts PKGSCRIPTS PKG/NH-Term.pkg + productbuild --synthesize --product Info.plist --package PKG/NH-Term.pkg Distribution.xml + productbuild --distribution Distribution.xml --resources RESOURCES --package-path PKG NetHack-$(SVS)-mac-Term.pkg + hdiutil create -verbose -srcfolder NetHack-$(SVS)-mac-Term.pkg NetHack-$(SVS)-mac-Term.dmg + +build_package_root: + cd src/.. # make sure we are at TOP + rm -rf PKGROOT + mkdir -p $(PKGROOT_UG)/lib $(PKGROOT_BIN) $(PKGROOT_UG)/man/man6 $(PKGROOT_UG)/doc $(PKGROOT_UGLN) + install -p src/nethack $(PKGROOT_BIN) + # XXX should this be called nethackrecover? + install -p util/recover $(PKGROOT_BIN) + install -p doc/nethack.6 $(PKGROOT_UG)/man/man6 + install -p doc/recover.6 $(PKGROOT_UG)/man/man6 + install -p doc/Guidebook $(PKGROOT_UG)/doc + install -p dat/nhdat $(PKGROOT_UGLN) + sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(PKGROOT_UGLN)/sysconf + cd dat; install -p $(DATNODLB) ../$(PKGROOT_UGLN) +# XXX these files should be somewhere else for good Mac form + touch $(PKGROOT_UGLN)/perm $(PKGROOT_UGLN)/record $(PKGROOT_UGLN)/logfile $(PKGROOT_UGLN)/xlogfile + mkdir $(PKGROOT_UGLN)/save +# XXX what about a news file? + + mkdir -p PKGSCRIPTS + echo '#!/bin/sh' > PKGSCRIPTS/postinstall + echo dseditgroup -o create -r '"Games Group"' -s 3600 $(GAMEGRP) >> PKGSCRIPTS/postinstall + echo $(CHOWN) -R $(GAMEUID) $(HACKDIR) >> PKGSCRIPTS/postinstall + echo $(CHGRP) -R $(GAMEGRP) $(HACKDIR) >> PKGSCRIPTS/postinstall + echo $(CHOWN) $(GAMEUID) $(SHELLDIR)/nethack >> PKGSCRIPTS/postinstall + echo $(CHGRP) $(GAMEGRP) $(SHELLDIR)/nethack >> PKGSCRIPTS/postinstall + echo $(CHOWN) $(GAMEUID) $(SHELLDIR)/recover >> PKGSCRIPTS/postinstall + echo $(CHGRP) $(GAMEGRP) $(SHELLDIR)/recover >> PKGSCRIPTS/postinstall + echo chmod $(VARDIRPERM) $(HACKDIR) >> PKGSCRIPTS/postinstall + echo chmod $(VARDIRPERM) $(HACKDIR)/save >> PKGSCRIPTS/postinstall + echo chmod $(FILEPERM) $(HACKDIR)/license >> PKGSCRIPTS/postinstall + echo chmod $(FILEPERM) $(HACKDIR)/nhdat >> PKGSCRIPTS/postinstall + echo chmod $(FILEPERM) $(HACKDIR)/symbols >> PKGSCRIPTS/postinstall + echo chmod $(VARFILEPERM) $(HACKDIR)/perm >> PKGSCRIPTS/postinstall + echo chmod $(VARFILEPERM) $(HACKDIR)/record >> PKGSCRIPTS/postinstall + echo chmod $(VARFILEPERM) $(HACKDIR)/logfile >> PKGSCRIPTS/postinstall + echo chmod $(VARFILEPERM) $(HACKDIR)/xlogfile >> PKGSCRIPTS/postinstall + echo chmod $(VARFILEPERM) $(HACKDIR)/sysconf >> PKGSCRIPTS/postinstall + echo chmod $(GAMEPERM) $(SHELLDIR)/nethack >> PKGSCRIPTS/postinstall + echo chmod $(EXEPERM) $(SHELLDIR)/recover >> PKGSCRIPTS/postinstall + chmod 0775 PKGSCRIPTS/postinstall + +endif # end of build_tty_pkg +endif # WANT_WIN_TTY for packaging + +ifdef WANT_WIN_QT +# XXX untested and incomplete (see below) +build_qt_pkg: +ifneq (,$(WANT_WIN_X11)$(WANT_WIN_TTY)) + -echo build_qt_pkg only works for a qt-only build + exit 1 +else + $(MAKE) build_package_root + rm -rf NetHackQt + mkdir -p NetHackQt/NetHackQt.app/nethackdir/save + mkdir NetHackQt/Documentation + cp doc/Guidebook.txt doc/nethack.txt doc/recover.txt NetHackQt/Documentation + + osacompile -o NetHackQt/NetHackQt.app/nethackdir/NetHackRecover.app \ + win/macosx/NetHackRecover.applescript + cp win/macosx/recover.pl NetHackQt/NetHackQt.app/nethackdir + + mkdir -p NetHackQt/NetHackQt.app/Contents/Frameworks + cp $(QTDIR)/libqt-mt.3.dylib NetHackQt/NetHackQt.app/Contents/Frameworks + + mkdir NetHackQt/NetHackQt.app/Contents/MacOS + mv PKGROOT/nethack NetHackQt/NetHackQt.app/Contents/MacOS + + mv PKGROOT/lib/nethackdir NetHackQt/NetHackQt.app/nethackdir + +# XXX still missing: +#NetHackQt/NetHackQt.app +# /Contents +# Info.plist +# Resources/nethack.icns +#NetHackQt/Documentation +#NetHackQtRecover.txt +#NetHack Defaults.txt +#changes.patch XXX is this still needed? why isn't it part of the tree? +# doesn't go here + hdiutil create -verbose -srcfolder NetHackQt NetHack-$(SVS)-macosx-qt.dmg +endif # end of build_qt_pkg +endif # WANT_WIN_QT for packaging +endif # MAKEFILE_TOP diff --git a/sys/winnt/.gitignore b/sys/winnt/.gitignore new file mode 100644 index 000000000..1fe00dd91 --- /dev/null +++ b/sys/winnt/.gitignore @@ -0,0 +1 @@ +NetHack.ico diff --git a/sys/winnt/Makefile.gcc b/sys/winnt/Makefile.gcc index 5be03e2ed..d46b94299 100644 --- a/sys/winnt/Makefile.gcc +++ b/sys/winnt/Makefile.gcc @@ -33,10 +33,16 @@ #============================================================================== # BUILD DECISIONS SECTION # -# There are currently only 3 decisions that you have to make. +# There are currently only 4 decisions that you have to make. # 1. 32-bit or 64-bit? # 2. Where do you want your build to end up? # 3. Do you want debug information in the executable? +# 4. Do you want additional GUI interfaces in the executable? +# +# Note that additional GUI interfaces may require external libraries. +# Qt is placed where the official installer places it. +# Other libraries are placed in a subdirectory of your home directory, either +# x86libs or x64libs depending on whether you're building for 64 bits. # #============================================================================== # 1. 32-bit or 64-bit? @@ -62,6 +68,26 @@ GAMEDIR = ../binary DEBUGINFO = Y +# +#--------------------------------------------------------------- +# 4. Do you want additional GUI interfaces in the executable? +# Make these Y to enable the GUIs. Win32 is always enabled, +# and is the default. +# + +WANT_WIN_QT4 = N + +# WANT_WIN_QT4 requires Qt 4 or Qt 5, see +# https://www.qt.io/download-open-source/ +# Earlier versions of Qt are not compatible with Windows +# For Qt 5, use: +QT4_DIRECTORY = c:/Qt/Qt5.9.2/5.9.2/mingw53_32 +HAVE_QT5 = Y + +# For Qt 4, comment out the above two lines and use: +#QT4_DIRECTORY = c:/Qt/4.8.6 +#HAVE_QT5 = N + # This marks the end of the BUILD DECISIONS section. #============================================================================== # @@ -97,6 +123,8 @@ MSWSYS = ../sys/winnt TTY = ../win/tty # window port files (WIN32) MSWIN = ../win/win32 +# window port files (Qt4) +QT4 = ../win/Qt4 # Tile support files WSHR = ../win/share @@ -107,8 +135,12 @@ WSHR = ../win/share OBJ = o cc = gcc +cxx = g++ rc = windres link = gcc +ifeq "$(WANT_WIN_QT4)" "Y" + link = g++ +endif # #========================================== @@ -159,6 +191,9 @@ RANDOM = $(OBJ)/random.o #RANDOM = WINPFLAG = -DTILES -DMSWIN_GRAPHICS -DWIN32CON -D_WIN32_IE=0x0400 -D_WIN32_WINNT=0x0501 +ifeq "$(WANT_WIN_QT4)" "Y" + WINPFLAG += -DQT_GRAPHICS -DPIXMAPDIR='"."' +endif # To store all the level files, # help files, etc. in a single library file. # USE_DLB = Y is left uncommented @@ -191,8 +226,38 @@ CFLAGSBASE = -c $(cflags) -I$(INCL) $(WINPINC) $(cdebug) #LFLAGSBASEC = $(linkdebug) #LFLAGSBASEG = $(linkdebug) -mwindows -conlibs = -lwinmm +conlibs = -lgdi32 -lwinmm guilibs = -lcomctl32 -lwinmm +ifeq "$(WANT_WIN_QT4)" "Y" + # Might be either Qt 4 or Qt 5 + ifeq "$(HAVE_QT5)" "Y" + guilibs += $(QT4_DIRECTORY)/lib/libQt5Core.a + guilibs += $(QT4_DIRECTORY)/lib/libQt5Gui.a + guilibs += $(QT4_DIRECTORY)/lib/libQt5Widgets.a + conlibs += $(QT4_DIRECTORY)/lib/libQt5Core.a + else + guilibs += $(QT4_DIRECTORY)/lib/libQtCore4.a + guilibs += $(QT4_DIRECTORY)/lib/libQtGui4.a + conlibs += $(QT4_DIRECTORY)/lib/libQtCore4.a + endif +endif + +#========================================== +# Extra files needed for some ports +#========================================== +EXTRA_FILES = +ifeq "$(WANT_WIN_QT4)" "Y" + ifeq "$(HAVE_QT5)" "Y" + EXTRA_FILES += $(GAMEDIR)/Qt5Core.dll + EXTRA_FILES += $(GAMEDIR)/Qt5Gui.dll + EXTRA_FILES += $(GAMEDIR)/Qt5Widgets.dll + else + # TODO: define QT 4 DLLs here + EXTRA_FILES += $(GAMEDIR)/QtCore4.dll + EXTRA_FILES += $(GAMEDIR)/QtGui4.dll + endif + EXTRA_FILES += $(GAMEDIR)/rip.xpm +endif #========================================== # Util builds @@ -208,6 +273,8 @@ LFLAGSU = $(LFLAGSBASEC) CFLAGS = $(CFLAGSBASE) $(WINPFLAG) $(DLBFLG) lflags = $(LFLAGSBASEC) $(linkdebuf) +CXXFLAGS = $(CFLAGS) + ifeq "$(USE_DLB)" "Y" DLB = nhdat else @@ -320,12 +387,28 @@ GUIOBJ = $(O)mhaskyn.o $(O)mhdlg.o \ $(O)mhfont.o $(O)mhinput.o $(O)mhmain.o $(O)mhmap.o \ $(O)mhmenu.o $(O)mhmsgwnd.o $(O)mhrip.o $(O)mhsplash.o \ $(O)mhstatus.o $(O)mhtext.o $(O)mswproc.o $(O)winhack.o +ifeq "$(WANT_WIN_QT4)" "Y" + GUIOBJ += $(O)qt4bind.o $(O)qt4click.o $(O)qt4clust.o $(O)qt4delay.o \ + $(O)qt4glyph.o $(O)qt4icon.o $(O)qt4inv.o $(O)qt4key.o $(O)qt4line.o \ + $(O)qt4main.o $(O)qt4map.o $(O)qt4menu.o $(O)qt4msg.o $(O)qt4plsel.o \ + $(O)qt4rip.o $(O)qt4set.o $(O)qt4stat.o $(O)qt4str.o $(O)qt4streq.o \ + $(O)qt4svsel.o $(O)qt4win.o $(O)qt4xcmd.o $(O)qt4yndlg.o +endif GUIHDR = $(MSWIN)/mhaskyn.h $(MSWIN)/mhdlg.h $(MSWIN)/mhfont.h \ $(MSWIN)/mhinput.h $(MSWIN)/mhmain.h $(MSWIN)/mhmap.h \ $(MSWIN)/mhmenu.h $(MSWIN)/mhmsg.h $(MSWIN)/mhmsgwnd.h \ $(MSWIN)/mhrip.h $(MSWIN)/mhstatus.h \ $(MSWIN)/mhtext.h $(MSWIN)/resource.h $(MSWIN)/winMS.h +ifeq "$(WANT_WIN_QT4)" "Y" + GUIHDR += $(QT4)/qt4bind.h $(QT4)/qt4click.h $(QT4)/qt4clust.h \ + $(QT4)/qt4delay.h $(QT4)/qt4glyph.h $(QT4)/qt4icon.h $(QT4)/qt4inv.h \ + $(QT4)/qt4kde0.h $(QT4)/qt4key.h $(QT4)/qt4line.h $(QT4)/qt4main.h \ + $(QT4)/qt4map.h $(QT4)/qt4menu.h $(QT4)/qt4msg.h $(QT4)/qt4plsel.h \ + $(QT4)/qt4rip.h $(QT4)/qt4set.h $(QT4)/qt4stat.h $(QT4)/qt4str.h \ + $(QT4)/qt4streq.h $(QT4)/qt4svsel.h $(QT4)/qt4win.h $(QT4)/qt4xcmd.h \ + $(QT4)/qt4yndlg.h +endif KEYDLLS = $(GAMEDIR)/nhdefkey.dll $(GAMEDIR)/nh340key.dll $(GAMEDIR)/nhraykey.dll @@ -385,7 +468,7 @@ DATABASE = $(DAT)/data.base #================ RULES ================== #========================================== -.SUFFIXES: .exe .o .til .uu .c .y .l +.SUFFIXES: .exe .o .til .uu .c .y .l .moc #========================================== # Rules for files in src @@ -405,7 +488,7 @@ $(OBJ)/%.o : $(SSYS)/%.c $(cc) $(CFLAGS) -o$@ $< $(OBJ)/%.o : $(SSYS)/%.cpp - g++ $(CFLAGS) -std=c++11 -o$@ $< + $(cxx) $(CXXFLAGS) -std=c++11 -o$@ $< #========================================== # Rules for files in sys/winnt @@ -451,6 +534,21 @@ $(OBJ)/%.o : $(TTY)/%.c $(OBJ)/%.o : $(MSWIN)/%.c $(cc) $(CFLAGS) -o$@ $< +#========================================== +# Rules for files in win/Qt4 +#========================================== + +ifeq "$(HAVE_QT5)" "Y" +QT4_CXXFLAGS = -std=c++11 +else +QT4_CXXFLAGS = +endif +$(OBJ)/%.o : $(QT4)/%.cpp + $(cxx) $(CXXFLAGS) $(QT4_CXXFLAGS) -I$(MSWIN) -I$(QT4_DIRECTORY)/include -o$@ $< + +$(QT4)/%.moc : $(QT4)/%.h + $(QT4_DIRECTORY)\bin\moc -o $@ $< + #========================================== #=============== TARGETS ================== #========================================== @@ -472,7 +570,7 @@ default : install all : install -install: graphicschk $(O)obj.tag $(GAMEDIR)/NetHack.exe $(GAMEDIR)/NetHackW.exe $(O)install.tag +install: graphicschk $(O)obj.tag $(GAMEDIR)/NetHack.exe $(GAMEDIR)/NetHackW.exe $(O)install.tag $(EXTRA_FILES) @echo NetHack is up to date. @echo Done. @@ -1035,8 +1133,33 @@ spotless: clean $(subst /,\,if exist $(U)recover.exe del $(U)recover.exe) $(subst /,\,if exist $(DAT)/dlb.lst del $(DAT)/dlb.lst) $(subst /,\,if exist nhdat. del nhdat.) + $(subst /,\,if exist $(QT4)/*.moc del $(QT4)/*.moc) + $(subst /,\,if exist $(DAT)/bogusmon del $(DAT)/bogusmon) + $(subst /,\,if exist $(DAT)/engrave del $(DAT)/engrave) + $(subst /,\,if exist $(DAT)/epitaph del $(DAT)/epitaph) + $(subst /,\,if exist $(DAT)/porthelp del $(DAT)/porthelp) + $(subst /,\,if exist $(INCL)/dgn_comp.h del $(INCL)/dgn_comp.h) + $(subst /,\,if exist $(INCL)/lev_comp.h del $(INCL)/lev_comp.h) + $(subst /,\,if exist $(INCL)/win32api.h del $(INCL)/win32api.h) + $(subst /,\,if exist $(MSWSYS)/NetHack.ico del $(MSWSYS)/NetHack.ico) + $(subst /,\,if exist $(U)dgn_flex.c del $(U)dgn_flex.c) + $(subst /,\,if exist $(U)dgn_yacc.c del $(U)dgn_yacc.c) + $(subst /,\,if exist $(U)dlb_main.exe del $(U)dlb_main.exe) + $(subst /,\,if exist $(U)lev_flex.c del $(U)lev_flex.c) + $(subst /,\,if exist $(U)lev_yacc.c del $(U)lev_yacc.c) + $(subst /,\,if exist $(U)tile2bmp.exe del $(U)tile2bmp.exe) + $(subst /,\,if exist $(U)tilemap.exe del $(U)tilemap.exe) + $(subst /,\,if exist $(U)uudecode.exe del $(U)uudecode.exe) + $(subst /,\,if exist $(MSWIN)/NetHack.ico del $(MSWIN)/NetHack.ico) + $(subst /,\,if exist $(MSWIN)/mnsel.bmp del $(MSWIN)/mnsel.bmp) + $(subst /,\,if exist $(MSWIN)/mnselcnt.bmp del $(MSWIN)/mnselcnt.bmp) + $(subst /,\,if exist $(MSWIN)/mnunsel.bmp del $(MSWIN)/mnunsel.bmp) + $(subst /,\,if exist $(MSWIN)/petmark.bmp del $(MSWIN)/petmark.bmp) + $(subst /,\,if exist $(MSWIN)/pilemark.bmp del $(MSWIN)/pilemark.bmp) + $(subst /,\,if exist $(MSWIN)/rip.bmp del $(MSWIN)/rip.bmp) + $(subst /,\,if exist $(MSWIN)/splash.bmp del $(MSWIN)/splash.bmp) ifneq "$(OBJ)" "" - $(subst /,\,rmdir $(OBJ)) /s /Q + $(subst /,\,if exist $(OBJ) rmdir $(OBJ)) /s /Q endif clean: @@ -1057,6 +1180,40 @@ clean: # OTHER DEPENDENCIES #=================================================================== +# Other files needed by some ports +$(GAMEDIR)/Qt5Core.dll : $(QT4_DIRECTORY)/bin/Qt5Core.dll + $(subst /,\,@copy $< $@ >nul) + +$(GAMEDIR)/Qt5Gui.dll : $(QT4_DIRECTORY)/bin/Qt5Gui.dll + $(subst /,\,@copy $< $@ >nul) + +$(GAMEDIR)/Qt5Widgets.dll : $(QT4_DIRECTORY)/bin/Qt5Widgets.dll + $(subst /,\,@copy $< $@ >nul) + +$(GAMEDIR)/QtCore4.dll : $(QT4_DIRECTORY)/bin/QtCore4.dll + $(subst /,\,@copy $< $@ >nul) + +$(GAMEDIR)/QtGui4.dll : $(QT4_DIRECTORY)/bin/QtGui4.dll + $(subst /,\,@copy $< $@ >nul) + +$(GAMEDIR)/nhtiles.bmp : $(SRC)/tiles.bmp + $(subst /,\,@copy $< $@ >nul) + +$(GAMEDIR)/rip.xpm : ../win/X11/rip.xpm + $(subst /,\,@copy $< $@ >nul) + + +# Dependencies on .moc files (for Qt 4 or 5) +$(OBJ)/qt4main.o : $(QT4)/qt4main.cpp $(QT4)/qt4main.moc $(QT4)/qt4kde0.moc +$(OBJ)/qt4map.o : $(QT4)/qt4map.cpp $(QT4)/qt4map.moc +$(OBJ)/qt4menu.o : $(QT4)/qt4menu.cpp $(QT4)/qt4menu.moc +$(OBJ)/qt4msg.o : $(QT4)/qt4msg.cpp $(QT4)/qt4msg.moc +$(OBJ)/qt4plsel.o : $(QT4)/qt4plsel.cpp $(QT4)/qt4plsel.moc +$(OBJ)/qt4set.o : $(QT4)/qt4set.cpp $(QT4)/qt4set.moc +$(OBJ)/qt4stat.o : $(QT4)/qt4stat.cpp $(QT4)/qt4stat.moc +$(OBJ)/qt4xcmd.o : $(QT4)/qt4xcmd.cpp $(QT4)/qt4xcmd.moc +$(OBJ)/qt4yndlg.o : $(QT4)/qt4yndlg.cpp $(QT4)/qt4yndlg.moc + # # dat dependencies # diff --git a/sys/winnt/stubs.c b/sys/winnt/stubs.c index 2a0d10e79..64193ce17 100644 --- a/sys/winnt/stubs.c +++ b/sys/winnt/stubs.c @@ -12,6 +12,10 @@ int GUILaunched; struct window_procs mswin_procs = { "guistubs" }; +#ifdef QT_GRAPHICS +struct window_procs Qt_procs = { "guistubs" }; +int qt_tilewidth, qt_tileheight, qt_fontsize, qt_compact_mode; +#endif void mswin_destroy_reg() { diff --git a/util/.gitignore b/util/.gitignore index 95b7c4db1..c211d0a77 100644 --- a/util/.gitignore +++ b/util/.gitignore @@ -1,6 +1,8 @@ dgn_lex.c +dgn_flex.c dgn_yacc.c lev_lex.c +lev_flex.c lev_yacc.c tiletxt.c makedefs diff --git a/win/Qt4/.gitignore b/win/Qt4/.gitignore new file mode 100644 index 000000000..e978b1085 --- /dev/null +++ b/win/Qt4/.gitignore @@ -0,0 +1 @@ +*.moc diff --git a/win/Qt4/qt4bind.cpp b/win/Qt4/qt4bind.cpp index 2fef131ce..27db51868 100644 --- a/win/Qt4/qt4bind.cpp +++ b/win/Qt4/qt4bind.cpp @@ -18,7 +18,7 @@ extern "C" { #undef max #include -#include +#include #if QT_VERSION >= 0x050000 #include #include @@ -350,9 +350,9 @@ void NetHackQtBind::qt_display_file(const char *filename, BOOLEAN_P must_exist) complain = must_exist; } else { while (dlb_fgets(buf, BUFSZ, f)) { - if ((cr = index(buf, '\n')) != 0) *cr = 0; + if ((cr = strchr(buf, '\n')) != 0) *cr = 0; #ifdef MSDOS - if ((cr = index(buf, '\r')) != 0) *cr = 0; + if ((cr = strchr(buf, '\r')) != 0) *cr = 0; #endif window->PutStr(ATR_NONE, tabexpand(buf)); } @@ -508,8 +508,8 @@ char NetHackQtBind::qt_yn_function(const char *question_, const char *choices, C message = QString("%1 [%2] ").arg(question, choicebuf); if (def) message += QString("(%1) ").arg(QChar(def)); // escape maps to 'q' or 'n' or default, in that order - yn_esc_map = (index(choices, 'q') ? 'q' : - (index(choices, 'n') ? 'n' : def)); + yn_esc_map = (strchr(choices, 'q') ? 'q' : + (strchr(choices, 'n') ? 'n' : def)); } else { message = question; } @@ -542,7 +542,7 @@ char NetHackQtBind::qt_yn_function(const char *question_, const char *choices, C char ch=NetHackQtBind::qt_nhgetch(); if (ch=='\033') { result=yn_esc_map; - } else if (choices && !index(choices,ch)) { + } else if (choices && !strchr(choices,ch)) { if (def && (ch==' ' || ch=='\r' || ch=='\n')) { result=def; } else { @@ -565,6 +565,8 @@ char NetHackQtBind::qt_yn_function(const char *question_, const char *choices, C else if (def) message += QString(" %1").arg(def); NetHackQtBind::qt_putstr(WIN_MESSAGE, ATR_BOLD, message); + + return ret; } } @@ -798,6 +800,7 @@ struct window_procs Qt_procs = { genl_can_suspend_yes, }; +#ifndef WIN32 extern "C" void play_usersound(const char* filename, int volume) { #ifdef USER_SOUNDS @@ -806,3 +809,4 @@ extern "C" void play_usersound(const char* filename, int volume) #endif #endif } +#endif diff --git a/win/Qt4/qt4xcmd.cpp b/win/Qt4/qt4xcmd.cpp index 3e8703e49..7c078f640 100644 --- a/win/Qt4/qt4xcmd.cpp +++ b/win/Qt4/qt4xcmd.cpp @@ -66,6 +66,7 @@ NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(QWidget *parent) : pb->setMinimumSize(butw,pb->sizeHint().height()); group->addButton(pb, i+1); gl->addWidget(pb,i/ncols,i%ncols); + buttons.append(pb); } group->addButton(can, 0); connect(group,SIGNAL(buttonPressed(int)),this,SLOT(done(int))); @@ -92,6 +93,7 @@ void NetHackQtExtCmdRequestor::keyPressEvent(QKeyEvent *event) QString promptstr = prompt->text(); if (promptstr != "#") prompt->setText(promptstr.left(promptstr.size()-1)); + enableButtons(); } else { @@ -111,6 +113,7 @@ void NetHackQtExtCmdRequestor::keyPressEvent(QKeyEvent *event) done(match+1); else if (matches >= 2) prompt->setText(promptstr); + enableButtons(); } } @@ -131,4 +134,15 @@ int NetHackQtExtCmdRequestor::get() return result()-1; } +// Enable only buttons that match the current prompt string +void NetHackQtExtCmdRequestor::enableButtons() +{ + QString typedstr = prompt->text().mid(1); // skip the '#' + std::size_t len = typedstr.size(); + + for (auto b = buttons.begin(); b != buttons.end(); ++b) { + (*b)->setVisible((*b)->text().left(len) == typedstr); + } +} + } // namespace nethack_qt4 diff --git a/win/Qt4/qt4xcmd.h b/win/Qt4/qt4xcmd.h index 29ba23f0d..338ef3370 100644 --- a/win/Qt4/qt4xcmd.h +++ b/win/Qt4/qt4xcmd.h @@ -21,6 +21,8 @@ public: private: QLabel *prompt; + QVector buttons; + void enableButtons(); private slots: void cancel(); diff --git a/win/win32/mhstatus.c b/win/win32/mhstatus.c index 52d24621a..80799ad82 100644 --- a/win/win32/mhstatus.c +++ b/win/win32/mhstatus.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mhstatus.c $NHDT-Date: 1432512810 2015/05/25 00:13:30 $ $NHDT-Branch: master $:$NHDT-Revision: 1.22 $ */ +/* NetHack 3.6 mhstatus.c $NHDT-Date: 1536411224 2018/09/08 12:53:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.29 $ */ /* Copyright (C) 2001 by Alex Kompel */ /* NetHack may be freely redistributed. See license for details. */ @@ -324,7 +324,7 @@ onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam) LONG left = rt.left; LONG cy = 0; int vlen; - for (f = *fop; *f != -1; f++) { + for (f = *fop; *f != BL_FLUSH; f++) { int clr, atr; int fntatr = ATR_NONE; HGDIOBJ fnt; @@ -362,7 +362,8 @@ onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam) SelectObject(hdc, fnt); SetBkMode(hdc, OPAQUE); SetBkColor(hdc, status_bg_color); - SetTextColor(hdc, nhcolor_to_RGB(hpbar_color)); + /* SetTextColor(hdc, nhcolor_to_RGB(hpbar_color)); */ + SetTextColor(hdc, status_fg_color); /* get bounding rectangle */ GetTextExtentPoint32(hdc, wbuf, vlen, &sz); @@ -370,21 +371,22 @@ onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam) /* first draw title normally */ DrawText(hdc, wbuf, vlen, &rt, DT_LEFT); - /* calc bar length */ - barrect.left = rt.left; - barrect.top = rt.top; - barrect.bottom = sz.cy; - if (hpbar_percent > 0) - barrect.right = (int)((hpbar_percent * sz.cx) / 100); - else - barrect.right = sz.cx; - - /* then draw hpbar on top of title */ - FillRect(hdc, &barrect, back_brush); - SetBkMode(hdc, TRANSPARENT); - SetTextColor(hdc, nBg); - DrawText(hdc, wbuf, vlen, &barrect, DT_LEFT); + if (hpbar_percent > 0) { + /* calc bar length */ + barrect.left = rt.left; + barrect.top = rt.top; + barrect.bottom = sz.cy; + if (hpbar_percent > 0) + barrect.right = (int)((hpbar_percent * sz.cx) / 100); + /* else + barrect.right = sz.cx; */ + /* then draw hpbar on top of title */ + FillRect(hdc, &barrect, back_brush); + SetBkMode(hdc, TRANSPARENT); + SetTextColor(hdc, nBg); + DrawText(hdc, wbuf, vlen, &barrect, DT_LEFT); + } DeleteObject(back_brush); } else { if (atr & HL_INVERSE) { diff --git a/win/win32/mswproc.c b/win/win32/mswproc.c index fb9ad0a94..feabf49b2 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mswproc.c $NHDT-Date: 1451611595 2016/01/01 01:26:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.98 $ */ +/* NetHack 3.6 mswproc.c $NHDT-Date: 1536411259 2018/09/08 12:54:19 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.118 $ */ /* Copyright (C) 2001 by Alex Kompel */ /* NetHack may be freely redistributed. See license for details. */ @@ -2899,10 +2899,21 @@ mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color, int ocolor, ochar; unsigned ospecial; long value = -1; + boolean reset_state = FALSE; logDebug("mswin_status_update(%d, %p, %d, %d, %x, %p)\n", idx, ptr, chg, percent, color, colormasks); - if (idx != BL_FLUSH && idx != BL_RESET) { + switch (idx) { + case BL_RESET: + reset_state = TRUE; + /* FALLTHRU */ + case BL_FLUSH: + /* FALLTHRU */ + default: + break; + } + + if (idx >= 0) { if (!_status_activefields[idx]) return; _status_percents[idx] = percent; @@ -2965,18 +2976,18 @@ mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color, text); } break; } - } - _status_colors[idx] = color; + _status_colors[idx] = color; - /* send command to status window */ - ZeroMemory(&update_cmd_data, sizeof(update_cmd_data)); - update_cmd_data.n_fields = MAXBLSTATS; - update_cmd_data.vals = _status_vals; - update_cmd_data.activefields = _status_activefields; - update_cmd_data.percents = _status_percents; - update_cmd_data.colors = _status_colors; - SendMessage(mswin_hwnd_from_winid(WIN_STATUS), WM_MSNH_COMMAND, + /* send command to status window */ + ZeroMemory(&update_cmd_data, sizeof(update_cmd_data)); + update_cmd_data.n_fields = MAXBLSTATS; + update_cmd_data.vals = _status_vals; + update_cmd_data.activefields = _status_activefields; + update_cmd_data.percents = _status_percents; + update_cmd_data.colors = _status_colors; + SendMessage(mswin_hwnd_from_winid(WIN_STATUS), WM_MSNH_COMMAND, (WPARAM) MSNH_MSG_UPDATE_STATUS, (LPARAM) &update_cmd_data); + } }