WoWInterface SVN AtlasLootReverse

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /tags
    from Rev 10 to Rev 12
    Reverse comparison

Rev 10 → Rev 12

1.2/libs/LibStub/LibStub.lua New file
0,0 → 1,30
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/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]
 
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
LibStub = LibStub or {libs = {}, minors = {} }
_G[LIBSTUB_MAJOR] = LibStub
LibStub.minor = LIBSTUB_MINOR
 
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
 
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
 
function LibStub:IterateLibraries() return pairs(self.libs) end
setmetatable(LibStub, { __call = LibStub.GetLibrary })
end
1.2/libs/AceLocale-3.0/AceLocale-3.0.lua New file
0,0 → 1,119
--- Manages localization in addons, allowing for multiple locale to be registered with fallback to the base locale for untranslated strings.
-- @class file
-- @name AceLocale-3.0
-- @release $Id: AceLocale-3.0.lua 719 2009-01-04 12:01:23Z nevcairiel $
local MAJOR,MINOR = "AceLocale-3.0", 2
 
local AceLocale, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 
if not AceLocale then return end -- no upgrade needed
 
local gameLocale = GetLocale()
if gameLocale == "enGB" then
gameLocale = "enUS"
end
 
AceLocale.apps = AceLocale.apps or {} -- array of ["AppName"]=localetableref
AceLocale.appnames = AceLocale.appnames or {} -- array of [localetableref]="AppName"
 
-- This metatable is used on all tables returned from GetLocale
local readmeta = {
__index = function(self, key) -- requesting totally unknown entries: fire off a nonbreaking error and return key
rawset(self, key, key) -- only need to see the warning once, really
geterrorhandler()(MAJOR..": "..tostring(AceLocale.appnames[self])..": Missing entry for '"..tostring(key).."'")
return key
end
}
 
-- This metatable is used on all tables returned from GetLocale if the silent flag is true, it does not issue a warning on unknown keys
local readmetasilent = {
__index = function(self, key) -- requesting totally unknown entries: return key
rawset(self, key, key) -- only need to invoke this function once
return key
end
}
 
-- Remember the locale table being registered right now (it gets set by :NewLocale())
-- NOTE: Do never try to register 2 locale tables at once and mix their definition.
local registering
 
-- local assert false function
local assertfalse = function() assert(false) end
 
-- This metatable proxy is used when registering nondefault locales
local writeproxy = setmetatable({}, {
__newindex = function(self, key, value)
rawset(registering, key, value == true and key or value) -- assigning values: replace 'true' with key string
end,
__index = assertfalse
})
 
-- This metatable proxy is used when registering the default locale.
-- It refuses to overwrite existing values
-- Reason 1: Allows loading locales in any order
-- Reason 2: If 2 modules have the same string, but only the first one to be
-- loaded has a translation for the current locale, the translation
-- doesn't get overwritten.
--
local writedefaultproxy = setmetatable({}, {
__newindex = function(self, key, value)
if not rawget(registering, key) then
rawset(registering, key, value == true and key or value)
end
end,
__index = assertfalse
})
 
-- AceLocale:NewLocale(application, locale, isDefault)
--
-- application (string) - unique name of addon / module
-- locale (string) - name of locale to register, e.g. "enUS", "deDE", etc...
-- isDefault (string) - if this is the default locale being registered
--
-- Returns a table where localizations can be filled out, or nil if the locale is not needed
function AceLocale:NewLocale(application, locale, isDefault, silent)
 
if silent and not isDefault then
error("Usage: NewLocale(application, locale[, isDefault[, silent]]): 'silent' can only be specified for the default locale", 2)
end
 
-- GAME_LOCALE allows translators to test translations of addons without having that wow client installed
-- Ammo: I still think this is a bad idea, for instance an addon that checks for some ingame string will fail, just because some other addon
-- gives the user the illusion that they can run in a different locale? Ditch this whole thing or allow a setting per 'application'. I'm of the
-- opinion to remove this.
local gameLocale = GAME_LOCALE or gameLocale
 
if locale ~= gameLocale and not isDefault then
return -- nop, we don't need these translations
end
 
local app = AceLocale.apps[application]
 
if not app then
app = setmetatable({}, silent and readmetasilent or readmeta)
AceLocale.apps[application] = app
AceLocale.appnames[app] = application
end
 
registering = app -- remember globally for writeproxy and writedefaultproxy
 
if isDefault then
return writedefaultproxy
end
 
return writeproxy
end
 
-- AceLocale:GetLocale(application [, silent])
--
-- application (string) - unique name of addon
-- silent (boolean) - if true, the locale is optional, silently return nil if it's not found
--
-- Returns localizations for the current locale (or default locale if translations are missing)
-- Errors if nothing is registered (spank developer, not just a missing translation)
function AceLocale:GetLocale(application, silent)
if not silent and not AceLocale.apps[application] then
error("Usage: GetLocale(application[, silent]): 'application' - No locales registered for '"..tostring(application).."'", 2)
end
return AceLocale.apps[application]
end
1.2/libs/AceLocale-3.0/AceLocale-3.0.xml New file
0,0 → 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="AceLocale-3.0.lua"/>
</Ui>
\ No newline at end of file
1.2/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml New file
0,0 → 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="CallbackHandler-1.0.lua"/>
</Ui>
\ No newline at end of file
1.2/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua New file
0,0 → 1,239
--[[ $Id: CallbackHandler-1.0.lua 504 2008-02-07 11:04:06Z nevcairiel $ ]]
local MAJOR, MINOR = "CallbackHandler-1.0", 3
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}
 
local type = type
local pcall = pcall
local pairs = pairs
local assert = assert
local concat = table.concat
local loadstring = loadstring
local next = next
local select = select
local type = type
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", concat(OLD_ARGS, ", ")):gsub("ARGS", concat(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, OnUsed, OnUnused)
-- TODO: Remove this after beta has gone out
assert(not OnUsed and not OnUnused, "ACE-80: OnUsed/OnUnused are deprecated. Callbacks are now done to registry.OnUsed and registry.OnUnused")
 
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"
if type(self)~="table" and type(self)~="string" then
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string 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.2/libs/LibExtraTip/API.txt New file
0,0 → 1,163
LibExtraTip
 
LibExtraTip is a library of API functions for manipulating additional
information into GameTooltips by either adding information to the bottom
of existing tooltips (embedded mode) or by adding information to an extra
"attached" tooltip construct which is placed to the bottom of the existing
tooltip.
Copyright (C) 2008, by the respecive below authors.
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
This library 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 Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
Author: Matt Richard (Tem)
Author: Ken Allan <ken@norganna.org>
Version: 1.0
 
Class Method LibExtraTip:RegisterTooltip(tooltip)
 
Adds the provided tooltip to the list of tooltips to monitor for items.
 
tooltip: GameTooltip object
Returns: true if tooltip is registered
Available since v1.0
 
Class Method LibExtraTip:IsRegistered(tooltip)
 
Checks to see if the tooltip has been registered with LibExtraTip
 
tooltip: GameTooltip object
Returns: true if tooltip is registered
Available since v1.0
 
Class Method LibExtraTip:AddCallback(callback, priority)
 
Adds a callback to be informed of any registered tooltip's activity.
 
Callbacks are passed the following parameters (in order):
* tooltip: The tooltip object being shown (GameTooltip object)
* item: The item being shown (in ItemLink format)
* quantity: The quantity of the item being shown (may be nil when the
quantity is unavailable)
* return values from GetItemInfo (in order)
callback: the method to be called
priority: the priority of the callback (optional, default 200)
Available since v1.0
 
Class Method LibExtraTip:RemoveCallback(callback)
 
Removes the given callback from the list of callbacks.
 
callback: the callback to remove from notifications
Returns: true if successfully removed
Available since v1.0
 
Class Method LibExtraTip:SetEmbedMode(flag)
 
Sets the default embed mode of the library (default false)
 
A false embedMode causes AddLine, AddDoubleLine and AddMoneyLine to add
lines to the attached tooltip rather than embed added lines directly in
the item tooltip. This setting only takes effect when embed mode is not
specified on individual AddLine, AddDoubleLine and AddMoneyLine
commands.
 
flag: boolean flag if true embeds by default
Available since v1.0
 
Class Method LibExtraTip:AddLine(tooltip, text, r, g, b, embed)
 
Adds a line to a registered tooltip.
 
tooltip: GameTooltip object
text: the contents of the tooltip line
r: red component of the tooltip line color (optional)
g: green component of the tooltip line color (optional)
b: blue component of the tooltip line color (optional)
embed: override the lib's embedMode setting (optional)
See also: SetEmbedMode
Available since v1.0
 
Class Method LibExtraTip:AddDoubleLine(tooltip, textLeft, textRight, lr, lg,
lb, rr, rg, rb, embed)
 
Adds a two-columned line to the tooltip.
 
tooltip: GameTooltip object
textLeft: the left column's contents
textRight: the left column's contents
r: red component of the tooltip line color (optional)
g: green component of the tooltip line color (optional)
b: blue component of the tooltip line color (optional)
embed: override the lib's embedMode setting (optional)
See also: SetEmbedMode
Available since v1.0
 
Class Method LibExtraTip:GetMoneyText(money, concise)
 
Creates a string representation of the money value passed using embedded
textures for the icons
 
money: the money value to be converted in copper
concise: when false (default), the representation of 1g is "1g 00s 00c"
when true, it is simply "1g" (optional)
Available since v1.0
 
Class Method LibExtraTip:AddMoneyLine(tooltip, text, money, r, g, b, embed)
 
Adds a line with text in the left column and a money frame in the right.
 
The money parameter is given in copper coins (i.e. 1g 27s 5c would be
12705)
 
tooltip: GameTooltip object
text: the contents of the tooltip line
money: the money value to be displayed (in copper)
r: red component of the tooltip line color (optional)
g: green component of the tooltip line color (optional)
b: blue component of the tooltip line color (optional)
embed: override the lib's embedMode setting (optional)
See also: SetEmbedMode
Available since v1.0
 
Class Method LibExtraTip:CallTooltipMethod(tooltip, method, args, detail)
 
Calls a tooltip's method, passing arguments and setting additional details.
 
You must use this function when you are setting your own tooltip, but
want LibExtraTip to display the extra tooltip information and notify any
callbacks.
 
tooltip: GameTooltip object
method: the tooltip method to call (or nil to not call any)
args: table of arguments to pass to tooltip method
detail: additional detail items to set for the callbacks
Returns: whatever the called method returns
Available since v1.0
 
Class Method LibExtraTip:GetTooltipAdditional(tooltip)
 
Get the additional information from a tooltip event.
 
Often additional event details are available about the situation under
which the tooltip was invoked, such as:
* The call that triggered the tooltip.
* The slot/inventory/index of the item in question.
* Whether the item is usable or not.
* Auction price information.
* Ownership information.
* Any data provided by the Get*Info() functions. If you require access to
this information for the current tooltip, call this function to retrieve
it.
 
tooltip: GameTooltip object
Returns: table containing the additional information
Available since v1.0
1.2/libs/LibExtraTip/LibExtraTip.lua New file
0,0 → 1,1125
--[[-
LibExtraTip
 
LibExtraTip is a library of API functions for manipulating additional information into GameTooltips by either adding information to the bottom of existing tooltips (embedded mode) or by adding information to an extra "attached" tooltip construct which is placed to the bottom of the existing tooltip.
 
Copyright (C) 2008, by the respective below authors.
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
 
This library 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
Lesser General Public License for more details.
 
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
@author Matt Richard (Tem)
@author Ken Allan <ken@norganna.org>
@libname LibExtraTip
@version 1.0
--]]
 
local MAJOR,MINOR,REVISION = "LibExtraTip", 1, "$Revision: 184 $"
 
-- A string unique to this version to prevent frame name conflicts.
local LIBSTRING = MAJOR.."_"..MINOR.."_"..REVISION
local lib = LibStub:NewLibrary(MAJOR.."-"..MINOR, REVISION)
if not lib then return end
 
