[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
This commit is contained in:
parent
7f17c0b697
commit
b3c0e78565
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user