PageRenderTime 16ms CodeModel.GetById 11ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Tukui/modules/datatext/micromenu.lua

http://github.com/Asphyxia/Tukui
Lua | 43 lines | 24 code | 7 blank | 12 comment | 3 complexity | 654cfb0c173e7bcc923138919377184d MD5 | raw file
 1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 2-----------------------------------------
 3-- Tukui Micro Menu
 4--
 5-- By: Rian Quinn
 6-- Date: 12-17-2010
 7--
 8-- Notes: This datatext is designed to
 9--        show the same micromenu that
10--        is shown when you use the
11--        middle mouse key on the mini
12--        map.
13-----------------------------------------
14
15if C["datatext"].micromenu and C["datatext"].micromenu > 0 then
16	local Stat = CreateFrame("Frame")
17	Stat:EnableMouse(true)
18	Stat:SetFrameStrata("HIGH")
19	Stat:SetFrameLevel(3)
20
21	local Text  = TukuiInfoLeft:CreateFontString(nil, "OVERLAY")
22	Text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
23	T.PP(C["datatext"].micromenu, Text)
24
25	local function OnEvent(self, event, ...)
26		Text:SetText(T.datacolor.."Micromenu")
27		self:SetAllPoints(Text)
28	end
29
30	local function OpenMenu()
31		if not TukuiMicroMenu or not TukuiMinimap then return end
32		
33		local xoff = 0
34		local position = TukuiMinimap:GetPoint()
35		if position:match("CENTER") then xoff = T.Scale(-14) end
36		
37		ToggleDropDownMenu(1, nil, TukuiMicroMenu, TukuiMinimap, xoff, T.Scale(-2))
38	end
39
40	Stat:RegisterEvent("PLAYER_LOGIN")
41	Stat:SetScript("OnEvent", OnEvent)
42	Stat:SetScript("OnMouseDown", function() OpenMenu() end)
43end