(feat/Prototypes) use WeakAurasMiniTalent in the Talent Known Trigger

(cherry picked from commit 0d025ff3813119b51a3d57157a18c47b96f9704a)
This commit is contained in:
NoM0Re
2025-12-11 15:03:06 +01:00
committed by andrew6180
parent 46a77128a6
commit 1b5678af13
3 changed files with 21 additions and 55 deletions
-1
View File
@@ -1207,7 +1207,6 @@ function HandleEvent(frame, event, arg1, arg2, ...)
end end
if (event == "PLAYER_ENTERING_WORLD") then if (event == "PLAYER_ENTERING_WORLD") then
timer:ScheduleTimer(function() timer:ScheduleTimer(function()
Private.CreateTalentCache()
WeakAuras.WatchForMounts() WeakAuras.WatchForMounts()
HandleEvent(frame, "WA_DELAYED_PLAYER_ENTERING_WORLD"); HandleEvent(frame, "WA_DELAYED_PLAYER_ENTERING_WORLD");
Private.ScanForLoads(nil, "WA_DELAYED_PLAYER_ENTERING_WORLD") Private.ScanForLoads(nil, "WA_DELAYED_PLAYER_ENTERING_WORLD")
+21 -37
View File
@@ -5288,8 +5288,11 @@ Private.event_prototypes = {
force_events = "PLAYER_TALENT_UPDATE", force_events = "PLAYER_TALENT_UPDATE",
name = L["Talent Known"], name = L["Talent Known"],
init = function(trigger) init = function(trigger)
local inverse = trigger.use_inverse
local ret = {} local ret = {}
table.insert(ret, [[
local active = true
local activeName, activeIcon, _
]])
if (trigger.use_talent) then if (trigger.use_talent) then
-- Single selection -- Single selection
local index = trigger.talent and trigger.talent.single; local index = trigger.talent and trigger.talent.single;
@@ -5298,7 +5301,7 @@ Private.event_prototypes = {
table.insert(ret, ([[ table.insert(ret, ([[
local tier = %s; local tier = %s;
local column = %s; local column = %s;
local active = false active = false
local name, icon, _, _, rank = GetTalentInfo(tier, column) local name, icon, _, _, rank = GetTalentInfo(tier, column)
if rank and rank > 0 then if rank and rank > 0 then
active = true; active = true;
@@ -5306,17 +5309,8 @@ Private.event_prototypes = {
activeIcon = icon; activeIcon = icon;
end end
]]):format(tier or 0, column or 0)) ]]):format(tier or 0, column or 0))
if (inverse) then
table.insert(ret, [[
active = not (active);
]])
end
elseif (trigger.use_talent == false) then elseif (trigger.use_talent == false) then
if (trigger.talent.multi) then if (trigger.talent.multi) then
table.insert(ret, [[
local active = true
local activeIcon, activeName, _
]])
table.insert(ret, [[ table.insert(ret, [[
local tier local tier
local column local column
@@ -5325,22 +5319,15 @@ Private.event_prototypes = {
local tier = index and ceil(index / MAX_NUM_TALENTS) local tier = index and ceil(index / MAX_NUM_TALENTS)
local column = index and ((index - 1) % MAX_NUM_TALENTS + 1) local column = index and ((index - 1) % MAX_NUM_TALENTS + 1)
table.insert(ret, ([[ table.insert(ret, ([[
if (not active) then tier = %s
tier = %s column = %s
column = %s local shouldBeActive = %s
local name, icon, _, _, rank = GetTalentInfo(tier, column) local rank
if rank > 0 then activeName, activeIcon, _, _, rank = GetTalentInfo(tier, column)
active = true; if ((rank and rank > 0) ~= shouldBeActive) then
activeName = name; active = false
activeIcon = icon;
end
end end
]]):format(tier, column)) ]]):format(tier, column, value and "true" or "false"))
end
if (inverse) then
table.insert(ret, [[
active = not (active);
]])
end end
end end
end end
@@ -5351,20 +5338,17 @@ Private.event_prototypes = {
name = "talent", name = "talent",
display = L["Talent"], display = L["Talent"],
type = "multiselect", type = "multiselect",
values = function(trigger) values = function()
local class = select(2, UnitClass("player")); local class = select(2, UnitClass("player"));
if Private.talent_types_specific and Private.talent_types_specific[class] then return Private.talentInfo[class]
return Private.talent_types_specific[class];
end
end, end,
multiUseControlWhenFalse = true,
multiAll = true,
multiNoSingle = true,
multiTristate = true, -- values can be true/false/nil
control = "WeakAurasMiniTalent",
test = "active", test = "active",
reloadOptions = true, reloadOptions = true
},
{
name = "inverse",
display = L["Inverse"],
type = "toggle",
test = "true",
}, },
{ {
hidden = true, hidden = true,
-17
View File
@@ -956,23 +956,6 @@ local function LoadCustomActionFunctions(data)
end end
end end
Private.talent_types_specific = {}
function Private.CreateTalentCache()
local _, player_class = UnitClass("player")
Private.talent_types_specific[player_class] = Private.talent_types_specific[player_class] or {};
for tab = 1, GetNumTalentTabs() do
for num_talent = 1, GetNumTalents(tab) do
local talentName, talentIcon = GetTalentInfo(tab, num_talent);
local talentId = (tab - 1) * MAX_NUM_TALENTS + num_talent
if (talentName and talentIcon) then
Private.talent_types_specific[player_class][talentId] = "|T"..talentIcon..":0|t "..talentName
end
end
end
end
Private.CompanionData = {} Private.CompanionData = {}
-- use this function to not overwrite data from other companion compatible addons -- use this function to not overwrite data from other companion compatible addons
-- when using this function, do not name your global data table "WeakAurasCompanion" -- when using this function, do not name your global data table "WeakAurasCompanion"