-- Call function to deactivate any outdated version of the library.
-- (calls the OLD version of this function, NOT the one defined in this
-- file's scope)
if lib.Deactivate then lib:Deactivate() end
 
-- Forward definition of a few locals that get defined at the bottom of
-- the file.
local tooltipMethods
local ExtraTipClass
 
-- The following events are enabled by default unless disabled in the
-- callback options "enabled" table all other events are default disabled:
local defaultEnable = {
SetAuctionItem = true,
SetAuctionSellItem = true,
SetBagItem = true,
SetBuybackItem = true,
SetGuildBankItem = true,
SetInboxItem = true,
SetInventoryItem = true,
SetLootItem = true,
SetLootRollItem = true,
SetMerchantItem = true,
SetQuestItem = true,
SetQuestLogItem = true,
SetSendMailItem = true,
SetTradePlayerItem = true,
SetTradeTargetItem = true,
SetTradeSkillItem = true,
SetHyperlink = true,
SetHyperlinkAndCount = true, -- Creating a tooltip via lib:SetHyperlinkAndCount()
}
 
-- Money Icon setup
local iconpath = "Interface\\MoneyFrame\\UI-"
local goldicon = "%d|T"..iconpath.."GoldIcon:0|t"
local silvericon = "%s|T"..iconpath.."SilverIcon:0|t"
local coppericon = "%s|T"..iconpath.."CopperIcon:0|t"
 
-- Function that calls all the interested tooltips
local function ProcessCallbacks(reg, tiptype, tooltip, ...)
local self = lib
if not reg then return end
 
local event = reg.additional.event or "Unknown"
local default = defaultEnable[event]
 
if self.sortedCallbacks and #self.sortedCallbacks > 0 then
for i,options in ipairs(self.sortedCallbacks) do
if options.type == tiptype and options.callback and type(options.callback) == "function" then
local enable = default
if options.enable and options.enable[event] ~= nil then
enable = options.enable[event]
end
if enable then
options.callback(tooltip, ...)
end
end
end
end
end
 
-- Function that gets run when an item is set on a registered tooltip.
local function OnTooltipSetItem(tooltip)
local self = lib
local reg = self.tooltipRegistry[tooltip]
assert(reg, "Unknown tooltip passed to LibExtraTip:OnTooltipSetItem()")
--print("tooltip set item")
 
if self.sortedCallbacks and #self.sortedCallbacks > 0 then
tooltip:Show()
 
local _,item = tooltip:GetItem()
-- For generated tooltips
if not item and reg.item then item = reg.item end
 
if item and not reg.hasItem then
local name,link,quality,ilvl,minlvl,itype,isubtype,stack,equiploc,texture = GetItemInfo(item)
if link then
name = name or "unknown" -- WotLK bug
reg.hasItem = true
local extraTip = self:GetFreeExtraTipObject()
reg.extraTip = extraTip
extraTip:Attach(tooltip)
local r,g,b = GetItemQualityColor(quality)
extraTip:AddLine(name,r,g,b)
 
local quantity = reg.quantity
 
reg.additional.item = item
reg.additional.quantity = quantity or 1
reg.additional.name = name
reg.additional.link = link
reg.additional.quality = quality
reg.additional.itemLevel = ilvl
reg.additional.minLevel = minlvl
reg.additional.itemType = itype
reg.additional.itemSubtype = isubtype
reg.additional.stackSize = stack
reg.additional.equipLocation = equiploc
reg.additional.texture = texture
 
ProcessCallbacks(reg, "item", tooltip, item,quantity,name,link,quality,ilvl,minlvl,itype,isubtype,stack,equiploc,texture)
tooltip:Show()
if reg.extraTipUsed then reg.extraTip:Show() end
end
end
end
end
 
-- Function that gets run when a spell is set on a registered tooltip.
local function OnTooltipSetSpell(tooltip)
local self = lib
local reg = self.tooltipRegistry[tooltip]
assert(reg, "Unknown tooltip passed to LibExtraTip:OnTooltipSetSpell()")
--print("tooltip set spell")
 
if self.sortedCallbacks and #self.sortedCallbacks > 0 then
tooltip:Show()
local name, rank = tooltip:GetSpell()
local link = reg.additional.link
 
if name and not reg.hasItem then
reg.hasItem = true
local extraTip = self:GetFreeExtraTipObject()
reg.extraTip = extraTip
extraTip:Attach(tooltip)
extraTip:AddLine(name, 1,0.8,0)
 
ProcessCallbacks(reg, "spell", tooltip, link, name,rank)
tooltip:Show()
if reg.extraTipUsed then reg.extraTip:Show() end
end
end
end
 
 
-- Function that gets run when a unit is set on a registered tooltip.
local function OnTooltipSetUnit(tooltip)
local self = lib
local reg = self.tooltipRegistry[tooltip]
assert(reg, "Unknown tooltip passed to LibExtraTip:OnTooltipSetUnit()")
--print("tooltip set unit")
 
if self.sortedCallbacks and #self.sortedCallbacks > 0 then
tooltip:Show()
local name, unitId = tooltip:GetUnit()
 
if name and not reg.hasItem then
reg.hasItem = true
local extraTip = self:GetFreeExtraTipObject()
reg.extraTip = extraTip
extraTip:Attach(tooltip)
extraTip:AddLine(name, 0.8,0.8,0.8)
 
ProcessCallbacks(reg, "unit", tooltip, name,unitId)
tooltip:Show()
if reg.extraTipUsed then reg.extraTip:Show() end
end
end
end
 
-- Function that gets run when a registered tooltip's item is cleared.
local function OnTooltipCleared(tooltip)
local self = lib
local reg = self.tooltipRegistry[tooltip]
assert(reg, "Unknown tooltip passed to LibExtraTip:OnTooltipCleared()")
--print("tooltip cleared",reg.ignoreOnCleared)
if reg.ignoreOnCleared then return end
tooltip:SetFrameLevel(1)
 
if reg.extraTip then
table.insert(self.extraTippool, reg.extraTip)
reg.extraTip:Hide()
reg.extraTip:Release()
reg.extraTip = nil
end
reg.extraTipUsed = nil
reg.minWidth = 0
reg.quantity = nil
reg.hasItem = nil
reg.item = nil
table.wipe(reg.additional)
end
 
-- Function that gets run when a registered tooltip's size changes.
local function OnSizeChanged(tooltip,w,h)
local self = lib
local reg = self.tooltipRegistry[tooltip]
assert(reg, "Unknown tooltip passed to LibExtraTip:OnSizeChanged()")
 
local extraTip = reg.extraTip
if extraTip then
extraTip:NeedsRefresh(true)
end
end
 
function lib:GetFreeExtraTipObject()
if not self.extraTippool then self.extraTippool = {} end
return table.remove(self.extraTippool) or ExtraTipClass:new()
end
 
local hooks = {}
 
-- Called to apply a pre-hook on the given tooltip's method.
local function hook(tip,method,hook)
local orig = tip[method]
hooks[tip] = hooks[tip] or {origs = {}, hooks = {}}
hooks[tip].origs[method] = orig
local reg = lib.tooltipRegistry[tip]
local h = function(self,...)
OnTooltipCleared(tip)
reg.ignoreOnCleared = true
if hooks[tip].hooks[method] then
hook(self,reg,...)
end
local a,b,c,d = orig(self,...)
reg.ignoreOnCleared = nil
return a,b,c,d
end
hooks[tip].hooks[method] = h
tip[method] = h
end
 
-- Called to remove all our pre-hooks on the given tooltip's method, or
-- deactivate our hooks if not possible.
local function unhook(tip,method)
if tip[method] == hooks[tip].hooks[method] then
-- We still own the top of the hook stack, just pop off
tip[method] = hooks[tip].origs[method]
else -- We don't own the top so deactivate our hook
hooks[tip].hooks[method] = nil
end
end
 
-- Called to apply a pre-hook on the given tooltip's event.
local function hookscript(tip,script,hook)
local orig = tip:GetScript(script)
hooks[tip] = hooks[tip] or {origs = {}, hooks = {}}
hooks[tip].origs[script] = orig
local h = function(...)
if hooks[tip].hooks[script] then
hook(...)
end
if orig then orig(...) end
end
hooks[tip].hooks[script] = h
tip:SetScript(script,h)
end
 
-- Called to remove all our pre-hooks on the given tooltip's event, or
-- deactivate our hooks if not possible.
local function unhookscript(tip,script)
if tip:GetScript(script) == hooks[tip].hooks[script] then
tip:SetScript(script,hooks[tip].origs[script])
else
hooks[tip].hooks[script] = nil
end
end
 
--[[-
Adds the provided tooltip to the list of tooltips to monitor for items.
@param tooltip GameTooltip object
@return true if tooltip is registered
@since 1.0
]]
function lib:RegisterTooltip(tooltip)
if not tooltip or type(tooltip) ~= "table" or type(tooltip.GetObjectType) ~= "function" or tooltip:GetObjectType() ~= "GameTooltip" then return end
 
if not self.tooltipRegistry then
self.tooltipRegistry = {}
self:GenerateTooltipMethodTable()
end
 
if not self.tooltipRegistry[tooltip] then
local reg = {}
self.tooltipRegistry[tooltip] = reg
reg.additional = {}
 
hookscript(tooltip,"OnTooltipSetItem",OnTooltipSetItem)
hookscript(tooltip,"OnTooltipSetUnit",OnTooltipSetUnit)
hookscript(tooltip,"OnTooltipSetSpell",OnTooltipSetSpell)
hookscript(tooltip,"OnTooltipCleared",OnTooltipCleared)
hookscript(tooltip,"OnSizeChanged",OnSizeChanged)
 
for k,v in pairs(tooltipMethods) do
hook(tooltip,k,v)
end
return true
end
end
 
--[[-
Checks to see if the tooltip has been registered with LibExtraTip
@param tooltip GameTooltip object
@return true if tooltip is registered
@since 1.0
]]
function lib:IsRegistered(tooltip)
if not self.tooltipRegistry or not self.tooltipRegistry[tooltip] then
return
end
return true
end
 
local sortFunc
 
--[[-
Adds a callback to be informed of any registered tooltip's activity.
Callbacks are passed the following parameters (in order):
* tooltip: The tooltip object being shown (GameTooltip object)
* item: The item being shown (in {@wowwiki:ItemLink} format)
* quantity: The quantity of the item being shown (may be nil when the quantity is unavailable)
* return values from {@wowwiki:API_GetItemInfo|GetItemInfo} (in order)
@param options a table containing the callback type and callback function
@param priority the priority of the callback (optional, default 200)
@since 1.0
]]
function lib:AddCallback(options,priority)
-- Lower priority gets called before higher priority. Default is 200.
if not options then return end
local otype = type(options)
if otype == "function" then
options = { type = "item", callback = options }
elseif otype ~= "table" then return end
 
if not self.callbacks then
self.callbacks = {}
self.sortedCallbacks = {}
local callbacks = self.callbacks
sortFunc = function(a,b)
return callbacks[a] < callbacks[b]
end
end
 
self.callbacks[options] = priority or 200
table.insert(self.sortedCallbacks,options)
table.sort(self.sortedCallbacks,sortFunc)
end
 
--[[-
Removes the given callback from the list of callbacks.
@param callback the callback to remove from notifications
@return true if successfully removed
@since 1.0
]]
function lib:RemoveCallback(callback)
if not (self.callbacks and self.callbacks[callback]) then return end
self.callbacks[callback] = nil
for i,c in ipairs(self.sortedCallbacks) do
if c == callback then
table.remove(self.sortedCallbacks,i)
return true
end
end
end
 
--[[-
Sets the default embed mode of the library (default false)
A false embedMode causes AddLine, AddDoubleLine and AddMoneyLine to add lines to the attached tooltip rather than embed added lines directly in the item tooltip.
This setting only takes effect when embed mode is not specified on individual AddLine, AddDoubleLine and AddMoneyLine commands.
@param flag boolean flag if true embeds by default
@since 1.0
]]
function lib:SetEmbedMode(flag)
self.embedMode = flag and true or false
end
 
--[[-
Adds a line to a registered tooltip.
@param tooltip GameTooltip object
@param text the contents of the tooltip line
@param r red component of the tooltip line color (optional)
@param g green component of the tooltip line color (optional)
@param b blue component of the tooltip line color (optional)
@param embed override the lib's embedMode setting (optional)
@see SetEmbedMode
@since 1.0
]]
function lib:AddLine(tooltip,text,r,g,b,embed)
local reg = self.tooltipRegistry[tooltip]
assert(reg, "Unknown tooltip passed to LibExtraTip:AddLine()")
 
if r and not g then embed = r r = nil end
embed = embed ~= nil and embed or self.embedMode
if not embed then
reg.extraTip:AddLine(text,r,g,b)
reg.extraTipUsed = true
else
tooltip:AddLine(text,r,g,b)
end
end
 
--[[-
Adds a two-columned line to the tooltip.
@param tooltip GameTooltip object
@param textLeft the left column's contents
@param textRight the left column's contents
@param r red component of the tooltip line color (optional)
@param g green component of the tooltip line color (optional)
@param b blue component of the tooltip line color (optional)
@param embed override the lib's embedMode setting (optional)
@see SetEmbedMode
@since 1.0
]]
function lib:AddDoubleLine(tooltip,textLeft,textRight,lr,lg,lb,rr,rg,rb,embed)
local reg = self.tooltipRegistry[tooltip]
assert(reg, "Unknown tooltip passed to LibExtraTip:AddDoubleLine()")
 
if lr and not lg and not rr then embed = lr lr = nil end
if lr and lg and rr and not rg then embed = rr rr = nil end
embed = embed ~= nil and embed or self.embedMode
if not embed then
reg.extraTip:AddDoubleLine(textLeft,textRight,lr,lg,lb,rr,rg,rb)
reg.extraTipUsed = true
else
tooltip:AddDoubleLine(textLeft,textRight,lr,lg,lb,rr,rg,rb)
end
end
 
--[[-
Creates a string representation of the money value passed using embedded textures for the icons
@param money the money value to be converted in copper
@param concise when false (default), the representation of 1g is "1g 00s 00c" when true, it is simply "1g" (optional)
@since 1.0
]]
function lib:GetMoneyText(money, concise)
local g = math.floor(money / 10000)
local s = math.floor(money % 10000 / 100)
local c = math.floor(money % 100)
 
local moneyText = ""
 
local sep, fmt = "", "%d"
if g > 0 then
moneyText = goldicon:format(g)
sep, fmt = " ", "%02d"
end
 
if s > 0 or (money >= 10000 and (concise and c > 0) or not concise) then
moneyText = moneyText..sep..silvericon:format(fmt):format(s)
sep, fmt = " ", "%02d"
end
 
if not concise or c > 0 or money < 100 then
moneyText = moneyText..sep..coppericon:format(fmt):format(c)
end
 
return moneyText
end
 
--[[-
Adds a line with text in the left column and a money frame in the right.
The money parameter is given in copper coins (i.e. 1g 27s 5c would be 12705)
@param tooltip GameTooltip object
@param text the contents of the tooltip line
@param money the money value to be displayed (in copper)
@param r red component of the tooltip line color (optional)
@param g green component of the tooltip line color (optional)
@param b blue component of the tooltip line color (optional)
@param embed override the lib's embedMode setting (optional)
@param concise specify if concise money mode is to be used (optional)
@see SetEmbedMode
@since 1.0
]]
function lib:AddMoneyLine(tooltip,text,money,r,g,b,embed,concise)
local reg = self.tooltipRegistry[tooltip]
assert(reg, "Unknown tooltip passed to LibExtraTip:AddMoneyLine()")
 
if r and not g then embed = r r = nil end
embed = embed ~= nil and embed or self.embedMode
 
local moneyText = self:GetMoneyText(money, concise)
 
if not embed then
reg.extraTip:AddDoubleLine(text,moneyText,r,g,b,1,1,1)
reg.extraTipUsed = true
else
tooltip:AddDoubleLine(text,moneyText,lr,lg,lb,1,1,1)
end
end
 
--[[-
Sets a tooltip to hyperlink with specified quantity
@param tooltip GameTooltip object
@param link hyperlink to display in the tooltip
@param quantity quantity of the item to display
@param detail additional detail items to set for the callbacks
@return nil
@since 1.0
]]
function lib:SetHyperlinkAndCount(tooltip, link, quantity, detail)
local reg = self.tooltipRegistry[tooltip]
assert(reg, "Unknown tooltip passed to LibExtraTip:SetHyperlinkAndCount()")
 
OnTooltipCleared(tooltip)
reg.quantity = quantity
reg.item = link
reg.additional.event = "SetHyperlinkAndCount"
reg.additional.eventLink = link
if detail then
for k,v in pairs(detail) do
reg.additional[k] = v
end
end
reg.ignoreOnCleared = true
hooks[tooltip].origs["SetHyperlink"](tooltip,link)
reg.ignoreOnCleared = nil
end
 
--[[-
Get the additional information from a tooltip event.
Often additional event details are available about the situation under which the tooltip was invoked, such as:
* The call that triggered the tooltip.
* The slot/inventory/index of the item in question.
* Whether the item is usable or not.
* Auction price information.
* Ownership information.
* Any data provided by the Get*Info() functions.
If you require access to this information for the current tooltip, call this function to retrieve it.
@param tooltip GameTooltip object
@return table containing the additional information
@since 1.0
]]
function lib:GetTooltipAdditional(tooltip)
local reg = self.tooltipRegistry[tooltip]
assert(reg, "Unknown tooltip passed to LibExtraTip:GetTooltipAdditional()")
 
if reg then
return reg.additional
end
return nil
end
 
 
 
--[[ INTERNAL USE ONLY
Deactivates this version of the library, rendering it inert.
Needed to run before an upgrade of the library takes place.
@since 1.0
]]
function lib:Deactivate()
if self.tooltipRegistry then
for tooltip in self.tooltipRegistry do
unhookscript(tooltip,"OnTooltipSetItem")
unhookscript(tooltip,"OnTooltipSetUnit")
unhookscript(tooltip,"OnTooltipSetSpell")
unhookscript(tooltip,"OnTooltipCleared")
unhookscript(tooltip,"OnSizeChanged")
for k,v in pairs(tooltipMethods) do
unhook(tooltip,k)
end
end
end
end
 
--[[ INTERNAL USE ONLY
Activates this version of the library.
Configures this library for use by setting up its variables and reregistering any previously registered tooltips.
@since 1.0
]]
function lib:Activate()
if self.tooltipRegistry then
local oldreg = self.tooltipRegistry
self.tooltipRegistry = nil
for tooltip in oldreg do
self:RegisterTooltip(tooltip)
end
end
end
 
-- Sets all the complex spell details
local function SetSpellDetail(reg, link)
local name, rank, icon, cost, funnel, power, ctime, min, max = GetSpellInfo(link)
reg.additional.name = name
reg.additional.link = link
reg.additional.rank = rank
reg.additional.icon = icon
reg.additional.cost = cost
reg.additional.powerType = power
reg.additional.isFunnel = funnel
reg.additional.castTime = ctime
reg.additional.minRange = min
reg.additional.maxRange = max
end
 
--[[ INTERNAL USE ONLY
Generates a tooltip method table.
The tooltip method table supplies hooking information for the tooltip registration functions, including the methods to hook and a function to run that parses the hooked functions parameters.
@since 1.0
]]
function lib:GenerateTooltipMethodTable() -- Sets up hooks to give the quantity of the item
local reg = self.tooltipRegistry
tooltipMethods = {
 
-- Default enabled events
 
SetAuctionItem = function(self,reg,type,index)
local _,_,q,_,cu,_ ,min,inc,bo,ba,hb,own = GetAuctionItemInfo(type,index)
reg.quantity = q
reg.additional.event = "SetAuctionItem"
reg.additional.eventType = type
reg.additional.eventIndex = index
reg.additional.canUse = cu
reg.additional.minBid = min
reg.additional.minIncrement = inc
reg.additional.buyoutPrice = bo
reg.additional.bidAmount = ba
reg.additional.highBidder = hb
reg.additional.owner = own
end,
 
SetAuctionSellItem = function(self,reg)
local name,texture,quantity,quality,canUse,price = GetAuctionSellItemInfo()
reg.quantity = quantity
reg.additional.event = "SetAuctionSellItem"
reg.additional.canUse = canUse
end,
 
SetBagItem = function(self,reg,bag,slot)
local _,q,l,_,r= GetContainerItemInfo(bag,slot)
reg.quantity = q
reg.additional.event = "SetBagItem"
reg.additional.eventContainer = bag
reg.additional.eventIndex = slot
reg.additional.readable = r
reg.additional.locked = l
end,
 
SetBuybackItem = function(self,reg,index)
local name,texture,price,quantity = GetBuybackItemInfo(index)
reg.quantity = quantity
reg.additional.event = "SetBuybackItem"
reg.additional.eventIndex = index
end,
 
SetGuildBankItem = function(self,reg,tab,index)
local texture,quantity,locked = GetGuildBankItemInfo(tab,index)
reg.quantity = quantity
reg.additional.event = "SetGuildBankItem"
reg.additional.eventContainer = tab
reg.additional.eventIndex = index
reg.additional.locked = locked
end,
 
SetInboxItem = function(self,reg,index)
local _,_,q,_,cu = GetInboxItem(index)
reg.quantity = q
reg.additional.event = "SetInboxItem"
reg.additional.eventIndex = index
reg.additional.canUse = cu
end,
 
SetInventoryItem = function(self,reg,unit,index)
local q = GetInventoryItemCount(unit,index)
reg.quantity = q
reg.additional.event = "SetInventoryItem"
reg.additional.eventIndex = index
reg.additional.eventUnit = unit
end,
 
SetLootItem = function(self,reg,index)
local _,_,q = GetLootSlotInfo(index)
reg.quantity = q
reg.additional.event = "SetLootItem"
reg.additional.eventIndex = index
end,
 
SetLootRollItem = function(self,reg,index)
local texture, name, count, quality = GetLootRollItemInfo(index)
reg.quantity = q
reg.additional.event = "SetLootRollItem"
reg.additional.eventIndex = index
end,
 
SetMerchantItem = function(self,reg,index)
local _,_,p,q,na,cu,ec = GetMerchantItemInfo(index)
reg.quantity = q
reg.additional.event = "SetLootItem"
reg.additional.eventIndex = index
reg.additional.price = p
reg.additional.numAvailable = na
reg.additional.canUse = cu
reg.additional.extendedCost = ec
end,
 
SetQuestItem = function(self,reg,type,index)
local _,_,q,_,cu = GetQuestItemInfo(type,index)
reg.quantity = q
reg.additional.event = "SetQuestItem"
reg.additional.eventType = type
reg.additional.eventIndex = index
reg.additional.canUse = cu
end,
 
SetQuestLogItem = function(self,reg,type,index)
local _,q,cu
if type == "choice" then
_,_,q,_,cu = GetQuestLogChoiceInfo(index)
else
_,_,q,_,cu = GetQuestLogRewardInfo(index)
end
reg.quantity = q
reg.additional.event = "SetQuestLogItem"
reg.additional.eventType = type
reg.additional.eventIndex = index
reg.additional.canUse = cu
end,
 
SetSendMailItem = function(self,reg,index)
local name,texture,quantity = GetSendMailItem(index)
reg.quantity = quantity
reg.additional.event = "SetSendMailItem"
reg.additional.eventIndex = index
end,
 
SetTradePlayerItem = function(self,reg,index)
local name, texture, quantity = GetTradePlayerItemInfo(index)
reg.quantity = quantity
reg.additional.event = "SetTradePlayerItem"
reg.additional.eventIndex = index
end,
 
SetTradeTargetItem = function(self,reg,index)
local name, texture, quantity = GetTradeTargetItemInfo(index)
reg.quantity = quantity
reg.additional.event = "SetTradeTargetItem"
reg.additional.eventIndex = index
end,
 
SetTradeSkillItem = function(self,reg,index,reagentIndex)
reg.additional.event = "SetTradeSkillItem"
reg.additional.eventIndex = index
reg.additional.eventReagentIndex = reagentIndex
if reagentIndex then
local _,_,q,rc = GetTradeSkillReagentInfo(index,reagentIndex)
reg.quantity = q
reg.additional.playerReagentCount = rc
else
local link = GetTradeSkillItemLink(index)
reg.additional.link = link
reg.result = item
reg.quantity = GetTradeSkillNumMade(index)
if (link:sub(0, 6) == "spell:") then
SetSpellDetail(reg, link)
end
end
end,
 
SetHyperlink = function(self,reg,link)
reg.additional.event = "SetHyperlink"
reg.additional.eventLink = link
reg.additional.link = link
end,
 
-- Default disabled events:
 
SetAction = function(self,reg, actionid)
local t,id,sub = GetActionInfo(actionid)
reg.additional.event = "SetAction"
reg.additional.eventIndex = actionid
reg.additional.actionType = t
reg.additional.actionIndex = id
reg.additional.actionSubtype = subtype
if t == "item" then
reg.quantity = GetActionCount(actionid)
elseif t == "spell" then
if id and id > 0 then
local link = GetSpellLink(id, sub)
SetSpellDetail(reg, link)
end
end
end,
 
SetAuctionCompareItem = function(self, reg, type, index, offset)
reg.additional.event = "SetAuctionCompareItem"
reg.additional.eventType = type
reg.additional.eventIndex = index
reg.additional.eventOffset = offset
end,
 
SetCurrencyToken = function(self, reg, index)
reg.additional.event = "SetCurrencyToken"
reg.additional.eventIndex = index
end,
 
SetMerchantCompareItem = function(self, reg, index, offset)
reg.additional.event = "SetMerchantCompareItem"
reg.additional.eventIndex = index
reg.additional.eventOffset = offset
end,
 
SetPetAction = function(self, reg, index)
reg.additional.event = "SetPetAction"
reg.additional.eventIndex = index
end,
 
SetPlayerBuff = function(self, reg, index)
reg.additional.event = "SetPlayerBuff"
reg.additional.eventIndex = index
end,
 
SetQuestLogRewardSpell = function(self, reg)
reg.additional.event = "SetQuestLogRewardSpell"
end,
 
SetQuestRewardSpell = function(self, reg)
reg.additional.event = "SetQuestRewardSpell"
end,
 
SetShapeshift = function(self, reg, index)
reg.additional.event = "SetShapeshift"
reg.additional.eventIndex = index
end,
 
SetSpell = function(self,reg,index,type)
local link = GetSpellLink(index, type)
if link then
reg.additional.event = "SetSpell"
reg.additional.eventIndex = index
reg.additional.eventType = type
SetSpellDetail(reg, link)
end
end,
 
SetTalent = function(self, reg, type, index)
reg.additional.event = "SetTalent"
reg.additional.eventIndex = index
end,
 
SetTracking = function(self, reg, index)
reg.additional.event = "SetTracking"
reg.additional.eventIndex = index
end,
 
SetTrainerService = function(self, reg, index)
reg.additional.event = "SetTrainerService"
reg.additional.eventIndex = index
end,
 
SetUnit = function(self, reg, unit)
reg.additional.event = "SetUnit"
reg.additional.eventUnit= unit
end,
 
SetUnitAura = function(self, reg, unit, index, filter)
reg.additional.event = "SetUnitAura"
reg.additional.eventUnit = unit
reg.additional.eventIndex = index
reg.additional.eventFilter = filter
end,
 
SetUnitBuff = function(self, reg, unit, index, filter)
reg.additional.event = "SetUnitBuff"
reg.additional.eventUnit = unit
reg.additional.eventIndex = index
reg.additional.eventFilter = filter
end,
 
SetUnitDebuff = function(self, reg, unit, index, filter)
reg.additional.event = "SetUnitDebuff"
reg.additional.eventUnit = unit
reg.additional.eventIndex = index
reg.additional.eventFilter = filter
end,
}
end
 
do -- ExtraTip "class" definition
local methods = {"InitLines","Attach","Show","MatchSize","Release","NeedsRefresh","SetParentClamp"}
local scripts = {"OnShow","OnHide","OnSizeChanged"}
local numTips = 0
local class = {}
ExtraTipClass = class
 
local addLine,addDoubleLine,show = GameTooltip.AddLine,GameTooltip.AddDoubleLine,GameTooltip.Show
 
local line_mt = {
__index = function(t,k)
local v = getglobal(t.name..k)
rawset(t,k,v)
return v
end
}
 
function class:new()
local n = numTips + 1
numTips = n
local o = CreateFrame("GameTooltip",LIBSTRING.."Tooltip"..n,UIParent,"GameTooltipTemplate")
 
for _,method in pairs(methods) do
o[method] = self[method]
end
 
for _,script in pairs(scripts) do
o:SetScript(script,self[script])
end
 
o.left = setmetatable({name = o:GetName().."TextLeft"},line_mt)
o.right = setmetatable({name = o:GetName().."TextRight"},line_mt)
return o
end
 
function class:Attach(tooltip)
if self.parent then self:SetParentClamp(0) end
self.parent = tooltip
self:SetParent(tooltip)
self:SetOwner(tooltip,"ANCHOR_NONE")
self:SetPoint("TOP",tooltip,"BOTTOM")
end
 
function class:Release()
if self.parent then self:SetParentClamp(0) end
self.parent = nil
self:SetParent(nil)
self.minWidth = 0
end
 
function class:InitLines()
local n = self:NumLines()
local changedLines = self.changedLines
if not changedLines or changedLines < n then
for i = changedLines or 1,n do
local left,right = self.left[i],self.right[i]
local font
if i == 1 then
font = GameFontNormal
else
font = GameFontNormalSmall
end
 
local r,g,b,a
 
r,g,b,a = left:GetTextColor()
left:SetFontObject(font)
left:SetTextColor(r,g,b,a)
 
r,g,b,a = right:GetTextColor()
right:SetFontObject(font)
right:SetTextColor(r,g,b,a)
end
self.changedLines = n
end
end
 
local function refresh(self)
self:NeedsRefresh(false)
self:MatchSize()
end
 
function class:NeedsRefresh(flag)
if flag then
self:SetScript("OnUpdate",refresh)
else
self:SetScript("OnUpdate",nil)
end
end
 
function class:SetParentClamp(h)
local p = self.parent
if not p then return end
local l,r,t,b = p:GetClampRectInsets()
p:SetClampRectInsets(l,r,t,-h)
self:NeedsRefresh(true)
end
 
function class:OnShow()
self:SetParentClamp(self:GetHeight())
end
 
function class:OnSizeChanged(w,h)
self:SetParentClamp(h)
end
 
function class:OnHide()
self:SetParentClamp(0)
end
 
-- The right-side text is statically positioned to the right of the left-side text.
-- As a result, manually changing the width of the tooltip causes the right-side text to not be in the right place.
local function fixRight(tooltip,lefts,rights)
local name,rn,ln,left,right
local getglobal = getglobal
if not lefts then
name = tooltip:GetName()
rn = name .. "TextRight"
ln = name .. "TextLeft"
end
for i=1,tooltip:NumLines() do
left = nil
right = nil
 
if lefts then left = lefts[i] end
if rights then right = rights[i] end
 
if not left then
left = getglobal(ln..i)
end
if not right then
right = getglobal(rn..i)
end
 
if right and right:IsVisible() then
right:ClearAllPoints()
right:SetPoint("LEFT",left,"RIGHT")
right:SetPoint("RIGHT",-10,0)
right:SetJustifyH("RIGHT")
end
end
end
 
function class:MatchSize()
local p = self.parent
local pw = p:GetWidth()
local w = self:GetWidth()
local d = pw - w
if d > .005 then
self.sizing = true
self:SetWidth(pw)
fixRight(self,self.left,self.right)
elseif d < -.005 then
self.sizing = true
p:SetWidth(w)
fixRight(p)
end
end
 
function class:Show()
show(self)
self:InitLines()
end
 
end
 
-- More housekeeping upgrade stuff
lib:SetEmbedMode(lib.embedMode)
lib:Activate()
 
 
--[[ Test Code -----------------------------------------------------
 
local LT = LibStub("LibExtraTip-1")
 
LT:RegisterTooltip(GameTooltip)
LT:RegisterTooltip(ItemRefTooltip)
 
--[=[
LT:AddCallback(function(tip,item,quantity,name,link,quality,ilvl)
LT:AddDoubleLine(tip,"Item Level:",ilvl,nil,nil,nil,1,1,1,0)
LT:AddDoubleLine(tip,"Item Level:",ilvl,1,1,1,0)
LT:AddDoubleLine(tip,"Item Level:",ilvl,0)
end,0)
--]=]
LT:AddCallback(function(tip,item,quantity,name,link,quality,ilvl)
quantity = quantity or 1
local price = GetSellValue(item)
if price then
LT:AddMoneyLine(tip,"Sell to vendor"..(quantity > 1 and "("..quantity..")" or "") .. ":",price*quantity,1)
end
LT:AddDoubleLine(tip,"Item Level:",ilvl,1)
end)
 
-- Test Code ]]-----------------------------------------------------
 
--[[ Debugging code
local f = {"AddDoubleLine", "AddFontStrings", "AddLine", "AddTexture", "AppendText", "ClearLines", "FadeOut", "GetAnchorType", "GetItem", "GetSpell", "GetOwner", "GetUnit", "IsUnit", "NumLines", "SetAction", "SetAuctionCompareItem", "SetAuctionItem", "SetAuctionSellItem", "SetBagItem", "SetBuybackItem", "SetCraftItem", "SetCraftSpell", "SetCurrencyToken", "SetGuildBankItem", "SetHyperlink", "SetInboxItem", "SetInventoryItem", "SetLootItem", "SetLootRollItem", "SetMerchantCompareItem", "SetMerchantItem", "SetMinimumWidth", "SetOwner", "SetPadding", "SetPetAction", "SetPlayerBuff", "SetQuestItem", "SetQuestLogItem", "SetQuestLogRewardSpell", "SetQuestRewardSpell", "SetSendMailItem", "SetShapeshift", "SetSpell", "SetTalent", "SetText", "SetTracking", "SetTradePlayerItem", "SetTradeSkillItem", "SetTradeTargetItem", "SetTrainerService", "SetUnit", "SetUnitAura", "SetUnitBuff", "SetUnitDebuff"}
 
for _,k in ipairs(f) do
print("Hooking ", k)
local h = GameTooltip[k]
GameTooltip[k] = function(...)
local t
for i=2,5 do
if not t then
t = debugstack(i,1,0):gsub("\n[.\s\n]*", ""):gsub(": in function.*", "")
if not t:match("Interface\\") then t = nil
else t = t:gsub("Interface\\", "") end
end
end
if t then
print(t..": "..k.."(", ..., ")")
elseif true then
print("-------");
print(debugstack());
print("Call to: "..k.."(", ..., ")")
print("-------");
end
return h(...)
end
end
--]]
1.2/libs/LibExtraTip/LibMoneyFrame.lua New file
0,0 → 1,232
--[[-
LibMoneyFrame
 
LibMoneyFrame is a small helper library to create view-only money frame as minimalistically as is currently possible.
 
Copyright (C) 2008, by the respecive below authors.
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
 
This library 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
Lesser General Public License for more details.
 
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
@author Tem
@author Ken Allan <ken@norganna.org>
@libname LibMoneyFrame
@version 1.0
--]]
 
local MAJOR,MINOR,REVISION = "LibMoneyFrame", 1, "$Revision: 144 $"
 
-- A string unique to this version to prevent frame name conflicts.
local LIBSTRING = MAJOR.."_"..MINOR.."_"..REVISION
local lib = LibStub:NewLibrary(MAJOR.."-"..MINOR, REVISION)
if not lib then return end
 
-- Call function to deactivate any outdated version of the library.
-- (calls the OLD version of this function, NOT the one defined in this
-- file's scope)
if lib.Deactivate then lib:Deactivate() end
 
local methods = {}
local numMoneys = 0
 
local function createCoin(frame, pos, width, height)
if not width then width = 200 end
if not height then height = 16 end
frame:SetWidth(width)
frame:SetHeight(height)
frame.label = frame:CreateFontString()
frame.label:SetFontObject(GameTooltipTextSmall)
local font = frame.label:GetFont()
frame.label:SetHeight(height)
frame.label:SetWidth(width-height)
frame.label:SetFont(font, height)
frame.label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0,0)
frame.label:SetJustifyH("RIGHT")
frame.label:SetJustifyV("CENTER")
frame.label:Show()
frame.texture = frame:CreateTexture()
frame.texture:SetWidth(height)
frame.texture:SetHeight(height)
frame.texture:SetPoint("TOPLEFT", frame.label, "TOPRIGHT", 2,0)
frame.texture:SetPoint("BOTTOM", frame.label, "BOTTOM", 0,0)
frame.texture:SetTexture("Interface\\MoneyFrame\\UI-MoneyIcons")
frame.texture:SetTexCoord(pos,pos+0.25, 0,1)
frame.texture:Show()
end
 
local function refresh(self)
self:NeedsRefresh(false)
self:UpdateWidth()
end
 
function methods:UpdateWidth()
local curWidth = ceil(self:GetWidth())
local width = 0
if self.gold:IsShown() then
width = self.gold.label:GetStringWidth()
self.gold.label:SetWidth(width)
width = width + self.gold.texture:GetWidth() + 2 -- Add 2 for the uncounted right side buffer
self.gold:SetWidth(width)
end
if self.silver:IsShown() then
width = width + self.silver:GetWidth() -- self.silver already has a right side buffer
end
width = width + self.copper:GetWidth() + 2 -- Add 2 extra for a left side buffer
 
width = ceil(width)
if curWidth ~= width then self:NeedsRefresh(true) end
self:RealSetWidth(width)
 
end
 
function methods:NeedsRefresh(flag)
if flag then
self:SetScript("OnUpdate", refresh)
else
self:SetScript("OnUpdate", nil)
end
end
 
function methods:SetValue(money, red,green,blue)
money = math.floor(tonumber(money) or 0)
local g = math.floor(money / 10000)
local s = math.floor(money % 10000 / 100)
local c = math.floor(money % 100)
 
if not (red and green and blue) then
red, green, blue = unpack(self.color)
end
 
local height = self.height
if g > 0 then
self.gold.label:SetWidth(strlen(tostring(g)) * height * 2) -- Guess at the size so it doesn't truncate the
-- string and return a bogus width when we try and get the string length.
self.gold.label:SetFormattedText("%d", g)
self.gold.label:SetTextColor(red,green,blue)
self.gold:Show()
self:NeedsRefresh(true)
else
self.gold:Hide()
end
if g + s > 0 then
if (g > 0) then
self.silver.label:SetFormattedText("%02d", s)
else
self.silver.label:SetFormattedText("%d", s)
end
self.silver.label:SetTextColor(red,green,blue)
self.silver:Show()
else
self.silver:Hide()
end
 
if g + s > 0 then
self.copper.label:SetFormattedText("%02d", c)
else
self.copper.label:SetFormattedText("%d", c)
end
self.copper.label:SetTextColor(red,green,blue)
self.copper:Show()
self:UpdateWidth()
 
self:Show()
end
 
function methods:SetColor(red, green, blue)
self.color = {red, green, blue}
self.copper.label:SetTextColor(red, green, blue)
self.silver.label:SetTextColor(red, green, blue)
self.gold.label:SetTextColor(red, green, blue)
end
 
function methods:SetHeight()
end
 
function methods:SetWidth(width)
end
 
function methods:SetDrawLayer(layer)
self.gold.texture:SetDrawLayer(layer)
self.silver.texture:SetDrawLayer(layer)
self.copper.texture:SetDrawLayer(layer)
end
 
function lib:new(height, red, green, blue)
local n = numMoneys + 1
numMoneys = n
 
if not height then height = 10 end
if not (red and green and blue) then
red, green, blue = 0.9, 0.9, 0.9
end
 
local width = height*15
 
local name = LIBSTRING.."MoneyView"..n
local o = CreateFrame("Frame",name)
o:UnregisterAllEvents()
o:SetWidth(width)
o:SetHeight(height)
 
o.width = width
o.height = height
 
o.copper = CreateFrame("Frame", name.."Copper", o)
o.copper:SetPoint("TOPRIGHT", o, "TOPRIGHT", 0,0)
createCoin(o.copper, 0.5, height*2.8,height)
 
o.silver = CreateFrame("Frame", name.."Silver", o)
o.silver:SetPoint("TOPRIGHT", o.copper, "TOPLEFT", 0,0)
createCoin(o.silver, 0.25, height*2.8,height)
 
o.gold = CreateFrame("Frame", name.."Gold", o)
o.gold:SetPoint("TOPRIGHT", o.silver, "TOPLEFT", 0,0)
createCoin(o.gold, 0, width-(height*2.8),height)
 
-- Debugging code to see the extents:
-- o.texture = o:CreateTexture()
-- o.texture:SetTexture(0,1,0,1)
-- o.texture:SetPoint("TOPLEFT")
-- o.texture:SetPoint("BOTTOMRIGHT")
-- o.texture:SetDrawLayer("BACKGROUND")
 
for method,func in pairs(methods) do
if o[method] then o["Real"..method] = o[method] end
o[method] = func
end
 
o:SetColor(red, green, blue)
o:Hide()
 
return o
end
 
--[[ INTERNAL USE ONLY
Deactivates this version of the library, rendering it inert.
Needed to run before an upgrade of the library takes place.
@since 1.0
]]
function lib:Deactivate()
end
 
--[[ INTERNAL USE ONLY
Activates this version of the library.
Configures this library for use by setting up its variables and reregistering any previously registered tooltips.
@since 1.0
]]
function lib:Activate()
end
 
 
lib:Activate()
1.2/libs/LibExtraTip/LibExtraTip.toc New file
0,0 → 1,10
## Title: LibExtraTip
## Notes: Assists in the management of additional tooltip information.
##
## Interface: 30000
## LoadOnDemand: 0
##
## Version: 1.0
## Revision: $Id: LibExtraTip.toc 143 2008-11-05 13:05:42Z Norganna $
##
Load.xml
1.2/libs/LibExtraTip/API.html New file
0,0 → 1,172
<html>
<head>
<title>API Documentation</title>
<style>
body {
font: 13px Verdana, Helvetica, sans-serif;
color: #333;
background: #eee;
}
h1, h2, h3, h4 {
margin: 0px;
padding: 0px;
}
.method {
margin-top: 20px;
}
.author, .version, .param, .return, .see, .since {
padding-left: 1em;
}
:target {
background: #ffd;
}
li {
padding-left: 2em;
}
.summary {
font-style: oblique;
}
.method {
color: #521;
text-decoration: underline;
}
.param {
color: #44b;
}
.return {
color: #4a4;
}
.since {
color: #777;
}
</style>
</head>
<body>
 
<h2 class="title">LibExtraTip</h2><br/>
LibExtraTip is a library of API functions for manipulating additional information into GameTooltips by either adding information to the bottom of existing tooltips (embedded mode) or by adding information to an extra "attached" tooltip construct which is placed to the bottom of the existing tooltip.<br/>
Copyright (C) 2008, by the respecive below authors.<br/>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.<br/>
This library 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
Lesser General Public License for more details.<br/>
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA<br/>
<br/>
<b class="author">Author: Matt Richard (Tem)</b><br/>
<b class="author">Author: Ken Allan &lt;ken@norganna.org></b><br/>
<b class="version">Version: 1.0</b><br/>
 
<h3 class="method" id="RegisterTooltip">Class Method LibExtraTip:RegisterTooltip(tooltip)</h3><br/>
<h4 class="summary">Adds the provided tooltip to the list of tooltips to monitor for items.</h4><br/>
<b class="param">tooltip</b>: GameTooltip object<br/>
<b class="return">Returns</b>: true if tooltip is registered<br/>
<b class="since">Available since v1.0</b><br/>
 
<h3 class="method" id="IsRegistered">Class Method LibExtraTip:IsRegistered(tooltip)</h3><br/>
<h4 class="summary">Checks to see if the tooltip has been registered with LibExtraTip</h4><br/>
<b class="param">tooltip</b>: GameTooltip object<br/>
<b class="return">Returns</b>: true if tooltip is registered<br/>
<b class="since">Available since v1.0</b><br/>
 
<h3 class="method" id="AddCallback">Class Method LibExtraTip:AddCallback(callback, priority)</h3><br/>
<h4 class="summary">Adds a callback to be informed of any registered tooltip's activity.</h4><br/>
Callbacks are passed the following parameters (in order):
<li>tooltip: The tooltip object being shown (GameTooltip object)</li>
<li>item: The item being shown (in <a href="http://wowwiki.com/ItemLink" target="_blank">ItemLink</a> format)</li>
<li>quantity: The quantity of the item being shown (may be nil when the quantity is unavailable)</li>
<li>return values from <a href="http://wowwiki.com/API_GetItemInfo" target="_blank">GetItemInfo</a> (in order)</li><br/>
<b class="param">callback</b>: the method to be called<br/>
<b class="param">priority</b>: the priority of the callback (optional, default 200)<br/>
<b class="since">Available since v1.0</b><br/>
 
<h3 class="method" id="RemoveCallback">Class Method LibExtraTip:RemoveCallback(callback)</h3><br/>
<h4 class="summary">Removes the given callback from the list of callbacks.</h4><br/>
<b class="param">callback</b>: the callback to remove from notifications<br/>
<b class="return">Returns</b>: true if successfully removed<br/>
<b class="since">Available since v1.0</b><br/>
 
<h3 class="method" id="SetEmbedMode">Class Method LibExtraTip:SetEmbedMode(flag)</h3><br/>
<h4 class="summary">Sets the default embed mode of the library (default false)</h4><br/>
A false embedMode causes AddLine, AddDoubleLine and AddMoneyLine to add lines to the attached tooltip rather than embed added lines directly in the item tooltip.
This setting only takes effect when embed mode is not specified on individual AddLine, AddDoubleLine and AddMoneyLine commands.<br/>
<br/>
<b class="param">flag</b>: boolean flag if true embeds by default<br/>
<b class="since">Available since v1.0</b><br/>
 
<h3 class="method" id="AddLine">Class Method LibExtraTip:AddLine(tooltip, text, r, g, b, embed)</h3><br/>
<h4 class="summary">Adds a line to a registered tooltip.</h4><br/>
<b class="param">tooltip</b>: GameTooltip object<br/>
<b class="param">text</b>: the contents of the tooltip line<br/>
<b class="param">r</b>: red component of the tooltip line color (optional)<br/>
<b class="param">g</b>: green component of the tooltip line color (optional)<br/>
<b class="param">b</b>: blue component of the tooltip line color (optional)<br/>
<b class="param">embed</b>: override the lib's embedMode setting (optional)<br/>
<b class="see">See also</b>: <a href="#SetEmbedMode">SetEmbedMode</a><br/>
<b class="since">Available since v1.0</b><br/>
 
<h3 class="method" id="AddDoubleLine">Class Method LibExtraTip:AddDoubleLine(tooltip, textLeft, textRight, lr, lg, lb, rr, rg, rb, embed)</h3><br/>
<h4 class="summary">Adds a two-columned line to the tooltip.</h4><br/>
<b class="param">tooltip</b>: GameTooltip object<br/>
<b class="param">textLeft</b>: the left column's contents<br/>
<b class="param">textRight</b>: the left column's contents<br/>
<b class="param">r</b>: red component of the tooltip line color (optional)<br/>
<b class="param">g</b>: green component of the tooltip line color (optional)<br/>
<b class="param">b</b>: blue component of the tooltip line color (optional)<br/>
<b class="param">embed</b>: override the lib's embedMode setting (optional)<br/>
<b class="see">See also</b>: <a href="#SetEmbedMode">SetEmbedMode</a><br/>
<b class="since">Available since v1.0</b><br/>
 
<h3 class="method" id="GetMoneyText">Class Method LibExtraTip:GetMoneyText(money, concise)</h3><br/>
<h4 class="summary">Creates a string representation of the money value passed using embedded textures for the icons</h4><br/>
<b class="param">money</b>: the money value to be converted in copper<br/>
<b class="param">concise</b>: when false (default), the representation of 1g is "1g 00s 00c" when true, it is simply "1g" (optional)<br/>
<b class="since">Available since v1.0</b><br/>
 
<h3 class="method" id="AddMoneyLine">Class Method LibExtraTip:AddMoneyLine(tooltip, text, money, r, g, b, embed)</h3><br/>
<h4 class="summary">Adds a line with text in the left column and a money frame in the right.</h4><br/>
The money parameter is given in copper coins (i.e. 1g 27s 5c would be 12705)<br/>
<br/>
<b class="param">tooltip</b>: GameTooltip object<br/>
<b class="param">text</b>: the contents of the tooltip line<br/>
<b class="param">money</b>: the money value to be displayed (in copper)<br/>
<b class="param">r</b>: red component of the tooltip line color (optional)<br/>
<b class="param">g</b>: green component of the tooltip line color (optional)<br/>
<b class="param">b</b>: blue component of the tooltip line color (optional)<br/>
<b class="param">embed</b>: override the lib's embedMode setting (optional)<br/>
<b class="see">See also</b>: <a href="#SetEmbedMode">SetEmbedMode</a><br/>
<b class="since">Available since v1.0</b><br/>
 
<h3 class="method" id="CallTooltipMethod">Class Method LibExtraTip:CallTooltipMethod(tooltip, method, args, detail)</h3><br/>
<h4 class="summary">Calls a tooltip's method, passing arguments and setting additional details.</h4><br/>
You must use this function when you are setting your own tooltip, but want LibExtraTip to display the extra tooltip information and notify any callbacks.<br/>
<br/>
<b class="param">tooltip</b>: GameTooltip object<br/>
<b class="param">method</b>: the tooltip method to call (or nil to not call any)<br/>
<b class="param">args</b>: table of arguments to pass to tooltip method<br/>
<b class="param">detail</b>: additional detail items to set for the callbacks<br/>
<b class="return">Returns</b>: whatever the called method returns<br/>
<b class="since">Available since v1.0</b><br/>
 
<h3 class="method" id="GetTooltipAdditional">Class Method LibExtraTip:GetTooltipAdditional(tooltip)</h3><br/>
<h4 class="summary">Get the additional information from a tooltip event.</h4><br/>
Often additional event details are available about the situation under which the tooltip was invoked, such as:
<li>The call that triggered the tooltip.</li>
<li>The slot/inventory/index of the item in question.</li>
<li>Whether the item is usable or not.</li>
<li>Auction price information.</li>
<li>Ownership information.</li>
<li>Any data provided by the Get*Info() functions.</li>
If you require access to this information for the current tooltip, call this function to retrieve it.<br/>
<br/>
<b class="param">tooltip</b>: GameTooltip object<br/>
<b class="return">Returns</b>: table containing the additional information<br/>
<b class="since">Available since v1.0</b><br/>
 
</body>
</html>
\ No newline at end of file
1.2/libs/LibExtraTip/Load.xml New file
0,0 → 1,5
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
<Script file="LibStub.lua"/>
<Script file="LibExtraTip.lua"/>
<Script file="LibMoneyFrame.lua"/>
</Ui>
1.2/libs/LibExtraTip/contrib/processDoc.bat New file
0,0 → 1,5
@echo off
 
perl processDoc.pl ..\LibExtraTip.lua
move API.html ..\API.html
 
1.2/libs/LibExtraTip/contrib/processDoc.sh New file
0,0 → 1,5
#!/bin/ksh
 
perl processDoc.pl ../LibExtraTip.lua
mv API.html ../API.html
 
1.2/libs/LibExtraTip/contrib/processDoc.pl New file
0,0 → 1,169
!#/usr/bin/perl
 
open API, ">API.html";
$header = "<html>
<head>
<title>API Documentation</title>
<style>
body {
font: 13px Verdana, Helvetica, sans-serif;
color: #333;
background: #eee;
}
h1, h2, h3, h4 {
margin: 0px;
padding: 0px;
}
.method {
margin-top: 20px;
}
.author, .version, .param, .return, .see, .since {
padding-left: 1em;
}
:target {
background: #ffd;
}
li {
padding-left: 2em;
}
.summary {
font-style: oblique;
}
.method {
color: #521;
text-decoration: underline;
}
.param {
color: #44b;
}
.return {
color: #4a4;
}
.since {
color: #777;
}
</style>
</head>
<body>
";
 
print API $header;
 
$libName = "lib";
$commentNum = 0;
$comment = "";
$inComment = 0;
$fLooking = 0;
$first = 0;
$detail = 0;
while (<>) {
s/^\s*//g;
s/\s*$//g;
print "$inComment$fLooking$detail Line: $_\n";
if (!$inComment && /^--\[\[-/) {
$commentNum = 0;
$inComment = 1;
$fLooking = 0;
$detail = 0;
process($comment) if ($comment ne "");
$comment = "";
}
elsif ($inComment && /\]\]/) {
$inComment = 0;
$fLooking = 1;
$detail = 0;
}
elsif ($inComment && /^\@libname ([^\s]+)/) {
$libName = $1;
}
elsif ($inComment) {
if (!$first) {
$comment .= "\@title $_\n\n";
$first = 1;
$detail = 1;
}
elsif ($commentNum == 0) {
$comment .= "\n\@summary $_\n\n";
$detail = 1;
}
else {
if (/^\@/) {
unless($detail) {
$comment .= "\n\n \n\n";
}
$detail = 1;
}
elsif (/^\*\s+/) {
$detail = 1;
}
else {
$detail = 0;
}
$comment .= "$_\n";
}
$commentNum++;
}
elsif ($fLooking) {
$fLooking = 0;
if (/^(local)?\s*function\s+([^\s\(:\.]+)(([:\.])([^\s\(]+))?\(([^\)]+)\)/) {
if ($1) {
$scope = "Local ";
}
else {
$scope = "";
}
@params = split/\s*\,\s*/, $6;
$params = join(", ", @params);
if ($3) {
$lib = $2;
$accessor = $4;
if ($accessor eq ":") {
$mode = "Class Method";
}
else {
$mode = "Member Function";
}
$function = $5;
 
if ($lib eq "lib") {
$lib = $libName;
}
 
$comment = "\@method $function $mode $lib$accessor$function($params)\n$comment";
}
else {
($lib, $accessor) = ();
$mode = "Function";
$function = $2;
$comment = "\@method $function $scope$mode $function($params)\n$comment";
}
process($comment);
$comment = "";
}
}
}
process($comment) if ($comment ne "");
 
print API "\n</body>\n</html>";
close (API);
 
sub process($) {
my ($comment) = @_;
print "$comment";
$comment =~ s/</&lt;/g;
$comment =~ s/^\@author (.*)/\n<b class="author">Author: $1<\/b>\n/mg;
$comment =~ s/^\@version (.*)/\n<b class="version">Version: $1<\/b>\n/mg;
$comment =~ s/^\@since (.*)/\n<b class="since">Available since v$1<\/b>\n/mg;
$comment =~ s/^\@method ([^\s]+)\s+(.*)/\n<h3 class="method" id="$1">$2<\/h3>/mg;
$comment =~ s/^\@param ([^\s]+)\s+(.*)/\n<b class="param">$1<\/b>: $2\n/mg;
$comment =~ s/^\@return (.*)/\n<b class="return">Returns<\/b>: $1\n/mg;
$comment =~ s/^\@summary (.*)/\n<h4 class="summary">$1<\/h4>\n/mg;
$comment =~ s/^\@title (.*)/\n<h2 class="title">$1<\/h2>\n/mg;
$comment =~ s/^\@see (.*)/\n<b class="see">See also<\/b>: <a href="#$1">$1<\/a>\n/mg;
$comment =~ s/^\*\s+(.*)/<li>$1<\/li>/mg;
$comment =~ s/{\@wowwiki:([^}\|]+)}/<a href="http:\/\/wowwiki.com\/$1" target="_blank">$1<\/a>/g;
$comment =~ s/{\@wowwiki:([^}\|]+)\|([^}]+)}/<a href="http:\/\/wowwiki.com\/$1" target="_blank">$2<\/a>/g;
$comment =~ s/\n\n+/<br\/>\n/g;
print API $comment;
}
 
