PageRenderTime 35ms CodeModel.GetById 20ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

/Tukui/modules/extras/bgannouncer.lua

http://github.com/Asphyxia/Tukui
Lua | 149 lines | 117 code | 21 blank | 11 comment | 5 complexity | 676fadcb751f39bc8e86fce3a1a742dc MD5 | raw file
  1local T, C, L = unpack(select(2, ...)) 
  2-----------------------------------------------
  3--	Battleground Defence Announcer, By Azmara 
  4-----------------------------------------------
  5if not C["datatext"].bgannouncer then return end
  6
  7local color = RAID_CLASS_COLORS[T.myclass]
  8local Text = TukuiInfoLeft:CreateFontString(nil, "OVERLAY")
  9Text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
 10
 11local curmapid = GetCurrentMapAreaID()
 12	
 13-- Create Main Button Frame
 14local buttonframe = CreateFrame("Frame", "BGAnnouncerButtonFrame", TukuiInfoRight)
 15buttonframe:SetAllPoints()
 16buttonframe:SetFrameStrata("DIALOG")
 17buttonframe:SetFrameLevel(10)
 18buttonframe:EnableMouse(true)
 19buttonframe:SetTemplate("Default")
 20
 21-- Button 1
 22local button1 = CreateFrame("Button", "BGAnnouncerButton1", buttonframe, "SecureActionButtonTemplate")
 23button1:CreatePanel("pron", (TukuiInfoRight:GetWidth()-11)/6, TukuiInfoRight:GetHeight(), "BOTTOMLEFT", buttonframe, "BOTTOMLEFT", 0,0)
 24button1:SetFrameLevel(buttonframe:GetFrameLevel() + 1)
 25button1:SetFrameStrata("DIALOG")
 26button1:CreateOverlay(button1)
 27button1:SetAttribute("type", "macro")
 28button1:SetAttribute("macrotext", "/bg Light attack incoming to "..GetMinimapZoneText())
 29
 30local button1_text = button1:CreateFontString(nil,"Overlay")
 31button1_text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
 32button1_text:Point("Center",1,1)
 33button1_text:SetText(T.datacolor.."Low")
 34button1:SetScript("OnEnter", function(self) self:SetBackdropBorderColor(color.r, color.g, color.b) end)
 35button1:SetScript("OnLeave", function(self) self:SetBackdropBorderColor(unpack(C.media.bordercolor)) end)
 36	
 37--Button 2
 38local button2 = CreateFrame("Button", "BGAnnouncerButton2", buttonframe, "SecureActionButtonTemplate")
 39button2:CreatePanel("pron", (TukuiInfoRight:GetWidth()-11)/6, TukuiInfoRight:GetHeight(), "LEFT", button1, "RIGHT", 2,0)
 40button2:SetFrameLevel(buttonframe:GetFrameLevel() + 1)
 41button2:SetFrameStrata("DIALOG")
 42button2:CreateOverlay(button2)
 43button2:SetAttribute("type", "macro")
 44button2:SetAttribute("macrotext", "/bg Medium attack Incoming to "..GetMinimapZoneText())
 45	
 46local button2_text = button2:CreateFontString(nil,"Overlay")
 47button2_text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
 48button2_text:Point("Center",1,1)
 49button2_text:SetText(T.datacolor.."Med")
 50button2:SetScript("OnEnter", function(self) self:SetBackdropBorderColor(color.r, color.g, color.b) end)
 51button2:SetScript("OnLeave", function(self) self:SetBackdropBorderColor(unpack(C.media.bordercolor)) end)
 52	
 53-- Button 3
 54local button3 = CreateFrame("Button", "BGAnnouncerButton3", buttonframe, "SecureActionButtonTemplate")
 55button3:CreatePanel("pron", (TukuiInfoRight:GetWidth()-11)/6, TukuiInfoRight:GetHeight(),"LEFT", button2, "RIGHT", 2,0)
 56button3:SetFrameLevel(buttonframe:GetFrameLevel() + 1)
 57button3:SetFrameStrata("DIALOG")
 58button3:CreateOverlay(button3)
 59button3:SetAttribute("type", "macro")
 60button3:SetAttribute("macrotext", "/bg Heavy Incoming to "..GetMinimapZoneText())
 61	
 62local button3_text = button3:CreateFontString(nil,"Overlay")
 63button3_text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
 64button3_text:Point("Center",1,1)
 65button3_text:SetText(T.datacolor.."High")
 66button3:SetScript("OnEnter", function(self) self:SetBackdropBorderColor(color.r, color.g, color.b) end)
 67button3:SetScript("OnLeave", function(self) self:SetBackdropBorderColor(unpack(C.media.bordercolor)) end)
 68
 69-- Button 4
 70local button4 = CreateFrame("Button", "BGAnnouncerButton4", buttonframe, "SecureActionButtonTemplate")
 71button4:CreatePanel("pron", (TukuiInfoRight:GetWidth()-11)/6, TukuiInfoRight:GetHeight(), "LEFT", button3, "RIGHT", 2,0)
 72button4:SetFrameLevel(buttonframe:GetFrameLevel() + 1)
 73button4:SetFrameStrata("DIALOG")
 74button4:CreateOverlay(button4)
 75button4:SetAttribute("type", "macro")
 76button4:SetAttribute("macrotext", "/bg All Secure at "..GetMinimapZoneText())
 77	
 78local button4_text = button4:CreateFontString(nil,"Overlay")
 79button4_text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
 80button4_text:Point("Center",1,1)
 81button4_text:SetText(T.datacolor.."Secure")
 82button4:SetScript("OnEnter", function(self) self:SetBackdropBorderColor(color.r, color.g, color.b) end)
 83button4:SetScript("OnLeave", function(self) self:SetBackdropBorderColor(unpack(C.media.bordercolor)) end)
 84
 85-- Button 5
 86local button5 = CreateFrame("Button", "BGAnnouncerButton5", buttonframe, "SecureActionButtonTemplate")
 87button5:CreatePanel("pron", (TukuiInfoRight:GetWidth()-11)/6, TukuiInfoRight:GetHeight(), "LEFT", button4, "RIGHT", 2,0)
 88button5:SetFrameLevel(buttonframe:GetFrameLevel() + 1)
 89button5:SetFrameStrata("DIALOG")
 90button5:CreateOverlay(button5)
 91button5:SetAttribute("type", "macro")
 92button5:SetAttribute("macrotext", "/say Focus Damage on %t")
 93	
 94local button5_text = button5:CreateFontString(nil,"Overlay")
 95button5_text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
 96button5_text:Point("Center",1,1)
 97button5_text:SetText(T.datacolor.."Focus")
 98button5:SetScript("OnEnter", function(self) self:SetBackdropBorderColor(color.r, color.g, color.b) end)
 99button5:SetScript("OnLeave", function(self) self:SetBackdropBorderColor(unpack(C.media.bordercolor)) end)
