From 5224c301ac690a2e56cd437cdcf478128ace9a6c Mon Sep 17 00:00:00 2001 From: Chrezm Date: Fri, 5 Nov 2021 09:09:21 -0400 Subject: [PATCH 1/6] Test --- dronline-client.pro | 2 +- src/aoblipplayer.cpp | 6 +++--- src/aoconfigpanel.cpp | 6 +++--- src/courtroom.cpp | 4 ++-- src/courtroom_sfx.cpp | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dronline-client.pro b/dronline-client.pro index 8fd003532..e23cc99d0 100644 --- a/dronline-client.pro +++ b/dronline-client.pro @@ -147,5 +147,5 @@ FORMS += \ res/ui/config_panel.ui # Mac stuff -QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.14 +QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12 ICON = icon.icns diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index 5385b29ad..3f0150c9a 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -12,16 +12,16 @@ AOBlipPlayer::AOBlipPlayer(AOApplication *p_ao_app, QObject *p_parent) : AOObjec void AOBlipPlayer::set_blips(QString p_blip) { - if (m_name.has_value() && m_name.value() == p_blip) + if (m_name.has_value() && m_name.value_or("") == p_blip) return; m_name = p_blip; - m_file = ao_app->get_sounds_path(m_name.value()); + m_file = ao_app->get_sounds_path(m_name.value_or("")); } void AOBlipPlayer::blip_tick() { if (!m_file.has_value()) return; - m_family->play_stream(m_file.value()); + m_family->play_stream(m_file.value_or("")); } diff --git a/src/aoconfigpanel.cpp b/src/aoconfigpanel.cpp index 8039f4ff2..8c864349b 100644 --- a/src/aoconfigpanel.cpp +++ b/src/aoconfigpanel.cpp @@ -387,10 +387,10 @@ void AOConfigPanel::update_audio_device_list() ui_device->addItem(i_device.get_name(), i_device.get_driver()); int item_index = ui_device->count() - 1; - if (current_device.has_value() && current_device.value().get_driver() == i_device.get_driver()) + if (current_device.has_value() && current_device.value_or(nullptr).get_driver() == i_device.get_driver()) current_device_index = item_index; - if (favorite_device.has_value() && favorite_device.value().get_driver() == i_device.get_driver()) + if (favorite_device.has_value() && favorite_device.value_or(DRAudioDevice()).get_driver() == i_device.get_driver()) ui_device->setItemData(item_index, QColor(Qt::green), Qt::BackgroundRole); } @@ -401,7 +401,7 @@ void AOConfigPanel::update_audio_device_list() } if (current_device_index.has_value()) - ui_device->setCurrentIndex(current_device_index.value()); + ui_device->setCurrentIndex(current_device_index.value_or(nullptr)); } void AOConfigPanel::on_reload_theme_clicked() diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 0e9eb0752..350f0b1a9 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1038,7 +1038,7 @@ void Courtroom::load_ic_text_format() if (const std::optional l_color = ao_app->maybe_color(QString("ic_chatlog_%1_color").arg(f_identifier), COURTROOM_FONTS_INI); l_color.has_value()) - f_format.setForeground(l_color.value()); + f_format.setForeground(l_color.value_or(QColor())); if (ao_app->get_font_property(QString("ic_chatlog_%1_bold").arg(f_identifier), COURTROOM_FONTS_INI)) f_format.setFontWeight(QFont::Bold); @@ -1299,7 +1299,7 @@ void Courtroom::calculate_chat_tick_interval() { double l_tick_rate = ao_config->chat_tick_interval(); if (m_server_tick_rate.has_value()) - l_tick_rate = qMax(m_server_tick_rate.value(), 0); + l_tick_rate = qMax(m_server_tick_rate.value_or(0), 0); l_tick_rate = qBound(0.0, l_tick_rate * (1.0 - qBound(-1.0, 0.4 * m_tick_speed, 1.0)), l_tick_rate * 2.0); m_tick_timer->setInterval(l_tick_rate); } diff --git a/src/courtroom_sfx.cpp b/src/courtroom_sfx.cpp index 7cf4a140d..1f6fc82b2 100644 --- a/src/courtroom_sfx.cpp +++ b/src/courtroom_sfx.cpp @@ -25,7 +25,7 @@ QString Courtroom::current_sfx_file() const std::optional l_optional_sfx = current_sfx(); if (!l_optional_sfx.has_value()) return l_current_emote_file; - const QString l_file = l_optional_sfx.value().file; + const QString l_file = l_optional_sfx.value_or(DRSfx("Silence", nullptr)).file; return l_file == m_sfx_default_file ? l_current_emote_file : l_file; } From 595b285a53b467502c1c0528a9c96a1a87c73216 Mon Sep 17 00:00:00 2001 From: Chrezm Date: Fri, 5 Nov 2021 11:33:26 -0400 Subject: [PATCH 2/6] Test2 --- src/aoconfig.cpp | 6 +++--- src/aoconfigpanel.cpp | 4 ++-- src/draudioengine.cpp | 6 +++--- src/draudioengine_p.cpp | 4 ++-- src/draudiostream.cpp | 20 ++++++++++---------- src/draudiostreamfamily.cpp | 7 ++++--- src/drdiscord.cpp | 12 ++++++------ 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/aoconfig.cpp b/src/aoconfig.cpp index 2fb58a8af..e46b13c65 100644 --- a/src/aoconfig.cpp +++ b/src/aoconfig.cpp @@ -217,7 +217,7 @@ void AOConfigPrivate::save_file() // audio if (favorite_device_driver.has_value()) - cfg.setValue("favorite_device_driver", favorite_device_driver.value()); + cfg.setValue("favorite_device_driver", favorite_device_driver.value_or("")); cfg.setValue("suppress_background_audio", suppress_background_audio); cfg.setValue("default_master", master_volume); @@ -256,7 +256,7 @@ void AOConfigPrivate::update_favorite_device() { if (!favorite_device_driver.has_value()) return; - audio_engine->set_favorite_device_by_driver(favorite_device_driver.value()); + audio_engine->set_favorite_device_by_driver(favorite_device_driver.value_or("")); } void AOConfigPrivate::on_application_state_changed(Qt::ApplicationState p_state) @@ -811,7 +811,7 @@ void AOConfig::set_suppress_background_audio(bool p_enabled) void AOConfig::set_favorite_device_driver(QString p_device_driver) { - if (d->favorite_device_driver.has_value() && d->favorite_device_driver.value() == p_device_driver) + if (d->favorite_device_driver.has_value() && d->favorite_device_driver.value_or("") == p_device_driver) return; d->favorite_device_driver = p_device_driver; d->update_favorite_device(); diff --git a/src/aoconfigpanel.cpp b/src/aoconfigpanel.cpp index bc2d5f4e0..36db1ad6a 100644 --- a/src/aoconfigpanel.cpp +++ b/src/aoconfigpanel.cpp @@ -380,7 +380,7 @@ void AOConfigPanel::update_audio_device_list() ui_device->addItem(i_device.get_name(), i_device.get_driver()); int item_index = ui_device->count() - 1; - if (current_device.has_value() && current_device.value_or(nullptr).get_driver() == i_device.get_driver()) + if (current_device.has_value() && current_device.value_or(DRAudioDevice()).get_driver() == i_device.get_driver()) current_device_index = item_index; if (favorite_device.has_value() && favorite_device.value_or(DRAudioDevice()).get_driver() == i_device.get_driver()) @@ -394,7 +394,7 @@ void AOConfigPanel::update_audio_device_list() } if (current_device_index.has_value()) - ui_device->setCurrentIndex(current_device_index.value_or(nullptr)); + ui_device->setCurrentIndex(current_device_index.value_or(0)); } void AOConfigPanel::on_reload_theme_clicked() diff --git a/src/draudioengine.cpp b/src/draudioengine.cpp index 882f9b5fd..05aa015f4 100644 --- a/src/draudioengine.cpp +++ b/src/draudioengine.cpp @@ -120,15 +120,15 @@ void DRAudioEngine::set_device(DRAudioDevice p_device) d->previous_device = d->device; d->device = d->device_map.value(p_device.get_driver()); d->update_device(); - Q_EMIT d->invoke_signal("device_changed", Q_ARG(DRAudioDevice, d->device.value())); + Q_EMIT d->invoke_signal("device_changed", Q_ARG(DRAudioDevice, d->device.value_or(DRAudioDevice()))); } void DRAudioEngine::set_favorite_device(DRAudioDevice p_device) { - if (d->favorite_device.has_value() && d->favorite_device.value().get_driver() == p_device.get_driver()) + if (d->favorite_device.has_value() && d->favorite_device.value_or(DRAudioDevice()).get_driver() == p_device.get_driver()) return; d->favorite_device = p_device; - Q_EMIT d->invoke_signal("favorite_device_changed", Q_ARG(DRAudioDevice, d->favorite_device.value())); + Q_EMIT d->invoke_signal("favorite_device_changed", Q_ARG(DRAudioDevice, d->favorite_device.value_or(DRAudioDevice()))); } void DRAudioEngine::set_favorite_device_by_driver(QString p_device_driver) diff --git a/src/draudioengine_p.cpp b/src/draudioengine_p.cpp index 8a7742d09..a44341a3a 100644 --- a/src/draudioengine_p.cpp +++ b/src/draudioengine_p.cpp @@ -133,7 +133,7 @@ void DRAudioEnginePrivate::on_event_tick() if (!i_device.is_enabled()) continue; - if (favorite_device && favorite_device.value().get_driver() == i_device.get_driver()) + if (favorite_device && favorite_device.value_or(DRAudioDevice()).get_driver() == i_device.get_driver()) { // if our favorite device doesn't have an id then // it was most likely set through the driver @@ -159,5 +159,5 @@ void DRAudioEnginePrivate::on_event_tick() #endif return; } - engine->set_device(target_device.value()); + engine->set_device(target_device.value_or(DRAudioDevice())); } diff --git a/src/draudiostream.cpp b/src/draudiostream.cpp index a89323e99..369e3cfb3 100644 --- a/src/draudiostream.cpp +++ b/src/draudiostream.cpp @@ -17,7 +17,7 @@ DRAudioStream::~DRAudioStream() { if (m_hstream.has_value()) { - const HSTREAM hstream = m_hstream.value(); + const HSTREAM hstream = m_hstream.value_or(0); while (!m_hsync_stack.empty()) { @@ -43,18 +43,18 @@ bool DRAudioStream::is_playing() const { if (!m_hstream.has_value()) return false; - return BASS_ChannelIsActive(m_hstream.value()) == BASS_ACTIVE_PLAYING; + return BASS_ChannelIsActive(m_hstream.value_or(0)) == BASS_ACTIVE_PLAYING; } void DRAudioStream::play() { if (!m_hstream.has_value()) return; - const BOOL result = BASS_ChannelPlay(m_hstream.value(), FALSE); + const BOOL result = BASS_ChannelPlay(m_hstream.value_or(0), FALSE); if (result == FALSE) { qWarning() << DRAudioError( - QString("failed to play file %1: %2").arg(m_file.value()).arg(DRAudio::get_last_bass_error())) + QString("failed to play file %1: %2").arg(m_file.value_or("")).arg(DRAudio::get_last_bass_error())) .what(); Q_EMIT finished(); } @@ -64,7 +64,7 @@ void DRAudioStream::stop() { if (!m_hstream.has_value()) return; - BASS_ChannelStop(m_hstream.value()); + BASS_ChannelStop(m_hstream.value_or(0)); Q_EMIT finished(); } @@ -113,7 +113,7 @@ void DRAudioStream::set_volume(float p_volume) if (!m_hstream.has_value()) return; m_volume = p_volume; - BASS_ChannelSetAttribute(m_hstream.value(), BASS_ATTRIB_VOL, float(p_volume) * 0.01f); + BASS_ChannelSetAttribute(m_hstream.value_or(0), BASS_ATTRIB_VOL, float(p_volume) * 0.01f); } #include @@ -153,8 +153,8 @@ void DRAudioStream::cache_position() return; if (m_position.has_value()) return; - m_position = BASS_ChannelGetPosition(m_hstream.value(), BASS_POS_BYTE); - BASS_ChannelStop(m_hstream.value()); + m_position = BASS_ChannelGetPosition(m_hstream.value_or(0), BASS_POS_BYTE); + BASS_ChannelStop(m_hstream.value_or(0)); } void DRAudioStream::on_device_error() @@ -173,7 +173,7 @@ void DRAudioStream::update_device() if (is_playing()) return; - const QString file = m_file.value(); + const QString file = m_file.value_or(""); m_file.reset(); m_hstream.reset(); @@ -186,7 +186,7 @@ void DRAudioStream::update_device() if (m_position.has_value()) { - if (BASS_ChannelSetPosition(m_hstream.value(), m_position.value(), BASS_POS_BYTE) == FALSE) + if (BASS_ChannelSetPosition(m_hstream.value_or(0), m_position.value_or(0), BASS_POS_BYTE) == FALSE) qWarning() << DRAudioError( QString("failed to set position for %1: %2").arg(file).arg(DRAudio::get_last_bass_error())) .what(); diff --git a/src/draudiostreamfamily.cpp b/src/draudiostreamfamily.cpp index 4b0e72657..5c81b3797 100644 --- a/src/draudiostreamfamily.cpp +++ b/src/draudiostreamfamily.cpp @@ -100,8 +100,9 @@ std::optional DRAudioStreamFamily::play_stream(QString p_fil std::optional r_stream = create_stream(p_file); if (r_stream.has_value()) { - auto stream = r_stream.value(); - qWarning() << "playing" << stream->get_file().value(); + DRAudioStream::ptr default_stream(new DRAudioStream(m_family)); + auto stream = r_stream.value_or(default_stream); + qWarning() << "playing" << stream->get_file().value_or(""); stream->play(); } return r_stream; @@ -163,7 +164,7 @@ void DRAudioStreamFamily::on_stream_finished() return; if (auto file = invoker->get_file(); file) - qInfo() << "removing" << file.value(); + qInfo() << "removing" << file.value_or(""); else qWarning() << "removing unspecified stream"; diff --git a/src/drdiscord.cpp b/src/drdiscord.cpp index b3b726881..caa6bf2ea 100644 --- a/src/drdiscord.cpp +++ b/src/drdiscord.cpp @@ -174,10 +174,10 @@ void DRDiscord::set_state(const DRDiscord::State f_state) void DRDiscord::set_server_name(const QString &f_server_name) { Q_ASSERT_X(!f_server_name.trimmed().isEmpty(), "DRDiscord", "a server name is required"); - if (m_server_name.has_value() && m_server_name.value() == f_server_name) + if (m_server_name.has_value() && m_server_name.value_or("") == f_server_name) return; m_server_name = f_server_name; - Q_EMIT server_name_changed(m_server_name.value()); + Q_EMIT server_name_changed(m_server_name.value_or("")); } void DRDiscord::clear_server_name() @@ -189,10 +189,10 @@ void DRDiscord::clear_server_name() void DRDiscord::set_character_name(const QString &f_character_name) { Q_ASSERT_X(!f_character_name.trimmed().isEmpty(), "DRDiscord", "a server name is required"); - if (m_character_name.has_value() && m_character_name.value() == f_character_name) + if (m_character_name.has_value() && m_character_name.value_or("") == f_character_name) return; m_character_name = f_character_name; - Q_EMIT character_name_changed(m_character_name.value()); + Q_EMIT character_name_changed(m_character_name.value_or("")); } void DRDiscord::clear_character_name() @@ -226,7 +226,7 @@ void DRDiscord::on_update_queued() if (!hide_server_enabled()) { m_buf_details = QString("In: %1") - .arg(m_server_name.has_value() ? m_server_name.value().toUtf8() : QString("")) + .arg(m_server_name.has_value() ? m_server_name.value_or("").toUtf8() : QString("")) .toUtf8(); } @@ -234,7 +234,7 @@ void DRDiscord::on_update_queued() if (!hide_character_enabled()) { m_buf_state.clear(); - m_buf_state = m_character_name.has_value() ? QString("As: %1").arg(m_character_name.value()).toUtf8() + m_buf_state = m_character_name.has_value() ? QString("As: %1").arg(m_character_name.value_or("")).toUtf8() : QByteArray("Spectating"); } break; From 78f4df9fd225404af0585e158782982acc17a387 Mon Sep 17 00:00:00 2001 From: Chrezm <42015761+Chrezm@users.noreply.github.com> Date: Fri, 5 Nov 2021 11:52:17 -0400 Subject: [PATCH 3/6] Downgrade Qt version for MacOS 10.12 to 5.12.9 --- .github/workflows/build-all.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml index 7aefaff63..f86411c3a 100644 --- a/.github/workflows/build-all.yml +++ b/.github/workflows/build-all.yml @@ -196,13 +196,13 @@ jobs: - name: Install Qt uses: jurplel/install-qt-action@v2 with: - version: '5.14.2' + version: '5.12.9' - name: Run qmake shell: bash working-directory: ${{env.parentworkspace}} run: | - ./Qt/5.14.2/clang_64/bin/qmake -makefile -o Makefile ./DRO-Client/dronline-client.pro -spec macx-clang "CONFIG+=x86_64" "CONFIG+=qtquickcompiler" + ./Qt/5.12.9/clang_64/bin/qmake -makefile -o Makefile ./DRO-Client/dronline-client.pro -spec macx-clang "CONFIG+=x86_64" "CONFIG+=qtquickcompiler" - name: Run make shell: bash @@ -223,7 +223,7 @@ jobs: working-directory: "${{env.parentworkspace}}/Danganronpa Online" shell: bash run: | - ../Qt/5.14.2/clang_64/bin/macdeployqt "Danganronpa Online.app" + ../Qt/5.12.9/clang_64/bin/macdeployqt "Danganronpa Online.app" cp ../discord-rpc/osx-dynamic/lib/libdiscord-rpc.dylib "./Danganronpa Online.app/Contents/Frameworks/" cp ../discord-rpc/osx-dynamic/lib/libdiscord-rpc.dylib "./Danganronpa Online.app/Contents/MacOS/" cp ../libbass.dylib "./Danganronpa Online.app/Contents/Frameworks/" From 74c2bc25d7f3c23b064864e9bb6d65ec644c5b66 Mon Sep 17 00:00:00 2001 From: Chrezm <42015761+Chrezm@users.noreply.github.com> Date: Sun, 6 Feb 2022 09:28:32 -0500 Subject: [PATCH 4/6] Update build-all.yml --- .github/workflows/build-all.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml index b9722b25f..1eb8beaa2 100644 --- a/.github/workflows/build-all.yml +++ b/.github/workflows/build-all.yml @@ -218,6 +218,7 @@ jobs: - name: Install Qt uses: jurplel/install-qt-action@v2 with: + version: '5.12.9' - name: Setup branch and commit hash tags shell: bash From 524ac81b3fa313982910a129c5f339f8efbf8253 Mon Sep 17 00:00:00 2001 From: Chrezm Date: Sun, 6 Feb 2022 09:49:26 -0500 Subject: [PATCH 5/6] Fix more features not available in 0) { - BASS_ChannelRemoveSync(m_hstream.value(), m_loop_sync); + BASS_ChannelRemoveSync(m_hstream.value_or(default_stream), m_loop_sync); m_loop_sync = 0; } @@ -110,13 +111,13 @@ void DRAudioStream::setup_looping() double l_sample_rate = 0.0; if (float l_float_sample_rate = 0.0f; - BASS_ChannelGetAttribute(m_hstream.value(), BASS_ATTRIB_FREQ, &l_float_sample_rate)) + BASS_ChannelGetAttribute(m_hstream.value_or(default_stream), BASS_ATTRIB_FREQ, &l_float_sample_rate)) l_sample_rate = double(l_float_sample_rate); if (qFabs(l_sample_rate) == 0.0) return; // Now sample_rate holds the sample rate in hertz - const char *ogg_value = BASS_ChannelGetTags(m_hstream.value(), BASS_TAG_OGG); + const char *ogg_value = BASS_ChannelGetTags(m_hstream.value_or(default_stream), BASS_TAG_OGG); QStringList ogg_comments; while (*ogg_value) { @@ -141,10 +142,10 @@ void DRAudioStream::setup_looping() // If we are at this point, we are successful in fetching all required values - m_loop_start = BASS_ChannelSeconds2Bytes(m_hstream.value(), loop_start / l_sample_rate); - m_loop_end = BASS_ChannelSeconds2Bytes(m_hstream.value(), loop_end / l_sample_rate); + m_loop_start = BASS_ChannelSeconds2Bytes(m_hstream.value_or(default_stream), loop_start / l_sample_rate); + m_loop_end = BASS_ChannelSeconds2Bytes(m_hstream.value_or(default_stream), loop_end / l_sample_rate); - m_loop_sync = BASS_ChannelSetSync(m_hstream.value(), BASS_SYNC_POS | BASS_SYNC_MIXTIME, m_loop_end, &loop_sync, this); + m_loop_sync = BASS_ChannelSetSync(m_hstream.value_or(default_stream), BASS_SYNC_POS | BASS_SYNC_MIXTIME, m_loop_end, &loop_sync, this); } std::optional DRAudioStream::set_file(QString p_file) From 4ea7cc0905c960fe0ce3c64a68722ccfc92ff6e4 Mon Sep 17 00:00:00 2001 From: Chrezm Date: Sun, 6 Feb 2022 10:14:53 -0500 Subject: [PATCH 6/6] Add necessary framework library for MacOS --- dronline-client.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dronline-client.pro b/dronline-client.pro index d1dfbf004..e507a7d21 100644 --- a/dronline-client.pro +++ b/dronline-client.pro @@ -149,3 +149,6 @@ FORMS += \ # Mac stuff QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12 ICON = icon.icns +macx { + LIBS += -framework CoreFoundation +}