]> granicus.if.org Git - nethack/commitdiff
Qt: force 'toptenwin' option On
authorPatR <rankin@nethack.org>
Thu, 6 Jan 2022 20:25:17 +0000 (12:25 -0800)
committerPatR <rankin@nethack.org>
Thu, 6 Jan 2022 20:25:17 +0000 (12:25 -0800)
'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.

doc/fixes37.0
win/Qt/qt_bind.cpp

index e6efc44775f670f944745f3d03848bbe84021e0d..9e10c24ec4010b58ff0c920dcd484da2f3401f92 100644 (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
        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
+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'
        for instance), clicking on [Search], entering a search target in the
        resulting popup and clicking on [Okay] or typing <return>, the text
index 5f6a193fe2513a64699062e76eff07f6e0fd8ea8..ac1d91ade13d419f7f75e0ccc0abb02213384798 100644 (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
 // Userid control
@@ -495,20 +503,29 @@ void NetHackQtBind::qt_cliparound_window(winid wid, int x, int y)
     NetHackQtWindow* window=id_to_window[(int)wid];
     window->ClipAround(x,y);
 }
-void NetHackQtBind::qt_print_glyph(winid wid,xchar x,xchar y,
-                                   const glyph_info *glyphinfo,
-                                   const glyph_info *bkglyphinfo UNUSED)
+
+void NetHackQtBind::qt_print_glyph(
+    winid wid, xchar x, xchar y,
+    const glyph_info *glyphinfo,
+    const glyph_info *bkglyphinfo UNUSED)
 {
     /* TODO: bkglyph */
-    NetHackQtWindow* window=id_to_window[(int)wid];
-    window->PrintGlyph(x,y,glyphinfo);
+    NetHackQtWindow *window = id_to_window[(int) wid];
+    window->PrintGlyph(x, y, glyphinfo);
+}
+
+#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);
 }
-//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)
 {
     puts(str);
@@ -516,7 +533,7 @@ void NetHackQtBind::qt_raw_print(const char *str)
 
 void NetHackQtBind::qt_raw_print_bold(const char *str)
 {
-    puts(str);
+    qt_raw_print(str);
 }
 
 int NetHackQtBind::qt_nhgetch()