Skip to content

Commit b3c0e78

Browse files
authored
[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
1 parent 7f17c0b commit b3c0e78

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/lobby.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
#include "widgets/server_editor_dialog.h"
99

1010
#include <QImageReader>
11+
#include <QMessageBox>
1112
#include <QUiLoader>
13+
#include <QVersionNumber>
14+
#include <qnamespace.h>
1215

1316
Lobby::Lobby(AOApplication *p_ao_app, NetworkManager *p_net_manager)
1417
: QMainWindow{}
@@ -101,9 +104,8 @@ void Lobby::reset_selection()
101104

102105
void Lobby::loadUI()
103106
{
104-
this->setWindowTitle(tr("Attorney Online %1").arg(QApplication::applicationVersion()));
105-
this->setWindowIcon(QIcon(":/logo.png"));
106-
this->setWindowFlags((this->windowFlags() | Qt::CustomizeWindowHint));
107+
setWindowIcon(QIcon(":/logo.png"));
108+
setWindowFlags((windowFlags() | Qt::CustomizeWindowHint));
107109

108110
QUiLoader l_loader(this);
109111
QFile l_uiFile(Options::getInstance().getUIAsset(DEFAULT_UI));
@@ -558,11 +560,16 @@ void Lobby::get_motd()
558560
void Lobby::check_for_updates()
559561
{
560562
net_manager->request_document(MSDocumentType::ClientVersion, [this](QString version) {
561-
const QString current_version = ao_app->get_version_string();
562-
if (!version.isEmpty() && version != current_version)
563+
QVersionNumber current_version = QVersionNumber::fromString(ao_app->get_version_string());
564+
QVersionNumber master_version = QVersionNumber::fromString(version);
565+
566+
if (current_version < master_version)
563567
{
564-
ui_game_version_lbl->setText(tr("Version: %1 (!)").arg(current_version));
565-
ui_game_version_lbl->setToolTip(tr("New version available: %1").arg(version));
568+
ui_game_version_lbl->setText(tr("Version: %1 [OUTDATED]").arg(current_version.toString()));
569+
setWindowTitle(tr("[Your client is outdated]"));
570+
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>");
571+
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);
572+
QMessageBox::warning(this, "Your client is outdated!", message);
566573
}
567574
});
568575
}

0 commit comments

Comments
 (0)