Merge branch 'qt-utf16' of https://github.com/chasonr/NetHack into NetHack-3.7

This commit is contained in:
nhmall
2023-06-05 00:37:23 -04:00
3 changed files with 14 additions and 10 deletions

View File

@@ -145,7 +145,9 @@ ifdef WANT_WIN_QT
WINCFLAGS += -DQT_GRAPHICS
WINSRC += $(WINQTSRC)
WINOBJ0 += $(WINQTOBJ)
ifndef WANT_WIN_QT4
SNDCFLAGS += -DSND_LIB_QTSOUND
endif #! WANT_WIN_QT4
HAVE_SNDLIB = 1
NEEDS_SND_USERSOUNDS = 1
NEEDS_SND_SEAUTOMAP = 1

View File

@@ -1043,7 +1043,7 @@ boolean NetHackQtBind::msgs_initd = false;
static void Qt_positionbar(char *) {}
#endif
#if defined(SND_LIB_QTSOUND) && !defined(NO_QT_SOUND)
#if defined(SND_LIB_QTSOUND) && !defined(QT_NO_SOUND)
void NetHackQtBind::qtsound_init_nhsound(void)
{
}
@@ -1069,15 +1069,11 @@ void NetHackQtBind::qtsound_ambience(int32_t ambienceid UNUSED, int32_t ambience
void NetHackQtBind::qtsound_verbal(char *text UNUSED, int32_t gender UNUSED, int32_t tone UNUSED, int32_t vol UNUSED, int32_t moreinfo UNUSED)
{
}
#endif
#if defined(USER_SOUNDS) && !defined(QT_NO_SOUND)
QSoundEffect *effect = NULL;
#endif
void NetHackQtBind::qtsound_play_usersound(char *filename, int32_t volume, int32_t idx UNUSED)
{
#if defined(USER_SOUNDS) && !defined(QT_NO_SOUND)
if (!effect)
effect = new QSoundEffect(nethack_qt_::NetHackQtBind::mainWidget());
if (effect) {
@@ -1086,11 +1082,8 @@ void NetHackQtBind::qtsound_play_usersound(char *filename, int32_t volume, int32
effect->setSource(QUrl::fromLocalFile(filename));
effect->play();
}
#else
nhUse(filename);
nhUse(volume);
#endif
}
#endif
} // namespace nethack_qt_

View File

@@ -211,8 +211,17 @@ void NetHackQtMapViewport::paintEvent(QPaintEvent* event)
painter.setPen(Qt::green);
#endif
if (!DrawWalls(painter, i * gW, j * gH, gW, gH, ch)) {
ushort utf16[3];
if (ch < 0x10000) {
utf16[0] = static_cast<ushort>(ch);
utf16[1] = 0;
} else {
utf16[0] = static_cast<ushort>((ch >> 10) + 0xD7C0);
utf16[1] = static_cast<ushort>((ch & 0x3FF) + 0xDC00);
utf16[2] = 0;
}
painter.drawText(i * gW, j * gH, gW, gH, Qt::AlignCenter,
QString(QChar(ch)).left(1));
QString::fromUtf16(utf16));
}
if ((special & MG_PET) != 0 && ::iflags.hilite_pet) {
painter.drawPixmap(QPoint(i * gW, j * gH),