Skip to content

Commit

Permalink
add Location trigger (#4917)
Browse files Browse the repository at this point in the history
Fixes: #4759
  • Loading branch information
Boneshockx authored Apr 21, 2024
1 parent 847eef2 commit 35d725c
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 22 deletions.
1 change: 0 additions & 1 deletion WeakAuras/GenericTrigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,6 @@ 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
Expand Down
156 changes: 148 additions & 8 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ end

local constants = {
nameRealmFilterDesc = L[" Filter formats: 'Name', 'Name-Realm', '-Realm'. \n\nSupports multiple entries, separated by commas\nCan use \\ to escape -."],
instanceFilterDeprecated = L["This filter has been moved to the Location trigger. Change your aura to use the new Location trigger or join the WeakAuras Discord server for help."],
}

if WeakAuras.IsClassicEraOrWrathOrCata() then
Expand Down Expand Up @@ -203,7 +204,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 @@ -10113,7 +10114,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 @@ -10137,9 +10137,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 @@ -10232,15 +10232,17 @@ Private.event_prototypes = {
},
{
name = "instance_size",
display = L["Instance Size Type"],
display = L["Instance Size Type"].." "..L["|cffff0000deprecated|r"],
desc = constants.instanceFilterDeprecated,
type = "multiselect",
values = "instance_types",
sorted = true,
init = "WeakAuras.InstanceType()",
},
{
name = "instance_difficulty",
display = L["Instance Difficulty"],
display = L["Instance Difficulty"].." "..L["|cffff0000deprecated|r"],
desc = constants.instanceFilterDeprecated,
type = "multiselect",
values = "difficulty_types",
init = "WeakAuras.InstanceDifficulty()",
Expand All @@ -10249,7 +10251,8 @@ Private.event_prototypes = {
},
{
name = "instance_type",
display = L["Instance Type"],
display = L["Instance Type"].." "..L["|cffff0000deprecated|r"],
desc = constants.instanceFilterDeprecated,
type = "multiselect",
values = "instance_difficulty_types",
init = "WeakAuras.InstanceTypeRaw()",
Expand Down Expand Up @@ -10764,6 +10767,143 @@ Private.event_prototypes = {
end,
automaticrequired = true
},
["Location"] = {
type = "unit",
events = {
["events"] = {
"ZONE_CHANGED",
"ZONE_CHANGED_INDOORS",
"ZONE_CHANGED_NEW_AREA",
"PLAYER_DIFFICULTY_CHANGED",
}
},
internal_events = {"INSTANCE_LOCATION_CHECK"},
force_events = "INSTANCE_LOCATION_CHECK",
name = WeakAuras.newFeatureString..L["Location"],
init = function(trigger)
local ret = [=[
local uiMapId = C_Map.GetBestMapForUnit("player")
local zonegroupId = uiMapId and C_Map.GetMapGroupID(uiMapId)
local instanceName, _, _, _, _, _, _, instanceId = GetInstanceInfo()
local minimapZoneText = GetMinimapZoneText()
local zoneText = GetZoneText()
]=]
return ret
end,
statesParameter = "one",
args = {
{
name = "zoneIds",
display = L["Player Location ID(s)"],
type = "string",
multiline = true,
desc = get_zoneId_list,
preamble = "local zoneChecker = Private.ExecEnv.ParseZoneCheck(%q)",
test = "zoneChecker:Check(uiMapId, zonegroupId, instanceId, minimapZoneText)",
conditionType = "string",
conditionPreamble = function(input)
return Private.ExecEnv.ParseZoneCheck(input)
end,
conditionTest = function(state, needle, op, preamble)
return preamble:Check(state.zoneId, state.zonegroupId, state.instanceId, state.subzone)
end,
operator_types = "none",
},
{
name = "zoneId",
display = L["Zone ID"],
init = "uiMapId",
store = true,
hidden = true,
test = "true",
},
{
name = "zonegroupId",
display = L["Zone Group ID"],
init = "zonegroupId",
store = true,
hidden = true,
test = "true",
},
{
name = "zone",
display = L["Zone Name"],
type = "string",
conditionType = "string",
store = true,
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 = "instanceTitle",
display = L["Instance Filters"],
type = "description",
},
{
name = "instanceId",
display = L["Instance ID"],
init = "instanceId",
store = true,
hidden = true,
test = "true",
},
{
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
31 changes: 19 additions & 12 deletions WeakAuras/WeakAuras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6138,11 +6138,16 @@ function Private.ExecEnv.ParseZoneCheck(input)
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
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
local areaName = C_Map.GetAreaInfo(id)
if areaName then
self.areaNames[areaName] = true
end
elseif prevChar == 'i' or prevChar == 'I' then
self.instanceIds[id] = true
else
Expand All @@ -6153,19 +6158,21 @@ function Private.ExecEnv.ParseZoneCheck(input)
zoneIds = {},
zoneGroupIds = {},
instanceIds = {},
areaNames = {}
areaNames = {},
}

local start = input:find('%d', 1)
local last = input:find('%D', start)
while (last) do
matcher:AddId(input, start, last - 1)
start = input:find('%d', last + 1)
last = input:find('%D', start)
end
if start then
local last = input:find('%D', start)
while (last) do
matcher:AddId(input, start, last - 1)
start = input:find('%d', last + 1) or #input + 1
last = input:find('%D', start)
end

last = #input
matcher:AddId(input, start, last)
last = #input
matcher:AddId(input, start, last)
end
return matcher
end

Expand Down
2 changes: 1 addition & 1 deletion WeakAurasOptions/LoadOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function OptionsPrivate.ConstructOptions(prototype, data, startorder, triggernum
width = WeakAuras.normalWidth,
name = arg.display,
desc = function()
if arg.multiNoSingle then return arg.desc end
if arg.multiNoSingle or arg.desc then return arg.desc end
local v = trigger["use_"..realname];
if(v == true) then
return L["Multiselect single tooltip"];
Expand Down

0 comments on commit 35d725c

Please sign in to comment.