mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-04-01 17:53:07 +02:00
Favorites/custom list (starting branch). Not complete.
This commit is contained in:
@@ -6,6 +6,7 @@ pageUp = A
|
||||
pageDown = B
|
||||
letterUp = N
|
||||
letterDown = M
|
||||
nextPlaylist = P
|
||||
select = Space
|
||||
back = Escape
|
||||
quit = Q
|
||||
|
||||
@@ -153,7 +153,7 @@ bool CollectionInfoBuilder::createCollectionDirectory(std::string name)
|
||||
return true;
|
||||
}
|
||||
|
||||
CollectionInfo *CollectionInfoBuilder::buildCollection(std::string name)
|
||||
CollectionInfo *CollectionInfoBuilder::buildCollection(std::string name, std::string listname)
|
||||
{
|
||||
std::string listItemsPathKey = "collections." + name + ".list.path";
|
||||
std::string listFilterKey = "collections." + name + ".list.filter";
|
||||
@@ -192,7 +192,7 @@ CollectionInfo *CollectionInfoBuilder::buildCollection(std::string name)
|
||||
|
||||
(void)conf_.getProperty("collections." + collection->name + ".launcher", collection->launcher);
|
||||
|
||||
ImportDirectory(collection);
|
||||
ImportDirectory(collection, listname);
|
||||
|
||||
return collection;
|
||||
}
|
||||
@@ -231,14 +231,14 @@ bool CollectionInfoBuilder::ImportBasicList(CollectionInfo *info, std::string fi
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
||||
bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string listname)
|
||||
{
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
std::string path = info->listpath;
|
||||
std::map<std::string, Item *> includeFilter;
|
||||
std::map<std::string, Item *> excludeFilter;
|
||||
std::string includeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "include.txt");
|
||||
std::string includeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, listname + ".txt");
|
||||
std::string excludeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "exclude.txt");
|
||||
std::string launcher;
|
||||
bool showMissing = false;
|
||||
|
||||
@@ -29,12 +29,12 @@ class CollectionInfoBuilder
|
||||
public:
|
||||
CollectionInfoBuilder(Configuration &c, MetadataDatabase &mdb);
|
||||
virtual ~CollectionInfoBuilder();
|
||||
CollectionInfo *buildCollection(std::string collectionName);
|
||||
CollectionInfo *buildCollection(std::string collectionName, std::string listname);
|
||||
static bool createCollectionDirectory(std::string collectionName);
|
||||
|
||||
private:
|
||||
Configuration &conf_;
|
||||
MetadataDatabase &metaDB_;
|
||||
bool ImportBasicList(CollectionInfo *info, std::string file, std::map<std::string, Item *> &list);
|
||||
bool ImportDirectory(CollectionInfo *info);
|
||||
bool ImportDirectory(CollectionInfo *info, std::string listname);
|
||||
};
|
||||
|
||||
@@ -103,7 +103,7 @@ bool MenuParser::buildMenuItems(CollectionInfo *collection, bool sort, Collectio
|
||||
std::string collectionName = collectionAttribute->value();
|
||||
Logger::write(Logger::ZONE_INFO, "Menu", "Loading collection into menu: " + collectionName);
|
||||
|
||||
CollectionInfo *subcollection = builder.buildCollection(collectionName);
|
||||
CollectionInfo *subcollection = builder.buildCollection(collectionName, "include");
|
||||
collection->addSubcollection(subcollection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
KeyCodePageUp,
|
||||
KeyCodeLetterDown,
|
||||
KeyCodeLetterUp,
|
||||
KeyCodeNextPlaylist,
|
||||
KeyCodeAdminMode,
|
||||
KeyCodeHideItem,
|
||||
KeyCodeQuit,
|
||||
|
||||
@@ -408,7 +408,7 @@ void Page::letterScroll(ScrollDirection direction)
|
||||
}
|
||||
|
||||
|
||||
bool Page::pushCollection(CollectionInfo *collection)
|
||||
bool Page::pushCollection(CollectionInfo *collection, bool discardCurrent)
|
||||
{
|
||||
collections_.push_back(collection);
|
||||
std::vector<ComponentItemBinding *> *sprites = ComponentItemBindingBuilder::buildCollectionItems(&collection->items);
|
||||
@@ -430,6 +430,16 @@ bool Page::pushCollection(CollectionInfo *collection)
|
||||
{
|
||||
ScrollingList *newList = new ScrollingList(*activeMenu_);
|
||||
newList->forceIdle();
|
||||
if(discardCurrent)
|
||||
{
|
||||
if(menus_.size() > 0)
|
||||
{
|
||||
ScrollingList *old = menus_.back();
|
||||
menus_.pop_back();
|
||||
delete old;
|
||||
menuDepth_--;
|
||||
}
|
||||
}
|
||||
pushMenu(newList);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
Page(Configuration &c);
|
||||
virtual ~Page();
|
||||
virtual void onNewItemSelected(Item *);
|
||||
bool pushCollection(CollectionInfo *collection);
|
||||
bool pushCollection(CollectionInfo *collection, bool discardCurrent);
|
||||
bool popCollection();
|
||||
void pushMenu(ScrollingList *s);
|
||||
bool isMenusFull();
|
||||
|
||||
@@ -282,13 +282,13 @@ void RetroFE::run()
|
||||
|
||||
currentPage_->start();
|
||||
config_.setProperty("currentCollection", firstCollection);
|
||||
CollectionInfo *info = getCollection(firstCollection);
|
||||
CollectionInfo *info = getCollection(firstCollection, "include");
|
||||
MenuParser mp;
|
||||
|
||||
CollectionInfoBuilder cib(config_, *metadb_);
|
||||
mp.buildMenuItems(info, menuSort, cib);
|
||||
|
||||
currentPage_->pushCollection(info);
|
||||
currentPage_->pushCollection(info, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -466,12 +466,15 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page)
|
||||
config_.setProperty("currentCollection", nextPageItem_->name);
|
||||
config_.getProperty("collections." + nextPageItem_->name + ".list.menuSort", menuSort);
|
||||
|
||||
CollectionInfo *info = getCollection(nextPageItem_->name);
|
||||
CollectionInfo *info = getCollection(nextPageItem_->name, "include");
|
||||
|
||||
MenuParser mp;
|
||||
CollectionInfoBuilder cib(config_, *metadb_);
|
||||
mp.buildMenuItems(info, menuSort, cib);
|
||||
page->pushCollection(info);
|
||||
page->pushCollection(info, false);
|
||||
listnames_.push_back("include");
|
||||
listnames_.push_back("favorites");
|
||||
listnameit_ = listnames_.begin();
|
||||
|
||||
if(rememberMenu && lastMenuOffsets_.find(nextPageItem_->name) != lastMenuOffsets_.end())
|
||||
{
|
||||
@@ -482,6 +485,32 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(input_.keystate(UserInput::KeyCodeNextPlaylist) && page->isMenuIdle())
|
||||
{
|
||||
nextPageItem_ = page->getSelectedItem();
|
||||
|
||||
bool menuSort = true;
|
||||
config_.setProperty("currentCollection", nextPageItem_->name);
|
||||
config_.getProperty("collections." + nextPageItem_->name + ".list.menuSort", menuSort);
|
||||
|
||||
listnameit_++;
|
||||
if(listnameit_ == listnames_.end()) listnameit_ = listnames_.begin();
|
||||
|
||||
CollectionInfo *info = getCollection(currentPage_->getCollectionName(), *listnameit_);
|
||||
|
||||
MenuParser mp;
|
||||
CollectionInfoBuilder cib(config_, *metadb_);
|
||||
mp.buildMenuItems(info, menuSort, cib);
|
||||
page->pushCollection(info, true);
|
||||
|
||||
if(rememberMenu && lastMenuOffsets_.find(nextPageItem_->name) != lastMenuOffsets_.end())
|
||||
{
|
||||
page->setScrollOffsetIndex(lastMenuOffsets_[nextPageItem_->name]);
|
||||
}
|
||||
|
||||
state = RETROFE_NEXT_PAGE_REQUEST;
|
||||
|
||||
}
|
||||
|
||||
if (input_.keystate(UserInput::KeyCodeBack) && page->isMenuIdle())
|
||||
{
|
||||
@@ -544,12 +573,12 @@ Page *RetroFE::loadSplashPage()
|
||||
}
|
||||
|
||||
|
||||
CollectionInfo *RetroFE::getCollection(std::string collectionName)
|
||||
CollectionInfo *RetroFE::getCollection(std::string collectionName, std::string listname)
|
||||
{
|
||||
// the page will deallocate this once its done
|
||||
|
||||
CollectionInfoBuilder cib(config_, *metadb_);
|
||||
CollectionInfo *collection = cib.buildCollection(collectionName);
|
||||
CollectionInfo *collection = cib.buildCollection(collectionName, listname);
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
RETROFE_STATE processUserInput(Page *page);
|
||||
void update(float dt, bool scrollActive);
|
||||
std::string getLayout(std::string collectionName);
|
||||
CollectionInfo *getCollection(std::string collectionName);
|
||||
CollectionInfo *getCollection(std::string collectionName, std::string listname);
|
||||
Configuration &config_;
|
||||
DB *db_;
|
||||
MetadataDatabase *metadb_;
|
||||
@@ -80,5 +80,7 @@ private:
|
||||
FontCache fontcache_;
|
||||
AttractMode attract_;
|
||||
std::map<std::string, unsigned int> lastMenuOffsets_;
|
||||
std::list<std::string> listnames_;
|
||||
std::list<std::string>::iterator listnameit_;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user