diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 489c4ebd1..a46b9c1c1 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.343 $ $NHDT-Date: 1603777052 2020/10/27 05:37:32 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.344 $ $NHDT-Date: 1603836614 2020/10/27 22:10:14 $ General Fixes and Modified Features ----------------------------------- @@ -462,6 +462,10 @@ Qt: handle '&' properly if it occurs as part of yn_function popup dialog Qt: fix the display side of saved game selection; character names for available save files are shown in a column of push buttons instead of each button overwriting all the ones before it +Qt: don't clobber an existing save file after choosing "new game" in the + saved game selection widget +Qt: don't get stuck in a loop after choosing "play" while the character name + field is empty in the character selection widget Qt+OSX: 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" diff --git a/win/Qt/Qt-issues.txt b/win/Qt/Qt-issues.txt index ba7ad5c95..4ac6fc2e7 100644 --- a/win/Qt/Qt-issues.txt +++ b/win/Qt/Qt-issues.txt @@ -44,15 +44,6 @@ On the map, ^V is a dead key (at least on OSX; all other ASCII control characters from ^A through ^U, ^W through ^Z, and ^[, ^\, ^], ^^, ^_ work; no attempt to have ^@ generate NUL has been made). -The save file selection widget writes all the file name selection -buttons on top of each other, with the last one added being the only -one visible. Clicking on it seems to be picking the first one instead. -If you pick "new game" and use a different character name then -eventually save, it clobbers the last one in the list (rather, warns -the player that a save file exists and asks whether to overwrite it; -answering yes and then loading the file shows the new character, not -the original one even though the file is still named for that one). - Map column #0, which the core reserves for its own purposes and isn't intended to be displayed, is displayed (as blank terrain). diff --git a/win/Qt/qt_bind.cpp b/win/Qt/qt_bind.cpp index b31465ad5..512ab06af 100644 --- a/win/Qt/qt_bind.cpp +++ b/win/Qt/qt_bind.cpp @@ -185,38 +185,57 @@ void NetHackQtBind::qt_player_selection() void NetHackQtBind::qt_askname() { - have_asked = true; + char default_plname[PL_NSIZ]; - // We do it all here, and nothing in askname + have_asked = true; + str_copy(default_plname, g.plname, PL_NSIZ); + + // We do it all here (plus qt_plsel.cpp and qt_svsel.cpp), + // nothing in player_selection(). char** saved = get_saved_games(); - int ch = -1; + int ch = -1; // -1 => new game if ( saved && *saved ) { if ( splash ) splash->hide(); NetHackQtSavedGameSelector sgsel((const char**)saved); ch = sgsel.choose(); if ( ch >= 0 ) str_copy(g.plname, saved[ch], SIZE(g.plname)); + // caller needs new lock name even if plname[] hasn't changed + // because successful get_saved_games() clobbers g.SAVEF[] + ::iflags.renameinprogress = TRUE; } free_saved_games(saved); switch (ch) { case -1: + // New Game if (splash) splash->hide(); - if (NetHackQtPlayerSelector(keybuffer).Choose()) - return; + if (NetHackQtPlayerSelector(keybuffer).Choose()) { + // success; handle plname[] verification below prior to returning + break; + } /*FALLTHRU*/ case -2: + // Quit + clearlocks(); + qt_exit_nhwindows(0); + nh_terminate(0); + /*NOTREACHED*/ break; default: - return; + // picked a character from the saved games list + break; } - // Quit - clearlocks(); - qt_exit_nhwindows(0); - nh_terminate(0); + if (!*g.plname) + // in case Choose() returns with plname[] empty + Strcpy(g.plname, default_plname); + else if (strcmp(g.plname, default_plname) != 0) + // caller needs to set new lock file name + ::iflags.renameinprogress = TRUE; + return; } void NetHackQtBind::qt_get_nh_event()