@@ -398,6 +398,24 @@ function unit:SetUnit(index, target)
398398 F :Print (L [" Invalid unit." ])
399399 end
400400end
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
402420unitname = Cell :CreateButton (menu , L [" Unit's Name" ], " transparent-accent" , {20 , 20 }, true , false , nil , nil , " SecureHandlerAttributeTemplate,SecureHandlerClickTemplate" )
403421P :Point (unitname , " TOPLEFT" , unit , " BOTTOMLEFT" )
@@ -431,6 +449,32 @@ function unitname:SetUnit(index, target)
431449 F :Print (L [" Invalid unit." ])
432450 end
433451end
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
435479unitpet = Cell :CreateButton (menu , L [" Unit's Pet" ], " transparent-accent" , {20 , 20 }, true , false , nil , nil , " SecureHandlerAttributeTemplate,SecureHandlerClickTemplate" )
436480P :Point (unitpet , " TOPLEFT" , unitname , " BOTTOMLEFT" )
@@ -982,4 +1026,4 @@ local function UpdateAppearance(which)
9821026 end )
9831027 end
9841028end
985- Cell :RegisterCallback (" UpdateAppearance" , " SpotlightFrame_UpdateAppearance" , UpdateAppearance )
1029+ Cell :RegisterCallback (" UpdateAppearance" , " SpotlightFrame_UpdateAppearance" , UpdateAppearance )
0 commit comments