From cc0568f5a08ac5cb8c9d74c9600f99e262a2c844 Mon Sep 17 00:00:00 2001 From: Tukz Date: Wed, 9 Oct 2024 14:40:36 -0400 Subject: [PATCH] Add DataText selection dropdown for /tukui dt --- Tukui/Modules/DataTexts/Anchors.lua | 26 +++++++++++++++++++++++- Tukui/Modules/Miscellaneous/DropDown.lua | 14 ------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Tukui/Modules/DataTexts/Anchors.lua b/Tukui/Modules/DataTexts/Anchors.lua index 886b9fc2..bffaddc4 100644 --- a/Tukui/Modules/DataTexts/Anchors.lua +++ b/Tukui/Modules/DataTexts/Anchors.lua @@ -18,13 +18,37 @@ DataTexts.Remove = function() end local OnMouseDown = function(self) + CurrentFrame = self + if Menu then - T.Miscellaneous.DropDown.DisplayDataTexts(self) + DataTexts.DisplayDataTextsDropDown(CurrentFrame) else T.Miscellaneous.DropDown.Open(DataMenu, MenuFrame, "cursor", 0 , 0, "MENU", 2) end end +function DataTexts:SwitchDataText() + local Object = DataTexts:GetDataText(self) + + if Object then + DataTexts:Toggle(Object) + else + DataTexts:Remove() + end +end + +function DataTexts:DisplayDataTextsDropDown() + MenuUtil.CreateContextMenu(self, function(Region, Description) + for Number, DataText in pairs(DataTexts.Menu) do + local Name = DataText.text + + Description:CreateButton(DataText.text, function() + DataTexts.SwitchDataText(Name) + end) + end + end) +end + function DataTexts:ToggleDataPositions() if Active then for i = 1, self.NumAnchors do diff --git a/Tukui/Modules/Miscellaneous/DropDown.lua b/Tukui/Modules/Miscellaneous/DropDown.lua index f6266d94..555cb226 100644 --- a/Tukui/Modules/Miscellaneous/DropDown.lua +++ b/Tukui/Modules/Miscellaneous/DropDown.lua @@ -6,20 +6,6 @@ local UIDropDownMenu_CreateFrames = UIDropDownMenu_CreateFrames local DropDown = CreateFrame("Frame") local DataTexts = T["DataTexts"] --- 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() if Menu then local Dropdown = Menu.GetManager():GetOpenMenu()