diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml index a66326873..1eb8beaa2 100644 --- a/.github/workflows/build-all.yml +++ b/.github/workflows/build-all.yml @@ -218,7 +218,7 @@ jobs: - name: Install Qt uses: jurplel/install-qt-action@v2 with: - version: '5.15.2' + version: '5.12.9' - name: Setup branch and commit hash tags shell: bash @@ -233,7 +233,7 @@ jobs: shell: bash working-directory: ${{env.parentworkspace}} run: | - ./Qt/5.15.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 @@ -254,7 +254,7 @@ jobs: working-directory: "${{env.parentworkspace}}/Danganronpa Online" shell: bash run: | - ../Qt/5.15.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/" diff --git a/dronline-client.pro b/dronline-client.pro index af54f6f2d..e507a7d21 100644 --- a/dronline-client.pro +++ b/dronline-client.pro @@ -147,5 +147,8 @@ FORMS += \ res/ui/config_panel.ui # Mac stuff -QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.14 +QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12 ICON = icon.icns +macx { + LIBS += -framework CoreFoundation +} 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/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 cca089ef1..abd1891f4 100644 --- a/src/aoconfigpanel.cpp +++ b/src/aoconfigpanel.cpp @@ -386,10 +386,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(DRAudioDevice()).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); } @@ -400,7 +400,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(0)); } void AOConfigPanel::on_reload_theme_clicked() diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 21142b8fd..2bffe46fd 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1017,7 +1017,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); @@ -1270,7 +1270,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 0aa5a8017..9c5881222 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; } 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 82c74576a..f8e7e2185 100644 --- a/src/draudiostream.cpp +++ b/src/draudiostream.cpp @@ -18,7 +18,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()) { @@ -44,18 +44,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(); } @@ -66,7 +66,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(); } @@ -97,10 +97,11 @@ void DRAudioStream::setup_looping() // Remove all previously set loop information m_loop_start = {}; m_loop_end = {}; + HSTREAM default_stream; if (m_loop_sync > 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) @@ -192,7 +193,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 @@ -232,8 +233,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() @@ -252,7 +253,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(); @@ -265,7 +266,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;