Commit ddc0fb0c authored by Gerhard Stein's avatar Gerhard Stein

Progressbar improvements

parent eebce6c9
......@@ -21,9 +21,18 @@ void GsProgressBar::processRender(const GsRect<float> &RectDispCoordFloat)
auto pBlitsurface = gVideoDriver.getBlitSurface();
const auto width = (float(mProgress)*displayRect.w)/1000.0f;
float progressWidth = 0.0;
progressRect.w = width;
if(mProgress < 0.0 || mProgress > 100.0)
{
progressWidth = displayRect.w;
}
else
{
progressWidth = (float(mProgress)*displayRect.w)/1000.0f;
}
progressRect.w = progressWidth;
displayRect.transform(RectDispCoordFloat);
......@@ -32,21 +41,34 @@ void GsProgressBar::processRender(const GsRect<float> &RectDispCoordFloat)
SDL_Rect bgSDLRect = displayRect.SDLRect();
SDL_Rect progressSDLRect = progressRect.SDLRect();
const auto bgColor = SDL_MapRGBA( pBlitsurface->format, 240, 255, 240, 255 );
const auto progressColor = SDL_MapRGBA( pBlitsurface->format, 0, 255, 0, 255 );
SDL_FillRect(pBlitsurface, &bgSDLRect, bgColor);
SDL_FillRect(pBlitsurface, &progressSDLRect, progressColor);
Uint32 bgColor = 0;
Uint32 progressColor = 0;
auto progressFloat = float(mProgress)/10.0f;
std::stringstream ss;
ss << "Now at ";
ss << std::setprecision(1);
ss << std::fixed;
ss << progressFloat;
ss << " %";
if(mProgress < 0.0 || mProgress > 100.0)
{
bgColor = SDL_MapRGBA( pBlitsurface->format, 240, 255, 240, 255 );
progressColor = SDL_MapRGBA( pBlitsurface->format, 0, 255, 64, 255 );
ss << "Fetching ...";
}
else
{
bgColor = SDL_MapRGBA( pBlitsurface->format, 240, 255, 240, 255 );
progressColor = SDL_MapRGBA( pBlitsurface->format, 0, 255, 0, 255 );
ss << "Now at ";
ss << std::setprecision(1);
ss << std::fixed;
ss << progressFloat;
ss << " %";
}
SDL_FillRect(pBlitsurface, &bgSDLRect, bgColor);
SDL_FillRect(pBlitsurface, &progressSDLRect, progressColor);
// Now lets draw the text of the list control
auto &Font = gGraphics.getFont(mFontID);
......
......@@ -99,8 +99,6 @@ int downloadFile(const std::string &filename, int &progress,
const std::string urlString = "http://downloads.sourceforge.net/project/clonekeenplus/Downloads/" + filename;
const std::string outputPath = JoinPaths(downloadDirPath, filename);
FILE *fp = OpenGameFile(outputPath, "wb");
CURLcode res = CURLE_OK;
struct myprogress prog;
......@@ -115,11 +113,16 @@ int downloadFile(const std::string &filename, int &progress,
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_NONE);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, older_progress);
/* pass the struct pointer into the progress function */
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &prog);
FILE *fp = OpenGameFile(outputPath, "wb");
if(fp != nullptr)
{
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment