Rework LibGroupTalents now also returns function returns additionally, add Spec Role triggers to load/generic/bt2, fix WeakAuras.GetRegion

- **WeakAuras.SpecForUnit(unit)** = Returns: `classFileName..spec`, `Dominant Tree`, `spent1`, `spent2`, `spent3`
- **WeakAuras.GetUnitRole(unit)** = Returns one of: `"melee"`, `"caster"`, `"healer"`, `"tank"`
- **WeakAuras.SpecRolePositionForUnit(unit)** = Returns: `Dominant Tree`, `spent1`, `spent2`, `spent3`
- **WeakAuras.CheckTalentForUnit(unit, talentId)** = Returns: `"Points spent"` in talent or `nil`
- **WeakAuras.CheckGlyphForUnit(unit, glyphId)** = Returns: `true` if the player has the glyph associated with `spellID` or `spellName`, we can only see the glyphs of players running `LibGroupTalents-1.0`
This commit is contained in:
NoM0Re
2025-02-11 00:12:30 +01:00
parent 0b40284f3f
commit 5d1ac74d27
12 changed files with 270 additions and 56 deletions
+94 -11
View File
@@ -76,6 +76,9 @@ local unitExistScanFunc = {}
-- Which units exist -- Which units exist
local existingUnits = {} local existingUnits = {}
-- Contains all scanFuncs that fetch the role + roleIcon
local groupRoleScanFunc = {}
-- Loaded ScanFuncs per unit type -- Loaded ScanFuncs per unit type
local groupScanFuncs = {} local groupScanFuncs = {}
--Active ScanFuncs per actual unit id --Active ScanFuncs per actual unit id
@@ -468,7 +471,29 @@ local function FindBestMatchDataForUnit(time, id, triggernum, triggerInfo, unit)
return bestMatch, matchCount, stackCount, nextCheck return bestMatch, matchCount, stackCount, nextCheck
end end
local function UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, matchCount, unitCount, maxUnitCount, matchCountPerUnit, totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, raidMark) local GetTexCoordsForRole = function(role)
local textureHeight, textureWidth = 256, 256;
local roleHeight, roleWidth = 67, 67;
if ( role == "GUIDE" ) then
return GetTexCoordsByGrid(1, 1, textureWidth, textureHeight, roleWidth, roleHeight);
elseif ( role == "TANK" ) then
return GetTexCoordsByGrid(1, 2, textureWidth, textureHeight, roleWidth, roleHeight);
elseif ( role == "HEALER" ) then
return GetTexCoordsByGrid(2, 1, textureWidth, textureHeight, roleWidth, roleHeight);
elseif ( role == "DAMAGER" ) then
return GetTexCoordsByGrid(2, 2, textureWidth, textureHeight, roleWidth, roleHeight);
end
end
local roleIcons = {
melee = CreateTextureMarkup([=[Interface\LFGFrame\UI-LFG-ICON-ROLES]=], 256, 256, 0, 0, GetTexCoordsForRole("DAMAGER")),
caster = CreateTextureMarkup([=[Interface\LFGFrame\UI-LFG-ICON-ROLES]=], 256, 256, 0, 0, GetTexCoordsForRole("DAMAGER")),
healer = CreateTextureMarkup([=[Interface\LFGFrame\UI-LFG-ICON-ROLES]=], 256, 256, 0, 0, GetTexCoordsForRole("HEALER")),
tank = CreateTextureMarkup([=[Interface\LFGFrame\UI-LFG-ICON-ROLES]=], 256, 256, 0, 0, GetTexCoordsForRole("TANK"))
}
local function UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, matchCount, unitCount, maxUnitCount, matchCountPerUnit, totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, role, raidMark)
if not triggerStates[cloneId] then if not triggerStates[cloneId] then
triggerStates[cloneId] = { triggerStates[cloneId] = {
show = true, show = true,
@@ -488,6 +513,8 @@ local function UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, mat
unit = bestMatch.unit, unit = bestMatch.unit,
unitName = bestMatch.unitName, unitName = bestMatch.unitName,
GUID = bestMatch.unit and UnitGUID(bestMatch.unit) or bestMatch.GUID, GUID = bestMatch.unit and UnitGUID(bestMatch.unit) or bestMatch.GUID,
role = role,
roleIcon = role and roleIcons[role],
raidMark = raidMark, raidMark = raidMark,
matchCount = matchCount, matchCount = matchCount,
unitCount = unitCount, unitCount = unitCount,
@@ -525,6 +552,12 @@ local function UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, mat
changed = true changed = true
end end
if state.role ~= role then
state.role = role
state.roleIcon = roleIcons[role]
changed = true
end
if state.raidMark ~= raidMark then if state.raidMark ~= raidMark then
state.raidMark = raidMark state.raidMark = raidMark
changed = true changed = true
@@ -689,7 +722,7 @@ local function UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, mat
end end
end end
local function UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId, unit, matchCount, unitCount, maxUnitCount, matchCountPerUnit, totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, raidMark) local function UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId, unit, matchCount, unitCount, maxUnitCount, matchCountPerUnit, totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, role, raidMark)
local fallbackName, fallbackIcon = BuffTrigger.GetNameAndIconSimple(WeakAuras.GetData(triggerInfo.id), triggerInfo.triggernum) local fallbackName, fallbackIcon = BuffTrigger.GetNameAndIconSimple(WeakAuras.GetData(triggerInfo.id), triggerInfo.triggernum)
if not triggerStates[cloneId] then if not triggerStates[cloneId] then
triggerStates[cloneId] = { triggerStates[cloneId] = {
@@ -709,7 +742,9 @@ local function UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId,
unaffected = unaffected, unaffected = unaffected,
unaffectedUnits = unaffectedUnits, unaffectedUnits = unaffectedUnits,
unit = unit, unit = unit,
role = role,
raidMark = raidMark, raidMark = raidMark,
roleIcon = role and roleIcons[role],
unitName = unit and GetUnitName(unit, false) or "", unitName = unit and GetUnitName(unit, false) or "",
destName = "", destName = "",
name = fallbackName, name = fallbackName,
@@ -777,6 +812,12 @@ local function UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId,
changed = true changed = true
end end
if state.role ~= role then
state.role = role
state.roleIcon = roleIcons[role]
changed = true
end
if state.raidMark ~= raidMark then if state.raidMark ~= raidMark then
state.raidMark = raidMark state.raidMark = raidMark
changed = true changed = true
@@ -1068,7 +1109,12 @@ local function TriggerInfoApplies(triggerInfo, unit)
return false return false
end end
if triggerInfo.raidRole and not triggerInfo.raidRole[WeakAuras.UnitRaidRole(unit) or ""] then local unitRole = WeakAuras.GetUnitRole(controllingUnit)
if triggerInfo.groupRole and unitRole and not triggerInfo.groupRole[unitRole or ""] then
return false
end
if triggerInfo.raidRole and not triggerInfo.raidRole[WeakAuras.UnitRaidRole(controllingUnit) or ""] then
return false return false
end end
@@ -1175,6 +1221,12 @@ local function bestUnit(triggerInfo, bestMatch)
end end
end end
local function roleForTriggerInfo(triggerInfo, unit)
if triggerInfo.fetchRole then
return WeakAuras.GetUnitRole(unit)
end
end
local function markForTriggerInfo(triggerInfo, unit) local function markForTriggerInfo(triggerInfo, unit)
if triggerInfo.fetchRaidMark then if triggerInfo.fetchRaidMark then
local rt = unit and GetRaidTargetIndex(unit) local rt = unit and GetRaidTargetIndex(unit)
@@ -1226,12 +1278,13 @@ local function UpdateTriggerState(time, id, triggernum)
end end
local unit = bestUnit(triggerInfo, bestMatch) local unit = bestUnit(triggerInfo, bestMatch)
local role = roleForTriggerInfo(triggerInfo, unit)
local mark = markForTriggerInfo(triggerInfo, unit) local mark = markForTriggerInfo(triggerInfo, unit)
if bestMatch then if bestMatch then
updated = UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, matchCount, unitCount, maxUnitCount, matchCount, totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, mark) updated = UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, matchCount, unitCount, maxUnitCount, matchCount, totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, role, mark)
else else
updated = UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId, unit, 0, 0, maxUnitCount, 0, 0, affected, affectedUnits, unaffected, unaffectedUnits, mark) updated = UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId, unit, 0, 0, maxUnitCount, 0, 0, affected, affectedUnits, unaffected, unaffectedUnits, role, mark)
end end
else else
updated = RemoveState(triggerStates, cloneId) updated = RemoveState(triggerStates, cloneId)
@@ -1293,17 +1346,19 @@ local function UpdateTriggerState(time, id, triggernum)
usedCloneIds[cloneId] = 1 usedCloneIds[cloneId] = 1
end end
local role = roleForTriggerInfo(triggerInfo, auraData.unit)
local mark = markForTriggerInfo(triggerInfo, auraData.unit) local mark = markForTriggerInfo(triggerInfo, auraData.unit)
updated = UpdateStateWithMatch(time, auraData, triggerStates, cloneId, matchCount, unitCount, maxUnitCount, updated = UpdateStateWithMatch(time, auraData, triggerStates, cloneId, matchCount, unitCount, maxUnitCount,
matchCountPerUnit[auraData.unit], totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, mark) or updated matchCountPerUnit[auraData.unit], totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, role, mark) or updated
cloneIds[cloneId] = true cloneIds[cloneId] = true
end end
if matchCount == 0 then if matchCount == 0 then
local unit = bestUnit(triggerInfo, nil) local unit = bestUnit(triggerInfo, nil)
local role = roleForTriggerInfo(triggerInfo, unit)
local mark = markForTriggerInfo(triggerInfo, unit) local mark = markForTriggerInfo(triggerInfo, unit)
updated = UpdateStateWithNoMatch(time, triggerStates, triggerInfo, "", nil, 0, 0, maxUnitCount, 0, totalStacks, updated = UpdateStateWithNoMatch(time, triggerStates, triggerInfo, "", nil, 0, 0, maxUnitCount, 0, totalStacks,
affected, affectedUnits, unaffected, unaffectedUnits, mark) or updated affected, affectedUnits, unaffected, unaffectedUnits, role, mark) or updated
cloneIds[""] = true cloneIds[""] = true
end end
end end
@@ -1350,9 +1405,10 @@ local function UpdateTriggerState(time, id, triggernum)
if triggerInfo.perUnitMode == "affected" then if triggerInfo.perUnitMode == "affected" then
for unit, bestMatch in pairs(matches) do for unit, bestMatch in pairs(matches) do
if bestMatch then if bestMatch then
local role = roleForTriggerInfo(triggerInfo, unit)
local mark = markForTriggerInfo(triggerInfo, unit) local mark = markForTriggerInfo(triggerInfo, unit)
updated = UpdateStateWithMatch(time, bestMatch, triggerStates, unit, matchCount, unitCount, maxUnitCount, updated = UpdateStateWithMatch(time, bestMatch, triggerStates, unit, matchCount, unitCount, maxUnitCount,
matchCountPerUnit[unit], totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, mark) matchCountPerUnit[unit], totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, role, mark)
or updated or updated
cloneIds[unit] = true cloneIds[unit] = true
end end
@@ -1362,18 +1418,19 @@ local function UpdateTriggerState(time, id, triggernum)
for unit in GetAllUnits(triggerInfo.unit, nil, triggerInfo.includePets) do for unit in GetAllUnits(triggerInfo.unit, nil, triggerInfo.includePets) do
if activeGroupScanFuncs[unit] and activeGroupScanFuncs[unit][triggerInfo] then if activeGroupScanFuncs[unit] and activeGroupScanFuncs[unit][triggerInfo] then
local bestMatch = matches[unit] local bestMatch = matches[unit]
local role = roleForTriggerInfo(triggerInfo, unit)
local mark = markForTriggerInfo(triggerInfo, unit) local mark = markForTriggerInfo(triggerInfo, unit)
if bestMatch then if bestMatch then
if triggerInfo.perUnitMode == "all" then if triggerInfo.perUnitMode == "all" then
updated = UpdateStateWithMatch(time, bestMatch, triggerStates, unit, matchCount, unitCount, maxUnitCount, updated = UpdateStateWithMatch(time, bestMatch, triggerStates, unit, matchCount, unitCount, maxUnitCount,
matchCountPerUnit[unit], totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, mark) matchCountPerUnit[unit], totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, role, mark)
or updated or updated
cloneIds[unit] = true cloneIds[unit] = true
end end
else else
updated = UpdateStateWithNoMatch(time, triggerStates, triggerInfo, unit, unit, matchCount, updated = UpdateStateWithNoMatch(time, triggerStates, triggerInfo, unit, unit, matchCount,
unitCount, maxUnitCount, matchCountPerUnit[unit], totalStacks, unitCount, maxUnitCount, matchCountPerUnit[unit], totalStacks,
affected, affectedUnits, unaffected, unaffectedUnits) affected, affectedUnits, unaffected, unaffectedUnits, role)
or updated or updated
cloneIds[unit] = true cloneIds[unit] = true
end end
@@ -1402,7 +1459,7 @@ local function UpdateTriggerState(time, id, triggernum)
triggerInfo.nextScheduledCheckHandle = nil triggerInfo.nextScheduledCheckHandle = nil
triggerInfo.nextScheduledCheck = nil triggerInfo.nextScheduledCheck = nil
end end
-- if the trigger has updated then check to see if it is flagged for WatchedTrigger and send to queue if it is -- if the trigger has updated then check to see if it is flagged for WatchedTrigger and send to queue if it is
if updated then if updated then
if watched_trigger_events[id] and watched_trigger_events[id][triggernum] then if watched_trigger_events[id] and watched_trigger_events[id][triggernum] then
@@ -1584,6 +1641,15 @@ local function UpdateStates(matchDataChanged, time)
end end
end end
local function ScanGroupRoleScanFunc(matchDataChanged)
for id, idData in pairs(groupRoleScanFunc) do
matchDataChanged[id] = matchDataChanged[id] or {}
for _, triggerInfo in ipairs(idData) do
matchDataChanged[id][triggerInfo.triggernum] = true
end
end
end
local function ScanRaidMarkScanFunc(matchDataChanged) local function ScanRaidMarkScanFunc(matchDataChanged)
for id, idData in pairs(raidMarkScanFuncs) do for id, idData in pairs(raidMarkScanFuncs) do
matchDataChanged[id] = matchDataChanged[id] or {} matchDataChanged[id] = matchDataChanged[id] or {}
@@ -1830,6 +1896,7 @@ local function EventHandler(frame, event, arg1, arg2, ...)
ScanGroupUnit(time, matchDataChanged, "group", unit) ScanGroupUnit(time, matchDataChanged, "group", unit)
end end
end end
ScanGroupRoleScanFunc(matchDataChanged)
elseif event == "UNIT_FLAGS" or event == "UNIT_NAME_UPDATE" or event == "PLAYER_FLAGS_CHANGED" then elseif event == "UNIT_FLAGS" or event == "UNIT_NAME_UPDATE" or event == "PLAYER_FLAGS_CHANGED" then
if Private.multiUnitUnits.group[arg1] then if Private.multiUnitUnits.group[arg1] then
RecheckActiveForUnitType("group", arg1, deactivatedTriggerInfos) RecheckActiveForUnitType("group", arg1, deactivatedTriggerInfos)
@@ -1994,6 +2061,7 @@ function BuffTrigger.UnloadAll()
wipe(scanFuncNameMulti) wipe(scanFuncNameMulti)
wipe(scanFuncSpellIdMulti) wipe(scanFuncSpellIdMulti)
wipe(unitExistScanFunc) wipe(unitExistScanFunc)
wipe(groupRoleScanFunc)
wipe(groupScanFuncs) wipe(groupScanFuncs)
wipe(raidMarkScanFuncs) wipe(raidMarkScanFuncs)
wipe(matchDataByTrigger) wipe(matchDataByTrigger)
@@ -2043,6 +2111,11 @@ local function LoadAura(id, triggernum, triggerInfo)
end end
end end
if triggerInfo.fetchRole then
groupRoleScanFunc[id] = groupRoleScanFunc[id] or {}
tinsert(groupRoleScanFunc[id], triggerInfo)
end
if triggerInfo.fetchRaidMark then if triggerInfo.fetchRaidMark then
raidMarkScanFuncs[id] = raidMarkScanFuncs[id] or {} raidMarkScanFuncs[id] = raidMarkScanFuncs[id] or {}
tinsert(raidMarkScanFuncs[id], triggerInfo) tinsert(raidMarkScanFuncs[id], triggerInfo)
@@ -2086,6 +2159,7 @@ function BuffTrigger.UnloadDisplays(toUnload)
unitData[id] = nil unitData[id] = nil
end end
groupRoleScanFunc[id] = nil
raidMarkScanFuncs[id] = nil raidMarkScanFuncs[id] = nil
for unit, unitData in pairs(matchData) do for unit, unitData in pairs(matchData) do
@@ -2165,6 +2239,8 @@ function BuffTrigger.Rename(oldid, newid)
unitData[newid] = unitData[oldid] unitData[newid] = unitData[oldid]
unitData[oldid] = nil unitData[oldid] = nil
end end
groupRoleScanFunc[newid] = groupRoleScanFunc[oldid]
groupRoleScanFunc[oldid] = nil
raidMarkScanFuncs[newid] = raidMarkScanFuncs[oldid] raidMarkScanFuncs[newid] = raidMarkScanFuncs[oldid]
raidMarkScanFuncs[oldid] = nil raidMarkScanFuncs[oldid] = nil
matchDataChanged[newid] = matchDataChanged[oldid] matchDataChanged[newid] = matchDataChanged[oldid]
@@ -2486,6 +2562,7 @@ function BuffTrigger.Add(data)
local groupTrigger = trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party" local groupTrigger = trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
local effectiveIgnoreSelf = (groupTrigger or trigger.unit == "nameplate") and trigger.ignoreSelf local effectiveIgnoreSelf = (groupTrigger or trigger.unit == "nameplate") and trigger.ignoreSelf
local effectiveGroupRole = groupTrigger and trigger.useGroupRole and trigger.group_role or nil
local effectiveRaidRole = groupTrigger and trigger.useRaidRole and trigger.raid_role or nil local effectiveRaidRole = groupTrigger and trigger.useRaidRole and trigger.raid_role or nil
local effectiveClass = groupTrigger and trigger.useClass and trigger.class local effectiveClass = groupTrigger and trigger.useClass and trigger.class
local effectiveSpecId = groupTrigger and trigger.useActualSpec and trigger.actualSpec or nil local effectiveSpecId = groupTrigger and trigger.useActualSpec and trigger.actualSpec or nil
@@ -2549,6 +2626,7 @@ function BuffTrigger.Add(data)
ignoreDead = effectiveIgnoreDead, ignoreDead = effectiveIgnoreDead,
ignoreDisconnected = effectiveIgnoreDisconnected, ignoreDisconnected = effectiveIgnoreDisconnected,
ignoreInvisible = effectiveIgnoreInvisible, ignoreInvisible = effectiveIgnoreInvisible,
groupRole = effectiveGroupRole,
raidRole = effectiveRaidRole, raidRole = effectiveRaidRole,
specId = effectiveSpecId, specId = effectiveSpecId,
groupSubType = groupSubType, groupSubType = groupSubType,
@@ -2707,6 +2785,11 @@ function BuffTrigger.GetAdditionalProperties(data, triggernum)
props["refreshTime"] = L["Since Apply/Refresh"] props["refreshTime"] = L["Since Apply/Refresh"]
end end
if trigger.unit ~= "multi" and trigger.fetchRole then
props["role"] = L["Assigned Role"]
props["roleIcon"] = L["Assigned Role Icon"]
end
if trigger.unit ~= "multi" and trigger.fetchRaidMark then if trigger.unit ~= "multi" and trigger.fetchRaidMark then
props["raidMark"] = L["Raid Mark"] props["raidMark"] = L["Raid Mark"]
end end
+16
View File
@@ -115,6 +115,22 @@ RAID_CLASS_COLORS.SHAMAN.colorStr = "ff0070de"
RAID_CLASS_COLORS.WARRIOR.colorStr = "ffc79c6e" RAID_CLASS_COLORS.WARRIOR.colorStr = "ffc79c6e"
RAID_CLASS_COLORS.DEATHKNIGHT.colorStr = "ffc41f3b" RAID_CLASS_COLORS.DEATHKNIGHT.colorStr = "ffc41f3b"
function CreateTextureMarkup(file, fileWidth, fileHeight, width, height, left, right, top, bottom, xOffset, yOffset)
return ("|T%s:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d|t"):format(
file
, height
, width
, xOffset or 0
, yOffset or 0
, fileWidth
, fileHeight
, left * fileWidth
, right * fileWidth
, top * fileHeight
, bottom * fileHeight
);
end
function Clamp(value, min, max) function Clamp(value, min, max)
if value > max then if value > max then
return max; return max;
+6
View File
@@ -3025,6 +3025,12 @@ function WeakAuras.WatchUnitChange(unit)
eventsToSend["UNIT_ROLE_CHANGED_" .. unit] = unit eventsToSend["UNIT_ROLE_CHANGED_" .. unit] = unit
watchUnitChange.unitRaidRole[unit] = newRaidRole watchUnitChange.unitRaidRole[unit] = newRaidRole
end end
local oldRole = watchUnitChange.unitRoles[unit]
local newRole = WeakAuras.GetUnitRole(unit)
if oldRole ~= newRole then
eventsToSend["UNIT_ROLE_CHANGED_" .. unit] = unit
watchUnitChange.unitRoles[unit] = newRole
end
end end
local function handleUnit(unit, eventsToSend, ...) local function handleUnit(unit, eventsToSend, ...)
+2 -2
View File
@@ -10,7 +10,7 @@ WeakAuras.doubleWidth = WeakAuras.normalWidth * 2
local versionStringFromToc = GetAddOnMetadata("WeakAuras", "Version") local versionStringFromToc = GetAddOnMetadata("WeakAuras", "Version")
local versionString = "5.19.0 Beta" local versionString = "5.19.0 Beta"
local buildTime = "20250127040000" local buildTime = "20250127040000"
local isAwesomeEnabled = C_NamePlate and C_NamePlate.GetNamePlateForUnit or false local isAwesomeEnabled = C_NamePlate and C_NamePlate.GetNamePlateForUnit and true or false
WeakAuras.versionString = versionString WeakAuras.versionString = versionString
WeakAuras.buildTime = buildTime WeakAuras.buildTime = buildTime
@@ -18,7 +18,7 @@ WeakAuras.newFeatureString = "|TInterface\\OptionsFrame\\UI-OptionsFrame-NewFeat
WeakAuras.BuildInfo = select(4, GetBuildInfo()) WeakAuras.BuildInfo = select(4, GetBuildInfo())
function WeakAuras.isAwesomeEnabled() function WeakAuras.isAwesomeEnabled()
return isAwesomeEnabled return isAwesomeEnabled or false
end end
function WeakAuras.IsCorrectVersion() function WeakAuras.IsCorrectVersion()
+40 -18
View File
@@ -8,8 +8,11 @@ local unpack = unpack
-- WoW APIs -- WoW APIs
local UnitName, UnitIsUnit, UnitClass, GetNumGroupMembers = UnitName, UnitIsUnit, UnitClass, GetNumGroupMembers local UnitName, UnitIsUnit, UnitClass, GetNumGroupMembers = UnitName, UnitIsUnit, UnitClass, GetNumGroupMembers
local LibGroupTalents = LibStub("LibGroupTalents-1.0")
local nameToGlyphs = {} local nameToGlyphs = {}
local nameToSpecMap = {} local nameToSpecMap = {}
local nameToUnitRole = {}
local nameToUnitMap = { local nameToUnitMap = {
[UnitName("player")] = "player" [UnitName("player")] = "player"
} }
@@ -17,14 +20,14 @@ local nameToUnitMap = {
local subscribers = {} local subscribers = {}
Private.LibGroupTalentsWrapper = { Private.LibGroupTalentsWrapper = {
Register = function(callback) end, Register = function(f) end,
SpecForUnit = function(unit) end, SpecForUnit = function(unit) end,
GetUnitRole = function(unit) end,
SpecRolePositionForUnit = function(unit) end, SpecRolePositionForUnit = function(unit) end,
CheckTalentForUnit = function(unit, talentId) end, CheckTalentForUnit = function(unit) end,
CheckGlyphForUnit = function(unit, glyphId) end, CheckGlyphForUnit = function(unit) end,
} }
local LibGroupTalents = LibStub("LibGroupTalents-1.0")
if LibGroupTalents then if LibGroupTalents then
--- LibGroupTalents callback for talents and glyphs --- LibGroupTalents callback for talents and glyphs
function Private.LibGroupTalentsWrapper:LibGroupTalentsCallback(_, _, unit) function Private.LibGroupTalentsWrapper:LibGroupTalentsCallback(_, _, unit)
@@ -58,15 +61,22 @@ if LibGroupTalents then
if not nameToUnitMap[storedName] then if not nameToUnitMap[storedName] then
nameToSpecMap[storedName] = nil nameToSpecMap[storedName] = nil
nameToGlyphs[storedName] = nil nameToGlyphs[storedName] = nil
nameToUnitRole[storedName] = nil
end end
end end
local specInfo = { LibGroupTalents:GetUnitTalentSpec(unit) } local specInfo = { LibGroupTalents:GetUnitTalentSpec(unit) }
local class = select(2, UnitClass(unit)) if specInfo and #specInfo > 0 then
if specInfo and #specInfo > 0 and class then local class = select(2, UnitClass(unit))
nameToSpecMap[unitName] = class .. specInfo[1] if specInfo and #specInfo > 0 and class then
nameToSpecMap[unitName] = {
class .. specInfo[1], unpack(specInfo)
}
end
end end
nameToUnitRole[unitName] = LibGroupTalents:GetUnitRole(unit)
local glyphs = { LibGroupTalents:GetUnitGlyphs(unit) } local glyphs = { LibGroupTalents:GetUnitGlyphs(unit) }
if glyphs and #glyphs > 0 then if glyphs and #glyphs > 0 then
nameToGlyphs[unitName] = {} nameToGlyphs[unitName] = {}
@@ -83,6 +93,8 @@ if LibGroupTalents then
end end
LibGroupTalents.RegisterCallback(Private.LibGroupTalentsWrapper, "LibGroupTalents_Update", "LibGroupTalentsCallback") LibGroupTalents.RegisterCallback(Private.LibGroupTalentsWrapper, "LibGroupTalents_Update", "LibGroupTalentsCallback")
LibGroupTalents.RegisterCallback(Private.LibGroupTalentsWrapper, "LibGroupTalents_RoleChange", "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)
@@ -97,17 +109,30 @@ if LibGroupTalents then
end end
if UnitIsUnit(unit, "player") and class then if UnitIsUnit(unit, "player") and class then
local specInfo = LibGroupTalents:GetUnitTalentSpec(unit) local specInfo = { LibGroupTalents:GetUnitTalentSpec(unit) }
if specInfo and #specInfo > 0 then if specInfo and #specInfo > 0 then
return class .. specInfo[1] return class .. specInfo[1], unpack(specInfo)
end end
end 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) function Private.LibGroupTalentsWrapper.SpecRolePositionForUnit(unit)
local data = nameToSpecMap[UnitName(unit)] local data = nameToSpecMap[UnitName(unit)]
if data then if data then
return unpack(data) return unpack(data, 2)
end end
if UnitIsUnit(unit, "player") then if UnitIsUnit(unit, "player") then
@@ -116,7 +141,7 @@ if LibGroupTalents then
end end
function Private.LibGroupTalentsWrapper.CheckTalentForUnit(unit, talentId) function Private.LibGroupTalentsWrapper.CheckTalentForUnit(unit, talentId)
return UnitIsUnit(unit, "player") and LibGroupTalents:UnitHasTalent(unit, talentId) and true or false return UnitIsUnit(unit, "player") and LibGroupTalents:UnitHasTalent(unit, talentId) and true or nil
end end
function Private.LibGroupTalentsWrapper.CheckGlyphForUnit(unit, glyphId) function Private.LibGroupTalentsWrapper.CheckGlyphForUnit(unit, glyphId)
@@ -127,23 +152,20 @@ if LibGroupTalents then
if UnitIsUnit(unit, "player") then if UnitIsUnit(unit, "player") then
local glyphs = { LibGroupTalents:GetUnitGlyphs(unit) } local glyphs = { LibGroupTalents:GetUnitGlyphs(unit) }
if glyphs then
for _, id in ipairs(glyphs) do for _, id in ipairs(glyphs) do
if id == glyphId then if id == glyphId then
return true return true
end end
end end
end
end end
end end
else
function Private.LibGroupTalentsWrapper.Register(f) end
function Private.LibGroupTalentsWrapper.SpecForUnit(unit) return nil end
function Private.LibGroupTalentsWrapper.SpecRolePositionForUnit(unit) return nil end
function Private.LibGroupTalentsWrapper.CheckTalentForUnit(unit) return nil end
function Private.LibGroupTalentsWrapper.CheckGlyphForUnit(unit) return nil end
end end
-- Export for GenericTrigger -- Export for GenericTrigger/Custom Code
WeakAuras.SpecForUnit = Private.LibGroupTalentsWrapper.SpecForUnit WeakAuras.SpecForUnit = Private.LibGroupTalentsWrapper.SpecForUnit
WeakAuras.GetUnitRole = Private.LibGroupTalentsWrapper.GetUnitRole
WeakAuras.SpecRolePositionForUnit = Private.LibGroupTalentsWrapper.SpecRolePositionForUnit WeakAuras.SpecRolePositionForUnit = Private.LibGroupTalentsWrapper.SpecRolePositionForUnit
WeakAuras.CheckTalentForUnit = Private.LibGroupTalentsWrapper.CheckTalentForUnit WeakAuras.CheckTalentForUnit = Private.LibGroupTalentsWrapper.CheckTalentForUnit
WeakAuras.CheckGlyphForUnit = Private.LibGroupTalentsWrapper.CheckGlyphForUnit WeakAuras.CheckGlyphForUnit = Private.LibGroupTalentsWrapper.CheckGlyphForUnit
+60 -9
View File
@@ -1094,6 +1094,14 @@ Private.load_prototype = {
limit = 2 limit = 2
}, },
}, },
{
name = "role",
display = L["Spec Role"],
type = "multiselect",
values = "role_types",
init = "arg",
events = {"PLAYER_TALENT_UPDATE", "PLAYER_ROLES_ASSIGNED", "SPELL_UPDATE_USABLE", "WA_DELAYED_PLAYER_ENTERING_WORLD"}
},
{ {
name = "raid_role", name = "raid_role",
display = L["Raid Role"], display = L["Raid Role"],
@@ -1474,9 +1482,8 @@ Private.event_prototypes = {
local unit = trigger.unit local unit = trigger.unit
local result = {} local result = {}
AddUnitChangeInternalEvents(unit, result, nil, trigger.use_unitisunit and trigger.unitisunit or nil) AddUnitChangeInternalEvents(unit, result, nil, trigger.use_unitisunit and trigger.unitisunit or nil)
if trigger.use_specId then AddUnitRoleChangeInternalEvents(unit, result)
AddUnitSpecChangeInternalEvents(unit, result) AddUnitSpecChangeInternalEvents(unit, result)
end
return result return result
end, end,
loadFunc = function(trigger) loadFunc = function(trigger)
@@ -1587,6 +1594,18 @@ Private.event_prototypes = {
store = true, store = true,
conditionType = "select" conditionType = "select"
}, },
{
name = "role",
display = L["Spec Role"],
type = "select",
init = "WeakAuras.GetUnitRole(unit)",
values = "role_types",
store = true,
conditionType = "select",
enable = function(trigger)
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
end
},
{ {
name = "raid_role", name = "raid_role",
display = L["Raid Role"], display = L["Raid Role"],
@@ -1912,9 +1931,7 @@ Private.event_prototypes = {
if includePets ~= "PetsOnly" then if includePets ~= "PetsOnly" then
AddUnitRoleChangeInternalEvents(unit, result) AddUnitRoleChangeInternalEvents(unit, result)
end end
if trigger.use_specId then AddUnitSpecChangeInternalEvents(unit, result)
AddUnitSpecChangeInternalEvents(unit, result)
end
return result return result
end, end,
loadFunc = function(trigger) loadFunc = function(trigger)
@@ -2101,6 +2118,18 @@ Private.event_prototypes = {
end, end,
desc = L["Requires syncing the specialization via LibGroupTalents."], desc = L["Requires syncing the specialization via LibGroupTalents."],
}, },
{
name = "role",
display = L["Spec Role"],
type = "select",
init = "WeakAuras.GetUnitRole(unit)",
values = "role_types",
store = true,
conditionType = "select",
enable = function(trigger)
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
end
},
{ {
name = "raid_role", name = "raid_role",
display = L["Raid Role"], display = L["Raid Role"],
@@ -2260,9 +2289,7 @@ Private.event_prototypes = {
if includePets ~= "PetsOnly" then if includePets ~= "PetsOnly" then
AddUnitRoleChangeInternalEvents(unit, result) AddUnitRoleChangeInternalEvents(unit, result)
end end
if trigger.use_specId then AddUnitSpecChangeInternalEvents(unit, result)
AddUnitSpecChangeInternalEvents(unit, result)
end
if trigger.use_showCost and trigger.unit == "player" then if trigger.use_showCost and trigger.unit == "player" then
tinsert(result, "WA_UNIT_QUEUED_SPELL_CHANGED"); tinsert(result, "WA_UNIT_QUEUED_SPELL_CHANGED");
end end
@@ -2515,6 +2542,18 @@ Private.event_prototypes = {
end, end,
desc = L["Requires syncing the specialization via LibGroupTalents."], desc = L["Requires syncing the specialization via LibGroupTalents."],
}, },
{
name = "role",
display = L["Spec Role"],
type = "select",
init = "WeakAuras.GetUnitRole(unit)",
values = "role_types",
store = true,
conditionType = "select",
enable = function(trigger)
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
end
},
{ {
name = "raid_role", name = "raid_role",
display = L["Raid Role"], display = L["Raid Role"],
@@ -6446,6 +6485,18 @@ Private.event_prototypes = {
return not trigger.use_inverse return not trigger.use_inverse
end end
}, },
{
name = "role",
display = L["Spec Role"],
type = "select",
init = "WeakAuras.GetUnitRole(unit)",
values = "role_types",
store = true,
conditionType = "select",
enable = function(trigger)
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
end
},
{ {
name = "raid_role", name = "raid_role",
display = L["Raid Role"], display = L["Raid Role"],
+7
View File
@@ -2315,6 +2315,13 @@ Private.raid_role_types = {
NONE = L["Other"] NONE = L["Other"]
} }
Private.role_types = {
tank = "|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES:16:16:0:0:64:64:0:19:22:41|t "..TANK,
melee = "|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES:16:16:0:0:64:64:20:39:22:41|t "..MELEE,
caster = "|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES:16:16:0:0:64:64:20:39:22:41|t "..L["Caster"],
healer = "|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES:16:16:0:0:64:64:20:39:1:20|t "..HEALER,
}
Private.group_member_types = { Private.group_member_types = {
LEADER = L["Leader"], LEADER = L["Leader"],
ASSIST = L["Assist"], ASSIST = L["Assist"],
+8 -8
View File
@@ -236,7 +236,6 @@ local loadEvents = {}
-- All regions keyed on id, has properties: region, regionType, also see clones -- All regions keyed on id, has properties: region, regionType, also see clones
Private.regions = {}; Private.regions = {};
local regions = Private.regions;
-- keyed on id, contains bool indicating whether the aura is loaded -- keyed on id, contains bool indicating whether the aura is loaded
Private.loaded = {}; Private.loaded = {};
@@ -1384,6 +1383,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 raidRole = false; local raidRole = false;
local raidID = UnitInRaid("player") local raidID = UnitInRaid("player")
if raidID then if raidID then
@@ -1391,7 +1391,7 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...)
end end
local _, class = UnitClass("player"); local _, class = UnitClass("player");
local inCombat = UnitAffectingCombat("player") -- or UnitAffectingCombat("pet"); local inCombat = UnitAffectingCombat("player")
local alive = not UnitIsDeadOrGhost('player') local alive = not UnitIsDeadOrGhost('player')
local pvp = UnitIsPVPFreeForAll("player") or UnitIsPVP("player") local pvp = UnitIsPVPFreeForAll("player") or UnitIsPVP("player")
local vehicle = UnitInVehicle("player") or UnitOnTaxi("player") or false local vehicle = UnitInVehicle("player") or UnitOnTaxi("player") or false
@@ -1422,8 +1422,8 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...)
if (data and not data.controlledChildren) then if (data and not data.controlledChildren) then
local loadFunc = loadFuncs[id]; local loadFunc = loadFuncs[id];
local loadOpt = loadFuncsForOptions[id]; local loadOpt = loadFuncsForOptions[id];
shouldBeLoaded = loadFunc and loadFunc("ScanForLoads_Auras", inCombat, alive, pvp, vehicle, vehicleUi, mounted, player, realm, class, race, faction, playerLevel, raidRole, group, groupSize, raidMemberType, zone, zoneId, subzone, size, difficulty); shouldBeLoaded = loadFunc and loadFunc("ScanForLoads_Auras", inCombat, alive, pvp, vehicle, vehicleUi, mounted, player, realm, class, race, faction, playerLevel, role, raidRole, group, groupSize, raidMemberType, zone, zoneId, subzone, size, difficulty);
couldBeLoaded = loadOpt and loadOpt("ScanForLoads_Auras", inCombat, alive, pvp, vehicle, vehicleUi, mounted, player, realm, class, race, faction, playerLevel, raidRole, group, groupSize, raidMemberType, zone, zoneId, subzone, size, difficulty); couldBeLoaded = loadOpt and loadOpt("ScanForLoads_Auras", inCombat, alive, pvp, vehicle, vehicleUi, mounted, player, realm, class, race, faction, playerLevel, role, raidRole, group, groupSize, raidMemberType, zone, zoneId, subzone, size, difficulty);
if(shouldBeLoaded and not loaded[id]) then if(shouldBeLoaded and not loaded[id]) then
changed = changed + 1; changed = changed + 1;
@@ -2888,9 +2888,9 @@ function Private.SetRegion(data, cloneId)
region = clones[id][cloneId]; region = clones[id][cloneId];
end end
else else
if((not regions[id]) or (not regions[id].region) or regions[id].regionType ~= regionType) then if((not Private.regions[id]) or (not Private.regions[id].region) or Private.regions[id].regionType ~= regionType) then
region = regionTypes[regionType].create(WeakAurasFrame, data); region = regionTypes[regionType].create(WeakAurasFrame, data);
regions[id] = { Private.regions[id] = {
regionType = regionType, regionType = regionType,
region = region region = region
}; };
@@ -2901,7 +2901,7 @@ function Private.SetRegion(data, cloneId)
region.toShow = true region.toShow = true
end end
else else
region = regions[id].region region = Private.regions[id].region
end end
end end
region.id = id; region.id = id;
@@ -4428,7 +4428,7 @@ function Private.UpdatedTriggerState(id)
state.changed = false; state.changed = false;
end end
end end
-- once updatedTriggerStates is complete, and empty states removed, etc., then check for queued watched triggers update -- once updatedTriggerStates is complete, and empty states removed, etc., then check for queued watched triggers update
Private.SendDelayedWatchedTriggers() Private.SendDelayedWatchedTriggers()
end end
+2 -2
View File
@@ -32,6 +32,7 @@ DefaultOptions.lua
# Core files # Core files
Types.lua Types.lua
LibGroupTalentsWrapper.lua
Prototypes.lua Prototypes.lua
Profiling.lua Profiling.lua
WeakAuras.lua WeakAuras.lua
@@ -43,7 +44,6 @@ Conditions.lua
AnchorToWeakAuras.lua AnchorToWeakAuras.lua
# Trigger systems # Trigger systems
LibGroupTalentsWrapper.lua
BuffTrigger2.lua BuffTrigger2.lua
GenericTrigger.lua GenericTrigger.lua
BossMods.lua BossMods.lua
@@ -81,4 +81,4 @@ SubRegionTypes\StopMotion.lua
SubRegionTypes\Texture.lua SubRegionTypes\Texture.lua
#Misc #Misc
DiscordList.lua DiscordList.lua
+29
View File
@@ -745,6 +745,35 @@ local function GetBuffTriggerOptions(data, triggernum)
and not trigger.useActualSpec) and not trigger.useActualSpec)
end end
}, },
useGroupRole = {
type = "toggle",
width = WeakAuras.normalWidth,
name = L["Filter by Group Role"],
order = 67.1,
hidden = function() return
not (trigger.type == "aura2" and (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"))
end
},
group_role = {
type = "multiselect",
width = WeakAuras.normalWidth,
name = L["Group Role"],
values = OptionsPrivate.Private.role_types,
hidden = function() return
not (trigger.type == "aura2" and (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party") and trigger.useGroupRole)
end,
order = 67.2
},
group_roleSpace = {
type = "description",
name = "",
order = 67.3,
width = WeakAuras.normalWidth,
hidden = function() return
not (trigger.type == "aura2" and (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party") and not trigger.useGroupRole)
end
},
useRaidRole = { useRaidRole = {
type = "toggle", type = "toggle",
width = WeakAuras.normalWidth, width = WeakAuras.normalWidth,
@@ -507,7 +507,7 @@ function OptionsPrivate.CreateFrame()
local awesomeWotlkButton local awesomeWotlkButton
if not WeakAuras.isAwesomeEnabled() then if not WeakAuras.isAwesomeEnabled() then
awesomeWotlkButton = addFooter("Awesome WotLK", [[Interface\AddOns\WeakAuras\Media\Textures\GitHub.tga]], "https://github.com/FrostAtom/awesome_wotlk/releases", awesomeWotlkButton = addFooter("Awesome WotLK", [[Interface\AddOns\WeakAuras\Media\Textures\GitHub.tga]], "https://github.com/FrostAtom/awesome_wotlk/releases",
L["Unlock nameplate anchoring & units in WeakAuras with the awesome_wotlk client patch"]) L["Unlock nameplate anchoring & units in WeakAuras with the Awesome WotLK client patch"])
awesomeWotlkButton:SetParent(tipFrame) awesomeWotlkButton:SetParent(tipFrame)
awesomeWotlkButton:SetPoint("LEFT", changelogButton or thanksButton, "RIGHT", 10, 0) awesomeWotlkButton:SetPoint("LEFT", changelogButton or thanksButton, "RIGHT", 10, 0)
end end
+5 -5
View File
@@ -249,11 +249,6 @@ local function createOptions(id, data)
desc = "|TInterface\\AddOns\\WeakAuras\\Media\\Textures\\edge-example:30|t\n"..L["Enable \"Edge\" part of the overlay"], desc = "|TInterface\\AddOns\\WeakAuras\\Media\\Textures\\edge-example:30|t\n"..L["Enable \"Edge\" part of the overlay"],
hidden = function() return not data.cooldown end, hidden = function() return not data.cooldown end,
}, },
endHeader = {
type = "header",
order = 100,
name = "",
},
ccWarning = { ccWarning = {
type = "description", type = "description",
width = WeakAuras.doubleWidth, width = WeakAuras.doubleWidth,
@@ -269,6 +264,11 @@ local function createOptions(id, data)
order = 11.7, order = 11.7,
hidden = function() return data.cooldownTextDisabled end hidden = function() return data.cooldownTextDisabled end
}, },
endHeader = {
type = "header",
order = 100,
name = "",
},
}; };
return { return {