Commit 3924da82 authored by Gerhard Stein's avatar Gerhard Stein

Downloader improvements where we check if there is something to download

yet.
parent 140f896e
......@@ -173,8 +173,17 @@ bool CGameLauncher::setupMenu()
#ifdef DOWNLOADER
GsButton *downloadBtn = new GsButton( "New Stuff", new GMDownloadDlgOpen() );
mLauncherDialog.addControl( downloadBtn, GsRect<float>(0.35f, 0.865f, 0.3f, 0.07f) );
int progress = 0;
GameDownloader gameDownloader(progress);
std::vector< std::string > missingList;
gameDownloader.checkForMissingGames( missingList );
if(!missingList.empty())
{
GsButton *downloadBtn = new GsButton( "New Stuff", new GMDownloadDlgOpen() );
mLauncherDialog.addControl( downloadBtn, GsRect<float>(0.35f, 0.865f, 0.3f, 0.07f) );
}
#endif
mpEpisodeText = new CGUIText("Game");
......
......@@ -5,6 +5,10 @@
#include <cstdio>
#include <curl/curl.h>
const std::vector< std::string > gameList = { "KEEN4Special" };
extern "C"
{
int unzipFile(const char *input,
......@@ -146,8 +150,38 @@ int downloadFile(const std::string &filename, int &progress,
}
bool GameDownloader::checkForMissingGames( std::vector< std::string > &missingList )
{
// Get the first path. We assume that one is writable
std::string searchPaths;
GetExactFileName(GetFirstSearchPath(), searchPaths);
const auto downloadPath = JoinPaths(searchPaths, "downloads");
// Need to check for a list of downloaded stuff and what we still need
for( const auto &gameName : gameList )
{
const std::string gameFile = gameName + ".zip";
const auto downloadGamePath = JoinPaths(downloadPath, gameFile);
if( !IsFileAvailable(downloadGamePath) )
{
missingList.push_back(gameName);
continue;
}
}
return true;
}
int GameDownloader::handle()
{
std::vector< std::string > missingList;
checkForMissingGames(missingList);
int res = 0;
// Get the first path. We assume that one is writable
......@@ -162,15 +196,15 @@ int GameDownloader::handle()
CreateRecDir(downloadPath);
// Keeping the count
const int numGames = 1;
const auto numGames = missingList.size();
const int numSteps = 2;
int game = 0;
const int ratio = (1000/(numGames*numSteps));
// TODO: Need to check for a list of downloaded stuff and what we still need
const std::string gameName = "KEEN4Special";
// Go through the missing pieces
for(const auto &gameName : missingList)
{
int step = 0;
......
......@@ -2,12 +2,16 @@
#define GAMEDOWNLOADER_H
#include <base/utils/ThreadPool.h>
#include <vector>
#include <string>
class GameDownloader : public Action
{
public:
GameDownloader(int &progress) : mProgress(progress) {}
bool checkForMissingGames( std::vector< std::string > &missingList );
int handle();
private:
......
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