1.2/libs/LibExtraTip/LibStub.lua New file
0,0 → 1,30
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/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]
 
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
LibStub = LibStub or {libs = {}, minors = {} }
_G[LIBSTUB_MAJOR] = LibStub
LibStub.minor = LIBSTUB_MINOR
 
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
 
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
 
function LibStub:IterateLibraries() return pairs(self.libs) end
setmetatable(LibStub, { __call = LibStub.GetLibrary })
end
1.2/libs/AceAddon-3.0/AceAddon-3.0.xml New file
0,0 → 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="AceAddon-3.0.lua"/>
</Ui>
\ No newline at end of file
1.2/libs/AceAddon-3.0/AceAddon-3.0.lua New file
0,0 → 1,602
--- '''AceAddon-3.0''' provides a template for creating addon objects.
-- It'll provide you with a set of callback functions that allow you to simplify the loading
-- process of your addon. Callbacks provided are:<br>
-- - '''OnInitialize''', which is called directly after the addon is fully loaded.<br>
-- - '''OnEnable''' which gets called during the PLAYER_LOGIN event, when most of the data provided by the game is already present.<br>
-- - '''OnDisable''', which is only called when your addon is manually being disabled.<br>
-- @class file
-- @name AceAddon-3.0.lua
-- @release $Id: AceAddon-3.0.lua 732 2009-02-03 15:07:43Z nevcairiel $
local MAJOR, MINOR = "AceAddon-3.0", 5
local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 
if not AceAddon then return end -- No Upgrade needed.
 
