performance update

performance update
This commit is contained in:
Meow
2026-01-03 12:33:39 +01:00
committed by GitHub
parent b0a0d88a7b
commit 9e434b515b
3 changed files with 109 additions and 56 deletions
+76
View File
@@ -7,6 +7,82 @@ setfenv(1, pfUI:GetEnvironment())
gfind = string.gmatch or string.gfind
mod = math.mod or mod
-- [ DLL Detection Helpers ]
-- Detects presence of various DLL extensions for enhanced functionality
-- [ HasSuperWoW ]
-- Returns true if SuperWoW DLL is active
-- SuperWoW provides: UNIT_CASTEVENT, UnitPosition, SetMouseoverUnit, SpellInfo, etc.
function pfUI.api.HasSuperWoW()
return SUPERWOW_VERSION or (SetAutoloot and SpellInfo)
end
-- [ HasUnitXP ]
-- Returns true if UnitXP_SP3 DLL is active
-- UnitXP provides: distance, line of sight, behind detection, targeting helpers
function pfUI.api.HasUnitXP()
local success = pcall(UnitXP, "nop", "nop")
return success
end
-- [ HasNampower ]
-- Returns true if Nampower DLL is active
-- Nampower provides: spell queuing, GetCastInfo, GetSpellIdCooldown, IsSpellInRange, etc.
function pfUI.api.HasNampower()
return GetNampowerVersion and true or false
end
-- [ GetUnitDistance ]
-- Returns distance to unit using best available method
-- 'unit1' [string] first unit (default: "player")
-- 'unit2' [string] second unit
-- returns: [number] distance in yards, or nil if unavailable
function pfUI.api.GetUnitDistance(unit1, unit2)
if not unit2 then
unit2 = unit1
unit1 = "player"
end
if not UnitExists(unit2) then return nil end
-- Try UnitXP first (most accurate)
if pfUI.api.HasUnitXP() then
local success, distance = pcall(UnitXP, "distanceBetween", unit1, unit2)
if success and distance then return distance end
end
-- Try SuperWoW UnitPosition
if pfUI.api.HasSuperWoW() and UnitPosition then
local x1, y1, z1 = UnitPosition(unit1)
local x2, y2, z2 = UnitPosition(unit2)
if x1 and y1 and z1 and x2 and y2 and z2 then
return ((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)^0.5
end
end
return nil
end
-- [ UnitInLineOfSight ]
-- Returns true if unit1 has line of sight to unit2
-- Requires UnitXP_SP3
function pfUI.api.UnitInLineOfSight(unit1, unit2)
if not pfUI.api.HasUnitXP() then return nil end
local success, inSight = pcall(UnitXP, "inSight", unit1, unit2)
if success then return inSight end
return nil
end
-- [ UnitIsBehind ]
-- Returns true if unit1 is behind unit2
-- Requires UnitXP_SP3
function pfUI.api.UnitIsBehind(unit1, unit2)
if not pfUI.api.HasUnitXP() then return nil end
local success, behind = pcall(UnitXP, "behind", unit1, unit2)
if success then return behind end
return nil
end
-- [ strsplit ]
-- Splits a string using a delimiter.
-- 'delimiter' [string] characters that will be interpreted as delimiter
+13
View File
@@ -221,6 +221,18 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", nil, "druidmanabar", "1")
pfUI:UpdateConfig("unitframes", nil, "druidmanaheight", "2")
pfUI:UpdateConfig("unitframes", nil, "druidmanatext", "0")
pfUI:UpdateConfig("unitframes", nil, "spellqueue", "1")
pfUI:UpdateConfig("unitframes", nil, "spellqueuesize", "24")
pfUI:UpdateConfig("unitframes", nil, "gcd_indicator", "0")
pfUI:UpdateConfig("unitframes", nil, "gcd_size", "4")
pfUI:UpdateConfig("unitframes", nil, "nampower_buffs", "1")
pfUI:UpdateConfig("unitframes", nil, "reactive_indicator", "0")
pfUI:UpdateConfig("unitframes", nil, "reactive_size", "28")
pfUI:UpdateConfig("unitframes", nil, "damage_tracking", "0")
pfUI:UpdateConfig("unitframes", nil, "los_indicator", "0")
pfUI:UpdateConfig("unitframes", nil, "behind_indicator", "0")
pfUI:UpdateConfig("unitframes", nil, "unitxp_notify", "0")
pfUI:UpdateConfig("unitframes", nil, "track_group", "0")
pfUI:UpdateConfig("unitframes", nil, "rangechecki", "4")
pfUI:UpdateConfig("unitframes", nil, "combowidth", "6")
pfUI:UpdateConfig("unitframes", nil, "comboheight", "6")
@@ -713,6 +725,7 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("chat", "text", "playerlinks", "1")
pfUI:UpdateConfig("chat", "text", "detecturl", "1")
pfUI:UpdateConfig("chat", "text", "classcolor", "1")
pfUI:UpdateConfig("chat", "text", "playerlevel", "1")
pfUI:UpdateConfig("chat", "text", "whosearchunknown", "0")
pfUI:UpdateConfig("chat", "left", "width", "380")
pfUI:UpdateConfig("chat", "left", "height", "180")
+20 -56
View File
@@ -420,21 +420,7 @@ function pfUI.uf:UpdateVisibility()
self.visible = nil
end
-- tbc visibility
if pfUI.client > 11200 then
self:SetAttribute("unit", unitstr)
-- update visibility condition on change
if self.visibilitycondition ~= visibility then
RegisterStateDriver(self, 'visibility', visibility)
self.visibilitycondition = visibility
self.visible = true
end
return
end
-- vanilla visibility
-- visibility
if self.unitname and self.unitname ~= "focus" and self.unitname ~= "focustarget" then
self:Show()
elseif visibility == "hide" then
@@ -866,8 +852,6 @@ function pfUI.uf:UpdateConfig()
if f:GetName() == "pfPlayer" then
f.buffs[i]:SetScript("OnUpdate", BuffOnUpdate)
elseif f:GetName() == "pfTarget" and pfUI.expansion == "tbc" then
f.buffs[i]:SetScript("OnUpdate", TargetBuffOnUpdate)
end
f.buffs[i]:SetScript("OnEnter", BuffOnEnter)
@@ -1209,6 +1193,18 @@ end
function pfUI.uf.OnEnter()
if not this.label then return end
-- SuperWoW: Set native mouseover unit for macro/addon compatibility
if SetMouseoverUnit then
local unitstr = this.label .. this.id
-- For GUID-based frames (focus), use the GUID directly
if this.label and string.find(this.label, "^0x") then
SetMouseoverUnit(this.label)
elseif UnitExists(unitstr) then
SetMouseoverUnit(unitstr)
end
end
if this.config.showtooltip == "0" then return end
GameTooltip_SetDefaultAnchor(GameTooltip, this)
GameTooltip:SetUnit(this.label .. this.id)
@@ -1216,6 +1212,11 @@ function pfUI.uf.OnEnter()
end
function pfUI.uf.OnLeave()
-- SuperWoW: Clear native mouseover unit
if SetMouseoverUnit then
SetMouseoverUnit()
end
GameTooltip:FadeOut()
end
@@ -2139,33 +2140,8 @@ function pfUI.uf:EnableClickCast()
local bconf = bid == 1 and "" or bid
if pfUI_config.unitframes["clickcast"..bconf..mconf] ~= "" then
-- prepare click casting
if pfUI.client > 11200 then
-- set attributes for tbc+
local prefix = modifier == "" and "" or modifier .. "-"
-- check for "/" in the beginning of the string, to detect macros
if string.find(pfUI_config.unitframes["clickcast"..bconf..mconf], "^%/(.+)") then
self:SetAttribute(prefix.."type"..bid, "macro")
self:SetAttribute(prefix.."macrotext"..bid, pfUI_config.unitframes["clickcast"..bconf..mconf])
self:SetAttribute(prefix.."spell"..bid, nil)
elseif string.find(pfUI_config.unitframes["clickcast"..bconf..mconf], "^target") then
self:SetAttribute(prefix.."type"..bid, "target")
self:SetAttribute(prefix.."macrotext"..bid, nil)
self:SetAttribute(prefix.."spell"..bid, nil)
elseif string.find(pfUI_config.unitframes["clickcast"..bconf..mconf], "^menu") then
self:SetAttribute(prefix.."type"..bid, "showmenu")
self:SetAttribute(prefix.."macrotext"..bid, nil)
self:SetAttribute(prefix.."spell"..bid, nil)
else
self:SetAttribute(prefix.."type"..bid, "spell")
self:SetAttribute(prefix.."spell"..bid, pfUI_config.unitframes["clickcast"..bconf..mconf])
self:SetAttribute(prefix.."macro"..bid, nil)
end
else
-- fill clickaction table for vanillla
self.clickactions = self.clickactions or {}
self.clickactions[modifier..button] = pfUI_config.unitframes["clickcast"..bconf..mconf]
end
self.clickactions = self.clickactions or {}
self.clickactions[modifier..button] = pfUI_config.unitframes["clickcast"..bconf..mconf]
end
end
end
@@ -2427,8 +2403,6 @@ function pfUI.uf:SetupBuffIndicators(config)
if myclass == "WARRIOR" then
-- Battle Shout
table.insert(indicators, "interface\\icons\\ability_warrior_battleshout")
-- Commanding Shout (TBC)
table.insert(indicators, "interface\\icons\\ability_warrior_rallyingcry")
end
if myclass == "MAGE" then
@@ -2447,14 +2421,6 @@ function pfUI.uf:SetupBuffIndicators(config)
-- Aspect of the Pack
table.insert(indicators, "interface\\icons\\ability_mount_whitetiger")
-- Misdirection (TBC)
table.insert(indicators, "interface\\icons\\ability_hunter_misdirection")
end
if myclass == "SHAMAN" then
-- Earth Shield (TBC)
table.insert(indicators, "interface\\icons\\spell_nature_skinofearth")
end
end
@@ -2483,8 +2449,6 @@ function pfUI.uf:SetupBuffIndicators(config)
table.insert(indicators, "interface\\icons\\spell_holy_renew")
-- Power Word: Shield
table.insert(indicators, "interface\\icons\\spell_holy_powerwordshield")
-- Prayer of Mending (TBC)
table.insert(indicators, "interface\\icons\\spell_holy_prayerofmendingtga")
end
if myclass == "DRUID" or config.all_hots == "1" then