@@ -473,6 +473,117 @@ function DF:GetUnitName(unit)
473473 return UnitName (unit ) or unit
474474end
475475
476+ -- Update name text on a frame - uses GetUnitName which can be overridden
477+ function DF :UpdateNameText (frame )
478+ if not frame or not frame .nameText or not frame .unit then return end
479+
480+ local unit = frame .unit
481+ local db = frame .isRaidFrame and DF :GetRaidDB () or DF :GetDB ()
482+
483+ -- Get name using the overridable method
484+ local name = DF :GetUnitName (unit ) or unit
485+
486+ -- Apply truncation if configured (UTF-8 aware)
487+ local nameLength = db .nameTextLength or 0
488+ if nameLength > 0 and name and DF :UTF8Len (name ) > nameLength then
489+ if db .nameTextTruncateMode == " ELLIPSIS" then
490+ name = DF :UTF8Sub (name , 1 , nameLength ) .. " ..."
491+ else
492+ name = DF :UTF8Sub (name , 1 , nameLength )
493+ end
494+ end
495+
496+ frame .nameText :SetText (name )
497+
498+ -- Get class for class-colored elements
499+ local _ , class = UnitClass (unit )
500+ local classColor = class and DF :GetClassColor (class )
501+
502+ -- Apply name color
503+ if db .nameTextUseClassColor and classColor then
504+ frame .nameText :SetTextColor (classColor .r , classColor .g , classColor .b , 1 )
505+ else
506+ local nameColor = db .nameTextColor or {r = 1 , g = 1 , b = 1 }
507+ frame .nameText :SetTextColor (nameColor .r , nameColor .g , nameColor .b , 1 )
508+ end
509+
510+ -- Apply health text class color if enabled
511+ if db .healthTextUseClassColor and classColor and frame .healthText then
512+ frame .healthText :SetTextColor (classColor .r , classColor .g , classColor .b , 1 )
513+ end
514+ end
515+
516+ -- Get the displayed party/raid index for a unit token.
517+ -- Party mode default: player=1, party1=2 ... party4=5
518+ -- Optional remap mode: party1=1 ... party4=4, player=5
519+ -- Raid mode: raid1 ... raid40
520+ function DF :GetUnitPartyIndex (unit , db )
521+ if not unit or unit == " " then return nil end
522+
523+ local raidTokenIndex = unit :match (" ^raid(%d+)$" )
524+ if raidTokenIndex then
525+ return tonumber (raidTokenIndex )
526+ end
527+
528+ local raidIndex = UnitInRaid (unit )
529+ if raidIndex and raidIndex > 0 then
530+ return raidIndex
531+ end
532+
533+ local partyTokenIndex = unit :match (" ^party(%d+)$" )
534+ if partyTokenIndex then
535+ if db and db .partyIndexTextPlayerAtBottom then
536+ return tonumber (partyTokenIndex )
537+ end
538+ return tonumber (partyTokenIndex ) + 1
539+ end
540+
541+ if UnitIsUnit (unit , " player" ) then
542+ if db and db .partyIndexTextPlayerAtBottom then
543+ return 5
544+ end
545+ return 1
546+ end
547+
548+ return nil
549+ end
550+
551+ function DF :UpdatePartyIndexText (frame )
552+ if not frame or not frame .partyIndexText or not frame .unit then return end
553+
554+ local db = frame .isRaidFrame and DF :GetRaidDB () or DF :GetDB ()
555+ if not db then return end
556+
557+ if db .partyIndexTextEnabled == false then
558+ frame .partyIndexText :SetText (" " )
559+ frame .partyIndexText :Hide ()
560+ return
561+ end
562+
563+ local index = DF :GetUnitPartyIndex (frame .unit , db )
564+ if not index then
565+ frame .partyIndexText :SetText (" " )
566+ frame .partyIndexText :Hide ()
567+ return
568+ end
569+
570+ frame .partyIndexText :SetText (tostring (index ))
571+ frame .partyIndexText :Show ()
572+
573+ if DF .UpdatePartyIndexTextAppearance then
574+ DF :UpdatePartyIndexTextAppearance (frame )
575+ elseif db .partyIndexTextUseClassColor then
576+ local _ , class = UnitClass (frame .unit )
577+ local classColor = class and DF :GetClassColor (class )
578+ if classColor then
579+ frame .partyIndexText :SetTextColor (classColor .r , classColor .g , classColor .b , 1 )
580+ end
581+ else
582+ local c = db .partyIndexTextColor or {r = 1 , g = 1 , b = 1 }
583+ frame .partyIndexText :SetTextColor (c .r , c .g , c .b , c .a or 1 )
584+ end
585+ end
586+
476587-- Iterator for all compact unit frames (player, party, raid)
477588-- Accepts a callback function OR returns an iterator if no callback provided
478589-- Usage with callback: DF:IterateCompactFrames(function(frame) ... end)
0 commit comments