]> granicus.if.org Git - nethack/commitdiff
Changes for Qt 6 on MacOS
authorRay Chason <chasonr@Rays-MacBook-Air.local>
Mon, 27 Dec 2021 18:45:54 +0000 (13:45 -0500)
committerPatR <rankin@nethack.org>
Thu, 30 Dec 2021 18:56:06 +0000 (10:56 -0800)
25 files changed:
sys/unix/Makefile.src
sys/unix/hints/macOS.2020
sys/unix/hints/macOS.2020-qt6 [new file with mode: 0755]
sys/unix/hints/macosx10.10-qt
win/Qt/qt_bind.cpp
win/Qt/qt_click.cpp
win/Qt/qt_delay.cpp
win/Qt/qt_glyph.cpp
win/Qt/qt_icon.cpp
win/Qt/qt_inv.cpp
win/Qt/qt_key.cpp
win/Qt/qt_line.cpp
win/Qt/qt_main.cpp
win/Qt/qt_map.cpp
win/Qt/qt_menu.cpp
win/Qt/qt_msg.cpp
win/Qt/qt_plsel.cpp
win/Qt/qt_rip.cpp
win/Qt/qt_set.cpp
win/Qt/qt_stat.cpp
win/Qt/qt_streq.cpp
win/Qt/qt_svsel.cpp
win/Qt/qt_win.cpp
win/Qt/qt_xcmd.cpp
win/Qt/qt_yndlg.cpp

index bb3e175cea997a4755889bcf8747ec63baba0df6..e077aad23c45eae7ac82571a1cd1d7625248a140 100644 (file)
@@ -179,6 +179,7 @@ SYSOBJ = $(TARGETPFX)ioctl.o $(TARGETPFX)unixmain.o $(TARGETPFX)unixtty.o \
 CXXFLAGS = $(CCXXFLAGS) -I. -I$(QTDIR)/include $(QTCXXFLAGS)
 CXX ?= g++
 MOC ?= moc
+MOCPATH ?= $(QTDIR)/bin/$(MOC)
 #LINK=g++
 
 # The default is for the TARGET_* variables to match the defaults.
@@ -679,25 +680,25 @@ qt3tableview.moc: ../win/Qt3/qt3tableview.h
 
 # Qt 4 windowport meta-object-compiler output
 qt_kde0.moc : ../win/Qt/qt_kde0.h
-       $(QTDIR)/bin/$(MOC) -o qt_kde0.moc ../win/Qt/qt_kde0.h
+       $(MOCPATH) -o qt_kde0.moc ../win/Qt/qt_kde0.h
 qt_main.moc : ../win/Qt/qt_main.h
-       $(QTDIR)/bin/$(MOC) -o qt_main.moc ../win/Qt/qt_main.h
+       $(MOCPATH) -o qt_main.moc ../win/Qt/qt_main.h
 qt_map.moc : ../win/Qt/qt_map.h
-       $(QTDIR)/bin/$(MOC) -o qt_map.moc ../win/Qt/qt_map.h
+       $(MOCPATH) -o qt_map.moc ../win/Qt/qt_map.h
 qt_menu.moc : ../win/Qt/qt_menu.h
-       $(QTDIR)/bin/$(MOC) -o qt_menu.moc ../win/Qt/qt_menu.h
+       $(MOCPATH) -o qt_menu.moc ../win/Qt/qt_menu.h
 qt_msg.moc : ../win/Qt/qt_msg.h
-       $(QTDIR)/bin/$(MOC) -o qt_msg.moc ../win/Qt/qt_msg.h
+       $(MOCPATH) -o qt_msg.moc ../win/Qt/qt_msg.h
 qt_plsel.moc : ../win/Qt/qt_plsel.h
-       $(QTDIR)/bin/$(MOC) -o qt_plsel.moc ../win/Qt/qt_plsel.h
+       $(MOCPATH) -o qt_plsel.moc ../win/Qt/qt_plsel.h
 qt_set.moc : ../win/Qt/qt_set.h
-       $(QTDIR)/bin/$(MOC) -o qt_set.moc ../win/Qt/qt_set.h
+       $(MOCPATH) -o qt_set.moc ../win/Qt/qt_set.h
 qt_stat.moc : ../win/Qt/qt_stat.h
