Honour wc_tile_width, wc_tile_height, and wc_tile_file.
This commit is contained in:
+24
-21
@@ -199,9 +199,8 @@ extern int total_tiles_used; // from tile.c
|
|||||||
extern short glyph2tile[]; // from tile.c
|
extern short glyph2tile[]; // from tile.c
|
||||||
}
|
}
|
||||||
|
|
||||||
// ### Try to replace these by looking at image size
|
static int tilefile_tile_W=16;
|
||||||
#define TILEWBASE 16
|
static int tilefile_tile_H=16;
|
||||||
#define TILEHBASE 16
|
|
||||||
|
|
||||||
#define TILEWMIN 1
|
#define TILEWMIN 1
|
||||||
#define TILEHMIN 1
|
#define TILEHMIN 1
|
||||||
@@ -4169,33 +4168,37 @@ void NetHackQtYnDialog::done(int i)
|
|||||||
|
|
||||||
NetHackQtGlyphs::NetHackQtGlyphs()
|
NetHackQtGlyphs::NetHackQtGlyphs()
|
||||||
{
|
{
|
||||||
const char* tile_file = "x11tiles";
|
const char* tile_file = "nhtiles.bmp";
|
||||||
|
if ( iflags.wc_tile_file )
|
||||||
int tw = TILEWBASE;
|
tile_file = iflags.wc_tile_file;
|
||||||
int th = TILEHBASE;
|
|
||||||
|
|
||||||
|
|
||||||
if (!img.load(tile_file)) {
|
if (!img.load(tile_file)) {
|
||||||
tile_file = "nhtiles.bmp";
|
tile_file = "x11tiles";
|
||||||
if (!img.load(tile_file)) {
|
if (!img.load(tile_file)) {
|
||||||
QString msg;
|
QString msg;
|
||||||
msg.sprintf("Cannot load x11tiles or nhtiles.bmp");
|
msg.sprintf("Cannot load x11tiles or nhtiles.bmp");
|
||||||
QMessageBox::warning(0, "IO Error", msg);
|
QMessageBox::warning(0, "IO Error", msg);
|
||||||
} else {
|
} else {
|
||||||
tiles_per_row = 40;
|
tiles_per_row = TILES_PER_ROW;
|
||||||
|
if (img.width()%tiles_per_row) {
|
||||||
|
impossible("Tile file \"%s\" has %d columns, not multiple of row count (%d)",
|
||||||
|
tile_file, img.width(), tiles_per_row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tiles_per_row = TILES_PER_ROW;
|
tiles_per_row = 40;
|
||||||
if (img.width()%tiles_per_row) {
|
|
||||||
impossible("Tile file \"%s\" has %d columns, not multiple of row count (%d)",
|
|
||||||
tile_file, img.width(), tiles_per_row);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int rows = ((total_tiles_used+tiles_per_row-1) / tiles_per_row);
|
int rows = ((total_tiles_used+tiles_per_row-1) / tiles_per_row);
|
||||||
tw = img.width() / tiles_per_row;
|
if ( iflags.wc_tile_width )
|
||||||
th = img.height() / rows;
|
tilefile_tile_W = iflags.wc_tile_width;
|
||||||
|
else
|
||||||
|
tilefile_tile_W = img.width() / tiles_per_row;
|
||||||
|
if ( iflags.wc_tile_height )
|
||||||
|
tilefile_tile_H = iflags.wc_tile_height;
|
||||||
|
else
|
||||||
|
tilefile_tile_H = tilefile_tile_W;
|
||||||
|
|
||||||
resize(tw, th);
|
resize(tilefile_tile_W, tilefile_tile_H);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int x, int y)
|
void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int x, int y)
|
||||||
@@ -4222,13 +4225,13 @@ void NetHackQtGlyphs::resize(int w, int h)
|
|||||||
if (!w || !h)
|
if (!w || !h)
|
||||||
return; // Still not decided
|
return; // Still not decided
|
||||||
|
|
||||||
if (w==TILEWBASE && h==TILEHBASE) {
|
if (w==tilefile_tile_W && h==tilefile_tile_H) {
|
||||||
pm.convertFromImage(img);
|
pm.convertFromImage(img);
|
||||||
} else {
|
} else {
|
||||||
QApplication::setOverrideCursor( Qt::waitCursor );
|
QApplication::setOverrideCursor( Qt::waitCursor );
|
||||||
QImage scaled = img.smoothScale(
|
QImage scaled = img.smoothScale(
|
||||||
w*img.width()/TILEWBASE,
|
w*img.width()/tilefile_tile_W,
|
||||||
h*img.height()/TILEHBASE
|
h*img.height()/tilefile_tile_H
|
||||||
);
|
);
|
||||||
pm.convertFromImage(scaled,Qt::ThresholdDither|Qt::PreferDither);
|
pm.convertFromImage(scaled,Qt::ThresholdDither|Qt::PreferDither);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|||||||
Reference in New Issue
Block a user