mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 09:48:51 +01:00
Added playlist support via the following keys:
favPlaylist: switch between all games and favorites playlist nextPlaylist: switch to the next playlist (that contains games) prevPlaylist: switch to the previous playlist (that contains games) The playlists should be placed as <playlist name>.txt in the collections/<collection name>/playlists directory.
This commit is contained in:
parent
04bf1a2644
commit
0918d9fb96
@ -349,16 +349,37 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
|
||||
}
|
||||
|
||||
|
||||
void CollectionInfoBuilder::addFavorites(CollectionInfo *info)
|
||||
void CollectionInfoBuilder::addPlaylists(CollectionInfo *info)
|
||||
{
|
||||
std::map<std::string, Item *> favoritesFilter;
|
||||
std::string favoritesFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "playlists/favorites.txt");
|
||||
ImportBasicList(info, favoritesFile, favoritesFilter);
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
std::string path = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "playlists");
|
||||
dp = opendir(path.c_str());
|
||||
|
||||
info->playlists["favorites"] = new std::vector<Item *>();
|
||||
while((dirp = readdir(dp)) != NULL)
|
||||
{
|
||||
std::string file = dirp->d_name;
|
||||
|
||||
// add the favorites list
|
||||
for(std::map<std::string, Item *>::iterator it = favoritesFilter.begin(); it != favoritesFilter.end(); it++)
|
||||
size_t position = file.find_last_of(".");
|
||||
std::string basename = (std::string::npos == position)? file : file.substr(0, position);
|
||||
|
||||
std::string comparator = ".txt";
|
||||
int start = file.length() - comparator.length();
|
||||
|
||||
if(start >= 0)
|
||||
{
|
||||
if(file.compare(start, comparator.length(), comparator) == 0)
|
||||
{
|
||||
Logger::write(Logger::ZONE_INFO, "RetroFE", "Loading playlist: " + basename);
|
||||
|
||||
std::map<std::string, Item *> playlistFilter;
|
||||
std::string playlistFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "playlists", file);
|
||||
ImportBasicList(info, playlistFile, playlistFilter);
|
||||
|
||||
info->playlists[basename] = new std::vector<Item *>();
|
||||
|
||||
// add the playlist list
|
||||
for(std::map<std::string, Item *>::iterator it = playlistFilter.begin(); it != playlistFilter.end(); it++)
|
||||
{
|
||||
std::string collectionName = info->name;
|
||||
std::string itemName = it->first;
|
||||
@ -377,11 +398,16 @@ void CollectionInfoBuilder::addFavorites(CollectionInfo *info)
|
||||
{
|
||||
if ( (*it)->name == itemName && (*it)->collectionInfo->name == collectionName)
|
||||
{
|
||||
info->playlists["favorites"]->push_back((*it));
|
||||
info->playlists[basename]->push_back((*it));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ public:
|
||||
virtual ~CollectionInfoBuilder();
|
||||
CollectionInfo *buildCollection(std::string collectionName);
|
||||
CollectionInfo *buildCollection(std::string collectionName, std::string mergedCollectionName);
|
||||
void addFavorites(CollectionInfo *info);
|
||||
void addPlaylists(CollectionInfo *info);
|
||||
void injectMetadata(CollectionInfo *info);
|
||||
static bool createCollectionDirectory(std::string collectionName);
|
||||
|
||||
|
||||
@ -76,7 +76,9 @@ bool UserInput::initialize()
|
||||
|
||||
MapKey("letterDown", KeyCodeLetterDown, false);
|
||||
MapKey("letterUp", KeyCodeLetterUp, false);
|
||||
MapKey("favPlaylist", KeyCodeFavPlaylist, false);
|
||||
MapKey("nextPlaylist", KeyCodeNextPlaylist, false);
|
||||
MapKey("prevPlaylist", KeyCodePrevPlaylist, false);
|
||||
MapKey("addPlaylist", KeyCodeAddPlaylist, false);
|
||||
MapKey("removePlaylist", KeyCodeRemovePlaylist, false);
|
||||
MapKey("random", KeyCodeRandom, false);
|
||||
|
||||
@ -39,7 +39,9 @@ public:
|
||||
KeyCodePageUp,
|
||||
KeyCodeLetterDown,
|
||||
KeyCodeLetterUp,
|
||||
KeyCodeFavPlaylist,
|
||||
KeyCodeNextPlaylist,
|
||||
KeyCodePrevPlaylist,
|
||||
KeyCodeRandom,
|
||||
KeyCodeAddPlaylist,
|
||||
KeyCodeRemovePlaylist,
|
||||
|
||||
@ -579,10 +579,23 @@ std::string Page::getPlaylistName()
|
||||
}
|
||||
|
||||
|
||||
void Page::favPlaylist()
|
||||
{
|
||||
if(playlist_->first == "favorites")
|
||||
{
|
||||
selectPlaylist("all");
|
||||
}
|
||||
else
|
||||
{
|
||||
selectPlaylist("favorites");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void Page::nextPlaylist()
|
||||
{
|
||||
MenuInfo_S &info = collections_.back();
|
||||
info.collection->Save();
|
||||
unsigned int numlists = info.collection->playlists.size();
|
||||
|
||||
for(unsigned int i = 0; i <= numlists; ++i)
|
||||
@ -599,6 +612,30 @@ void Page::nextPlaylist()
|
||||
playlistChange();
|
||||
}
|
||||
|
||||
|
||||
void Page::prevPlaylist()
|
||||
{
|
||||
MenuInfo_S &info = collections_.back();
|
||||
unsigned int numlists = info.collection->playlists.size();
|
||||
|
||||
for(unsigned int i = 0; i <= numlists; ++i)
|
||||
{
|
||||
// wrap
|
||||
if(playlist_ == info.collection->playlists.begin())
|
||||
{
|
||||
playlist_ = info.collection->playlists.end();
|
||||
}
|
||||
playlist_--;
|
||||
|
||||
// find the first playlist
|
||||
if(playlist_->second->size() != 0) break;
|
||||
}
|
||||
|
||||
activeMenu_->setItems(playlist_->second);
|
||||
playlistChange();
|
||||
}
|
||||
|
||||
|
||||
void Page::selectPlaylist(std::string playlist)
|
||||
{
|
||||
MenuInfo_S &info = collections_.back();
|
||||
|
||||
@ -50,7 +50,9 @@ public:
|
||||
void enterMenu();
|
||||
void exitMenu();
|
||||
std::string getPlaylistName();
|
||||
void favPlaylist();
|
||||
void nextPlaylist();
|
||||
void prevPlaylist();
|
||||
void selectPlaylist(std::string playlist);
|
||||
void pushMenu(ScrollingList *s);
|
||||
bool isMenusFull();
|
||||
|
||||
@ -702,7 +702,9 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page)
|
||||
!input_.keystate(UserInput::KeyCodePageDown) &&
|
||||
!input_.keystate(UserInput::KeyCodeLetterUp) &&
|
||||
!input_.keystate(UserInput::KeyCodeLetterDown) &&
|
||||
!input_.keystate(UserInput::KeyCodeFavPlaylist) &&
|
||||
!input_.keystate(UserInput::KeyCodeNextPlaylist) &&
|
||||
!input_.keystate(UserInput::KeyCodePrevPlaylist) &&
|
||||
!input_.keystate(UserInput::KeyCodeAddPlaylist) &&
|
||||
!input_.keystate(UserInput::KeyCodeRemovePlaylist) &&
|
||||
!input_.keystate(UserInput::KeyCodeRandom))
|
||||
@ -741,11 +743,21 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page)
|
||||
page->reallocateMenuSpritePoints();
|
||||
state = RETROFE_HIGHLIGHT_REQUEST;
|
||||
}
|
||||
if(input_.newKeyPressed(UserInput::KeyCodeFavPlaylist))
|
||||
{
|
||||
page->favPlaylist();
|
||||
state = RETROFE_PLAYLIST_REQUEST;
|
||||
}
|
||||
if(input_.newKeyPressed(UserInput::KeyCodeNextPlaylist))
|
||||
{
|
||||
page->nextPlaylist();
|
||||
state = RETROFE_PLAYLIST_REQUEST;
|
||||
}
|
||||
if(input_.newKeyPressed(UserInput::KeyCodePrevPlaylist))
|
||||
{
|
||||
page->prevPlaylist();
|
||||
state = RETROFE_PLAYLIST_REQUEST;
|
||||
}
|
||||
if(input_.newKeyPressed(UserInput::KeyCodeRemovePlaylist))
|
||||
{
|
||||
page->removePlaylist();
|
||||
@ -895,7 +907,7 @@ CollectionInfo *RetroFE::getCollection(std::string collectionName)
|
||||
MenuParser mp;
|
||||
mp.buildMenuItems(collection, menuSort);
|
||||
|
||||
cib.addFavorites(collection);
|
||||
cib.addPlaylists(collection);
|
||||
collection->sortFavoriteItems();
|
||||
|
||||
return collection;
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
std::string retrofe_version_major = "0";
|
||||
std::string retrofe_version_minor = "7";
|
||||
std::string retrofe_version_build = "20";
|
||||
std::string retrofe_version_build = "20b1";
|
||||
|
||||
|
||||
std::string Version::getString()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user