Skip to content

Commit

Permalink
Merge pull request #212 from JerichoR/PartyWidgets
Browse files Browse the repository at this point in the history
Move Party to WidgetManager
  • Loading branch information
tukz authored Nov 24, 2024
2 parents 0ae2287 + e6e77ab commit f6958a4
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 242 deletions.
1 change: 1 addition & 0 deletions Tukui/Config/Gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ local UnitFrames = function(self)
Window:CreateColorSelection("All", "UnitFrames", "HealCommSelfColor", "HealComm - my heals")
Window:CreateColorSelection("All", "UnitFrames", "HealCommOtherColor", "HealComm - others heals")
Window:CreateColorSelection("Retail", "UnitFrames", "HealCommAbsorbColor", "HealComm - absorbs")
Window:CreateColorSelection("Retail", "UnitFrames", "HealCommHealAbsorbColor", "HealComm - heal absorbs")
Window:CreateColorSelection("All", "UnitFrames", "CastingColor", "Cast bar casting color")
Window:CreateColorSelection("All", "UnitFrames", "ChannelingColor", "Cast bar channeling color")
Window:CreateColorSelection("Retail", "UnitFrames", "NotInterruptibleColor", "Cast bar not interruptible color")
Expand Down
1 change: 1 addition & 0 deletions Tukui/Config/Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ C["UnitFrames"] = {
["HealCommSelfColor"] = {0.29, 1, 0.30},
["HealCommOtherColor"] = {1, .72, 0.30},
["HealCommAbsorbColor"] = {207/255, 181/255, 59/255},
["HealCommHealAbsorbColor"] = {.8, .5, .15},
["RaidIconSize"] = 24,
["Boss"] = true,
["Arena"] = true,
Expand Down
230 changes: 35 additions & 195 deletions Tukui/Modules/UnitFrames/Groups/Party.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
local T, C, L = unpack((select(2, ...)))

local UnitFrames = T["UnitFrames"]
local Class = select(2, UnitClass("player"))
local Widgets = UnitFrames.Widgets

local function addDefaultWidgets(self, unitFrame)
self:add("Health", Widgets.HealthBar, { height = 19, font = C.Party.HealthFont, showValue = C.Party.ShowHealthText,
valueAnchor = { "TOPRIGHT", -4, 6 }, tag = C.Party.HealthTag.Value, texture = C.Textures.UFPartyHealthTexture, })
self:add("Power", Widgets.PowerBar, { height = 4, font = C.Party.HealthFont, showValue = C.Party.ShowManaText,
texture = C.Textures.UFPartyPowerTexture, })
self:add("Name", Widgets.Name, { font = C.Party.Font, anchor = { "TOPLEFT", 4, 7 }, })

self:add("RaidTargetIndicator", Widgets.RaidTargetIndicator, { anchor = { "CENTER" }, })
self:add("ReadyCheckIndicator", Widgets.ReadyCheckIndicator)
self:add("ResurrectIndicator", Widgets.ResurrectIndicator)
self:add("LeaderIndicator", Widgets.LeaderIndicator)
self:add("Range", Widgets.RangeIndicator, { outsideAlpha = C.Party.RangeAlpha, })
self:add("Highlight", Widgets.HighlightIndicator, { size = C.Party.HighlightSize, color = C.Party.HighlightColor, })

function UnitFrames:Party()
local HealthTexture = T.GetTexture(C["Textures"].UFPartyHealthTexture)
local PowerTexture = T.GetTexture(C["Textures"].UFPartyPowerTexture)
local Font = T.GetFont(C["Party"].Font)
local HealthFont = T.GetFont(C["Party"].HealthFont)
if C.UnitFrames.HealComm then
self:add("HealComm", Widgets.HealComm, { texture = C.Textures.UFPartyHealthTexture, })
end

if C.Party.Buffs then
self:add("Buffs", Widgets.BuffsIndicator, { parent = unitFrame, height = 24, width = 190,
anchor = { "TOPLEFT", "BOTTOMLEFT", 0, -6 }, buffSize = 24, buffNum = 7, })
end

if C.Party.Debuffs then
self:add("Debuffs", Widgets.Debuffs, { parent = unitFrame, height = unitFrame:GetHeight(), width = 250,
anchor = { "LEFT", "RIGHT", 6, 0 }, debuffSize = unitFrame:GetHeight(), debuffNum = 6, })
end
end

-- Create new WidgetManager for Party and expose for external edits.
UnitFrames.PartyWidgets = UnitFrames.newWidgetManager("Party", addDefaultWidgets)

function UnitFrames:Party()
self:RegisterForClicks("AnyUp")
self:SetScript("OnEnter", UnitFrame_OnEnter)
self:SetScript("OnLeave", UnitFrame_OnLeave)
Expand All @@ -21,198 +48,11 @@ function UnitFrames:Party()
self.Backdrop:SetBackdrop(UnitFrames.Backdrop)
self.Backdrop:SetBackdropColor(0, 0, 0)

local Health = CreateFrame("StatusBar", nil, self)
Health:SetPoint("TOPLEFT")
Health:SetPoint("TOPRIGHT")
Health:SetHeight(self:GetHeight() - 5)
Health:SetStatusBarTexture(HealthTexture)

Health.Background = Health:CreateTexture(nil, "BACKGROUND")
Health.Background:SetTexture(HealthTexture)
Health.Background:SetAllPoints(Health)
Health.Background.multiplier = C.UnitFrames.StatusBarBackgroundMultiplier / 100

if C.Party.ShowHealthText then
Health.Value = Health:CreateFontString(nil, "OVERLAY")
Health.Value:SetFontObject(Font)
Health.Value:SetPoint("TOPRIGHT", -4, 6)

self:Tag(Health.Value, C.Party.HealthTag.Value)
end

Health.colorDisconnected = true
Health.colorClass = true
Health.colorReaction = true
Health.isParty = true

-- Power
local Power = CreateFrame("StatusBar", nil, self)
Power:SetHeight(4)
Power:SetPoint("TOPLEFT", Health, "BOTTOMLEFT", 0, -1)
Power:SetPoint("TOPRIGHT", Health, "BOTTOMRIGHT", 0, -1)
Power:SetStatusBarTexture(PowerTexture)

Power.Background = Power:CreateTexture(nil, "BORDER")
Power.Background:SetTexture(PowerTexture)
Power.Background:SetAllPoints(Power)
Power.Background.multiplier = C.UnitFrames.StatusBarBackgroundMultiplier / 100

if C.Party.ShowManaText then
Power.Value = Power:CreateFontString(nil, "OVERLAY")
Power.Value:SetFontObject(Font)
Power.Value:SetPoint("BOTTOMRIGHT", -4, 0)
Power.PostUpdate = UnitFrames.PostUpdatePower
end

Power.colorPower = true
Power.isParty = true

local Name = Health:CreateFontString(nil, "OVERLAY")
Name:SetPoint("TOPLEFT", 4, 7)
Name:SetFontObject(Font)

if C.Party.Buffs then
local Buffs = CreateFrame("Frame", self:GetName().."Buffs", self)
Buffs:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -6)
Buffs:SetHeight(24)
Buffs:SetWidth(190)
Buffs.size = 24
Buffs.num = 7
Buffs.numRow = 1
Buffs.spacing = 2
Buffs.initialAnchor = "TOPLEFT"
Buffs.PostCreateIcon = UnitFrames.PostCreateAura
Buffs.PostUpdateIcon = UnitFrames.PostUpdateAura
Buffs.PostCreateButton = UnitFrames.PostCreateAura
Buffs.PostUpdateButton = UnitFrames.PostUpdateAura

