Fix incorrect login message, rework LibGroupTalentsWrapper
The login message was triggered incorrectly due to the "Beta" tag in the version string. This has been fixed. Almost completely removed due to impracticality with the 3.3.5a API. When RAID_ROSTER_UPDATE or PARTY_MEMBERS_CHANGED fires, data is unavailable for ~1.5 seconds. If these events fire again within that time, the timer needs to be restarted, leading to excessive code complexity and requiring handling for every edge case. Instead, we now simply check if the unit has changed when the library fires its callback.
This commit is contained in:
@@ -1110,8 +1110,7 @@ local function TriggerInfoApplies(triggerInfo, unit)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local unitRole = WeakAuras.GetUnitRole(controllingUnit)
|
if triggerInfo.groupRole and not triggerInfo.groupRole[WeakAuras.LGT:GetUnitRole(controllingUnit) or ""] then
|
||||||
if triggerInfo.groupRole and unitRole and not triggerInfo.groupRole[unitRole or ""] then
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1120,8 +1119,9 @@ local function TriggerInfoApplies(triggerInfo, unit)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if triggerInfo.specId then
|
if triggerInfo.specId then
|
||||||
local spec = Private.LibGroupTalentsWrapper.SpecForUnit(controllingUnit)
|
local spec = WeakAuras.LGT:GetUnitTalentSpec(controllingUnit)
|
||||||
if not triggerInfo.specId[spec] then
|
local class = select(2, UnitClass(controllingUnit))
|
||||||
|
if not (spec and class and triggerInfo.specId[class .. spec]) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3053,7 +3053,7 @@ function WeakAuras.WatchUnitChange(unit)
|
|||||||
watchUnitChange.unitRaidRole[unit] = newRaidRole
|
watchUnitChange.unitRaidRole[unit] = newRaidRole
|
||||||
end
|
end
|
||||||
local oldRole = watchUnitChange.unitRoles[unit]
|
local oldRole = watchUnitChange.unitRoles[unit]
|
||||||
local newRole = WeakAuras.GetUnitRole(unit)
|
local newRole = WeakAuras.LGT:GetUnitRole(unit)
|
||||||
if oldRole ~= newRole then
|
if oldRole ~= newRole then
|
||||||
eventsToSend["UNIT_ROLE_CHANGED_" .. unit] = unit
|
eventsToSend["UNIT_ROLE_CHANGED_" .. unit] = unit
|
||||||
watchUnitChange.unitRoles[unit] = newRole
|
watchUnitChange.unitRoles[unit] = newRole
|
||||||
|
|||||||
+1
-1
@@ -80,7 +80,7 @@ if not libsAreOk then
|
|||||||
WeakAuras.prettyPrint("WeakAuras is missing necessary libraries. Please reinstall a proper package.")
|
WeakAuras.prettyPrint("WeakAuras is missing necessary libraries. Please reinstall a proper package.")
|
||||||
end
|
end
|
||||||
|
|
||||||
if versionString ~= versionStringFromToc and versionStringFromToc ~= "Dev" then
|
if versionString ~= versionStringFromToc .. " Beta" and versionStringFromToc ~= "Dev" then
|
||||||
WeakAuras.prettyPrint("You need to restart your game client to complete the WeakAuras update!")
|
WeakAuras.prettyPrint("You need to restart your game client to complete the WeakAuras update!")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,158 +2,26 @@ if not WeakAuras.IsLibsOK() then return end
|
|||||||
|
|
||||||
local AddonName, Private = ...
|
local AddonName, Private = ...
|
||||||
|
|
||||||
-- Lua APIs
|
local LibGroupTalents = LibStub:GetLibrary("LibGroupTalents-1.0", true)
|
||||||
local unpack, wipe = unpack, wipe
|
|
||||||
|
|
||||||
-- WoW APIs
|
|
||||||
local UnitName, UnitIsUnit, UnitClass, GetNumGroupMembers = UnitName, UnitIsUnit, UnitClass, GetNumGroupMembers
|
|
||||||
|
|
||||||
local LibGroupTalents = LibStub("LibGroupTalents-1.0")
|
|
||||||
|
|
||||||
local nameToGlyphs = {}
|
|
||||||
local nameToSpecMap = {}
|
|
||||||
local nameToUnitRole = {}
|
|
||||||
local nameToUnitMap = {
|
|
||||||
[UnitName("player")] = "player"
|
|
||||||
}
|
|
||||||
|
|
||||||
local subscribers = {}
|
local subscribers = {}
|
||||||
|
|
||||||
Private.LibGroupTalentsWrapper = {
|
Private.LibGroupTalentsWrapper = {
|
||||||
Register = function(f) end,
|
Register = function(f) end,
|
||||||
SpecForUnit = function(unit) end,
|
|
||||||
GetUnitRole = function(unit) end,
|
|
||||||
SpecRolePositionForUnit = function(unit) end,
|
|
||||||
CheckTalentForUnit = function(unit) end,
|
|
||||||
CheckGlyphForUnit = function(unit) end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if LibGroupTalents then
|
if LibGroupTalents then
|
||||||
--- LibGroupTalents callback for talents and glyphs
|
function Private.LibGroupTalentsWrapper.CallbackHandler(_, _, _, unit)
|
||||||
function Private.LibGroupTalentsWrapper:LibGroupTalentsCallback(_, _, unit)
|
if unit then
|
||||||
if not unit then
|
print(unit)
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local unitName = UnitName(unit)
|
|
||||||
local ownName = UnitName("player")
|
|
||||||
|
|
||||||
local numMembers = GetNumGroupMembers()
|
|
||||||
local units = IsInRaid() and WeakAuras.raidUnits or WeakAuras.partyUnits
|
|
||||||
|
|
||||||
nameToUnitMap = { [ownName] = "player" }
|
|
||||||
for i = 1, numMembers do
|
|
||||||
local groupUnitName = UnitName(units[i])
|
|
||||||
if groupUnitName then
|
|
||||||
nameToUnitMap[groupUnitName] = groupUnitName
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for storedName in pairs(nameToSpecMap) do
|
|
||||||
if not nameToUnitMap[storedName] then
|
|
||||||
nameToSpecMap[storedName] = nil
|
|
||||||
nameToGlyphs[storedName] = nil
|
|
||||||
nameToUnitRole[storedName] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local specInfo = { LibGroupTalents:GetUnitTalentSpec(unit) }
|
|
||||||
local class = select(2, UnitClass(unit))
|
|
||||||
if specInfo and #specInfo > 0 and class then
|
|
||||||
nameToSpecMap[unitName] = {
|
|
||||||
class .. specInfo[1], unpack(specInfo)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
nameToUnitRole[unitName] = LibGroupTalents:GetUnitRole(unit)
|
|
||||||
|
|
||||||
nameToGlyphs[unitName] = {}
|
|
||||||
for _, glyphId in ipairs({ LibGroupTalents:GetUnitGlyphs(unit) }) do
|
|
||||||
if glyphId then
|
|
||||||
nameToGlyphs[unitName][glyphId] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if nameToUnitMap[unitName] then
|
|
||||||
for _, f in ipairs(subscribers) do
|
for _, f in ipairs(subscribers) do
|
||||||
f(nameToUnitMap[unitName])
|
f(unit)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
LibGroupTalents.RegisterCallback(Private.LibGroupTalentsWrapper, "LibGroupTalents_Update", "LibGroupTalentsCallback")
|
|
||||||
LibGroupTalents.RegisterCallback(Private.LibGroupTalentsWrapper, "LibGroupTalents_GlyphUpdate", "LibGroupTalentsCallback")
|
|
||||||
|
|
||||||
function Private.LibGroupTalentsWrapper.Register(f)
|
function Private.LibGroupTalentsWrapper.Register(f)
|
||||||
table.insert(subscribers, f)
|
table.insert(subscribers, f)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Private.LibGroupTalentsWrapper.SpecForUnit(unit)
|
WeakAuras.LGT.RegisterCallback(Private.LibGroupTalentsWrapper, "LibGroupTalents_Update", "CallbackHandler")
|
||||||
local unitName = UnitName(unit)
|
|
||||||
local class = select(2, UnitClass(unit))
|
|
||||||
|
|
||||||
if nameToSpecMap[unitName] then
|
|
||||||
return nameToSpecMap[unitName]
|
|
||||||
end
|
|
||||||
|
|
||||||
if UnitIsUnit(unit, "player") and class then
|
|
||||||
local specInfo = { LibGroupTalents:GetUnitTalentSpec(unit) }
|
|
||||||
if specInfo and #specInfo > 0 then
|
|
||||||
return class .. specInfo[1], unpack(specInfo)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Private.LibGroupTalentsWrapper.GetUnitRole(unit)
|
|
||||||
local unitName = UnitName(unit)
|
|
||||||
|
|
||||||
if nameToUnitRole[unitName] then
|
|
||||||
return nameToUnitRole[unitName]
|
|
||||||
end
|
|
||||||
|
|
||||||
if UnitIsUnit(unit, "player") then
|
|
||||||
local unitRole = LibGroupTalents:GetUnitRole(unit)
|
|
||||||
return unitRole
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Private.LibGroupTalentsWrapper.SpecRolePositionForUnit(unit)
|
|
||||||
local data = nameToSpecMap[UnitName(unit)]
|
|
||||||
if data then
|
|
||||||
return unpack(data, 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
if UnitIsUnit(unit, "player") then
|
|
||||||
return LibGroupTalents:GetUnitTalentSpec(unit)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Private.LibGroupTalentsWrapper.CheckTalentForUnit(unit, talentId)
|
|
||||||
return UnitIsUnit(unit, "player") and LibGroupTalents:UnitHasTalent(unit, talentId) and true or nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function Private.LibGroupTalentsWrapper.CheckGlyphForUnit(unit, glyphId)
|
|
||||||
local unitName = UnitName(unit)
|
|
||||||
if nameToGlyphs[unitName] and nameToGlyphs[unitName][glyphId] then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if UnitIsUnit(unit, "player") then
|
|
||||||
local glyphs = { LibGroupTalents:GetUnitGlyphs(unit) }
|
|
||||||
if glyphs then
|
|
||||||
for _, id in ipairs(glyphs) do
|
|
||||||
if id == glyphId then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Export for GenericTrigger/Custom Code
|
|
||||||
WeakAuras.SpecForUnit = Private.LibGroupTalentsWrapper.SpecForUnit
|
|
||||||
WeakAuras.GetUnitRole = Private.LibGroupTalentsWrapper.GetUnitRole
|
|
||||||
WeakAuras.SpecRolePositionForUnit = Private.LibGroupTalentsWrapper.SpecRolePositionForUnit
|
|
||||||
WeakAuras.CheckTalentForUnit = Private.LibGroupTalentsWrapper.CheckTalentForUnit
|
|
||||||
WeakAuras.CheckGlyphForUnit = Private.LibGroupTalentsWrapper.CheckGlyphForUnit
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ local MONEY = MONEY
|
|||||||
local WeakAuras = WeakAuras
|
local WeakAuras = WeakAuras
|
||||||
local L = WeakAuras.L
|
local L = WeakAuras.L
|
||||||
|
|
||||||
|
local LibGroupTalents = LibStub("LibGroupTalents-1.0")
|
||||||
|
|
||||||
local SpellRange = LibStub("SpellRange-1.0")
|
local SpellRange = LibStub("SpellRange-1.0")
|
||||||
function WeakAuras.IsSpellInRange(spellId, unit)
|
function WeakAuras.IsSpellInRange(spellId, unit)
|
||||||
return SpellRange.IsSpellInRange(spellId, unit)
|
return SpellRange.IsSpellInRange(spellId, unit)
|
||||||
@@ -796,6 +798,12 @@ function WeakAuras.GetSpellCritChance()
|
|||||||
return spellCrit
|
return spellCrit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function WeakAuras.GetSpecString(unit)
|
||||||
|
local spec = WeakAuras.LGT:GetUnitTalentSpec(unit)
|
||||||
|
local class = select(2, UnitClass(unit))
|
||||||
|
return spec and class and (class .. spec)
|
||||||
|
end
|
||||||
|
|
||||||
function WeakAuras.IsSpellKnownForLoad(spell, exact)
|
function WeakAuras.IsSpellKnownForLoad(spell, exact)
|
||||||
local result = WeakAuras.IsSpellKnown(spell)
|
local result = WeakAuras.IsSpellKnown(spell)
|
||||||
if exact or result then
|
if exact or result then
|
||||||
@@ -1589,7 +1597,7 @@ Private.event_prototypes = {
|
|||||||
name = "specId",
|
name = "specId",
|
||||||
display = L["Specialization"],
|
display = L["Specialization"],
|
||||||
type = "multiselect",
|
type = "multiselect",
|
||||||
init = "WeakAuras.SpecForUnit(unit)",
|
init = "WeakAuras.LGT:GetUnitTalentSpec(unit)",
|
||||||
values = "spec_types_all",
|
values = "spec_types_all",
|
||||||
store = true,
|
store = true,
|
||||||
conditionType = "select",
|
conditionType = "select",
|
||||||
@@ -1608,7 +1616,7 @@ Private.event_prototypes = {
|
|||||||
name = "role",
|
name = "role",
|
||||||
display = L["Spec Role"],
|
display = L["Spec Role"],
|
||||||
type = "select",
|
type = "select",
|
||||||
init = "WeakAuras.GetUnitRole(unit)",
|
init = "WeakAuras.LGT:GetUnitRole(unit)",
|
||||||
values = "role_types",
|
values = "role_types",
|
||||||
store = true,
|
store = true,
|
||||||
conditionType = "select",
|
conditionType = "select",
|
||||||
@@ -2113,7 +2121,7 @@ Private.event_prototypes = {
|
|||||||
name = "specId",
|
name = "specId",
|
||||||
display = L["Specialization"],
|
display = L["Specialization"],
|
||||||
type = "multiselect",
|
type = "multiselect",
|
||||||
init = "WeakAuras.SpecForUnit(unit)",
|
init = "WeakAuras.GetSpecString(unit)",
|
||||||
values = "spec_types_all",
|
values = "spec_types_all",
|
||||||
store = true,
|
store = true,
|
||||||
conditionType = "select",
|
conditionType = "select",
|
||||||
@@ -2126,7 +2134,7 @@ Private.event_prototypes = {
|
|||||||
name = "role",
|
name = "role",
|
||||||
display = L["Spec Role"],
|
display = L["Spec Role"],
|
||||||
type = "select",
|
type = "select",
|
||||||
init = "WeakAuras.GetUnitRole(unit)",
|
init = "WeakAuras.LGT:GetUnitRole(unit)",
|
||||||
values = "role_types",
|
values = "role_types",
|
||||||
store = true,
|
store = true,
|
||||||
conditionType = "select",
|
conditionType = "select",
|
||||||
@@ -2534,7 +2542,7 @@ Private.event_prototypes = {
|
|||||||
name = "specId",
|
name = "specId",
|
||||||
display = L["Specialization"],
|
display = L["Specialization"],
|
||||||
type = "multiselect",
|
type = "multiselect",
|
||||||
init = "WeakAuras.SpecForUnit(unit)",
|
init = "WeakAuras.GetSpecString(unit)",
|
||||||
values = "spec_types_all",
|
values = "spec_types_all",
|
||||||
store = true,
|
store = true,
|
||||||
conditionType = "select",
|
conditionType = "select",
|
||||||
@@ -2547,7 +2555,7 @@ Private.event_prototypes = {
|
|||||||
name = "role",
|
name = "role",
|
||||||
display = L["Spec Role"],
|
display = L["Spec Role"],
|
||||||
type = "select",
|
type = "select",
|
||||||
init = "WeakAuras.GetUnitRole(unit)",
|
init = "WeakAuras.LGT:GetUnitRole(unit)",
|
||||||
values = "role_types",
|
values = "role_types",
|
||||||
store = true,
|
store = true,
|
||||||
conditionType = "select",
|
conditionType = "select",
|
||||||
@@ -6580,7 +6588,7 @@ Private.event_prototypes = {
|
|||||||
name = "role",
|
name = "role",
|
||||||
display = L["Spec Role"],
|
display = L["Spec Role"],
|
||||||
type = "select",
|
type = "select",
|
||||||
init = "WeakAuras.GetUnitRole(unit)",
|
init = "WeakAuras.LGT:GetUnitRole(unit)",
|
||||||
values = "role_types",
|
values = "role_types",
|
||||||
store = true,
|
store = true,
|
||||||
conditionType = "select",
|
conditionType = "select",
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ local prettyPrint = WeakAuras.prettyPrint
|
|||||||
WeakAurasTimers = setmetatable({}, {__tostring=function() return "WeakAuras" end})
|
WeakAurasTimers = setmetatable({}, {__tostring=function() return "WeakAuras" end})
|
||||||
LibStub("AceTimer-3.0"):Embed(WeakAurasTimers)
|
LibStub("AceTimer-3.0"):Embed(WeakAurasTimers)
|
||||||
|
|
||||||
|
WeakAuras.LGT = LibStub("LibGroupTalents-1.0") or {
|
||||||
|
GetUnitTalentSpec = function() end,
|
||||||
|
GetUnitRole = function() end
|
||||||
|
}
|
||||||
|
|
||||||
Private.watched_trigger_events = {}
|
Private.watched_trigger_events = {}
|
||||||
|
|
||||||
-- The worlds simplest callback system.
|
-- The worlds simplest callback system.
|
||||||
@@ -1381,7 +1386,7 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...)
|
|||||||
local _, race = UnitRace("player")
|
local _, race = UnitRace("player")
|
||||||
local faction = UnitFactionGroup("player")
|
local faction = UnitFactionGroup("player")
|
||||||
local zoneId = GetCurrentMapAreaID()
|
local zoneId = GetCurrentMapAreaID()
|
||||||
local role = WeakAuras.GetUnitRole("player")
|
local role = WeakAuras.LGT:GetUnitRole("player")
|
||||||
local raidRole = false;
|
local raidRole = false;
|
||||||
local raidID = UnitInRaid("player")
|
local raidID = UnitInRaid("player")
|
||||||
if raidID then
|
if raidID then
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ DefaultOptions.lua
|
|||||||
|
|
||||||
# Core files
|
# Core files
|
||||||
Types.lua
|
Types.lua
|
||||||
LibGroupTalentsWrapper.lua
|
|
||||||
Prototypes.lua
|
Prototypes.lua
|
||||||
Profiling.lua
|
Profiling.lua
|
||||||
WeakAuras.lua
|
WeakAuras.lua
|
||||||
@@ -44,6 +43,7 @@ Conditions.lua
|
|||||||
AnchorToWeakAuras.lua
|
AnchorToWeakAuras.lua
|
||||||
|
|
||||||
# Trigger systems
|
# Trigger systems
|
||||||
|
LibGroupTalentsWrapper.lua
|
||||||
BuffTrigger2.lua
|
BuffTrigger2.lua
|
||||||
GenericTrigger.lua
|
GenericTrigger.lua
|
||||||
BossMods.lua
|
BossMods.lua
|
||||||
|
|||||||
Reference in New Issue
Block a user