mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-24 04:50:49 +00:00
actionbar: reduce time spent in update functions
* Introduce a list of buttons that need updates instead of iterating over all * Introduce a list of all ever created buttons * Move all (update/event/button)lists from bars into local space * Replace integer button iterators with pairs iteration * Rename ButtonUpdate to ButtonRangeUpdate as it no longer holds any other calls
This commit is contained in:
+36
-49
@@ -13,6 +13,10 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
end
|
end
|
||||||
local bpad = border > 1 and border - 1 or 1
|
local bpad = border > 1 and border - 1 or 1
|
||||||
|
|
||||||
|
local eventcache = { } -- contains a list of events that shall be processed later
|
||||||
|
local updatecache = { } -- contains a list of buttons that shall be refreshed later
|
||||||
|
local buttoncache = { } -- contains a list of all buttons ever created
|
||||||
|
|
||||||
-- hide blizzard bars
|
-- hide blizzard bars
|
||||||
local function kill(f, killshow)
|
local function kill(f, killshow)
|
||||||
if f.Show and killshow then f.Show = function() return end end
|
if f.Show and killshow then f.Show = function() return end end
|
||||||
@@ -377,24 +381,18 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ButtonUpdate(self)
|
local function ButtonRangeUpdate(self)
|
||||||
local self = self or this
|
local self = self or this
|
||||||
|
|
||||||
-- trigger forced updates
|
|
||||||
if self.forceupdate then
|
|
||||||
self.forceupdate = nil
|
|
||||||
ButtonRefresh(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- update range display
|
-- update range display
|
||||||
if C.bars.glowrange == "1" and self.bar ~= 11 and self.bar ~= 12 and HasAction(self.id) and ActionHasRange(self.id) and IsActionInRange(self.id) == 0 then
|
if C.bars.glowrange == "1" and self.bar ~= 11 and self.bar ~= 12 and HasAction(self.id) and ActionHasRange(self.id) and IsActionInRange(self.id) == 0 then
|
||||||
if not self.outofrange then
|
if not self.outofrange then
|
||||||
self.outofrange = true
|
self.outofrange = true
|
||||||
self.forceupdate = true
|
table.insert(updatecache, self)
|
||||||
end
|
end
|
||||||
elseif self.outofrange then
|
elseif self.outofrange then
|
||||||
self.outofrange = nil
|
self.outofrange = nil
|
||||||
self.forceupdate = true
|
table.insert(updatecache, self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -555,7 +553,7 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
|
|
||||||
-- cache events that are triggered way to often
|
-- cache events that are triggered way to often
|
||||||
if event == "ACTIONBAR_UPDATE_COOLDOWN" or event == "ACTIONBAR_UPDATE_STATE" then
|
if event == "ACTIONBAR_UPDATE_COOLDOWN" or event == "ACTIONBAR_UPDATE_STATE" then
|
||||||
self.eventcache[event] = true
|
eventcache[event] = true
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -576,10 +574,8 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- handle global events
|
-- handle global events
|
||||||
for j=1,12 do
|
for id, button in pairs(buttoncache) do
|
||||||
for i=1,10 do
|
ButtonRefresh(button)
|
||||||
if self[i][j] then ButtonRefresh(self[i][j]) end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -588,37 +584,30 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
local button
|
local button
|
||||||
|
|
||||||
-- run cached cooldown events
|
-- run cached cooldown events
|
||||||
if self.eventcache["ACTIONBAR_UPDATE_COOLDOWN"] then
|
if eventcache["ACTIONBAR_UPDATE_COOLDOWN"] then
|
||||||
self.eventcache["ACTIONBAR_UPDATE_COOLDOWN"] = nil
|
eventcache["ACTIONBAR_UPDATE_COOLDOWN"] = nil
|
||||||
for j=1,12 do
|
for id, button in pairs(buttoncache) do
|
||||||
for i=1,10 do
|
ButtonUpdateCooldown(button)
|
||||||
ButtonUpdateCooldown(self[i][j])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- run cached button state events
|
-- run cached button state events
|
||||||
if self.eventcache["ACTIONBAR_UPDATE_STATE"] then
|
if eventcache["ACTIONBAR_UPDATE_STATE"] then
|
||||||
self.eventcache["ACTIONBAR_UPDATE_STATE"] = nil
|
eventcache["ACTIONBAR_UPDATE_STATE"] = nil
|
||||||
for j=1,12 do
|
for id, button in pairs(buttoncache) do
|
||||||
for i=1,10 do
|
ButtonUpdateActive(button)
|
||||||
ButtonUpdateActive(self[i][j])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- calculate 0.1 second ticks in order to refresh range updates
|
for id, button in pairs(updatecache) do
|
||||||
self.tick = self.tick or GetTime()
|
ButtonRefresh(button)
|
||||||
if self.tick + .1 < GetTime() then self.tick = nil end
|
updatecache[id] = nil
|
||||||
local tick = not self.tick
|
end
|
||||||
|
|
||||||
for j=1,12 do
|
if ( this.tick or .2) > GetTime() then return else this.tick = GetTime() + .2 end
|
||||||
for i=1,10 do
|
|
||||||
button = self[i][j]
|
for id, button in pairs(buttoncache) do
|
||||||
if button and button:IsShown() and (tick or button.forceupdate ) then
|
if button:IsShown() then ButtonRangeUpdate(button) end
|
||||||
ButtonUpdate(button)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -627,7 +616,6 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
for event in pairs(global_events) do bars:RegisterEvent(event) end
|
for event in pairs(global_events) do bars:RegisterEvent(event) end
|
||||||
for event in pairs(aura_events) do bars:RegisterEvent(event) end
|
for event in pairs(aura_events) do bars:RegisterEvent(event) end
|
||||||
for event in pairs(pet_events) do bars:RegisterEvent(event) end
|
for event in pairs(pet_events) do bars:RegisterEvent(event) end
|
||||||
bars.eventcache = { }
|
|
||||||
|
|
||||||
-- refresh actionbar buttons on event
|
-- refresh actionbar buttons on event
|
||||||
bars:SetScript("OnEvent", BarsEvent)
|
bars:SetScript("OnEvent", BarsEvent)
|
||||||
@@ -749,6 +737,9 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
f.active:SetBackdropBorderColor(1,1,.5,1)
|
f.active:SetBackdropBorderColor(1,1,.5,1)
|
||||||
f.active:SetAllPoints()
|
f.active:SetAllPoints()
|
||||||
f.active:Hide()
|
f.active:Hide()
|
||||||
|
|
||||||
|
-- add to buttoncache
|
||||||
|
table.insert(buttoncache, f)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set animation
|
-- set animation
|
||||||
@@ -942,7 +933,7 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- refresh button
|
-- refresh button
|
||||||
bars[i][j].forceupdate = true
|
table.insert(updatecache, bars[i][j])
|
||||||
end
|
end
|
||||||
|
|
||||||
for j=buttons+1,12 do
|
for j=buttons+1,12 do
|
||||||
@@ -1033,17 +1024,13 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
if not typ then
|
if not typ then
|
||||||
showgrid = state
|
showgrid = state
|
||||||
|
|
||||||
for j=1,12 do
|
for id, button in pairs(buttoncache) do
|
||||||
for i=1,10 do
|
table.insert(updatecache, button)
|
||||||
if pfUI.bars[i][j] then
|
|
||||||
pfUI.bars[i][j].forceupdate = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
elseif typ == "PET" then
|
elseif typ == "PET" then
|
||||||
showgrid_pet = state
|
showgrid_pet = state
|
||||||
for j=1,10 do
|
for j=1,10 do
|
||||||
pfUI.bars[12][j].forceupdate = true
|
table.insert(updatecache, bars[12][j])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1060,7 +1047,7 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
local function RefreshSlot(slot)
|
local function RefreshSlot(slot)
|
||||||
local bar, button = ceil(slot/12), mod(slot, 12)
|
local bar, button = ceil(slot/12), mod(slot, 12)
|
||||||
button = button == 0 and 12 or button
|
button = button == 0 and 12 or button
|
||||||
bars[bar][button].forceupdate = true
|
table.insert(updatecache, bars[bar][button])
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Localize custom keybinds for additional actionbars (see Bindings.xml)
|
-- Localize custom keybinds for additional actionbars (see Bindings.xml)
|
||||||
@@ -1116,7 +1103,7 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
for i=1,12 do
|
for i=1,12 do
|
||||||
local id = i + (bar-1)*12
|
local id = i + (bar-1)*12
|
||||||
bars[1][i].id = id
|
bars[1][i].id = id
|
||||||
bars[1][i].forceupdate = true
|
table.insert(updatecache, bars[1][i])
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -1167,7 +1154,7 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
local action = SecureButton_GetModifiedAttribute(self, "action", SecureStateChild_GetEffectiveButton(self)) or 0
|
local action = SecureButton_GetModifiedAttribute(self, "action", SecureStateChild_GetEffectiveButton(self)) or 0
|
||||||
if self.id ~= action then
|
if self.id ~= action then
|
||||||
self.id = action
|
self.id = action
|
||||||
self.forceupdate = true
|
table.insert(updatecache, self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
## Title: |cff33ffccpf|cffffffffUI |cffaaaaaa[beta]
|
## Title: |cff33ffccpf|cffffffffUI |cffaaaaaa[beta]
|
||||||
## Author: Shagu
|
## Author: Shagu
|
||||||
## Notes: A complete user interface replacement.
|
## Notes: A complete user interface replacement.
|
||||||
## Version: 4.3.2
|
## Version: 4.3.3
|
||||||
## SavedVariables: pfUI_profiles, pfUI_addon_profiles, pfUI_cache
|
## SavedVariables: pfUI_profiles, pfUI_addon_profiles, pfUI_cache
|
||||||
## SavedVariablesPerCharacter: pfUI_config, pfUI_init, pfUI_playerDB
|
## SavedVariablesPerCharacter: pfUI_config, pfUI_init, pfUI_playerDB
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
## Title: |cff33ffccpf|cffffffffUI
|
## Title: |cff33ffccpf|cffffffffUI
|
||||||
## Author: Shagu
|
## Author: Shagu
|
||||||
## Notes: A complete user interface replacement.
|
## Notes: A complete user interface replacement.
|
||||||
## Version: 4.3.2
|
## Version: 4.3.3
|
||||||
## SavedVariables: pfUI_profiles, pfUI_addon_profiles, pfUI_cache
|
## SavedVariables: pfUI_profiles, pfUI_addon_profiles, pfUI_cache
|
||||||
## SavedVariablesPerCharacter: pfUI_config, pfUI_init, pfUI_playerDB
|
## SavedVariablesPerCharacter: pfUI_config, pfUI_init, pfUI_playerDB
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user