Qt: force 'toptenwin' option On

'toptenwin' defaults to false, so the high scores list at end of game
gets written to stdout by default.  stdout might be a bit bucket if
the game is started from a menu somewhere or from Explorer or Finder
or something comparable.  Even when started from a terminal, writing
to stdout is bad if running asynchronously ('nethack &').

Have Qt init force the 'toptenwin' option to true to show the high
scores in a pop-up text window.  The "since you were in wizard mode
your score is ignored" line also goes to a pop-up text window now too.
An extra <return> is needed to dismiss that when quitting if you go
through the full disclosure sequence.

'nethack -s' writes scores to stdout before interface initialization
takes place, so isn't affected by this change.  That's intentional so
that 'nethack -s > ~/myscores' can be used to capture the output.
This commit is contained in:
PatR
2022-01-06 12:25:17 -08:00
parent a77e1602f1
commit 86343af200
2 changed files with 33 additions and 13 deletions
+3
View File
@@ -1117,6 +1117,9 @@ Qt: while a text window was shown (such as the "things that are here" popup
Qt: if player's run-time options specified a tiles file and it couldn't be Qt: if player's run-time options specified a tiles file and it couldn't be
loaded, Qt was falling back to x11tiles just like when the default loaded, Qt was falling back to x11tiles just like when the default
can't be loaded; fallback to player's file plus explicit path instead can't be loaded; fallback to player's file plus explicit path instead
Qt: force the 'toptenwin' option On so that high scores display at end of game
is shown in a text window instead of being written to stdout where it
might not be seen (note: doesn't apply to 'nethack -s')
Qt: {maybe just Qt+OSX:} when viewing a text window ('V' to look at 'history' Qt: {maybe just Qt+OSX:} when viewing a text window ('V' to look at 'history'
for instance), clicking on [Search], entering a search target in the for instance), clicking on [Search], entering a search target in the
resulting popup and clicking on [Okay] or typing <return>, the text resulting popup and clicking on [Okay] or typing <return>, the text
+30 -13
View File
@@ -154,9 +154,17 @@ NetHackQtBind::qt_Splash()
} }
} }
void NetHackQtBind::qt_init_nhwindows(int* argc, char** argv) void NetHackQtBind::qt_init_nhwindows(int *argc, char **argv)
{ {
iflags.menu_tab_sep = true; // menu entries use embedded <tab> to align fields;
// it could be toggled off via 'O', but only when in wizard mode
::iflags.menu_tab_sep = true;
// force high scores display to be shown in a window, and don't allow
// that to be toggled off via 'O' (note: 'nethack -s' won't reach here;
// its output goes to stdout so can potentially be redirected into a file)
::iflags.toptenwin = true;
::set_option_mod_status("toptenwin", ::set_in_config);
#ifdef UNIX #ifdef UNIX
// Userid control // Userid control
@@ -495,20 +503,29 @@ void NetHackQtBind::qt_cliparound_window(winid wid, int x, int y)
NetHackQtWindow* window=id_to_window[(int)wid]; NetHackQtWindow* window=id_to_window[(int)wid];
window->ClipAround(x,y); window->ClipAround(x,y);
} }
void NetHackQtBind::qt_print_glyph(winid wid,xchar x,xchar y,
const glyph_info *glyphinfo, void NetHackQtBind::qt_print_glyph(
const glyph_info *bkglyphinfo UNUSED) winid wid, xchar x, xchar y,
const glyph_info *glyphinfo,
const glyph_info *bkglyphinfo UNUSED)
{ {
/* TODO: bkglyph */ /* TODO: bkglyph */
NetHackQtWindow* window=id_to_window[(int)wid]; NetHackQtWindow *window = id_to_window[(int) wid];
window->PrintGlyph(x,y,glyphinfo); window->PrintGlyph(x, y, glyphinfo);
} }
//void NetHackQtBind::qt_print_glyph_compose(winid wid,xchar x,xchar y,int glyph1, int glyph2)
//{
//NetHackQtWindow* window=id_to_window[(int)wid];
//window->PrintGlyphCompose(x,y,glyph1,glyph2);
//}
#if 0
void NetHackQtBind::qt_print_glyph_compose(
winid wid, xchar x, xchar y, int glyph1, int glyph2)
{
NetHackQtWindow *window = id_to_window[(int) wid];
window->PrintGlyphCompose(x, y, glyph1, glyph2);
}
#endif /*0*/
//
// FIXME: sending output to stdout can mean that the player never sees it.
//
void NetHackQtBind::qt_raw_print(const char *str) void NetHackQtBind::qt_raw_print(const char *str)
{ {
puts(str); puts(str);
@@ -516,7 +533,7 @@ void NetHackQtBind::qt_raw_print(const char *str)
void NetHackQtBind::qt_raw_print_bold(const char *str) void NetHackQtBind::qt_raw_print_bold(const char *str)
{ {
puts(str); qt_raw_print(str);
} }
int NetHackQtBind::qt_nhgetch() int NetHackQtBind::qt_nhgetch()