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.
This commit is contained in:
@@ -103,15 +103,18 @@ NetHackQtGlyphs::NetHackQtGlyphs()
|
|||||||
setSize(tilefile_tile_W, tilefile_tile_H);
|
setSize(tilefile_tile_W, tilefile_tile_H);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int tileidx,
|
// display a map tile somewhere other than the map;
|
||||||
int x, int y, bool fem, bool reversed)
|
// 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 (!reversed) {
|
||||||
#if 0
|
#if 0
|
||||||
int tile = glyph2tile[glyph];
|
int tile = glyph2tile[glyph];
|
||||||
/* this is not required with the new glyph representation */
|
|
||||||
if (fem)
|
|
||||||
++tile;
|
|
||||||
#else
|
#else
|
||||||
int tile = tileidx;
|
int tile = tileidx;
|
||||||
#endif
|
#endif
|
||||||
@@ -121,21 +124,29 @@ void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int tileidx,
|
|||||||
painter.drawPixmap(x, y, pm, px, py, width(), height());
|
painter.drawPixmap(x, y, pm, px, py, width(), height());
|
||||||
} else {
|
} else {
|
||||||
// for paper doll; mirrored image for left side of two-handed weapon
|
// 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());
|
0, 0, width(), height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetHackQtGlyphs::drawCell(QPainter& painter, int glyph, int tileidx,
|
// draw a tile into the paper doll
|
||||||
int cellx, int celly, bool fem)
|
void
|
||||||
|
NetHackQtGlyphs::drawCell(
|
||||||
|
QPainter& painter,
|
||||||
|
int glyph, int tileidx,
|
||||||
|
int cellx, int celly)
|
||||||
{
|
{
|
||||||
drawGlyph(painter, glyph, tileidx, cellx * width(), celly * height(),
|
drawGlyph(painter, glyph, tileidx, cellx * width(), celly * height(),
|
||||||
fem, false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph,
|
// draw a tile into the paper doll and then draw a BUC border around it
|
||||||
int tileidx, int cellx, int celly,
|
void
|
||||||
int border, bool reversed, bool fem)
|
NetHackQtGlyphs::drawBorderedCell(
|
||||||
|
QPainter& painter,
|
||||||
|
int glyph, int tileidx,
|
||||||
|
int cellx, int celly,
|
||||||
|
int border, bool reversed)
|
||||||
{
|
{
|
||||||
int wd = width(),
|
int wd = width(),
|
||||||
ht = height(),
|
ht = height(),
|
||||||
@@ -143,7 +154,7 @@ void NetHackQtGlyphs::drawBorderedCell(QPainter& painter, int glyph,
|
|||||||
lox = cellx * (wd + 2),
|
lox = cellx * (wd + 2),
|
||||||
loy = celly * (ht + 2) + yoffset;
|
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
|
#ifdef TEXTCOLOR
|
||||||
if (border != NO_BORDER) {
|
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
|
// 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
|
#if 0
|
||||||
int tile = glyph2tile[glyphindx];
|
int tile = glyph2tile[glyphindx];
|
||||||
if (fem)
|
|
||||||
++tile;
|
|
||||||
#else
|
#else
|
||||||
int tile = tileidx;
|
int tile = tileidx;
|
||||||
#endif
|
#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
|
// 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
|
#ifdef ENHANCED_PAPERDOLL
|
||||||
qreal wid = (qreal) pxmp.width(),
|
qreal wid = (qreal) pxmp.width(),
|
||||||
//hgt = (qreal) pxmp.height(),
|
//hgt = (qreal) pxmp.height(),
|
||||||
|
|||||||
@@ -27,14 +27,14 @@ public:
|
|||||||
|
|
||||||
void drawGlyph(QPainter &, int glyph, int tileidx,
|
void drawGlyph(QPainter &, int glyph, int tileidx,
|
||||||
int pixelx, int pixely,
|
int pixelx, int pixely,
|
||||||
bool fem, bool reversed = false);
|
bool reversed = false);
|
||||||
void drawCell(QPainter &, int glyph, int tileidx,
|
void drawCell(QPainter &, int glyph, int tileidx,
|
||||||
int cellx, int celly, bool fem);
|
int cellx, int celly);
|
||||||
void drawBorderedCell(QPainter &, int glyph, int tileidx,
|
void drawBorderedCell(QPainter &, int glyph, int tileidx,
|
||||||
int cellx, int celly, int bordercode,
|
int cellx, int celly, int bordercode,
|
||||||
bool reversed, bool fem = false);
|
bool reversed);
|
||||||
QPixmap glyph(int glyphindx, int tileidx, bool fem = false);
|
QPixmap glyph(int glyphindx, int tileidx);
|
||||||
QPixmap reversed_pixmap(int glyphindx, int tileidx, bool fem = false);
|
QPixmap reversed_pixmap(int glyphindx, int tileidx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QImage img;
|
QImage img;
|
||||||
|
|||||||
@@ -217,8 +217,8 @@ void NetHackQtMapViewport::paintEvent(QPaintEvent* event)
|
|||||||
unsigned short g = Glyph(i,j);
|
unsigned short g = Glyph(i,j);
|
||||||
unsigned special = Glyphflags(i, j);
|
unsigned special = Glyphflags(i, j);
|
||||||
unsigned tileidx = Glyphtileidx(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) {
|
if ((special & MG_PET) != 0 && ::iflags.hilite_pet) {
|
||||||
painter.drawPixmap(QPoint(i * gW, j * gH),
|
painter.drawPixmap(QPoint(i * gW, j * gH),
|
||||||
@@ -906,9 +906,8 @@ void NetHackQtMapWindow::paintEvent(QPaintEvent* event)
|
|||||||
int ch = Glyphttychar(i,j);
|
int ch = Glyphttychar(i,j);
|
||||||
unsigned special = Glyphflags(i,j);
|
unsigned special = Glyphflags(i,j);
|
||||||
unsigned short tileidx = Glyphtileidx(i,j);
|
unsigned short tileidx = Glyphtileidx(i,j);
|
||||||
bool femflag = (special & MG_FEMALE) ? true : false;
|
|
||||||
qt_settings->glyphs().drawCell(painter, g, tileidx,
|
qt_settings->glyphs().drawCell(painter, g, tileidx, i, j);
|
||||||
i, j, femflag);
|
|
||||||
#ifdef TEXTCOLOR
|
#ifdef TEXTCOLOR
|
||||||
if ((special & MG_PET) != 0 && ::iflags.hilite_pet) {
|
if ((special & MG_PET) != 0 && ::iflags.hilite_pet) {
|
||||||
painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
|
painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(),
|
||||||
|
|||||||
@@ -82,14 +82,14 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void setGlyph(int g, int tileidx, bool fem)
|
void setGlyph(int g, int tileidx)
|
||||||
{
|
{
|
||||||
NetHackQtGlyphs& glyphs = qt_settings->glyphs();
|
NetHackQtGlyphs& glyphs = qt_settings->glyphs();
|
||||||
int gw = glyphs.width();
|
int gw = glyphs.width();
|
||||||
int gh = glyphs.height();
|
int gh = glyphs.height();
|
||||||
QPixmap pm(gw,gh);
|
QPixmap pm(gw,gh);
|
||||||
QPainter p(&pm);
|
QPainter p(&pm);
|
||||||
glyphs.drawGlyph(p, g, tileidx, 0, 0, fem);
|
glyphs.drawGlyph(p, g, tileidx, 0, 0, false);
|
||||||
p.end();
|
p.end();
|
||||||
setIcon(QIcon(pm));
|
setIcon(QIcon(pm));
|
||||||
//RLC setHeight(std::max(pm.height()+1,height()));
|
//RLC setHeight(std::max(pm.height()+1,height()));
|
||||||
@@ -127,7 +127,7 @@ public:
|
|||||||
glyph_info gi;
|
glyph_info gi;
|
||||||
int glyph = monnum_to_glyph(roles[id].malenum, MALE);
|
int glyph = monnum_to_glyph(roles[id].malenum, MALE);
|
||||||
map_glyphinfo(0, 0, glyph, 0, &gi);
|
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;
|
glyph_info gi;
|
||||||
int glyph = monnum_to_glyph(races[id].malenum, MALE);
|
int glyph = monnum_to_glyph(races[id].malenum, MALE);
|
||||||
map_glyphinfo(0, 0, glyph, 0, &gi);
|
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);
|
map_glyphinfo(0, 0, glyph, 0, &gi);
|
||||||
|
|
||||||
QTableWidgetItem *item = new QTableWidgetItem(
|
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);
|
(fem && roles[i].name.f) ? roles[i].name.f : roles[i].name.m);
|
||||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
role->setItem(i, 0, item);
|
role->setItem(i, 0, item);
|
||||||
@@ -295,7 +295,7 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks UNUSED)
|
|||||||
map_glyphinfo(0, 0, glyph, 0, &gi);
|
map_glyphinfo(0, 0, glyph, 0, &gi);
|
||||||
|
|
||||||
QTableWidgetItem *item = new QTableWidgetItem(
|
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);
|
races[i].noun);
|
||||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
race->setItem(i, 0, item);
|
race->setItem(i, 0, item);
|
||||||
|
|||||||
Reference in New Issue
Block a user