]> granicus.if.org Git - nethack/commitdiff
Qt tile rendering
authorPatR <rankin@nethack.org>
Tue, 4 Jan 2022 20:23:06 +0000 (12:23 -0800)
committerPatR <rankin@nethack.org>
Tue, 4 Jan 2022 20:23:06 +0000 (12:23 -0800)
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
win/Qt/qt_glyph.h
win/Qt/qt_map.cpp
win/Qt/qt_plsel.cpp

index 75bc234d9537a20c6a2301e55df5f42901dd52bd..abb1a7254a081afdee093244fb28a10a3ca27aa6 100644 (file)
@@ -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(),
index c00a112148382588173443770ca52a8e0e3eb56d..8f5e9c65a2d3bc15d7b64f08e179aea214d259d3 100644 (file)
@@ -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;
index 85d78da646f6672d60a539169ca817e9b5ad55c6..f25067fb088c901449eda1f5e8141d422e489ade 100644 (file)
@@ -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(),
index 4650cbdf910b2eda092e0c4cfb36249c166a9db2..f3ca26933c8719537f049892e08c4442f5cd8f2e 100644 (file)
@@ -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);