-       $(QTDIR)/bin/$(MOC) -o qt_stat.moc ../win/Qt/qt_stat.h
+       $(MOCPATH) -o qt_stat.moc ../win/Qt/qt_stat.h
 qt_xcmd.moc : ../win/Qt/qt_xcmd.h
-       $(QTDIR)/bin/$(MOC) -o qt_xcmd.moc ../win/Qt/qt_xcmd.h
+       $(MOCPATH) -o qt_xcmd.moc ../win/Qt/qt_xcmd.h
 qt_yndlg.moc : ../win/Qt/qt_yndlg.h
-       $(QTDIR)/bin/$(MOC) -o qt_yndlg.moc ../win/Qt/qt_yndlg.h
+       $(MOCPATH) -o qt_yndlg.moc ../win/Qt/qt_yndlg.h
 
 #      build monst.o and objects.o before executing '$(MAKE) makedefs'
 $(MAKEDEFS): $(FIRSTOBJ) \
index c4ec7f732bb4ee3f583da9a5fe83b147632a563b..26742dea0aa15680a526a43cf2f0295b00e5b8db 100755 (executable)
@@ -31,7 +31,7 @@ endif
 ifdef WANT_WIN_QT
 #QTDIR=/Developer/Qt
 # Qt installed via homebrew
-QTDIR=$(shell brew --prefix)/opt/qt
+QTDIR=$(shell brew --prefix)/opt/qt@5
 # Qt installed via macports
 #QTDIR=/opt/local/libexec/qt5
 endif  # WANT_WIN_QT
