WoWInterface SVN AtlasLootReverse

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 56 to Rev 57
    Reverse comparison

Rev 56 → Rev 57

tags/1.15/AtlasLootReverse.toc New file
0,0 → 1,17
## Interface: 40100
## Title: AtlasLootReverse
## Notes: Does a reverse lookup of AtlasLoot for an item's drop info.
## Version: 1.15
## 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
tags/1.15/locales/locale-enUS.lua New file
0,0 → 1,17
local L = LibStub("AceLocale-3.0"):NewLocale("AtlasLootReverse", "enUS", true)
if not L then return end
 
L["AtlasLootReverse"] = true
 
-- Chat commands
L["atlaslootreverse"] = true
L["alr"] = true
L["Tooltip embedded: "] = true
L["Commands:\n/alr embed - Toggles the tooltip being embedded or split into another box"] = true
 
L["Drops from %s"] = true -- %s is boss (instance)
L["Heroic %s"] = true -- %s is instance
L["25 Man %s"] = true -- %s is instance
L["25 Man Heroic %s"] = true -- %s is instance
L["PvP %s Set"] = true -- %s is level
L["Tier %s"] = true -- %s is number
\ No newline at end of file
tags/1.15/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
tags/1.15/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
tags/1.15/libs/AceLocale-3.0/AceLocale-3.0.lua New file
0,0 → 1,137
--- **AceLocale-3.0** 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 1005 2011-01-29 14:19:43Z mikk $
local MAJOR,MINOR = "AceLocale-3.0", 5
 
local AceLocale, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 
if not AceLocale then return end -- no upgrade needed
 
-- Lua APIs
local assert, tostring, error = assert, tostring, error
local setmetatable, rawset, rawget = setmetatable, rawset, rawget
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: GAME_LOCALE, geterrorhandler
 
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
})
 
--- Register a new locale (or extend an existing one) for the specified application.
-- :NewLocale will return a table you can fill your locale into, or nil if the locale isn't needed for the players
-- game locale.
-- @paramsig application, locale[, isDefault[, silent]]
-- @param application Unique name of addon / module
-- @param locale Name of the locale to register, e.g. "enUS", "deDE", etc.
-- @param isDefault If this is the default locale being registered (your addon is written in this language, generally enUS)
-- @param silent If true, the locale will not issue warnings for missing keys. Must be set on the first locale registered. If set to "raw", nils will be returned for unknown keys (no metatable used).
-- @usage
-- -- enUS.lua
-- local L = LibStub("AceLocale-3.0"):NewLocale("TestLocale", "enUS", true)
-- L["string1"] = true
--
-- -- deDE.lua
-- local L = LibStub("AceLocale-3.0"):NewLocale("TestLocale", "deDE")
-- if not L then return end
-- L["string1"] = "Zeichenkette1"
-- @return Locale Table to add localizations to, or nil if the current locale is not required.
function AceLocale:NewLocale(application, locale, isDefault, silent)
 
-- GAME_LOCALE allows translators to test translations of addons without having that wow client installed
local gameLocale = GAME_LOCALE or gameLocale
 
local app = AceLocale.apps[application]
 
if silent and app then
geterrorhandler()("Usage: NewLocale(application, locale[, isDefault[, silent]]): 'silent' must be specified for the first locale registered")
end
 
if not app then
if silent=="raw" then
app = {}
else
app = setmetatable({}, silent and readmetasilent or readmeta)
end
AceLocale.apps[application] = app
AceLocale.appnames[app] = application
end
 
if locale ~= gameLocale and not isDefault then
return -- nop, we don't need these translations
end
 
registering = app -- remember globally for writeproxy and writedefaultproxy
 
if isDefault then
return writedefaultproxy
end
 
return writeproxy
end
 
--- 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)
-- @param application Unique name of addon / module
-- @param silent If true, the locale is optional, silently return nil if it's not found (defaults to false, optional)
-- @return The locale table for the current language.
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
tags/1.15/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
tags/1.15/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua New file
0,0 → 1,240
--[[ $Id: CallbackHandler-1.0.lua 965 2010-08-09 00:47:52Z mikk $ ]]
local MAJOR, MINOR = "CallbackHandler-1.0", 6
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
 
if not CallbackHandler then return end -- No upgrade needed
 
local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
 
-- Lua APIs
local tconcat = table.concat
local assert, error, loadstring = assert, error, loadstring
local setmetatable, rawset, rawget = setmetatable, rawset, rawget
local next, select, pairs, type, tostring = next, select, pairs, type, tostring
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: geterrorhandler
 
local xpcall = xpcall
 
local function errorhandler(err)
return geterrorhandler()(err)
end
 
local function CreateDispatcher(argCount)
local code = [[
local next, xpcall, eh = ...
 
local method, ARGS
local function call() method(ARGS) end
 
local function dispatch(handlers, ...)
local index
index, method = next(handlers)
if not method then return end
local OLD_ARGS = ARGS
ARGS = ...
repeat
xpcall(call, eh)
index, method = next(handlers, index)
until not method
ARGS = OLD_ARGS
end
 
return dispatch
]]
 
local ARGS, OLD_ARGS = {}, {}
for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
code = code:gsub("OLD_ARGS", tconcat(OLD_ARGS, ", ")):gsub("ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
end
 
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
local dispatcher = CreateDispatcher(argCount)
rawset(self, argCount, dispatcher)
return dispatcher
end})
 
--------------------------------------------------------------------------
-- CallbackHandler:New
--
-- target - target object to embed public APIs in
-- RegisterName - name of the callback registration API, default "RegisterCallback"
-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback"
-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
 
function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName, 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" or self=thread
if type(self)~="table" and type(self)~="string" and type(self)~="thread" then
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2)
end
 
if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
local arg=select(1,...)
regfunc = function(...) method(arg,...) end
else
regfunc = method
end
end
 
 
if events[eventname][self] or registry.recurse<1 then
-- if registry.recurse<1 then
-- we're overwriting an existing entry, or not currently recursing. just set it.
events[eventname][self] = regfunc
-- fire OnUsed callback?
if registry.OnUsed and first then
registry.OnUsed(registry, target, eventname)
end
else
-- we're currently processing a callback in this registry, so delay the registration of this new entry!
-- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency
registry.insertQueue = registry.insertQueue or setmetatable({},meta)
registry.insertQueue[eventname][self] = regfunc
end
end
 
