mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 09:48:51 +01:00
Support for merged collection mediapaths.
This commit is contained in:
parent
2320c62577
commit
b8e7d708f1
@ -8,4 +8,5 @@ Documentation/Artifacts/*
|
||||
Documentation/Manual/_build/*
|
||||
Configuration/Configuration/bin/**
|
||||
Configuration/Configuration/obj/**
|
||||
Artifacts/**
|
||||
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -20,7 +20,8 @@
|
||||
#include <algorithm>
|
||||
|
||||
Item::Item()
|
||||
: leaf(true)
|
||||
: collectionInfo(NULL)
|
||||
, leaf(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -172,12 +172,13 @@ void ReloadableMedia::reloadTexture()
|
||||
{
|
||||
config_.getMediaPropertyAbsolutePath(collectionName, "video", true, videoPath);
|
||||
loadedComponent_ = videoBuild.createVideo(videoPath, "video", scaleX_, scaleY_);
|
||||
}
|
||||
else
|
||||
|
||||
if(!loadedComponent_)
|
||||
{
|
||||
config_.getMediaPropertyAbsolutePath(collectionName, "video", false, videoPath);
|
||||
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_);
|
||||
}
|
||||
|
||||
|
||||
@ -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->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 && item->title != item->fullTitle)
|
||||
{
|
||||
t = imageBuild.CreateImage(imagePath, item->fullTitle, scaleX_, scaleY_);
|
||||
}
|
||||
if (!t)
|
||||
{
|
||||
t = new Text(item->title, fontInst_, scaleX_, scaleY_);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user