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 3 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
63 changes: 63 additions & 0 deletions WeakAuras/Modernize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,69 @@ function Private.Modernize(data)

end

-- Version 72 moves instance filters from a conditions trigger to a player location trigger
if data.internalVersion < 72 then
local new_triggers = {}
local delete_triggers = {}
local condition_filters = {
"alwaystrue",
"incombat",
"pvpflagged",
"alive",
"vehicle",
"resting",
"mounted",
"HasPet",
"ismoving",
"afk",
"ingroup",
}

for i, triggerData in ipairs(data.triggers) do
local t = triggerData.trigger
local canRemoveTrigger = true

-- Check for a Conditions trigger with instance filters
if t.event == "Conditions" and (
t.use_instance_size
or t.use_instance_difficulty
or t.use_instance_type
) then -- Create a new trigger object
local new = CopyTable(triggerData)
new.trigger.event = "Player Location"
new.trigger.use_instanceDifficulty = new.trigger.use_instance_difficulty
new.trigger.use_instance_difficulty = nil
new.trigger.instanceDifficulty = new.trigger.instance_difficulty
new.trigger.instance_difficulty = nil

-- Remove any condition filters from the new trigger
for _, name in ipairs(condition_filters) do
if t["use_"..name] ~= nil then
canRemoveTrigger = false
end
new.trigger[name] = nil
new.trigger["use_"..name] = nil
end
tinsert(new_triggers, new)
end

-- the remaining conditions trigger has no active filters and the trigger can be removed
if canRemoveTrigger then
delete_triggers[i] = true
end
end

-- Remove triggers
for i in pairs(delete_triggers) do
data.triggers[i] = nil
end

-- Add triggers
for _,triggerData in ipairs(new_triggers) do
tinsert(data.triggers, triggerData)
end
end
InfusOnWoW marked this conversation as resolved.
Show resolved Hide resolved

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

204 changes: 164 additions & 40 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,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 @@ -1769,7 +1769,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 @@ -9921,13 +9921,6 @@ Private.event_prototypes = {
tinsert(events, "GROUP_ROSTER_UPDATE")
end

if trigger.use_instance_difficulty ~= nil
or trigger.use_instance_type ~= nil
or trigger.use_instance_size ~= nil
then
tinsert(events, "PLAYER_DIFFICULTY_CHANGED")
end

return {
["events"] = events,
["unit_events"] = {
Expand All @@ -9943,11 +9936,7 @@ Private.event_prototypes = {
tinsert(events, "PLAYER_MOVING_UPDATE");
end

if trigger.use_instance_difficulty ~= nil
or trigger.use_instance_type ~= nil
or trigger.use_instance_size ~= nil
or trigger.use_pvpflagged ~= nil
then
if trigger.use_pvpflagged ~= nil then
tinsert(events, "WA_DELAYED_PLAYER_ENTERING_WORLD")
end

Expand Down Expand Up @@ -10037,32 +10026,6 @@ Private.event_prototypes = {
values = "group_types",
init = "Private.ExecEnv.GroupType()",
},
{
name = "instance_size",
display = L["Instance Size Type"],
type = "multiselect",
values = "instance_types",
sorted = true,
init = "WeakAuras.InstanceType()",
},
{
name = "instance_difficulty",
display = L["Instance Difficulty"],
type = "multiselect",
values = "difficulty_types",
init = "WeakAuras.InstanceDifficulty()",
enable = WeakAuras.IsRetail(),
hidden = not WeakAuras.IsRetail(),
},
{
name = "instance_type",
display = L["Instance Type"],
type = "multiselect",
values = "instance_difficulty_types",
init = "WeakAuras.InstanceTypeRaw()",
enable = WeakAuras.IsRetail(),
hidden = not WeakAuras.IsRetail(),
},
},
automaticrequired = true,
progressType = "none"
Expand Down Expand Up @@ -10571,6 +10534,167 @@ Private.event_prototypes = {
end,
automaticrequired = true
},
["Player 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 = L["Player 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 = 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 = "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.mapType",
values = "map_types",
store = true,
},
{
name = "indoors",
display = L["Indoors"],
type = "toggle",
conditionType = "boolean",
init = "isIndoors",
},
{
name = "instanceTitle",
display = L["Instance Filters"],
type = "description",
},
{
name = "instance",
display = L["Instance Name"],
test = "true",
hidden = "true",
store = true,
},
{
name = "instance_size",
display = L["Instance Size Type"],
type = "multiselect",
values = "instance_types",
sorted = true,
init = "WeakAuras.InstanceType()",
},
{
name = "instanceDifficulty",
display = L["Instance Difficulty"],
type = "multiselect",
values = "difficulty_types",
init = "WeakAuras.InstanceDifficulty()",
store = true,
enable = WeakAuras.IsRetail(),
hidden = not WeakAuras.IsRetail(),
},
{
name = "instance_type",
display = L["Instance Type"],
type = "multiselect",
values = "instance_difficulty_types",
init = "WeakAuras.InstanceTypeRaw()",
enable = WeakAuras.IsRetail(),
hidden = not WeakAuras.IsRetail(),
},
},
automaticrequired = true,
progressType = "none"
},
};

if WeakAuras.IsClassicEraOrWrath() then
Expand Down
10 changes: 10 additions & 0 deletions WeakAuras/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2874,6 +2874,16 @@ do
end
end

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"],
}

---@class Private
---@field TocToExpansion table<number, string>
Private.TocToExpansion = {
Expand Down
16 changes: 10 additions & 6 deletions 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 = 71
local internalVersion = 72

-- Lua APIs
local insert = table.insert
Expand Down Expand Up @@ -6096,7 +6096,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 @@ -6111,9 +6111,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 @@ -6127,7 +6130,8 @@ function Private.ExecEnv.ParseZoneCheck(input)
zoneIds = {},
zoneGroupIds = {},
instanceIds = {},
areaNames = {}
areaNames = {},
isChildFilter = false
}

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