diff options
| m--------- | base/themes | 0 | ||||
| -rw-r--r-- | include/aoapplication.h | 4 | ||||
| -rw-r--r-- | include/aomusicplayer.h | 6 | ||||
| -rw-r--r-- | include/aotextarea.h | 3 | ||||
| -rw-r--r-- | include/courtroom.h | 14 | ||||
| -rw-r--r-- | src/aoapplication.cpp | 25 | ||||
| -rw-r--r-- | src/aoimage.cpp | 2 | ||||
| -rw-r--r-- | src/aolayer.cpp | 4 | ||||
| -rw-r--r-- | src/aomusicplayer.cpp | 39 | ||||
| -rw-r--r-- | src/aotextarea.cpp | 17 | ||||
| -rw-r--r-- | src/charselect.cpp | 2 | ||||
| -rw-r--r-- | src/courtroom.cpp | 127 | ||||
| -rw-r--r-- | src/lobby.cpp | 4 | ||||
| -rw-r--r-- | src/main.cpp | 2 | ||||
| -rw-r--r-- | src/networkmanager.cpp | 4 | ||||
| -rw-r--r-- | src/packet_distribution.cpp | 8 | ||||
| -rw-r--r-- | src/text_file_functions.cpp | 10 |
17 files changed, 177 insertions, 94 deletions
diff --git a/base/themes b/base/themes -Subproject 7c036c09ddfadc2680a2c5dbfa188dc98142a42 +Subproject 0d8220b1912e841ecaaa8f47198c8406e41fb5b diff --git a/include/aoapplication.h b/include/aoapplication.h index 957d7f6b..ab738220 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -567,6 +567,10 @@ private slots: public slots: void server_disconnected(); void loading_cancelled(); + +signals: + void qt_log_message(QtMsgType type, const QMessageLogContext &context, + const QString &msg); }; #endif // AOAPPLICATION_H diff --git a/include/aomusicplayer.h b/include/aomusicplayer.h index f899b9a2..7c9bfb34 100644 --- a/include/aomusicplayer.h +++ b/include/aomusicplayer.h @@ -10,6 +10,8 @@ #include <QDebug> #include <QWidget> #include <string.h> +#include <QFuture> +#include <QFutureWatcher> class AOMusicPlayer { public: @@ -24,8 +26,10 @@ public: int loop_start[4] = {0, 0, 0, 0}; int loop_end[4] = {0, 0, 0, 0}; + QFutureWatcher<QString> music_watcher; + public slots: - int play(QString p_song, int channel = 0, bool loop = false, + QString play(QString p_song, int channel = 0, bool loop = false, int effect_flags = 0); void stop(int channel = 0); diff --git a/include/aotextarea.h b/include/aotextarea.h index 453e9659..d9a960db 100644 --- a/include/aotextarea.h +++ b/include/aotextarea.h @@ -12,7 +12,8 @@ public: AOTextArea(QWidget *p_parent = nullptr); void append_linked(QString p_message); - void append_chatmessage(QString p_name, QString p_message, QString p_colur); + void append_chatmessage(QString p_name, QString p_message, + QString p_name_colour, QString p_color = QString()); void append_error(QString p_message); private: diff --git a/include/courtroom.h b/include/courtroom.h index 4bc86242..8a41b605 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -57,6 +57,8 @@ #include <QTextCharFormat> #include <QElapsedTimer> +#include <QFuture> + #include <algorithm> #include <stack> @@ -214,8 +216,12 @@ public: void list_music(); void list_areas(); - // these are for OOC chat - void append_ms_chatmessage(QString f_name, QString f_message); + // Debug log (formerly master server chat log) + void debug_message_handler(QtMsgType type, const QMessageLogContext &context, + const QString &msg); + void append_debug_message(QString f_message); + + // OOC chat log void append_server_chatmessage(QString p_name, QString p_message, QString p_color); @@ -628,7 +634,7 @@ private: QTextEdit *ui_ic_chatlog; - AOTextArea *ui_ms_chatlog; + AOTextArea *ui_debug_log; AOTextArea *ui_server_chatlog; QListWidget *ui_mute_list; @@ -814,6 +820,8 @@ public slots: bool steno); void on_reload_theme_clicked(); + void update_ui_music_name(); + private slots: void start_chat_ticking(); void play_sfx(); diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp index 4a5ed52a..b50cc7ad 100644 --- a/src/aoapplication.cpp +++ b/src/aoapplication.cpp @@ -8,6 +8,15 @@ #include "aocaseannouncerdialog.h" #include "aooptionsdialog.h" +static QtMessageHandler original_message_handler; +static AOApplication *message_handler_context; +void message_handler(QtMsgType type, const QMessageLogContext &context, + const QString &msg) +{ + emit message_handler_context->qt_log_message(type, context, msg); + original_message_handler(type, context, msg); +} + AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv) { // Create the QSettings class that points to the config.ini. @@ -20,6 +29,9 @@ AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv) this, &AOApplication::ms_connect_finished); asset_lookup_cache.reserve(2048); + + message_handler_context = this; + original_message_handler = qInstallMessageHandler(message_handler); } AOApplication::~AOApplication() @@ -28,12 +40,13 @@ AOApplication::~AOApplication() destruct_courtroom(); delete discord; delete configini; + qInstallMessageHandler(original_message_handler); } void AOApplication::construct_lobby() { if (lobby_constructed) { - qDebug() << "W: lobby was attempted constructed when it already exists"; + qWarning() << "lobby was attempted constructed when it already exists"; return; } @@ -58,7 +71,7 @@ void AOApplication::construct_lobby() void AOApplication::destruct_lobby() { if (!lobby_constructed) { - qDebug() << "W: lobby was attempted destructed when it did not exist"; + qWarning() << "lobby was attempted destructed when it did not exist"; return; } @@ -70,7 +83,7 @@ void AOApplication::destruct_lobby() void AOApplication::construct_courtroom() { if (courtroom_constructed) { - qDebug() << "W: courtroom was attempted constructed when it already exists"; + qWarning() << "courtroom was attempted constructed when it already exists"; return; } @@ -87,14 +100,14 @@ void AOApplication::construct_courtroom() w_courtroom, &Courtroom::skip_clocks); } else { - qDebug() << "W: demo server did not exist during courtroom construction"; + qWarning() << "demo server did not exist during courtroom construction"; } } void AOApplication::destruct_courtroom() { if (!courtroom_constructed) { - qDebug() << "W: courtroom was attempted destructed when it did not exist"; + qWarning() << "courtroom was attempted destructed when it did not exist"; return; } @@ -232,7 +245,7 @@ void AOApplication::initBASS() BASS_Init(static_cast<int>(a), 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); load_bass_opus_plugin(); - qDebug() << info.name << "was set as the default audio output device."; + qInfo() << info.name << "was set as the default audio output device."; return; } } diff --git a/src/aoimage.cpp b/src/aoimage.cpp index 82e17b98..b84a279f 100644 --- a/src/aoimage.cpp +++ b/src/aoimage.cpp @@ -30,7 +30,7 @@ bool AOImage::set_image(QString p_image, QString p_misc) ao_app->default_theme, p_misc, "", "", is_static || !ao_app->get_animated_theme()); if (!file_exists(p_image)) { - qDebug() << "Warning: Image" << p_image << "not found! Can't set!"; + qWarning() << "Image" << p_image << "not found! Can't set!"; return false; } path = p_image; diff --git a/src/aolayer.cpp b/src/aolayer.cpp index dd1fe76c..1587d289 100644 --- a/src/aolayer.cpp +++ b/src/aolayer.cpp @@ -437,7 +437,7 @@ void CharLayer::load_network_effects() continue; int f_frame = frame_split.at(0).toInt(); if (f_frame >= max_frames || f_frame < 0) { - qDebug() << "Warning: out of bounds" << effects_list[i] << "frame" + qWarning() << "out of bounds" << effects_list[i] << "frame" << f_frame << "out of" << max_frames << "for" << m_emote; continue; } @@ -461,7 +461,7 @@ void CharLayer::load_network_effects() void CharLayer::play_frame_effect(int p_frame) { if (p_frame >= movie_effects.size()) { - qDebug() << "W: Attempted to play a frame effect bigger than the size of movie_effects"; + qWarning() << "Attempted to play a frame effect bigger than the size of movie_effects"; return; } if (p_frame < max_frames) { diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index d0d95635..16d6df7a 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -13,12 +13,13 @@ AOMusicPlayer::~AOMusicPlayer() } } -int AOMusicPlayer::play(QString p_song, int channel, bool loop, +QString AOMusicPlayer::play(QString p_song, int channel, bool loop, int effect_flags) { + QFuture<QString> invoking_future = music_watcher.future(); channel = channel % m_channelmax; if (channel < 0) // wtf? - return BASS_ERROR_NOCHAN; + return "[ERROR] Invalid Channel"; QString f_path = ao_app->get_real_path(ao_app->get_music_path(p_song)); unsigned int flags = BASS_STREAM_PRESCAN | BASS_STREAM_AUTOFREE | @@ -43,6 +44,14 @@ int AOMusicPlayer::play(QString p_song, int channel, bool loop, newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); } + int error_code = BASS_ErrorGetCode(); + + if (invoking_future.isCanceled() && channel == 0) { + // Target future has changed. This stream has become irrelevant. + // So even if the stream manages to finish after the latest one, we don't run + // into order issues. + return QString(); + } if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice()); @@ -109,7 +118,7 @@ int AOMusicPlayer::play(QString p_song, int channel, bool loop, BASS_ChannelStop(m_stream_list[channel]); m_stream_list[channel] = newstream; - BASS_ChannelPlay(m_stream_list[channel], false); + BASS_ChannelPlay(newstream, false); if (effect_flags & FADE_IN) { // Fade in our sample BASS_ChannelSetAttribute(newstream, BASS_ATTRIB_VOL, 0); @@ -120,12 +129,32 @@ int AOMusicPlayer::play(QString p_song, int channel, bool loop, else this->set_volume(m_volume[channel], channel); - BASS_ChannelSetSync(m_stream_list[channel], BASS_SYNC_DEV_FAIL, 0, + BASS_ChannelSetSync(newstream, BASS_SYNC_DEV_FAIL, 0, ao_app->BASSreset, 0); this->set_looping(loop, channel); // Have to do this here due to any // crossfading-related changes, etc. - return BASS_ErrorGetCode(); + + bool is_stop = (p_song == "~stop.mp3"); + QString p_song_clear = QUrl(p_song).fileName(); + p_song_clear = p_song_clear.left(p_song_clear.lastIndexOf('.')); + + if (is_stop) { + return QObject::tr("None"); + } + + if (error_code == BASS_ERROR_HANDLE) { // Cheap hack to see if file missing + return QObject::tr("[MISSING] %1").arg(p_song_clear); + } + + if (p_song.startsWith("http") && channel == 0) { + return QObject::tr("[STREAM] %1").arg(p_song_clear); + } + + if (channel == 0) + return p_song_clear; + + return ""; } void AOMusicPlayer::stop(int channel) diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp index 52e32f55..3513d221 100644 --- a/src/aotextarea.cpp +++ b/src/aotextarea.cpp @@ -11,7 +11,7 @@ void AOTextArea::append_linked(QString p_message) } void AOTextArea::append_chatmessage(QString p_name, QString p_message, - QString p_colour) + QString p_name_colour, QString p_color) { const QTextCursor old_cursor = this->textCursor(); const int old_scrollbar_value = this->verticalScrollBar()->value(); @@ -21,15 +21,22 @@ void AOTextArea::append_chatmessage(QString p_name, QString p_message, this->moveCursor(QTextCursor::End); this->append(""); - this->insertHtml("<b><font color=" + p_colour + ">" + p_name.toHtmlEscaped() + - "</font></b>: "); + if (!p_name.isEmpty()) { + this->insertHtml("<b><font color=" + p_name_colour + ">" + p_name.toHtmlEscaped() + + "</font></b>: "); + + // cheap workarounds ahoy + p_message += " "; + } - // cheap workarounds ahoy - p_message += " "; QString result = p_message.toHtmlEscaped() .replace("\n", "<br>") .replace(url_parser_regex, "<a href='\\1'>\\1</a>"); + if (!p_color.isEmpty()) { + result = "<font color=" + p_color + ">" + result + "</font>"; + } + this->insertHtml(result); this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); diff --git a/src/charselect.cpp b/src/charselect.cpp index 8928f446..3109558e 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -82,7 +82,7 @@ void Courtroom::set_char_select() ao_app->get_element_dimensions("char_select", filename); if (f_charselect.width < 0 || f_charselect.height < 0) { - qDebug() << "W: did not find char_select width or height in " + qWarning() << "did not find char_select width or height in " "courtroom_design.ini!"; this->setFixedSize(714, 668); } diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3eda1635..486cb1c2 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -27,6 +27,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() music_player = new AOMusicPlayer(this, ao_app); music_player->set_volume(0); + connect(&music_player->music_watcher, &QFutureWatcher<QString>::finished, + this, &Courtroom::update_ui_music_name, Qt::QueuedConnection); sfx_player = new AOSfxPlayer(this, ao_app); sfx_player->set_volume(0); @@ -111,11 +113,13 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() log_timestamp = ao_app->get_log_timestamp(); log_timestamp_format = ao_app->get_log_timestamp_format(); - ui_ms_chatlog = new AOTextArea(this); - ui_ms_chatlog->setReadOnly(true); - ui_ms_chatlog->setOpenExternalLinks(true); - ui_ms_chatlog->hide(); - ui_ms_chatlog->setObjectName("ui_ms_chatlog"); + ui_debug_log = new AOTextArea(this); + ui_debug_log->setReadOnly(true); + ui_debug_log->setOpenExternalLinks(true); + ui_debug_log->hide(); + ui_debug_log->setObjectName("ui_debug_log"); + connect(ao_app, &AOApplication::qt_log_message, + this, &Courtroom::debug_message_handler); ui_server_chatlog = new AOTextArea(this); ui_server_chatlog->setReadOnly(true); @@ -560,7 +564,7 @@ void Courtroom::set_courtroom_size() ao_app->get_element_dimensions("courtroom", filename); if (f_courtroom.width < 0 || f_courtroom.height < 0) { - qDebug() << "W: did not find courtroom width or height in " << filename; + qWarning() << "did not find courtroom width or height in " << filename; this->setFixedSize(714, 668); } @@ -679,7 +683,7 @@ void Courtroom::set_widgets() ao_app->get_element_dimensions("chat_arrow", "courtroom_design.ini"); if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; + qWarning() << "could not find \"chat_arrow\" in courtroom_design.ini"; ui_vp_chat_arrow->hide(); } else { @@ -725,8 +729,9 @@ void Courtroom::set_widgets() ui_ic_chatlog->setPlaceholderText(log_goes_downwards ? "▼ " + tr("Log goes down") + " ▼" : "▲ " + tr("Log goes up") + " ▲"); - set_size_and_pos(ui_ms_chatlog, "ms_chatlog"); - ui_ms_chatlog->setFrameShape(QFrame::NoFrame); + set_size_and_pos(ui_debug_log, "ms_chatlog"); // Old name + set_size_and_pos(ui_debug_log, "debug_log"); // New name + ui_debug_log->setFrameShape(QFrame::NoFrame); set_size_and_pos(ui_server_chatlog, "server_chatlog"); ui_server_chatlog->setFrameShape(QFrame::NoFrame); @@ -786,7 +791,7 @@ void Courtroom::set_widgets() ao_app->get_element_dimensions("music_display", "courtroom_design.ini"); if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"music_display\" in courtroom_design.ini"; + qWarning() << "could not find \"music_display\" in courtroom_design.ini"; ui_music_display->hide(); } else { @@ -1139,7 +1144,7 @@ void Courtroom::set_fonts(QString p_char) set_font(ui_vp_showname, "", "showname", p_char); set_font(ui_vp_message, "", "message", p_char); set_font(ui_ic_chatlog, "", "ic_chatlog", p_char); - set_font(ui_ms_chatlog, "", "ms_chatlog", p_char); + set_font(ui_debug_log, "", "debug_log", p_char); set_font(ui_server_chatlog, "", "server_chatlog", p_char); set_font(ui_music_list, "", "music_list", p_char); set_font(ui_area_list, "", "area_list", p_char); @@ -1248,7 +1253,7 @@ void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier, QStrin ao_app->get_element_dimensions(p_identifier, filename, p_misc); if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; + qWarning() << "could not find \"" << p_identifier << "\" in " << filename; p_widget->hide(); } else { @@ -1282,7 +1287,7 @@ QPoint Courtroom::get_theme_pos(QString p_identifier) ao_app->get_element_dimensions(p_identifier, filename); if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; + qWarning() << "could not find \"" << p_identifier << "\" in " << filename; return QPoint(0, 0); } else { @@ -1733,12 +1738,27 @@ void Courtroom::list_areas() } } -void Courtroom::append_ms_chatmessage(QString f_name, QString f_message) +void Courtroom::debug_message_handler(QtMsgType type, const QMessageLogContext &context, + const QString &msg) { - ui_ms_chatlog->append_chatmessage( - f_name, f_message, - ao_app->get_color("ms_chatlog_sender_color", "courtroom_fonts.ini") - .name()); + const QMap<QtMsgType, QString> colors = { + {QtDebugMsg, "debug"}, + {QtInfoMsg, "info"}, + {QtWarningMsg, "warn"}, + {QtCriticalMsg, "critical"}, + {QtFatalMsg, "fatal"} + }; + const QString color_id = QString("debug_log_%1_color").arg(colors.value(type, "info")); + ui_debug_log->append_chatmessage( + QString(), qFormatLogMessage(type, context, msg), + QString(), ao_app->get_color(color_id, "courtroom_fonts.ini").name()); +} + +void Courtroom::append_debug_message(QString f_message) +{ + ui_debug_log->append_chatmessage( + QString(), f_message, + ao_app->get_color("debug_log_color", "courtroom_fonts.ini").name()); } void Courtroom::append_server_chatmessage(QString p_name, QString p_message, @@ -1758,7 +1778,6 @@ void Courtroom::append_server_chatmessage(QString p_name, QString p_message, on_authentication_state_received(1); } - ui_server_chatlog->append_chatmessage(p_name, p_message, color); if (ao_app->get_text_logging_enabled() && !ao_app->log_filename.isEmpty()) { @@ -2492,7 +2511,7 @@ void Courtroom::handle_emote_mod(int emote_mod, bool p_immediate) break; default: // This should never happen, but if it does anyway, yell in the console about it. - qDebug() << "W: invalid emote mod: " << QString::number(emote_mod); + qWarning() << "invalid emote mod: " << QString::number(emote_mod); } } @@ -2732,7 +2751,7 @@ void Courtroom::initialize_chatbox() pos_size_type design_ini_result = ao_app->get_element_dimensions( "chat_arrow", "courtroom_design.ini", p_misc); if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; + qWarning() << "could not find \"chat_arrow\" in courtroom_design.ini"; ui_vp_chat_arrow->hide(); } else { @@ -3246,7 +3265,7 @@ void Courtroom::play_preanim(bool immediate) else anim_state = 1; preanim_done(); - qDebug() << "W: could not find " + anim_to_find; + qWarning() << "could not find " + anim_to_find; return; } ui_vp_player_char->set_static_duration(preanim_duration); @@ -3807,13 +3826,8 @@ void Courtroom::handle_song(QStringList *p_contents) int effect_flags = 0; // No effects by default - vanilla functionality QString f_song = f_contents.at(0); - QString f_song_clear = f_song.left(f_song.lastIndexOf(".")); - if (f_song.startsWith("http")) { - QByteArray f_song_bytearray = f_song.toUtf8(); - QString f_song_decoded = QUrl::fromPercentEncoding(f_song_bytearray); - f_song_clear = f_song_decoded.left(f_song_decoded.lastIndexOf(".")); - } - f_song_clear = f_song_clear.right(f_song_clear.length() - (f_song_clear.lastIndexOf("/") + 1)); + QString f_song_clear = QUrl(f_song).fileName(); + f_song_clear = f_song_clear.left(f_song_clear.lastIndexOf('.')); int n_char = f_contents.at(1).toInt(&ok); if (!ok) @@ -3862,27 +3876,25 @@ void Courtroom::handle_song(QStringList *p_contents) } } - int error_code = music_player->play(f_song, channel, looping, effect_flags); - - if (is_stop) { - ui_music_name->setText(tr("None")); - return; - } - - if (error_code == BASS_ERROR_HANDLE) { // Cheap hack to see if file missing - ui_music_name->setText(tr("[MISSING] %1").arg(f_song_clear)); - return; - } - - if (f_song.startsWith("http") && channel == 0) { - ui_music_name->setText(tr("[STREAM] %1").arg(f_song_clear)); - return; + QFuture<QString> future = QtConcurrent::run(music_player, &AOMusicPlayer::play, f_song, channel, + looping, effect_flags); + if (channel == 0) { + // Current song UI only displays the song playing, not other channels. + // Any other music playing is irrelevant. + if (music_player->music_watcher.isRunning()) { + music_player->music_watcher.cancel(); + } + music_player->music_watcher.setFuture(future); + ui_music_name->setText(tr("[LOADING] %1").arg(f_song_clear)); } +} - if (channel == 0){ - ui_music_name->setText(f_song_clear); - return; - } +void Courtroom::update_ui_music_name() +{ + QString result = music_player->music_watcher.result(); + if (result.isEmpty()) + return; + ui_music_name->setText(result); } void Courtroom::handle_wtce(QString p_wtce, int variant) @@ -4199,14 +4211,14 @@ void Courtroom::on_ooc_return_pressed() void Courtroom::on_ooc_toggle_clicked() { if (server_ooc) { - ui_ms_chatlog->show(); + ui_debug_log->show(); ui_server_chatlog->hide(); - ui_ooc_toggle->setText(tr("Master")); + ui_ooc_toggle->setText(tr("Debug")); server_ooc = false; } else { - ui_ms_chatlog->hide(); + ui_debug_log->hide(); ui_server_chatlog->show(); ui_ooc_toggle->setText(tr("Server")); @@ -4441,10 +4453,11 @@ void Courtroom::set_sfx_dropdown() void Courtroom::on_sfx_dropdown_changed(int p_index) { - Q_UNUSED(p_index); ui_ic_chat_message->setFocus(); - ui_sfx_remove->hide(); - custom_sfx = ""; + if (p_index == 0) { + ui_sfx_remove->hide(); + custom_sfx = ""; + } } void Courtroom::on_sfx_dropdown_custom(QString p_sfx) @@ -4623,7 +4636,7 @@ void Courtroom::on_mute_list_clicked(QModelIndex p_index) } if (f_cid < 0 || f_cid >= char_list.size()) { - qDebug() << "W: " << real_char << " not present in char_list"; + qWarning() << "" << real_char << " not present in char_list"; return; } @@ -4657,7 +4670,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) } if (f_cid < -2 || f_cid >= char_list.size()) { - qDebug() << "W: " << real_char << " not present in char_list"; + qWarning() << "" << real_char << " not present in char_list"; return; } @@ -5104,7 +5117,7 @@ void Courtroom::on_text_color_changed(int p_color) int c = color_row_to_number.at(p_color); QString markdown_start = color_markdown_start_list.at(c); if (markdown_start.isEmpty()) { - qDebug() << "W: Color list dropdown selected a non-existent markdown " + qWarning() << "Color list dropdown selected a non-existent markdown " "start character"; return; } diff --git a/src/lobby.cpp b/src/lobby.cpp index 54e4c704..e9d95e09 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -116,7 +116,7 @@ void Lobby::set_widgets() pos_size_type f_lobby = ao_app->get_element_dimensions("lobby", filename); if (f_lobby.width < 0 || f_lobby.height < 0) { - qDebug() << "W: did not find lobby width or height in " << filename; + qWarning() << "did not find lobby width or height in " << filename; // Most common symptom of bad config files and missing assets. call_notice( @@ -205,7 +205,7 @@ void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier) ao_app->get_element_dimensions(p_identifier, filename); if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find " << p_identifier << " in " << filename; + qWarning() << "could not find " << p_identifier << " in " << filename; p_widget->hide(); } else { diff --git a/src/main.cpp b/src/main.cpp index ef61bca3..d7bbed1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,8 @@ int main(int argc, char *argv[]) { + qSetMessagePattern("%{type}: %{if-category}%{category}: %{endif}%{message}"); + #if QT_VERSION > QT_VERSION_CHECK(5, 6, 0) // High-DPI support is for Qt version >=5.6. // However, many Linux distros still haven't brought their stable/LTS diff --git a/src/networkmanager.cpp b/src/networkmanager.cpp index 08d01242..b302ceae 100644 --- a/src/networkmanager.cpp +++ b/src/networkmanager.cpp @@ -149,8 +149,8 @@ void NetworkManager::on_srv_lookup() ms_socket->state() != QAbstractSocket::HostLookupState && ms_socket->error() != -1) { qDebug() << ms_socket->error(); - qWarning() << "Error connecting to master server:" - << ms_socket->errorString(); + qCritical() << "Error connecting to master server:" + << ms_socket->errorString(); ms_socket->abort(); ms_socket->close(); break; diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 15906080..bc7ae826 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -29,7 +29,7 @@ void AOApplication::ms_packet_received(AOPacket *p_packet) QStringList sub_contents = i_string.split("&"); if (sub_contents.size() < 4) { - qDebug() << "W: malformed packet"; + qWarning() << "malformed packet"; continue; } @@ -63,7 +63,8 @@ void AOApplication::ms_packet_received(AOPacket *p_packet) w_lobby->append_chatmessage(f_name, f_message); } if (courtroom_constructed && courtroom_loaded) { - w_courtroom->append_ms_chatmessage(f_name, f_message); + w_courtroom->append_server_chatmessage(tr("[Global] %1").arg(f_name), + f_message, "0"); } } else if (header == "AO2CHECK") { @@ -453,7 +454,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) goto end; if (lobby_constructed) - w_courtroom->append_ms_chatmessage("", w_lobby->get_chatlog()); + w_courtroom->append_server_chatmessage(tr("[Global log]"), + w_lobby->get_chatlog(), "0"); w_courtroom->character_loading_finished(); w_courtroom->done_received(); diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index af96b3d1..6ea82f59 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -167,7 +167,7 @@ QString AOApplication::read_file(QString filename) QFile f_log(filename); if (!f_log.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug() << "Couldn't open" << filename; + qWarning() << "Couldn't open" << filename; return ""; } @@ -699,7 +699,7 @@ QString AOApplication::get_emote_comment(QString p_char, int p_emote) QStringList result_contents = f_result.split("#"); if (result_contents.size() < 4) { - qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote; + qWarning() << "misformatted char.ini: " << p_char << ", " << p_emote; return "normal"; } return result_contents.at(0); @@ -713,7 +713,7 @@ QString AOApplication::get_pre_emote(QString p_char, int p_emote) QStringList result_contents = f_result.split("#"); if (result_contents.size() < 4) { - qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote; + qWarning() << "misformatted char.ini: " << p_char << ", " << p_emote; return ""; } return result_contents.at(1); @@ -727,7 +727,7 @@ QString AOApplication::get_emote(QString p_char, int p_emote) QStringList result_contents = f_result.split("#"); if (result_contents.size() < 4) { - qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote; + qWarning() << "misformatted char.ini: " << p_char << ", " << p_emote; return "normal"; } return result_contents.at(2); @@ -741,7 +741,7 @@ int AOApplication::get_emote_mod(QString p_char, int p_emote) QStringList result_contents = f_result.split("#"); if (result_contents.size() < 4) { - qDebug() << "W: misformatted char.ini: " << p_char << ", " + qWarning() << "misformatted char.ini: " << p_char << ", " << QString::number(p_emote); return 0; } |
