From 3cd8d3cefd966beb5119877a62b08ae6c044a56d Mon Sep 17 00:00:00 2001 From: Tukz Date: Sun, 29 Sep 2024 11:05:09 -0400 Subject: [PATCH] [Cata] Fix dropdown lua error on live servers. --- Tukui/Modules/DataTexts/Anchors.lua | 15 ++-- Tukui/Modules/Miscellaneous/DropDown.lua | 96 ++++++++++++++++++++---- 2 files changed, 90 insertions(+), 21 deletions(-) diff --git a/Tukui/Modules/DataTexts/Anchors.lua b/Tukui/Modules/DataTexts/Anchors.lua index 69e298f3..886b9fc2 100644 --- a/Tukui/Modules/DataTexts/Anchors.lua +++ b/Tukui/Modules/DataTexts/Anchors.lua @@ -4,10 +4,11 @@ local T, C = unpack((select(2, ...))) local MenuFrame = CreateFrame("Frame", "TukuiDataTextToggleDropDown", UIParent, "UIDropDownMenuTemplate") local DataTexts = T["DataTexts"] local Anchors = DataTexts.Anchors -local Menu = DataTexts.Menu +local DataMenu = DataTexts.Menu local Active = false local CurrentFrame + DataTexts.Toggle = function(self, object) CurrentFrame:SetData(object) end @@ -17,9 +18,11 @@ DataTexts.Remove = function() end local OnMouseDown = function(self) - CurrentFrame = self - - T.Miscellaneous.DropDown.Open(Menu, MenuFrame, "cursor", 0 , 0, "MENU", 2) + if Menu then + T.Miscellaneous.DropDown.DisplayDataTexts(self) + else + T.Miscellaneous.DropDown.Open(DataMenu, MenuFrame, "cursor", 0 , 0, "MENU", 2) + end end function DataTexts:ToggleDataPositions() @@ -47,6 +50,6 @@ end function DataTexts:AddRemove() -- Add a remove button - tinsert(Menu, {text = "", notCheckable = true}) - tinsert(Menu, {text = "|cffFF0000"..REMOVE.."|r", notCheckable = true, func = DataTexts.Remove}) + tinsert(DataMenu, {text = "", notCheckable = true}) + tinsert(DataMenu, {text = "|cffFF0000"..REMOVE.."|r", notCheckable = true, func = DataTexts.Remove}) end diff --git a/Tukui/Modules/Miscellaneous/DropDown.lua b/Tukui/Modules/Miscellaneous/DropDown.lua index 592ac2b3..f6266d94 100644 --- a/Tukui/Modules/Miscellaneous/DropDown.lua +++ b/Tukui/Modules/Miscellaneous/DropDown.lua @@ -4,31 +4,97 @@ local Miscellaneous = T["Miscellaneous"] local Noop = function() end local UIDropDownMenu_CreateFrames = UIDropDownMenu_CreateFrames local DropDown = CreateFrame("Frame") +local DataTexts = T["DataTexts"] -DropDown.ChatMenus = { - "ChatMenu", - "EmoteMenu", - "LanguageMenu", - "VoiceMacroMenu", -} +-- WIP +function DropDown:Warning() + T.Print("Dropdown are currently being rewrote from scratch and will be available soon!") +end + +function DropDown:DisplayDataTexts() + MenuUtil.CreateContextMenu(self, function(Region, Description) + for Number, DataText in pairs(DataTexts.Menu) do + Description:CreateButton(DataText.text, DropDown.Warning) + end + end) +end +-- WIP function DropDown:Skin() - local Dropdown = Menu.GetManager():GetOpenMenu() + if Menu then + local Dropdown = Menu.GetManager():GetOpenMenu() + + if Dropdown then + Dropdown:StripTextures() + Dropdown:SetTemplate() + end + else + for i = 1, Levels do + local Backdrop + + Backdrop = _G["DropDownList"..i.."MenuBackdrop"] + if Backdrop and not Backdrop.IsSkinned then + if Backdrop.NineSlice then + Backdrop.NineSlice:SetAlpha(0) + end + + Backdrop:StripTextures() + Backdrop:CreateBackdrop("Default") + Backdrop:CreateShadow() + Backdrop.IsSkinned = true + end + + Backdrop = _G["DropDownList"..i.."Backdrop"] + if Backdrop and not Backdrop.IsSkinned then + if Backdrop.NineSlice then + Backdrop.NineSlice:SetAlpha(0) + end - if Dropdown then - Dropdown:StripTextures() - Dropdown:SetTemplate() + Backdrop:StripTextures() + Backdrop:CreateBackdrop("Default") + Backdrop:CreateShadow() + Backdrop.IsSkinned = true + end + + Backdrop = _G["Lib_DropDownList"..i.."MenuBackdrop"] + if Backdrop and not Backdrop.IsSkinned then + if Backdrop.NineSlice then + Backdrop.NineSlice:SetAlpha(0) + end + + Backdrop:StripTextures() + Backdrop:CreateBackdrop("Default") + Backdrop:CreateShadow() + Backdrop.IsSkinned = true + end + + Backdrop = _G["Lib_DropDownList"..i.."Backdrop"] + if Backdrop and not Backdrop.IsSkinned then + if Backdrop.NineSlice then + Backdrop.NineSlice:SetAlpha(0) + end + + Backdrop:StripTextures() + Backdrop:CreateBackdrop("Default") + Backdrop:CreateShadow() + Backdrop.IsSkinned = true + end + end end end function DropDown:Enable() - local Manager = Menu.GetManager() + if Menu then + local Manager = Menu.GetManager() - hooksecurefunc(Manager, "OpenMenu", self.Skin) - hooksecurefunc(Manager, "OpenContextMenu", self.Skin) + hooksecurefunc(Manager, "OpenMenu", self.Skin) + hooksecurefunc(Manager, "OpenContextMenu", self.Skin) + else + hooksecurefunc("UIDropDownMenu_CreateFrames", self.Skin) - -- TWW need rework - self.Open = function() T.Print("Not available for Retail yet, work in progress") return end + -- use dropdown lib + self.Open = Lib_EasyMenu or EasyMenu + end end Miscellaneous.DropDown = DropDown