Commit 33b568e8 authored by Gerhard Stein's avatar Gerhard Stein

Download-Manager improvements. Progress-Bar is looking better...

parent ece7c141
......@@ -18,8 +18,26 @@ void GsProgressBar::processRender(const GsRect<float> &RectDispCoordFloat)
// TODO: Rendering of the progress bar
// Transform to the display coordinates
GsRect<float> displayRect = mRect;
GsRect<float> progressRect = mRect;
auto pBlitsurface = gVideoDriver.getBlitSurface();
const auto width = (float(mProgress)*displayRect.w)/1000.0f;
progressRect.w = width;
displayRect.transform(RectDispCoordFloat);
SDL_Rect lRect = displayRect.SDLRect();
progressRect.transform(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);
auto progressFloat = float(mProgress)/10.0f;
......@@ -32,6 +50,6 @@ void GsProgressBar::processRender(const GsRect<float> &RectDispCoordFloat)
ss << " %";
// Now lets draw the text of the list control
GsFont &Font = gGraphics.getFont(mFontID);
Font.drawFontCentered(gVideoDriver.getBlitSurface(), ss.str(), lRect.x, lRect.w, lRect.y, false);
auto &Font = gGraphics.getFont(mFontID);
Font.drawFontCentered( pBlitsurface, ss.str(), bgSDLRect.x, bgSDLRect.w, bgSDLRect.y, false );
}
......@@ -162,7 +162,7 @@ void CGUITextSelectionList::processLogic()
void CGUITextSelectionList::processRender(const GsRect<float> &RectDispCoordFloat)
{
// Blit the List surface
SDL_Surface *Blitsurface = gVideoDriver.getBlitSurface();
SDL_Surface *pBlitsurface = gVideoDriver.getBlitSurface();
// Transform to the display coordinates
GsRect<float> displayRect = mRect;
......@@ -173,11 +173,11 @@ void CGUITextSelectionList::processRender(const GsRect<float> &RectDispCoordFloa
if(!mEnabled)
{
SDL_FillRect(Blitsurface, &lRect, 0xFFDFDFDF);
SDL_FillRect(pBlitsurface, &lRect, 0xFFDFDFDF);
}
else
{
SDL_FillRect(Blitsurface, &lRect, 0xFFFFFFFF);
SDL_FillRect(pBlitsurface, &lRect, 0xFFFFFFFF);
}
// Now lets draw the text of the list control
......@@ -209,21 +209,21 @@ void CGUITextSelectionList::processRender(const GsRect<float> &RectDispCoordFloa
if(mPressedSelection == curLinePos )
{
lRect.y = ypos+(line*lRect.h)-1;
SDL_FillRect(Blitsurface, &lRect, 0xFFA5A5F1);
SDL_FillRect(pBlitsurface, &lRect, 0xFFA5A5F1);
}
else if(mReleasedSelection == curLinePos )
{
lRect.y = ypos+(line*lRect.h)-1;
if(mSelected)
SDL_FillRect(Blitsurface, &lRect, 0xFFB5B5F1);
SDL_FillRect(pBlitsurface, &lRect, 0xFFB5B5F1);
else
SDL_FillRect(Blitsurface, &lRect, 0xFFC5C5C5);
SDL_FillRect(pBlitsurface, &lRect, 0xFFC5C5C5);
}
else if(mHoverSelection == curLinePos )
{
lRect.y = ypos+(line*sepHeight)-1;
SDL_FillRect(Blitsurface, &lRect, 0xFFE5E5F1);
SDL_FillRect(pBlitsurface, &lRect, 0xFFE5E5F1);
}
......@@ -235,7 +235,7 @@ void CGUITextSelectionList::processRender(const GsRect<float> &RectDispCoordFloa
trimmedText = trimmedText.substr(0, textlimitWidth);
}
Font.drawFont(Blitsurface, trimmedText, xpos, ypos+(line*lRect.h), false);
Font.drawFont(pBlitsurface, trimmedText, xpos, ypos+(line*lRect.h), false);
}
mScrollbar.mMaxScrollAmt = mItemList.size()-mScrollbar.lastToShow();
......
......@@ -112,7 +112,7 @@ void CGameLauncher::setupDownloadDialog()
mpGameStoreDialog->addControl(mpGSSelList, GsRect<float>(0.01f, 0.07f, 0.98f, 0.72f)) );
// Progress Bar
mpGameStoreDialog->addControl(new GsProgressBar(mDownloadProgress), GsRect<float>(0.1f, 0.8f, 0.8f, 0.1f));
mpGameStoreDialog->addControl(new GsProgressBar(mDownloadProgress), GsRect<float>(0.1f, 0.8f, 0.8f, 0.05f));
// Bottom Controls
mpDloadBack = std::dynamic_pointer_cast<GsButton>(
......
......@@ -193,22 +193,11 @@ int GameDownloader::handle()
// Create Download directory if it does not exist yet
CreateRecDir(downloadPath);
// Keeping the count
const auto numGames = 1;
const int numSteps = 2;
int game = 0;
const int ratio = (1000/(numGames*numSteps));
// Go through the missing pieces
const auto &gameName = mGameName;
//for(const auto &gameName : missingList)
{
int step = 0;
gDlfrom = mProgress = (game*numSteps+step)*ratio;
gDlto = (game*numSteps+step+1)*ratio;
gDlfrom = mProgress = 0;
gDlto = 900;
const std::string gameFile = gameName + ".zip";
......@@ -220,8 +209,7 @@ int GameDownloader::handle()
res = downloadFile(gameFile, mProgress, downloadPath);
}
step++;
mProgress = (game*numSteps+step)*ratio;
mProgress = gDlto;
// TODO: Now the downloaded stuff must be extracted to the games directory
// At this point the file should be available
......@@ -240,8 +228,6 @@ int GameDownloader::handle()
const std::string errStr = "Something went wrong with downloading \"" + gameFile + "\"!";
gLogging.ftextOut(PURPLE, errStr.c_str() );
}
mProgress = (game*numSteps+step)*ratio;
}
......
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