Support for merged collection mediapaths.

This commit is contained in:
Don Honerbrink 2015-06-26 09:40:11 -05:00
parent 2320c62577
commit b8e7d708f1
11 changed files with 67 additions and 29 deletions

View File

@ -8,4 +8,5 @@ Documentation/Artifacts/*
Documentation/Manual/_build/*
Configuration/Configuration/bin/**
Configuration/Configuration/obj/**
Artifacts/**

View File

@ -35,8 +35,17 @@ CollectionInfo::CollectionInfo(std::string name,
CollectionInfo::~CollectionInfo()
{
std::vector<Item *>::iterator it = items.begin();
// remove items from the subcollections so their destructors do not
// delete the items since the parent collection will delete them.
std::vector<CollectionInfo *>::iterator subit;
for (subit != subcollections_.begin(); subit != subcollections_.end(); subit++)
{
CollectionInfo *info = *subit;
info->items.clear();
}
std::vector<Item *>::iterator it = items.begin();
while(it != items.end())
{
delete *it;
@ -62,6 +71,12 @@ void CollectionInfo::extensionList(std::vector<std::string> &extensionlist)
}
}
void CollectionInfo::addSubcollection(CollectionInfo *newinfo)
{
subcollections_.push_back(newinfo);
items.insert(items.begin(), newinfo->items.begin(), newinfo->items.end());
}
bool CollectionInfo::itemIsLess(Item *lhs, Item *rhs)
{

View File

@ -27,13 +27,16 @@ public:
virtual ~CollectionInfo();
std::string settingsPath() const;
void sortItems();
void addSubcollection(CollectionInfo *info);
void extensionList(std::vector<std::string> &extensions);
std::string name;
std::string listpath;
std::string metadataType;
std::string launcher;
std::vector<Item *> items;
private:
std::vector<CollectionInfo *> subcollections_;
std::string metadataPath_;
std::string extensions_;
static bool itemIsLess(Item *lhs, Item *rhs);

View File

@ -190,13 +190,15 @@ CollectionInfo *CollectionInfoBuilder::buildCollection(std::string name)
CollectionInfo *collection = new CollectionInfo(name, listItemsPath, extensions, metadataType, metadataPath);
(void)conf_.getProperty("collections." + collection->name + ".launcher", collection->launcher);
ImportDirectory(collection);
return collection;
}
bool CollectionInfoBuilder::ImportBasicList(CollectionInfo * /*info*/, std::string file, std::string launcher, std::map<std::string, Item *> &list)
bool CollectionInfoBuilder::ImportBasicList(CollectionInfo *info, std::string file, std::map<std::string, Item *> &list)
{
std::ifstream includeStream(file.c_str());
@ -220,7 +222,7 @@ bool CollectionInfoBuilder::ImportBasicList(CollectionInfo * /*info*/, std::stri
i->fullTitle = line;
i->name = line;
i->title = line;
i->launcher = launcher;
i->collectionInfo = info;
list[line] = i;
}
@ -241,11 +243,10 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
std::string launcher;
bool showMissing = false;
(void)conf_.getProperty("collections." + info->name + ".launcher", launcher);
(void)conf_.getProperty("collections." + info->name + ".list.includeMissingItems", showMissing);
ImportBasicList(info, includeFile, launcher, includeFilter);
ImportBasicList(info, excludeFile, launcher, excludeFilter);
ImportBasicList(info, includeFile, includeFilter);
ImportBasicList(info, excludeFile, excludeFilter);
std::vector<std::string> extensions;
std::vector<std::string>::iterator extensionsIt;
@ -299,7 +300,8 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
i->name = basename;
i->fullTitle = basename;
i->title = basename;
i->launcher = launcher;
i->collectionInfo = info;
info->items.push_back(i);
}
}

View File

@ -35,6 +35,6 @@ public:
private:
Configuration &conf_;
MetadataDatabase &metaDB_;
bool ImportBasicList(CollectionInfo *info, std::string file, std::string launcher, std::map<std::string, Item *> &list);
bool ImportBasicList(CollectionInfo *info, std::string file, std::map<std::string, Item *> &list);
bool ImportDirectory(CollectionInfo *info);
};

View File

@ -20,7 +20,8 @@
#include <algorithm>
Item::Item()
: leaf(true)
: collectionInfo(NULL)
, leaf(true)
{
}

