feat: add version to update menu

This commit is contained in:
2021-11-14 15:27:09 +01:00
parent 11a517a41a
commit 6a79f2b490
3 changed files with 33 additions and 7 deletions

View File

@@ -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();