diff --git a/.gitignore b/.gitignore index 0b767f1..5119800 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ base_override.h .DS_Store base-full/ +base/ bass.lib bin/ diff --git a/Attorney_Online.pro b/Attorney_Online.pro index e1961a0..f490917 100644 --- a/Attorney_Online.pro +++ b/Attorney_Online.pro @@ -1,4 +1,4 @@ -QT += core gui widgets multimedia network +QT += core gui widgets network TARGET = Attorney_Online TEMPLATE = app @@ -12,9 +12,31 @@ MOC_DIR = $$PWD/build SOURCES += $$files($$PWD/src/*.cpp) HEADERS += $$files($$PWD/include/*.h) -LIBS += -L$$PWD/lib -lbass -ldiscord-rpc + + +LIBS += -L$$PWD/lib + +DEFINES += DISCORD + +contains(DEFINES, DISCORD) { +LIBS += -ldiscord-rpc +} + +DEFINES += BASSAUDIO + +contains(DEFINES, BASSAUDIO) { +LIBS += -lbass +} + +#DEFINES += QTAUDIO + +contains(DEFINES, QTAUDIO) { +QT += multimedia +} + macx:LIBS += -framework CoreFoundation -framework Foundation -framework CoreServices + CONFIG += c++14 RESOURCES += resources.qrc diff --git a/include/aoapplication.h b/include/aoapplication.h index 2eed7f2..f7103b8 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -95,9 +95,9 @@ public: //////////////////versioning/////////////// - int get_release() const { return RELEASE; } - int get_major_version() const { return MAJOR_VERSION; } - int get_minor_version() const { return MINOR_VERSION; } + const int get_release() const { return RELEASE; } + const int get_major_version() const { return MAJOR_VERSION; } + const int get_minor_version() const { return MINOR_VERSION; } QString get_version_string(); /////////////////////////////////////////// diff --git a/include/aoblipplayer.h b/include/aoblipplayer.h index aebba77..102a040 100644 --- a/include/aoblipplayer.h +++ b/include/aoblipplayer.h @@ -1,13 +1,19 @@ #ifndef AOBLIPPLAYER_H #define AOBLIPPLAYER_H +#if defined(BASSAUDIO) #include "bass.h" +#elif defined(QTAUDIO) +#include +#endif + #include "aoapplication.h" #include #include #include + class AOBlipPlayer { public: @@ -24,7 +30,11 @@ private: AOApplication *ao_app; int m_volume; + #if defined(BASSAUDIO) HSTREAM m_stream_list[5]; + #elif defined(QTAUDIO) + QSoundEffect m_blips; + #endif }; #endif // AOBLIPPLAYER_H diff --git a/include/aomusicplayer.h b/include/aomusicplayer.h index 560a7f9..b34267c 100644 --- a/include/aomusicplayer.h +++ b/include/aomusicplayer.h @@ -1,13 +1,18 @@ #ifndef AOMUSICPLAYER_H #define AOMUSICPLAYER_H +#if defined(BASSAUDIO) #include "bass.h" +#elif defined(QTAUDIO) +#include +#endif #include "aoapplication.h" #include #include #include +#if defined(BASSAUDIO) class AOMusicPlayer { public: @@ -24,5 +29,37 @@ private: int m_volume = 0; HSTREAM m_stream; }; +#elif defined(QTAUDIO) +class AOMusicPlayer +{ +public: + AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app); + ~AOMusicPlayer(); + + void play(QString p_song); + void set_volume(int p_value); + +private: + QMediaPlayer m_player; + QWidget *m_parent; + AOApplication *ao_app; + + int m_volume = 0; +}; +#else +class AOMusicPlayer +{ +public: + AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app); + ~AOMusicPlayer(); + + void play(QString p_song); + void set_volume(int p_value); + +private: + QWidget *m_parent; + AOApplication *ao_app; +}; +#endif #endif // AOMUSICPLAYER_H diff --git a/include/aosfxplayer.h b/include/aosfxplayer.h index 30cbe9d..4b97685 100644 --- a/include/aosfxplayer.h +++ b/include/aosfxplayer.h @@ -1,7 +1,12 @@ #ifndef AOSFXPLAYER_H #define AOSFXPLAYER_H +#if defined(BASSAUDIO) #include "bass.h" +#elif defined(QTAUDIO) +#include +#endif + #include "aoapplication.h" #include @@ -20,9 +25,12 @@ public: private: QWidget *m_parent; AOApplication *ao_app; - - int m_volume = 0; + #if defined(BASSAUDIO) HSTREAM m_stream; + #elif defined(QTAUDIO) + QSoundEffect m_sfx; + #endif + int m_volume = 0; }; #endif // AOSFXPLAYER_H diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index 74757c5..4dfb895 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -1,5 +1,6 @@ #include "aoblipplayer.h" +#if defined(BASSAUDIO) //Using bass.dll for the blips AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) { m_parent = parent; @@ -28,7 +29,6 @@ void AOBlipPlayer::blip_tick() 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); @@ -45,3 +45,59 @@ void AOBlipPlayer::set_volume(int p_value) BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); } } +#elif defined(QTAUDIO) //Using Qt's QSoundEffect class +AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +void AOBlipPlayer::set_blips(QString p_sfx) +{ + QString f_path = ao_app->get_sounds_path(p_sfx); + + for (int n_stream = 0 ; n_stream < 5 ; ++n_stream) + { + m_blips.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; + + m_blips.play(); +} + +void AOBlipPlayer::set_volume(int p_value) +{ + m_volume = p_value; + m_blips.setVolume(m_volume); +} +#else //No audio +AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +void AOBlipPlayer::set_blips(QString p_sfx) +{ + +} + +void AOBlipPlayer::blip_tick() +{ + +} + +void AOBlipPlayer::set_volume(int p_value) +{ + +} +#endif diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index 997d82d..2791809 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -1,5 +1,6 @@ #include "aomusicplayer.h" +#if defined(BASSAUDIO) AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) { m_parent = parent; @@ -32,3 +33,55 @@ void AOMusicPlayer::set_volume(int p_value) float volume = m_volume / 100.0f; BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); } +#elif defined(QTAUDIO) +AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +AOMusicPlayer::~AOMusicPlayer() +{ + m_player.stop(); +} + +void AOMusicPlayer::play(QString p_song) +{ + m_player.stop(); + + QString f_path = ao_app->get_music_path(p_song); + + m_player.setMedia(QUrl::fromLocalFile(f_path)); + + this->set_volume(m_volume); + + m_player.play(); +} + +void AOMusicPlayer::set_volume(int p_value) +{ + m_volume = p_value; + m_player.setVolume(m_volume); +} +#else +AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +AOMusicPlayer::~AOMusicPlayer() +{ + +} + +void AOMusicPlayer::play(QString p_song) +{ + +} + +void AOMusicPlayer::set_volume(int p_value) +{ + +} +#endif diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index cd69c76..0f6a054 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -199,6 +199,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_callwords_layout->addWidget(ui_callwords_explain_lbl); // The audio tab. + #ifdef BASSAUDIO ui_audio_tab = new QWidget(); ui_settings_tabs->addTab(ui_audio_tab, tr("Audio")); @@ -218,7 +219,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_audio_device_combobox = new QComboBox(ui_audio_widget); - // Let's fill out the combobox with the available audio devices. + // Let's fill out the combobox with the available audio devices. Or don't if there is no audio int a = 0; BASS_DEVICEINFO info; @@ -311,6 +312,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_blank_blips_cb->setChecked(p_ao_app->get_blank_blip()); ui_audio_layout->setWidget(7, QFormLayout::FieldRole, ui_blank_blips_cb); + #endif // The casing tab! ui_casing_tab = new QWidget(); diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 7fe7987..710d7a8 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -1,6 +1,7 @@ #include "aosfxplayer.h" #include "file_functions.h" +#if defined(BASSAUDIO) //Using bass.dll for sfx AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) { m_parent = parent; @@ -49,3 +50,74 @@ void AOSfxPlayer::set_volume(int p_value) float volume = p_value / 100.0f; BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); } +#elif defined(QTAUDIO) //Using Qt's QSoundEffect class +AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) +{ + m_sfx.stop(); + + QString misc_path = ""; + QString char_path = ""; + QString sound_path = ao_app->get_sounds_path(p_sfx); + + if (shout != "") + misc_path = ao_app->get_base_path() + "misc/" + shout + "/" + p_sfx; + if (p_char != "") + char_path = ao_app->get_character_path(p_char, p_sfx); + + QString f_path; + + if (file_exists(char_path)) + f_path = char_path; + else if (file_exists(misc_path)) + f_path = misc_path; + else + f_path = sound_path; + + if (file_exists(f_path)) //if its missing, it will glitch out + { + m_sfx.setSource(QUrl::fromLocalFile(f_path)); + + set_volume(m_volume); + + m_sfx.play(); + } +} + +void AOSfxPlayer::stop() +{ + m_sfx.stop(); +} + +void AOSfxPlayer::set_volume(int p_value) +{ + m_volume = p_value; + m_sfx.setVolume(m_volume); +} +#else +AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) +{ + +} + +void AOSfxPlayer::stop() +{ + +} + +void AOSfxPlayer::set_volume(int p_value) +{ + +} +#endif diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 237bedc..5258120 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3,7 +3,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() { ao_app = p_ao_app; - + #ifdef BASSAUDIO // Change the default audio output device to be the one the user has given // in his config.ini file for now. unsigned int a = 0; @@ -28,6 +28,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() } } } + #endif keepalive_timer = new QTimer(this); keepalive_timer->start(60000); @@ -3568,23 +3569,29 @@ Courtroom::~Courtroom() delete blip_player; } + #if (defined (_WIN32) || defined (_WIN64)) void Courtroom::load_bass_opus_plugin() { + #ifdef BASSAUDIO BASS_PluginLoad("bassopus.dll", 0); + #endif } #elif (defined (LINUX) || defined (__linux__)) void Courtroom::load_bass_opus_plugin() { + #ifdef BASSAUDIO BASS_PluginLoad("libbassopus.so", 0); + #endif } #elif defined __APPLE__ void Courtroom::load_bass_opus_plugin() { QString libpath = ao_app->get_base_path() + "../../Frameworks/libbassopus.dylib"; QByteArray ba = libpath.toLocal8Bit(); - + #ifdef BASSAUDIO BASS_PluginLoad(ba.data(), 0); + #endif } #else #error This operating system is unsupported for bass plugins. diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index ac14bb2..95a824a 100644 --- a/src/discord_rich_presence.cpp +++ b/src/discord_rich_presence.cpp @@ -2,6 +2,7 @@ namespace AttorneyOnline { +#ifdef DISCORD Discord::Discord() { DiscordEventHandlers handlers; @@ -99,5 +100,36 @@ void Discord::state_spectate() presence.state = "Spectating"; Discord_UpdatePresence(&presence); } +#else +Discord::Discord() +{ } + +Discord::~Discord() +{ + +} + +void Discord::state_lobby() +{ + +} + +void Discord::state_server(std::string name, std::string server_id) +{ + qDebug() << "Discord RPC: Setting server state"; +} + +void Discord::state_character(std::string name) +{ + qDebug() << "Discord RPC: Setting character state"; +} + +void Discord::state_spectate() +{ + qDebug() << "Discord RPC: Setting specator state"; + +} +#endif +} diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 18c43ac..7247625 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -453,8 +453,9 @@ QString AOApplication::get_chat(QString p_char) QString AOApplication::get_char_shouts(QString p_char) { QString f_result = read_char_ini(p_char, "shouts", "Options"); - - return f_result; + if (f_result == "") + return "default"; + else return f_result; } int AOApplication::get_preanim_duration(QString p_char, QString p_emote)