From 37ce6f72b39fa9647b76033a526e01b0f4c5b39d Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 2 Jan 2022 01:48:07 -0800 Subject: [PATCH] Qt without tiles 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 | 8 +++++++- win/Qt/qt_glyph.h | 2 ++ win/Qt/qt_inv.cpp | 5 +++-- win/Qt/qt_set.cpp | 25 ++++++++++++++++++------- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/win/Qt/qt_glyph.cpp b/win/Qt/qt_glyph.cpp index 06647638d..75bc234d9 100644 --- a/win/Qt/qt_glyph.cpp +++ b/win/Qt/qt_glyph.cpp @@ -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) diff --git a/win/Qt/qt_glyph.h b/win/Qt/qt_glyph.h index 2842d2d14..c00a11214 100644 --- a/win/Qt/qt_glyph.h +++ b/win/Qt/qt_glyph.h @@ -16,6 +16,8 @@ enum border_code { class NetHackQtGlyphs { public: + bool no_tiles; + NetHackQtGlyphs(); int width() const { return size.width(); } diff --git a/win/Qt/qt_inv.cpp b/win/Qt/qt_inv.cpp index 50f17f47c..53a32ac70 100644 --- a/win/Qt/qt_inv.cpp +++ b/win/Qt/qt_inv.cpp @@ -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 diff --git a/win/Qt/qt_set.cpp b/win/Qt/qt_set.cpp index 2f6655417..4703839f5 100644 --- a/win/Qt/qt_set.cpp +++ b/win/Qt/qt_set.cpp @@ -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"); -- 2.49.0