-- Unregister a callback
target[UnregisterName] = function(self, eventname)
if not self or self==target then
error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2)
end
if type(eventname) ~= "string" then
error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2)
end
if rawget(events, eventname) and events[eventname][self] then
events[eventname][self] = nil
-- Fire OnUnused callback?
if registry.OnUnused and not next(events[eventname]) then
registry.OnUnused(registry, target, eventname)
end
end
if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
registry.insertQueue[eventname][self] = nil
end
end
 
-- OPTIONAL: Unregister all callbacks for given selfs/addonIds
if UnregisterAllName then
target[UnregisterAllName] = function(...)
if select("#",...)<1 then
error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2)
end
if select("#",...)==1 and ...==target then
error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2)
end
 
 
for i=1,select("#",...) do
local self = select(i,...)
if registry.insertQueue then
for eventname, callbacks in pairs(registry.insertQueue) do
if callbacks[self] then
callbacks[self] = nil
end
end
end
for eventname, callbacks in pairs(events) do
if callbacks[self] then
callbacks[self] = nil
-- Fire OnUnused callback?
if registry.OnUnused and not next(callbacks) then
registry.OnUnused(registry, target, eventname)
end
end
end
end
end
end
 
return registry
end
 
 
-- CallbackHandler purposefully does NOT do explicit embedding. Nor does it
-- try to upgrade old implicit embeds since the system is selfcontained and
-- relies on closures to work.
 
tags/1.15/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
tags/1.15/libs/LibExtraTip/LibExtraTip.lua New file
0,0 → 1,1293
--[[-
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.1
--]]
 
local MAJOR,MINOR,REVISION = "LibExtraTip", 1, "$Revision: 302 $"
 
-- 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 tooltipMethodPrehooks
local tooltipMethodPosthooks
local ExtraTipClass
 
--[[ The following events are enabled by default unless disabled in the
callback options "enabled" table all other events are default disabled.
Note that this only applies to events that will lead to calling ProcessCallbacks,
currently any method that fires OnTooltipSetItem, OnTooltipSetSpell or
OnTooltipSetUnit
--]]
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()")
 
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()")
 
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()")
 
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()")
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:SetHeight(0)
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
 
--[[ hookStore:
@since version 1.1
(see below for hookStore version)
stores control information for method and script hooks on tooltips
lib.hookStore[tooltip][method] = <control>
<control> = {prehook, posthook}
<control> is an upvalue to our installed hookstub: insert new values to change the hook, or wipe it to deactivate
 
if we are updating, keep the old hookStore table IF it has the right version, so that we can reuse the hook stubs
--]]
local HOOKSTORE_VERSION = "A"
if not lib.hookStore or lib.hookStore.version ~= HOOKSTORE_VERSION then
lib.hookStore = {version = HOOKSTORE_VERSION}
end
 
-- Called to install/modify a pre-/post-hook on the given tooltip's method
local function hook(tip, method, prehook, posthook)
if not lib.hookStore[tip] then lib.hookStore[tip] = {} end
local control
-- check for existing hook
control = lib.hookStore[tip][method]
if control then
control[1] = prehook or control[1] or false --(avoid nil values by substituting false instead)
control[2] = posthook or control[2] or false
return
end
-- prepare upvalues
local orig = tip[method]
if not orig then
-- There should be an original method - abort if it's missing
if nLog then
nLog.AddMessage("LibExtraTip", "Hooks", N_NOTICE, "Missing method", "LibExtraTip:hook detected missing method: "..tostring(method))
end
return
end
control = {prehook or false, posthook or false}
lib.hookStore[tip][method] = control
-- install hook stub
local stub = function(...)
local h
-- prehook
h = control[1]
if h then h(...) end
-- original hook
local a,b,c,d = orig(...)
-- posthook
h = control[2]
if h then h(...) end
-- return values from original
return a,b,c,d
end
tip[method] = stub
--[[
Note: neither the stub hook nor the original function should be called directly after our hook is installed,
because the behaviour of any other third-party hooks to the same method would then be undefined
(i.e. they might get called or they might not...)
--]]
end
 
-- Called to deactivate our stub hook for the given tooltip's method
-- The stub is left in place: we assume we are undergoing a version upgrade, and that the stubs will be reused
--[[ not used in this version (left in place in case needed for future changes)
local function unhook(tip,method)
wipe(lib.hookStore[tip][method])
end
--]]
 
-- Called to install/modify a pre-hook on the given tooltip's event
-- Currently we do not need any posthooks on scripts
local function hookscript(tip, script, prehook)
if not lib.hookStore[tip] then lib.hookStore[tip] = {} end
local control
-- check for existing hook
control = lib.hookStore[tip][script]
if control then
control[1] = prehook or control[1]
return
end
-- prepare upvalues
local orig = tip:GetScript(script)
control = {prehook}
lib.hookStore[tip][script] = control
-- install hook stub
local stub = function(...)
local h
-- prehook
h = control[1]
if h then h(...) end
-- original hook
if orig then orig(...) end
end
tip:SetScript(script, stub)
end
 
-- Called to deactivate all our pre-hooks on the given tooltip's event
--local function unhookscript(tip,script)
-- not used in this version
 
