Skip to content

Commit

Permalink
Replace EasyMenu with the new Blizzard_Menu (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
nebularg authored Nov 21, 2024
1 parent 7197f26 commit 4c6d79f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ read_globals = {
"CloseDropDownMenus",
"CreateFrame",
"debugprofilestop",
"EasyMenu",
"MenuUtil",
"Enum",
"GameTooltip",
"GameTooltip_Hide",
Expand Down
37 changes: 21 additions & 16 deletions Transcriptor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1682,11 +1682,25 @@ end
-- Addon
--

local menu = {}
--local popupFrame = CreateFrame("Frame", "TranscriptorMenu", eventFrame, "UIDropDownMenuTemplate")
--local function openMenu(frame)
-- EasyMenu(menu, popupFrame, frame, 20, 4, "MENU")
--end
local setupMenu
do
local function isSelected(v)
return TranscriptIgnore[v]
end
local function setSelected(v)
TranscriptIgnore[v] = not TranscriptIgnore[v] or nil
end
function setupMenu(_, root)
root:SetScrollMode(400)
root:CreateTitle(L["|cFFFFD200Transcriptor|r - Disabled Events"])
for _, v in ipairs(Transcriptor.events) do
root:CreateCheckbox(v, isSelected, setSelected, v)
end
root:CreateButton(CLOSE, function()
return 4 -- MenuResponse.CloseAll
end)
end
end

local ldb = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("Transcriptor", {
type = "data source",
Expand All @@ -1708,22 +1722,15 @@ local ldb = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("Transcriptor"
else
Transcriptor:StopLog()
end
--elseif button == "RightButton" then
--openMenu(self) -- XXX make a new menu?
elseif button == "RightButton" then
MenuUtil.CreateContextMenu(self, setupMenu)
end
end,
})

Transcriptor.events = {}
local function insertMenuItems(tbl)
for _, v in next, tbl do
tinsert(menu, {
text = v,
func = function() TranscriptIgnore[v] = not TranscriptIgnore[v] end,
checked = function() return TranscriptIgnore[v] end,
isNotRadio = true,
keepShownOnClick = 1,
})
tinsert(Transcriptor.events, v)
end
end
Expand All @@ -1733,11 +1740,9 @@ init:SetScript("OnEvent", function(self, event)
if type(TranscriptDB) ~= "table" then TranscriptDB = {} end
if type(TranscriptIgnore) ~= "table" then TranscriptIgnore = {} end

tinsert(menu, { text = L["|cFFFFD200Transcriptor|r - Disabled Events"], fontObject = "GameTooltipHeader", notCheckable = 1 })
insertMenuItems(wowEvents)
if BigWigsLoader then insertMenuItems(bwEvents) end
if DBM then insertMenuItems(dbmEvents) end
tinsert(menu, { text = CLOSE, func = function() CloseDropDownMenus() end, notCheckable = 1 })

C_ChatInfo.RegisterAddonMessagePrefix("Transcriptor")

Expand Down

0 comments on commit 4c6d79f

Please sign in to comment.