Updates for TBC classic. Switched as many versions checks as I could to feature detection rather than hardcoded version number checks.

This commit is contained in:
Andrew Scott
2021-04-24 12:08:40 -07:00
parent 3f2505245c
commit f845e20c05
11 changed files with 72 additions and 87 deletions

View File

@ -42,4 +42,9 @@ jobs:
- name: Package and release for Classic
uses: BigWigsMods/packager@master
with:
args: -g 1.13.6 -w 0
args: -g classic -w 0
- name: Package and release for TBC
uses: BigWigsMods/packager@master
with:
args: -g bc -w 0

View File

@ -18,7 +18,6 @@ local newList, del = DogTag.newList, DogTag.del
local currentAuras, currentDebuffTypes, currentAuraTimes, currentNumDebuffs
local wow_700 = select(4, GetBuildInfo()) >= 70000
local wow_800 = select(4, GetBuildInfo()) >= 80000
local mt = {__index=function(self, unit)
@ -404,8 +403,8 @@ DogTag:AddTag("Unit", "AuraDuration", {
category = L["Auras"],
})
local SHADOWFORM = GetSpellInfo(15473)
if not wow_700 then
local SHADOWFORM = GetSpellInfo(15473) or GetSpellInfo(232698)
if SHADOWFORM then
DogTag:AddTag("Unit", "IsShadowform", {
alias = ("HasAura(aura=%q, unit=unit)"):format(SHADOWFORM),
arg = {
@ -418,7 +417,11 @@ DogTag:AddTag("Unit", "IsShadowform", {
end
local STEALTH = GetSpellInfo(1784)
local SHADOWMELD = GetSpellInfo(58984) or GetSpellInfo(743) -- 58984 is the ID in BFA, 743 is the ID in Classic.
local SHADOWMELD =
GetSpellInfo(58984) -- BFA
or GetSpellInfo(20580) -- Classic TBC
or GetSpellInfo(743) -- Classic Vanilla
local PROWL = GetSpellInfo(5215)
DogTag:AddTag("Unit", "IsStealthed", {
alias = ("HasAura(aura=%q, unit=unit) or HasAura(aura=%q, unit=unit) or HasAura(aura=%q, unit=unit)"):format(STEALTH, SHADOWMELD, PROWL),

View File

@ -20,8 +20,7 @@ local UnitGUID = UnitGUID
local IsNormalUnit = DogTag_Unit.IsNormalUnit
local wow_ver = select(4, GetBuildInfo())
local wow_classic = WOW_PROJECT_ID and WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local wow_800 = wow_ver >= 80000
local cast_api_has_ranks = wow_ver < 80000 and WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
local playerGuid = nil
DogTag:AddEventHandler("Unit", "PLAYER_LOGIN", function()
@ -47,14 +46,7 @@ DogTag:AddEventHandler("Unit", "EventRequested", function(_, event)
local spell, rank, displayName, icon, startTime, endTime
local channeling = false
if wow_800 then
spell, displayName, icon, startTime, endTime = UnitCastingInfo(unit)
rank = nil
if not spell then
spell, displayName, icon, startTime, endTime = UnitChannelInfo(unit)
channeling = true
end
elseif wow_classic then
if CastingInfo then
-- Classic only has an API for player spellcasts. No API for arbitrary units.
if unit == "player" then
spell, displayName, icon, startTime, endTime = CastingInfo()
@ -64,12 +56,19 @@ DogTag:AddEventHandler("Unit", "EventRequested", function(_, event)
channeling = true
end
end
else
elseif cast_api_has_ranks then
spell, rank, displayName, icon, startTime, endTime = UnitCastingInfo(unit)
if not spell then
spell, rank, displayName, icon, startTime, endTime = UnitChannelInfo(unit)
channeling = true
end
else
spell, displayName, icon, startTime, endTime = UnitCastingInfo(unit)
rank = nil
if not spell then
spell, displayName, icon, startTime, endTime = UnitChannelInfo(unit)
channeling = true
end
end
if spell then
@ -196,7 +195,7 @@ DogTag:AddEventHandler("Unit", "EventRequested", function(_, event)
-- The purpose of this event is to predict the next spell target.
-- This seems to be removed in at least wow_800
if unit == "player" and not wow_800 then
if unit == "player" and cast_api_has_ranks then
nextSpell = spell
nextRank = rank and tonumber(rank:match("%d+"))
nextTarget = target ~= "" and target or nil

View File

@ -17,17 +17,12 @@ DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
local L = DogTag_Unit.L
-- Pre 3.2.0 compatability support
local wow_320 = select(4, GetBuildInfo()) >= 30200
local wow_700 = select(4, GetBuildInfo()) >= 70000
local wow_800 = select(4, GetBuildInfo()) >= 80000
local wow_classic = WOW_PROJECT_ID and WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local GetQuestDifficultyColor
if not wow_320 and not wow_classic then
GetQuestDifficultyColor = _G.GetDifficultyColor
else
GetQuestDifficultyColor = _G.GetQuestDifficultyColor
end
local wow_build = select(4, GetBuildInfo())
local wow_800 = wow_build >= 80000
-- The mere presence of WOW_PROJECT_ID tells us how "modern" the client is.
local WOW_PROJECT_ID = _G.WOW_PROJECT_ID
local GetQuestDifficultyColor = GetQuestDifficultyColor or GetDifficultyColor
DogTag:AddTag("Unit", "IsFriend", {
code = function(unit)
@ -186,7 +181,7 @@ local function Class(unit)
if UnitIsPlayer(unit) then
return UnitClass(unit) or UNKNOWN
else
if wow_800 then
if wow_800 or WOW_PROJECT_ID then
local classbase, classindex = UnitClassBase(unit)
return classbase and GetClassInfo(classindex) or UNKNOWN
else
@ -552,7 +547,11 @@ DogTag:AddTag("Unit", "HostileColor", {
-- either enemy or friend, no violence
r, g, b = unpack(DogTag.__colors.civilian)
end
elseif (not wow_700 and not wow_classic and UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) or ((wow_700 or wow_classic) and UnitIsTapDenied(unit)) or UnitIsDead(unit) then
elseif
(UnitIsTapDenied and UnitIsTapDenied(unit)) or
(UnitIsTapped and UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) or
UnitIsDead(unit)
then
r, g, b = unpack(DogTag.__colors.tapped)
else
local reaction = UnitReaction(unit, "player")

View File

@ -9,8 +9,6 @@ local _G, unpack = _G, unpack
local UnitHealth, UnitHealthMax, UnitIsGhost, UnitGetTotalAbsorbs =
UnitHealth, UnitHealthMax, UnitIsGhost, UnitGetTotalAbsorbs
-- Support for new UnitGetTotalAbsorbs functionality
local wow_502 = select(4, GetBuildInfo()) >= 50200
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
@ -94,7 +92,7 @@ DogTag:AddTag("Unit", "IsMaxHP", {
category = L["Health"]
})
if wow_502 then
if UnitGetTotalAbsorbs then
DogTag:AddTag("Unit", "TotalAbsorb", {
code = UnitGetTotalAbsorbs,
arg = {

View File

@ -13,19 +13,18 @@ DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
local L = DogTag_Unit.L
local wow_ver = select(4, GetBuildInfo())
local wow_600 = wow_ver >= 60000
local wow_700 = wow_ver >= 70000
DogTag:AddTag("Unit", "Combos", {
code = function (unit, target)
if unit and target then
if wow_600 then
if not GetComboPoints then
return UnitPower(unit, 4)
else
return GetComboPoints(unit, target)
end
else
if wow_600 then
if not GetComboPoints then
return UnitPower((UnitHasVehicleUI and UnitHasVehicleUI("player")) and "vehicle" or "player", 4)
else
return GetComboPoints((UnitHasVehicleUI and UnitHasVehicleUI("player")) and "vehicle" or "player", "target")
@ -37,7 +36,7 @@ DogTag:AddTag("Unit", "Combos", {
'target', 'string;undef', '@undef'
},
ret = "number",
events = wow_700 and "UNIT_POWER_FREQUENT#$unit" or "UNIT_COMBO_POINTS",
events = (wow_700 or WOW_PROJECT_ID) and "UNIT_POWER_FREQUENT#$unit" or "UNIT_COMBO_POINTS",
doc = L["Return the number of combo points you have"],
example = '[Combos] => "5"; [Combos("pet"))] => "5"; [Combos("vehicle", "target"))] => "5"',
category = L["Miscellaneous"]

View File

@ -19,10 +19,8 @@ DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
local L = DogTag_Unit.L
local wow_700 = select(4, GetBuildInfo()) >= 70000
local wow_800 = select(4, GetBuildInfo()) >= 80000
local mpEvents = "UNIT_POWER_FREQUENT#$unit;UNIT_MAXPOWER#$unit;UNIT_DISPLAYPOWER#$unit"
if wow_800 then
if Enum and Enum.PowerType then
SPELL_POWER_MANA, SPELL_POWER_RUNES, SPELL_POWER_CHI, SPELL_POWER_ECLIPSE, SPELL_POWER_SOUL_SHARDS, SPELL_POWER_ARCANE_CHARGES =
Enum.PowerType.Mana, Enum.PowerType.Runes, Enum.PowerType.Chi, Enum.PowerType.LunarPower, Enum.PowerType.SoulShards, Enum.PowerType.ArcaneCharges
SPELL_POWER_BURNING_EMBERS, SPELL_POWER_HOLY_POWER, SPELL_POWER_LIGHT_FORCE, SPELL_POWER_SHADOW_ORBS =
@ -325,7 +323,8 @@ if RUNIC_POWER then
})
end
if wow_700 then
if GetRuneCooldown then
local GetRuneCooldown = GetRuneCooldown
DogTag:AddTag("Unit", "RunesAvailable", {
code = function(unit)
local numAvailable = 0
@ -423,7 +422,6 @@ DogTag:AddTag("Unit", "PowerColor", {
})
local wow_501 = select(4, GetBuildInfo()) >= 50100
local specialPowers = {
{
class = "WARLOCK",
@ -448,7 +446,7 @@ local specialPowers = {
class = "MONK",
tag = "Chi",
arg2 = SPELL_POWER_CHI or SPELL_POWER_LIGHT_FORCE,
eventPowerIdentifier = wow_501 and "CHI" or "LIGHT_FORCE",
eventPowerIdentifier = SPELL_POWER_CHI and "CHI" or "LIGHT_FORCE",
},
}
if not wow_700 then -- Parnic: shadow orbs are no more in 7.0

View File

@ -12,6 +12,8 @@ local UnitExists, UnitGUID, UnitAffectingCombat, UnitIsAFK, UnitIsDeadOrGhost, U
UnitExists, UnitGUID, UnitAffectingCombat, UnitIsAFK, UnitIsDeadOrGhost, UnitIsGhost, UnitIsDead, UnitIsDND, UnitIsPVP, UnitIsPVPFreeForAll
local GetNumRaidMembers, GetNumPartyMembers, GetPetHappiness, GetRaidTargetIndex, UnitIsTapped, GetBindingText, GetBindingKey, GetRaidRosterInfo =
GetNumRaidMembers, GetNumPartyMembers, GetPetHappiness, GetRaidTargetIndex, UnitIsTapped, GetBindingText, GetBindingKey, GetRaidRosterInfo
local UnitIsGroupLeader, GetNumGroupMembers =
UnitIsGroupLeader, GetNumGroupMembers
local UnitName, UnitInRaid, UnitFactionGroup, GetPVPTimer, IsPVPTimerRunning, GetSpellInfo, IsResting =
UnitName, UnitInRaid, UnitFactionGroup, GetPVPTimer, IsPVPTimerRunning, GetSpellInfo, IsResting
@ -24,29 +26,15 @@ local offlineTimes = {}
local afkTimes = {}
local deadTimes = {}
-- Parnic: support for cataclysm; Divine Intervention was removed
local wow_ver = select(4, GetBuildInfo())
local wow_classic = WOW_PROJECT_ID and WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local wow_400 = wow_ver >= 40000
local wow_500 = wow_ver >= 50000
local wow_600 = wow_ver >= 60000
local wow_700 = wow_ver >= 70000
local petHappinessEvent = "UNIT_POWER_UPDATE"
local partyChangedEvent = "PARTY_MEMBERS_CHANGED"
if wow_500 or wow_classic then
if UnitIsGroupLeader then
UnitIsPartyLeader = UnitIsGroupLeader
partyChangedEvent = "GROUP_ROSTER_UPDATE"
end
-- Parnic: pet happiness removed in 4.1
local wow_401 = wow_ver >= 40100
-- ...and back in Classic
if wow_classic then
petHappinessEvent = "UNIT_HAPPINESS"
end
-- Parnic: GetNumRaidMembers/GetNumPartyMembers removed in 6.0
if wow_600 or wow_classic then
if GetNumGroupMembers then
GetNumRaidMembers = GetNumGroupMembers
GetNumPartyMembers = GetNumGroupMembers
end
@ -63,14 +51,14 @@ _G.iterateGroupMembers = iterateGroupMembers
local tmp = {}
local function PARTY_MEMBERS_CHANGED(event)
local prefix, min, max = "raid", 1, 0
if wow_500 then
if GetNumGroupMembers then
max = GetNumGroupMembers()
else
max = GetNumRaidMembers()
end
if wow_500 and max <= 5 or (not wow_500 and max == 0) then
if GetNumGroupMembers and max <= 5 or (not GetNumGroupMembers and max == 0) then
prefix, min = "party", 0
if not wow_500 then
if not GetNumGroupMembers then
max = GetNumPartyMembers()
end
end
@ -468,13 +456,13 @@ DogTag:AddTag("Unit", "IsFeignedDeath", {
})
-- Parnic: pet happiness removed in 4.1
if not wow_401 then
if GetPetHappiness then
DogTag:AddTag("Unit", "HappyNum", {
code = function()
return GetPetHappiness() or 0
end,
ret = "number",
events = petHappinessEvent,
events = "UNIT_HAPPINESS",
doc = L["Return the happiness number of your pet"],
example = '[HappyNum] => "3"',
category = L["Status"]
@ -485,7 +473,7 @@ DogTag:AddTag("Unit", "HappyText", {
return _G["PET_HAPPINESS" .. (GetPetHappiness() or 0)]
end,
ret = "string;nil",
events = petHappinessEvent,
events = "UNIT_HAPPINESS",
doc = L["Return a description of how happy your pet is"],
example = ('[HappyText] => %q'):format(_G.PET_HAPPINESS3),
category = L["Status"]
@ -508,7 +496,7 @@ DogTag:AddTag("Unit", "HappyIcon", {
'unhappy', 'string', 'B(',
},
ret = "string;nil",
events = petHappinessEvent,
events = "UNIT_HAPPINESS",
doc = L["Return an icon representative of how happy your pet is"],
example = ('[HappyIcon] => ":D"; [HappyIcon] => ":I"; [HappyIcon] => "B("'),
category = L["Status"]
@ -535,7 +523,7 @@ DogTag:AddTag("Unit", "RaidIcon", {
category = L["Status"]
})
if wow_700 or wow_classic then
if UnitIsTapDenied then
DogTag:AddTag("Unit", "IsNotTappableByMe", {
code = UnitIsTapDenied,
arg = {
@ -946,7 +934,7 @@ DogTag:AddTag("Unit", "StatusColor", {
})
-- Parnic: pet happiness removed in 4.1
if not wow_401 then
if GetPetHappiness then
DogTag:AddTag("Unit", "HappyColor", {
code = function(value)
local x = GetPetHappiness()
@ -972,7 +960,7 @@ DogTag:AddTag("Unit", "HappyColor", {
'value', 'string;undef', "@undef",
},
ret = "nil;string",
events = petHappinessEvent,
events = "UNIT_HAPPINESS",
doc = L["Return the color or wrap value with the color associated with your pet's happiness"],
example = '["Hello":HappyColor] => "|cff00ff00Hello|r"; [HappyColor "Hello"] => "|cff00ff00Hello"',
category = L["Status"]
@ -980,8 +968,8 @@ DogTag:AddTag("Unit", "HappyColor", {
end
-- Parnic: DI removed in Cataclysm
if not wow_400 then
local DIVINE_INTERVENTION = GetSpellInfo(19752)
if DIVINE_INTERVENTION then
DogTag:AddTag("Unit", "Status", {
alias = ("Offline(unit=unit) or (HasDivineIntervention(unit=unit) ? %q) or (IsFeignedDeath(unit=unit) ? %q) or [if Dead(unit=unit) then ((HasSoulstone(unit=unit) ? %q) or Dead(unit=unit))]"):format(DIVINE_INTERVENTION, L["Feigned Death"], L["Soulstoned"]),
arg = {

View File

@ -5,17 +5,16 @@ if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
end
local wow_ver = select(4, GetBuildInfo())
local wow_500 = wow_ver >= 50000
local _G, table, setmetatable, rawget = _G, table, setmetatable, rawget
local UnitName, GetActiveTalentGroup, GetTalentTabInfo, UnitIsPlayer, GetNumTalentTabs =
UnitName, GetActiveTalentGroup, GetTalentTabInfo, UnitIsPlayer, GetNumTalentTabs
local UnitName, GetActiveTalentGroup, GetTalentTabInfo, UnitIsPlayer =
UnitName, GetActiveTalentGroup, GetTalentTabInfo, UnitIsPlayer
local GetSpecialization, GetSpecializationInfo
= GetSpecialization, GetSpecializationInfo
if wow_500 then
if GetActiveSpecGroup then
GetActiveTalentGroup = GetActiveSpecGroup
GetTalentTabInfo = GetSpecializationInfo
GetNumTalentTabs = GetNumSpecializations
end
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
@ -53,7 +52,7 @@ DogTag:AddAddonFinder("Unit", "LibStub", "LibTalentQuery-1.0", function(LibTalen
LibTalentQuery.RegisterCallback(DogTag_Unit, "TalentQuery_Ready", function(event, name, realm, unitId)
local fullName = realm and name .. "-" .. realm or name
if wow_500 then
if GetInspectSpecialization then
local inspectSpec = GetInspectSpecialization(unitId)
local roleById = GetSpecializationInfoByID(inspectSpec)
if roleById ~= nil then
@ -80,7 +79,7 @@ DogTag:AddAddonFinder("Unit", "LibStub", "LibTalentQuery-1.0", function(LibTalen
local lastUnit
local function func(self, name)
if name == playerName then
if wow_500 then
if GetSpecialization then
talentSpecNames[playerName] = select(2, GetSpecializationInfo(GetSpecialization()))
return
end

View File

@ -22,10 +22,9 @@ local L = DogTag_Unit.L
local newList = DogTag.newList
local del = DogTag.del
local wow_ver = select(4, GetBuildInfo())
local wow_500 = wow_ver >= 50000
local PartyChangedEvent = "PARTY_MEMBERS_CHANGED"
if wow_500 then
if UnitIsGroupLeader then
-- Changed in wow 5.0
PartyChangedEvent = "GROUP_ROSTER_UPDATE"
end

View File

@ -1,9 +1,7 @@
#@retail@
## Interface: 90005
#@end-retail@
#@non-retail@
# ## Interface: 11306
#@end-non-retail@
## Interface-Retail: 90005
## Interface-Classic: 11306
## Interface-BC: 20501
## LoadOnDemand: 1
## Title: Lib: DogTag-Unit-3.0
## Notes: A library to provide unit-oriented tags to LibDogTag-3.0