mirror of
https://github.com/glest/glest-source.git
synced 2025-08-11 10:54:01 +02:00
Added update notifier
This commit is contained in:
@@ -83,5 +83,8 @@ SoundVolumeMusic=70
|
|||||||
StencilBits=0
|
StencilBits=0
|
||||||
Textures3D=true
|
Textures3D=true
|
||||||
UnitParticles=true
|
UnitParticles=true
|
||||||
|
UpdateCheckURL=https://glest.io/version.txt
|
||||||
|
UpdateDownloadURL=https://github.com/glest/glest-source#download-for-windows
|
||||||
|
UpdateNotifier=true
|
||||||
UserData_Root=$HOME/.glest/
|
UserData_Root=$HOME/.glest/
|
||||||
Windowed=false
|
Windowed=false
|
||||||
|
@@ -82,5 +82,8 @@ SoundVolumeMusic=70
|
|||||||
StencilBits=0
|
StencilBits=0
|
||||||
Textures3D=true
|
Textures3D=true
|
||||||
UnitParticles=true
|
UnitParticles=true
|
||||||
|
UpdateCheckURL=https://glest.io/version.txt
|
||||||
|
UpdateDownloadURL=https://github.com/glest/glest-source#download-for-windows
|
||||||
|
UpdateNotifier=true
|
||||||
UserData_Root=$APPDATA\glest\
|
UserData_Root=$APPDATA\glest\
|
||||||
Windowed=false
|
Windowed=false
|
||||||
|
@@ -82,5 +82,8 @@ SoundVolumeMusic=70
|
|||||||
StencilBits=0
|
StencilBits=0
|
||||||
Textures3D=true
|
Textures3D=true
|
||||||
UnitParticles=true
|
UnitParticles=true
|
||||||
|
UpdateCheckURL=https://glest.io/version.txt
|
||||||
|
UpdateDownloadURL=https://github.com/glest/glest-source#download-for-windows
|
||||||
|
UpdateNotifier=true
|
||||||
UserData_Root=$APPDATA\glest\
|
UserData_Root=$APPDATA\glest\
|
||||||
Windowed=false
|
Windowed=false
|
||||||
|
@@ -286,7 +286,15 @@ namespace Game {
|
|||||||
if (ftpMessageBox.mouseClick(x, y, button)) {
|
if (ftpMessageBox.mouseClick(x, y, button)) {
|
||||||
ftpMessageBox.setEnabled(false);
|
ftpMessageBox.setEnabled(false);
|
||||||
if (button == 0) {
|
if (button == 0) {
|
||||||
startFTPClientIfRequired();
|
string update = Config::getInstance().getString("UpdateDownloadURL", "");
|
||||||
|
if (update != "") {
|
||||||
|
#ifdef WIN32
|
||||||
|
ShellExecuteA(0, 0, update.c_str(), 0, 0, SW_SHOW);
|
||||||
|
#else
|
||||||
|
system(("open " + update).c_str());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/*startFTPClientIfRequired();
|
||||||
|
|
||||||
lastDownloadProgress = 0;
|
lastDownloadProgress = 0;
|
||||||
printf("Adding ftpFileName [%s] ftpFileURL [%s]\n",
|
printf("Adding ftpFileName [%s] ftpFileURL [%s]\n",
|
||||||
@@ -307,7 +315,7 @@ namespace Game {
|
|||||||
ftpClientThread->getProgressMutex()->
|
ftpClientThread->getProgressMutex()->
|
||||||
setOwnerId(mutexOwnerId);
|
setOwnerId(mutexOwnerId);
|
||||||
fileFTPProgressList[ftpFileName] = pair < int, string >(0, "");
|
fileFTPProgressList[ftpFileName] = pair < int, string >(0, "");
|
||||||
safeMutexFTPProgress.ReleaseLock();
|
safeMutexFTPProgress.ReleaseLock();*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mainMessageBox.getEnabled() == false
|
} else if (mainMessageBox.getEnabled() == false
|
||||||
@@ -781,7 +789,7 @@ namespace Game {
|
|||||||
|
|
||||||
string updateCheckURL =
|
string updateCheckURL =
|
||||||
Config::getInstance().getString("UpdateCheckURL", "");
|
Config::getInstance().getString("UpdateCheckURL", "");
|
||||||
if (updateCheckURL != "") {
|
if (updateCheckURL != "" && Config::getInstance().getBool("UpdateNotifier", "true")) {
|
||||||
|
|
||||||
string baseURL = updateCheckURL;
|
string baseURL = updateCheckURL;
|
||||||
|
|
||||||
@@ -808,7 +816,7 @@ namespace Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (curlResult != CURLE_OK) {
|
if (curlResult != CURLE_OK) {
|
||||||
string curlError = curl_easy_strerror(curlResult);
|
/*string curlError = curl_easy_strerror(curlResult);
|
||||||
|
|
||||||
if (SystemFlags::VERBOSE_MODE_ENABLED)
|
if (SystemFlags::VERBOSE_MODE_ENABLED)
|
||||||
printf("In [%s::%s Line %d] curlError [%s]..\n", __FILE__,
|
printf("In [%s::%s Line %d] curlError [%s]..\n", __FILE__,
|
||||||
@@ -818,34 +826,28 @@ namespace Game {
|
|||||||
snprintf(szMsg, 8096,
|
snprintf(szMsg, 8096,
|
||||||
"An error was detected while checking for new updates\n%s",
|
"An error was detected while checking for new updates\n%s",
|
||||||
curlError.c_str());
|
curlError.c_str());
|
||||||
showErrorMessageBox(szMsg, "ERROR", false);
|
showErrorMessageBox(szMsg, "ERROR", false);*/
|
||||||
}
|
} else if (curlResult == CURLE_OK ||
|
||||||
|
|
||||||
if (curlResult == CURLE_OK ||
|
|
||||||
(curlResult != CURLE_COULDNT_RESOLVE_HOST &&
|
(curlResult != CURLE_COULDNT_RESOLVE_HOST &&
|
||||||
curlResult != CURLE_COULDNT_CONNECT)) {
|
curlResult != CURLE_COULDNT_CONNECT)) {
|
||||||
|
|
||||||
Properties props;
|
//Properties props;
|
||||||
props.loadFromText(updateMetaData);
|
//props.loadFromText(updateMetaData);
|
||||||
|
|
||||||
int compareResult =
|
int compareResult =
|
||||||
compareMajorMinorVersion(GameVersionString,
|
compareMajorMinorVersion(GameVersionString + GameBuildDateString, updateMetaData);
|
||||||
props.getString("LatestGameVersion",
|
//props.getString("LatestGameVersion", ""));
|
||||||
""));
|
|
||||||
if (compareResult == 0) {
|
if (compareResult == 0) {
|
||||||
if (GameVersionString !=
|
if (GameVersionString != updateMetaData) {
|
||||||
props.getString("LatestGameVersion", "")) {
|
|
||||||
compareResult = -1;
|
compareResult = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SystemFlags::VERBOSE_MODE_ENABLED)
|
if (SystemFlags::VERBOSE_MODE_ENABLED)
|
||||||
printf("compareResult = %d local [%s] remote [%s]\n",
|
printf("compareResult = %d local [%s] remote [%s]\n",
|
||||||
compareResult, GameVersionString.c_str(),
|
compareResult, GameVersionString.c_str(), updateMetaData.c_str());
|
||||||
props.getString("LatestGameVersion", "").c_str());
|
|
||||||
|
|
||||||
if (compareResult < 0) {
|
if (compareResult < 0) {
|
||||||
|
/*string downloadBinaryKey =
|
||||||
string downloadBinaryKey =
|
|
||||||
"LatestGameBinaryUpdateArchiveURL-" +
|
"LatestGameBinaryUpdateArchiveURL-" +
|
||||||
getPlatformTypeNameString() + getPlatformArchTypeNameString();
|
getPlatformTypeNameString() + getPlatformArchTypeNameString();
|
||||||
if (props.hasString(downloadBinaryKey)) {
|
if (props.hasString(downloadBinaryKey)) {
|
||||||
@@ -858,23 +860,19 @@ namespace Game {
|
|||||||
if (SystemFlags::VERBOSE_MODE_ENABLED)
|
if (SystemFlags::VERBOSE_MODE_ENABLED)
|
||||||
printf
|
printf
|
||||||
("Checking update key downloadBinaryKey [%s] ftpFileURL [%s]\n",
|
("Checking update key downloadBinaryKey [%s] ftpFileURL [%s]\n",
|
||||||
downloadBinaryKey.c_str(), ftpFileURL.c_str());
|
downloadBinaryKey.c_str(), ftpFileURL.c_str());*/
|
||||||
|
ftpFileURL = Config::getInstance().getString("UpdateDownloadURL", "");
|
||||||
if (props.getBool("AllowUpdateDownloads", "false") == false
|
if (ftpFileURL == "") {
|
||||||
|| ftpFileURL == "") {
|
|
||||||
char szMsg[8096] = "";
|
char szMsg[8096] = "";
|
||||||
snprintf(szMsg, 8096,
|
snprintf(szMsg, 8096,
|
||||||
"A new update was detected: %s\nUpdate Date: %s\nPlease visit glest.io for details!",
|
"A new update was detected: %s, please visit glest.io for details!", updateMetaData.c_str());
|
||||||
props.getString("LatestGameVersion", "unknown").c_str(),
|
|
||||||
props.getString("LatestGameVersionReleaseDate", "unknown").c_str());
|
|
||||||
showFTPMessageBox(szMsg, "Update", false, true);
|
showFTPMessageBox(szMsg, "Update", false, true);
|
||||||
} else {
|
} else {
|
||||||
char szMsg[8096] = "";
|
char szMsg[8096] = "";
|
||||||
snprintf(szMsg, 8096,
|
snprintf(szMsg, 8096,
|
||||||
"A new update was detected: %s\nUpdate Date: %s\nDownload update now?",
|
"A new update was detected: %s, do you want to download the update now?", updateMetaData.c_str());
|
||||||
props.getString("LatestGameVersion", "unknown").c_str(),
|
|
||||||
props.getString("LatestGameVersionReleaseDate", "unknown").c_str());
|
|
||||||
showFTPMessageBox(szMsg, "Update", false, false);
|
showFTPMessageBox(szMsg, "Update", false, false);
|
||||||
|
system("<mybrowser> http://google.com");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user