Move the nine #undef's common to all qt_*.cpp sources into qt_pre.h.
Make "hack.h" usage consistent; always enclose withing 'extern "C {'
and '}' even though only some of the sources care.
The core is mapping #annotate to ^N, which has no effect when
number_pad is Off. The Qt menu setup saw it as the way to run
that command, which will only work when number_pad is On. This
fixes the menu and didn't break the large subset of other menu
commands I've tried, but I haven't gotten through half of them yet.
The Qt menu entries which were executing nethack's help command
(the '?' menu) were doing so because their command keystroke was
a meta-character and such characters are being converted to '?'
to indicate an error in conversion to Latin1 character set. The
old Qt3 code didn't perform any such conversion.
This fix feels fragile because there are two different places
deciding how to disambiguate partial extended commands (the code
for Qt's '#' handling and a new routine in the core). Qt menus
now send '#' and enough letters to satisfy '#' handling for any
command which uses M-c or has no regular keystroke nor M-c one.
(If it were to send the full extended command name, the letters
after the unambiguous prefix would be left in the input queue to
be processed as subsequent commands.)
There is a fundamental problem that this doesn't address: if
the player uses BIND directives in the run-time config file, the
Qt menu bindings will break unless the BINDs are all done before
selecting windowtype. Qt's menu bindings translate a click on
a menu entry into the keystroke used to invoke the corresponding
command, so using BIND to change that after the menus are set up
will result in the wrong commands being executed.
Changes affecting everybody (using Qt): rename game->Save to
game->Save-and-exit and game->Quit to game->Quit-without-saving.
OSX-specific changes: add separate nethack->Quit and change
game->Quit-without-saving to game->_Quit-without-saving to prevent
that from being hijacked for the nethack menu. nethack->Quit menu
entry works. Command+Q is a keyboard shortcut for it. They bring
up a menu with choices of "Quit without saving" and "Cancel and
return to game". It's not the same as the handler for the window
Close button, which used to offer "Save" or "Cancel" (with the
latter triggering an infinite loop) but now offers "Save and exit"
or "Quit without saving". They don't share any code. The
game->_Quit-without-saving entry doesn't work; it runs nethack's '?'
command like a bunch of other broken menu entries. If it did work,
it would give nethack's "Really quit?" prompt and proceed from there.
The "Quit without saving" response for nethack->Quit confirmation
bypasses that and just quits.
Also OSX, add a second 'about' entry. The first one is hijacked and
added to the nethack menu, the second is help->_About_Qt_NetHack_
and avoids hijacking. Both nethack->About and help->_About_ bring
up the same dialog box showing version and assorted other info.
A lot of flailing about with for relatively small amount of progress.
Menu hackery: change a couple of menu entry names on OSX to
control where they end up.
Move nethack's 'O' command from its hijacked position (due to name
"Options") of "nethack->Preferences..." to "Game->Run-time options".
Move persistent Qt settings on OSX from "Game->Qt settings" to
"nethack->Preferences...".
The Qt settings dialog (now accessed as Preferences...) desperately
needs a title and/or other explanatory text but I haven't figured
out how do to that. The values set with it are persistent, with
apparently quite a few choices for where to save them for future
runs. I used it to increase the size of text in the status window,
and found my settings stored in binary file
~/Library/Preferences/org.nethack.NetHack.plist
The subdirectories ~/Library and ~/Library/Preferences are
standard OSX per-user things. The file name is derived from values
set up in main routine: qt_main.cpp is setting OrganizationDomain
to "nethack.org" and ApplicationName to "NetHack". I've added a
value for ApplicationVersion but don't know whether anything cares
about it.
Add ^X (as "Attributes (extended status)") to the "Info" drop down
menu, also Overview, and Annotate.
Attributes and Overview work, Annotate results in running southeast.
Existing entries Conduct, Adjust, and Skills execute nethack's '?'
command so I didn't bother holding back on adding Annotate. Other
existing entries (Inventory, Discoveries, Spells, and Name) work.
If there's any sort of pattern involved, I'm not seeing it.
The Game menu has "Save", which shows up and works, but that's
supposed to be followed by "Quit" which doesn't show up when the
menu is used. This doesn't attempt to deal with that.
Command+q keystroke, which should close the application, behaves
the same as previously mentioned "quit nethack" in nethack menu:
runs nethack's '?' command and then resumes play.
Prevent an infinite loop that occurred if player clicked on the
close window button and then tried to cancel out of that in the
dialog it brings up.
I don't know whether Qt interface on platforms other than OSX
need this but they're getting it. The choices are changed from
"Save" or "Cancel" to "Save and exit" or "Quit without saving".
Since save allows subsequent restore, not being able to cancel
out of the application shutdown should only be an inconvenience.
Unresolved issues:
I don't know whether there's any other way to bring up that dialog,
where Cancel might be a viable choice. If so, handling that might
be tricky. Quit should definitely be available as an alterative
to Save, but that type of dialog doesn't seem to allow more than
two choices.
Picking "nethack" from application menu and then "quit nethack"
from the resulting pull down menu results in executing nethack's
help command (the '?' menu) and then just resumes play.
Add Michael's fix for control+x.
The enum name of the argument suggests that option+x should have
been sending control characters but that wasn't the case for me.
Before this fix, both control+x and option+x behaved like dead
keys, not transmitting anything for nethack to use. After this
fix, control+x sends ^X as desired but option+x is still dead.
The presence of longer lines has made the 'about' box become wider
so combine the first two short lines into one longer one.
Switching to the longer nethack version string resulted in "This
is NetHack MacOSX Nethack ..." so remove the initial "NetHack"
from the 'about' box's format string. That version string also
includes a final period; strip that off since "with Qt 5.x.y."
follows it to end the sentence.
Still some issues:
The application menu has first entry "nethack" which ought to be
capitalized but I haven't been able to figure out how to accomplish
that.
Some code in qt_main.cpp tries to add an extra instance of "about
NetHack" to the game window's "Help" menu but it doesn't show up.
Update the 'about' popup to reflect current information.
When I start Qt nethack on OSX 10.11, the horizontal application
menu for nethack that's rendered across the top of the desktop won't
respond to mouse clicks, not even if I click on nethack's title bar
or inside its game window first. But if I give another application
focus (which swaps top-edge menu to one for that other application)
and then click on nethack's title bar to give focus back to nethack
(which also swaps back to the top menu for it), clicking on that menu
begins working. I have no idea what's going on there.
Picking "nethack" in the application menu gives a pull down menu with
"about nethack" as the first entry. When choosing that, the revised
popup looks like
| Qt NetHack is a version of NetHack
| built using the Qt 5 GUI toolkit.
|
| This is NetHack 3.7.0-22 with Qt 5.11.3.
|
| NetHack's Qt interface originally developed by
| Warwick Allison.
|
| Qt:
| https://qt.io/
| NetHack:
| https://www.nethack.org/
The line with Warwick's name is wrapping and I don't know how to
make the popup wide enough to avoid that. The old edition had a
"Homepage" URL for him instead of that sentence but the URL was out
of date. It also had an obsolete URL for Qt and none at all for
NetHack itself.
In file included from ../win/Qt/qt_bind.cpp:20:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:4:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qglobal.h:1302:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qflags.h:121:41: warning: declaration shadows a
variable in the global namespace [-Wshadow]
Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {}
^
[…]
../include/flag.h:390:29: note: previous declaration is here
extern NEARDATA struct flag flags;
^
In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:36:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qcache.h:191:15: warning: declaration shadows a
variable in the global namespace [-Wshadow]
Node *u = n;
^
../include/decl.h:219:23: note: previous declaration is here
E NEARDATA struct you u;
^
[…]
In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:45:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qtextlayout.h:47:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qcolor.h:44:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qrgb.h:66:46: warning: declaration shadows a
variable in the global namespace [-Wshadow]
inline Q_DECL_CONSTEXPR QRgb qRgb(int r, int g, int b)// set RGB value
^
../include/decl.h:1208:27: note: previous declaration is here
E struct instance_globals g;
^
[…]
In file included from ../win/Qt/qt_glyph.cpp:21:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:48:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qpalette.h:107:49: warning: declaration shadows a
variable in the global namespace [-Wshadow]
inline void setCurrentColorGroup(ColorGroup cg) { data.current_group = cg; }
^
../include/decl.h:1216:30: note: previous declaration is here
E const struct const_globals cg;
^