Add support for nameplate units (#1)

This commit is contained in:
Andrew Scott
2021-02-27 19:21:15 -08:00
committed by GitHub
parent bd42fc6339
commit 7fb0ee06da
2 changed files with 25 additions and 2 deletions

View File

@ -108,6 +108,10 @@ setmetatable(UnitToLocale, {__index=function(self, unit)
local num = unit:match("^boss(%d)$")
self[unit] = L["Boss #%d"]:format(num)
return self[unit]
elseif unit:find("^nameplate%d$") then
local num = unit:match("^nameplate(%d)$")
self[unit] = L["Nameplate #%d"]:format(num)
return self[unit]
elseif unit:find("^partypet%d$") then
local num = unit:match("^partypet(%d)$")
self[unit] = UnitToLocale["party" .. num .. "pet"]
@ -137,7 +141,7 @@ DogTag.IsLegitimateUnit = IsLegitimateUnit
local IsNormalUnit = { player = true, target = true, focus = true, pet = true, playerpet = true, mouseover = true }
local WACKY_UNITS = { targettarget = true, playertargettarget = true, targettargettarget = true, playertargettargettarget = true, pettarget = true, playerpettarget = true, pettargettarget = true, playerpettargettarget = true }
DogTag.IsNormalUnit = IsNormalUnit
for i = 1, 4 do
for i = 1, MAX_PARTY_MEMBERS do
IsLegitimateUnit["party" .. i] = true
IsLegitimateUnit["partypet" .. i] = true
IsLegitimateUnit["party" .. i .. "pet"] = true
@ -151,7 +155,7 @@ for i = 1, 4 do
WACKY_UNITS["partypet" .. i .. "targettarget"] = true
WACKY_UNITS["party" .. i .. "pettargettarget"] = true
end
for i = 1, 40 do
for i = 1, MAX_RAID_MEMBERS do
IsLegitimateUnit["raid" .. i] = true
IsNormalUnit["raid" .. i] = true
IsLegitimateUnit["raidpet" .. i] = true
@ -162,6 +166,14 @@ for i = 1, 40 do
WACKY_UNITS["raidpet" .. i .. "target"] = true
WACKY_UNITS["raid" .. i .. "pettarget"] = true
end
for i = 1, 40 do
-- There is no const for max nameplate units,
-- but it currently appears to be 40 based on in-game testing
-- (i.e. "pull everything in stockades")
-- (at some point in the past it used to be 30).
IsLegitimateUnit["nameplate" .. i] = true
IsNormalUnit["nameplate" .. i] = true
end
for i = 1, MAX_BOSS_FRAMES do
IsLegitimateUnit["boss" .. i] = true
IsNormalUnit["boss" .. i] = true
@ -463,6 +475,16 @@ DogTag:AddEventHandler("Unit", "UNIT_TARGETABLE_CHANGED", function(event, unit)
DogTag:FireEvent("UnitChanged", unit)
end)
DogTag:AddEventHandler("Unit", "NAME_PLATE_UNIT_ADDED", function(event, unit)
refreshGUID(unit)
DogTag:FireEvent("UnitChanged", unit)
end)
DogTag:AddEventHandler("Unit", "NAME_PLATE_UNIT_REMOVED", function(event, unit)
refreshGUID(unit)
DogTag:FireEvent("UnitChanged", unit)
end)
DogTag:AddEventHandler("Unit", "UNIT_PET", function(event, unit)
if unit == "player" then unit = "" end
local unit_pet = unit .. "pet"