Qt without tiles
Qt is capable of using an ascii map, and does so on the rogue level. So failing to load tiles doesn't need to quit; it can continue in text mode. Not extensively tested. This disables the paper doll when the ascii map is forced (either via options settings or due to tiles loading failure, but not when simply on the rogue level) rather than trying to display it with object class characters.
This commit is contained in:
+7
-5
@@ -46,16 +46,15 @@ NetHackQtGlyphs::NetHackQtGlyphs()
|
||||
tile_file = iflags.wc_tile_file;
|
||||
|
||||
if (!img.load(tile_file)) {
|
||||
tiles_per_row = TILES_PER_ROW;
|
||||
|
||||
tile_file = PIXMAPDIR "/x11tiles";
|
||||
if (!img.load(tile_file)) {
|
||||
QString msg;
|
||||
|
||||
msg.sprintf("Cannot load 'nhtiles.bmp' or 'x11tiles'.");
|
||||
QMessageBox::warning(0, "IO Error", msg);
|
||||
NetHackQtBind::qt_exit_nhwindows((const char *) 0);
|
||||
nh_terminate(EXIT_FAILURE);
|
||||
iflags.wc_ascii_map = 1;
|
||||
iflags.wc_tiled_map = 0;
|
||||
} else {
|
||||
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)",
|
||||
@@ -68,8 +67,11 @@ NetHackQtGlyphs::NetHackQtGlyphs()
|
||||
|
||||
if (iflags.wc_tile_width)
|
||||
tilefile_tile_W = iflags.wc_tile_width;
|
||||
else if (iflags.wc_ascii_map)
|
||||
tilefile_tile_W = 16;
|
||||
else
|
||||
tilefile_tile_W = img.width() / tiles_per_row;
|
||||
|
||||
if (iflags.wc_tile_height)
|
||||
tilefile_tile_H = iflags.wc_tile_height;
|
||||
else
|
||||
|
||||
+8
-2
@@ -85,6 +85,8 @@ void NetHackQtInvUsageWindow::paintEvent(QPaintEvent*)
|
||||
// show leash-in-use on lower left side
|
||||
|
||||
#ifdef ENHANCED_PAPERDOLL
|
||||
if (iflags.wc_ascii_map)
|
||||
qt_settings->doll_is_shown = false;
|
||||
if (!qt_settings->doll_is_shown)
|
||||
return;
|
||||
qt_settings->glyphs().setSize(qt_settings->dollWidth,
|
||||
@@ -144,13 +146,17 @@ QSize NetHackQtInvUsageWindow::sizeHint(void) const
|
||||
// 1+X+1: one pixel border surrounding each tile in the paper doll,
|
||||
// so +1 left and +1 right, also +1 above and +1 below
|
||||
#ifdef ENHANCED_PAPERDOLL
|
||||
if (iflags.wc_ascii_map)
|
||||
qt_settings->doll_is_shown = false;
|
||||
if (qt_settings->doll_is_shown) {
|
||||
w = (1 + qt_settings->dollWidth + 1) * 3;
|
||||
h = (1 + qt_settings->dollHeight + 1) * 6;
|
||||
}
|
||||
#else
|
||||
w = (1 + qt_settings->glyphs().width() + 1) * 3;
|
||||
h = (1 + qt_settings->glyphs().height() + 1) * 6;
|
||||
if (iflags.wc_tiles_map) {
|
||||
w = (1 + qt_settings->glyphs().width() + 1) * 3;
|
||||
h = (1 + qt_settings->glyphs().height() + 1) * 6;
|
||||
}
|
||||
#endif
|
||||
return QSize(w, h);
|
||||
} else {
|
||||
|
||||
+7
-2
@@ -196,6 +196,9 @@ NetHackQtSettings::NetHackQtSettings() :
|
||||
|
||||
NetHackQtGlyphs& NetHackQtSettings::glyphs()
|
||||
{
|
||||
// Caveat:
|
||||
// 'theglyphs' will be Null if the tiles file couldn't be loaded;
|
||||
// the game can still procede with an ascii map in that situation.
|
||||
return *theglyphs;
|
||||
}
|
||||
|
||||
@@ -213,8 +216,10 @@ void NetHackQtSettings::resizeTiles()
|
||||
settings.setValue("tilewidth", tileWidth);
|
||||
settings.setValue("tileheight", tileHeight);
|
||||
|
||||
theglyphs->setSize(tileWidth, tileHeight);
|
||||
emit tilesChanged();
|
||||
if (theglyphs) {
|
||||
theglyphs->setSize(tileWidth, tileHeight);
|
||||
emit tilesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void NetHackQtSettings::toggleGlyphSize()
|
||||
|
||||
Reference in New Issue
Block a user