Qt support for changing 'statuslines' dynamically

Turns out it was nearly as simple as I originally thought.
I just missed one significant detail the first time around.
This leaves DYNAMIC_STATUSLINES as conditionl but now enables
it by default.  Using 'O' to change 'statuslines' from 2 to 3
or vice versa now works for Qt as well as for curses and tty.
This commit is contained in:
PatR
2020-12-22 11:10:32 -08:00
parent 430edb5a74
commit 934808be0e
6 changed files with 19 additions and 21 deletions
+2 -4
View File
@@ -246,7 +246,8 @@ statushilites whether to display status highlights (when non-zero) and [0]
also how many turns to display temporary highlights (for also how many turns to display temporary highlights (for
'up', 'down', and 'changed' hilite_status rules) 'up', 'down', and 'changed' hilite_status rules)
statuslines whether to use expanded (3) or condensed (2) status [2] statuslines whether to use expanded (3) or condensed (2) status [2]
(for tty and curses; 2 is traditional, 3 is recommended) (for tty and curses; 2 is traditional, 3 is recommended;
also for Qt, where 3 is traditional and 2 is recommended)
suppress_alert disable various version-specific warnings about changes [] suppress_alert disable various version-specific warnings about changes []
in game play or the user interface, such as notification given in game play or the user interface, such as notification given
for the 'Q' command that quitting is now done via #quit for the 'Q' command that quitting is now done via #quit
@@ -321,9 +322,6 @@ role Your starting role (e.g., role:Barbarian, role:Valk). [random]
as possible. You can also still denote your role by as possible. You can also still denote your role by
appending it to the "name" option (e.g., name:Vic-V), but appending it to the "name" option (e.g., name:Vic-V), but
the "role" option will take precedence. the "role" option will take precedence.
statuslines whether to use expanded (3) or condensed (2) status [2]
(unlike for tty and curses, for Qt this can only be be set at
startup; also unlike tty and curses, 2 is recommended over 3)
windowtype windowing system to be used [depends on operating system and windowtype windowing system to be used [depends on operating system and
compile-time setup] if more than one choice is available. compile-time setup] if more than one choice is available.
Some instances of the program support only one window-type; Some instances of the program support only one window-type;
+2 -6
View File
@@ -1,4 +1,4 @@
.\" $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.408 $ $NHDT-Date: 1608175317 2020/12/17 03:21:57 $ .\" $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.410 $ $NHDT-Date: 1608664223 2020/12/22 19:10:23 $
.\" .\"
.\" This is an excerpt from the 'roff' man page from the 'groff' package. .\" This is an excerpt from the 'roff' man page from the 'groff' package.
.\" Guidebook.mn currently does *not* fully adhere to these guidelines. .\" Guidebook.mn currently does *not* fully adhere to these guidelines.
@@ -4387,7 +4387,7 @@ up (default yes).
Number of lines for traditional below-the-map status display. Number of lines for traditional below-the-map status display.
Acceptable values are \f(CR2\fP and \f(CR3\fP (default is \f(CR2\fP). Acceptable values are \f(CR2\fP and \f(CR3\fP (default is \f(CR2\fP).
.lp "" .lp ""
For \f(CR3\fP, the \f(CRtty\fP interface moves some fields around and When set to \f(CR3\fP, the \f(CRtty\fP interface moves some fields around and
mainly shows status conditions on their own line. mainly shows status conditions on their own line.
A display capable of showing at least 25 lines is recommended. A display capable of showing at least 25 lines is recommended.
The value can be toggled back and forth during the game with the \(oqO\(cq The value can be toggled back and forth during the game with the \(oqO\(cq
@@ -4408,10 +4408,6 @@ original format, with the status window spread out vertically.
A value of \f(CR2\fP makes status be slightly condensed, moving some A value of \f(CR2\fP makes status be slightly condensed, moving some
fields to different lines to eliminate one whole line, reducing the fields to different lines to eliminate one whole line, reducing the
height needed. height needed.
For \f(CRQt\fP,
.op statuslines
can only be set in the configuration file or via NETHACKOPTIONS, not
with the \(oqO\(cq command.
.lp "term_cols\ \ \fIand\fP" .lp "term_cols\ \ \fIand\fP"
.lp term_rows .lp term_rows
Curses interface only. Curses interface only.
+1 -5
View File
@@ -4783,7 +4783,7 @@ Number of lines for traditional below-the-map status display.
Acceptable values are {\tt 2} and {\tt 3} (default is {\tt 2}). Acceptable values are {\tt 2} and {\tt 3} (default is {\tt 2}).
%.lp "" %.lp ""
For {\tt 3}, the {\tt tty} interface moves some fields around and When set to {\tt 3}, the {\tt tty} interface moves some fields around and
mainly shows status conditions on their own line. mainly shows status conditions on their own line.
A display capable of showing at least 25 lines is recommended. A display capable of showing at least 25 lines is recommended.
The value can be toggled back and forth during the game with the `O' The value can be toggled back and forth during the game with the `O'
@@ -4806,10 +4806,6 @@ original format, with the status window spread out vertically.
A value of {\tt 2} makes status be slightly condensed, moving some A value of {\tt 2} makes status be slightly condensed, moving some
fields to different lines to eliminate one whole line, reducing the fields to different lines to eliminate one whole line, reducing the
height needed. height needed.
For {\tt Qt},
{\it statuslines\/}
can only be set in the configuration file or via NETHACKOPTIONS, not
with the `O' command.
%.lp %.lp
\item[\ib{term\verb+_+cols} {\normalfont and}] \item[\ib{term\verb+_+cols} {\normalfont and}]
%.lp %.lp
+3 -2
View File
@@ -834,10 +834,11 @@ void NetHackQtBind::qt_outrip(winid wid, int how, time_t when)
void NetHackQtBind::qt_preference_update(const char *optname) void NetHackQtBind::qt_preference_update(const char *optname)
{ {
#ifdef DYNAMIC_STATUSLINES // leave disabled; redoStatus() doesn't work #ifdef DYNAMIC_STATUSLINES // defined in qt_main.h
if (!strcmp(optname, "statuslines")) { if (!strcmp(optname, "statuslines")) {
// delete and recreate status window // delete and recreate status window
main->redoStatus(); // to toggle statuslines from 2 to 3 or vice versa
id_to_window[WIN_STATUS] = main->redoStatus();
} }
#else #else
nhUse(optname); nhUse(optname);
+5 -3
View File
@@ -1180,14 +1180,14 @@ void NetHackQtMainWindow::layout()
} }
} }
#ifdef DYNAMIC_STATUSLINES // leave disabled; this doesn't work as intended #ifdef DYNAMIC_STATUSLINES
// called when 'statuslines' changes from 2 to 3 or vice versa; simpler to // called when 'statuslines' changes from 2 to 3 or vice versa; simpler to
// destroy and recreate the status window than to adjust existing fields // destroy and recreate the status window than to adjust existing fields
void NetHackQtMainWindow::redoStatus() NetHackQtWindow *NetHackQtMainWindow::redoStatus()
{ {
NetHackQtStatusWindow *oldstatus = this->status; NetHackQtStatusWindow *oldstatus = this->status;
if (!oldstatus) if (!oldstatus)
return; // not ready yet? return NULL; // not ready yet?
this->status = new NetHackQtStatusWindow; this->status = new NetHackQtStatusWindow;
if (!qt_compact_mode) if (!qt_compact_mode)
@@ -1195,6 +1195,8 @@ void NetHackQtMainWindow::redoStatus()
delete oldstatus; delete oldstatus;
ShowIfReady(); ShowIfReady();
return (NetHackQtWindow *) this->status;
} }
#endif #endif
+6 -1
View File
@@ -14,6 +14,11 @@
#include "qt_kde0.h" #include "qt_kde0.h"
#endif #endif
// Allow changing 'statuslines:2' to 'statuslines:3' or vice versa
// while the game is running; deletes and re-creates the status window.
// [Used in qt_bind.cpp and qt_main.cpp, but not referenced in qt_stat.cpp.]
#define DYNAMIC_STATUSLINES
namespace nethack_qt_ { namespace nethack_qt_ {
class NetHackQtInvUsageWindow; class NetHackQtInvUsageWindow;
@@ -54,7 +59,7 @@ public:
void resizePaperDoll(bool); // ENHANCED_PAPERDOLL void resizePaperDoll(bool); // ENHANCED_PAPERDOLL
#ifdef DYNAMIC_STATUSLINES #ifdef DYNAMIC_STATUSLINES
// called when 'statuslines' option has been changed // called when 'statuslines' option has been changed
void redoStatus(); NetHackQtWindow *redoStatus();
#endif #endif
public slots: public slots: