diff --git a/Package/Environment/Common/controls.conf b/Package/Environment/Common/controls.conf index 6e8b4c1..a315ed2 100644 --- a/Package/Environment/Common/controls.conf +++ b/Package/Environment/Common/controls.conf @@ -6,6 +6,7 @@ pageUp = A pageDown = B letterUp = N letterDown = M +nextPlaylist = P select = Space back = Escape quit = Q diff --git a/RetroFE/Source/Collection/CollectionInfo.cpp b/RetroFE/Source/Collection/CollectionInfo.cpp index 508e357..d74955b 100644 --- a/RetroFE/Source/Collection/CollectionInfo.cpp +++ b/RetroFE/Source/Collection/CollectionInfo.cpp @@ -37,11 +37,17 @@ CollectionInfo::~CollectionInfo() { // remove items from the subcollections so their destructors do not // delete the items since the parent collection will delete them. - std::vector::iterator subit; - for (subit != subcollections_.begin(); subit != subcollections_.end(); subit++) + std::vector::iterator subit = subcollections_.begin(); + while (subit != subcollections_.end()) { CollectionInfo *info = *subit; - info->items.clear(); + subcollections_.erase(subit); + + if(info != this) + { + delete info; + } + subit = subcollections_.begin(); } diff --git a/RetroFE/Source/Collection/CollectionInfo.h b/RetroFE/Source/Collection/CollectionInfo.h index a1b5812..d4086da 100644 --- a/RetroFE/Source/Collection/CollectionInfo.h +++ b/RetroFE/Source/Collection/CollectionInfo.h @@ -17,6 +17,7 @@ #include #include +#include class Item; @@ -36,6 +37,9 @@ public: std::string launcher; std::vector items; + typedef std::map > Playlists_T; + Playlists_T playlists; + private: std::vector subcollections_; std::string metadataPath_; diff --git a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp index 5209b73..595b70c 100644 --- a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp +++ b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp @@ -242,8 +242,10 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me struct dirent *dirp; std::string path = info->listpath; std::map includeFilter; + std::map favoritesFilter; std::map excludeFilter; std::string includeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "include.txt"); + std::string favoritesFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "favorites.txt"); std::string excludeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "exclude.txt"); std::string launcher; @@ -269,6 +271,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me { Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Checking for \"" + includeFile + "\""); ImportBasicList(info, includeFile, includeFilter); + ImportBasicList(info, favoritesFile, favoritesFilter); ImportBasicList(info, excludeFile, excludeFilter); } @@ -297,6 +300,10 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me } } } + for(std::map::iterator it = favoritesFilter.begin(); it != favoritesFilter.end(); it++) + { + info->playlists["favorites"].push_back(it->second); + } while((dirp = readdir(dp)) != NULL) { @@ -327,6 +334,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me i->collectionInfo = info; info->items.push_back(i); + info->playlists["include"].push_back(i); } } } diff --git a/RetroFE/Source/Control/UserInput.cpp b/RetroFE/Source/Control/UserInput.cpp index 4449fcc..8dcc048 100644 --- a/RetroFE/Source/Control/UserInput.cpp +++ b/RetroFE/Source/Control/UserInput.cpp @@ -67,6 +67,7 @@ bool UserInput::initialize() retVal = MapKey("select", KeyCodeSelect) && retVal; retVal = MapKey("back", KeyCodeBack) && retVal; retVal = MapKey("quit", KeyCodeQuit) && retVal; + MapKey("nextPlaylist", KeyCodeNextPlaylist); // these features will need to be implemented at a later time // retVal = MapKey("admin", KeyCodeAdminMode) && retVal; // retVal = MapKey("remove", KeyCodeHideItem) && retVal; diff --git a/RetroFE/Source/Control/UserInput.h b/RetroFE/Source/Control/UserInput.h index 4fbb66a..34ed4ab 100644 --- a/RetroFE/Source/Control/UserInput.h +++ b/RetroFE/Source/Control/UserInput.h @@ -38,6 +38,7 @@ public: KeyCodePageUp, KeyCodeLetterDown, KeyCodeLetterUp, + KeyCodeNextPlaylist, KeyCodeAdminMode, KeyCodeHideItem, KeyCodeQuit, diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index c42c291..090d110 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -125,6 +125,7 @@ ScrollingList::~ScrollingList() destroyItems(); } + void ScrollingList::setItems(std::vector *spriteList) { notifyAllRequested_ = true; @@ -227,6 +228,7 @@ void ScrollingList::destroyItems() { return; } + std::vector::iterator it = spriteList_->begin(); while(it != spriteList_->end()) @@ -235,11 +237,7 @@ void ScrollingList::destroyItems() { deallocateTexture(*it); - if((*it)->item) - { - delete (*it)->item; - } - + // items are destroyed when collections are destroyed delete *it; } diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index eb7392e..7a4c3eb 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -438,6 +438,7 @@ bool Page::pushCollection(CollectionInfo *collection) activeMenu_->destroyItems(); activeMenu_->setItems(sprites); activeMenu_->triggerMenuEnterEvent(); + playlist_ = collection->playlists.begin(); if(menuDepth_ < menus_.size()) { @@ -514,9 +515,26 @@ bool Page::popCollection() } } + if(collection) + { + delete collection; + } + return true; } +void Page::nextPlaylist() +{ + CollectionInfo *collection = collections_.back(); + playlist_++; + if(playlist_ == collection->playlists.end()) playlist_ = collection->playlists.begin(); + + std::vector *sprites = ComponentItemBindingBuilder::buildCollectionItems(&playlist_->second); + + activeMenu_->destroyItems(); + activeMenu_->setItems(sprites); + activeMenu_->triggerMenuEnterEvent(); +} void Page::update(float dt) { diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index 617fa76..2591d5e 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -16,13 +16,13 @@ #pragma once #include "MenuNotifierInterface.h" +#include "../Collection/CollectionInfo.h" #include #include #include #include -class CollectionInfo; class Component; class Configuration; class ScrollingList; @@ -46,6 +46,7 @@ public: virtual void onNewItemSelected(Item *); bool pushCollection(CollectionInfo *collection); bool popCollection(); + void nextPlaylist(); void pushMenu(ScrollingList *s); bool isMenusFull(); void setLoadSound(Sound *chunk); @@ -105,6 +106,7 @@ private: Sound *selectSoundChunk_; float minShowTime_; float elapsedTime_; + CollectionInfo::Playlists_T::iterator playlist_; }; diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 76fefb1..a7317e0 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -489,7 +489,10 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page) } } } - + if(input_.keystate(UserInput::KeyCodeNextPlaylist) && page->isMenuIdle()) + { + page->nextPlaylist(); + } if (input_.keystate(UserInput::KeyCodeBack) && page->isMenuIdle()) { if(back(exit) || exit)