Commit 6981e02d authored by Gerhard Stein's avatar Gerhard Stein

Extended Download with more widgets

parent 3824d2a0
......@@ -22,6 +22,7 @@
#include <ostream>
#include "core/CResourceLoader.h"
#include "gamedownloader.h"
// The directory/path to start the search at
#define DIR_ROOT "."
......@@ -136,11 +137,14 @@ private:
std::unique_ptr<CGUIDialog> mpPatchDialog;
// Download Dialog Section. TODO: Make it external
std::vector<GameCatalogueEntry> mGameCatalogue;
std::unique_ptr<CGUIDialog> mpGameStoreDialog;
std::shared_ptr<CGUIText> mpDloadTitleText;
std::shared_ptr<CGUIText> mpDDescriptionText;
std::shared_ptr<CGUITextSelectionList> mpDloadSelectionList;
std::shared_ptr<GsButton> mpDloadBack;
std::shared_ptr<GsButton> mpDloadDownload;
std::shared_ptr<CGUIBitmap> mpCurrentDownloadBmp;
std::unique_ptr<CGUIDialog> mpDosExecDialog;
......
......@@ -25,6 +25,9 @@ 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();
#endif
}
......@@ -44,10 +47,33 @@ void CGameLauncher::pullGame(const int selection)
mpGameDownloader = threadPool->start(new GameDownloader(mDownloadProgress, gameName), "Game Downloader started!");
}
#include <base/utils/FindFile.h>
void CGameLauncher::ponderDownloadDialog()
{
// TODO: This is yet no way to cancel the download progress
{
// Update the description
uint sel = mpGSSelList->getSelection();
// mpDDescriptionText
auto &gameEntry = mGameCatalogue[sel];
mpDDescriptionText->setText(gameEntry.mDescription);
/*const std::string fname = "cache/keen1special.bmp";
SDL_Surface *pPrimBmp = nullptr;
pPrimBmp = SDL_LoadBMP(GetFullFileName(fname).c_str());
std::shared_ptr<SDL_Surface> bmpSfcPtr( pPrimBmp );
std::shared_ptr<GsBitmap> pBmp(new GsBitmap(bmpSfcPtr));*/
mpCurrentDownloadBmp->setBitmapPtr(gameEntry.pBmp);
//mpCurrentDownloadBmp->setBitmapPtr(pBmp);
}
// Disable Some Elements while downloading
if(mDownloading)
{
......@@ -110,7 +136,19 @@ void CGameLauncher::setupDownloadDialog()
// Selection List
mpDloadSelectionList = std::dynamic_pointer_cast<CGUITextSelectionList>(
mpGameStoreDialog->addControl(mpGSSelList, GsRect<float>(0.01f, 0.07f, 0.98f, 0.72f)) );
mpGameStoreDialog->addControl(mpGSSelList, GsRect<float>(0.01f, 0.04f, 0.50f, 0.55f)) );
// 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.48f)) );
// Description Text Box
mpDDescriptionText = std::dynamic_pointer_cast<CGUIText>(
mpGameStoreDialog->addControl(new CGUIText("Description"), GsRect<float>(0.01f, 0.60f, 0.98f, 0.23f)) );
// Progress Bar
mpGameStoreDialog->addControl(new GsProgressBar(mDownloadProgress), GsRect<float>(0.1f, 0.8f, 0.8f, 0.05f));
......
......@@ -180,6 +180,13 @@ bool GameDownloader::loadCatalogue(const std::string &catalogueFile)
gce.mDescription = gameNode.second.get<std::string>("<xmlattr>.description");
gce.mPictureFile = gameNode.second.get<std::string>("<xmlattr>.picture");
const auto filePath = JoinPaths("cache", gce.mPictureFile);
const auto fullfname = GetFullFileName(filePath);
SDL_Surface *pPrimBmp = SDL_LoadBMP( fullfname.c_str() );
std::shared_ptr<SDL_Surface> bmpSfcPtr( pPrimBmp );
gce.pBmp.reset( new GsBitmap(bmpSfcPtr) );
mGameCatalogue.push_back(gce);
}
......
......@@ -2,9 +2,11 @@
#define GAMEDOWNLOADER_H
#include <base/utils/ThreadPool.h>
#include <graphics/GsBitmap.h>
#include <vector>
#include <string>
#include <memory>
struct GameCatalogueEntry
{
......@@ -12,6 +14,9 @@ struct GameCatalogueEntry
std::string mLink;
std::string mDescription;
std::string mPictureFile;
// Pointer to the bitmap
std::shared_ptr<GsBitmap> pBmp;
};
......@@ -44,6 +49,15 @@ public:
bool checkForMissingGames( std::vector< std::string > &missingList );
/**
* @brief getGameCatalogue Access to the game catalogue
* @return
*/
const std::vector<GameCatalogueEntry> &getGameCatalogue() const
{
return mGameCatalogue;
}
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