Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #4662

Merged
merged 3 commits into from
Oct 26, 2023
Merged

fix #4662

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions WeakAuras/BuffTrigger2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ local roleIcons = {
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, unaffected, role, raidMark)
local function UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, matchCount, unitCount, maxUnitCount, matchCountPerUnit, totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, role, raidMark)
local debuffClassIcon = WeakAuras.EJIcons[bestMatch.debuffClass]
if not triggerStates[cloneId] then
triggerStates[cloneId] = {
Expand Down Expand Up @@ -711,7 +711,9 @@ local function UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, mat
tooltip4 = bestMatch.tooltip4,
points = bestMatch.points,
affected = affected,
affectedUnits = affectedUnits,
unaffected = unaffected,
unaffectedUnits = unaffectedUnits,
totalStacks = totalStacks,
initialTime = time,
refreshTime = time,
Expand Down Expand Up @@ -898,11 +900,13 @@ local function UpdateStateWithMatch(time, bestMatch, triggerStates, cloneId, mat

if state.affected ~= affected then
state.affected = affected
state.affectedUnits = affectedUnits
changed = true
end

if state.unaffected ~= unaffected then
state.unaffected = unaffected
state.unaffectedUnits = unaffectedUnits
changed = true
end

Expand All @@ -923,7 +927,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, unaffected, role, 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] = {
Expand All @@ -940,7 +944,9 @@ local function UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId,
active = false,
time = time,
affected = affected,
affectedUnits = affectedUnits,
unaffected = unaffected,
unaffectedUnits = unaffectedUnits,
unit = unit,
role = role,
raidMark = raidMark,
Expand Down Expand Up @@ -1097,11 +1103,13 @@ local function UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId,

if state.affected ~= affected then
state.affected = affected
state.affectedUnits = affectedUnits
changed = true
end

if state.unaffected ~= unaffected then
state.unaffected = unaffected
state.unaffectedUnits = unaffectedUnits
changed = true
end

Expand Down Expand Up @@ -1402,19 +1410,22 @@ end
local function FormatAffectedUnaffected(triggerInfo, matchedUnits)
local affected = ""
local unaffected = ""
local affectedUnits, unaffectedUnits = {}, {}
for unit in GetAllUnits(triggerInfo.unit, nil, triggerInfo.includePets) do
if activeGroupScanFuncs[unit] and activeGroupScanFuncs[unit][triggerInfo] then
if matchedUnits[unit] then
affected = affected .. (GetUnitName(unit, false) or unit) .. ", "
tinsert(affectedUnits, unit)
else
unaffected = unaffected .. (GetUnitName(unit, false) or unit) .. ", "
tinsert(unaffectedUnits, unit)
end
end
end
unaffected = unaffected == "" and L["None"] or unaffected:sub(1, -3)
affected = affected == "" and L["None"] or affected:sub(1, -3)

return affected, unaffected
return affected, affectedUnits, unaffected, unaffectedUnits
end

local recheckTriggerInfo
Expand Down Expand Up @@ -1494,19 +1505,19 @@ local function UpdateTriggerState(time, id, triggernum)
end

if useMatch then
local affected, unaffected
local affected, unaffected, affectedUnits, unaffectedUnits
if triggerInfo.useAffected then
affected, unaffected = FormatAffectedUnaffected(triggerInfo, matchedUnits)
affected, affectedUnits, unaffected, unaffectedUnits = FormatAffectedUnaffected(triggerInfo, matchedUnits)
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, unaffected, role, 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, unaffected, role, 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)
Expand Down Expand Up @@ -1550,9 +1561,9 @@ local function UpdateTriggerState(time, id, triggernum)
if useMatches then
table.sort(auraDatas, SortMatchDataByUnitIndex)

local affected, unaffected
local affected, affectedUnits, unaffected, unaffectedUnits
if triggerInfo.useAffected then
affected, unaffected = FormatAffectedUnaffected(triggerInfo, matchedUnits)
affected, affectedUnits, unaffected, unaffectedUnits = FormatAffectedUnaffected(triggerInfo, matchedUnits)
end

local usedCloneIds = {};
Expand All @@ -1569,7 +1580,7 @@ local function UpdateTriggerState(time, id, triggernum)
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, unaffected, role, mark) or updated
matchCountPerUnit[auraData.unit], totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, role, mark) or updated
cloneIds[cloneId] = true
end

Expand All @@ -1578,7 +1589,7 @@ local function UpdateTriggerState(time, id, triggernum)
local role = roleForTriggerInfo(triggerInfo, unit)
local mark = markForTriggerInfo(triggerInfo, unit)
updated = UpdateStateWithNoMatch(time, triggerStates, triggerInfo, "", nil, 0, 0, maxUnitCount, 0, totalStacks,
affected, unaffected, role, mark) or updated
affected, affectedUnits, unaffected, unaffectedUnits, role, mark) or updated
cloneIds[""] = true
end
end
Expand Down Expand Up @@ -1617,9 +1628,9 @@ local function UpdateTriggerState(time, id, triggernum)

local cloneIds = {}
if useMatches then
local affected, unaffected
local affected, affectedUnits, unaffected, unaffectedUnits
if triggerInfo.useAffected then
affected, unaffected = FormatAffectedUnaffected(triggerInfo, matchedUnits)
affected, affectedUnits, unaffected, unaffectedUnits = FormatAffectedUnaffected(triggerInfo, matchedUnits)
end

