fix options search when menus are defined recursively

This commit is contained in:
Alexander Kromm 2021-09-03 22:58:35 +07:00 committed by Christoph Oelckers
parent 355e367a08
commit 3102640210

View file

@ -31,7 +31,8 @@ class os_Menu : OptionMenu
addSearchField(text); addSearchField(text);
bool found = listOptions(mDesc, "MainMenu", query, "", isAnyTermMatches); Dictionary searchedMenus = Dictionary.Create();
bool found = listOptions(mDesc, "MainMenu", query, "", isAnyTermMatches, searchedMenus);
if (!found) { addNoResultsItem(mDesc); } if (!found) { addNoResultsItem(mDesc); }
@ -54,21 +55,29 @@ class os_Menu : OptionMenu
string menuName, string menuName,
os_Query query, os_Query query,
string path, string path,
bool isAnyTermMatches) bool isAnyTermMatches,
Dictionary searchedMenus)
{ {
if (searchedMenus.At(menuName).length() > 0)
{
return false;
}
searchedMenus.Insert(menuName, "1");
let desc = MenuDescriptor.GetDescriptor(menuName); let desc = MenuDescriptor.GetDescriptor(menuName);
let listMenuDesc = ListMenuDescriptor(desc); let listMenuDesc = ListMenuDescriptor(desc);
if (listMenuDesc) if (listMenuDesc)
{ {
return listOptionsListMenu(listMenuDesc, targetDesc, query, path, isAnyTermMatches); return listOptionsListMenu(listMenuDesc, targetDesc, query, path, isAnyTermMatches, searchedMenus);
} }
let optionMenuDesc = OptionMenuDescriptor(desc); let optionMenuDesc = OptionMenuDescriptor(desc);
if (optionMenuDesc) if (optionMenuDesc)
{ {
return listOptionsOptionMenu(optionMenuDesc, targetDesc, query, path, isAnyTermMatches); return listOptionsOptionMenu(optionMenuDesc, targetDesc, query, path, isAnyTermMatches, searchedMenus);
} }
return false; return false;
@ -78,7 +87,8 @@ class os_Menu : OptionMenu
OptionMenuDescriptor targetDesc, OptionMenuDescriptor targetDesc,
os_Query query, os_Query query,
string path, string path,
bool isAnyTermMatches) bool isAnyTermMatches,
Dictionary searchedMenus)
{ {
int nItems = sourceDesc.mItems.size(); int nItems = sourceDesc.mItems.size();
bool found = false; bool found = false;
@ -92,7 +102,7 @@ class os_Menu : OptionMenu
? makePath(path, StringTable.Localize(textItem.mText)) ? makePath(path, StringTable.Localize(textItem.mText))
: path; : path;
found |= listOptions(targetDesc, actionN, query, newPath, isAnyTermMatches); found |= listOptions(targetDesc, actionN, query, newPath, isAnyTermMatches, searchedMenus);
} }
return found; return found;
@ -102,7 +112,8 @@ class os_Menu : OptionMenu
OptionMenuDescriptor targetDesc, OptionMenuDescriptor targetDesc,
os_Query query, os_Query query,
string path, string path,
bool isAnyTermMatches) bool isAnyTermMatches,
Dictionary searchedMenus)
{ {
if (sourceDesc == targetDesc) { return false; } if (sourceDesc == targetDesc) { return false; }
@ -152,7 +163,7 @@ class os_Menu : OptionMenu
{ {
string newPath = makePath(path, label); string newPath = makePath(path, label);
found |= listOptions(targetDesc, item.GetAction(), query, newPath, isAnyTermMatches); found |= listOptions(targetDesc, item.GetAction(), query, newPath, isAnyTermMatches, searchedMenus);
} }
} }