From: PatR Date: Mon, 17 Aug 2020 23:42:24 +0000 (-0700) Subject: Qt without tiles X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae4c180cf62ce4f19bd020495d6b089584b2426b;p=nethack 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. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index e465340d5..64988cf11 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.287 $ $NHDT-Date: 1597704087 2020/08/17 22:41:27 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.288 $ $NHDT-Date: 1597707740 2020/08/17 23:42:20 $ General Fixes and Modified Features ----------------------------------- @@ -349,6 +349,7 @@ curses: for vertical status, line up conditions in columns; usually two but msdos: add -DSTATUES_LOOK_LIKE_MONSTERS to Makefile1.cross so the VESA mode can display statue glyphs Qt: quit if can't load tiles file instead of continuing and then segfaulting +Qt: [later] tiles load failure at startup now continues using an ascii map Qt: use more columns for extended command selection dialog so that the number of rows needed doesn't result in some commands being unaccessible Qt: suppress wizard mode commands from '#' handling when not in wizard mode diff --git a/win/Qt/qt_glyph.cpp b/win/Qt/qt_glyph.cpp index 5554a7b3f..807b4dc7d 100644 --- a/win/Qt/qt_glyph.cpp +++ b/win/Qt/qt_glyph.cpp @@ -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 diff --git a/win/Qt/qt_inv.cpp b/win/Qt/qt_inv.cpp index 1cab0ab11..f6cc6a92e 100644 --- a/win/Qt/qt_inv.cpp +++ b/win/Qt/qt_inv.cpp @@ -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 { diff --git a/win/Qt/qt_set.cpp b/win/Qt/qt_set.cpp index fc4df1ac1..939ae89a7 100644 --- a/win/Qt/qt_set.cpp +++ b/win/Qt/qt_set.cpp @@ -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()