extern int warning_of(struct monst *);
extern void map_glyphinfo(xchar, xchar, int, unsigned, glyph_info *);
extern void reset_glyphmap(enum glyphmap_change_triggers trigger);
+extern int fn_cmap_to_glyph(int);
/* ### do.c ### */
return idx;
}
+/*
+ * c++ 20 has problems with some of the display.h macros because
+ * comparisons and bit-fiddling and math between different enums
+ * is deprecated.
+ * Create function versions of some of the macros used in some
+ * NetHack c++ source files (Qt) for use there.
+ */
+int
+fn_cmap_to_glyph(int cmap)
+{
+ return cmap_to_glyph(cmap);
+}
/*display.c*/
if (qt_compact_mode) {
splash->showMaximized();
} else {
+#if __cplusplus >= 202002L
+ splash->setFrameStyle(static_cast<int>(QFrame::WinPanel)
+ | static_cast<int>(QFrame::Raised));
+#else
splash->setFrameStyle(QFrame::WinPanel | QFrame::Raised);
+#endif
splash->setLineWidth(10);
splash->adjustSize();
splash->show();
nhUse(alttip);
#endif
// an empty slot is shown as floor tile unless it's always empty
- glyph = canbe ? cmap_to_glyph(S_room) : GLYPH_UNEXPLORED;
+ glyph = canbe ? fn_cmap_to_glyph(S_room) : GLYPH_UNEXPLORED;
}
map_glyphinfo(0, 0, glyph, 0, &gi); /* this skirts the defined
* interface unfortunately */
QGridLayout *grid = new QGridLayout();
table->setColumnCount(5);
+#if __cplusplus >= 202002L
+ table->setFrameStyle(static_cast<int>(QFrame::Panel)
+ | static_cast<int>(QFrame::Raised));
+#else
table->setFrameStyle(QFrame::Panel|QFrame::Sunken);
+#endif
table->setLineWidth(2); // note: this is not row spacing
table->setShowGrid(false);
table->horizontalHeader()->hide();
char buf[BUFSZ];
char *dpx;
- int line, snpres;
+ int line;
/* Put name on stone */
(void) snprintf(rip_line[NAME_LINE], STONE_LINE_LEN + 1,
long cash = std::max(g.done_money, 0L);
/* force less that 10 digits to satisfy elaborate format checking;
it's arbitrary but still way, way more than could ever be needed */
+ if (cash < 0)
+ cash = 0;
if (cash > 999999999L)
cash = 999999999L;
- snpres = snprintf(rip_line[GOLD_LINE], STONE_LINE_LEN + 1, "%ld Au", cash);
- nhUse(snpres);
+ (void) snprintf(rip_line[GOLD_LINE], STONE_LINE_LEN + 1, "%ld Au", cash);
+
/* Put together death description */
formatkiller(buf, sizeof buf, how, FALSE);
//str_copy(buf, killer, SIZE(buf));
* #include after <Qt.../Qt...>.
*/
+#if defined(__cplusplus)
#ifdef __clang__
#pragma clang diagnostic pop
-#elif defined(__GNUC__) && defined(__cplusplus)
+#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif /* compiler-specific bits */
+#endif /* __cplusplus */
/*qt_post.h*/
#undef min
#undef max
+#if defined(__cplusplus)
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#endif
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#endif
+/* the diagnostic pop is in qt_post.h */
+
+#ifdef __clang__
/* disable warnings for shadowed names; some of the Qt prototypes use
placeholder argument names which conflict with nethack variables
('g', 'u', a couple of others) */
-#ifdef __clang__
-#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshadow"
-#elif defined(__GNUC__) && defined(__cplusplus)
-#pragma GCC diagnostic push
+#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#define QFM_WIDTH(foo) horizontalAdvance(foo)
#endif
+#if __cplusplus >= 202002L
+/* c++20 or newer */
+#if QT_VERSION < 0x060000
+/*
+ * qt5/QtWidgets/qsizepolicy.h
+ * Qt5 header file issue under c++ 20
+ *
+ * warning: bitwise operation between different enumeration types
+ * ‘QSizePolicy::Policy’ and ‘QSizePolicy::PolicyFlag’
+ * is deprecated [-Wdeprecated-enum-enum-conversion]
+ */
+#if defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion"
+#endif
+#if defined(__clang__)
+#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"
+#endif
+#endif /* QT_VERSION < 0x060000 */
+#endif /* __cplusplus >= 202002L */
+#endif /* __cplusplus */
+
/*qt_pre.h*/
painter.begin(this);
painter.drawPixmap(pix_x,pix_y,*pixmap);
for (int i=0; i<riplines; i++) {
- painter.drawText(rip_text_x-i/2,rip_text_y+i*rip_text_h,
- 1,1,Qt::TextDontClip|Qt::AlignHCenter,line[i]);
+ painter.drawText(rip_text_x-i/2,rip_text_y+i*rip_text_h, 1,1,
+#if __cplusplus >= 202002L
+ static_cast<int>(Qt::TextDontClip)
+ | static_cast<int>(Qt::AlignHCenter),
+#else
+ Qt::TextDontClip|Qt::AlignHCenter,
+#endif
+ line[i]);
}
painter.end();
}
ride.setIcon(p_ride, "riding");
// separator lines
+#if __cplusplus >= 202002L
+ hline1.setFrameStyle(static_cast<int>(QFrame::HLine)
+ | static_cast<int>(QFrame::Sunken));
+ hline2.setFrameStyle(static_cast<int>(QFrame::HLine)
+ | static_cast<int>(QFrame::Sunken));
+ hline3.setFrameStyle(static_cast<int>(QFrame::HLine)
+ | static_cast<int>(QFrame::Sunken));
+#else
hline1.setFrameStyle(QFrame::HLine | QFrame::Sunken);
hline2.setFrameStyle(QFrame::HLine | QFrame::Sunken);
hline3.setFrameStyle(QFrame::HLine | QFrame::Sunken);
+#endif
hline1.setLineWidth(1);
hline2.setLineWidth(1);
hline3.setLineWidth(1);
// vertical separators for condensed layout (statuslines:2)
+#if __cplusplus >= 202002L
+ vline1.setFrameStyle(static_cast<int>(QFrame::VLine)
+ | static_cast<int>(QFrame::Sunken));
+ vline2.setFrameStyle(static_cast<int>(QFrame::VLine)
+ | static_cast<int>(QFrame::Sunken));
+#else
vline1.setFrameStyle(QFrame::VLine | QFrame::Sunken);
vline2.setFrameStyle(QFrame::VLine | QFrame::Sunken);
+#endif
vline1.setLineWidth(1); // separates Alignment from Charisma
vline2.setLineWidth(1);
vline2.hide(); // padding to keep row 2 aligned with row 1, never shown
} else {
QLabel label(qlabel,this);
QPushButton cancel("Dismiss",this);
+#if __cplusplus >= 202002L
+ label.setFrameStyle(static_cast<int>(QFrame::Box)
+ | static_cast<int>(QFrame::Sunken));
+#else
label.setFrameStyle(QFrame::Box|QFrame::Sunken);
+#endif
label.setAlignment(Qt::AlignCenter);
label.resize(fontMetrics().QFM_WIDTH(qlabel)+60,30+fontMetrics().height());
cancel.move(width()/2-cancel.width()/2,label.geometry().bottom()+8);