Qt paper doll's depiction of two-handed weapon

When wielding a two-handed weapon, Qt's paper doll shows uwep
in the shield slot as well as in the weapon slot to reflect
that it's occupying both hands.  Make the shield slot's copy
be a mirror image of the weapon's tile so that it looks less
like wielding two weapons.
This commit is contained in:
PatR
2020-11-08 16:38:01 -08:00
parent ea0ef81ecd
commit 6b37efa9e1
4 changed files with 67 additions and 27 deletions
+40 -10
View File
@@ -81,23 +81,31 @@ NetHackQtGlyphs::NetHackQtGlyphs()
setSize(tilefile_tile_W, tilefile_tile_H);
}
void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int x, int y)
void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int x, int y,
bool reversed)
{
int tile = glyph2tile[glyph];
int px = (tile % tiles_per_row) * width();
int py = tile / tiles_per_row * height();
if (!reversed) {
int tile = glyph2tile[glyph];
int px = (tile % tiles_per_row) * width();
int py = tile / tiles_per_row * height();
painter.drawPixmap(x, y, pm, px, py, width(), height());
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),
0, 0, width(), height());
}
}
void NetHackQtGlyphs::drawCell(QPainter& painter, int glyph,
int cellx, int celly)
{
drawGlyph(painter, glyph, cellx * width(), celly * height());
drawGlyph(painter, glyph, cellx * width(), celly * height(), false);
}
void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph,
int cellx, int celly, int border)
int cellx, int celly, int border,
bool reversed)
{
int wd = width(),
ht = height(),
@@ -105,7 +113,7 @@ void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph,
lox = cellx * (wd + 2),
loy = celly * (ht + 2) + yoffset;
drawGlyph(painter, glyph, lox + 1, loy + 1);
drawGlyph(painter, glyph, lox + 1, loy + 1, reversed);
#ifdef TEXTCOLOR
if (border != NO_BORDER) {
@@ -155,9 +163,10 @@ void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph,
#endif
}
QPixmap NetHackQtGlyphs::glyph(int glyph)
// mis-named routine to get the pixmap for a particular glyph
QPixmap NetHackQtGlyphs::glyph(int glyphindx)
{
int tile = glyph2tile[glyph];
int tile = glyph2tile[glyphindx];
int px = (tile % tiles_per_row) * tilefile_tile_W;
int py = tile / tiles_per_row * tilefile_tile_H;
@@ -165,6 +174,27 @@ QPixmap NetHackQtGlyphs::glyph(int glyph)
tilefile_tile_W, tilefile_tile_H));
}
// transpose a glyph's tile horizontally, scaled for use in paper doll
QPixmap NetHackQtGlyphs::reversed_pixmap(int glyphindx)
{
QPixmap pxmp = glyph(glyphindx);
#ifdef ENHANCED_PAPERDOLL
qreal wid = (qreal) pxmp.width(),
//hgt = (qreal) pxmp.height(),
xscale = (qreal) qt_settings->dollWidth / (qreal) tilefile_tile_W,
yscale = (qreal) qt_settings->dollHeight / (qreal) tilefile_tile_H;
QTransform *mirrormatrix = new QTransform(
// negate x coordinates to flip the image across the y-axis
-1.0 * xscale, 0.0, 0.0, yscale,
// slide flipped image to the right to make things positive again
wid * xscale, 0.0
);
return pxmp.transformed(*mirrormatrix);
#else
return pxmp;
#endif
}
void NetHackQtGlyphs::setSize(int w, int h)
{
if (size == QSize(w, h))