--[[ ############################################################################## _____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# ___\///////////___________\///___________\/////////_____\///////////_# ############################################################################## S U P E R - V I L L A I N - U I By: Munglunch # ############################################################################## STATS:Extend EXAMPLE USAGE: MOD:Extend(newStat,eventList,onEvents,update,click,focus,blur) ########################################################## LOCALIZED LUA FUNCTIONS ########################################################## ]]-- --[[ GLOBALS ]]-- local _G = _G; local unpack = _G.unpack; local select = _G.select; local pairs = _G.pairs; local ipairs = _G.ipairs; local type = _G.type; local error = _G.error; local pcall = _G.pcall; local assert = _G.assert; local tostring = _G.tostring; local tonumber = _G.tonumber; local tinsert = _G.tinsert; local string = _G.string; local math = _G.math; local table = _G.table; --[[ STRING METHODS ]]-- local lower, upper = string.lower, string.upper; local find, format, len, split = string.find, string.format, string.len, string.split; local match, sub, join = string.match, string.sub, string.join; local gmatch, gsub = string.gmatch, string.gsub; --[[ MATH METHODS ]]-- local abs, ceil, floor, round = math.abs, math.ceil, math.floor, math.round; -- Basic --[[ TABLE METHODS ]]-- local twipe, tsort = table.wipe, table.sort; --[[ ########################################################## GET ADDON DATA ########################################################## ]]-- local SV, L, Registry = unpack(select(2, ...)); local MOD = SV.SVStats; --[[ ########################################################## CALL TO ARMS STATS ########################################################## ]]-- local StatEvents = {"PLAYER_ENTERING_WORLD", "LFG_UPDATE_RANDOM_INFO"}; local tooltipString = ("%s: N/A"):format(BATTLEGROUND_HOLIDAY) local currentObject; local function formatCTAtext(tanks, heals, dps) local result = "" if tanks then result = result.."|TInterface\\AddOns\\SVUI\\assets\\textures\\default\\tank.tga:14:14|t" end if heals then result = result.."|TInterface\\AddOns\\SVUI\\assets\\textures\\default\\healer.tga:14:14|t" end if dps then result = result.."|TInterface\\AddOns\\SVUI\\assets\\textures\\default\\dps.tga:14:14|t" end return result end local function CTA_OnEvent(self, ...) local isTank = false; local isHeal = false; local isDPS = false; local isNormal = true; for r = 1, GetNumRandomDungeons()do local id, name = GetLFGRandomDungeonInfo(r) for i = 1, LFG_ROLE_NUM_SHORTAGE_TYPES do local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, i) if eligible then isNormal = false end if eligible and forTank and itemCount > 0 then isTank = true; end if eligible and forHealer and itemCount > 0 then isHeal = true; end if eligible and forDamage and itemCount > 0 then isDPS = true; end end end if isNormal then self.text:SetText(tooltipString) else self.text:SetText(BATTLEGROUND_HOLIDAY..": "..formatCTAtext(isTank, isHeal, isDPS)) end currentObject = self end local function CTA_OnClick() ToggleFrame(LFDParentFrame) end local function CTA_OnEnter(self) MOD:Tip(self) local counter = 0; for r = 1, GetNumRandomDungeons()do local isTank = false; local isHeal = false; local isDPS = false; local isNormal = true; local id, name = GetLFGRandomDungeonInfo(r) for i = 1, LFG_ROLE_NUM_SHORTAGE_TYPES do local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, i) if eligible then isNormal = false end if eligible and forTank and itemCount > 0 then isTank = true; end if eligible and forHealer and itemCount > 0 then isHeal = true; end if eligible and forDamage and itemCount > 0 then isDPS = true; end end if not isNormal then local text = formatCTAtext(isTank,isHeal,isDPS) if text ~= "" then MOD.tooltip:AddDoubleLine(name..":", text, 1, 1, 1) end if isTank or isHeal or isDPS then counter = counter + 1 end end end MOD:ShowTip() end local CTAColorUpdate = function() local hexColor = SV:HexColor("highlight"); tooltipString = ("%s: |cff%sN/A|r"):format(BATTLEGROUND_HOLIDAY, hexColor) if currentObject ~= nil then CTA_OnEvent(currentObject) end end Registry:NewCallback(CTAColorUpdate) MOD:Extend('Call to Arms', StatEvents, CTA_OnEvent, nil, CTA_OnClick, CTA_OnEnter)