/
--[[ $Id: AceEvent-3.0.lua 494 2008-02-03 13:03:56Z nevcairiel $ ]] |
--- AceEvent-3.0 provides event registration and secure dispatching. |
-- @class file |
-- @name AceEvent-3.0 |
-- @release $Id: AceEvent-3.0.lua 710 2008-12-19 10:14:39Z nevcairiel $ |
local MAJOR, MINOR = "AceEvent-3.0", 3 |
local AceEvent = LibStub:NewLibrary(MAJOR, MINOR) |
--[[ $Id: AceConsole-3.0.lua 629 2008-04-22 08:26:12Z ammo $ ]] |
--- AceConsole-3.0 provides registration facilities for slash commands. |
-- @class file |
-- @name AceConsole-3.0 |
-- @release $Id: AceConsole-3.0.lua 710 2008-12-19 10:14:39Z nevcairiel $ |
local MAJOR,MINOR = "AceConsole-3.0", 6 |
local AceConsole, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
local name = "ACECONSOLE_"..command:upper() |
if type( func ) == "string" then |
SlashCmdList[name] = function(input) |
self[func](self, input) |
SlashCmdList[name] = function(input, editBox) |
self[func](self, input, editBox) |
end |
else |
SlashCmdList[name] = func |
--[[ $Id: AceGUI-3.0.lua 681 2008-09-06 13:01:59Z nargiddley $ ]] |
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 16 |
--- AceGUI-3.0 provides access to numerous widgets which can be used to create GUIs. |
-- @class file |
-- @name AceGUI-3.0 |
-- @release $Id: AceGUI-3.0.lua 740 2009-02-15 13:56:40Z nevcairiel $ |
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 18 |
local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR) |
if not AceGUI then return end -- No upgrade needed |
-- end |
end |
WidgetContainerBase.AddChild = function(self, child) |
tinsert(self.children,child) |
WidgetContainerBase.AddChild = function(self, child, beforeWidget) |
if beforeWidget then |
local siblingIndex = 1 |
for _, widget in pairs(self.children) do |
if widget == beforeWidget then |
break |
end |
siblingIndex = siblingIndex + 1 |
end |
tinsert(self.children, siblingIndex, child) |
else |
tinsert(self.children, child) |
end |
child:SetParent(self) |
child.frame:Show() |
self:DoLayout() |
]] |
do |
local Type = "EditBox" |
local Version = 8 |
local Version = 9 |
local function OnAcquire(self) |
self:SetDisabled(false) |
self.label:Show() |
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18) |
self.frame:SetHeight(44) |
self.alignoffset = 30 |
else |
self.label:SetText("") |
self.label:Hide() |
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0) |
self.frame:SetHeight(26) |
self.alignoffset = 12 |
end |
end |
do |
local Type = "TreeGroup" |
local Version = 16 |
local Version = 17 |
local DEFAULT_TREE_WIDTH = 175 |
local DEFAULT_TREE_SIZABLE = true |
}, |
} |
]] |
local function SetTree(self, tree) |
local function SetTree(self, tree, filter) |
self.filter = filter |
if tree then |
assert(type(tree) == "table") |
end |
self:RefreshTree() |
end |
local function ShouldDisplayLevel(tree) |
local result = false |
for k, v in ipairs(tree) do |
if v.children == nil and v.visible ~= false then |
result = true |
elseif v.children then |
result = result or ShouldDisplayLevel(v.children) |
end |
if result then return result end |
end |
return false |
end |
local function addLine(self, v, tree, level, parent) |
local line = new() |
line.value = v.value |
line.text = v.text |
line.disabled = v.disabled |
line.tree = tree |
line.level = level |
line.parent = parent |
line.visible = v.visible |
line.uniquevalue = GetButtonUniqueValue(line) |
if v.children then |
line.hasChildren = true |
else |
line.hasChildren = nil |
end |
self.lines[#self.lines+1] = line |
return line |
end |
local function BuildLevel(self, tree, level, parent) |
local lines = self.lines |
local status = (self.status or self.localstatus) |
local groups = status.groups |
local groups = (self.status or self.localstatus).groups |
local hasChildren = self.hasChildren |
for i, v in ipairs(tree) do |
local line = new() |
lines[#lines+1] = line |
line.value = v.value |
line.text = v.text |
line.disabled = v.disabled |
line.tree = tree |
line.level = level |
line.parent = parent |
line.uniquevalue = GetButtonUniqueValue(line) |
if v.children then |
line.hasChildren = true |
else |
line.hasChildren = nil |
end |
if v.children then |
if groups[line.uniquevalue] then |
self:BuildLevel(v.children, level+1, line) |
if not self.filter or ShouldDisplayLevel(v.children) then |
local line = addLine(self, v, tree, level, parent) |
if groups[line.uniquevalue] then |
self:BuildLevel(v.children, level+1, line) |
end |
end |
elseif v.visible ~= false or not self.filter then |
addLine(self, v, tree, level, parent) |
end |
end |
end |
end |
local function RefreshTree(self) |
local buttons = self.buttons |
local buttons = self.buttons |
local lines = self.lines |
for i, v in ipairs(buttons) do |
end |
local function Select(self, uniquevalue, ...) |
self.filter = false |
local status = self.status or self.localstatus |
local groups = status.groups |
for i = 1, select('#', ...) do |
self.hasChildren = {} |
self.localstatus = {} |
self.localstatus.groups = {} |
self.filter = false |
local treeframe = CreateFrame("Frame",nil,frame) |
treeframe.obj = self |
self.OnWidthSet = OnWidthSet |
self.OnHeightSet = OnHeightSet |
self.EnableButtonTooltips = EnableButtonTooltips |
self.Filter = Filter |
self.frame = frame |
frame.obj = self |
do |
local Type = "TabGroup" |
local Version = 15 |
local Version = 17 |
local PaneBackdrop = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
self:Fire("OnTabLeave", self.tabs[this.id].value, this) |
end |
local function Tab_OnShow(this) |
_G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30) |
end |
local function CreateTab(self, id) |
local tabname = "AceGUITabGroup"..self.num.."Tab"..id |
local tab = CreateFrame("Button",tabname,self.border,"OptionsFrameTabButtonTemplate") |
tab:SetScript("OnClick",Tab_OnClick) |
tab:SetScript("OnEnter",Tab_OnEnter) |
tab:SetScript("OnLeave",Tab_OnLeave) |
tab:SetScript("OnShow", Tab_OnShow) |
tab._SetText = tab.SetText |
tab.SetText = Tab_SetText |
tab:SetDisabled(v.disabled) |
tab.value = v.value |
widths[i] = tab:GetWidth() - 10 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing |
widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text |
end |
--First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout |
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px |
rowends[numrows] = i - 1 |
numrows = numrows + 1 |
usedwidth = 0 |
usedwidth = 0 |
end |
usedwidth = usedwidth + widths[i] |
end |
local tab = tabs[tabno] |
tab:ClearAllPoints() |
if first then |
tab:SetPoint("TOPLEFT",self.frame,"TOPLEFT",0,-7-(row-1)*20 ) |
tab:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -7-(row-1)*20 ) |
first = false |
else |
tab:SetPoint("LEFT",tabs[tabno-1],"RIGHT",-10,0) |
tab:SetPoint("LEFT", tabs[tabno-1], "RIGHT", -10, 0) |
end |
end |
--equal padding for each tab to fill the available width |
local padding = (width - rowwidths[row]) / (endtab - starttab+1) |
-- equal padding for each tab to fill the available width, |
-- if the used space is above 75% already |
local padding = 0 |
if not (numrows == 1 and rowwidths[1] < width*0.75) then |
padding = (width - rowwidths[row]) / (endtab - starttab+1) |
end |
for i = starttab, endtab do |
PanelTemplates_TabResize(tabs[i], padding) |
PanelTemplates_TabResize(tabs[i], padding + 4) |
end |
starttab = endtab + 1 |
end |
--[[ $Id: AceAddon-3.0.lua 654 2008-05-21 13:43:29Z ammo $ ]] |
--- '''AceAddon-3.0''' provides a template for creating addon objects. |
-- It'll provide you with a set of callback functions that allow you to simplify the loading |
-- process of your addon. Callbacks provided are:<br> |
-- - '''OnInitialize''', which is called directly after the addon is fully loaded.<br> |
-- - '''OnEnable''' which gets called during the PLAYER_LOGIN event, when most of the data provided by the game is already present.<br> |
-- - '''OnDisable''', which is only called when your addon is manually being disabled.<br> |
-- @class file |
-- @name AceAddon-3.0.lua |
-- @release $Id: AceAddon-3.0.lua 732 2009-02-03 15:07:43Z nevcairiel $ |
local MAJOR, MINOR = "AceAddon-3.0", 5 |
local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
-- used in the addon metatable |
local function addontostring( self ) return self.name end |
-- AceAddon:NewAddon( [object, ]name, [lib, lib, lib, ...] ) |
-- [object] (table) - table to use as the base for the addon |
-- name (string) - unique addon object name |
-- [lib] (string) - optional libs to embed in the addon object |
--- Create a new AceAddon-3.0 addon. |
-- @paramsig [object ,]name[, lib, ...] |
-- @param object Table to use as a base for the addon (optional) |
-- @param name Name of the addon object to create |
-- @param lib List of libraries to embed into the addon |
-- @usage |
-- -- Create a simple addon object |
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceEvent-3.0") |
-- |
-- returns the addon object when succesful |
-- -- Create a Addon object based on the table of a frame |
-- local MyFrame = CreateFrame("Frame") |
-- local MyBetterAddon = LibStub("AceAddon-3.0"):NewAddon(MyFrame, "MyBetterAddon", "AceEvent-3.0") |
-- @return The newly created addon object |
function AceAddon:NewAddon(objectorname, ...) |
local object,name |
local i=1 |
end |
-- AceAddon:GetAddon( name, [silent]) |
-- name (string) - unique addon object name |
-- silent (boolean) - if true, addon is optional, silently return nil if its not found |
-- |
-- throws an error if the addon object can not be found (except silent is set) |
-- returns the addon object if found |
--- Get the addon object by its name from the internal AceAddon registry. |
-- Throws an error if the addon object cannot be found (except if silent is set). |
-- @param name unique name of the addon object |
-- @param silent if true, the addon is optional, silently return nil if its not found |
-- @usage |
-- -- Get the Addon |
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") |
-- @return The addon object, if found |
function AceAddon:GetAddon(name, silent) |
if not silent and not self.addons[name] then |
error(("Usage: GetAddon(name): 'name' - Cannot find an AceAddon '%s'."):format(tostring(name)), 2) |
return self.addons[name] |
end |
-- AceAddon:EmbedLibraries( addon, [lib, lib, lib, ...] ) |
-- addon (object) - addon to embed the libs in |
-- [lib] (string) - optional libs to embed |
--- Embed a list of libraries into the specified addon. |
-- Note: This function is for internal use by :NewAddon/:NewModule |
-- @paramsig addon, [lib, ...] |
-- @param addon addon object to embed the libs in |
-- @param lib List of libraries to embed into the addon |
function AceAddon:EmbedLibraries(addon, ...) |
for i=1,select("#", ... ) do |
local libname = select(i, ...) |
end |
end |
-- AceAddon:EmbedLibrary( addon, libname, silent, offset ) |
-- addon (object) - addon to embed the libs in |
-- libname (string) - lib to embed |
-- [silent] (boolean) - optional, marks an embed to fail silently if the library doesn't exist. |
-- [offset] (number) - will push the error messages back to said offset defaults to 2 |
--- Embed a library into the addon object. |
-- Note: This function is for internal use by :EmbedLibraries |
-- @paramsig addon, libname[, silent[, offset]] |
-- @param addon addon object to embed the library in |
-- @param libname name of the library to embed |
-- @param silent marks an embed to fail silently if the library doesn't exist (optional) |
-- @param offset will push the error messages back to said offset, defaults to 2 (optional) |
function AceAddon:EmbedLibrary(addon, libname, silent, offset) |
local lib = LibStub:GetLibrary(libname, true) |
if not lib and not silent then |
end |
end |
-- addon:GetModule( name, [silent]) |
-- name (string) - unique module object name |
-- silent (boolean) - if true, module is optional, silently return nil if its not found |
-- |
-- throws an error if the addon object can not be found (except silent is set) |
-- returns the module object if found |
--- Return the specified module from an addon object. |
-- Throws an error if the addon object cannot be found (except if silent is set) |
-- @paramsig name[, silent] |
-- @param name unique name of the module |
-- @param silent if true, the module is optional, silently return nil if its not found (optional) |
-- @usage |
-- -- Get the Addon |
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") |
-- -- Get the Module |
-- MyModule = MyAddon:GetModule("MyModule") |
-- @return the module object, if found |
function GetModule(self, name, silent) |
if not self.modules[name] and not silent then |
error(("Usage: GetModule(name, silent): 'name' - Cannot find module '%s'."):format(tostring(name)), 2) |
local function IsModuleTrue(self) return true end |
-- addon:NewModule( name, [prototype, [lib, lib, lib, ...] ) |
-- name (string) - unique module object name for this addon |
-- prototype (object) - object to derive this module from, methods and values from this table will be mixed into the module, if a string is passed a lib is assumed |
-- [lib] (string) - optional libs to embed in the addon object |
-- |
-- returns the addon object when succesful |
--- Create a new module for the addon. |
-- The new module can have its own embeded libraries and/or use a module prototype to be mixed into the module.<br> |
-- A module has the same functionality as a real addon, it can have modules of its own, and has the same API as |
-- an addon object. |
-- @paramsig name[, prototype|lib[, lib, ...]] |
-- @param name unique name of the module |
-- @param prototype object to derive this module from, methods and values from this table will be mixed into the module (optional) |
-- @param lib List of libraries to embed into the addon |
-- @usage |
-- -- Create a module with some embeded libraries |
-- MyModule = MyAddon:NewModule("MyModule", "AceEvent-3.0", "AceHook-3.0") |
-- |
-- -- Create a module with a prototype |
-- local prototype = { OnEnable = function(self) print("OnEnable called!") end } |
-- MyModule = MyAddon:NewModule("MyModule", prototype, "AceEvent-3.0", "AceHook-3.0") |
-- @return the module object, if successfull |
function NewModule(self, name, prototype, ...) |
if type(name) ~= "string" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end |
if type(prototype) ~= "string" and type(prototype) ~= "table" and type(prototype) ~= "nil" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'prototype' - table (prototype), string (lib) or nil expected got '%s'."):format(type(prototype)), 2) end |
return module |
end |
--addon:GetName() |
-- Returns the real name of the addon or module, without any prefix |
--- Returns the real name of the addon or module, without any prefix. |
-- @paramsig |
-- @usage |
-- print(MyAddon:GetName()) |
-- -- prints "MyAddon" |
-- @return The name of the addon or module |
function GetName(self) |
return self.moduleName or self.name |
end |
--addon:Enable() |
-- Enables the Addon if possible, return true or false depending on success |
--- Enables the Addon, if possible, return true or false depending on success. |
-- This internally calls AceAddon:EnableAddon(), thus dispatching a OnEnable callback |
-- and enabling all modules of the addon (unless explicitly disabled).<br> |
-- :Enable() also sets the internal `enableState` variable to true |
-- @paramsig |
-- @usage |
-- -- Enable MyModule |
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") |
-- MyModule = MyAddon:GetModule("MyModule") |
-- MyModule:Enable() |
-- @return true if the addon was enabled successfully |
function Enable(self) |
self:SetEnabledState(true) |
return AceAddon:EnableAddon(self) |
end |
--addon:Disable() |
-- Disables the Addon if possible, return true or false depending on success |
--- Disables the Addon, if possible, return true or false depending on success. |
-- This internally calls AceAddon:DisableAddon(), thus dispatching a OnDisable callback |
-- and disabling all modules of the addon.<br> |
-- :Disable() also sets the internal `enableState` variable to false |
-- @paramsig |
-- @usage |
-- -- Disable MyAddon |
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") |
-- MyAddon:Disable() |
-- @return true if the addon was disabled successfully |
function Disable(self) |
self:SetEnabledState(false) |
return AceAddon:DisableAddon(self) |
end |
-- addon:EnableModule( name ) |
-- name (string) - unique module object name |
--- Enables the Module, if possible, return true or false depending on success. |
-- Short-hand function that retrieves the module via `:GetModule` and calls `:Enable` on the module object. |
-- @paramsig name |
-- @usage |
-- -- Enable MyModule using :GetModule |
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") |
-- MyModule = MyAddon:GetModule("MyModule") |
-- MyModule:Enable() |
-- |
-- Enables the Module if possible, return true or false depending on success |
-- -- Enable MyModule using the short-hand |
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") |
-- MyAddon:EnableModule("MyModule") |
-- @return true if the module was enabled successfully |
-- @see Enable |
function EnableModule(self, name) |
local module = self:GetModule( name ) |
return module:Enable() |
end |
-- addon:DisableModule( name ) |
-- name (string) - unique module object name |
--- Disables the Module, if possible, return true or false depending on success. |
-- Short-hand function that retrieves the module via `:GetModule` and calls `:Disable` on the module object. |
-- @paramsig name |
-- @usage |
-- -- Disable MyModule using :GetModule |
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") |
-- MyModule = MyAddon:GetModule("MyModule") |
-- MyModule:Disable() |
-- |
-- Disables the Module if possible, return true or false depending on success |
-- -- Disable MyModule using the short-hand |
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") |
-- MyAddon:DisableModule("MyModule") |
-- @return true if the module was disabled successfully |
-- @see Disable |
function DisableModule(self, name) |
local module = self:GetModule( name ) |
return module:Disable() |
end |
-- addon:SetDefaultModuleLibraries( [lib, lib, lib, ...] ) |
-- [lib] (string) - libs to embed in every module |
--- Set the default libraries to be mixed into all modules created by this object. |
-- Note that you can only change the default module libraries before any module is created. |
-- @paramsig lib[, lib, ...] |
-- @param lib List of libraries to embed into the addon |
-- @usage |
-- -- Create the addon object |
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") |
-- -- Configure default libraries for modules (all modules need AceEvent-3.0) |
-- MyAddon:SetDefaultModuleLibraries("AceEvent-3.0") |
-- -- Create a module |
-- MyModule = MyAddon:NewModule("MyModule") |
function SetDefaultModuleLibraries(self, ...) |
if next(self.modules) then |
error("Usage: SetDefaultModuleLibraries(...): cannot change the module defaults after a module has been registered.", 2) |
self.defaultModuleLibraries = {...} |
end |
-- addon:SetDefaultModuleState( state ) |
-- state (boolean) - default state for new modules (enabled=true, disabled=false) |
--- Set the default state in which new modules are being created. |
-- Note that you can only change the default state before any module is created. |
-- @paramsig state |
-- @param state Default state for new modules, true for enabled, false for disabled |
-- @usage |
-- -- Create the addon object |
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") |
-- -- Set the default state to "disabled" |
-- MyAddon:SetDefaultModuleState(false) |
-- -- Create a module and explicilty enable it |
-- MyModule = MyAddon:NewModule("MyModule") |
-- MyModule:Enable() |
function SetDefaultModuleState(self, state) |
if next(self.modules) then |
error("Usage: SetDefaultModuleState(state): cannot change the module defaults after a module has been registered.", 2) |
self.defaultModuleState = state |
end |
-- addon:SetDefaultModulePrototype( prototype ) |
-- prototype (string or table) - the default prototype to use if none is specified on module creation |
--- Set the default prototype to use for new modules on creation. |
-- Note that you can only change the default prototype before any module is created. |
-- @paramsig prototype |
-- @param prototype Default prototype for the new modules (table) |
-- @usage |
-- -- Define a prototype |
-- local prototype = { OnEnable = function(self) print("OnEnable called!") end } |
-- -- Set the default prototype |
-- MyAddon:SetDefaultModulePrototype(prototype) |
-- -- Create a module and explicitly Enable it |
-- MyModule = MyAddon:NewModule("MyModule") |
-- MyModule:Enable() |
-- -- should print "OnEnable called!" now |
-- @see NewModule |
function SetDefaultModulePrototype(self, prototype) |
if next(self.modules) then |
error("Usage: SetDefaultModulePrototype(prototype): cannot change the module defaults after a module has been registered.", 2) |
self.defaultModulePrototype = prototype |
end |
-- addon:SetEnabledState ( state ) |
-- state ( boolean ) - set the state of an addon or module (enabled=true, disabled=false) |
-- |
-- should only be called before any Enabling actually happend, aka in OnInitialize |
--- Set the state of an addon or module |
-- This should only be caleld before any enabling actually happend, aka in/before OnInitialize. |
-- @paramsig state |
-- @param state the state of an addon or module (enabled=true, disabled=false) |
function SetEnabledState(self, state) |
self.enabledState = state |
end |
--- Return an iterator of all modules associated to the addon. |
-- @paramsig |
-- @usage |
-- -- Enable all modules |
-- for name, module in MyAddon:IterateModules() do |
-- module:Enable() |
-- end |
-- @return Iterator of all modules |
local function IterateModules(self) return pairs(self.modules) end |
-- Returns an iterator of all embeds in the addon |
-- @paramsig |
-- @return Iterator of all embeded libraries |
local function IterateEmbeds(self) return pairs(AceAddon.embeds[self]) end |
--- Query the enabledState of an addon. |
-- @paramsig |
-- @usage |
-- if MyAddon:IsEnabled() then |
-- MyAddon:Disable() |
-- end |
-- @return true if the addon/module is enabled, false otherwise |
local function IsEnabled(self) return self.enabledState end |
local mixins = { |
NewModule = NewModule, |
end |
-- AceAddon:IntializeAddon( addon ) |
-- addon (object) - addon to intialize |
-- |
-- calls OnInitialize on the addon object if available |
-- calls OnEmbedInitialize on embedded libs in the addon object if available |
--- Initialize the addon after creation. |
-- Note: This function is only used internally during the ADDON_LOADED event |
-- It will call the '''OnInitialize''' function on the addon object (if present), |
-- and the '''OnEmbedInitialize''' function on all embeded libraries. <br> |
-- Do not call this function manually, unless you're absolutely sure that you know what you are doing. |
-- @param addon addon object to intialize |
function AceAddon:InitializeAddon(addon) |
safecall(addon.OnInitialize, addon) |
-- from the event handler and only done _once_ |
end |
-- AceAddon:EnableAddon( addon ) |
-- addon (object) - addon to enable |
-- |
-- calls OnEnable on the addon object if available |
-- calls OnEmbedEnable on embedded libs in the addon object if available |
--- Enable the addon after creation. |
-- Note: This function is only used internally during the PLAYER_LOGIN event, or during ADDON_LOADED, |
-- if IsLoggedIn() already returns true at that point, e.g. for LoD Addons. |
-- It will call the '''OnEnable''' function on the addon object (if present), |
-- and the '''OnEmbedEnable''' function on all embeded libraries.<br> |
-- This function does not toggle the enable state of the addon itself, and will return early if the addon is disabled.<br> |
-- Do not call this function manually, unless you're absolutely sure that you know what you are doing. |
-- @param addon addon object to enable |
function AceAddon:EnableAddon(addon) |
if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end |
if self.statuses[addon.name] or not addon.enabledState then return false end |
-- set the statuses first, before calling the OnEnable. this allows for Disabling of the addon in OnEnable. |
self.statuses[addon.name] = true |
-- TODO: handle 'first'? Or let addons do it on their own? |
safecall(addon.OnEnable, addon) |
-- make sure we're still enabled before continueing |
return self.statuses[addon.name] -- return true if we're disabled |
end |
-- AceAddon:DisableAddon( addon ) |
-- addon (object|string) - addon to disable |
-- |
-- calls OnDisable on the addon object if available |
-- calls OnEmbedDisable on embedded libs in the addon object if available |
--- Disable the addon |
-- Note: This function is only used internally. |
-- It will call the '''OnDisable''' function on the addon object (if present), |
-- and the '''OnEmbedDisable''' function on all embeded libraries.<br> |
-- This function does not toggle the enable state of the addon itself, and will return early if the addon is still enabled.<br> |
-- Do not call this function manually, unless you're absolutely sure that you know what you are doing. |
-- @param addon addon object to enable |
function AceAddon:DisableAddon(addon) |
if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end |
if not self.statuses[addon.name] then return false end |
--The next few funcs are just because no one should be reaching into the internal registries |
--Thoughts? |
--- Get an iterator over all registered addons. |
-- @usage |
-- -- Print a list of all installed AceAddon's |
-- for name, addon in AceAddon:IterateAddons() do |
-- print("Addon: " .. name) |
-- end |
-- @return Iterator over all addons (pairs) |
function AceAddon:IterateAddons() return pairs(self.addons) end |
--- Get an iterator over the internal status registry. |
-- @usage |
-- -- Print a list of all enabled addons |
-- for name, status in AceAddon:IterateAddonStatus() do |
-- if status then |
-- print("EnabledAddon: " .. name) |
-- end |
-- end |
-- @return Iterator over the status registry |
function AceAddon:IterateAddonStatus() return pairs(self.statuses) end |
-- Following Iterators are deprecated, and their addon specific versions should be used |
-- e.g. addon:IterateEmbeds() instead of :IterateEmbedsOnAddon(addon) |
function AceAddon:IterateEmbedsOnAddon(addon) return pairs(self.embeds[addon]) end |
function AceAddon:IterateAddonStatus() return pairs(self.statuses) end |
function AceAddon:IterateModulesOfAddon(addon) return pairs(addon.modules) end |
-- Event Handling |
--[[ $Id: AceConfig-3.0.lua 494 2008-02-03 13:03:56Z nevcairiel $ ]] |
--- AceConfig-3.0 wrapper library. |
-- Provides an API to register an options table with the config registry, |
-- as well as associate it with a slash command. |
-- @class file |
-- @name AceConfig-3.0 |
-- @release $Id: AceConfig-3.0.lua 710 2008-12-19 10:14:39Z nevcairiel $ |
--[[ |
AceConfig-3.0 |
--[[ |
AceConfigDialog-3.0 |
--- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables. |
-- @class file |
-- @name AceConfigDialog-3.0 |
-- @release $Id: AceConfigDialog-3.0.lua 736 2009-02-14 11:13:43Z nevcairiel $ |
]] |
local LibStub = LibStub |
local MAJOR, MINOR = "AceConfigDialog-3.0", 25 |
local MAJOR, MINOR = "AceConfigDialog-3.0", 26 |
local lib = LibStub:NewLibrary(MAJOR, MINOR) |
if not lib then return end |
if dialog and oldstrata then |
dialog:SetFrameStrata(oldstrata) |
end |
lib:Open(appName, rootframe, basepath and unpack(basepath)) |
del(info) |
end |
for i = 1, select('#', ...) do |
--- AceConfigCmd-3.0 handles access to optionstable through the "command line" interface via the ChatFrames. |
-- @class file |
-- @name AceConfigCmd-3.0 |
-- @release $Id: AceConfigCmd-3.0.lua 733 2009-02-03 22:24:44Z nevcairiel $ |
--[[ |
AceConfigCmd-3.0 |
-- TODO: plugin args |
local MAJOR, MINOR = "AceConfigCmd-3.0", 6 |
local MAJOR, MINOR = "AceConfigCmd-3.0", 7 |
local lib = LibStub:NewLibrary(MAJOR, MINOR) |
if not lib then return end |
if v.type == "group" and pickfirstset(v.cmdInline, v.inline, false) then |
print(" "..(desc or name)..":") |
showhelp(info, inputpos, v, true) |
else |
elseif v.type ~= "description" and v.type ~= "header" then |
print(" |cffffff78"..k.."|r - "..(desc or name or "")) |
end |
end |
--[[ |
AceConfigRegistry-3.0: |
Handle central registration of options tables in use by addons and modules. Do nothing else. |
Options tables can be registered as raw tables, or as function refs that return a table. |
These functions receive two arguments: "uiType" and "uiName". |
- Valid "uiTypes": "cmd", "dropdown", "dialog". This is verified by the library at call time. |
- The "uiName" field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time. |
:IterateOptionsTables() and :GetOptionsTable() always return a function reference that the requesting config handling addon must call with the above arguments. |
]] |
--- AceConfigRegistry-3.0 handles central registration of options tables in use by addons and modules. |
-- Options tables can be registered as raw tables, or as function refs that return a table.<br> |
-- These functions receive two arguments: "uiType" and "uiName". <br> |
-- Valid "uiTypes": "cmd", "dropdown", "dialog". This is verified by the library at call time. <br> |
-- The "uiName" field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.<br> |
-- :IterateOptionsTables() and :GetOptionsTable() always return a function reference that the requesting config handling addon must call with the above arguments. |
-- @class file |
-- @name AceConfigRegistry-3.0 |
-- @release $Id: AceConfigRegistry-3.0.lua 710 2008-12-19 10:14:39Z nevcairiel $ |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 6 |
local lib = LibStub:NewLibrary(MAJOR, MINOR) |
--[[ $Id: AceDB-3.0.lua 667 2008-06-11 14:34:58Z nevcairiel $ ]] |
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 8 |
--- AceDB-3.0 allows you to create profiles and smart default values for the SavedVariables of your addon. |
-- @class file |
-- @name AceDB-3.0.lua |
-- @release $Id: AceDB-3.0.lua 735 2009-02-14 11:10:48Z nevcairiel $ |
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 10 |
local AceDB, oldminor = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR) |
if not AceDB then return end -- No upgrade needed |
if defaults[key] == nil and (not blocker or blocker[key] == nil) then |
removeDefaults(value, v) |
-- if the table is empty afterwards, remove it |
if not next(value) then |
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 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 not next(db[k]) then |
if next(db[k]) == nil then |
db[k] = nil |
end |
else |
AceDB Object Method Definitions |
---------------------------------------------------------------------------]] |
-- DBObject:RegisterDefaults(defaults) |
-- defaults (table) - A table of defaults for this database |
-- |
-- Sets the defaults table for the given database object by clearing any |
--- 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 |
end |
-- DBObject:SetProfile(name) |
-- name (string) - The name of the profile to set as the current profile |
-- |
-- Changes the profile of the database and all of it's namespaces to the |
--- 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) |
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) |
self.callbacks:Fire("OnProfileChanged", self, name) |
end |
-- DBObject:GetProfiles(tbl) |
-- tbl (table) - A table to store the profile names in (optional) |
-- |
-- Returns a table with the names of the existing profiles in the database. |
--- 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) |
return tbl, i |
end |
-- DBObject:GetCurrentProfile() |
-- |
-- Returns the current profile name used by the database |
--- Returns the current profile name used by the database |
function DBObjectLib:GetCurrentProfile() |
return self.keys.profile |
end |
-- DBObject:DeleteProfile(name) |
-- name (string) - The name of the profile to be deleted |
-- |
-- Deletes a named profile. This profile must not be the active profile. |
--- 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) |
self.callbacks:Fire("OnProfileDeleted", self, name) |
end |
-- DBObject:CopyProfile(name) |
-- name (string) - The name of the profile to be copied into the current profile |
-- |
-- Copies a named profile into the current profile, overwriting any conflicting |
--- 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) |
self.callbacks:Fire("OnProfileCopied", self, name) |
end |
-- DBObject:ResetProfile() |
-- noChildren (boolean) - if set to true, the reset will not be populated to the child namespaces of this DB object |
-- |
-- Resets the current profile |
--- Resets the current profile to the default values (if specified). |
-- @param noChildren if set to true, the reset will not be populated to the child namespaces of this DB object |
function DBObjectLib:ResetProfile(noChildren) |
local profile = self.profile |
self.callbacks:Fire("OnProfileReset", self) |
end |
-- DBObject:ResetDB(defaultProfile) |
-- defaultProfile (string) - The profile name to use as the default |
-- |
-- Resets the entire database, using the string defaultProfile as the default |
--- 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) |
return self |
end |
-- DBObject:RegisterNamespace(name [, defaults]) |
-- name (string) - The name of the new namespace |
-- defaults (table) - A table of values to use as defaults |
-- |
-- Creates a new database namespace, directly tied to the database. This |
--- 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) |
AceDB Exposed Methods |
---------------------------------------------------------------------------]] |
-- AceDB:New(name, defaults, defaultProfile) |
-- name (table or string) - The name of variable, or table to use for the database |
-- defaults (table) - A table of database defaults |
-- defaultProfile (string) - The name of the default profile |
-- |
-- Creates a new database object that can be used to handle database settings |
--- Creates a new database object that can be used to handle database settings |
-- and profiles. |
-- @param name The name of variable, or table to use for the database |
-- @param defaults A table of database defaults |
-- @param defaultProfile The name of the default profile |
function AceDB:New(tbl, defaults, defaultProfile) |
if type(tbl) == "string" then |
local name = tbl |
## Interface: 30000 |
## Interface: 30100 |
## Title: Plink! |
## Version: 1.1 |
## Version: 1.1.1 |
## Author: Seerah |
## Notes: Plays a sound when your Spell Reflect buff gets used |
## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets |