update WeakAuras.FindSpellActionButtons

This commit is contained in:
Bunny67
2020-08-25 20:57:08 +03:00
parent f4a801a3d7
commit d9a27f5e50
2 changed files with 60 additions and 24 deletions
+56 -1
View File
@@ -59,7 +59,7 @@ if not WeakAuras.IsCorrectVersion() then return end
-- Lua APIs
local tinsert, tconcat, wipe = table.insert, table.concat, wipe
local tostring, pairs, type = tostring, pairs, type
local tonumber, tostring, pairs, type = tonumber, tostring, pairs, type
local error, setmetatable = error, setmetatable
WeakAurasAceEvents = setmetatable({}, {__tostring=function() return "WeakAuras" end});
@@ -3295,6 +3295,61 @@ do
end
end
-- Queued Action
do
local GetActionInfo, GetMacroSpell, GetSpellLink = GetActionInfo, GetMacroSpell, GetSpellLink
local queuedActionFrame = nil
local buttonIDList = {}
local spellIDList = {}
local function GetActionSpellID(slot)
local actionType, id, _, spellId = GetActionInfo(slot)
if actionType == "spell" then
return spellId
elseif actionType == "macro" then
local name, rank = GetMacroSpell(id)
if name then
local spellLink = GetSpellLink(name, rank or "")
if spellLink then
return tonumber(spellLink:match("spell:(%d+)"))
end
end
end
end
function WeakAuras.WatchQueuedAction()
if not(queuedActionFrame) then
queuedActionFrame = CreateFrame("frame");
WeakAuras.frames["Queued Action Frame"] = queuedActionFrame
for slotID = 1, 120 do
local spellID = GetActionSpellID(slotID)
if spellID then
buttonIDList[slotID] = spellID
spellIDList[spellID] = slotID
end
end
end
queuedActionFrame:RegisterEvent("ACTIONBAR_SLOT_CHANGED")
queuedActionFrame:SetScript("OnEvent", function(_, _, slotID)
WeakAuras.StartProfileSystem("generictrigger");
local spellID = GetActionSpellID(slotID)
if spellID then
buttonIDList[slotID] = spellID
spellIDList[spellID] = slotID
elseif buttonIDList[slotID] then
spellIDList[buttonIDList[slotID]] = nil
buttonIDList[slotID] = nil
end
WeakAuras.StopProfileSystem("generictrigger");
end)
end
function WeakAuras.FindSpellActionButtons(spellID)
return spellIDList[spellID]
end
end
do
local scheduled_scans = {};
+4 -23
View File
@@ -2,10 +2,9 @@ if not WeakAuras.IsCorrectVersion() then return end
-- Lua APIs
local tinsert, tsort = table.insert, table.sort
local tonumber, tostring = tonumber, tostring
local tostring = tostring
local select, pairs, type = select, pairs, type
local ceil, min = ceil, min
local match = string.match
-- WoW APIs
local GetTalentInfo = GetTalentInfo
@@ -14,7 +13,6 @@ local GetSpellInfo, GetItemInfo, GetItemCount, GetItemIcon = GetSpellInfo, GetIt
local GetShapeshiftFormInfo, GetShapeshiftForm = GetShapeshiftFormInfo, GetShapeshiftForm
local GetRuneCooldown, UnitCastingInfo, UnitChannelInfo = GetRuneCooldown, UnitCastingInfo, UnitChannelInfo
local UnitDetailedThreatSituation, UnitThreatSituation = UnitDetailedThreatSituation, UnitThreatSituation
local GetActionInfo, GetMacroSpell, GetSpellLink = GetActionInfo, GetMacroSpell, GetSpellLink
local WeakAuras = WeakAuras
local L = WeakAuras.L
@@ -652,26 +650,6 @@ function WeakAuras.IsSpellKnownIncludingPet(spell)
end
end
function WeakAuras.FindSpellActionButtons(spellID)
for i = 120, 1, -1 do
local actionType, id, _, globalID = GetActionInfo(i)
if actionType == "spell" and globalID and globalID == spellID then
return i
elseif actionType == "macro" then
local name, rank = GetMacroSpell(id)
if name then
local spellLink = GetSpellLink(name, rank or "")
if spellLink then
globalID = tonumber(match(spellLink, "spell:(%d+)"))
if globalID and globalID == spellID then
return i
end
end
end
end
end
end
local function valuesForTalentFunction(trigger)
return function()
local single_class;
@@ -5605,6 +5583,9 @@ WeakAuras.event_prototypes = {
"ACTIONBAR_PAGE_CHANGED"
},
name = L["Queued Action"],
loadFunc = function()
WeakAuras.WatchQueuedAction()
end,
init = function(trigger)
trigger.spellName = trigger.spellName or 0
local ret = [=[