]> granicus.if.org Git - nethack/commitdiff
Qt "paperdoll" as command button
authorPatR <rankin@nethack.org>
Tue, 6 Oct 2020 16:42:59 +0000 (09:42 -0700)
committerPatR <rankin@nethack.org>
Tue, 6 Oct 2020 16:42:59 +0000 (09:42 -0700)
Clicking on the paper doll inventory subset window will cause
the '*' command (#seeall) to execute.  They convey the same
information (unless multiple leashes or multiple light sources
are in use; seeall lists all of them instead of just the first
of each) but the doll shows the info with a small grid of map
tiles and seeall shows it with an inventory display of worn and
wielded items plus tools in active use.

Ideally it should show information about a specific item as a
"tool tip" when the mouse hovers over one of the doll slots.
I don't know whether I'll ever attempt to tackle that or even
if that's feasible with Qt.  Perhaps use right click instead.

doc/fixes37.0
win/Qt/qt_inv.cpp
win/Qt/qt_inv.h
win/Qt/qt_main.cpp
win/Qt/qt_main.h

index b68978a00772ba7051c5853005d27e03c08a2892..378797cfe171eb42669c436bac37c9545309ecf0 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.321 $ $NHDT-Date: 1601940384 2020/10/05 23:26:24 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.322 $ $NHDT-Date: 1602002574 2020/10/06 16:42:54 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -564,8 +564,11 @@ user_sounds: provide an experimental mechanism for terminal-side sounds similar
        act on it)
 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 door inventory; when BUC is
+Qt: draw a border around each tile in the paper doll inventory; when BUC is
        known for a doll item, change the border's color and thicken it
+Qt: clicking on the paper doll runs the #seeall command (inventory of wielded
+       and worn items plus tools [lamps, leashes] actively in use; in other
+       words, same set of things whose tiles are used to populate the doll)
 
 
 NetHack Community Patches (or Variation) Included
index f6cc6a92efb77f8f4f3a6c2d669d31ea6fee40d7..b6e408af61a7143d091c5b39e9df77cc24541f75 100644 (file)
@@ -20,6 +20,7 @@ extern "C" {
 #include "qt_post.h"
 #include "qt_inv.h"
 #include "qt_glyph.h"
+#include "qt_main.h"
 #include "qt_set.h"
 
 namespace nethack_qt_ {
@@ -52,12 +53,14 @@ void NetHackQtInvUsageWindow::drawWorn(QPainter& painter, obj* nhobj,
 
     if (nhobj) {
         border = BORDER_DEFAULT;
+#ifdef ENHANCED_PAPERDOLL
         if (Role_if('P') && !Blind)
             nhobj->bknown = 1;
         if (nhobj->bknown)
             border = nhobj->cursed ? BORDER_CURSED
                      : !nhobj->blessed ? BORDER_UNCURSED
                        : BORDER_BLESSED;
+#endif
         glyph = obj_to_glyph(nhobj, rn2_on_display_rng);
     } else {
         border = NO_BORDER;
@@ -153,7 +156,7 @@ QSize NetHackQtInvUsageWindow::sizeHint(void) const
             h = (1 + qt_settings->dollHeight + 1) * 6;
         }
 #else
-        if (iflags.wc_tiles_map) {
+        if (iflags.wc_tiled_map) {
             w = (1 + qt_settings->glyphs().width() + 1) * 3;
             h = (1 + qt_settings->glyphs().height() + 1) * 6;
         }
@@ -164,4 +167,18 @@ QSize NetHackQtInvUsageWindow::sizeHint(void) const
     }
 }
 
+// ENHANCED_PAPERDOLL - clicking on the PaperDoll runs #seeall
+void NetHackQtInvUsageWindow::mousePressEvent(QMouseEvent *event UNUSED)
+{
+#ifdef ENHANCED_PAPERDOLL
+    char cmdbuf[32];
+    Strcpy(cmdbuf, "#");
+    (void) cmdname_from_func(doprinuse, &cmdbuf[1], FALSE);
+    // queue up #seeall as if user had typed it; we don't execute doprinuse()
+    // directly because the program might not be ready for the next command
+    QWidget *main = NetHackQtBind::mainWidget();
+    (static_cast <NetHackQtMainWindow *> (main))->DollClickToKeys(cmdbuf);
+#endif
+}
+
 } // namespace nethack_qt_
index 4c74b8a6a8c57536bf83791f158dc97ec7afa8bf..9c38128c5a7c2548a0fac291868ea79b198b6958 100644 (file)
@@ -16,6 +16,9 @@ public:
        virtual void paintEvent(QPaintEvent*);
        virtual QSize sizeHint(void) const;
 
+protected:
+       virtual void mousePressEvent(QMouseEvent *event);
+
 private:
        void drawWorn(QPainter& painter, obj*, int x, int y, bool canbe=true);
 };
index de4dff75c784fa9011c0529942a8ee7346631496..6378f48e113d5c0b40b0cfc9e13f2ea95ca1c8db 100644 (file)
@@ -990,6 +990,13 @@ void NetHackQtMainWindow::doKeys(const QString& k)
     qApp->exit();
 }
 
+// ENHANCED_PAPERDOLL - player clicked on PaperDoll window
+void NetHackQtMainWindow::DollClickToKeys(const char *cmds)
+{
+    keysink.Put(cmds);
+    qApp->exit();
+}
+
 void NetHackQtMainWindow::AddMessageWindow(NetHackQtMessageWindow* window)
 {
     message=window;
index fbec9fb63129a8e6ed4cf551fe2302197d47e5ee..b21c60cfce4d8759d9f70749f6ead6c1136e7e7f 100644 (file)
@@ -49,8 +49,9 @@ public:
 
        void fadeHighlighting(bool before_key);
 
-        // this is unconditional in case qt_main.h comes before qt_set.h
+        // these are unconditional in case qt_main.h comes before qt_set.h
         void resizePaperDoll(bool); // ENHANCED_PAPERDOLL
+        void DollClickToKeys(const char *); // ENHANCED_PAPERDOLL
 
 public slots:
        void doMenuItem(QAction *);