Merge with mergedcollections

This commit is contained in:
emb 2015-07-27 12:59:41 -05:00
commit bd1f1657ca
16 changed files with 284 additions and 120 deletions

View File

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

View File

@ -1,6 +1,6 @@
executable = ../HyperLaunch/HyperLaunch.exe
arguments = -s "%ITEM_COLLECTION_NAME%" -r "%ITEM_FILEPATH%" -p RetroFE -f "%RETROFE_EXEC_PATH%"
# For v3.0.1.1 compliant version, comment out the above arguments
# and uncomment the following line:
#arguments = "%ITEM_COLLECTION_NAME%" "%ITEM_NAME%"
executable = ../RocketLauncher/RocketLauncher.exe
arguments = -s "%ITEM_COLLECTION_NAME%" -r "%ITEM_FILEPATH%" -p RetroFE -f "%RETROFE_EXEC_PATH%"
# For v3.0.1.1 compliant version, comment out the above arguments
# and uncomment the following line:
#arguments = "%ITEM_COLLECTION_NAME%" "%ITEM_NAME%"

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,17 @@ 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::hasSubcollections()
{
return (subcollections_.size() > 0);
}
bool CollectionInfo::itemIsLess(Item *lhs, Item *rhs)
{

View File

@ -27,13 +27,17 @@ public:
virtual ~CollectionInfo();
std::string settingsPath() const;
void sortItems();
void addSubcollection(CollectionInfo *info);
bool hasSubcollections();
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

@ -16,6 +16,7 @@
#include "MenuParser.h"
#include "CollectionInfo.h"
#include "CollectionInfoBuilder.h"
#include "Item.h"
#include "../Utility/Log.h"
#include "../Utility/Utils.h"
@ -40,7 +41,7 @@ MenuParser::~MenuParser()
}
//todo: clean up this method, too much nesting
bool MenuParser::buildMenuItems(CollectionInfo *collection, bool sort)
bool MenuParser::buildMenuItems(CollectionInfo *collection, bool sort, CollectionInfoBuilder &builder)
{
bool retVal = false;
//todo: magic string
@ -93,6 +94,8 @@ bool MenuParser::buildMenuItems(CollectionInfo *collection, bool sort)
item->fullTitle = title;
item->name = collectionAttribute->value();
item->leaf = false;
item->collectionInfo = collection;
menuItems.push_back(item);
}
else
@ -100,11 +103,14 @@ bool MenuParser::buildMenuItems(CollectionInfo *collection, bool sort)
std::string collectionName = collectionAttribute->value();
Logger::write(Logger::ZONE_INFO, "Menu", "Loading collection into menu: " + collectionName);
//todo: unsupported option with this refactor
// need to append the collection
CollectionInfo *subcollection = builder.buildCollection(collectionName);
collection->addSubcollection(subcollection);
}
}
std::sort( collection->items.begin(), collection->items.end(), VectorSort);
// todo: sorting should occur within the collection itself, not externally
if(sort)
{

View File

@ -15,6 +15,7 @@
*/
#pragma once
#include "CollectionInfoBuilder.h"
class CollectionInfo;
class MenuParser
@ -22,6 +23,6 @@ class MenuParser
public:
MenuParser();
virtual ~MenuParser();
bool buildMenuItems(CollectionInfo *cdb, bool sort);
bool buildMenuItems(CollectionInfo *cdb, bool sort, CollectionInfoBuilder &builder);
};

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

@ -383,7 +383,7 @@ bool Component::animate(bool loop)
}
else
{
elapsedTime = tween->duration;
elapsedTime = static_cast<float>(tween->duration);
}
float value = tween->animate(elapsedTime);

View File

