feat: add version to update menu
This commit is contained in:
@@ -13,18 +13,20 @@ namespace td {
|
||||
namespace utils {
|
||||
|
||||
bool Updater::checkUpdate() {
|
||||
std::string newFileUrl = getDownloadFileURL();
|
||||
|
||||
if (newFileUrl.empty()) return false;
|
||||
|
||||
httplib::Client client("thesims.freeboxos.fr", 30000);
|
||||
|
||||
if (auto res = client.Get("/Tower%20Defense/version")) {
|
||||
|
||||
std::string currentVersion = TD_VERSION;
|
||||
std::string lastVersion = res.value().body;
|
||||
std::string currentVersion = getCurrentVersion();
|
||||
m_LastVersion = res.value().body;
|
||||
|
||||
if (currentVersion != lastVersion) {
|
||||
// we only look at the first line
|
||||
m_LastVersion = m_LastVersion.substr(0, m_LastVersion.find('\n'));
|
||||
|
||||
std::cout << "Current version : [" << getCurrentVersion() << "]\n";
|
||||
std::cout << "Last version : [" << m_LastVersion << "]\n";
|
||||
|
||||
if (currentVersion != m_LastVersion) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -36,6 +38,10 @@ bool Updater::checkUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Updater::canUpdate() {
|
||||
return !getDownloadFileURL().empty();
|
||||
}
|
||||
|
||||
std::string Updater::getDownloadFileURL() {
|
||||
Os systemOs = getSystemOs();
|
||||
Architecture systemArch = getSystemArchitecture();
|
||||
|
||||
Reference in New Issue
Block a user