Merge branch 'NetHack-3.6.2'
This commit is contained in:
1
win/Qt4/.gitignore
vendored
Normal file
1
win/Qt4/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.moc
|
||||
@@ -18,7 +18,7 @@ extern "C" {
|
||||
#undef max
|
||||
|
||||
#include <QtGui/QtGui>
|
||||
#include <QStringList>
|
||||
#include <QtCore/QStringList>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QtWidgets/QtWidgets>
|
||||
#include <QtMultimedia/QSound>
|
||||
@@ -350,9 +350,9 @@ void NetHackQtBind::qt_display_file(const char *filename, BOOLEAN_P must_exist)
|
||||
complain = must_exist;
|
||||
} else {
|
||||
while (dlb_fgets(buf, BUFSZ, f)) {
|
||||
if ((cr = index(buf, '\n')) != 0) *cr = 0;
|
||||
if ((cr = strchr(buf, '\n')) != 0) *cr = 0;
|
||||
#ifdef MSDOS
|
||||
if ((cr = index(buf, '\r')) != 0) *cr = 0;
|
||||
if ((cr = strchr(buf, '\r')) != 0) *cr = 0;
|
||||
#endif
|
||||
window->PutStr(ATR_NONE, tabexpand(buf));
|
||||
}
|
||||
@@ -508,8 +508,8 @@ char NetHackQtBind::qt_yn_function(const char *question_, const char *choices, C
|
||||
message = QString("%1 [%2] ").arg(question, choicebuf);
|
||||
if (def) message += QString("(%1) ").arg(QChar(def));
|
||||
// escape maps to 'q' or 'n' or default, in that order
|
||||
yn_esc_map = (index(choices, 'q') ? 'q' :
|
||||
(index(choices, 'n') ? 'n' : def));
|
||||
yn_esc_map = (strchr(choices, 'q') ? 'q' :
|
||||
(strchr(choices, 'n') ? 'n' : def));
|
||||
} else {
|
||||
message = question;
|
||||
}
|
||||
@@ -542,7 +542,7 @@ char NetHackQtBind::qt_yn_function(const char *question_, const char *choices, C
|
||||
char ch=NetHackQtBind::qt_nhgetch();
|
||||
if (ch=='\033') {
|
||||
result=yn_esc_map;
|
||||
} else if (choices && !index(choices,ch)) {
|
||||
} else if (choices && !strchr(choices,ch)) {
|
||||
if (def && (ch==' ' || ch=='\r' || ch=='\n')) {
|
||||
result=def;
|
||||
} else {
|
||||
@@ -565,6 +565,8 @@ char NetHackQtBind::qt_yn_function(const char *question_, const char *choices, C
|
||||
else if (def)
|
||||
message += QString(" %1").arg(def);
|
||||
NetHackQtBind::qt_putstr(WIN_MESSAGE, ATR_BOLD, message);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -798,6 +800,7 @@ struct window_procs Qt_procs = {
|
||||
genl_can_suspend_yes,
|
||||
};
|
||||
|
||||
#ifndef WIN32
|
||||
extern "C" void play_usersound(const char* filename, int volume)
|
||||
{
|
||||
#ifdef USER_SOUNDS
|
||||
@@ -806,3 +809,4 @@ extern "C" void play_usersound(const char* filename, int volume)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -66,6 +66,7 @@ NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(QWidget *parent) :
|
||||
pb->setMinimumSize(butw,pb->sizeHint().height());
|
||||
group->addButton(pb, i+1);
|
||||
gl->addWidget(pb,i/ncols,i%ncols);
|
||||
buttons.append(pb);
|
||||
}
|
||||
group->addButton(can, 0);
|
||||
connect(group,SIGNAL(buttonPressed(int)),this,SLOT(done(int)));
|
||||
@@ -92,6 +93,7 @@ void NetHackQtExtCmdRequestor::keyPressEvent(QKeyEvent *event)
|
||||
QString promptstr = prompt->text();
|
||||
if (promptstr != "#")
|
||||
prompt->setText(promptstr.left(promptstr.size()-1));
|
||||
enableButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -111,6 +113,7 @@ void NetHackQtExtCmdRequestor::keyPressEvent(QKeyEvent *event)
|
||||
done(match+1);
|
||||
else if (matches >= 2)
|
||||
prompt->setText(promptstr);
|
||||
enableButtons();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,4 +134,15 @@ int NetHackQtExtCmdRequestor::get()
|
||||
return result()-1;
|
||||
}
|
||||
|
||||
// Enable only buttons that match the current prompt string
|
||||
void NetHackQtExtCmdRequestor::enableButtons()
|
||||
{
|
||||
QString typedstr = prompt->text().mid(1); // skip the '#'
|
||||
std::size_t len = typedstr.size();
|
||||
|
||||
for (auto b = buttons.begin(); b != buttons.end(); ++b) {
|
||||
(*b)->setVisible((*b)->text().left(len) == typedstr);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace nethack_qt4
|
||||
|
||||
@@ -21,6 +21,8 @@ public:
|
||||
|
||||
private:
|
||||
QLabel *prompt;
|
||||
QVector<QPushButton *> buttons;
|
||||
void enableButtons();
|
||||
|
||||
private slots:
|
||||
void cancel();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 mhstatus.c $NHDT-Date: 1432512810 2015/05/25 00:13:30 $ $NHDT-Branch: master $:$NHDT-Revision: 1.22 $ */
|
||||
/* NetHack 3.6 mhstatus.c $NHDT-Date: 1536411224 2018/09/08 12:53:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.29 $ */
|
||||
/* Copyright (C) 2001 by Alex Kompel */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -324,7 +324,7 @@ onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
LONG left = rt.left;
|
||||
LONG cy = 0;
|
||||
int vlen;
|
||||
for (f = *fop; *f != -1; f++) {
|
||||
for (f = *fop; *f != BL_FLUSH; f++) {
|
||||
int clr, atr;
|
||||
int fntatr = ATR_NONE;
|
||||
HGDIOBJ fnt;
|
||||
@@ -362,7 +362,8 @@ onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
SelectObject(hdc, fnt);
|
||||
SetBkMode(hdc, OPAQUE);
|
||||
SetBkColor(hdc, status_bg_color);
|
||||
SetTextColor(hdc, nhcolor_to_RGB(hpbar_color));
|
||||
/* SetTextColor(hdc, nhcolor_to_RGB(hpbar_color)); */
|
||||
SetTextColor(hdc, status_fg_color);
|
||||
|
||||
/* get bounding rectangle */
|
||||
GetTextExtentPoint32(hdc, wbuf, vlen, &sz);
|
||||
@@ -370,21 +371,22 @@ onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
/* first draw title normally */
|
||||
DrawText(hdc, wbuf, vlen, &rt, DT_LEFT);
|
||||
|
||||
/* calc bar length */
|
||||
barrect.left = rt.left;
|
||||
barrect.top = rt.top;
|
||||
barrect.bottom = sz.cy;
|
||||
if (hpbar_percent > 0)
|
||||
barrect.right = (int)((hpbar_percent * sz.cx) / 100);
|
||||
else
|
||||
barrect.right = sz.cx;
|
||||
|
||||
/* then draw hpbar on top of title */
|
||||
FillRect(hdc, &barrect, back_brush);
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
SetTextColor(hdc, nBg);
|
||||
DrawText(hdc, wbuf, vlen, &barrect, DT_LEFT);
|
||||
if (hpbar_percent > 0) {
|
||||
/* calc bar length */
|
||||
barrect.left = rt.left;
|
||||
barrect.top = rt.top;
|
||||
barrect.bottom = sz.cy;
|
||||
if (hpbar_percent > 0)
|
||||
barrect.right = (int)((hpbar_percent * sz.cx) / 100);
|
||||
/* else
|
||||
barrect.right = sz.cx; */
|
||||
|
||||
/* then draw hpbar on top of title */
|
||||
FillRect(hdc, &barrect, back_brush);
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
SetTextColor(hdc, nBg);
|
||||
DrawText(hdc, wbuf, vlen, &barrect, DT_LEFT);
|
||||
}
|
||||
DeleteObject(back_brush);
|
||||
} else {
|
||||
if (atr & HL_INVERSE) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 mswproc.c $NHDT-Date: 1451611595 2016/01/01 01:26:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.98 $ */
|
||||
/* NetHack 3.6 mswproc.c $NHDT-Date: 1536411259 2018/09/08 12:54:19 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.118 $ */
|
||||
/* Copyright (C) 2001 by Alex Kompel */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -2899,10 +2899,21 @@ mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color,
|
||||
int ocolor, ochar;
|
||||
unsigned ospecial;
|
||||
long value = -1;
|
||||
boolean reset_state = FALSE;
|
||||
|
||||
logDebug("mswin_status_update(%d, %p, %d, %d, %x, %p)\n", idx, ptr, chg, percent, color, colormasks);
|
||||
|
||||
if (idx != BL_FLUSH && idx != BL_RESET) {
|
||||
switch (idx) {
|
||||
case BL_RESET:
|
||||
reset_state = TRUE;
|
||||
/* FALLTHRU */
|
||||
case BL_FLUSH:
|
||||
/* FALLTHRU */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (idx >= 0) {
|
||||
if (!_status_activefields[idx])
|
||||
return;
|
||||
_status_percents[idx] = percent;
|
||||
@@ -2965,18 +2976,18 @@ mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color,
|
||||
text);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
_status_colors[idx] = color;
|
||||
_status_colors[idx] = color;
|
||||
|
||||
/* send command to status window */
|
||||
ZeroMemory(&update_cmd_data, sizeof(update_cmd_data));
|
||||
update_cmd_data.n_fields = MAXBLSTATS;
|
||||
update_cmd_data.vals = _status_vals;
|
||||
update_cmd_data.activefields = _status_activefields;
|
||||
update_cmd_data.percents = _status_percents;
|
||||
update_cmd_data.colors = _status_colors;
|
||||
SendMessage(mswin_hwnd_from_winid(WIN_STATUS), WM_MSNH_COMMAND,
|
||||
/* send command to status window */
|
||||
ZeroMemory(&update_cmd_data, sizeof(update_cmd_data));
|
||||
update_cmd_data.n_fields = MAXBLSTATS;
|
||||
update_cmd_data.vals = _status_vals;
|
||||
update_cmd_data.activefields = _status_activefields;
|
||||
update_cmd_data.percents = _status_percents;
|
||||
update_cmd_data.colors = _status_colors;
|
||||
SendMessage(mswin_hwnd_from_winid(WIN_STATUS), WM_MSNH_COMMAND,
|
||||
(WPARAM) MSNH_MSG_UPDATE_STATUS, (LPARAM) &update_cmd_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user