From: PatR Date: Tue, 6 Oct 2020 22:20:25 +0000 (-0700) Subject: Qt status panel as command button X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da8558e26211d3b31a55ef30d8e45921b723e9b6;p=nethack Qt status panel as command button Clicking on the status panel runs ^X to show character and status information without abbreviations. The code needed is identical to what's now used for clicking on the paper doll inventory panel except for the command to execute. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 378797cfe..0246efc53 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.322 $ $NHDT-Date: 1602002574 2020/10/06 16:42:54 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.323 $ $NHDT-Date: 1602022805 2020/10/06 22:20:05 $ General Fixes and Modified Features ----------------------------------- @@ -569,6 +569,7 @@ Qt: draw a border around each tile in the paper doll inventory; when BUC is 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) +Qt: clicking on the status window runs the #attributes command (^X) NetHack Community Patches (or Variation) Included diff --git a/win/Qt/qt_stat.cpp b/win/Qt/qt_stat.cpp index 7ba03c549..7da64cfc6 100644 --- a/win/Qt/qt_stat.cpp +++ b/win/Qt/qt_stat.cpp @@ -396,13 +396,13 @@ void NetHackQtStatusWindow::fadeHighlighting() * the other. So only do our update when we update the second line. * * Information on the first line: - * name, attributes, alignment, score + * name, Str/Dex/&c characteristics, alignment, score * * Information on the second line: * dlvl, gold, hp, power, ac, {level & exp or HD **} * status (hunger, encumbrance, sick, stun, conf, halu, blind), time * - * [**] HD is shown instead of level and exp if mtimedone is non-zero. + * [**] HD is shown instead of level and exp when hero is polymorphed. */ void NetHackQtStatusWindow::updateStats() { @@ -553,8 +553,7 @@ void NetHackQtStatusWindow::updateStats() score.setLabel(""); } - if (first_set) - { + if (first_set) { first_set=false; name.highlightWhenChanging(); @@ -604,4 +603,18 @@ void NetHackQtStatusWindow::checkTurnEvents() { } +// clicking on status window runs #attributes (^X) +void NetHackQtStatusWindow::mousePressEvent(QMouseEvent *event UNUSED) +{ + // same code as NetHackQtInvUsageWindow::mousePressEvent except for func + char cmdbuf[32]; + Strcpy(cmdbuf, "#"); + (void) cmdname_from_func(doattributes, &cmdbuf[1], FALSE); + // queue up #attribues as if user had typed it; we don't execute + // doattributes() directly because the program might not be ready + // for a command right now + QWidget *main = NetHackQtBind::mainWidget(); + (static_cast (main))->DollClickToKeys(cmdbuf); +} + } // namespace nethack_qt_ diff --git a/win/Qt/qt_stat.h b/win/Qt/qt_stat.h index 2b7382289..a8d27cb95 100644 --- a/win/Qt/qt_stat.h +++ b/win/Qt/qt_stat.h @@ -27,6 +27,7 @@ public: void fadeHighlighting(); protected: + virtual void mousePressEvent(QMouseEvent *event); //RLC void resizeEvent(QResizeEvent*); private slots: