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) 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 }; local LFG_ANGER_INC_VAL = 30; local LFG_ANGER_DEC_VAL = 1; local LFG_ANGER_INIT_VAL = 60; local LFG_ANGER_END_VAL = 75; local LFG_ANGER_CAP_VAL = 90; 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() local inBattlefield, showScoreboard = QueueStatus_InActiveBattlefield(); if ( IsInLFDBattlefield() ) then inBattlefield = true; showScoreboard = true; end local lfgListActiveEntry = C_LFGList.HasActiveEntryInfo(); if ( inBattlefield ) then if ( showScoreboard ) then TogglePVPScoreboardOrResults(); end elseif ( lfgListActiveEntry ) then LFGListUtil_OpenBestWindow(true); else --See if we have any active LFGList applications local apps = C_LFGList.GetApplications(); for i=1, #apps do local _, appStatus = C_LFGList.GetApplicationInfo(apps[i]); if ( appStatus == "applied" or appStatus == "invited" ) then --We want to open to the LFGList screen LFGListUtil_OpenBestWindow(true); return; end end PVEFrame_ToggleFrame("GroupFinderFrame", LFDParentFrame) end 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() QueueStatusButtonDropDown.point = screenHalf == "TOP" and "TOPLEFT" or "BOTTOMLEFT" QueueStatusButtonDropDown.relativePoint = screenHalf == "TOP" and "BOTTOMLEFT" or "TOPLEFT" ToggleDropDownMenu(1, nil, QueueStatusButtonDropDown, 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)