performance update

performance update
This commit is contained in:
Meow
2026-01-03 12:58:31 +01:00
parent b2f6df84a9
commit 5d0e195d1e
116 changed files with 3980 additions and 4105 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")
+145 -82
View File
@@ -14,6 +14,79 @@ end)
pfUI.uf.frames = {}
pfUI.uf.delayed = {}
-- =====================================================
-- ZENTRALER EVENT-HANDLER für Raid/Party Performance
-- =====================================================
pfUI.uf.unitmap = {} -- Maps "raid1" -> frame, "party2" -> frame, etc.
pfUI.uf.RebuildUnitmap = function()
-- Clear old mappings
for k in pairs(pfUI.uf.unitmap) do
pfUI.uf.unitmap[k] = nil
end
-- Rebuild raid mappings
if pfUI.uf.raid then
for i = 1, 40 do
local frame = pfUI.uf.raid[i]
if frame and frame.id and frame.id ~= 0 then
pfUI.uf.unitmap["raid" .. frame.id] = frame
end
end
end
-- Rebuild party mappings
for i = 1, 4 do
local frame = _G["pfGroup" .. i]
if frame and frame.label == "party" then
pfUI.uf.unitmap["party" .. frame.id] = frame
end
end
end
pfUI.uf.eventframe = CreateFrame("Frame")
pfUI.uf.eventframe:RegisterEvent("UNIT_HEALTH")
pfUI.uf.eventframe:RegisterEvent("UNIT_MAXHEALTH")
pfUI.uf.eventframe:RegisterEvent("UNIT_MANA")
pfUI.uf.eventframe:RegisterEvent("UNIT_MAXMANA")
pfUI.uf.eventframe:RegisterEvent("UNIT_RAGE")
pfUI.uf.eventframe:RegisterEvent("UNIT_MAXRAGE")
pfUI.uf.eventframe:RegisterEvent("UNIT_ENERGY")
pfUI.uf.eventframe:RegisterEvent("UNIT_MAXENERGY")
pfUI.uf.eventframe:RegisterEvent("UNIT_AURA")
pfUI.uf.eventframe:RegisterEvent("UNIT_PORTRAIT_UPDATE")
pfUI.uf.eventframe:RegisterEvent("UNIT_MODEL_CHANGED")
pfUI.uf.eventframe:RegisterEvent("UNIT_DISPLAYPOWER")
pfUI.uf.eventframe:RegisterEvent("UNIT_FACTION")
pfUI.uf.eventframe:RegisterEvent("RAID_ROSTER_UPDATE")
pfUI.uf.eventframe:RegisterEvent("PARTY_MEMBERS_CHANGED")
pfUI.uf.eventframe:SetScript("OnEvent", function()
-- Unitmap neu aufbauen bei Roster-Änderungen
if event == "RAID_ROSTER_UPDATE" or event == "PARTY_MEMBERS_CHANGED" then
pfUI.uf.RebuildUnitmap()
return
end
if not arg1 then return end
-- Direkt den richtigen Frame finden
local frame = pfUI.uf.unitmap[arg1]
if not frame then return end
-- Event verarbeiten (gleiche Logik wie vorher)
if event == "UNIT_PORTRAIT_UPDATE" or event == "UNIT_MODEL_CHANGED" then
frame.update_portrait = true
elseif event == "UNIT_AURA" then
frame.update_aura = true
elseif event == "UNIT_FACTION" then
frame.update_pvp = true
else
frame.update_full = true
end
end)
-- =====================================================
-- slash command to toggle unitframe test mode
_G.SLASH_PFTEST1, _G.SLASH_PFTEST2 = "/pftest", "/pfuftest"
_G.SlashCmdList.PFTEST = function()
@@ -51,6 +124,9 @@ local function BuffOnUpdate()
end
local function TargetBuffOnUpdate()
-- throttle to 0.1s
if ( this.tick or .1) > GetTime() then return else this.tick = GetTime() + .1 end
local name, rank, icon, count, duration, timeleft = _G.UnitBuff("target", this.id)
if duration and timeleft then
CooldownFrame_SetTimer(this.cd, GetTime() + timeleft - duration, duration, 1)
@@ -344,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
@@ -790,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)
@@ -921,6 +981,13 @@ function pfUI.uf.OnUpdate()
-- update combat feedback
if this.feedbackText then CombatFeedback_OnUpdate(arg1) end
-- Throttle for raid/party frames: only process updates every 0.1s
-- This reduces OnUpdate calls from 5760/sec (40 frames * 144fps) to ~400/sec
if this.label == "raid" or this.label == "party" then
if (this.tick or 0) > GetTime() then return end
this.tick = GetTime() + 0.1
end
-- process indicator update events
if this.update_indicators then
pfUI.uf:RefreshIndicators(this)
@@ -1126,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)
@@ -1133,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
@@ -1164,33 +1248,49 @@ end
function pfUI.uf:EnableEvents()
local f = self
local unitstr = f.label .. f.id
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:RegisterEvent("UNIT_DISPLAYPOWER")
f:RegisterEvent("UNIT_HEALTH")
f:RegisterEvent("UNIT_MAXHEALTH")
f:RegisterEvent("UNIT_MANA")
f:RegisterEvent("UNIT_MAXMANA")
f:RegisterEvent("UNIT_RAGE")
f:RegisterEvent("UNIT_MAXRAGE")
f:RegisterEvent("UNIT_ENERGY")
f:RegisterEvent("UNIT_MAXENERGY")
f:RegisterEvent("UNIT_FOCUS")
f:RegisterEvent("UNIT_PORTRAIT_UPDATE")
f:RegisterEvent("UNIT_MODEL_CHANGED")
f:RegisterEvent("UNIT_FACTION")
f:RegisterEvent("UNIT_AURA") -- frame=buff, frame=debuff
f:RegisterEvent("PLAYER_AURAS_CHANGED") -- label=player && frame=buff
f:RegisterEvent("UNIT_INVENTORY_CHANGED") -- label=player && frame=buff
f:RegisterEvent("PARTY_MEMBERS_CHANGED") -- label=party, frame=leaderIcon
f:RegisterEvent("PARTY_LEADER_CHANGED") -- frame=leaderIcon
f:RegisterEvent("RAID_ROSTER_UPDATE") -- label=raidIcon
f:RegisterEvent("PLAYER_UPDATE_RESTING") -- label=restIcon
f:RegisterEvent("PLAYER_TARGET_CHANGED") -- label=target
f:RegisterEvent("PARTY_LOOT_METHOD_CHANGED") -- frame=lootIcon
f:RegisterEvent("RAID_TARGET_UPDATE") -- frame=raidIcon
f:RegisterEvent("UNIT_PET")
f:RegisterEvent("UNIT_HAPPINESS")
-- Raid/Party Frames: Registriere im zentralen Handler statt selbst
if f.label == "raid" or f.label == "party" then
-- Nur nicht-UNIT_* Events selbst registrieren
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:RegisterEvent("PARTY_MEMBERS_CHANGED")
f:RegisterEvent("PARTY_LEADER_CHANGED")
f:RegisterEvent("RAID_ROSTER_UPDATE")
f:RegisterEvent("PARTY_LOOT_METHOD_CHANGED")
f:RegisterEvent("RAID_TARGET_UPDATE")
-- Unitmap aktualisieren
pfUI.uf.RebuildUnitmap()
else
-- Alle anderen Frames: Normale Event-Registrierung
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:RegisterEvent("UNIT_DISPLAYPOWER")
f:RegisterEvent("UNIT_HEALTH")
f:RegisterEvent("UNIT_MAXHEALTH")
f:RegisterEvent("UNIT_MANA")
f:RegisterEvent("UNIT_MAXMANA")
f:RegisterEvent("UNIT_RAGE")
f:RegisterEvent("UNIT_MAXRAGE")
f:RegisterEvent("UNIT_ENERGY")
f:RegisterEvent("UNIT_MAXENERGY")
f:RegisterEvent("UNIT_FOCUS")
f:RegisterEvent("UNIT_PORTRAIT_UPDATE")
f:RegisterEvent("UNIT_MODEL_CHANGED")
f:RegisterEvent("UNIT_FACTION")
f:RegisterEvent("UNIT_AURA")
f:RegisterEvent("PLAYER_AURAS_CHANGED")
f:RegisterEvent("UNIT_INVENTORY_CHANGED")
f:RegisterEvent("PARTY_MEMBERS_CHANGED")
f:RegisterEvent("PARTY_LEADER_CHANGED")
f:RegisterEvent("RAID_ROSTER_UPDATE")
f:RegisterEvent("PLAYER_UPDATE_RESTING")
f:RegisterEvent("PLAYER_TARGET_CHANGED")
f:RegisterEvent("PARTY_LOOT_METHOD_CHANGED")
f:RegisterEvent("RAID_TARGET_UPDATE")
f:RegisterEvent("UNIT_PET")
f:RegisterEvent("UNIT_HAPPINESS")
end
f:RegisterForClicks('LeftButtonUp', 'RightButtonUp',
'MiddleButtonUp', 'Button4Up', 'Button5Up')
@@ -2040,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
@@ -2328,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
@@ -2348,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
@@ -2384,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