aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSalanto <62221668+Salanto@users.noreply.github.com>2024-10-31 12:12:38 +0100
committerGitHub <noreply@github.com>2024-10-31 12:12:38 +0100
commitb3c0e78565ac5ee51caaf774395b70fd05817b7c (patch)
tree66b45be9228d62313e75ef6cf398e9ed052987ed /src
parent7f17c0b69714bccaa649b4bd70afdf321176458e (diff)
[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
Diffstat (limited to 'src')
-rw-r--r--src/lobby.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/lobby.cpp b/src/lobby.cpp
index 46bb504a..f19845fa 100644
--- a/src/lobby.cpp
+++ b/src/lobby.cpp
@@ -8,7 +8,10 @@
#include "widgets/server_editor_dialog.h"
#include <QImageReader>
+#include <QMessageBox>
#include <QUiLoader>
+#include <QVersionNumber>
+#include <qnamespace.h>
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"), "<a href='\\1'>\\1</a>");
+ const QString message = QString("Your client is outdated!<br>Your Version: %1<br>Current Version: %2<br>Download the latest version at<br>%3").arg(current_version.toString(), master_version.toString(), download_url);
+ QMessageBox::warning(this, "Your client is outdated!", message);
}
});
}