mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-04-02 02:05:55 +02:00
Favorites/custom list (starting branch). Not complete.
This commit is contained in:
@@ -6,6 +6,7 @@ pageUp = A
|
|||||||
pageDown = B
|
pageDown = B
|
||||||
letterUp = N
|
letterUp = N
|
||||||
letterDown = M
|
letterDown = M
|
||||||
|
nextPlaylist = P
|
||||||
select = Space
|
select = Space
|
||||||
back = Escape
|
back = Escape
|
||||||
quit = Q
|
quit = Q
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ bool CollectionInfoBuilder::createCollectionDirectory(std::string name)
|
|||||||
return true;
|
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 listItemsPathKey = "collections." + name + ".list.path";
|
||||||
std::string listFilterKey = "collections." + name + ".list.filter";
|
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);
|
(void)conf_.getProperty("collections." + collection->name + ".launcher", collection->launcher);
|
||||||
|
|
||||||
ImportDirectory(collection);
|
ImportDirectory(collection, listname);
|
||||||
|
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
@@ -231,14 +231,14 @@ bool CollectionInfoBuilder::ImportBasicList(CollectionInfo *info, std::string fi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string listname)
|
||||||
{
|
{
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
struct dirent *dirp;
|
struct dirent *dirp;
|
||||||
std::string path = info->listpath;
|
std::string path = info->listpath;
|
||||||
std::map<std::string, Item *> includeFilter;
|
std::map<std::string, Item *> includeFilter;
|
||||||
std::map<std::string, Item *> excludeFilter;
|
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 excludeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "exclude.txt");
|
||||||
std::string launcher;
|
std::string launcher;
|
||||||
bool showMissing = false;
|
bool showMissing = false;
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ class CollectionInfoBuilder
|
|||||||
public:
|
public:
|
||||||
CollectionInfoBuilder(Configuration &c, MetadataDatabase &mdb);
|
CollectionInfoBuilder(Configuration &c, MetadataDatabase &mdb);
|
||||||
virtual ~CollectionInfoBuilder();
|
virtual ~CollectionInfoBuilder();
|
||||||
CollectionInfo *buildCollection(std::string collectionName);
|
CollectionInfo *buildCollection(std::string collectionName, std::string listname);
|
||||||
static bool createCollectionDirectory(std::string collectionName);
|
static bool createCollectionDirectory(std::string collectionName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Configuration &conf_;
|
Configuration &conf_;
|
||||||
MetadataDatabase &metaDB_;
|
MetadataDatabase &metaDB_;
|
||||||
bool ImportBasicList(CollectionInfo *info, std::string file, std::map<std::string, Item *> &list);
|
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();
|
std::string collectionName = collectionAttribute->value();
|
||||||
Logger::write(Logger::ZONE_INFO, "Menu", "Loading collection into menu: " + collectionName);
|
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);
|
collection->addSubcollection(subcollection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ bool UserInput::initialize()
|
|||||||
retVal = MapKey("select", KeyCodeSelect) && retVal;
|
retVal = MapKey("select", KeyCodeSelect) && retVal;
|
||||||
retVal = MapKey("back", KeyCodeBack) && retVal;
|
retVal = MapKey("back", KeyCodeBack) && retVal;
|
||||||
retVal = MapKey("quit", KeyCodeQuit) && retVal;
|
retVal = MapKey("quit", KeyCodeQuit) && retVal;
|
||||||
|
MapKey("nextPlaylist", KeyCodeNextPlaylist);
|
||||||
// these features will need to be implemented at a later time
|
// these features will need to be implemented at a later time
|
||||||
// retVal = MapKey("admin", KeyCodeAdminMode) && retVal;
|
// retVal = MapKey("admin", KeyCodeAdminMode) && retVal;
|
||||||
// retVal = MapKey("remove", KeyCodeHideItem) && retVal;
|
// retVal = MapKey("remove", KeyCodeHideItem) && retVal;
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public:
|
|||||||
KeyCodePageUp,
|
KeyCodePageUp,
|
||||||
KeyCodeLetterDown,
|
KeyCodeLetterDown,
|
||||||
KeyCodeLetterUp,
|
KeyCodeLetterUp,
|
||||||
|
KeyCodeNextPlaylist,
|
||||||
KeyCodeAdminMode,
|
KeyCodeAdminMode,
|
||||||
KeyCodeHideItem,
|
KeyCodeHideItem,
|
||||||
KeyCodeQuit,
|
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);
|
collections_.push_back(collection);
|
||||||
std::vector<ComponentItemBinding *> *sprites = ComponentItemBindingBuilder::buildCollectionItems(&collection->items);
|
std::vector<ComponentItemBinding *> *sprites = ComponentItemBindingBuilder::buildCollectionItems(&collection->items);
|
||||||
@@ -430,6 +430,16 @@ bool Page::pushCollection(CollectionInfo *collection)
|
|||||||
{
|
{
|
||||||
ScrollingList *newList = new ScrollingList(*activeMenu_);
|
ScrollingList *newList = new ScrollingList(*activeMenu_);
|
||||||
newList->forceIdle();
|
newList->forceIdle();
|
||||||
|
if(discardCurrent)
|
||||||
|
{
|
||||||
|
if(menus_.size() > 0)
|
||||||
|
{
|
||||||
|
ScrollingList *old = menus_.back();
|
||||||
|
menus_.pop_back();
|
||||||
|
delete old;
|
||||||
|
menuDepth_--;
|
||||||
|
}
|
||||||
|
}
|
||||||
pushMenu(newList);
|
pushMenu(newList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
Page(Configuration &c);
|
Page(Configuration &c);
|
||||||
virtual ~Page();
|
virtual ~Page();
|
||||||
virtual void onNewItemSelected(Item *);
|
virtual void onNewItemSelected(Item *);
|
||||||
bool pushCollection(CollectionInfo *collection);
|
bool pushCollection(CollectionInfo *collection, bool discardCurrent);
|
||||||
bool popCollection();
|
bool popCollection();
|
||||||
void pushMenu(ScrollingList *s);
|
void pushMenu(ScrollingList *s);
|
||||||
bool isMenusFull();
|
bool isMenusFull();
|
||||||
|
|||||||
@@ -282,13 +282,13 @@ void RetroFE::run()
|
|||||||
|
|
||||||
currentPage_->start();
|
currentPage_->start();
|
||||||
config_.setProperty("currentCollection", firstCollection);
|
config_.setProperty("currentCollection", firstCollection);
|
||||||
CollectionInfo *info = getCollection(firstCollection);
|
CollectionInfo *info = getCollection(firstCollection, "include");
|
||||||
MenuParser mp;
|
MenuParser mp;
|
||||||
|
|
||||||
CollectionInfoBuilder cib(config_, *metadb_);
|
CollectionInfoBuilder cib(config_, *metadb_);
|
||||||
mp.buildMenuItems(info, menuSort, cib);
|
mp.buildMenuItems(info, menuSort, cib);
|
||||||
|
|
||||||
currentPage_->pushCollection(info);
|
currentPage_->pushCollection(info, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -466,12 +466,15 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page)
|
|||||||
config_.setProperty("currentCollection", nextPageItem_->name);
|
config_.setProperty("currentCollection", nextPageItem_->name);
|
||||||
config_.getProperty("collections." + nextPageItem_->name + ".list.menuSort", menuSort);
|
config_.getProperty("collections." + nextPageItem_->name + ".list.menuSort", menuSort);
|
||||||
|
|
||||||
CollectionInfo *info = getCollection(nextPageItem_->name);
|
CollectionInfo *info = getCollection(nextPageItem_->name, "include");
|
||||||
|
|
||||||
MenuParser mp;
|
MenuParser mp;
|
||||||
CollectionInfoBuilder cib(config_, *metadb_);
|
CollectionInfoBuilder cib(config_, *metadb_);
|
||||||
mp.buildMenuItems(info, menuSort, cib);
|
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())
|
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())
|
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
|
// the page will deallocate this once its done
|
||||||
|
|
||||||
CollectionInfoBuilder cib(config_, *metadb_);
|
CollectionInfoBuilder cib(config_, *metadb_);
|
||||||
CollectionInfo *collection = cib.buildCollection(collectionName);
|
CollectionInfo *collection = cib.buildCollection(collectionName, listname);
|
||||||
|
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ private:
|
|||||||
RETROFE_STATE processUserInput(Page *page);
|
RETROFE_STATE processUserInput(Page *page);
|
||||||
void update(float dt, bool scrollActive);
|
void update(float dt, bool scrollActive);
|
||||||
std::string getLayout(std::string collectionName);
|
std::string getLayout(std::string collectionName);
|
||||||
CollectionInfo *getCollection(std::string collectionName);
|
CollectionInfo *getCollection(std::string collectionName, std::string listname);
|
||||||
Configuration &config_;
|
Configuration &config_;
|
||||||
DB *db_;
|
DB *db_;
|
||||||
MetadataDatabase *metadb_;
|
MetadataDatabase *metadb_;
|
||||||
@@ -80,5 +80,7 @@ private:
|
|||||||
FontCache fontcache_;
|
FontCache fontcache_;
|
||||||
AttractMode attract_;
|
AttractMode attract_;
|
||||||
std::map<std::string, unsigned int> lastMenuOffsets_;
|
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