-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.286 $ $NHDT-Date: 1597700875 2020/08/17 21:47:55 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.287 $ $NHDT-Date: 1597704087 2020/08/17 22:41:27 $
General Fixes and Modified Features
-----------------------------------
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
+ known for a doll item, change the border's color and thicken it
NetHack Community Patches (or Variation) Included
#include "qt_glyph.h"
#include "qt_bind.h"
#include "qt_set.h"
+#include "qt_inv.h"
+#include "qt_map.h"
#include "qt_str.h"
extern short glyph2tile[]; // from tile.c
drawGlyph(painter, glyph, cellx * width(), celly * height());
}
+void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph,
+ int cellx, int celly, int border)
+{
+ int wd = width(),
+ ht = height(),
+ lox = cellx * (wd + 2),
+ loy = celly * (ht + 2);
+
+ drawGlyph(painter, glyph, lox + 1, loy + 1);
+
+#ifdef TEXTCOLOR
+ if (border != NO_BORDER) {
+ // gray would be a better mid-point between red and cyan but it
+ // doesn't show up well enough against the wall tile background
+ painter.setPen((border == BORDER_CURSED) ? Qt::red
+ : (border == BORDER_UNCURSED) ? Qt::yellow
+ : (border == BORDER_BLESSED) ? Qt::cyan
+ : Qt::white); // BORDER_DEFAULT
+ // assuming 32x32, draw 34x34 rectangle from 0..33x0..33, outside glyph
+#if 0 /* Qt 5.11 drawRect(x,y,width,height) seems to have an off by 1 bug;
+ * drawRect(0,0,34,34) is drawing at 0..34x0..34 which is 35x35;
+ * should subtract 1 when adding width and/or height to base coord;
+ * the relevant code in QtCore/QRect.h is correct so this observable
+ * misbehavior is a mystery... */
+ painter.drawRect(lox, loy, wd + 2, ht + 2);
+#else
+ painter.drawLine(lox, loy, lox + wd + 1, loy); // 0,0->33,0
+ painter.drawLine(lox, loy + ht + 1, lox + wd + 1, loy + ht + 1);
+ painter.drawLine(lox, loy, lox, loy + ht + 1); // 0,0->0,33
+ painter.drawLine(lox + wd + 1, loy, lox + wd + 1, loy + ht + 1);
+#endif
+ if (border != BORDER_DEFAULT) {
+ // assuming 32x32, draw rectangle from 1..32x1..32, inside glyph
+#if 0 /* (see above) */
+ painter.drawRect(lox + 1, loy + 1, wd, ht);
+#else
+ painter.drawLine(lox + 1, loy + 1, lox + wd, loy + 1); // 1,1->32,1
+ painter.drawLine(lox + 1, loy + ht, lox + wd, loy + ht);
+ painter.drawLine(lox + 1, loy + 1, lox + 1, loy + ht); // 1,1->1,32
+ painter.drawLine(lox + wd, loy + 1, lox + wd, loy + ht);
+#endif
+ for (int i = lox + 2; i < lox + wd - 1; i += 2) {
+ // assuming 32x32, draw points along <2..31,2> and <2..31,31>
+ painter.drawPoint(i, loy + 2);
+ painter.drawPoint(i + 1, loy + ht - 1);
+ }
+ for (int j = loy + 2; j < loy + ht - 1; j += 2) {
+ // assuming 32x32, draw points along <2,2..31> and <31,2..31>
+ painter.drawPoint(lox + 2, j);
+ painter.drawPoint(lox + wd - 1, j + 1);
+ }
+ }
+ }
+#else
+ nhUse(border);
+#endif
+}
+
QPixmap NetHackQtGlyphs::glyph(int glyph)
{
int tile = glyph2tile[glyph];
namespace nethack_qt_ {
+enum border_code {
+ NO_BORDER, BORDER_DEFAULT,
+ BORDER_CURSED, BORDER_UNCURSED, BORDER_BLESSED
+};
+
class NetHackQtGlyphs {
public:
NetHackQtGlyphs();
void drawGlyph(QPainter&, int glyph, int pixelx, int pixely);
void drawCell(QPainter&, int glyph, int cellx, int celly);
+ void drawBorderedCell(QPainter&, int glyph,
+ int cellx, int celly, int bordercode);
QPixmap glyph(int glyph);
private:
int x, int y, bool canbe)
{
short int glyph;
+ int border;
+
if (nhobj) {
- /* Hallucination doesn't affect inventory */
+ border = BORDER_DEFAULT;
+ if (Role_if('P') && !Blind)
+ nhobj->bknown = 1;
+ if (nhobj->bknown)
+ border = nhobj->cursed ? BORDER_CURSED
+ : !nhobj->blessed ? BORDER_UNCURSED
+ : BORDER_BLESSED;
glyph = obj_to_glyph(nhobj, rn2_on_display_rng);
} else {
+ border = NO_BORDER;
glyph = canbe ? cmap_to_glyph(S_room) : GLYPH_UNEXPLORED;
}
- qt_settings->glyphs().drawCell(painter, glyph, x, y);
+ qt_settings->glyphs().drawBorderedCell(painter, glyph, x, y, border);
}
void NetHackQtInvUsageWindow::paintEvent(QPaintEvent*)
{
if (qt_settings) {
int w = 0, h = 0;
+ // 1+X+1: one pixel border surrounding each tile in the paper doll,
+ // so +1 left and +1 right, also +1 above and +1 below
#ifdef ENHANCED_PAPERDOLL
if (qt_settings->doll_is_shown) {
- w = qt_settings->dollWidth * 3;
- h = qt_settings->dollHeight * 6;
+ w = (1 + qt_settings->dollWidth + 1) * 3;
+ h = (1 + qt_settings->dollHeight + 1) * 6;
}
#else
- w = qt_settings->glyphs().width() * 3;
- h = qt_settings->glyphs().height() * 6;
+ w = (1 + qt_settings->glyphs().width() + 1) * 3;
+ h = (1 + qt_settings->glyphs().height() + 1) * 6;
#endif
return QSize(w, h);
} else {
clicksink(click_sink),
change(10)
{
- pet_annotation = QPixmap(qt_compact_mode ? pet_mark_small_xpm : pet_mark_xpm);
+ pet_annotation = QPixmap(qt_compact_mode ? pet_mark_small_xpm
+ : pet_mark_xpm);
pile_annotation = QPixmap(pile_mark_xpm);
Clear();
}
#ifdef TEXTCOLOR
if (((special & MG_PET) != 0) && ::iflags.hilite_pet) {
- painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pet_annotation);
+ painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
+ j*qt_settings->glyphs().height()),
+ pet_annotation);
} else if (((special & MG_OBJPILE) != 0) && ::iflags.hilite_pile) {
- painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pile_annotation);
+ painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
+ j*qt_settings->glyphs().height()),
+ pile_annotation);
}
#endif
}
qt_settings->glyphs().drawCell(painter, g, i, j);
#ifdef TEXTCOLOR
if (((special & MG_PET) != 0) && ::iflags.hilite_pet) {
- painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pet_annotation);
+ painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
+ j*qt_settings->glyphs().height()),
+ pet_annotation);
} else if (((special & MG_OBJPILE) != 0) && ::iflags.hilite_pile) {
- painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pile_annotation);
+ painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
+ j*qt_settings->glyphs().height()),
+ pile_annotation);
}
#endif
}
palette.setColor(viewport.backgroundRole(), Qt::black);
viewport.setPalette(palette);
- pet_annotation = QPixmap(qt_compact_mode ? pet_mark_small_xpm : pet_mark_xpm);
+ pet_annotation = QPixmap(qt_compact_mode ? pet_mark_small_xpm
+ : pet_mark_xpm);
pile_annotation = QPixmap(pile_mark_xpm);
cursor.setX(0);
);
#ifdef TEXTCOLOR
if (((special & MG_PET) != 0) && ::iflags.hilite_pet) {
- painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pet_annotation);
+ painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
+ j*qt_settings->glyphs().height()),
+ pet_annotation);
} else if (((special & MG_OBJPILE) != 0) && ::iflags.hilite_pile) {
- painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pile_annotation);
+ painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
+ j*qt_settings->glyphs().height()),
+ pile_annotation);
}
#endif
}
qt_settings->glyphs().drawCell(painter, g, i, j);
#ifdef TEXTCOLOR
if (((special & MG_PET) != 0) && ::iflags.hilite_pet) {
- painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pet_annotation);
+ painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
+ j*qt_settings->glyphs().height()),
+ pet_annotation);
} else if (((special & MG_OBJPILE) != 0) && ::iflags.hilite_pile) {
- painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pile_annotation);
+ painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
+ j*qt_settings->glyphs().height()),
+ pile_annotation);
}
#endif
}
protected:
virtual void paintEvent(QPaintEvent* event);
- bool DrawWalls(QPainter& painter, int x, int y, int w, int h, unsigned ch);
+ bool DrawWalls(QPainter& painter, int x, int y,
+ int w, int h, unsigned ch);
virtual QSize sizeHint() const;
virtual QSize minimumSizeHint() const;
virtual void mousePressEvent(QMouseEvent* event);