local addonName, addon = ... local childName = addon['childName'] local child = addon[childName] local events = child['events'] local db local L = LibStub("AceLocale-3.0"):GetLocale(childName, true) local function prepareDB() db = addon['db']['profile'][childName] child['db'] = db addon['callbacks']:Fire(format("Init%s", childName)) end local currentQueueType local currentFrame = 1 local currentIcon = LFG_EYE_TEXTURES.default local iconCoords = currentIcon.iconCoords local updateDelay = currentIcon.delay local counter = 0 local queueTypes = { "dungeon", -- Dungeon Finder "raid", -- Other Raids "raid", -- Raid Finder "scenario", -- Scenarios "raid", -- Flex Raid "pvp" -- World PVP } function child:GetQueueInfo() for i = 1, NUM_LE_LFG_CATEGORYS do local mode, submode = GetLFGMode(i) if mode then return queueTypes[i], mode, submode, i end end for i = 1, GetMaxBattlefieldID() do local status = GetBattlefieldStatus(i) if status and status ~= "none" then return "pvp", status end end for i = 1, MAX_WORLD_PVP_QUEUES do local status = GetWorldPVPQueueStatus(i) if status and status ~= "none" then return "pvp", status end end local status = C_PetBattles.GetPVPMatchmakingInfo() if status then return "petbattle", status end end local function UpdateIconCoords(self, elapsed) counter = counter + elapsed if counter > updateDelay then if currentFrame > currentIcon.frames then currentFrame = 1 end -- ldbobj['iconCoords'] = iconCoords[currentFrame] or iconCoords[1] child:SetIconCoords(iconCoords[currentFrame] or iconCoords[1]) currentFrame = currentFrame + 1 counter = 0 end end local function OnEvent(self, event) local queueType, queueStatus = child:GetQueueInfo() if queueType and queueStatus ~= "queued" then queueType = nil end if queueType == currentQueueType then return end currentQueueType = queueType currentIcon = queueType and LFG_EYE_TEXTURES[queueType] or LFG_EYE_TEXTURES.default iconCoords = currentIcon.iconCoords updateDelay = currentIcon.delay child:SetIcon(currentIcon.file) -- ldbobj['icon'] = currentIcon.file if queueType then currentFrame = 1 self:SetScript("OnUpdate", UpdateIconCoords) else self:SetScript("OnUpdate", nil) currentFrame = 1 child:SetIconCoords(iconCoords[1]) -- ldbobj['iconCoords'] = iconCoords[1] end end local function OnEvent2(lib, event) local mode, _ = GetLFGMode(LE_LFG_CATEGORY_LFD) local label = child:GetLabel() if(mode == 'queued') then local hasData, _, tankNeeds, healerNeeds, dpsNeeds, _ = GetLFGQueueStats(LE_LFG_CATEGORY_LFD) if(hasData) then local newtext = "" if(tankNeeds > 0) then newtext = "T" end if(healerNeeds > 0) then newtext = newtext .. "H" end if(dpsNeeds > 0) then for i = 1, dpsNeeds do newtext = newtext .. "D" end end -- ldbobj['text'] = newtext == "" and ldbobj['label'] or format(("|cffFF3300%s|r"),newtext) child:OnText(childName, newtext == "" and label or format(("|cffFF3300%s|r"), newtext)) else child:OnText(childName, label) -- ldbobj['text'] = ldbobj['label'] end else child:OnText(childName, label) -- ldbobj['text'] = ldbobj['label'] end end child['specs'] = { ['name'] = childName, ['sv'] = true, ['cfg'] = true, ['cfgReset'] = prepareDB, ['ldb'] = child['ldb'], ['defaults'] = { ['profile'] = { [childName] = {} } } } function events:PLAYER_ENTERING_WORLD(event) child:UnregisterEvent('PLAYER_ENTERING_WORLD') local QSF = CreateFrame("Frame") QueueStatusFrame_OnLoad(QSF) QSF:SetScript("OnEvent", OnEvent) child:RegisterEvent({"LFG_UPDATE", "LFG_ROLE_CHECK_UPDATE", "LFG_PROPOSAL_UPDATE", "LFG_PROPOSAL_FAILED", "LFG_PROPOSAL_SUCCEEDED", "LFG_PROPOSAL_SHOW", "LFG_QUEUE_STATUS_UPDATE"}, OnEvent2) end child:NewAddOn(...)