AceAddon.frame = AceAddon.frame or CreateFrame("Frame", "AceAddon30Frame") -- Our very own frame
AceAddon.addons = AceAddon.addons or {} -- addons in general
AceAddon.statuses = AceAddon.statuses or {} -- statuses of addon.
AceAddon.initializequeue = AceAddon.initializequeue or {} -- addons that are new and not initialized
AceAddon.enablequeue = AceAddon.enablequeue or {} -- addons that are initialized and waiting to be enabled
AceAddon.embeds = AceAddon.embeds or setmetatable({}, {__index = function(tbl, key) tbl[key] = {} return tbl[key] end }) -- contains a list of libraries embedded in an addon
 
local tinsert, tconcat = table.insert, table.concat
local fmt = string.format
local pairs, next, type = pairs, next, type
 
--[[
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, ...)
-- we check to see if the func is passed is actually a function here and don't error when it isn't
-- this safecall is used for optional functions like OnInitialize OnEnable etc. When they are not
-- present execution should continue without hinderance
if type(func) == "function" then
return Dispatchers[select('#', ...)](func, ...)
end
end
 
-- local functions that will be implemented further down
local Enable, Disable, EnableModule, DisableModule, Embed, NewModule, GetModule, GetName, SetDefaultModuleState, SetDefaultModuleLibraries, SetEnabledState, SetDefaultModulePrototype
 
-- used in the addon metatable
local function addontostring( self ) return self.name end
 
--- Create a new AceAddon-3.0 addon.
-- @paramsig [object ,]name[, lib, ...]
-- @param object Table to use as a base for the addon (optional)
-- @param name Name of the addon object to create
-- @param lib List of libraries to embed into the addon
-- @usage
-- -- Create a simple addon object
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceEvent-3.0")
--
-- -- Create a Addon object based on the table of a frame
-- local MyFrame = CreateFrame("Frame")
-- local MyBetterAddon = LibStub("AceAddon-3.0"):NewAddon(MyFrame, "MyBetterAddon", "AceEvent-3.0")
-- @return The newly created addon object
function AceAddon:NewAddon(objectorname, ...)
local object,name
local i=1
if type(objectorname)=="table" then
object=objectorname
name=...
i=2
else
name=objectorname
end
if type(name)~="string" then
error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2)
end
if self.addons[name] then
error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - Addon '%s' already exists."):format(name), 2)
end
 
