Skip to content

Commit

Permalink
[Cata] Fix dropdown lua error on live servers.
Browse files Browse the repository at this point in the history
  • Loading branch information
tukz committed Sep 29, 2024
1 parent b8d14db commit 3cd8d3c
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 21 deletions.
15 changes: 9 additions & 6 deletions Tukui/Modules/DataTexts/Anchors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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
96 changes: 81 additions & 15 deletions Tukui/Modules/Miscellaneous/DropDown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3cd8d3c

Please sign in to comment.