Added support for genre/manufacturer/year for collections, drawing the information from fields of the same name in the collection's settings.conf.

This commit is contained in:
Pieter Hulshoff 2016-05-04 10:22:01 +02:00
parent 93f6b65c1e
commit 9ead070052
4 changed files with 35 additions and 17 deletions

View File

@ -119,18 +119,22 @@ bool CollectionInfoBuilder::createCollectionDirectory(std::string name)
settingsFile << "list.menuSort = yes" << std::endl;
settingsFile << std::endl;
settingsFile << "launcher = mame" << std::endl;
settingsFile << "metadata.type = MAME" << std::endl;
settingsFile << "#metadata.type = MAME" << std::endl;
settingsFile << std::endl;
settingsFile << "#media.screenshot = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screenshot") << std::endl;
settingsFile << "#media.screentitle = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screentitle") << std::endl;
settingsFile << "#media.artwork_back = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "artwork_back") << std::endl;
settingsFile << "#media.artwork_front = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "artwork_front") << std::endl;
settingsFile << "#media.logo = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "logo") << std::endl;
settingsFile << "#media.medium_back = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "medium_back") << std::endl;
settingsFile << "#media.medium_front = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "medium_front") << std::endl;
settingsFile << "#media.screenshot = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screenshot") << std::endl;
settingsFile << "#media.screentitle = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screentitle") << std::endl;
settingsFile << "#media.video = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "video") << std::endl;
settingsFile << "#manufacturer = " << std::endl;
settingsFile << "#year = " << std::endl;
settingsFile << "#genre = " << std::endl;
settingsFile << std::endl;
settingsFile << "#media.screenshot = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screenshot") << std::endl;
settingsFile << "#media.screentitle = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screentitle") << std::endl;
settingsFile << "#media.artwork_back = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "artwork_back") << std::endl;
settingsFile << "#media.artwork_front = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "artwork_front") << std::endl;
settingsFile << "#media.logo = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "logo") << std::endl;
settingsFile << "#media.medium_back = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "medium_back") << std::endl;
settingsFile << "#media.medium_front = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "medium_front") << std::endl;
settingsFile << "#media.screenshot = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screenshot") << std::endl;
settingsFile << "#media.screentitle = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screentitle") << std::endl;
settingsFile << "#media.video = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "video") << std::endl;
settingsFile << "#media.system_artwork = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "system_artwork") << std::endl;
settingsFile.close();

View File

@ -23,8 +23,9 @@
#include <vector>
#include <iostream>
ReloadableText::ReloadableText(std::string type, Page &page, Font *font, std::string layoutKey, float scaleX, float scaleY)
ReloadableText::ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, float scaleX, float scaleY)
: Component(page)
, config_(config)
, imageInst_(NULL)
, layoutKey_(layoutKey)
, reloadRequested_(false)
@ -160,16 +161,28 @@ void ReloadableText::ReloadTexture()
ss << selectedItem->numberPlayers;
break;
case TextTypeYear:
ss << selectedItem->year;
if (selectedItem->leaf) // item is a leaf
text = selectedItem->year;
else // item is a collection
(void)config_.getProperty("collections." + selectedItem->name + ".year", text );
ss << text;
break;
case TextTypeTitle:
ss << selectedItem->title;
break;
case TextTypeManufacturer:
ss << selectedItem->manufacturer;
if (selectedItem->leaf) // item is a leaf
text = selectedItem->manufacturer;
else // item is a collection
(void)config_.getProperty("collections." + selectedItem->name + ".manufacturer", text );
ss << text;
break;
case TextTypeGenre:
ss << selectedItem->genre;
if (selectedItem->leaf) // item is a leaf
text = selectedItem->genre;
else // item is a collection
(void)config_.getProperty("collections." + selectedItem->name + ".genre", text );
ss << text;
break;
case TextTypePlaylist:
ss << playlistName;

View File

@ -25,7 +25,7 @@
class ReloadableText : public Component
{
public:
ReloadableText(std::string type, Page &page, Font *font, std::string layoutKey, float scaleX, float scaleY);
ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, float scaleX, float scaleY);
virtual ~ReloadableText();
void update(float dt);
void draw();
@ -52,6 +52,7 @@ private:
void ReloadTexture();
Configuration &config_;
Text *imageInst_;
TextType type_;
std::string layoutKey_;

View File

@ -446,7 +446,7 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
if(type)
{
Font *font = addFont(componentXml, NULL);
c = new ReloadableText(type->value(), *page, font, layoutKey, scaleX_, scaleY_);
c = new ReloadableText(type->value(), *page, config_, font, layoutKey, scaleX_, scaleY_);
}
}
else