PageRenderTime 872ms CodeModel.GetById 855ms RepoModel.GetById 1ms app.codeStats 0ms

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