object = object or {}
object.name = name
 
local addonmeta = {}
local oldmeta = getmetatable(object)
if oldmeta then
for k, v in pairs(oldmeta) do addonmeta[k] = v end
end
addonmeta.__tostring = addontostring
 
setmetatable( object, addonmeta )
self.addons[name] = object
object.modules = {}
object.defaultModuleLibraries = {}
Embed( object ) -- embed NewModule, GetModule methods
self:EmbedLibraries(object, select(i,...))
 
-- add to queue of addons to be initialized upon ADDON_LOADED
tinsert(self.initializequeue, object)
return object
end
 
 
--- Get the addon object by its name from the internal AceAddon registry.
-- Throws an error if the addon object cannot be found (except if silent is set).
-- @param name unique name of the addon object
-- @param silent if true, the addon is optional, silently return nil if its not found
-- @usage
-- -- Get the Addon
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- @return The addon object, if found
function AceAddon:GetAddon(name, silent)
if not silent and not self.addons[name] then
error(("Usage: GetAddon(name): 'name' - Cannot find an AceAddon '%s'."):format(tostring(name)), 2)
end
return self.addons[name]
end
 
--- Embed a list of libraries into the specified addon.
-- Note: This function is for internal use by :NewAddon/:NewModule
-- @paramsig addon, [lib, ...]
-- @param addon addon object to embed the libs in
-- @param lib List of libraries to embed into the addon
function AceAddon:EmbedLibraries(addon, ...)
for i=1,select("#", ... ) do
local libname = select(i, ...)
self:EmbedLibrary(addon, libname, false, 4)
end
end
 