diff --git a/sys/unix/hints/macOS.2020-qt6 b/sys/unix/hints/macOS.2020-qt6
new file mode 100755 (executable)
index 0000000..9407a0a
--- /dev/null
@@ -0,0 +1,470 @@
+# NetHack 3.7  macOS.2020 $NHDT-Date: 1633401749 2021/10/05 02:42:29 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.88 $
+# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015.
+# NetHack may be freely redistributed.  See license for details.
+#
+#---------------------------------------------------------------------
+# MacOS hints file with support for multiple window ports (interfaces)
+# Tested on:
+#     - MacOS Catalina 10.15
+#
+# If this doesn't work for some other version of Mac OS X, consider
+# making a new hints file it, rather than changing this one.
+# And let us know about it.
+# Useful info: http://www.opensource.apple.com/darwinsource/index.html
+
+#-PRE xxxx
+# macOS X hints file
+#
+
+# note: '#-INCLUDE' is not just a comment; multiw-1 contains sections 1 to 2
+#-INCLUDE multiw-1.2020
+
+# 3. 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, Qt3, Qt4 will not work)
+#  B) set XPMLIB to point to the Xpm library
+ifndef WANT_WIN_QT
+ifdef WANT_WIN_ALL
+WANT_WIN_QT=1
+endif
+endif
+ifdef WANT_WIN_QT
+#QTDIR=/Developer/Qt
+# Qt installed via homebrew
+QTDIR=$(shell brew --prefix)/opt/qt@6
+# Qt installed via macports
+#QTDIR=/opt/local/libexec/qt5
+endif  # WANT_WIN_QT
+ifndef LIBXPM
+LIBXPM= -L/opt/X11/lib -lXpm
+endif
+
+# 4. Other
+
+#-----------------------------------------------------------------------------
+# You shouldn't need to change anything below here (in the hints file; if
+# you're reading this in Makefile augmented by hints, that may not be true).
+#
+
+#-INCLUDE multiw-2.2020
+
+# compiler.2020 contains compiler detection and adjustments common
+# to both linux and macOS
+
+#-INCLUDE compiler.2020
+
+# NetHack sources control
+NHCFLAGS+=-DDLB
+NHCFLAGS+=-DHACKDIR=\"$(HACKDIR)\"
+NHCFLAGS+=-DDEFAULT_WINDOW_SYS=\"$(WANT_DEFAULT)\"
+NHCFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
+#NHCFLAGS+=-DTIMED_DELAY
+#NHCFLAGS+=-DDUMPLOG
+#NHCFLAGS+=-DCONFIG_ERROR_SECURE=FALSE
+NHCFLAGS+=-DGREPPATH=\"/usr/bin/grep\"
+#NHCFLAGS+=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\"
+NHCFLAGS+=-DNOMAIL
+#NHCFLAGS+=-DEXTRA_SANITY_CHECKS
+#NHCFLAGS+=-DEDIT_GETLIN
+#NHCFLAGS+=-DSCORE_ON_BOTL
+#NHCFLAGS+=-DMSGHANDLER
+#NHCFLAGS+=-DTTY_TILES_ESCCODES
+#NHCFLAGS+=-DTTY_SOUND_ESCCODES
+
+CFLAGS+= $(WINCFLAGS)  #WINCFLAGS set from multiw-2.2020
+CFLAGS+= $(NHCFLAGS)
+
+CCXXFLAGS+= $(WINCFLAGS) #WINCFLAGS set from multiw-2.2020
+CCXXFLAGS+= $(NHCFLAGS)
+
+VARDATND =
+VARDATND0 =
+CURSESLIB =
+
+ifdef WANT_WIN_CHAIN
+HINTSRC=$(CHAINSRC)
+HINTOBJ=$(CHAINOBJ)
+endif # WANT_WIN_CHAIN
+
+ifdef WANT_WIN_TTY
+CURSESLIB = -lncurses
+endif
+
+ifdef WANT_WIN_CURSES
+CURSESLIB = -lncurses
+endif
+
+ifdef CURSESLIB
+WINLIB += $(CURSESLIB)
+endif
+
+ifdef WANT_WIN_X11
+USE_XPM=1
+WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
+VARDATND0 += x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
+# -x: if built without dlb, some versions of mkfontdir think *.lev are fonts
+POSTINSTALL += bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; ( cd $(HACKDIR); mkfontdir -x .lev );
+# separate from CFLAGS so that we don't pass it to every file
+X11CFLAGS = -I/opt/X11/include
+# avoid repeated complaints about _X_NONNULL(args...) in <X11/Xfuncproto.h>
+X11CFLAGS += -Wno-variadic-macros
+ifdef USE_XPM
+CFLAGS += -DUSE_XPM
+WINX11LIB += -lXpm
+VARDATND0 += rip.xpm
+endif
+WINLIB += $(WINX11LIB)
+LFLAGS=-L/opt/X11/lib
+endif  # WANT_WIN_X11
+
+ifdef WANT_WIN_QT
+# Qt5 requires C++11
+LINK = $(CXX)
+QTCXXFLAGS += -std=c++17 -I $(QTDIR)/include -I $(QTDIR)/include/QtCore
+MOC = moc
+MOCPATH = $(QTDIR)/share/qt/libexec/moc
+WINLIB += -F $(QTDIR)/Frameworks -framework QtCore -framework QtGui -framework QtWidgets
+WINSRC += $(WINQTSRC)
+WINOBJ0 += $(WINQTOBJ)
+VARDATND0 += nhtiles.bmp rip.xpm nhsplash.xpm
+# 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
+else   # !WANT_WIN_QT
+LINK=$(CC)
+endif  # !WANT_WIN_QT
+
+# prevent duplicate tile.o in WINOBJ
+WINOBJ = $(sort $(WINOBJ0))
+# prevent duplicates in VARDATND if both X11 and Qt are being supported
+VARDATND += $(sort $(VARDATND0))
+
+GIT_HASH := $(shell echo `git rev-parse --verify HEAD` 2>&1)
+GIT_BRANCH := $(shell echo `git rev-parse --abbrev-ref HEAD` 2>&1)
+
+ifdef GIT_HASH
+GITHASH = -DNETHACK_GIT_SHA=\"$(GIT_HASH)\"
+endif
+ifdef GIT_BRANCH
+GITBRANCH = -DNETHACK_GIT_BRANCH=\"$(GIT_BRANCH)\"
+endif 
+
+ifdef WANT_LIBNH
+CFLAGS += -DSHIM_GRAPHICS -DNOTTYGRAPHICS -DNOSHELL -DLIBNH
+LIBNHSYSSRC = ../sys/libnh/libnhmain.c \
+               ../sys/share/ioctl.c ../sys/share/unixtty.c \
+               ../sys/unix/unixunix.c ../sys/unix/unixres.c \
+               ../win/shim/winshim.c
+LIBNHSYSOBJ= libnhmain.o ioctl.o unixtty.o unixunix.o \
+                unixres.o winshim.o
+#don't bother building the game executable as it will fail
+#without winshim
+override GAME=
+MOREALL += ( cd src ; $(MAKE) pregame ; $(MAKE) libnh.a )
+endif  # WANT_LIBNH
+
+WANT_BUNDLE=1
+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;
+
+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_DEFAULT),X11)
+# install nethack.rc as ~/.nethackrc if no ~/.nethackrc exists
+PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc || true
+endif  # WANT_DEFAULT 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;
+ifdef WANT_BUNDLE
+#
+# Bundle
+#
+# $(HACKDIR)/$(GAME).app/
+#              Contents/
+#                 Frameworks/
+#                 Info.plist
+#                 MacOS/
+#                    $(GAME)
+#                 PkgInfo/
+#                 PlugIns/
+#                 Resources/
+#                 SharedFrameWorks/
+#
+BUNDLE = mkdir -p $(HACKDIR)/nethack.app/Contents/MacOS; \
+              sys/unix/hints/macosx.sh infoplist > $(HACKDIR)/nethack.app/Contents/Info.plist; \
+              mv $(HACKDIR)/nethack $(HACKDIR)/nethack.app/Contents/MacOS/nethack;
+ifdef WANT_SHARE_INSTALL
+BUNDLE+= chmod $(GAMEPERM) $(HACKDIR)/nethack.app/Contents/MacOS/nethack;
+endif
+
+POSTINSTALL+= $(BUNDLE)
+POSTINSTALL+= if test -f $(SHELLDIR)/$(GAME); then \
+                         sed -i '' 's;HACKDIR/$(GAME);HACKDIR/$(GAME).app/Contents/MacOS/$(GAME);' $(SHELLDIR)/$(GAME) ; fi;
+endif   # WANT_BUNDLE
+endif   # !WANT_SHARE_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).
+#
+#-INCLUDE cross-pre.2020
+#
+#-POST
+
+ifdef WANT_LIBNH
+libnh.a: $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua.a
+       $(AR) rcs $@ $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua.a
+       @echo "$@ built."
+libnhmain.o : ../sys/libnh/libnhmain.c $(HACK_H)
+       $(CC) $(CFLAGS) -c -o$@ $<
+winshim.o : ../win/shim/winshim.c $(HACK_H)
+       $(CC) $(CFLAGS) -c -o$@ $<
+endif  # WANT_LIBNH
+
+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.
+#
+# Packages that are being distributed must be signed by a Developer ID
+# Installer certificate.  Set DEVELOPER_CERT to the name of the certificate
+# if you wish for your package to be signed for distribution.
+#
+# If building a package for signing, you must use sudo approriately.
+# the binaries and package using sudo but you DO NOT use sudo to sign the
+# package.  If you use sudo to sign the package, it will fail.
+#
+#   sudo make all
+#   sudo make build_tty_pkg
+#   make sign_tty_pkg
+#
+
+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)
+
+#DEVELOPER_CERT = Developer ID Installer: Bart House
+DEVELOPER_CERT = NONE
+
+spotless::
+       rm -rf RESOURCES
+       rm -rf PKG
+       rm -rf PKGSCRIPTS
+       rm -rf PKGROOT
+       rm -f Info.plist
+       rm -f Distribution.xml
+       rm -f NetHack-*-mac-Term*
+
+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-unsigned.pkg
+ifeq ($(DEVELOPER_CERT),NONE)
+       cp NetHack-$(SVS)-mac-Term-unsigned.pkg NetHack-$(SVS)-mac-Term.pkg
+       hdiutil create -verbose -srcfolder NetHack-$(SVS)-mac-Term-unsigned.pkg NetHack-$(SVS)-mac-Term-unsigned.dmg
+       @echo -------------------------------------------
+       @echo PACKAGE IS NOT SIGNED FOR DISTRIBUTION!!!!!
+       @echo ===========================================
+else
+       @echo "run 'make sign_tty_pkg' to complete package"
+endif
+
+sign_tty_pkg:
+       productsign --timestamp=none --sign "$(DEVELOPER_CERT)" NetHack-$(SVS)-mac-Term-unsigned.pkg NetHack-$(SVS)-mac-Term.pkg || (echo "Package signing failed"; exit 1)
+       spctl -a -v --type install NetHack-$(SVS)-mac-Term.pkg || (echo "Package not signed properly"; exit 1)
+       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) $(GAMEUID) $(HACKDIR)        >> PKGSCRIPTS/postinstall
+       echo $(CHOWN) $(GAMEUID) $(HACKDIR)/*        >> PKGSCRIPTS/postinstall
+       echo $(CHGRP) $(GAMEGRP) $(HACKDIR)        >> PKGSCRIPTS/postinstall
+       echo $(CHGRP) $(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
+#
+#-INCLUDE cross-post.2020
+#
index 35b83213b37418b2a91b6b000d39714253d774ee..99899ec1ea55fdcb7fd271ebaaefb70bd8153e57 100644 (file)
@@ -32,7 +32,7 @@ WANT_DEFAULT=Qt
 #     library installation root.  (Qt2 or Qt3 will not work.)
 ifdef WANT_WIN_QT
 # Qt installed via homebrew
-QTDIR=$(shell brew --prefix)/opt/qt
+QTDIR=$(shell brew --prefix)/opt/qt@5
 # Qt installed via macports (qt511 package; 5.13 requires OSX 10.12 or later)
 #QTDIR=/opt/local/libexec/qt5
 endif  # WANT_WIN_QT
index c04e9f30352275ff2ac5e3204bfc3e6bf3b57e3a..94f54f52809557c316e0027fb3a43158babac4ca 100644 (file)
@@ -7,15 +7,20 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
 #include <QtCore/QStringList>
-#if QT_VERSION >= 0x050000
+#if QT_VERSION < 0x050000
+#include <QtGui/QSound>
+#elif QT_VERSION < 0x060000
 #include <QtWidgets/QtWidgets>
 #include <QtMultimedia/QSound>
 #else
-#include <QtGui/QSound>
+#include <QtWidgets/QtWidgets>
+#undef QT_NO_SOUND
+#define QT_NO_SOUND 1
 #endif
 #include "qt_post.h"
 #include "qt_bind.h"
@@ -88,10 +93,10 @@ NetHackQtBind::NetHackQtBind(int& argc, char** argv) :
        capt->setAlignment(Qt::AlignCenter);
        if ( !pm.isNull() ) {
            lsplash->setFixedSize(pm.size());
-           lsplash->setMask(pm);
+           lsplash->setMask(QBitmap(pm));
        }
-       splash->move((QApplication::desktop()->width()-pm.width())/2,
-                     (QApplication::desktop()->height()-pm.height())/2);
+       splash->move((splash->screen()->size().width()-pm.width())/2,
+                     (splash->screen()->size().height()-pm.height())/2);
        //splash->setGeometry(0,0,100,100);
        if ( qt_compact_mode ) {
            splash->showMaximized();
@@ -930,9 +935,9 @@ bool NetHackQtBind::notify(QObject *receiver, QEvent *event)
                 }
             }
             QString key = key_event->text();
-            QChar ch = !key.isEmpty() ? key.at(0) : 0;
-            if (ch > 128)
-                ch = 0;
+            QChar ch = !key.isEmpty() ? key.at(0) : QChar(0);
+            if (ch > QChar(128))
+                ch = QChar(0);
             // on OSX, ascii control codes are not sent, force them
             if (ch == 0 && (mod & Qt::ControlModifier) != 0) {
                 if (k >= Qt::Key_A && k <= Qt::Key_Underscore)
index d8f5030b7df868c0f51e32a089b4bc596d449c31..a72d62a16c49835e52d52ef538e63f44fbe1e746 100644 (file)
@@ -7,6 +7,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index 0fa3003ce644f47826c433b752c11617d910f1ff..7a510f5061946a9e9a355b95791181dcf99ed152 100644 (file)
@@ -7,6 +7,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index 6c1df7c0c56cf705ba1dcf924b5949098fd65617..5a7336252503e578a9337a1f6d18d1c751628b64 100644 (file)
@@ -8,6 +8,7 @@ extern "C" {
 #include "hack.h"
 #include "tile2x11.h" /* x11tiles is potential fallback for nhtiles.bmp */
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index fea5747421fb85b3d5d95cfa891ae5f385fb801d..46057c804015ebcae87d49696d9a838ea5d5249b 100644 (file)
@@ -27,6 +27,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index 50f17f47c7dc3e6f9935e3f83d39f1740149a29b..ec8077f4f0c357fc89d740c739723c2a5bc6b476 100644 (file)
@@ -21,6 +21,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index 7b0e63aac69c4a466d658a98641b3327fdd06198..2f2d13b70a96860d40d71567c9a38b3bfc6bfcd4 100644 (file)
@@ -7,6 +7,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
@@ -25,10 +26,10 @@ uchar keyValue(QKeyEvent *key_event)
     const int k = key_event->key();
     Qt::KeyboardModifiers mod = key_event->modifiers();
     const QString &txt = key_event->text();