View File

@ -16,6 +16,7 @@
#pragma once
#include <string>
#include "CollectionInfo.h"
class Item
{
@ -26,7 +27,6 @@ public:
std::string lowercaseTitle() ;
std::string lowercaseFullTitle();
std::string name;
std::string launcher;
std::string filepath;
std::string title;
std::string fullTitle;
@ -36,6 +36,7 @@ public:
std::string cloneof;
std::string numberPlayers;
std::string numberButtons;
CollectionInfo *collectionInfo;
bool leaf;
};

View File

@ -94,23 +94,17 @@ bool MenuParser::buildMenuItems(CollectionInfo *collection, bool sort, Collectio
item->fullTitle = title;
item->name = collectionAttribute->value();
item->leaf = false;
item->collectionInfo = collection;
menuItems.push_back(item);
}
else
{
std::string collectionName = collectionAttribute->value();
Logger::write(Logger::ZONE_INFO, "Menu", "Loading collection into menu: " + collectionName);
CollectionInfo *subcollection = builder.buildCollection(collectionName);
// todo, there must be a faster way of doing this
collection->items.insert(collection->items.begin(), subcollection->items.begin(), subcollection->items.end());
// prevent the temporary collection object from deleting the item pointers
subcollection->items.clear();
delete subcollection;
//todo: unsupported option with this refactor
// need to append the collection
collection->addSubcollection(subcollection);
}
}

View File

@ -38,7 +38,7 @@ Launcher::Launcher(RetroFE &p, Configuration &c)
bool Launcher::run(std::string collection, Item *collectionItem)
{
std::string launcherName = collectionItem->launcher;
std::string launcherName = collectionItem->collectionInfo->launcher;
std::string executablePath;
std::string selectedItemsDirectory;
std::string selectedItemsPath;

View File

@ -172,11 +172,12 @@ void ReloadableMedia::reloadTexture()
{
config_.getMediaPropertyAbsolutePath(collectionName, "video", true, videoPath);
loadedComponent_ = videoBuild.createVideo(videoPath, "video", scaleX_, scaleY_);
}
else
{
config_.getMediaPropertyAbsolutePath(collectionName, "video", false, videoPath);
loadedComponent_ = videoBuild.createVideo(videoPath, names[n], scaleX_, scaleY_);
if(!loadedComponent_)
{
config_.getMediaPropertyAbsolutePath(selectedItem->collectionInfo->name, "video", false, videoPath);
loadedComponent_ = videoBuild.createVideo(videoPath, names[n], scaleX_, scaleY_);
}
}
if(!loadedComponent_ && !systemMode_)
@ -238,7 +239,7 @@ void ReloadableMedia::reloadTexture()
}
else
{
config_.getMediaPropertyAbsolutePath(collectionName, type_, false, imagePath);
config_.getMediaPropertyAbsolutePath(selectedItem->collectionInfo->name, type_, false, imagePath);
loadedComponent_ = imageBuild.CreateImage(imagePath, imageBasename, scaleX_, scaleY_);
}

View File

@ -782,19 +782,39 @@ bool ScrollingList::allocateTexture(ComponentItemBinding *s)
Component *t = NULL;
ImageBuilder imageBuild;
// check collection path for art based on gamename
config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->name, scaleX_, scaleY_);
// check sub-collection path for art based on gamename
if(!t)
{
config_.getMediaPropertyAbsolutePath(item->name, imageType_, true, imagePath);
t = imageBuild.CreateImage(imagePath, imageType_, scaleX_, scaleY_);
config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->name, scaleX_, scaleY_);
}
// check collection path for art based on game name (full title)
if(!t && item->title != item->fullTitle)
{
config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->fullTitle, scaleX_, scaleY_);
}
// check sub-collection path for art based on game name (full title)
if(!t && item->title != item->fullTitle)
{
config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->fullTitle, scaleX_, scaleY_);
}
// check collection path for art based on system name
if(!t)
{
config_.getMediaPropertyAbsolutePath(item->name, imageType_, true, imagePath);
t = imageBuild.CreateImage(imagePath, imageType_, scaleX_, scaleY_);
}
if (!t)
{
t = new Text(item->title, fontInst_, scaleX_, scaleY_);