Skip to content

Commit b8dfa85

Browse files
committed
Add functions for toggling spotlight frames
1 parent 8a10042 commit b8dfa85

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

RaidFrames/Groups/SpotlightFrame.lua

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,24 @@ function unit:SetUnit(index, target)
398398
F:Print(L["Invalid unit."])
399399
end
400400
end
401+
function spotlightFrame:ToggleUnit(target)
402+
local firstAvailable
403+
for i, f in pairs(Cell.unitButtons.spotlight) do
404+
local unit = f:GetAttribute("unit")
405+
if not unit and not firstAvailable then
406+
firstAvailable = i
407+
end
408+
if unit and unit == target then
409+
f:SetAttribute("unit", nil)
410+
f:SetAttribute("refreshOnUpdate", nil)
411+
f:SetAttribute("updateOnTargetChanged", nil)
412+
assignmentButtons[i]:SetText("none")
413+
menu:Save(i, nil)
414+
return
415+
end
416+
end
417+
unit:SetUnit(firstAvailable, target)
418+
end
401419

402420
unitname = Cell:CreateButton(menu, L["Unit's Name"], "transparent-accent", {20, 20}, true, false, nil, nil, "SecureHandlerAttributeTemplate,SecureHandlerClickTemplate")
403421
P:Point(unitname, "TOPLEFT", unit, "BOTTOMLEFT")
@@ -431,6 +449,32 @@ function unitname:SetUnit(index, target)
431449
F:Print(L["Invalid unit."])
432450
end
433451
end
452+
function spotlightFrame:ToggleUnitName(target)
453+
local unitId = F:GetTargetUnitID(target)
454+
if unitId and (UnitIsPlayer(unitId) or UnitInPartyIsAI(unitId)) then
455+
local name = GetUnitName(unitId, true)
456+
local existing = names[name]
457+
if existing then
458+
local f = Cell.unitButtons.spotlight[existing]
459+
f:SetAttribute("unit", nil)
460+
f:SetAttribute("refreshOnUpdate", nil)
461+
f:SetAttribute("updateOnTargetChanged", nil)
462+
assignmentButtons[existing]:SetText("none")
463+
menu:Save(existing, nil)
464+
return
465+
end
466+
467+
for i, f in pairs(Cell.unitButtons.spotlight) do
468+
local unit = f:GetAttribute("unit")
469+
if not unit then
470+
unitname:SetUnit(i, target)
471+
return
472+
end
473+
end
474+
else
475+
F:Print(L["Invalid unit."])
476+
end
477+
end
434478

435479
unitpet = Cell:CreateButton(menu, L["Unit's Pet"], "transparent-accent", {20, 20}, true, false, nil, nil, "SecureHandlerAttributeTemplate,SecureHandlerClickTemplate")
436480
P:Point(unitpet, "TOPLEFT", unitname, "BOTTOMLEFT")
@@ -982,4 +1026,4 @@ local function UpdateAppearance(which)
9821026
end)
9831027
end
9841028
end
985-
Cell:RegisterCallback("UpdateAppearance", "SpotlightFrame_UpdateAppearance", UpdateAppearance)
1029+
Cell:RegisterCallback("UpdateAppearance", "SpotlightFrame_UpdateAppearance", UpdateAppearance)

0 commit comments

Comments
 (0)