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

add Location trigger #4917

Merged
merged 25 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
93458f6
add Player Location trigger
jjholleman Mar 18, 2024
404b4bc
that should've been a string
jjholleman Mar 18, 2024
5f9ec6b
minor tweaks
jjholleman Mar 18, 2024
5130556
Merge branch 'main' into feature/location
jjholleman Mar 21, 2024
1502768
Only copy instance filters, don't delete them, instead show AuraWarni…
jjholleman Mar 21, 2024
805874d
Merge branch 'main' into feature/location
jjholleman Apr 4, 2024
80a7917
rename to "Location" trigger
jjholleman Apr 4, 2024
fb77aa2
remove migration
jjholleman Apr 4, 2024
9e61634
small tweaks and fix bugs
jjholleman Apr 4, 2024
f1bfeb1
Merge branch 'main' into feature/location
jjholleman Apr 4, 2024
d52086a
Merge branch 'main' into feature/location
jjholleman Apr 7, 2024
32897ab
always listen for events that are required by stored values
jjholleman Apr 7, 2024
3a369f7
bugfix: start = 1 if no match is found
jjholleman Apr 7, 2024
528f129
remove the optional recursive check: child filters are always recursive
jjholleman Apr 7, 2024
1ec1d90
overwrite multiselect desc if arg.desc is set
jjholleman Apr 7, 2024
fd53b76
remove instance filter aurawarning, instead show a guiding description
jjholleman Apr 7, 2024
4683051
remove mapType filter
jjholleman Apr 7, 2024
dabfbd8
make player location ID available as a condition
jjholleman Apr 7, 2024
208b591
remove conditionType since we can use Player Location Id. noProgressS…
jjholleman Apr 7, 2024
2f9684e
smoll 🪲-fix
jjholleman Apr 8, 2024
e1ab9a1
Merge branch 'main' into feature/location
jjholleman Apr 13, 2024
1026f5f
WA_DPEW and VEHICLE_UPDATE are not required
jjholleman Apr 13, 2024
cf6fe85
Tweak
InfusOnWoW Apr 16, 2024
c8ec339
Merge branch 'main' into feature/location
jjholleman Apr 19, 2024
9d3b412
Remove indoors option
jjholleman Apr 19, 2024
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
25 changes: 24 additions & 1 deletion WeakAuras/GenericTrigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,7 @@ function GenericTrigger.Add(data, region)
watched_trigger_events[id] = nil

local warnAboutCLEUEvents = false
local warnAboutDeprecatedInstanceFilters = false

for triggernum, triggerData in ipairs(data.triggers) do
local trigger, untrigger = triggerData.trigger, triggerData.untrigger
Expand Down Expand Up @@ -1611,10 +1612,17 @@ function GenericTrigger.Add(data, region)
force_events = force_events(trigger, untrigger)
end


if prototype.includePets then
includePets = trigger.use_includePets == true and trigger.includePets or nil
end

if trigger.event == "Conditions" and (
trigger.use_instance_size ~= nil
or trigger.use_instance_difficulty ~= nil
or trigger.use_instance_type ~= nil
) then
warnAboutDeprecatedInstanceFilters = true
end
end
end
else -- CUSTOM
Expand Down Expand Up @@ -1781,6 +1789,21 @@ function GenericTrigger.Add(data, region)
else
Private.AuraWarnings.UpdateWarning(data.uid, "spammy_event_warning")
end

if warnAboutDeprecatedInstanceFilters then
Private.AuraWarnings.UpdateWarning(data.uid, "deprecated_instance_filter", "warning",
InfusOnWoW marked this conversation as resolved.
Show resolved Hide resolved
string.format("%s\n|cffff0000%s\n%s\n%s|r\n\n%s\n%s",
L["This aura contains a |cffff0000Conditions trigger|r with one of the following deprecated filters:"],
L["Instance Size Type"],
L["Instance Difficulty"],
L["Instance Type"],
L["These instance filters have been migrated to a Location trigger and will be removed from the Condition trigger in a future update."],
L["Change your aura to use the new Location trigger or join the WeakAuras Discord server for help."]
)
)
else
Private.AuraWarnings.UpdateWarning(data.uid, "deprecated_instance_filter")
end
end

do
Expand Down
194 changes: 185 additions & 9 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ local function get_zoneId_list()
L["Parent Zone"], parentmap_name, currentmap_info.parentMapID)
end

