-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.292 $ $NHDT-Date: 1598831076 2020/08/30 23:44:36 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.293 $ $NHDT-Date: 1598852985 2020/08/31 05:49:45 $
General Fixes and Modified Features
-----------------------------------
Qt: menu choices All, None, Invert were setting, unsetting, or toggling menu
entry checkboxes internally but didn't redraw the menu to show that
Qt: fix the F1/F2/Tab macro keys to not require that number_pad be On
+Qt: unhighlight highlighted message (last one issued) after player has seen it
Qt+QSX: fix control key
Qt+OSX: rename menu entry "nethack->Preferences..." for invoking nethack's
'O' command to "Game->Run-time options" and entry "Game->Qt settings"
int NetHackQtBind::qt_nhgetch()
{
if (main)
- main->fadeHighlighting();
+ main->fadeHighlighting(true);
// Process events until a key arrives.
//
qApp->exec();
}
+ // after getting a key rather than before
+ if (main)
+ main->fadeHighlighting(false);
+
return keybuffer.GetAscii();
}
int NetHackQtBind::qt_nh_poskey(int *x, int *y, int *mod)
{
if (main)
- main->fadeHighlighting();
+ main->fadeHighlighting(true);
// Process events until a key or map-click arrives.
//
while (keybuffer.Empty() && clickbuffer.Empty()) {
qApp->exec();
}
+
+ // after getting a key or click rather than before
+ if (main)
+ main->fadeHighlighting(false);
+
if (!keybuffer.Empty()) {
return keybuffer.GetAscii();
} else {
the application menu instead of the help menu; we'll add it to
the latter now and have two ways to access it; without the
leading underscore (or some other spelling variation such as
- "'bout"), this one would get interceptd too and then evidently
+ "'bout"), this one would get intercepted too and then evidently
be discarded as a duplicate */
help->addSeparator();
help->addAction("_About_Qt_NetHack_", this, SLOT(doAbout(bool)));
}
}
-void NetHackQtMainWindow::fadeHighlighting()
+void NetHackQtMainWindow::fadeHighlighting(bool before_key)
{
- if (status) {
- status->fadeHighlighting();
+ if (before_key) {
+ // status highlighting fades at start of turn
+ if (status)
+ status->fadeHighlighting();
+ } else {
+ // message highlighting fades after user has given input
+ if (message && message->hilit_mesgs())
+ message->unhighlight_mesgs();
}
}
void RemoveWindow(NetHackQtWindow* window);
void updateInventory();
- void fadeHighlighting();
+ void fadeHighlighting(bool before_key);
// this is unconditional in case qt_main.h comes before qt_set.h
void resizePaperDoll(bool); // ENHANCED_PAPERDOLL
void NetHackQtMapWindow2::putMessage(int attr UNUSED, const QString& text)
{
- if ( !messages.isEmpty() )
+ if (!messages.isEmpty())
messages += "\n";
messages += QString(text).replace(QChar(0x200B), "");
- QFontMetrics fm = fontMetrics();
#if 0
- messages_rect = fm.boundingRect(viewport.contentsX(),viewport.contentsY(),viewport.width(),0, Qt::TextWordWrap|Qt::AlignTop|Qt::AlignLeft|Qt::TextDontClip, messages);
+ QFontMetrics fm = fontMetrics();
+ messages_rect = fm.boundingRect(viewport.contentsX(), viewport.contentsY(),
+ viewport.width(), 0,
+ (Qt::TextWordWrap | Qt::AlignTop
+ | Qt::AlignLeft | Qt::TextDontClip),
+ messages);
update(messages_rect);
#endif
}
void NetHackQtMessageWindow::Display(bool block UNUSED)
{
+ //
+ // FIXME: support for 'block' is necessary for MSGTYPE=stop
+ //
if (changed) {
list->repaint();
changed=false;
QListWidgetItem *item = list->item(currgetmsg++);
if (item) {
QString str = item->text();
- //raw_printf("getstr[%i]='%s'", currgetmsg, str.toLatin1().constData());
- return str.toLatin1().constData();
+ const char *result = str.toLatin1().constData();
+ //raw_printf("getstr[%d]='%s'", currgetmsg, result);
+ return result;
}
return NULL;
}
font.setWeight((attr == ATR_BOLD) ? QFont::Bold : QFont::Normal);
item->setFont(font);
- QColor fg = item->foreground().color();
- QColor bg = item->background().color();
- if (attr == ATR_DIM)
- {
- fg.setAlpha(fg.alpha() / 2);
+ if (attr == ATR_DIM || attr == ATR_INVERSE) {
+ QColor fg = item->foreground().color();
+ QColor bg = item->background().color();
+ if (attr == ATR_DIM) {
+ fg.setAlpha(fg.alpha() / 2);
+ new_fgbg = true;
+ }
+ if (attr == ATR_INVERSE) {
+ QColor swap;
+ swap = fg; fg = bg; bg = swap;
+ }
+ item->setForeground(fg);
+ item->setBackground(bg);
}
- if (attr == ATR_INVERSE)
- {
- QColor swap;
- swap = fg; fg = bg; bg = swap;
- }
- item->setForeground(fg);
- item->setBackground(bg);
+ // ATR_BLINK not supported
#endif
- // ATR_BLINK not supported
if (list->count() >= (int) ::iflags.msg_history)
delete list->item(0);
list->addItem(text2);
// Force scrollbar to bottom
- list->setCurrentRow(list->count()-1);
+ list->setCurrentRow(list->count() - 1);
- if ( map )
+ if (map)
map->putMessage(attr, text2);
}
+// are there any highlighted messages?
+bool NetHackQtMessageWindow::hilit_mesgs()
+{
+ // PutStr() uses setCurrentRow() to select the last message line;
+ // being selected causes that line to be highlighted.
+ //
+ // We could/should keep track of whether anything is currently
+ // highlighted instead of just assuming that last message still is.
+ if (list && list->count())
+ return true;
+ return false;
+}
+
+// unhighlight any highlighted messages
+void NetHackQtMessageWindow::unhighlight_mesgs()
+{
+ if (list)
+ list->clearSelection();
+}
+
} // namespace nethack_qt_
void setMap(NetHackQtMapWindow2*);
+ bool hilit_mesgs();
+ void unhighlight_mesgs();
+
private:
QListWidget* list;
bool changed;