Removed the dependency on bass.dll
.
This is merely a reimplementation of Gameboyprinter's changes on the main thing. The only thing that's different from that one is that the options menu has had its audio device removed, too.
This commit is contained in:
parent
2fe5d440f4
commit
fe955d6923
@ -70,7 +70,6 @@ HEADERS += lobby.h \
|
||||
misc_functions.h \
|
||||
aocharmovie.h \
|
||||
aoemotebutton.h \
|
||||
bass.h \
|
||||
aosfxplayer.h \
|
||||
aomusicplayer.h \
|
||||
aoblipplayer.h \
|
||||
@ -83,15 +82,10 @@ HEADERS += lobby.h \
|
||||
discord-rpc.h \
|
||||
aooptionsdialog.h
|
||||
|
||||
# 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
|
||||
# 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"
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
|
@ -103,9 +103,3 @@ 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.
|
||||
|
@ -265,7 +265,7 @@ private:
|
||||
|
||||
const int CCCC_RELEASE = 1;
|
||||
const int CCCC_MAJOR_VERSION = 3;
|
||||
const int CCCC_MINOR_VERSION = 1;
|
||||
const int CCCC_MINOR_VERSION = 5;
|
||||
|
||||
QString current_theme = "default";
|
||||
|
||||
|
@ -2,46 +2,32 @@
|
||||
|
||||
AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
|
||||
{
|
||||
m_sfxplayer = new QSoundEffect;
|
||||
m_parent = parent;
|
||||
ao_app = p_ao_app;
|
||||
}
|
||||
|
||||
void AOBlipPlayer::set_blips(QString p_sfx)
|
||||
AOBlipPlayer::~AOBlipPlayer()
|
||||
{
|
||||
QString f_path = ao_app->get_sounds_path() + p_sfx.toLower();
|
||||
|
||||
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);
|
||||
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));
|
||||
set_volume(m_volume);
|
||||
}
|
||||
|
||||
void AOBlipPlayer::blip_tick()
|
||||
{
|
||||
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);
|
||||
m_sfxplayer->play();
|
||||
}
|
||||
|
||||
void AOBlipPlayer::set_volume(int p_value)
|
||||
{
|
||||
m_volume = p_value;
|
||||
|
||||
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);
|
||||
}
|
||||
m_sfxplayer->setVolume(p_value / 100.0);
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
#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();
|
||||
@ -22,9 +23,9 @@ public:
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
AOApplication *ao_app;
|
||||
QSoundEffect *m_sfxplayer;
|
||||
|
||||
int m_volume;
|
||||
HSTREAM m_stream_list[5];
|
||||
};
|
||||
|
||||
#endif // AOBLIPPLAYER_H
|
||||
|
@ -4,34 +4,24 @@ AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app)
|
||||
{
|
||||
m_parent = parent;
|
||||
ao_app = p_ao_app;
|
||||
m_player = new QMediaPlayer();
|
||||
}
|
||||
|
||||
AOMusicPlayer::~AOMusicPlayer()
|
||||
{
|
||||
BASS_ChannelStop(m_stream);
|
||||
m_player->stop();
|
||||
m_player->deleteLater();
|
||||
}
|
||||
|
||||
void AOMusicPlayer::play(QString 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);
|
||||
|
||||
m_player->setMedia(QUrl::fromLocalFile(ao_app->get_music_path(p_song)));
|
||||
this->set_volume(m_volume);
|
||||
|
||||
if (ao_app->get_audio_output_device() != "Default")
|
||||
BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
|
||||
BASS_ChannelPlay(m_stream, false);
|
||||
m_player->play();
|
||||
}
|
||||
|
||||
void AOMusicPlayer::set_volume(int p_value)
|
||||
{
|
||||
m_volume = p_value;
|
||||
|
||||
float volume = m_volume / 100.0f;
|
||||
|
||||
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
|
||||
|
||||
m_player->setVolume(p_value);
|
||||
}
|
||||
|
@ -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,105 +199,73 @@ 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(2, QFormLayout::LabelRole, MusicVolumeLabel);
|
||||
AudioForm->setWidget(1, QFormLayout::LabelRole, MusicVolumeLabel);
|
||||
|
||||
MusicVolumeSpinbox = new QSpinBox(formLayoutWidget_2);
|
||||
MusicVolumeSpinbox->setValue(p_ao_app->get_default_music());
|
||||
MusicVolumeSpinbox->setMaximum(100);
|
||||
MusicVolumeSpinbox->setSuffix("%");
|
||||
|
||||
AudioForm->setWidget(2, QFormLayout::FieldRole, MusicVolumeSpinbox);
|
||||
AudioForm->setWidget(1, 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(3, QFormLayout::LabelRole, SFXVolumeLabel);
|
||||
AudioForm->setWidget(2, QFormLayout::LabelRole, SFXVolumeLabel);
|
||||
|
||||
SFXVolumeSpinbox = new QSpinBox(formLayoutWidget_2);
|
||||
SFXVolumeSpinbox->setValue(p_ao_app->get_default_sfx());
|
||||
SFXVolumeSpinbox->setMaximum(100);
|
||||
SFXVolumeSpinbox->setSuffix("%");
|
||||
|
||||
AudioForm->setWidget(3, QFormLayout::FieldRole, SFXVolumeSpinbox);
|
||||
AudioForm->setWidget(2, 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(4, QFormLayout::LabelRole, BlipsVolumeLabel);
|
||||
AudioForm->setWidget(3, QFormLayout::LabelRole, BlipsVolumeLabel);
|
||||
|
||||
BlipsVolumeSpinbox = new QSpinBox(formLayoutWidget_2);
|
||||
BlipsVolumeSpinbox->setValue(p_ao_app->get_default_blip());
|
||||
BlipsVolumeSpinbox->setMaximum(100);
|
||||
BlipsVolumeSpinbox->setSuffix("%");
|
||||
|
||||
AudioForm->setWidget(4, QFormLayout::FieldRole, BlipsVolumeSpinbox);
|
||||
AudioForm->setWidget(3, QFormLayout::FieldRole, BlipsVolumeSpinbox);
|
||||
|
||||
VolumeBlipDivider = new QFrame(formLayoutWidget_2);
|
||||
VolumeBlipDivider->setFrameShape(QFrame::HLine);
|
||||
VolumeBlipDivider->setFrameShadow(QFrame::Sunken);
|
||||
|
||||
AudioForm->setWidget(5, QFormLayout::FieldRole, VolumeBlipDivider);
|
||||
AudioForm->setWidget(4, QFormLayout::FieldRole, VolumeBlipDivider);
|
||||
|
||||
BlipRateLabel = new QLabel(formLayoutWidget_2);
|
||||
BlipRateLabel->setText("Blip rate:");
|
||||
BlipRateLabel->setToolTip("Sets the delay between playing the blip sounds.");
|
||||
|
||||
AudioForm->setWidget(6, QFormLayout::LabelRole, BlipRateLabel);
|
||||
AudioForm->setWidget(5, QFormLayout::LabelRole, BlipRateLabel);
|
||||
|
||||
BlipRateSpinbox = new QSpinBox(formLayoutWidget_2);
|
||||
BlipRateSpinbox->setValue(p_ao_app->read_blip_rate());
|
||||
BlipRateSpinbox->setMinimum(1);
|
||||
|
||||
AudioForm->setWidget(6, QFormLayout::FieldRole, BlipRateSpinbox);
|
||||
AudioForm->setWidget(5, 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(7, QFormLayout::LabelRole, BlankBlipsLabel);
|
||||
AudioForm->setWidget(6, QFormLayout::LabelRole, BlankBlipsLabel);
|
||||
|
||||
BlankBlipsCheckbox = new QCheckBox(formLayoutWidget_2);
|
||||
BlankBlipsCheckbox->setChecked(p_ao_app->get_blank_blip());
|
||||
|
||||
AudioForm->setWidget(7, QFormLayout::FieldRole, BlankBlipsCheckbox);
|
||||
AudioForm->setWidget(6, QFormLayout::FieldRole, BlankBlipsCheckbox);
|
||||
|
||||
// When we're done, we should continue the updates!
|
||||
setUpdatesEnabled(true);
|
||||
@ -329,7 +297,6 @@ 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());
|
||||
@ -344,17 +311,3 @@ 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,7 +2,6 @@
|
||||
#define AOOPTIONSDIALOG_H
|
||||
|
||||
#include "aoapplication.h"
|
||||
#include "bass.h"
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtWidgets/QApplication>
|
||||
@ -63,9 +62,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;
|
||||
@ -79,8 +78,6 @@ private:
|
||||
QLabel *BlankBlipsLabel;
|
||||
QDialogButtonBox *SettingsButtons;
|
||||
|
||||
bool needs_default_audiodev();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
@ -4,12 +4,19 @@ 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)
|
||||
{
|
||||
BASS_ChannelStop(m_stream);
|
||||
|
||||
m_sfxplayer->stop();
|
||||
p_sfx = p_sfx.toLower();
|
||||
|
||||
QString f_path;
|
||||
@ -19,26 +26,19 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char)
|
||||
else
|
||||
f_path = ao_app->get_sounds_path() + p_sfx;
|
||||
|
||||
m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
|
||||
|
||||
m_sfxplayer->setSource(QUrl::fromLocalFile(f_path));
|
||||
set_volume(m_volume);
|
||||
|
||||
if (ao_app->get_audio_output_device() != "Default")
|
||||
BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
|
||||
BASS_ChannelPlay(m_stream, false);
|
||||
m_sfxplayer->play();
|
||||
}
|
||||
|
||||
void AOSfxPlayer::stop()
|
||||
{
|
||||
BASS_ChannelStop(m_stream);
|
||||
m_sfxplayer->stop();
|
||||
}
|
||||
|
||||
void AOSfxPlayer::set_volume(int p_value)
|
||||
{
|
||||
m_volume = p_value;
|
||||
|
||||
float volume = p_value / 100.0f;
|
||||
|
||||
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
|
||||
|
||||
m_sfxplayer->setVolume(p_value / 100.0);
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
#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 = "");
|
||||
void stop();
|
||||
@ -20,9 +21,9 @@ public:
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
AOApplication *ao_app;
|
||||
QSoundEffect *m_sfxplayer;
|
||||
|
||||
int m_volume = 0;
|
||||
HSTREAM m_stream;
|
||||
};
|
||||
|
||||
#endif // AOSFXPLAYER_H
|
||||
|
@ -11,34 +11,6 @@ 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