--- Embed a library into the addon object.
-- Note: This function is for internal use by :EmbedLibraries
-- @paramsig addon, libname[, silent[, offset]]
-- @param addon addon object to embed the library in
-- @param libname name of the library to embed
-- @param silent marks an embed to fail silently if the library doesn't exist (optional)
-- @param offset will push the error messages back to said offset, defaults to 2 (optional)
function AceAddon:EmbedLibrary(addon, libname, silent, offset)
local lib = LibStub:GetLibrary(libname, true)
if not lib and not silent then
error(("Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Cannot find a library instance of %q."):format(tostring(libname)), offset or 2)
elseif lib and type(lib.Embed) == "function" then
lib:Embed(addon)
tinsert(self.embeds[addon], libname)
return true
elseif lib then
error(("Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Library '%s' is not Embed capable"):format(libname), offset or 2)
end
end
 
--- Return the specified module from an addon object.
-- Throws an error if the addon object cannot be found (except if silent is set)
-- @paramsig name[, silent]
-- @param name unique name of the module
-- @param silent if true, the module is optional, silently return nil if its not found (optional)
-- @usage
-- -- Get the Addon
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- -- Get the Module
-- MyModule = MyAddon:GetModule("MyModule")
-- @return the module object, if found
function GetModule(self, name, silent)
if not self.modules[name] and not silent then
error(("Usage: GetModule(name, silent): 'name' - Cannot find module '%s'."):format(tostring(name)), 2)
end
return self.modules[name]
end
 
local function IsModuleTrue(self) return true end
 
--- Create a new module for the addon.
-- The new module can have its own embeded libraries and/or use a module prototype to be mixed into the module.<br>
-- A module has the same functionality as a real addon, it can have modules of its own, and has the same API as
-- an addon object.
-- @paramsig name[, prototype|lib[, lib, ...]]
-- @param name unique name of the module
-- @param prototype object to derive this module from, methods and values from this table will be mixed into the module (optional)
-- @param lib List of libraries to embed into the addon
-- @usage
-- -- Create a module with some embeded libraries
-- MyModule = MyAddon:NewModule("MyModule", "AceEvent-3.0", "AceHook-3.0")
--
-- -- Create a module with a prototype
-- local prototype = { OnEnable = function(self) print("OnEnable called!") end }
-- MyModule = MyAddon:NewModule("MyModule", prototype, "AceEvent-3.0", "AceHook-3.0")
-- @return the module object, if successfull
function NewModule(self, name, prototype, ...)
if type(name) ~= "string" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end
if type(prototype) ~= "string" and type(prototype) ~= "table" and type(prototype) ~= "nil" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'prototype' - table (prototype), string (lib) or nil expected got '%s'."):format(type(prototype)), 2) end
 
if self.modules[name] then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - Module '%s' already exists."):format(name), 2) end
 
-- modules are basically addons. We treat them as such. They will be added to the initializequeue properly as well.
-- NewModule can only be called after the parent addon is present thus the modules will be initialized after their parent is.
local module = AceAddon:NewAddon(fmt("%s_%s", self.name or tostring(self), name))
 
module.IsModule = IsModuleTrue
module:SetEnabledState(self.defaultModuleState)
module.moduleName = name
 
if type(prototype) == "string" then
AceAddon:EmbedLibraries(module, prototype, ...)
else
AceAddon:EmbedLibraries(module, ...)
end
AceAddon:EmbedLibraries(module, unpack(self.defaultModuleLibraries))
 
if not prototype or type(prototype) == "string" then
prototype = self.defaultModulePrototype or nil
end
 
if type(prototype) == "table" then
local mt = getmetatable(module)
mt.__index = prototype
setmetatable(module, mt) -- More of a Base class type feel.
end
 
safecall(self.OnModuleCreated, self, module) -- Was in Ace2 and I think it could be a cool thing to have handy.
self.modules[name] = module
 
return module
end
 
--- Returns the real name of the addon or module, without any prefix.
-- @paramsig
-- @usage
-- print(MyAddon:GetName())
-- -- prints "MyAddon"
-- @return The name of the addon or module
function GetName(self)
return self.moduleName or self.name
end
 
--- Enables the Addon, if possible, return true or false depending on success.
-- This internally calls AceAddon:EnableAddon(), thus dispatching a OnEnable callback
-- and enabling all modules of the addon (unless explicitly disabled).<br>
-- :Enable() also sets the internal `enableState` variable to true
-- @paramsig
-- @usage
-- -- Enable MyModule
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyModule = MyAddon:GetModule("MyModule")
-- MyModule:Enable()
-- @return true if the addon was enabled successfully
function Enable(self)
self:SetEnabledState(true)
return AceAddon:EnableAddon(self)
end
 
--- Disables the Addon, if possible, return true or false depending on success.
-- This internally calls AceAddon:DisableAddon(), thus dispatching a OnDisable callback
-- and disabling all modules of the addon.<br>
-- :Disable() also sets the internal `enableState` variable to false
-- @paramsig
-- @usage
-- -- Disable MyAddon
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyAddon:Disable()
-- @return true if the addon was disabled successfully
function Disable(self)
self:SetEnabledState(false)
return AceAddon:DisableAddon(self)
end
 
--- Enables the Module, if possible, return true or false depending on success.
-- Short-hand function that retrieves the module via `:GetModule` and calls `:Enable` on the module object.
-- @paramsig name
-- @usage
-- -- Enable MyModule using :GetModule
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyModule = MyAddon:GetModule("MyModule")
-- MyModule:Enable()
--
-- -- Enable MyModule using the short-hand
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyAddon:EnableModule("MyModule")
-- @return true if the module was enabled successfully
-- @see Enable
function EnableModule(self, name)
local module = self:GetModule( name )
return module:Enable()
end
 
--- Disables the Module, if possible, return true or false depending on success.
-- Short-hand function that retrieves the module via `:GetModule` and calls `:Disable` on the module object.
-- @paramsig name
-- @usage
-- -- Disable MyModule using :GetModule
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyModule = MyAddon:GetModule("MyModule")
-- MyModule:Disable()
--
-- -- Disable MyModule using the short-hand
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyAddon:DisableModule("MyModule")
-- @return true if the module was disabled successfully
-- @see Disable
function DisableModule(self, name)
local module = self:GetModule( name )
return module:Disable()
end
 
--- Set the default libraries to be mixed into all modules created by this object.
-- Note that you can only change the default module libraries before any module is created.
-- @paramsig lib[, lib, ...]
-- @param lib List of libraries to embed into the addon
-- @usage
-- -- Create the addon object
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon")
-- -- Configure default libraries for modules (all modules need AceEvent-3.0)
-- MyAddon:SetDefaultModuleLibraries("AceEvent-3.0")
-- -- Create a module
-- MyModule = MyAddon:NewModule("MyModule")
function SetDefaultModuleLibraries(self, ...)
if next(self.modules) then
error("Usage: SetDefaultModuleLibraries(...): cannot change the module defaults after a module has been registered.", 2)
end
self.defaultModuleLibraries = {...}
end
 
--- Set the default state in which new modules are being created.
-- Note that you can only change the default state before any module is created.
-- @paramsig state
-- @param state Default state for new modules, true for enabled, false for disabled
-- @usage
-- -- Create the addon object
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon")
-- -- Set the default state to "disabled"
-- MyAddon:SetDefaultModuleState(false)
-- -- Create a module and explicilty enable it
-- MyModule = MyAddon:NewModule("MyModule")
-- MyModule:Enable()
function SetDefaultModuleState(self, state)
if next(self.modules) then
error("Usage: SetDefaultModuleState(state): cannot change the module defaults after a module has been registered.", 2)
end
self.defaultModuleState = state
end
 
--- Set the default prototype to use for new modules on creation.
-- Note that you can only change the default prototype before any module is created.
-- @paramsig prototype
-- @param prototype Default prototype for the new modules (table)
-- @usage
-- -- Define a prototype
-- local prototype = { OnEnable = function(self) print("OnEnable called!") end }
-- -- Set the default prototype
-- MyAddon:SetDefaultModulePrototype(prototype)
-- -- Create a module and explicitly Enable it
-- MyModule = MyAddon:NewModule("MyModule")
-- MyModule:Enable()
-- -- should print "OnEnable called!" now
-- @see NewModule
function SetDefaultModulePrototype(self, prototype)
if next(self.modules) then
error("Usage: SetDefaultModulePrototype(prototype): cannot change the module defaults after a module has been registered.", 2)
end
if type(prototype) ~= "table" then
error(("Usage: SetDefaultModulePrototype(prototype): 'prototype' - table expected got '%s'."):format(type(prototype)), 2)
end
self.defaultModulePrototype = prototype
end
 
--- Set the state of an addon or module
-- This should only be caleld before any enabling actually happend, aka in/before OnInitialize.
-- @paramsig state
-- @param state the state of an addon or module (enabled=true, disabled=false)
function SetEnabledState(self, state)
self.enabledState = state
end
 
 
--- Return an iterator of all modules associated to the addon.
-- @paramsig
-- @usage
-- -- Enable all modules
-- for name, module in MyAddon:IterateModules() do
-- module:Enable()
-- end
-- @return Iterator of all modules
local function IterateModules(self) return pairs(self.modules) end
 
-- Returns an iterator of all embeds in the addon
-- @paramsig
-- @return Iterator of all embeded libraries
local function IterateEmbeds(self) return pairs(AceAddon.embeds[self]) end
 
--- Query the enabledState of an addon.
-- @paramsig
-- @usage
-- if MyAddon:IsEnabled() then
-- MyAddon:Disable()
-- end
-- @return true if the addon/module is enabled, false otherwise
local function IsEnabled(self) return self.enabledState end
local mixins = {
NewModule = NewModule,
GetModule = GetModule,
Enable = Enable,
Disable = Disable,
EnableModule = EnableModule,
DisableModule = DisableModule,
IsEnabled = IsEnabled,
SetDefaultModuleLibraries = SetDefaultModuleLibraries,
SetDefaultModuleState = SetDefaultModuleState,
SetDefaultModulePrototype = SetDefaultModulePrototype,
SetEnabledState = SetEnabledState,
IterateModules = IterateModules,
IterateEmbeds = IterateEmbeds,
GetName = GetName,
}
local function IsModule(self) return false end
local pmixins = {
defaultModuleState = true,
enabledState = true,
IsModule = IsModule,
}
-- Embed( target )
-- target (object) - target object to embed aceaddon in
--
-- this is a local function specifically since it's meant to be only called internally
function Embed(target)
for k, v in pairs(mixins) do
target[k] = v
end
for k, v in pairs(pmixins) do
target[k] = target[k] or v
end
end
 
 
--- Initialize the addon after creation.
-- Note: This function is only used internally during the ADDON_LOADED event
-- It will call the '''OnInitialize''' function on the addon object (if present),
-- and the '''OnEmbedInitialize''' function on all embeded libraries. <br>
-- Do not call this function manually, unless you're absolutely sure that you know what you are doing.
-- @param addon addon object to intialize
function AceAddon:InitializeAddon(addon)
safecall(addon.OnInitialize, addon)
 
