diff --git a/WeakAuras/BuffTrigger2.lua b/WeakAuras/BuffTrigger2.lua index 630b523..1cb1774 100644 --- a/WeakAuras/BuffTrigger2.lua +++ b/WeakAuras/BuffTrigger2.lua @@ -76,6 +76,9 @@ local unitExistScanFunc = {} -- Which units exist local existingUnits = {} +-- Contains all scanFuncs that fetch the role + roleIcon +local groupRoleScanFunc = {} + -- Loaded ScanFuncs per unit type local groupScanFuncs = {} --Active ScanFuncs per actual unit id @@ -468,7 +471,29 @@ local function FindBestMatchDataForUnit(time, id, triggernum, triggerInfo, unit) return bestMatch, matchCount, stackCount, nextCheck 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 triggerStates[cloneId] = { show = true, @@ -488,6 +513,8 @@ local function UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, mat unit = bestMatch.unit, unitName = bestMatch.unitName, GUID = bestMatch.unit and UnitGUID(bestMatch.unit) or bestMatch.GUID, + role = role, + roleIcon = role and roleIcons[role], raidMark = raidMark, matchCount = matchCount, unitCount = unitCount, @@ -525,6 +552,12 @@ local function UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, mat changed = true end + if state.role ~= role then + state.role = role + state.roleIcon = roleIcons[role] + changed = true + end + if state.raidMark ~= raidMark then state.raidMark = raidMark changed = true @@ -689,7 +722,7 @@ local function UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, mat 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) if not triggerStates[cloneId] then triggerStates[cloneId] = { @@ -709,7 +742,9 @@ local function UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId, unaffected = unaffected, unaffectedUnits = unaffectedUnits, unit = unit, + role = role, raidMark = raidMark, + roleIcon = role and roleIcons[role], unitName = unit and GetUnitName(unit, false) or "", destName = "", name = fallbackName, @@ -777,6 +812,12 @@ local function UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId, changed = true end + if state.role ~= role then + state.role = role + state.roleIcon = roleIcons[role] + changed = true + end + if state.raidMark ~= raidMark then state.raidMark = raidMark changed = true @@ -1068,7 +1109,12 @@ local function TriggerInfoApplies(triggerInfo, unit) return false 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 end @@ -1175,6 +1221,12 @@ local function bestUnit(triggerInfo, bestMatch) end end +local function roleForTriggerInfo(triggerInfo, unit) + if triggerInfo.fetchRole then + return WeakAuras.GetUnitRole(unit) + end +end + local function markForTriggerInfo(triggerInfo, unit) if triggerInfo.fetchRaidMark then local rt = unit and GetRaidTargetIndex(unit) @@ -1226,12 +1278,13 @@ local function UpdateTriggerState(time, id, triggernum) end local unit = bestUnit(triggerInfo, bestMatch) + local role = roleForTriggerInfo(triggerInfo, unit) local mark = markForTriggerInfo(triggerInfo, unit) 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 - 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 else updated = RemoveState(triggerStates, cloneId) @@ -1293,17 +1346,19 @@ local function UpdateTriggerState(time, id, triggernum) usedCloneIds[cloneId] = 1 end + local role = roleForTriggerInfo(triggerInfo, auraData.unit) local mark = markForTriggerInfo(triggerInfo, auraData.unit) 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 end if matchCount == 0 then local unit = bestUnit(triggerInfo, nil) + local role = roleForTriggerInfo(triggerInfo, unit) local mark = markForTriggerInfo(triggerInfo, unit) 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 end end @@ -1350,9 +1405,10 @@ local function UpdateTriggerState(time, id, triggernum) if triggerInfo.perUnitMode == "affected" then for unit, bestMatch in pairs(matches) do if bestMatch then + local role = roleForTriggerInfo(triggerInfo, unit) local mark = markForTriggerInfo(triggerInfo, unit) 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 cloneIds[unit] = true end @@ -1362,18 +1418,19 @@ local function UpdateTriggerState(time, id, triggernum) for unit in GetAllUnits(triggerInfo.unit, nil, triggerInfo.includePets) do if activeGroupScanFuncs[unit] and activeGroupScanFuncs[unit][triggerInfo] then local bestMatch = matches[unit] + local role = roleForTriggerInfo(triggerInfo, unit) local mark = markForTriggerInfo(triggerInfo, unit) if bestMatch then if triggerInfo.perUnitMode == "all" then 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 cloneIds[unit] = true end else updated = UpdateStateWithNoMatch(time, triggerStates, triggerInfo, unit, unit, matchCount, unitCount, maxUnitCount, matchCountPerUnit[unit], totalStacks, - affected, affectedUnits, unaffected, unaffectedUnits) + affected, affectedUnits, unaffected, unaffectedUnits, role) or updated cloneIds[unit] = true end @@ -1402,7 +1459,7 @@ local function UpdateTriggerState(time, id, triggernum) triggerInfo.nextScheduledCheckHandle = nil triggerInfo.nextScheduledCheck = nil end - + -- 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 watched_trigger_events[id] and watched_trigger_events[id][triggernum] then @@ -1584,6 +1641,15 @@ local function UpdateStates(matchDataChanged, time) 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) for id, idData in pairs(raidMarkScanFuncs) do matchDataChanged[id] = matchDataChanged[id] or {} @@ -1830,6 +1896,7 @@ local function EventHandler(frame, event, arg1, arg2, ...) ScanGroupUnit(time, matchDataChanged, "group", unit) end end + ScanGroupRoleScanFunc(matchDataChanged) elseif event == "UNIT_FLAGS" or event == "UNIT_NAME_UPDATE" or event == "PLAYER_FLAGS_CHANGED" then if Private.multiUnitUnits.group[arg1] then RecheckActiveForUnitType("group", arg1, deactivatedTriggerInfos) @@ -1994,6 +2061,7 @@ function BuffTrigger.UnloadAll() wipe(scanFuncNameMulti) wipe(scanFuncSpellIdMulti) wipe(unitExistScanFunc) + wipe(groupRoleScanFunc) wipe(groupScanFuncs) wipe(raidMarkScanFuncs) wipe(matchDataByTrigger) @@ -2043,6 +2111,11 @@ local function LoadAura(id, triggernum, triggerInfo) end end + if triggerInfo.fetchRole then + groupRoleScanFunc[id] = groupRoleScanFunc[id] or {} + tinsert(groupRoleScanFunc[id], triggerInfo) + end + if triggerInfo.fetchRaidMark then raidMarkScanFuncs[id] = raidMarkScanFuncs[id] or {} tinsert(raidMarkScanFuncs[id], triggerInfo) @@ -2086,6 +2159,7 @@ function BuffTrigger.UnloadDisplays(toUnload) unitData[id] = nil end + groupRoleScanFunc[id] = nil raidMarkScanFuncs[id] = nil for unit, unitData in pairs(matchData) do @@ -2165,6 +2239,8 @@ function BuffTrigger.Rename(oldid, newid) unitData[newid] = unitData[oldid] unitData[oldid] = nil end + groupRoleScanFunc[newid] = groupRoleScanFunc[oldid] + groupRoleScanFunc[oldid] = nil raidMarkScanFuncs[newid] = raidMarkScanFuncs[oldid] raidMarkScanFuncs[oldid] = nil 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 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 effectiveClass = groupTrigger and trigger.useClass and trigger.class local effectiveSpecId = groupTrigger and trigger.useActualSpec and trigger.actualSpec or nil @@ -2549,6 +2626,7 @@ function BuffTrigger.Add(data) ignoreDead = effectiveIgnoreDead, ignoreDisconnected = effectiveIgnoreDisconnected, ignoreInvisible = effectiveIgnoreInvisible, + groupRole = effectiveGroupRole, raidRole = effectiveRaidRole, specId = effectiveSpecId, groupSubType = groupSubType, @@ -2707,6 +2785,11 @@ function BuffTrigger.GetAdditionalProperties(data, triggernum) props["refreshTime"] = L["Since Apply/Refresh"] 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 props["raidMark"] = L["Raid Mark"] end diff --git a/WeakAuras/Compatibility.lua b/WeakAuras/Compatibility.lua index 84eddd5..01282c6 100644 --- a/WeakAuras/Compatibility.lua +++ b/WeakAuras/Compatibility.lua @@ -115,6 +115,22 @@ RAID_CLASS_COLORS.SHAMAN.colorStr = "ff0070de" RAID_CLASS_COLORS.WARRIOR.colorStr = "ffc79c6e" 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) if value > max then return max; diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index 7f727e6..f7658bd 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -3025,6 +3025,12 @@ function WeakAuras.WatchUnitChange(unit) eventsToSend["UNIT_ROLE_CHANGED_" .. unit] = unit watchUnitChange.unitRaidRole[unit] = newRaidRole 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 local function handleUnit(unit, eventsToSend, ...) diff --git a/WeakAuras/Init.lua b/WeakAuras/Init.lua index 3a8e982..3832bf9 100644 --- a/WeakAuras/Init.lua +++ b/WeakAuras/Init.lua @@ -10,7 +10,7 @@ WeakAuras.doubleWidth = WeakAuras.normalWidth * 2 local versionStringFromToc = GetAddOnMetadata("WeakAuras", "Version") local versionString = "5.19.0 Beta" 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.buildTime = buildTime @@ -18,7 +18,7 @@ WeakAuras.newFeatureString = "|TInterface\\OptionsFrame\\UI-OptionsFrame-NewFeat WeakAuras.BuildInfo = select(4, GetBuildInfo()) function WeakAuras.isAwesomeEnabled() - return isAwesomeEnabled + return isAwesomeEnabled or false end function WeakAuras.IsCorrectVersion() diff --git a/WeakAuras/LibGroupTalentsWrapper.lua b/WeakAuras/LibGroupTalentsWrapper.lua index 073604a..400d1be 100644 --- a/WeakAuras/LibGroupTalentsWrapper.lua +++ b/WeakAuras/LibGroupTalentsWrapper.lua @@ -8,8 +8,11 @@ local unpack = unpack -- 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" } @@ -17,14 +20,14 @@ local nameToUnitMap = { local subscribers = {} Private.LibGroupTalentsWrapper = { - Register = function(callback) end, + Register = function(f) end, SpecForUnit = function(unit) end, + GetUnitRole = function(unit) end, SpecRolePositionForUnit = function(unit) end, - CheckTalentForUnit = function(unit, talentId) end, - CheckGlyphForUnit = function(unit, glyphId) end, + CheckTalentForUnit = function(unit) end, + CheckGlyphForUnit = function(unit) end, } -local LibGroupTalents = LibStub("LibGroupTalents-1.0") if LibGroupTalents then --- LibGroupTalents callback for talents and glyphs function Private.LibGroupTalentsWrapper:LibGroupTalentsCallback(_, _, unit) @@ -58,15 +61,22 @@ if LibGroupTalents then 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] + if specInfo and #specInfo > 0 then + local class = select(2, UnitClass(unit)) + if specInfo and #specInfo > 0 and class then + nameToSpecMap[unitName] = { + class .. specInfo[1], unpack(specInfo) + } + end end + nameToUnitRole[unitName] = LibGroupTalents:GetUnitRole(unit) + local glyphs = { LibGroupTalents:GetUnitGlyphs(unit) } if glyphs and #glyphs > 0 then nameToGlyphs[unitName] = {} @@ -83,6 +93,8 @@ if LibGroupTalents then end 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) table.insert(subscribers, f) @@ -97,17 +109,30 @@ if LibGroupTalents then end if UnitIsUnit(unit, "player") and class then - local specInfo = LibGroupTalents:GetUnitTalentSpec(unit) + local specInfo = { LibGroupTalents:GetUnitTalentSpec(unit) } if specInfo and #specInfo > 0 then - return class .. specInfo[1] + 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) + return unpack(data, 2) end if UnitIsUnit(unit, "player") then @@ -116,7 +141,7 @@ if LibGroupTalents then end 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 function Private.LibGroupTalentsWrapper.CheckGlyphForUnit(unit, glyphId) @@ -127,23 +152,20 @@ if LibGroupTalents then 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 -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 --- Export for GenericTrigger +-- 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 6fae78a..ec5ed26 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -1094,6 +1094,14 @@ Private.load_prototype = { 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", display = L["Raid Role"], @@ -1474,9 +1482,8 @@ Private.event_prototypes = { local unit = trigger.unit local result = {} AddUnitChangeInternalEvents(unit, result, nil, trigger.use_unitisunit and trigger.unitisunit or nil) - if trigger.use_specId then - AddUnitSpecChangeInternalEvents(unit, result) - end + AddUnitRoleChangeInternalEvents(unit, result) + AddUnitSpecChangeInternalEvents(unit, result) return result end, loadFunc = function(trigger) @@ -1587,6 +1594,18 @@ Private.event_prototypes = { store = true, 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", display = L["Raid Role"], @@ -1912,9 +1931,7 @@ Private.event_prototypes = { if includePets ~= "PetsOnly" then AddUnitRoleChangeInternalEvents(unit, result) end - if trigger.use_specId then - AddUnitSpecChangeInternalEvents(unit, result) - end + AddUnitSpecChangeInternalEvents(unit, result) return result end, loadFunc = function(trigger) @@ -2101,6 +2118,18 @@ Private.event_prototypes = { end, 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", display = L["Raid Role"], @@ -2260,9 +2289,7 @@ Private.event_prototypes = { if includePets ~= "PetsOnly" then AddUnitRoleChangeInternalEvents(unit, result) end - if trigger.use_specId then - AddUnitSpecChangeInternalEvents(unit, result) - end + AddUnitSpecChangeInternalEvents(unit, result) if trigger.use_showCost and trigger.unit == "player" then tinsert(result, "WA_UNIT_QUEUED_SPELL_CHANGED"); end @@ -2515,6 +2542,18 @@ Private.event_prototypes = { end, 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", display = L["Raid Role"], @@ -6446,6 +6485,18 @@ Private.event_prototypes = { return not trigger.use_inverse 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", display = L["Raid Role"], diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index 8eba128..cc907ce 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -2315,6 +2315,13 @@ Private.raid_role_types = { 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 = { LEADER = L["Leader"], ASSIST = L["Assist"], diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index 31264bd..f8e3bbb 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -236,7 +236,6 @@ local loadEvents = {} -- All regions keyed on id, has properties: region, regionType, also see clones Private.regions = {}; -local regions = Private.regions; -- keyed on id, contains bool indicating whether the aura is loaded Private.loaded = {}; @@ -1384,6 +1383,7 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...) local _, race = UnitRace("player") local faction = UnitFactionGroup("player") local zoneId = GetCurrentMapAreaID() + local role = WeakAuras.GetUnitRole("player") local raidRole = false; local raidID = UnitInRaid("player") if raidID then @@ -1391,7 +1391,7 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...) end local _, class = UnitClass("player"); - local inCombat = UnitAffectingCombat("player") -- or UnitAffectingCombat("pet"); + local inCombat = UnitAffectingCombat("player") local alive = not UnitIsDeadOrGhost('player') local pvp = UnitIsPVPFreeForAll("player") or UnitIsPVP("player") 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 local loadFunc = loadFuncs[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); - 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); + 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, role, raidRole, group, groupSize, raidMemberType, zone, zoneId, subzone, size, difficulty); if(shouldBeLoaded and not loaded[id]) then changed = changed + 1; @@ -2888,9 +2888,9 @@ function Private.SetRegion(data, cloneId) region = clones[id][cloneId]; end 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); - regions[id] = { + Private.regions[id] = { regionType = regionType, region = region }; @@ -2901,7 +2901,7 @@ function Private.SetRegion(data, cloneId) region.toShow = true end else - region = regions[id].region + region = Private.regions[id].region end end region.id = id; @@ -4428,7 +4428,7 @@ function Private.UpdatedTriggerState(id) state.changed = false; end end - + -- once updatedTriggerStates is complete, and empty states removed, etc., then check for queued watched triggers update Private.SendDelayedWatchedTriggers() end diff --git a/WeakAuras/WeakAuras.toc b/WeakAuras/WeakAuras.toc index 59d28bd..99121fa 100644 --- a/WeakAuras/WeakAuras.toc +++ b/WeakAuras/WeakAuras.toc @@ -32,6 +32,7 @@ DefaultOptions.lua # Core files Types.lua +LibGroupTalentsWrapper.lua Prototypes.lua Profiling.lua WeakAuras.lua @@ -43,7 +44,6 @@ Conditions.lua AnchorToWeakAuras.lua # Trigger systems -LibGroupTalentsWrapper.lua BuffTrigger2.lua GenericTrigger.lua BossMods.lua @@ -81,4 +81,4 @@ SubRegionTypes\StopMotion.lua SubRegionTypes\Texture.lua #Misc -DiscordList.lua \ No newline at end of file +DiscordList.lua diff --git a/WeakAurasOptions/BuffTrigger2.lua b/WeakAurasOptions/BuffTrigger2.lua index 02057f5..000fd06 100644 --- a/WeakAurasOptions/BuffTrigger2.lua +++ b/WeakAurasOptions/BuffTrigger2.lua @@ -745,6 +745,35 @@ local function GetBuffTriggerOptions(data, triggernum) and not trigger.useActualSpec) 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 = { type = "toggle", width = WeakAuras.normalWidth, diff --git a/WeakAurasOptions/OptionsFrames/OptionsFrame.lua b/WeakAurasOptions/OptionsFrames/OptionsFrame.lua index f60d118..65c8807 100644 --- a/WeakAurasOptions/OptionsFrames/OptionsFrame.lua +++ b/WeakAurasOptions/OptionsFrames/OptionsFrame.lua @@ -507,7 +507,7 @@ function OptionsPrivate.CreateFrame() local awesomeWotlkButton if not WeakAuras.isAwesomeEnabled() then 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:SetPoint("LEFT", changelogButton or thanksButton, "RIGHT", 10, 0) end diff --git a/WeakAurasOptions/RegionOptions/Icon.lua b/WeakAurasOptions/RegionOptions/Icon.lua index 5708a01..b523926 100644 --- a/WeakAurasOptions/RegionOptions/Icon.lua +++ b/WeakAurasOptions/RegionOptions/Icon.lua @@ -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"], hidden = function() return not data.cooldown end, }, - endHeader = { - type = "header", - order = 100, - name = "", - }, ccWarning = { type = "description", width = WeakAuras.doubleWidth, @@ -269,6 +264,11 @@ local function createOptions(id, data) order = 11.7, hidden = function() return data.cooldownTextDisabled end }, + endHeader = { + type = "header", + order = 100, + name = "", + }, }; return {