-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcore.lua
More file actions
48 lines (44 loc) · 1.77 KB
/
core.lua
File metadata and controls
48 lines (44 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- Declare function to automatically apply to a group
local function SignUp(button)
-- If an application is already open, do not continue
if (button.isApplication) then return end
-- Click the "SignUp" Button on the LFG frame
LFGListSearchPanel_SignUp(button:GetParent():GetParent():GetParent())
-- Click the "SignUp" Button on the Role Select dialog
LFGListApplicationDialog.SignUpButton:Click()
end
-- Declare DoubleClick event handler function
local function OnDoubleClick(button, buttonName)
-- When the player is not in a group, or is the leader of the group
if (buttonName == "LeftButton" and (IsInGroup() ~= true or UnitIsGroupLeader("player") == true)) then
-- Run function to apply to the group
SignUp(button)
end
end
local function AddDoubleClickHook(frame)
frame:SetScript("OnDoubleClick", OnDoubleClick)
end
local function LogError(msg)
error("Failed to set double click script")
end
-- Create EventFrame
local EventFrame = CreateFrame("Frame", "EventFrame")
-- Add Event Handler for LFG Search Results Displayed
EventFrame:RegisterEvent("LFG_LIST_SEARCH_RESULTS_RECEIVED")
EventFrame:RegisterEvent("LFG_ROLE_CHECK_SHOW")
-- Set function for event
EventFrame:SetScript("OnEvent", function(self, event, ...)
-- Only continue if event matches exactly
if (event == "LFG_LIST_SEARCH_RESULTS_RECEIVED") then
-- Get the LFGList "frames" ie list of groups
local frames = LFGListFrame.SearchPanel.ScrollBox:GetView():GetFrames();
-- Loop through all groups/listings
for _, frame in ipairs(frames) do
-- Set DoubleClick event handler but log any errors
xpcall(AddDoubleClickHook, LogError, frame)
end
elseif (event == "LFG_ROLE_CHECK_SHOW") then
-- Complete the role check if somebody else in your group applies to an LFG group
CompleteLFGRoleCheck(true)
end
end)