Revert "Removed the dependency on bass.dll
."
This reverts commit fe955d6923
.
This commit is contained in:
parent
6fad08521a
commit
c1c042b93d
@ -70,6 +70,7 @@ HEADERS += lobby.h \
|
||||
misc_functions.h \
|
||||
aocharmovie.h \
|
||||
aoemotebutton.h \
|
||||
bass.h \
|
||||
aosfxplayer.h \
|
||||
aomusicplayer.h \
|
||||
aoblipplayer.h \
|
||||
@ -83,10 +84,15 @@ HEADERS += lobby.h \
|
||||
aooptionsdialog.h \
|
||||
text_file_functions.h
|
||||
|
||||
# You need to compile the Discord Rich Presence SDK separately and add the lib/headers.
|
||||
# Discord RPC uses CMake, which does not play nicely with QMake, so this step must be manual.
|
||||
unix:LIBS += -L$$PWD -ldiscord-rpc
|
||||
win32:LIBS += -L$$PWD -ldiscord-rpc #"$$PWD/discord-rpc.dll"
|
||||
# 1. You need to get BASS and put the x86 bass DLL/headers in the project root folder
|
||||
# AND the compilation output folder. If you want a static link, you'll probably
|
||||
# need the .lib file too. MinGW-GCC is really finicky finding BASS, it seems.
|
||||
# 2. You need to compile the Discord Rich Presence SDK separately and add the lib/headers
|
||||
# in the same way as BASS. Discord RPC uses CMake, which does not play nicely with
|
||||
# QMake, so this step must be manual.
|
||||
unix:LIBS += -L$$PWD -lbass -ldiscord-rpc
|
||||
win32:LIBS += -L$$PWD "$$PWD/bass.dll" -ldiscord-rpc #"$$PWD/discord-rpc.dll"
|
||||
android:LIBS += -L$$PWD\android\libs\armeabi-v7a\ -lbass
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
|
@ -103,3 +103,9 @@ Modifications copyright (c) 2017-2018 oldmud0
|
||||
This project uses Qt 5, which is licensed under the [GNU Lesser General Public License](https://www.gnu.org/licenses/lgpl-3.0.txt) with [certain licensing restrictions and exceptions](https://www.qt.io/qt-licensing-terms/). To comply with licensing requirements for static linking, object code is available if you would like to relink with an alternative version of Qt, and the source code for Qt may be found at https://github.com/qt/qtbase, http://code.qt.io/cgit/, or at https://qt.io.
|
||||
|
||||
Copyright (c) 2016 The Qt Company Ltd.
|
||||
|
||||
## BASS
|
||||
|
||||
This project depends on the BASS shared library. Get it here: http://www.un4seen.com/
|
||||
|
||||
Copyright (c) 1999-2016 Un4seen Developments Ltd. All rights reserved.
|
||||
|
@ -272,7 +272,7 @@ private:
|
||||
|
||||
const int CCCC_RELEASE = 1;
|
||||
const int CCCC_MAJOR_VERSION = 3;
|
||||
const int CCCC_MINOR_VERSION = 5;
|
||||
const int CCCC_MINOR_VERSION = 1;
|
||||
|
||||
QString current_theme = "default";
|
||||
|
||||
|
@ -2,32 +2,46 @@
|
||||
|
||||
AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
|
||||
{
|
||||
m_sfxplayer = new QSoundEffect;
|
||||
m_parent = parent;
|
||||
ao_app = p_ao_app;
|
||||
}
|
||||
|
||||
AOBlipPlayer::~AOBlipPlayer()
|
||||
{
|
||||
m_sfxplayer->stop();
|
||||
m_sfxplayer->deleteLater();
|
||||
}
|
||||
|
||||
void AOBlipPlayer::set_blips(QString p_sfx)
|
||||
{
|
||||
m_sfxplayer->stop();
|
||||
QString f_path = ao_app->get_sounds_path() + p_sfx.toLower();
|
||||
m_sfxplayer->setSource(QUrl::fromLocalFile(f_path));
|
||||
|
||||
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
|
||||
{
|
||||
BASS_StreamFree(m_stream_list[n_stream]);
|
||||
|
||||
m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
|
||||
}
|
||||
|
||||
set_volume(m_volume);
|
||||
}
|
||||
|
||||
void AOBlipPlayer::blip_tick()
|
||||
{
|
||||
m_sfxplayer->play();
|
||||
int f_cycle = m_cycle++;
|
||||
|
||||
if (m_cycle == 5)
|
||||
m_cycle = 0;
|
||||
|
||||
HSTREAM f_stream = m_stream_list[f_cycle];
|
||||
|
||||
if (ao_app->get_audio_output_device() != "Default")
|
||||
BASS_ChannelSetDevice(f_stream, BASS_GetDevice());
|
||||
BASS_ChannelPlay(f_stream, false);
|
||||
}
|
||||
|
||||
void AOBlipPlayer::set_volume(int p_value)
|
||||
{
|
||||
m_volume = p_value;
|
||||
m_sfxplayer->setVolume(p_value / 100.0);
|
||||
|
||||
float volume = p_value / 100.0f;
|
||||
|
||||
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
|
||||
{
|
||||
BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume);
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
#ifndef AOBLIPPLAYER_H
|
||||
#define AOBLIPPLAYER_H
|
||||
|
||||
#include "bass.h"
|
||||
#include "aoapplication.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <string.h>
|
||||
#include <QDebug>
|
||||
#include <QSoundEffect>
|
||||
|
||||
class AOBlipPlayer
|
||||
{
|
||||
public:
|
||||
AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app);
|
||||
~AOBlipPlayer();
|
||||
|
||||
void set_blips(QString p_sfx);
|
||||
void blip_tick();
|
||||
@ -23,9 +22,9 @@ public:
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
AOApplication *ao_app;
|
||||
QSoundEffect *m_sfxplayer;
|
||||
|
||||
int m_volume;
|
||||
HSTREAM m_stream_list[5];
|
||||
};
|
||||
|
||||
#endif // AOBLIPPLAYER_H
|
||||
|
@ -4,24 +4,34 @@ AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app)
|
||||
{
|
||||
m_parent = parent;
|
||||
ao_app = p_ao_app;
|
||||
m_player = new QMediaPlayer();
|
||||
}
|
||||
|
||||
AOMusicPlayer::~AOMusicPlayer()
|
||||
{
|
||||
m_player->stop();
|
||||
m_player->deleteLater();
|
||||
BASS_ChannelStop(m_stream);
|
||||
}
|
||||
|
||||
void AOMusicPlayer::play(QString p_song)
|
||||
{
|
||||
m_player->setMedia(QUrl::fromLocalFile(ao_app->get_music_path(p_song)));
|
||||
BASS_ChannelStop(m_stream);
|
||||
|
||||
QString f_path = ao_app->get_music_path(p_song);
|
||||
|
||||
m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
|
||||
|
||||
this->set_volume(m_volume);
|
||||
m_player->play();
|
||||
|
||||
if (ao_app->get_audio_output_device() != "Default")
|
||||
BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
|
||||
BASS_ChannelPlay(m_stream, false);
|
||||
}
|
||||
|
||||
void AOMusicPlayer::set_volume(int p_value)
|
||||
{
|
||||
m_volume = p_value;
|
||||
m_player->setVolume(p_value);
|
||||
|
||||
float volume = m_volume / 100.0f;
|
||||
|
||||
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
#ifndef AOMUSICPLAYER_H
|
||||
#define AOMUSICPLAYER_H
|
||||
|
||||
#include "bass.h"
|
||||
#include "aoapplication.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <string.h>
|
||||
#include <QDebug>
|
||||
#include <QMediaPlayer>
|
||||
|
||||
class AOMusicPlayer
|
||||
{
|
||||
@ -20,9 +20,9 @@ public:
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
AOApplication *ao_app;
|
||||
QMediaPlayer *m_player;
|
||||
|
||||
int m_volume = 0;
|
||||
HSTREAM m_stream;
|
||||
};
|
||||
|
||||
#endif // AOMUSICPLAYER_H
|
||||
|
@ -199,73 +199,105 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
|
||||
AudioForm->setFormAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
|
||||
AudioForm->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
AudioDevideLabel = new QLabel(formLayoutWidget_2);
|
||||
AudioDevideLabel->setText("Audio device:");
|
||||
AudioDevideLabel->setToolTip("Allows you to set the theme used ingame. If your theme changes the lobby's look, too, you'll obviously need to reload the lobby somehow for it take effect. Joining a server and leaving it should work.");
|
||||
|
||||
AudioForm->setWidget(0, QFormLayout::LabelRole, AudioDevideLabel);
|
||||
|
||||
AudioDeviceCombobox = new QComboBox(formLayoutWidget_2);
|
||||
|
||||
// Let's fill out the combobox with the available audio devices.
|
||||
int a = 0;
|
||||
BASS_DEVICEINFO info;
|
||||
|
||||
if (needs_default_audiodev())
|
||||
{
|
||||
AudioDeviceCombobox->addItem("Default");
|
||||
}
|
||||
|
||||
for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
|
||||
{
|
||||
AudioDeviceCombobox->addItem(info.name);
|
||||
if (p_ao_app->get_audio_output_device() == info.name)
|
||||
AudioDeviceCombobox->setCurrentIndex(AudioDeviceCombobox->count()-1);
|
||||
}
|
||||
|
||||
AudioForm->setWidget(0, QFormLayout::FieldRole, AudioDeviceCombobox);
|
||||
|
||||
DeviceVolumeDivider = new QFrame(formLayoutWidget_2);
|
||||
DeviceVolumeDivider->setFrameShape(QFrame::HLine);
|
||||
DeviceVolumeDivider->setFrameShadow(QFrame::Sunken);
|
||||
|
||||
AudioForm->setWidget(1, QFormLayout::FieldRole, DeviceVolumeDivider);
|
||||
|
||||
MusicVolumeLabel = new QLabel(formLayoutWidget_2);
|
||||
MusicVolumeLabel->setText("Music:");
|
||||
MusicVolumeLabel->setToolTip("Sets the music's default volume.");
|
||||
|
||||
AudioForm->setWidget(1, QFormLayout::LabelRole, MusicVolumeLabel);
|
||||
AudioForm->setWidget(2, QFormLayout::LabelRole, MusicVolumeLabel);
|
||||
|
||||
MusicVolumeSpinbox = new QSpinBox(formLayoutWidget_2);
|
||||
MusicVolumeSpinbox->setValue(p_ao_app->get_default_music());
|
||||
MusicVolumeSpinbox->setMaximum(100);
|
||||
MusicVolumeSpinbox->setSuffix("%");
|
||||
|
||||
AudioForm->setWidget(1, QFormLayout::FieldRole, MusicVolumeSpinbox);
|
||||
AudioForm->setWidget(2, QFormLayout::FieldRole, MusicVolumeSpinbox);
|
||||
|
||||
SFXVolumeLabel = new QLabel(formLayoutWidget_2);
|
||||
SFXVolumeLabel->setText("SFX:");
|
||||
SFXVolumeLabel->setToolTip("Sets the SFX's default volume. Interjections and actual sound effects count as 'SFX'.");
|
||||
|
||||
AudioForm->setWidget(2, QFormLayout::LabelRole, SFXVolumeLabel);
|
||||
AudioForm->setWidget(3, QFormLayout::LabelRole, SFXVolumeLabel);
|
||||
|
||||
SFXVolumeSpinbox = new QSpinBox(formLayoutWidget_2);
|
||||
SFXVolumeSpinbox->setValue(p_ao_app->get_default_sfx());
|
||||
SFXVolumeSpinbox->setMaximum(100);
|
||||
SFXVolumeSpinbox->setSuffix("%");
|
||||
|
||||
AudioForm->setWidget(2, QFormLayout::FieldRole, SFXVolumeSpinbox);
|
||||
AudioForm->setWidget(3, QFormLayout::FieldRole, SFXVolumeSpinbox);
|
||||
|
||||
BlipsVolumeLabel = new QLabel(formLayoutWidget_2);
|
||||
BlipsVolumeLabel->setText("Blips:");
|
||||
BlipsVolumeLabel->setToolTip("Sets the volume of the blips, the talking sound effects.");
|
||||
|
||||
AudioForm->setWidget(3, QFormLayout::LabelRole, BlipsVolumeLabel);
|
||||
AudioForm->setWidget(4, QFormLayout::LabelRole, BlipsVolumeLabel);
|
||||
|
||||
BlipsVolumeSpinbox = new QSpinBox(formLayoutWidget_2);
|
||||
BlipsVolumeSpinbox->setValue(p_ao_app->get_default_blip());
|
||||
BlipsVolumeSpinbox->setMaximum(100);
|
||||
BlipsVolumeSpinbox->setSuffix("%");
|
||||
|
||||
AudioForm->setWidget(3, QFormLayout::FieldRole, BlipsVolumeSpinbox);
|
||||
AudioForm->setWidget(4, QFormLayout::FieldRole, BlipsVolumeSpinbox);
|
||||
|
||||
VolumeBlipDivider = new QFrame(formLayoutWidget_2);
|
||||
VolumeBlipDivider->setFrameShape(QFrame::HLine);
|
||||
VolumeBlipDivider->setFrameShadow(QFrame::Sunken);
|
||||
|
||||
AudioForm->setWidget(4, QFormLayout::FieldRole, VolumeBlipDivider);
|
||||
AudioForm->setWidget(5, QFormLayout::FieldRole, VolumeBlipDivider);
|
||||
|
||||
BlipRateLabel = new QLabel(formLayoutWidget_2);
|
||||
BlipRateLabel->setText("Blip rate:");
|
||||
BlipRateLabel->setToolTip("Sets the delay between playing the blip sounds.");
|
||||
|
||||
AudioForm->setWidget(5, QFormLayout::LabelRole, BlipRateLabel);
|
||||
AudioForm->setWidget(6, QFormLayout::LabelRole, BlipRateLabel);
|
||||
|
||||
BlipRateSpinbox = new QSpinBox(formLayoutWidget_2);
|
||||
BlipRateSpinbox->setValue(p_ao_app->read_blip_rate());
|
||||
BlipRateSpinbox->setMinimum(1);
|
||||
|
||||
AudioForm->setWidget(5, QFormLayout::FieldRole, BlipRateSpinbox);
|
||||
AudioForm->setWidget(6, QFormLayout::FieldRole, BlipRateSpinbox);
|
||||
|
||||
BlankBlipsLabel = new QLabel(formLayoutWidget_2);
|
||||
BlankBlipsLabel->setText("Blank blips:");
|
||||
BlankBlipsLabel->setToolTip("If true, the game will play a blip sound even when a space is 'being said'.");
|
||||
|
||||
AudioForm->setWidget(6, QFormLayout::LabelRole, BlankBlipsLabel);
|
||||
AudioForm->setWidget(7, QFormLayout::LabelRole, BlankBlipsLabel);
|
||||
|
||||
BlankBlipsCheckbox = new QCheckBox(formLayoutWidget_2);
|
||||
BlankBlipsCheckbox->setChecked(p_ao_app->get_blank_blip());
|
||||
|
||||
AudioForm->setWidget(6, QFormLayout::FieldRole, BlankBlipsCheckbox);
|
||||
AudioForm->setWidget(7, QFormLayout::FieldRole, BlankBlipsCheckbox);
|
||||
|
||||
// When we're done, we should continue the updates!
|
||||
setUpdatesEnabled(true);
|
||||
@ -297,6 +329,7 @@ void AOOptionsDialog::save_pressed()
|
||||
callwordsini->close();
|
||||
}
|
||||
|
||||
configini->setValue("default_audio_device", AudioDeviceCombobox->currentText());
|
||||
configini->setValue("default_music", MusicVolumeSpinbox->value());
|
||||
configini->setValue("default_sfx", SFXVolumeSpinbox->value());
|
||||
configini->setValue("default_blip", BlipsVolumeSpinbox->value());
|
||||
@ -311,3 +344,17 @@ void AOOptionsDialog::discard_pressed()
|
||||
{
|
||||
done(0);
|
||||
}
|
||||
|
||||
#if (defined (_WIN32) || defined (_WIN64))
|
||||
bool AOOptionsDialog::needs_default_audiodev()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#elif (defined (LINUX) || defined (__linux__))
|
||||
bool AOOptionsDialog::needs_default_audiodev()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
#error This operating system is not supported.
|
||||
#endif
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define AOOPTIONSDIALOG_H
|
||||
|
||||
#include "aoapplication.h"
|
||||
#include "bass.h"
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtWidgets/QApplication>
|
||||
@ -62,9 +63,9 @@ private:
|
||||
QWidget *AudioTab;
|
||||
QWidget *formLayoutWidget_2;
|
||||
QFormLayout *AudioForm;
|
||||
//QLabel *AudioDevideLabel;
|
||||
//QComboBox *AudioDeviceCombobox;
|
||||
//QFrame *DeviceVolumeDivider;
|
||||
QLabel *AudioDevideLabel;
|
||||
QComboBox *AudioDeviceCombobox;
|
||||
QFrame *DeviceVolumeDivider;
|
||||
QSpinBox *MusicVolumeSpinbox;
|
||||
QLabel *MusicVolumeLabel;
|
||||
QSpinBox *SFXVolumeSpinbox;
|
||||
@ -78,6 +79,8 @@ private:
|
||||
QLabel *BlankBlipsLabel;
|
||||
QDialogButtonBox *SettingsButtons;
|
||||
|
||||
bool needs_default_audiodev();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
@ -5,19 +5,12 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
|
||||
{
|
||||
m_parent = parent;
|
||||
ao_app = p_ao_app;
|
||||
m_sfxplayer = new QSoundEffect();
|
||||
}
|
||||
|
||||
AOSfxPlayer::~AOSfxPlayer()
|
||||
{
|
||||
m_sfxplayer->stop();
|
||||
m_sfxplayer->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout)
|
||||
{
|
||||
m_sfxplayer->stop();
|
||||
BASS_ChannelStop(m_stream);
|
||||
|
||||
p_sfx = p_sfx.toLower();
|
||||
|
||||
QString misc_path = "";
|
||||
@ -38,19 +31,26 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout)
|
||||
else
|
||||
f_path = sound_path;
|
||||
|
||||
m_sfxplayer->setSource(QUrl::fromLocalFile(f_path));
|
||||
m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
|
||||
|
||||
set_volume(m_volume);
|
||||
|
||||
m_sfxplayer->play();
|
||||
if (ao_app->get_audio_output_device() != "Default")
|
||||
BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
|
||||
BASS_ChannelPlay(m_stream, false);
|
||||
}
|
||||
|
||||
void AOSfxPlayer::stop()
|
||||
{
|
||||
m_sfxplayer->stop();
|
||||
BASS_ChannelStop(m_stream);
|
||||
}
|
||||
|
||||
void AOSfxPlayer::set_volume(int p_value)
|
||||
{
|
||||
m_volume = p_value;
|
||||
m_sfxplayer->setVolume(p_value / 100.0);
|
||||
|
||||
float volume = p_value / 100.0f;
|
||||
|
||||
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
#ifndef AOSFXPLAYER_H
|
||||
#define AOSFXPLAYER_H
|
||||
|
||||
#include "bass.h"
|
||||
#include "aoapplication.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <string.h>
|
||||
#include <QDebug>
|
||||
#include <QSoundEffect>
|
||||
|
||||
class AOSfxPlayer
|
||||
{
|
||||
public:
|
||||
AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app);
|
||||
~AOSfxPlayer();
|
||||
|
||||
void play(QString p_sfx, QString p_char = "", QString shout = "");
|
||||
void stop();
|
||||
@ -21,9 +20,9 @@ public:
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
AOApplication *ao_app;
|
||||
QSoundEffect *m_sfxplayer;
|
||||
|
||||
int m_volume = 0;
|
||||
HSTREAM m_stream;
|
||||
};
|
||||
|
||||
#endif // AOSFXPLAYER_H
|
||||
|
@ -11,6 +11,34 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
||||
{
|
||||
ao_app = p_ao_app;
|
||||
|
||||
//initializing sound device
|
||||
|
||||
|
||||
// Change the default audio output device to be the one the user has given
|
||||
// in his config.ini file for now.
|
||||
int a = 0;
|
||||
BASS_DEVICEINFO info;
|
||||
|
||||
if (ao_app->get_audio_output_device() == "Default")
|
||||
{
|
||||
BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, 0, NULL);
|
||||
BASS_PluginLoad("bassopus.dll", BASS_UNICODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
|
||||
{
|
||||
if (ao_app->get_audio_output_device() == info.name)
|
||||
{
|
||||
BASS_SetDevice(a);
|
||||
BASS_Init(a, 48000, BASS_DEVICE_LATENCY, 0, NULL);
|
||||
BASS_PluginLoad("bassopus.dll", BASS_UNICODE);
|
||||
qDebug() << info.name << "was set as the default audio output device.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
keepalive_timer = new QTimer(this);
|
||||
keepalive_timer->start(60000);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user