From 8d819451b4257914f2a2527bda4266165cb44aab Mon Sep 17 00:00:00 2001 From: Don Honerbrink Date: Tue, 23 Jun 2015 15:36:39 +0000 Subject: [PATCH 01/11] Updated rocketlauncher.conf. --- Package/Environment/Windows/launchers/rocketlauncher.conf | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Package/Environment/Windows/launchers/rocketlauncher.conf diff --git a/Package/Environment/Windows/launchers/rocketlauncher.conf b/Package/Environment/Windows/launchers/rocketlauncher.conf new file mode 100644 index 0000000..f895b5b --- /dev/null +++ b/Package/Environment/Windows/launchers/rocketlauncher.conf @@ -0,0 +1,6 @@ +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%" \ No newline at end of file From 16e69be97b9c934dd35555475a0640effdb2baa0 Mon Sep 17 00:00:00 2001 From: Don Honerbrink Date: Tue, 23 Jun 2015 15:37:21 +0000 Subject: [PATCH 02/11] hyperlaunch.conf deleted online with Bitbucket --- Package/Environment/Common/launchers/hyperlaunch.conf | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 Package/Environment/Common/launchers/hyperlaunch.conf diff --git a/Package/Environment/Common/launchers/hyperlaunch.conf b/Package/Environment/Common/launchers/hyperlaunch.conf deleted file mode 100644 index 057a172..0000000 --- a/Package/Environment/Common/launchers/hyperlaunch.conf +++ /dev/null @@ -1,6 +0,0 @@ -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%" From 2320c62577a4c8aad3bd780a97219db027b9a6f5 Mon Sep 17 00:00:00 2001 From: Don Honerbrink Date: Thu, 25 Jun 2015 17:45:09 -0500 Subject: [PATCH 03/11] Starting development branch. Merging works, artwork does not fully work. --- RetroFE/Source/Collection/MenuParser.cpp | 14 +++++++++++++- RetroFE/Source/Collection/MenuParser.h | 3 ++- RetroFE/Source/RetroFE.cpp | 8 ++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/RetroFE/Source/Collection/MenuParser.cpp b/RetroFE/Source/Collection/MenuParser.cpp index 3ff41fa..defee6d 100644 --- a/RetroFE/Source/Collection/MenuParser.cpp +++ b/RetroFE/Source/Collection/MenuParser.cpp @@ -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 @@ -99,12 +100,23 @@ bool MenuParser::buildMenuItems(CollectionInfo *collection, bool sort) { 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 } } + + std::sort( collection->items.begin(), collection->items.end(), VectorSort); + // todo: sorting should occur within the collection itself, not externally if(sort) { diff --git a/RetroFE/Source/Collection/MenuParser.h b/RetroFE/Source/Collection/MenuParser.h index bb957cb..5386cdd 100644 --- a/RetroFE/Source/Collection/MenuParser.h +++ b/RetroFE/Source/Collection/MenuParser.h @@ -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); }; diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 95b18f4..1ce9bbe 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -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 @@ -469,7 +472,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()) From b8e7d708f10b1726376d38974570ed5378fe1f11 Mon Sep 17 00:00:00 2001 From: Don Honerbrink Date: Fri, 26 Jun 2015 09:40:11 -0500 Subject: [PATCH 04/11] Support for merged collection mediapaths. --- .hgignore | 1 + RetroFE/Source/Collection/CollectionInfo.cpp | 17 ++++++++++++- RetroFE/Source/Collection/CollectionInfo.h | 3 +++ .../Collection/CollectionInfoBuilder.cpp | 14 ++++++----- .../Source/Collection/CollectionInfoBuilder.h | 2 +- RetroFE/Source/Collection/Item.cpp | 3 ++- RetroFE/Source/Collection/Item.h | 3 ++- RetroFE/Source/Collection/MenuParser.cpp | 14 ++++------- RetroFE/Source/Execute/Launcher.cpp | 2 +- .../Graphics/Component/ReloadableMedia.cpp | 13 +++++----- .../Graphics/Component/ScrollingList.cpp | 24 +++++++++++++++++-- 11 files changed, 67 insertions(+), 29 deletions(-) diff --git a/.hgignore b/.hgignore index 2e155dd..ffb94b6 100644 --- a/.hgignore +++ b/.hgignore @@ -8,4 +8,5 @@ Documentation/Artifacts/* Documentation/Manual/_build/* Configuration/Configuration/bin/** Configuration/Configuration/obj/** +Artifacts/** diff --git a/RetroFE/Source/Collection/CollectionInfo.cpp b/RetroFE/Source/Collection/CollectionInfo.cpp index 0897ac0..de0b0cf 100644 --- a/RetroFE/Source/Collection/CollectionInfo.cpp +++ b/RetroFE/Source/Collection/CollectionInfo.cpp @@ -35,8 +35,17 @@ CollectionInfo::CollectionInfo(std::string name, CollectionInfo::~CollectionInfo() { - std::vector::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::iterator subit; + for (subit != subcollections_.begin(); subit != subcollections_.end(); subit++) + { + CollectionInfo *info = *subit; + info->items.clear(); + } + + std::vector::iterator it = items.begin(); while(it != items.end()) { delete *it; @@ -62,6 +71,12 @@ void CollectionInfo::extensionList(std::vector &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) { diff --git a/RetroFE/Source/Collection/CollectionInfo.h b/RetroFE/Source/Collection/CollectionInfo.h index c3589ab..2effbc9 100644 --- a/RetroFE/Source/Collection/CollectionInfo.h +++ b/RetroFE/Source/Collection/CollectionInfo.h @@ -27,13 +27,16 @@ public: virtual ~CollectionInfo(); std::string settingsPath() const; void sortItems(); + void addSubcollection(CollectionInfo *info); void extensionList(std::vector &extensions); std::string name; std::string listpath; std::string metadataType; + std::string launcher; std::vector items; private: + std::vector subcollections_; std::string metadataPath_; std::string extensions_; static bool itemIsLess(Item *lhs, Item *rhs); diff --git a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp index f6e3374..39e8d13 100644 --- a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp +++ b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp @@ -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 &list) +bool CollectionInfoBuilder::ImportBasicList(CollectionInfo *info, std::string file, std::map &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 extensions; std::vector::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); } } diff --git a/RetroFE/Source/Collection/CollectionInfoBuilder.h b/RetroFE/Source/Collection/CollectionInfoBuilder.h index eacbf3a..5bd5221 100644 --- a/RetroFE/Source/Collection/CollectionInfoBuilder.h +++ b/RetroFE/Source/Collection/CollectionInfoBuilder.h @@ -35,6 +35,6 @@ public: private: Configuration &conf_; MetadataDatabase &metaDB_; - bool ImportBasicList(CollectionInfo *info, std::string file, std::string launcher, std::map &list); + bool ImportBasicList(CollectionInfo *info, std::string file, std::map &list); bool ImportDirectory(CollectionInfo *info); }; diff --git a/RetroFE/Source/Collection/Item.cpp b/RetroFE/Source/Collection/Item.cpp index 7d63809..7f74e79 100644 --- a/RetroFE/Source/Collection/Item.cpp +++ b/RetroFE/Source/Collection/Item.cpp @@ -20,7 +20,8 @@ #include Item::Item() - : leaf(true) + : collectionInfo(NULL) + , leaf(true) { } diff --git a/RetroFE/Source/Collection/Item.h b/RetroFE/Source/Collection/Item.h index c4bd20f..1826f50 100644 --- a/RetroFE/Source/Collection/Item.h +++ b/RetroFE/Source/Collection/Item.h @@ -16,6 +16,7 @@ #pragma once #include +#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; }; diff --git a/RetroFE/Source/Collection/MenuParser.cpp b/RetroFE/Source/Collection/MenuParser.cpp index defee6d..b07beb3 100644 --- a/RetroFE/Source/Collection/MenuParser.cpp +++ b/RetroFE/Source/Collection/MenuParser.cpp @@ -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); } } diff --git a/RetroFE/Source/Execute/Launcher.cpp b/RetroFE/Source/Execute/Launcher.cpp index 2720116..d708c84 100644 --- a/RetroFE/Source/Execute/Launcher.cpp +++ b/RetroFE/Source/Execute/Launcher.cpp @@ -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; diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index 8e846a8..b9f4566 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -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_); } diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 6068bb0..8f05449 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -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_); From c0e086d55c7246ddd48228ada72ac495860675f6 Mon Sep 17 00:00:00 2001 From: emb <> Date: Thu, 2 Jul 2015 07:50:06 -0500 Subject: [PATCH 05/11] Updated launcher execution to execute. Fixed windows compile errors from refactor. --- RetroFE/Source/Database/Configuration.cpp | 2 +- RetroFE/Source/Graphics/Component/Component.cpp | 2 +- RetroFE/Source/RetroFE.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RetroFE/Source/Database/Configuration.cpp b/RetroFE/Source/Database/Configuration.cpp index f9cf2dc..ff8c92b 100644 --- a/RetroFE/Source/Database/Configuration.cpp +++ b/RetroFE/Source/Database/Configuration.cpp @@ -55,7 +55,7 @@ void Configuration::initialize() GetModuleFileName(hModule, exe, MAX_PATH); std::string sPath(exe); sPath = Utils::getDirectory(sPath); - sPath = Utils::GetParentDirectory(sPath); + sPath = Utils::getParentDirectory(sPath); #else char exepath[1024]; sprintf(exepath, "/proc/%d/exe", getpid()); diff --git a/RetroFE/Source/Graphics/Component/Component.cpp b/RetroFE/Source/Graphics/Component/Component.cpp index 5540cb5..a95c591 100644 --- a/RetroFE/Source/Graphics/Component/Component.cpp +++ b/RetroFE/Source/Graphics/Component/Component.cpp @@ -383,7 +383,7 @@ bool Component::animate(bool loop) } else { - elapsedTime = tween->duration; + elapsedTime = static_cast(tween->duration); } float value = tween->animate(elapsedTime); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 1ce9bbe..5824a54 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -308,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; From e7e3d5afa54d0b737672f2665b173b4f7c17ab7b Mon Sep 17 00:00:00 2001 From: Don Honerbrink Date: Thu, 2 Jul 2015 11:36:46 -0500 Subject: [PATCH 06/11] Cleaned up ReloadableMedia. Work on fixing search paths --- .../Graphics/Component/ReloadableMedia.cpp | 224 ++++++++++-------- .../Graphics/Component/ReloadableMedia.h | 2 + 2 files changed, 121 insertions(+), 105 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index b9f4566..1250b8c 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -137,8 +137,6 @@ void ReloadableMedia::freeGraphicsMemory() } void ReloadableMedia::reloadTexture() { - bool found = false; - if(loadedComponent_) { delete loadedComponent_; @@ -146,126 +144,142 @@ void ReloadableMedia::reloadTexture() } Item *selectedItem = getSelectedItem(); + if(!selectedItem) return; config_.getProperty("currentCollection", currentCollection_); - if (selectedItem != NULL) + // build clone list + std::vector names; + + names.push_back(selectedItem->name); + names.push_back(selectedItem->fullTitle); + + if(selectedItem->cloneof.length() > 0) { - std::vector 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_) - { - VideoBuilder videoBuild; - std::string videoPath; - - if(systemMode_) - { - config_.getMediaPropertyAbsolutePath(collectionName, "video", true, videoPath); - loadedComponent_ = videoBuild.createVideo(videoPath, "video", scaleX_, scaleY_); - - if(!loadedComponent_) - { - config_.getMediaPropertyAbsolutePath(selectedItem->collectionInfo->name, "video", false, videoPath); - loadedComponent_ = videoBuild.createVideo(videoPath, names[n], scaleX_, scaleY_); - } - } - - if(!loadedComponent_ && !systemMode_) - { - config_.getMediaPropertyAbsolutePath(names[n], type_, true, videoPath); - loadedComponent_ = videoBuild.createVideo(videoPath, "video", scaleX_, scaleY_); - } - - if(loadedComponent_) - { - loadedComponent_->allocateGraphicsMemory(); - baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth; - baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight; - found = true; - } - } - - std::string imageBasename = names[n]; - - std::string typeLC = Utils::toLower(type_); - - 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; - } - - Utils::replaceSlashesWithUnderscores(imageBasename); + std::string basename = names[n]; + loadedComponent_ = findComponent(collectionName, basename, type_); 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(selectedItem->collectionInfo->name, 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; - } - + loadedComponent_ = findComponent(selectedItem->collectionInfo->name, basename, type_); } - 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 imageBasename = names[n]; + + std::string typeLC = Utils::toLower(type_); + + 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; + } + + Utils::replaceSlashesWithUnderscores(imageBasename); + + std::string imagePath; + + loadedComponent_ = findComponent(collectionName, imageBasename, type_); + + if(!loadedComponent_) + { + loadedComponent_ = findComponent(selectedItem->collectionInfo->name, imageBasename, type_); + } + + 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 basename, std::string type) +{ + std::string imagePath; + Component *component = NULL; + VideoBuilder videoBuild; + ImageBuilder imageBuild; + // check the current collection + + if(systemMode_) + { + // check the system folder + config_.getMediaPropertyAbsolutePath(collection, type, true, imagePath); + + if(type == "video") + { + component = videoBuild.createVideo(imagePath, type, scaleX_, scaleY_); + } + else + { + component = imageBuild.CreateImage(imagePath, type, scaleX_, scaleY_); + } + } + else + { + // check the list folders + config_.getMediaPropertyAbsolutePath(collection, type, false, imagePath); + + if(type == "video") + { + component = videoBuild.createVideo(imagePath, basename, scaleX_, scaleY_); + } + else + { + component = imageBuild.CreateImage(imagePath, basename, scaleX_, scaleY_); + } + } + + return component; + } void ReloadableMedia::draw() diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.h b/RetroFE/Source/Graphics/Component/ReloadableMedia.h index 1d28281..69c8620 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.h +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.h @@ -35,6 +35,8 @@ public: void allocateGraphicsMemory(); void launchEnter(); void launchExit(); + Component *findComponent(std::string collection, std::string basename, std::string type); + void enableTextFallback_(bool value); private: From 238cef121a9c409ed2ea467f474ef3ba5f27b931 Mon Sep 17 00:00:00 2001 From: Don Honerbrink Date: Thu, 2 Jul 2015 14:51:23 -0500 Subject: [PATCH 07/11] Only allow searching subcollections when using merged collections --- RetroFE/Source/Collection/CollectionInfo.cpp | 5 + RetroFE/Source/Collection/CollectionInfo.h | 1 + .../Graphics/Component/ReloadableMedia.cpp | 107 +++++++++++------- .../Graphics/Component/ReloadableMedia.h | 2 +- 4 files changed, 71 insertions(+), 44 deletions(-) diff --git a/RetroFE/Source/Collection/CollectionInfo.cpp b/RetroFE/Source/Collection/CollectionInfo.cpp index de0b0cf..508e357 100644 --- a/RetroFE/Source/Collection/CollectionInfo.cpp +++ b/RetroFE/Source/Collection/CollectionInfo.cpp @@ -78,6 +78,11 @@ void CollectionInfo::addSubcollection(CollectionInfo *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) { return lhs->lowercaseFullTitle() < rhs->lowercaseFullTitle(); diff --git a/RetroFE/Source/Collection/CollectionInfo.h b/RetroFE/Source/Collection/CollectionInfo.h index 2effbc9..a1b5812 100644 --- a/RetroFE/Source/Collection/CollectionInfo.h +++ b/RetroFE/Source/Collection/CollectionInfo.h @@ -28,6 +28,7 @@ public: std::string settingsPath() const; void sortItems(); void addSubcollection(CollectionInfo *info); + bool hasSubcollections(); void extensionList(std::vector &extensions); std::string name; std::string listpath; diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index 1250b8c..91da839 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -164,11 +164,29 @@ void ReloadableMedia::reloadTexture() for(unsigned int n = 0; n < names.size() && !loadedComponent_; ++n) { std::string basename = names[n]; - loadedComponent_ = findComponent(collectionName, basename, type_); - - if(!loadedComponent_) + if(systemMode_) { - loadedComponent_ = findComponent(selectedItem->collectionInfo->name, basename, type_); + // only look through the master collection for the system artifact + loadedComponent_ = findComponent(collectionName, type_, type_, true); + } + else + { + // check the master collection for the artifact + loadedComponent_ = findComponent(collectionName, type_, basename, false); + + if(!loadedComponent_ && selectedItem->collectionInfo->hasSubcollections()) + { + if(selectedItem->leaf) + { + // check the subcollection for artwork artifacts + loadedComponent_ = findComponent(selectedItem->collectionInfo->name, type_, basename, false); + } + else + { + // item is a submenu, check the subcollection for system artwork artifacts + loadedComponent_ = findComponent(selectedItem->collectionInfo->name, type_, type_, true); + } + } } if(loadedComponent_) @@ -183,45 +201,62 @@ void ReloadableMedia::reloadTexture() // check for images if video could not be found (and was specified) for(unsigned int n = 0; n < names.size() && !loadedComponent_; ++n) { - std::string imageBasename = names[n]; + std::string basename = names[n]; std::string typeLC = Utils::toLower(type_); if(typeLC == "numberButtons") { - imageBasename = selectedItem->numberButtons; + basename = selectedItem->numberButtons; } else if(typeLC == "numberPlayers") { - imageBasename = selectedItem->numberPlayers; + basename = selectedItem->numberPlayers; } else if(typeLC == "year") { - imageBasename = selectedItem->year; + basename = selectedItem->year; } else if(typeLC == "title") { - imageBasename = selectedItem->title; + basename = selectedItem->title; } else if(typeLC == "manufacturer") { - imageBasename = selectedItem->manufacturer; + basename = selectedItem->manufacturer; } else if(typeLC == "genre") { - imageBasename = selectedItem->genre; + basename = selectedItem->genre; } - Utils::replaceSlashesWithUnderscores(imageBasename); + Utils::replaceSlashesWithUnderscores(basename); - std::string imagePath; - - loadedComponent_ = findComponent(collectionName, imageBasename, type_); - - if(!loadedComponent_) + if(systemMode_) { - loadedComponent_ = findComponent(selectedItem->collectionInfo->name, imageBasename, type_); + // only look through the master collection for the system artifact + loadedComponent_ = findComponent(collectionName, type_, type_, true); } + else + { + // check the master collection for the artifact + loadedComponent_ = findComponent(collectionName, type_, basename, false); + + if(!loadedComponent_ && selectedItem->collectionInfo->hasSubcollections()) + { + if(selectedItem->leaf) + { + // check the subcollection for artwork artifacts + loadedComponent_ = findComponent(selectedItem->collectionInfo->name, type_, basename, false); + } + else + { + // item is a submenu, check the subcollection for system artwork artifacts + loadedComponent_ = findComponent(selectedItem->collectionInfo->name, type_, type_, true); + } + } + } + if (loadedComponent_ != NULL) { @@ -241,41 +276,27 @@ void ReloadableMedia::reloadTexture() } -Component *ReloadableMedia::findComponent(std::string collection, std::string basename, std::string type) +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 current collection - if(systemMode_) + // check the system folder + config_.getMediaPropertyAbsolutePath(collection, type, systemMode, imagePath); + + if(type == "video") { - // check the system folder - config_.getMediaPropertyAbsolutePath(collection, type, true, imagePath); - - if(type == "video") - { - component = videoBuild.createVideo(imagePath, type, scaleX_, scaleY_); - } - else - { - component = imageBuild.CreateImage(imagePath, type, scaleX_, scaleY_); - } + component = videoBuild.createVideo(imagePath, basename, scaleX_, scaleY_); +if(component) +{ +std::cout << "Found video!" << std::endl; +} } else { - // check the list folders - config_.getMediaPropertyAbsolutePath(collection, type, false, imagePath); - - if(type == "video") - { - component = videoBuild.createVideo(imagePath, basename, scaleX_, scaleY_); - } - else - { - component = imageBuild.CreateImage(imagePath, basename, scaleX_, scaleY_); - } + component = imageBuild.CreateImage(imagePath, basename, scaleX_, scaleY_); } return component; diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.h b/RetroFE/Source/Graphics/Component/ReloadableMedia.h index 69c8620..6cfdaf1 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.h +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.h @@ -35,7 +35,7 @@ public: void allocateGraphicsMemory(); void launchEnter(); void launchExit(); - Component *findComponent(std::string collection, std::string basename, std::string type); + Component *findComponent(std::string collection, std::string type, std::string basename, bool systemMode); void enableTextFallback_(bool value); From a2512e5b7ef87de5c5e11dd9e1f6ae10329150cb Mon Sep 17 00:00:00 2001 From: Don Honerbrink Date: Thu, 2 Jul 2015 14:54:36 -0500 Subject: [PATCH 08/11] Remove debug couts --- RetroFE/Source/Graphics/Component/ReloadableMedia.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index 91da839..714f864 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -289,10 +289,6 @@ Component *ReloadableMedia::findComponent(std::string collection, std::string ty if(type == "video") { component = videoBuild.createVideo(imagePath, basename, scaleX_, scaleY_); -if(component) -{ -std::cout << "Found video!" << std::endl; -} } else { From e505d702dfd045b8ce1f4a6d9fa6fa5da1c62abe Mon Sep 17 00:00:00 2001 From: Don Honerbrink Date: Thu, 2 Jul 2015 15:22:14 -0500 Subject: [PATCH 09/11] overrwrite video paths --- RetroFE/Source/Graphics/Component/ReloadableMedia.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index 714f864..f0fc346 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -167,12 +167,12 @@ void ReloadableMedia::reloadTexture() if(systemMode_) { // only look through the master collection for the system artifact - loadedComponent_ = findComponent(collectionName, type_, type_, true); + loadedComponent_ = findComponent(collectionName, "video", "video", true); } else { // check the master collection for the artifact - loadedComponent_ = findComponent(collectionName, type_, basename, false); + loadedComponent_ = findComponent(collectionName, "video", basename, false); if(!loadedComponent_ && selectedItem->collectionInfo->hasSubcollections()) { @@ -184,7 +184,7 @@ void ReloadableMedia::reloadTexture() else { // item is a submenu, check the subcollection for system artwork artifacts - loadedComponent_ = findComponent(selectedItem->collectionInfo->name, type_, type_, true); + loadedComponent_ = findComponent(selectedItem->collectionInfo->name, "video", "video", true); } } } @@ -285,6 +285,7 @@ Component *ReloadableMedia::findComponent(std::string collection, std::string ty // check the system folder config_.getMediaPropertyAbsolutePath(collection, type, systemMode, imagePath); +std::cout << "searching path: " << imagePath << " =>" << basename << std::endl; if(type == "video") { From ac4cd7719b251212ac445ec16f9421fb7967b848 Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Wed, 22 Jul 2015 21:12:46 +0200 Subject: [PATCH 10/11] Fixed reloadable media paths. --- .../Graphics/Component/ReloadableMedia.cpp | 113 +++++++++++++----- 1 file changed, 84 insertions(+), 29 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index f0fc346..fb61a5e 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -135,6 +135,8 @@ void ReloadableMedia::freeGraphicsMemory() loadedComponent_->freeGraphicsMemory(); } } + + void ReloadableMedia::reloadTexture() { if(loadedComponent_) @@ -166,27 +168,54 @@ void ReloadableMedia::reloadTexture() std::string basename = names[n]; if(systemMode_) { - // only look through the master collection for the system artifact + + // check the master collection for the system artifact loadedComponent_ = findComponent(collectionName, "video", "video", true); + + // check the collection for the system artifact + if(!loadedComponent_) + { + loadedComponent_ = findComponent(selectedItem->collectionInfo->name, "video", "video", true); + } + } else { - // check the master collection for the artifact - loadedComponent_ = findComponent(collectionName, "video", basename, false); - if(!loadedComponent_ && selectedItem->collectionInfo->hasSubcollections()) + // are we looking at a leaf or a submenu + if (selectedItem->leaf) // item is a leaf { - if(selectedItem->leaf) - { - // check the subcollection for artwork artifacts - loadedComponent_ = findComponent(selectedItem->collectionInfo->name, type_, basename, false); - } - else - { - // item is a submenu, check the subcollection for system artwork artifacts - loadedComponent_ = findComponent(selectedItem->collectionInfo->name, "video", "video", true); - } + + // 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); + } + } + else // item is a submenu + { + + // 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); + } + + // check the submenu collection for the system artifact + if (!loadedComponent_) + { + loadedComponent_ = findComponent(selectedItem->name, "video", "video", true); + } + + } + } if(loadedComponent_) @@ -234,29 +263,55 @@ void ReloadableMedia::reloadTexture() if(systemMode_) { - // only look through the master collection for the system artifact + + // 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 { - // check the master collection for the artifact - loadedComponent_ = findComponent(collectionName, type_, basename, false); - if(!loadedComponent_ && selectedItem->collectionInfo->hasSubcollections()) + // are we looking at a leaf or a submenu + if (selectedItem->leaf) // item is a leaf { - if(selectedItem->leaf) - { - // check the subcollection for artwork artifacts - loadedComponent_ = findComponent(selectedItem->collectionInfo->name, type_, basename, false); - } - else - { - // item is a submenu, check the subcollection for system artwork artifacts - loadedComponent_ = findComponent(selectedItem->collectionInfo->name, type_, type_, true); - } + + // 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) { From 5e9c7f0448e476ce3e264ccc9e1b32c11f638fe4 Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Wed, 22 Jul 2015 22:23:17 +0200 Subject: [PATCH 11/11] Added search for parent art in scrolling list. --- .../Source/Graphics/Component/ScrollingList.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 8f05449..81fe8e8 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -808,6 +808,20 @@ bool ScrollingList::allocateTexture(ComponentItemBinding *s) 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) {