aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCerapter <cerap@protonmail.com>2018-09-04 17:32:20 +0200
committerCerapter <cerap@protonmail.com>2018-09-04 17:32:20 +0200
commitfe955d692350cd3bac192721c09d8fdd445afc5d (patch)
tree30246face43b40f99ff33b3f1389fc39165404e9
parent2fe5d440f419b3bfad71345350458181c9164033 (diff)
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.
-rw-r--r--Attorney_Online_remake.pro14
-rw-r--r--README.md6
-rw-r--r--aoapplication.h2
-rw-r--r--aoblipplayer.cpp36
-rw-r--r--aoblipplayer.h5
-rw-r--r--aomusicplayer.cpp22
-rw-r--r--aomusicplayer.h4
-rw-r--r--aooptionsdialog.cpp69
-rw-r--r--aooptionsdialog.h9
-rw-r--r--aosfxplayer.cpp26
-rw-r--r--aosfxplayer.h5
-rw-r--r--courtroom.cpp28
12 files changed, 57 insertions, 169 deletions
diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro
index 599531c6..8c064802 100644
--- a/Attorney_Online_remake.pro
+++ b/Attorney_Online_remake.pro
@@ -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
diff --git a/README.md b/README.md
index 913b1745..828d329b 100644
--- a/README.md
+++ b/README.md
@@ -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.
diff --git a/aoapplication.h b/aoapplication.h
index fe5a4789..2d70041b 100644
--- a/aoapplication.h
+++ b/aoapplication.h
@@ -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";
diff --git a/aoblipplayer.cpp b/aoblipplayer.cpp
index 0ea08978..5e3929e2 100644
--- a/aoblipplayer.cpp
+++ b/aoblipplayer.cpp
@@ -2,46 +2,32 @@
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();
-
- 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->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);
}
diff --git a/aoblipplayer.h b/aoblipplayer.h
index aebba77d..c8a8cb6d 100644
--- a/aoblipplayer.h
+++ b/aoblipplayer.h
@@ -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
diff --git a/aomusicplayer.cpp b/aomusicplayer.cpp
index 9e763582..62aa7302 100644
--- a/aomusicplayer.cpp
+++ b/aomusicplayer.cpp
@@ -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);
}
diff --git a/aomusicplayer.h b/aomusicplayer.h
index 560a7f90..7716ea9e 100644
--- a/aomusicplayer.h
+++ b/aomusicplayer.h
@@ -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
diff --git a/aooptionsdialog.cpp b/aooptionsdialog.cpp
index 7d307dd3..e79c6f69 100644
--- a/aooptionsdialog.cpp
+++ b/aooptionsdialog.cpp
@@ -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
diff --git a/aooptionsdialog.h b/aooptionsdialog.h
index a48bff9e..0401a594 100644
--- a/aooptionsdialog.h
+++ b/aooptionsdialog.h
@@ -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:
diff --git a/aosfxplayer.cpp b/aosfxplayer.cpp
index df26ddf5..972cd749 100644
--- a/aosfxplayer.cpp
+++ b/aosfxplayer.cpp
@@ -4,12 +4,19 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
{
m_parent = parent;
ao_app = p_ao_app;
+ m_sfxplayer = new QSoundEffect();
}
-void AOSfxPlayer::play(QString p_sfx, QString p_char)
+AOSfxPlayer::~AOSfxPlayer()
{
- BASS_ChannelStop(m_stream);
+ m_sfxplayer->stop();
+ m_sfxplayer->deleteLater();
+}
+
+void AOSfxPlayer::play(QString p_sfx, QString p_char)
+{
+ 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);
}
diff --git a/aosfxplayer.h b/aosfxplayer.h
index 4fd597c9..1b73e490 100644
--- a/aosfxplayer.h
+++ b/aosfxplayer.h
@@ -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
diff --git a/courtroom.cpp b/courtroom.cpp
index 28540deb..64afd4d9 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -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);