-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.278 $ $NHDT-Date: 1596936095 2020/08/09 01:21:35 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.279 $ $NHDT-Date: 1597010101 2020/08/09 21:55:01 $
General Fixes and Modified Features
-----------------------------------
with no opportunity to try to back out of the Close operation
Qt: add 3.6 status fields Stone, Slime, Strngl, Deaf, Lev, Fly, Ride
Qt: add Attributes, Overview, and Annotate to the "Info" pull down menu
+Qt: rename menu entries game->Save to game->Save-and-exit and game->Quit
+ to game->Quit-without-saving
Qt+QSX: fix control key
Qt+OSX: rename menu entry "nethack->Preferences..." for invoking nethack's
'O' command to "Game->Run-time options" and entry "Game->Qt settings"
for making persistent Qt customizations to "nethack->Preferences..."
+Qt+OSX: prevent game->Quit-without-saving from being hijacked for the nethack
+ menu by renaming it game->_Quit-without-saving (OSX only)
+Qt+OSX: add a separate nethack->Quit menu entry with different functionality;
+ Command+Q invokes it
+Qt+OSX: since menu entry help->"About Qt NetHack" gets hijacked and becomes
+ "nethack->About nethack", add a separate help->_About_Qt_NetHack_
+ which stays where intended and brings up the same information
tiles: add indicator of thonged portion to aklys tile
tty: role and race selection menus weren't filtering out potential choices
which got excluded by OPTIONS=align:!lawful or !neutral or !chaotic
{ game, "History", 3, dohistory},
{ game, "Redraw", 0, doredraw}, // useless
{ game,
-#ifndef MACOSX
- "Options",
-#else
- /* Qt on OSX would rename "Options" to "Preferences..." and
- move it from intended destination to the application menu */
- "Run-time options",
+#ifdef MACOSX
+ /* Qt on OSX would rename "Options" to "Preferences..." and
+ move it from intended destination to the application menu */
+ "Run-time &" // rely on adjacent string concatenation
#endif
- 3, doset},
+ "Options", 3, doset},
{ game, "Explore mode", 3, enter_explore_mode},
{ game, 0, 3},
- { game, "Save", 3, dosave},
- { game, "Quit", 3, done2},
+ { game, "Save-and-exit", 3, dosave},
+ { game,
+#ifdef MACOSX
+ /* need something to prevent matching leading "quit"
+ so that it isn't hijacked for the application menu */
+ "_&"
+#endif
+ "Quit-without-saving", 3, done2},
{ apparel, "Apparel off", 2, doddoremarm},
{ apparel, "Remove many", 1, doddoremarm},
"Preferences...",
#endif
this, SLOT(doQtSettings(bool)));
- /* on OSX, 'about' will end up in the application menu
- rather than the help menu; at present, just live with that */
- help->addAction("About Qt NetHack...",this,SLOT(doAbout(bool)));
- //help->addAction("NetHack Guidebook...",this,SLOT(doGuidebook(bool)));
+ /* on OSX, 'about' will end up in the application menu rather than
+ the help menu (this had trailing "..." but that conflicts with
+ the convention that an elipsis indicates the choice will bring
+ up its own sub-menu) */
+ help->addAction("About Qt NetHack", this, SLOT(doAbout(bool)));
+ //help->addAction("NetHack Guidebook", this, SLOT(doGuidebook(bool)));
help->addSeparator();
for (i=0; item[i].menu; i++) {
help->setTitle("Help");
menubar->addMenu(help);
}
+#ifdef MACOSX
+ /* for OSX, the attempt above to add "About Qt NetHack" went into
+ the application menu instead of the help menu; we'll add it to
+ the latter now and have two ways to access it; without the
+ leading underscore (or some other spelling variation such as
+ "'bout"), this one would get interceptd too and then evidently
+ be discarded as a duplicate */
+ help->addSeparator();
+ help->addAction("_About_Qt_NetHack_", this, SLOT(doAbout(bool)));
+ /* we also want a "Quit NetHack" entry in the application menu;
+ when "_Quit-without-saving" was called "Quit" it got intercepted
+ for that, but now it needs to be added separately; we'll use a
+ handy menu and let the interception put it in the intended place */
+ game->addAction("Quit NetHack", this, SLOT(doQuit(bool)));
+#endif
QSignalMapper* sm = new QSignalMapper(this);
connect(sm, SIGNAL(mapped(const QString&)), this, SLOT(doKeys(const QString&)));
QMessageBox::about(this, "About Qt NetHack", aboutMsg());
}
+// on OSX, "quit nethack" has been selected in the application menu or
+// "Command+Q" has been typed -- user is asking to quit the application;
+// unlike with the window's Close button, user has a chance to back out
+void NetHackQtMainWindow::doQuit(bool)
+{
+ // there is a separate Quit-without-saving menu entry in the game menu
+ // that leads to nethack's "Really quit?" prompt; OSX players can use
+ // either one, other implementations only have that other one but this
+ // routine is unconditional in case someone wants to change that
+#ifdef MACOSX
+ QString info;
+ info.sprintf("This will end your NetHack session.%s",
+ !g.program_state.something_worth_saving ? ""
+ : "\n(Cancel quitting and use the Save command"
+ "\nto save your current game.)");
+ /* this is similar to closeEvent but the details are different */
+ int act = QMessageBox::information(this, "NetHack", info,
+ "&Quit without saving",
+ "&Cancel and return to game",
+ 0, 1);
+ switch (act) {
+ case 0:
+ // quit -- bypass the prompting preformed by done2()
+ g.program_state.stopprint++;
+ done(QUIT);
+ /*NOTREACHED*/
+ break;
+ case 1:
+ // cancel
+ break; // return to game
+ }
+#endif
+ return;
+}
+
#if 0 // RLC this isn't used
void NetHackQtMainWindow::doGuidebook(bool)
{
}
}
-void NetHackQtMainWindow::closeEvent(QCloseEvent* e)
+// game window's Close button has been activated
+void NetHackQtMainWindow::closeEvent(QCloseEvent *e UNUSED)
{
+ int ok = 0;
if ( g.program_state.something_worth_saving ) {
- int ok = 0;
/* this used to offer "Save" and "Cancel"
but cancel (ignoring the close attempt) won't work
if user has clicked on the window's Close button */
int act = QMessageBox::information(this, "NetHack",
- "This will end your NetHack session",
- "&Save and exit", "&Quit without saving", 0, 1);
+ "This will end your NetHack session.",
+ "&Save and exit", "&Quit without saving", 0, 1);
switch (act) {
case 0:
// See dosave() function
done(QUIT);
/*NOTREACHED*/
break;
- case 2:
- // cancel -- no longer an alternative
- break; // ignore the event
}
- /* if !ok, we should try to continue, but we don't... */
- u.uhp = -1;
- NetHackQtBind::qt_exit_nhwindows(0);
- nh_terminate(EXIT_SUCCESS);
} else {
- e->accept();
+ /* nothing worth saving; just close/quit */
+ ok = 1;
}
+ /* if !ok, we should try to continue, but we don't... */
+ u.uhp = -1;
+ NetHackQtBind::qt_exit_nhwindows(0);
+ nh_terminate(EXIT_SUCCESS);
}
void NetHackQtMainWindow::ShowIfReady()