Nameplate Overhaul (#38)

* ElvUI/NamePlates: initial nameplate conversions

* More nameplate work

* Modules/Cooldowns: various CD fixes, nameplates cant show 'swipe' texture

* ElvUI/NamePlates: final nameplate polish

* Modules/Misc: add space before interrupted announcement
This commit is contained in:
Andrew
2023-05-22 19:18:59 -07:00
committed by GitHub
parent 5d51f92ed3
commit 8edf2d7f8a
75 changed files with 8870 additions and 8088 deletions
+21 -39
View File
@@ -77,47 +77,29 @@ local function createConfigEnv()
__newindex = function(_, key, value) _G[key] = value end,
})
overrideFuncs["namecolor"] = ElvUF.Tags.Methods["namecolor"]
overrideFuncs["name:veryshort"] = ElvUF.Tags.Methods["name:veryshort"]
overrideFuncs["name:short"] = ElvUF.Tags.Methods["name:short"]
overrideFuncs["name:medium"] = ElvUF.Tags.Methods["name:medium"]
overrideFuncs["name:long"] = ElvUF.Tags.Methods["name:long"]
overrideFuncs['classcolor'] = ElvUF.Tags.Methods['classcolor']
overrideFuncs['name:veryshort'] = ElvUF.Tags.Methods['name:veryshort']
overrideFuncs['name:short'] = ElvUF.Tags.Methods['name:short']
overrideFuncs['name:medium'] = ElvUF.Tags.Methods['name:medium']
overrideFuncs['name:long'] = ElvUF.Tags.Methods['name:long']
overrideFuncs["healthcolor"] = ElvUF.Tags.Methods["healthcolor"]
overrideFuncs["health:current"] = ElvUF.Tags.Methods["health:current"]
overrideFuncs["health:deficit"] = ElvUF.Tags.Methods["health:deficit"]
overrideFuncs["health:current-percent"] = ElvUF.Tags.Methods["health:current-percent"]
overrideFuncs["health:current-max"] = ElvUF.Tags.Methods["health:current-max"]
overrideFuncs["health:current-max-percent"] = ElvUF.Tags.Methods["health:current-max-percent"]
overrideFuncs["health:max"] = ElvUF.Tags.Methods["health:max"]
overrideFuncs["health:percent"] = ElvUF.Tags.Methods["health:percent"]
overrideFuncs['healthcolor'] = ElvUF.Tags.Methods['healthcolor']
overrideFuncs['health:current'] = ElvUF.Tags.Methods['health:current']
overrideFuncs['health:deficit'] = ElvUF.Tags.Methods['health:deficit']
overrideFuncs['health:current-percent'] = ElvUF.Tags.Methods['health:current-percent']
overrideFuncs['health:current-max'] = ElvUF.Tags.Methods['health:current-max']
overrideFuncs['health:current-max-percent'] = ElvUF.Tags.Methods['health:current-max-percent']
overrideFuncs['health:max'] = ElvUF.Tags.Methods['health:max']
overrideFuncs['health:percent'] = ElvUF.Tags.Methods['health:percent']
overrideFuncs["powercolor"] = ElvUF.Tags.Methods["powercolor"]
overrideFuncs["power:current"] = ElvUF.Tags.Methods["power:current"]
overrideFuncs["power:deficit"] = ElvUF.Tags.Methods["power:deficit"]
overrideFuncs["power:current-percent"] = ElvUF.Tags.Methods["power:current-percent"]
overrideFuncs["power:current-max"] = ElvUF.Tags.Methods["power:current-max"]
overrideFuncs["power:current-max-percent"] = ElvUF.Tags.Methods["power:current-max-percent"]
overrideFuncs["power:max"] = ElvUF.Tags.Methods["power:max"]
overrideFuncs["power:percent"] = ElvUF.Tags.Methods["power:percent"]
overrideFuncs["energycolor"] = ElvUF.Tags.Methods["energycolor"]
overrideFuncs["energy:current"] = ElvUF.Tags.Methods["energy:current"]
overrideFuncs["energy:deficit"] = ElvUF.Tags.Methods["energy:deficit"]
overrideFuncs["energy:current-percent"] = ElvUF.Tags.Methods["energy:current-percent"]
overrideFuncs["energy:current-max"] = ElvUF.Tags.Methods["energy:current-max"]
overrideFuncs["energy:current-max-percent"] = ElvUF.Tags.Methods["energy:current-max-percent"]
overrideFuncs["energy:max"] = ElvUF.Tags.Methods["energy:max"]
overrideFuncs["energy:percent"] = ElvUF.Tags.Methods["energy:percent"]
overrideFuncs["ragecolor"] = ElvUF.Tags.Methods["ragecolor"]
overrideFuncs["rage:current"] = ElvUF.Tags.Methods["rage:current"]
overrideFuncs["rage:deficit"] = ElvUF.Tags.Methods["rage:deficit"]
overrideFuncs["rage:current-percent"] = ElvUF.Tags.Methods["rage:current-percent"]
overrideFuncs["rage:current-max"] = ElvUF.Tags.Methods["rage:current-max"]
overrideFuncs["rage:current-max-percent"] = ElvUF.Tags.Methods["rage:current-max-percent"]
overrideFuncs["rage:max"] = ElvUF.Tags.Methods["rage:max"]
overrideFuncs["rage:percent"] = ElvUF.Tags.Methods["rage:percent"]
overrideFuncs['powercolor'] = ElvUF.Tags.Methods['powercolor']
overrideFuncs['power:current'] = ElvUF.Tags.Methods['power:current']
overrideFuncs['power:deficit'] = ElvUF.Tags.Methods['power:deficit']
overrideFuncs['power:current-percent'] = ElvUF.Tags.Methods['power:current-percent']
overrideFuncs['power:current-max'] = ElvUF.Tags.Methods['power:current-max']
overrideFuncs['power:current-max-percent'] = ElvUF.Tags.Methods['power:current-max-percent']
overrideFuncs['power:max'] = ElvUF.Tags.Methods['power:max']
overrideFuncs['power:percent'] = ElvUF.Tags.Methods['power:percent']
end
function UF:ForceShow(frame)
@@ -173,6 +173,33 @@ function UF.SortAuraBarName(a, b)
return a.name > b.name
end
function UF:ConvertFilters(auras, priority)
if not priority or priority == '' then return end
local list = auras.filterList or {}
if next(list) then wipe(list) end
local special, filters = G.unitframe.specialFilters, E.global.unitframe.aurafilters
for _, name in next, { strsplit(',', priority) } do
local friend, enemy = strmatch(name, '^Friendly:([^,]*)'), strmatch(name, '^Enemy:([^,]*)')
local real = friend or enemy or name
local custom = filters[real]
if special[real] or custom then
tinsert(list, {
name = real,
custom = custom,
status = (friend and 1) or (enemy and 2)
})
end
end
if next(list) then
return list
end
end
function UF:CheckFilter(name, caster, spellID, isFriend, isPlayer, isUnit, allowDuration, noDuration, canDispell, ...)
for i = 1, select("#", ...) do
local filterName = select(i, ...)
+120
View File
@@ -1,5 +1,6 @@
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local UF = E:GetModule("UnitFrames")
local NP = E:GetModule('NamePlates')
local LSM = E.Libs.LSM
--Lua functions
@@ -16,6 +17,58 @@ local UnitCanAttack = UnitCanAttack
local UnitIsFriend = UnitIsFriend
local UnitIsUnit = UnitIsUnit
UF.MatchGrowthY = { TOP = 'TOP', BOTTOM = 'BOTTOM' }
UF.MatchGrowthX = { LEFT = 'LEFT', RIGHT = 'RIGHT' }
UF.SortAuraFuncs = {
TIME_REMAINING = function(a, b, dir)
local A = a.noTime and huge or a.expiration or -huge
local B = b.noTime and huge or b.expiration or -huge
if dir == 'DESCENDING' then return A < B else return A > B end
end,
DURATION = function(a, b, dir)
local A = a.noTime and huge or a.duration or -huge
local B = b.noTime and huge or b.duration or -huge
if dir == 'DESCENDING' then return A < B else return A > B end
end,
NAME = function(a, b, dir)
local A, B = a.name or '', b.name or ''
if dir == 'DESCENDING' then return A < B else return A > B end
end,
PLAYER = function(a, b, dir)
local A, B = a.isPlayer or false, b.isPlayer or false
if dir == 'DESCENDING' then return A and not B else return not A and B end
end,
}
UF.SmartPosition = {
BUFFS_ON_DEBUFFS = {
from = 'BUFFS', to = 'Debuffs',
warning = format(L["This setting caused a conflicting anchor point, where '%s' would be attached to itself. Please check your anchor points. Setting '%s' to be attached to '%s'."], L["Buffs"], L["Debuffs"], L["Frame"]),
func = function(db, buffs, debuffs)
db.buffs.attachTo = 'DEBUFFS'
buffs.attachTo = debuffs
buffs.PostUpdate = nil
debuffs.PostUpdate = UF.UpdateAuraSmartPoisition
end
},
DEBUFFS_ON_BUFFS = {
from = 'DEBUFFS', to = 'Buffs',
warning = format(L["This setting caused a conflicting anchor point, where '%s' would be attached to itself. Please check your anchor points. Setting '%s' to be attached to '%s'."], L["Debuffs"], L["Buffs"], L["Frame"]),
func = function(db, buffs, debuffs)
db.debuffs.attachTo = 'BUFFS'
debuffs.attachTo = buffs
debuffs.PostUpdate = nil
buffs.PostUpdate = UF.UpdateAuraSmartPoisition
end
}
}
UF.SmartPosition.FLUID_BUFFS_ON_DEBUFFS = E:CopyTable({fluid = true}, UF.SmartPosition.BUFFS_ON_DEBUFFS)
UF.SmartPosition.FLUID_DEBUFFS_ON_BUFFS = E:CopyTable({fluid = true}, UF.SmartPosition.DEBUFFS_ON_BUFFS)
function UF:Construct_Buffs(frame)
local buffs = CreateFrame("Frame", frame:GetName().."Buffs", frame)
buffs.spacing = E.Spacing
@@ -134,6 +187,48 @@ function UF:UpdateAuraCooldownPosition(button)
button.needsUpdateCooldownPosition = nil
end
function UF:GetAuraElements(frame)
if frame.isNamePlate then
return frame.Buffs_, frame.Debuffs_
else
return frame.Buffs, frame.Debuffs
end
end
function UF:SetSmartPosition(frame, db)
if frame.isNamePlate then db = NP:PlateDB(frame) end
local position, fluid = db.smartAuraPosition
local buffs, debuffs = UF:GetAuraElements(frame)
local info = UF.SmartPosition[position]
if info then
local TO = db[strlower(info.to)]
if TO.attachTo == info.from then
TO.attachTo = 'FRAME'
E:Print(info.warning)
local element = (info.to == 'Debuffs' and debuffs) or buffs
element.attachTo = frame
element:ClearAllPoints()
element:Point(element.initialAnchor, element.attachTo, element.anchorPoint, element.xOffset, element.yOffset)
end
fluid = info.fluid
info.func(db, buffs, debuffs, info.isFuild)
else
buffs.PostUpdate = nil
debuffs.PostUpdate = nil
end
if db.debuffs.attachTo == 'BUFFS' and db.buffs.attachTo == 'DEBUFFS' then
E:Print(format(L["%s frame has a conflicting anchor point. Forcing the Buffs to be attached to the main unitframe."], E:StringTitle(frame:GetName())))
db.buffs.attachTo = 'FRAME'
end
return position, fluid
end
function UF:Configure_Auras(frame, auraType)
if not frame.VARIABLES_SET then return end
@@ -382,6 +477,31 @@ function UF:PostUpdateAura(unit, button)
end
end
function UF:GetSmartAuraElements(auras)
local Buffs, Debuffs = UF:GetAuraElements(auras:GetParent())
if auras == Buffs then
return Debuffs, Buffs, auras.visibleBuffs
else
return Buffs, Debuffs, auras.visibleDebuffs
end
end
function UF:UpdateAuraSmartPoisition()
local element, other, visible = UF:GetSmartAuraElements(self)
if visible == 0 then
if self.smartFluid then
element:ClearAllPoints()
element:Point(other.initialAnchor, other.attachTo, other.anchorPoint, other.xOffset, other.yOffset)
else
other:Height(UF:GetAuraPosition(other, true))
end
else
element:ClearAllPoints()
element:Point(element.initialAnchor, element.attachTo, element.anchorPoint, element.xOffset, element.yOffset)
end
end
function UF:AuraFilter(unit, button, name, _, _, _, debuffType, duration, expiration, caster, isStealable, _, spellID)
if not name then return end -- checking for an aura that is not there, pass nil to break while loop
@@ -10,7 +10,7 @@ function UF:Construct_Cutaway(frame)
if frame.Power then
local powerTexture = frame.Power:GetStatusBarTexture()
local cutawayPower = frame.Power.ClipFrame:CreateTexture(frameName.."CutawayPower")
local cutawayPower = frame.Power:CreateTexture(frameName.."CutawayPower")
cutawayPower:SetPoint("TOPLEFT", powerTexture, "TOPRIGHT")
cutawayPower:SetPoint("BOTTOMLEFT", powerTexture, "BOTTOMRIGHT")
cutawayPower:SetTexture(E.media.blankTex)
@@ -18,7 +18,7 @@ function UF:Construct_Cutaway(frame)
end
local healthTexture = frame.Health:GetStatusBarTexture()
local cutawayHealth = frame.Health.ClipFrame:CreateTexture(frameName.."CutawayHealth")
local cutawayHealth = frame.Health:CreateTexture(frameName.."CutawayHealth")
cutawayHealth:SetPoint("TOPLEFT", healthTexture, "TOPRIGHT")
cutawayHealth:SetPoint("BOTTOMLEFT", healthTexture, "BOTTOMRIGHT")
cutawayHealth:SetTexture(E.media.blankTex)
@@ -65,6 +65,12 @@ function UF:Configure_Happiness(frame)
end
function UF:HappinessOverride(event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if not unit or self.unit ~= unit then return end
local db = self.db
@@ -60,7 +60,7 @@ function UF:Configure_Energy(frame)
local energy = frame.Energy
energy.origParent = frame
if frame.USE_ENERGYBAR then
if frame.USE_ENERGYBAR and C_Player:IsHero() then
if not frame:IsElementEnabled("Energy") then
frame:EnableElement("Energy")
energy:Show()
@@ -60,7 +60,7 @@ function UF:Configure_Rage(frame)
local rage = frame.Rage
rage.origParent = frame
if frame.USE_RAGEBAR then
if frame.USE_RAGEBAR and C_Player:IsHero() then
if not frame:IsElementEnabled("Rage") then
frame:EnableElement("Rage")
rage:Show()
@@ -30,6 +30,12 @@ function UF:Configure_PVPIcon(frame)
end
function UF:UpdateOverridePvP(event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if not unit or self.unit ~= unit then return end
local element = self.PvPIndicator
+6 -1
View File
@@ -95,7 +95,12 @@ end
function UF:UpdateThreat(unit, status, r, g, b)
local parent = self:GetParent()
if unit and parent.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = parent.unit and UnitIsUnit(parent.unit, unit)
if isUnit then
unit = parent.unit
end
end
if (parent.unit ~= unit) or not unit then return end
local db = parent.db
+15
View File
@@ -461,6 +461,21 @@ function UF:Configure_Fader(frame)
end
end
function UF:Construct_ClipFrame(frame, bar)
local clipFrame = CreateFrame('ScrollFrame', nil, bar)
clipFrame:SetAllPoints()
clipFrame:EnableMouse(false)
local child = CreateFrame("Frame", nil, clipFrame)
child:SetPoint("CENTER")
child:SetSize(clipFrame:GetSize())
child.__frame = frame
bar.ClipFrame = child
return child
end
function UF:Configure_FontString(obj)
UF.fontstrings[obj] = true
obj:FontTemplate() --This is temporary.