@ -135,10 +135,10 @@ void ReloadableMedia::freeGraphicsMemory()
loadedComponent_->freeGraphicsMemory();
}
}
void ReloadableMedia::reloadTexture()
{
bool found = false;
if(loadedComponent_)
{
delete loadedComponent_;
@ -146,125 +146,213 @@ void ReloadableMedia::reloadTexture()
}
Item *selectedItem = getSelectedItem();
if(!selectedItem) return;
config_.getProperty("currentCollection", currentCollection_);
if (selectedItem != NULL)
// build clone list
std::vector<std::string> names;
names.push_back(selectedItem->name);
names.push_back(selectedItem->fullTitle);
if(selectedItem->cloneof.length() > 0)
{
std::vector<std::string> names;
names.push_back(selectedItem->cloneof);
}
names.push_back(selectedItem->name);
names.push_back(selectedItem->fullTitle);
if(selectedItem->cloneof.length() > 0)
if(isVideo_)
{
for(unsigned int n = 0; n < names.size() && !loadedComponent_; ++n)
{
names.push_back(selectedItem->cloneof);
}
for(unsigned int n = 0; n < names.size() && !found; ++n)
{
if(isVideo_)
std::string basename = names[n];
if(systemMode_)
{
VideoBuilder videoBuild;
std::string videoPath;
if(systemMode_)
// check the master collection for the system artifact
loadedComponent_ = findComponent(collectionName, "video", "video", true);
// check the collection for the system artifact
if(!loadedComponent_)
{
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_);
loadedComponent_ = findComponent(selectedItem->collectionInfo->name, "video", "video", true);
}
if(!loadedComponent_ && !systemMode_)
}
else
{
// are we looking at a leaf or a submenu
if (selectedItem->leaf) // item is a leaf
{
config_.getMediaPropertyAbsolutePath(names[n], type_, true, videoPath);
loadedComponent_ = videoBuild.createVideo(videoPath, "video", scaleX_, scaleY_);
// check the master collection for the artifact
loadedComponent_ = findComponent(collectionName, "video", basename, false);
// check the collection for the artifact
if(!loadedComponent_)
{
loadedComponent_ = findComponent(selectedItem->collectionInfo->name, "video", basename, false);
}
}
if(loadedComponent_)
else // item is a submenu
{
loadedComponent_->allocateGraphicsMemory();
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
found = true;
}
}
std::string imageBasename = names[n];
// check the master collection for the artifact
loadedComponent_ = findComponent(collectionName, "video", basename, false);
std::string typeLC = Utils::toLower(type_);
// check the collection for the artifact
if(!loadedComponent_)
{
loadedComponent_ = findComponent(selectedItem->collectionInfo->name, "video", basename, false);
}
if(typeLC == "numberButtons")
{
imageBasename = selectedItem->numberButtons;
}
else if(typeLC == "numberPlayers")
{
imageBasename = selectedItem->numberPlayers;
}
else if(typeLC == "year")
{
imageBasename = selectedItem->year;
}
else if(typeLC == "title")
{
imageBasename = selectedItem->title;
}
else if(typeLC == "manufacturer")
{
imageBasename = selectedItem->manufacturer;
}
else if(typeLC == "genre")
{
imageBasename = selectedItem->genre;
}
// check the submenu collection for the system artifact
if (!loadedComponent_)
{
loadedComponent_ = findComponent(selectedItem->name, "video", "video", true);
}
Utils::replaceSlashesWithUnderscores(imageBasename);
if(!loadedComponent_)
{
std::string imagePath;
ImageBuilder imageBuild;
if(systemMode_)
{
config_.getMediaPropertyAbsolutePath(collectionName, type_, true, imagePath);
loadedComponent_ = imageBuild.CreateImage(imagePath, type_, scaleX_, scaleY_);
}
else
{
config_.getMediaPropertyAbsolutePath(collectionName, type_, false, imagePath);
loadedComponent_ = imageBuild.CreateImage(imagePath, imageBasename, scaleX_, scaleY_);
}
if(!loadedComponent_ && !systemMode_)
{
config_.getMediaPropertyAbsolutePath(imageBasename, type_, true, imagePath);
loadedComponent_ = imageBuild.CreateImage(imagePath, type_, scaleX_, scaleY_);
}
if (loadedComponent_ != NULL)
{
loadedComponent_->allocateGraphicsMemory();
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
}
}
if(!loadedComponent_ && textFallback_)
if(loadedComponent_)
{
loadedComponent_ = new Text(imageBasename, FfntInst_, scaleX_, scaleY_);
loadedComponent_->allocateGraphicsMemory();
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
}
}
}
// check for images if video could not be found (and was specified)
for(unsigned int n = 0; n < names.size() && !loadedComponent_; ++n)
{
std::string basename = names[n];
std::string typeLC = Utils::toLower(type_);
if(typeLC == "numberButtons")
{
basename = selectedItem->numberButtons;
}
else if(typeLC == "numberPlayers")
{
basename = selectedItem->numberPlayers;
}
else if(typeLC == "year")
{
basename = selectedItem->year;
}
else if(typeLC == "title")
{
basename = selectedItem->title;
}
else if(typeLC == "manufacturer")
{
basename = selectedItem->manufacturer;
}
else if(typeLC == "genre")
{
basename = selectedItem->genre;
}
Utils::replaceSlashesWithUnderscores(basename);
if(systemMode_)
{
// check the master collection for the system artifact
loadedComponent_ = findComponent(collectionName, type_, type_, true);
// check collection for the system artifact
if(!loadedComponent_)
{
loadedComponent_ = findComponent(selectedItem->collectionInfo->name, type_, type_, true);
}
}
else
{
// are we looking at a leaf or a submenu
if (selectedItem->leaf) // item is a leaf
{
// check the master collection for the artifact
loadedComponent_ = findComponent(collectionName, type_, basename, false);
// check the collection for the artifact
if(!loadedComponent_)
{
loadedComponent_ = findComponent(selectedItem->collectionInfo->name, type_, basename, false);
}
}
else // item is a submenu
{
// check the master collection for the artifact
loadedComponent_ = findComponent(collectionName, type_, basename, false);
// check the collection for the artifact
if(!loadedComponent_)
{
loadedComponent_ = findComponent(selectedItem->collectionInfo->name, type_, basename, false);
}
// check the submenu collection for the system artifact
if (!loadedComponent_)
{
loadedComponent_ = findComponent(selectedItem->name, type_, type_, true);
}
}
}
if (loadedComponent_ != NULL)
{
loadedComponent_->allocateGraphicsMemory();
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
}
}
// if image and artwork was not specified, fall back to displaying text
if(!loadedComponent_ && textFallback_)
{
loadedComponent_ = new Text(selectedItem->fullTitle, FfntInst_, scaleX_, scaleY_);
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
}
}
Component *ReloadableMedia::findComponent(std::string collection, std::string type, std::string basename, bool systemMode)
{
std::string imagePath;
Component *component = NULL;
VideoBuilder videoBuild;
ImageBuilder imageBuild;
// check the system folder
config_.getMediaPropertyAbsolutePath(collection, type, systemMode, imagePath);
std::cout << "searching path: " << imagePath << " =>" << basename << std::endl;
if(type == "video")
{
component = videoBuild.createVideo(imagePath, basename, scaleX_, scaleY_);
}
else
{
component = imageBuild.CreateImage(imagePath, basename, scaleX_, scaleY_);
}
return component;
}
void ReloadableMedia::draw()

