From 1157096f55b1b70062d5767cd33a0e08326f6156 Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Wed, 8 Jun 2016 13:32:23 +0200 Subject: [PATCH] Added mode attribute "layout" and "systemlayout" to allow art to be loaded from the layout directory rather than the collections directory. Their standard counter modes are no mode attribute, and mode="system". Example: no mode: load collections/MAME/medium_artwork/video/mslug.mp4 mode "layout": load layouts//collections/MAME/medium_artwork/video/mslug.mp4 Example: mode "system": load collections/MAME/system_artwork/device.png mode "systemlayout": load layouts//collections/MAME/system_artwork/device.png --- .../Graphics/Component/ReloadableMedia.cpp | 18 ++++++++++++++++-- .../Graphics/Component/ReloadableMedia.h | 3 ++- RetroFE/Source/Graphics/PageBuilder.cpp | 12 +++++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index 679f0af..8d94a3d 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -28,10 +28,11 @@ #include #include -ReloadableMedia::ReloadableMedia(Configuration &config, bool systemMode, std::string type, Page &p, int displayOffset, bool isVideo, Font *font, float scaleX, float scaleY) +ReloadableMedia::ReloadableMedia(Configuration &config, bool systemMode, bool layoutMode, std::string type, Page &p, int displayOffset, bool isVideo, Font *font, float scaleX, float scaleY) : Component(p) , config_(config) , systemMode_(systemMode) + , layoutMode_(layoutMode) , loadedComponent_(NULL) , videoInst_(NULL) , isVideo_(isVideo) @@ -329,7 +330,20 @@ Component *ReloadableMedia::findComponent(std::string collection, std::string ty ImageBuilder imageBuild; // check the system folder - config_.getMediaPropertyAbsolutePath(collection, type, systemMode, imagePath); + if (layoutMode_) + { + std::string layoutName; + config_.getProperty("layout", layoutName); + imagePath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, "collections", collection); + if (systemMode) + imagePath = Utils::combinePath(imagePath, "system_artwork"); + else + imagePath = Utils::combinePath(imagePath, "medium_artwork"); + } + else + { + config_.getMediaPropertyAbsolutePath(collection, type, systemMode, imagePath); + } if(type == "video") { diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.h b/RetroFE/Source/Graphics/Component/ReloadableMedia.h index 8639666..ed07d77 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.h +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.h @@ -27,7 +27,7 @@ class Image; class ReloadableMedia : public Component { public: - ReloadableMedia(Configuration &config, bool systemMode, std::string type, Page &page, int displayOffset, bool isVideo, Font *font, float scaleX, float scaleY); + ReloadableMedia(Configuration &config, bool systemMode, bool layoutMode, std::string type, Page &page, int displayOffset, bool isVideo, Font *font, float scaleX, float scaleY); virtual ~ReloadableMedia(); void update(float dt); void draw(); @@ -43,6 +43,7 @@ private: void reloadTexture(); Configuration &config_; bool systemMode_; + bool layoutMode_; Component *loadedComponent_; IVideo *videoInst_; bool isVideo_; diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index ed3ee4d..b554d77 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -406,6 +406,7 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName, xml_attribute<> *timeFormatXml = componentXml->first_attribute("timeFormat"); xml_attribute<> *selectedOffsetXml = componentXml->first_attribute("selectedOffset"); bool systemMode = false; + bool layoutMode = false; int selectedOffset = 0; if(tagName == "reloadableVideo") { @@ -430,6 +431,15 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName, { systemMode = true; } + if(sysMode == "layout") + { + layoutMode = true; + } + if(sysMode == "systemlayout") + { + systemMode = true; + layoutMode = true; + } } if(selectedOffsetXml) @@ -458,7 +468,7 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName, else { Font *font = addFont(componentXml, NULL); - c = new ReloadableMedia(config_, systemMode, type->value(), *page, selectedOffset, (tagName == "reloadableVideo"), font, scaleX_, scaleY_); + c = new ReloadableMedia(config_, systemMode, layoutMode, type->value(), *page, selectedOffset, (tagName == "reloadableVideo"), font, scaleX_, scaleY_); xml_attribute<> *textFallback = componentXml->first_attribute("textFallback"); if(textFallback && Utils::toLower(textFallback->value()) == "true")