diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-09-12 23:00:11 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-09-12 23:00:11 +0000 |
commit | 07b3632e605488221f34bff48f298b394af7083a (patch) | |
tree | 185dba6ce8342687cc7215d24e9848e0acb771d6 /src/gui/updatewindow.cpp | |
parent | 8a598e713f504c88402ff204907044c0d62c5f29 (diff) | |
download | mana-07b3632e605488221f34bff48f298b394af7083a.tar.gz mana-07b3632e605488221f34bff48f298b394af7083a.tar.bz2 mana-07b3632e605488221f34bff48f298b394af7083a.tar.xz mana-07b3632e605488221f34bff48f298b394af7083a.zip |
Enabled OpenGL checkbox and added messagebox informing the user that apply this
change requires restarting the client. Also made progress of update downloads
start displaying at 0%.
Diffstat (limited to 'src/gui/updatewindow.cpp')
-rw-r--r-- | src/gui/updatewindow.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 0ec591b1..4f53495c 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -178,17 +178,20 @@ void UpdaterWindow::addRow(const std::string &row) mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll()); } -int UpdaterWindow::updateProgress(void *ptr, double dt, double dn, double ut, double un) +int UpdaterWindow::updateProgress(void *ptr, + double dt, double dn, double ut, double un) { - float progress = dn/dt; + float progress = dn / dt; UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(ptr); if (progress < 0) { progress = 0.0f; } + std::stringstream progressString; - progressString << uw->mCurrentFile << " (" << ((int)(progress*100)) << "%)"; + progressString << uw->mCurrentFile + << " (" << ((int)(progress * 100)) << "%)"; uw->setLabel(progressString.str().c_str()); uw->setProgress(progress); @@ -200,17 +203,25 @@ int UpdaterWindow::updateProgress(void *ptr, double dt, double dn, double ut, do return 0; } -size_t UpdaterWindow::memoryWrite(void *ptr, size_t size, size_t nmemb, FILE *stream) +size_t UpdaterWindow::memoryWrite(void *ptr, + size_t size, size_t nmemb, FILE *stream) { UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(stream); - uw->mMemoryBuffer = (char *)realloc(uw->mMemoryBuffer, uw->mDownloadedBytes + nmemb * size + 1); + size_t totalMem = size * nmemb; + uw->mMemoryBuffer = (char*)realloc(uw->mMemoryBuffer, + uw->mDownloadedBytes + totalMem + 1); if (uw->mMemoryBuffer) { - memcpy(&(uw->mMemoryBuffer[uw->mDownloadedBytes]), ptr, nmemb * size); - uw->mDownloadedBytes += nmemb; + memcpy(&(uw->mMemoryBuffer[uw->mDownloadedBytes]), ptr, totalMem); + uw->mDownloadedBytes += totalMem; + + // Make sure the memory buffer is NULL terminated, because this + // function is used to download text files that are later parsed as a + // string. uw->mMemoryBuffer[uw->mDownloadedBytes] = 0; } - return nmemb; + + return totalMem; } int UpdaterWindow::downloadThread(void *ptr) @@ -221,6 +232,7 @@ int UpdaterWindow::downloadThread(void *ptr) UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(ptr); std::string outFilename; std::string url(uw->mUpdateHost + "/" + uw->mCurrentFile); + uw->setLabel(uw->mCurrentFile + " (0%)"); curl = curl_easy_init(); |