139 lines
4.6 KiB
Lua
Executable File
139 lines
4.6 KiB
Lua
Executable File
local addonName, addon = ...
|
|
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
|
|
return "TOP"
|
|
else
|
|
return "BOTTOM"
|
|
end
|
|
end
|
|
local actions = {
|
|
{
|
|
text = L["Click to open the Dungeon Finder."],
|
|
enabled = function() return C_LFGInfo.CanPlayerUseLFD() end,
|
|
selected = function(button) return button == "LeftButton" and not IsModifierKeyDown() end,
|
|
func = function() PVEFrame_ToggleFrame("GroupFinderFrame", LFDParentFrame) end,
|
|
},
|
|
{
|
|
text = L["Alt-Click to open the Raid Finder."],
|
|
enabled = function() return C_LFGInfo.CanPlayerUseLFR() end,
|
|
selected = function(button) return button == "LeftButton" and IsAltKeyDown() end,
|
|
func = function() PVEFrame_ToggleFrame("GroupFinderFrame", RaidFinderFrame) end,
|
|
},
|
|
{
|
|
text = L["Ctrl-Click to open the Premade Groups window."],
|
|
enabled = function() return not IsTrialAccount() end,
|
|
selected = function(button) return button == "LeftButton" and IsControlKeyDown() end,
|
|
func = function() PVEFrame_ToggleFrame("GroupFinderFrame", LFGListPVEStub) end,
|
|
},
|
|
{
|
|
text = L["Right-Click to open the PVP window."],
|
|
enabled = function() return C_LFGInfo.CanPlayerUsePVP() end,
|
|
selected = function(button) return button == "RightButton" end,
|
|
func = function() TogglePVPUI() end,
|
|
},
|
|
{
|
|
text = L["Middle-Click or Shift-Click to open the Pet Journal."],
|
|
enabled = function() return C_PetJournal.IsFindBattleEnabled() and C_PetJournal.IsJournalUnlocked() end,
|
|
selected = function(button) return button == "MiddleButton" or (button == "LeftButton" and IsShiftKeyDown()) end,
|
|
func = function() ToggleCollectionsJournal(2) end,
|
|
},
|
|
}
|
|
|
|
local function OnClick(self, button)
|
|
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"
|
|
QueueStatusMinimapButtonDropDown.relativePoint = screenHalf == "TOP" and "BOTTOMLEFT" or "TOPLEFT"
|
|
ToggleDropDownMenu(1, nil, QueueStatusMinimapButtonDropDown, self, 0, 0)
|
|
else
|
|
for i = 1, #actions do
|
|
local action = actions[i]
|
|
if action.selected(button) then
|
|
if action.enabled() then
|
|
action.func()
|
|
end
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
local function OnEnter(self,...)
|
|
if child:GetQueueInfo() and not QueueStatusFrame:IsVisible() then
|
|
QueueStatusFrame:Show()
|
|
QueueStatusFrame:SetParent(UIParent)
|
|
QueueStatusFrame:SetClampedToScreen(true)
|
|
QueueStatusFrame:SetFrameStrata("TOOLTIP")
|
|
QueueStatusFrame:ClearAllPoints()
|
|
if GetScreenHalf() == "TOP" then
|
|
QueueStatusFrame:SetPoint("TOP", self, "BOTTOM", 0, -5)
|
|
else
|
|
QueueStatusFrame:SetPoint("BOTTOM", self, "TOP", 0, 5)
|
|
end
|
|
else
|
|
GameTooltip:SetOwner(self, "ANCHOR_BOTTOM")
|
|
GameTooltip:ClearLines()
|
|
GameTooltip:SetText(L["LFG"])
|
|
for i = 1, #actions do
|
|
if actions[i].enabled() then
|
|
GameTooltip:AddLine(actions[i].text, 1, 1, 1)
|
|
end
|
|
end
|
|
GameTooltip:Show()
|
|
end
|
|
end
|
|
local function OnLeave(self)
|
|
QueueStatusFrame:Hide()
|
|
GameTooltip:Hide()
|
|
end
|
|
function child:SetIcon(icon)
|
|
local ldbobj = zzLDB:GetLDB(childName)
|
|
ldbobj['icon'] = icon
|
|
end
|
|
function child:SetIconCoords(iconCoords)
|
|
local ldbobj = zzLDB:GetLDB(childName)
|
|
ldbobj['iconCoords'] = iconCoords
|
|
end
|
|
function child:GetLabel()
|
|
local ldbobj = zzLDB:GetLDB(childName)
|
|
return ldbobj['label']
|
|
end
|
|
child['ldb'] = {
|
|
['type'] = "data source", -- 'data source | launcher'
|
|
['icon'] = "Interface\\LFGFrame\\LFG-Eye",
|
|
['text'] = L.LFG,
|
|
['iconCoords'] = LFG_EYE_TEXTURES.default.iconCoords[1],
|
|
['OnEnter'] = OnEnter,
|
|
['OnLeave'] = OnLeave,
|
|
['OnClick'] = OnClick,
|
|
}
|
|
local init = {
|
|
Setup = function(self, childName, event)
|
|
-- print("setup ldb", childName, event)
|
|
if(child['ldb']['type'] == 'data source') then
|
|
child.OnText = zzLDB.DefaultOnText
|
|
end
|
|
end
|
|
}
|
|
addon.RegisterCallback(init, format("Init%s", childName), 'Setup', childName) |