local embeds = self.embeds[addon]
for i = 1, #embeds do
local lib = LibStub:GetLibrary(embeds[i], true)
if lib then safecall(lib.OnEmbedInitialize, lib, addon) end
end
 
-- we don't call InitializeAddon on modules specifically, this is handled
-- from the event handler and only done _once_
end
 
--- Enable the addon after creation.
-- Note: This function is only used internally during the PLAYER_LOGIN event, or during ADDON_LOADED,
-- if IsLoggedIn() already returns true at that point, e.g. for LoD Addons.
-- It will call the '''OnEnable''' function on the addon object (if present),
-- and the '''OnEmbedEnable''' function on all embeded libraries.<br>
-- This function does not toggle the enable state of the addon itself, and will return early if the addon is disabled.<br>
-- Do not call this function manually, unless you're absolutely sure that you know what you are doing.
-- @param addon addon object to enable
function AceAddon:EnableAddon(addon)
if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end
if self.statuses[addon.name] or not addon.enabledState then return false end
 
-- set the statuses first, before calling the OnEnable. this allows for Disabling of the addon in OnEnable.
self.statuses[addon.name] = true
 
safecall(addon.OnEnable, addon)
 
-- make sure we're still enabled before continueing
if self.statuses[addon.name] then
local embeds = self.embeds[addon]
for i = 1, #embeds do
local lib = LibStub:GetLibrary(embeds[i], true)
if lib then safecall(lib.OnEmbedEnable, lib, addon) end
end
 
-- enable possible modules.
for name, module in pairs(addon.modules) do
self:EnableAddon(module)
end
end
return self.statuses[addon.name] -- return true if we're disabled
end
 
--- Disable the addon
-- Note: This function is only used internally.
-- It will call the '''OnDisable''' function on the addon object (if present),
-- and the '''OnEmbedDisable''' function on all embeded libraries.<br>
-- This function does not toggle the enable state of the addon itself, and will return early if the addon is still enabled.<br>
-- Do not call this function manually, unless you're absolutely sure that you know what you are doing.
-- @param addon addon object to enable
function AceAddon:DisableAddon(addon)
if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end
if not self.statuses[addon.name] then return false end
 
-- set statuses first before calling OnDisable, this allows for aborting the disable in OnDisable.
self.statuses[addon.name] = false
 
safecall( addon.OnDisable, addon )
 
-- make sure we're still disabling...
if not self.statuses[addon.name] then
local embeds = self.embeds[addon]
for i = 1, #embeds do
local lib = LibStub:GetLibrary(embeds[i], true)
if lib then safecall(lib.OnEmbedDisable, lib, addon) end
end
-- disable possible modules.
for name, module in pairs(addon.modules) do
self:DisableAddon(module)
end
end
 
return not self.statuses[addon.name] -- return true if we're disabled
end
 
--The next few funcs are just because no one should be reaching into the internal registries
--Thoughts?
 
--- Get an iterator over all registered addons.
-- @usage
-- -- Print a list of all installed AceAddon's
-- for name, addon in AceAddon:IterateAddons() do
-- print("Addon: " .. name)
-- end
-- @return Iterator over all addons (pairs)
function AceAddon:IterateAddons() return pairs(self.addons) end
 
--- Get an iterator over the internal status registry.
-- @usage
-- -- Print a list of all enabled addons
-- for name, status in AceAddon:IterateAddonStatus() do
-- if status then
-- print("EnabledAddon: " .. name)
-- end
-- end
-- @return Iterator over the status registry
function AceAddon:IterateAddonStatus() return pairs(self.statuses) end
 
-- Following Iterators are deprecated, and their addon specific versions should be used
-- e.g. addon:IterateEmbeds() instead of :IterateEmbedsOnAddon(addon)
function AceAddon:IterateEmbedsOnAddon(addon) return pairs(self.embeds[addon]) end
function AceAddon:IterateModulesOfAddon(addon) return pairs(addon.modules) end
 
