mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-21 03:40:49 +00:00
nameplates: reduce load by caching the name
This commit is contained in:
+33
-32
@@ -304,26 +304,27 @@ pfUI:RegisterModule("nameplates", function ()
|
|||||||
|
|
||||||
local healthbar = this.healthbar
|
local healthbar = this.healthbar
|
||||||
local border, glow, name, level, levelicon , raidicon = this.border, this.glow, this.name, this.level, this.levelicon , this.raidicon
|
local border, glow, name, level, levelicon , raidicon = this.border, this.glow, this.name, this.level, this.levelicon , this.raidicon
|
||||||
|
local unitname = name:GetText()
|
||||||
|
|
||||||
-- add scan entry if not existing
|
-- add scan entry if not existing
|
||||||
if this.needNameUpdate and name:GetText() ~= UNKNOWN then
|
if this.needNameUpdate and unitname ~= UNKNOWN then
|
||||||
if not pfUI.nameplates.targets[this.name:GetText()] then
|
if not pfUI.nameplates.targets[unitname] then
|
||||||
table.insert(pfUI.nameplates.scanqueue, this.name:GetText())
|
table.insert(pfUI.nameplates.scanqueue, unitname)
|
||||||
end
|
end
|
||||||
this.needNameUpdate = nil
|
this.needNameUpdate = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- hide non-player frames
|
-- hide non-player frames
|
||||||
if C.nameplates.players == "1" and not this.needNameUpdate then
|
if C.nameplates.players == "1" and not this.needNameUpdate then
|
||||||
if pfUI.nameplates.targets[name:GetText()] == "OK" then
|
if pfUI.nameplates.targets[unitname] == "OK" then
|
||||||
if not pfUI.nameplates.players[name:GetText()] then this:Hide() end
|
if not pfUI.nameplates.players[unitname] then this:Hide() end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- hide critters
|
-- hide critters
|
||||||
if C.nameplates.critters == "1" and not this.needNameUpdate then
|
if C.nameplates.critters == "1" and not this.needNameUpdate then
|
||||||
local red, green, blue, _ = healthbar:GetStatusBarColor()
|
local red, green, blue, _ = healthbar:GetStatusBarColor()
|
||||||
local name_val = name:GetText()
|
local name_val = unitname
|
||||||
for i, critter_val in pairs(L["critters"]) do
|
for i, critter_val in pairs(L["critters"]) do
|
||||||
if red > 0.9 and green > 0.9 and blue < 0.2 and name_val == critter_val then
|
if red > 0.9 and green > 0.9 and blue < 0.2 and name_val == critter_val then
|
||||||
this:Hide()
|
this:Hide()
|
||||||
@@ -332,13 +333,13 @@ pfUI:RegisterModule("nameplates", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- level elite indicator
|
-- level elite indicator
|
||||||
if this.needEliteUpdate and pfUI.nameplates.mobs[name:GetText()] then
|
if this.needEliteUpdate and pfUI.nameplates.mobs[unitname] then
|
||||||
if level:GetText() ~= nil then
|
if level:GetText() ~= nil then
|
||||||
if pfUI.nameplates.mobs[name:GetText()] == "elite" then
|
if pfUI.nameplates.mobs[unitname] == "elite" then
|
||||||
level:SetText(level:GetText() .. "+")
|
level:SetText(level:GetText() .. "+")
|
||||||
elseif pfUI.nameplates.mobs[name:GetText()] == "rareelite" then
|
elseif pfUI.nameplates.mobs[unitname] == "rareelite" then
|
||||||
level:SetText(level:GetText() .. "R+")
|
level:SetText(level:GetText() .. "R+")
|
||||||
elseif pfUI.nameplates.mobs[name:GetText()] == "rare" then
|
elseif pfUI.nameplates.mobs[unitname] == "rare" then
|
||||||
level:SetText(level:GetText() .. "R")
|
level:SetText(level:GetText() .. "R")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -380,30 +381,30 @@ pfUI:RegisterModule("nameplates", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- add class colors
|
-- add class colors
|
||||||
if this.needClassColorUpdate and pfUI.nameplates.targets[name:GetText()] == "OK" then
|
if this.needClassColorUpdate and pfUI.nameplates.targets[unitname] == "OK" then
|
||||||
-- show class names?
|
-- show class names?
|
||||||
if healthbar.reaction == 0 then
|
if healthbar.reaction == 0 then
|
||||||
if C.nameplates["enemyclassc"] == "1"
|
if C.nameplates["enemyclassc"] == "1"
|
||||||
and pfUI.nameplates.players[name:GetText()]
|
and pfUI.nameplates.players[unitname]
|
||||||
and pfUI.nameplates.players[name:GetText()]["class"]
|
and pfUI.nameplates.players[unitname]["class"]
|
||||||
and RAID_CLASS_COLORS[pfUI.nameplates.players[name:GetText()]["class"]]
|
and RAID_CLASS_COLORS[pfUI.nameplates.players[unitname]["class"]]
|
||||||
then
|
then
|
||||||
healthbar:SetStatusBarColor(
|
healthbar:SetStatusBarColor(
|
||||||
RAID_CLASS_COLORS[pfUI.nameplates.players[name:GetText()]["class"]].r,
|
RAID_CLASS_COLORS[pfUI.nameplates.players[unitname]["class"]].r,
|
||||||
RAID_CLASS_COLORS[pfUI.nameplates.players[name:GetText()]["class"]].g,
|
RAID_CLASS_COLORS[pfUI.nameplates.players[unitname]["class"]].g,
|
||||||
RAID_CLASS_COLORS[pfUI.nameplates.players[name:GetText()]["class"]].b,
|
RAID_CLASS_COLORS[pfUI.nameplates.players[unitname]["class"]].b,
|
||||||
0.9)
|
0.9)
|
||||||
end
|
end
|
||||||
elseif healthbar.reaction == 2 then
|
elseif healthbar.reaction == 2 then
|
||||||
if C.nameplates["friendclassc"] == "1"
|
if C.nameplates["friendclassc"] == "1"
|
||||||
and pfUI.nameplates.players[name:GetText()]
|
and pfUI.nameplates.players[unitname]
|
||||||
and pfUI.nameplates.players[name:GetText()]["class"]
|
and pfUI.nameplates.players[unitname]["class"]
|
||||||
and RAID_CLASS_COLORS[pfUI.nameplates.players[name:GetText()]["class"]]
|
and RAID_CLASS_COLORS[pfUI.nameplates.players[unitname]["class"]]
|
||||||
then
|
then
|
||||||
healthbar:SetStatusBarColor(
|
healthbar:SetStatusBarColor(
|
||||||
RAID_CLASS_COLORS[pfUI.nameplates.players[name:GetText()]["class"]].r,
|
RAID_CLASS_COLORS[pfUI.nameplates.players[unitname]["class"]].r,
|
||||||
RAID_CLASS_COLORS[pfUI.nameplates.players[name:GetText()]["class"]].g,
|
RAID_CLASS_COLORS[pfUI.nameplates.players[unitname]["class"]].g,
|
||||||
RAID_CLASS_COLORS[pfUI.nameplates.players[name:GetText()]["class"]].b,
|
RAID_CLASS_COLORS[pfUI.nameplates.players[unitname]["class"]].b,
|
||||||
0.9)
|
0.9)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -421,16 +422,16 @@ pfUI:RegisterModule("nameplates", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- show castbar
|
-- show castbar
|
||||||
if healthbar.castbar and pfUI.castbar and C.nameplates["showcastbar"] == "1" and pfUI.castbar.target.casterDB[name:GetText()] ~= nil and pfUI.castbar.target.casterDB[name:GetText()]["cast"] ~= nil then
|
if healthbar.castbar and pfUI.castbar and C.nameplates["showcastbar"] == "1" and pfUI.castbar.target.casterDB[unitname] ~= nil and pfUI.castbar.target.casterDB[unitname]["cast"] ~= nil then
|
||||||
if pfUI.castbar.target.casterDB[name:GetText()]["starttime"] + pfUI.castbar.target.casterDB[name:GetText()]["casttime"] <= GetTime() then
|
if pfUI.castbar.target.casterDB[unitname]["starttime"] + pfUI.castbar.target.casterDB[unitname]["casttime"] <= GetTime() then
|
||||||
pfUI.castbar.target.casterDB[name:GetText()] = nil
|
pfUI.castbar.target.casterDB[unitname] = nil
|
||||||
healthbar.castbar:Hide()
|
healthbar.castbar:Hide()
|
||||||
else
|
else
|
||||||
healthbar.castbar:SetMinMaxValues(0, pfUI.castbar.target.casterDB[name:GetText()]["casttime"])
|
healthbar.castbar:SetMinMaxValues(0, pfUI.castbar.target.casterDB[unitname]["casttime"])
|
||||||
healthbar.castbar:SetValue(GetTime() - pfUI.castbar.target.casterDB[name:GetText()]["starttime"])
|
healthbar.castbar:SetValue(GetTime() - pfUI.castbar.target.casterDB[unitname]["starttime"])
|
||||||
healthbar.castbar.text:SetText(round( pfUI.castbar.target.casterDB[name:GetText()]["starttime"] + pfUI.castbar.target.casterDB[name:GetText()]["casttime"] - GetTime(),1))
|
healthbar.castbar.text:SetText(round( pfUI.castbar.target.casterDB[unitname]["starttime"] + pfUI.castbar.target.casterDB[unitname]["casttime"] - GetTime(),1))
|
||||||
if C.nameplates.spellname == "1" and healthbar.castbar.spell then
|
if C.nameplates.spellname == "1" and healthbar.castbar.spell then
|
||||||
healthbar.castbar.spell:SetText(pfUI.castbar.target.casterDB[name:GetText()]["cast"])
|
healthbar.castbar.spell:SetText(pfUI.castbar.target.casterDB[unitname]["cast"])
|
||||||
else
|
else
|
||||||
healthbar.castbar.spell:SetText("")
|
healthbar.castbar.spell:SetText("")
|
||||||
end
|
end
|
||||||
@@ -439,8 +440,8 @@ pfUI:RegisterModule("nameplates", function ()
|
|||||||
this.debuffs[1]:SetPoint("TOPLEFT", healthbar.castbar, "BOTTOMLEFT", 0, -3)
|
this.debuffs[1]:SetPoint("TOPLEFT", healthbar.castbar, "BOTTOMLEFT", 0, -3)
|
||||||
end
|
end
|
||||||
|
|
||||||
if pfUI.castbar.target.casterDB[name:GetText()]["icon"] then
|
if pfUI.castbar.target.casterDB[unitname]["icon"] then
|
||||||
healthbar.castbar.icon:SetTexture("Interface\\Icons\\" .. pfUI.castbar.target.casterDB[name:GetText()]["icon"])
|
healthbar.castbar.icon:SetTexture("Interface\\Icons\\" .. pfUI.castbar.target.casterDB[unitname]["icon"])
|
||||||
healthbar.castbar.icon:SetTexCoord(.1,.9,.1,.9)
|
healthbar.castbar.icon:SetTexCoord(.1,.9,.1,.9)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user