mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-17 10:10:50 +00:00
actionbar: move usable update into own function
Don't trigger full updates on usable changes. Also removing the `UPDATE_INVENTORY_ALERTS` event, as it is no longer in use.
This commit is contained in:
+38
-21
@@ -62,7 +62,6 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
["PLAYER_LEAVE_COMBAT"] = true,
|
["PLAYER_LEAVE_COMBAT"] = true,
|
||||||
-- cooldown updates
|
-- cooldown updates
|
||||||
["ACTIONBAR_UPDATE_USABLE"] = true,
|
["ACTIONBAR_UPDATE_USABLE"] = true,
|
||||||
["UPDATE_INVENTORY_ALERTS"] = true,
|
|
||||||
["ACTIONBAR_UPDATE_COOLDOWN"] = true,
|
["ACTIONBAR_UPDATE_COOLDOWN"] = true,
|
||||||
["UNIT_INVENTORY_CHANGED"] = true,
|
["UNIT_INVENTORY_CHANGED"] = true,
|
||||||
}
|
}
|
||||||
@@ -247,14 +246,14 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
table.insert(updatecache, pfUI.bars[bar][button])
|
table.insert(updatecache, pfUI.bars[bar][button])
|
||||||
end
|
end
|
||||||
|
|
||||||
local usable, oom, start, duration, enable, castable, autocast, token
|
local start, duration, enable, castable, autocast, token
|
||||||
local id, bar, active, texture
|
local id, bar, active, texture, _
|
||||||
local function ButtonRefresh(self)
|
local function ButtonRefresh(self)
|
||||||
local self = self or this
|
local self = self or this
|
||||||
local sid = self.id -- 1 to 120
|
local sid = self.id -- 1 to 120
|
||||||
|
|
||||||
-- reset shared variables
|
-- reset shared variables
|
||||||
oom, castable, autocast, token = nil, nil, nil, nil
|
castable, autocast, token = nil, nil, nil
|
||||||
|
|
||||||
-- set the own ID for compatibility to some vanilla addons
|
-- set the own ID for compatibility to some vanilla addons
|
||||||
if pfUI.client <= 11200 then self:SetID(self.id) end
|
if pfUI.client <= 11200 then self:SetID(self.id) end
|
||||||
@@ -265,20 +264,18 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
-- stance button
|
-- stance button
|
||||||
bar = self.bar
|
bar = self.bar
|
||||||
id = sid
|
id = sid
|
||||||
texture, _, active, usable = GetShapeshiftFormInfo(id)
|
texture, _, active = GetShapeshiftFormInfo(id)
|
||||||
elseif self.bar == 12 then
|
elseif self.bar == 12 then
|
||||||
-- pet button
|
-- pet button
|
||||||
bar = self.bar
|
bar = self.bar
|
||||||
id = sid
|
id = sid
|
||||||
_, _, texture, token, active, castable, autocast = GetPetActionInfo(id)
|
_, _, texture, token, active, castable, autocast = GetPetActionInfo(id)
|
||||||
texture = token and _G[texture] or texture
|
texture = token and _G[texture] or texture
|
||||||
usable = true
|
|
||||||
else
|
else
|
||||||
active = IsCurrentAction(sid) or IsAutoRepeatAction(sid)
|
active = IsCurrentAction(sid) or IsAutoRepeatAction(sid)
|
||||||
texture = GetActionTexture(sid)
|
texture = GetActionTexture(sid)
|
||||||
bar = GetActiveBar()
|
bar = GetActiveBar()
|
||||||
id = sid - ((self.bar == 1 and bar or self.bar)-1)*12
|
id = sid - ((self.bar == 1 and bar or self.bar)-1)*12
|
||||||
usable, oom = IsUsableAction(sid)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not self.showempty and self.backdrop and not texture and grid == 0 then
|
if not self.showempty and self.backdrop and not texture and grid == 0 then
|
||||||
@@ -339,20 +336,6 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- update usable
|
|
||||||
if self.outofrange and C.bars.glowrange == "1" then
|
|
||||||
self.icon:SetVertexColor(self.rangeColor[1], self.rangeColor[2], self.rangeColor[3], self.rangeColor[4])
|
|
||||||
elseif oom and C.bars.showoom == "1" then
|
|
||||||
self.icon:SetVertexColor(self.oomColor[1], self.oomColor[2], self.oomColor[3], self.oomColor[4])
|
|
||||||
elseif not usable and C.bars.showna == "1" then
|
|
||||||
self.icon:SetVertexColor(self.naColor[1], self.naColor[2], self.naColor[3], self.naColor[4])
|
|
||||||
else
|
|
||||||
self.icon:SetVertexColor(1, 1, 1, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- don't go further on those events
|
|
||||||
if event == "ACTIONBAR_UPDATE_USABLE" or event == "UPDATE_INVENTORY_ALERTS" then return end
|
|
||||||
|
|
||||||
-- icon
|
-- icon
|
||||||
if texture ~= self.texture then
|
if texture ~= self.texture then
|
||||||
self.icon:SetTexture(texture)
|
self.icon:SetTexture(texture)
|
||||||
@@ -518,6 +501,32 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
GameTooltip:Hide()
|
GameTooltip:Hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function ButtonUpdateUsable(self)
|
||||||
|
local self = self or this
|
||||||
|
local sid = self.id -- 1 to 120
|
||||||
|
|
||||||
|
local usable, oom, _
|
||||||
|
|
||||||
|
if self.bar == 11 then
|
||||||
|
_, _, _, usable = GetShapeshiftFormInfo(sid)
|
||||||
|
elseif self.bar == 12 then
|
||||||
|
usable = true
|
||||||
|
else
|
||||||
|
usable, oom = IsUsableAction(sid)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- update usable
|
||||||
|
if self.outofrange and C.bars.glowrange == "1" then
|
||||||
|
self.icon:SetVertexColor(self.rangeColor[1], self.rangeColor[2], self.rangeColor[3], self.rangeColor[4])
|
||||||
|
elseif oom and C.bars.showoom == "1" then
|
||||||
|
self.icon:SetVertexColor(self.oomColor[1], self.oomColor[2], self.oomColor[3], self.oomColor[4])
|
||||||
|
elseif not usable and C.bars.showna == "1" then
|
||||||
|
self.icon:SetVertexColor(self.naColor[1], self.naColor[2], self.naColor[3], self.naColor[4])
|
||||||
|
else
|
||||||
|
self.icon:SetVertexColor(1, 1, 1, 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function ButtonUpdateCooldown(button)
|
local function ButtonUpdateCooldown(button)
|
||||||
if not button then return end
|
if not button then return end
|
||||||
local start, duration, enable
|
local start, duration, enable
|
||||||
@@ -586,6 +595,14 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function ()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- update usable actions
|
||||||
|
if event == "ACTIONBAR_UPDATE_USABLE" then
|
||||||
|
for id, button in pairs(buttoncache) do
|
||||||
|
ButtonUpdateUsable(button)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- handle global events
|
-- handle global events
|
||||||
for id, button in pairs(buttoncache) do
|
for id, button in pairs(buttoncache) do
|
||||||
ButtonRefresh(button)
|
ButtonRefresh(button)
|
||||||
|
|||||||
Reference in New Issue
Block a user