diff options
| -rw-r--r-- | .travis.yml | 1 | ||||
| -rw-r--r-- | include/aoapplication.h | 9 | ||||
| -rw-r--r-- | include/aoblipplayer.h | 6 | ||||
| -rw-r--r-- | include/aooptionsdialog.h | 6 | ||||
| -rw-r--r-- | include/aosfxplayer.h | 9 | ||||
| -rw-r--r-- | include/courtroom.h | 1 | ||||
| -rw-r--r-- | include/lobby.h | 3 | ||||
| -rwxr-xr-x | scripts/macos_build.sh | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | scripts/macos_post_build.sh | 2 | ||||
| -rw-r--r-- | src/aoblipplayer.cpp | 30 | ||||
| -rw-r--r-- | src/aooptionsdialog.cpp | 12 | ||||
| -rw-r--r-- | src/aosfxplayer.cpp | 33 | ||||
| -rw-r--r-- | src/courtroom.cpp | 14 | ||||
| -rw-r--r-- | src/hardware_functions.cpp | 25 | ||||
| -rw-r--r-- | src/lobby.cpp | 13 | ||||
| -rw-r--r-- | src/packet_distribution.cpp | 4 | ||||
| -rw-r--r-- | src/path_functions.cpp | 2 |
17 files changed, 138 insertions, 34 deletions
diff --git a/.travis.yml b/.travis.yml index 4243b3b9..36f31d59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ os: osx addons: homebrew: + update: true packages: - qt5 diff --git a/include/aoapplication.h b/include/aoapplication.h index af43cf3c..5475eb7b 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -23,6 +23,9 @@ #include <QStringList> #include <QColor> #include <QScreen> +#ifdef QTAUDIO +#include <QAudioDeviceInfo> +#endif class NetworkManager; class Lobby; @@ -173,6 +176,9 @@ public: // Returns the audio device used for the client. QString get_audio_output_device(); + #ifdef QTAUDIO + QAudioDeviceInfo QtAudioDevice; + #endif // Returns whether the user would like to have custom shownames on by default. bool get_showname_enabled_by_default(); @@ -196,8 +202,7 @@ public: pos_size_type get_element_dimensions(QString p_identifier, QString p_file); //Returns the name of the font with p_identifier from p_file - QString get_font_name(QString p_identifier, QString p_file); - + QString get_font_name(QString p_identifier, QString p_file); //Returns the value of font_size with p_identifier from p_file int get_font_size(QString p_identifier, QString p_file); diff --git a/include/aoblipplayer.h b/include/aoblipplayer.h index 102a0408..44ca48bb 100644 --- a/include/aoblipplayer.h +++ b/include/aoblipplayer.h @@ -21,15 +21,17 @@ public: void set_blips(QString p_sfx); void blip_tick(); - void set_volume(int p_volume); + void set_volume(qreal p_volume); int m_cycle = 0; private: QWidget *m_parent; AOApplication *ao_app; + qreal m_volume; + + void set_volume_internal(qreal p_volume); - int m_volume; #if defined(BASSAUDIO) HSTREAM m_stream_list[5]; #elif defined(QTAUDIO) diff --git a/include/aooptionsdialog.h b/include/aooptionsdialog.h index 83b84cbc..934d2577 100644 --- a/include/aooptionsdialog.h +++ b/include/aooptionsdialog.h @@ -2,7 +2,13 @@ #define AOOPTIONSDIALOG_H #include "aoapplication.h" + +#ifdef BASSAUDIO #include "bass.h" +#elif defined QTAUDIO +#include <QAudio> +#include <QAudioDeviceInfo> +#endif #include <QtCore/QVariant> #include <QtWidgets/QApplication> diff --git a/include/aosfxplayer.h b/include/aosfxplayer.h index 4b976852..19d4bdf3 100644 --- a/include/aosfxplayer.h +++ b/include/aosfxplayer.h @@ -20,17 +20,20 @@ public: void play(QString p_sfx, QString p_char = "", QString shout = ""); void stop(); - void set_volume(int p_volume); + void set_volume(qreal p_volume); private: QWidget *m_parent; AOApplication *ao_app; + qreal m_volume = 0; + + void set_volume_internal(qreal p_volume); + #if defined(BASSAUDIO) HSTREAM m_stream; #elif defined(QTAUDIO) - QSoundEffect m_sfx; + QSoundEffect m_sfx; #endif - int m_volume = 0; }; #endif // AOSFXPLAYER_H diff --git a/include/courtroom.h b/include/courtroom.h index 99a090b0..f0b69967 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -10,6 +10,7 @@ #include "aomovie.h" #include "aocharmovie.h" #include "aomusicplayer.h" +#include "aooptionsdialog.h" #include "aosfxplayer.h" #include "aoblipplayer.h" #include "aoevidencebutton.h" diff --git a/include/lobby.h b/include/lobby.h index 19276a7d..4293ac36 100644 --- a/include/lobby.h +++ b/include/lobby.h @@ -75,6 +75,8 @@ private: QProgressBar *ui_progress_bar; AOButton *ui_cancel; + QModelIndex last_model; + void set_size_and_pos(QWidget *p_widget, QString p_identifier); private slots: @@ -89,6 +91,7 @@ private slots: void on_connect_released(); void on_about_clicked(); void on_server_list_clicked(QModelIndex p_model); + void on_server_list_doubleclicked(QModelIndex p_model); void on_chatfield_return_pressed(); }; diff --git a/scripts/macos_build.sh b/scripts/macos_build.sh index 22e2d457..efb7653f 100755 --- a/scripts/macos_build.sh +++ b/scripts/macos_build.sh @@ -30,4 +30,4 @@ tar -xvf apng.tar.xz cp clang_64/plugins/imageformats/libqapng.dylib ../lib cd .. -qmake && make -j2 +/usr/local/opt/qt/bin/qmake && make -j2 diff --git a/scripts/macos_post_build.sh b/scripts/macos_post_build.sh index 50acb408..25400bf5 100644..100755 --- a/scripts/macos_post_build.sh +++ b/scripts/macos_post_build.sh @@ -13,7 +13,7 @@ ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" cd ${ROOT_DIR} # This thing basically does all the work -macdeployqt ../bin/Attorney_Online.app +/usr/local/opt/qt/bin/macdeployqt ../bin/Attorney_Online.app # Need to add the dependencies cp ../lib/* ../bin/Attorney_Online.app/Contents/Frameworks diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index 4dfb895c..1c668ab4 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -18,7 +18,7 @@ void AOBlipPlayer::set_blips(QString p_sfx) m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE); } - set_volume(m_volume); + set_volume_internal(m_volume); } void AOBlipPlayer::blip_tick() @@ -34,11 +34,15 @@ void AOBlipPlayer::blip_tick() BASS_ChannelPlay(f_stream, false); } -void AOBlipPlayer::set_volume(int p_value) +void AOBlipPlayer::set_volume(qreal p_value) { - m_volume = p_value; + m_volume = p_value / 100; + set_volume_internal(m_volume); +} - float volume = p_value / 100.0f; +void AOBlipPlayer::set_volume_internal(qreal p_value) +{ + float volume = p_value; for (int n_stream = 0 ; n_stream < 5 ; ++n_stream) { @@ -61,7 +65,7 @@ void AOBlipPlayer::set_blips(QString p_sfx) m_blips.setSource(QUrl::fromLocalFile(f_path)); } - set_volume(m_volume); + set_volume_internal(m_volume); } void AOBlipPlayer::blip_tick() @@ -74,9 +78,14 @@ void AOBlipPlayer::blip_tick() m_blips.play(); } -void AOBlipPlayer::set_volume(int p_value) +void AOBlipPlayer::set_volume(qreal p_value) +{ + m_volume = p_value / 100; + set_volume_internal(m_volume); +} + +void AOBlipPlayer::set_volume_internal(qreal p_value) { - m_volume = p_value; m_blips.setVolume(m_volume); } #else //No audio @@ -96,7 +105,12 @@ void AOBlipPlayer::blip_tick() } -void AOBlipPlayer::set_volume(int p_value) +void AOBlipPlayer::set_volume(qreal p_value) +{ + +} + +void AOBlipPlayer::set_volume_internal(qreal p_value) { } diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index b5cb46fe..82507a1f 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -1,6 +1,5 @@ #include "aooptionsdialog.h" #include "aoapplication.h" -#include "bass.h" AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDialog(parent) { @@ -235,9 +234,6 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi // Let's fill out the combobox with the available audio devices. Or don't if there is no audio int a = 0; - #ifdef BASSAUDIO - BASS_DEVICEINFO info; - #endif if (needs_default_audiodev()) { @@ -245,12 +241,20 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi } #ifdef BASSAUDIO + BASS_DEVICEINFO info; for (a = 0; BASS_GetDeviceInfo(a, &info); a++) { ui_audio_device_combobox->addItem(info.name); if (p_ao_app->get_audio_output_device() == info.name) ui_audio_device_combobox->setCurrentIndex(ui_audio_device_combobox->count()-1); } + #elif defined QTAUDIO + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) + { + ui_audio_device_combobox->addItem(deviceInfo.deviceName()); + if (p_ao_app->get_audio_output_device() == deviceInfo.deviceName()) + ui_audio_device_combobox->setCurrentIndex(ui_audio_device_combobox->count()-1); + } #endif ui_audio_layout->setWidget(0, QFormLayout::FieldRole, ui_audio_device_combobox); diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 710d7a8a..ad8ced60 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -32,7 +32,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); - set_volume(m_volume); + set_volume_internal(m_volume); if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); @@ -44,11 +44,16 @@ void AOSfxPlayer::stop() BASS_ChannelStop(m_stream); } -void AOSfxPlayer::set_volume(int p_value) +void AOSfxPlayer::set_volume(qreal p_value) { - m_volume = p_value; - float volume = p_value / 100.0f; - BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); + m_volume = p_value / 100; + set_volume_internal(m_volume); +} + +void AOSfxPlayer::set_volume_internal(qreal p_value) +{ + float volume = p_value; + BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); } #elif defined(QTAUDIO) //Using Qt's QSoundEffect class AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) @@ -83,7 +88,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) { m_sfx.setSource(QUrl::fromLocalFile(f_path)); - set_volume(m_volume); + set_volume_internal(m_volume); m_sfx.play(); } @@ -94,9 +99,14 @@ void AOSfxPlayer::stop() m_sfx.stop(); } -void AOSfxPlayer::set_volume(int p_value) +void AOSfxPlayer::set_volume(qreal p_value) +{ + m_volume = p_value/100; + set_volume_internal(m_volume); +} + +void AOSfxPlayer::set_volume_internal(qreal p_value) { - m_volume = p_value; m_sfx.setVolume(m_volume); } #else @@ -116,7 +126,12 @@ void AOSfxPlayer::stop() } -void AOSfxPlayer::set_volume(int p_value) +void AOSfxPlayer::set_volume(qreal p_value) +{ + +} + +void AOSfxPlayer::set_volume_internal(qreal p_value) { } diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 54b1b2df..a1714163 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -28,6 +28,20 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() } } } + #elif defined QTAUDIO + + if (ao_app->get_audio_output_device() != "default") + { + foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) + { + if (ao_app->get_audio_output_device() == deviceInfo.deviceName()) + { + ao_app->QtAudioDevice = deviceInfo; + qDebug() << deviceInfo.deviceName() << "was set as the default audio output device."; + break; + } + } + } #endif keepalive_timer = new QTimer(this); diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp index 5d6b6ffa..bd6a6c3c 100644 --- a/src/hardware_functions.cpp +++ b/src/hardware_functions.cpp @@ -50,10 +50,31 @@ QString get_hdid() } #elif defined __APPLE__ +#include <CoreFoundation/CoreFoundation.h> +#include <IOKit/IOKitLib.h> + QString get_hdid() { - //hdids are broken at this point anyways - return "just a mac passing by"; + CFStringRef serial; + char buffer[64] = {0}; + QString hdid; + io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, + IOServiceMatching("IOPlatformExpertDevice")); + if (platformExpert) + { + CFTypeRef serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, + CFSTR(kIOPlatformSerialNumberKey), + kCFAllocatorDefault, 0); + if (serialNumberAsCFString) { + serial = (CFStringRef)serialNumberAsCFString; + } + if (CFStringGetCString(serial, buffer, 64, kCFStringEncodingUTF8)) { + hdid = buffer; + } + + IOObjectRelease(platformExpert); + } + return hdid; } #else diff --git a/src/lobby.cpp b/src/lobby.cpp index c95fd49c..6f257cec 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -47,6 +47,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() connect(ui_connect, SIGNAL(released()), this, SLOT(on_connect_released())); connect(ui_about, SIGNAL(clicked()), this, SLOT(on_about_clicked())); connect(ui_server_list, SIGNAL(clicked(QModelIndex)), this, SLOT(on_server_list_clicked(QModelIndex))); + connect(ui_server_list, SIGNAL(activated(QModelIndex)), this, SLOT(on_server_list_doubleclicked(QModelIndex))); connect(ui_chatmessage, SIGNAL(returnPressed()), this, SLOT(on_chatfield_return_pressed())); connect(ui_cancel, SIGNAL(clicked()), ao_app, SLOT(loading_cancelled())); @@ -282,9 +283,13 @@ void Lobby::on_about_clicked() QMessageBox::about(this, "About", msg); } +//clicked on an item in the serverlist void Lobby::on_server_list_clicked(QModelIndex p_model) { + if (p_model != last_model) + { server_type f_server; + last_model = p_model; int n_server = p_model.row(); if (n_server < 0) @@ -318,6 +323,14 @@ void Lobby::on_server_list_clicked(QModelIndex p_model) ui_connect->setEnabled(false); ao_app->net_manager->connect_to_server(f_server); + } +} + +//doubleclicked on an item in the serverlist so we'll connect right away +void Lobby::on_server_list_doubleclicked(QModelIndex p_model) +{ + on_server_list_clicked(p_model); + on_connect_released(); } void Lobby::on_chatfield_return_pressed() diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index b79ec309..40015fda 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -175,6 +175,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) s_pv = f_contents.at(0).toInt(); server_software = f_contents.at(1); + w_lobby->enable_connect_button(); + send_server_packet(new AOPacket("ID#AO2#" + get_version_string() + "#%")); } else if (header == "CT") @@ -214,8 +216,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet) casing_alerts_enabled = true; if (f_packet.contains("modcall_reason",Qt::CaseInsensitive)) modcall_reason_enabled = true; - - w_lobby->enable_connect_button(); } else if (header == "PN") { diff --git a/src/path_functions.cpp b/src/path_functions.cpp index c51cfde3..5eb97a32 100644 --- a/src/path_functions.cpp +++ b/src/path_functions.cpp @@ -30,6 +30,8 @@ QString AOApplication::get_base_path() QString external_storage = getenv("EXTERNAL_STORAGE"); base_path = external_storage + "/AO2/"; } +#elif defined __APPLE__ + base_path = applicationDirPath() + "/../../../base/"; #else base_path = applicationDirPath() + "/base/"; #endif |
