Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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/"
Expand Down
5 changes: 4 additions & 1 deletion dronline-client.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions src/aoblipplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(""));
}
6 changes: 3 additions & 3 deletions src/aoconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/aoconfigpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ void Courtroom::load_ic_text_format()
if (const std::optional<QColor> 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);
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/courtroom_sfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ QString Courtroom::current_sfx_file()
const std::optional<DRSfx> 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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/draudioengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/draudioengine_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()));
}
33 changes: 17 additions & 16 deletions src/draudiostream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -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();
}
Expand All @@ -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();
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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)
{
Expand All @@ -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<DRAudioError> DRAudioStream::set_file(QString p_file)
Expand Down Expand Up @@ -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 <QTimer>
Expand Down Expand Up @@ -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()
Expand All @@ -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();
Expand All @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions src/draudiostreamfamily.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ std::optional<DRAudioStream::ptr> DRAudioStreamFamily::play_stream(QString p_fil
std::optional<DRAudioStream::ptr> 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;
Expand Down Expand Up @@ -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";

Expand Down
12 changes: 6 additions & 6 deletions src/drdiscord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -226,15 +226,15 @@ 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("<private>"))
.arg(m_server_name.has_value() ? m_server_name.value_or("").toUtf8() : QString("<private>"))
.toUtf8();
}

m_buf_state.clear();
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;
Expand Down