| 124 | } |
| 125 | |
| 126 | void NetHackQtMapViewport::paintEvent(QPaintEvent* event) |
| 127 | { |
| 128 | NetHackQtGlyphs &glyphs = qt_settings->glyphs(); |
| 129 | int gW = glyphs.width(), |
| 130 | gH = glyphs.height(); |
| 131 | QRect area = event->rect(); |
| 132 | QRect garea; |
| 133 | garea.setCoords(std::max(0, area.left() / gW), |
| 134 | std::max(0, area.top() / gH), |
| 135 | std::min(COLNO - 1, area.right() / gW), |
| 136 | std::min(ROWNO - 1, area.bottom() / gH)); |
| 137 | |
| 138 | QPainter painter; |
| 139 | painter.begin(this); |
| 140 | |
| 141 | unsigned special, tileidx; |
| 142 | uint32 color; |
| 143 | uint32 framecolor; |
| 144 | |
| 145 | if (Is_rogue_level(&u.uz) || iflags.wc_ascii_map) { |
| 146 | // You enter a VERY primitive world! |
| 147 | |
| 148 | painter.setClipRect( event->rect() ); // (normally we don't clip) |
| 149 | painter.fillRect( event->rect(), Qt::black ); |
| 150 | |
| 151 | if (!rogue_font) |
| 152 | SetupTextmapFont(painter); |
| 153 | painter.setFont(*rogue_font); |
| 154 | |
| 155 | for (int j = garea.top(); j <= garea.bottom(); j++) { |
| 156 | for (int i = garea.left(); i <= garea.right(); i++) { |
| 157 | char32_t ch = Glyphttychar(i, j); |
| 158 | |
| 159 | special = Glyphflags(i, j); |
| 160 | if (SYMHANDLING(H_IBM)) { |
| 161 | ch = cp437(ch); |
| 162 | } |
| 163 | color = Glyphcolor(i, j); |
| 164 | painter.setPen(NetHackQtBind::nhcolor_to_pen(color)); |
| 165 | if (!DrawWalls(painter, i * gW, j * gH, gW, gH, ch)) { |
| 166 | ushort utf16[3]; |
| 167 | if (ch < 0x10000) { |
| 168 | utf16[0] = static_cast<ushort>(ch); |
| 169 | utf16[1] = 0; |
| 170 | } else { |
| 171 | utf16[0] = static_cast<ushort>((ch >> 10) + 0xD7C0); |
| 172 | utf16[1] = static_cast<ushort>((ch & 0x3FF) + 0xDC00); |
| 173 | utf16[2] = 0; |
| 174 | } |
| 175 | painter.drawText(i * gW, j * gH, gW, gH, Qt::AlignCenter, |
| 176 | QString::fromUtf16(utf16)); |
| 177 | } |
| 178 | if ((special & MG_PET) != 0 && ::iflags.hilite_pet) { |
| 179 | painter.drawPixmap(QPoint(i * gW, j * gH), |
| 180 | pet_annotation); |
| 181 | } else if ((special & MG_OBJPILE) != 0 |
| 182 | && ::iflags.hilite_pile) { |
| 183 | painter.drawPixmap(QPoint(i * gW, j * gH), |