From d7e6b7bf1178aa22199d914819ab603b902419bc Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Fri, 19 Aug 2016 10:52:38 +0200 Subject: [PATCH] Added support for mode="layout" for menu items. --- .../Graphics/Component/ScrollingList.cpp | 77 +++++++++++++++++-- .../Source/Graphics/Component/ScrollingList.h | 4 +- RetroFE/Source/Graphics/PageBuilder.cpp | 23 ++++-- 3 files changed, 89 insertions(+), 15 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 5a5428d..0bd7cfd 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -41,6 +41,7 @@ //todo: remove coupling from configuration data (if possible) ScrollingList::ScrollingList(Configuration &c, Page &p, + bool layoutMode, float scaleX, float scaleY, Font *font, @@ -48,6 +49,7 @@ ScrollingList::ScrollingList(Configuration &c, std::string imageType) : Component(p) , horizontalScroll(false) + , layoutMode_(layoutMode) , spriteList_(NULL) , scrollPoints_(NULL) , tweenPoints_(NULL) @@ -585,50 +587,109 @@ bool ScrollingList::allocateTexture(unsigned int index, Item *item) ImageBuilder imageBuild; + std::string layoutName; + config_.getProperty("layout", layoutName); + // check collection path for art based on gamename - config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath); + if (layoutMode_) + { + imagePath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, "collections", collectionName); + imagePath = Utils::combinePath(imagePath, "medium_artwork", imageType_); + } + else + { + config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath); + } t = imageBuild.CreateImage(imagePath, page, item->name, scaleX_, scaleY_); // check sub-collection path for art based on gamename if(!t) { - config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath); + if (layoutMode_) + { + imagePath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, "collections", item->collectionInfo->name); + imagePath = Utils::combinePath(imagePath, "medium_artwork", imageType_); + } + else + { + config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath); + } t = imageBuild.CreateImage(imagePath, page, 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); + if (layoutMode_) + { + imagePath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, "collections", collectionName); + imagePath = Utils::combinePath(imagePath, "medium_artwork", imageType_); + } + else + { + config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath); + } t = imageBuild.CreateImage(imagePath, page, 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); + if (layoutMode_) + { + imagePath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, "collections", item->collectionInfo->name); + imagePath = Utils::combinePath(imagePath, "medium_artwork", imageType_); + } + else + { + config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath); + } t = imageBuild.CreateImage(imagePath, page, item->fullTitle, scaleX_, scaleY_); } // check collection path for art based on parent game name if(!t && item->cloneof != "") { - config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath); + if (layoutMode_) + { + imagePath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, "collections", collectionName); + imagePath = Utils::combinePath(imagePath, "medium_artwork", imageType_); + } + else + { + config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath); + } t = imageBuild.CreateImage(imagePath, page, 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); + if (layoutMode_) + { + imagePath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, "collections", item->collectionInfo->name); + imagePath = Utils::combinePath(imagePath, "medium_artwork", imageType_); + } + else + { + config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath); + } t = imageBuild.CreateImage(imagePath, page, 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, page, imageType_, scaleX_, scaleY_); + if (layoutMode_) + { + imagePath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, "collections", item->name); + imagePath = Utils::combinePath(imagePath, "system_artwork"); + } + else + { + config_.getMediaPropertyAbsolutePath(item->name, imageType_, true, imagePath); + } + t = imageBuild.CreateImage(imagePath, page, imageType_, scaleX_, scaleY_); } if (!t) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 7d658d5..9654683 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -44,6 +44,7 @@ public: ScrollingList(Configuration &c, Page &p, + bool layoutMode, float scaleX, float scaleY, Font *font, @@ -65,7 +66,7 @@ public: void destroyItems(); void setPoints(std::vector *scrollPoints, std::vector *tweenPoints); void setScrollDirection(ScrollDirection direction); - unsigned int getSelectedIndex(); + unsigned int getSelectedIndex(); unsigned int getSize(); void pageUp(); void pageDown(); @@ -104,6 +105,7 @@ private: ScrollStateIdle }; + bool layoutMode_; std::vector *spriteList_; std::vector *scrollPoints_; std::vector *tweenPoints_; diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 6d76f40..e1147cb 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -733,12 +733,13 @@ ScrollingList * PageBuilder::buildMenu(xml_node<> *menuXml, Page &page) std::string menuType = "vertical"; std::string imageType = "null"; std::map *> overrideItems; - xml_node<> *itemDefaults = menuXml->first_node("itemDefaults"); - xml_attribute<> *imageTypeXml = menuXml->first_attribute("imageType"); - xml_attribute<> *menuTypeXml = menuXml->first_attribute("type"); - xml_attribute<> *scrollTimeXml = menuXml->first_attribute("scrollTime"); + xml_node<> *itemDefaults = menuXml->first_node("itemDefaults"); + xml_attribute<> *modeXml = menuXml->first_attribute("mode"); + xml_attribute<> *imageTypeXml = menuXml->first_attribute("imageType"); + xml_attribute<> *menuTypeXml = menuXml->first_attribute("type"); + xml_attribute<> *scrollTimeXml = menuXml->first_attribute("scrollTime"); xml_attribute<> *scrollAccelerationXml = menuXml->first_attribute("scrollAcceleration"); - xml_attribute<> *scrollOrientationXml = menuXml->first_attribute("orientation"); + xml_attribute<> *scrollOrientationXml = menuXml->first_attribute("orientation"); if(menuTypeXml) { @@ -756,10 +757,20 @@ ScrollingList * PageBuilder::buildMenu(xml_node<> *menuXml, Page &page) imageType = imageTypeXml->value(); } + bool layoutMode = false; + if(modeXml) + { + std::string sysMode = modeXml->value(); + if(sysMode == "layout") + { + layoutMode = true; + } + } + // on default, text will be rendered to the menu. Preload it into cache. Font *font = addFont(itemDefaults, NULL); - menu = new ScrollingList(config_, page, scaleX_, scaleY_, font, layoutKey, imageType); + menu = new ScrollingList(config_, page, layoutMode, scaleX_, scaleY_, font, layoutKey, imageType); if(scrollTimeXml) {