self.Buffs = Buffs
end

if C.Party.Debuffs then
local Debuffs = CreateFrame("Frame", self:GetName().."Debuffs", self)
Debuffs:SetPoint("LEFT", self, "RIGHT", 6, 0)
Debuffs:SetHeight(self:GetHeight())
Debuffs:SetWidth(250)
Debuffs.size = self:GetHeight()
Debuffs.num = 6
Debuffs.spacing = 2
Debuffs.initialAnchor = "TOPLEFT"
Debuffs.PostCreateIcon = UnitFrames.PostCreateAura
Debuffs.PostUpdateIcon = UnitFrames.PostUpdateAura
Debuffs.PostCreateButton = UnitFrames.PostCreateAura
Debuffs.PostUpdateButton = UnitFrames.PostUpdateAura

self.Debuffs = Debuffs
end

local Leader = self:CreateTexture(nil, "OVERLAY")
Leader:SetSize(16, 16)
Leader:SetPoint("TOPRIGHT", self, "TOPLEFT", -4, 0)

-- not implemented anywhere?
local MasterLooter = self:CreateTexture(nil, "OVERLAY")
MasterLooter:SetSize(16, 16)
MasterLooter:SetPoint("TOPRIGHT", self, "TOPLEFT", -4.5, -20)

local ReadyCheck = Health:CreateTexture(nil, "OVERLAY")
ReadyCheck:SetPoint("CENTER", Health, "CENTER")
ReadyCheck:SetSize(16, 16)

