Qt: To play user sounds with volume, replace QSound with QSoundEffect
This commit is contained in:
@@ -1360,6 +1360,7 @@ Qt: during role/race/&c selection, update role titles with their icons, and
|
|||||||
Qt: if a menu of objects contains at least one iron ball, and player is not
|
Qt: if a menu of objects contains at least one iron ball, and player is not
|
||||||
alreadly in the midst of entering a count, recognize '0' as a group
|
alreadly in the midst of entering a count, recognize '0' as a group
|
||||||
accelerator rather than the start of a count
|
accelerator rather than the start of a count
|
||||||
|
Qt: to play user sounds with volume, replace QSound with QSoundEffect
|
||||||
Qt: {maybe just Qt+OSX:} when viewing a text window ('V' to look at 'history'
|
Qt: {maybe just Qt+OSX:} when viewing a text window ('V' to look at 'history'
|
||||||
for instance), clicking on [Search], entering a search target in the
|
for instance), clicking on [Search], entering a search target in the
|
||||||
resulting popup and clicking on [Okay] or typing <return>, the text
|
resulting popup and clicking on [Okay] or typing <return>, the text
|
||||||
|
|||||||
+14
-4
@@ -12,10 +12,10 @@ extern "C" {
|
|||||||
#include <QtGui/QtGui>
|
#include <QtGui/QtGui>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
#if QT_VERSION < 0x050000
|
#if QT_VERSION < 0x050000
|
||||||
#include <QtGui/QSound>
|
#include <QtGui/QSoundEffect>
|
||||||
#elif QT_VERSION < 0x060000
|
#elif QT_VERSION < 0x060000
|
||||||
#include <QtWidgets/QtWidgets>
|
#include <QtWidgets/QtWidgets>
|
||||||
#include <QtMultimedia/QSound>
|
#include <QtMultimedia/QSoundEffect>
|
||||||
#else
|
#else
|
||||||
#include <QtWidgets/QtWidgets>
|
#include <QtWidgets/QtWidgets>
|
||||||
#undef QT_NO_SOUND
|
#undef QT_NO_SOUND
|
||||||
@@ -1100,14 +1100,24 @@ struct window_procs Qt_procs = {
|
|||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
extern "C" void play_usersound(const char *, int);
|
extern "C" void play_usersound(const char *, int);
|
||||||
|
|
||||||
|
QSoundEffect *effect = NULL;
|
||||||
|
|
||||||
/* called from core, sounds.c */
|
/* called from core, sounds.c */
|
||||||
void
|
void
|
||||||
play_usersound(const char *filename, int volume UNUSED)
|
play_usersound(const char *filename, int volume)
|
||||||
{
|
{
|
||||||
#if defined(USER_SOUNDS) && !defined(QT_NO_SOUND)
|
#if defined(USER_SOUNDS) && !defined(QT_NO_SOUND)
|
||||||
QSound::play(filename);
|
if (!effect)
|
||||||
|
effect = new QSoundEffect(nethack_qt_::NetHackQtBind::mainWidget());
|
||||||
|
if (effect) {
|
||||||
|
effect->setLoopCount(1);
|
||||||
|
effect->setVolume((1.00f * volume) / 100.0f);
|
||||||
|
effect->setSource(QUrl::fromLocalFile(filename));
|
||||||
|
effect->play();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
nhUse(filename);
|
nhUse(filename);
|
||||||
|
nhUse(volume);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif /*!WIN32*/
|
#endif /*!WIN32*/
|
||||||
|
|||||||
Reference in New Issue
Block a user