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