mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-28 18:36:01 +00:00
performance update
performance update
This commit is contained in:
+145
-82
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user