if triggerInfo.perUnitMode == "affected" then
Expand All @@ -1628,7 +1639,7 @@ local function UpdateTriggerState(time, id, triggernum)
local role = roleForTriggerInfo(triggerInfo, unit)
local mark = markForTriggerInfo(triggerInfo, unit)
updated = UpdateStateWithMatch(time, bestMatch, triggerStates, unit, matchCount, unitCount, maxUnitCount,
matchCountPerUnit[unit], totalStacks, affected, unaffected, role, mark)
matchCountPerUnit[unit], totalStacks, affected, affectedUnits, unaffected, unaffectedUnits, role, mark)
or updated
cloneIds[unit] = true
end
Expand All @@ -1643,14 +1654,14 @@ local function UpdateTriggerState(time, id, triggernum)
if bestMatch then
if triggerInfo.perUnitMode == "all" then
updated = UpdateStateWithMatch(time, bestMatch, triggerStates, unit, matchCount, unitCount, maxUnitCount,
matchCountPerUnit[unit], totalStacks, affected, unaffected, role, 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, unaffected, role)
affected, affectedUnits, unaffected, unaffectedUnits, role)
or updated
cloneIds[unit] = true
end
Expand Down Expand Up @@ -3374,6 +3385,8 @@ function BuffTrigger.GetAdditionalProperties(data, triggernum)
if (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party") and trigger.useAffected then
ret = ret .. "|cFFFF0000%".. triggernum .. ".affected|r - " .. L["Names of affected Players"] .. "\n"
ret = ret .. "|cFFFF0000%".. triggernum .. ".unaffected|r - " .. L["Names of unaffected Players"] .. "\n"
ret = ret .. "|cFFFF0000%".. triggernum .. ".affectedUnits|r - " .. L["Units of affected Players in a table format"] .. "\n"
ret = ret .. "|cFFFF0000%".. triggernum .. ".unaffectedUnits|r - " .. L["Units of unaffected Players in a table format"] .. "\n"
end

return ret
Expand Down
17 changes: 11 additions & 6 deletions WeakAuras/Modernize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1734,13 +1734,14 @@ function Private.Modernize(data)
end
end

if data.internalVersion < 67 then
local function migrateToTable(tab, field)
local value = tab[field]
if value ~= nil and type(value) ~= "table" then
tab[field] = { value }
end
local function migrateToTable(tab, field)
local value = tab[field]
if value ~= nil and type(value) ~= "table" then
tab[field] = { value }
end
end

if data.internalVersion < 67 then
do
local trigger_migration = {
["Cast"] = {
Expand Down Expand Up @@ -1967,6 +1968,10 @@ function Private.Modernize(data)
end
end

if data.internalVersion < 69 then
migrateToTable(data.load, "itemequiped")
end

data.internalVersion = max(data.internalVersion or 0, WeakAuras.InternalVersion())
end

13 changes: 13 additions & 0 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1825,9 +1825,22 @@ Private.load_prototype = {
name = "itemequiped",
display = L["Item Equipped"],
type = "item",
multiEntry = {
operator = "or"
},
test = "IsEquippedItem(GetItemInfo(%s))",
events = { "UNIT_INVENTORY_CHANGED", "PLAYER_EQUIPMENT_CHANGED"}
},
{
name = "not_itemequiped",
display = WeakAuras.newFeatureString .. L["|cFFFF0000Not|r Item Equipped"],
type = "item",
multiEntry = {
operator = "or"
},
test = "not IsEquippedItem(GetItemInfo(%s))",
events = { "UNIT_INVENTORY_CHANGED", "PLAYER_EQUIPMENT_CHANGED"}
},
{
name = "itemtypeequipped",
display = L["Item Type Equipped"],
Expand Down
6 changes: 6 additions & 0 deletions WeakAuras/RegionTypes/Text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ local function modify(parent, region, data)

local fontPath = SharedMedia:Fetch("font", data.font);
text:SetFont(fontPath, data.fontSize, data.outline);
if not text:GetFont() and fontPath then -- workaround font not loading correctly
local objectName = "WeakAuras-Font-" .. data.font
local fontObject = _G[objectName] or CreateFont(objectName)
fontObject:SetFont(fontPath, data.fontSize, data.outline)
text:SetFontObject(fontObject)
end
if not text:GetFont() then -- Font invalid, set the font but keep the setting
text:SetFont(STANDARD_TEXT_FONT, data.fontSize, data.outline);
end
Expand Down
6 changes: 6 additions & 0 deletions WeakAuras/SubRegionTypes/SubText.lua
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ local function modify(parent, region, parentData, data, first)

local fontPath = SharedMedia:Fetch("font", data.text_font);
text:SetFont(fontPath, data.text_fontSize, data.text_fontType);
if not text:GetFont() and fontPath then -- workaround font not loading correctly
local objectName = "WeakAuras-Font-" .. data.text_font
local fontObject = _G[objectName] or CreateFont(objectName)
fontObject:SetFont(fontPath, data.text_fontSize, data.text_fontType)
text:SetFontObject(fontObject)
end
if not text:GetFont() then -- Font invalid, set the font but keep the setting
text:SetFont(STANDARD_TEXT_FONT, data.text_fontSize, data.text_fontType);
end
Expand Down
2 changes: 1 addition & 1 deletion WeakAuras/WeakAuras.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--- @type string, Private
local AddonName, Private = ...

local internalVersion = 68
local internalVersion = 69

-- Lua APIs
local insert = table.insert
Expand Down
2 changes: 1 addition & 1 deletion WeakAurasOptions/BuffTrigger2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ local function GetBuffTriggerOptions(data, triggernum)
},
useAffected = {
type = "toggle",
name = L["Fetch Affected/Unaffected Names"],
name = L["Fetch Affected/Unaffected Names and Units"],
width = WeakAuras.doubleWidth,
order = 65.1,
hidden = function() return not (trigger.type == "aura2" and (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party")) end
Expand Down