--[[-
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(tooltipMethodPrehooks) do
hook(tooltip,k,v)
end
for k,v in pairs(tooltipMethodPosthooks) do
hook(tooltip,k,nil,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 sortFunc then
local callbacks = self.callbacks
if not callbacks then
callbacks = {}
self.callbacks = callbacks
self.sortedCallbacks = {}
end
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 (callback and self.callbacks) then return end
if not self.callbacks[callback] then
-- backward compatibility for old 'function' style AddCallback and RemoveCallback
for options, priority in pairs(self.callbacks) do
if options.callback == callback then
callback = options
break
end
end
if not self.callbacks[callback] then return end
end
self.callbacks[callback] = nil
for index,options in ipairs(self.sortedCallbacks) do
if options == callback then
table.remove(self.sortedCallbacks, index)
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
reg.ignoreSetHyperlink = true
tooltip:SetHyperlink(link)
reg.ignoreSetHyperlink = nil
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()
-- deactivate all hook stubs
for tooltip, tiptable in pairs(lib.hookStore) do
if tooltip ~= "version" then -- skip over the version indicator
for method, control in pairs(tiptable) do
wipe(control) -- disable the hook stub by removing all hooks from the control table
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 pairs(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
Addendum: generates 2 method tables, for prehooks and posthooks. Where the prehook sets a flag, a posthook must be installed to clear it. Specifically: reg.ignoreOnCleared
]]
function lib:GenerateTooltipMethodTable() -- Sets up hooks to give the quantity of the item
local tooltipRegistry = self.tooltipRegistry
 
tooltipMethodPrehooks = {
 
-- Default enabled events
 
SetAuctionItem = function(self,type,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
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)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
local name,texture,quantity,quality,canUse,price = GetAuctionSellItemInfo()
reg.quantity = quantity
reg.additional.event = "SetAuctionSellItem"
reg.additional.canUse = canUse
end,
 
SetBagItem = function(self,bag,slot)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
local tex,q,l,_,r,loot = GetContainerItemInfo(bag,slot)
if tex then -- texture (only used as a test for occupied bagslot)
reg.quantity = q
reg.additional.event = "SetBagItem"
reg.additional.eventContainer = bag
reg.additional.eventIndex = slot
reg.additional.readable = r
reg.additional.locked = l
reg.additional.lootable = loot
end
end,
 
SetBuybackItem = function(self,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
local name,texture,price,quantity = GetBuybackItemInfo(index)
reg.quantity = quantity
reg.additional.event = "SetBuybackItem"
reg.additional.eventIndex = index
end,
 
SetGuildBankItem = function(self,tab,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
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,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
local _,_,q,_,cu = GetInboxItem(index)
reg.quantity = q
reg.additional.event = "SetInboxItem"
reg.additional.eventIndex = index
reg.additional.canUse = cu
end,
 
SetInventoryItem = function(self,unit,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
local q = GetInventoryItemCount(unit,index)
reg.quantity = q
reg.additional.event = "SetInventoryItem"
reg.additional.eventIndex = index
reg.additional.eventUnit = unit
end,
 
SetLootItem = function(self,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
local _,_,q = GetLootSlotInfo(index)
reg.quantity = q
reg.additional.event = "SetLootItem"
reg.additional.eventIndex = index
end,
 
SetLootRollItem = function(self,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
local texture, name, count, quality = GetLootRollItemInfo(index)
reg.quantity = count
reg.additional.event = "SetLootRollItem"
reg.additional.eventIndex = index
end,
 
SetMerchantItem = function(self,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
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,type,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
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,type,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
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,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
local name,texture,quantity = GetSendMailItem(index)
reg.quantity = quantity
reg.additional.event = "SetSendMailItem"
reg.additional.eventIndex = index
end,
 
SetTradePlayerItem = function(self,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
local name, texture, quantity = GetTradePlayerItemInfo(index)
reg.quantity = quantity
reg.additional.event = "SetTradePlayerItem"
reg.additional.eventIndex = index
end,
 
SetTradeTargetItem = function(self,index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
local name, texture, quantity = GetTradeTargetItemInfo(index)
reg.quantity = quantity
reg.additional.event = "SetTradeTargetItem"
reg.additional.eventIndex = index
end,
 
SetTradeSkillItem = function(self,index,reagentIndex)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
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.quantity = GetTradeSkillNumMade(index)
if link and link:match("spell:%d") then
SetSpellDetail(reg, link)
end
end
end,
 
SetHyperlink = function(self,link)
local reg = tooltipRegistry[self]
if reg.ignoreSetHyperlink then return end
OnTooltipCleared(self)
reg.ignoreOnCleared = true
reg.additional.event = "SetHyperlink"
reg.additional.eventLink = link
reg.additional.link = link
end,
 
-- Default disabled events:
 
--[[ disabled due to taint issues
SetAction = function(self,actionid)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
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,
--]]
 
SetCurrencyToken = function(self, index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
reg.additional.event = "SetCurrencyToken"
reg.additional.eventIndex = index
end,
 
SetPetAction = function(self, index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
reg.additional.event = "SetPetAction"
reg.additional.eventIndex = index
end,
 
SetQuestLogRewardSpell = function(self)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
reg.additional.event = "SetQuestLogRewardSpell"
end,
 
SetQuestRewardSpell = function(self)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
reg.additional.event = "SetQuestRewardSpell"
end,
 
SetShapeshift = function(self, index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
reg.additional.event = "SetShapeshift"
reg.additional.eventIndex = index
end,
 
SetSpellBookItem = function(self,index,booktype)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
local link = GetSpellLink(index, booktype)
if link then
reg.additional.event = "SetSpellBookItem"
reg.additional.eventIndex = index
reg.additional.eventType = booktype
SetSpellDetail(reg, link)
end
end,
 
SetTalent = function(self, type, index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
reg.additional.event = "SetTalent"
reg.additional.eventIndex = index
end,
 
SetTrainerService = function(self, index)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
reg.additional.event = "SetTrainerService"
reg.additional.eventIndex = index
end,
 
SetUnit = function(self, unit)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
reg.additional.event = "SetUnit"
reg.additional.eventUnit= unit
end,
 
--[[ disabled due to taint issues
SetUnitAura = function(self, unit, index, filter)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
reg.additional.event = "SetUnitAura"
reg.additional.eventUnit = unit
reg.additional.eventIndex = index
reg.additional.eventFilter = filter
end,
--]]
 
SetUnitBuff = function(self, unit, index, filter)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
reg.additional.event = "SetUnitBuff"
reg.additional.eventUnit = unit
reg.additional.eventIndex = index
reg.additional.eventFilter = filter
end,
 
SetUnitDebuff = function(self, unit, index, filter)
OnTooltipCleared(self)
local reg = tooltipRegistry[self]
reg.ignoreOnCleared = true
reg.additional.event = "SetUnitDebuff"
reg.additional.eventUnit = unit
reg.additional.eventIndex = index
reg.additional.eventFilter = filter
end,
}
 
local function posthookClearIgnore(self)
tooltipRegistry[self].ignoreOnCleared = nil
end
tooltipMethodPosthooks = {
SetAuctionItem = posthookClearIgnore,
SetAuctionSellItem = posthookClearIgnore,
SetBagItem = posthookClearIgnore,
SetBuybackItem = posthookClearIgnore,
SetGuildBankItem = posthookClearIgnore,
SetInboxItem = posthookClearIgnore,
SetInventoryItem = posthookClearIgnore,
SetLootItem = posthookClearIgnore,
SetLootRollItem = posthookClearIgnore,
SetMerchantItem = posthookClearIgnore,
SetQuestItem = posthookClearIgnore,
SetQuestLogItem = posthookClearIgnore,
SetSendMailItem = posthookClearIgnore,
SetTradePlayerItem = posthookClearIgnore,
SetTradeTargetItem = posthookClearIgnore,
SetTradeSkillItem = posthookClearIgnore,
 
SetHyperlink = function(self)
local reg = tooltipRegistry[self]
if not reg.ignoreSetHyperlink then
reg.ignoreOnCleared = nil
end
end,
 
--SetAction = posthookClearIgnore,
SetCurrencyToken = posthookClearIgnore,
SetPetAction = posthookClearIgnore,
SetQuestLogRewardSpell = posthookClearIgnore,
SetQuestRewardSpell = posthookClearIgnore,
SetShapeshift = posthookClearIgnore,
SetSpellBookItem = posthookClearIgnore,
SetTalent = posthookClearIgnore,
SetTrainerService = posthookClearIgnore,
SetUnit = posthookClearIgnore,
--SetUnitAura = posthookClearIgnore,
SetUnitBuff = posthookClearIgnore,
SetUnitDebuff = posthookClearIgnore,
}
 
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 = _G[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 nlines = self:NumLines()
local changedLines = self.changedLines or 0
if changedLines < nlines then
for i = changedLines + 1, nlines 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 = nlines
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, shift)
local rights, rightname
rights = tooltip.Right
if not rights then
rightname = tooltip:GetName().."TextRight"
end
for line = 1, tooltip:NumLines() do
local right
if rights then
right = rights[line]
else
right = _G[rightname..line]
end
if right and right:IsVisible() then
for index = 1, right:GetNumPoints() do
local point, relativeTo, relativePoint, xofs, yofs = right:GetPoint(index)
if xofs then
right:SetPoint(point, relativeTo, relativePoint, xofs + shift, yofs)
end
end
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, d)
elseif d < -.005 then
self.sizing = true
p:SetWidth(w)
fixRight(p, -d)
end
end
 
function class:Show()
self:InitLines()
show(self)
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
--]]
tags/1.15/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()
tags/1.15/libs/LibExtraTip/LibExtraTip.toc New file
0,0 → 1,16
## Title: LibExtraTip |cff224477(lib)
## Notes: Assists in the management of additional tooltip information.
##
## Interface: 40000
## LoadOnDemand: 0
##
## Version: <%version%> (<%codename%>)
## Revision: $Id: LibExtraTip.toc 284 2010-11-01 04:11:43Z dinesh $
## Author: Norganna's AddOns
## X-Part-Of: Libraries
## X-Category: Library
## X-Max-Interface: 40000
## X-URL: http://zip.norganna.org/libs/LibExtraTip/
## X-Feedback: http://forums.norganna.org
##
Load.xml
tags/1.15/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
tags/1.15/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>
tags/1.15/libs/LibExtraTip/contrib/processDoc.sh New file
0,0 → 1,5
#!/bin/ksh
 
perl processDoc.pl ../LibExtraTip.lua
mv API.html ../API.html
 
tags/1.15/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;
}
 
tags/1.15/libs/LibExtraTip/contrib/processDoc.bat New file
0,0 → 1,5
@echo off
 
perl processDoc.pl ..\LibExtraTip.lua
move API.html ..\API.html
 
tags/1.15/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
tags/1.15/libs/AceConsole-3.0/AceConsole-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="AceConsole-3.0.lua"/>
</Ui>
\ No newline at end of file
tags/1.15/libs/AceConsole-3.0/AceConsole-3.0.lua New file
0,0 → 1,250
--- **AceConsole-3.0** provides registration facilities for slash commands.
-- You can register slash commands to your custom functions and use the `GetArgs` function to parse them
-- to your addons individual needs.
--
-- **AceConsole-3.0** can be embeded into your addon, either explicitly by calling AceConsole:Embed(MyAddon) or by
-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
-- and can be accessed directly, without having to explicitly call AceConsole itself.\\
-- It is recommended to embed AceConsole, otherwise you'll have to specify a custom `self` on all calls you
-- make into AceConsole.
-- @class file
-- @name AceConsole-3.0
-- @release $Id: AceConsole-3.0.lua 878 2009-11-02 18:51:58Z nevcairiel $
local MAJOR,MINOR = "AceConsole-3.0", 7
 
local AceConsole, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 
if not AceConsole then return end -- No upgrade needed
 
AceConsole.embeds = AceConsole.embeds or {} -- table containing objects AceConsole is embedded in.
AceConsole.commands = AceConsole.commands or {} -- table containing commands registered
AceConsole.weakcommands = AceConsole.weakcommands or {} -- table containing self, command => func references for weak commands that don't persist through enable/disable
 
-- Lua APIs
local tconcat, tostring, select = table.concat, tostring, select
local type, pairs, error = type, pairs, error
local format, strfind, strsub = string.format, string.find, string.sub
local max = math.max
 
-- WoW APIs
local _G = _G
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: DEFAULT_CHAT_FRAME, SlashCmdList, hash_SlashCmdList
 
local tmp={}
local function Print(self,frame,...)
local n=0
if self ~= AceConsole then
n=n+1
tmp[n] = "|cff33ff99"..tostring( self ).."|r:"
end
for i=1, select("#", ...) do
n=n+1
tmp[n] = tostring(select(i, ...))
end
frame:AddMessage( tconcat(tmp," ",1,n) )
end
 
--- Print to DEFAULT_CHAT_FRAME or given ChatFrame (anything with an .AddMessage function)
-- @paramsig [chatframe ,] ...
-- @param chatframe Custom ChatFrame to print to (or any frame with an .AddMessage function)
-- @param ... List of any values to be printed
function AceConsole:Print(...)
local frame = ...
if type(frame) == "table" and frame.AddMessage then -- Is first argument something with an .AddMessage member?
return Print(self, frame, select(2,...))
else
return Print(self, DEFAULT_CHAT_FRAME, ...)
end
end
 
 
--- Formatted (using format()) print to DEFAULT_CHAT_FRAME or given ChatFrame (anything with an .AddMessage function)
-- @paramsig [chatframe ,] "format"[, ...]
-- @param chatframe Custom ChatFrame to print to (or any frame with an .AddMessage function)
-- @param format Format string - same syntax as standard Lua format()
-- @param ... Arguments to the format string
function AceConsole:Printf(...)
local frame = ...
if type(frame) == "table" and frame.AddMessage then -- Is first argument something with an .AddMessage member?
return Print(self, frame, format(select(2,...)))
else
return Print(self, DEFAULT_CHAT_FRAME, format(...))
end
end
 
 
 
 
--- Register a simple chat command
-- @param command Chat command to be registered WITHOUT leading "/"
-- @param func Function to call when the slash command is being used (funcref or methodname)
-- @param persist if false, the command will be soft disabled/enabled when aceconsole is used as a mixin (default: true)
function AceConsole:RegisterChatCommand( command, func, persist )
if type(command)~="string" then error([[Usage: AceConsole:RegisterChatCommand( "command", func[, persist ]): 'command' - expected a string]], 2) end
 
if persist==nil then persist=true end -- I'd rather have my addon's "/addon enable" around if the author screws up. Having some extra slash regged when it shouldnt be isn't as destructive. True is a better default. /Mikk
 
local name = "ACECONSOLE_"..command:upper()
 
if type( func ) == "string" then
SlashCmdList[name] = function(input, editBox)
self[func](self, input, editBox)
end
else
SlashCmdList[name] = func
end
_G["SLASH_"..name.."1"] = "/"..command:lower()
AceConsole.commands[command] = name
-- non-persisting commands are registered for enabling disabling
if not persist then
if not AceConsole.weakcommands[self] then AceConsole.weakcommands[self] = {} end
AceConsole.weakcommands[self][command] = func
end
return true
end
 
--- Unregister a chatcommand
-- @param command Chat command to be unregistered WITHOUT leading "/"
function AceConsole:UnregisterChatCommand( command )
local name = AceConsole.commands[command]
if name then
SlashCmdList[name] = nil
_G["SLASH_" .. name .. "1"] = nil
hash_SlashCmdList["/" .. command:upper()] = nil
AceConsole.commands[command] = nil
end
end
 
--- Get an iterator over all Chat Commands registered with AceConsole
-- @return Iterator (pairs) over all commands
function AceConsole:IterateChatCommands() return pairs(AceConsole.commands) end
 
 
local function nils(n, ...)
if n>1 then
return nil, nils(n-1, ...)
elseif n==1 then
return nil, ...
else
return ...
end
end
 
 
--- Retreive one or more space-separated arguments from a string.
-- Treats quoted strings and itemlinks as non-spaced.
-- @param string The raw argument string
-- @param numargs How many arguments to get (default 1)
-- @param startpos Where in the string to start scanning (default 1)
-- @return Returns arg1, arg2, ..., nextposition\\
-- Missing arguments will be returned as nils. 'nextposition' is returned as 1e9 at the end of the string.
function AceConsole:GetArgs(str, numargs, startpos)
numargs = numargs or 1
startpos = max(startpos or 1, 1)
 
local pos=startpos
 
-- find start of new arg
pos = strfind(str, "[^ ]", pos)
if not pos then -- whoops, end of string
return nils(numargs, 1e9)
end
 
if numargs<1 then
return pos
end
 
-- quoted or space separated? find out which pattern to use
local delim_or_pipe
local ch = strsub(str, pos, pos)
if ch=='"' then
pos = pos + 1
delim_or_pipe='([|"])'
elseif ch=="'" then
pos = pos + 1
delim_or_pipe="([|'])"
else
delim_or_pipe="([| ])"
end
 
startpos = pos
 
while true do
-- find delimiter or hyperlink
local ch,_
pos,_,ch = strfind(str, delim_or_pipe, pos)
 
if not pos then break end
 
if ch=="|" then
-- some kind of escape
 
if strsub(str,pos,pos+1)=="|H" then
-- It's a |H....|hhyper link!|h
pos=strfind(str, "|h", pos+2) -- first |h
if not pos then break end
 
pos=strfind(str, "|h", pos+2) -- second |h
if not pos then break end
elseif strsub(str,pos, pos+1) == "|T" then
-- It's a |T....|t texture
pos=strfind(str, "|t", pos+2)
if not pos then break end
end
 
pos=pos+2 -- skip past this escape (last |h if it was a hyperlink)
 
else
-- found delimiter, done with this arg
return strsub(str, startpos, pos-1), AceConsole:GetArgs(str, numargs-1, pos+1)
end
 
end
 
-- search aborted, we hit end of string. return it all as one argument. (yes, even if it's an unterminated quote or hyperlink)
return strsub(str, startpos), nils(numargs-1, 1e9)
end
 
 
--- embedding and embed handling
 
local mixins = {
"Print",
"Printf",
"RegisterChatCommand",
"UnregisterChatCommand",
"GetArgs",
}
 
-- Embeds AceConsole into the target object making the functions from the mixins list available on target:..
-- @param target target object to embed AceBucket in
function AceConsole:Embed( target )
for k, v in pairs( mixins ) do
target[v] = self[v]
end
self.embeds[target] = true
return target
end
 
function AceConsole:OnEmbedEnable( target )
if AceConsole.weakcommands[target] then
for command, func in pairs( AceConsole.weakcommands[target] ) do
target:RegisterChatCommand( command, func, false, true ) -- nonpersisting and silent registry
end
end
end
 
function AceConsole:OnEmbedDisable( target )
if AceConsole.weakcommands[target] then
for command, func in pairs( AceConsole.weakcommands[target] ) do
target:UnregisterChatCommand( command ) -- TODO: this could potentially unregister a command from another application in case of command conflicts. Do we care?
end
end
end
 
for addon in pairs(AceConsole.embeds) do
AceConsole:Embed(addon)
end
tags/1.15/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
tags/1.15/libs/AceAddon-3.0/AceAddon-3.0.lua New file
0,0 → 1,658
--- **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:\\
-- * **OnInitialize**, which is called directly after the addon is fully loaded.
-- * **OnEnable** which gets called during the PLAYER_LOGIN event, when most of the data provided by the game is already present.
-- * **OnDisable**, which is only called when your addon is manually being disabled.
-- @usage
-- -- A small (but complete) addon, that doesn't do anything,
-- -- but shows usage of the callbacks.
-- local MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon")
--
-- function MyAddon:OnInitialize()
-- -- do init tasks here, like loading the Saved Variables,
-- -- or setting up slash commands.
-- end
--
-- function MyAddon:OnEnable()
-- -- Do more initialization here, that really enables the use of your addon.
-- -- Register Events, Hook functions, Create Frames, Get information from
-- -- the game that wasn't available in OnInitialize
-- end
--
-- function MyAddon:OnDisable()
-- -- Unhook, Unregister Events, Hide frames that you created.
-- -- You would probably only use an OnDisable if you want to
-- -- build a "standby" mode, or be able to toggle modules on/off.
-- end
-- @class file
-- @name AceAddon-3.0.lua
-- @release $Id: AceAddon-3.0.lua 980 2010-10-27 14:20:11Z nevcairiel $
 
local MAJOR, MINOR = "AceAddon-3.0", 10
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
 
-- Lua APIs
local tinsert, tconcat, tremove = table.insert, table.concat, table.remove
local fmt, tostring = string.format, tostring
local select, pairs, next, type, unpack = select, pairs, next, type, unpack
local loadstring, assert, error = loadstring, assert, error
local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: LibStub, IsLoggedIn, geterrorhandler
 
--[[
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.
-- Any libraries you specified will be embeded, and the addon will be scheduled for
-- its OnInitialize and OnEnable callbacks.
-- The final addon object, with all libraries embeded, will be returned.
-- @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")
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon(MyFrame, "MyAddon", "AceEvent-3.0")
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.orderedModules = {}
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")
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.
-- This function will try to embed all of the listed libraries into the addon
-- and error if a single one fails.
--
-- **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.
-- This function will check if the specified library is registered with LibStub
-- and if it has a :Embed function to call. It'll error if any of those conditions
-- fails.
--
-- **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)
-- @name //addon//:GetModule
-- @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")
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.\\
-- 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.
-- @name //addon//:NewModule
-- @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")
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
tinsert(self.orderedModules, module)
 
return module
end
 
--- Returns the real name of the addon or module, without any prefix.
-- @name //addon//:GetName
-- @paramsig
-- @usage
-- print(MyAddon:GetName())
-- -- prints "MyAddon"
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).\\
-- :Enable() also sets the internal `enableState` variable to true
-- @name //addon//:Enable
-- @paramsig
-- @usage
-- -- Enable MyModule
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyModule = MyAddon:GetModule("MyModule")
-- MyModule:Enable()
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.\\
-- :Disable() also sets the internal `enableState` variable to false
-- @name //addon//:Disable
-- @paramsig
-- @usage
-- -- Disable MyAddon
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyAddon:Disable()
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.
-- @name //addon//:EnableModule
-- @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")
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.
-- @name //addon//:DisableModule
-- @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")
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.
-- @name //addon//:SetDefaultModuleLibraries
-- @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.
-- @name //addon//:SetDefaultModuleState
-- @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.
-- @name //addon//:SetDefaultModulePrototype
-- @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 called before any enabling actually happend, e.g. in/before OnInitialize.
-- @name //addon//:SetEnabledState
-- @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.
-- @name //addon//:IterateModules
-- @paramsig
-- @usage
-- -- Enable all modules
-- for name, module in MyAddon:IterateModules() do
-- module:Enable()
-- end
local function IterateModules(self) return pairs(self.modules) end
 
-- Returns an iterator of all embeds in the addon
-- @name //addon//:IterateEmbeds
-- @paramsig
local function IterateEmbeds(self) return pairs(AceAddon.embeds[self]) end
 
--- Query the enabledState of an addon.
-- @name //addon//:IsEnabled
-- @paramsig
-- @usage
-- if MyAddon:IsEnabled() then
-- MyAddon:Disable()
-- end
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, skipPMixins)
for k, v in pairs(mixins) do
target[k] = v
end
if not skipPMixins then
for k, v in pairs(pmixins) do
target[k] = target[k] or v
end
end
end
 
 
-- - Initialize the addon after creation.
-- 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.
--
-- **Note:** 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.\\
-- This function does not toggle the enable state of the addon itself, and will return early if the addon is disabled.
--
-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing.
-- Use :Enable on the addon itself instead.
-- @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.
local modules = addon.orderedModules
for i = 1, #modules do
self:EnableAddon(modules[i])
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.\\
-- This function does not toggle the enable state of the addon itself, and will return early if the addon is still enabled.
--
-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing.
-- Use :Disable on the addon itself instead.
-- @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.
local modules = addon.orderedModules
for i = 1, #modules do
self:DisableAddon(modules[i])
end
end
 
return not self.statuses[addon.name] -- return true if we're disabled
end
 
--- 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
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
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, true)
end
 
-- 2010-10-27 nevcairiel - add new "orderedModules" table
if oldminor and oldminor < 10 then
for name, addon in pairs(AceAddon.addons) do
addon.orderedModules = {}
for module_name, module in pairs(addon.modules) do
tinsert(addon.orderedModules, module)
end
end
end
tags/1.15/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
tags/1.15/libs/AceDB-3.0/AceDB-3.0.lua New file
0,0 → 1,728
--- **AceDB-3.0** manages the SavedVariables of your addon.
-- It offers profile management, smart defaults and namespaces for modules.\\
-- Data can be saved in different data-types, depending on its intended usage.
-- The most common data-type is the `profile` type, which allows the user to choose
-- the active profile, and manage the profiles of all of his characters.\\
-- The following data types are available:
-- * **char** Character-specific data. Every character has its own database.
-- * **realm** Realm-specific data. All of the players characters on the same realm share this database.
-- * **class** Class-specific data. All of the players characters of the same class share this database.
-- * **race** Race-specific data. All of the players characters of the same race share this database.
-- * **faction** Faction-specific data. All of the players characters of the same faction share this database.
-- * **factionrealm** Faction and realm specific data. All of the players characters on the same realm and of the same faction share this database.
-- * **global** Global Data. All characters on the same account share this database.
-- * **profile** Profile-specific data. All characters using the same profile share this database. The user can control which profile should be used.
--
-- Creating a new Database using the `:New` function will return a new DBObject. A database will inherit all functions
-- of the DBObjectLib listed here. \\
-- If you create a new namespaced child-database (`:RegisterNamespace`), you'll get a DBObject as well, but note
-- that the child-databases cannot individually change their profile, and are linked to their parents profile - and because of that,
-- the profile related APIs are not available. Only `:RegisterDefaults` and `:ResetProfile` are available on child-databases.
--
-- For more details on how to use AceDB-3.0, see the [[AceDB-3.0 Tutorial]].
--
-- You may also be interested in [[libdualspec-1-0|LibDualSpec-1.0]] to do profile switching automatically when switching specs.
--
-- @usage
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("DBExample")
--
-- -- declare defaults to be used in the DB
-- local defaults = {
-- profile = {
-- setting = true,
-- }
-- }
--
-- function MyAddon:OnInitialize()
-- -- Assuming the .toc says ## SavedVariables: MyAddonDB
-- self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults, true)
-- end
-- @class file
-- @name AceDB-3.0.lua
-- @release $Id: AceDB-3.0.lua 940 2010-06-19 08:01:47Z nevcairiel $
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 21
local AceDB, oldminor = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR)
 
if not AceDB then return end -- No upgrade needed
 
-- Lua APIs
local type, pairs, next, error = type, pairs, next, error
local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget
 
-- WoW APIs
local _G = _G
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: LibStub
 
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)
-- remove all metatables from the db, so we don't accidentally create new sub-tables through them
setmetatable(db, nil)
-- loop through the defaults and remove their content
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
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
 
-- map "true" to our "Default" profile
if defaultProfile == true then defaultProfile = "Default" end
 
local profileKey
if not parent then
-- Make a container for profile keys
if not sv.profileKeys then sv.profileKeys = {} end
 
-- Try to get the profile selected from the char db
profileKey = sv.profileKeys[charKey] or defaultProfile or charKey
 
-- save the selected profile for later
sv.profileKeys[charKey] = profileKey
else
-- Use the profile of the parents DB
profileKey = parent.keys.profile or defaultProfile or charKey
 
-- clear the profileKeys in the DB, namespaces don't need to store them
sv.profileKeys = nil
end
 
-- 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
-- and cleans up empty sections
local function logoutHandler(frame, event)
if event == "PLAYER_LOGOUT" then
for db in pairs(AceDB.db_registry) do
db.callbacks:Fire("OnDatabaseShutdown", db)
db:RegisterDefaults(nil)
 
-- cleanup sections that are empty without defaults
local sv = rawget(db, "sv")
for section in pairs(db.keys) do
if rawget(sv, section) then
-- global is special, all other sections have sub-entrys
-- also don't delete empty profiles on main dbs, only on namespaces
if section ~= "global" and (section ~= "profiles" or rawget(db, "parent")) then
for key in pairs(sv[section]) do
if not next(sv[section][key]) then
sv[section][key] = nil
end
end
end
if not next(sv[section]) then
sv[section] = nil
end
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
 
-- if the storage exists, save the new profile
-- this won't exist on namespaces.
if self.sv.profileKeys then
self.sv.profileKeys[charKey] = name
end
 
-- 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.profiles, name) and not silent then
error("Cannot delete profile '" .. name .. "'. It does not exist.", 2)
end
 
self.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.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, nil, true)
 
local profile = self.profile
local source = self.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
-- @param noCallbacks if set to true, won't fire the OnProfileReset callback
function DBObjectLib:ResetProfile(noChildren, noCallbacks)
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, nil, noCallbacks)
end
end
 
-- Callback: OnProfileReset, database
if not noCallbacks then
self.callbacks:Fire("OnProfileReset", self)
end
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
 
--- Returns an already existing namespace from the database object.
-- @param name The name of the new namespace
-- @param silent if true, the addon is optional, silently return nil if its not found
-- @usage
-- local namespace = self.db:GetNamespace('namespace')
-- @return the namespace object if found
function DBObjectLib:GetNamespace(name, silent)
if type(name) ~= "string" then
error("Usage: AceDBObject:GetNamespace(name): 'name' - string expected.", 2)
end
if not silent and not (self.children and self.children[name]) then
error ("Usage: AceDBObject:GetNamespace(name): 'name' - namespace does not exist.", 2)
end
if not self.children then self.children = {} end
return self.children[name]
end
 
--[[-------------------------------------------------------------------------
AceDB Exposed Methods
---------------------------------------------------------------------------]]
 
--- Creates a new database object that can be used to handle database settings and profiles.
-- By default, an empty DB is created, using a character specific profile.
--
-- You can override the default profile used by passing any profile name as the third argument,
-- or by passing //true// as the third argument to use a globally shared profile called "Default".
--
-- Note that there is no token replacement in the default profile name, passing a defaultProfile as "char"
-- will use a profile named "char", and not a character-specific profile.
-- @param tbl 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. If not set, a character specific profile will be used as the default.
-- You can also pass //true// to use a shared global profile called "Default".
-- @usage
-- -- Create an empty DB using a character-specific default profile.
-- self.db = LibStub("AceDB-3.0"):New("MyAddonDB")
-- @usage
-- -- Create a DB using defaults and using a shared default profile
-- self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults, true)
function AceDB:New(tbl, defaults, defaultProfile)
if type(tbl) == "string" then
local name = tbl
tbl = _G[name]
if not tbl then
tbl = {}
_G[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" and defaultProfile ~= true then
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaultProfile' - string or true 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
db.ResetProfile = DBObjectLib.ResetProfile
end
end
tags/1.15/AtlasLootReverse.lua New file
0,0 → 1,177
--[[
AtlasLootReverse
Written by pceric
http://www.wowinterface.com/downloads/info9179-Know-It-All.html
]]
AtlasLootReverse = LibStub("AceAddon-3.0"):NewAddon("AtlasLootReverse", "AceConsole-3.0")
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
 
-- Default settings
local defaults = {
profile = {
dbversion = "",
alversion = "",
whoTable = {},
embedded = true
}
}
 
-- 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, true)
db = alrdb.profile --local the profile table
self:RegisterChatCommand(L["atlaslootreverse"], "ChatCommand")
self:RegisterChatCommand(L["alr"], "ChatCommand")
TT:RegisterTooltip(GameTooltip)
TT:RegisterTooltip(ItemRefTooltip)
end
 
----------------------
--Disabled
function AtlasLootReverse:OnDisable()
TT:RemoveCallback(AtlasLootReverse.Who)
end
 
----------------------
--Loaded
function AtlasLootReverse:OnEnable()
-- Sanity check for v6 of ALE
assert(ATLASLOOT_VERSION_NUM, "Your AtlasLoot is either too old or broken!")
if db.dbversion ~= AtlasLootReverse.version or db.alversion ~= ATLASLOOT_VERSION_NUM then
local zone
local excludes = {
[29434] = true, -- BoJ
[40752] = true, -- EoH
[40753] = true, -- EoV
[43102] = true, -- Frozen Orb
[45624] = true, -- EoC
[47241] = true, -- EoT
[49426] = true, -- EoF
[44990] = true, -- CS
[45038] = true, -- Frag
[46017] = true, -- Hammer
[47242] = true, -- Trophy
[49908] = true, -- Primordial Saronite
[50274] = true, -- Shadowfrost Shard
[52025] = true, -- VMoS
[52026] = true, -- PMoS
[52027] = true, -- CMoS
}
local tiers = {
["PVP70SET"] = string.format(L["PvP %s Set"], "70"),
["PVP80SET"] = string.format(L["PvP %s Set"], "80"),
["PVP85SET"] = string.format(L["PvP %s Set"], "85"),
["T456SET"] = string.format(L["PvP %s Set"], "4/5/6"),
["T7T8SET"] = string.format(L["Tier %s"], "7/8"),
["T9SET"] = string.format(L["Tier %s"], "9"),
["T10SET"] = string.format(L["Tier %s"], "10"),
["T11SET"] = string.format(L["Tier %s"], "11"),
}
wipe(db.whoTable) -- Wipe the table
-- Force AtlasLoot to load all modules
--AtlasLoot:LoadModule("all") -- (broken in 6.03)
for _,module in pairs(AtlasLoot.Modules) do
LoadAddOn(module[2])
end
for _,itable in pairs(AtlasLoot_Data) do
for k,v in pairs(itable) do
if string.find(k, "Normal") or string.find(k, "Heroic") or string.find(k, "25Man") then -- Doing a find because some are _A and some _H
for _, page in pairs(v) do
for _,v2 in pairs(page) do
if type(v2) == "table" and type(v2[2]) == "number" and v2[2] > 0 and not excludes[v2[2]] and itable.info.name ~= "Keys" then
-- Sanity check for boss name
if not itable.info.name then itable.info.name = "?" end
-- Find zone name
if itable.info.instance and AtlasLoot_LootTableRegister.Instances[itable.info.instance] then
-- Some bizzare voodoo in ALE v6.02.00
if type(AtlasLoot_LootTableRegister.Instances[itable.info.instance]) == "string" then
zone = AtlasLoot_LootTableRegister.Instances[AtlasLoot_LootTableRegister.Instances[itable.info.instance]].Info[1]
else
zone = AtlasLoot_LootTableRegister.Instances[itable.info.instance].Info[1]
end
else
zone = ""
end
-- Check if non-normal zone
if k == "Heroic" then
zone = strtrim(string.format(L["Heroic %s"], zone))
elseif k == "25Man" then
zone = strtrim(string.format(L["25 Man %s"], zone))
elseif k == "25ManHeroic" then
zone = strtrim(string.format(L["25 Man Heroic %s"], zone))
end
if zone ~= "" then
zone = " (" .. zone .. ")"
end
-- Check to see if it drops from multiple people
if (db.whoTable[v2[2]]) then
if not string.find(db.whoTable[v2[2]], itable.info.name .. zone, 1, true) then
db.whoTable[v2[2]] = db.whoTable[v2[2]] .. "|" .. itable.info.name .. zone
end
else
db.whoTable[v2[2]] = itable.info.name .. zone
end
-- Check to see if this is a set piece
if itable.info.menu and tiers[itable.info.menu] then
db.whoTable[v2[2]] = db.whoTable[v2[2]] .. " " .. tiers[itable.info.menu]
end
end
end
end
end
end
end
db.dbversion = AtlasLootReverse.version
db.alversion = ATLASLOOT_VERSION_NUM
print(AtlasLootReverse.title .. " database rebuilt.")
end
TT:AddCallback(AtlasLootReverse.Who)
end
 
----------------------
--Command Handler
function AtlasLootReverse:ChatCommand(input)
if input:trim() == "embed" then
db.embedded = not db.embedded
print(L["Tooltip embedded: "] .. tostring(db.embedded))
else
print(L["Commands:\n/alr embed - Toggles the tooltip being embedded or split into another box"])
end
end
 
-- LibExtraTip Call Backs
function AtlasLootReverse:Who(item)
local _, itemId = strsplit(":", item)
--TT:AddLine(self, itemId, nil, nil, nil, db.embedded)
if db.whoTable[tonumber(itemId)] then
for v in string.gmatch(db.whoTable[tonumber(itemId)], "[^|]+") do
if not string.find(v, 'Tier ') and not string.find(v, 'Tabards') and not string.find(v, 'PvP ') then
v = string.format(L["Drops from %s"], v)
end
TT:AddLine(self, v, nil, nil, nil, db.embedded)
end
end
end
\ No newline at end of file
tags/1.15/embeds.xml New file
0,0 → 1,11
<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\AceConsole-3.0\AceConsole-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
tags/1.15 Property changes : Added: wowi:dirname + AtlasLootReverse