/Tukui/modules/datatext/calltoarms.lua
Lua | 110 lines | 94 code | 13 blank | 3 comment | 22 complexity | 1242ab881fb5acc417c1448d9e09412b MD5 | raw file
1local T, C, L = unpack(select(2, ...)) 2 3-------------------------------------------------------------------- 4 -- Call To Arms -- Elv22 5-------------------------------------------------------------------- 6 7if C["datatext"].calltoarms and C["datatext"].calltoarms > 0 then 8 local Stat = CreateFrame("Frame") 9 Stat:EnableMouse(true) 10 Stat:SetFrameStrata("MEDIUM") 11 Stat:SetFrameLevel(3) 12 13 local Text = TukuiInfoLeft:CreateFontString(nil, "OVERLAY") 14 Text:SetFont(C["media"].pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE") 15 Text:SetShadowOffset(T.mult, -T.mult) 16 Text:SetShadowColor(0, 0, 0, 0.4) 17 T.PP(C["datatext"].calltoarms, Text) 18 Stat:SetParent(Text:GetParent()) 19 20 local TANK_ICON = "|TInterface\\LFGFRAME\\UI-LFG-ICON-PORTRAITROLES.blp:14:14:0:0:64:64:0:18:22:40|t" 21 local HEALER_ICON = "|TInterface\\LFGFRAME\\UI-LFG-ICON-PORTRAITROLES.blp:14:14:0:0:64:64:20:38:1:19|t" 22 local DPS_ICON = "|TInterface\\LFGFRAME\\UI-LFG-ICON-PORTRAITROLES.blp:14:14:0:0:64:64:20:38:22:40|t" 23 24 local function MakeIconString(tank, healer, damage) 25 local str = "" 26 if tank then 27 str = str..TANK_ICON 28 end 29 if healer then 30 str = str..HEALER_ICON 31 end 32 if damage then 33 str = str..DPS_ICON 34 end 35 36 return str 37 end 38 39 local function OnEvent(self, event, ...) 40 local tankReward = false 41 local healerReward = false 42 local dpsReward = false 43 local unavailable = true 44 for i=1, GetNumRandomDungeons() do 45 local id, name = GetLFGRandomDungeonInfo(i) 46 for x = 1,LFG_ROLE_NUM_SHORTAGE_TYPES do 47 local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x) 48 if eligible then unavailable = false end 49 if eligible and forTank and itemCount > 0 then tankReward = true end 50 if eligible and forHealer and itemCount > 0 then healerReward = true end 51 if eligible and forDamage and itemCount > 0 then dpsReward = true end 52 end 53 end 54 55 if unavailable then 56 Text:SetText(QUEUE_TIME_UNAVAILABLE) 57 else 58 Text:SetText(BATTLEGROUND_HOLIDAY..":"..MakeIconString(tankReward, healerReward, dpsReward)) 59 end 60 61 self:SetAllPoints(Text) 62 end 63 64 local function OnEnter(self) 65 local anchor, panel, xoff, yoff = T.DataTextTooltipAnchor(Text) 66 GameTooltip:SetOwner(panel, anchor, xoff, yoff) 67 GameTooltip:ClearLines() 68 GameTooltip:AddLine(BATTLEGROUND_HOLIDAY) 69 GameTooltip:AddLine(' ') 70 71 local allUnavailable = true 72 local numCTA = 0 73 for i=1, GetNumRandomDungeons() do 74 local id, name = GetLFGRandomDungeonInfo(i) 75 local tankReward = false 76 local healerReward = false 77 local dpsReward = false 78 local unavailable = true 79 for x=1, LFG_ROLE_NUM_SHORTAGE_TYPES do 80 local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x) 81 if eligible then unavailable = false end 82 if eligible and forTank and itemCount > 0 then tankReward = true end 83 if eligible and forHealer and itemCount > 0 then healerReward = true end 84 if eligible and forDamage and itemCount > 0 then dpsReward = true end 85 end 86 if not unavailable then 87 allUnavailable = false 88 local rolesString = MakeIconString(tankReward, healerReward, dpsReward) 89 if rolesString ~= "" then 90 GameTooltip:AddDoubleLine(name..":", rolesString, 1, 1, 1) 91 end 92 if tankReward or healerReward or dpsReward then numCTA = numCTA + 1 end 93 end 94 end 95 96 if allUnavailable then 97 GameTooltip:AddLine(L.datatext_cta_allunavailable) 98 elseif numCTA == 0 then 99 GameTooltip:AddLine(L.datatext_cta_nodungeons) 100 end 101 GameTooltip:Show() 102 end 103 104 Stat:RegisterEvent("LFG_UPDATE_RANDOM_INFO") 105 Stat:RegisterEvent("PLAYER_LOGIN") 106 Stat:SetScript("OnEvent", OnEvent) 107 Stat:SetScript("OnMouseDown", function() ToggleFrame(LFDParentFrame) end) 108 Stat:SetScript("OnEnter", OnEnter) 109 Stat:SetScript("OnLeave", function() GameTooltip:Hide() end) 110end