drop ascension embeded libraries
This commit is contained in:
@@ -1,308 +0,0 @@
|
||||
--- **AceComm-3.0** allows you to send messages of unlimited length over the addon comm channels.
|
||||
-- It'll automatically split the messages into multiple parts and rebuild them on the receiving end.\\
|
||||
-- **ChatThrottleLib** is of course being used to avoid being disconnected by the server.
|
||||
--
|
||||
-- **AceComm-3.0** can be embeded into your addon, either explicitly by calling AceComm:Embed(MyAddon) or by
|
||||
-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
|
||||
-- and can be accessed directly, without having to explicitly call AceComm itself.\\
|
||||
-- It is recommended to embed AceComm, otherwise you'll have to specify a custom `self` on all calls you
|
||||
-- make into AceComm.
|
||||
-- @class file
|
||||
-- @name AceComm-3.0
|
||||
-- @release $Id$
|
||||
|
||||
--[[ AceComm-3.0
|
||||
|
||||
TODO: Time out old data rotting around from dead senders? Not a HUGE deal since the number of possible sender names is somewhat limited.
|
||||
|
||||
]]
|
||||
|
||||
local CallbackHandler = LibStub("CallbackHandler-1.0")
|
||||
local CTL = assert(ChatThrottleLib, "AceComm-3.0 requires ChatThrottleLib")
|
||||
|
||||
local MAJOR, MINOR = "AceComm-3.0", 12
|
||||
local AceComm,oldminor = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not AceComm then return end
|
||||
|
||||
-- Lua APIs
|
||||
local type, next, pairs, tostring = type, next, pairs, tostring
|
||||
local strsub, strfind = string.sub, string.find
|
||||
local tinsert, tconcat = table.insert, table.concat
|
||||
local error, assert = error, assert
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: LibStub, DEFAULT_CHAT_FRAME, geterrorhandler
|
||||
|
||||
AceComm.embeds = AceComm.embeds or {}
|
||||
|
||||
-- for my sanity and yours, let's give the message type bytes some names
|
||||
local MSG_MULTI_FIRST = "\001"
|
||||
local MSG_MULTI_NEXT = "\002"
|
||||
local MSG_MULTI_LAST = "\003"
|
||||
|
||||
AceComm.multipart_origprefixes = AceComm.multipart_origprefixes or {} -- e.g. "Prefix\001"="Prefix", "Prefix\002"="Prefix"
|
||||
AceComm.multipart_reassemblers = AceComm.multipart_reassemblers or {} -- e.g. "Prefix\001"="OnReceiveMultipartFirst"
|
||||
|
||||
-- the multipart message spool: indexed by a combination of sender+distribution+
|
||||
AceComm.multipart_spool = AceComm.multipart_spool or {}
|
||||
|
||||
--- Register for Addon Traffic on a specified prefix
|
||||
-- @param prefix A printable character (\032-\255) classification of the message (typically AddonName or AddonNameEvent)
|
||||
-- @param method Callback to call on message reception: Function reference, or method name (string) to call on self. Defaults to "OnCommReceived"
|
||||
function AceComm:RegisterComm(prefix, method)
|
||||
if method == nil then
|
||||
method = "OnCommReceived"
|
||||
end
|
||||
|
||||
return AceComm._RegisterComm(self, prefix, method) -- created by CallbackHandler
|
||||
end
|
||||
|
||||
local warnedPrefix=false
|
||||
|
||||
--- Send a message over the Addon Channel
|
||||
-- @param prefix A printable character (\032-\255) classification of the message (typically AddonName or AddonNameEvent)
|
||||
-- @param text Data to send, nils (\000) not allowed. Any length.
|
||||
-- @param distribution Addon channel, e.g. "RAID", "GUILD", etc; see SendAddonMessage API
|
||||
-- @param target Destination for some distributions; see SendAddonMessage API
|
||||
-- @param prio OPTIONAL: ChatThrottleLib priority, "BULK", "NORMAL" or "ALERT". Defaults to "NORMAL".
|
||||
-- @param callbackFn OPTIONAL: callback function to be called as each chunk is sent. receives 3 args: the user supplied arg (see next), the number of bytes sent so far, and the number of bytes total to send.
|
||||
-- @param callbackArg: OPTIONAL: first arg to the callback function. nil will be passed if not specified.
|
||||
function AceComm:SendCommMessage(prefix, text, distribution, target, prio, callbackFn, callbackArg)
|
||||
prio = prio or "NORMAL" -- pasta's reference implementation had different prio for singlepart and multipart, but that's a very bad idea since that can easily lead to out-of-sequence delivery!
|
||||
if not( type(prefix)=="string" and
|
||||
type(text)=="string" and
|
||||
type(distribution)=="string" and
|
||||
(target==nil or type(target)=="string" or type(target)=="number") and
|
||||
(prio=="BULK" or prio=="NORMAL" or prio=="ALERT")
|
||||
) then
|
||||
error('Usage: SendCommMessage(addon, "prefix", "text", "distribution"[, "target"[, "prio"[, callbackFn, callbackarg]]])', 2)
|
||||
end
|
||||
|
||||
if strfind(prefix, "[\001-\009]") then
|
||||
if strfind(prefix, "[\001-\003]") then
|
||||
error("SendCommMessage: Characters \\001--\\003 in prefix are reserved for AceComm metadata", 2)
|
||||
elseif not warnedPrefix then
|
||||
-- I have some ideas about future extensions that require more control characters /mikk, 20090808
|
||||
geterrorhandler()("SendCommMessage: Heads-up developers: Characters \\004--\\009 in prefix are reserved for AceComm future extension")
|
||||
warnedPrefix = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local textlen = #text
|
||||
local maxtextlen = 254 - #prefix -- 254 is the max length of prefix + text that can be sent in one message
|
||||
local queueName = prefix..distribution..(target or "")
|
||||
|
||||
local ctlCallback = nil
|
||||
if callbackFn then
|
||||
ctlCallback = function(sent)
|
||||
return callbackFn(callbackArg, sent, textlen)
|
||||
end
|
||||
end
|
||||
|
||||
if textlen <= maxtextlen then
|
||||
-- fits all in one message
|
||||
CTL:SendAddonMessage(prio, prefix, text, distribution, target, queueName, ctlCallback, textlen)
|
||||
else
|
||||
maxtextlen = maxtextlen - 1 -- 1 extra byte for part indicator in prefix
|
||||
|
||||
-- first part
|
||||
local chunk = strsub(text, 1, maxtextlen)
|
||||
CTL:SendAddonMessage(prio, prefix..MSG_MULTI_FIRST, chunk, distribution, target, queueName, ctlCallback, maxtextlen)
|
||||
|
||||
-- continuation
|
||||
local pos = 1+maxtextlen
|
||||
local prefix2 = prefix..MSG_MULTI_NEXT
|
||||
|
||||
while pos+maxtextlen <= textlen do
|
||||
chunk = strsub(text, pos, pos+maxtextlen-1)
|
||||
CTL:SendAddonMessage(prio, prefix2, chunk, distribution, target, queueName, ctlCallback, pos+maxtextlen-1)
|
||||
pos = pos + maxtextlen
|
||||
end
|
||||
|
||||
-- final part
|
||||
chunk = strsub(text, pos)
|
||||
CTL:SendAddonMessage(prio, prefix..MSG_MULTI_LAST, chunk, distribution, target, queueName, ctlCallback, textlen)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Message receiving
|
||||
----------------------------------------
|
||||
|
||||
do
|
||||
local compost = setmetatable({}, {__mode = "k"})
|
||||
local function new()
|
||||
local t = next(compost)
|
||||
if t then
|
||||
compost[t]=nil
|
||||
for i=#t,3,-1 do -- faster than pairs loop. don't even nil out 1/2 since they'll be overwritten
|
||||
t[i]=nil
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
return {}
|
||||
end
|
||||
|
||||
local function lostdatawarning(prefix,sender,where)
|
||||
DEFAULT_CHAT_FRAME:AddMessage(MAJOR..": Warning: lost network data regarding '"..tostring(prefix).."' from '"..tostring(sender).."' (in "..where..")")
|
||||
end
|
||||
|
||||
function AceComm:OnReceiveMultipartFirst(prefix, message, distribution, sender)
|
||||
local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender
|
||||
local spool = AceComm.multipart_spool
|
||||
|
||||
--[[
|
||||
if spool[key] then
|
||||
lostdatawarning(prefix,sender,"First")
|
||||
-- continue and overwrite
|
||||
end
|
||||
--]]
|
||||
|
||||
spool[key] = message -- plain string for now
|
||||
end
|
||||
|
||||
function AceComm:OnReceiveMultipartNext(prefix, message, distribution, sender)
|
||||
local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender
|
||||
local spool = AceComm.multipart_spool
|
||||
local olddata = spool[key]
|
||||
|
||||
if not olddata then
|
||||
--lostdatawarning(prefix,sender,"Next")
|
||||
return
|
||||
end
|
||||
|
||||
if type(olddata)~="table" then
|
||||
-- ... but what we have is not a table. So make it one. (Pull a composted one if available)
|
||||
local t = new()
|
||||
t[1] = olddata -- add old data as first string
|
||||
t[2] = message -- and new message as second string
|
||||
spool[key] = t -- and put the table in the spool instead of the old string
|
||||
else
|
||||
tinsert(olddata, message)
|
||||
end
|
||||
end
|
||||
|
||||
function AceComm:OnReceiveMultipartLast(prefix, message, distribution, sender)
|
||||
local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender
|
||||
local spool = AceComm.multipart_spool
|
||||
local olddata = spool[key]
|
||||
|
||||
if not olddata then
|
||||
--lostdatawarning(prefix,sender,"End")
|
||||
return
|
||||
end
|
||||
|
||||
spool[key] = nil
|
||||
|
||||
if type(olddata) == "table" then
|
||||
-- if we've received a "next", the spooled data will be a table for rapid & garbage-free tconcat
|
||||
tinsert(olddata, message)
|
||||
AceComm.callbacks:Fire(prefix, tconcat(olddata, ""), distribution, sender)
|
||||
compost[olddata] = true
|
||||
else
|
||||
-- if we've only received a "first", the spooled data will still only be a string
|
||||
AceComm.callbacks:Fire(prefix, olddata..message, distribution, sender)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Embed CallbackHandler
|
||||
----------------------------------------
|
||||
|
||||
if not AceComm.callbacks then
|
||||
-- ensure that 'prefix to watch' table is consistent with registered
|
||||
-- callbacks
|
||||
AceComm.__prefixes = {}
|
||||
|
||||
AceComm.callbacks = CallbackHandler:New(AceComm,
|
||||
"_RegisterComm",
|
||||
"UnregisterComm",
|
||||
"UnregisterAllComm")
|
||||
end
|
||||
|
||||
function AceComm.callbacks:OnUsed(target, prefix)
|
||||
AceComm.multipart_origprefixes[prefix..MSG_MULTI_FIRST] = prefix
|
||||
AceComm.multipart_reassemblers[prefix..MSG_MULTI_FIRST] = "OnReceiveMultipartFirst"
|
||||
|
||||
AceComm.multipart_origprefixes[prefix..MSG_MULTI_NEXT] = prefix
|
||||
AceComm.multipart_reassemblers[prefix..MSG_MULTI_NEXT] = "OnReceiveMultipartNext"
|
||||
|
||||
AceComm.multipart_origprefixes[prefix..MSG_MULTI_LAST] = prefix
|
||||
AceComm.multipart_reassemblers[prefix..MSG_MULTI_LAST] = "OnReceiveMultipartLast"
|
||||
end
|
||||
|
||||
function AceComm.callbacks:OnUnused(target, prefix)
|
||||
AceComm.multipart_origprefixes[prefix..MSG_MULTI_FIRST] = nil
|
||||
AceComm.multipart_reassemblers[prefix..MSG_MULTI_FIRST] = nil
|
||||
|
||||
AceComm.multipart_origprefixes[prefix..MSG_MULTI_NEXT] = nil
|
||||
AceComm.multipart_reassemblers[prefix..MSG_MULTI_NEXT] = nil
|
||||
|
||||
AceComm.multipart_origprefixes[prefix..MSG_MULTI_LAST] = nil
|
||||
AceComm.multipart_reassemblers[prefix..MSG_MULTI_LAST] = nil
|
||||
end
|
||||
|
||||
local function OnEvent(this, event, ...)
|
||||
if event == "CHAT_MSG_ADDON" then
|
||||
local prefix,message,distribution,sender = ...
|
||||
local reassemblername = AceComm.multipart_reassemblers[prefix]
|
||||
if reassemblername then
|
||||
-- multipart: reassemble
|
||||
local aceCommReassemblerFunc = AceComm[reassemblername]
|
||||
local origprefix = AceComm.multipart_origprefixes[prefix]
|
||||
aceCommReassemblerFunc(AceComm, origprefix, message, distribution, sender)
|
||||
else
|
||||
-- single part: fire it off immediately and let CallbackHandler decide if it's registered or not
|
||||
AceComm.callbacks:Fire(prefix, message, distribution, sender)
|
||||
end
|
||||
else
|
||||
assert(false, "Received "..tostring(event).." event?!")
|
||||
end
|
||||
end
|
||||
|
||||
AceComm.frame = AceComm.frame or CreateFrame("Frame", "AceComm30Frame")
|
||||
AceComm.frame:SetScript("OnEvent", OnEvent)
|
||||
AceComm.frame:UnregisterAllEvents()
|
||||
AceComm.frame:RegisterEvent("CHAT_MSG_ADDON")
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Base library stuff
|
||||
----------------------------------------
|
||||
|
||||
local mixins = {
|
||||
"RegisterComm",
|
||||
"UnregisterComm",
|
||||
"UnregisterAllComm",
|
||||
"SendCommMessage",
|
||||
}
|
||||
|
||||
-- Embeds AceComm-3.0 into the target object making the functions from the mixins list available on target:..
|
||||
-- @param target target object to embed AceComm-3.0 in
|
||||
function AceComm:Embed(target)
|
||||
for k, v in pairs(mixins) do
|
||||
target[v] = self[v]
|
||||
end
|
||||
self.embeds[target] = true
|
||||
return target
|
||||
end
|
||||
|
||||
function AceComm:OnEmbedDisable(target)
|
||||
target:UnregisterAllComm()
|
||||
end
|
||||
|
||||
-- Update embeds
|
||||
for target, v in pairs(AceComm.embeds) do
|
||||
AceComm:Embed(target)
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="ChatThrottleLib.lua"/>
|
||||
<Script file="AceComm-3.0.lua"/>
|
||||
</Ui>
|
||||
@@ -1,523 +0,0 @@
|
||||
--
|
||||
-- ChatThrottleLib by Mikk
|
||||
--
|
||||
-- Manages AddOn chat output to keep player from getting kicked off.
|
||||
--
|
||||
-- ChatThrottleLib:SendChatMessage/:SendAddonMessage functions that accept
|
||||
-- a Priority ("BULK", "NORMAL", "ALERT") as well as prefix for SendChatMessage.
|
||||
--
|
||||
-- Priorities get an equal share of available bandwidth when fully loaded.
|
||||
-- Communication channels are separated on extension+chattype+destination and
|
||||
-- get round-robinned. (Destination only matters for whispers and channels,
|
||||
-- obviously)
|
||||
--
|
||||
-- Will install hooks for SendChatMessage and SendAddonMessage to measure
|
||||
-- bandwidth bypassing the library and use less bandwidth itself.
|
||||
--
|
||||
--
|
||||
-- Fully embeddable library. Just copy this file into your addon directory,
|
||||
-- add it to the .toc, and it's done.
|
||||
--
|
||||
-- Can run as a standalone addon also, but, really, just embed it! :-)
|
||||
--
|
||||
-- LICENSE: ChatThrottleLib is released into the Public Domain
|
||||
--
|
||||
|
||||
local CTL_VERSION = 24
|
||||
|
||||
local _G = _G
|
||||
|
||||
if _G.ChatThrottleLib then
|
||||
if _G.ChatThrottleLib.version >= CTL_VERSION then
|
||||
-- There's already a newer (or same) version loaded. Buh-bye.
|
||||
return
|
||||
elseif not _G.ChatThrottleLib.securelyHooked then
|
||||
print("ChatThrottleLib: Warning: There's an ANCIENT ChatThrottleLib.lua (pre-wow 2.0, <v16) in an addon somewhere. Get the addon updated or copy in a newer ChatThrottleLib.lua (>=v16) in it!")
|
||||
-- ATTEMPT to unhook; this'll behave badly if someone else has hooked...
|
||||
-- ... and if someone has securehooked, they can kiss that goodbye too... >.<
|
||||
_G.SendChatMessage = _G.ChatThrottleLib.ORIG_SendChatMessage
|
||||
if _G.ChatThrottleLib.ORIG_SendAddonMessage then
|
||||
_G.SendAddonMessage = _G.ChatThrottleLib.ORIG_SendAddonMessage
|
||||
end
|
||||
end
|
||||
_G.ChatThrottleLib.ORIG_SendChatMessage = nil
|
||||
_G.ChatThrottleLib.ORIG_SendAddonMessage = nil
|
||||
end
|
||||
|
||||
if not _G.ChatThrottleLib then
|
||||
_G.ChatThrottleLib = {}
|
||||
end
|
||||
|
||||
ChatThrottleLib = _G.ChatThrottleLib -- in case some addon does "local ChatThrottleLib" above us and we're copypasted (AceComm-2, sigh)
|
||||
local ChatThrottleLib = _G.ChatThrottleLib
|
||||
|
||||
ChatThrottleLib.version = CTL_VERSION
|
||||
|
||||
|
||||
|
||||
------------------ TWEAKABLES -----------------
|
||||
|
||||
ChatThrottleLib.MAX_CPS = 800 -- 2000 seems to be safe if NOTHING ELSE is happening. let's call it 800.
|
||||
ChatThrottleLib.MSG_OVERHEAD = 40 -- Guesstimate overhead for sending a message; source+dest+chattype+protocolstuff
|
||||
|
||||
ChatThrottleLib.BURST = 4000 -- WoW's server buffer seems to be about 32KB. 8KB should be safe, but seen disconnects on _some_ servers. Using 4KB now.
|
||||
|
||||
ChatThrottleLib.MIN_FPS = 20 -- Reduce output CPS to half (and don't burst) if FPS drops below this value
|
||||
|
||||
|
||||
local setmetatable = setmetatable
|
||||
local table_remove = table.remove
|
||||
local tostring = tostring
|
||||
local GetTime = GetTime
|
||||
local math_min = math.min
|
||||
local math_max = math.max
|
||||
local next = next
|
||||
local strlen = string.len
|
||||
local GetFramerate = GetFramerate
|
||||
local strlower = string.lower
|
||||
local unpack,type,pairs,wipe = unpack,type,pairs,wipe
|
||||
local UnitInRaid,GetNumPartyMembers = UnitInRaid,GetNumPartyMembers
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- Double-linked ring implementation
|
||||
|
||||
local Ring = {}
|
||||
local RingMeta = { __index = Ring }
|
||||
|
||||
function Ring:New()
|
||||
local ret = {}
|
||||
setmetatable(ret, RingMeta)
|
||||
return ret
|
||||
end
|
||||
|
||||
function Ring:Add(obj) -- Append at the "far end" of the ring (aka just before the current position)
|
||||
if self.pos then
|
||||
obj.prev = self.pos.prev
|
||||
obj.prev.next = obj
|
||||
obj.next = self.pos
|
||||
obj.next.prev = obj
|
||||
else
|
||||
obj.next = obj
|
||||
obj.prev = obj
|
||||
self.pos = obj
|
||||
end
|
||||
end
|
||||
|
||||
function Ring:Remove(obj)
|
||||
obj.next.prev = obj.prev
|
||||
obj.prev.next = obj.next
|
||||
if self.pos == obj then
|
||||
self.pos = obj.next
|
||||
if self.pos == obj then
|
||||
self.pos = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- Recycling bin for pipes
|
||||
-- A pipe is a plain integer-indexed queue of messages
|
||||
-- Pipes normally live in Rings of pipes (3 rings total, one per priority)
|
||||
|
||||
ChatThrottleLib.PipeBin = nil -- pre-v19, drastically different
|
||||
local PipeBin = setmetatable({}, {__mode="k"})
|
||||
|
||||
local function DelPipe(pipe)
|
||||
for i = #pipe, 1, -1 do
|
||||
pipe[i] = nil
|
||||
end
|
||||
pipe.prev = nil
|
||||
pipe.next = nil
|
||||
|
||||
PipeBin[pipe] = true
|
||||
end
|
||||
|
||||
local function NewPipe()
|
||||
local pipe = next(PipeBin)
|
||||
if pipe then
|
||||
wipe(pipe)
|
||||
PipeBin[pipe] = nil
|
||||
return pipe
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- Recycling bin for messages
|
||||
|
||||
ChatThrottleLib.MsgBin = nil -- pre-v19, drastically different
|
||||
local MsgBin = setmetatable({}, {__mode="k"})
|
||||
|
||||
local function DelMsg(msg)
|
||||
msg[1] = nil
|
||||
-- there's more parameters, but they're very repetetive so the string pool doesn't suffer really, and it's faster to just not delete them.
|
||||
MsgBin[msg] = true
|
||||
end
|
||||
|
||||
local function NewMsg()
|
||||
local msg = next(MsgBin)
|
||||
if msg then
|
||||
MsgBin[msg] = nil
|
||||
return msg
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- ChatThrottleLib:Init
|
||||
-- Initialize queues, set up frame for OnUpdate, etc
|
||||
|
||||
|
||||
function ChatThrottleLib:Init()
|
||||
|
||||
-- Set up queues
|
||||
if not self.Prio then
|
||||
self.Prio = {}
|
||||
self.Prio["ALERT"] = { ByName = {}, Ring = Ring:New(), avail = 0 }
|
||||
self.Prio["NORMAL"] = { ByName = {}, Ring = Ring:New(), avail = 0 }
|
||||
self.Prio["BULK"] = { ByName = {}, Ring = Ring:New(), avail = 0 }
|
||||
end
|
||||
|
||||
-- v4: total send counters per priority
|
||||
for _, Prio in pairs(self.Prio) do
|
||||
Prio.nTotalSent = Prio.nTotalSent or 0
|
||||
end
|
||||
|
||||
if not self.avail then
|
||||
self.avail = 0 -- v5
|
||||
end
|
||||
if not self.nTotalSent then
|
||||
self.nTotalSent = 0 -- v5
|
||||
end
|
||||
|
||||
|
||||
-- Set up a frame to get OnUpdate events
|
||||
if not self.Frame then
|
||||
self.Frame = CreateFrame("Frame")
|
||||
self.Frame:Hide()
|
||||
end
|
||||
self.Frame:SetScript("OnUpdate", self.OnUpdate)
|
||||
self.Frame:SetScript("OnEvent", self.OnEvent) -- v11: Monitor P_E_W so we can throttle hard for a few seconds
|
||||
self.Frame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
self.OnUpdateDelay = 0
|
||||
self.LastAvailUpdate = GetTime()
|
||||
self.HardThrottlingBeginTime = GetTime() -- v11: Throttle hard for a few seconds after startup
|
||||
|
||||
-- Hook SendChatMessage and SendAddonMessage so we can measure unpiped traffic and avoid overloads (v7)
|
||||
if not self.securelyHooked then
|
||||
-- Use secure hooks as of v16. Old regular hook support yanked out in v21.
|
||||
self.securelyHooked = true
|
||||
--SendChatMessage
|
||||
hooksecurefunc("SendChatMessage", function(...)
|
||||
return ChatThrottleLib.Hook_SendChatMessage(...)
|
||||
end)
|
||||
--SendAddonMessage
|
||||
hooksecurefunc("SendAddonMessage", function(...)
|
||||
return ChatThrottleLib.Hook_SendAddonMessage(...)
|
||||
end)
|
||||
end
|
||||
self.nBypass = 0
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- ChatThrottleLib.Hook_SendChatMessage / .Hook_SendAddonMessage
|
||||
|
||||
local bMyTraffic = false
|
||||
|
||||
function ChatThrottleLib.Hook_SendChatMessage(text, chattype, language, destination, ...)
|
||||
if bMyTraffic then
|
||||
return
|
||||
end
|
||||
local self = ChatThrottleLib
|
||||
local size = strlen(tostring(text or "")) + strlen(tostring(destination or "")) + self.MSG_OVERHEAD
|
||||
self.avail = self.avail - size
|
||||
self.nBypass = self.nBypass + size -- just a statistic
|
||||
end
|
||||
function ChatThrottleLib.Hook_SendAddonMessage(prefix, text, chattype, destination, ...)
|
||||
if bMyTraffic then
|
||||
return
|
||||
end
|
||||
local self = ChatThrottleLib
|
||||
local size = tostring(text or ""):len() + tostring(prefix or ""):len();
|
||||
size = size + tostring(destination or ""):len() + self.MSG_OVERHEAD
|
||||
self.avail = self.avail - size
|
||||
self.nBypass = self.nBypass + size -- just a statistic
|
||||
end
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- ChatThrottleLib:UpdateAvail
|
||||
-- Update self.avail with how much bandwidth is currently available
|
||||
|
||||
function ChatThrottleLib:UpdateAvail()
|
||||
local now = GetTime()
|
||||
local MAX_CPS = self.MAX_CPS;
|
||||
local newavail = MAX_CPS * (now - self.LastAvailUpdate)
|
||||
local avail = self.avail
|
||||
|
||||
if now - self.HardThrottlingBeginTime < 5 then
|
||||
-- First 5 seconds after startup/zoning: VERY hard clamping to avoid irritating the server rate limiter, it seems very cranky then
|
||||
avail = math_min(avail + (newavail*0.1), MAX_CPS*0.5)
|
||||
self.bChoking = true
|
||||
elseif GetFramerate() < self.MIN_FPS then -- GetFramerate call takes ~0.002 secs
|
||||
avail = math_min(MAX_CPS, avail + newavail*0.5)
|
||||
self.bChoking = true -- just a statistic
|
||||
else
|
||||
avail = math_min(self.BURST, avail + newavail)
|
||||
self.bChoking = false
|
||||
end
|
||||
|
||||
avail = math_max(avail, 0-(MAX_CPS*2)) -- Can go negative when someone is eating bandwidth past the lib. but we refuse to stay silent for more than 2 seconds; if they can do it, we can.
|
||||
|
||||
self.avail = avail
|
||||
self.LastAvailUpdate = now
|
||||
|
||||
return avail
|
||||
end
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- Despooling logic
|
||||
-- Reminder:
|
||||
-- - We have 3 Priorities, each containing a "Ring" construct ...
|
||||
-- - ... made up of N "Pipe"s (1 for each destination/pipename)
|
||||
-- - and each pipe contains messages
|
||||
|
||||
function ChatThrottleLib:Despool(Prio)
|
||||
local ring = Prio.Ring
|
||||
while ring.pos and Prio.avail > ring.pos[1].nSize do
|
||||
local msg = table_remove(ring.pos, 1)
|
||||
if not ring.pos[1] then -- did we remove last msg in this pipe?
|
||||
local pipe = Prio.Ring.pos
|
||||
Prio.Ring:Remove(pipe)
|
||||
Prio.ByName[pipe.name] = nil
|
||||
DelPipe(pipe)
|
||||
else
|
||||
Prio.Ring.pos = Prio.Ring.pos.next
|
||||
end
|
||||
local didSend=false
|
||||
local lowerDest = strlower(msg[3] or "")
|
||||
if lowerDest == "raid" and not UnitInRaid("player") then
|
||||
-- do nothing
|
||||
elseif lowerDest == "party" and GetNumPartyMembers() == 0 then
|
||||
-- do nothing
|
||||
else
|
||||
Prio.avail = Prio.avail - msg.nSize
|
||||
bMyTraffic = true
|
||||
msg.f(unpack(msg, 1, msg.n))
|
||||
bMyTraffic = false
|
||||
Prio.nTotalSent = Prio.nTotalSent + msg.nSize
|
||||
DelMsg(msg)
|
||||
didSend = true
|
||||
end
|
||||
-- notify caller of delivery (even if we didn't send it)
|
||||
if msg.callbackFn then
|
||||
msg.callbackFn (msg.callbackArg, didSend)
|
||||
end
|
||||
-- USER CALLBACK MAY ERROR
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function ChatThrottleLib.OnEvent(this,event)
|
||||
-- v11: We know that the rate limiter is touchy after login. Assume that it's touchy after zoning, too.
|
||||
local self = ChatThrottleLib
|
||||
if event == "PLAYER_ENTERING_WORLD" then
|
||||
self.HardThrottlingBeginTime = GetTime() -- Throttle hard for a few seconds after zoning
|
||||
self.avail = 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function ChatThrottleLib.OnUpdate(this,delay)
|
||||
local self = ChatThrottleLib
|
||||
|
||||
self.OnUpdateDelay = self.OnUpdateDelay + delay
|
||||
if self.OnUpdateDelay < 0.08 then
|
||||
return
|
||||
end
|
||||
self.OnUpdateDelay = 0
|
||||
|
||||
self:UpdateAvail()
|
||||
|
||||
if self.avail < 0 then
|
||||
return -- argh. some bastard is spewing stuff past the lib. just bail early to save cpu.
|
||||
end
|
||||
|
||||
-- See how many of our priorities have queued messages (we only have 3, don't worry about the loop)
|
||||
local n = 0
|
||||
for prioname,Prio in pairs(self.Prio) do
|
||||
if Prio.Ring.pos or Prio.avail < 0 then
|
||||
n = n + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- Anything queued still?
|
||||
if n<1 then
|
||||
-- Nope. Move spillover bandwidth to global availability gauge and clear self.bQueueing
|
||||
for prioname, Prio in pairs(self.Prio) do
|
||||
self.avail = self.avail + Prio.avail
|
||||
Prio.avail = 0
|
||||
end
|
||||
self.bQueueing = false
|
||||
self.Frame:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
-- There's stuff queued. Hand out available bandwidth to priorities as needed and despool their queues
|
||||
local avail = self.avail/n
|
||||
self.avail = 0
|
||||
|
||||
for prioname, Prio in pairs(self.Prio) do
|
||||
if Prio.Ring.pos or Prio.avail < 0 then
|
||||
Prio.avail = Prio.avail + avail
|
||||
if Prio.Ring.pos and Prio.avail > Prio.Ring.pos[1].nSize then
|
||||
self:Despool(Prio)
|
||||
-- Note: We might not get here if the user-supplied callback function errors out! Take care!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- Spooling logic
|
||||
|
||||
function ChatThrottleLib:Enqueue(prioname, pipename, msg)
|
||||
local Prio = self.Prio[prioname]
|
||||
local pipe = Prio.ByName[pipename]
|
||||
if not pipe then
|
||||
self.Frame:Show()
|
||||
pipe = NewPipe()
|
||||
pipe.name = pipename
|
||||
Prio.ByName[pipename] = pipe
|
||||
Prio.Ring:Add(pipe)
|
||||
end
|
||||
|
||||
pipe[#pipe + 1] = msg
|
||||
|
||||
self.bQueueing = true
|
||||
end
|
||||
|
||||
function ChatThrottleLib:SendChatMessage(prio, prefix, text, chattype, language, destination, queueName, callbackFn, callbackArg)
|
||||
if not self or not prio or not prefix or not text or not self.Prio[prio] then
|
||||
error('Usage: ChatThrottleLib:SendChatMessage("{BULK||NORMAL||ALERT}", "prefix", "text"[, "chattype"[, "language"[, "destination"]]]', 2)
|
||||
end
|
||||
if callbackFn and type(callbackFn)~="function" then
|
||||
error('ChatThrottleLib:ChatMessage(): callbackFn: expected function, got '..type(callbackFn), 2)
|
||||
end
|
||||
|
||||
local nSize = text:len()
|
||||
|
||||
if nSize>255 then
|
||||
error("ChatThrottleLib:SendChatMessage(): message length cannot exceed 255 bytes", 2)
|
||||
end
|
||||
|
||||
nSize = nSize + self.MSG_OVERHEAD
|
||||
|
||||
-- Check if there's room in the global available bandwidth gauge to send directly
|
||||
if not self.bQueueing and nSize < self:UpdateAvail() then
|
||||
self.avail = self.avail - nSize
|
||||
bMyTraffic = true
|
||||
_G.SendChatMessage(text, chattype, language, destination)
|
||||
bMyTraffic = false
|
||||
self.Prio[prio].nTotalSent = self.Prio[prio].nTotalSent + nSize
|
||||
if callbackFn then
|
||||
callbackFn (callbackArg, true)
|
||||
end
|
||||
-- USER CALLBACK MAY ERROR
|
||||
return
|
||||
end
|
||||
|
||||
-- Message needs to be queued
|
||||
local msg = NewMsg()
|
||||
msg.f = _G.SendChatMessage
|
||||
msg[1] = text
|
||||
msg[2] = chattype or "SAY"
|
||||
msg[3] = language
|
||||
msg[4] = destination
|
||||
msg.n = 4
|
||||
msg.nSize = nSize
|
||||
msg.callbackFn = callbackFn
|
||||
msg.callbackArg = callbackArg
|
||||
|
||||
self:Enqueue(prio, queueName or (prefix..(chattype or "SAY")..(destination or "")), msg)
|
||||
end
|
||||
|
||||
|
||||
function ChatThrottleLib:SendAddonMessage(prio, prefix, text, chattype, target, queueName, callbackFn, callbackArg)
|
||||
if not self or not prio or not prefix or not text or not chattype or not self.Prio[prio] then
|
||||
error('Usage: ChatThrottleLib:SendAddonMessage("{BULK||NORMAL||ALERT}", "prefix", "text", "chattype"[, "target"])', 2)
|
||||
end
|
||||
if callbackFn and type(callbackFn)~="function" then
|
||||
error('ChatThrottleLib:SendAddonMessage(): callbackFn: expected function, got '..type(callbackFn), 2)
|
||||
end
|
||||
|
||||
local nSize = prefix:len() + 1 + text:len();
|
||||
|
||||
if nSize>255 then
|
||||
error("ChatThrottleLib:SendAddonMessage(): prefix + message length cannot exceed 254 bytes", 2)
|
||||
end
|
||||
|
||||
nSize = nSize + self.MSG_OVERHEAD;
|
||||
|
||||
-- Check if there's room in the global available bandwidth gauge to send directly
|
||||
if not self.bQueueing and nSize < self:UpdateAvail() then
|
||||
self.avail = self.avail - nSize
|
||||
bMyTraffic = true
|
||||
_G.SendAddonMessage(prefix, text, chattype, target)
|
||||
bMyTraffic = false
|
||||
self.Prio[prio].nTotalSent = self.Prio[prio].nTotalSent + nSize
|
||||
if callbackFn then
|
||||
callbackFn (callbackArg, true)
|
||||
end
|
||||
-- USER CALLBACK MAY ERROR
|
||||
return
|
||||
end
|
||||
|
||||
-- Message needs to be queued
|
||||
local msg = NewMsg()
|
||||
msg.f = _G.SendAddonMessage
|
||||
msg[1] = prefix
|
||||
msg[2] = text
|
||||
msg[3] = chattype
|
||||
msg[4] = target
|
||||
msg.n = (target~=nil) and 4 or 3;
|
||||
msg.nSize = nSize
|
||||
msg.callbackFn = callbackFn
|
||||
msg.callbackArg = callbackArg
|
||||
|
||||
self:Enqueue(prio, queueName or (prefix..chattype..(target or "")), msg)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- Get the ball rolling!
|
||||
|
||||
ChatThrottleLib:Init()
|
||||
|
||||
--[[ WoWBench debugging snippet
|
||||
if(WOWB_VER) then
|
||||
local function SayTimer()
|
||||
print("SAY: "..GetTime().." "..arg1)
|
||||
end
|
||||
ChatThrottleLib.Frame:SetScript("OnEvent", SayTimer)
|
||||
ChatThrottleLib.Frame:RegisterEvent("CHAT_MSG_SAY")
|
||||
end
|
||||
]]
|
||||
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
--- **AceSerializer-3.0** can serialize any variable (except functions or userdata) into a string format,
|
||||
-- that can be send over the addon comm channel. AceSerializer was designed to keep all data intact, especially
|
||||
-- very large numbers or floating point numbers, and table structures. The only caveat currently is, that multiple
|
||||
-- references to the same table will be send individually.
|
||||
--
|
||||
-- **AceSerializer-3.0** can be embeded into your addon, either explicitly by calling AceSerializer:Embed(MyAddon) or by
|
||||
-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
|
||||
-- and can be accessed directly, without having to explicitly call AceSerializer itself.\\
|
||||
-- It is recommended to embed AceSerializer, otherwise you'll have to specify a custom `self` on all calls you
|
||||
-- make into AceSerializer.
|
||||
-- @class file
|
||||
-- @name AceSerializer-3.0
|
||||
-- @release $Id: AceSerializer-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $
|
||||
local MAJOR,MINOR = "AceSerializer-3.0", 5
|
||||
local AceSerializer, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not AceSerializer then return end
|
||||
|
||||
-- Lua APIs
|
||||
local strbyte, strchar, gsub, gmatch, format = string.byte, string.char, string.gsub, string.gmatch, string.format
|
||||
local assert, error, pcall = assert, error, pcall
|
||||
local type, tostring, tonumber = type, tostring, tonumber
|
||||
local pairs, select, frexp = pairs, select, math.frexp
|
||||
local tconcat = table.concat
|
||||
|
||||
-- quick copies of string representations of wonky numbers
|
||||
local inf = math.huge
|
||||
|
||||
local serNaN = "-1.#IND"
|
||||
local serInf, serInfMac = "1.#INF", "inf"
|
||||
local serNegInf, serNegInfMac = "-1.#INF", "-inf"
|
||||
|
||||
|
||||
-- Serialization functions
|
||||
|
||||
local function SerializeStringHelper(ch) -- Used by SerializeValue for strings
|
||||
-- We use \126 ("~") as an escape character for all nonprints plus a few more
|
||||
local n = strbyte(ch)
|
||||
if n==30 then -- v3 / ticket 115: catch a nonprint that ends up being "~^" when encoded... DOH
|
||||
return "\126\122"
|
||||
elseif n<=32 then -- nonprint + space
|
||||
return "\126"..strchar(n+64)
|
||||
elseif n==94 then -- value separator
|
||||
return "\126\125"
|
||||
elseif n==126 then -- our own escape character
|
||||
return "\126\124"
|
||||
elseif n==127 then -- nonprint (DEL)
|
||||
return "\126\123"
|
||||
else
|
||||
assert(false) -- can't be reached if caller uses a sane regex
|
||||
end
|
||||
end
|
||||
|
||||
local function SerializeValue(v, res, nres)
|
||||
-- We use "^" as a value separator, followed by one byte for type indicator
|
||||
local t=type(v)
|
||||
|
||||
if t=="string" then -- ^S = string (escaped to remove nonprints, "^"s, etc)
|
||||
res[nres+1] = "^S"
|
||||
res[nres+2] = gsub(v,"[%c \94\126\127]", SerializeStringHelper)
|
||||
nres=nres+2
|
||||
|
||||
elseif t=="number" then -- ^N = number (just tostring()ed) or ^F (float components)
|
||||
local str = tostring(v)
|
||||
if tonumber(str)==v or str==serNaN then
|
||||
-- translates just fine, transmit as-is
|
||||
res[nres+1] = "^N"
|
||||
res[nres+2] = str
|
||||
nres=nres+2
|
||||
elseif v == inf or v == -inf then
|
||||
res[nres+1] = "^N"
|
||||
res[nres+2] = v == inf and serInf or serNegInf
|
||||
nres=nres+2
|
||||
else
|
||||
local m,e = frexp(v)
|
||||
res[nres+1] = "^F"
|
||||
res[nres+2] = format("%.0f",m*2^53) -- force mantissa to become integer (it's originally 0.5--0.9999)
|
||||
res[nres+3] = "^f"
|
||||
res[nres+4] = tostring(e-53) -- adjust exponent to counteract mantissa manipulation
|
||||
nres=nres+4
|
||||
end
|
||||
|
||||
elseif t=="table" then -- ^T...^t = table (list of key,value pairs)
|
||||
nres=nres+1
|
||||
res[nres] = "^T"
|
||||
for key,value in pairs(v) do
|
||||
nres = SerializeValue(key, res, nres)
|
||||
nres = SerializeValue(value, res, nres)
|
||||
end
|
||||
nres=nres+1
|
||||
res[nres] = "^t"
|
||||
|
||||
elseif t=="boolean" then -- ^B = true, ^b = false
|
||||
nres=nres+1
|
||||
if v then
|
||||
res[nres] = "^B" -- true
|
||||
else
|
||||
res[nres] = "^b" -- false
|
||||
end
|
||||
|
||||
elseif t=="nil" then -- ^Z = nil (zero, "N" was taken :P)
|
||||
nres=nres+1
|
||||
res[nres] = "^Z"
|
||||
|
||||
else
|
||||
error(MAJOR..": Cannot serialize a value of type '"..t.."'") -- can't produce error on right level, this is wildly recursive
|
||||
end
|
||||
|
||||
return nres
|
||||
end
|
||||
|
||||
|
||||
|
||||
local serializeTbl = { "^1" } -- "^1" = Hi, I'm data serialized by AceSerializer protocol rev 1
|
||||
|
||||
--- Serialize the data passed into the function.
|
||||
-- Takes a list of values (strings, numbers, booleans, nils, tables)
|
||||
-- and returns it in serialized form (a string).\\
|
||||
-- May throw errors on invalid data types.
|
||||
-- @param ... List of values to serialize
|
||||
-- @return The data in its serialized form (string)
|
||||
function AceSerializer:Serialize(...)
|
||||
local nres = 1
|
||||
|
||||
for i=1,select("#", ...) do
|
||||
local v = select(i, ...)
|
||||
nres = SerializeValue(v, serializeTbl, nres)
|
||||
end
|
||||
|
||||
serializeTbl[nres+1] = "^^" -- "^^" = End of serialized data
|
||||
|
||||
return tconcat(serializeTbl, "", 1, nres+1)
|
||||
end
|
||||
|
||||
-- Deserialization functions
|
||||
local function DeserializeStringHelper(escape)
|
||||
if escape<"~\122" then
|
||||
return strchar(strbyte(escape,2,2)-64)
|
||||
elseif escape=="~\122" then -- v3 / ticket 115: special case encode since 30+64=94 ("^") - OOPS.
|
||||
return "\030"
|
||||
elseif escape=="~\123" then
|
||||
return "\127"
|
||||
elseif escape=="~\124" then
|
||||
return "\126"
|
||||
elseif escape=="~\125" then
|
||||
return "\94"
|
||||
end
|
||||
error("DeserializeStringHelper got called for '"..escape.."'?!?") -- can't be reached unless regex is screwed up
|
||||
end
|
||||
|
||||
local function DeserializeNumberHelper(number)
|
||||
if number == serNaN then
|
||||
return 0/0
|
||||
elseif number == serNegInf or number == serNegInfMac then
|
||||
return -inf
|
||||
elseif number == serInf or number == serInfMac then
|
||||
return inf
|
||||
else
|
||||
return tonumber(number)
|
||||
end
|
||||
end
|
||||
|
||||
-- DeserializeValue: worker function for :Deserialize()
|
||||
-- It works in two modes:
|
||||
-- Main (top-level) mode: Deserialize a list of values and return them all
|
||||
-- Recursive (table) mode: Deserialize only a single value (_may_ of course be another table with lots of subvalues in it)
|
||||
--
|
||||
-- The function _always_ works recursively due to having to build a list of values to return
|
||||
--
|
||||
-- Callers are expected to pcall(DeserializeValue) to trap errors
|
||||
|
||||
local function DeserializeValue(iter,single,ctl,data)
|
||||
|
||||
if not single then
|
||||
ctl,data = iter()
|
||||
end
|
||||
|
||||
if not ctl then
|
||||
error("Supplied data misses AceSerializer terminator ('^^')")
|
||||
end
|
||||
|
||||
if ctl=="^^" then
|
||||
-- ignore extraneous data
|
||||
return
|
||||
end
|
||||
|
||||
local res
|
||||
|
||||
if ctl=="^S" then
|
||||
res = gsub(data, "~.", DeserializeStringHelper)
|
||||
elseif ctl=="^N" then
|
||||
res = DeserializeNumberHelper(data)
|
||||
if not res then
|
||||
error("Invalid serialized number: '"..tostring(data).."'")
|
||||
end
|
||||
elseif ctl=="^F" then -- ^F<mantissa>^f<exponent>
|
||||
local ctl2,e = iter()
|
||||
if ctl2~="^f" then
|
||||
error("Invalid serialized floating-point number, expected '^f', not '"..tostring(ctl2).."'")
|
||||
end
|
||||
local m=tonumber(data)
|
||||
e=tonumber(e)
|
||||
if not (m and e) then
|
||||
error("Invalid serialized floating-point number, expected mantissa and exponent, got '"..tostring(m).."' and '"..tostring(e).."'")
|
||||
end
|
||||
res = m*(2^e)
|
||||
elseif ctl=="^B" then -- yeah yeah ignore data portion
|
||||
res = true
|
||||
elseif ctl=="^b" then -- yeah yeah ignore data portion
|
||||
res = false
|
||||
elseif ctl=="^Z" then -- yeah yeah ignore data portion
|
||||
res = nil
|
||||
elseif ctl=="^T" then
|
||||
-- ignore ^T's data, future extensibility?
|
||||
res = {}
|
||||
local k,v
|
||||
while true do
|
||||
ctl,data = iter()
|
||||
if ctl=="^t" then break end -- ignore ^t's data
|
||||
k = DeserializeValue(iter,true,ctl,data)
|
||||
if k==nil then
|
||||
error("Invalid AceSerializer table format (no table end marker)")
|
||||
end
|
||||
ctl,data = iter()
|
||||
v = DeserializeValue(iter,true,ctl,data)
|
||||
if v==nil then
|
||||
error("Invalid AceSerializer table format (no table end marker)")
|
||||
end
|
||||
res[k]=v
|
||||
end
|
||||
else
|
||||
error("Invalid AceSerializer control code '"..ctl.."'")
|
||||
end
|
||||
|
||||
if not single then
|
||||
return res,DeserializeValue(iter)
|
||||
else
|
||||
return res
|
||||
end
|
||||
end
|
||||
|
||||
--- Deserializes the data into its original values.
|
||||
-- Accepts serialized data, ignoring all control characters and whitespace.
|
||||
-- @param str The serialized data (from :Serialize)
|
||||
-- @return true followed by a list of values, OR false followed by an error message
|
||||
function AceSerializer:Deserialize(str)
|
||||
str = gsub(str, "[%c ]", "") -- ignore all control characters; nice for embedding in email and stuff
|
||||
|
||||
local iter = gmatch(str, "(^.)([^^]*)") -- Any ^x followed by string of non-^
|
||||
local ctl,data = iter()
|
||||
if not ctl or ctl~="^1" then
|
||||
-- we purposefully ignore the data portion of the start code, it can be used as an extension mechanism
|
||||
return false, "Supplied data is not AceSerializer data (rev 1)"
|
||||
end
|
||||
|
||||
return pcall(DeserializeValue, iter)
|
||||
end
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Base library stuff
|
||||
----------------------------------------
|
||||
|
||||
AceSerializer.internals = { -- for test scripts
|
||||
SerializeValue = SerializeValue,
|
||||
SerializeStringHelper = SerializeStringHelper,
|
||||
}
|
||||
|
||||
local mixins = {
|
||||
"Serialize",
|
||||
"Deserialize",
|
||||
}
|
||||
|
||||
AceSerializer.embeds = AceSerializer.embeds or {}
|
||||
|
||||
function AceSerializer:Embed(target)
|
||||
for k, v in pairs(mixins) do
|
||||
target[v] = self[v]
|
||||
end
|
||||
self.embeds[target] = true
|
||||
return target
|
||||
end
|
||||
|
||||
-- Update embeds
|
||||
for target, v in pairs(AceSerializer.embeds) do
|
||||
AceSerializer:Embed(target)
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="AceSerializer-3.0.lua"/>
|
||||
</Ui>
|
||||
@@ -1,327 +0,0 @@
|
||||
--- **AceTimer-3.0** provides a central facility for registering timers.
|
||||
-- AceTimer supports one-shot timers and repeating timers. All timers are stored in an efficient
|
||||
-- data structure that allows easy dispatching and fast rescheduling. Timers can be registered
|
||||
-- or canceled at any time, even from within a running timer, without conflict or large overhead.\\
|
||||
-- AceTimer is currently limited to firing timers at a frequency of 0.01s.
|
||||
--
|
||||
-- All `:Schedule` functions will return a handle to the current timer, which you will need to store if you
|
||||
-- need to cancel the timer you just registered.
|
||||
--
|
||||
-- **AceTimer-3.0** can be embeded into your addon, either explicitly by calling AceTimer:Embed(MyAddon) or by
|
||||
-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
|
||||
-- and can be accessed directly, without having to explicitly call AceTimer itself.\\
|
||||
-- It is recommended to embed AceTimer, otherwise you'll have to specify a custom `self` on all calls you
|
||||
-- make into AceTimer.
|
||||
-- @class file
|
||||
-- @name AceTimer-3.0
|
||||
-- @release $Id$
|
||||
|
||||
local MAJOR, MINOR = "AceTimer-3.0", 1017 -- Bump minor on changes
|
||||
local AceTimer, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not AceTimer then return end -- No upgrade needed
|
||||
AceTimer.frame = AceTimer.frame or CreateFrame("Frame", "AceTimer30Frame")
|
||||
AceTimer.activeTimers = AceTimer.activeTimers or {} -- Active timer list
|
||||
local activeTimers = AceTimer.activeTimers -- Upvalue our private data
|
||||
|
||||
-- Lua APIs
|
||||
local assert, loadstring, rawset, tconcat = assert, loadstring, rawset, table.concat
|
||||
local type, unpack, next, error, select = type, unpack, next, error, select
|
||||
-- WoW APIs
|
||||
local GetTime = GetTime
|
||||
|
||||
--[[
|
||||
xpcall safecall implementation
|
||||
]]
|
||||
local xpcall = xpcall
|
||||
|
||||
local function errorhandler(err)
|
||||
return geterrorhandler()(err)
|
||||
end
|
||||
|
||||
local function CreateDispatcher(argCount)
|
||||
local code = [[
|
||||
local xpcall, eh = ...
|
||||
local method, ARGS
|
||||
local function call() return method(ARGS) end
|
||||
|
||||
local function dispatch(func, ...)
|
||||
method = func
|
||||
if not method then return end
|
||||
ARGS = ...
|
||||
return xpcall(call, eh)
|
||||
end
|
||||
|
||||
return dispatch
|
||||
]]
|
||||
|
||||
local ARGS = {}
|
||||
for i = 1, argCount do ARGS[i] = "arg"..i end
|
||||
code = code:gsub("ARGS", tconcat(ARGS, ", "))
|
||||
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
|
||||
end
|
||||
|
||||
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
|
||||
local dispatcher = CreateDispatcher(argCount)
|
||||
rawset(self, argCount, dispatcher)
|
||||
return dispatcher
|
||||
end})
|
||||
Dispatchers[0] = function(func)
|
||||
return xpcall(func, errorhandler)
|
||||
end
|
||||
|
||||
local function safecall(func, ...)
|
||||
return Dispatchers[select("#", ...)](func, ...)
|
||||
end
|
||||
|
||||
local function new(self, loop, func, delay, ...)
|
||||
if delay < 0.01 then
|
||||
delay = 0.01 -- Restrict to the lowest time
|
||||
end
|
||||
|
||||
local timer = {
|
||||
object = self,
|
||||
func = func,
|
||||
looping = loop,
|
||||
argsCount = select("#", ...),
|
||||
delay = delay,
|
||||
timeleft = delay,
|
||||
ends = GetTime() + delay,
|
||||
...
|
||||
}
|
||||
|
||||
activeTimers[timer] = timer
|
||||
|
||||
return timer
|
||||
end
|
||||
|
||||
--- Schedule a new one-shot timer.
|
||||
-- The timer will fire once in `delay` seconds, unless canceled before.
|
||||
-- @param callback Callback function for the timer pulse (funcref or method name).
|
||||
-- @param delay Delay for the timer, in seconds.
|
||||
-- @param ... An optional, unlimited amount of arguments to pass to the callback function.
|
||||
-- @usage
|
||||
-- MyAddOn = LibStub("AceAddon-3.0"):NewAddon("MyAddOn", "AceTimer-3.0")
|
||||
--
|
||||
-- function MyAddOn:OnEnable()
|
||||
-- self:ScheduleTimer("TimerFeedback", 5)
|
||||
-- end
|
||||
--
|
||||
-- function MyAddOn:TimerFeedback()
|
||||
-- print("5 seconds passed")
|
||||
-- end
|
||||
function AceTimer:ScheduleTimer(func, delay, ...)
|
||||
if not func or not delay then
|
||||
error(MAJOR..": ScheduleTimer(callback, delay, args...): 'callback' and 'delay' must have set values.", 2)
|
||||
end
|
||||
if type(func) == "string" then
|
||||
if type(self) ~= "table" then
|
||||
error(MAJOR..": ScheduleTimer(callback, delay, args...): 'self' - must be a table.", 2)
|
||||
elseif not self[func] then
|
||||
error(MAJOR..": ScheduleTimer(callback, delay, args...): Tried to register '"..func.."' as the callback, but it doesn't exist in the module.", 2)
|
||||
end
|
||||
end
|
||||
return new(self, nil, func, delay, ...)
|
||||
end
|
||||
|
||||
--- Schedule a repeating timer.
|
||||
-- The timer will fire every `delay` seconds, until canceled.
|
||||
-- @param callback Callback function for the timer pulse (funcref or method name).
|
||||
-- @param delay Delay for the timer, in seconds.
|
||||
-- @param ... An optional, unlimited amount of arguments to pass to the callback function.
|
||||
-- @usage
|
||||
-- MyAddOn = LibStub("AceAddon-3.0"):NewAddon("MyAddOn", "AceTimer-3.0")
|
||||
--
|
||||
-- function MyAddOn:OnEnable()
|
||||
-- self.timerCount = 0
|
||||
-- self.testTimer = self:ScheduleRepeatingTimer("TimerFeedback", 5)
|
||||
-- end
|
||||
--
|
||||
-- function MyAddOn:TimerFeedback()
|
||||
-- self.timerCount = self.timerCount + 1
|
||||
-- print(("%d seconds passed"):format(5 * self.timerCount))
|
||||
-- -- run 30 seconds in total
|
||||
-- if self.timerCount == 6 then
|
||||
-- self:CancelTimer(self.testTimer)
|
||||
-- end
|
||||
-- end
|
||||
function AceTimer:ScheduleRepeatingTimer(func, delay, ...)
|
||||
if not func or not delay then
|
||||
error(MAJOR..": ScheduleRepeatingTimer(callback, delay, args...): 'callback' and 'delay' must have set values.", 2)
|
||||
end
|
||||
if type(func) == "string" then
|
||||
if type(self) ~= "table" then
|
||||
error(MAJOR..": ScheduleRepeatingTimer(callback, delay, args...): 'self' - must be a table.", 2)
|
||||
elseif not self[func] then
|
||||
error(MAJOR..": ScheduleRepeatingTimer(callback, delay, args...): Tried to register '"..func.."' as the callback, but it doesn't exist in the module.", 2)
|
||||
end
|
||||
end
|
||||
return new(self, true, func, delay, ...)
|
||||
end
|
||||
|
||||
--- Cancels a timer with the given id, registered by the same addon object as used for `:ScheduleTimer`
|
||||
-- Both one-shot and repeating timers can be canceled with this function, as long as the `id` is valid
|
||||
-- and the timer has not fired yet or was canceled before.
|
||||
-- @param id The id of the timer, as returned by `:ScheduleTimer` or `:ScheduleRepeatingTimer`
|
||||
function AceTimer:CancelTimer(id)
|
||||
local timer = activeTimers[id]
|
||||
|
||||
if not timer then
|
||||
return false
|
||||
else
|
||||
timer.cancelled = true
|
||||
activeTimers[id] = nil
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
--- Cancels all timers registered to the current addon object ('self')
|
||||
function AceTimer:CancelAllTimers()
|
||||
for k,v in next, activeTimers do
|
||||
if v.object == self then
|
||||
AceTimer.CancelTimer(self, k)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Returns the time left for a timer with the given id, registered by the current addon object ('self').
|
||||
-- This function will return 0 when the id is invalid.
|
||||
-- @param id The id of the timer, as returned by `:ScheduleTimer` or `:ScheduleRepeatingTimer`
|
||||
-- @return The time left on the timer.
|
||||
function AceTimer:TimeLeft(id)
|
||||
local timer = activeTimers[id]
|
||||
if not timer then
|
||||
return
|
||||
else
|
||||
return timer.ends - GetTime()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Upgrading
|
||||
|
||||
-- Upgrade from old hash-bucket based timers to C_Timer.After timers.
|
||||
if oldminor and oldminor < 10 then
|
||||
-- disable old timer logic
|
||||
AceTimer.frame:SetScript("OnUpdate", nil)
|
||||
AceTimer.frame:SetScript("OnEvent", nil)
|
||||
AceTimer.frame:UnregisterAllEvents()
|
||||
-- convert timers
|
||||
for object,timers in next, AceTimer.selfs do
|
||||
for handle,timer in next, timers do
|
||||
if type(timer) == "table" and timer.callback then
|
||||
local newTimer
|
||||
if timer.delay then
|
||||
newTimer = AceTimer.ScheduleRepeatingTimer(timer.object, timer.callback, timer.delay, timer.arg)
|
||||
else
|
||||
newTimer = AceTimer.ScheduleTimer(timer.object, timer.callback, timer.when - GetTime(), timer.arg)
|
||||
end
|
||||
-- Use the old handle for old timers
|
||||
activeTimers[newTimer] = nil
|
||||
activeTimers[handle] = newTimer
|
||||
newTimer.handle = handle
|
||||
end
|
||||
end
|
||||
end
|
||||
AceTimer.selfs = nil
|
||||
AceTimer.hash = nil
|
||||
AceTimer.debug = nil
|
||||
elseif oldminor and oldminor < 17 then
|
||||
-- Upgrade from old animation based timers to C_Timer.After timers.
|
||||
AceTimer.inactiveTimers = nil
|
||||
local oldTimers = AceTimer.activeTimers
|
||||
-- Clear old timer table and update upvalue
|
||||
AceTimer.activeTimers = {}
|
||||
activeTimers = AceTimer.activeTimers
|
||||
for handle, timer in next, oldTimers do
|
||||
local newTimer
|
||||
-- Stop the old timer animation
|
||||
local duration, elapsed = timer:GetDuration(), timer:GetElapsed()
|
||||
timer:GetParent():Stop()
|
||||
if timer.looping then
|
||||
newTimer = AceTimer.ScheduleRepeatingTimer(timer.object, timer.func, duration, unpack(timer.args, 1, timer.argsCount))
|
||||
else
|
||||
newTimer = AceTimer.ScheduleTimer(timer.object, timer.func, duration - elapsed, unpack(timer.args, 1, timer.argsCount))
|
||||
end
|
||||
-- Use the old handle for old timers
|
||||
activeTimers[newTimer] = nil
|
||||
activeTimers[handle] = newTimer
|
||||
newTimer.handle = handle
|
||||
end
|
||||
|
||||
-- Migrate transitional handles
|
||||
if oldminor < 13 and AceTimer.hashCompatTable then
|
||||
for handle, id in next, AceTimer.hashCompatTable do
|
||||
local t = activeTimers[id]
|
||||
if t then
|
||||
activeTimers[id] = nil
|
||||
activeTimers[handle] = t
|
||||
t.handle = handle
|
||||
end
|
||||
end
|
||||
AceTimer.hashCompatTable = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Embed handling
|
||||
|
||||
AceTimer.embeds = AceTimer.embeds or {}
|
||||
|
||||
local mixins = {
|
||||
"ScheduleTimer", "ScheduleRepeatingTimer",
|
||||
"CancelTimer", "CancelAllTimers",
|
||||
"TimeLeft"
|
||||
}
|
||||
|
||||
function AceTimer:Embed(target)
|
||||
AceTimer.embeds[target] = true
|
||||
for _,v in next, mixins do
|
||||
target[v] = AceTimer[v]
|
||||
end
|
||||
return target
|
||||
end
|
||||
|
||||
-- AceTimer:OnEmbedDisable(target)
|
||||
-- target (object) - target object that AceTimer is embedded in.
|
||||
--
|
||||
-- cancel all timers registered for the object
|
||||
function AceTimer:OnEmbedDisable(target)
|
||||
target:CancelAllTimers()
|
||||
end
|
||||
|
||||
for addon in next, AceTimer.embeds do
|
||||
AceTimer:Embed(addon)
|
||||
end
|
||||
|
||||
AceTimer.frame:SetScript("OnUpdate", function(self, elapsed)
|
||||
for _, timer in next, activeTimers do
|
||||
if not timer.cancelled then
|
||||
if timer.timeleft > elapsed then
|
||||
timer.timeleft = timer.timeleft - elapsed
|
||||
else
|
||||
if type(timer.func) == "string" then
|
||||
-- We manually set the unpack count to prevent issues with an arg set that contains nil and ends with nil
|
||||
-- e.g. local t = {1, 2, nil, 3, nil} print(#t) will result in 2, instead of 5. This fixes said issue.
|
||||
safecall(timer.object[timer.func], timer.object, unpack(timer, 1, timer.argsCount))
|
||||
else
|
||||
safecall(timer.func, unpack(timer, 1, timer.argsCount))
|
||||
end
|
||||
|
||||
if timer.looping and not timer.cancelled then
|
||||
-- Compensate delay to get a perfect average delay, even if individual times don't match up perfectly
|
||||
-- due to fps differences
|
||||
local time = GetTime()
|
||||
local delay = timer.delay - (time - timer.ends)
|
||||
-- Ensure the delay doesn't go below the threshold
|
||||
if delay < 0.01 then delay = 0.01 end
|
||||
timer.ends = time + delay
|
||||
timer.timeleft = timer.delay
|
||||
else
|
||||
activeTimers[timer.handle or timer] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -1,4 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="AceTimer-3.0.lua"/>
|
||||
</Ui>
|
||||
@@ -1,238 +0,0 @@
|
||||
--[[ $Id: CallbackHandler-1.0.lua 18 2014-10-16 02:52:20Z mikk $ ]]
|
||||
local MAJOR, MINOR = "CallbackHandler-1.0", 6
|
||||
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not CallbackHandler then return end -- No upgrade needed
|
||||
|
||||
local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
|
||||
|
||||
-- Lua APIs
|
||||
local tconcat = table.concat
|
||||
local assert, error, loadstring = assert, error, loadstring
|
||||
local setmetatable, rawset, rawget = setmetatable, rawset, rawget
|
||||
local next, select, pairs, type, tostring = next, select, pairs, type, tostring
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: geterrorhandler
|
||||
|
||||
local xpcall = xpcall
|
||||
|
||||
local function errorhandler(err)
|
||||
return geterrorhandler()(err)
|
||||
end
|
||||
|
||||
local function CreateDispatcher(argCount)
|
||||
local code = [[
|
||||
local next, xpcall, eh = ...
|
||||
|
||||
local method, ARGS
|
||||
local function call() method(ARGS) end
|
||||
|
||||
local function dispatch(handlers, ...)
|
||||
local index
|
||||
index, method = next(handlers)
|
||||
if not method then return end
|
||||
local OLD_ARGS = ARGS
|
||||
ARGS = ...
|
||||
repeat
|
||||
xpcall(call, eh)
|
||||
index, method = next(handlers, index)
|
||||
until not method
|
||||
ARGS = OLD_ARGS
|
||||
end
|
||||
|
||||
return dispatch
|
||||
]]
|
||||
|
||||
local ARGS, OLD_ARGS = {}, {}
|
||||
for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
|
||||
code = code:gsub("OLD_ARGS", tconcat(OLD_ARGS, ", ")):gsub("ARGS", tconcat(ARGS, ", "))
|
||||
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
|
||||
end
|
||||
|
||||
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
|
||||
local dispatcher = CreateDispatcher(argCount)
|
||||
rawset(self, argCount, dispatcher)
|
||||
return dispatcher
|
||||
end})
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
-- CallbackHandler:New
|
||||
--
|
||||
-- target - target object to embed public APIs in
|
||||
-- RegisterName - name of the callback registration API, default "RegisterCallback"
|
||||
-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback"
|
||||
-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
|
||||
|
||||
function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName)
|
||||
|
||||
RegisterName = RegisterName or "RegisterCallback"
|
||||
UnregisterName = UnregisterName or "UnregisterCallback"
|
||||
if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
|
||||
UnregisterAllName = "UnregisterAllCallbacks"
|
||||
end
|
||||
|
||||
-- we declare all objects and exported APIs inside this closure to quickly gain access
|
||||
-- to e.g. function names, the "target" parameter, etc
|
||||
|
||||
|
||||
-- Create the registry object
|
||||
local events = setmetatable({}, meta)
|
||||
local registry = { recurse=0, events=events }
|
||||
|
||||
-- registry:Fire() - fires the given event/message into the registry
|
||||
function registry:Fire(eventname, ...)
|
||||
if not rawget(events, eventname) or not next(events[eventname]) then return end
|
||||
local oldrecurse = registry.recurse
|
||||
registry.recurse = oldrecurse + 1
|
||||
|
||||
Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...)
|
||||
|
||||
registry.recurse = oldrecurse
|
||||
|
||||
if registry.insertQueue and oldrecurse==0 then
|
||||
-- Something in one of our callbacks wanted to register more callbacks; they got queued
|
||||
for eventname,callbacks in pairs(registry.insertQueue) do
|
||||
local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
|
||||
for self,func in pairs(callbacks) do
|
||||
events[eventname][self] = func
|
||||
-- fire OnUsed callback?
|
||||
if first and registry.OnUsed then
|
||||
registry.OnUsed(registry, target, eventname)
|
||||
first = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
registry.insertQueue = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Registration of a callback, handles:
|
||||
-- self["method"], leads to self["method"](self, ...)
|
||||
-- self with function ref, leads to functionref(...)
|
||||
-- "addonId" (instead of self) with function ref, leads to functionref(...)
|
||||
-- all with an optional arg, which, if present, gets passed as first argument (after self if present)
|
||||
target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]])
|
||||
if type(eventname) ~= "string" then
|
||||
error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2)
|
||||
end
|
||||
|
||||
method = method or eventname
|
||||
|
||||
local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
|
||||
|
||||
if type(method) ~= "string" and type(method) ~= "function" then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2)
|
||||
end
|
||||
|
||||
local regfunc
|
||||
|
||||
if type(method) == "string" then
|
||||
-- self["method"] calling style
|
||||
if type(self) ~= "table" then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2)
|
||||
elseif self==target then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2)
|
||||
elseif type(self[method]) ~= "function" then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2)
|
||||
end
|
||||
|
||||
if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
|
||||
local arg=select(1,...)
|
||||
regfunc = function(...) self[method](self,arg,...) end
|
||||
else
|
||||
regfunc = function(...) self[method](self,...) end
|
||||
end
|
||||
else
|
||||
-- function ref with self=object or self="addonId" or self=thread
|
||||
if type(self)~="table" and type(self)~="string" and type(self)~="thread" then
|
||||
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2)
|
||||
end
|
||||
|
||||
if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
|
||||
local arg=select(1,...)
|
||||
regfunc = function(...) method(arg,...) end
|
||||
else
|
||||
regfunc = method
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if events[eventname][self] or registry.recurse<1 then
|
||||
-- if registry.recurse<1 then
|
||||
-- we're overwriting an existing entry, or not currently recursing. just set it.
|
||||
events[eventname][self] = regfunc
|
||||
-- fire OnUsed callback?
|
||||
if registry.OnUsed and first then
|
||||
registry.OnUsed(registry, target, eventname)
|
||||
end
|
||||
else
|
||||
-- we're currently processing a callback in this registry, so delay the registration of this new entry!
|
||||
-- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency
|
||||
registry.insertQueue = registry.insertQueue or setmetatable({},meta)
|
||||
registry.insertQueue[eventname][self] = regfunc
|
||||
end
|
||||
end
|
||||
|
||||
-- Unregister a callback
|
||||
target[UnregisterName] = function(self, eventname)
|
||||
if not self or self==target then
|
||||
error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2)
|
||||
end
|
||||
if type(eventname) ~= "string" then
|
||||
error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2)
|
||||
end
|
||||
if rawget(events, eventname) and events[eventname][self] then
|
||||
events[eventname][self] = nil
|
||||
-- Fire OnUnused callback?
|
||||
if registry.OnUnused and not next(events[eventname]) then
|
||||
registry.OnUnused(registry, target, eventname)
|
||||
end
|
||||
end
|
||||
if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
|
||||
registry.insertQueue[eventname][self] = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- OPTIONAL: Unregister all callbacks for given selfs/addonIds
|
||||
if UnregisterAllName then
|
||||
target[UnregisterAllName] = function(...)
|
||||
if select("#",...)<1 then
|
||||
error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2)
|
||||
end
|
||||
if select("#",...)==1 and ...==target then
|
||||
error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2)
|
||||
end
|
||||
|
||||
|
||||
for i=1,select("#",...) do
|
||||
local self = select(i,...)
|
||||
if registry.insertQueue then
|
||||
for eventname, callbacks in pairs(registry.insertQueue) do
|
||||
if callbacks[self] then
|
||||
callbacks[self] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
for eventname, callbacks in pairs(events) do
|
||||
if callbacks[self] then
|
||||
callbacks[self] = nil
|
||||
-- Fire OnUnused callback?
|
||||
if registry.OnUnused and not next(callbacks) then
|
||||
registry.OnUnused(registry, target, eventname)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return registry
|
||||
end
|
||||
|
||||
|
||||
-- CallbackHandler purposefully does NOT do explicit embedding. Nor does it
|
||||
-- try to upgrade old implicit embeds since the system is selfcontained and
|
||||
-- relies on closures to work.
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="CallbackHandler-1.0.lua"/>
|
||||
</Ui>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +0,0 @@
|
||||
## Interface: 90002
|
||||
|
||||
## Title: Lib: Compress
|
||||
## Notes: Compression and Decompression library
|
||||
## Author: Galmok at Stormrage-EU (Horde) and JJSheets
|
||||
## Version: r86-release
|
||||
## X-Website: http://www.wowace.com/addons/libcompress/
|
||||
## X-Category: Library
|
||||
## X-eMail: galmok AT gmail DOT com, sheets DOT jeff AT gmail DOT com
|
||||
## X-License: GPL v2
|
||||
## LoadOnDemand: 1
|
||||
|
||||
LibStub\LibStub.lua
|
||||
lib.xml
|
||||
@@ -1,4 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="LibCompress.lua" />
|
||||
</Ui>
|
||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
||||
## Interface: 80200
|
||||
## Title: Lib: CustomGlow
|
||||
## Notes: Creates custom glow functions
|
||||
## Author: deezo
|
||||
## X-Category: Library
|
||||
## X-License: BSD
|
||||
## Version: 1.0.3
|
||||
## OptionalDeps: Masque
|
||||
|
||||
LibStub\LibStub.lua
|
||||
|
||||
LibCustomGlow-1.0.xml
|
||||
@@ -1,4 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file = "LibCustomGlow-1.0.lua"/>
|
||||
</Ui>
|
||||
@@ -1,52 +0,0 @@
|
||||
Adds functions:
|
||||
|
||||
PixelGlow_Start(frame[, color[, N[, frequency[, length[, th[, xOffset[, yOffset[, border[ ,key]]]]]]]])
|
||||
|
||||
Starts glow over target frame with set parameters:
|
||||
|
||||
frame - target frame to set glowing;
|
||||
color - {r,g,b,a}, color of lines and opacity, from 0 to 1. Defaul value is {0.95, 0.95, 0.32, 1};
|
||||
N - number of lines. Defaul value is 8;
|
||||
frequency - frequency, set to negative to inverse direction of rotation. Default value is 0.25;
|
||||
length - length of lines. Default value depends on region size and number of lines;
|
||||
th - thickness of lines. Default value is 2;
|
||||
xOffset,yOffset - offset of glow relative to region border;
|
||||
border - set to true to create border under lines;
|
||||
key - key of glow, allows for multiple glows on one frame;
|
||||
PixelGlow_Stop(frame[, key])
|
||||
|
||||
Stops glow with set key over target frame
|
||||
|
||||
|
||||
|
||||
AutoCastGlow_Start(frame[, color[, N[, frequency[, scale[, xOffset[, yOffset[, key]]]]]]])
|
||||
|
||||
Starts glow over target frame with set parameters:
|
||||
|
||||
frame - target frame to set glowing;
|
||||
color - {r,g,b,a}, color of particles and opacity, from 0 to 1. Defaul value is {0.95, 0.95, 0.32, 1};
|
||||
N - number of particle groups. Each group contains 4 particles. Defaul value is 4;
|
||||
frequency - frequency, set to negative to inverse direction of rotation. Default value is 0.125;
|
||||
scale - scale of particles;
|
||||
xOffset,yOffset - offset of glow relative to region border;
|
||||
key - key of glow, allows for multiple glows on one frame;
|
||||
AutoCastGlow_Stop(frame[, key])
|
||||
|
||||
Stops glow with set key over target frame
|
||||
|
||||
|
||||
|
||||
Blizzard glow is based heavily on https://www.wowace.com/projects/libbuttonglow-1-0
|
||||
|
||||
ButtonGlow_Start(frame[, color[, frequency]]])
|
||||
|
||||
Starts glow over target frame with set parameters:
|
||||
|
||||
frame - target frame to set glowing;
|
||||
color - {r,g,b,a}, color of particles and opacity, from 0 to 1. Defaul value is {0.95, 0.95, 0.32, 1};
|
||||
frequency - frequency. Default value is 0.125;
|
||||
ButtonGlow_Stop(frame)
|
||||
|
||||
Stops glow over target frame
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,300 +0,0 @@
|
||||
--[[
|
||||
Name: DBIcon-1.0
|
||||
Revision: $Rev: 15 $
|
||||
Author(s): Rabbit (rabbit.magtheridon@gmail.com)
|
||||
Description: Allows addons to register to recieve a lightweight minimap icon as an alternative to more heavy LDB displays.
|
||||
Dependencies: LibStub
|
||||
License: GPL v2 or later.
|
||||
]]
|
||||
|
||||
--[[
|
||||
Copyright (C) 2008-2010 Rabbit
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
]]
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- DBIcon-1.0
|
||||
--
|
||||
-- Disclaimer: Most of this code was ripped from Barrel but fixed, streamlined
|
||||
-- and cleaned up a lot so that it no longer sucks.
|
||||
--
|
||||
|
||||
local DBICON10 = "LibDBIcon-1.0"
|
||||
local DBICON10_MINOR = tonumber(("$Rev: 21 $"):match("(%d+)"))
|
||||
if not LibStub then error(DBICON10 .. " requires LibStub.") end
|
||||
local ldb = LibStub("LibDataBroker-1.1", true)
|
||||
if not ldb then error(DBICON10 .. " requires LibDataBroker-1.1.") end
|
||||
local lib, oldminor = LibStub:NewLibrary(DBICON10, DBICON10_MINOR)
|
||||
if not lib then return end
|
||||
|
||||
lib.disabled = lib.disabled or nil
|
||||
lib.objects = lib.objects or {}
|
||||
lib.callbackRegistered = lib.callbackRegistered or nil
|
||||
lib.notCreated = lib.notCreated or {}
|
||||
|
||||
function lib:IconCallback(event, name, key, value, dataobj)
|
||||
if lib.objects[name] then
|
||||
if key == "icon" then
|
||||
lib.objects[name].icon:SetTexture(dataobj and dataobj.icon or value)
|
||||
elseif key == "iconCoords" then
|
||||
lib.objects[name].icon:UpdateCoord()
|
||||
elseif key == "iconR" then
|
||||
local _, g, b = lib.objects[name].icon:GetVertexColor()
|
||||
lib.objects[name].icon:SetVertexColor(value, g, b)
|
||||
elseif key == "iconG" then
|
||||
local r, _, b = lib.objects[name].icon:GetVertexColor()
|
||||
lib.objects[name].icon:SetVertexColor(r, value, b)
|
||||
elseif key == "iconB" then
|
||||
local r, g = lib.objects[name].icon:GetVertexColor()
|
||||
lib.objects[name].icon:SetVertexColor(r, g, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if oldminor and oldminor < 21 then
|
||||
if not lib.newCallbackRegistered then
|
||||
ldb.RegisterCallback(lib, "LibDataBroker_AttributeChanged__iconCoords", "IconCallback")
|
||||
ldb.RegisterCallback(lib, "LibDataBroker_AttributeChanged__iconR", "IconCallback")
|
||||
ldb.RegisterCallback(lib, "LibDataBroker_AttributeChanged__iconG", "IconCallback")
|
||||
ldb.RegisterCallback(lib, "LibDataBroker_AttributeChanged__iconB", "IconCallback")
|
||||
lib.newCallbackRegistered = true
|
||||
end
|
||||
end
|
||||
|
||||
if not lib.callbackRegistered then
|
||||
ldb.RegisterCallback(lib, "LibDataBroker_AttributeChanged__icon", "IconCallback")
|
||||
lib.callbackRegistered = true
|
||||
end
|
||||
|
||||
-- Tooltip code ripped from StatBlockCore by Funkydude
|
||||
local function getAnchors(frame)
|
||||
local x, y = frame:GetCenter()
|
||||
if not x or not y then return "CENTER" end
|
||||
local hhalf = (x > UIParent:GetWidth()*2/3) and "RIGHT" or (x < UIParent:GetWidth()/3) and "LEFT" or ""
|
||||
local vhalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM"
|
||||
return vhalf..hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf
|
||||
end
|
||||
|
||||
local function onEnter(self)
|
||||
if self.isMoving then return end
|
||||
local obj = self.dataObject
|
||||
if obj.OnTooltipShow then
|
||||
GameTooltip:SetOwner(self, "ANCHOR_NONE")
|
||||
GameTooltip:SetPoint(getAnchors(self))
|
||||
obj.OnTooltipShow(GameTooltip)
|
||||
GameTooltip:Show()
|
||||
elseif obj.OnEnter then
|
||||
obj.OnEnter(self)
|
||||
end
|
||||
end
|
||||
|
||||
local function onLeave(self)
|
||||
local obj = self.dataObject
|
||||
GameTooltip:Hide()
|
||||
if obj.OnLeave then obj.OnLeave(self) end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local minimapShapes = {
|
||||
["ROUND"] = {true, true, true, true},
|
||||
["SQUARE"] = {false, false, false, false},
|
||||
["CORNER-TOPLEFT"] = {true, false, false, false},
|
||||
["CORNER-TOPRIGHT"] = {false, false, true, false},
|
||||
["CORNER-BOTTOMLEFT"] = {false, true, false, false},
|
||||
["CORNER-BOTTOMRIGHT"] = {false, false, false, true},
|
||||
["SIDE-LEFT"] = {true, true, false, false},
|
||||
["SIDE-RIGHT"] = {false, false, true, true},
|
||||
["SIDE-TOP"] = {true, false, true, false},
|
||||
["SIDE-BOTTOM"] = {false, true, false, true},
|
||||
["TRICORNER-TOPLEFT"] = {true, true, true, false},
|
||||
["TRICORNER-TOPRIGHT"] = {true, false, true, true},
|
||||
["TRICORNER-BOTTOMLEFT"] = {true, true, false, true},
|
||||
["TRICORNER-BOTTOMRIGHT"] = {false, true, true, true},
|
||||
}
|
||||
|
||||
local function updatePosition(button)
|
||||
local angle = math.rad(button.db and button.db.minimapPos or button.minimapPos or 225)
|
||||
local x, y, q = math.cos(angle), math.sin(angle), 1
|
||||
if x < 0 then q = q + 1 end
|
||||
if y > 0 then q = q + 2 end
|
||||
local minimapShape = GetMinimapShape and GetMinimapShape() or "ROUND"
|
||||
local quadTable = minimapShapes[minimapShape]
|
||||
if quadTable[q] then
|
||||
x, y = x*80, y*80
|
||||
else
|
||||
local diagRadius = 103.13708498985 --math.sqrt(2*(80)^2)-10
|
||||
x = math.max(-80, math.min(x*diagRadius, 80))
|
||||
y = math.max(-80, math.min(y*diagRadius, 80))
|
||||
end
|
||||
button:SetPoint("CENTER", Minimap, "CENTER", x, y)
|
||||
end
|
||||
|
||||
local function onClick(self, b) if self.dataObject.OnClick then self.dataObject.OnClick(self, b) end end
|
||||
local function onMouseDown(self) self.icon:SetTexCoord(0, 1, 0, 1) end
|
||||
local function onMouseUp(self) self.icon:SetTexCoord(0.05, 0.95, 0.05, 0.95) end
|
||||
|
||||
local function onUpdate(self)
|
||||
local mx, my = Minimap:GetCenter()
|
||||
local px, py = GetCursorPosition()
|
||||
local scale = Minimap:GetEffectiveScale()
|
||||
px, py = px / scale, py / scale
|
||||
if self.db then
|
||||
self.db.minimapPos = math.deg(math.atan2(py - my, px - mx)) % 360
|
||||
else
|
||||
self.minimapPos = math.deg(math.atan2(py - my, px - mx)) % 360
|
||||
end
|
||||
updatePosition(self)
|
||||
end
|
||||
|
||||
local function onDragStart(self)
|
||||
self:LockHighlight()
|
||||
self.icon:SetTexCoord(0, 1, 0, 1)
|
||||
self:SetScript("OnUpdate", onUpdate)
|
||||
self.isMoving = true
|
||||
GameTooltip:Hide()
|
||||
end
|
||||
|
||||
local function onDragStop(self)
|
||||
self:SetScript("OnUpdate", nil)
|
||||
self.icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
|
||||
self:UnlockHighlight()
|
||||
self.isMoving = nil
|
||||
end
|
||||
|
||||
local function createButton(name, object, db)
|
||||
local button = CreateFrame("Button", "LibDBIcon10_"..name, Minimap)
|
||||
button.dataObject = object
|
||||
button.db = db
|
||||
button:SetFrameStrata("MEDIUM")
|
||||
button:SetWidth(31); button:SetHeight(31)
|
||||
button:SetFrameLevel(8)
|
||||
button:RegisterForClicks("anyUp")
|
||||
button:RegisterForDrag("LeftButton")
|
||||
button:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight")
|
||||
local overlay = button:CreateTexture(nil, "OVERLAY")
|
||||
overlay:SetWidth(53); overlay:SetHeight(53)
|
||||
overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder")
|
||||
overlay:SetPoint("TOPLEFT")
|
||||
local background = button:CreateTexture(nil, "BACKGROUND")
|
||||
background:SetSize(20, 20)
|
||||
background:SetTexture("Interface\\Minimap\\UI-Minimap-Background")
|
||||
background:SetPoint("TOPLEFT", 7, -5)
|
||||
local icon = button:CreateTexture(nil, "ARTWORK")
|
||||
icon:SetWidth(20); icon:SetHeight(20)
|
||||
icon:SetTexture(object.icon)
|
||||
icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
|
||||
icon:SetPoint("TOPLEFT", 7, -5)
|
||||
button.icon = icon
|
||||
|
||||
button:SetScript("OnEnter", onEnter)
|
||||
button:SetScript("OnLeave", onLeave)
|
||||
button:SetScript("OnClick", onClick)
|
||||
button:SetScript("OnDragStart", onDragStart)
|
||||
button:SetScript("OnDragStop", onDragStop)
|
||||
button:SetScript("OnMouseDown", onMouseDown)
|
||||
button:SetScript("OnMouseUp", onMouseUp)
|
||||
|
||||
lib.objects[name] = button
|
||||
|
||||
if lib.loggedIn then
|
||||
updatePosition(button)
|
||||
if not db or not db.hide then button:Show()
|
||||
else button:Hide() end
|
||||
end
|
||||
end
|
||||
|
||||
-- We could use a metatable.__index on lib.objects, but then we'd create
|
||||
-- the icons when checking things like :IsRegistered, which is not necessary.
|
||||
local function check(name)
|
||||
if lib.notCreated[name] then
|
||||
createButton(name, lib.notCreated[name][1], lib.notCreated[name][2])
|
||||
lib.notCreated[name] = nil
|
||||
end
|
||||
end
|
||||
|
||||
lib.loggedIn = lib.loggedIn or false
|
||||
-- Wait a bit with the initial positioning to let any GetMinimapShape addons
|
||||
-- load up.
|
||||
if not lib.loggedIn then
|
||||
local f = CreateFrame("Frame")
|
||||
f:SetScript("OnEvent", function()
|
||||
for _, object in pairs(lib.objects) do
|
||||
updatePosition(object)
|
||||
if not lib.disabled and (not object.db or not object.db.hide) then object:Show()
|
||||
else object:Hide() end
|
||||
end
|
||||
lib.loggedIn = true
|
||||
f:SetScript("OnEvent", nil)
|
||||
f = nil
|
||||
end)
|
||||
f:RegisterEvent("PLAYER_LOGIN")
|
||||
end
|
||||
|
||||
function lib:Register(name, object, db)
|
||||
if lib.disabled then return end
|
||||
if not object.icon then error("Can't register LDB objects without icons set!") end
|
||||
if lib.objects[name] or lib.notCreated[name] then error("Already registered, nubcake.") end
|
||||
if not db or not db.hide then
|
||||
createButton(name, object, db)
|
||||
else
|
||||
lib.notCreated[name] = {object, db}
|
||||
end
|
||||
end
|
||||
|
||||
function lib:Hide(name)
|
||||
if not lib.objects[name] then return end
|
||||
lib.objects[name]:Hide()
|
||||
end
|
||||
function lib:Show(name)
|
||||
if lib.disabled then return end
|
||||
check(name)
|
||||
lib.objects[name]:Show()
|
||||
updatePosition(lib.objects[name])
|
||||
end
|
||||
function lib:IsRegistered(name)
|
||||
return (lib.objects[name] or lib.notCreated[name]) and true or false
|
||||
end
|
||||
function lib:Refresh(name, db)
|
||||
if lib.disabled then return end
|
||||
check(name)
|
||||
local button = lib.objects[name]
|
||||
if db then button.db = db end
|
||||
updatePosition(button)
|
||||
if not db or not db.hide then
|
||||
button:Show()
|
||||
else
|
||||
button:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function lib:EnableLibrary()
|
||||
lib.disabled = nil
|
||||
for name, object in pairs(lib.objects) do
|
||||
if not object.db or (object.db and not object.db.hide) then
|
||||
object:Show()
|
||||
updatePosition(object)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function lib:DisableLibrary()
|
||||
lib.disabled = true
|
||||
for name, object in pairs(lib.objects) do
|
||||
object:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
|
||||
assert(LibStub, "LibDataBroker-1.1 requires LibStub")
|
||||
assert(LibStub:GetLibrary("CallbackHandler-1.0", true), "LibDataBroker-1.1 requires CallbackHandler-1.0")
|
||||
|
||||
local lib, oldminor = LibStub:NewLibrary("LibDataBroker-1.1", 4)
|
||||
if not lib then return end
|
||||
oldminor = oldminor or 0
|
||||
|
||||
|
||||
lib.callbacks = lib.callbacks or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
|
||||
lib.attributestorage, lib.namestorage, lib.proxystorage = lib.attributestorage or {}, lib.namestorage or {}, lib.proxystorage or {}
|
||||
local attributestorage, namestorage, callbacks = lib.attributestorage, lib.namestorage, lib.callbacks
|
||||
|
||||
if oldminor < 2 then
|
||||
lib.domt = {
|
||||
__metatable = "access denied",
|
||||
__index = function(self, key) return attributestorage[self] and attributestorage[self][key] end,
|
||||
}
|
||||
end
|
||||
|
||||
if oldminor < 3 then
|
||||
lib.domt.__newindex = function(self, key, value)
|
||||
if not attributestorage[self] then attributestorage[self] = {} end
|
||||
if attributestorage[self][key] == value then return end
|
||||
attributestorage[self][key] = value
|
||||
local name = namestorage[self]
|
||||
if not name then return end
|
||||
callbacks:Fire("LibDataBroker_AttributeChanged", name, key, value, self)
|
||||
callbacks:Fire("LibDataBroker_AttributeChanged_"..name, name, key, value, self)
|
||||
callbacks:Fire("LibDataBroker_AttributeChanged_"..name.."_"..key, name, key, value, self)
|
||||
callbacks:Fire("LibDataBroker_AttributeChanged__"..key, name, key, value, self)
|
||||
end
|
||||
end
|
||||
|
||||
if oldminor < 2 then
|
||||
function lib:NewDataObject(name, dataobj)
|
||||
if self.proxystorage[name] then return end
|
||||
|
||||
if dataobj then
|
||||
assert(type(dataobj) == "table", "Invalid dataobj, must be nil or a table")
|
||||
self.attributestorage[dataobj] = {}
|
||||
for i,v in pairs(dataobj) do
|
||||
self.attributestorage[dataobj][i] = v
|
||||
dataobj[i] = nil
|
||||
end
|
||||
end
|
||||
dataobj = setmetatable(dataobj or {}, self.domt)
|
||||
self.proxystorage[name], self.namestorage[dataobj] = dataobj, name
|
||||
self.callbacks:Fire("LibDataBroker_DataObjectCreated", name, dataobj)
|
||||
return dataobj
|
||||
end
|
||||
end
|
||||
|
||||
if oldminor < 1 then
|
||||
function lib:DataObjectIterator()
|
||||
return pairs(self.proxystorage)
|
||||
end
|
||||
|
||||
function lib:GetDataObjectByName(dataobjectname)
|
||||
return self.proxystorage[dataobjectname]
|
||||
end
|
||||
|
||||
function lib:GetNameByDataObject(dataobject)
|
||||
return self.namestorage[dataobject]
|
||||
end
|
||||
end
|
||||
|
||||
if oldminor < 4 then
|
||||
local next = pairs(attributestorage)
|
||||
function lib:pairs(dataobject_or_name)
|
||||
local t = type(dataobject_or_name)
|
||||
assert(t == "string" or t == "table", "Usage: ldb:pairs('dataobjectname') or ldb:pairs(dataobject)")
|
||||
|
||||
local dataobj = self.proxystorage[dataobject_or_name] or dataobject_or_name
|
||||
assert(attributestorage[dataobj], "Data object not found")
|
||||
|
||||
return next, attributestorage[dataobj], nil
|
||||
end
|
||||
|
||||
local ipairs_iter = ipairs(attributestorage)
|
||||
function lib:ipairs(dataobject_or_name)
|
||||
local t = type(dataobject_or_name)
|
||||
assert(t == "string" or t == "table", "Usage: ldb:ipairs('dataobjectname') or ldb:ipairs(dataobject)")
|
||||
|
||||
local dataobj = self.proxystorage[dataobject_or_name] or dataobject_or_name
|
||||
assert(attributestorage[dataobj], "Data object not found")
|
||||
|
||||
return ipairs_iter, attributestorage[dataobj], 0
|
||||
end
|
||||
end
|
||||
@@ -1,13 +0,0 @@
|
||||
LibDataBroker is a small WoW addon library designed to provide a "MVC":http://en.wikipedia.org/wiki/Model-view-controller interface for use in various addons.
|
||||
LDB's primary goal is to "detach" plugins for TitanPanel and FuBar from the display addon.
|
||||
Plugins can provide data into a simple table, and display addons can receive callbacks to refresh their display of this data.
|
||||
LDB also provides a place for addons to register "quicklaunch" functions, removing the need for authors to embed many large libraries to create minimap buttons.
|
||||
Users who do not wish to be "plagued" by these buttons simply do not install an addon to render them.
|
||||
|
||||
Due to it's simple generic design, LDB can be used for any design where you wish to have an addon notified of changes to a table.
|
||||
|
||||
h2. Links
|
||||
|
||||
* "API documentation":http://github.com/tekkub/libdatabroker-1-1/wikis/api
|
||||
* "Data specifications":http://github.com/tekkub/libdatabroker-1-1/wikis/data-specifications
|
||||
* "Addons using LDB":http://github.com/tekkub/libdatabroker-1-1/wikis/addons-using-ldb
|
||||
@@ -1,19 +0,0 @@
|
||||
zlib License
|
||||
|
||||
(C) 2018-2021 Haoqian He
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +0,0 @@
|
||||
## Interface: 80300
|
||||
## Title: Lib: LibDeflate
|
||||
## Notes: Compressor and decompressor with high compression ratio using DEFLATE/zlib format.
|
||||
## Author: Haoqian He (WoW: Safetyy at Illidan-US (Horde))
|
||||
## Version: afc3b78
|
||||
## X-Website: https://wow.curseforge.com/projects/libdeflate
|
||||
## X-Category: Library
|
||||
## X-License: zlib
|
||||
## X-Curse-Project-ID: 293814
|
||||
## X-WoWI-ID: 25453
|
||||
## X-Wago-ID: Xb6X5wKp
|
||||
|
||||
LibStub\LibStub.lua
|
||||
lib.xml
|
||||
@@ -1,4 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="LibDeflate.lua" />
|
||||
</Ui>
|
||||
@@ -1,327 +0,0 @@
|
||||
--- **AceTimer-3.0** provides a central facility for registering timers.
|
||||
-- AceTimer supports one-shot timers and repeating timers. All timers are stored in an efficient
|
||||
-- data structure that allows easy dispatching and fast rescheduling. Timers can be registered
|
||||
-- or canceled at any time, even from within a running timer, without conflict or large overhead.\\
|
||||
-- AceTimer is currently limited to firing timers at a frequency of 0.01s.
|
||||
--
|
||||
-- All `:Schedule` functions will return a handle to the current timer, which you will need to store if you
|
||||
-- need to cancel the timer you just registered.
|
||||
--
|
||||
-- **AceTimer-3.0** can be embeded into your addon, either explicitly by calling AceTimer:Embed(MyAddon) or by
|
||||
-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
|
||||
-- and can be accessed directly, without having to explicitly call AceTimer itself.\\
|
||||
-- It is recommended to embed AceTimer, otherwise you'll have to specify a custom `self` on all calls you
|
||||
-- make into AceTimer.
|
||||
-- @class file
|
||||
-- @name AceTimer-3.0
|
||||
-- @release $Id$
|
||||
|
||||
local MAJOR, MINOR = "AceTimer-3.0", 1017 -- Bump minor on changes
|
||||
local AceTimer, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not AceTimer then return end -- No upgrade needed
|
||||
AceTimer.frame = AceTimer.frame or CreateFrame("Frame", "AceTimer30Frame")
|
||||
AceTimer.activeTimers = AceTimer.activeTimers or {} -- Active timer list
|
||||
local activeTimers = AceTimer.activeTimers -- Upvalue our private data
|
||||
|
||||
-- Lua APIs
|
||||
local assert, loadstring, rawset, tconcat = assert, loadstring, rawset, table.concat
|
||||
local type, unpack, next, error, select = type, unpack, next, error, select
|
||||
-- WoW APIs
|
||||
local GetTime = GetTime
|
||||
|
||||
--[[
|
||||
xpcall safecall implementation
|
||||
]]
|
||||
local xpcall = xpcall
|
||||
|
||||
local function errorhandler(err)
|
||||
return geterrorhandler()(err)
|
||||
end
|
||||
|
||||
local function CreateDispatcher(argCount)
|
||||
local code = [[
|
||||
local xpcall, eh = ...
|
||||
local method, ARGS
|
||||
local function call() return method(ARGS) end
|
||||
|
||||
local function dispatch(func, ...)
|
||||
method = func
|
||||
if not method then return end
|
||||
ARGS = ...
|
||||
return xpcall(call, eh)
|
||||
end
|
||||
|
||||
return dispatch
|
||||
]]
|
||||
|
||||
local ARGS = {}
|
||||
for i = 1, argCount do ARGS[i] = "arg"..i end
|
||||
code = code:gsub("ARGS", tconcat(ARGS, ", "))
|
||||
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
|
||||
end
|
||||
|
||||
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
|
||||
local dispatcher = CreateDispatcher(argCount)
|
||||
rawset(self, argCount, dispatcher)
|
||||
return dispatcher
|
||||
end})
|
||||
Dispatchers[0] = function(func)
|
||||
return xpcall(func, errorhandler)
|
||||
end
|
||||
|
||||
local function safecall(func, ...)
|
||||
return Dispatchers[select("#", ...)](func, ...)
|
||||
end
|
||||
|
||||
local function new(self, loop, func, delay, ...)
|
||||
if delay < 0.01 then
|
||||
delay = 0.01 -- Restrict to the lowest time
|
||||
end
|
||||
|
||||
local timer = {
|
||||
object = self,
|
||||
func = func,
|
||||
looping = loop,
|
||||
argsCount = select("#", ...),
|
||||
delay = delay,
|
||||
timeleft = delay,
|
||||
ends = GetTime() + delay,
|
||||
...
|
||||
}
|
||||
|
||||
activeTimers[timer] = timer
|
||||
|
||||
return timer
|
||||
end
|
||||
|
||||
--- Schedule a new one-shot timer.
|
||||
-- The timer will fire once in `delay` seconds, unless canceled before.
|
||||
-- @param callback Callback function for the timer pulse (funcref or method name).
|
||||
-- @param delay Delay for the timer, in seconds.
|
||||
-- @param ... An optional, unlimited amount of arguments to pass to the callback function.
|
||||
-- @usage
|
||||
-- MyAddOn = LibStub("AceAddon-3.0"):NewAddon("MyAddOn", "AceTimer-3.0")
|
||||
--
|
||||
-- function MyAddOn:OnEnable()
|
||||
-- self:ScheduleTimer("TimerFeedback", 5)
|
||||
-- end
|
||||
--
|
||||
-- function MyAddOn:TimerFeedback()
|
||||
-- print("5 seconds passed")
|
||||
-- end
|
||||
function AceTimer:ScheduleTimer(func, delay, ...)
|
||||
if not func or not delay then
|
||||
error(MAJOR..": ScheduleTimer(callback, delay, args...): 'callback' and 'delay' must have set values.", 2)
|
||||
end
|
||||
if type(func) == "string" then
|
||||
if type(self) ~= "table" then
|
||||
error(MAJOR..": ScheduleTimer(callback, delay, args...): 'self' - must be a table.", 2)
|
||||
elseif not self[func] then
|
||||
error(MAJOR..": ScheduleTimer(callback, delay, args...): Tried to register '"..func.."' as the callback, but it doesn't exist in the module.", 2)
|
||||
end
|
||||
end
|
||||
return new(self, nil, func, delay, ...)
|
||||
end
|
||||
|
||||
--- Schedule a repeating timer.
|
||||
-- The timer will fire every `delay` seconds, until canceled.
|
||||
-- @param callback Callback function for the timer pulse (funcref or method name).
|
||||
-- @param delay Delay for the timer, in seconds.
|
||||
-- @param ... An optional, unlimited amount of arguments to pass to the callback function.
|
||||
-- @usage
|
||||
-- MyAddOn = LibStub("AceAddon-3.0"):NewAddon("MyAddOn", "AceTimer-3.0")
|
||||
--
|
||||
-- function MyAddOn:OnEnable()
|
||||
-- self.timerCount = 0
|
||||
-- self.testTimer = self:ScheduleRepeatingTimer("TimerFeedback", 5)
|
||||
-- end
|
||||
--
|
||||
-- function MyAddOn:TimerFeedback()
|
||||
-- self.timerCount = self.timerCount + 1
|
||||
-- print(("%d seconds passed"):format(5 * self.timerCount))
|
||||
-- -- run 30 seconds in total
|
||||
-- if self.timerCount == 6 then
|
||||
-- self:CancelTimer(self.testTimer)
|
||||
-- end
|
||||
-- end
|
||||
function AceTimer:ScheduleRepeatingTimer(func, delay, ...)
|
||||
if not func or not delay then
|
||||
error(MAJOR..": ScheduleRepeatingTimer(callback, delay, args...): 'callback' and 'delay' must have set values.", 2)
|
||||
end
|
||||
if type(func) == "string" then
|
||||
if type(self) ~= "table" then
|
||||
error(MAJOR..": ScheduleRepeatingTimer(callback, delay, args...): 'self' - must be a table.", 2)
|
||||
elseif not self[func] then
|
||||
error(MAJOR..": ScheduleRepeatingTimer(callback, delay, args...): Tried to register '"..func.."' as the callback, but it doesn't exist in the module.", 2)
|
||||
end
|
||||
end
|
||||
return new(self, true, func, delay, ...)
|
||||
end
|
||||
|
||||
--- Cancels a timer with the given id, registered by the same addon object as used for `:ScheduleTimer`
|
||||
-- Both one-shot and repeating timers can be canceled with this function, as long as the `id` is valid
|
||||
-- and the timer has not fired yet or was canceled before.
|
||||
-- @param id The id of the timer, as returned by `:ScheduleTimer` or `:ScheduleRepeatingTimer`
|
||||
function AceTimer:CancelTimer(id)
|
||||
local timer = activeTimers[id]
|
||||
|
||||
if not timer then
|
||||
return false
|
||||
else
|
||||
timer.cancelled = true
|
||||
activeTimers[id] = nil
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
--- Cancels all timers registered to the current addon object ('self')
|
||||
function AceTimer:CancelAllTimers()
|
||||
for k,v in next, activeTimers do
|
||||
if v.object == self then
|
||||
AceTimer.CancelTimer(self, k)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Returns the time left for a timer with the given id, registered by the current addon object ('self').
|
||||
-- This function will return 0 when the id is invalid.
|
||||
-- @param id The id of the timer, as returned by `:ScheduleTimer` or `:ScheduleRepeatingTimer`
|
||||
-- @return The time left on the timer.
|
||||
function AceTimer:TimeLeft(id)
|
||||
local timer = activeTimers[id]
|
||||
if not timer then
|
||||
return
|
||||
else
|
||||
return timer.ends - GetTime()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Upgrading
|
||||
|
||||
-- Upgrade from old hash-bucket based timers to C_Timer.After timers.
|
||||
if oldminor and oldminor < 10 then
|
||||
-- disable old timer logic
|
||||
AceTimer.frame:SetScript("OnUpdate", nil)
|
||||
AceTimer.frame:SetScript("OnEvent", nil)
|
||||
AceTimer.frame:UnregisterAllEvents()
|
||||
-- convert timers
|
||||
for object,timers in next, AceTimer.selfs do
|
||||
for handle,timer in next, timers do
|
||||
if type(timer) == "table" and timer.callback then
|
||||
local newTimer
|
||||
if timer.delay then
|
||||
newTimer = AceTimer.ScheduleRepeatingTimer(timer.object, timer.callback, timer.delay, timer.arg)
|
||||
else
|
||||
newTimer = AceTimer.ScheduleTimer(timer.object, timer.callback, timer.when - GetTime(), timer.arg)
|
||||
end
|
||||
-- Use the old handle for old timers
|
||||
activeTimers[newTimer] = nil
|
||||
activeTimers[handle] = newTimer
|
||||
newTimer.handle = handle
|
||||
end
|
||||
end
|
||||
end
|
||||
AceTimer.selfs = nil
|
||||
AceTimer.hash = nil
|
||||
AceTimer.debug = nil
|
||||
elseif oldminor and oldminor < 17 then
|
||||
-- Upgrade from old animation based timers to C_Timer.After timers.
|
||||
AceTimer.inactiveTimers = nil
|
||||
local oldTimers = AceTimer.activeTimers
|
||||
-- Clear old timer table and update upvalue
|
||||
AceTimer.activeTimers = {}
|
||||
activeTimers = AceTimer.activeTimers
|
||||
for handle, timer in next, oldTimers do
|
||||
local newTimer
|
||||
-- Stop the old timer animation
|
||||
local duration, elapsed = timer:GetDuration(), timer:GetElapsed()
|
||||
timer:GetParent():Stop()
|
||||
if timer.looping then
|
||||
newTimer = AceTimer.ScheduleRepeatingTimer(timer.object, timer.func, duration, unpack(timer.args, 1, timer.argsCount))
|
||||
else
|
||||
newTimer = AceTimer.ScheduleTimer(timer.object, timer.func, duration - elapsed, unpack(timer.args, 1, timer.argsCount))
|
||||
end
|
||||
-- Use the old handle for old timers
|
||||
activeTimers[newTimer] = nil
|
||||
activeTimers[handle] = newTimer
|
||||
newTimer.handle = handle
|
||||
end
|
||||
|
||||
-- Migrate transitional handles
|
||||
if oldminor < 13 and AceTimer.hashCompatTable then
|
||||
for handle, id in next, AceTimer.hashCompatTable do
|
||||
local t = activeTimers[id]
|
||||
if t then
|
||||
activeTimers[id] = nil
|
||||
activeTimers[handle] = t
|
||||
t.handle = handle
|
||||
end
|
||||
end
|
||||
AceTimer.hashCompatTable = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Embed handling
|
||||
|
||||
AceTimer.embeds = AceTimer.embeds or {}
|
||||
|
||||
local mixins = {
|
||||
"ScheduleTimer", "ScheduleRepeatingTimer",
|
||||
"CancelTimer", "CancelAllTimers",
|
||||
"TimeLeft"
|
||||
}
|
||||
|
||||
function AceTimer:Embed(target)
|
||||
AceTimer.embeds[target] = true
|
||||
for _,v in next, mixins do
|
||||
target[v] = AceTimer[v]
|
||||
end
|
||||
return target
|
||||
end
|
||||
|
||||
-- AceTimer:OnEmbedDisable(target)
|
||||
-- target (object) - target object that AceTimer is embedded in.
|
||||
--
|
||||
-- cancel all timers registered for the object
|
||||
function AceTimer:OnEmbedDisable(target)
|
||||
target:CancelAllTimers()
|
||||
end
|
||||
|
||||
for addon in next, AceTimer.embeds do
|
||||
AceTimer:Embed(addon)
|
||||
end
|
||||
|
||||
AceTimer.frame:SetScript("OnUpdate", function(self, elapsed)
|
||||
for _, timer in next, activeTimers do
|
||||
if not timer.cancelled then
|
||||
if timer.timeleft > elapsed then
|
||||
timer.timeleft = timer.timeleft - elapsed
|
||||
else
|
||||
if type(timer.func) == "string" then
|
||||
-- We manually set the unpack count to prevent issues with an arg set that contains nil and ends with nil
|
||||
-- e.g. local t = {1, 2, nil, 3, nil} print(#t) will result in 2, instead of 5. This fixes said issue.
|
||||
safecall(timer.object[timer.func], timer.object, unpack(timer, 1, timer.argsCount))
|
||||
else
|
||||
safecall(timer.func, unpack(timer, 1, timer.argsCount))
|
||||
end
|
||||
|
||||
if timer.looping and not timer.cancelled then
|
||||
-- Compensate delay to get a perfect average delay, even if individual times don't match up perfectly
|
||||
-- due to fps differences
|
||||
local time = GetTime()
|
||||
local delay = timer.delay - (time - timer.ends)
|
||||
-- Ensure the delay doesn't go below the threshold
|
||||
if delay < 0.01 then delay = 0.01 end
|
||||
timer.ends = time + delay
|
||||
timer.timeleft = timer.delay
|
||||
else
|
||||
activeTimers[timer.handle or timer] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -1,4 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="AceTimer-3.0.lua"/>
|
||||
</Ui>
|
||||
@@ -1,238 +0,0 @@
|
||||
--[[ $Id: CallbackHandler-1.0.lua 18 2014-10-16 02:52:20Z mikk $ ]]
|
||||
local MAJOR, MINOR = "CallbackHandler-1.0", 6
|
||||
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not CallbackHandler then return end -- No upgrade needed
|
||||
|
||||
local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
|
||||
|
||||
-- Lua APIs
|
||||
local tconcat = table.concat
|
||||
local assert, error, loadstring = assert, error, loadstring
|
||||
local setmetatable, rawset, rawget = setmetatable, rawset, rawget
|
||||
local next, select, pairs, type, tostring = next, select, pairs, type, tostring
|
||||
|
||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||
-- List them here for Mikk's FindGlobals script
|
||||
-- GLOBALS: geterrorhandler
|
||||
|
||||
local xpcall = xpcall
|
||||
|
||||
local function errorhandler(err)
|
||||
return geterrorhandler()(err)
|
||||
end
|
||||
|
||||
local function CreateDispatcher(argCount)
|
||||
local code = [[
|
||||
local next, xpcall, eh = ...
|
||||
|
||||
local method, ARGS
|
||||
local function call() method(ARGS) end
|
||||
|
||||
local function dispatch(handlers, ...)
|
||||
local index
|
||||
index, method = next(handlers)
|
||||
if not method then return end
|
||||
local OLD_ARGS = ARGS
|
||||
ARGS = ...
|
||||
repeat
|
||||
xpcall(call, eh)
|
||||
index, method = next(handlers, index)
|
||||
until not method
|
||||
ARGS = OLD_ARGS
|
||||
end
|
||||
|
||||
return dispatch
|
||||
]]
|
||||
|
||||
local ARGS, OLD_ARGS = {}, {}
|
||||
for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
|
||||
code = code:gsub("OLD_ARGS", tconcat(OLD_ARGS, ", ")):gsub("ARGS", tconcat(ARGS, ", "))
|
||||
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
|
||||
end
|
||||
|
||||
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
|
||||
local dispatcher = CreateDispatcher(argCount)
|
||||
rawset(self, argCount, dispatcher)
|
||||
return dispatcher
|
||||
end})
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
-- CallbackHandler:New
|
||||
--
|
||||
-- target - target object to embed public APIs in
|
||||
-- RegisterName - name of the callback registration API, default "RegisterCallback"
|
||||
-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback"
|
||||
-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
|
||||
|
||||
function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName)
|
||||
|
||||
RegisterName = RegisterName or "RegisterCallback"
|
||||
UnregisterName = UnregisterName or "UnregisterCallback"
|
||||
if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
|
||||
UnregisterAllName = "UnregisterAllCallbacks"
|
||||
end
|
||||
|
||||
-- we declare all objects and exported APIs inside this closure to quickly gain access
|
||||
-- to e.g. function names, the "target" parameter, etc
|
||||
|
||||
|
||||
-- Create the registry object
|
||||
local events = setmetatable({}, meta)
|
||||
local registry = { recurse=0, events=events }
|
||||
|
||||
-- registry:Fire() - fires the given event/message into the registry
|
||||
function registry:Fire(eventname, ...)
|
||||
if not rawget(events, eventname) or not next(events[eventname]) then return end
|
||||
local oldrecurse = registry.recurse
|
||||
registry.recurse = oldrecurse + 1
|
||||
|
||||
Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...)
|
||||
|
||||
registry.recurse = oldrecurse
|
||||
|
||||
if registry.insertQueue and oldrecurse==0 then
|
||||
-- Something in one of our callbacks wanted to register more callbacks; they got queued
|
||||
for eventname,callbacks in pairs(registry.insertQueue) do
|
||||
local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
|
||||
for self,func in pairs(callbacks) do
|
||||
events[eventname][self] = func
|
||||
-- fire OnUsed callback?
|
||||
if first and registry.OnUsed then
|
||||
registry.OnUsed(registry, target, eventname)
|
||||
first = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
registry.insertQueue = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Registration of a callback, handles:
|
||||
-- self["method"], leads to self["method"](self, ...)
|
||||
-- self with function ref, leads to functionref(...)
|
||||
-- "addonId" (instead of self) with function ref, leads to functionref(...)
|
||||
-- all with an optional arg, which, if present, gets passed as first argument (after self if present)
|
||||
target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]])
|
||||
if type(eventname) ~= "string" then
|
||||
error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2)
|
||||
end
|
||||
|
||||
method = method or eventname
|
||||
|
||||
local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
|
||||
|
||||
if type(method) ~= "string" and type(method) ~= "function" then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2)
|
||||
end
|
||||
|
||||
local regfunc
|
||||
|
||||
if type(method) == "string" then
|
||||
-- self["method"] calling style
|
||||
if type(self) ~= "table" then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2)
|
||||
elseif self==target then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2)
|
||||
elseif type(self[method]) ~= "function" then
|
||||
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2)
|
||||
end
|
||||
|
||||
if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
|
||||
local arg=select(1,...)
|
||||
regfunc = function(...) self[method](self,arg,...) end
|
||||
else
|
||||
regfunc = function(...) self[method](self,...) end
|
||||
end
|
||||
else
|
||||
-- function ref with self=object or self="addonId" or self=thread
|
||||
if type(self)~="table" and type(self)~="string" and type(self)~="thread" then
|
||||
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2)
|
||||
end
|
||||
|
||||
if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
|
||||
local arg=select(1,...)
|
||||
regfunc = function(...) method(arg,...) end
|
||||
else
|
||||
regfunc = method
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if events[eventname][self] or registry.recurse<1 then
|
||||
-- if registry.recurse<1 then
|
||||
-- we're overwriting an existing entry, or not currently recursing. just set it.
|
||||
events[eventname][self] = regfunc
|
||||
-- fire OnUsed callback?
|
||||
if registry.OnUsed and first then
|
||||
registry.OnUsed(registry, target, eventname)
|
||||
end
|
||||
else
|
||||
-- we're currently processing a callback in this registry, so delay the registration of this new entry!
|
||||
-- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency
|
||||
registry.insertQueue = registry.insertQueue or setmetatable({},meta)
|
||||
registry.insertQueue[eventname][self] = regfunc
|
||||
end
|
||||
end
|
||||
|
||||
-- Unregister a callback
|
||||
target[UnregisterName] = function(self, eventname)
|
||||
if not self or self==target then
|
||||
error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2)
|
||||
end
|
||||
if type(eventname) ~= "string" then
|
||||
error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2)
|
||||
end
|
||||
if rawget(events, eventname) and events[eventname][self] then
|
||||
events[eventname][self] = nil
|
||||
-- Fire OnUnused callback?
|
||||
if registry.OnUnused and not next(events[eventname]) then
|
||||
registry.OnUnused(registry, target, eventname)
|
||||
end
|
||||
end
|
||||
if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
|
||||
registry.insertQueue[eventname][self] = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- OPTIONAL: Unregister all callbacks for given selfs/addonIds
|
||||
if UnregisterAllName then
|
||||
target[UnregisterAllName] = function(...)
|
||||
if select("#",...)<1 then
|
||||
error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2)
|
||||
end
|
||||
if select("#",...)==1 and ...==target then
|
||||
error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2)
|
||||
end
|
||||
|
||||
|
||||
for i=1,select("#",...) do
|
||||
local self = select(i,...)
|
||||
if registry.insertQueue then
|
||||
for eventname, callbacks in pairs(registry.insertQueue) do
|
||||
if callbacks[self] then
|
||||
callbacks[self] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
for eventname, callbacks in pairs(events) do
|
||||
if callbacks[self] then
|
||||
callbacks[self] = nil
|
||||
-- Fire OnUnused callback?
|
||||
if registry.OnUnused and not next(callbacks) then
|
||||
registry.OnUnused(registry, target, eventname)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return registry
|
||||
end
|
||||
|
||||
|
||||
-- CallbackHandler purposefully does NOT do explicit embedding. Nor does it
|
||||
-- try to upgrade old implicit embeds since the system is selfcontained and
|
||||
-- relies on closures to work.
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="CallbackHandler-1.0.lua"/>
|
||||
</Ui>
|
||||
@@ -1,339 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -1,746 +0,0 @@
|
||||
local MAJOR_VERSION = "LibGetFrame-1.0"
|
||||
local MINOR_VERSION = 63
|
||||
if not LibStub then
|
||||
error(MAJOR_VERSION .. " requires LibStub.")
|
||||
end
|
||||
local lib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
|
||||
if not lib then
|
||||
return
|
||||
end
|
||||
|
||||
lib.timer = lib.timer or LibStub("AceTimer-3.0")
|
||||
if not lib.timer then
|
||||
error(MAJOR_VERSION .. " requires AceTimer-3.0.")
|
||||
end
|
||||
|
||||
lib.callbacks = lib.callbacks or LibStub("CallbackHandler-1.0"):New(lib)
|
||||
local callbacks = lib.callbacks
|
||||
|
||||
local GetPlayerInfoByGUID, UnitExists, UnitIsUnit, SecureButton_GetUnit, IsAddOnLoaded =
|
||||
GetPlayerInfoByGUID, UnitExists, UnitIsUnit, SecureButton_GetUnit, IsAddOnLoaded
|
||||
local tinsert, CopyTable, wipe = tinsert, CopyTable, wipe
|
||||
|
||||
function lib.Mixin(object, ...)
|
||||
for i = 1, select("#", ...) do
|
||||
local mixin = select(i, ...);
|
||||
for k, v in pairs(mixin) do
|
||||
object[k] = v;
|
||||
end
|
||||
end
|
||||
return object;
|
||||
end
|
||||
|
||||
local maxDepth = 50
|
||||
|
||||
local defaultFramePriorities = {
|
||||
-- raid frames
|
||||
"^Vd1", -- vuhdo
|
||||
"^Vd2", -- vuhdo
|
||||
"^Vd3", -- vuhdo
|
||||
"^Vd4", -- vuhdo
|
||||
"^Vd5", -- vuhdo
|
||||
"^Vd", -- vuhdo
|
||||
"^HealBot_HealUnit", -- healbot
|
||||
"^hbPet_HealUnit", -- healbot
|
||||
"^HealBot", -- healbot
|
||||
"^GridLayout", -- grid
|
||||
"^Grid2Layout", -- grid2
|
||||
"^NugRaid%d+UnitButton%d+", -- Aptechka
|
||||
"^PlexusLayout", -- plexus
|
||||
"^ElvUF_Raid%d*Group", -- elv
|
||||
"^ElvUF_RaidGroup", -- elv
|
||||
"^oUF_bdGrid", -- bdgrid
|
||||
"^oUF_.-Raid", -- generic oUF
|
||||
"^LimeGroup", -- lime
|
||||
"^InvenRaidFrames3Group%dUnitButton", -- InvenRaidFrames3
|
||||
"^SUFHeaderraid", -- suf
|
||||
"^LUFHeaderraid", -- luf
|
||||
"^AshToAshUnit%d+Unit%d+", -- AshToAsh
|
||||
"^Cell", -- Cell
|
||||
-- party frames
|
||||
"^AleaUI_GroupHeader", -- Alea
|
||||
"^SUFHeaderparty", -- suf
|
||||
"^LUFHeaderparty", -- luf
|
||||
"^ElvUF_PartyGroup", -- elv
|
||||
"^oUF_.-Party", -- generic oUF
|
||||
"^PitBull4_Groups_Party", -- pitbull4
|
||||
"^CompactRaid", -- blizz
|
||||
"^CompactParty", -- blizz
|
||||
"^PartyFrame", -- blizz
|
||||
"^PartyMemberFrame", -- blizz
|
||||
-- player frame
|
||||
"^InvenUnitFrames_Player",
|
||||
"^SUFUnitplayer",
|
||||
"^LUFUnitplayer",
|
||||
"^PitBull4_Frames_Player",
|
||||
"^ElvUF_Player",
|
||||
"^oUF_.-Player",
|
||||
"^PlayerFrame",
|
||||
}
|
||||
local getDefaultFramePriorities = function()
|
||||
return CopyTable(defaultFramePriorities)
|
||||
end
|
||||
lib.getDefaultFramePriorities = getDefaultFramePriorities
|
||||
|
||||
local defaultPlayerFrames = {
|
||||
"^InvenUnitFrames_Player",
|
||||
"SUFUnitplayer",
|
||||
"LUFUnitplayer",
|
||||
"PitBull4_Frames_Player",
|
||||
"ElvUF_Player",
|
||||
"oUF_.-Player",
|
||||
"oUF_PlayerPlate",
|
||||
"PlayerFrame",
|
||||
}
|
||||
local getDefaultPlayerFrames = function()
|
||||
return CopyTable(defaultPlayerFrames)
|
||||
end
|
||||
lib.getDefaultPlayerFrames = getDefaultPlayerFrames
|
||||
|
||||
local defaultTargetFrames = {
|
||||
"^InvenUnitFrames_Target",
|
||||
"SUFUnittarget",
|
||||
"LUFUnittarget",
|
||||
"PitBull4_Frames_Target",
|
||||
"ElvUF_Target",
|
||||
"oUF_.-Target",
|
||||
"TargetFrame",
|
||||
"^hbExtra_HealUnit",
|
||||
}
|
||||
local getDefaultTargetFrames = function()
|
||||
return CopyTable(defaultTargetFrames)
|
||||
end
|
||||
lib.getDefaultTargetFrames = getDefaultTargetFrames
|
||||
|
||||
local defaultTargettargetFrames = {
|
||||
"^InvenUnitFrames_TargetTarget",
|
||||
"SUFUnittargetarget",
|
||||
"LUFUnittargetarget",
|
||||
"PitBull4_Frames_Target's target",
|
||||
"ElvUF_TargetTarget",
|
||||
"oUF_.-TargetTarget",
|
||||
"oUF_ToT",
|
||||
"TargetTargetFrame",
|
||||
}
|
||||
local getDefaultTargettargetFrames = function()
|
||||
return CopyTable(defaultTargettargetFrames)
|
||||
end
|
||||
lib.getDefaultTargettargetFrames = getDefaultTargettargetFrames
|
||||
|
||||
local defaultPartyFrames = {
|
||||
"^InvenUnitFrames_Party%d",
|
||||
"^AleaUI_GroupHeader",
|
||||
"^SUFHeaderparty",
|
||||
"^LUFHeaderparty",
|
||||
"^ElvUF_PartyGroup",
|
||||
"^oUF_.-Party",
|
||||
"^PitBull4_Groups_Party",
|
||||
"^PartyFrame",
|
||||
"^CompactParty",
|
||||
"^PartyMemberFrame",
|
||||
}
|
||||
local getDefaultPartyFrames = function()
|
||||
return CopyTable(defaultPartyFrames)
|
||||
end
|
||||
lib.getDefaultPartyFrames = getDefaultPartyFrames
|
||||
|
||||
local defaultPartyTargetFrames = {
|
||||
"SUFChildpartytarget%d",
|
||||
}
|
||||
local getDefaultPartyTargetFrames = function()
|
||||
return CopyTable(defaultPartyTargetFrames)
|
||||
end
|
||||
lib.getDefaultPartyTargetFrames = getDefaultPartyTargetFrames
|
||||
|
||||
local defaultFocusFrames = {
|
||||
"^InvenUnitFrames_Focus",
|
||||
"ElvUF_FocusTarget",
|
||||
"LUFUnitfocus",
|
||||
"FocusFrame",
|
||||
"^hbExtra_HealUnit",
|
||||
}
|
||||
local getDefaultFocusFrames = function()
|
||||
return CopyTable(defaultFocusFrames)
|
||||
end
|
||||
lib.getDefaultFocusFrames = getDefaultFocusFrames
|
||||
|
||||
local defaultRaidFrames = {
|
||||
"^Vd",
|
||||
"^HealBot_HealUnit",
|
||||
"^hbPet_HealUnit",
|
||||
"^HealBot",
|
||||
"^GridLayout",
|
||||
"^Grid2Layout",
|
||||
"^PlexusLayout",
|
||||
"^InvenRaidFrames3Group%dUnitButton",
|
||||
"^ElvUF_Raid%d*Group",
|
||||
"^ElvUF_RaidGroup",
|
||||
"^oUF_.-Raid",
|
||||
"^AshToAsh",
|
||||
"^Cell",
|
||||
"^LimeGroup",
|
||||
"^SUFHeaderraid",
|
||||
"^LUFHeaderraid",
|
||||
"^CompactRaid",
|
||||
"^RaidPullout",
|
||||
}
|
||||
local getDefaultRaidFrames = function()
|
||||
return CopyTable(defaultRaidFrames)
|
||||
end
|
||||
lib.getDefaultRaidFrames = getDefaultRaidFrames
|
||||
--
|
||||
local CacheMonitorMixin = {}
|
||||
function CacheMonitorMixin:Init(makeDiff)
|
||||
self.data = {}
|
||||
self.cache = {}
|
||||
if makeDiff then
|
||||
self.makeDiff = makeDiff
|
||||
self.added = {}
|
||||
self.updated = {}
|
||||
self.removed = {}
|
||||
end
|
||||
end
|
||||
-- fill cache, added, updated
|
||||
function CacheMonitorMixin:Add(key, ...)
|
||||
local args = select("#", ...)
|
||||
if args > 1 then
|
||||
if self.makeDiff then
|
||||
if type(self.data[key]) == "table" then
|
||||
for i = 1, args do
|
||||
local arg = select(i, ...)
|
||||
if self.data[key][i] ~= arg then
|
||||
self.updated[key] = self.data[key]
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
self.added[key] = true
|
||||
end
|
||||
end
|
||||
self.cache[key] = {...}
|
||||
else
|
||||
local value = ...
|
||||
if self.makeDiff then
|
||||
if self.data[key] ~= value then
|
||||
if self.data[key] == nil then
|
||||
self.added[key] = true
|
||||
else
|
||||
self.updated[key] = self.data[key]
|
||||
end
|
||||
end
|
||||
end
|
||||
self.cache[key] = value
|
||||
end
|
||||
end
|
||||
function CacheMonitorMixin:CalcRemoved()
|
||||
if not self.makeDiff then return end
|
||||
for key, value in pairs(self.data) do
|
||||
if self.cache[key] == nil then
|
||||
self.removed[key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
function CacheMonitorMixin:WriteCache()
|
||||
wipe(self.data)
|
||||
self.data, self.cache = self.cache, {}
|
||||
end
|
||||
function CacheMonitorMixin:Reset()
|
||||
if self.makeDiff then
|
||||
wipe(self.updated)
|
||||
wipe(self.removed)
|
||||
wipe(self.added)
|
||||
end
|
||||
end
|
||||
--
|
||||
local FrameToFrameName = {} -- frame adress => frame name
|
||||
local FrameToUnit = {} -- frame adress => unitToken
|
||||
lib.Mixin(FrameToFrameName, CacheMonitorMixin)
|
||||
lib.Mixin(FrameToUnit, CacheMonitorMixin)
|
||||
FrameToFrameName:Init()
|
||||
FrameToUnit:Init(true)
|
||||
|
||||
local profiling = false
|
||||
local profileData
|
||||
|
||||
local function doNothing()
|
||||
end
|
||||
|
||||
local StartProfiling = doNothing
|
||||
local StopProfiling = doNothing
|
||||
|
||||
local function _StartProfiling(id)
|
||||
if not profileData[id] then
|
||||
profileData[id] = {}
|
||||
profileData[id].count = 1
|
||||
profileData[id].start = debugprofilestop()
|
||||
profileData[id].elapsed = 0
|
||||
profileData[id].spike = 0
|
||||
return
|
||||
end
|
||||
|
||||
if profileData[id].count == 0 then
|
||||
profileData[id].count = 1
|
||||
profileData[id].start = debugprofilestop()
|
||||
else
|
||||
profileData[id].count = profileData[id].count + 1
|
||||
end
|
||||
end
|
||||
|
||||
local function _StopProfiling(id)
|
||||
profileData[id].count = profileData[id].count - 1
|
||||
if profileData[id].count == 0 then
|
||||
local elapsed = debugprofilestop() - profileData[id].start
|
||||
profileData[id].elapsed = profileData[id].elapsed + elapsed
|
||||
if elapsed > profileData[id].spike then
|
||||
profileData[id].spike = elapsed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function lib.StartProfile()
|
||||
if profiling then
|
||||
print(MAJOR_VERSION, " (StartProfile) Profiling already started")
|
||||
return false
|
||||
end
|
||||
profiling = true
|
||||
profileData = {}
|
||||
StartProfiling = _StartProfiling
|
||||
StopProfiling = _StopProfiling
|
||||
end
|
||||
|
||||
function lib.StopProfile()
|
||||
if not profiling then
|
||||
print(MAJOR_VERSION, " (StopProfile) Profiling not running")
|
||||
return false
|
||||
end
|
||||
profiling = false
|
||||
StartProfiling = doNothing
|
||||
StopProfiling = doNothing
|
||||
end
|
||||
|
||||
function lib.GetProfileData()
|
||||
return profileData or {}
|
||||
end
|
||||
|
||||
-- if frame doesn't have a name, try to use the key from it's parent
|
||||
local function recurseGetName(frame)
|
||||
local name = frame.GetName and frame:GetName() or nil
|
||||
if name then
|
||||
return name
|
||||
end
|
||||
local parent = frame.GetParent and frame:GetParent()
|
||||
if parent then
|
||||
local parentKey
|
||||
for key, child in pairs(parent) do
|
||||
if child == frame then
|
||||
parentKey = key
|
||||
break
|
||||
end
|
||||
end
|
||||
if parentKey then
|
||||
return (recurseGetName(parent) or "") .. "." .. parentKey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--local notAUnitFrameTypeAttribute = {
|
||||
-- cancelaura = true
|
||||
--}
|
||||
|
||||
local function ScanFrames(depth, frame, ...)
|
||||
coroutine.yield()
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
if depth < maxDepth then
|
||||
local frameType = frame:GetObjectType()
|
||||
if frameType == "Frame" or frameType == "Button" then
|
||||
ScanFrames(depth + 1, frame:GetChildren())
|
||||
end
|
||||
if frameType == "Button" then
|
||||
local typeAttribute = frame:GetAttribute("type")
|
||||
--if not notAUnitFrameTypeAttribute[typeAttribute] then
|
||||
local unit = SecureButton_GetUnit(frame)
|
||||
if unit and frame:IsVisible() then
|
||||
local name = recurseGetName(frame)
|
||||
if name then
|
||||
FrameToFrameName:Add(frame, name)
|
||||
FrameToUnit:Add(frame, unit)
|
||||
end
|
||||
end
|
||||
--end
|
||||
end
|
||||
end
|
||||
ScanFrames(depth, ...)
|
||||
end
|
||||
|
||||
local status = "ready"
|
||||
local co
|
||||
local coroutineFrame = CreateFrame("Frame")
|
||||
coroutineFrame:Hide()
|
||||
|
||||
local function doScanForUnitFrames()
|
||||
if not coroutineFrame:IsShown() then
|
||||
status = "scanning"
|
||||
co = coroutine.create(ScanFrames)
|
||||
coroutineFrame:Show()
|
||||
end
|
||||
end
|
||||
|
||||
coroutineFrame:SetScript("OnUpdate", function()
|
||||
local start = debugprofilestop()
|
||||
-- Limit to 5ms per frame
|
||||
StartProfiling("scan frames")
|
||||
while debugprofilestop() - start < 5 and coroutine.status(co) ~= "dead" do
|
||||
coroutine.resume(co, 0, UIParent)
|
||||
end
|
||||
StopProfiling("scan frames")
|
||||
if coroutine.status(co) == "dead" then
|
||||
StartProfiling("callbacks")
|
||||
FrameToFrameName:WriteCache()
|
||||
FrameToUnit:CalcRemoved()
|
||||
FrameToUnit:WriteCache()
|
||||
StartProfiling("callback GETFRAME_REFRESH")
|
||||
callbacks:Fire("GETFRAME_REFRESH")
|
||||
StopProfiling("callback GETFRAME_REFRESH")
|
||||
-- FrameToUnit
|
||||
if next(FrameToUnit.added) then
|
||||
StartProfiling("callback FRAME_UNIT_ADDED")
|
||||
for frame in pairs(FrameToUnit.added) do
|
||||
callbacks:Fire("FRAME_UNIT_ADDED", frame, FrameToUnit.data[frame])
|
||||
end
|
||||
StopProfiling("callback FRAME_UNIT_ADDED")
|
||||
end
|
||||
if next(FrameToUnit.updated) then
|
||||
StartProfiling("callback FRAME_UNIT_UPDATE")
|
||||
for frame, previousUnit in pairs(FrameToUnit.updated) do
|
||||
callbacks:Fire("FRAME_UNIT_UPDATE", frame, FrameToUnit.data[frame], previousUnit)
|
||||
end
|
||||
StopProfiling("callback FRAME_UNIT_UPDATE")
|
||||
end
|
||||
if next(FrameToUnit.removed) then
|
||||
StartProfiling("callback FRAME_UNIT_REMOVED")
|
||||
for frame, unit in pairs(FrameToUnit.removed) do
|
||||
callbacks:Fire("FRAME_UNIT_REMOVED", frame, unit)
|
||||
end
|
||||
StopProfiling("callback FRAME_UNIT_REMOVED")
|
||||
end
|
||||
coroutineFrame:Hide()
|
||||
FrameToFrameName:Reset()
|
||||
FrameToUnit:Reset()
|
||||
StopProfiling("callbacks")
|
||||
if status == "scan_queued" then
|
||||
doScanForUnitFrames("queued")
|
||||
else
|
||||
status = "ready"
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local function ScanForUnitFrames(noDelay)
|
||||
if status == "ready" then
|
||||
if noDelay then
|
||||
doScanForUnitFrames()
|
||||
else
|
||||
status = "scan_delay"
|
||||
lib.timer:ScheduleTimer(function()
|
||||
doScanForUnitFrames()
|
||||
end, 1)
|
||||
end
|
||||
elseif status == "scanning" then
|
||||
status = "scan_queued"
|
||||
end
|
||||
end
|
||||
|
||||
function lib.ScanForUnitFrames()
|
||||
ScanForUnitFrames(true)
|
||||
end
|
||||
|
||||
local function isFrameFiltered(name, ignoredFrames)
|
||||
for _, filter in pairs(ignoredFrames) do
|
||||
if name:find(filter) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function GetUnitFrames(target, ignoredFrames)
|
||||
if not UnitExists(target) then
|
||||
if type(target) ~= "string" then
|
||||
return
|
||||
end
|
||||
if target:match("^0x") then
|
||||
target = select(6, GetPlayerInfoByGUID(target))
|
||||
end
|
||||
if not UnitExists(target) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local frames
|
||||
for frame, frameName in pairs(FrameToFrameName.data) do
|
||||
local unit = SecureButton_GetUnit(frame)
|
||||
if unit and UnitIsUnit(unit, target) and not isFrameFiltered(frameName, ignoredFrames) then
|
||||
frames = frames or {}
|
||||
frames[frame] = frameName
|
||||
end
|
||||
end
|
||||
return frames
|
||||
end
|
||||
|
||||
local function ElvuiWorkaround(frame)
|
||||
if IsAddOnLoaded("ElvUI") and frame and frame:GetName() and frame:GetName():find("^ElvUF_") and frame.Health then
|
||||
return frame.Health
|
||||
else
|
||||
return frame
|
||||
end
|
||||
end
|
||||
|
||||
local function CellGetUnitFrames(target, frames, framePriorities)
|
||||
if not IsAddOnLoaded("Cell") or not Cell.GetUnitFramesForLGF then
|
||||
return frames
|
||||
end
|
||||
return Cell.GetUnitFramesForLGF(target, frames, framePriorities)
|
||||
end
|
||||
|
||||
local defaultOptions = {
|
||||
framePriorities = defaultFramePriorities,
|
||||
ignorePlayerFrame = true,
|
||||
ignoreTargetFrame = true,
|
||||
ignoreTargettargetFrame = true,
|
||||
ignorePartyFrame = false,
|
||||
ignorePartyTargetFrame = true,
|
||||
ignoreFocusFrame = true,
|
||||
ignoreRaidFrame = false,
|
||||
playerFrames = defaultPlayerFrames,
|
||||
targetFrames = defaultTargetFrames,
|
||||
targettargetFrames = defaultTargettargetFrames,
|
||||
partyFrames = defaultPartyFrames,
|
||||
partyTargetFrames = defaultPartyTargetFrames,
|
||||
focusFrames = defaultFocusFrames,
|
||||
raidFrames = defaultRaidFrames,
|
||||
ignoreFrames = {
|
||||
"PitBull4_Frames_Target's target's target",
|
||||
"ElvUF_PartyGroup%dUnitButton%dTarget",
|
||||
"RavenButton",
|
||||
"RavenOverlay",
|
||||
"AshToAshUnit%d+ShadowGroupHeaderUnitButton%d+",
|
||||
"InvenUnitFrames_TargetTargetTarget",
|
||||
"CellQuickCastButton",
|
||||
},
|
||||
skipCellOverrides = false,
|
||||
returnAll = false,
|
||||
}
|
||||
local getDefaultOptions = function()
|
||||
return CopyTable(defaultOptions)
|
||||
end
|
||||
lib.getDefaultOptions = getDefaultOptions
|
||||
|
||||
local IterateGroupMembers = function(reversed, forceParty)
|
||||
local unit = (not forceParty and GetNumRaidMembers() > 0) and 'raid' or 'party'
|
||||
local numGroupMembers = unit == 'party' and GetNumPartyMembers() or GetNumRaidMembers()
|
||||
local i = reversed and numGroupMembers or (unit == 'party' and 0 or 1)
|
||||
return function()
|
||||
local ret
|
||||
if i == 0 and unit == 'party' then
|
||||
ret = 'player'
|
||||
elseif i <= numGroupMembers and i > 0 then
|
||||
ret = unit .. i
|
||||
end
|
||||
i = i + (reversed and -1 or 1)
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
local unitPetState = {} -- track if unit's pet exists
|
||||
|
||||
local saveGetUnitFrame
|
||||
local function fixGetUnitFrameIntegrity()
|
||||
lib.GetUnitFrame = saveGetUnitFrame
|
||||
lib.GetFrame = saveGetUnitFrame
|
||||
if WeakAuras and WeakAuras.GetUnitFrame then
|
||||
WeakAuras.GetUnitFrame = saveGetUnitFrame
|
||||
end
|
||||
end
|
||||
|
||||
local GetFramesCacheListener
|
||||
local function Init(noDelay)
|
||||
GetFramesCacheListener = CreateFrame("Frame")
|
||||
GetFramesCacheListener:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||
GetFramesCacheListener:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
GetFramesCacheListener:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
GetFramesCacheListener:RegisterEvent("RAID_ROSTER_UPDATE")
|
||||
GetFramesCacheListener:RegisterEvent("PARTY_MEMBERS_CHANGED")
|
||||
GetFramesCacheListener:RegisterEvent("UNIT_PET")
|
||||
GetFramesCacheListener:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT")
|
||||
GetFramesCacheListener:SetScript("OnEvent", function(self, event, unit, ...)
|
||||
fixGetUnitFrameIntegrity()
|
||||
if event == "RAID_ROSTER_UPDATE" or event == "PARTY_MEMBERS_CHANGED" then
|
||||
wipe(unitPetState)
|
||||
for member in IterateGroupMembers() do
|
||||
unitPetState[member] = UnitExists(member .. "pet") and true or nil
|
||||
end
|
||||
end
|
||||
if event == "UNIT_PET" then
|
||||
if not (UnitIsUnit("player", unit) or UnitInParty(unit) or UnitInRaid(unit)) then
|
||||
return
|
||||
end
|
||||
-- skip if unit's pet existance has not changed
|
||||
local exists = UnitExists(unit .. "pet") and true or nil
|
||||
if unitPetState[unit] == exists then
|
||||
return
|
||||
else
|
||||
unitPetState[unit] = exists
|
||||
end
|
||||
end
|
||||
ScanForUnitFrames(false)
|
||||
end)
|
||||
ScanForUnitFrames(noDelay)
|
||||
end
|
||||
|
||||
function lib.GetUnitFrame(target, opt)
|
||||
if type(GetFramesCacheListener) ~= "table" then
|
||||
Init(true)
|
||||
end
|
||||
opt = opt or {}
|
||||
setmetatable(opt, { __index = defaultOptions })
|
||||
|
||||
if not target then
|
||||
return
|
||||
end
|
||||
|
||||
local ignoredFrames = CopyTable(opt.ignoreFrames)
|
||||
if opt.ignorePlayerFrame then
|
||||
for _, v in pairs(opt.playerFrames) do
|
||||
tinsert(ignoredFrames, v)
|
||||
end
|
||||
end
|
||||
if opt.ignoreTargetFrame then
|
||||
for _, v in pairs(opt.targetFrames) do
|
||||
tinsert(ignoredFrames, v)
|
||||
end
|
||||
end
|
||||
if opt.ignoreTargettargetFrame then
|
||||
for _, v in pairs(opt.targettargetFrames) do
|
||||
tinsert(ignoredFrames, v)
|
||||
end
|
||||
end
|
||||
if opt.ignorePartyFrame then
|
||||
for _, v in pairs(opt.partyFrames) do
|
||||
tinsert(ignoredFrames, v)
|
||||
end
|
||||
end
|
||||
if opt.ignorePartyTargetFrame then
|
||||
for _, v in pairs(opt.partyTargetFrames) do
|
||||
tinsert(ignoredFrames, v)
|
||||
end
|
||||
end
|
||||
if opt.ignoreFocusFrame then
|
||||
for _, v in pairs(opt.focusFrames) do
|
||||
tinsert(ignoredFrames, v)
|
||||
end
|
||||
end
|
||||
if opt.ignoreRaidFrame then
|
||||
for _, v in pairs(opt.raidFrames) do
|
||||
tinsert(ignoredFrames, v)
|
||||
end
|
||||
end
|
||||
|
||||
local frames = GetUnitFrames(target, ignoredFrames)
|
||||
|
||||
if not (opt.ignoreRaidFrame or opt.skipCellOverrides) then
|
||||
frames = CellGetUnitFrames(target, frames, opt.framePriorities)
|
||||
end
|
||||
|
||||
if not frames then
|
||||
return
|
||||
end
|
||||
|
||||
if not opt.returnAll then
|
||||
for i = 1, #opt.framePriorities do
|
||||
for frame, frameName in pairs(frames) do
|
||||
if frameName:find(opt.framePriorities[i]) then
|
||||
return ElvuiWorkaround(frame)
|
||||
end
|
||||
end
|
||||
end
|
||||
local next = next
|
||||
return ElvuiWorkaround(next(frames))
|
||||
else
|
||||
for frame in pairs(frames) do
|
||||
frames[frame] = ElvuiWorkaround(frame)
|
||||
end
|
||||
return frames
|
||||
end
|
||||
end
|
||||
saveGetUnitFrame = lib.GetUnitFrame
|
||||
lib.GetFrame = lib.GetUnitFrame -- compatibility
|
||||
|
||||
-- nameplates
|
||||
function lib.GetUnitNameplate(unit)
|
||||
if not unit then
|
||||
return
|
||||
end
|
||||
local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
|
||||
if nameplate then
|
||||
-- credit to Exality for https://wago.io/explosiveorbs
|
||||
if nameplate.UnitFrame and nameplate.UnitFrame.Health then
|
||||
-- ElvUI Bunny
|
||||
return nameplate.UnitFrame.Health:IsShown() and nameplate.UnitFrame.Health
|
||||
or nameplate.UnitFrame.Name:IsShown() and nameplate.UnitFrame.Name
|
||||
or nameplate
|
||||
|
||||
elseif nameplate.unitFrame and nameplate.unitFrame.Health then
|
||||
-- ElvUI Crum
|
||||
return nameplate.unitFrame.Health:IsShown() and nameplate.unitFrame.Health
|
||||
or nameplate.unitFrame.Name and nameplate.unitFrame.Name:IsShown() and nameplate.unitFrame.Name
|
||||
or nameplate
|
||||
|
||||
elseif nameplate.unitFramePlater and nameplate.unitFramePlater.healthBar then
|
||||
-- Plater
|
||||
-- fallback to default nameplate in case plater is not on screen and uses blizzard default (module disabled, force-blizzard functionality)
|
||||
return nameplate.unitFramePlater.PlaterOnScreen
|
||||
and nameplate.unitFramePlater.healthBar
|
||||
and nameplate.unitFramePlater.healthBar:IsShown() and nameplate.unitFramePlater.healthBar
|
||||
or (nameplate.UnitFrame and nameplate.UnitFrame.healthBar and nameplate.UnitFrame.healthBar:IsShown() and nameplate.UnitFrame.healthBar)
|
||||
or nameplate
|
||||
|
||||
elseif nameplate.kui and nameplate.kui.HealthBar then
|
||||
-- KuiNameplates
|
||||
return nameplate.kui.HealthBar:IsShown() and nameplate.kui.HealthBar
|
||||
or nameplate
|
||||
|
||||
elseif nameplate.extended and nameplate.extended.visual and nameplate.extended.visual.healthbar then
|
||||
-- TidyPlates
|
||||
return nameplate.extended.visual.healthbar:IsShown() and nameplate.extended.visual.healthbar
|
||||
or nameplate
|
||||
|
||||
elseif nameplate.TPFrame and nameplate.TPFrame.visual and nameplate.TPFrame.visual.healthbar then
|
||||
-- Threat Plates
|
||||
return nameplate.TPFrame.visual.healthbar:IsShown() and nameplate.TPFrame.visual.healthbar
|
||||
or nameplate
|
||||
|
||||
elseif nameplate.ouf and nameplate.ouf.Health then
|
||||
-- bdNameplates
|
||||
return nameplate.ouf.Health:IsShown() and nameplate.ouf.Health
|
||||
or nameplate
|
||||
|
||||
elseif nameplate.slab
|
||||
and nameplate.slab.components
|
||||
and nameplate.slab.components.healthBar
|
||||
and nameplate.slab.components.healthBar.frame then
|
||||
-- Slab
|
||||
return nameplate.slab.components.healthBar.frame:IsShown() and nameplate.slab.components.healthBar.frame
|
||||
or nameplate
|
||||
|
||||
elseif nameplate.UnitFrame and nameplate.UnitFrame.healthBar then
|
||||
-- default
|
||||
return nameplate.UnitFrame.healthBar:IsShown() and nameplate.UnitFrame.healthBar
|
||||
or nameplate
|
||||
|
||||
else
|
||||
return nameplate
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,13 +0,0 @@
|
||||
## Interface: 33000
|
||||
## Title: Lib: GetFrame
|
||||
## Notes: Get unit frame for a unit
|
||||
## Author: Buds
|
||||
## X-Category: Library
|
||||
## X-License: BSD
|
||||
## Version: 1.6.3
|
||||
## DefaultState: Enabled
|
||||
## LoadOnDemand: 0
|
||||
|
||||
LibStub\LibStub.lua
|
||||
|
||||
LibGetFrame-1.0.xml
|
||||
@@ -1,7 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file = "LibStub\LibStub.lua"/>
|
||||
<Include file ="CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
|
||||
<Include file = "AceTimer-3.0\AceTimer-3.0.xml"/>
|
||||
<Script file = "LibGetFrame-1.0.lua"/>
|
||||
</Ui>
|
||||
@@ -1,51 +0,0 @@
|
||||
-- $Id: LibStub.lua 103 2014-10-16 03:02:50Z mikk $
|
||||
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/addons/libstub/ for more info
|
||||
-- LibStub is hereby placed in the Public Domain
|
||||
-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
|
||||
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
|
||||
local LibStub = _G[LIBSTUB_MAJOR]
|
||||
|
||||
-- Check to see is this version of the stub is obsolete
|
||||
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
|
||||
LibStub = LibStub or {libs = {}, minors = {} }
|
||||
_G[LIBSTUB_MAJOR] = LibStub
|
||||
LibStub.minor = LIBSTUB_MINOR
|
||||
|
||||
-- LibStub:NewLibrary(major, minor)
|
||||
-- major (string) - the major version of the library
|
||||
-- minor (string or number ) - the minor version of the library
|
||||
--
|
||||
-- returns nil if a newer or same version of the lib is already present
|
||||
-- returns empty library object or old library object if upgrade is needed
|
||||
function LibStub:NewLibrary(major, minor)
|
||||
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
|
||||
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
|
||||
|
||||
local oldminor = self.minors[major]
|
||||
if oldminor and oldminor >= minor then return nil end
|
||||
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
|
||||
return self.libs[major], oldminor
|
||||
end
|
||||
|
||||
-- LibStub:GetLibrary(major, [silent])
|
||||
-- major (string) - the major version of the library
|
||||
-- silent (boolean) - if true, library is optional, silently return nil if its not found
|
||||
--
|
||||
-- throws an error if the library can not be found (except silent is set)
|
||||
-- returns the library object if found
|
||||
function LibStub:GetLibrary(major, silent)
|
||||
if not self.libs[major] and not silent then
|
||||
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
|
||||
end
|
||||
return self.libs[major], self.minors[major]
|
||||
end
|
||||
|
||||
-- LibStub:IterateLibraries()
|
||||
--
|
||||
-- Returns an iterator for the currently registered libraries
|
||||
function LibStub:IterateLibraries()
|
||||
return pairs(self.libs)
|
||||
end
|
||||
|
||||
setmetatable(LibStub, { __call = LibStub.GetLibrary })
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
## Interface: 80000
|
||||
## Title: Lib: LibStub
|
||||
## Notes: Universal Library Stub
|
||||
## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
|
||||
## X-Website: http://www.wowace.com/addons/libstub/
|
||||
## X-Category: Library
|
||||
## X-License: Public Domain
|
||||
|
||||
LibStub.lua
|
||||
@@ -1,41 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
|
||||
assert(lib) -- should return the library table
|
||||
assert(not oldMinor) -- should not return the old minor, since it didn't exist
|
||||
|
||||
-- the following is to create data and then be able to check if the same data exists after the fact
|
||||
function lib:MyMethod()
|
||||
end
|
||||
local MyMethod = lib.MyMethod
|
||||
lib.MyTable = {}
|
||||
local MyTable = lib.MyTable
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
|
||||
assert(not newLib) -- should not return since out of date
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
|
||||
assert(not newLib) -- should not return since out of date
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
|
||||
assert(newLib) -- library table
|
||||
assert(rawequal(newLib, lib)) -- should be the same reference as the previous
|
||||
assert(newOldMinor == 1) -- should return the minor version of the previous version
|
||||
|
||||
assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
|
||||
assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
|
||||
assert(newLib) -- library table
|
||||
assert(newOldMinor == 2) -- previous version was 2
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number)
|
||||
assert(newLib)
|
||||
assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
|
||||
assert(newLib)
|
||||
assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)
|
||||
@@ -1,27 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
for major, library in LibStub:IterateLibraries() do
|
||||
-- check that MyLib doesn't exist yet, by iterating through all the libraries
|
||||
assert(major ~= "MyLib")
|
||||
end
|
||||
|
||||
assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
|
||||
assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
|
||||
local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
|
||||
assert(lib) -- check it exists
|
||||
assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
|
||||
|
||||
assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
|
||||
|
||||
local count=0
|
||||
for major, library in LibStub:IterateLibraries() do
|
||||
-- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
|
||||
if major == "MyLib" then -- we found it!
|
||||
count = count +1
|
||||
assert(rawequal(library, lib)) -- verify that the references are equal
|
||||
end
|
||||
end
|
||||
assert(count == 1) -- verify that we actually found it, and only once
|
||||
@@ -1,14 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
local proxy = newproxy() -- non-string
|
||||
|
||||
assert(not pcall(LibStub.NewLibrary, LibStub, proxy, 1)) -- should error, proxy is not a string, it's userdata
|
||||
local success, ret = pcall(LibStub.GetLibrary, proxy, true)
|
||||
assert(not success or not ret) -- either error because proxy is not a string or because it's not actually registered.
|
||||
|
||||
assert(not pcall(LibStub.NewLibrary, LibStub, "Something", "No number in here")) -- should error, minor has no string in it.
|
||||
|
||||
assert(not LibStub:GetLibrary("Something", true)) -- shouldn't've created it from the above statement
|
||||
@@ -1,41 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
|
||||
-- Pretend like loaded libstub is old and doesn't have :IterateLibraries
|
||||
assert(LibStub.minor)
|
||||
LibStub.minor = LibStub.minor - 0.0001
|
||||
LibStub.IterateLibraries = nil
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(type(LibStub.IterateLibraries)=="function")
|
||||
|
||||
|
||||
-- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created
|
||||
LibStub.IterateLibraries = 123
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
-- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created
|
||||
LibStub.minor = LibStub.minor + 0.0001
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
-- Again with a huge number
|
||||
LibStub.minor = LibStub.minor + 1234567890
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
print("OK")
|
||||
@@ -1,187 +0,0 @@
|
||||
# LibGetFrame
|
||||
|
||||
Return unit frame for a given unit
|
||||
|
||||
## Usage
|
||||
|
||||
```Lua
|
||||
local LGF = LibStub("LibGetFrame-1.0")
|
||||
local frame = LGF.GetUnitFrame(unit , options)
|
||||
|
||||
local callback = function(event, frame, unit)
|
||||
if event == "GETFRAME_REFRESH" then
|
||||
-- cache was refreshed
|
||||
end
|
||||
if event == "FRAME_UNIT_UPDATE" then
|
||||
-- 'frame' was updated and is now a match for 'unit'
|
||||
end
|
||||
if event == "FRAME_UNIT_REMOVED" then
|
||||
-- 'frame' was updated and is no longer a match for 'unit'
|
||||
end
|
||||
end
|
||||
|
||||
LGF.RegisterCallback("MyAddonName", "GETFRAME_REFRESH", callback)
|
||||
LGF.RegisterCallback("MyAddonName", "FRAME_UNIT_UPDATE", callback)
|
||||
LGF.RegisterCallback("MyAddonName", "FRAME_UNIT_REMOVED", callback)
|
||||
|
||||
```
|
||||
|
||||
## Public functions
|
||||
|
||||
```Lua
|
||||
LGF:GetUnitFrame(unit, options)
|
||||
```
|
||||
|
||||
Options:
|
||||
|
||||
- framePriorities : array
|
||||
|
||||
- ignorePlayerFrame : boolean (default true)
|
||||
- ignoreTargetFrame : boolean (default true)
|
||||
- ignoreTargettargetFrame : boolean (default true)
|
||||
- ignorePartyFrame : boolean (default false)
|
||||
- ignorePartyTargetFrame : boolean (default true)
|
||||
- ignoreRaidFrame : boolean (default false)
|
||||
|
||||
- playerFrames : array
|
||||
- targetFrames : array
|
||||
- targettargetFrames : array
|
||||
- partyFrames : array
|
||||
- partyTargetFrames : array
|
||||
- raidFrames : array
|
||||
- ignoreFrames : array
|
||||
- returnAll : boolean (default false)
|
||||
|
||||
If returnAll is false, GetUnitFrame will return a single best match
|
||||
|
||||
For arrays check LibGetFrame-1.0.lua code for defaults
|
||||
|
||||
```Lua
|
||||
LGF:ScanForUnitFrames()
|
||||
```
|
||||
|
||||
Ask lib to do a new scan of frames.
|
||||
|
||||
This scan can take a few frames to be completed.
|
||||
|
||||
You should not expect the cache use by LGF:GetUnitFrame to be updated in the same frame as this ScanForUnitFrames call.
|
||||
|
||||
Use lib's callbacks to know when the cache is refresh.
|
||||
|
||||
```Lua
|
||||
LGF:GetUnitNameplate(unit)
|
||||
```
|
||||
|
||||
Return health bar for a nameplate unit, works with a variety of addons
|
||||
|
||||
|
||||
## Callbacks
|
||||
|
||||
```Lua
|
||||
-- Fired after a scan complete and cache refreshed
|
||||
LGF.RegisterCallback("MyAddonName", "GETFRAME_REFRESH", function(event) end)
|
||||
```
|
||||
|
||||
```Lua
|
||||
-- Fired when a frame is a new match for a unit (it does not test if it is the BEST match!)
|
||||
LGF.RegisterCallback("MyAddonName", "FRAME_UNIT_UPDATE", function(event, frame, unit) end)
|
||||
```
|
||||
|
||||
```Lua
|
||||
-- Fired when a frame is not a new match for a unit anymore
|
||||
LGF.RegisterCallback("MyAddonName", "FRAME_UNIT_REMOVED", function(event, frame, unit) end)
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Glow player frame
|
||||
|
||||
```Lua
|
||||
local LGF = LibStub("LibGetFrame-1.0")
|
||||
local LCG = LibStub("LibCustomGlow-1.0")
|
||||
local frame = LGF.GetUnitFrame("player")
|
||||
|
||||
if frame then
|
||||
LCG.ButtonGlow_Start(frame)
|
||||
-- LCG.ButtonGlow_Stop(frame)
|
||||
end
|
||||
```
|
||||
|
||||
### Glow every frames for your target
|
||||
|
||||
```Lua
|
||||
local LGF = LibStub("LibGetFrame-1.0")
|
||||
local LCG = LibStub("LibCustomGlow-1.0")
|
||||
|
||||
local frames = LGF.GetUnitFrame("target", {
|
||||
ignorePlayerFrame = false,
|
||||
ignoreTargetFrame = false,
|
||||
ignoreTargettargetFrame = false,
|
||||
returnAll = true,
|
||||
})
|
||||
|
||||
for _, frame in pairs(frames) do
|
||||
LCG.ButtonGlow_Start(frame)
|
||||
--LCG.ButtonGlow_Stop(frame)
|
||||
end
|
||||
```
|
||||
|
||||
### Ignore Vuhdo panel 2 and 3
|
||||
|
||||
```Lua
|
||||
local frame = LGF.GetUnitFrame("player", {
|
||||
ignoreFrames = { "Vd2.*", "Vd3.*" }
|
||||
})
|
||||
```
|
||||
|
||||
### Glow specific units and update glow when frames changes
|
||||
|
||||
```Lua
|
||||
local LGF = LibStub("LibGetFrame-1.0")
|
||||
local LCG = LibStub("LibCustomGlow-1.0")
|
||||
|
||||
-- list of units i want glowing
|
||||
local glow_units = {
|
||||
player = true
|
||||
}
|
||||
-- track which frame is glowing per unit
|
||||
local glow_unit_frames = {}
|
||||
|
||||
-- glow them using current cache
|
||||
for unit in pairs(glow_units) do
|
||||
local frame = LGF.GetUnitFrame("player")
|
||||
if frame then
|
||||
LCG.ButtonGlow_Start(frame)
|
||||
glow_unit_frames[unit] = frame
|
||||
end
|
||||
end
|
||||
|
||||
local callback = function(event, frame, unit)
|
||||
if not glow_units[unit] then
|
||||
return
|
||||
end
|
||||
-- new match for GetUnitFrame(unit), check if it's different from previous "best match" returned
|
||||
local new_best_match = LGF.GetUnitFrame(unit)
|
||||
if new_best_match == nil then
|
||||
-- didn't found a best match for this unit
|
||||
if glow_unit_frames[unit] then
|
||||
-- stop previous glow
|
||||
LCG.ButtonGlow_Stop(glow_unit_frames[unit])
|
||||
glow_unit_frames[unit] = nil
|
||||
end
|
||||
elseif new_best_match ~= glow_unit_frames[unit] then
|
||||
-- best match found, but different from previous one
|
||||
if glow_unit_frames[unit] then
|
||||
-- stop previous glow
|
||||
LCG.ButtonGlow_Stop(glow_unit_frames[unit])
|
||||
end
|
||||
LCG.ButtonGlow_Start(new_best_match)
|
||||
glow_unit_frames[unit] = new_best_match
|
||||
end
|
||||
end
|
||||
|
||||
LGF.RegisterCallback("MyAddonName", "FRAME_UNIT_UPDATE", callback)
|
||||
LGF.RegisterCallback("MyAddonName", "FRAME_UNIT_REMOVED", callback)
|
||||
```
|
||||
|
||||
[GitHub Project](https://github.com/mrbuds/LibGetFrame)
|
||||
@@ -1,5 +0,0 @@
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
column_width = 180
|
||||
line_endings = "Unix"
|
||||
quote_style = "ForceDouble"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,17 +0,0 @@
|
||||
## Interface: 30300
|
||||
## LoadOnDemand: 1
|
||||
## Title: Lib: GroupTalents-1.0
|
||||
## Notes: Library to help with querying unit talents.
|
||||
## Author: Zek
|
||||
## Version: $Rev: 51 $
|
||||
## OptionalDeps: Ace3, LibTalentQuery-1.0, LibBabble-TalentTree-3.0
|
||||
## X-Category: Library
|
||||
## X-ReleaseDate: $Date$
|
||||
## X-Website: http://wowace.com/wiki/LibGroupTalents-1.0
|
||||
## X-License: MIT
|
||||
## X-Curse-Packaged-Version: 3.3 Release 3
|
||||
## X-Curse-Project-Name: LibGroupTalents-1.0
|
||||
## X-Curse-Project-ID: libgrouptalents-1-0
|
||||
## X-Curse-Repository-ID: wow/libgrouptalents-1-0/mainline
|
||||
|
||||
lib.xml
|
||||
@@ -1,358 +0,0 @@
|
||||
--[[
|
||||
Name: LibTalentQuery-1.0
|
||||
Revision: $Rev: 84 $
|
||||
Author: Rich Martel (richmartel@gmail.com)
|
||||
Documentation: http://wowace.com/wiki/LibTalentQuery-1.0
|
||||
SVN: svn://svn.wowace.com/wow/libtalentquery-1-0/mainline/trunk
|
||||
Description: Library to help with querying unit talents
|
||||
Dependancies: LibStub, CallbackHandler-1.0
|
||||
License: LGPL v2.1
|
||||
|
||||
Example Usage:
|
||||
local TalentQuery = LibStub:GetLibrary("LibTalentQuery-1.0")
|
||||
TalentQuery.RegisterCallback(self, "TalentQuery_Ready")
|
||||
|
||||
local raidTalents = {}
|
||||
...
|
||||
TalentQuery:Query(unit)
|
||||
...
|
||||
function MyAddon:TalentQuery_Ready(e, name, realm, unitid)
|
||||
local isnotplayer = not UnitIsUnit(unitid, "player")
|
||||
local spec = {}
|
||||
for tab = 1, GetNumTalentTabs(isnotplayer) do
|
||||
local treename, _, pointsspent = GetTalentTabInfo(tab, isnotplayer)
|
||||
tinsert(spec, pointsspent)
|
||||
end
|
||||
raidTalents[UnitGUID(unitid)] = spec
|
||||
end
|
||||
]]
|
||||
|
||||
local MAJOR, MINOR = "LibTalentQuery-1.0", 90000 + tonumber(("$Rev: 84 $"):match("(%d+)"))
|
||||
|
||||
local lib = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
if not lib then return end
|
||||
|
||||
local INSPECTDELAY = 1
|
||||
local INSPECTTIMEOUT = 5
|
||||
if not lib.events then
|
||||
lib.events = LibStub("CallbackHandler-1.0"):New(lib)
|
||||
end
|
||||
|
||||
local validateTrees
|
||||
local enteredWorld = IsLoggedIn()
|
||||
local frame = lib.frame
|
||||
if not frame then
|
||||
frame = CreateFrame("Frame", MAJOR .. "_Frame")
|
||||
lib.frame = frame
|
||||
end
|
||||
frame:UnregisterAllEvents()
|
||||
frame:RegisterEvent("INSPECT_TALENT_READY")
|
||||
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
frame:RegisterEvent("PLAYER_LEAVING_WORLD")
|
||||
frame:RegisterEvent("PLAYER_LOGIN")
|
||||
frame:SetScript("OnEvent", function(this, event, ...)
|
||||
return lib[event](lib, ...)
|
||||
end)
|
||||
|
||||
do
|
||||
local lastUpdateTime = 0
|
||||
frame:SetScript("OnUpdate", function(this, elapsed)
|
||||
lastUpdateTime = lastUpdateTime + elapsed
|
||||
if lastUpdateTime > INSPECTDELAY then
|
||||
lib:CheckInspectQueue()
|
||||
lastUpdateTime = 0
|
||||
end
|
||||
end)
|
||||
frame:Hide()
|
||||
end
|
||||
|
||||
local inspectQueue = lib.inspectQueue or {}
|
||||
lib.inspectQueue = inspectQueue
|
||||
local garbageQueue = lib.garbageQueue or {} -- Added a second queue to things. Inspects that initially fail are now
|
||||
lib.garbageQueue = garbageQueue -- thrown into second queue will will be processed once main queue is empty
|
||||
|
||||
if next(inspectQueue) then
|
||||
frame:Show()
|
||||
end
|
||||
|
||||
local UnitIsPlayer = _G.UnitIsPlayer
|
||||
local UnitName = _G.UnitName
|
||||
local UnitExists = _G.UnitExists
|
||||
local UnitGUID = _G.UnitGUID
|
||||
local GetNumRaidMembers = _G.GetNumRaidMembers
|
||||
local GetNumPartyMembers = _G.GetNumPartyMembers
|
||||
local UnitIsVisible = _G.UnitIsVisible
|
||||
local UnitIsConnected = _G.UnitIsConnected
|
||||
local UnitCanAttack = _G.UnitCanAttack
|
||||
local CanInspect = _G.CanInspect
|
||||
|
||||
local function UnitFullName(unit)
|
||||
local name, realm = UnitName(unit)
|
||||
local namerealm = realm and realm ~= "" and name .. "-" .. realm or name
|
||||
return namerealm
|
||||
end
|
||||
|
||||
-- GuidToUnitID
|
||||
local function GuidToUnitID(guid)
|
||||
local prefix, min, max = "raid", 1, GetNumRaidMembers()
|
||||
if max == 0 then
|
||||
prefix, min, max = "party", 0, GetNumPartyMembers()
|
||||
end
|
||||
|
||||
-- Prioritise getting direct units first because other players targets
|
||||
-- can change between notify and event which can bugger things up
|
||||
for i = min, max do
|
||||
local unit = i == 0 and "player" or prefix .. i
|
||||
if (UnitGUID(unit) == guid) then
|
||||
return unit
|
||||
end
|
||||
end
|
||||
|
||||
-- This properly detects target units
|
||||
if (UnitGUID("target") == guid) then
|
||||
return "target"
|
||||
elseif (UnitGUID("focus") == guid) then
|
||||
return "focus"
|
||||
elseif (UnitGUID("mouseover") == guid) then
|
||||
return "mouseover"
|
||||
end
|
||||
|
||||
for i = min, max + 3 do
|
||||
local unit
|
||||
if i == 0 then
|
||||
unit = "player"
|
||||
elseif i == max + 1 then
|
||||
unit = "target"
|
||||
elseif i == max + 2 then
|
||||
unit = "focus"
|
||||
elseif i == max + 3 then
|
||||
unit = "mouseover"
|
||||
else
|
||||
unit = prefix .. i
|
||||
end
|
||||
if (UnitGUID(unit .. "target") == guid) then
|
||||
return unit .. "target"
|
||||
elseif (i <= max and UnitGUID(unit.."pettarget") == guid) then
|
||||
return unit .. "pettarget"
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Query
|
||||
function lib:Query(unit)
|
||||
if (UnitLevel(unit) < 10 or UnitName(unit) == UNKNOWN) then
|
||||
return
|
||||
end
|
||||
|
||||
self.lastQueuedInspectReceived = nil
|
||||
if UnitIsUnit(unit, "player") then
|
||||
self.events:Fire("TalentQuery_Ready", UnitName("player"), nil, "player")
|
||||
else
|
||||
if type(unit) ~= "string" then
|
||||
error(("Bad argument #2 to 'Query'. Expected %q, received %q (%s)"):format("string", type(unit), tostring(unit)), 2)
|
||||
elseif not UnitExists(unit) or not UnitIsPlayer(unit) then
|
||||
error(("Bad argument #2 to 'Query'. %q is not a valid player unit"):format(tostring(unit)), 2)
|
||||
elseif not UnitExists(unit) or not UnitIsPlayer(unit) then
|
||||
error(("Bad argument #2 to 'Query'. %q does not require a server query before reading talents"):format("player"), 2)
|
||||
else
|
||||
local name = UnitFullName(unit)
|
||||
if (not inspectQueue[name]) then
|
||||
inspectQueue[name] = UnitGUID(unit)
|
||||
garbageQueue[name] = nil
|
||||
end
|
||||
frame:Show()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- CheckInspectQueue
|
||||
-- Originally, it would wait until no pending NotifyInspect() were expected, and then do it's own.
|
||||
-- It was also only bother looking at ready results if it had triggered the Notify for that occasion.
|
||||
-- For the changes I've done, no assumption is made about which mod is performing NotifyInspect().
|
||||
-- We note the name, unit, time of any inspects done whether from this queue or any other source,
|
||||
-- we remove from our queue any we were expecting, and use a seperate event in case extra talent
|
||||
-- info is any time wanted (opportunistic refreshes etc) - Zeksie, 20th May 2009
|
||||
function lib:CheckInspectQueue()
|
||||
if (_G.InspectFrame and _G.InspectFrame:IsShown()) then
|
||||
return
|
||||
end
|
||||
|
||||
if (not self.lastInspectTime or self.lastInspectTime < GetTime() - INSPECTTIMEOUT) then
|
||||
self.lastInspectPending = 0
|
||||
end
|
||||
|
||||
if (self.lastInspectPending > 0 or not enteredWorld) then
|
||||
return
|
||||
end
|
||||
|
||||
if (self.lastQueuedInspectReceived and self.lastQueuedInspectReceived < GetTime() - 60) then
|
||||
-- No queued results received for a minute, so purge the queue as invalid and move on with our lives
|
||||
self.lastQueuedInspectReceived = nil
|
||||
inspectQueue = {}
|
||||
lib.inspectQueue = inspectQueue
|
||||
garbageQueue = {}
|
||||
lib.garbageQueue = garbageQueue
|
||||
frame:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
for name,guid in pairs(inspectQueue) do
|
||||
local unit = GuidToUnitID(guid)
|
||||
if (not unit) then
|
||||
inspectQueue[name] = nil
|
||||
else
|
||||
if (UnitIsVisible(unit) and UnitIsConnected(unit) and not UnitCanAttack("player", unit) and not UnitCanAttack(unit, "player") and CanInspect(unit) and UnitClass(unit)) then
|
||||
NotifyInspect(unit)
|
||||
break
|
||||
else
|
||||
garbageQueue[name] = guid -- Not available, throw into secondary queue and continue
|
||||
inspectQueue[name] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (not next(inspectQueue)) then
|
||||
if (next(garbageQueue)) then
|
||||
-- Retry initially failed inspects
|
||||
lib.inspectQueue = garbageQueue
|
||||
inspectQueue = lib.inspectQueue
|
||||
lib.garbageQueue = {}
|
||||
garbageQueue = lib.garbageQueue
|
||||
else
|
||||
frame:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- NotifyInspect
|
||||
if not lib.NotifyInspect then -- don't hook twice
|
||||
hooksecurefunc("NotifyInspect", function(...) return lib:NotifyInspect(...) end)
|
||||
end
|
||||
function lib:NotifyInspect(unit)
|
||||
if (not (UnitExists(unit) and UnitIsVisible(unit) and UnitIsConnected(unit) and CheckInteractDistance(unit, 4))) then
|
||||
return
|
||||
end
|
||||
self.lastInspectUnit = unit
|
||||
self.lastInspectGUID = UnitGUID(unit)
|
||||
self.lastInspectTime = GetTime()
|
||||
self.lastInspectName = UnitFullName(unit)
|
||||
self.lastInspectPending = self.lastInspectPending + 1
|
||||
local isnotplayer = not UnitIsUnit("player", unit)
|
||||
self.lastInspectTree = GetTalentTabInfo(1, isnotplayer) -- Talent tree names are available immediately
|
||||
end
|
||||
|
||||
-- Reset
|
||||
function lib:Reset()
|
||||
self.lastInspectPending = 0
|
||||
self.lastInspectUnit = nil
|
||||
self.lastInspectTime = nil
|
||||
self.lastInspectName = nil
|
||||
self.lastInspectGUID = nil
|
||||
self.lastInspectTree = nil
|
||||
end
|
||||
|
||||
-- INSPECT_TALENT_READY
|
||||
function lib:INSPECT_TALENT_READY()
|
||||
self.lastInspectPending = self.lastInspectPending - 1
|
||||
|
||||
-- Results are valid only when we have received as many events as we have posted notifies
|
||||
if (self.lastInspectName and self.lastInspectPending == 0) then
|
||||
-- Check unit ID is still pointing to same actual unit
|
||||
if (UnitGUID(self.lastInspectUnit) == self.lastInspectGUID) then
|
||||
local guid = inspectQueue[self.lastInspectName]
|
||||
inspectQueue[self.lastInspectName] = nil
|
||||
|
||||
local name, realm = strsplit("-", self.lastInspectName)
|
||||
|
||||
self.lastQueuedInspectReceived = GetTime()
|
||||
|
||||
-- Notify of expected talent results
|
||||
local isnotplayer = not UnitIsUnit("player", self.lastInspectName)
|
||||
local group = GetActiveTalentGroup(isnotplayer)
|
||||
local tree1, _, spent1 = GetTalentTabInfo(1, isnotplayer, nil, group)
|
||||
if (tree1 ~= self.lastInspectTree) then
|
||||
-- Expected talent tree name to be the same as it was when we triggered the NotifyInspect()
|
||||
garbageQueue[self.lastInspectName] = self.lastInspectGUID
|
||||
self:Reset()
|
||||
self:CheckInspectQueue()
|
||||
return
|
||||
|
||||
elseif (validateTrees) then
|
||||
-- Double checking here. Check the tree name matches what we expect for this class
|
||||
local _, class = UnitClass(self.lastInspectUnit)
|
||||
if (tree1 ~= validateTrees[class]) then
|
||||
garbageQueue[self.lastInspectName] = self.lastInspectGUID
|
||||
self:Reset()
|
||||
self:CheckInspectQueue()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local tree2, _, spent2 = GetTalentTabInfo(2, isnotplayer, nil, group)
|
||||
local tree3, _, spent3 = GetTalentTabInfo(3, isnotplayer, nil, group)
|
||||
if ((spent1 or 0) + (spent2 or 0) + (spent3 or 0) > 0) then
|
||||
if (guid) then
|
||||
-- It was in our queue
|
||||
self.events:Fire("TalentQuery_Ready", name, realm, self.lastInspectUnit)
|
||||
else
|
||||
-- Also notify of non-expected ones, as it's entirely useful to refresh them if they're there
|
||||
-- It is up to the receiving applicating to determine whether they want to receive the information
|
||||
self.events:Fire("TalentQuery_Ready_Outsider", name, realm, self.lastInspectUnit)
|
||||
end
|
||||
else
|
||||
-- Tree came back with zero points spent, probably an issue while logging in
|
||||
garbageQueue[self.lastInspectName] = guid
|
||||
end
|
||||
end
|
||||
|
||||
self:Reset()
|
||||
self:CheckInspectQueue()
|
||||
end
|
||||
end
|
||||
|
||||
function lib:PLAYER_ENTERING_WORLD()
|
||||
-- We can't inspect other's talents until now
|
||||
-- We just get 0/0/0 back even though we get an INSPECT_TALENT_READY event
|
||||
enteredWorld = true
|
||||
end
|
||||
|
||||
function lib:PLAYER_LEAVING_WORLD()
|
||||
enteredWorld = nil
|
||||
end
|
||||
|
||||
function lib:PLAYER_LOGIN()
|
||||
validateTrees = {
|
||||
DRUID = "Balance",
|
||||
PRIEST = "Discipline",
|
||||
ROGUE = "Assassination",
|
||||
HUNTER = "Beast Mastery",
|
||||
WARLOCK = "Affliction",
|
||||
WARRIOR = "Arms",
|
||||
DEATHKNIGHT = "Blood",
|
||||
PALADIN = "Holy",
|
||||
SHAMAN = "Elemental",
|
||||
MAGE = "Arcane",
|
||||
}
|
||||
|
||||
if (GetLocale() ~= "enUS" and GetLocale() ~= "enGB") then
|
||||
-- LibBabble-TalentTree-3.0 only loaded if present and not enUS
|
||||
local LBT = LibStub("LibBabble-TalentTree-3.0", true)
|
||||
if (not LBT) then
|
||||
LoadAddOn("LibBabble-TalentTree-3.0")
|
||||
LBT = LibStub("LibBabble-TalentTree-3.0", true)
|
||||
end
|
||||
LBT = LBT and LBT:GetLookupTable()
|
||||
if (LBT) then
|
||||
for class,tree1 in pairs(validateTrees) do
|
||||
validateTrees[class] = LBT[tree1]
|
||||
end
|
||||
else
|
||||
validateTrees = nil
|
||||
end
|
||||
end
|
||||
|
||||
self.PLAYER_LOGIN = nil
|
||||
end
|
||||
|
||||
lib:Reset()
|
||||
@@ -1,5 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="LibTalentQuery-1.0.lua"/>
|
||||
<Script file="LibGroupTalents-1.0.lua"/>
|
||||
</Ui>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,4 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="LibSerialize.lua" />
|
||||
</Ui>
|
||||
@@ -1,246 +0,0 @@
|
||||
--[[
|
||||
Name: LibSharedMedia-3.0
|
||||
Revision: $Revision: 62 $
|
||||
Author: Elkano (elkano@gmx.de)
|
||||
Inspired By: SurfaceLib by Haste/Otravi (troeks@gmail.com)
|
||||
Website: http://www.wowace.com/projects/libsharedmedia-3-0/
|
||||
Description: Shared handling of media data (fonts, sounds, textures, ...) between addons.
|
||||
Dependencies: LibStub, CallbackHandler-1.0
|
||||
License: LGPL v2.1
|
||||
]]
|
||||
|
||||
local MAJOR, MINOR = "LibSharedMedia-3.0", 3030002 -- 3.3.5 / increase manually on changes
|
||||
local lib = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not lib then return end
|
||||
|
||||
local _G = getfenv(0)
|
||||
|
||||
local pairs = _G.pairs
|
||||
local type = _G.type
|
||||
|
||||
local band = _G.bit.band
|
||||
local table_sort = _G.table.sort
|
||||
|
||||
local locale = GetLocale()
|
||||
local locale_is_western
|
||||
local LOCALE_MASK = 0
|
||||
lib.LOCALE_BIT_koKR = 1
|
||||
lib.LOCALE_BIT_ruRU = 2
|
||||
lib.LOCALE_BIT_zhCN = 4
|
||||
lib.LOCALE_BIT_zhTW = 8
|
||||
lib.LOCALE_BIT_western = 128
|
||||
|
||||
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
|
||||
|
||||
lib.callbacks = lib.callbacks or CallbackHandler:New(lib)
|
||||
|
||||
lib.DefaultMedia = lib.DefaultMedia or {}
|
||||
lib.MediaList = lib.MediaList or {}
|
||||
lib.MediaTable = lib.MediaTable or {}
|
||||
lib.MediaType = lib.MediaType or {}
|
||||
lib.OverrideMedia = lib.OverrideMedia or {}
|
||||
|
||||
local defaultMedia = lib.DefaultMedia
|
||||
local mediaList = lib.MediaList
|
||||
local mediaTable = lib.MediaTable
|
||||
local overrideMedia = lib.OverrideMedia
|
||||
|
||||
|
||||
-- create mediatype constants
|
||||
lib.MediaType.BACKGROUND = "background" -- background textures
|
||||
lib.MediaType.BORDER = "border" -- border textures
|
||||
lib.MediaType.FONT = "font" -- fonts
|
||||
lib.MediaType.STATUSBAR = "statusbar" -- statusbar textures
|
||||
lib.MediaType.SOUND = "sound" -- sound files
|
||||
|
||||
-- populate lib with default Blizzard data
|
||||
-- BACKGROUND
|
||||
if not lib.MediaTable.background then lib.MediaTable.background = {} end
|
||||
lib.MediaTable.background["None"] = [[]]
|
||||
lib.MediaTable.background["Blizzard Dialog Background"] = [[Interface\DialogFrame\UI-DialogBox-Background]]
|
||||
lib.MediaTable.background["Blizzard Dialog Background Dark"] = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]]
|
||||
lib.MediaTable.background["Blizzard Dialog Background Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]
|
||||
lib.MediaTable.background["Blizzard Low Health"] = [[Interface\FullScreenTextures\LowHealth]]
|
||||
lib.MediaTable.background["Blizzard Marble"] = [[Interface\FrameGeneral\UI-Background-Marble]]
|
||||
lib.MediaTable.background["Blizzard Out of Control"] = [[Interface\FullScreenTextures\OutOfControl]]
|
||||
lib.MediaTable.background["Blizzard Parchment"] = [[Interface\AchievementFrame\UI-Achievement-Parchment-Horizontal]]
|
||||
lib.MediaTable.background["Blizzard Parchment 2"] = [[Interface\AchievementFrame\UI-GuildAchievement-Parchment-Horizontal]]
|
||||
lib.MediaTable.background["Blizzard Rock"] = [[Interface\FrameGeneral\UI-Background-Rock]]
|
||||
lib.MediaTable.background["Blizzard Tabard Background"] = [[Interface\TabardFrame\TabardFrameBackground]]
|
||||
lib.MediaTable.background["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Background]]
|
||||
lib.MediaTable.background["Solid"] = [[Interface\Buttons\WHITE8X8]]
|
||||
lib.DefaultMedia.background = "None"
|
||||
|
||||
-- BORDER
|
||||
if not lib.MediaTable.border then lib.MediaTable.border = {} end
|
||||
lib.MediaTable.border["None"] = [[]]
|
||||
lib.MediaTable.border["Blizzard Achievement Wood"] = [[Interface\AchievementFrame\UI-Achievement-WoodBorder]]
|
||||
lib.MediaTable.border["Blizzard Chat Bubble"] = [[Interface\Tooltips\ChatBubble-Backdrop]]
|
||||
lib.MediaTable.border["Blizzard Dialog"] = [[Interface\DialogFrame\UI-DialogBox-Border]]
|
||||
lib.MediaTable.border["Blizzard Dialog Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Border]]
|
||||
lib.MediaTable.border["Blizzard Party"] = [[Interface\CHARACTERFRAME\UI-Party-Border]]
|
||||
lib.MediaTable.border["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Border]]
|
||||
lib.DefaultMedia.border = "None"
|
||||
|
||||
-- FONT
|
||||
if not lib.MediaTable.font then lib.MediaTable.font = {} end
|
||||
local SML_MT_font = lib.MediaTable.font
|
||||
if locale == "koKR" then
|
||||
LOCALE_MASK = lib.LOCALE_BIT_koKR
|
||||
--
|
||||
SML_MT_font["굵은 글꼴"] = [[Fonts\2002B.TTF]]
|
||||
SML_MT_font["기본 글꼴"] = [[Fonts\2002.TTF]]
|
||||
SML_MT_font["데미지 글꼴"] = [[Fonts\K_Damage.TTF]]
|
||||
SML_MT_font["퀘스트 글꼴"] = [[Fonts\K_Pagetext.TTF]]
|
||||
--
|
||||
lib.DefaultMedia["font"] = "기본 글꼴" -- someone from koKR please adjust if needed
|
||||
--
|
||||
elseif locale == "zhCN" then
|
||||
LOCALE_MASK = lib.LOCALE_BIT_zhCN
|
||||
--
|
||||
SML_MT_font["伤害数字"] = [[Fonts\ZYKai_C.ttf]]
|
||||
SML_MT_font["默认"] = [[Fonts\ZYKai_T.ttf]]
|
||||
SML_MT_font["聊天"] = [[Fonts\ZYHei.ttf]]
|
||||
--
|
||||
lib.DefaultMedia["font"] = "默认" -- someone from zhCN please adjust if needed
|
||||
--
|
||||
elseif locale == "zhTW" then
|
||||
LOCALE_MASK = lib.LOCALE_BIT_zhTW
|
||||
--
|
||||
SML_MT_font["提示訊息"] = [[Fonts\bHEI00M.ttf]]
|
||||
SML_MT_font["聊天"] = [[Fonts\bHEI01B.ttf]]
|
||||
SML_MT_font["傷害數字"] = [[Fonts\bKAI00M.ttf]]
|
||||
SML_MT_font["預設"] = [[Fonts\bLEI00D.ttf]]
|
||||
--
|
||||
lib.DefaultMedia["font"] = "預設" -- someone from zhTW please adjust if needed
|
||||
|
||||
elseif locale == "ruRU" then
|
||||
LOCALE_MASK = lib.LOCALE_BIT_ruRU
|
||||
--
|
||||
SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
|
||||
SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]]
|
||||
SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS.TTF]]
|
||||
SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]]
|
||||
SML_MT_font["Skurri"] = [[Fonts\SKURRI.TTF]]
|
||||
--
|
||||
lib.DefaultMedia.font = "Arial Narrow"
|
||||
--
|
||||
else
|
||||
LOCALE_MASK = lib.LOCALE_BIT_western
|
||||
locale_is_western = true
|
||||
--
|
||||
SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
|
||||
SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]]
|
||||
SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS.TTF]]
|
||||
SML_MT_font["Skurri"] = [[Fonts\SKURRI.TTF]]
|
||||
--
|
||||
lib.DefaultMedia.font = "Friz Quadrata TT"
|
||||
--
|
||||
end
|
||||
|
||||
-- STATUSBAR
|
||||
if not lib.MediaTable.statusbar then lib.MediaTable.statusbar = {} end
|
||||
lib.MediaTable.statusbar["Blizzard"] = [[Interface\TargetingFrame\UI-StatusBar]]
|
||||
lib.MediaTable.statusbar["Blizzard Character Skills Bar"] = [[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]]
|
||||
lib.MediaTable.statusbar["Solid"] = [[Interface\Buttons\WHITE8X8]]
|
||||
lib.DefaultMedia.statusbar = "Blizzard"
|
||||
|
||||
-- SOUND
|
||||
if not lib.MediaTable.sound then lib.MediaTable.sound = {} end
|
||||
lib.MediaTable.sound["None"] = [[Interface\Quiet.ogg]] -- Relies on the fact that PlaySound[File] doesn't error on these values.
|
||||
lib.DefaultMedia.sound = "None"
|
||||
|
||||
local function rebuildMediaList(mediatype)
|
||||
local mtable = mediaTable[mediatype]
|
||||
if not mtable then return end
|
||||
if not mediaList[mediatype] then mediaList[mediatype] = {} end
|
||||
local mlist = mediaList[mediatype]
|
||||
-- list can only get larger, so simply overwrite it
|
||||
local i = 0
|
||||
for k in pairs(mtable) do
|
||||
i = i + 1
|
||||
mlist[i] = k
|
||||
end
|
||||
table_sort(mlist)
|
||||
end
|
||||
|
||||
function lib:Register(mediatype, key, data, langmask)
|
||||
if type(mediatype) ~= "string" then
|
||||
error(MAJOR..":Register(mediatype, key, data, langmask) - mediatype must be string, got "..type(mediatype))
|
||||
end
|
||||
if type(key) ~= "string" then
|
||||
error(MAJOR..":Register(mediatype, key, data, langmask) - key must be string, got "..type(key))
|
||||
end
|
||||
mediatype = mediatype:lower()
|
||||
if mediatype == lib.MediaType.FONT and ((langmask and band(langmask, LOCALE_MASK) == 0) or not (langmask or locale_is_western)) then
|
||||
-- ignore fonts that aren't flagged as supporting local glyphs on non-western clients
|
||||
return false
|
||||
end
|
||||
if mediatype == lib.MediaType.SOUND and type(data) == "string" then
|
||||
local path = data:lower()
|
||||
if not path:find(".ogg", nil, true) and not path:find(".mp3", nil, true) and not path:find(".wav", nil, true) then
|
||||
-- Only wav, ogg and mp3 are valid sounds.
|
||||
return false
|
||||
end
|
||||
end
|
||||
if not mediaTable[mediatype] then mediaTable[mediatype] = {} end
|
||||
local mtable = mediaTable[mediatype]
|
||||
if mtable[key] then return false end
|
||||
|
||||
mtable[key] = data
|
||||
rebuildMediaList(mediatype)
|
||||
self.callbacks:Fire("LibSharedMedia_Registered", mediatype, key)
|
||||
return true
|
||||
end
|
||||
|
||||
function lib:Fetch(mediatype, key, noDefault)
|
||||
local mtt = mediaTable[mediatype]
|
||||
local overridekey = overrideMedia[mediatype]
|
||||
local result = mtt and ((overridekey and mtt[overridekey] or mtt[key]) or (not noDefault and defaultMedia[mediatype] and mtt[defaultMedia[mediatype]])) or nil
|
||||
return result ~= "" and result or nil
|
||||
end
|
||||
|
||||
function lib:IsValid(mediatype, key)
|
||||
return mediaTable[mediatype] and (not key or mediaTable[mediatype][key]) and true or false
|
||||
end
|
||||
|
||||
function lib:HashTable(mediatype)
|
||||
return mediaTable[mediatype]
|
||||
end
|
||||
|
||||
function lib:List(mediatype)
|
||||
if not mediaTable[mediatype] then
|
||||
return nil
|
||||
end
|
||||
if not mediaList[mediatype] then
|
||||
rebuildMediaList(mediatype)
|
||||
end
|
||||
return mediaList[mediatype]
|
||||
end
|
||||
|
||||
function lib:GetGlobal(mediatype)
|
||||
return overrideMedia[mediatype]
|
||||
end
|
||||
|
||||
function lib:SetGlobal(mediatype, key)
|
||||
if not mediaTable[mediatype] then
|
||||
return false
|
||||
end
|
||||
overrideMedia[mediatype] = (key and mediaTable[mediatype][key]) and key or nil
|
||||
self.callbacks:Fire("LibSharedMedia_SetGlobal", mediatype, overrideMedia[mediatype])
|
||||
return true
|
||||
end
|
||||
|
||||
function lib:GetDefault(mediatype)
|
||||
return defaultMedia[mediatype]
|
||||
end
|
||||
|
||||
function lib:SetDefault(mediatype, key)
|
||||
if mediaTable[mediatype] and mediaTable[mediatype][key] and not defaultMedia[mediatype] then
|
||||
defaultMedia[mediatype] = key
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="LibSharedMedia-3.0.lua" />
|
||||
</Ui>
|
||||
@@ -1,235 +0,0 @@
|
||||
--- = Background =
|
||||
-- Blizzard's IsSpellInRange API has always been very limited - you either must have the name of the spell, or its spell book ID. Checking directly by spellID is simply not possible.
|
||||
-- Now, in Mists of Pandaria, Blizzard changed the way that many talents and specialization spells work - instead of giving you a new spell when leaned, they replace existing spells. These replacement spells do not work with Blizzard's IsSpellInRange function whatsoever; this limitation is what prompted the creation of this lib.
|
||||
-- = Usage =
|
||||
-- **LibSpellRange-1.0** exposes an enhanced version of IsSpellInRange that:
|
||||
-- * Allows ranged checking based on both spell name and spellID.
|
||||
-- * Works correctly with replacement spells that will not work using Blizzard's IsSpellInRange method alone.
|
||||
--
|
||||
-- @class file
|
||||
-- @name LibSpellRange-1.0.lua
|
||||
|
||||
local major = "SpellRange-1.0"
|
||||
local minor = 19
|
||||
|
||||
assert(LibStub, format("%s requires LibStub.", major))
|
||||
|
||||
local Lib = LibStub:NewLibrary(major, minor)
|
||||
if not Lib then return end
|
||||
|
||||
local tonumber = _G.tonumber
|
||||
local strlower = _G.strlower
|
||||
local wipe = _G.wipe
|
||||
local type = _G.type
|
||||
|
||||
local GetSpellInfo = _G.GetSpellInfo
|
||||
local GetSpellLink = _G.GetSpellLink
|
||||
local GetSpellName = _G.GetSpellName
|
||||
local GetSpellTabInfo = _G.GetSpellTabInfo
|
||||
|
||||
local IsSpellInRange = _G.IsSpellInRange
|
||||
local SpellHasRange = _G.SpellHasRange
|
||||
|
||||
local MAX_SKILLLINE_TABS = _G.MAX_SKILLLINE_TABS
|
||||
|
||||
-- isNumber is basically a tonumber cache for maximum efficiency
|
||||
Lib.isNumber = Lib.isNumber or setmetatable({}, {
|
||||
__mode = "kv",
|
||||
__index = function(t, i)
|
||||
local o = tonumber(i) or false
|
||||
t[i] = o
|
||||
return o
|
||||
end})
|
||||
local isNumber = Lib.isNumber
|
||||
|
||||
-- strlower cache for maximum efficiency
|
||||
Lib.strlowerCache = Lib.strlowerCache or setmetatable(
|
||||
{}, {
|
||||
__index = function(t, i)
|
||||
if not i then return end
|
||||
local o
|
||||
if type(i) == "number" then
|
||||
o = i
|
||||
else
|
||||
o = strlower(i)
|
||||
end
|
||||
t[i] = o
|
||||
return o
|
||||
end,
|
||||
}) local strlowerCache = Lib.strlowerCache
|
||||
|
||||
-- Matches lowercase player spell names to their spellBookID
|
||||
Lib.spellsByName_spell = Lib.spellsByName_spell or {}
|
||||
local spellsByName_spell = Lib.spellsByName_spell
|
||||
|
||||
-- Matches player spellIDs to their spellBookID
|
||||
Lib.spellsByID_spell = Lib.spellsByID_spell or {}
|
||||
local spellsByID_spell = Lib.spellsByID_spell
|
||||
|
||||
-- Matches lowercase pet spell names to their spellBookID
|
||||
Lib.spellsByName_pet = Lib.spellsByName_pet or {}
|
||||
local spellsByName_pet = Lib.spellsByName_pet
|
||||
|
||||
-- Matches pet spellIDs to their spellBookID
|
||||
Lib.spellsByID_pet = Lib.spellsByID_pet or {}
|
||||
local spellsByID_pet = Lib.spellsByID_pet
|
||||
|
||||
local blacklistedIDs = {}
|
||||
|
||||
-- Updates spellsByName and spellsByID
|
||||
local function UpdateBook(bookType)
|
||||
local _, offs, numspells
|
||||
local max = 0
|
||||
|
||||
for i = MAX_SKILLLINE_TABS, 1, -1 do
|
||||
_, _, offs, numspells = GetSpellTabInfo(i)
|
||||
|
||||
if numspells > 0 then
|
||||
max = offs + numspells
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local spellsByName = Lib["spellsByName_" .. bookType]
|
||||
local spellsByID = Lib["spellsByID_" .. bookType]
|
||||
|
||||
wipe(spellsByName)
|
||||
wipe(spellsByID)
|
||||
wipe(blacklistedIDs)
|
||||
|
||||
for spellBookID = 1, max do
|
||||
local spellName, rank = GetSpellName(spellBookID, bookType)
|
||||
|
||||
if spellName and (rank == "" or rank:match("%d+")) then
|
||||
local link = GetSpellLink(spellName, rank)
|
||||
local spellID = tonumber(link and link:gsub("|", "||"):match("spell:(%d+)"))
|
||||
|
||||
if spellName then
|
||||
spellsByName[strlower(spellName)] = spellBookID
|
||||
end
|
||||
|
||||
if spellID then
|
||||
spellsByID[spellID] = spellBookID
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Handles updating spellsByName and spellsByID
|
||||
if not Lib.updaterFrame then
|
||||
Lib.updaterFrame = CreateFrame("Frame")
|
||||
end
|
||||
Lib.updaterFrame:UnregisterAllEvents()
|
||||
Lib.updaterFrame:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
Lib.updaterFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
|
||||
local function UpdateSpells(_, event)
|
||||
UpdateBook("spell")
|
||||
UpdateBook("pet")
|
||||
if event == "PLAYER_ENTERING_WORLD" then
|
||||
Lib.updaterFrame:UnregisterEvent(event)
|
||||
end
|
||||
end
|
||||
|
||||
Lib.updaterFrame:SetScript("OnEvent", UpdateSpells)
|
||||
UpdateSpells()
|
||||
|
||||
--- Improved spell range checking function.
|
||||
-- @name SpellRange.IsSpellInRange
|
||||
-- @paramsig spell, unit
|
||||
-- @param spell Name or spellID of a spell that you wish to check the range of. The spell must be a spell that you have in your spellbook or your pet's spellbook.
|
||||
-- @param unit UnitID of the spell that you wish to check the range on.
|
||||
-- @return Exact same returns as http://wowprogramming.com/docs/api/IsSpellInRange
|
||||
-- @usage
|
||||
-- -- Check spell range by spell name on unit "target"
|
||||
-- local SpellRange = LibStub("SpellRange-1.0")
|
||||
-- local inRange = SpellRange.IsSpellInRange("Stormstrike", "target")
|
||||
--
|
||||
-- -- Check spell range by spellID on unit "mouseover"
|
||||
-- local SpellRange = LibStub("SpellRange-1.0")
|
||||
-- local inRange = SpellRange.IsSpellInRange(17364, "mouseover")
|
||||
function Lib.IsSpellInRange(spellInput, unit)
|
||||
if isNumber[spellInput] then
|
||||
local spell = spellsByID_spell[spellInput]
|
||||
if spell then
|
||||
return IsSpellInRange(spell, "spell", unit)
|
||||
else
|
||||
spell = spellsByID_pet[spellInput]
|
||||
if spell then
|
||||
return IsSpellInRange(spell, "pet", unit)
|
||||
elseif not blacklistedIDs[spellInput] then
|
||||
spell = GetSpellInfo(spellInput)
|
||||
if spell then
|
||||
spell = strlowerCache[spell]
|
||||
if spellsByName_spell[spell] then
|
||||
local spellBookID = spellsByName_spell[spell]
|
||||
Lib["spellsByID_spell"][spellInput] = spellBookID
|
||||
return IsSpellInRange(spellBookID, "spell", unit)
|
||||
elseif spellsByName_pet[spell] then
|
||||
local spellBookID = spellsByName_pet[spell]
|
||||
Lib["spellsByID_pet"][spellInput] = spellBookID
|
||||
return IsSpellInRange(spellBookID, "pet", unit)
|
||||
end
|
||||
end
|
||||
|
||||
blacklistedIDs[spellInput] = true
|
||||
return
|
||||
end
|
||||
end
|
||||
else
|
||||
spellInput = strlowerCache[spellInput]
|
||||
|
||||
local spell = spellsByName_spell[spellInput]
|
||||
if spell then
|
||||
return IsSpellInRange(spell, "spell", unit)
|
||||
else
|
||||
spell = spellsByName_pet[spellInput]
|
||||
if spell then
|
||||
return IsSpellInRange(spell, "pet", unit)
|
||||
end
|
||||
end
|
||||
|
||||
return IsSpellInRange(spellInput, unit)
|
||||
end
|
||||
end
|
||||
|
||||
--- Improved SpellHasRange.
|
||||
-- @name SpellRange.SpellHasRange
|
||||
-- @paramsig spell
|
||||
-- @param spell Name or spellID of a spell that you wish to check for a range. The spell must be a spell that you have in your spellbook or your pet's spellbook.
|
||||
-- @return Exact same returns as http://wowprogramming.com/docs/api/SpellHasRange
|
||||
-- @usage
|
||||
-- -- Check if a spell has a range by spell name
|
||||
-- local SpellRange = LibStub("SpellRange-1.0")
|
||||
-- local hasRange = SpellRange.SpellHasRange("Stormstrike")
|
||||
--
|
||||
-- -- Check if a spell has a range by spellID
|
||||
-- local SpellRange = LibStub("SpellRange-1.0")
|
||||
-- local hasRange = SpellRange.SpellHasRange(17364)
|
||||
function Lib.SpellHasRange(spellInput)
|
||||
if isNumber[spellInput] then
|
||||
local spell = spellsByID_spell[spellInput]
|
||||
if spell then
|
||||
return SpellHasRange(spell, "spell")
|
||||
else
|
||||
spell = spellsByID_pet[spellInput]
|
||||
if spell then
|
||||
return SpellHasRange(spell, "pet")
|
||||
end
|
||||
end
|
||||
else
|
||||
spellInput = strlowerCache[spellInput]
|
||||
|
||||
local spell = spellsByName_spell[spellInput]
|
||||
if spell then
|
||||
return SpellHasRange(spell, "spell")
|
||||
else
|
||||
spell = spellsByName_pet[spellInput]
|
||||
if spell then
|
||||
return SpellHasRange(spell, "pet")
|
||||
end
|
||||
end
|
||||
|
||||
return SpellHasRange(spellInput)
|
||||
end
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
## Interface: 80100
|
||||
## Version: 1.0.13
|
||||
## X-CompatibleWith: 80000
|
||||
## Title: Lib: SpellRange-1.0
|
||||
## Notes: Provides enhanced spell range checking functionality
|
||||
## Author: Cybeloras of Aerie Peak
|
||||
## X-Category: Library
|
||||
|
||||
libs\LibStub\LibStub.lua
|
||||
|
||||
lib.xml
|
||||
@@ -1,61 +0,0 @@
|
||||
# LibSpellRange-1.0
|
||||
|
||||
## Background
|
||||
|
||||
Blizzard's `IsSpellInRange` API has always been very limited - you either must have the name of the spell,
|
||||
or its spell book ID. Checking directly by spellID is simply not possible.
|
||||
Now, since Mists of Pandaria, Blizzard changed the way that many talents and specialization spells work -
|
||||
instead of giving you a new spell when leaned, they replace existing spells. These replacement spells do
|
||||
not work with Blizzard's IsSpellInRange function whatsoever; this limitation is what prompted the creation of this lib.
|
||||
|
||||
## Usage
|
||||
|
||||
**LibSpellRange-1.0** exposes an enhanced version of IsSpellInRange that:
|
||||
|
||||
* Allows ranged checking based on both spell name and spellID.
|
||||
* Works correctly with replacement spells that will not work using Blizzard's IsSpellInRange method alone.
|
||||
|
||||
### `SpellRange.IsSpellInRange(spell, unit)` - Improved `IsSpellInRange`
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `spell` - Name or spellID of a spell that you wish to check the range of. The spell must be a spell that you have in your spellbook or your pet's spellbook.
|
||||
- `unit` - UnitID of the spell that you wish to check the range on.
|
||||
|
||||
#### Return value
|
||||
|
||||
Exact same returns as [the built-in `IsSpellInRange`](http://wowprogramming.com/docs/api/IsSpellInRange.html)
|
||||
|
||||
#### Usage
|
||||
|
||||
``` lua
|
||||
-- Check spell range by spell name on unit "target"
|
||||
local SpellRange = LibStub("SpellRange-1.0")
|
||||
local inRange = SpellRange.IsSpellInRange("Stormstrike", "target")
|
||||
|
||||
-- Check spell range by spellID on unit "mouseover"
|
||||
local SpellRange = LibStub("SpellRange-1.0")
|
||||
local inRange = SpellRange.IsSpellInRange(17364, "mouseover")
|
||||
```
|
||||
|
||||
### `SpellRange.SpellHasRange(spell)` - Improved `SpellHasRange`
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `spell` - Name or spellID of a spell that you wish to check for a range. The spell must be a spell that you have in your spellbook or your pet's spellbook.
|
||||
|
||||
#### Return value
|
||||
|
||||
Exact same returns as [the built-in `SpellHasRange`](http://wowprogramming.com/docs/api/SpellHasRange.html)
|
||||
|
||||
#### Usage
|
||||
|
||||
``` lua
|
||||
-- Check if a spell has a range by spell name
|
||||
local SpellRange = LibStub("SpellRange-1.0")
|
||||
local hasRange = SpellRange.SpellHasRange("Stormstrike")
|
||||
|
||||
-- Check if a spell has a range by spellID
|
||||
local SpellRange = LibStub("SpellRange-1.0")
|
||||
local hasRange = SpellRange.SpellHasRange(17364)
|
||||
```
|
||||
@@ -1,3 +0,0 @@
|
||||
<Ui>
|
||||
<Script file="LibSpellRange-1.0.lua"/>
|
||||
</Ui>
|
||||
@@ -1,51 +0,0 @@
|
||||
-- $Id: LibStub.lua 103 2014-10-16 03:02:50Z mikk $
|
||||
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/addons/libstub/ for more info
|
||||
-- LibStub is hereby placed in the Public Domain
|
||||
-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
|
||||
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
|
||||
local LibStub = _G[LIBSTUB_MAJOR]
|
||||
|
||||
-- Check to see is this version of the stub is obsolete
|
||||
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
|
||||
LibStub = LibStub or {libs = {}, minors = {} }
|
||||
_G[LIBSTUB_MAJOR] = LibStub
|
||||
LibStub.minor = LIBSTUB_MINOR
|
||||
|
||||
-- LibStub:NewLibrary(major, minor)
|
||||
-- major (string) - the major version of the library
|
||||
-- minor (string or number ) - the minor version of the library
|
||||
--
|
||||
-- returns nil if a newer or same version of the lib is already present
|
||||
-- returns empty library object or old library object if upgrade is needed
|
||||
function LibStub:NewLibrary(major, minor)
|
||||
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
|
||||
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
|
||||
|
||||
local oldminor = self.minors[major]
|
||||
if oldminor and oldminor >= minor then return nil end
|
||||
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
|
||||
return self.libs[major], oldminor
|
||||
end
|
||||
|
||||
-- LibStub:GetLibrary(major, [silent])
|
||||
-- major (string) - the major version of the library
|
||||
-- silent (boolean) - if true, library is optional, silently return nil if its not found
|
||||
--
|
||||
-- throws an error if the library can not be found (except silent is set)
|
||||
-- returns the library object if found
|
||||
function LibStub:GetLibrary(major, silent)
|
||||
if not self.libs[major] and not silent then
|
||||
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
|
||||
end
|
||||
return self.libs[major], self.minors[major]
|
||||
end
|
||||
|
||||
-- LibStub:IterateLibraries()
|
||||
--
|
||||
-- Returns an iterator for the currently registered libraries
|
||||
function LibStub:IterateLibraries()
|
||||
return pairs(self.libs)
|
||||
end
|
||||
|
||||
setmetatable(LibStub, { __call = LibStub.GetLibrary })
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
## Interface: 90005
|
||||
## Title: Lib: LibStub
|
||||
## Notes: Universal Library Stub
|
||||
## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
|
||||
## X-Website: http://www.wowace.com/addons/libstub/
|
||||
## X-Category: Library
|
||||
## X-License: Public Domain
|
||||
|
||||
LibStub.lua
|
||||
@@ -1,41 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
|
||||
assert(lib) -- should return the library table
|
||||
assert(not oldMinor) -- should not return the old minor, since it didn't exist
|
||||
|
||||
-- the following is to create data and then be able to check if the same data exists after the fact
|
||||
function lib:MyMethod()
|
||||
end
|
||||
local MyMethod = lib.MyMethod
|
||||
lib.MyTable = {}
|
||||
local MyTable = lib.MyTable
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
|
||||
assert(not newLib) -- should not return since out of date
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
|
||||
assert(not newLib) -- should not return since out of date
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
|
||||
assert(newLib) -- library table
|
||||
assert(rawequal(newLib, lib)) -- should be the same reference as the previous
|
||||
assert(newOldMinor == 1) -- should return the minor version of the previous version
|
||||
|
||||
assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
|
||||
assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
|
||||
assert(newLib) -- library table
|
||||
assert(newOldMinor == 2) -- previous version was 2
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number)
|
||||
assert(newLib)
|
||||
assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)
|
||||
|
||||
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
|
||||
assert(newLib)
|
||||
assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)
|
||||
@@ -1,27 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
for major, library in LibStub:IterateLibraries() do
|
||||
-- check that MyLib doesn't exist yet, by iterating through all the libraries
|
||||
assert(major ~= "MyLib")
|
||||
end
|
||||
|
||||
assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
|
||||
assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
|
||||
local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
|
||||
assert(lib) -- check it exists
|
||||
assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
|
||||
|
||||
assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
|
||||
|
||||
local count=0
|
||||
for major, library in LibStub:IterateLibraries() do
|
||||
-- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
|
||||
if major == "MyLib" then -- we found it!
|
||||
count = count +1
|
||||
assert(rawequal(library, lib)) -- verify that the references are equal
|
||||
end
|
||||
end
|
||||
assert(count == 1) -- verify that we actually found it, and only once
|
||||
@@ -1,14 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
local proxy = newproxy() -- non-string
|
||||
|
||||
assert(not pcall(LibStub.NewLibrary, LibStub, proxy, 1)) -- should error, proxy is not a string, it's userdata
|
||||
local success, ret = pcall(LibStub.GetLibrary, proxy, true)
|
||||
assert(not success or not ret) -- either error because proxy is not a string or because it's not actually registered.
|
||||
|
||||
assert(not pcall(LibStub.NewLibrary, LibStub, "Something", "No number in here")) -- should error, minor has no string in it.
|
||||
|
||||
assert(not LibStub:GetLibrary("Something", true)) -- shouldn't've created it from the above statement
|
||||
@@ -1,41 +0,0 @@
|
||||
debugstack = debug.traceback
|
||||
strmatch = string.match
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
|
||||
-- Pretend like loaded libstub is old and doesn't have :IterateLibraries
|
||||
assert(LibStub.minor)
|
||||
LibStub.minor = LibStub.minor - 0.0001
|
||||
LibStub.IterateLibraries = nil
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(type(LibStub.IterateLibraries)=="function")
|
||||
|
||||
|
||||
-- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created
|
||||
LibStub.IterateLibraries = 123
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
-- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created
|
||||
LibStub.minor = LibStub.minor + 0.0001
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
-- Again with a huge number
|
||||
LibStub.minor = LibStub.minor + 1234567890
|
||||
|
||||
loadfile("../LibStub.lua")()
|
||||
|
||||
assert(LibStub.IterateLibraries == 123)
|
||||
|
||||
|
||||
print("OK")
|
||||
@@ -1,350 +0,0 @@
|
||||
if ObjectPoolMixin then
|
||||
return
|
||||
end
|
||||
|
||||
local assert = assert
|
||||
local ipairs = ipairs
|
||||
local next = next
|
||||
local pairs = pairs
|
||||
local select = select
|
||||
|
||||
local function Mixin(object, ...)
|
||||
for i = 1, select("#", ...) do
|
||||
local mixin = select(i, ...);
|
||||
for k, v in pairs(mixin) do
|
||||
object[k] = v;
|
||||
end
|
||||
end
|
||||
|
||||
return object;
|
||||
end
|
||||
|
||||
local function CreateFromMixins(...)
|
||||
return Mixin({}, ...)
|
||||
end
|
||||
|
||||
local function nop()
|
||||
end
|
||||
|
||||
ObjectPoolMixin = {};
|
||||
|
||||
function ObjectPoolMixin:OnLoad(creationFunc, resetterFunc)
|
||||
self.creationFunc = creationFunc;
|
||||
self.resetterFunc = resetterFunc;
|
||||
|
||||
self.activeObjects = {};
|
||||
self.inactiveObjects = {};
|
||||
|
||||
self.numActiveObjects = 0;
|
||||
end
|
||||
|
||||
function ObjectPoolMixin:Acquire()
|
||||
local numInactiveObjects = #self.inactiveObjects;
|
||||
if numInactiveObjects > 0 then
|
||||
local obj = self.inactiveObjects[numInactiveObjects];
|
||||
self.activeObjects[obj] = true;
|
||||
self.numActiveObjects = self.numActiveObjects + 1;
|
||||
self.inactiveObjects[numInactiveObjects] = nil;
|
||||
return obj, false;
|
||||
end
|
||||
|
||||
local newObj = self.creationFunc(self);
|
||||
if self.resetterFunc then
|
||||
self.resetterFunc(self, newObj);
|
||||
end
|
||||
self.activeObjects[newObj] = true;
|
||||
self.numActiveObjects = self.numActiveObjects + 1;
|
||||
return newObj, true;
|
||||
end
|
||||
|
||||
function ObjectPoolMixin:Release(obj)
|
||||
if self:IsActive(obj) then
|
||||
self.inactiveObjects[#self.inactiveObjects + 1] = obj;
|
||||
self.activeObjects[obj] = nil;
|
||||
self.numActiveObjects = self.numActiveObjects - 1;
|
||||
if self.resetterFunc then
|
||||
self.resetterFunc(self, obj);
|
||||
end
|
||||
|
||||
return true;
|
||||
end
|
||||
|
||||
return false;
|
||||
end
|
||||
|
||||
function ObjectPoolMixin:ReleaseAll()
|
||||
for obj in pairs(self.activeObjects) do
|
||||
self:Release(obj);
|
||||
end
|
||||
end
|
||||
|
||||
function ObjectPoolMixin:EnumerateActive()
|
||||
return pairs(self.activeObjects);
|
||||
end
|
||||
|
||||
function ObjectPoolMixin:GetNextActive(current)
|
||||
return (next(self.activeObjects, current));
|
||||
end
|
||||
|
||||
function ObjectPoolMixin:IsActive(object)
|
||||
return (self.activeObjects[object] ~= nil);
|
||||
end
|
||||
|
||||
function ObjectPoolMixin:GetNumActive()
|
||||
return self.numActiveObjects;
|
||||
end
|
||||
|
||||
function ObjectPoolMixin:EnumerateInactive()
|
||||
return ipairs(self.inactiveObjects);
|
||||
end
|
||||
|
||||
function CreateObjectPool(creationFunc, resetterFunc)
|
||||
local objectPool = CreateFromMixins(ObjectPoolMixin);
|
||||
objectPool:OnLoad(creationFunc, resetterFunc);
|
||||
return objectPool;
|
||||
end
|
||||
|
||||
FramePoolMixin = CreateFromMixins(ObjectPoolMixin);
|
||||
|
||||
local function FramePoolFactory(framePool)
|
||||
return CreateFrame(framePool.frameType, nil, framePool.parent, framePool.frameTemplate);
|
||||
end
|
||||
|
||||
local function ForbiddenFramePoolFactory(framePool)
|
||||
return CreateForbiddenFrame(framePool.frameType, nil, framePool.parent, framePool.frameTemplate);
|
||||
end
|
||||
|
||||
function FramePoolMixin:OnLoad(frameType, parent, frameTemplate, resetterFunc, forbidden)
|
||||
if forbidden then
|
||||
ObjectPoolMixin.OnLoad(self, ForbiddenFramePoolFactory, resetterFunc);
|
||||
else
|
||||
ObjectPoolMixin.OnLoad(self, FramePoolFactory, resetterFunc);
|
||||
end
|
||||
self.frameType = frameType;
|
||||
self.parent = parent;
|
||||
self.frameTemplate = frameTemplate;
|
||||
end
|
||||
|
||||
function FramePoolMixin:GetTemplate()
|
||||
return self.frameTemplate;
|
||||
end
|
||||
|
||||
function FramePool_Hide(framePool, frame)
|
||||
frame:Hide();
|
||||
end
|
||||
|
||||
function FramePool_HideAndClearAnchors(framePool, frame)
|
||||
frame:Hide();
|
||||
frame:ClearAllPoints();
|
||||
end
|
||||
|
||||
function CreateFramePool(frameType, parent, frameTemplate, resetterFunc, forbidden)
|
||||
local framePool = CreateFromMixins(FramePoolMixin);
|
||||
framePool:OnLoad(frameType, parent, frameTemplate, resetterFunc or FramePool_HideAndClearAnchors, forbidden);
|
||||
return framePool;
|
||||
end
|
||||
|
||||
TexturePoolMixin = CreateFromMixins(ObjectPoolMixin);
|
||||
|
||||
local function TexturePoolFactory(texturePool)
|
||||
return texturePool.parent:CreateTexture(nil, texturePool.layer, texturePool.textureTemplate);
|
||||
end
|
||||
|
||||
function TexturePoolMixin:OnLoad(parent, layer, textureTemplate, resetterFunc)
|
||||
ObjectPoolMixin.OnLoad(self, TexturePoolFactory, resetterFunc);
|
||||
self.parent = parent;
|
||||
self.layer = layer;
|
||||
self.textureTemplate = textureTemplate;
|
||||
end
|
||||
|
||||
TexturePool_Hide = FramePool_Hide;
|
||||
TexturePool_HideAndClearAnchors = FramePool_HideAndClearAnchors;
|
||||
|
||||
function CreateTexturePool(parent, layer, textureTemplate, resetterFunc)
|
||||
local texturePool = CreateFromMixins(TexturePoolMixin);
|
||||
texturePool:OnLoad(parent, layer, textureTemplate, resetterFunc or TexturePool_HideAndClearAnchors);
|
||||
return texturePool;
|
||||
end
|
||||
|
||||
FontStringPoolMixin = CreateFromMixins(ObjectPoolMixin);
|
||||
|
||||
local function FontStringPoolFactory(fontStringPool)
|
||||
return fontStringPool.parent:CreateFontString(nil, fontStringPool.layer, fontStringPool.fontStringTemplate);
|
||||
end
|
||||
|
||||
function FontStringPoolMixin:OnLoad(parent, layer, fontStringTemplate, resetterFunc)
|
||||
ObjectPoolMixin.OnLoad(self, FontStringPoolFactory, resetterFunc);
|
||||
self.parent = parent;
|
||||
self.layer = layer;
|
||||
self.fontStringTemplate = fontStringTemplate;
|
||||
end
|
||||
|
||||
FontStringPool_Hide = FramePool_Hide;
|
||||
FontStringPool_HideAndClearAnchors = FramePool_HideAndClearAnchors;
|
||||
|
||||
function CreateFontStringPool(parent, layer, fontStringTemplate, resetterFunc)
|
||||
local fontStringPool = CreateFromMixins(FontStringPoolMixin);
|
||||
fontStringPool:OnLoad(parent, layer, fontStringTemplate, resetterFunc or FontStringPool_HideAndClearAnchors);
|
||||
return fontStringPool;
|
||||
end
|
||||
|
||||
ActorPoolMixin = CreateFromMixins(ObjectPoolMixin);
|
||||
|
||||
local function ActorPoolFactory(actorPool)
|
||||
return actorPool.parent:CreateActor(nil, actorPool.actorTemplate);
|
||||
end
|
||||
|
||||
function ActorPoolMixin:OnLoad(parent, actorTemplate, resetterFunc)
|
||||
ObjectPoolMixin.OnLoad(self, ActorPoolFactory, resetterFunc);
|
||||
self.parent = parent;
|
||||
self.actorTemplate = actorTemplate;
|
||||
end
|
||||
|
||||
ActorPool_Hide = FramePool_Hide;
|
||||
function ActorPool_HideAndClearModel(actorPool, actor)
|
||||
actor:ClearModel();
|
||||
actor:Hide();
|
||||
end
|
||||
|
||||
function CreateActorPool(parent, actorTemplate, resetterFunc)
|
||||
local actorPool = CreateFromMixins(ActorPoolMixin);
|
||||
actorPool:OnLoad(parent, actorTemplate, resetterFunc or ActorPool_HideAndClearModel);
|
||||
return actorPool;
|
||||
end
|
||||
|
||||
FramePoolCollectionMixin = {};
|
||||
|
||||
function CreateFramePoolCollection()
|
||||
local poolCollection = CreateFromMixins(FramePoolCollectionMixin);
|
||||
poolCollection:OnLoad();
|
||||
return poolCollection;
|
||||
end
|
||||
|
||||
function FramePoolCollectionMixin:OnLoad()
|
||||
self.pools = {};
|
||||
end
|
||||
|
||||
function FramePoolCollectionMixin:GetNumActive()
|
||||
local numTotalActive = 0;
|
||||
for _, pool in pairs(self.pools) do
|
||||
numTotalActive = numTotalActive + pool:GetNumActive();
|
||||
end
|
||||
return numTotalActive;
|
||||
end
|
||||
|
||||
function FramePoolCollectionMixin:GetOrCreatePool(frameType, parent, template, resetterFunc, forbidden)
|
||||
local pool = self:GetPool(template);
|
||||
if not pool then
|
||||
pool = self:CreatePool(frameType, parent, template, resetterFunc, forbidden);
|
||||
end
|
||||
return pool;
|
||||
end
|
||||
|
||||
function FramePoolCollectionMixin:CreatePool(frameType, parent, template, resetterFunc, forbidden)
|
||||
assert(self:GetPool(template) == nil);
|
||||
local pool = CreateFramePool(frameType, parent, template, resetterFunc, forbidden);
|
||||
self.pools[template] = pool;
|
||||
return pool;
|
||||
end
|
||||
|
||||
function FramePoolCollectionMixin:GetPool(template)
|
||||
return self.pools[template];
|
||||
end
|
||||
|
||||
function FramePoolCollectionMixin:Acquire(template)
|
||||
local pool = self:GetPool(template);
|
||||
assert(pool);
|
||||
return pool:Acquire();
|
||||
end
|
||||
|
||||
function FramePoolCollectionMixin:Release(object)
|
||||
for _, pool in pairs(self.pools) do
|
||||
if pool:Release(object) then
|
||||
-- Found it! Just return
|
||||
return;
|
||||
end
|
||||
end
|
||||
|
||||
-- Huh, we didn't find that object
|
||||
assert(false);
|
||||
end
|
||||
|
||||
function FramePoolCollectionMixin:ReleaseAllByTemplate(template)
|
||||
local pool = self:GetPool(template);
|
||||
if pool then
|
||||
pool:ReleaseAll();
|
||||
end
|
||||
end
|
||||
|
||||
function FramePoolCollectionMixin:ReleaseAll()
|
||||
for key, pool in pairs(self.pools) do
|
||||
pool:ReleaseAll();
|
||||
end
|
||||
end
|
||||
|
||||
function FramePoolCollectionMixin:EnumerateActiveByTemplate(template)
|
||||
local pool = self:GetPool(template);
|
||||
if pool then
|
||||
return pool:EnumerateActive();
|
||||
end
|
||||
|
||||
return nop;
|
||||
end
|
||||
|
||||
function FramePoolCollectionMixin:EnumerateActive()
|
||||
local currentPoolKey, currentPool = next(self.pools, nil);
|
||||
local currentObject = nil;
|
||||
return function()
|
||||
if currentPool then
|
||||
currentObject = currentPool:GetNextActive(currentObject);
|
||||
while not currentObject do
|
||||
currentPoolKey, currentPool = next(self.pools, currentPoolKey);
|
||||
if currentPool then
|
||||
currentObject = currentPool:GetNextActive();
|
||||
else
|
||||
break;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return currentObject;
|
||||
end, nil;
|
||||
end
|
||||
|
||||
FixedSizeFramePoolCollectionMixin = CreateFromMixins(FramePoolCollectionMixin);
|
||||
|
||||
function CreateFixedSizeFramePoolCollection()
|
||||
local poolCollection = CreateFromMixins(FixedSizeFramePoolCollectionMixin);
|
||||
poolCollection:OnLoad();
|
||||
return poolCollection;
|
||||
end
|
||||
|
||||
function FixedSizeFramePoolCollectionMixin:OnLoad()
|
||||
FramePoolCollectionMixin.OnLoad(self);
|
||||
self.sizes = {};
|
||||
end
|
||||
|
||||
function FixedSizeFramePoolCollectionMixin:CreatePool(frameType, parent, template, resetterFunc, forbidden, maxPoolSize, preallocate)
|
||||
local pool = FramePoolCollectionMixin.CreatePool(self, frameType, parent, template, resetterFunc, forbidden);
|
||||
|
||||
if preallocate then
|
||||
for i = 1, maxPoolSize do
|
||||
pool:Acquire();
|
||||
end
|
||||
pool:ReleaseAll();
|
||||
end
|
||||
|
||||
self.sizes[template] = maxPoolSize;
|
||||
|
||||
return pool;
|
||||
end
|
||||
|
||||
function FixedSizeFramePoolCollectionMixin:Acquire(template)
|
||||
local pool = self:GetPool(template);
|
||||
assert(pool);
|
||||
|
||||
if pool:GetNumActive() < self.sizes[template] then
|
||||
return pool:Acquire();
|
||||
end
|
||||
return nil;
|
||||
end
|
||||
@@ -1,20 +1,4 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="Libs\LibStub\LibStub.lua"/>
|
||||
<Include file="Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
|
||||
<Include file="Libs\AceTimer-3.0\AceTimer-3.0.xml"/>
|
||||
<Include file="Libs\AceSerializer-3.0\AceSerializer-3.0.xml"/>
|
||||
<Include file="Libs\AceComm-3.0\AceComm-3.0.xml"/>
|
||||
<Include file="Libs\LibSharedMedia-3.0\lib.xml"/>
|
||||
<Script file="Libs\LibCompress\LibCompress.lua"/>
|
||||
<Script file="Libs\LibDataBroker-1.1\LibDataBroker-1.1.lua"/>
|
||||
<Script file="Libs\LibSpellRange-1.0\LibSpellRange-1.0.lua"/>
|
||||
<Script file="Libs\LibRangeCheck-2.0\LibRangeCheck-2.0.lua"/>
|
||||
<Script file="Libs\LibDeflate\LibDeflate.lua"/>
|
||||
<Include file="Libs\LibCustomGlow-1.0\LibCustomGlow-1.0.xml"/>
|
||||
<Script file="Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua"/>
|
||||
<Script file="Libs\LibGetFrame-1.0\LibGetFrame-1.0.lua"/>
|
||||
<Include file="Libs\Archivist\Archivist.xml"/>
|
||||
<Include file="Libs\LibSerialize\lib.xml"/>
|
||||
<Include file="Libs\LibGroupTalents-1.0\lib.xml"/>
|
||||
</Ui>
|
||||
|
||||
Reference in New Issue
Block a user