From: PatR Date: Sun, 3 Jan 2021 02:50:04 +0000 (-0800) Subject: curses: restoring via menu X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=46460255efb5202620ba620a44c0e0066a71df56;p=nethack curses: restoring via menu Clone the tty SELECTSAVED code in curses. If you would be getting the "who are you?" prompt (perhaps via 'nethack -u player') and you have at least one save file, you'll get a menu of save files (plus entries for 'new game' and 'quit') to choose from. Requires '#define SELECTDSAVED' at build time (only ntconf.h does that by default) and when present, can be disabled by setting 'selectsaved' to False in NETHACKOPTIONS or .nethackrc. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 57caece17..7193712bf 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.417 $ $NHDT-Date: 1609617569 2021/01/02 19:59:29 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.418 $ $NHDT-Date: 1609642144 2021/01/03 02:49:04 $ General Fixes and Modified Features ----------------------------------- @@ -742,6 +742,7 @@ user_sounds: provide an experimental mechanism for terminal-side sounds similar requires compile-time definition of TTY_SOUND_ESCCODES (also requires terminal-side code external to NetHack to recognize the sequence and act on it) +curses: implement save file selection menu Qt: the "paper doll" inventory subset can be controlled via the "Qt Settings" dialog box ("Preferences..." on OSX) Qt: draw a border around each tile in the paper doll inventory; when BUC is diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index b3dae7c69..ba738db52 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -40,13 +40,16 @@ struct window_procs curses_procs = { #endif | WC_PERM_INVENT | WC_POPUP_DIALOG | WC_SPLASH_SCREEN), (WC2_DARKGRAY | WC2_HITPOINTBAR +#ifdef SELECTSAVED + | WC2_SELECTSAVED +#endif #if defined(STATUS_HILITES) | WC2_HILITE_STATUS #endif | WC2_FLUSH_STATUS | WC2_TERM_SIZE | WC2_STATUSLINES | WC2_WINDOWBORDERS | WC2_PETATTR | WC2_GUICOLOR | WC2_SUPPRESS_HIST), - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */ + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */ curses_init_nhwindows, curses_player_selection, curses_askname, @@ -237,6 +240,19 @@ curses_player_selection() void curses_askname() { +#ifdef SELECTSAVED + if (iflags.wc2_selectsaved && !iflags.renameinprogress) + switch (restore_menu(MAP_WIN)) { + case -1: + curses_bail("Until next time then..."); /* quit */ + /*NOTREACHED*/ + case 0: + break; /* no game chosen; start new game */ + case 1: + return; /* g.plname[] has been set */ + } +#endif /* SELECTSAVED */ + g.plname[0] = '\0'; curses_line_input_dialog("Who are you?", g.plname, PL_NSIZ); }