Commit f818d32b authored by Gerhard Stein's avatar Gerhard Stein

Downloader improved

parent 49643dc8
......@@ -28,6 +28,8 @@ void CGameLauncher::verifyGameStore()
GsButton *downloadBtn = new GsButton( "New Stuff", new GMDownloadDlgOpen() );
mLauncherDialog.addControl( downloadBtn, GsRect<float>(0.35f, 0.865f, 0.3f, 0.07f) );
}
mGameCatalogue = gameDownloader.getGameCatalogue();
}
......@@ -41,12 +43,15 @@ void CGameLauncher::pullGame(const int selection)
return;
// Start downloading the game
const auto gameName = mpGSSelList->getItemString(selection);
const auto gameFileName = mGameCatalogue[selection].mLink;
const auto gameName = mGameCatalogue[selection].mName;
mDownloading = true;
mpDloadTitleText->setText("Downloading Game...");
mpGameDownloader = threadPool->start(new GameDownloader(mDownloadProgress, gameName), "Game Downloader started!");
mpGameDownloader = threadPool->start(new GameDownloader(mDownloadProgress,
gameFileName,
gameName), "Game Downloader started!");
}
......@@ -134,7 +139,7 @@ void CGameLauncher::setupDownloadDialog()
// Create an empty Bitmap control for the preview
mpCurrentDownloadBmp = std::dynamic_pointer_cast<CGUIBitmap>(
mpGameStoreDialog->addControl( new CGUIBitmap(),
GsRect<float>(0.51f, 0.07f, 0.48f, 0.58f)) );
GsRect<float>(0.51f, 0.04f, 0.48f, 0.38f)) );
// Description Text Box
......
......@@ -218,6 +218,8 @@ bool GameDownloader::checkForMissingGames( std::vector< std::string > &missingLi
const auto downloadPath = JoinPaths(searchPaths, "downloads");
std::vector<GameCatalogueEntry> reducedCatalogue;
// Need to check for a list of downloaded stuff and what we still need
for( const auto &gameEntry : mGameCatalogue )
{
......@@ -228,10 +230,13 @@ bool GameDownloader::checkForMissingGames( std::vector< std::string > &missingLi
if( !IsFileAvailable(downloadGamePath) )
{
missingList.push_back(gameEntry.mName);
reducedCatalogue.push_back(gameEntry);
continue;
}
}
mGameCatalogue = reducedCatalogue;
return true;
}
......@@ -254,19 +259,18 @@ int GameDownloader::handle()
CreateRecDir(downloadPath);
// Go through the missing pieces
const auto &gameFileName = mGameFileName;
const auto &gameName = mGameName;
{
gDlfrom = mProgress = 0;
gDlto = 900;
const std::string gameFile = gameName + ".zip";
const auto downloadGamePath = JoinPaths(downloadPath, gameFile);
const auto downloadGamePath = JoinPaths(downloadPath, gameFileName);
if( !IsFileAvailable(downloadGamePath) )
{
// TODO: We also must pass the gamepath and a downloads folder we all the file packages can be set.
res = downloadFile(gameFile, mProgress, downloadPath);
res = downloadFile(gameFileName, mProgress, downloadPath);
}
mProgress = gDlto;
......@@ -285,7 +289,7 @@ int GameDownloader::handle()
}
else
{
const std::string errStr = "Something went wrong with downloading \"" + gameFile + "\"!";
const std::string errStr = "Something went wrong with downloading \"" + gameFileName + "\"!";
gLogging.ftextOut(PURPLE, errStr.c_str() );
}
}
......
......@@ -30,8 +30,10 @@ public:
GameDownloader(int &progress,
const std::string &gameFileName,
const std::string &gameName) :
mProgress(progress),
mGameFileName(gameFileName),
mGameName(gameName) {}
/**
......@@ -60,6 +62,7 @@ public:
private:
int &mProgress;
const std::string mGameFileName;
const std::string mGameName;
std::vector<GameCatalogueEntry> mGameCatalogue;
......
......@@ -2,15 +2,15 @@
<Catalogue>
<Game name="Commader Keen 1 Special"
link="KEEN1-Special.zip"
description="Rescue the elders"
picture=""/>
description="Get your ship parts back!"
picture="keen1special.png"/>
<Game name="Commader Keen 4 Special"
link="KEEN4-Special.zip"
description="get your parts back"
picture=""/>
<Game name="Eight-Accumulators"
description="Rescue the members of the High Council of Gnosticus IV!"
picture="keen4special.png"/>
<Game name="The Eight Accumulators"
link="Eight-Accumulators.zip"
description="Not sure"
picture=""/>
description="The story continues on from the Battle of the Brains ending."
picture="eightacc.png"/>
</Catalogue>
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