From 0870fb32ac8fbbf49fa20a5a114d4e26e342efe7 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 4 Jan 2022 12:23:06 -0800 Subject: [PATCH] Qt tile rendering Get rid of the no longer used 'fem' argument for Qt's tile drawing routines. It's incorporated in the tile index these days. --- win/Qt/qt_glyph.cpp | 50 +++++++++++++++++++++++++++++---------------- win/Qt/qt_glyph.h | 10 ++++----- win/Qt/qt_map.cpp | 9 ++++---- win/Qt/qt_plsel.cpp | 12 +++++------ 4 files changed, 47 insertions(+), 34 deletions(-) diff --git a/win/Qt/qt_glyph.cpp b/win/Qt/qt_glyph.cpp index 75bc234d9..abb1a7254 100644 --- a/win/Qt/qt_glyph.cpp +++ b/win/Qt/qt_glyph.cpp @@ -103,15 +103,18 @@ NetHackQtGlyphs::NetHackQtGlyphs() setSize(tilefile_tile_W, tilefile_tile_H); } -void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int tileidx, - int x, int y, bool fem, bool reversed) +// display a map tile somewhere other than the map; +// used for paper doll and also role/race selection +void +NetHackQtGlyphs::drawGlyph( + QPainter& painter, + int glyph, int tileidx, + int x, int y, + bool reversed) { if (!reversed) { #if 0 int tile = glyph2tile[glyph]; - /* this is not required with the new glyph representation */ - if (fem) - ++tile; #else int tile = tileidx; #endif @@ -121,21 +124,29 @@ void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int tileidx, painter.drawPixmap(x, y, pm, px, py, width(), height()); } else { // for paper doll; mirrored image for left side of two-handed weapon - painter.drawPixmap(x, y, reversed_pixmap(glyph, tileidx, fem), + painter.drawPixmap(x, y, reversed_pixmap(glyph, tileidx), 0, 0, width(), height()); } } -void NetHackQtGlyphs::drawCell(QPainter& painter, int glyph, int tileidx, - int cellx, int celly, bool fem) +// draw a tile into the paper doll +void +NetHackQtGlyphs::drawCell( + QPainter& painter, + int glyph, int tileidx, + int cellx, int celly) { drawGlyph(painter, glyph, tileidx, cellx * width(), celly * height(), - fem, false); + false); } -void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph, - int tileidx, int cellx, int celly, - int border, bool reversed, bool fem) +// draw a tile into the paper doll and then draw a BUC border around it +void +NetHackQtGlyphs::drawBorderedCell( + QPainter& painter, + int glyph, int tileidx, + int cellx, int celly, + int border, bool reversed) { int wd = width(), ht = height(), @@ -143,7 +154,7 @@ void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph, lox = cellx * (wd + 2), loy = celly * (ht + 2) + yoffset; - drawGlyph(painter, glyph, tileidx, lox + 1, loy + 1, fem, reversed); + drawGlyph(painter, glyph, tileidx, lox + 1, loy + 1, reversed); #ifdef TEXTCOLOR if (border != NO_BORDER) { @@ -194,12 +205,13 @@ void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph, } // mis-named routine to get the pixmap for a particular glyph -QPixmap NetHackQtGlyphs::glyph(int glyphindx UNUSED, int tileidx, bool fem UNUSED) +QPixmap +NetHackQtGlyphs::glyph( + int glyphindx UNUSED, + int tileidx) { #if 0 int tile = glyph2tile[glyphindx]; - if (fem) - ++tile; #else int tile = tileidx; #endif @@ -211,9 +223,11 @@ QPixmap NetHackQtGlyphs::glyph(int glyphindx UNUSED, int tileidx, bool fem UNUSE } // transpose a glyph's tile horizontally, scaled for use in paper doll -QPixmap NetHackQtGlyphs::reversed_pixmap(int glyphindx, int tileidx, bool fem) +QPixmap +NetHackQtGlyphs::reversed_pixmap( + int glyphindx, int tileidx) { - QPixmap pxmp = glyph(glyphindx, tileidx, fem); + QPixmap pxmp = glyph(glyphindx, tileidx); #ifdef ENHANCED_PAPERDOLL qreal wid = (qreal) pxmp.width(), //hgt = (qreal) pxmp.height(), diff --git a/win/Qt/qt_glyph.h b/win/Qt/qt_glyph.h index c00a11214..8f5e9c65a 100644 --- a/win/Qt/qt_glyph.h +++ b/win/Qt/qt_glyph.h @@ -27,14 +27,14 @@ public: void drawGlyph(QPainter &, int glyph, int tileidx, int pixelx, int pixely, - bool fem, bool reversed = false); + bool reversed = false); void drawCell(QPainter &, int glyph, int tileidx, - int cellx, int celly, bool fem); + int cellx, int celly); void drawBorderedCell(QPainter &, int glyph, int tileidx, int cellx, int celly, int bordercode, - bool reversed, bool fem = false); - QPixmap glyph(int glyphindx, int tileidx, bool fem = false); - QPixmap reversed_pixmap(int glyphindx, int tileidx, bool fem = false); + bool reversed); + QPixmap glyph(int glyphindx, int tileidx); + QPixmap reversed_pixmap(int glyphindx, int tileidx); private: QImage img; diff --git a/win/Qt/qt_map.cpp b/win/Qt/qt_map.cpp index 85d78da64..f25067fb0 100644 --- a/win/Qt/qt_map.cpp +++ b/win/Qt/qt_map.cpp @@ -217,8 +217,8 @@ void NetHackQtMapViewport::paintEvent(QPaintEvent* event) unsigned short g = Glyph(i,j); unsigned special = Glyphflags(i, j); unsigned tileidx = Glyphtileidx(i, j); - bool femflag = (special & MG_FEMALE) ? true : false; - glyphs.drawCell(painter, g, tileidx, i, j, femflag); + + glyphs.drawCell(painter, g, tileidx, i, j); if ((special & MG_PET) != 0 && ::iflags.hilite_pet) { painter.drawPixmap(QPoint(i * gW, j * gH), @@ -906,9 +906,8 @@ void NetHackQtMapWindow::paintEvent(QPaintEvent* event) int ch = Glyphttychar(i,j); unsigned special = Glyphflags(i,j); unsigned short tileidx = Glyphtileidx(i,j); - bool femflag = (special & MG_FEMALE) ? true : false; - qt_settings->glyphs().drawCell(painter, g, tileidx, - i, j, femflag); + + qt_settings->glyphs().drawCell(painter, g, tileidx, i, j); #ifdef TEXTCOLOR if ((special & MG_PET) != 0 && ::iflags.hilite_pet) { painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), diff --git a/win/Qt/qt_plsel.cpp b/win/Qt/qt_plsel.cpp index 4650cbdf9..f3ca26933 100644 --- a/win/Qt/qt_plsel.cpp +++ b/win/Qt/qt_plsel.cpp @@ -82,14 +82,14 @@ public: { } - void setGlyph(int g, int tileidx, bool fem) + void setGlyph(int g, int tileidx) { NetHackQtGlyphs& glyphs = qt_settings->glyphs(); int gw = glyphs.width(); int gh = glyphs.height(); QPixmap pm(gw,gh); QPainter p(&pm); - glyphs.drawGlyph(p, g, tileidx, 0, 0, fem); + glyphs.drawGlyph(p, g, tileidx, 0, 0, false); p.end(); setIcon(QIcon(pm)); //RLC setHeight(std::max(pm.height()+1,height())); @@ -127,7 +127,7 @@ public: glyph_info gi; int glyph = monnum_to_glyph(roles[id].malenum, MALE); map_glyphinfo(0, 0, glyph, 0, &gi); - setGlyph(glyph, gi.gm.tileidx, false); + setGlyph(glyph, gi.gm.tileidx); } }; @@ -145,7 +145,7 @@ public: glyph_info gi; int glyph = monnum_to_glyph(races[id].malenum, MALE); map_glyphinfo(0, 0, glyph, 0, &gi); - setGlyph(glyph, gi.gm.tileidx, false); + setGlyph(glyph, gi.gm.tileidx); } }; @@ -275,7 +275,7 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks UNUSED) map_glyphinfo(0, 0, glyph, 0, &gi); QTableWidgetItem *item = new QTableWidgetItem( - QIcon(qt_settings->glyphs().glyph(glyph, gi.gm.tileidx, fem)), + QIcon(qt_settings->glyphs().glyph(glyph, gi.gm.tileidx)), (fem && roles[i].name.f) ? roles[i].name.f : roles[i].name.m); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); role->setItem(i, 0, item); @@ -295,7 +295,7 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks UNUSED) map_glyphinfo(0, 0, glyph, 0, &gi); QTableWidgetItem *item = new QTableWidgetItem( - QIcon(qt_settings->glyphs().glyph(glyph, gi.gm.tileidx, fem)), + QIcon(qt_settings->glyphs().glyph(glyph, gi.gm.tileidx)), races[i].noun); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); race->setItem(i, 0, item);