diff options
Diffstat (limited to 'src')
| -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 |
8 files changed, 108 insertions, 25 deletions
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 |
