Qt tiles file loading
Redo how Qt retries if it can't load the primary tiles file.
This commit is contained in:
@@ -1103,6 +1103,9 @@ Qt: while a text window was shown (such as the "things that are here" popup
|
||||
when stepping on items), typing commands had the input passed on to
|
||||
the map and then executed; sometimes that caused the not-yet-dismissed
|
||||
text window to hang
|
||||
Qt: if player's run-time options specified a tiles file and it couldn't be
|
||||
loaded, Qt was falling back to x11tiles just like when the default
|
||||
can't be loaded; fallback to player's file plus explicit path instead
|
||||
Qt: {maybe just Qt+OSX:} when viewing a text window ('V' to look at 'history'
|
||||
for instance), clicking on [Search], entering a search target in the
|
||||
resulting popup and clicking on [Okay] or typing <return>, the text
|
||||
|
||||
@@ -40,29 +40,46 @@ static int tilefile_tile_H=16;
|
||||
|
||||
NetHackQtGlyphs::NetHackQtGlyphs()
|
||||
{
|
||||
const char* tile_file = PIXMAPDIR "/nhtiles.bmp";
|
||||
boolean tilesok = TRUE, user_tiles = (::iflags.wc_tile_file != NULL);
|
||||
char cbuf[BUFSZ];
|
||||
const char *tile_file = NULL, *tile_list[2];
|
||||
|
||||
if (iflags.wc_tile_file)
|
||||
tile_file = iflags.wc_tile_file;
|
||||
tiles_per_row = TILES_PER_ROW;
|
||||
|
||||
if (!img.load(tile_file)) {
|
||||
tiles_per_row = TILES_PER_ROW;
|
||||
|
||||
tile_file = PIXMAPDIR "/x11tiles";
|
||||
if (!img.load(tile_file)) {
|
||||
QString msg = QString::asprintf("Cannot load 'nhtiles.bmp' or 'x11tiles'.");
|
||||
QMessageBox::warning(0, "IO Error", msg);
|
||||
iflags.wc_ascii_map = 1;
|
||||
iflags.wc_tiled_map = 0;
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (user_tiles) {
|
||||
tile_list[0] = ::iflags.wc_tile_file;
|
||||
Snprintf(cbuf, sizeof cbuf, "%s/%s", PIXMAPDIR, tile_list[0]);
|
||||
tile_list[1] = cbuf;
|
||||
} else {
|
||||
tiles_per_row = 40;
|
||||
tile_list[0] = PIXMAPDIR "/nhtiles.bmp";
|
||||
tile_list[1] = PIXMAPDIR "/x11tiles";
|
||||
}
|
||||
|
||||
if (img.load(tile_list[0]))
|
||||
tile_file = tile_list[0];
|
||||
else if (img.load(tile_list[1]))
|
||||
tile_file = tile_list[1];
|
||||
|
||||
if (!tile_file) {
|
||||
tilesok = FALSE;
|
||||
QString msg = QString::asprintf("Cannot load '%s'.",
|
||||
user_tiles ? tile_list[0]
|
||||
// mismatched quotes match format
|
||||
: "nhtiles.bmp' or 'x11tiles");
|
||||
QMessageBox::warning(0, "IO Error", msg);
|
||||
} else {
|
||||
if (img.width() % tiles_per_row) {
|
||||
tilesok = FALSE;
|
||||
impossible(
|
||||
"Tile file \"%s\" has %d columns, not multiple of row count (%d)",
|
||||
tile_file, img.width(), tiles_per_row);
|
||||
}
|
||||
}
|
||||
|
||||
if (!tilesok) {
|
||||
::iflags.wc_ascii_map = 1;
|
||||
::iflags.wc_tiled_map = 0;
|
||||
tiles_per_row = 40; // arbitrary
|
||||
}
|
||||
|
||||
if (iflags.wc_tile_width)
|
||||
|
||||
Reference in New Issue
Block a user