Skip to content

Commit

Permalink
feat(unitframe): add 'RaidTargetIndicator' on group frames
Browse files Browse the repository at this point in the history
  • Loading branch information
ffainy committed Jun 14, 2022
1 parent f788153 commit 9f54d18
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 35 deletions.
22 changes: 18 additions & 4 deletions gui/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ local function UpdateGroupAuras()
UNITFRAME:UpdateGroupAuras()
end

local function UpdateRaidTargetIndicator()
UNITFRAME:UpdateRaidTargetIndicator()
end

-- General

local function UpdateVignettingVisibility()
Expand Down Expand Up @@ -1582,12 +1586,12 @@ GUI.OptionsList = {
{
1,
'Unitframe',
'SmartRaid',
L['Smart GroupFrame'],
'RaidTargetIndicator',
L['Raid Target Indicator'],
true,
nil,
UpdateAllHeaders,
L['If enabled, only show RaidFrame if there are more than 5 members in your group.|nIf disabled, show RaidFrame when in raid, show PartyFrame when in party.'],
UpdateRaidTargetIndicator,
L['Display raid target indicator on GroupFrame.'],
},
{
1,
Expand Down Expand Up @@ -1619,6 +1623,16 @@ GUI.OptionsList = {
nil,
L['Save the position of the GroupFrame separately according to the specialization.'],
},
{
1,
'Unitframe',
'SmartRaid',
L['Smart GroupFrame'],
true,
nil,
UpdateAllHeaders,
L['If enabled, only show RaidFrame if there are more than 5 members in your group.|nIf disabled, show RaidFrame when in raid, show PartyFrame when in party.'],
},
{},
{ 1, 'Unitframe', 'DebuffWatcher', L['Enable Debuff Watcher'] },
{
Expand Down
1 change: 1 addition & 0 deletions modules/nameplate/elements/elements.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="indicator.lua"/>
<Script file="totem.lua"/>
</Ui>
29 changes: 29 additions & 0 deletions modules/nameplate/elements/indicator.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local F, C = unpack(select(2, ...))
local NAMEPLATE = F:GetModule('Nameplate')

function NAMEPLATE.UpdateRaidTargetIndicator(frame)
local icon = frame.RaidTargetIndicator
local enable = C.DB.Nameplate.RaidTargetIndicator
local nameOnly = frame.plateType == 'NameOnly'
local name = frame.NameTag

if nameOnly then
icon:SetPoint('BOTTOM', name, 'TOP')
else
icon:ClearAllPoints()
icon:SetPoint('LEFT', frame, 'RIGHT', 4, 0)
end

icon:SetAlpha(1)
icon:SetSize(frame:GetHeight(), frame:GetHeight())
icon:SetScale(2)
icon:SetShown(enable)
end

function NAMEPLATE:CreateRaidTargetIndicator(self)
local icon = self:CreateTexture(nil, 'OVERLAY')

self.RaidTargetIndicator = icon

NAMEPLATE.UpdateRaidTargetIndicator(self)
end
54 changes: 23 additions & 31 deletions modules/unitframe/elements/indicator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ local UNITFRAME = F:GetModule('UnitFrame')
local NAMEPLATE = F:GetModule('Nameplate')
local oUF = F.Libs.oUF

function UNITFRAME.UpdateRaidTargetIndicator(frame)
function UNITFRAME.ConfigureTargetIndicator(frame)
local icon = frame.RaidTargetIndicator
local enable = C.DB.Unitframe.RaidTargetIndicator

icon:SetPoint('LEFT', frame, 'RIGHT', 4, 0)
icon:SetPoint('CENTER', frame, 'TOP')
icon:SetAlpha(1)
icon:SetSize(frame:GetHeight(), frame:GetHeight())
icon:SetSize(16, 16)
icon:SetScale(1)
icon:SetShown(enable)
end
Expand All @@ -20,7 +20,26 @@ function UNITFRAME:CreateRaidTargetIndicator(self)

self.RaidTargetIndicator = icon

UNITFRAME.UpdateRaidTargetIndicator(self)
UNITFRAME.ConfigureTargetIndicator(self)
end

function UNITFRAME:UpdateRaidTargetIndicator()
for _, frame in pairs(oUF.objects) do
if frame.unitStyle == 'party' or frame.unitStyle == 'raid' then
if C.DB.Unitframe.RaidTargetIndicator then
if not frame:IsElementEnabled('RaidTargetIndicator') then
frame:EnableElement('RaidTargetIndicator')
if frame.RaidTargetIndicator then
frame.RaidTargetIndicator:ForceUpdate()
end
end
else
if frame:IsElementEnabled('RaidTargetIndicator') then
frame:DisableElement('RaidTargetIndicator')
end
end
end
end
end

local classify = {
Expand Down Expand Up @@ -69,33 +88,6 @@ function NAMEPLATE:UpdateUnitClassify(unit)
end
end

function NAMEPLATE.UpdateRaidTargetIndicator(frame)
local icon = frame.RaidTargetIndicator
local enable = C.DB.Nameplate.RaidTargetIndicator
local nameOnly = frame.plateType == 'NameOnly'
local name = frame.NameTag

if nameOnly then
icon:SetPoint('BOTTOM', name, 'TOP')
else
icon:ClearAllPoints()
icon:SetPoint('LEFT', frame, 'RIGHT', 4, 0)
end

icon:SetAlpha(1)
icon:SetSize(frame:GetHeight(), frame:GetHeight())
icon:SetScale(2)
icon:SetShown(enable)
end

function NAMEPLATE:CreateRaidTargetIndicator(self)
local icon = self:CreateTexture(nil, 'OVERLAY')

self.RaidTargetIndicator = icon

NAMEPLATE.UpdateRaidTargetIndicator(self)
end

function UNITFRAME:CreateReadyCheckIndicator(self)
local readyCheckIndicator = self:CreateTexture(nil, 'OVERLAY')
readyCheckIndicator:SetPoint('CENTER')
Expand Down
1 change: 1 addition & 0 deletions modules/unitframe/unitframe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ function UNITFRAME:UpdateAllElements()
UNITFRAME:UpdateAuras()
UNITFRAME:UpdateFader()
UNITFRAME:UpdateClassPower()
UNITFRAME:UpdateRaidTargetIndicator()
end

function UNITFRAME:OnLogin()
Expand Down
2 changes: 2 additions & 0 deletions modules/unitframe/units.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ local function CreatePartyStyle(self)
UNITFRAME:CreatePhaseIndicator(self)
UNITFRAME:CreateSummonIndicator(self)
UNITFRAME:CreateThreatIndicator(self)
UNITFRAME:CreateRaidTargetIndicator(self)
UNITFRAME:CreateSelectedBorder(self)
UNITFRAME:CreateRangeCheck(self)
UNITFRAME:CreatePartyAuras(self)
Expand Down Expand Up @@ -397,6 +398,7 @@ local function CreateRaidStyle(self)
UNITFRAME:CreateGroupRoleTag(self)
UNITFRAME:CreatePhaseIndicator(self)
UNITFRAME:CreateSummonIndicator(self)
UNITFRAME:CreateRaidTargetIndicator(self)
UNITFRAME:CreateSelectedBorder(self)
UNITFRAME:CreateRangeCheck(self)
UNITFRAME:CreateCornerIndicator(self)
Expand Down

0 comments on commit 9f54d18

Please sign in to comment.