Add support for blocked submenu options

Some menus, such as when targeting other players, use mixins which are themselves menus. We have to dive down one more layer to resolve those. The official UI source does this submenu thing (as opposed to recursion) so this should exactly mimic how the base game now works.
This commit is contained in:
Parnic
2022-06-06 09:02:43 -05:00
parent d424afdab1
commit d31872512e
3 changed files with 41 additions and 7 deletions

View File

@ -772,8 +772,22 @@ local function munge_unit_menu(menu)
if data.GetMenuButtons then
local btns = data.GetMenuButtons()
for i=1, #btns do
if BLACKLISTED_UNIT_MENU_OPTIONS[btns[i]:GetText()] then
found = true
if btns[i].IsMenu() then
local subbtns = btns[i].GetMenuButtons()
for j=1, #subbtns do
if BLACKLISTED_UNIT_MENU_OPTIONS[subbtns[j]:GetText()] then
found = true
break
end
end
else
if BLACKLISTED_UNIT_MENU_OPTIONS[btns[i]:GetText()] then
found = true
break
end
end
if found then
break
end
end
@ -797,11 +811,23 @@ local function munge_unit_menu(menu)
local new_buttons_list = {}
local btns = data.GetMenuButtons()
for i=1, #btns do
local blacklisted = BLACKLISTED_UNIT_MENU_OPTIONS[btns[i]:GetText()]
if not blacklisted then
new_buttons_list[#new_buttons_list+1] = btns[i]
elseif blacklisted ~= true then
new_buttons_list[#new_buttons_list+1] = blacklisted
if btns[i].IsMenu() then
local subbtns = btns[i].GetMenuButtons()
for j=1, #subbtns do
local blacklisted = BLACKLISTED_UNIT_MENU_OPTIONS[subbtns[j]:GetText()]
if not blacklisted then
new_buttons_list[#new_buttons_list+1] = subbtns[j]
elseif blacklisted ~= true then
new_buttons_list[#new_buttons_list+1] = blacklisted
end
end
else
local blacklisted = BLACKLISTED_UNIT_MENU_OPTIONS[btns[i]:GetText()]
if not blacklisted then
new_buttons_list[#new_buttons_list+1] = btns[i]
elseif blacklisted ~= true then
new_buttons_list[#new_buttons_list+1] = blacklisted
end
end
end

View File

@ -1,5 +1,9 @@
# Changelog
v1.13.14.3:
- Restored right-click menus on Info and Health bars when targeting other players.
v1.13.14.2:
- Restored right-click menus on Info and Health bars.

View File

@ -1,5 +1,9 @@
# Changelog
v1.13.14.3:
- Restored right-click menus on Info and Health bars when targeting other players.
v1.13.14.2:
- Restored right-click menus on Info and Health bars.