Implement some sort of semi automatic kicking from group
By overlaying a button over the existing button... Not great but the best we can do
This commit is contained in:
@@ -25,8 +25,77 @@ function shared.Inviter.Init()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local framePool = {}
|
||||||
|
---@param name string
|
||||||
|
local function OverlayKickButtonElvUI(name)
|
||||||
|
for group = 1, 8 do
|
||||||
|
for player = 1, 5 do
|
||||||
|
local button = _G[string.format("ElvUF_RaidGroup%dUnitButton%d", group, player)]
|
||||||
|
|
||||||
|
local unitName = button and button.unit and UnitName(button.unit)
|
||||||
|
if unitName == name then
|
||||||
|
local overlayButton = framePool[button.unit] or
|
||||||
|
CreateFrame("Button",
|
||||||
|
string.format("HeimdallKickButton%s", button.unit, button, "SecureActionButtonTemplate"))
|
||||||
|
framePool[button.unit] = overlayButton
|
||||||
|
|
||||||
|
overlayButton:SetSize(button.UNIT_WIDTH/2, button.UNIT_HEIGHT/2)
|
||||||
|
overlayButton:SetPoint("CENTER", button, "CENTER", 0, 0)
|
||||||
|
overlayButton:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
||||||
|
overlayButton:SetHighlightTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
||||||
|
overlayButton:SetPushedTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
||||||
|
overlayButton:SetDisabledTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
|
||||||
|
overlayButton:SetAlpha(0.5)
|
||||||
|
overlayButton:Show()
|
||||||
|
overlayButton:SetScript("OnClick", function()
|
||||||
|
UninviteUnit(name)
|
||||||
|
overlayButton:Hide()
|
||||||
|
end)
|
||||||
|
-- button:SetAttribute("type", "macro")
|
||||||
|
-- button:SetAttribute("macrotext", "/kick " .. unit)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@type table<string, number>
|
||||||
local groupMembers = {}
|
local groupMembers = {}
|
||||||
local function CleanGroups()
|
local function CleanGroups()
|
||||||
|
print("Cleaning groups")
|
||||||
|
local now = GetTime()
|
||||||
|
for i = 1, 40 do
|
||||||
|
local unit = "raid" .. i
|
||||||
|
if UnitExists(unit) then
|
||||||
|
local name = UnitName(unit)
|
||||||
|
if name then
|
||||||
|
-- When we load (into game) we want to consider everyone "online"
|
||||||
|
-- In other words everyone we haven't seen before is "online" the first time we see them
|
||||||
|
-- This is to avoid kicking people who might not be offline which we don't know because we just logged in
|
||||||
|
if not groupMembers[name] then
|
||||||
|
groupMembers[name] = now
|
||||||
|
else
|
||||||
|
local online = UnitIsConnected(unit)
|
||||||
|
if online then
|
||||||
|
groupMembers[name] = now
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for name, time in pairs(groupMembers) do
|
||||||
|
print(string.format("Checking %s - %d", name, time))
|
||||||
|
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
|
||||||
|
print(string.format("%s no longer in party", name))
|
||||||
|
groupMembers[name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
local function Tick()
|
local function Tick()
|
||||||
CleanGroups()
|
CleanGroups()
|
||||||
|
|||||||
Reference in New Issue
Block a user