PageRenderTime 156ms CodeModel.GetById 90ms app.highlight 8ms RepoModel.GetById 24ms app.codeStats 0ms

/Tukui/modules/panels/control_panel.lua

http://github.com/Asphyxia/Tukui
Lua | 135 lines | 110 code | 15 blank | 10 comment | 7 complexity | 2692a4133ed8b79ad2bcbc359d4e962a MD5 | raw file
  1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  2
  3----------------------------------------------------------------------------------
  4-- Config Panel For Action Bars [Credit Smelly]
  5----------------------------------------------------------------------------------
  6
  7local function ModifiedBackdrop(self)
  8	local color = RAID_CLASS_COLORS[T.myclass]
  9	self:SetBackdropColor(color.r*.15, color.g*.15, color.b*.15)
 10	self:SetBackdropBorderColor(color.r, color.g, color.b)
 11end
 12
 13local function OriginalBackdrop(self)
 14	self:SetTemplate("Default")
 15end
 16
 17-- BG for action bar config
 18local actionBarBG = CreateFrame("Frame", "actionBarBG", UIParent)
 19actionBarBG:CreatePanel("Default", 150, 61, "CENTER", UIParent, "CENTER", 0, 25)
 20if T.lowversion then
 21	actionBarBG:Height(61)
 22else
 23	actionBarBG:Height(80)
 24end
 25T.fadeIn(actionBarBG)
 26actionBarBG:SetFrameLevel(15)
 27actionBarBG:Hide()
 28
 29local abHeader = CreateFrame("Frame", "abHeader", actionBarBG)
 30abHeader:CreatePanel("Transparent", actionBarBG:GetWidth() - 1, 20, "BOTTOM", actionBarBG, "TOP", 0, 2, true)
 31abHeader.text:SetText(T.datacolor.."Actionbar Config Menu")
 32
 33-- BG for Control Panel
 34local extrasBG = CreateFrame("Frame", "extrasBG", UIParent)
 35extrasBG:CreatePanel("Default", 152, 114 , "CENTER", UIParent, "CENTER", 0, 25)
 36extrasBG:SetFrameLevel(10)
 37extrasBG:SetFrameStrata("BACKGROUND")
 38extrasBG:Hide()
 39T.fadeIn(extrasBG)
 40
 41local extraHeader = CreateFrame("Frame", "extraHeader", extrasBG)
 42extraHeader:CreatePanel("Transparent", extrasBG:GetWidth() - 1, 20, "BOTTOM", extrasBG, "TOP", 0, 2, true)
 43extraHeader.text:SetText(T.datacolor.."Control Panel Menu")
 44
 45-- close button inside action bar config
 46local closeAB = CreateFrame("Frame", "closeAB", actionBarBG)
 47closeAB:CreatePanel("Default", actionBarBG:GetWidth() - 8, 15, "BOTTOM", actionBarBG, "BOTTOM", 0, 4, true)
 48closeAB:SetFrameLevel(actionBarBG:GetFrameLevel() + 1)
 49closeAB:HookScript("OnEnter", ModifiedBackdrop)
 50closeAB:HookScript("OnLeave", OriginalBackdrop)
 51closeAB.text:SetText(T.datacolor.."Close")
 52closeAB:CreateOverlay(closeAB)
 53closeAB:SetScript("OnMouseDown", function()
 54	T.fadeOut(actionBarBG)
 55	extrasBG:Show()
 56end)
 57
 58-- slash command to open up actionbar config
 59function SlashCmdList.AB()
 60	if extrasBG:IsShown() then
 61		actionBarBG:Show()
 62		T.fadeOut(extrasBG)
 63	else
 64		actionBarBG:Show()
 65	end
 66end
 67SLASH_AB1 = "/ab"
 68
 69-- setup config button slash commands
 70local buttons = {
 71	[1] = {"/ab"},
 72	[2] = {"/am"},
 73	[3] = {"/tc"},
 74	[4] = {"/mtukui"},
 75}
 76
 77-- setup text in each button
 78local texts = {
 79	[1] = {T.datacolor.."Actionbar Config"},
 80	[2] = {T.datacolor.."Addons"},
 81	[3] = {T.datacolor.."Config UI"},
 82	[4] = {T.datacolor.."Move UI"},
 83}
 84
 85-- create the config buttons
 86local button = CreateFrame("Button", "button", extrasBG)
 87for i = 1, getn(buttons) do
 88	button[i] = CreateFrame("Button", "button"..i, extrasBG, "SecureActionButtonTemplate")
 89	button[i]:CreatePanel("Default", extrasBG:GetWidth() - 8, 24, "TOP", extrasBG, "TOP", 0, -4, true)
 90	button[i]:SetFrameLevel(extrasBG:GetFrameLevel() + 1)
 91	button[i].text:SetText(unpack(texts[i]))
 92	if i == 1 then
 93		button[i]:Point("TOP", extrasBG, "TOP", 0, -5)
 94	else
 95		button[i]:Point("TOP", button[i-1], "BOTTOM", 0, -3)
 96	end
 97	button[i]:SetAttribute("type", "macro")
 98	button[i]:SetAttribute("macrotext", unpack(buttons[i]))
 99	button[i]:SetFrameStrata("BACKGROUND")
100	button[i]:CreateOverlay(button[i])
101	button[i]:HookScript("OnEnter", ModifiedBackdrop)
102	button[i]:HookScript("OnLeave", OriginalBackdrop)
103end
104
105local close = CreateFrame("Button", "close", extrasBG)
106close:CreatePanel("Default", extrasBG:GetWidth() - 8, 24, "TOP", button[7], "BOTTOM", 0, -3, true)
107close:SetFrameLevel(extrasBG:GetFrameLevel() + 1)
108close:SetFrameStrata("BACKGROUND")
109close.text:SetText(T.datacolor.."Close")
110close:HookScript("OnEnter", ModifiedBackdrop)
111close:HookScript("OnLeave", OriginalBackdrop)
112close:SetScript("OnMouseDown", function()
113	T.fadeOut(extrasBG)
114end)
115
116local extraToggle = CreateFrame("Frame", "extraToggle", UIParent)
117extraToggle:CreatePanel("Default", 100, 20, "BOTTOM", UIParent, "BOTTOM", 0, 2, true)
118extraToggle:CreateBorder(false, true)
119extraToggle:SetFrameLevel(2)
120extraToggle:SetFrameStrata("LOW")
121extraToggle:CreateShadow("Default")
122extraToggle:CreateOverlay(extraToggle)
123extraToggle.text:SetText(T.datacolor.."Control Panel")
124extraToggle:HookScript("OnEnter", ModifiedBackdrop)
125extraToggle:HookScript("OnLeave", OriginalBackdrop)
126
127extraToggle:SetScript("OnMouseDown", function(self)
128if InCombatLockdown() then print(ERR_NOT_IN_COMBAT) return end
129	if not extrasBG:IsShown() then
130		extrasBG:Show()
131		T.fadeOut(actionBarBG)
132	else
133		T.fadeOut(extrasBG)
134	end
135end)