From f85de73816d5d575a5e9d86a1f716c835e70d52a Mon Sep 17 00:00:00 2001 From: shagu Date: Wed, 20 May 2020 16:32:02 +0200 Subject: [PATCH] nameplates: don't pollute parent frame with shortcuts --- modules/nameplates.lua | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/modules/nameplates.lua b/modules/nameplates.lua index f4c931eb..ca224e1b 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -168,22 +168,23 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () nameplate.cache = {} nameplate.UnitDebuff = PlateUnitDebuff nameplate.CacheDebuffs = PlateCacheDebuffs + nameplate.original = {} -- create shortcuts for all known elements and disable them - parent.healthbar, parent.castbar = parent:GetChildren() - DisableObject(parent.healthbar) - DisableObject(parent.castbar) + nameplate.original.healthbar, nameplate.original.castbar = parent:GetChildren() + DisableObject(nameplate.original.healthbar) + DisableObject(nameplate.original.castbar) for i, object in pairs({parent:GetRegions()}) do if NAMEPLATE_OBJECTORDER[i] and NAMEPLATE_OBJECTORDER[i] == "raidicon" then nameplate[NAMEPLATE_OBJECTORDER[i]] = object else - parent[NAMEPLATE_OBJECTORDER[i]] = object + nameplate.original[NAMEPLATE_OBJECTORDER[i]] = object DisableObject(object) end end - HookScript(parent.healthbar, "OnValueChanged", nameplates.OnValueChanged) + HookScript(nameplate.original.healthbar, "OnValueChanged", nameplates.OnValueChanged) -- adjust sizes and scaling of the nameplate nameplate:SetScale(UIParent:GetScale()) @@ -382,18 +383,18 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () end nameplates.OnDataChanged = function(self, plate) - local hp = plate.parent.healthbar:GetValue() - local hpmin, hpmax = plate.parent.healthbar:GetMinMaxValues() - local name = plate.parent.name:GetText() - local level = plate.parent.level:IsShown() and plate.parent.level:GetObjectType() == "FontString" and tonumber(plate.parent.level:GetText()) or "??" + local hp = plate.original.healthbar:GetValue() + local hpmin, hpmax = plate.original.healthbar:GetMinMaxValues() + local name = plate.original.name:GetText() + local level = plate.original.level:IsShown() and plate.original.level:GetObjectType() == "FontString" and tonumber(plate.original.level:GetText()) or "??" local class, _, elite, player = GetUnitData(name, true) local target = UnitExists("target") and plate.parent:GetAlpha() == 1 or nil - local mouseover = UnitExists("mouseover") and plate.parent.glow:IsShown() or nil + local mouseover = UnitExists("mouseover") and plate.original.glow:IsShown() or nil local unitstr = target and "target" or mouseover and "mouseover" or nil - local red, green, blue = plate.parent.healthbar:GetStatusBarColor() + local red, green, blue = plate.original.healthbar:GetStatusBarColor() local unittype = GetUnitType(red, green, blue) if player and unittype == "ENEMY_NPC" then unittype = "ENEMY_PLAYER" end - elite = plate.parent.levelicon:IsShown() and not player and "boss" or elite + elite = plate.original.levelicon:IsShown() and not player and "boss" or elite if not class then plate.wait_for_scan = true end -- target event sometimes fires too quickly, where nameplate identifiers are not @@ -521,7 +522,7 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function () local frame = frame or this local name = frame.name:GetText() local target = UnitExists("target") and frame:GetAlpha() == 1 or nil - local mouseover = UnitExists("mouseover") and frame.glow:IsShown() or nil + local mouseover = UnitExists("mouseover") and frame.nameplate.original.glow:IsShown() or nil if frame:GetAlpha() < tonumber(C.nameplates.notargalpha) then frame:SetAlpha(tonumber(C.nameplates.notargalpha)) end