From 01d3f1653e34bcb27e93994909d032ff1927a8dd Mon Sep 17 00:00:00 2001 From: tbkizle Date: Sat, 27 Jul 2024 14:37:57 -0400 Subject: [PATCH] Fix EasyMenu for Retail --- Baggins-Options.lua | 2 +- Baggins.lua | 25 +++++++++++++++++++++---- src/filters/PeriodicTable.lua | 3 +-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Baggins-Options.lua b/Baggins-Options.lua index 0f06720..8e58125 100644 --- a/Baggins-Options.lua +++ b/Baggins-Options.lua @@ -3753,7 +3753,7 @@ function Baggins:DoBagMenu() func = openBagCategoryConfig, notCheckable = true, }) - EasyMenu(menu, bagDropdownMenuFrame, "cursor", 0, 0, "MENU") + Baggins:EasyMenu(menu, bagDropdownMenuFrame, "cursor", 0, 0, "MENU") end end diff --git a/Baggins.lua b/Baggins.lua index 2106a25..6b3dfaf 100644 --- a/Baggins.lua +++ b/Baggins.lua @@ -324,7 +324,7 @@ local ldbdata = { if message == "RightButton" then tooltip:Hide() updateMenu() - EasyMenu(ldbDropDownMenu, ldbDropDownFrame, "cursor", 0, 0, "MENU") + Baggins:EasyMenu(ldbDropDownMenu, ldbDropDownFrame, "cursor", 0, 0, "MENU") -- Baggins:OpenConfig() else Baggins:OnClick() @@ -2478,7 +2478,7 @@ do return end makeMenu(bag, slot) - EasyMenu(menu, itemDropdownFrame, "cursor", 0, 0, "MENU") + Baggins:EasyMenu(menu, itemDropdownFrame, "cursor", 0, 0, "MENU") -- make sure we restore the original scroll-wheel behavior for the DropdownList2-Frame -- when the item-dropdown is closed Baggins:SecureHookScript(DropDownList1, "OnHide", function() @@ -2510,7 +2510,7 @@ do return end makeMenu(bag, slot) - EasyMenu(menu, itemDropdownFrame, "cursor", 0, 0, "MENU") + Baggins:EasyMenu(menu, itemDropdownFrame, "cursor", 0, 0, "MENU") -- make sure we restore the original scroll-wheel behavior for the DropdownList2-Frame -- when the item-dropdown is closed Baggins:SecureHookScript(DropDownList1, "OnHide", function() @@ -3604,7 +3604,7 @@ function BagginsOnAddonCompartmentClick(_,button) if button == "RightButton" then --tooltip:Hide() updateMenu() - EasyMenu(ldbDropDownMenu, ldbDropDownFrame, "cursor", 0, 0, "MENU") + Baggins:EasyMenu(ldbDropDownMenu, ldbDropDownFrame, "cursor", 0, 0, "MENU") -- Baggins:OpenConfig() else Baggins:OnClick() @@ -4331,3 +4331,20 @@ local function GetItemUpgradeLevel(itemLink) end end + +local function EasyMenu_Initialize(frame, level, menuList) + for index = 1, #menuList do + local value = menuList[index] + if value.text then value.index = index; UIDropDownMenu_AddButton(value, level) end + end +end + +function Baggins:EasyMenu(menuList, menuFrame, anchor, x, y, displayMode, autoHideDelay) + if Baggins:IsRetailWow() then + if displayMode=='MENU' then menuFrame.displayMode = displayMode end + UIDropDownMenu_Initialize(menuFrame, EasyMenu_Initialize, displayMode, nil, menuList) + ToggleDropDownMenu(1, nil, menuFrame, anchor, x, y, menuList, nil, autoHideDelay) + else + EasyMenu(menuList, menuFrame, anchor, x, y, displayMode, autoHideDelay) + end +end diff --git a/src/filters/PeriodicTable.lua b/src/filters/PeriodicTable.lua index 4494a33..67aa0f0 100644 --- a/src/filters/PeriodicTable.lua +++ b/src/filters/PeriodicTable.lua @@ -13,7 +13,6 @@ local AddOn = _G[AddOnName] local pairs, type, tonumber, wipe, ceil = pairs, type, tonumber, wipe, ceil local GetContainerItemLink = C_Container and C_Container.GetContainerItemLink or GetContainerItemLink -local EasyMenu = EasyMenu local tinsert, tsort = tinsert, table.sort @@ -128,7 +127,7 @@ local function showPTDropdown(info) local attr = info[#info] --luacheck: ignore 211 currentRule = info.arg --luacheck: ignore 111 local menu = buildMenu(ptsets) - EasyMenu(menu, ptdropdownFrame, "cursor", 0, 0, "MENU") + AddOn:EasyMenu(menu, ptdropdownFrame, "cursor", 0, 0, "MENU") end -- Test for match