local RaidIcon = Health:CreateTexture(nil, "OVERLAY")
RaidIcon:SetSize(C.UnitFrames.RaidIconSize, C.UnitFrames.RaidIconSize)
RaidIcon:SetPoint("CENTER", Health, "CENTER")
RaidIcon:SetTexture([[Interface\AddOns\Tukui\Medias\Textures\Others\RaidIcons]])

local Range = {
insideAlpha = 1,
outsideAlpha = C["Party"].RangeAlpha,
}

if C.UnitFrames.HealComm then
local myBar = CreateFrame("StatusBar", nil, Health)
local otherBar = CreateFrame("StatusBar", nil, Health)
local absorbBar = CreateFrame("StatusBar", nil, Health)

myBar:SetFrameLevel(Health:GetFrameLevel())
myBar:SetStatusBarTexture(HealthTexture)
myBar:SetPoint("TOP")
myBar:SetPoint("BOTTOM")
myBar:SetPoint("LEFT", Health:GetStatusBarTexture(), "RIGHT")
myBar:SetWidth(180)
myBar:SetStatusBarColor(unpack(C.UnitFrames.HealCommSelfColor))
myBar:SetMinMaxValues(0, 1)
myBar:SetValue(0)

otherBar:SetFrameLevel(Health:GetFrameLevel())
otherBar:SetPoint("TOP")
otherBar:SetPoint("BOTTOM")
otherBar:SetPoint("LEFT", myBar:GetStatusBarTexture(), "RIGHT")
otherBar:SetWidth(180)
otherBar:SetStatusBarTexture(HealthTexture)
otherBar:SetStatusBarColor(unpack(C.UnitFrames.HealCommOtherColor))
otherBar:SetMinMaxValues(0, 1)
otherBar:SetValue(0)

absorbBar:SetFrameLevel(Health:GetFrameLevel())
absorbBar:SetPoint("TOP")
absorbBar:SetPoint("BOTTOM")
absorbBar:SetPoint("LEFT", otherBar:GetStatusBarTexture(), "RIGHT")
absorbBar:SetWidth(180)
absorbBar:SetStatusBarTexture(HealthTexture)
absorbBar:SetStatusBarColor(unpack(C.UnitFrames.HealCommAbsorbColor))
absorbBar:SetMinMaxValues(0, 1)
absorbBar:SetValue(0)

local HealthPrediction = {
myBar = myBar,
otherBar = otherBar,
absorbBar = absorbBar,
maxOverflow = 1,
}

self.HealthPrediction = HealthPrediction
end

local ResurrectIndicator = Health:CreateTexture(nil, "OVERLAY")
ResurrectIndicator:SetSize(24, 24)
ResurrectIndicator:SetPoint("CENTER", Health)

local Highlight = CreateFrame("Frame", nil, self, "BackdropTemplate")
Highlight:SetBackdrop({edgeFile = C.Medias.Glow, edgeSize = C.Party.HighlightSize})
Highlight:SetOutside(self, C.Party.HighlightSize, C.Party.HighlightSize)
Highlight:SetBackdropBorderColor(unpack(C.Party.HighlightColor))
Highlight:SetFrameLevel(0)
Highlight:Hide()

