Skip to content

Commit

Permalink
add option to toggle player tags visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ffainy committed Apr 6, 2022
1 parent 3161e84 commit 7434a0e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions gui/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ GUI.OptionsList = {
{1, 'Unitframe', 'GCDIndicator', L['GCD Indicator'], true, nil, UpdateGCDTicker, L['Show global cooldown ticker above the player frame.']},
{1, 'Unitframe', 'AbbrName', L['Abbreviate Name'], nil, nil, UpdateUnitTags},
{1, 'Unitframe', 'ClassPower', L['Class Power'], true, SetupClassPower, nil, L['Show special resources of the class, such as Combo Points, Holy Power, Chi, Runes, etc.']},
{1, 'Unitframe', 'HidePlayerTags', L['Hide Player Tags'], nil, nil, UpdateUnitTags, L['Only show player tags on mouseover.']},
{},
{1, 'Unitframe', 'OnlyShowPlayer', L['Player Debuffs Only'], nil, nil, nil, L['Display debuffs cast by player only.']},
{1, 'Unitframe', 'DesaturateIcon', L['Desaturate Debuffs'], true, nil, nil, L['Desaturate debuffs cast by others.']},
Expand Down
35 changes: 26 additions & 9 deletions modules/unitframe/tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ local events = {
-- abbreviate the name
-- aaa.bbbbb -> a.bbbbb
local function AbbrName(string, i)
if string.len(string) > i then
if string and string.len(string) > i then
return string.gsub(string, '%s?(.[\128-\191]*)%S+%s', '%1. ')
else
return string
Expand Down Expand Up @@ -389,8 +389,27 @@ local function Player_OnEnter(self)
end

local function Player_OnLeave(self)
self.LeftTag:Hide()
self.RightTag:Hide()
if C.DB.Unitframe.HidePlayerTags then
self.LeftTag:Hide()
self.RightTag:Hide()
else
self.LeftTag:Show()
self.RightTag:Show()
end
end

local function UpdatePlayerTags(self)
if C.DB.Unitframe.HidePlayerTags then
self.LeftTag:Hide()
self.RightTag:Hide()
self:HookScript('OnEnter', Player_OnEnter)
self:HookScript('OnLeave', Player_OnLeave)
else
self.LeftTag:Show()
self.RightTag:Show()
self:HookScript('OnEnter', Player_OnEnter)
self:HookScript('OnLeave', Player_OnLeave)
end
end

function UNITFRAME:CreatePlayerTags(self)
Expand All @@ -410,12 +429,7 @@ function UNITFRAME:CreatePlayerTags(self)
self.LeftTag = leftTag
self.RightTag = rightTag

if C.DB.Unitframe.HidePlayerTags then
self.LeftTag:Hide()
self.RightTag:Hide()
self:HookScript('OnEnter', Player_OnEnter)
self:HookScript('OnLeave', Player_OnLeave)
end

end

function NAMEPLATE:CreateHealthTag(self)
Expand All @@ -437,6 +451,9 @@ end
function UNITFRAME:UpdateUnitTags()
for _, frame in pairs(oUF.objects) do
if frame.unitStyle ~= 'party' and frame.unitStyle ~= 'raid' then
if frame.unitStyle == 'player' then
UpdatePlayerTags(frame)
end
frame:UpdateTags()
end
end
Expand Down

0 comments on commit 7434a0e

Please sign in to comment.