]> granicus.if.org Git - nethack/commitdiff
Qt without tiles
authorPatR <rankin@nethack.org>
Mon, 17 Aug 2020 23:42:24 +0000 (16:42 -0700)
committerPatR <rankin@nethack.org>
Mon, 17 Aug 2020 23:42:24 +0000 (16:42 -0700)
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.

doc/fixes37.0
win/Qt/qt_glyph.cpp
win/Qt/qt_inv.cpp
win/Qt/qt_set.cpp

index e465340d574947bb7f046bcc4718b1da583d6762..64988cf116ee482037d3c956619642d40ed5bdee 100644 (file)
@@ -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
index 5554a7b3fc1ba38e59bfec5be700e14ac864087f..807b4dc7d769d2642fb1c6bb3e09c11db7625f2d 100644 (file)
@@ -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
index 1cab0ab11deb7fcca83569f50a336e7fa09fe2fa..f6cc6a92efb77f8f4f3a6c2d669d31ea6fee40d7 100644 (file)
@@ -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 {
index fc4df1ac1083513292266af297f287c1f7fbd96c..939ae89a78721b9290563c10ef11071310b1ff8f 100644 (file)
@@ -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()