more Qt formatting

This commit is contained in:
PatR
2020-08-13 02:00:11 -07:00
parent 58d208ee8f
commit cee29d3338
+12 -14
View File
@@ -6,7 +6,7 @@
extern "C" { extern "C" {
#include "hack.h" #include "hack.h"
#include "tile2x11.h" #include "tile2x11.h" /* x11tiles is potential fallback for nhtiles.bmp */
} }
#include "qt_pre.h" #include "qt_pre.h"
@@ -82,45 +82,43 @@ void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int x, int y)
int px = (tile % tiles_per_row) * width(); int px = (tile % tiles_per_row) * width();
int py = tile / tiles_per_row * height(); int py = tile / tiles_per_row * height();
painter.drawPixmap( painter.drawPixmap(x, y, pm, px, py, width(), height());
x,
y,
pm,
px,py,
width(),height()
);
} }
void NetHackQtGlyphs::drawCell(QPainter& painter, int glyph, int cellx, int celly)
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());
} }
QPixmap NetHackQtGlyphs::glyph(int glyph) QPixmap NetHackQtGlyphs::glyph(int glyph)
{ {
int tile = glyph2tile[glyph]; int tile = glyph2tile[glyph];
int px = (tile % tiles_per_row) * tilefile_tile_W; int px = (tile % tiles_per_row) * tilefile_tile_W;
int py = tile / tiles_per_row * tilefile_tile_H; int py = tile / tiles_per_row * tilefile_tile_H;
return QPixmap::fromImage(img.copy(px, py, tilefile_tile_W, tilefile_tile_H)); return QPixmap::fromImage(img.copy(px, py,
tilefile_tile_W, tilefile_tile_H));
} }
void NetHackQtGlyphs::setSize(int w, int h) void NetHackQtGlyphs::setSize(int w, int h)
{ {
if (size == QSize(w, h)) if (size == QSize(w, h))
return; return;
bool was1 = size == pm1.size();
size = QSize(w, h); size = QSize(w, h);
if (!w || !h) if (!w || !h)
return; // Still not decided return; // Still not decided
if ( size == pm1.size() ) { if (size == pm1.size()) { // not zoomed
pm = pm1; pm = pm1;
return; return;
} }
if ( size == pm2.size() ) { if (size == pm2.size()) { // zoomed
pm = pm2; pm = pm2;
return; return;
} }
bool was1 = (size == pm1.size());
if (w == tilefile_tile_W && h == tilefile_tile_H) { if (w == tilefile_tile_W && h == tilefile_tile_H) {
pm.convertFromImage(img); pm.convertFromImage(img);
} else { } else {