diff --git a/Broker_StartMenu.toc b/Broker_StartMenu.toc index 77aa8dd..36b5940 100644 --- a/Broker_StartMenu.toc +++ b/Broker_StartMenu.toc @@ -22,7 +22,6 @@ libs\EasyDisplay.lua loc\enUS.lua -SecureButtonsOverlay.lua Tooltip.lua Menu.lua Core.lua diff --git a/Menu.lua b/Menu.lua index 5dbdf7f..6a6d770 100644 --- a/Menu.lua +++ b/Menu.lua @@ -22,10 +22,8 @@ ]] local addonName, addon = ... -local dropdown = CreateFrame("Frame", "StartMenuFrame", nil, "UIDropDownMenuTemplate") local display = LibStub("EasyDisplay-1.0") local L = LibStub("AceLocale-3.0"):GetLocale(addonName) -dropdown:Hide() local menu = {} local disabledItems = { "talents" } @@ -47,7 +45,6 @@ local function insertItem(name, order) if interface.button then entry.button = interface.button - entry.func = interface.func else entry.func = function() display:DisplayInterface(name) end end @@ -78,20 +75,6 @@ local function comp(a, b) return a.order < b.order end -DropDownList1:HookScript("OnShow", function(self) - if InCombatLockdown() then - return - end - addon:RemoveSecureButtonsOverlay() - if addon:IsMenuVisible() then - addon:AddSecureButtonsOverlay(menu) - end -end) - -DropDownList1:HookScript("OnHide", function(self) - addon:RemoveSecureButtonsOverlay() -end) - function addon:BuildMenu() if not self.updateMenu then return @@ -146,6 +129,17 @@ function addon:CreateMenu() addon:BuildMenu() end +local dropdown = LibStub("Libra"):CreateDropdown("Menu") +dropdown.initialize = function(self, level) + for index = 1, #menu do + local value = menu[index] + if value.text then + value.index = index + UIDropDownMenu_AddButton(value, level) + end + end +end + function addon:OpenMenu(frame, button) local name local isLeftButton = self.db.profile.mouseButton == 1 and button == "LeftButton" @@ -164,15 +158,10 @@ function addon:OpenMenu(frame, button) if isLeftButton or isRightButton then display:DisplayInterface(name) else - EasyMenu(menu, dropdown, frame, 0, 0, "MENU") + dropdown:Toggle(nil, frame) end end function addon:IsMenuVisible() - local current = UIDropDownMenu_GetCurrentDropDown() - if current and current == dropdown and DropDownList1:IsShown() then - return true - else - return false - end + return dropdown:IsShown() end \ No newline at end of file diff --git a/SecureButtonsOverlay.lua b/SecureButtonsOverlay.lua deleted file mode 100644 index 37fc8cd..0000000 --- a/SecureButtonsOverlay.lua +++ /dev/null @@ -1,111 +0,0 @@ ---[[ - Copyright (c) 2012 Eyal Shilony - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -]] - -local _, addon = ... - -local secureButtons = { } - --- script handlers to mimic regular dropdown button behaviour --- close menu when clicked -local function onClick(self) - self.parent:GetParent():Hide() -end - -local function onMouseDown(self) - self.parent:SetButtonState("PUSHED") -end - -local function onMouseUp(self) - self.parent:SetButtonState("NORMAL") -end - --- prevent menu from hiding -local function onEnter(self) - local grandParent = self.parent:GetParent() - CloseDropDownMenus(grandParent:GetID() + 1) - _G[self.parent:GetName().."Highlight"]:Show() - UIDropDownMenu_StopCounting(grandParent) -end - --- hide menu after timeout -local function onLeave(self) - _G[self.parent:GetName().."Highlight"]:Hide() - UIDropDownMenu_StartCounting(self.parent:GetParent()) - GameTooltip:Hide() -end - -local function createSecureButtonOverlay(button) - local secureButton = CreateFrame("Button", nil, nil, "SecureActionButtonTemplate") - secureButton:SetSize(200, 16) - secureButton:HookScript("OnClick", onClick) - secureButton:SetScript("OnEnter", onEnter) - secureButton:SetScript("OnLeave", onLeave) - secureButton:SetScript("OnMouseDown", onMouseDown) - secureButton:SetScript("OnMouseUp", onMouseUp) - secureButton:SetAttribute("type", "click") - secureButton:SetAttribute("clickbutton", button) - return secureButton -end - --- TODO: We can remove the dependency on the menu by using the dropdown itself, for now it works! -function addon:AddSecureButtonsOverlay(menu) - local index = 0 - for _, item in pairs(menu) do - if item.order and item.order > 0 then - index = index + 1 - local parent = _G["DropDownList1Button" .. index] - if not parent then - UIDropDownMenu_CreateFrames(1, index) - parent = _G["DropDownList1Button" .. index] - end - if parent and item.button then - local button = createSecureButtonOverlay(item.button) - table.insert(secureButtons, button) - button.parent = parent - button:SetParent(parent) - button:SetAllPoints() - --[[button:SetBackdrop({ - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - tile = true, - tileSize = 16, - --edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - edgeSize = 16, - insets = {left = 5, right = 3, top = 3, bottom = 5} - }) - button:SetBackdropColor(0, 1, 0, 0.5)]] - button:Show() - end - end - end -end - -function addon:RemoveSecureButtonsOverlay() - if #secureButtons > 0 then - for index, button in ipairs(secureButtons) do - button:SetParent(UIParent) - button:ClearAllPoints() - button:Hide() - end - wipe(secureButtons) - end -end \ No newline at end of file diff --git a/libs/EasyDisplay.lua b/libs/EasyDisplay.lua index 8a6609c..1d979f5 100644 --- a/libs/EasyDisplay.lua +++ b/libs/EasyDisplay.lua @@ -25,7 +25,7 @@ assert(LibStub, "EasyDisplay-1.0 requires LibStub") -local lib, minor = LibStub:NewLibrary("EasyDisplay-1.0", 7) +local lib, minor = LibStub:NewLibrary("EasyDisplay-1.0", 8) if not lib then return end minor = minor or 0 @@ -127,7 +127,7 @@ local interfaces = { title = CALENDAR, alias = "cal", frameName = "CalendarFrame", - func = function() ToggleCalendar() end, + func = ToggleCalendar, }, { name = "questlog", @@ -142,7 +142,7 @@ local interfaces = { title = SOCIAL_BUTTON, alias = "soc", frameName = "FriendsFrame", - func = function() ToggleFriendsFrame() end, + func = ToggleFriendsFrame, }, { name = "pvp", @@ -150,7 +150,7 @@ local interfaces = { frameName = "PVPFrame", level = SHOW_PVP_LEVEL, --button = PVPMicroButton, - func = function() TogglePVPUI() end, + func = TogglePVPUI, }, { name = "lfd", @@ -165,7 +165,7 @@ local interfaces = { title = RAID_FINDER, frameName = "LFRParentFrame", level = SHOW_LFD_LEVEL, - func = function() ToggleRaidFrame() end, + func = ToggleRaidFrame, }, { name = "collections", @@ -204,15 +204,13 @@ local interfaces = { { name = "bags", title = BAGS, - func = function() - ToggleAllBags() - end, + func = ToggleAllBags, }, { name = "time", title = TIMEMANAGER_TITLE, frameName = "TimeManagerFrame", - func = function() ToggleTimeManager() end, + func = ToggleTimeManager, }, { name = "help", @@ -316,16 +314,12 @@ local interfaces = { { name = "whatsnew", title = GAMEMENU_NEW_BUTTON, - func = function() - SplashFrame_Open() - end, + func = SplashFrame_Open, }, { name = "shops", title = BLIZZARD_STORE, - func = function() - ToggleStoreUI() - end, + func = ToggleStoreUI, } }