Clean up code
This commit is contained in:
parent
c13d56a05b
commit
a722502e4a
22
broker.lua
22
broker.lua
|
@ -3,6 +3,22 @@ local childName = addon['childName']
|
|||
local child = addon[childName]
|
||||
local zzLDB = LibStub:GetLibrary("zzLDB")
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
|
||||
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
|
||||
|
||||
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
|
||||
local function GetScreenHalf()
|
||||
local _, y = GetCursorPosition()
|
||||
if y * 2 > UIParent:GetHeight() then
|
||||
|
@ -45,7 +61,7 @@ local actions = {
|
|||
}
|
||||
|
||||
local function OnClick(self, button)
|
||||
if button == "RightButton" and GetQueueInfo() and not IsShiftKeyDown() then
|
||||
if button == "RightButton" and child:GetQueueInfo() and not IsShiftKeyDown() then
|
||||
PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
|
||||
local screenHalf = GetScreenHalf()
|
||||
QueueStatusMinimapButtonDropDown.point = screenHalf == "TOP" and "TOPLEFT" or "BOTTOMLEFT"
|
||||
|
@ -64,7 +80,7 @@ local function OnClick(self, button)
|
|||
end
|
||||
end
|
||||
local function OnEnter(self,...)
|
||||
if GetQueueInfo() and not QueueStatusFrame:IsVisible() then
|
||||
if child:GetQueueInfo() and not QueueStatusFrame:IsVisible() then
|
||||
QueueStatusFrame:Show()
|
||||
QueueStatusFrame:SetParent(UIParent)
|
||||
QueueStatusFrame:SetClampedToScreen(true)
|
||||
|
@ -111,7 +127,7 @@ child['ldb'] = {
|
|||
['OnEnter'] = OnEnter,
|
||||
['OnLeave'] = OnLeave,
|
||||
['OnClick'] = OnClick,
|
||||
}
|
||||
}
|
||||
local init = {
|
||||
Setup = function(self, childName, event)
|
||||
-- print("setup ldb", childName, event)
|
||||
|
|
19
core.lua
19
core.lua
|
@ -9,22 +9,7 @@ local function prepareDB()
|
|||
child['db'] = db
|
||||
addon['callbacks']:Fire(format("Init%s", childName))
|
||||
end
|
||||
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
|
||||
|
||||
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
|
||||
local currentQueueType
|
||||
local currentFrame = 1
|
||||
local currentIcon = LFG_EYE_TEXTURES.default
|
||||
|
@ -40,7 +25,7 @@ local queueTypes = {
|
|||
"pvp" -- World PVP
|
||||
}
|
||||
|
||||
local function GetQueueInfo()
|
||||
function child:GetQueueInfo()
|
||||
for i = 1, NUM_LE_LFG_CATEGORYS do
|
||||
local mode, submode = GetLFGMode(i)
|
||||
if mode then
|
||||
|
@ -80,7 +65,7 @@ local function UpdateIconCoords(self, elapsed)
|
|||
end
|
||||
end
|
||||
local function OnEvent(self, event)
|
||||
local queueType, queueStatus = GetQueueInfo()
|
||||
local queueType, queueStatus = child:GetQueueInfo()
|
||||
|
||||
if queueType and queueStatus ~= "queued" then
|
||||
queueType = nil
|
||||
|
|
Loading…
Reference in New Issue