-    QChar ch = !txt.isEmpty() ? txt.at(0) : 0;
+    QChar ch = !txt.isEmpty() ? txt.at(0) : QChar(0);
 
-    if (ch >= 128)
-        ch = 0;
+    if (ch >= QChar(128))
+        ch = QChar(0);
     // on OSX, ascii control codes are not sent, force them
     if (ch == 0 && (mod & Qt::ControlModifier) != 0) {
         if (k >= Qt::Key_A && k <= Qt::Key_Underscore)
index 482122589442732d800b376aa5cc0fbefb2f716d..0482ca25aa6db45f925064580676c29ad6e6fa05 100644 (file)
@@ -7,6 +7,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index 21f6b265717e3dd6e6baa9dcc7e93f27288dd18d..fb990bfc65e63f5660cd74d3294693b26eb10285 100644 (file)
@@ -7,10 +7,16 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
+#define CTRL(c) (0x1f & (c))
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
+#if QT_VERSION >= 0x060000
+#include <QtGui/QShortcut>
+#else
 #include <QtWidgets/QShortcut>
+#endif
 
 #if QT_VERSION >= 0x050000
 #include <QtWidgets/QtWidgets>
@@ -856,8 +862,8 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
 #endif
 
     int x=0,y=0;
-    int w=QApplication::desktop()->width()-10; // XXX arbitrary extra space for frame
-    int h=QApplication::desktop()->height()-50;
+    int w=screen()->size().width()-10; // XXX arbitrary extra space for frame
+    int h=screen()->size().height()-50;
 
     int maxwn;
     int maxhn;
@@ -902,7 +908,7 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
 // all other control characters go through NetHackQtBind::notify()
 void NetHackQtMainWindow::CtrlV()
 {
-    static const char cV[] = { C('V'), '\0' };
+    static const char cV[] = { CTRL('V'), '\0' };
     doKeys(cV);
 }
 #endif
index 3eb76686692db29904aa2b0a59436256bbf21af2..c805e9eead02b3b49382c64a033afcef1a638c56 100644 (file)
@@ -7,6 +7,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index 507e252dd1370b5eac1c09f62bf76b42f8e18d0b..c5403f7c8957c64bed303ce72ef4c2c9e3af1a52 100644 (file)
@@ -28,6 +28,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
@@ -1132,7 +1133,7 @@ void NetHackQtTextWindow::Display(bool block UNUSED)
        search.show();
        rip.hide();
     }