-- Event Handling
local function onEvent(this, event, arg1)
if event == "ADDON_LOADED" or event == "PLAYER_LOGIN" then
-- if a addon loads another addon, recursion could happen here, so we need to validate the table on every iteration
while(#AceAddon.initializequeue > 0) do
local addon = tremove(AceAddon.initializequeue, 1)
-- this might be an issue with recursion - TODO: validate
if event == "ADDON_LOADED" then addon.baseName = arg1 end
AceAddon:InitializeAddon(addon)
tinsert(AceAddon.enablequeue, addon)
end
 
if IsLoggedIn() then
while(#AceAddon.enablequeue > 0) do
local addon = tremove(AceAddon.enablequeue, 1)
AceAddon:EnableAddon(addon)
end
end
end
end
 
AceAddon.frame:RegisterEvent("ADDON_LOADED")
AceAddon.frame:RegisterEvent("PLAYER_LOGIN")
AceAddon.frame:SetScript("OnEvent", onEvent)
 
-- upgrade embeded
for name, addon in pairs(AceAddon.addons) do
Embed(addon)
end
1.2/libs/AceDB-3.0/AceDB-3.0.xml New file
0,0 → 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="AceDB-3.0.lua"/>
</Ui>
\ No newline at end of file
1.2/libs/AceDB-3.0/AceDB-3.0.lua New file
0,0 → 1,614
--- AceDB-3.0 allows you to create profiles and smart default values for the SavedVariables of your addon.
-- @class file
-- @name AceDB-3.0.lua
-- @release $Id: AceDB-3.0.lua 735 2009-02-14 11:10:48Z nevcairiel $
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 10
local AceDB, oldminor = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR)
 
if not AceDB then return end -- No upgrade needed
 
local type = type
local pairs, next = pairs, next
local rawget, rawset = rawget, rawset
local setmetatable = setmetatable
 
AceDB.db_registry = AceDB.db_registry or {}
AceDB.frame = AceDB.frame or CreateFrame("Frame")
 
local CallbackHandler
local CallbackDummy = { Fire = function() end }
 
local DBObjectLib = {}
 
--[[-------------------------------------------------------------------------
AceDB Utility Functions
---------------------------------------------------------------------------]]
 
-- Simple shallow copy for copying defaults
local function copyTable(src, dest)
if type(dest) ~= "table" then dest = {} end
if type(src) == "table" then
for k,v in pairs(src) do
if type(v) == "table" then
-- try to index the key first so that the metatable creates the defaults, if set, and use that table
v = copyTable(v, dest[k])
end
dest[k] = v
end
end
return dest
end
 
-- Called to add defaults to a section of the database
--
-- When a ["*"] default section is indexed with a new key, a table is returned
-- and set in the host table. These tables must be cleaned up by removeDefaults
-- in order to ensure we don't write empty default tables.
local function copyDefaults(dest, src)
-- this happens if some value in the SV overwrites our default value with a non-table
--if type(dest) ~= "table" then return end
for k, v in pairs(src) do
if k == "*" or k == "**" then
if type(v) == "table" then
-- This is a metatable used for table defaults
local mt = {
-- This handles the lookup and creation of new subtables
__index = function(t,k)
if k == nil then return nil end
local tbl = {}
copyDefaults(tbl, v)
rawset(t, k, tbl)
return tbl
end,
}
setmetatable(dest, mt)
-- handle already existing tables in the SV
for dk, dv in pairs(dest) do
if not rawget(src, dk) and type(dv) == "table" then
copyDefaults(dv, v)
end
end
else
-- Values are not tables, so this is just a simple return
local mt = {__index = function(t,k) return k~=nil and v or nil end}
setmetatable(dest, mt)
end
elseif type(v) == "table" then
if not rawget(dest, k) then rawset(dest, k, {}) end
if type(dest[k]) == "table" then
copyDefaults(dest[k], v)
if src['**'] then
copyDefaults(dest[k], src['**'])
end
end
else
if rawget(dest, k) == nil then
rawset(dest, k, v)
end
end
end
end
 
-- Called to remove all defaults in the default table from the database
local function removeDefaults(db, defaults, blocker)
for k,v in pairs(defaults) do
if k == "*" or k == "**" then
if type(v) == "table" then
-- Loop through all the actual k,v pairs and remove
for key, value in pairs(db) do
if type(value) == "table" then
-- if the key was not explicitly specified in the defaults table, just strip everything from * and ** tables
if defaults[key] == nil and (not blocker or blocker[key] == nil) then
removeDefaults(value, v)
-- if the table is empty afterwards, remove it
if next(value) == nil then
db[key] = nil
end
-- if it was specified, only strip ** content, but block values which were set in the key table
elseif k == "**" then
removeDefaults(value, v, defaults[key])
end
end
end
elseif k == "*" then
-- check for non-table default
for key, value in pairs(db) do
if defaults[key] == nil and v == value then
db[key] = nil
end
end
end
elseif type(v) == "table" and type(db[k]) == "table" then
-- if a blocker was set, dive into it, to allow multi-level defaults
removeDefaults(db[k], v, blocker and blocker[k])
if next(db[k]) == nil then
db[k] = nil
end
else
-- check if the current value matches the default, and that its not blocked by another defaults table
if db[k] == defaults[k] and (not blocker or blocker[k] == nil) then
db[k] = nil
end
end
end
-- remove all metatables from the db
setmetatable(db, nil)
end
 
-- This is called when a table section is first accessed, to set up the defaults
local function initSection(db, section, svstore, key, defaults)
local sv = rawget(db, "sv")
 
local tableCreated
if not sv[svstore] then sv[svstore] = {} end
if not sv[svstore][key] then
sv[svstore][key] = {}
tableCreated = true
end
 
local tbl = sv[svstore][key]
 
if defaults then
copyDefaults(tbl, defaults)
end
rawset(db, section, tbl)
 
return tableCreated, tbl
end
 
-- Metatable to handle the dynamic creation of sections and copying of sections.
local dbmt = {
__index = function(t, section)
local keys = rawget(t, "keys")
local key = keys[section]
if key then
local defaultTbl = rawget(t, "defaults")
local defaults = defaultTbl and defaultTbl[section]
 
if section == "profile" then
local new = initSection(t, section, "profiles", key, defaults)
if new then
-- Callback: OnNewProfile, database, newProfileKey
t.callbacks:Fire("OnNewProfile", t, key)
end
elseif section == "profiles" then
local sv = rawget(t, "sv")
if not sv.profiles then sv.profiles = {} end
rawset(t, "profiles", sv.profiles)
elseif section == "global" then
local sv = rawget(t, "sv")
if not sv.global then sv.global = {} end
if defaults then
copyDefaults(sv.global, defaults)
end
rawset(t, section, sv.global)
else
initSection(t, section, section, key, defaults)
end
end
 
return rawget(t, section)
end
}
 
local function validateDefaults(defaults, keyTbl, offset)
if not defaults then return end
offset = offset or 0
for k in pairs(defaults) do
if not keyTbl[k] or k == "profiles" then
error(("Usage: AceDBObject:RegisterDefaults(defaults): '%s' is not a valid datatype."):format(k), 3 + offset)
end
end
end
 
local preserve_keys = {
["callbacks"] = true,
["RegisterCallback"] = true,
["UnregisterCallback"] = true,
["UnregisterAllCallbacks"] = true,
["children"] = true,
}
 
local realmKey = GetRealmName()
local charKey = UnitName("player") .. " - " .. realmKey
local _, classKey = UnitClass("player")
local _, raceKey = UnitRace("player")
local factionKey = UnitFactionGroup("player")
local factionrealmKey = factionKey .. " - " .. realmKey
-- Actual database initialization function
local function initdb(sv, defaults, defaultProfile, olddb, parent)
-- Generate the database keys for each section
 
-- Make a container for profile keys
if not sv.profileKeys then sv.profileKeys = {} end
 
-- Try to get the profile selected from the char db
local profileKey = sv.profileKeys[charKey] or defaultProfile or charKey
sv.profileKeys[charKey] = profileKey
 
-- This table contains keys that enable the dynamic creation
-- of each section of the table. The 'global' and 'profiles'
-- have a key of true, since they are handled in a special case
local keyTbl= {
["char"] = charKey,
["realm"] = realmKey,
["class"] = classKey,
["race"] = raceKey,
["faction"] = factionKey,
["factionrealm"] = factionrealmKey,
["profile"] = profileKey,
["global"] = true,
["profiles"] = true,
}
 
validateDefaults(defaults, keyTbl, 1)
 
-- This allows us to use this function to reset an entire database
-- Clear out the old database
if olddb then
for k,v in pairs(olddb) do if not preserve_keys[k] then olddb[k] = nil end end
end
 
-- Give this database the metatable so it initializes dynamically
local db = setmetatable(olddb or {}, dbmt)
 
if not rawget(db, "callbacks") then
-- try to load CallbackHandler-1.0 if it loaded after our library
if not CallbackHandler then CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0", true) end
db.callbacks = CallbackHandler and CallbackHandler:New(db) or CallbackDummy
end
 
-- Copy methods locally into the database object, to avoid hitting
-- the metatable when calling methods
 
if not parent then
for name, func in pairs(DBObjectLib) do
db[name] = func
end
else
-- hack this one in
db.RegisterDefaults = DBObjectLib.RegisterDefaults
db.ResetProfile = DBObjectLib.ResetProfile
end
 
-- Set some properties in the database object
db.profiles = sv.profiles
db.keys = keyTbl
db.sv = sv
--db.sv_name = name
db.defaults = defaults
db.parent = parent
 
-- store the DB in the registry
AceDB.db_registry[db] = true
 
return db
end
 
-- handle PLAYER_LOGOUT
-- strip all defaults from all databases
local function logoutHandler(frame, event)
if event == "PLAYER_LOGOUT" then
for db in pairs(AceDB.db_registry) do
db.callbacks:Fire("OnDatabaseShutdown", db)
for section, key in pairs(db.keys) do
if db.defaults and db.defaults[section] and rawget(db, section) then
removeDefaults(db[section], db.defaults[section])
end
end
end
end
end
 
AceDB.frame:RegisterEvent("PLAYER_LOGOUT")
AceDB.frame:SetScript("OnEvent", logoutHandler)
 
 
--[[-------------------------------------------------------------------------
AceDB Object Method Definitions
---------------------------------------------------------------------------]]
 
--- Sets the defaults table for the given database object by clearing any
-- that are currently set, and then setting the new defaults.
-- @param defaults A table of defaults for this database
function DBObjectLib:RegisterDefaults(defaults)
if defaults and type(defaults) ~= "table" then
error("Usage: AceDBObject:RegisterDefaults(defaults): 'defaults' - table or nil expected.", 2)
end
 
validateDefaults(defaults, self.keys)
 
-- Remove any currently set defaults
if self.defaults then
for section,key in pairs(self.keys) do
if self.defaults[section] and rawget(self, section) then
removeDefaults(self[section], self.defaults[section])
end
end
end
 
-- Set the DBObject.defaults table
self.defaults = defaults
 
-- Copy in any defaults, only touching those sections already created
if defaults then
for section,key in pairs(self.keys) do
if defaults[section] and rawget(self, section) then
copyDefaults(self[section], defaults[section])
end
end
end
end
 
--- Changes the profile of the database and all of it's namespaces to the
-- supplied named profile
-- @param name The name of the profile to set as the current profile
function DBObjectLib:SetProfile(name)
if type(name) ~= "string" then
error("Usage: AceDBObject:SetProfile(name): 'name' - string expected.", 2)
end
 
-- changing to the same profile, dont do anything
if name == self.keys.profile then return end
 
local oldProfile = self.profile
local defaults = self.defaults and self.defaults.profile
 
-- Callback: OnProfileShutdown, database
self.callbacks:Fire("OnProfileShutdown", self)
 
if oldProfile and defaults then
-- Remove the defaults from the old profile
removeDefaults(oldProfile, defaults)
end
 
self.profile = nil
self.keys["profile"] = name
self.sv.profileKeys[charKey] = name
 
-- populate to child namespaces
if self.children then
for _, db in pairs(self.children) do
DBObjectLib.SetProfile(db, name)
end
end
 
-- Callback: OnProfileChanged, database, newProfileKey
self.callbacks:Fire("OnProfileChanged", self, name)
end
 
--- Returns a table with the names of the existing profiles in the database.
-- You can optionally supply a table to re-use for this purpose.
-- @param tbl A table to store the profile names in (optional)
function DBObjectLib:GetProfiles(tbl)
if tbl and type(tbl) ~= "table" then
error("Usage: AceDBObject:GetProfiles(tbl): 'tbl' - table or nil expected.", 2)
end
 
-- Clear the container table
if tbl then
for k,v in pairs(tbl) do tbl[k] = nil end
else
tbl = {}
end
 
local curProfile = self.keys.profile
 
local i = 0
for profileKey in pairs(self.profiles) do
i = i + 1
tbl[i] = profileKey
if curProfile and profileKey == curProfile then curProfile = nil end
end
 
-- Add the current profile, if it hasn't been created yet
if curProfile then
i = i + 1
tbl[i] = curProfile
end
 
return tbl, i
end
 
--- Returns the current profile name used by the database
function DBObjectLib:GetCurrentProfile()
return self.keys.profile
end
 
--- Deletes a named profile. This profile must not be the active profile.
-- @param name The name of the profile to be deleted
-- @param silent If true, do not raise an error when the profile does not exist
function DBObjectLib:DeleteProfile(name, silent)
if type(name) ~= "string" then
error("Usage: AceDBObject:DeleteProfile(name): 'name' - string expected.", 2)
end
 
if self.keys.profile == name then
error("Cannot delete the active profile in an AceDBObject.", 2)
end
 
if not rawget(self.sv.profiles, name) and not silent then
error("Cannot delete profile '" .. name .. "'. It does not exist.", 2)
end
 
self.sv.profiles[name] = nil
 
-- populate to child namespaces
if self.children then
for _, db in pairs(self.children) do
DBObjectLib.DeleteProfile(db, name, true)
end
end
 
-- Callback: OnProfileDeleted, database, profileKey
self.callbacks:Fire("OnProfileDeleted", self, name)
end
 
--- Copies a named profile into the current profile, overwriting any conflicting
-- settings.
-- @param name The name of the profile to be copied into the current profile
-- @param silent If true, do not raise an error when the profile does not exist
function DBObjectLib:CopyProfile(name, silent)
if type(name) ~= "string" then
error("Usage: AceDBObject:CopyProfile(name): 'name' - string expected.", 2)
end
 
if name == self.keys.profile then
error("Cannot have the same source and destination profiles.", 2)
end
 
if not rawget(self.sv.profiles, name) and not silent then
error("Cannot copy profile '" .. name .. "'. It does not exist.", 2)
end
 
-- Reset the profile before copying
DBObjectLib.ResetProfile(self)
 
local profile = self.profile
local source = self.sv.profiles[name]
 
copyTable(source, profile)
 
-- populate to child namespaces
if self.children then
for _, db in pairs(self.children) do
DBObjectLib.CopyProfile(db, name, true)
end
end
 
-- Callback: OnProfileCopied, database, sourceProfileKey
self.callbacks:Fire("OnProfileCopied", self, name)
end
 
--- Resets the current profile to the default values (if specified).
-- @param noChildren if set to true, the reset will not be populated to the child namespaces of this DB object
function DBObjectLib:ResetProfile(noChildren)
local profile = self.profile
 
for k,v in pairs(profile) do
profile[k] = nil
end
 
local defaults = self.defaults and self.defaults.profile
if defaults then
copyDefaults(profile, defaults)
end
 
-- populate to child namespaces
if self.children and not noChildren then
for _, db in pairs(self.children) do
DBObjectLib.ResetProfile(db)
end
end
 
-- Callback: OnProfileReset, database
self.callbacks:Fire("OnProfileReset", self)
end
 
--- Resets the entire database, using the string defaultProfile as the new default
-- profile.
-- @param defaultProfile The profile name to use as the default
function DBObjectLib:ResetDB(defaultProfile)
if defaultProfile and type(defaultProfile) ~= "string" then
error("Usage: AceDBObject:ResetDB(defaultProfile): 'defaultProfile' - string or nil expected.", 2)
end
 
local sv = self.sv
for k,v in pairs(sv) do
sv[k] = nil
end
 
local parent = self.parent
 
initdb(sv, self.defaults, defaultProfile, self)
 
-- fix the child namespaces
if self.children then
if not sv.namespaces then sv.namespaces = {} end
for name, db in pairs(self.children) do
if not sv.namespaces[name] then sv.namespaces[name] = {} end
initdb(sv.namespaces[name], db.defaults, self.keys.profile, db, self)
end
end
 
-- Callback: OnDatabaseReset, database
self.callbacks:Fire("OnDatabaseReset", self)
-- Callback: OnProfileChanged, database, profileKey
self.callbacks:Fire("OnProfileChanged", self, self.keys["profile"])
 
return self
end
 
--- Creates a new database namespace, directly tied to the database. This
-- is a full scale database in it's own rights other than the fact that
-- it cannot control its profile individually
-- @param name The name of the new namespace
-- @param defaults A table of values to use as defaults
function DBObjectLib:RegisterNamespace(name, defaults)
if type(name) ~= "string" then
error("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - string expected.", 2)
end
if defaults and type(defaults) ~= "table" then
error("Usage: AceDBObject:RegisterNamespace(name, defaults): 'defaults' - table or nil expected.", 2)
end
if self.children and self.children[name] then
error ("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - a namespace with that name already exists.", 2)
end
 
local sv = self.sv
if not sv.namespaces then sv.namespaces = {} end
if not sv.namespaces[name] then
sv.namespaces[name] = {}
end
 
local newDB = initdb(sv.namespaces[name], defaults, self.keys.profile, nil, self)
 
if not self.children then self.children = {} end
self.children[name] = newDB
return newDB
end
 
--[[-------------------------------------------------------------------------
AceDB Exposed Methods
---------------------------------------------------------------------------]]
 
--- Creates a new database object that can be used to handle database settings
-- and profiles.
-- @param name The name of variable, or table to use for the database
-- @param defaults A table of database defaults
-- @param defaultProfile The name of the default profile
function AceDB:New(tbl, defaults, defaultProfile)
if type(tbl) == "string" then
local name = tbl
tbl = getglobal(name)
if not tbl then
tbl = {}
setglobal(name, tbl)
end
end
 
if type(tbl) ~= "table" then
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'tbl' - table expected.", 2)
end
 
if defaults and type(defaults) ~= "table" then
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaults' - table expected.", 2)
end
 
if defaultProfile and type(defaultProfile) ~= "string" then
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaultProfile' - string expected.", 2)
end
 
return initdb(tbl, defaults, defaultProfile)
end
 
-- upgrade existing databases
for db in pairs(AceDB.db_registry) do
if not db.parent then
for name,func in pairs(DBObjectLib) do
db[name] = func
end
else
db.RegisterDefaults = DBObjectLib.RegisterDefaults
end
end
1.2/AtlasLootReverse.lua New file
0,0 → 1,104
--[[
AtlasLootReverse
Written by pceric
http://www.wowinterface.com/downloads/info9179-Know-It-All.html
]]
AtlasLootReverse = LibStub("AceAddon-3.0"):NewAddon("AtlasLootReverse")
local TT = LibStub("LibExtraTip-1")
local L = LibStub("AceLocale-3.0"):GetLocale("AtlasLootReverse", true)
 
AtlasLootReverse.title = L["AtlasLootReverse"]
AtlasLootReverse.version = GetAddOnMetadata("AtlasLootReverse", "Version")
 
local db
local tmp = ""
 
local defaults = {
profile = {
dbversion = "",
alversion = "",
whoTable = {}
}
}
 
-- searches a table for string s
local function tfind(t, s)
local last
for k, v in pairs(t) do
if type(v) == "table" then
tfind(v, s)
else
if v == s then tmp = last end
last = v
end
end
end
 
----------------------
--On start
function AtlasLootReverse:OnInitialize()
local alrdb = LibStub("AceDB-3.0"):New("AtlasLootReverseDB", defaults, "Default")
db = alrdb.profile --local the profile table
TT:RegisterTooltip(GameTooltip)
TT:RegisterTooltip(ItemRefTooltip)
end
 
----------------------
--Disabled
function AtlasLootReverse:OnDisable()
TT:RemoveCallback(AtlasLootReverse.Who)
end
 
----------------------
--Loaded
function AtlasLootReverse:OnEnable()
if db.dbversion ~= AtlasLootReverse.version or db.alversion ~= ATLASLOOT_VERSION then
local zone
wipe(db.whoTable) -- Wipe the table
AtlasLoot_LoadAllModules() -- Force AtlasLoot to load all modules
for k1,v1 in pairs(AtlasLoot_TableNames) do
if type(AtlasLoot_Data[k1]) == "table" then
for k2,v2 in pairs(AtlasLoot_Data[k1]) do
if type(v2) == "table" and type(v2[2]) == "number" and not db.whoTable[v2[2]] and v2[2] > 0 then
if strsub(k1, -5) == "25Man" then
zone = strtrim(string.format(L["25 Man %s"], AtlasLootReverse:FindZone(strsub(k1, 1, strlen(k1)-5))))
else
zone = AtlasLootReverse:FindZone(k1)
end
if zone ~= "" then zone = " (" .. zone .. ")" end
db.whoTable[v2[2]] = v1[1] .. zone
end
end
end
end
db.dbversion = AtlasLootReverse.version
db.alversion = ATLASLOOT_VERSION
print(AtlasLootReverse.title .. " database rebuilt.")
end
TT:AddCallback(AtlasLootReverse.Who)
end
 
----------------------
--Gets a Zone given an AtlasLoot Boss ID
function AtlasLootReverse:FindZone(ALBID)
local val
for k,v in pairs(AtlasLoot_DewDropDown_SubTables) do
for i,j in pairs(v) do
if j[2] == ALBID then
tfind(AtlasLoot_DewDropDown, k)
val = tmp
tmp = ""
return val
end
end
end
return ""
end
 
-- LibExtraTip Call Backs
function AtlasLootReverse:Who(item)
local _, itemId = strsplit(":", item)
if db.whoTable[tonumber(itemId)] then
TT:AddLine(self, string.format(L["Drops from %s"], db.whoTable[tonumber(itemId)]), nil, nil, nil, true)
end
end
\ No newline at end of file
1.2/embeds.xml New file
0,0 → 1,10
<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\AceAddon-3.0\AceAddon-3.0.xml" />
<Include file="libs\AceDB-3.0\AceDB-3.0.xml" />
<Include file="libs\AceLocale-3.0\AceLocale-3.0.xml" />
<Include file="libs\LibExtraTip\Load.xml" />
</Ui>
\ No newline at end of file
1.2/AtlasLootReverse.toc New file
0,0 → 1,17
## Interface: 30000
## Title: AtlasLootReverse
## Notes: Does a reverse lookup of AtlasLoot for an item's drop info.
## Version: 1.2
## Author: pceric
## SavedVariables: AtlasLootReverseDB
## X-Website: http://www.wowinterface.com/downloads/info12834-AtlasLootReverse.html
## X-Category: Interface Enhancements
## X-Embeds: Ace3, LibExtraTip
## Dependencies: AtlasLoot
## OptionalDeps: Ace3, LibExtraTip
 
embeds.xml
 
locales\locale-enUS.lua
 
AtlasLootReverse.lua
1.2/locales/locale-enUS.lua New file
0,0 → 1,6
local L = LibStub("AceLocale-3.0"):NewLocale("AtlasLootReverse", "enUS", true)
 
L["AtlasLootReverse"] = true
 
L["Drops from %s"] = true -- %s is boss (instance)
L["25 Man %s"] = true -- %s is instance
1.2 Property changes : Added: wowi:dirname + AtlasLootReverse