--[[ ############################################################################## _____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# ___\///////////___________\///___________\/////////_____\///////////_# ############################################################################## S U P E R - V I L L A I N - U I By: Munglunch # ############################################################################## ########################################################## LOCALIZED LUA FUNCTIONS ########################################################## ]]-- --[[ GLOBALS ]]-- local _G = _G; local unpack = _G.unpack; local select = _G.select; --[[ ########################################################## GET ADDON DATA ########################################################## ]]-- local SuperVillain, L = unpack(select(2, ...)); --[[ ########################################################## LOCALS ########################################################## ]]-- local function EnteringBattleGround() SVUI_PVPComm:Show() local numButtons = 1 local points = GetNumMapLandmarks() for i = 1, points do if(numButtons <= 6) then local name, description, icon, _, _, _, active = GetMapLandmarkInfo(i) local buttonName = ("SVUI_PVPCommButton"):format(numButtons) local button = _G[buttonName] button.name = name button.description = description button.Text:SetText(name) button:SetFontString(button.Text) button:Show() numButtons = numButtons + 1 end end end local function ExitingBattleGround() for i = 1, 6 do local buttonName = ("SVUI_PVPCommButton"):format(numButtons) local button = _G[buttonName] button.name = "" button.description = "" button.Text:SetText("") button:SetFontString(button.Text) button:Hide() end SVUI_PVPComm:Hide() end --[[ ########################################################## HANDLERS ########################################################## ]]-- local Incoming_OnEnter = function(self) if InCombatLockdown() then return end if(self.description and self.description ~= "") then self:SetBackdropBorderColor(1,0.45,0) GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT", 0, 4) GameTooltip:ClearLines() GameTooltip:AddLine(self.description, 1, 1, 1) GameTooltip:Show() end end local Incoming_OnLeave = function(self) if InCombatLockdown() then return end self:SetBackdropBorderColor(0,0,0) if(GameTooltip:IsShown()) then GameTooltip:Hide() end end local Incoming_OnClick = function(self) if(self.name and self.name ~= "") then local msg = ("{rt8} Incoming %s {rt8}"):format(self.name) SendChatMessage(msg, "INSTANCE_CHAT") end end local PVPCommunicator = CreateFrame("Frame", nil) local PVPCommunicator_OnEvent = function(self, event, ...) local instance, groupType = IsInInstance() if(instance and groupType == "pvp") then if(not self.InPVP) then EnteringBattleGround() self.InPVP = true end else if(self.InPVP) then ExitingBattleGround() self.InPVP = nil end end end --[[ ########################################################## LOADER ########################################################## ]]-- local function LoadPVPComm() local width = 119 local height = 156 local holder = CreateFrame("Frame", "SVUI_PVPComm", UIParent) holder:SetSize(width, height) holder:SetPoint("RIGHT", UIParent, "CENTER", -200, 0) holder:SetPanelTemplate("Transparent") for i = 1, 6 do local yOffset = (24 * (i - 1)) + 2 local buttonName = ("SVUI_PVPCommButton"):format(i) if(not _G[buttonName]) then local button = CreateFrame("Button", buttonName, holder) button:SetSize(115, 22) button:SetPoint("TOP", holder, "TOP", 0, -yOffset) button:SetButtonTemplate() button.Text = button:CreateFontString(nil,"OVERLAY") button.Text:SetFont(SuperVillain.Media.font.roboto, 12, "NONE") button.Text:SetAllPoints(button) button.Text:SetJustifyH("CENTER") button.Text:SetText("") button:SetFontString(button.Text) button:SetScript("OnEnter", Incoming_OnEnter) button:SetScript("OnLeave", Incoming_OnLeave) button:SetScript("OnClick", Incoming_OnClick) end end SuperVillain:SetSVMovable(holder, "SVUI_PVPComm_MOVE", L["PvP Communicator"]) PVPCommunicator:RegisterEvent("PLAYER_ENTERING_WORLD") PVPCommunicator:SetScript("OnEvent", PVPCommunicator_OnEvent) holder:Hide() end SuperVillain.Registry:NewScript(LoadPVPComm)