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,11 +772,25 @@ local function munge_unit_menu(menu)
if data.GetMenuButtons then if data.GetMenuButtons then
local btns = data.GetMenuButtons() local btns = data.GetMenuButtons()
for i=1, #btns do for i=1, #btns do
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 if BLACKLISTED_UNIT_MENU_OPTIONS[btns[i]:GetText()] then
found = true found = true
break break
end end
end end
if found then
break
end
end
else else
for _, v in ipairs(data) do for _, v in ipairs(data) do
if BLACKLISTED_UNIT_MENU_OPTIONS[v] then if BLACKLISTED_UNIT_MENU_OPTIONS[v] then
@ -797,6 +811,17 @@ local function munge_unit_menu(menu)
local new_buttons_list = {} local new_buttons_list = {}
local btns = data.GetMenuButtons() local btns = data.GetMenuButtons()
for i=1, #btns do for i=1, #btns do
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()] local blacklisted = BLACKLISTED_UNIT_MENU_OPTIONS[btns[i]:GetText()]
if not blacklisted then if not blacklisted then
new_buttons_list[#new_buttons_list+1] = btns[i] new_buttons_list[#new_buttons_list+1] = btns[i]
@ -804,6 +829,7 @@ local function munge_unit_menu(menu)
new_buttons_list[#new_buttons_list+1] = blacklisted new_buttons_list[#new_buttons_list+1] = blacklisted
end end
end end
end
new_data = data new_data = data
function new_data:GetMenuButtons() function new_data:GetMenuButtons()

View File

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

View File

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