Merge branch 'NetHack-3.7' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.7

This commit is contained in:
nhmall
2020-08-02 23:04:56 -04:00
2 changed files with 51 additions and 19 deletions
+33 -12
View File
@@ -1,4 +1,4 @@
// NetHack 3.6 qt_win.cpp $NHDT-Date: 1575917720 2019/12/09 18:55:20 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.0 $ // NetHack 3.6 qt_win.cpp $NHDT-Date: 1596404695 2020/08/02 21:44:55 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.91 $
// Copyright (c) Warwick Allison, 1999. // Copyright (c) Warwick Allison, 1999.
// NetHack may be freely redistributed. See license for details. // NetHack may be freely redistributed. See license for details.
@@ -146,23 +146,44 @@ static const char nh_attribution[] = "<center><big>NetHack</big>"
static QString static QString
aboutMsg() aboutMsg()
{ {
char vbuf[BUFSZ];
QString msg; QString msg;
msg.sprintf( msg.sprintf(
"Qt NetHack is a version of NetHack built\n" // format
"Qt NetHack is a version of NetHack\n"
"built using" // no newline
#ifdef KDE #ifdef KDE
"using KDE and the Qt GUI toolkit.\n" " KDE and" // ditto
#endif
" the Qt %d GUI toolkit.\n"
"\nThis is NetHack %s%s.\n"
"\nNetHack's Qt interface originally developed by Warwick Allison.\n"
"\n"
#if 0
"Homepage:\n http://trolls.troll.no/warwick/nethack/\n" //obsolete
#endif
#ifdef KDE
"KDE:\n https://kde.org/\n"
#endif
#if 1
"Qt:\n https://qt.io/\n"
#else #else
"using the Qt GUI toolkit.\n" "Qt:\n http://www.troll.no/\n" // obsolete
#endif #endif
"This is version %d.%d.%d\n\n" "NetHack:\n %s\n",
"Homepage:\n http://trolls.troll.no/warwick/nethack/\n\n" // arguments
#ifdef KDE #ifdef QT_VERSION_MAJOR
"KDE:\n http://www.kde.org\n" QT_VERSION_MAJOR,
#else
3, // Qt version macro should exist; if not, assume Qt3
#endif #endif
"Qt:\n http://www.troll.no", version_string(vbuf), /* nethack version */
VERSION_MAJOR, #ifdef QT_VERSION_STR
VERSION_MINOR, " with Qt " QT_VERSION_STR,
PATCHLEVEL); #else
"",
#endif
DEVTEAM_URL);
return msg; return msg;
} }
+18 -7
View File
@@ -91,6 +91,11 @@ NetHackQtMenuWindow::NetHackQtMenuWindow(QWidget *parent) :
prompt(0), prompt(0),
counting(false) counting(false)
{ {
// setFont() was in SelectMenu(), in time to be rendered but too late
// when measuring the width and height that will be needed
QFont tablefont(qt_settings->normalFixedFont());
table->setFont(tablefont);
QGridLayout *grid = new QGridLayout(); QGridLayout *grid = new QGridLayout();
table->setColumnCount(5); table->setColumnCount(5);
table->setFrameStyle(QFrame::Panel|QFrame::Sunken); table->setFrameStyle(QFrame::Panel|QFrame::Sunken);
@@ -134,7 +139,8 @@ NetHackQtMenuWindow::NetHackQtMenuWindow(QWidget *parent) :
grid->setRowStretch(2, 1); grid->setRowStretch(2, 1);
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
table->setFocusPolicy(Qt::NoFocus); table->setFocusPolicy(Qt::NoFocus);
connect(table, SIGNAL(cellClicked(int,int)), this, SLOT(cellToggleSelect(int,int))); connect(table, SIGNAL(cellClicked(int,int)),
this, SLOT(cellToggleSelect(int,int)));
setLayout(grid); setLayout(grid);
} }
@@ -214,9 +220,6 @@ void NetHackQtMenuWindow::EndMenu(const QString& p)
int NetHackQtMenuWindow::SelectMenu(int h, MENU_ITEM_P **menu_list) int NetHackQtMenuWindow::SelectMenu(int h, MENU_ITEM_P **menu_list)
{ {
QFont tablefont(qt_settings->normalFixedFont());
table->setFont(tablefont);
table->setRowCount(itemcount); table->setRowCount(itemcount);
how=h; how=h;
@@ -243,10 +246,18 @@ int NetHackQtMenuWindow::SelectMenu(int h, MENU_ITEM_P **menu_list)
std::vector<int> col_widths; std::vector<int> col_widths;
for (std::size_t i = 0; i < (size_t) itemlist.size(); ++i) { for (std::size_t i = 0; i < (size_t) itemlist.size(); ++i) {
QStringList columns = itemlist[i].str.split("\t"); QStringList columns = itemlist[i].str.split("\t");
if (!itemlist[i].Selectable() && columns.size() == 1) if (!itemlist[i].Selectable() && columns.size() == 1) {
{ // Nonselectable line with no column dividers.
// Nonselectable line with no column dividers
// Assume this is a section header // Assume this is a section header
// or ordinary text (^X feedback, for instance) rendered in
// a menu because tty's paginated menus can be used to go
// backward, unlike text windows which can only go forward.
QTableWidgetItem *twi = table->item(i, 4);
if (twi) {
QString text = twi->text();
#define MENU_WIDTH_SLOP 20 /* this should not be necessary */
WidenColumn(4, fm.width(text) + MENU_WIDTH_SLOP);
}
continue; continue;
} }
for (std::size_t j = 0U; j < (size_t) columns.size(); ++j) { for (std::size_t j = 0U; j < (size_t) columns.size(); ++j) {