Added list.menuSort option.

This commit is contained in:
Don Honerbrink 2015-06-25 11:58:52 -05:00
parent bcf35a954d
commit 08fad4d876
7 changed files with 43 additions and 8 deletions

View File

@ -20,6 +20,13 @@ list.includeMissingItems = true
############################################################################### ###############################################################################
list.extensions = zip list.extensions = zip
###############################################################################
# If a menu.xml file exists, it will display the menu alphabetically. To
# not auto-sort the menu items alphabetically, set the following to false.
# This does not apply to how your ROMs are sorted.
###############################################################################
list.menuSort = true
############################################################################### ###############################################################################
# The executable to run when an item in a collection item is selected # The executable to run when an item in a collection item is selected
############################################################################### ###############################################################################

View File

@ -4,3 +4,11 @@
# See Menu.xml to configure the menu # See Menu.xml to configure the menu
############################################################################### ###############################################################################
###############################################################################
# If a menu.xml file exists, it will display the menu alphabetically. To
# not auto-sort the menu items alphabetically, set the following to false.
# This does not apply to how your ROMs are sorted.
###############################################################################
list.menuSort = true

View File

@ -21,6 +21,13 @@ list.includeMissingItems = true
############################################################################### ###############################################################################
list.extensions = zip list.extensions = zip
###############################################################################
# If a menu.xml file exists, it will display the menu alphabetically. To
# not auto-sort the menu items alphabetically, set the following to false.
# This does not apply to how your ROMs are sorted.
###############################################################################
list.menuSort = true
############################################################################### ###############################################################################
# The executable to run when an item in a collection item is selected # The executable to run when an item in a collection item is selected
############################################################################### ###############################################################################

View File

@ -116,6 +116,8 @@ bool CollectionInfoBuilder::createCollectionDirectory(std::string name)
settingsFile << "#list.path = " << Utils::combinePath("%BASE_ITEM_PATH%", "%ITEM_COLLECTION_NAME%", "roms") << std::endl; settingsFile << "#list.path = " << Utils::combinePath("%BASE_ITEM_PATH%", "%ITEM_COLLECTION_NAME%", "roms") << std::endl;
settingsFile << "list.includeMissingItems = false" << std::endl; settingsFile << "list.includeMissingItems = false" << std::endl;
settingsFile << "list.extensions = zip" << std::endl; settingsFile << "list.extensions = zip" << std::endl;
settingsFile << "list.menuSort = yes" << std::endl;
settingsFile << std::endl;
settingsFile << "launcher = mame" << std::endl; settingsFile << "launcher = mame" << std::endl;
settingsFile << "metadata.type = MAME" << std::endl; settingsFile << "metadata.type = MAME" << std::endl;
settingsFile << std::endl; settingsFile << std::endl;

View File

@ -40,13 +40,14 @@ MenuParser::~MenuParser()
} }
//todo: clean up this method, too much nesting //todo: clean up this method, too much nesting
bool MenuParser::menuItems(CollectionInfo *collection) bool MenuParser::buildMenuItems(CollectionInfo *collection, bool sort)
{ {
bool retVal = false; bool retVal = false;
//todo: magic string //todo: magic string
std::string menuFilename = Utils::combinePath(Configuration::absolutePath, "collections", collection->name, "menu.xml"); std::string menuFilename = Utils::combinePath(Configuration::absolutePath, "collections", collection->name, "menu.xml");
rapidxml::xml_document<> doc; rapidxml::xml_document<> doc;
rapidxml::xml_node<> * rootNode; rapidxml::xml_node<> * rootNode;
std::vector<Item *> menuItems;
Logger::write(Logger::ZONE_INFO, "Menu", "Checking if menu exists at \"" + menuFilename + "\""); Logger::write(Logger::ZONE_INFO, "Menu", "Checking if menu exists at \"" + menuFilename + "\"");
@ -92,8 +93,7 @@ bool MenuParser::menuItems(CollectionInfo *collection)
item->fullTitle = title; item->fullTitle = title;
item->name = collectionAttribute->value(); item->name = collectionAttribute->value();
item->leaf = false; item->leaf = false;
collection->items.push_back(item); menuItems.push_back(item);
} }
else else
{ {
@ -106,8 +106,13 @@ bool MenuParser::menuItems(CollectionInfo *collection)
} }
// todo: sorting should occur within the collection itself, not externally // todo: sorting should occur within the collection itself, not externally
std::vector<Item *> *items = &collection->items; if(sort)
std::sort( items->begin(), items->end(), VectorSort); {
// sort the menu if requested
std::sort( menuItems.begin(), menuItems.end(), VectorSort);
}
collection->items.insert(collection->items.begin(), menuItems.begin(), menuItems.end());
retVal = true; retVal = true;
} }

View File

@ -22,6 +22,6 @@ class MenuParser
public: public:
MenuParser(); MenuParser();
virtual ~MenuParser(); virtual ~MenuParser();
bool menuItems(CollectionInfo *cdb); bool buildMenuItems(CollectionInfo *cdb, bool sort);
}; };

View File

@ -275,13 +275,16 @@ void RetroFE::run()
if(currentPage_) if(currentPage_)
{ {
std::string firstCollection = "Main"; std::string firstCollection = "Main";
bool menuSort = true;
config_.getProperty("firstCollection", firstCollection); config_.getProperty("firstCollection", firstCollection);
config_.getProperty("collections." + firstCollection + ".list.menuSort", menuSort);
currentPage_->start(); currentPage_->start();
config_.setProperty("currentCollection", firstCollection); config_.setProperty("currentCollection", firstCollection);
CollectionInfo *info = getCollection(firstCollection); CollectionInfo *info = getCollection(firstCollection);
MenuParser mp; MenuParser mp;
mp.menuItems(info); mp.buildMenuItems(info, menuSort);
currentPage_->pushCollection(info); currentPage_->pushCollection(info);
} }
else else
@ -459,11 +462,14 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page)
} }
else else
{ {
bool menuSort = true;
config_.setProperty("currentCollection", nextPageItem_->name); config_.setProperty("currentCollection", nextPageItem_->name);
config_.getProperty("collections." + nextPageItem_->name + ".list.menuSort", menuSort);
CollectionInfo *info = getCollection(nextPageItem_->name); CollectionInfo *info = getCollection(nextPageItem_->name);
MenuParser mp; MenuParser mp;
mp.menuItems(info); mp.buildMenuItems(info, menuSort);
page->pushCollection(info); page->pushCollection(info);
if(rememberMenu && lastMenuOffsets_.find(nextPageItem_->name) != lastMenuOffsets_.end()) if(rememberMenu && lastMenuOffsets_.find(nextPageItem_->name) != lastMenuOffsets_.end())