Skip to content

Commit

Permalink
fix options search when menus are defined recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaulwurff authored and coelckers committed Sep 3, 2021
1 parent 355e367 commit 3102640
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions wadsrc/static/zscript/engine/ui/menu/search/menu.zs
Expand Up @@ -31,7 +31,8 @@ class os_Menu : OptionMenu

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); }

Expand All @@ -54,21 +55,29 @@ class os_Menu : OptionMenu
string menuName,
os_Query query,
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 listMenuDesc = ListMenuDescriptor(desc);

if (listMenuDesc)
{
return listOptionsListMenu(listMenuDesc, targetDesc, query, path, isAnyTermMatches);
return listOptionsListMenu(listMenuDesc, targetDesc, query, path, isAnyTermMatches, searchedMenus);
}

let optionMenuDesc = OptionMenuDescriptor(desc);

if (optionMenuDesc)
{
return listOptionsOptionMenu(optionMenuDesc, targetDesc, query, path, isAnyTermMatches);
return listOptionsOptionMenu(optionMenuDesc, targetDesc, query, path, isAnyTermMatches, searchedMenus);
}

return false;
Expand All @@ -78,7 +87,8 @@ class os_Menu : OptionMenu
OptionMenuDescriptor targetDesc,
os_Query query,
string path,
bool isAnyTermMatches)
bool isAnyTermMatches,
Dictionary searchedMenus)
{
int nItems = sourceDesc.mItems.size();
bool found = false;
Expand All @@ -92,7 +102,7 @@ class os_Menu : OptionMenu
? makePath(path, StringTable.Localize(textItem.mText))
: path;

found |= listOptions(targetDesc, actionN, query, newPath, isAnyTermMatches);
found |= listOptions(targetDesc, actionN, query, newPath, isAnyTermMatches, searchedMenus);
}

return found;
Expand All @@ -102,7 +112,8 @@ class os_Menu : OptionMenu
OptionMenuDescriptor targetDesc,
os_Query query,
string path,
bool isAnyTermMatches)
bool isAnyTermMatches,
Dictionary searchedMenus)
{
if (sourceDesc == targetDesc) { return false; }

Expand Down Expand Up @@ -152,7 +163,7 @@ class os_Menu : OptionMenu
{
string newPath = makePath(path, label);

found |= listOptions(targetDesc, item.GetAction(), query, newPath, isAnyTermMatches);
found |= listOptions(targetDesc, item.GetAction(), query, newPath, isAnyTermMatches, searchedMenus);
}
}

Expand Down

0 comments on commit 3102640

Please sign in to comment.