| 1652 | } |
| 1653 | |
| 1654 | void NetHackQtMapWindow::paintEvent(QPaintEvent* event) |
| 1655 | { |
| 1656 | QRect area=event->rect(); |
| 1657 | QRect garea; |
| 1658 | garea.setCoords( |
| 1659 | QMAX(0,area.left()/qt_settings->glyphs().width()), |
| 1660 | QMAX(0,area.top()/qt_settings->glyphs().height()), |
| 1661 | QMIN(COLNO-1,area.right()/qt_settings->glyphs().width()), |
| 1662 | QMIN(ROWNO-1,area.bottom()/qt_settings->glyphs().height()) |
| 1663 | ); |
| 1664 | |
| 1665 | QPainter painter; |
| 1666 | |
| 1667 | painter.begin(this); |
| 1668 | |
| 1669 | if (Is_rogue_level(&u.uz) || iflags.wc_ascii_map) |
| 1670 | { |
| 1671 | // You enter a VERY primitive world! |
| 1672 | |
| 1673 | painter.setClipRect( event->rect() ); // (normally we don't clip) |
| 1674 | painter.fillRect( event->rect(), black ); |
| 1675 | |
| 1676 | if ( !rogue_font ) { |
| 1677 | // Find font... |
| 1678 | int pts = 5; |
| 1679 | QString fontfamily = iflags.wc_font_map |
| 1680 | ? iflags.wc_font_map : "Courier"; |
| 1681 | bool bold = FALSE; |
| 1682 | if ( fontfamily.right(5).lower() == "-bold" ) { |
| 1683 | fontfamily.truncate(fontfamily.length()-5); |
| 1684 | bold = TRUE; |
| 1685 | } |
| 1686 | while ( pts < 32 ) { |
| 1687 | QFont f(fontfamily, pts, bold ? QFont::Bold : QFont::Normal); |
| 1688 | painter.setFont(QFont(fontfamily, pts)); |
| 1689 | QFontMetrics fm = painter.fontMetrics(); |
| 1690 | if ( fm.width("M") > qt_settings->glyphs().width() ) |
| 1691 | break; |
| 1692 | if ( fm.height() > qt_settings->glyphs().height() ) |
| 1693 | break; |
| 1694 | pts++; |
| 1695 | } |
| 1696 | rogue_font = new QFont(fontfamily,pts-1); |
| 1697 | } |
| 1698 | painter.setFont(*rogue_font); |
| 1699 | |
| 1700 | for (int j=garea.top(); j<=garea.bottom(); j++) { |
| 1701 | for (int i=garea.left(); i<=garea.right(); i++) { |
| 1702 | unsigned short g=Glyph(i,j); |
| 1703 | uchar ch; |
| 1704 | int color, och; |
| 1705 | unsigned special; |
| 1706 | |
| 1707 | painter.setPen( green ); |
| 1708 | /* map glyph to character and color */ |
| 1709 | (void)mapglyph(g, &och, &color, &special, i, j, 0); |
| 1710 | ch = (uchar)och; |
| 1711 | painter.setPen( nhcolor_to_pen(color) ); |