Qt4: Pile mark

This commit is contained in:
Pasi Kallinen
2017-10-10 21:47:35 +03:00
parent dbacc98a1d
commit 4dff3a707e
3 changed files with 47 additions and 22 deletions

View File

@@ -946,6 +946,20 @@ static const char *pet_mark_small_xpm[] = {
"..X.."
};
/* XPM */
static const char *pile_mark_xpm[] = {
/* width height ncolors chars_per_pixel */
"5 5 2 1",
/* colors */
". c None",
"X c #00FF00",
/* pixels */
"..X..",
"..X..",
"XXXXX",
"..X..",
"..X.."
};
/* XPM */
static const char *satiated_xpm[] = {
/* width height ncolors chars_per_pixel */
"40 40 23 1",

View File

@@ -71,6 +71,7 @@ NetHackQtMapViewport::NetHackQtMapViewport(NetHackQtClickBuffer& click_sink) :
change(10)
{
pet_annotation = QPixmap(qt_compact_mode ? pet_mark_small_xpm : pet_mark_xpm);
pile_annotation = QPixmap(pile_mark_xpm);
Clear();
cursor.setX(0);
@@ -157,29 +158,33 @@ void NetHackQtMapViewport::paintEvent(QPaintEvent* event)
QString(QChar(ch)).left(1)
);
}
if (glyph_is_pet(g)
#ifdef TEXTCOLOR
&& ::iflags.hilite_pet
if (((special & MG_PET) != 0) && ::iflags.hilite_pet) {
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);
}
#endif
) {
painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pet_annotation);
}
}
}
}
}
painter.setFont(font());
} else {
for (int j=garea.top(); j<=garea.bottom(); j++) {
for (int i=garea.left(); i<=garea.right(); i++) {
unsigned short g=Glyph(i,j);
int color;
int ch;
unsigned special;
mapglyph(g, &ch, &color, &special, i, j);
qt_settings->glyphs().drawCell(painter, g, i, j);
if (glyph_is_pet(g)
#ifdef TEXTCOLOR
&& ::iflags.hilite_pet
if (((special & MG_PET) != 0) && ::iflags.hilite_pet) {
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);
}
#endif
) {
painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pet_annotation);
}
}
}
}
@@ -649,6 +654,7 @@ NetHackQtMapWindow::NetHackQtMapWindow(NetHackQtClickBuffer& click_sink) :
viewport.setPalette(palette);
pet_annotation = QPixmap(qt_compact_mode ? pet_mark_small_xpm : pet_mark_xpm);
pile_annotation = QPixmap(pile_mark_xpm);
cursor.setX(0);
cursor.setY(0);
@@ -835,13 +841,13 @@ void NetHackQtMapWindow::paintEvent(QPaintEvent* event)
Qt::AlignCenter,
QString(QChar(ch)).left(1)
);
if (glyph_is_pet(g)
#ifdef TEXTCOLOR
&& ::iflags.hilite_pet
if (((special & MG_PET) != 0) && ::iflags.hilite_pet) {
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);
}
#endif
) {
painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pet_annotation);
}
}
}
@@ -850,14 +856,18 @@ void NetHackQtMapWindow::paintEvent(QPaintEvent* event)
for (int j=garea.top(); j<=garea.bottom(); j++) {
for (int i=garea.left(); i<=garea.right(); i++) {
unsigned short g=Glyph(i,j);
int color;
int ch;
unsigned special;
mapglyph(g, &ch, &color, &special, i, j);
qt_settings->glyphs().drawCell(painter, g, i, j);
if (glyph_is_pet(g)
#ifdef TEXTCOLOR
&& ::iflags.hilite_pet
if (((special & MG_PET) != 0) && ::iflags.hilite_pet) {
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);
}
#endif
) {
painter.drawPixmap(QPoint(i*qt_settings->glyphs().width(), j*qt_settings->glyphs().height()), pet_annotation);
}
}
}
}

View File

@@ -33,6 +33,7 @@ private:
unsigned short& Glyph(int x, int y) { return glyph[y][x]; }
QPoint cursor;
QPixmap pet_annotation;
QPixmap pile_annotation;
NetHackQtClickBuffer& clicksink;
Clusterizer change;