]> granicus.if.org Git - nethack/commitdiff
Qt without tiles
authorPatR <rankin@nethack.org>
Sun, 2 Jan 2022 09:48:07 +0000 (01:48 -0800)
committerPatR <rankin@nethack.org>
Sun, 2 Jan 2022 09:48:07 +0000 (01:48 -0800)
When tiles fail to load, the Qt interface switches to the text map.
But it wasn't inhibiting the player from trying to switch to tiles
map.  Also, when the text map was in use it was forcing the paper
doll inventory subset to be disabled regardless of whether the map
was by choice or because tiles wouldn't load.  Allow the paper doll
in combination with the text map if tiles got loaded successfully.

win/Qt/qt_glyph.cpp
win/Qt/qt_glyph.h
win/Qt/qt_inv.cpp
win/Qt/qt_set.cpp

index 06647638d42ac527e52defebd6ef769ee1d8cfcb..75bc234d9537a20c6a2301e55df5f42901dd52bd 100644 (file)
@@ -44,6 +44,7 @@ NetHackQtGlyphs::NetHackQtGlyphs()
     char cbuf[BUFSZ];
     const char *tile_file = NULL, *tile_list[2];
 
+    this->no_tiles = false;
     tiles_per_row = TILES_PER_ROW;
 
     if (user_tiles) {
@@ -77,9 +78,14 @@ NetHackQtGlyphs::NetHackQtGlyphs()
     }
 
     if (!tilesok) {
+        this->no_tiles = true;
+        /* tiles wouldn't load so force ascii map */
         ::iflags.wc_ascii_map = 1;
         ::iflags.wc_tiled_map = 0;
-        tiles_per_row = 40; // arbitrary
+        /* tiles wouldn't load so don't allow toggling to tiled map */
+        ::set_wc_option_mod_status(WC_ASCII_MAP | WC_TILED_MAP,
+                                   ::set_in_config);
+        tiles_per_row = 40; // arbitrary to avoid potential divide-by-0
     }
 
     if (iflags.wc_tile_width)
index 2842d2d14f23d4abc543148e239c11aa9138850e..c00a112148382588173443770ca52a8e0e3eb56d 100644 (file)
@@ -16,6 +16,8 @@ enum border_code {
 
 class NetHackQtGlyphs {
 public:
+        bool no_tiles;
+
        NetHackQtGlyphs();
 
        int width() const { return size.width(); }
index 50f17f47c7dc3e6f9935e3f83d39f1740149a29b..53a32ac704fc18357702ccfa7f0ab4eaf198d951 100644 (file)
@@ -176,7 +176,8 @@ void NetHackQtInvUsageWindow::paintEvent(QPaintEvent*)
     // Actually indexed by grid[column][row].
 
 #ifdef ENHANCED_PAPERDOLL
-    if (iflags.wc_ascii_map)
+    if (qt_settings->doll_is_shown && ::iflags.wc_ascii_map
+        && qt_settings->glyphs().no_tiles)
         qt_settings->doll_is_shown = false;
     if (!qt_settings->doll_is_shown)
         return;
@@ -185,7 +186,7 @@ void NetHackQtInvUsageWindow::paintEvent(QPaintEvent*)
                                   qt_settings->dollHeight);
 
     /* for drawWorn()'s use of obj->invlet */
-    if (!flags.invlet_constant)
+    if (!::flags.invlet_constant)
         reassign();
 #endif
 
index 2f665541756f909ab65e113a79f641bcc0c6ef14..4703839f5641dbcb9ca7ce6457ea598b0a26999d 100644 (file)
@@ -136,17 +136,28 @@ NetHackQtSettings::NetHackQtSettings() :
     }
 
     theglyphs=new NetHackQtGlyphs();
-    resizeTiles();
+    if (!theglyphs->no_tiles) {
+        resizeTiles();
 
-    connect(&whichsize, SIGNAL(toggled(bool)), this, SLOT(setGlyphSize(bool)));
-    connect(&tilewidth, SIGNAL(valueChanged(int)), this, SLOT(resizeTiles()));
-    connect(&tileheight, SIGNAL(valueChanged(int)), this, SLOT(resizeTiles()));
+        connect(&whichsize, SIGNAL(toggled(bool)), this,
+                SLOT(setGlyphSize(bool)));
+        connect(&tilewidth, SIGNAL(valueChanged(int)), this,
+                SLOT(resizeTiles()));
+        connect(&tileheight, SIGNAL(valueChanged(int)), this,
+                SLOT(resizeTiles()));
 
 #ifdef ENHANCED_PAPERDOLL
-    connect(&dollshown, SIGNAL(toggled(bool)), this, SLOT(setDollShown(bool)));
-    connect(&dollwidth, SIGNAL(valueChanged(int)), this, SLOT(resizeDoll()));
-    connect(&dollheight, SIGNAL(valueChanged(int)), this, SLOT(resizeDoll()));
+        connect(&dollshown, SIGNAL(toggled(bool)), this,
+                SLOT(setDollShown(bool)));
+        connect(&dollwidth, SIGNAL(valueChanged(int)), this,
+                SLOT(resizeDoll()));
+        connect(&dollheight, SIGNAL(valueChanged(int)), this,
+                SLOT(resizeDoll()));
 #endif
+    } else {
+        // paper doll requires map tiles and those just failed to load
+        doll_is_shown = false;
+    }
 
     fontsize.setMinimumContentsLength((int) strlen("Medium"));
     fontsize.addItem("Huge");