From b3c0e78565ac5ee51caaf774395b70fd05817b7c Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:12:38 +0100 Subject: [PATCH] [QoL] Improve client version check (#1053) * Improve version check * Add informative warning * Fix the most critical issue that AO2 has ever encountered An ugly header include * Increase verbosity and visibility * TUH --- src/lobby.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/lobby.cpp b/src/lobby.cpp index 46bb504a1..f19845fad 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -8,7 +8,10 @@ #include "widgets/server_editor_dialog.h" #include +#include #include +#include +#include Lobby::Lobby(AOApplication *p_ao_app, NetworkManager *p_net_manager) : QMainWindow{} @@ -101,9 +104,8 @@ void Lobby::reset_selection() void Lobby::loadUI() { - this->setWindowTitle(tr("Attorney Online %1").arg(QApplication::applicationVersion())); - this->setWindowIcon(QIcon(":/logo.png")); - this->setWindowFlags((this->windowFlags() | Qt::CustomizeWindowHint)); + setWindowIcon(QIcon(":/logo.png")); + setWindowFlags((windowFlags() | Qt::CustomizeWindowHint)); QUiLoader l_loader(this); QFile l_uiFile(Options::getInstance().getUIAsset(DEFAULT_UI)); @@ -558,11 +560,16 @@ void Lobby::get_motd() void Lobby::check_for_updates() { net_manager->request_document(MSDocumentType::ClientVersion, [this](QString version) { - const QString current_version = ao_app->get_version_string(); - if (!version.isEmpty() && version != current_version) + QVersionNumber current_version = QVersionNumber::fromString(ao_app->get_version_string()); + QVersionNumber master_version = QVersionNumber::fromString(version); + + if (current_version < master_version) { - ui_game_version_lbl->setText(tr("Version: %1 (!)").arg(current_version)); - ui_game_version_lbl->setToolTip(tr("New version available: %1").arg(version)); + ui_game_version_lbl->setText(tr("Version: %1 [OUTDATED]").arg(current_version.toString())); + setWindowTitle(tr("[Your client is outdated]")); + const QString download_url = QString("https://github.com/AttorneyOnline/AO2-Client/releases/latest").replace(QRegularExpression("\\b(https?://\\S+\\.\\S+)\\b"), "\\1"); + const QString message = QString("Your client is outdated!
Your Version: %1
Current Version: %2
Download the latest version at
%3").arg(current_version.toString(), master_version.toString(), download_url); + QMessageBox::warning(this, "Your client is outdated!", message); } }); }