View File

@ -35,6 +35,8 @@ public:
void allocateGraphicsMemory();
void launchEnter();
void launchExit();
Component *findComponent(std::string collection, std::string type, std::string basename, bool systemMode);
void enableTextFallback_(bool value);
private:

View File

@ -782,19 +782,53 @@ 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 parent game name
if(!t && item->cloneof != "")
{
config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->cloneof, scaleX_, scaleY_);
}
// check sub-collection path for art based on parent game name
if(!t && item->cloneof != "")
{
config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->cloneof, 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_);

View File

@ -284,7 +284,10 @@ void RetroFE::run()
config_.setProperty("currentCollection", firstCollection);
CollectionInfo *info = getCollection(firstCollection);
MenuParser mp;
mp.buildMenuItems(info, menuSort);
CollectionInfoBuilder cib(config_, *metadb_);
mp.buildMenuItems(info, menuSort, cib);
currentPage_->pushCollection(info);
}
else
@ -305,7 +308,7 @@ void RetroFE::run()
case RETROFE_LAUNCH_REQUEST:
nextPageItem_ = currentPage_->getSelectedItem();
l.run(currentPage_->getCollectionName(), nextPageItem_);
l.run(nextPageItem_->collectionInfo->name, nextPageItem_);
state = RETROFE_IDLE;
break;
@ -466,7 +469,8 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page)
CollectionInfo *info = getCollection(nextPageItem_->name);
MenuParser mp;
mp.buildMenuItems(info, menuSort);
CollectionInfoBuilder cib(config_, *metadb_);
mp.buildMenuItems(info, menuSort, cib);
page->pushCollection(info);
if(rememberMenu && lastMenuOffsets_.find(nextPageItem_->name) != lastMenuOffsets_.end())