-    int mh = QApplication::desktop()->height()*3/5;
+    int mh = screen()->size().height()*3/5;
     if ( (qt_compact_mode && lines->TotalHeight() > mh) || use_rip ) {
        // big, so make it fill
        showMaximized();
index 66fd93daee6aab7da241c7108b883adc6be9cfe6..04ba80b2a12584b3febf135483470e21f65aeb33 100644 (file)
@@ -7,6 +7,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index c9fd097568298679ed4c16d7062bd023aafe1028..2bba646a2711ecafd11c7f405316c466bcb3c8a9 100644 (file)
@@ -18,6 +18,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index b4aeb1a3a329533892254a07b34240a8dbc2a135..91bf1ad25e9b8b225516d36133bf219968879b3e 100644 (file)
@@ -7,6 +7,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index 2f665541756f909ab65e113a79f641bcc0c6ef14..5f93286534a59e5920333e11eec88b0af7726b23 100644 (file)
@@ -8,6 +8,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index 376e0a7bf43bea3516e0699117fe3b29812ce7f5..81b8f5d9f97a6e8241a8b95db0635ad1d15c48f6 100644 (file)
@@ -78,6 +78,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
@@ -558,7 +559,9 @@ QHBoxLayout *NetHackQtStatusWindow::InitHitpointBar()
 
     QHBoxLayout *hpbar = new QHBoxLayout;
     hpbar->setSpacing(0);
+#if QT_VERSION < 0x060000
     hpbar->setMargin(0);
+#endif
     hpbar->addWidget(&hpbar_health);
     hpbar->setAlignment(&hpbar_health, Qt::AlignLeft);
     hpbar->addWidget(&hpbar_injury);
index dc6712a4dd8c4b0b5172f4cf7e33ddc05efbd691..c98ef5dbb5fe31210a7206f34036b8887f5c083a 100644 (file)
@@ -7,6 +7,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index 9fcc3854db346b6e0e47a47a8291f5b5793c04be..a1509d4e62dc05f330a9f40240569eb9e440b484 100644 (file)
@@ -41,6 +41,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
index 60f422261288aa9f60088d4c3c6c97bd20585f27..06ebf62a811822491421f4e7b17ba1347f54fab4 100644 (file)
@@ -49,6 +49,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
@@ -78,10 +79,10 @@ namespace nethack_qt_ {
 void
 centerOnMain(QWidget *w)
 {
+    QPoint p(0, 0);
     QWidget *m = NetHackQtBind::mainWidget();
-    if (!m)
-        m = qApp->desktop();
-    QPoint p = m->mapToGlobal(QPoint(0, 0));
+    if (m)
+        p = m->mapToGlobal(p);
     w->move(p.x() + m->width() / 2  - w->width() / 2,
             p.y() + m->height() / 2 - w->height() / 2);
 }
index f5ddabeb816698449172871aabf4f15a465c0927..50b724f8397035214aced8cf935e9fd99fefde1f 100644 (file)
@@ -77,6 +77,7 @@ extern "C" {
 #include "hack.h"
 #include "func_tab.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
@@ -544,7 +545,7 @@ void NetHackQtExtCmdRequestor::keyPressEvent(QKeyEvent *event)
             // <return> or <space> without a pending exact match; cancel
             reject();
         } else if (matches >= 2
-                   || promptstr.midRef(1, len) == rest.leftRef(len)) {
+                   || promptstr.mid(1, len) == rest.left(len)) {
             // update the text-so-far
             prompt->setText(promptstr);
         } else if (saveexactmatchindx != xcmdNoMatch) {
index 0e607a0b640e7545dd57904617ead7184c0c2755..c2f28505c9d3d029838d19e79d100737c883dbd8 100644 (file)
@@ -7,6 +7,7 @@
 extern "C" {
 #include "hack.h"
 }
+#undef C
 
 #include "qt_pre.h"
 #include <QtGui/QtGui>
@@ -96,7 +97,7 @@ char NetHackQtYnDialog::Exec()
                if ( question[c] == '-' ) {
                    from = question[c - 1].cell();
                } else if ( from != 0 ) {
-                   for (unsigned f=from+1; f<=question[c]; f++)
+                   for (unsigned f=from+1; QChar(f)<=question[c]; f++)
                        ch.append(QChar(f));
                    from = 0;
                } else {
@@ -259,7 +260,7 @@ char NetHackQtYnDialog::Exec()
                     // two consecutive ampersands are needed to display
                     // one in a button label; first check whether caller
                     // has already done that, skip this one if so
-                    if (i > 0 && ch[i - 1].cell() == QChar('&'))
+                    if (i > 0 && ch[i - 1].cell() == '&')
                         continue; // next i
                     button_name = "&&";
                     break;