Fix inviter kick buttons
This commit is contained in:
@@ -64,50 +64,61 @@ function shared.Inviter.Init()
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param name string
|
---@param name string
|
||||||
---Kicking people or othwerise people leaving will fuck up the buttons
|
---@return Frame?
|
||||||
---We should make them reactive to GROUP_ROSTER_UPDATE
|
local function FindPlayerRaidFrame(name)
|
||||||
---But that is currently not trivial and would require some work
|
|
||||||
---Since I'm the only one currently using this - I don't care where the buttons are
|
|
||||||
local function OverlayKickButtonElvUI(name)
|
|
||||||
if Heimdall_Data.config.inviter.debug then
|
|
||||||
print(string.format("[%s] OverlayKickButtonElvUI", ModuleName))
|
|
||||||
shared.dumpTable(Heimdall_Data.config.inviter)
|
|
||||||
end
|
|
||||||
for group = 1, 8 do
|
for group = 1, 8 do
|
||||||
for player = 1, 5 do
|
for player = 1, 5 do
|
||||||
local button = _G[string.format("ElvUF_RaidGroup%dUnitButton%d", group, player)]
|
local button = _G[string.format("ElvUF_RaidGroup%dUnitButton%d", group, player)]
|
||||||
if Heimdall_Data.config.inviter.debug then
|
if Heimdall_Data.config.inviter.debug then
|
||||||
print(string.format("[%s] button = %s", ModuleName, button))
|
print(string.format("[%s] button = %s", ModuleName, tostring(button)))
|
||||||
end
|
end
|
||||||
|
|
||||||
local unitName = button and button.unit and UnitName(button.unit)
|
local unitName = button and button.unit and UnitName(button.unit)
|
||||||
if Heimdall_Data.config.inviter.debug then
|
if Heimdall_Data.config.inviter.debug then
|
||||||
print(string.format("[%s] unitName = %s", ModuleName, unitName))
|
print(string.format("[%s] unitName = %s", ModuleName, tostring(unitName)))
|
||||||
end
|
end
|
||||||
if unitName == name then
|
if unitName == name then
|
||||||
if Heimdall_Data.config.inviter.debug then
|
if Heimdall_Data.config.inviter.debug then
|
||||||
print(string.format("[%s] unitName == name", ModuleName))
|
print(string.format("[%s] unitName == name", ModuleName))
|
||||||
end
|
end
|
||||||
local overlayButton = framePool[button.unit] or
|
return button
|
||||||
CreateFrame("Button",
|
end
|
||||||
string.format("HeimdallKickButton%s", button.unit, button, "SecureActionButtonTemplate"))
|
end
|
||||||
framePool[button.unit] = overlayButton
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
overlayButton:SetSize(button.UNIT_WIDTH / 2, button.UNIT_HEIGHT / 2)
|
local framePool = {}
|
||||||
overlayButton:SetPoint("CENTER", button, "CENTER", 0, 0)
|
local playerButtons = {}
|
||||||
overlayButton:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
setmetatable(playerButtons, { __mode = "kv" })
|
||||||
overlayButton:SetHighlightTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
---@param players string[]
|
||||||
overlayButton:SetPushedTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
local function OverlayKickButtons(players)
|
||||||
overlayButton:SetDisabledTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
for _, frame in pairs(framePool) do
|
||||||
overlayButton:SetAlpha(0.5)
|
frame:Hide()
|
||||||
overlayButton:Show()
|
end
|
||||||
overlayButton:SetScript("OnClick", function()
|
for _, name in pairs(players) do
|
||||||
UninviteUnit(name)
|
local frame = FindPlayerRaidFrame(name)
|
||||||
overlayButton:Hide()
|
if frame then
|
||||||
end)
|
playerButtons[name] = frame
|
||||||
-- button:SetAttribute("type", "macro")
|
local button = framePool[frame.unit] or CreateFrame("Button",
|
||||||
-- button:SetAttribute("macrotext", "/kick " .. unit)
|
string.format("HeimdallKickButton%s", frame.unit, frame, "SecureActionButtonTemplate"))
|
||||||
return
|
framePool[frame.unit] = button
|
||||||
|
|
||||||
|
button:SetSize(frame.UNIT_WIDTH / 2, frame.UNIT_HEIGHT / 2)
|
||||||
|
button:SetPoint("CENTER", frame, "CENTER", 0, 0)
|
||||||
|
button:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
||||||
|
button:SetHighlightTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
||||||
|
button:SetPushedTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
||||||
|
button:SetDisabledTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
||||||
|
button:SetAlpha(0.5)
|
||||||
|
button:Show()
|
||||||
|
button:SetScript("OnClick", function()
|
||||||
|
UninviteUnit(name)
|
||||||
|
button:Hide()
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
if Heimdall_Data.config.inviter.debug then
|
||||||
|
print(string.format("[%s] Frame for player %s not found", ModuleName, name))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -138,18 +149,21 @@ function shared.Inviter.Init()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local afkPlayers = {}
|
||||||
for name, time in pairs(groupMembers) do
|
for name, time in pairs(groupMembers) do
|
||||||
if time < now - Heimdall_Data.config.inviter.afkThreshold then
|
|
||||||
print(string.format("Kicking %s for being offline", name))
|
|
||||||
-- Blyat this is protected...
|
|
||||||
-- UninviteUnit(name)
|
|
||||||
OverlayKickButtonElvUI(name)
|
|
||||||
end
|
|
||||||
if not UnitInParty(name) then
|
if not UnitInParty(name) then
|
||||||
print(string.format("%s no longer in party", name))
|
print(string.format("%s no longer in party", name))
|
||||||
groupMembers[name] = nil
|
groupMembers[name] = nil
|
||||||
|
else
|
||||||
|
if time < now - Heimdall_Data.config.inviter.afkThreshold then
|
||||||
|
print(string.format("Kicking %s for being offline", name))
|
||||||
|
afkPlayers[#afkPlayers + 1] = name
|
||||||
|
-- Blyat this is protected...
|
||||||
|
-- UninviteUnit(name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
OverlayKickButtons(afkPlayers)
|
||||||
end
|
end
|
||||||
local function Tick()
|
local function Tick()
|
||||||
CleanGroups()
|
CleanGroups()
|
||||||
@@ -181,10 +195,10 @@ function shared.Inviter.Init()
|
|||||||
local inviterChannelFrame = CreateFrame("Frame")
|
local inviterChannelFrame = CreateFrame("Frame")
|
||||||
inviterChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
inviterChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||||
inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||||
-- if Heimdall_Data.config.inviter.debug then
|
--if Heimdall_Data.config.inviter.debug then
|
||||||
-- print(string.format("[%s] Chat message received: %s", ModuleName, msg))
|
-- print(string.format("[%s] Chat message received: %s", ModuleName, msg))
|
||||||
-- shared.dumpTable(Heimdall_Data.config.inviter)
|
-- shared.dumpTable(Heimdall_Data.config.inviter)
|
||||||
-- end
|
--end
|
||||||
if not Heimdall_Data.config.inviter.enabled then return end
|
if not Heimdall_Data.config.inviter.enabled then return end
|
||||||
local channelId = select(6, ...)
|
local channelId = select(6, ...)
|
||||||
local _, channelname = GetChannelName(channelId)
|
local _, channelname = GetChannelName(channelId)
|
||||||
|
|||||||
Reference in New Issue
Block a user