summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui/selector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/mame/ui/selector.cpp')
-rw-r--r--src/frontend/mame/ui/selector.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/frontend/mame/ui/selector.cpp b/src/frontend/mame/ui/selector.cpp
index 59aa51f9d13..83738641142 100644
--- a/src/frontend/mame/ui/selector.cpp
+++ b/src/frontend/mame/ui/selector.cpp
@@ -60,7 +60,6 @@ void menu_selector::handle()
m_handler(selection);
- ui_globals::switch_image = true;
stack_pop();
}
else if (menu_event->iptkey == IPT_SPECIAL)
@@ -136,12 +135,17 @@ void menu_selector::custom_render(void *selectedref, float top, float bottom, fl
void menu_selector::find_matches(const char *str)
{
// allocate memory to track the penalty value
- std::vector<int> penalty(VISIBLE_GAMES_IN_SEARCH, 9999);
- int index = 0;
+ m_ucs_items.reserve(m_str_items.size());
+ std::vector<double> penalty(VISIBLE_GAMES_IN_SEARCH, 1.0);
+ std::u32string const search(ustr_from_utf8(normalize_unicode(str, unicode_normalization_form::D, true)));
- for (; index < m_str_items.size(); ++index)
+ int index = 0;
+ for ( ; index < m_str_items.size(); ++index)
{
- int curpenalty = fuzzy_substring(str, m_str_items[index]);
+ assert(m_ucs_items.size() >= index);
+ if (m_ucs_items.size() == index)
+ m_ucs_items.emplace_back(ustr_from_utf8(normalize_unicode(m_str_items[index], unicode_normalization_form::D, true)));
+ double const curpenalty(util::edit_distance(search, m_ucs_items[index]));
// insert into the sorted table of matches
for (int matchnum = VISIBLE_GAMES_IN_SEARCH - 1; matchnum >= 0; --matchnum)