-- Enable smoothing bars animation?
if C.UnitFrames.Smoothing then
Health.smoothing = true
Power.smoothing = true

if self.HealthPrediction then
self.HealthPrediction.smoothing = true
end
end

self.Health = Health
self.Health.bg = Health.Background
self.Power = Power
self.Power.bg = Power.Background
self.Name = Name
self.LeaderIndicator = Leader
self.MasterLooterIndicator = MasterLooter
self.ReadyCheckIndicator = ReadyCheck
self.RaidTargetIndicator = RaidIcon
self.Range = Range
self.Highlight = Highlight
self.ResurrectIndicator = ResurrectIndicator

if T.Retail then
self:Tag(Name, "[level] [Tukui:NameLong] [Tukui:Role]")
else
self:Tag(Name, "[level] [Tukui:NameLong]")
end

self:RegisterEvent("PLAYER_TARGET_CHANGED", UnitFrames.Highlight, true)
self:RegisterEvent("RAID_ROSTER_UPDATE", UnitFrames.Highlight, true)
UnitFrames.PartyWidgets:createWidgets(self)
end
4 changes: 2 additions & 2 deletions Tukui/Modules/UnitFrames/Groups/Raid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local T, C, L = unpack((select(2, ...)))
local UnitFrames = T["UnitFrames"]
local Widgets = UnitFrames.Widgets

local function addDefaultWidgets(self)
local function addDefaultWidgets(self, unitFrame)
self:add("Health", Widgets.HealthBar, { height = C.Raid.HeightSize - 1 - 3 - 1 - 18, -- border, power, border, namepanel
texture = C.Raid.UFRaidHealthTexture, font = C.Raid.HealthFont, tag = C.Raid.HealthTag.Value,
orientation = C.Raid.VerticalHealth and "VERTICAL" or "HORIZONTAL", })
Expand All @@ -15,7 +15,7 @@ local function addDefaultWidgets(self)
end

self:add("RaidTargetIndicator", Widgets.RaidTargetIndicator)
self:add("ReadyCheckIndicator", Widgets.ReadyCheckIndicator)
self:add("ReadyCheckIndicator", Widgets.ReadyCheckIndicator, { parent = unitFrame.Power, size = 12, })
self:add("ResurrectIndicator", Widgets.ResurrectIndicator)
self:add("Range", Widgets.RangeIndicator, { outsideAlpha = C.Raid.RangeAlpha, })
self:add("Highlight", Widgets.HighlightIndicator, { size = C.Raid.HighlightSize, color = C.Raid.HighlightColor, })
Expand Down
14 changes: 7 additions & 7 deletions Tukui/Modules/UnitFrames/WidgetManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ local function rebuildIndex(self, changedWidget)
manager[manager._Count] = nil
manager._Count = manager._Count - 1
end

return changedWidget
end


Expand Down Expand Up @@ -146,8 +148,7 @@ function WidgetManager:remove(nameOrIndex)
manager[widget.index] = nil
manager[widget.name] = nil

rebuildIndex(self, widget)
return widget
return rebuildIndex(self, widget)
end
end

Expand All @@ -159,12 +160,11 @@ function WidgetManager:insert(atIndex, name, func, config)
local manager = Widgets[self]

-- fails if name is not a string, a widget of that name already exists, or the index is outside the current range
if type(name) == "string" and not manager[name] and 0 <= atIndex and atIndex <= manager._Count + 1 then
if type(name) == "string" and not manager[name] and 1 <= atIndex and atIndex <= manager._Count + 1 then
local widget = Widget(atIndex, name, func, config)
manager[name] = widget

rebuildIndex(self, widget)
return widget
return rebuildIndex(self, widget)
end
end

Expand All @@ -174,9 +174,9 @@ function WidgetManager:createWidgets(unitFrame)

-- Execute only once as changes are stored in the manager
if not manager._Initialized then
manager._AddDefaultWidgets(self)
manager._AddDefaultWidgets(self, unitFrame)
if self._UpdateWidgetList then
self._UpdateWidgetList(self)
self._UpdateWidgetList(self, unitFrame)
end
manager._Initialized = true
end
Expand Down
Loading

0 comments on commit f6958a4

Please sign in to comment.