From 63b7b9d521712404dc35156ef8d7e606440b4156 Mon Sep 17 00:00:00 2001 From: mahlemiut Date: Sat, 24 Dec 2016 01:23:17 +1300 Subject: ui: another attempt at sorting File Manager entries (nw) --- src/frontend/mame/ui/filesel.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/frontend/mame/ui/filesel.cpp') diff --git a/src/frontend/mame/ui/filesel.cpp b/src/frontend/mame/ui/filesel.cpp index 114fa317c74..2efe4e0e24f 100644 --- a/src/frontend/mame/ui/filesel.cpp +++ b/src/frontend/mame/ui/filesel.cpp @@ -22,7 +22,8 @@ #include "zippath.h" #include - +#include +#include namespace ui { /*************************************************************************** @@ -297,6 +298,7 @@ void menu_file_selector::populate(float &customtop, float &custombottom) const file_selector_entry *selected_entry = nullptr; int i; const char *volume_name; + uint8_t first; // open the directory err = util::zippath_opendir(m_current_directory, &directory); @@ -332,6 +334,9 @@ void menu_file_selector::populate(float &customtop, float &custombottom) i++; } + // mark first filename entry + first = m_entrylist.size() + 1; + // build the menu for each item if (err == osd_file::error::NONE) { @@ -353,6 +358,16 @@ void menu_file_selector::populate(float &customtop, float &custombottom) } } + // sort the menu entries + std::wstring_convert> conv; + const std::collate& coll = std::use_facet>(std::locale()); + std::sort(m_entrylist.begin()+first, m_entrylist.end(), [&coll, &conv](file_selector_entry const &x, file_selector_entry const &y) + { + std::wstring xstr = conv.from_bytes(x.basename); + std::wstring ystr = conv.from_bytes(y.basename); + return coll.compare(xstr.data(), xstr.data()+xstr.size(), ystr.data(), ystr.data()+ystr.size()) < 0; + } ); + // append all of the menu entries for (auto &entry : m_entrylist) append_entry_menu_item(&entry); -- cgit v1.2.3-70-g09d2