]> granicus.if.org Git - nethack/commitdiff
Qt status
authorPatR <rankin@nethack.org>
Sat, 14 Nov 2020 01:15:04 +0000 (17:15 -0800)
committerPatR <rankin@nethack.org>
Sat, 14 Nov 2020 01:15:04 +0000 (17:15 -0800)
Try to set the initial window sizes to be big enough to show the
full welcome line in the message window when the Qt settings
(Preferences on OSX) specify Large font (Huge/Medium/Small/Tiny
seemed ok but I wasn't systematic about checking them).

While at it, I added a long comment about the status window format
and noticed a bug with experience formatting there.  Again only
seemed to matter for Large font but the change to fix ignores font
size.

Plus add a couple of Qt "issues", one old and one just discovered.

doc/fixes37.0
win/Qt/Qt-issues.txt
win/Qt/qt_main.cpp
win/Qt/qt_stat.cpp

index 3903646301dac32275346e02b97ab7ddd530b7e1..52d629f107a73aab6a3d2c0a1758067d1440a057 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.352 $ $NHDT-Date: 1605315160 2020/11/14 00:52:40 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.353 $ $NHDT-Date: 1605316497 2020/11/14 01:14:57 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -385,6 +385,8 @@ tins of spinach and 'dead' eggs could cause out of array bounds access
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
+Qt: at Xp levels above 20 with 'showexp' On, the combined status field
+       "Level:NN/nnnnnnnn" was too big and truncated by a char at each end
 tty: redraw unexplored locations as S_unexplored rather than <space> after
        map has been partially overwritten by popup menu or text display
 tty: previous change resulted in remnants of previous level being shown on
index b25adff97c5b87293d54bbb3876ff705f60a3603..c38fca66192e065c1a14826b947d9289eebb237c 100644 (file)
@@ -59,4 +59,15 @@ code into its own routine and calling that for both types of windows.
 From the text window code, it sees the initial shift but not the ':'
 that should follow.
 
+Clicking on window close button pops up a confirmation dialog with
+  [  Save and exit  ]  [__Quit_without_saving__]
+with the second one highlighted.  Internally they're specified as
+"&Save" and "&Quit".  Typing <return> or <space> picks Quit, but
+typing 'Q' or 'q' picks Save-and-exit because Alt+Q is expected for
+the keyboard shortcut.
+
+The status window can't be resized while hitpointbar is active.
+Toggling it off, resizing as desired, then toggling it back on is a
+viable workaround.
+
 -----
index 00765d8a98498c5e842333ae435f22f02239149c..69a2729dc83ad45df2b2966f3250e1be417885f9 100644 (file)
@@ -1138,6 +1138,16 @@ void NetHackQtMainWindow::layout()
         // call resizePaperDoll() indirectly...
         qt_settings->resizeDoll();
 #endif
+        // reset widths
+        int w = width(); /* of main window */
+        // 10: approximate size of resizing hotspots
+        int d = qt_settings->doll_is_shown ? 10 + invusage->width() + 10 : 10;
+        if (d % 4)
+            d += 4 - d % 4;
+        splittersizes[2] = w / 2 - (d * 1 / 4); // status
+        splittersizes[1] = d - 10;              // invusage
+        splittersizes[0] = w / 2 - (d * 3 / 4); // messages
+        hsplitter->setSizes(splittersizes);
     }
 }
 
@@ -1162,8 +1172,8 @@ void NetHackQtMainWindow::resizePaperDoll(bool showdoll)
         hsplitter->setSizes(hsplittersizes);
     }
 
-    // Height limit is 48 pixels per doll cell;
-    // values greater than 44 need taller window which pushes the map down.
+    // Height limit is 48+2 pixels per doll cell plus 1 pixel margin at top;
+    // values greater than 42+2 need taller window which pushes the map down.
     // FIXME: this doesn't shrink the window back if size is reduced from 45+
     int oldheight = vsplittersizes[0],
         newheight = w->height();
index 7b918e070efc7c289386ca9ff838b0dfb15b93bb..deadd798f42cf9196cca8e17b9b9b1e499f2bc7f 100644 (file)
@@ -3,6 +3,43 @@
 // NetHack may be freely redistributed.  See license for details.
 
 // qt_stat.cpp -- status window, upper right portion of the overall window
+//
+// The Qt status window consists of many lines:
+//
+//      hitpoint bar (when enabled)
+//      Title (plname the Rank or plname the MonsterSpecies)
+//      Dungeon location (branch and level)
+//      separator line
+//      six icons (special 40x40 tiles, paired with...)
+//      six characteristic texts ("Str:18/03", "Dex:15", &c)
+//      separator line
+//      five status fields without icons (some containing two values:
+//        Gold, HP/HPmax, Energy/Enmax, AC, XpLevel/ExpPoints or HD)
+//      optional line with two text fields (Time:1234, Score:89)
+//      separator line
+//      varying number of icons (one or more, each paired with...)
+//      corresponding text (Alignment plus zero or more status conditions
+//        including Hunger if not "normal" and encumbrance if not "normal")
+//
+// The hitpoint bar spans the width of the status window when enabled.
+// Title and location are centered.
+// The icons and text for the size characteristics are evenly spaced.
+// The five main stats are padded with an empty sixth and spaced to
+//   match the characteristics.
+// Time and Score are spaced as if each were three fields wide.
+// Icons and texts for alignment and conditions are left justified.
+// The separator lines are thin and don't take up much vertical space.
+// The hitpoint bar line and the Time+Score line are omitted when the
+//   corresponding items are disabled.
+//
+// FIXME:
+//  When hitpoint bar is shown, attempting to resize horizontally won't
+//    do anything.  Toggling it off, then resizing, and back On works.
+//
+// TODO:
+//  If/when status conditions become too wide for the status window, scale
+//    down their icons and switch their text to a smaller font to match.
+//
 
 extern "C" {
 #include "hack.h"
@@ -23,6 +60,8 @@ extern "C" {
 extern const char *enc_stat[]; /* from botl.c */
 extern const char *hu_stat[]; /* from eat.c */
 
+extern int qt_compact_mode;
+
 namespace nethack_qt_ {
 
 NetHackQtStatusWindow::NetHackQtStatusWindow() :
@@ -67,6 +106,11 @@ NetHackQtStatusWindow::NetHackQtStatusWindow() :
     first_set(true),
     alreadyfullhp(false)
 {
+    if (!qt_compact_mode) {
+        int w = NetHackQtBind::mainWidget()->width();
+        setMaximumWidth(w / 2);
+    }
+
     p_str = QPixmap(str_xpm);
     p_str = QPixmap(str_xpm);
     p_dex = QPixmap(dex_xpm);
@@ -648,7 +692,11 @@ void NetHackQtStatusWindow::updateStats()
         // up/down highlighting becomes tricky--don't try very hard
         if (::flags.showexp) {
             buf.sprintf("%ld/%ld", (long) u.ulevel, (long) u.uexp);
-            level.setLabel("Level:" + buf,
+            // at levels above 20, "Level:NN/nnnnnnnn" doesn't fit so
+            // shorten "Level" to "Lvl" at that stage;
+            // at level 30, a few pixels are truncated from the start
+            // and end of "Lvl:30/nnnnnnnnn" but the result is ledgible
+            level.setLabel(((u.ulevel <= 20) ? "Level:" : "Lvl:") + buf,
                            NetHackQtLabelledIcon::NoNum, (long) u.uexp);
         } else {
             level.setLabel("Level:", (long) u.ulevel);