- update API

- use :ClearNamespace
This commit is contained in:
ckknight
2008-03-28 21:34:02 +00:00
parent a87c215fff
commit d03c596f14
9 changed files with 44 additions and 36 deletions

View File

@ -76,7 +76,7 @@ local auraQueue = {}
local nextAuraUpdate = 0
local nextWackyAuraUpdate = 0
DogTag:AddTimerHandler(function(num, currentTime)
DogTag:AddTimerHandler("Unit", function(num, currentTime)
if currentTime >= nextAuraUpdate and hasEvent('Aura') then
nextAuraUpdate = currentTime + 0.25
if currentTime >= nextWackyAuraUpdate then
@ -195,7 +195,7 @@ DogTag:AddTimerHandler(function(num, currentTime)
end)
DogTag:AddEventHandler("UnitChanged", function(event, unit)
DogTag:AddEventHandler("Unit", "UnitChanged", function(event, unit)
if rawget(currentAuras, unit) then
currentAuras[unit] = del(currentAuras[unit])
currentDebuffTypes[unit] = del(currentDebuffTypes[unit])
@ -205,7 +205,7 @@ DogTag:AddEventHandler("UnitChanged", function(event, unit)
end
end)
DogTag:AddEventHandler("UNIT_AURA", function(event, unit)
DogTag:AddEventHandler("Unit", "UNIT_AURA", function(event, unit)
auraQueue[unit] = true
end)

View File

@ -44,7 +44,7 @@ local castData = setmetatable({}, {__index=function(self, unit)
return data
end})
DogTag:AddTimerHandler(function(num, currentTime)
DogTag:AddTimerHandler("Unit", function(num, currentTime)
for unit, data in pairs(castData) do
if not IsNormalUnit[unit] then
castData[unit] = del(data)
@ -60,7 +60,7 @@ DogTag:AddTimerHandler(function(num, currentTime)
end
end)
DogTag:AddEventHandler("UnitChange", function(event, unit)
DogTag:AddEventHandler("Unit", "UnitChange", function(event, unit)
if rawget(castData, unit) then
castData[unit] = del(castData[unit])
end
@ -82,7 +82,7 @@ local function UNIT_SPELLCAST_SENT(event, unit, spell, rank, target)
DogTag:FireEvent("Cast", unit)
end
DogTag:AddEventHandler("UNIT_SPELLCAST_SENT", UNIT_SPELLCAST_SENT)
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_SENT", UNIT_SPELLCAST_SENT)
local function UNIT_SPELLCAST_START(event, unit)
if not hasEvent('Cast') then
@ -100,8 +100,8 @@ local function UNIT_SPELLCAST_START(event, unit)
DogTag:FireEvent("Cast", unit)
end
DogTag:AddEventHandler("UNIT_SPELLCAST_START", UNIT_SPELLCAST_START)
DogTag:AddEventHandler("UNIT_SPELLCAST_CHANNEL_START", UNIT_SPELLCAST_START)
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_START", UNIT_SPELLCAST_START)
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_CHANNEL_START", UNIT_SPELLCAST_START)
local function UNIT_SPELLCAST_STOP(event, unit)
if not hasEvent('Cast') or not rawget(castData, unit) or not castData[unit].casting or castData[unit].fading then
@ -114,7 +114,7 @@ local function UNIT_SPELLCAST_STOP(event, unit)
DogTag:FireEvent("Cast", unit)
end
DogTag:AddEventHandler("UNIT_SPELLCAST_STOP", UNIT_SPELLCAST_STOP)
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_STOP", UNIT_SPELLCAST_STOP)
local function UNIT_SPELLCAST_SUCCEEDED(event, unit, name, rank)
if not hasEvent('Cast') or unit ~= "player" or lastPlayerEvent ~= "UNIT_SPELLCAST_SENT" then
@ -146,7 +146,7 @@ local function UNIT_SPELLCAST_SUCCEEDED(event, unit, name, rank)
DogTag:FireEvent("Cast", unit)
end
DogTag:AddEventHandler("UNIT_SPELLCAST_SUCCEEDED", UNIT_SPELLCAST_SUCCEEDED)
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_SUCCEEDED", UNIT_SPELLCAST_SUCCEEDED)
local function UNIT_SPELLCAST_FAILED(event, unit)
if not hasEvent('Cast') or not rawget(castData, unit) or castData[unit].fading then
@ -157,7 +157,7 @@ local function UNIT_SPELLCAST_FAILED(event, unit)
DogTag:FireEvent("Cast", unit)
end
DogTag:AddEventHandler("UNIT_SPELLCAST_FAILED", UNIT_SPELLCAST_FAILED)
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_FAILED", UNIT_SPELLCAST_FAILED)
local function UNIT_SPELLCAST_INTERRUPTED(event, unit)
if not hasEvent('Cast') or not rawget(castData, unit) then
@ -168,8 +168,8 @@ local function UNIT_SPELLCAST_INTERRUPTED(event, unit)
DogTag:FireEvent("Cast", unit)
end
DogTag:AddEventHandler("UNIT_SPELLCAST_INTERRUPTED", UNIT_SPELLCAST_INTERRUPTED)
DogTag:AddEventHandler("UNIT_SPELLCAST_CHANNEL_INTERRUPTED", UNIT_SPELLCAST_INTERRUPTED)
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_INTERRUPTED", UNIT_SPELLCAST_INTERRUPTED)
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_CHANNEL_INTERRUPTED", UNIT_SPELLCAST_INTERRUPTED)
local function UNIT_SPELLCAST_DELAYED(event, unit)
if not hasEvent('Cast') or not rawget(castData, unit) or not castData[unit].casting or castData[unit].stopTime then
@ -192,7 +192,7 @@ local function UNIT_SPELLCAST_DELAYED(event, unit)
DogTag:FireEvent("Cast", unit)
end
DogTag:AddEventHandler("UNIT_SPELLCAST_DELAYED", UNIT_SPELLCAST_DELAYED)
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_DELAYED", UNIT_SPELLCAST_DELAYED)
local function UNIT_SPELLCAST_CHANNEL_UPDATE(event, unit)
if not hasEvent('Cast') or not rawget(castData, unit) or castData[unit].casting or castData[unit].stopTime then
@ -215,7 +215,7 @@ local function UNIT_SPELLCAST_CHANNEL_UPDATE(event, unit)
castData[unit].endTime = endTime / 1000
castData[unit].delay = castData[unit].delay + (oldStart - startTime)
end
DogTag:AddEventHandler("UNIT_SPELLCAST_CHANNEL_UPDATE", UNIT_SPELLCAST_CHANNEL_UPDATE)
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_CHANNEL_UPDATE", UNIT_SPELLCAST_CHANNEL_UPDATE)
local function UNIT_SPELLCAST_CHANNEL_STOP(event, unit)
if not hasEvent('Cast') or not rawget(castData, unit) or castData[unit].casting or castData[unit].stopTime then
@ -226,7 +226,7 @@ local function UNIT_SPELLCAST_CHANNEL_STOP(event, unit)
DogTag:FireEvent("Cast", unit)
end
DogTag:AddEventHandler("UNIT_SPELLCAST_CHANNEL_STOP", UNIT_SPELLCAST_CHANNEL_STOP)
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_CHANNEL_STOP", UNIT_SPELLCAST_CHANNEL_STOP)
DogTag:AddTag("Unit", "CastName", {
code = function(unit)

View File

@ -9,12 +9,12 @@ DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
local L = DogTag_Unit.L
DogTag:AddEventHandler("UNIT_PET_EXPERIENCE", function(event, ...)
DogTag:AddEventHandler("Unit", "UNIT_PET_EXPERIENCE", function(event, ...)
DogTag:FireEvent("UpdateExperience", "pet")
DogTag:FireEvent("UpdateExperience", "playerpet")
end)
DogTag:AddEventHandler("PLAYER_XP_UPDATE", function(event, ...)
DogTag:AddEventHandler("Unit", "PLAYER_XP_UPDATE", function(event, ...)
DogTag:FireEvent("UpdateExperience", "player")
end)

View File

@ -51,17 +51,17 @@ guildNotes = setmetatable({},x)
officerNotes = setmetatable({},x)
local nextGuildRosterUpdate = 0
DogTag:AddEventHandler("GUILD_ROSTER_UPDATE", function()
DogTag:AddEventHandler("Unit", "GUILD_ROSTER_UPDATE", function()
refreshGuildNotes()
nextGuildRosterUpdate = GetTime() + 20
end)
DogTag:AddEventHandler("PLAYER_GUILD_UPDATE", function()
DogTag:AddEventHandler("Unit", "PLAYER_GUILD_UPDATE", function()
refreshGuildNotes()
end)
DogTag:AddTimerHandler(function(num, currentTime)
DogTag:AddTimerHandler("Unit", function(num, currentTime)
if currentTime > nextGuildRosterUpdate then
if IsInGuild() then
GuildRoster()

View File

@ -95,7 +95,7 @@ local function PARTY_MEMBERS_CHANGED(event)
tmp[guid] = nil
end
end
DogTag:AddEventHandler("PARTY_MEMBERS_CHANGED", PARTY_MEMBERS_CHANGED)
DogTag:AddEventHandler("Unit", "PARTY_MEMBERS_CHANGED", PARTY_MEMBERS_CHANGED)
DogTag:AddAddonFinder("Unit", "_G", "oRA", function(v)
if AceLibrary and AceLibrary:HasInstance("AceEvent-2.0") then
@ -112,7 +112,7 @@ DogTag:AddAddonFinder("Unit", "_G", "CT_RAOptions_UpdateMTs", function(v)
end)
local first = true
DogTag:AddTimerHandler(function(currentTime, num)
DogTag:AddTimerHandler("Unit", function(currentTime, num)
if first then
first = false
PARTY_MEMBERS_CHANGED()

View File

@ -108,8 +108,8 @@ local function UPDATE_FACTION()
factionList[name] = true
end
end
DogTag:AddEventHandler("UPDATE_FACTION", UPDATE_FACTION)
DogTag:AddEventHandler("PLAYER_LOGIN", UPDATE_FACTION)
DogTag:AddEventHandler("Unit", "UPDATE_FACTION", UPDATE_FACTION)
DogTag:AddEventHandler("Unit", "PLAYER_LOGIN", UPDATE_FACTION)
DogTag:AddTag("Unit", "Guild", {
code = function(unit)

View File

@ -12,6 +12,8 @@ local DogTag_Unit, oldMinor = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
local DogTag_Unit_funcs = _G.DogTag_Unit_funcs
_G.DogTag_Unit_funcs = nil
if not DogTag_Unit then
DogTag_Unit_funcs = nil
collectgarbage('collect')
return
end
@ -20,6 +22,10 @@ if not DogTag then
error(("Cannot load %s without first loading %s"):format(MAJOR_VERSION, DOGTAG_MAJOR_VERSION))
end
if oldMinor then
DogTag:ClearNamespace("Unit")
end
local oldLib
if next(DogTag_Unit) ~= nil then
oldLib = {}
@ -33,7 +39,7 @@ DogTag_Unit.oldLib = oldLib
for _,v in ipairs(DogTag_Unit_funcs) do
v(DogTag_Unit, DogTag)
end
--[[
local function DogTag_Unit_RefreshLibrary(self)
local oldLib = {}
for k, v in pairs(DogTag_Unit) do
@ -51,3 +57,4 @@ end
DogTag_Unit.RefreshLibrary = DogTag_Unit_RefreshLibrary
DogTag:AddSubLibrary(MAJOR_VERSION)
]]

View File

@ -133,10 +133,10 @@ local function PARTY_MEMBERS_CHANGED()
DogTag:FireEvent("UnitChanged", unit)
end
end
DogTag:AddEventHandler("PARTY_MEMBERS_CHANGED", PARTY_MEMBERS_CHANGED)
DogTag:AddEventHandler("Unit", "PARTY_MEMBERS_CHANGED", PARTY_MEMBERS_CHANGED)
PARTY_MEMBERS_CHANGED()
DogTag:AddEventHandler("PLAYER_LOGIN", PARTY_MEMBERS_CHANGED)
DogTag:AddEventHandler("Unit", "PLAYER_LOGIN", PARTY_MEMBERS_CHANGED)
local t = {}
local function IterateUnitsWithGUID(guid)
@ -280,34 +280,34 @@ DogTag:AddCompilationStep("Unit", "tagevents", function(ast, t, u, tag, tagData,
end
end)
DogTag:AddEventHandler("PLAYER_TARGET_CHANGED", function(event, ...)
DogTag:AddEventHandler("Unit", "PLAYER_TARGET_CHANGED", function(event, ...)
refreshGUID("target")
DogTag:FireEvent("UnitChanged", "target")
DogTag:FireEvent("UnitChanged", "playertarget")
end)
DogTag:AddEventHandler("PLAYER_FOCUS_CHANGED", function(event, ...)
DogTag:AddEventHandler("Unit", "PLAYER_FOCUS_CHANGED", function(event, ...)
refreshGUID("focus")
DogTag:FireEvent("UnitChanged", "focus")
end)
DogTag:AddEventHandler("PLAYER_PET_CHANGED", function(event, ...)
DogTag:AddEventHandler("Unit", "PLAYER_PET_CHANGED", function(event, ...)
refreshGUID("pet")
DogTag:FireEvent("UnitChanged", "pet")
end)
DogTag:AddEventHandler("UNIT_TARGET", function(event, unit)
DogTag:AddEventHandler("Unit", "UNIT_TARGET", function(event, unit)
DogTag:FireEvent("UnitChanged", unit .. "target")
end)
DogTag:AddEventHandler("UNIT_PET", function(event, unit)
DogTag:AddEventHandler("Unit", "UNIT_PET", function(event, unit)
local unit_pet = unit .. "pet"
refreshGUID(unit_pet)
DogTag:FireEvent("UnitChanged", unit_pet)
end)
local inMouseover = false
DogTag:AddEventHandler("UPDATE_MOUSEOVER_UNIT", function(event, ...)
DogTag:AddEventHandler("Unit", "UPDATE_MOUSEOVER_UNIT", function(event, ...)
inMouseover = true
refreshGUID("mouseover")
DogTag:FireEvent("UnitChanged", "mouseover")
@ -331,7 +331,7 @@ local nsListHasUnit = setmetatable({}, { __index = function(self, key)
end })
local nextUpdateWackyUnitsTime = 0
DogTag:AddTimerHandler(function(num, currentTime)
DogTag:AddTimerHandler("Unit", function(num, currentTime)
local exists = not not UnitExists("mouseover")
if inMouseover ~= exists then
inMouseover = exists
@ -351,7 +351,7 @@ DogTag:AddTimerHandler(function(num, currentTime)
end
end)
DogTag:AddTimerHandler(function(num, currentTime)
DogTag:AddTimerHandler("Unit", function(num, currentTime)
local exists = not not UnitExists("mouseover")
if not exists then
for fs, nsList in pairs(fsToNSList) do

View File

@ -680,6 +680,7 @@ assert_equal(DogTag:Evaluate("[IsMana]", "Unit", { unit = 'target' }), nil)
assert_equal(DogTag:Evaluate("[~IsMana]", "Unit", { unit = 'target' }), "True")
assert_equal(DogTag:Evaluate("[[~IsMaxMP:~IsMana] ? PercentMP:Percent] [IsMana ? MaxMP:VeryShort:Prepend(\"| \")]", "Unit", { unit = 'target' }), nil)
assert_equal(DogTag:Evaluate("[One + NameRealm]", "Unit", { unit = 'target' }), 1)
--[Guild = "player":Guild] [Guild(unit="mouseover"):Angle]