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/<layout name>/collections/MAME/medium_artwork/video/mslug.mp4
Example:
  mode "system":       load collections/MAME/system_artwork/device.png
  mode "systemlayout": load layouts/<layout name>/collections/MAME/system_artwork/device.png
This commit is contained in:
Pieter Hulshoff 2016-06-08 13:32:23 +02:00
parent 3f3a53e6c0
commit 1157096f55
3 changed files with 29 additions and 4 deletions

View File

@ -28,10 +28,11 @@
#include <vector>
#include <iostream>
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")
{

View File

@ -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_;

View File

@ -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")