diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/aomusicplayer.cpp | 22 | ||||
| -rw-r--r-- | src/aopacket.cpp | 54 | ||||
| -rw-r--r-- | src/courtroom.cpp | 34 | ||||
| -rw-r--r-- | src/lobby.cpp | 2 | ||||
| -rw-r--r-- | src/path_functions.cpp | 3 |
5 files changed, 56 insertions, 59 deletions
diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index 6c61b9ad..585a7f42 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -23,14 +23,26 @@ void AOMusicPlayer::play(QString p_song, int channel, bool loop, unsigned int flags = BASS_STREAM_PRESCAN | BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE; - if (loop) + unsigned int streaming_flags = BASS_STREAM_AUTOFREE; + if (loop) { flags |= BASS_SAMPLE_LOOP; + streaming_flags |= BASS_SAMPLE_LOOP; + } DWORD newstream; - if (f_path.endsWith(".opus")) - newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); - else - newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); + if (f_path.startsWith("http")) { + if (f_path.endsWith(".opus")) + newstream = BASS_OPUS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0); + else + newstream = BASS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0); + + } else { + if (f_path.endsWith(".opus")) + newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); + else + newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); + } + if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice()); diff --git a/src/aopacket.cpp b/src/aopacket.cpp index 4cf43e1d..bb6ac73b 100644 --- a/src/aopacket.cpp +++ b/src/aopacket.cpp @@ -4,59 +4,27 @@ AOPacket::AOPacket(QString p_packet_string) { QStringList packet_contents = p_packet_string.split("#"); - m_header = packet_contents.at(0); - - for (int n_string = 1; n_string < packet_contents.size() - 1; ++n_string) { - m_contents.append(packet_contents.at(n_string)); - } -} - -AOPacket::AOPacket(QString p_header, QStringList &p_contents) -{ - m_header = p_header; - m_contents = p_contents; + m_header = packet_contents.first(); + m_contents = packet_contents.mid(1, packet_contents.size()-2); // trims % } -AOPacket::~AOPacket() {} - QString AOPacket::to_string() { - QString f_string = m_header; - - for (QString i_string : m_contents) { - f_string += ("#" + i_string); - } - - f_string += "#%"; - - - return f_string; + return m_header + "#" + m_contents.join("#") + "#%"; } void AOPacket::net_encode() { - for (int n_element = 0; n_element < m_contents.size(); ++n_element) { - QString f_element = m_contents.at(n_element); - f_element.replace("#", "<num>") - .replace("%", "<percent>") - .replace("$", "<dollar>") - .replace("&", "<and>"); - - m_contents.removeAt(n_element); - m_contents.insert(n_element, f_element); - } + m_contents.replaceInStrings("#", "<num>") + .replaceInStrings("%", "<percent>") + .replaceInStrings("$", "<dollar>") + .replaceInStrings("&", "<and>"); } void AOPacket::net_decode() { - for (int n_element = 0; n_element < m_contents.size(); ++n_element) { - QString f_element = m_contents.at(n_element); - f_element.replace("<num>", "#") - .replace("<percent>", "%") - .replace("<dollar>", "$") - .replace("<and>", "&"); - - m_contents.removeAt(n_element); - m_contents.insert(n_element, f_element); - } + m_contents.replaceInStrings("<num>", "#") + .replaceInStrings("<percent>", "%") + .replaceInStrings("<dollar>", "$") + .replaceInStrings("<and>", "&"); } diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 95189112..ba13e216 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2619,7 +2619,7 @@ void Courtroom::log_ic_text(QString p_name, QString p_showname, } void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, - int color) + int color, QDateTime timestamp) { QTextCharFormat bold; QTextCharFormat normal; @@ -2645,10 +2645,14 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, } // Timestamp if we're doing that meme - if (log_timestamp) - ui_ic_chatlog->textCursor().insertText( - "[" + QDateTime::currentDateTime().toString("h:mm:ss AP") + "] ", - normal); + if (log_timestamp) { + if (timestamp.isValid()) { + ui_ic_chatlog->textCursor().insertText( + "[" + timestamp.toString("h:mm:ss AP") + "] ", normal); + } else { + qDebug() << "could not insert invalid timestamp"; + } + } // Format the name of the actor ui_ic_chatlog->textCursor().insertText(p_name, bold); @@ -3573,9 +3577,10 @@ void Courtroom::on_ooc_return_pressed() if (!caseauth.isEmpty()) append_server_chatmessage(tr("CLIENT"), tr("Case made by %1.").arg(caseauth), "1"); - if (!casedoc.isEmpty()) - ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + - "#/doc " + casedoc + "#%")); + if (!casedoc.isEmpty()) { + QStringList f_contents = {ui_ooc_chat_name->text(), "/doc " + casedoc}; + ao_app->send_server_packet(new AOPacket("CT", f_contents)); + } if (!casestatus.isEmpty()) ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/status " + casestatus + "#%")); @@ -3588,7 +3593,15 @@ void Courtroom::on_ooc_return_pressed() new AOPacket("DE#" + QString::number(i) + "#%")); } - foreach (QString evi, casefile.childGroups()) { + // sort the case_evidence numerically + QStringList case_evidence = casefile.childGroups(); + std::sort(case_evidence.begin(), case_evidence.end(), + [] (const QString &a, const QString &b) { + return a.toInt() < b.toInt(); + }); + + // load evidence + foreach (QString evi, case_evidence) { if (evi == "General") continue; @@ -4780,7 +4793,8 @@ void Courtroom::regenerate_ic_chatlog() append_ic_text(item.get_message(), ui_showname_enable->isChecked() ? item.get_showname() : item.get_name(), - item.get_action(), item.get_chat_color()); + item.get_action(), item.get_chat_color(), + item.get_datetime().toLocalTime()); } } diff --git a/src/lobby.cpp b/src/lobby.cpp index 79a565a8..afbf221e 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -356,7 +356,7 @@ void Lobby::on_connect_released() void Lobby::on_about_clicked() { - const bool hasApng = QImageReader::supportedImageFormats().contains("APNG"); + const bool hasApng = QImageReader::supportedImageFormats().contains("apng"); QString msg = tr("<h2>Attorney Online %1</h2>" diff --git a/src/path_functions.cpp b/src/path_functions.cpp index b1d79762..c6c73a8b 100644 --- a/src/path_functions.cpp +++ b/src/path_functions.cpp @@ -73,6 +73,9 @@ QString AOApplication::get_sounds_path(QString p_file) QString AOApplication::get_music_path(QString p_song) { + if (p_song.startsWith("http")) { + return p_song; // url + } QString path = get_base_path() + "sounds/music/" + p_song; return get_case_sensitive_path(path); } |