100	
101-- Button 6
102local button6 = CreateFrame("Button", "BGAnnouncerButton5", buttonframe, "SecureActionButtonTemplate")
103button6:CreatePanel("pron", (TukuiInfoRight:GetWidth()-11)/6, TukuiInfoRight:GetHeight(), "LEFT", button5, "RIGHT", 2,0)
104button6:SetFrameLevel(buttonframe:GetFrameLevel() + 1)
105button6:SetFrameStrata("DIALOG")
106button6:CreateOverlay(button6)
107button6:SetAttribute("type", "macro")
108button6:SetAttribute("macrotext", "/say Stealthed Enemies Nearby")
109
110local button6_text = button6:CreateFontString(nil,"Overlay")
111button6_text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
112button6_text:Point("Center",1,1)
113button6_text:SetText(T.datacolor.."Hidden")
114button6:SetScript("OnEnter", function(self) self:SetBackdropBorderColor(color.r, color.g, color.b) end)
115button6:SetScript("OnLeave", function(self) self:SetBackdropBorderColor(unpack(C.media.bordercolor)) end)
116
117local Stat = CreateFrame("Frame")
118Stat:EnableMouse(true)
119
120local UpdateZone = CreateFrame("Frame")
121UpdateZone:RegisterEvent("ZONE_CHANGED")
122UpdateZone:RegisterEvent("ZONE_CHANGED_NEW_AREA")
123UpdateZone:RegisterEvent("PLAYER_ENTERING_WORLD")
124UpdateZone:SetScript("OnEvent", OnEvent)
125UpdateZone:SetScript("OnUpdate", Update)
126UpdateZone:SetScript("OnEvent", function()
127	button1:SetAttribute("macrotext", "/bg Light attack incoming to "..GetMinimapZoneText())
128	button2:SetAttribute("macrotext", "/bg Medium attack Incoming to "..GetMinimapZoneText())
129	button3:SetAttribute("macrotext", "/bg Heavy Incoming to "..GetMinimapZoneText())
130	button4:SetAttribute("macrotext", "/bg All Secure at "..GetMinimapZoneText())
131end)
132
133--hide text when not in an bg
134local function OnEvent(self, event)
135	if event == "PLAYER_ENTERING_WORLD" then
136		local inInstance, instanceType = IsInInstance()
137		if inInstance and (instanceType == "pvp") then
138			buttonframe:Show()
139		else
140			buttonframe:Hide()
141		end
142	end
143end
144
145Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
146Stat:SetScript("OnEvent", OnEvent)
147Stat:SetScript("OnUpdate", Update)
148
149