Upvalue Omen's menu and quick menu functions.

This commit is contained in:
Xinhuan
2009-03-02 11:38:27 +08:00
parent 246181fc55
commit 623c47c922
+44 -23
View File
@@ -222,6 +222,25 @@ for i = 1, 40 do
end end
----------------------------------------------------------------------------------------
-- Use a common frame and setup some common functions for the Omen dropdown menus
local Omen_DropDownMenu = CreateFrame("Frame", "Omen_DropDownMenu")
Omen_DropDownMenu.displayMode = "MENU"
Omen_DropDownMenu.info = {}
Omen_DropDownMenu.HideMenu = function()
if UIDROPDOWNMENU_OPEN_MENU == Omen_DropDownMenu then
CloseDropDownMenus()
end
end
Omen_DropDownMenu.OnClick = function(frame, button, down)
if Omen_DropDownMenu.initialize ~= frame.initMenuFunc then
CloseDropDownMenus()
Omen_DropDownMenu.initialize = frame.initMenuFunc
end
ToggleDropDownMenu(1, nil, Omen_DropDownMenu, frame, 0, 0)
end
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- Table Pool for recycling tables -- Table Pool for recycling tables
local tablePool = {} local tablePool = {}
@@ -339,11 +358,8 @@ function Omen:CreateFrames()
self.Title:EnableMouse(true) self.Title:EnableMouse(true)
self.Title:SetScript("OnMouseDown", startmoving) self.Title:SetScript("OnMouseDown", startmoving)
self.Title:SetScript("OnMouseUp", stopmoving) self.Title:SetScript("OnMouseUp", stopmoving)
self.Title:SetScript("OnClick", function(self, button, down) self.Title:SetScript("OnClick", Omen_DropDownMenu.OnClick)
if button == "RightButton" then self.Title.initMenuFunc = self.TitleQuickMenu
ToggleDropDownMenu(1, nil, Omen_TitleDropDownMenu, self:GetName(), 0, 0)
end
end)
self.Title:RegisterForClicks("RightButtonUp") self.Title:RegisterForClicks("RightButtonUp")
-- Create Title text -- Create Title text
@@ -1717,11 +1733,24 @@ end
-- Title Right Click menu -- Title Right Click menu
do do
local info = {} -- Upvalue the functions in the menu
local Omen_TitleDropDownMenu = CreateFrame("Frame", "Omen_TitleDropDownMenu") local function updateGrip()
Omen_TitleDropDownMenu.displayMode = "MENU" db.Locked = not db.Locked
Omen_TitleDropDownMenu.initialize = function(self, level) Omen:UpdateGrips()
LibStub("AceConfigRegistry-3.0"):NotifyChange("Omen")
end
local function toggleFocus() Omen:ToggleFocus() end
local function toggleTestMode()
testMode = not testMode
Omen:UpdateBars()
LibStub("AceConfigRegistry-3.0"):NotifyChange("Omen")
end
local function showConfig() Omen:ShowConfig() end
local function toggle() Omen:Toggle() end
function Omen.TitleQuickMenu(self, level)
if not level then return end if not level then return end
local info = self.info
wipe(info) wipe(info)
if level == 1 then if level == 1 then
-- Create the title of the menu -- Create the title of the menu
@@ -1735,50 +1764,42 @@ do
info.notCheckable = nil info.notCheckable = nil
info.text = L["Lock Omen"] info.text = L["Lock Omen"]
info.func = function() info.func = updateGrip
db.Locked = not db.Locked
Omen:UpdateGrips()
LibStub("AceConfigRegistry-3.0"):NotifyChange("Omen")
end
info.checked = db.Locked info.checked = db.Locked
info.tooltipTitle = L["Lock Omen"] info.tooltipTitle = L["Lock Omen"]
info.tooltipText = L["Locks Omen in place and prevents it from being dragged or resized."] info.tooltipText = L["Locks Omen in place and prevents it from being dragged or resized."]
UIDropDownMenu_AddButton(info, level) UIDropDownMenu_AddButton(info, level)
info.text = L["Use Focus Target"] info.text = L["Use Focus Target"]
info.func = function() Omen:ToggleFocus() end info.func = toggleFocus
info.checked = db.UseFocus info.checked = db.UseFocus
info.tooltipTitle = L["Use Focus Target"] info.tooltipTitle = L["Use Focus Target"]
info.tooltipText = L["Tells Omen to additionally check your 'focus' and 'focustarget' before your 'target' and 'targettarget' in that order for threat display."] info.tooltipText = L["Tells Omen to additionally check your 'focus' and 'focustarget' before your 'target' and 'targettarget' in that order for threat display."]
UIDropDownMenu_AddButton(info, level) UIDropDownMenu_AddButton(info, level)
info.text = L["Test Mode"] info.text = L["Test Mode"]
info.func = function() info.func = toggleTestMode
testMode = not testMode
Omen:UpdateBars()
LibStub("AceConfigRegistry-3.0"):NotifyChange("Omen")
end
info.checked = testMode info.checked = testMode
info.tooltipTitle = L["Test Mode"] info.tooltipTitle = L["Test Mode"]
info.tooltipText = L["Tells Omen to enter Test Mode so that you can configure Omen's display much more easily."] info.tooltipText = L["Tells Omen to enter Test Mode so that you can configure Omen's display much more easily."]
UIDropDownMenu_AddButton(info, level) UIDropDownMenu_AddButton(info, level)
info.text = L["Open Config"] info.text = L["Open Config"]
info.func = function() Omen:ShowConfig() end info.func = showConfig
info.checked = nil info.checked = nil
info.tooltipTitle = L["Open Config"] info.tooltipTitle = L["Open Config"]
info.tooltipText = L["Open Omen's configuration panel"] info.tooltipText = L["Open Omen's configuration panel"]
UIDropDownMenu_AddButton(info, level) UIDropDownMenu_AddButton(info, level)
info.text = L["Hide Omen"] info.text = L["Hide Omen"]
info.func = function() Omen:Toggle() end info.func = toggle
info.tooltipTitle = L["Hide Omen"] info.tooltipTitle = L["Hide Omen"]
info.tooltipText = nil info.tooltipText = nil
UIDropDownMenu_AddButton(info, level) UIDropDownMenu_AddButton(info, level)
-- Close menu item -- Close menu item
info.text = CLOSE info.text = CLOSE
info.func = function() CloseDropDownMenus() end info.func = self.HideMenu
info.checked = nil info.checked = nil
info.arg1 = nil info.arg1 = nil
info.notCheckable = 1 info.notCheckable = 1