2021-03-27 12:03:41 +00:00
|
|
|
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
|
|
|
|
|
2022-12-03 16:43:10 +00:00
|
|
|
local LFG_EYE_TEXTURES = { };
|
|
|
|
LFG_EYE_TEXTURES["default"] = { file = "Interface\\LFGFrame\\LFG-Eye", width = 512, height = 256, frames = 29, iconSize = 64, delay = 0.1 };
|
|
|
|
LFG_EYE_TEXTURES["raid"] = { file = "Interface\\LFGFrame\\LFR-Anim", width = 256, height = 256, frames = 16, iconSize = 64, delay = 0.05 };
|
|
|
|
LFG_EYE_TEXTURES["unknown"] = { file = "Interface\\LFGFrame\\WaitAnim", width = 128, height = 128, frames = 4, iconSize = 64, delay = 0.25 };
|
2021-03-27 12:03:41 +00:00
|
|
|
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
|
|
|
|
}
|
2022-12-09 14:51:31 +00:00
|
|
|
for _, t in pairs(LFG_EYE_TEXTURES) do
|
|
|
|
local cols = floor(t.width / t.iconSize)
|
|
|
|
local colWidth = t.iconSize / t.width
|
|
|
|
local rowHeight = t.iconSize / t.height
|
2021-03-27 12:03:41 +00:00
|
|
|
|
2022-12-09 14:51:31 +00:00
|
|
|
local iconCoords = { }
|
|
|
|
for i = 1, t.frames do
|
|
|
|
local L = mod(i - 1, cols) * colWidth
|
|
|
|
local R = L + colWidth
|
|
|
|
local T = ceil(i / cols) * rowHeight
|
|
|
|
local B = T - rowHeight
|
|
|
|
|
|
|
|
iconCoords[i] = { L, R, B, T }
|
|
|
|
end
|
|
|
|
t.iconCoords = iconCoords
|
|
|
|
end
|
2021-03-27 21:45:59 +00:00
|
|
|
function child:GetQueueInfo()
|
2021-03-27 12:03:41 +00:00
|
|
|
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)
|
2021-03-27 21:45:59 +00:00
|
|
|
local queueType, queueStatus = child:GetQueueInfo()
|
2021-03-27 12:03:41 +00:00
|
|
|
|
|
|
|
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
|
2022-12-09 14:51:31 +00:00
|
|
|
currentFrame = 1
|
2021-03-27 12:03:41 +00:00
|
|
|
if queueType then
|
|
|
|
self:SetScript("OnUpdate", UpdateIconCoords)
|
|
|
|
else
|
|
|
|
self:SetScript("OnUpdate", nil)
|
|
|
|
child:SetIconCoords(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] = {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-09 14:51:31 +00:00
|
|
|
local function OnEvent3(self, event)
|
|
|
|
print(event)
|
|
|
|
end
|
2021-03-27 12:03:41 +00:00
|
|
|
function events:PLAYER_ENTERING_WORLD(event)
|
|
|
|
child:UnregisterEvent('PLAYER_ENTERING_WORLD')
|
|
|
|
local QSF = CreateFrame("Frame")
|
2022-12-03 16:43:10 +00:00
|
|
|
Mixin(QSF, QueueStatusFrameMixin)
|
2022-12-09 14:51:31 +00:00
|
|
|
QSF:OnLoad()
|
|
|
|
QSF:HookScript("OnEvent", OnEvent)
|
2021-03-27 12:03:41 +00:00
|
|
|
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(...)
|