diff --git a/WeakAuras/BuffTrigger2.lua b/WeakAuras/BuffTrigger2.lua index 8a49500..821a8b9 100644 --- a/WeakAuras/BuffTrigger2.lua +++ b/WeakAuras/BuffTrigger2.lua @@ -1110,8 +1110,7 @@ local function TriggerInfoApplies(triggerInfo, unit) return false end - local unitRole = WeakAuras.GetUnitRole(controllingUnit) - if triggerInfo.groupRole and unitRole and not triggerInfo.groupRole[unitRole or ""] then + if triggerInfo.groupRole and not triggerInfo.groupRole[WeakAuras.LGT:GetUnitRole(controllingUnit) or ""] then return false end @@ -1120,8 +1119,9 @@ local function TriggerInfoApplies(triggerInfo, unit) end if triggerInfo.specId then - local spec = Private.LibGroupTalentsWrapper.SpecForUnit(controllingUnit) - if not triggerInfo.specId[spec] then + local spec = WeakAuras.LGT:GetUnitTalentSpec(controllingUnit) + local class = select(2, UnitClass(controllingUnit)) + if not (spec and class and triggerInfo.specId[class .. spec]) then return false end end diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index a60cd46..f2049be 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -3053,7 +3053,7 @@ function WeakAuras.WatchUnitChange(unit) watchUnitChange.unitRaidRole[unit] = newRaidRole end local oldRole = watchUnitChange.unitRoles[unit] - local newRole = WeakAuras.GetUnitRole(unit) + local newRole = WeakAuras.LGT:GetUnitRole(unit) if oldRole ~= newRole then eventsToSend["UNIT_ROLE_CHANGED_" .. unit] = unit watchUnitChange.unitRoles[unit] = newRole diff --git a/WeakAuras/Init.lua b/WeakAuras/Init.lua index 912165c..4a85063 100644 --- a/WeakAuras/Init.lua +++ b/WeakAuras/Init.lua @@ -80,7 +80,7 @@ if not libsAreOk then WeakAuras.prettyPrint("WeakAuras is missing necessary libraries. Please reinstall a proper package.") 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!") end diff --git a/WeakAuras/LibGroupTalentsWrapper.lua b/WeakAuras/LibGroupTalentsWrapper.lua index 34e6b6a..a1f9dba 100644 --- a/WeakAuras/LibGroupTalentsWrapper.lua +++ b/WeakAuras/LibGroupTalentsWrapper.lua @@ -2,158 +2,26 @@ if not WeakAuras.IsLibsOK() then return end local AddonName, Private = ... --- Lua APIs -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 LibGroupTalents = LibStub:GetLibrary("LibGroupTalents-1.0", true) local subscribers = {} Private.LibGroupTalentsWrapper = { 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 - --- LibGroupTalents callback for talents and glyphs - function Private.LibGroupTalentsWrapper:LibGroupTalentsCallback(_, _, unit) - if not unit then - 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 + function Private.LibGroupTalentsWrapper.CallbackHandler(_, _, _, unit) + if unit then + print(unit) for _, f in ipairs(subscribers) do - f(nameToUnitMap[unitName]) + f(unit) end end end - LibGroupTalents.RegisterCallback(Private.LibGroupTalentsWrapper, "LibGroupTalents_Update", "LibGroupTalentsCallback") - LibGroupTalents.RegisterCallback(Private.LibGroupTalentsWrapper, "LibGroupTalents_GlyphUpdate", "LibGroupTalentsCallback") - function Private.LibGroupTalentsWrapper.Register(f) table.insert(subscribers, f) end - function Private.LibGroupTalentsWrapper.SpecForUnit(unit) - 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 + WeakAuras.LGT.RegisterCallback(Private.LibGroupTalentsWrapper, "LibGroupTalents_Update", "CallbackHandler") 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 diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 496d1fc..d26f642 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -18,6 +18,8 @@ local MONEY = MONEY local WeakAuras = WeakAuras local L = WeakAuras.L +local LibGroupTalents = LibStub("LibGroupTalents-1.0") + local SpellRange = LibStub("SpellRange-1.0") function WeakAuras.IsSpellInRange(spellId, unit) return SpellRange.IsSpellInRange(spellId, unit) @@ -796,6 +798,12 @@ function WeakAuras.GetSpellCritChance() return spellCrit 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) local result = WeakAuras.IsSpellKnown(spell) if exact or result then @@ -1589,7 +1597,7 @@ Private.event_prototypes = { name = "specId", display = L["Specialization"], type = "multiselect", - init = "WeakAuras.SpecForUnit(unit)", + init = "WeakAuras.LGT:GetUnitTalentSpec(unit)", values = "spec_types_all", store = true, conditionType = "select", @@ -1608,7 +1616,7 @@ Private.event_prototypes = { name = "role", display = L["Spec Role"], type = "select", - init = "WeakAuras.GetUnitRole(unit)", + init = "WeakAuras.LGT:GetUnitRole(unit)", values = "role_types", store = true, conditionType = "select", @@ -2113,7 +2121,7 @@ Private.event_prototypes = { name = "specId", display = L["Specialization"], type = "multiselect", - init = "WeakAuras.SpecForUnit(unit)", + init = "WeakAuras.GetSpecString(unit)", values = "spec_types_all", store = true, conditionType = "select", @@ -2126,7 +2134,7 @@ Private.event_prototypes = { name = "role", display = L["Spec Role"], type = "select", - init = "WeakAuras.GetUnitRole(unit)", + init = "WeakAuras.LGT:GetUnitRole(unit)", values = "role_types", store = true, conditionType = "select", @@ -2534,7 +2542,7 @@ Private.event_prototypes = { name = "specId", display = L["Specialization"], type = "multiselect", - init = "WeakAuras.SpecForUnit(unit)", + init = "WeakAuras.GetSpecString(unit)", values = "spec_types_all", store = true, conditionType = "select", @@ -2547,7 +2555,7 @@ Private.event_prototypes = { name = "role", display = L["Spec Role"], type = "select", - init = "WeakAuras.GetUnitRole(unit)", + init = "WeakAuras.LGT:GetUnitRole(unit)", values = "role_types", store = true, conditionType = "select", @@ -6580,7 +6588,7 @@ Private.event_prototypes = { name = "role", display = L["Spec Role"], type = "select", - init = "WeakAuras.GetUnitRole(unit)", + init = "WeakAuras.LGT:GetUnitRole(unit)", values = "role_types", store = true, conditionType = "select", diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index e0291f7..92141ab 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -28,6 +28,11 @@ local prettyPrint = WeakAuras.prettyPrint WeakAurasTimers = setmetatable({}, {__tostring=function() return "WeakAuras" end}) LibStub("AceTimer-3.0"):Embed(WeakAurasTimers) +WeakAuras.LGT = LibStub("LibGroupTalents-1.0") or { + GetUnitTalentSpec = function() end, + GetUnitRole = function() end +} + Private.watched_trigger_events = {} -- The worlds simplest callback system. @@ -1381,7 +1386,7 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...) local _, race = UnitRace("player") local faction = UnitFactionGroup("player") local zoneId = GetCurrentMapAreaID() - local role = WeakAuras.GetUnitRole("player") + local role = WeakAuras.LGT:GetUnitRole("player") local raidRole = false; local raidID = UnitInRaid("player") if raidID then diff --git a/WeakAuras/WeakAuras.toc b/WeakAuras/WeakAuras.toc index 3a6bee6..ed1062b 100644 --- a/WeakAuras/WeakAuras.toc +++ b/WeakAuras/WeakAuras.toc @@ -32,7 +32,6 @@ DefaultOptions.lua # Core files Types.lua -LibGroupTalentsWrapper.lua Prototypes.lua Profiling.lua WeakAuras.lua @@ -44,6 +43,7 @@ Conditions.lua AnchorToWeakAuras.lua # Trigger systems +LibGroupTalentsWrapper.lua BuffTrigger2.lua GenericTrigger.lua BossMods.lua