Refactored GameData to be completely independent of SystemData.

This commit is contained in:
Aloshi 2013-09-28 11:16:20 -05:00
parent c5d772657b
commit cfd63c74db
4 changed files with 5 additions and 15 deletions

View file

@ -5,8 +5,8 @@
#include <ctime>
#include <sstream>
GameData::GameData(SystemData* system, std::string path)
: mSystem(system), mPath(path), mBaseName(boost::filesystem::path(path).stem().string()), mMetaData(system->getGameMDD())
GameData::GameData(const std::string& path, const MetaDataList& metadata)
: mPath(path), mBaseName(boost::filesystem::path(path).stem().string()), mMetaData(metadata)
{
if(mMetaData.get("name").empty())
mMetaData.set("name", mBaseName);

View file

@ -4,14 +4,13 @@
#include <string>
#include "FileData.h"
#include "SystemData.h"
#include "MetaData.h"
//This class holds information about a game: at the least, its name, system, and path. Additional information is optional and read by other classes.
class GameData : public FileData
{
public:
GameData(SystemData* system, std::string path);
GameData(const std::string& path, const MetaDataList& metadata);
const std::string& getName() const override;
const std::string& getPath() const override;
@ -28,18 +27,9 @@ public:
MetaDataList* metadata();
private:
SystemData* mSystem;
const std::string mPath;
const std::string mBaseName;
//extra data
/*std::string mDescription;
std::string mImagePath;
float mRating;
float mUserRating;
size_t mTimesPlayed;
std::time_t mLastPlayed;*/
MetaDataList mMetaData;
};

View file

@ -147,7 +147,7 @@ void SystemData::populateFolder(FolderData* folder)
//if it matches, add it
if(chkExt == extension)
{
GameData* newGame = new GameData(this, filePath.generic_string());
GameData* newGame = new GameData(filePath.generic_string(), MetaDataList(getGameMDD()));
folder->pushFileData(newGame);
isGame = true;
break;

View file

@ -90,7 +90,7 @@ GameData* createGameFromPath(std::string gameAbsPath, SystemData* system)
loops++;
}
GameData* game = new GameData(system, gameAbsPath);
GameData* game = new GameData(gameAbsPath, MetaDataList(system->getGameMDD()));
folder->pushFileData(game);
return game;
}