Skip to content

Commit 7b04021

Browse files
Added new text for displaying party numbers.
1 parent ccb5892 commit 7b04021

9 files changed

Lines changed: 355 additions & 2 deletions

File tree

Config.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,18 @@ DF.PartyDefaults = {
13321332
nameTextX = 0,
13331333
nameTextY = -10,
13341334

1335+
-- Party Number Text
1336+
partyIndexTextAnchor = "TOPLEFT",
1337+
partyIndexTextColor = {r = 1, g = 1, b = 1, a = 1},
1338+
partyIndexTextEnabled = false,
1339+
partyIndexTextFont = "DF Roboto SemiBold",
1340+
partyIndexTextFontSize = 10,
1341+
partyIndexTextOutline = "SHADOW",
1342+
partyIndexTextPlayerAtBottom = false,
1343+
partyIndexTextUseClassColor = false,
1344+
partyIndexTextX = 2,
1345+
partyIndexTextY = -2,
1346+
13351347
-- Out of Range
13361348
oorAbsorbBarAlpha = 0.20000000298023,
13371349
oorAurasAlpha = 0.20000000298023,
@@ -2539,6 +2551,18 @@ DF.RaidDefaults = {
25392551
nameTextX = 0,
25402552
nameTextY = -10,
25412553

2554+
-- Party Number Text
2555+
partyIndexTextAnchor = "TOPLEFT",
2556+
partyIndexTextColor = {r = 1, g = 1, b = 1, a = 1},
2557+
partyIndexTextEnabled = false,
2558+
partyIndexTextFont = "DF Roboto SemiBold",
2559+
partyIndexTextFontSize = 10,
2560+
partyIndexTextOutline = "SHADOW",
2561+
partyIndexTextPlayerAtBottom = false,
2562+
partyIndexTextUseClassColor = false,
2563+
partyIndexTextX = 2,
2564+
partyIndexTextY = -2,
2565+
25422566
-- Out of Range
25432567
oorAbsorbBarAlpha = 0.20000000298023,
25442568
oorAurasAlpha = 0.20000000298023,

Core.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,12 @@ function DF:LightweightUpdateFontSize(textType)
533533
if fontOutline == "NONE" then fontOutline = "" end
534534
local size = db.statusTextFontSize or 10
535535
DF:SafeSetFont(frame.statusText, fontPath, size, fontOutline)
536+
elseif textType == "partyIndex" and frame.partyIndexText then
537+
local fontPath = db.partyIndexTextFont or "Fonts\\FRIZQT__.TTF"
538+
local fontOutline = db.partyIndexTextOutline or "OUTLINE"
539+
if fontOutline == "NONE" then fontOutline = "" end
540+
local size = db.partyIndexTextFontSize or 10
541+
DF:SafeSetFont(frame.partyIndexText, fontPath, size, fontOutline)
536542
end
537543
end
538544

@@ -560,6 +566,10 @@ function DF:LightweightUpdateTextPosition(textType)
560566
frame.statusText:ClearAllPoints()
561567
local anchor = db.statusTextAnchor or "BOTTOM"
562568
frame.statusText:SetPoint(anchor, frame, anchor, db.statusTextX or 0, db.statusTextY or 0)
569+
elseif textType == "partyIndex" and frame.partyIndexText then
570+
frame.partyIndexText:ClearAllPoints()
571+
local anchor = db.partyIndexTextAnchor or "TOPLEFT"
572+
frame.partyIndexText:SetPoint(anchor, frame, anchor, db.partyIndexTextX or 2, db.partyIndexTextY or -2)
563573
end
564574
end
565575

@@ -1927,6 +1937,10 @@ function DF:LightweightUpdateTextColor(textType)
19271937
elseif textType == "status" then
19281938
colorKey = "statusTextColor"
19291939
textKey = "statusText"
1940+
elseif textType == "partyIndex" then
1941+
if db.partyIndexTextUseClassColor then return end
1942+
colorKey = "partyIndexTextColor"
1943+
textKey = "partyIndexText"
19301944
else
19311945
return
19321946
end
@@ -1958,13 +1972,21 @@ function DF:LightweightUpdateTextColor(textType)
19581972
else
19591973
alpha = db.rangeFadeAlpha or 0.55
19601974
end
1975+
elseif textType == "partyIndex" then
1976+
if db.oorEnabled then
1977+
alpha = db.oorNameTextAlpha or 0.55
1978+
else
1979+
alpha = db.rangeFadeAlpha or 0.55
1980+
end
19611981
end
19621982
-- Dead fade only applies when in range
19631983
elseif testData.status and db.fadeDeadFrames then
19641984
if textType == "name" then
19651985
alpha = db.fadeDeadName or 1.0
19661986
elseif textType == "status" then
19671987
alpha = db.fadeDeadStatusText or 1.0
1988+
elseif textType == "partyIndex" then
1989+
alpha = db.fadeDeadName or 1.0
19681990
end
19691991
end
19701992
end

Features/ElementAppearance.lua

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,54 @@ function DF:UpdateStatusTextAppearance(frame)
538538
frame.statusText:SetAlpha(alpha)
539539
end
540540

541+
-- ============================================================
542+
-- PARTY INDEX TEXT APPEARANCE
543+
-- ============================================================
544+
545+
function DF:UpdatePartyIndexTextAppearance(frame)
546+
if not IsDandersFrame(frame) then return end
547+
if not frame.partyIndexText then return end
548+
549+
local db = GetDB(frame)
550+
if not db then return end
551+
552+
if db.partyIndexTextEnabled == false then
553+
frame.partyIndexText:Hide()
554+
return
555+
end
556+
557+
local deadOrOffline = IsDeadOrOffline(frame)
558+
local inRange = GetInRange(frame)
559+
560+
local r, g, b = 1, 1, 1
561+
local baseAlpha = 1.0
562+
563+
if db.partyIndexTextUseClassColor then
564+
local classColor = GetClassColor(frame)
565+
r, g, b = classColor.r, classColor.g, classColor.b
566+
elseif deadOrOffline then
567+
r, g, b = 0.5, 0.5, 0.5
568+
else
569+
local c = db.partyIndexTextColor or DEFAULT_COLOR_WHITE
570+
r, g, b = c.r, c.g, c.b
571+
baseAlpha = c.a or 1.0
572+
end
573+
574+
local alpha = baseAlpha
575+
if deadOrOffline and db.fadeDeadFrames then
576+
alpha = db.fadeDeadName or 1.0
577+
end
578+
579+
frame.partyIndexText:SetTextColor(r, g, b, 1.0)
580+
581+
if db.oorEnabled then
582+
local oorAlpha = db.oorNameTextAlpha or 1
583+
ApplyOORAlpha(frame.partyIndexText, inRange, alpha, oorAlpha)
584+
else
585+
frame.partyIndexText:SetAlpha(alpha)
586+
end
587+
end
588+
541589
-- ============================================================
542590
-- POWER BAR APPEARANCE
543591
-- ============================================================
@@ -1146,6 +1194,7 @@ function DF:UpdateAllElementAppearances(frame)
11461194
DF:UpdateNameTextAppearance(frame)
11471195
DF:UpdateHealthTextAppearance(frame)
11481196
DF:UpdateStatusTextAppearance(frame)
1197+
DF:UpdatePartyIndexTextAppearance(frame)
11491198
DF:UpdatePowerBarAppearance(frame)
11501199
DF:UpdateBuffIconsAppearance(frame)
11511200
DF:UpdateDebuffIconsAppearance(frame)
@@ -1217,6 +1266,7 @@ DF.UpdateBackgroundAlpha = DF.UpdateBackgroundAppearance
12171266
DF.UpdateNameTextAlpha = DF.UpdateNameTextAppearance
12181267
DF.UpdateHealthTextAlpha = DF.UpdateHealthTextAppearance
12191268
DF.UpdateStatusTextAlpha = DF.UpdateStatusTextAppearance
1269+
DF.UpdatePartyIndexTextAlpha = DF.UpdatePartyIndexTextAppearance
12201270
DF.UpdatePowerBarAlpha = DF.UpdatePowerBarAppearance
12211271
DF.UpdateBuffIconsAlpha = DF.UpdateBuffIconsAppearance
12221272
DF.UpdateDebuffIconsAlpha = DF.UpdateDebuffIconsAppearance

Frames/Core.lua

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,117 @@ function DF:GetUnitName(unit)
473473
return UnitName(unit) or unit
474474
end
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)

Frames/Create.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,20 @@ function DF:CreateFrameElements(frame, isRaid)
634634
frame.statusText:SetTextColor(statusColor.r, statusColor.g, statusColor.b, 1)
635635
frame.statusText:SetDrawLayer("OVERLAY", 7)
636636
frame.statusText:Hide()
637+
638+
-- ========================================
639+
-- PARTY INDEX TEXT
640+
-- ========================================
641+
frame.partyIndexText = frame.contentOverlay:CreateFontString(nil, "OVERLAY")
642+
local partyIndexOutline = db.partyIndexTextOutline or "OUTLINE"
643+
if partyIndexOutline == "NONE" then partyIndexOutline = "" end
644+
DF:SafeSetFont(frame.partyIndexText, db.partyIndexTextFont or "Fonts\\FRIZQT__.TTF", db.partyIndexTextFontSize or 10, partyIndexOutline)
645+
local partyIndexAnchor = db.partyIndexTextAnchor or "TOPLEFT"
646+
frame.partyIndexText:SetPoint(partyIndexAnchor, frame, partyIndexAnchor, db.partyIndexTextX or 2, db.partyIndexTextY or -2)
647+
local partyIndexColor = db.partyIndexTextColor or {r = 1, g = 1, b = 1}
648+
frame.partyIndexText:SetTextColor(partyIndexColor.r, partyIndexColor.g, partyIndexColor.b, partyIndexColor.a or 1)
649+
frame.partyIndexText:SetDrawLayer("OVERLAY", 7)
650+
frame.partyIndexText:Hide()
637651

638652
-- Continue with the rest of the elements...
639653
-- (Border, icons, power bar, auras, absorbs, etc.)
@@ -1344,6 +1358,20 @@ function DF:CreateUnitFrame(unit, index, isRaid)
13441358
frame.statusText:SetTextColor(statusColor.r, statusColor.g, statusColor.b, 1)
13451359
frame.statusText:SetDrawLayer("OVERLAY", 7)
13461360
frame.statusText:Hide()
1361+
1362+
-- ========================================
1363+
-- PARTY INDEX TEXT
1364+
-- ========================================
1365+
frame.partyIndexText = frame.contentOverlay:CreateFontString(nil, "OVERLAY")
1366+
local partyIndexOutline = db.partyIndexTextOutline or "OUTLINE"
1367+
if partyIndexOutline == "NONE" then partyIndexOutline = "" end
1368+
DF:SafeSetFont(frame.partyIndexText, db.partyIndexTextFont or "Fonts\\FRIZQT__.TTF", db.partyIndexTextFontSize or 10, partyIndexOutline)
1369+
local partyIndexAnchor = db.partyIndexTextAnchor or "TOPLEFT"
1370+
frame.partyIndexText:SetPoint(partyIndexAnchor, frame, partyIndexAnchor, db.partyIndexTextX or 2, db.partyIndexTextY or -2)
1371+
local partyIndexColor = db.partyIndexTextColor or {r = 1, g = 1, b = 1}
1372+
frame.partyIndexText:SetTextColor(partyIndexColor.r, partyIndexColor.g, partyIndexColor.b, partyIndexColor.a or 1)
1373+
frame.partyIndexText:SetDrawLayer("OVERLAY", 7)
1374+
frame.partyIndexText:Hide()
13471375

13481376
-- ========================================
13491377
-- BORDER

0 commit comments

Comments
 (0)