return ("%s|cffffd200%s|r\n%s: %d\n\n%s%s|cffffd200%s|r\n%s: %d\n\n%s"):format(
return ("%s|cffffd200%s|r\n%s: %d\n\n%s%s|cffffd200%s|r\n%s: i%d\n\n%s"):format(
Private.get_zoneId_list(),
L["Current Zone"],
currentmap_name,
Expand Down Expand Up @@ -1772,7 +1772,7 @@ Private.load_prototype = {
multiline = true,
events = {"ZONE_CHANGED", "ZONE_CHANGED_INDOORS", "ZONE_CHANGED_NEW_AREA", "VEHICLE_UPDATE"},
desc = get_zoneId_list,
preamble = "local zoneChecker = Private.ExecEnv.ParseZoneCheck(%q)",
preamble = "local zoneChecker = Private.ExecEnv.ParseZoneCheck(%q, true)",
test = "zoneChecker:Check(zoneId, zonegroupId, instanceId, minimapZoneText)",
optional = true,
},
Expand Down Expand Up @@ -10051,7 +10051,6 @@ Private.event_prototypes = {
if trigger.use_ingroup ~= nil then
tinsert(events, "GROUP_ROSTER_UPDATE")
end

if trigger.use_instance_difficulty ~= nil
or trigger.use_instance_type ~= nil
or trigger.use_instance_size ~= nil
Expand All @@ -10075,9 +10074,9 @@ Private.event_prototypes = {
end

if trigger.use_instance_difficulty ~= nil
or trigger.use_instance_type ~= nil
or trigger.use_instance_size ~= nil
or trigger.use_pvpflagged ~= nil
or trigger.use_instance_type ~= nil
or trigger.use_instance_size ~= nil
or trigger.use_pvpflagged ~= nil
then
tinsert(events, "WA_DELAYED_PLAYER_ENTERING_WORLD")
end
Expand Down Expand Up @@ -10170,15 +10169,15 @@ Private.event_prototypes = {
},
{
name = "instance_size",
display = L["Instance Size Type"],
display = L["Instance Size Type"].." "..L["|cffff0000deprecated|r"],
InfusOnWoW marked this conversation as resolved.
Show resolved Hide resolved
type = "multiselect",
values = "instance_types",
sorted = true,
init = "WeakAuras.InstanceType()",
},
{
name = "instance_difficulty",
display = L["Instance Difficulty"],
display = L["Instance Difficulty"].." "..L["|cffff0000deprecated|r"],
type = "multiselect",
values = "difficulty_types",
init = "WeakAuras.InstanceDifficulty()",
Expand All @@ -10187,7 +10186,7 @@ Private.event_prototypes = {
},
{
name = "instance_type",
display = L["Instance Type"],
display = L["Instance Type"].." "..L["|cffff0000deprecated|r"],
type = "multiselect",
values = "instance_difficulty_types",
init = "WeakAuras.InstanceTypeRaw()",
Expand Down Expand Up @@ -10702,6 +10701,183 @@ Private.event_prototypes = {
end,
automaticrequired = true
},
["Location"] = {
type = "unit",
events = function(trigger, untrigger)
local events = {}
if trigger.use_zoneIds ~= nil
or trigger.use_zone ~= nil
or trigger.use_subzone ~= nil
or trigger.use_mapType ~= nil
then
tinsert(events, "ZONE_CHANGED")
tinsert(events, "ZONE_CHANGED_INDOORS")
tinsert(events, "ZONE_CHANGED_NEW_AREA")
tinsert(events, "VEHICLE_UPDATE")
end
if trigger.use_indoors ~= nil then
tinsert(events, "MINIMAP_UPDATE_ZOOM")
tinsert(events, "ZONE_CHANGED_INDOORS")
end
if trigger.use_instanceDifficulty ~= nil
or trigger.use_instance_type ~= nil
or trigger.use_instance_size ~= nil
then
tinsert(events, "PLAYER_DIFFICULTY_CHANGED")
end
return {
["events"] = events,
}
end,
internal_events = function(trigger, untrigger)
local events = {"INSTANCE_LOCATION_CHECK"};
if trigger.use_instance_difficulty ~= nil
or trigger.use_instance_type ~= nil
or trigger.use_instance_size ~= nil
then
InfusOnWoW marked this conversation as resolved.
Show resolved Hide resolved
tinsert(events, "WA_DELAYED_PLAYER_ENTERING_WORLD")
end
return events;
end,
force_events = "INSTANCE_LOCATION_CHECK",
name = WeakAuras.newFeatureString..L["Location"],
init = function(trigger)
local ret = [=[
local recursive = %s
local zoneChecker = Private.ExecEnv.ParseZoneCheck(%q, recursive)
InfusOnWoW marked this conversation as resolved.
Show resolved Hide resolved

local uiMapId = C_Map.GetBestMapForUnit("player")
local zonegroupId = uiMapId and C_Map.GetMapGroupID(uiMapId)
local instanceName, _, _, _, _, _, _, instanceId = GetInstanceInfo()
local minimapZoneText = GetMinimapZoneText()

local zoneText = GetZoneText()
local mapInfo = uiMapId and C_Map.GetMapInfo(uiMapId)
local isIndoors = IsIndoors()
]=]
return ret:format(trigger.use_recursive and "true" or "nil", trigger.zoneIds or 0)
end,
statesParameter = "one",
args = {
{
name = "zoneIds",
display = L["Player Location ID(s)"],
type = "string",
multiline = true,
desc = get_zoneId_list,
test = "zoneChecker:Check(uiMapId, zonegroupId, instanceId, minimapZoneText)",
},
{
name = "recursive",
display = L["Recursive"],
desc = L["Enable this to recurse on each child map until it finds a match. Disable this to only include direct descendants."],
type = "toggle",
test = "true",
enable = function(trigger)
if trigger.use_zoneIds then
local zoneChecker = Private.ExecEnv.ParseZoneCheck(trigger.zoneIds)
return zoneChecker and zoneChecker.isChildFilter
end
end,
},
{
name = "zoneId",
display = L["Zone ID"],
conditionType = "number",
init = "uiMapId",
store = true,
hidden = true,
test = "true",
noProgressSource = true,
},
{
name = "zone",
display = L["Zone Name"],
type = "string",
conditionType = "string",
store = true,
InfusOnWoW marked this conversation as resolved.
Show resolved Hide resolved
init = "zoneText",
multiEntry = {
operator = "or",
}
},
{
name = "subzone",
display = L["Subzone Name"],
desc = L["Name of the (sub-)zone currently shown above the minimap."],
type = "string",
conditionType = "string",
store = true,
init = "minimapZoneText",
multiEntry = {
operator = "or",
},
},
{
name = "mapType",
display = L["Map Type"],
InfusOnWoW marked this conversation as resolved.
Show resolved Hide resolved
type = "select",
conditionType = "select",
init = "mapInfo and mapInfo.mapType",
values = "map_types",
store = true,
},
{
name = "indoors",
display = L["Indoors"],
type = "tristate",
conditionType = "bool",
init = "isIndoors",
store = true,
},
{
name = "instanceTitle",
display = L["Instance Filters"],
type = "description",
},
{
name = "instance",
display = L["Instance Name"],
test = "true",
hidden = "true",
store = true,
},
{
name = "instanceSize",
display = L["Instance Size Type"],
type = "multiselect",
values = "instance_types",
sorted = true,
init = "WeakAuras.InstanceType()",
conditionType = "select",
store = true,
},
{
name = "instanceDifficulty",
display = L["Instance Difficulty"],
type = "multiselect",
values = "difficulty_types",
init = "WeakAuras.InstanceDifficulty()",
conditionType = "select",
store = true,
enable = WeakAuras.IsRetail(),
hidden = not WeakAuras.IsRetail(),
},
{
name = "instanceType",
display = L["Instance Type"],
type = "multiselect",
values = "instance_difficulty_types",
init = "WeakAuras.InstanceTypeRaw()",
conditionType = "select",
store = true,
enable = WeakAuras.IsRetail(),
hidden = not WeakAuras.IsRetail(),
},
},
automaticrequired = true,
progressType = "none"
},
};

if WeakAuras.IsClassicEraOrWrathOrCata() then
Expand Down
11 changes: 11 additions & 0 deletions WeakAuras/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2775,6 +2775,17 @@ if WeakAuras.IsRetail() then
end
end

---@type table<number, string>
Private.map_types = {
[Enum.UIMapType.Cosmic] = L["Cosmic"],
[Enum.UIMapType.World] = L["World"],
[Enum.UIMapType.Continent] = L["Continent"],
[Enum.UIMapType.Zone] = L["Zone"],
[Enum.UIMapType.Dungeon] = L["Dungeon"],
[Enum.UIMapType.Micro] = L["Micro"],
[Enum.UIMapType.Orphan] = L["Orphan"],
}

---@type table<number, string>
Private.TocToExpansion = {
[1] = L["Classic"],
Expand Down
14 changes: 9 additions & 5 deletions WeakAuras/WeakAuras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6072,7 +6072,7 @@ function Private.ExecEnv.ParseNameCheck(name)
return matches
end

function Private.ExecEnv.ParseZoneCheck(input)
function Private.ExecEnv.ParseZoneCheck(input, recursive)
if not input then return end

local matcher = {
Expand All @@ -6087,9 +6087,12 @@ function Private.ExecEnv.ParseZoneCheck(input)
self.zoneGroupIds[id] = true
elseif prevChar == 'c' or prevChar == 'C' then
self.zoneIds[id] = true
local info = C_Map.GetMapChildrenInfo(id, nil, true)
for _,childInfo in pairs(info) do
self.zoneIds[childInfo.mapID] = true
self.isChildFilter = true
local info = C_Map.GetMapChildrenInfo(id, nil, recursive)
if info then
for _,childInfo in pairs(info) do
self.zoneIds[childInfo.mapID] = true
end
end
elseif prevChar == 'a' or prevChar == 'A' then
self.areaNames[C_Map.GetAreaInfo(id)] = true
Expand All @@ -6103,7 +6106,8 @@ function Private.ExecEnv.ParseZoneCheck(input)
zoneIds = {},
zoneGroupIds = {},
instanceIds = {},
areaNames = {}
areaNames = {},
isChildFilter = false
}

local start = input:find('%d', 1)
Expand Down