Added lastplayedCollectionSize parameter to allow a lastplayed playlist of collections as well.

This commit is contained in:
Pieter Hulshoff 2020-04-19 09:58:31 +02:00
parent 353c8e8da5
commit 902cc0a8a5
4 changed files with 19 additions and 9 deletions

View File

@ -493,7 +493,7 @@ void CollectionInfoBuilder::addPlaylists(CollectionInfo *info)
}
void CollectionInfoBuilder::updateLastPlayedPlaylist(CollectionInfo *info, Item *item)
void CollectionInfoBuilder::updateLastPlayedPlaylist(CollectionInfo *info, Item *item, int size)
{
std::string path = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "playlists");
Logger::write(Logger::ZONE_INFO, "RetroFE", "Updating lastplayed playlist");
@ -507,10 +507,7 @@ void CollectionInfoBuilder::updateLastPlayedPlaylist(CollectionInfo *info, Item
else
info->playlists["lastplayed"]->clear();
int lastplayedSize = 0;
(void)conf_.getProperty("lastplayedSize", lastplayedSize);
if (lastplayedSize == 0)
if (size == 0)
return;
// Put the new item at the front of the list.
@ -519,7 +516,7 @@ void CollectionInfoBuilder::updateLastPlayedPlaylist(CollectionInfo *info, Item
// Add the items already in the playlist up to the lastplayedSize.
for(std::vector<Item *>::iterator it = lastplayedList.begin(); it != lastplayedList.end(); it++)
{
if (info->playlists["lastplayed"]->size() >= static_cast<unsigned int>( lastplayedSize ))
if (info->playlists["lastplayed"]->size() >= static_cast<unsigned int>( size ))
break;
std::string collectionName = info->name;

View File

@ -32,7 +32,7 @@ public:
CollectionInfo *buildCollection(std::string collectionName);
CollectionInfo *buildCollection(std::string collectionName, std::string mergedCollectionName);
void addPlaylists(CollectionInfo *info);
void updateLastPlayedPlaylist(CollectionInfo *info, Item *item);
void updateLastPlayedPlaylist(CollectionInfo *info, Item *item, int size);
void injectMetadata(CollectionInfo *info);
static bool createCollectionDirectory(std::string collectionName);
bool ImportBasicList(CollectionInfo *info, std::string file, std::vector<Item *> &list);

View File

@ -1004,11 +1004,13 @@ void RetroFE::run( )
CollectionInfoBuilder cib(config_, *metadb_);
std::string attractModeSkipPlaylist = "";
std::string lastPlayedSkipCollection = "";
int size = 0;
config_.getProperty( "attractModeSkipPlaylist", attractModeSkipPlaylist );
config_.getProperty( "lastPlayedSkipCollection", lastPlayedSkipCollection );
config_.getProperty( "lastplayedSize", size );
if (currentPage_->getPlaylistName( ) != attractModeSkipPlaylist &&
nextPageItem_->collectionInfo->name != lastPlayedSkipCollection)
cib.updateLastPlayedPlaylist( currentPage_->getCollection(), nextPageItem_ ); // Update last played playlist if not currently in the skip playlist (e.g. settings)
cib.updateLastPlayedPlaylist( currentPage_->getCollection(), nextPageItem_, size ); // Update last played playlist if not currently in the skip playlist (e.g. settings)
l.run(nextPageItem_->collectionInfo->name, nextPageItem_);
launchExit( );
currentPage_->exitGame( );
@ -1483,6 +1485,17 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput( Page *page )
}
else
{
CollectionInfoBuilder cib(config_, *metadb_);
std::string attractModeSkipPlaylist = "";
std::string lastPlayedSkipCollection = "";
int size = 0;
config_.getProperty( "attractModeSkipPlaylist", attractModeSkipPlaylist );
config_.getProperty( "lastPlayedSkipCollection", lastPlayedSkipCollection );
config_.getProperty("lastplayedCollectionSize", size);
if (currentPage_->getPlaylistName( ) != attractModeSkipPlaylist &&
nextPageItem_->collectionInfo->name != lastPlayedSkipCollection)
cib.updateLastPlayedPlaylist( currentPage_->getCollection(), nextPageItem_, size ); // Update last played playlist if not currently in the skip playlist (e.g. settings)
state = RETROFE_NEXT_PAGE_REQUEST;
}
}

View File

@ -21,7 +21,7 @@
std::string retrofe_version_major = "0";
std::string retrofe_version_minor = "9";
std::string retrofe_version_build = "31";
std::string retrofe_version_build = "32";
std::string Version::getString( )