summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-07-14 09:02:59 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-07-14 09:02:59 +0000
commit92ff85076658f0bd2d175b53e4ee1d03b9437aa3 (patch)
tree9e07ab4464091aae7d7b90b66b6916eafec15805
parent9d048c03f63f0f44b8acd264a891deb44aa40e03 (diff)
downloadmana-92ff85076658f0bd2d175b53e4ee1d03b9437aa3.tar.gz
mana-92ff85076658f0bd2d175b53e4ee1d03b9437aa3.tar.bz2
mana-92ff85076658f0bd2d175b53e4ee1d03b9437aa3.tar.xz
mana-92ff85076658f0bd2d175b53e4ee1d03b9437aa3.zip
Some fixes to the updating system.
-rw-r--r--src/gui/updatewindow.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 15c7afb3..b9d3ea7e 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -32,10 +32,9 @@
#include "SDL_thread.h"
UpdaterWindow *updaterWindow;
-float progress = 0.0f;
SDL_Thread *thread;
std::string updateHost = "themanaworld.org/files";
-bool downloadComplete = false;
+bool downloadComplete = true;
UpdaterWindow::UpdaterWindow()
: Window("Updating...")
@@ -89,6 +88,7 @@ void UpdaterWindow::setLabel(const std::string &str)
void UpdaterWindow::enable()
{
playButton->setEnabled(true);
+ playButton->requestFocus();
}
void UpdaterWindow::draw(gcn::Graphics *graphics)
@@ -112,10 +112,12 @@ int updateProgress(void *ptr,
double ultotal,
double ulnow)
{
- std::stringstream labelString;
- progress = d/t;
- labelString << (char *)ptr << " (" << (int)(progress*100) << "%)";
- updaterWindow->setLabel(labelString.str());
+ std::string labelString((char *)ptr);
+ float progress = d/t;
+ std::stringstream progressString;
+ progressString << ((int)(progress*100));
+ labelString += " (" + progressString.str() + "%)";
+ updaterWindow->setLabel(labelString.c_str());
updaterWindow->setProgress(progress);
if (state != UPDATE) {
@@ -139,8 +141,6 @@ int downloadThread(void *ptr)
curl = curl_easy_init();
if (curl)
{
- downloadComplete = false;
- progress = 0.0f;
// TODO: download in the proper folder (data?)
outfile = fopen(fileName.c_str(), "wb");
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
@@ -161,6 +161,7 @@ int downloadThread(void *ptr)
int download(std::string url)
{
+ downloadComplete = false;
thread = SDL_CreateThread(downloadThread, (void *)url.c_str());
if (thread == NULL) {