diff --git a/Broker2FuBar/Broker2FuBar.toc b/Broker2FuBar/Broker2FuBar.toc
new file mode 100644
index 0000000..eb92a2a
--- /dev/null
+++ b/Broker2FuBar/Broker2FuBar.toc
@@ -0,0 +1,26 @@
+## Interface: 100002
+## Title: Broker2FuBar
+## Notes: Shows your LDB sources in FuBar.
+## Author: Kemayo, Adirelle, Arrowmaster
+## Version: 1.0
+## X-Category: Miscellaneous
+## OptionalDeps: Ace3, LibFuBarPlugin-3.0, FuBar, FuBar2Broker
+## SavedVariables: Broker2FuBarDB
+
+libs\LibStub\LibStub.lua
+libs\CallbackHandler-1.0\CallbackHandler-1.0.xml
+
+#@no-lib-strip@
+libs\AceAddon-3.0\AceAddon-3.0.xml
+libs\AceGUI-3.0\AceGUI-3.0.xml
+libs\AceConfig-3.0\AceConfig-3.0.xml
+libs\AceDB-3.0\AceDB-3.0.xml
+libs\AceConsole-3.0\AceConsole-3.0.xml
+libs\LibFuBarPlugin-3.0\lib.xml
+#@end-no-lib-strip@
+
+libs\LibDataBroker-1.1\LibDataBroker-1.1.lua
+
+core.lua
+pluginPrototype.lua
+options.lua
diff --git a/Broker2FuBar/Changelog-Broker2FuBar-1.1.txt b/Broker2FuBar/Changelog-Broker2FuBar-1.1.txt
new file mode 100644
index 0000000..8f227da
--- /dev/null
+++ b/Broker2FuBar/Changelog-Broker2FuBar-1.1.txt
@@ -0,0 +1,170 @@
+------------------------------------------------------------------------
+r29 | adirelle | 2008-10-17 23:17:10 +0000 (Fri, 17 Oct 2008) | 1 line
+Changed paths:
+ A /tags/1.1 (from /trunk:28)
+
+Tagging as 1.1.
+------------------------------------------------------------------------
+r28 | adirelle | 2008-10-17 15:39:55 +0000 (Fri, 17 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/core.lua
+
+Register the Blizzard UI on initialization, instead of postponing it to first /b2f use.
+------------------------------------------------------------------------
+r27 | adirelle | 2008-10-17 14:25:03 +0000 (Fri, 17 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk
+ M /trunk/.pkgmeta
+ M /trunk/Broker2FuBar.toc
+ M /trunk/core.lua
+
+Fix externals and remove AceHook-3.0 (that wasn't even used).
+Use Blizzard options UI for configuration.
+------------------------------------------------------------------------
+r25 | arrowmaster | 2008-10-17 00:51:02 +0000 (Fri, 17 Oct 2008) | 1 line
+Changed paths:
+ M /trunk/Broker2FuBar.toc
+
+Didn't mean to bump the version to 1.1 when 1.0 hasn't been 'released' yet
+------------------------------------------------------------------------
+r24 | arrowmaster | 2008-10-17 00:44:27 +0000 (Fri, 17 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk
+ M /trunk/.pkgmeta
+ M /trunk/Broker2FuBar.toc
+ M /trunk/core.lua
+ D /trunk/embeds.xml
+ D /trunk/libs
+ M /trunk/options.lua
+ M /trunk/pluginPrototype.lua
+
+Rightclicks now passed to LDB plugin, use /b2f to configure the FuBar plugins
+Uses LibFuBarPlugin-3.0 instead of LibFuBarPlugin-Mod-3.0
+------------------------------------------------------------------------
+r19 | pneumatus | 2008-10-15 16:38:37 +0000 (Wed, 15 Oct 2008) | 2 lines
+Changed paths:
+ M /trunk
+ M /trunk/.pkgmeta
+ M /trunk/embeds.xml
+
+Broker2FuBar:
+- Fix missing libs
+------------------------------------------------------------------------
+r18 | root | 2008-09-30 23:06:43 +0000 (Tue, 30 Sep 2008) | 1 line
+Changed paths:
+ M /trunk
+ A /trunk/.pkgmeta
+
+Facilitate WowAce-on-CurseForge transition
+------------------------------------------------------------------------
+r16 | root | 2008-09-30 22:35:19 +0000 (Tue, 30 Sep 2008) | 1 line
+Changed paths:
+ D /tmp/trunk/Broker2FuBar
+ A /trunk (from /tmp/trunk/Broker2FuBar:15)
+
+Importing oldrepo data under /trunk
+------------------------------------------------------------------------
+r15 | sayclub | 2008-09-10 23:23:14 +0000 (Wed, 10 Sep 2008) | 2 lines
+Changed paths:
+ M /tmp/trunk/Broker2FuBar/options.lua
+
+Broker2FuBar:
+- fixed a typo in localization
+------------------------------------------------------------------------
+r14 | adirelle | 2008-09-10 18:31:13 +0000 (Wed, 10 Sep 2008) | 4 lines
+Changed paths:
+ M /tmp/trunk/Broker2FuBar/Broker2FuBar.toc
+ M /tmp/trunk/Broker2FuBar/core.lua
+ M /tmp/trunk/Broker2FuBar/pluginPrototype.lua
+
+Broker2FuBar:
+- only wrap launcher and data sources,
+- display label or name in tooltip if neither OnTooltipShow nor OnEnter is provided,
+- added a safety net to prevent evil things to happen when FuBar2Broker is loaded.
+------------------------------------------------------------------------
+r13 | adirelle | 2008-09-05 13:00:13 +0000 (Fri, 05 Sep 2008) | 3 lines
+Changed paths:
+ M /tmp/trunk/Broker2FuBar/pluginPrototype.lua
+
+Broker2FuBar:
+- fixed a bug where the plugin icon was not updated when the .icon attribute was changed,
+- the plugins now only register callbacks while enabled.
+------------------------------------------------------------------------
+r12 | adirelle | 2008-08-30 09:40:25 +0000 (Sat, 30 Aug 2008) | 3 lines
+Changed paths:
+ M /tmp/trunk/Broker2FuBar/Broker2FuBar.toc
+ M /tmp/trunk/Broker2FuBar/core.lua
+ M /tmp/trunk/Broker2FuBar/options.lua
+ A /tmp/trunk/Broker2FuBar/pluginPrototype.lua
+
+Broker2FuBar:
+- fixed error on plugin dragging,
+- do not create AceAddon-3.0 object on the fly anymore, use internal structure instead.
+------------------------------------------------------------------------
+r11 | adirelle | 2008-08-26 05:46:29 +0000 (Tue, 26 Aug 2008) | 3 lines
+Changed paths:
+ M /tmp/trunk/Broker2FuBar/core.lua
+
+Broker2FuBar:
+- provide the fubar plugin frame to :OnEnter / :OnClick method, instead of the FuBar panel.
+- dropped support of deprecated .tooltiptext attribute.
+------------------------------------------------------------------------
+r10 | adirelle | 2008-08-11 19:21:44 +0000 (Mon, 11 Aug 2008) | 1 line
+Changed paths:
+ M /tmp/trunk/Broker2FuBar/core.lua
+ M /tmp/trunk/Broker2FuBar/options.lua
+
+Broker2FuBar: configuration is now working.
+------------------------------------------------------------------------
+r9 | adirelle | 2008-08-11 15:12:05 +0000 (Mon, 11 Aug 2008) | 6 lines
+Changed paths:
+ M /tmp/trunk/Broker2FuBar
+ M /tmp/trunk/Broker2FuBar/Broker2FuBar.toc
+ M /tmp/trunk/Broker2FuBar/core.lua
+ A /tmp/trunk/Broker2FuBar/embeds.xml
+ A /tmp/trunk/Broker2FuBar/libs/LibFuBarPlugin-Mod-3.0
+ A /tmp/trunk/Broker2FuBar/libs/LibFuBarPlugin-Mod-3.0/LibFuBarPlugin-Mod-3.0.lua
+ A /tmp/trunk/Broker2FuBar/libs/LibFuBarPlugin-Mod-3.0/lib.xml
+ M /tmp/trunk/Broker2FuBar/options.lua
+
+Broker2FuBar:
+- added the options to disable the plugins (not fully working),
+- hard-embedded LibStub'd FuBarPlugin (so it should work without manual checkout),
+- fixed externals,
+- added embeds.xml.
+
+------------------------------------------------------------------------
+r8 | adirelle | 2008-08-10 23:09:08 +0000 (Sun, 10 Aug 2008) | 1 line
+Changed paths:
+ M /tmp/trunk/Broker2FuBar/Broker2FuBar.toc
+ M /tmp/trunk/Broker2FuBar/core.lua
+ A /tmp/trunk/Broker2FuBar/options.lua
+
+Broker2FuBar: now provides some configuration.
+------------------------------------------------------------------------
+r7 | adirelle | 2008-08-10 22:05:54 +0000 (Sun, 10 Aug 2008) | 2 lines
+Changed paths:
+ M /tmp/trunk/Broker2FuBar/core.lua
+
+Broker2FuBar: added support for the following attributes : tooltip, tooltiptext, OnEnter, OnLeave.
+
+------------------------------------------------------------------------
+r6 | kemayo | 2008-08-03 23:49:26 +0000 (Sun, 03 Aug 2008) | 1 line
+Changed paths:
+ M /tmp/trunk/Broker2FuBar
+ M /tmp/trunk/Broker2FuBar/Broker2FuBar.toc
+
+Broker2FuBar: Externals, blah blah blah
+------------------------------------------------------------------------
+r5 | kemayo | 2008-08-03 23:40:30 +0000 (Sun, 03 Aug 2008) | 2 lines
+Changed paths:
+ A /tmp/trunk/Broker2FuBar
+ A /tmp/trunk/Broker2FuBar/Broker2FuBar.toc
+ A /tmp/trunk/Broker2FuBar/core.lua
+ A /tmp/trunk/Broker2FuBar/libs
+ A /tmp/trunk/Broker2FuBar/libs/LibDataBroker-1.1
+ A /tmp/trunk/Broker2FuBar/libs/LibDataBroker-1.1/LibDataBroker-1.1.lua
+
+Broker2FuBar: This is really, really rough. It has no config. But it does work.
+
+------------------------------------------------------------------------
diff --git a/Broker2FuBar/core.lua b/Broker2FuBar/core.lua
new file mode 100644
index 0000000..56b5006
--- /dev/null
+++ b/Broker2FuBar/core.lua
@@ -0,0 +1,109 @@
+local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
+local lfbp = LibStub:GetLibrary("LibFuBarPlugin-3.0")
+
+local AceAddon = LibStub("AceAddon-3.0")
+local addon = AceAddon:NewAddon("Broker2FuBar", "AceConsole-3.0")
+
+addon.registry = {}
+addon.fubared = {}
+
+function addon:OnInitialize()
+ if IsAddOnLoaded('FuBar2Broker') then
+ self:Print(self.name..' disabled itself because FuBar2Broker is loaded. Running these two addons at the same time is a very bad idea.')
+ self:SetEnabledState(false)
+ return
+ end
+
+ self.db = LibStub("AceDB-3.0"):New("Broker2FuBarDB", {
+ profile = {
+ objects = {
+ ['*'] = true,
+ },
+ },
+ })
+
+ LibStub("AceConfig-3.0"):RegisterOptionsTable(self.name, self.options)
+ self:RegisterChatCommand("b2f", "OpenGUI", true)
+ self.blizzardOptionPanel = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(self.name, self.name)
+
+ for name, data_object in ldb:DataObjectIterator() do
+ self:RegisterObject(name, data_object)
+ end
+ ldb.RegisterCallback(self, "LibDataBroker_DataObjectCreated")
+end
+
+function addon:OpenGUI()
+ InterfaceOptionsFrame_OpenToCategory(self.blizzardOptionPanel)
+end
+
+function addon:LibDataBroker_DataObjectCreated(event, name, data_object)
+ self:RegisterObject(name, data_object)
+end
+
+function addon:RegisterObject(name, data_object)
+ if data_object.type ~= 'launcher' and data_object.type ~= 'data source' then
+ return
+ end
+ if not self.registry[name] then
+ self.registry[name] = data_object.label or name
+ end
+ if self:IsObjectEnabled(name) then
+ self:OnObjectEnable(name, data_object)
+ end
+end
+
+function addon:IsObjectEnabled(name)
+ return self.db.profile.objects[name]
+end
+
+function addon:EnableObject(name, value)
+ if value and not self.db.profile.objects[name] then
+ self.db.profile.objects[name] = true
+ self:OnObjectEnable(name)
+ elseif not value and self.db.profile.objects[name] then
+ self.db.profile.objects[name] = false
+ self:OnObjectDisable(name)
+ end
+end
+
+function addon:OnObjectEnable(name, data_object)
+ local fu = self:FuBarize(name, data_object)
+ fu:Enable()
+end
+
+function addon:OnObjectDisable(name)
+ local fu = self.fubared[name]
+ if not fu then return end
+ fu:Disable()
+end
+
+function addon:FuBarize(name, data_object)
+ if self.fubared[name] then
+ return self.fubared[name]
+ end
+ data_object = data_object or ldb:GetDataObjectByName(name)
+
+ -- Create the pseudo-addon
+ local fu = setmetatable({
+ name = name .. "_B2F",
+ data_object_name = name,
+ data_object = data_object,
+ db = self.db:RegisterNamespace(name, {profile={}})
+ }, self.pluginPrototypeMetatable)
+
+ -- Embeds FuBarPlugin
+ lfbp:Embed(fu)
+
+ -- Initiialize it
+ fu:Initialize()
+
+ -- Create the option group
+ local optKey = name:gsub('%s', '_')
+ self.objectOptions[optKey] = setmetatable({
+ name = data_object.label or name,
+ handler = fu
+ }, self.objectOptionsMetaTable)
+
+ self.fubared[name] = fu
+ return fu
+end
diff --git a/Broker2FuBar/libs/AceAddon-3.0/AceAddon-3.0.lua b/Broker2FuBar/libs/AceAddon-3.0/AceAddon-3.0.lua
new file mode 100644
index 0000000..0ea93d1
--- /dev/null
+++ b/Broker2FuBar/libs/AceAddon-3.0/AceAddon-3.0.lua
@@ -0,0 +1,649 @@
+--- **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 1284 2022-09-25 09:15:30Z nevcairiel $
+
+local MAJOR, MINOR = "AceAddon-3.0", 13
+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
+
+--[[
+ xpcall safecall implementation
+]]
+local xpcall = xpcall
+
+local function errorhandler(err)
+ return geterrorhandler()(err)
+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 xpcall(func, errorhandler, ...)
+ 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
+
+-- Check if the addon is queued for initialization
+local function queuedForInitialization(addon)
+ for i = 1, #AceAddon.initializequeue do
+ if AceAddon.initializequeue[i] == addon then
+ return true
+ end
+ end
+ return false
+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)
+
+ -- nevcairiel 2013-04-27: don't enable an addon/module if its queued for init still
+ -- it'll be enabled after the init process
+ if not queuedForInitialization(self) then
+ return AceAddon:EnableAddon(self)
+ end
+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
+
+-- Blizzard AddOns which can load very early in the loading process and mess with Ace3 addon loading
+local BlizzardEarlyLoadAddons = {
+ Blizzard_DebugTools = true,
+ Blizzard_TimeManager = true,
+ Blizzard_BattlefieldMap = true,
+ Blizzard_MapCanvas = true,
+ Blizzard_SharedMapDataProviders = true,
+ Blizzard_CombatLog = true,
+}
+
+-- Event Handling
+local function onEvent(this, event, arg1)
+ -- 2020-08-28 nevcairiel - ignore the load event of Blizzard addons which occur early in the loading process
+ if (event == "ADDON_LOADED" and (arg1 == nil or not BlizzardEarlyLoadAddons[arg1])) 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
diff --git a/Broker2FuBar/libs/AceAddon-3.0/AceAddon-3.0.xml b/Broker2FuBar/libs/AceAddon-3.0/AceAddon-3.0.xml
new file mode 100644
index 0000000..c607008
--- /dev/null
+++ b/Broker2FuBar/libs/AceAddon-3.0/AceAddon-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/Broker2FuBar/libs/AceConfig-3.0/AceConfig-3.0.lua b/Broker2FuBar/libs/AceConfig-3.0/AceConfig-3.0.lua
new file mode 100644
index 0000000..aae348b
--- /dev/null
+++ b/Broker2FuBar/libs/AceConfig-3.0/AceConfig-3.0.lua
@@ -0,0 +1,58 @@
+--- 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 1202 2019-05-15 23:11:22Z nevcairiel $
+
+--[[
+AceConfig-3.0
+
+Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole.
+
+]]
+
+local cfgreg = LibStub("AceConfigRegistry-3.0")
+local cfgcmd = LibStub("AceConfigCmd-3.0")
+
+local MAJOR, MINOR = "AceConfig-3.0", 3
+local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceConfig then return end
+
+--TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true)
+--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true)
+
+-- Lua APIs
+local pcall, error, type, pairs = pcall, error, type, pairs
+
+-- -------------------------------------------------------------------
+-- :RegisterOptionsTable(appName, options, slashcmd, persist)
+--
+-- - appName - (string) application name
+-- - options - table or function ref, see AceConfigRegistry
+-- - slashcmd - slash command (string) or table with commands, or nil to NOT create a slash command
+
+--- Register a option table with the AceConfig registry.
+-- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly.
+-- @paramsig appName, options [, slashcmd]
+-- @param appName The application name for the config table.
+-- @param options The option table (or a function to generate one on demand). http://www.wowace.com/addons/ace3/pages/ace-config-3-0-options-tables/
+-- @param slashcmd A slash command to register for the option table, or a table of slash commands.
+-- @usage
+-- local AceConfig = LibStub("AceConfig-3.0")
+-- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
+function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
+ local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
+ if not ok then error(msg, 2) end
+
+ if slashcmd then
+ if type(slashcmd) == "table" then
+ for _,cmd in pairs(slashcmd) do
+ cfgcmd:CreateChatCommand(cmd, appName)
+ end
+ else
+ cfgcmd:CreateChatCommand(slashcmd, appName)
+ end
+ end
+end
diff --git a/Broker2FuBar/libs/AceConfig-3.0/AceConfig-3.0.xml b/Broker2FuBar/libs/AceConfig-3.0/AceConfig-3.0.xml
new file mode 100644
index 0000000..84c8d03
--- /dev/null
+++ b/Broker2FuBar/libs/AceConfig-3.0/AceConfig-3.0.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
diff --git a/Broker2FuBar/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua b/Broker2FuBar/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua
new file mode 100644
index 0000000..a4240ce
--- /dev/null
+++ b/Broker2FuBar/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua
@@ -0,0 +1,787 @@
+--- AceConfigCmd-3.0 handles access to an options table through the "command line" interface via the ChatFrames.
+-- @class file
+-- @name AceConfigCmd-3.0
+-- @release $Id: AceConfigCmd-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $
+
+--[[
+AceConfigCmd-3.0
+
+Handles commandline optionstable access
+
+REQUIRES: AceConsole-3.0 for command registration (loaded on demand)
+
+]]
+
+-- TODO: plugin args
+
+local cfgreg = LibStub("AceConfigRegistry-3.0")
+
+local MAJOR, MINOR = "AceConfigCmd-3.0", 14
+local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceConfigCmd then return end
+
+AceConfigCmd.commands = AceConfigCmd.commands or {}
+local commands = AceConfigCmd.commands
+
+local AceConsole -- LoD
+local AceConsoleName = "AceConsole-3.0"
+
+-- Lua APIs
+local strsub, strsplit, strlower, strmatch, strtrim = string.sub, string.split, string.lower, string.match, string.trim
+local format, tonumber, tostring = string.format, tonumber, tostring
+local tsort, tinsert = table.sort, table.insert
+local select, pairs, next, type = select, pairs, next, type
+local error, assert = error, assert
+
+-- WoW APIs
+local _G = _G
+
+local L = setmetatable({}, { -- TODO: replace with proper locale
+ __index = function(self,k) return k end
+})
+
+local function print(msg)
+ (SELECTED_CHAT_FRAME or DEFAULT_CHAT_FRAME):AddMessage(msg)
+end
+
+-- constants used by getparam() calls below
+
+local handlertypes = {["table"]=true}
+local handlermsg = "expected a table"
+
+local functypes = {["function"]=true, ["string"]=true}
+local funcmsg = "expected function or member name"
+
+
+-- pickfirstset() - picks the first non-nil value and returns it
+
+local function pickfirstset(...)
+ for i=1,select("#",...) do
+ if select(i,...)~=nil then
+ return select(i,...)
+ end
+ end
+end
+
+
+-- err() - produce real error() regarding malformed options tables etc
+
+local function err(info,inputpos,msg )
+ local cmdstr=" "..strsub(info.input, 1, inputpos-1)
+ error(MAJOR..": /" ..info[0] ..cmdstr ..": "..(msg or "malformed options table"), 2)
+end
+
+
+-- usererr() - produce chatframe message regarding bad slash syntax etc
+
+local function usererr(info,inputpos,msg )
+ local cmdstr=strsub(info.input, 1, inputpos-1);
+ print("/" ..info[0] .. " "..cmdstr ..": "..(msg or "malformed options table"))
+end
+
+
+-- callmethod() - call a given named method (e.g. "get", "set") with given arguments
+
+local function callmethod(info, inputpos, tab, methodtype, ...)
+ local method = info[methodtype]
+ if not method then
+ err(info, inputpos, "'"..methodtype.."': not set")
+ end
+
+ info.arg = tab.arg
+ info.option = tab
+ info.type = tab.type
+
+ if type(method)=="function" then
+ return method(info, ...)
+ elseif type(method)=="string" then
+ if type(info.handler[method])~="function" then
+ err(info, inputpos, "'"..methodtype.."': '"..method.."' is not a member function of "..tostring(info.handler))
+ end
+ return info.handler[method](info.handler, info, ...)
+ else
+ assert(false) -- type should have already been checked on read
+ end
+end
+
+-- callfunction() - call a given named function (e.g. "name", "desc") with given arguments
+
+local function callfunction(info, tab, methodtype, ...)
+ local method = tab[methodtype]
+
+ info.arg = tab.arg
+ info.option = tab
+ info.type = tab.type
+
+ if type(method)=="function" then
+ return method(info, ...)
+ else
+ assert(false) -- type should have already been checked on read
+ end
+end
+
+-- do_final() - do the final step (set/execute) along with validation and confirmation
+
+local function do_final(info, inputpos, tab, methodtype, ...)
+ if info.validate then
+ local res = callmethod(info,inputpos,tab,"validate",...)
+ if type(res)=="string" then
+ usererr(info, inputpos, "'"..strsub(info.input, inputpos).."' - "..res)
+ return
+ end
+ end
+ -- console ignores .confirm
+
+ callmethod(info,inputpos,tab,methodtype, ...)
+end
+
+
+-- getparam() - used by handle() to retreive and store "handler", "get", "set", etc
+
+local function getparam(info, inputpos, tab, depth, paramname, types, errormsg)
+ local old,oldat = info[paramname], info[paramname.."_at"]
+ local val=tab[paramname]
+ if val~=nil then
+ if val==false then
+ val=nil
+ elseif not types[type(val)] then
+ err(info, inputpos, "'" .. paramname.. "' - "..errormsg)
+ end
+ info[paramname] = val
+ info[paramname.."_at"] = depth
+ end
+ return old,oldat
+end
+
+
+-- iterateargs(tab) - custom iterator that iterates both t.args and t.plugins.*
+local dummytable={}
+
+local function iterateargs(tab)
+ if not tab.plugins then
+ return pairs(tab.args)
+ end
+
+ local argtabkey,argtab=next(tab.plugins)
+ local v
+
+ return function(_, k)
+ while argtab do
+ k,v = next(argtab, k)
+ if k then return k,v end
+ if argtab==tab.args then
+ argtab=nil
+ else
+ argtabkey,argtab = next(tab.plugins, argtabkey)
+ if not argtabkey then
+ argtab=tab.args
+ end
+ end
+ end
+ end
+end
+
+local function checkhidden(info, inputpos, tab)
+ if tab.cmdHidden~=nil then
+ return tab.cmdHidden
+ end
+ local hidden = tab.hidden
+ if type(hidden) == "function" or type(hidden) == "string" then
+ info.hidden = hidden
+ hidden = callmethod(info, inputpos, tab, 'hidden')
+ info.hidden = nil
+ end
+ return hidden
+end
+
+local function showhelp(info, inputpos, tab, depth, noHead)
+ if not noHead then
+ print("|cff33ff99"..info.appName.."|r: Arguments to |cffffff78/"..info[0].."|r "..strsub(info.input,1,inputpos-1)..":")
+ end
+
+ local sortTbl = {} -- [1..n]=name
+ local refTbl = {} -- [name]=tableref
+
+ for k,v in iterateargs(tab) do
+ if not refTbl[k] then -- a plugin overriding something in .args
+ tinsert(sortTbl, k)
+ refTbl[k] = v
+ end
+ end
+
+ tsort(sortTbl, function(one, two)
+ local o1 = refTbl[one].order or 100
+ local o2 = refTbl[two].order or 100
+ if type(o1) == "function" or type(o1) == "string" then
+ info.order = o1
+ info[#info+1] = one
+ o1 = callmethod(info, inputpos, refTbl[one], "order")
+ info[#info] = nil
+ info.order = nil
+ end
+ if type(o2) == "function" or type(o1) == "string" then
+ info.order = o2
+ info[#info+1] = two
+ o2 = callmethod(info, inputpos, refTbl[two], "order")
+ info[#info] = nil
+ info.order = nil
+ end
+ if o1<0 and o2<0 then return o1 4) and not _G["KEY_" .. text] then
+ return false
+ end
+ local s = text
+ if shift then
+ s = "SHIFT-" .. s
+ end
+ if ctrl then
+ s = "CTRL-" .. s
+ end
+ if alt then
+ s = "ALT-" .. s
+ end
+ return s
+end
+
+-- handle() - selfrecursing function that processes input->optiontable
+-- - depth - starts at 0
+-- - retfalse - return false rather than produce error if a match is not found (used by inlined groups)
+
+local function handle(info, inputpos, tab, depth, retfalse)
+
+ if not(type(tab)=="table" and type(tab.type)=="string") then err(info,inputpos) end
+
+ -------------------------------------------------------------------
+ -- Grab hold of handler,set,get,func,etc if set (and remember old ones)
+ -- Note that we do NOT validate if method names are correct at this stage,
+ -- the handler may change before they're actually used!
+
+ local oldhandler,oldhandler_at = getparam(info,inputpos,tab,depth,"handler",handlertypes,handlermsg)
+ local oldset,oldset_at = getparam(info,inputpos,tab,depth,"set",functypes,funcmsg)
+ local oldget,oldget_at = getparam(info,inputpos,tab,depth,"get",functypes,funcmsg)
+ local oldfunc,oldfunc_at = getparam(info,inputpos,tab,depth,"func",functypes,funcmsg)
+ local oldvalidate,oldvalidate_at = getparam(info,inputpos,tab,depth,"validate",functypes,funcmsg)
+ --local oldconfirm,oldconfirm_at = getparam(info,inputpos,tab,depth,"confirm",functypes,funcmsg)
+
+ -------------------------------------------------------------------
+ -- Act according to .type of this table
+
+ if tab.type=="group" then
+ ------------ group --------------------------------------------
+
+ if type(tab.args)~="table" then err(info, inputpos) end
+ if tab.plugins and type(tab.plugins)~="table" then err(info,inputpos) end
+
+ -- grab next arg from input
+ local _,nextpos,arg = (info.input):find(" *([^ ]+) *", inputpos)
+ if not arg then
+ showhelp(info, inputpos, tab, depth)
+ return
+ end
+ nextpos=nextpos+1
+
+ -- loop .args and try to find a key with a matching name
+ for k,v in iterateargs(tab) do
+ if not(type(k)=="string" and type(v)=="table" and type(v.type)=="string") then err(info,inputpos, "options table child '"..tostring(k).."' is malformed") end
+
+ -- is this child an inline group? if so, traverse into it
+ if v.type=="group" and pickfirstset(v.cmdInline, v.inline, false) then
+ info[depth+1] = k
+ if handle(info, inputpos, v, depth+1, true)==false then
+ info[depth+1] = nil
+ -- wasn't found in there, but that's ok, we just keep looking down here
+ else
+ return -- done, name was found in inline group
+ end
+ -- matching name and not a inline group
+ elseif strlower(arg)==strlower(k:gsub(" ", "_")) then
+ info[depth+1] = k
+ return handle(info,nextpos,v,depth+1)
+ end
+ end
+
+ -- no match
+ if retfalse then
+ -- restore old infotable members and return false to indicate failure
+ info.handler,info.handler_at = oldhandler,oldhandler_at
+ info.set,info.set_at = oldset,oldset_at
+ info.get,info.get_at = oldget,oldget_at
+ info.func,info.func_at = oldfunc,oldfunc_at
+ info.validate,info.validate_at = oldvalidate,oldvalidate_at
+ --info.confirm,info.confirm_at = oldconfirm,oldconfirm_at
+ return false
+ end
+
+ -- couldn't find the command, display error
+ usererr(info, inputpos, "'"..arg.."' - " .. L["unknown argument"])
+ return
+ end
+
+ local strInput = strsub(info.input,inputpos);
+
+ if tab.type=="execute" then
+ ------------ execute --------------------------------------------
+ do_final(info, inputpos, tab, "func")
+
+
+
+ elseif tab.type=="input" then
+ ------------ input --------------------------------------------
+
+ local res = true
+ if tab.pattern then
+ if type(tab.pattern)~="string" then err(info, inputpos, "'pattern' - expected a string") end
+ if not strmatch(strInput, tab.pattern) then
+ usererr(info, inputpos, "'"..strInput.."' - " .. L["invalid input"])
+ return
+ end
+ end
+
+ do_final(info, inputpos, tab, "set", strInput)
+
+
+
+ elseif tab.type=="toggle" then
+ ------------ toggle --------------------------------------------
+ local b
+ local str = strtrim(strlower(strInput))
+ if str=="" then
+ b = callmethod(info, inputpos, tab, "get")
+
+ if tab.tristate then
+ --cycle in true, nil, false order
+ if b then
+ b = nil
+ elseif b == nil then
+ b = false
+ else
+ b = true
+ end
+ else
+ b = not b
+ end
+
+ elseif str==L["on"] then
+ b = true
+ elseif str==L["off"] then
+ b = false
+ elseif tab.tristate and str==L["default"] then
+ b = nil
+ else
+ if tab.tristate then
+ usererr(info, inputpos, format(L["'%s' - expected 'on', 'off' or 'default', or no argument to toggle."], str))
+ else
+ usererr(info, inputpos, format(L["'%s' - expected 'on' or 'off', or no argument to toggle."], str))
+ end
+ return
+ end
+
+ do_final(info, inputpos, tab, "set", b)
+
+
+ elseif tab.type=="range" then
+ ------------ range --------------------------------------------
+ local val = tonumber(strInput)
+ if not val then
+ usererr(info, inputpos, "'"..strInput.."' - "..L["expected number"])
+ return
+ end
+ if type(info.step)=="number" then
+ val = val- (val % info.step)
+ end
+ if type(info.min)=="number" and valinfo.max then
+ usererr(info, inputpos, val.." - "..format(L["must be equal to or lower than %s"], tostring(info.max)) )
+ return
+ end
+
+ do_final(info, inputpos, tab, "set", val)
+
+
+ elseif tab.type=="select" then
+ ------------ select ------------------------------------
+ local str = strtrim(strlower(strInput))
+
+ local values = tab.values
+ if type(values) == "function" or type(values) == "string" then
+ info.values = values
+ values = callmethod(info, inputpos, tab, "values")
+ info.values = nil
+ end
+
+ if str == "" then
+ local b = callmethod(info, inputpos, tab, "get")
+ local fmt = "|cffffff78- [%s]|r %s"
+ local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
+ print(L["Options for |cffffff78"..info[#info].."|r:"])
+ for k, v in pairs(values) do
+ if b == k then
+ print(fmt_sel:format(k, v))
+ else
+ print(fmt:format(k, v))
+ end
+ end
+ return
+ end
+
+ local ok
+ for k,v in pairs(values) do
+ if strlower(k)==str then
+ str = k -- overwrite with key (in case of case mismatches)
+ ok = true
+ break
+ end
+ end
+ if not ok then
+ usererr(info, inputpos, "'"..str.."' - "..L["unknown selection"])
+ return
+ end
+
+ do_final(info, inputpos, tab, "set", str)
+
+ elseif tab.type=="multiselect" then
+ ------------ multiselect -------------------------------------------
+ local str = strtrim(strlower(strInput))
+
+ local values = tab.values
+ if type(values) == "function" or type(values) == "string" then
+ info.values = values
+ values = callmethod(info, inputpos, tab, "values")
+ info.values = nil
+ end
+
+ if str == "" then
+ local fmt = "|cffffff78- [%s]|r %s"
+ local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
+ print(L["Options for |cffffff78"..info[#info].."|r (multiple possible):"])
+ for k, v in pairs(values) do
+ if callmethod(info, inputpos, tab, "get", k) then
+ print(fmt_sel:format(k, v))
+ else
+ print(fmt:format(k, v))
+ end
+ end
+ return
+ end
+
+ --build a table of the selections, checking that they exist
+ --parse for =on =off =default in the process
+ --table will be key = true for options that should toggle, key = [on|off|default] for options to be set
+ local sels = {}
+ for v in str:gmatch("[^ ]+") do
+ --parse option=on etc
+ local opt, val = v:match('(.+)=(.+)')
+ --get option if toggling
+ if not opt then
+ opt = v
+ end
+
+ --check that the opt is valid
+ local ok
+ for k in pairs(values) do
+ if strlower(k)==opt then
+ opt = k -- overwrite with key (in case of case mismatches)
+ ok = true
+ break
+ end
+ end
+
+ if not ok then
+ usererr(info, inputpos, "'"..opt.."' - "..L["unknown selection"])
+ return
+ end
+
+ --check that if val was supplied it is valid
+ if val then
+ if val == L["on"] or val == L["off"] or (tab.tristate and val == L["default"]) then
+ --val is valid insert it
+ sels[opt] = val
+ else
+ if tab.tristate then
+ usererr(info, inputpos, format(L["'%s' '%s' - expected 'on', 'off' or 'default', or no argument to toggle."], v, val))
+ else
+ usererr(info, inputpos, format(L["'%s' '%s' - expected 'on' or 'off', or no argument to toggle."], v, val))
+ end
+ return
+ end
+ else
+ -- no val supplied, toggle
+ sels[opt] = true
+ end
+ end
+
+ for opt, val in pairs(sels) do
+ local newval
+
+ if (val == true) then
+ --toggle the option
+ local b = callmethod(info, inputpos, tab, "get", opt)
+
+ if tab.tristate then
+ --cycle in true, nil, false order
+ if b then
+ b = nil
+ elseif b == nil then
+ b = false
+ else
+ b = true
+ end
+ else
+ b = not b
+ end
+ newval = b
+ else
+ --set the option as specified
+ if val==L["on"] then
+ newval = true
+ elseif val==L["off"] then
+ newval = false
+ elseif val==L["default"] then
+ newval = nil
+ end
+ end
+
+ do_final(info, inputpos, tab, "set", opt, newval)
+ end
+
+
+ elseif tab.type=="color" then
+ ------------ color --------------------------------------------
+ local str = strtrim(strlower(strInput))
+ if str == "" then
+ --TODO: Show current value
+ return
+ end
+
+ local r, g, b, a
+
+ local hasAlpha = tab.hasAlpha
+ if type(hasAlpha) == "function" or type(hasAlpha) == "string" then
+ info.hasAlpha = hasAlpha
+ hasAlpha = callmethod(info, inputpos, tab, 'hasAlpha')
+ info.hasAlpha = nil
+ end
+
+ if hasAlpha then
+ if str:len() == 8 and str:find("^%x*$") then
+ --parse a hex string
+ r,g,b,a = tonumber(str:sub(1, 2), 16) / 255, tonumber(str:sub(3, 4), 16) / 255, tonumber(str:sub(5, 6), 16) / 255, tonumber(str:sub(7, 8), 16) / 255
+ else
+ --parse seperate values
+ r,g,b,a = str:match("^([%d%.]+) ([%d%.]+) ([%d%.]+) ([%d%.]+)$")
+ r,g,b,a = tonumber(r), tonumber(g), tonumber(b), tonumber(a)
+ end
+ if not (r and g and b and a) then
+ usererr(info, inputpos, format(L["'%s' - expected 'RRGGBBAA' or 'r g b a'."], str))
+ return
+ end
+
+ if r >= 0.0 and r <= 1.0 and g >= 0.0 and g <= 1.0 and b >= 0.0 and b <= 1.0 and a >= 0.0 and a <= 1.0 then
+ --values are valid
+ elseif r >= 0 and r <= 255 and g >= 0 and g <= 255 and b >= 0 and b <= 255 and a >= 0 and a <= 255 then
+ --values are valid 0..255, convert to 0..1
+ r = r / 255
+ g = g / 255
+ b = b / 255
+ a = a / 255
+ else
+ --values are invalid
+ usererr(info, inputpos, format(L["'%s' - values must all be either in the range 0..1 or 0..255."], str))
+ end
+ else
+ a = 1.0
+ if str:len() == 6 and str:find("^%x*$") then
+ --parse a hex string
+ r,g,b = tonumber(str:sub(1, 2), 16) / 255, tonumber(str:sub(3, 4), 16) / 255, tonumber(str:sub(5, 6), 16) / 255
+ else
+ --parse seperate values
+ r,g,b = str:match("^([%d%.]+) ([%d%.]+) ([%d%.]+)$")
+ r,g,b = tonumber(r), tonumber(g), tonumber(b)
+ end
+ if not (r and g and b) then
+ usererr(info, inputpos, format(L["'%s' - expected 'RRGGBB' or 'r g b'."], str))
+ return
+ end
+ if r >= 0.0 and r <= 1.0 and g >= 0.0 and g <= 1.0 and b >= 0.0 and b <= 1.0 then
+ --values are valid
+ elseif r >= 0 and r <= 255 and g >= 0 and g <= 255 and b >= 0 and b <= 255 then
+ --values are valid 0..255, convert to 0..1
+ r = r / 255
+ g = g / 255
+ b = b / 255
+ else
+ --values are invalid
+ usererr(info, inputpos, format(L["'%s' - values must all be either in the range 0-1 or 0-255."], str))
+ end
+ end
+
+ do_final(info, inputpos, tab, "set", r,g,b,a)
+
+ elseif tab.type=="keybinding" then
+ ------------ keybinding --------------------------------------------
+ local str = strtrim(strlower(strInput))
+ if str == "" then
+ --TODO: Show current value
+ return
+ end
+ local value = keybindingValidateFunc(str:upper())
+ if value == false then
+ usererr(info, inputpos, format(L["'%s' - Invalid Keybinding."], str))
+ return
+ end
+
+ do_final(info, inputpos, tab, "set", value)
+
+ elseif tab.type=="description" then
+ ------------ description --------------------
+ -- ignore description, GUI config only
+ else
+ err(info, inputpos, "unknown options table item type '"..tostring(tab.type).."'")
+ end
+end
+
+--- Handle the chat command.
+-- This is usually called from a chat command handler to parse the command input as operations on an aceoptions table.\\
+-- AceConfigCmd uses this function internally when a slash command is registered with `:CreateChatCommand`
+-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param input The commandline input (as given by the WoW handler, i.e. without the command itself)
+-- @usage
+-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceConsole-3.0")
+-- -- Use AceConsole-3.0 to register a Chat Command
+-- MyAddon:RegisterChatCommand("mychat", "ChatCommand")
+--
+-- -- Show the GUI if no input is supplied, otherwise handle the chat input.
+-- function MyAddon:ChatCommand(input)
+-- -- Assuming "MyOptions" is the appName of a valid options table
+-- if not input or input:trim() == "" then
+-- LibStub("AceConfigDialog-3.0"):Open("MyOptions")
+-- else
+-- LibStub("AceConfigCmd-3.0").HandleCommand(MyAddon, "mychat", "MyOptions", input)
+-- end
+-- end
+function AceConfigCmd:HandleCommand(slashcmd, appName, input)
+
+ local optgetter = cfgreg:GetOptionsTable(appName)
+ if not optgetter then
+ error([[Usage: HandleCommand("slashcmd", "appName", "input"): 'appName' - no options table "]]..tostring(appName)..[[" has been registered]], 2)
+ end
+ local options = assert( optgetter("cmd", MAJOR) )
+
+ local info = { -- Don't try to recycle this, it gets handed off to callbacks and whatnot
+ [0] = slashcmd,
+ appName = appName,
+ options = options,
+ input = input,
+ self = self,
+ handler = self,
+ uiType = "cmd",
+ uiName = MAJOR,
+ }
+
+ handle(info, 1, options, 0) -- (info, inputpos, table, depth)
+end
+
+--- Utility function to create a slash command handler.
+-- Also registers tab completion with AceTab
+-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+function AceConfigCmd:CreateChatCommand(slashcmd, appName)
+ if not AceConsole then
+ AceConsole = LibStub(AceConsoleName)
+ end
+ if AceConsole.RegisterChatCommand(self, slashcmd, function(input)
+ AceConfigCmd.HandleCommand(self, slashcmd, appName, input) -- upgradable
+ end,
+ true) then -- succesfully registered so lets get the command -> app table in
+ commands[slashcmd] = appName
+ end
+end
+
+--- Utility function that returns the options table that belongs to a slashcommand.
+-- Designed to be used for the AceTab interface.
+-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
+-- @return The options table associated with the slash command (or nil if the slash command was not registered)
+function AceConfigCmd:GetChatCommandOptions(slashcmd)
+ return commands[slashcmd]
+end
diff --git a/Broker2FuBar/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.xml b/Broker2FuBar/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.xml
new file mode 100644
index 0000000..c8caf34
--- /dev/null
+++ b/Broker2FuBar/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/Broker2FuBar/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua b/Broker2FuBar/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua
new file mode 100644
index 0000000..146bb7c
--- /dev/null
+++ b/Broker2FuBar/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua
@@ -0,0 +1,2028 @@
+--- 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 1296 2022-11-04 18:50:10Z nevcairiel $
+
+local LibStub = LibStub
+local gui = LibStub("AceGUI-3.0")
+local reg = LibStub("AceConfigRegistry-3.0")
+
+local MAJOR, MINOR = "AceConfigDialog-3.0", 86
+local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceConfigDialog then return end
+
+AceConfigDialog.OpenFrames = AceConfigDialog.OpenFrames or {}
+AceConfigDialog.Status = AceConfigDialog.Status or {}
+AceConfigDialog.frame = AceConfigDialog.frame or CreateFrame("Frame")
+AceConfigDialog.tooltip = AceConfigDialog.tooltip or CreateFrame("GameTooltip", "AceConfigDialogTooltip", UIParent, "GameTooltipTemplate")
+
+AceConfigDialog.frame.apps = AceConfigDialog.frame.apps or {}
+AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {}
+AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {}
+
+-- Lua APIs
+local tinsert, tsort, tremove, wipe = table.insert, table.sort, table.remove, table.wipe
+local strmatch, format = string.match, string.format
+local error = error
+local pairs, next, select, type, unpack, ipairs = pairs, next, select, type, unpack, ipairs
+local tostring, tonumber = tostring, tonumber
+local math_min, math_max, math_floor = math.min, math.max, math.floor
+
+local emptyTbl = {}
+
+--[[
+ xpcall safecall implementation
+]]
+local xpcall = xpcall
+
+local function errorhandler(err)
+ return geterrorhandler()(err)
+end
+
+local function safecall(func, ...)
+ if func then
+ return xpcall(func, errorhandler, ...)
+ end
+end
+
+local width_multiplier = 170
+
+--[[
+Group Types
+ Tree - All Descendant Groups will all become nodes on the tree, direct child options will appear above the tree
+ - Descendant Groups with inline=true and thier children will not become nodes
+
+ Tab - Direct Child Groups will become tabs, direct child options will appear above the tab control
+ - Grandchild groups will default to inline unless specified otherwise
+
+ Select- Same as Tab but with entries in a dropdown rather than tabs
+
+
+ Inline Groups
+ - Will not become nodes of a select group, they will be effectivly part of thier parent group seperated by a border
+ - If declared on a direct child of a root node of a select group, they will appear above the group container control
+ - When a group is displayed inline, all descendants will also be inline members of the group
+
+]]
+
+-- Recycling functions
+local new, del, copy
+--newcount, delcount,createdcount,cached = 0,0,0
+do
+ local pool = setmetatable({},{__mode="k"})
+ function new()
+ --newcount = newcount + 1
+ local t = next(pool)
+ if t then
+ pool[t] = nil
+ return t
+ else
+ --createdcount = createdcount + 1
+ return {}
+ end
+ end
+ function copy(t)
+ local c = new()
+ for k, v in pairs(t) do
+ c[k] = v
+ end
+ return c
+ end
+ function del(t)
+ --delcount = delcount + 1
+ wipe(t)
+ pool[t] = true
+ end
+-- function cached()
+-- local n = 0
+-- for k in pairs(pool) do
+-- n = n + 1
+-- end
+-- return n
+-- end
+end
+
+-- picks the first non-nil value and returns it
+local function pickfirstset(...)
+ for i=1,select("#",...) do
+ if select(i,...)~=nil then
+ return select(i,...)
+ end
+ end
+end
+
+--gets an option from a given group, checking plugins
+local function GetSubOption(group, key)
+ if group.plugins then
+ for plugin, t in pairs(group.plugins) do
+ if t[key] then
+ return t[key]
+ end
+ end
+ end
+
+ return group.args[key]
+end
+
+--Option member type definitions, used to decide how to access it
+
+--Is the member Inherited from parent options
+local isInherited = {
+ set = true,
+ get = true,
+ func = true,
+ confirm = true,
+ validate = true,
+ disabled = true,
+ hidden = true
+}
+
+--Does a string type mean a literal value, instead of the default of a method of the handler
+local stringIsLiteral = {
+ name = true,
+ desc = true,
+ icon = true,
+ usage = true,
+ width = true,
+ image = true,
+ fontSize = true,
+ tooltipHyperlink = true
+}
+
+--Is Never a function or method
+local allIsLiteral = {
+ type = true,
+ descStyle = true,
+ imageWidth = true,
+ imageHeight = true,
+}
+
+--gets the value for a member that could be a function
+--function refs are called with an info arg
+--every other type is returned
+local function GetOptionsMemberValue(membername, option, options, path, appName, ...)
+ --get definition for the member
+ local inherits = isInherited[membername]
+
+
+ --get the member of the option, traversing the tree if it can be inherited
+ local member
+
+ if inherits then
+ local group = options
+ if group[membername] ~= nil then
+ member = group[membername]
+ end
+ for i = 1, #path do
+ group = GetSubOption(group, path[i])
+ if group[membername] ~= nil then
+ member = group[membername]
+ end
+ end
+ else
+ member = option[membername]
+ end
+
+ --check if we need to call a functon, or if we have a literal value
+ if ( not allIsLiteral[membername] ) and ( type(member) == "function" or ((not stringIsLiteral[membername]) and type(member) == "string") ) then
+ --We have a function to call
+ local info = new()
+ --traverse the options table, picking up the handler and filling the info with the path
+ local group = options
+ local handler = group.handler
+
+ for i = 1, #path do
+ group = GetSubOption(group, path[i])
+ info[i] = path[i]
+ handler = group.handler or handler
+ end
+
+ info.options = options
+ info.appName = appName
+ info[0] = appName
+ info.arg = option.arg
+ info.handler = handler
+ info.option = option
+ info.type = option.type
+ info.uiType = "dialog"
+ info.uiName = MAJOR
+
+ local a, b, c ,d
+ --using 4 returns for the get of a color type, increase if a type needs more
+ if type(member) == "function" then
+ --Call the function
+ a,b,c,d = member(info, ...)
+ else
+ --Call the method
+ if handler and handler[member] then
+ a,b,c,d = handler[member](handler, info, ...)
+ else
+ error(format("Method %s doesn't exist in handler for type %s", member, membername))
+ end
+ end
+ del(info)
+ return a,b,c,d
+ else
+ --The value isnt a function to call, return it
+ return member
+ end
+end
+
+--[[calls an options function that could be inherited, method name or function ref
+local function CallOptionsFunction(funcname ,option, options, path, appName, ...)
+ local info = new()
+
+ local func
+ local group = options
+ local handler
+
+ --build the info table containing the path
+ -- pick up functions while traversing the tree
+ if group[funcname] ~= nil then
+ func = group[funcname]
+ end
+ handler = group.handler or handler
+
+ for i, v in ipairs(path) do
+ group = GetSubOption(group, v)
+ info[i] = v
+ if group[funcname] ~= nil then
+ func = group[funcname]
+ end
+ handler = group.handler or handler
+ end
+
+ info.options = options
+ info[0] = appName
+ info.arg = option.arg
+
+ local a, b, c ,d
+ if type(func) == "string" then
+ if handler and handler[func] then
+ a,b,c,d = handler[func](handler, info, ...)
+ else
+ error(string.format("Method %s doesn't exist in handler for type func", func))
+ end
+ elseif type(func) == "function" then
+ a,b,c,d = func(info, ...)
+ end
+ del(info)
+ return a,b,c,d
+end
+--]]
+
+--tables to hold orders and names for options being sorted, will be created with new()
+--prevents needing to call functions repeatedly while sorting
+local tempOrders
+local tempNames
+
+local function compareOptions(a,b)
+ if not a then
+ return true
+ end
+ if not b then
+ return false
+ end
+ local OrderA, OrderB = tempOrders[a] or 100, tempOrders[b] or 100
+ if OrderA == OrderB then
+ local NameA = (type(tempNames[a]) == "string") and tempNames[a] or ""
+ local NameB = (type(tempNames[b]) == "string") and tempNames[b] or ""
+ return NameA:upper() < NameB:upper()
+ end
+ if OrderA < 0 then
+ if OrderB >= 0 then
+ return false
+ end
+ else
+ if OrderB < 0 then
+ return true
+ end
+ end
+ return OrderA < OrderB
+end
+
+
+
+--builds 2 tables out of an options group
+-- keySort, sorted keys
+-- opts, combined options from .plugins and args
+local function BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+ tempOrders = new()
+ tempNames = new()
+
+ if group.plugins then
+ for plugin, t in pairs(group.plugins) do
+ for k, v in pairs(t) do
+ if not opts[k] then
+ tinsert(keySort, k)
+ opts[k] = v
+
+ path[#path+1] = k
+ tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName)
+ tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName)
+ path[#path] = nil
+ end
+ end
+ end
+ end
+
+ for k, v in pairs(group.args) do
+ if not opts[k] then
+ tinsert(keySort, k)
+ opts[k] = v
+
+ path[#path+1] = k
+ tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName)
+ tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName)
+ path[#path] = nil
+ end
+ end
+
+ tsort(keySort, compareOptions)
+
+ del(tempOrders)
+ del(tempNames)
+end
+
+local function DelTree(tree)
+ if tree.children then
+ local childs = tree.children
+ for i = 1, #childs do
+ DelTree(childs[i])
+ del(childs[i])
+ end
+ del(childs)
+ end
+end
+
+local function CleanUserData(widget, event)
+
+ local user = widget:GetUserDataTable()
+
+ if user.path then
+ del(user.path)
+ end
+
+ if widget.type == "TreeGroup" then
+ local tree = user.tree
+ widget:SetTree(nil)
+ if tree then
+ for i = 1, #tree do
+ DelTree(tree[i])
+ del(tree[i])
+ end
+ del(tree)
+ end
+ end
+
+ if widget.type == "TabGroup" then
+ widget:SetTabs(nil)
+ if user.tablist then
+ del(user.tablist)
+ end
+ end
+
+ if widget.type == "DropdownGroup" then
+ widget:SetGroupList(nil)
+ if user.grouplist then
+ del(user.grouplist)
+ end
+ if user.orderlist then
+ del(user.orderlist)
+ end
+ end
+end
+
+-- - Gets a status table for the given appname and options path.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param path The path to the options (a table with all group keys)
+-- @return
+function AceConfigDialog:GetStatusTable(appName, path)
+ local status = self.Status
+
+ if not status[appName] then
+ status[appName] = {}
+ status[appName].status = {}
+ status[appName].children = {}
+ end
+
+ status = status[appName]
+
+ if path then
+ for i = 1, #path do
+ local v = path[i]
+ if not status.children[v] then
+ status.children[v] = {}
+ status.children[v].status = {}
+ status.children[v].children = {}
+ end
+ status = status.children[v]
+ end
+ end
+
+ return status.status
+end
+
+--- Selects the specified path in the options window.
+-- The path specified has to match the keys of the groups in the table.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param ... The path to the key that should be selected
+function AceConfigDialog:SelectGroup(appName, ...)
+ local path = new()
+
+
+ local app = reg:GetOptionsTable(appName)
+ if not app then
+ error(("%s isn't registed with AceConfigRegistry, unable to open config"):format(appName), 2)
+ end
+ local options = app("dialog", MAJOR)
+ local group = options
+ local status = self:GetStatusTable(appName, path)
+ if not status.groups then
+ status.groups = {}
+ end
+ status = status.groups
+ local treevalue
+ local treestatus
+
+ for n = 1, select("#",...) do
+ local key = select(n, ...)
+
+ if group.childGroups == "tab" or group.childGroups == "select" then
+ --if this is a tab or select group, select the group
+ status.selected = key
+ --children of this group are no longer extra levels of a tree
+ treevalue = nil
+ else
+ --tree group by default
+ if treevalue then
+ --this is an extra level of a tree group, build a uniquevalue for it
+ treevalue = treevalue.."\001"..key
+ else
+ --this is the top level of a tree group, the uniquevalue is the same as the key
+ treevalue = key
+ if not status.groups then
+ status.groups = {}
+ end
+ --save this trees status table for any extra levels or groups
+ treestatus = status
+ end
+ --make sure that the tree entry is open, and select it.
+ --the selected group will be overwritten if a child is the final target but still needs to be open
+ treestatus.selected = treevalue
+ treestatus.groups[treevalue] = true
+
+ end
+
+ --move to the next group in the path
+ group = GetSubOption(group, key)
+ if not group then
+ break
+ end
+ tinsert(path, key)
+ status = self:GetStatusTable(appName, path)
+ if not status.groups then
+ status.groups = {}
+ end
+ status = status.groups
+ end
+
+ del(path)
+ reg:NotifyChange(appName)
+end
+
+local function OptionOnMouseOver(widget, event)
+ --show a tooltip/set the status bar to the desc text
+ local user = widget:GetUserDataTable()
+ local opt = user.option
+ local options = user.options
+ local path = user.path
+ local appName = user.appName
+ local tooltip = AceConfigDialog.tooltip
+
+ tooltip:SetOwner(widget.frame, "ANCHOR_TOPRIGHT")
+
+ local tooltipHyperlink = GetOptionsMemberValue("tooltipHyperlink", opt, options, path, appName)
+ if tooltipHyperlink then
+ tooltip:SetHyperlink(tooltipHyperlink)
+ tooltip:Show()
+ return
+ end
+
+ local name = GetOptionsMemberValue("name", opt, options, path, appName)
+ local desc = GetOptionsMemberValue("desc", opt, options, path, appName)
+ local usage = GetOptionsMemberValue("usage", opt, options, path, appName)
+ local descStyle = opt.descStyle
+
+ if descStyle and descStyle ~= "tooltip" then return end
+
+ tooltip:SetText(name, 1, .82, 0, true)
+
+ if opt.type == "multiselect" then
+ tooltip:AddLine(user.text, 0.5, 0.5, 0.8, true)
+ end
+ if type(desc) == "string" then
+ tooltip:AddLine(desc, 1, 1, 1, true)
+ end
+ if type(usage) == "string" then
+ tooltip:AddLine("Usage: "..usage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, true)
+ end
+
+ tooltip:Show()
+end
+
+local function OptionOnMouseLeave(widget, event)
+ AceConfigDialog.tooltip:Hide()
+end
+
+local function GetFuncName(option)
+ if option.type == "execute" then
+ return "func"
+ else
+ return "set"
+ end
+end
+do
+ local frame = AceConfigDialog.popup
+ if not frame or oldminor < 81 then
+ frame = CreateFrame("Frame", nil, UIParent)
+ AceConfigDialog.popup = frame
+ frame:Hide()
+ frame:SetPoint("CENTER", UIParent, "CENTER")
+ frame:SetSize(320, 72)
+ frame:EnableMouse(true) -- Do not allow click-through on the frame
+ frame:SetFrameStrata("TOOLTIP")
+ frame:SetFrameLevel(100) -- Lots of room to draw under it
+ frame:SetScript("OnKeyDown", function(self, key)
+ if key == "ESCAPE" then
+ self:SetPropagateKeyboardInput(false)
+ if self.cancel:IsShown() then
+ self.cancel:Click()
+ else -- Showing a validation error
+ self:Hide()
+ end
+ else
+ self:SetPropagateKeyboardInput(true)
+ end
+ end)
+
+ local border = CreateFrame("Frame", nil, frame, "DialogBorderOpaqueTemplate")
+ border:SetAllPoints(frame)
+ frame:SetFixedFrameStrata(true)
+ frame:SetFixedFrameLevel(true)
+
+ local text = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
+ text:SetSize(290, 0)
+ text:SetPoint("TOP", 0, -16)
+ frame.text = text
+
+ local function newButton(newText)
+ local button = CreateFrame("Button", nil, frame)
+ button:SetSize(128, 21)
+ button:SetNormalFontObject(GameFontNormal)
+ button:SetHighlightFontObject(GameFontHighlight)
+ button:SetNormalTexture(130763) -- "Interface\\Buttons\\UI-DialogBox-Button-Up"
+ button:GetNormalTexture():SetTexCoord(0.0, 1.0, 0.0, 0.71875)
+ button:SetPushedTexture(130761) -- "Interface\\Buttons\\UI-DialogBox-Button-Down"
+ button:GetPushedTexture():SetTexCoord(0.0, 1.0, 0.0, 0.71875)
+ button:SetHighlightTexture(130762) -- "Interface\\Buttons\\UI-DialogBox-Button-Highlight"
+ button:GetHighlightTexture():SetTexCoord(0.0, 1.0, 0.0, 0.71875)
+ button:SetText(newText)
+ return button
+ end
+
+ local accept = newButton(ACCEPT)
+ accept:SetPoint("BOTTOMRIGHT", frame, "BOTTOM", -6, 16)
+ frame.accept = accept
+
+ local cancel = newButton(CANCEL)
+ cancel:SetPoint("LEFT", accept, "RIGHT", 13, 0)
+ frame.cancel = cancel
+ end
+end
+local function confirmPopup(appName, rootframe, basepath, info, message, func, ...)
+ local frame = AceConfigDialog.popup
+ frame:Show()
+ frame.text:SetText(message)
+ -- From StaticPopup.lua
+ -- local height = 32 + text:GetHeight() + 2;
+ -- height = height + 6 + accept:GetHeight()
+ -- We add 32 + 2 + 6 + 21 (button height) == 61
+ local height = 61 + frame.text:GetHeight()
+ frame:SetHeight(height)
+
+ frame.accept:ClearAllPoints()
+ frame.accept:SetPoint("BOTTOMRIGHT", frame, "BOTTOM", -6, 16)
+ frame.cancel:Show()
+
+ local t = {...}
+ local tCount = select("#", ...)
+ frame.accept:SetScript("OnClick", function(self)
+ safecall(func, unpack(t, 1, tCount)) -- Manually set count as unpack() stops on nil (bug with #table)
+ AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl))
+ frame:Hide()
+ self:SetScript("OnClick", nil)
+ frame.cancel:SetScript("OnClick", nil)
+ del(info)
+ end)
+ frame.cancel:SetScript("OnClick", function(self)
+ AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl))
+ frame:Hide()
+ self:SetScript("OnClick", nil)
+ frame.accept:SetScript("OnClick", nil)
+ del(info)
+ end)
+end
+
+local function validationErrorPopup(message)
+ local frame = AceConfigDialog.popup
+ frame:Show()
+ frame.text:SetText(message)
+ -- From StaticPopup.lua
+ -- local height = 32 + text:GetHeight() + 2;
+ -- height = height + 6 + accept:GetHeight()
+ -- We add 32 + 2 + 6 + 21 (button height) == 61
+ local height = 61 + frame.text:GetHeight()
+ frame:SetHeight(height)
+
+ frame.accept:ClearAllPoints()
+ frame.accept:SetPoint("BOTTOM", frame, "BOTTOM", 0, 16)
+ frame.cancel:Hide()
+
+ frame.accept:SetScript("OnClick", function()
+ frame:Hide()
+ end)
+end
+
+local function ActivateControl(widget, event, ...)
+ --This function will call the set / execute handler for the widget
+ --widget:GetUserDataTable() contains the needed info
+ local user = widget:GetUserDataTable()
+ local option = user.option
+ local options = user.options
+ local path = user.path
+ local info = new()
+
+ local func
+ local group = options
+ local funcname = GetFuncName(option)
+ local handler
+ local confirm
+ local validate
+ --build the info table containing the path
+ -- pick up functions while traversing the tree
+ if group[funcname] ~= nil then
+ func = group[funcname]
+ end
+ handler = group.handler
+ confirm = group.confirm
+ validate = group.validate
+ for i = 1, #path do
+ local v = path[i]
+ group = GetSubOption(group, v)
+ info[i] = v
+ if group[funcname] ~= nil then
+ func = group[funcname]
+ end
+ handler = group.handler or handler
+ if group.confirm ~= nil then
+ confirm = group.confirm
+ end
+ if group.validate ~= nil then
+ validate = group.validate
+ end
+ end
+
+ info.options = options
+ info.appName = user.appName
+ info.arg = option.arg
+ info.handler = handler
+ info.option = option
+ info.type = option.type
+ info.uiType = "dialog"
+ info.uiName = MAJOR
+
+ local name
+ if type(option.name) == "function" then
+ name = option.name(info)
+ elseif type(option.name) == "string" then
+ name = option.name
+ else
+ name = ""
+ end
+ local usage = option.usage
+ local pattern = option.pattern
+
+ local validated = true
+
+ if option.type == "input" then
+ if type(pattern)=="string" then
+ if not strmatch(..., pattern) then
+ validated = false
+ end
+ end
+ end
+
+ local success
+ if validated and option.type ~= "execute" then
+ if type(validate) == "string" then
+ if handler and handler[validate] then
+ success, validated = safecall(handler[validate], handler, info, ...)
+ if not success then validated = false end
+ else
+ error(format("Method %s doesn't exist in handler for type execute", validate))
+ end
+ elseif type(validate) == "function" then
+ success, validated = safecall(validate, info, ...)
+ if not success then validated = false end
+ end
+ end
+
+ if not validated or type(validated) == "string" then
+ if not validated then
+ if usage then
+ validated = name..": "..usage
+ else
+ if pattern then
+ validated = name..": Expected "..pattern
+ else
+ validated = name..": Invalid Value"
+ end
+ end
+ end
+
+ -- show validate message
+ if user.rootframe.SetStatusText then
+ user.rootframe:SetStatusText(validated)
+ else
+ validationErrorPopup(validated)
+ end
+ PlaySound(882) -- SOUNDKIT.IG_PLAYER_INVITE_DECLINE || _DECLINE is actually missing from the table
+ del(info)
+ return true
+ else
+
+ local confirmText = option.confirmText
+ --call confirm func/method
+ if type(confirm) == "string" then
+ if handler and handler[confirm] then
+ success, confirm = safecall(handler[confirm], handler, info, ...)
+ if success and type(confirm) == "string" then
+ confirmText = confirm
+ confirm = true
+ elseif not success then
+ confirm = false
+ end
+ else
+ error(format("Method %s doesn't exist in handler for type confirm", confirm))
+ end
+ elseif type(confirm) == "function" then
+ success, confirm = safecall(confirm, info, ...)
+ if success and type(confirm) == "string" then
+ confirmText = confirm
+ confirm = true
+ elseif not success then
+ confirm = false
+ end
+ end
+
+ --confirm if needed
+ if type(confirm) == "boolean" then
+ if confirm then
+ if not confirmText then
+ local option_name, desc = option.name, option.desc
+ if type(option_name) == "function" then
+ option_name = option_name(info)
+ end
+ if type(desc) == "function" then
+ desc = desc(info)
+ end
+ confirmText = option_name
+ if desc then
+ confirmText = confirmText.." - "..desc
+ end
+ end
+
+ local iscustom = user.rootframe:GetUserData("iscustom")
+ local rootframe
+
+ if iscustom then
+ rootframe = user.rootframe
+ end
+ local basepath = user.rootframe:GetUserData("basepath")
+ if type(func) == "string" then
+ if handler and handler[func] then
+ confirmPopup(user.appName, rootframe, basepath, info, confirmText, handler[func], handler, info, ...)
+ else
+ error(format("Method %s doesn't exist in handler for type func", func))
+ end
+ elseif type(func) == "function" then
+ confirmPopup(user.appName, rootframe, basepath, info, confirmText, func, info, ...)
+ end
+ --func will be called and info deleted when the confirm dialog is responded to
+ return
+ end
+ end
+
+ --call the function
+ if type(func) == "string" then
+ if handler and handler[func] then
+ safecall(handler[func],handler, info, ...)
+ else
+ error(format("Method %s doesn't exist in handler for type func", func))
+ end
+ elseif type(func) == "function" then
+ safecall(func,info, ...)
+ end
+
+
+
+ local iscustom = user.rootframe:GetUserData("iscustom")
+ local basepath = user.rootframe:GetUserData("basepath") or emptyTbl
+ --full refresh of the frame, some controls dont cause this on all events
+ if option.type == "color" then
+ if event == "OnValueConfirmed" then
+
+ if iscustom then
+ AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
+ else
+ AceConfigDialog:Open(user.appName, unpack(basepath))
+ end
+ end
+ elseif option.type == "range" then
+ if event == "OnMouseUp" then
+ if iscustom then
+ AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
+ else
+ AceConfigDialog:Open(user.appName, unpack(basepath))
+ end
+ end
+ --multiselects don't cause a refresh on 'OnValueChanged' only 'OnClosed'
+ elseif option.type == "multiselect" then
+ user.valuechanged = true
+ else
+ if iscustom then
+ AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
+ else
+ AceConfigDialog:Open(user.appName, unpack(basepath))
+ end
+ end
+
+ end
+ del(info)
+end
+
+local function ActivateSlider(widget, event, value)
+ local option = widget:GetUserData("option")
+ local min, max, step = option.min or (not option.softMin and 0 or nil), option.max or (not option.softMax and 100 or nil), option.step
+ if min then
+ if step then
+ value = math_floor((value - min) / step + 0.5) * step + min
+ end
+ value = math_max(value, min)
+ end
+ if max then
+ value = math_min(value, max)
+ end
+ ActivateControl(widget,event,value)
+end
+
+--called from a checkbox that is part of an internally created multiselect group
+--this type is safe to refresh on activation of one control
+local function ActivateMultiControl(widget, event, ...)
+ ActivateControl(widget, event, widget:GetUserData("value"), ...)
+ local user = widget:GetUserDataTable()
+ local iscustom = user.rootframe:GetUserData("iscustom")
+ local basepath = user.rootframe:GetUserData("basepath") or emptyTbl
+ if iscustom then
+ AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
+ else
+ AceConfigDialog:Open(user.appName, unpack(basepath))
+ end
+end
+
+local function MultiControlOnClosed(widget, event, ...)
+ local user = widget:GetUserDataTable()
+ if user.valuechanged and not widget:IsReleasing() then
+ local iscustom = user.rootframe:GetUserData("iscustom")
+ local basepath = user.rootframe:GetUserData("basepath") or emptyTbl
+ if iscustom then
+ AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
+ else
+ AceConfigDialog:Open(user.appName, unpack(basepath))
+ end
+ end
+end
+
+local function FrameOnClose(widget, event)
+ local appName = widget:GetUserData("appName")
+ AceConfigDialog.OpenFrames[appName] = nil
+ gui:Release(widget)
+end
+
+local function CheckOptionHidden(option, options, path, appName)
+ --check for a specific boolean option
+ local hidden = pickfirstset(option.dialogHidden,option.guiHidden)
+ if hidden ~= nil then
+ return hidden
+ end
+
+ return GetOptionsMemberValue("hidden", option, options, path, appName)
+end
+
+local function CheckOptionDisabled(option, options, path, appName)
+ --check for a specific boolean option
+ local disabled = pickfirstset(option.dialogDisabled,option.guiDisabled)
+ if disabled ~= nil then
+ return disabled
+ end
+
+ return GetOptionsMemberValue("disabled", option, options, path, appName)
+end
+--[[
+local function BuildTabs(group, options, path, appName)
+ local tabs = new()
+ local text = new()
+ local keySort = new()
+ local opts = new()
+
+ BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+
+ for i = 1, #keySort do
+ local k = keySort[i]
+ local v = opts[k]
+ if v.type == "group" then
+ path[#path+1] = k
+ local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
+ local hidden = CheckOptionHidden(v, options, path, appName)
+ if not inline and not hidden then
+ tinsert(tabs, k)
+ text[k] = GetOptionsMemberValue("name", v, options, path, appName)
+ end
+ path[#path] = nil
+ end
+ end
+
+ del(keySort)
+ del(opts)
+
+ return tabs, text
+end
+]]
+local function BuildSelect(group, options, path, appName)
+ local groups = new()
+ local order = new()
+ local keySort = new()
+ local opts = new()
+
+ BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+
+ for i = 1, #keySort do
+ local k = keySort[i]
+ local v = opts[k]
+ if v.type == "group" then
+ path[#path+1] = k
+ local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
+ local hidden = CheckOptionHidden(v, options, path, appName)
+ if not inline and not hidden then
+ groups[k] = GetOptionsMemberValue("name", v, options, path, appName)
+ tinsert(order, k)
+ end
+ path[#path] = nil
+ end
+ end
+
+ del(opts)
+ del(keySort)
+
+ return groups, order
+end
+
+local function BuildSubGroups(group, tree, options, path, appName)
+ local keySort = new()
+ local opts = new()
+
+ BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+
+ for i = 1, #keySort do
+ local k = keySort[i]
+ local v = opts[k]
+ if v.type == "group" then
+ path[#path+1] = k
+ local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
+ local hidden = CheckOptionHidden(v, options, path, appName)
+ if not inline and not hidden then
+ local entry = new()
+ entry.value = k
+ entry.text = GetOptionsMemberValue("name", v, options, path, appName)
+ entry.icon = GetOptionsMemberValue("icon", v, options, path, appName)
+ entry.iconCoords = GetOptionsMemberValue("iconCoords", v, options, path, appName)
+ entry.disabled = CheckOptionDisabled(v, options, path, appName)
+ if not tree.children then tree.children = new() end
+ tinsert(tree.children,entry)
+ if (v.childGroups or "tree") == "tree" then
+ BuildSubGroups(v,entry, options, path, appName)
+ end
+ end
+ path[#path] = nil
+ end
+ end
+
+ del(keySort)
+ del(opts)
+end
+
+local function BuildGroups(group, options, path, appName, recurse)
+ local tree = new()
+ local keySort = new()
+ local opts = new()
+
+ BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+
+ for i = 1, #keySort do
+ local k = keySort[i]
+ local v = opts[k]
+ if v.type == "group" then
+ path[#path+1] = k
+ local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
+ local hidden = CheckOptionHidden(v, options, path, appName)
+ if not inline and not hidden then
+ local entry = new()
+ entry.value = k
+ entry.text = GetOptionsMemberValue("name", v, options, path, appName)
+ entry.icon = GetOptionsMemberValue("icon", v, options, path, appName)
+ entry.iconCoords = GetOptionsMemberValue("iconCoords", v, options, path, appName)
+ entry.disabled = CheckOptionDisabled(v, options, path, appName)
+ tinsert(tree,entry)
+ if recurse and (v.childGroups or "tree") == "tree" then
+ BuildSubGroups(v,entry, options, path, appName)
+ end
+ end
+ path[#path] = nil
+ end
+ end
+ del(keySort)
+ del(opts)
+ return tree
+end
+
+local function InjectInfo(control, options, option, path, rootframe, appName)
+ local user = control:GetUserDataTable()
+ for i = 1, #path do
+ user[i] = path[i]
+ end
+ user.rootframe = rootframe
+ user.option = option
+ user.options = options
+ user.path = copy(path)
+ user.appName = appName
+ control:SetCallback("OnRelease", CleanUserData)
+ control:SetCallback("OnLeave", OptionOnMouseLeave)
+ control:SetCallback("OnEnter", OptionOnMouseOver)
+end
+
+local function CreateControl(userControlType, fallbackControlType)
+ local control
+ if userControlType then
+ control = gui:Create(userControlType)
+ if not control then
+ geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(userControlType)))
+ end
+ end
+ if not control then
+ control = gui:Create(fallbackControlType)
+ end
+ return control
+end
+
+local function sortTblAsStrings(x,y)
+ return tostring(x) < tostring(y) -- Support numbers as keys
+end
+
+--[[
+ options - root of the options table being fed
+ container - widget that controls will be placed in
+ rootframe - Frame object the options are in
+ path - table with the keys to get to the group being fed
+--]]
+
+local function FeedOptions(appName, options,container,rootframe,path,group,inline)
+ local keySort = new()
+ local opts = new()
+
+ BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
+
+ for i = 1, #keySort do
+ local k = keySort[i]
+ local v = opts[k]
+ tinsert(path, k)
+ local hidden = CheckOptionHidden(v, options, path, appName)
+ local name = GetOptionsMemberValue("name", v, options, path, appName)
+ if not hidden then
+ if v.type == "group" then
+ if inline or pickfirstset(v.dialogInline,v.guiInline,v.inline, false) then
+ --Inline group
+ local GroupContainer
+ if name and name ~= "" then
+ GroupContainer = gui:Create("InlineGroup")
+ GroupContainer:SetTitle(name or "")
+ else
+ GroupContainer = gui:Create("SimpleGroup")
+ end
+
+ GroupContainer.width = "fill"
+ GroupContainer:SetLayout("flow")
+ container:AddChild(GroupContainer)
+ FeedOptions(appName,options,GroupContainer,rootframe,path,v,true)
+ end
+ else
+ --Control to feed
+ local control
+
+ if v.type == "execute" then
+
+ local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName)
+ local image, width, height = GetOptionsMemberValue("image",v, options, path, appName)
+
+ local iconControl = type(image) == "string" or type(image) == "number"
+ control = CreateControl(v.dialogControl or v.control, iconControl and "Icon" or "Button")
+ if iconControl then
+ if not width then
+ width = GetOptionsMemberValue("imageWidth",v, options, path, appName)
+ end
+ if not height then
+ height = GetOptionsMemberValue("imageHeight",v, options, path, appName)
+ end
+ if type(imageCoords) == "table" then
+ control:SetImage(image, unpack(imageCoords))
+ else
+ control:SetImage(image)
+ end
+ if type(width) ~= "number" then
+ width = 32
+ end
+ if type(height) ~= "number" then
+ height = 32
+ end
+ control:SetImageSize(width, height)
+ control:SetLabel(name)
+ else
+ control:SetText(name)
+ end
+ control:SetCallback("OnClick",ActivateControl)
+
+ elseif v.type == "input" then
+ control = CreateControl(v.dialogControl or v.control, v.multiline and "MultiLineEditBox" or "EditBox")
+
+ if v.multiline and control.SetNumLines then
+ control:SetNumLines(tonumber(v.multiline) or 4)
+ end
+ control:SetLabel(name)
+ control:SetCallback("OnEnterPressed",ActivateControl)
+ local text = GetOptionsMemberValue("get",v, options, path, appName)
+ if type(text) ~= "string" then
+ text = ""
+ end
+ control:SetText(text)
+
+ elseif v.type == "toggle" then
+ control = CreateControl(v.dialogControl or v.control, "CheckBox")
+ control:SetLabel(name)
+ control:SetTriState(v.tristate)
+ local value = GetOptionsMemberValue("get",v, options, path, appName)
+ control:SetValue(value)
+ control:SetCallback("OnValueChanged",ActivateControl)
+
+ if v.descStyle == "inline" then
+ local desc = GetOptionsMemberValue("desc", v, options, path, appName)
+ control:SetDescription(desc)
+ end
+
+ local image = GetOptionsMemberValue("image", v, options, path, appName)
+ local imageCoords = GetOptionsMemberValue("imageCoords", v, options, path, appName)
+
+ if type(image) == "string" or type(image) == "number" then
+ if type(imageCoords) == "table" then
+ control:SetImage(image, unpack(imageCoords))
+ else
+ control:SetImage(image)
+ end
+ end
+ elseif v.type == "range" then
+ control = CreateControl(v.dialogControl or v.control, "Slider")
+ control:SetLabel(name)
+ control:SetSliderValues(v.softMin or v.min or 0, v.softMax or v.max or 100, v.bigStep or v.step or 0)
+ control:SetIsPercent(v.isPercent)
+ local value = GetOptionsMemberValue("get",v, options, path, appName)
+ if type(value) ~= "number" then
+ value = 0
+ end
+ control:SetValue(value)
+ control:SetCallback("OnValueChanged",ActivateSlider)
+ control:SetCallback("OnMouseUp",ActivateSlider)
+
+ elseif v.type == "select" then
+ local values = GetOptionsMemberValue("values", v, options, path, appName)
+ local sorting = GetOptionsMemberValue("sorting", v, options, path, appName)
+ if v.style == "radio" then
+ local disabled = CheckOptionDisabled(v, options, path, appName)
+ local width = GetOptionsMemberValue("width",v,options,path,appName)
+ control = gui:Create("InlineGroup")
+ control:SetLayout("Flow")
+ control:SetTitle(name)
+ control.width = "fill"
+
+ control:PauseLayout()
+ local optionValue = GetOptionsMemberValue("get",v, options, path, appName)
+ if not sorting then
+ sorting = {}
+ for value, text in pairs(values) do
+ sorting[#sorting+1]=value
+ end
+ tsort(sorting, sortTblAsStrings)
+ end
+ for _, value in ipairs(sorting) do
+ local text = values[value]
+ local radio = gui:Create("CheckBox")
+ radio:SetLabel(text)
+ radio:SetUserData("value", value)
+ radio:SetUserData("text", text)
+ radio:SetDisabled(disabled)
+ radio:SetType("radio")
+ radio:SetValue(optionValue == value)
+ radio:SetCallback("OnValueChanged", ActivateMultiControl)
+ InjectInfo(radio, options, v, path, rootframe, appName)
+ control:AddChild(radio)
+ if width == "double" then
+ radio:SetWidth(width_multiplier * 2)
+ elseif width == "half" then
+ radio:SetWidth(width_multiplier / 2)
+ elseif (type(width) == "number") then
+ radio:SetWidth(width_multiplier * width)
+ elseif width == "full" then
+ radio.width = "fill"
+ else
+ radio:SetWidth(width_multiplier)
+ end
+ end
+ control:ResumeLayout()
+ control:DoLayout()
+ else
+ control = CreateControl(v.dialogControl or v.control, "Dropdown")
+ local itemType = v.itemControl
+ if itemType and not gui:GetWidgetVersion(itemType) then
+ geterrorhandler()(("Invalid Custom Item Type - %s"):format(tostring(itemType)))
+ itemType = nil
+ end
+ control:SetLabel(name)
+ control:SetList(values, sorting, itemType)
+ local value = GetOptionsMemberValue("get",v, options, path, appName)
+ if not values[value] then
+ value = nil
+ end
+ control:SetValue(value)
+ control:SetCallback("OnValueChanged", ActivateControl)
+ end
+
+ elseif v.type == "multiselect" then
+ local values = GetOptionsMemberValue("values", v, options, path, appName)
+ local disabled = CheckOptionDisabled(v, options, path, appName)
+
+ local valuesort = new()
+ if values then
+ for value, text in pairs(values) do
+ tinsert(valuesort, value)
+ end
+ end
+ tsort(valuesort)
+
+ local controlType = v.dialogControl or v.control
+ if controlType then
+ control = gui:Create(controlType)
+ if not control then
+ geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
+ end
+ end
+ if control then
+ control:SetMultiselect(true)
+ control:SetLabel(name)
+ control:SetList(values)
+ control:SetDisabled(disabled)
+ control:SetCallback("OnValueChanged",ActivateControl)
+ control:SetCallback("OnClosed", MultiControlOnClosed)
+ local width = GetOptionsMemberValue("width",v,options,path,appName)
+ if width == "double" then
+ control:SetWidth(width_multiplier * 2)
+ elseif width == "half" then
+ control:SetWidth(width_multiplier / 2)
+ elseif (type(width) == "number") then
+ control:SetWidth(width_multiplier * width)
+ elseif width == "full" then
+ control.width = "fill"
+ else
+ control:SetWidth(width_multiplier)
+ end
+ --check:SetTriState(v.tristate)
+ for s = 1, #valuesort do
+ local key = valuesort[s]
+ local value = GetOptionsMemberValue("get",v, options, path, appName, key)
+ control:SetItemValue(key,value)
+ end
+ else
+ control = gui:Create("InlineGroup")
+ control:SetLayout("Flow")
+ control:SetTitle(name)
+ control.width = "fill"
+
+ control:PauseLayout()
+ local width = GetOptionsMemberValue("width",v,options,path,appName)
+ for s = 1, #valuesort do
+ local value = valuesort[s]
+ local text = values[value]
+ local check = gui:Create("CheckBox")
+ check:SetLabel(text)
+ check:SetUserData("value", value)
+ check:SetUserData("text", text)
+ check:SetDisabled(disabled)
+ check:SetTriState(v.tristate)
+ check:SetValue(GetOptionsMemberValue("get",v, options, path, appName, value))
+ check:SetCallback("OnValueChanged",ActivateMultiControl)
+ InjectInfo(check, options, v, path, rootframe, appName)
+ control:AddChild(check)
+ if width == "double" then
+ check:SetWidth(width_multiplier * 2)
+ elseif width == "half" then
+ check:SetWidth(width_multiplier / 2)
+ elseif (type(width) == "number") then
+ check:SetWidth(width_multiplier * width)
+ elseif width == "full" then
+ check.width = "fill"
+ else
+ check:SetWidth(width_multiplier)
+ end
+ end
+ control:ResumeLayout()
+ control:DoLayout()
+
+
+ end
+
+ del(valuesort)
+
+ elseif v.type == "color" then
+ control = CreateControl(v.dialogControl or v.control, "ColorPicker")
+ control:SetLabel(name)
+ control:SetHasAlpha(GetOptionsMemberValue("hasAlpha",v, options, path, appName))
+ control:SetColor(GetOptionsMemberValue("get",v, options, path, appName))
+ control:SetCallback("OnValueChanged",ActivateControl)
+ control:SetCallback("OnValueConfirmed",ActivateControl)
+
+ elseif v.type == "keybinding" then
+ control = CreateControl(v.dialogControl or v.control, "Keybinding")
+ control:SetLabel(name)
+ control:SetKey(GetOptionsMemberValue("get",v, options, path, appName))
+ control:SetCallback("OnKeyChanged",ActivateControl)
+
+ elseif v.type == "header" then
+ control = CreateControl(v.dialogControl or v.control, "Heading")
+ control:SetText(name)
+ control.width = "fill"
+
+ elseif v.type == "description" then
+ control = CreateControl(v.dialogControl or v.control, "Label")
+ control:SetText(name)
+
+ local fontSize = GetOptionsMemberValue("fontSize",v, options, path, appName)
+ if fontSize == "medium" then
+ control:SetFontObject(GameFontHighlight)
+ elseif fontSize == "large" then
+ control:SetFontObject(GameFontHighlightLarge)
+ else -- small or invalid
+ control:SetFontObject(GameFontHighlightSmall)
+ end
+
+ local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName)
+ local image, width, height = GetOptionsMemberValue("image",v, options, path, appName)
+
+ if type(image) == "string" or type(image) == "number" then
+ if not width then
+ width = GetOptionsMemberValue("imageWidth",v, options, path, appName)
+ end
+ if not height then
+ height = GetOptionsMemberValue("imageHeight",v, options, path, appName)
+ end
+ if type(imageCoords) == "table" then
+ control:SetImage(image, unpack(imageCoords))
+ else
+ control:SetImage(image)
+ end
+ if type(width) ~= "number" then
+ width = 32
+ end
+ if type(height) ~= "number" then
+ height = 32
+ end
+ control:SetImageSize(width, height)
+ end
+ local controlWidth = GetOptionsMemberValue("width",v,options,path,appName)
+ control.width = not controlWidth and "fill"
+ end
+
+ --Common Init
+ if control then
+ if control.width ~= "fill" then
+ local width = GetOptionsMemberValue("width",v,options,path,appName)
+ if width == "double" then
+ control:SetWidth(width_multiplier * 2)
+ elseif width == "half" then
+ control:SetWidth(width_multiplier / 2)
+ elseif (type(width) == "number") then
+ control:SetWidth(width_multiplier * width)
+ elseif width == "full" then
+ control.width = "fill"
+ else
+ control:SetWidth(width_multiplier)
+ end
+ end
+ if control.SetDisabled then
+ local disabled = CheckOptionDisabled(v, options, path, appName)
+ control:SetDisabled(disabled)
+ end
+
+ InjectInfo(control, options, v, path, rootframe, appName)
+ container:AddChild(control)
+ end
+
+ end
+ end
+ tremove(path)
+ end
+ container:ResumeLayout()
+ container:DoLayout()
+ del(keySort)
+ del(opts)
+end
+
+local function BuildPath(path, ...)
+ for i = 1, select("#",...) do
+ tinsert(path, (select(i,...)))
+ end
+end
+
+
+local function TreeOnButtonEnter(widget, event, uniquevalue, button)
+ local user = widget:GetUserDataTable()
+ if not user then return end
+ local options = user.options
+ local option = user.option
+ local path = user.path
+ local appName = user.appName
+ local tooltip = AceConfigDialog.tooltip
+
+ local feedpath = new()
+ for i = 1, #path do
+ feedpath[i] = path[i]
+ end
+
+ BuildPath(feedpath, ("\001"):split(uniquevalue))
+ local group = options
+ for i = 1, #feedpath do
+ if not group then return end
+ group = GetSubOption(group, feedpath[i])
+ end
+
+ local name = GetOptionsMemberValue("name", group, options, feedpath, appName)
+ local desc = GetOptionsMemberValue("desc", group, options, feedpath, appName)
+
+ tooltip:SetOwner(button, "ANCHOR_NONE")
+ tooltip:ClearAllPoints()
+ if widget.type == "TabGroup" then
+ tooltip:SetPoint("BOTTOM",button,"TOP")
+ else
+ tooltip:SetPoint("LEFT",button,"RIGHT")
+ end
+
+ tooltip:SetText(name, 1, .82, 0, true)
+
+ if type(desc) == "string" then
+ tooltip:AddLine(desc, 1, 1, 1, true)
+ end
+
+ tooltip:Show()
+end
+
+local function TreeOnButtonLeave(widget, event, value, button)
+ AceConfigDialog.tooltip:Hide()
+end
+
+
+local function GroupExists(appName, options, path, uniquevalue)
+ if not uniquevalue then return false end
+
+ local feedpath = new()
+ local temppath = new()
+ for i = 1, #path do
+ feedpath[i] = path[i]
+ end
+
+ BuildPath(feedpath, ("\001"):split(uniquevalue))
+
+ local group = options
+ for i = 1, #feedpath do
+ local v = feedpath[i]
+ temppath[i] = v
+ group = GetSubOption(group, v)
+
+ if not group or group.type ~= "group" or CheckOptionHidden(group, options, temppath, appName) then
+ del(feedpath)
+ del(temppath)
+ return false
+ end
+ end
+ del(feedpath)
+ del(temppath)
+ return true
+end
+
+local function GroupSelected(widget, event, uniquevalue)
+
+ local user = widget:GetUserDataTable()
+
+ local options = user.options
+ local option = user.option
+ local path = user.path
+ local rootframe = user.rootframe
+
+ local feedpath = new()
+ for i = 1, #path do
+ feedpath[i] = path[i]
+ end
+
+ BuildPath(feedpath, ("\001"):split(uniquevalue))
+ widget:ReleaseChildren()
+ AceConfigDialog:FeedGroup(user.appName,options,widget,rootframe,feedpath)
+
+ del(feedpath)
+end
+
+
+
+--[[
+-- INTERNAL --
+This function will feed one group, and any inline child groups into the given container
+Select Groups will only have the selection control (tree, tabs, dropdown) fed in
+and have a group selected, this event will trigger the feeding of child groups
+
+Rules:
+ If the group is Inline, FeedOptions
+ If the group has no child groups, FeedOptions
+
+ If the group is a tab or select group, FeedOptions then add the Group Control
+ If the group is a tree group FeedOptions then
+ its parent isnt a tree group: then add the tree control containing this and all child tree groups
+ if its parent is a tree group, its already a node on a tree
+--]]
+
+function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isRoot)
+ local group = options
+ --follow the path to get to the curent group
+ local inline
+ local grouptype, parenttype = options.childGroups, "none"
+
+
+ for i = 1, #path do
+ local v = path[i]
+ group = GetSubOption(group, v)
+ inline = inline or pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
+ parenttype = grouptype
+ grouptype = group.childGroups
+ end
+
+ if not parenttype then
+ parenttype = "tree"
+ end
+
+ --check if the group has child groups
+ local hasChildGroups
+ for k, v in pairs(group.args) do
+ if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) and not CheckOptionHidden(v, options, path, appName) then
+ hasChildGroups = true
+ end
+ end
+ if group.plugins then
+ for plugin, t in pairs(group.plugins) do
+ for k, v in pairs(t) do
+ if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) and not CheckOptionHidden(v, options, path, appName) then
+ hasChildGroups = true
+ end
+ end
+ end
+ end
+
+ container:SetLayout("flow")
+ local scroll
+
+ --Add a scrollframe if we are not going to add a group control, this is the inverse of the conditions for that later on
+ if (not (hasChildGroups and not inline)) or (grouptype ~= "tab" and grouptype ~= "select" and (parenttype == "tree" and not isRoot)) then
+ if container.type ~= "InlineGroup" and container.type ~= "SimpleGroup" then
+ scroll = gui:Create("ScrollFrame")
+ scroll:SetLayout("flow")
+ scroll.width = "fill"
+ scroll.height = "fill"
+ container:SetLayout("fill")
+ container:AddChild(scroll)
+ container = scroll
+ end
+ end
+
+ FeedOptions(appName,options,container,rootframe,path,group,nil)
+
+ if scroll then
+ container:PerformLayout()
+ local status = self:GetStatusTable(appName, path)
+ if not status.scroll then
+ status.scroll = {}
+ end
+ scroll:SetStatusTable(status.scroll)
+ end
+
+ if hasChildGroups and not inline then
+ local name = GetOptionsMemberValue("name", group, options, path, appName)
+ if grouptype == "tab" then
+
+ local tab = gui:Create("TabGroup")
+ InjectInfo(tab, options, group, path, rootframe, appName)
+ tab:SetCallback("OnGroupSelected", GroupSelected)
+ tab:SetCallback("OnTabEnter", TreeOnButtonEnter)
+ tab:SetCallback("OnTabLeave", TreeOnButtonLeave)
+
+ local status = AceConfigDialog:GetStatusTable(appName, path)
+ if not status.groups then
+ status.groups = {}
+ end
+ tab:SetStatusTable(status.groups)
+ tab.width = "fill"
+ tab.height = "fill"
+
+ local tabs = BuildGroups(group, options, path, appName)
+ tab:SetTabs(tabs)
+ tab:SetUserData("tablist", tabs)
+
+ for i = 1, #tabs do
+ local entry = tabs[i]
+ if not entry.disabled then
+ tab:SelectTab((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or entry.value)
+ break
+ end
+ end
+
+ container:AddChild(tab)
+
+ elseif grouptype == "select" then
+
+ local selectGroup = gui:Create("DropdownGroup")
+ selectGroup:SetTitle(name)
+ InjectInfo(selectGroup, options, group, path, rootframe, appName)
+ selectGroup:SetCallback("OnGroupSelected", GroupSelected)
+ local status = AceConfigDialog:GetStatusTable(appName, path)
+ if not status.groups then
+ status.groups = {}
+ end
+ selectGroup:SetStatusTable(status.groups)
+ local grouplist, orderlist = BuildSelect(group, options, path, appName)
+ selectGroup:SetGroupList(grouplist, orderlist)
+ selectGroup:SetUserData("grouplist", grouplist)
+ selectGroup:SetUserData("orderlist", orderlist)
+
+ local firstgroup = orderlist[1]
+ if firstgroup then
+ selectGroup:SetGroup((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup)
+ end
+
+ selectGroup.width = "fill"
+ selectGroup.height = "fill"
+
+ container:AddChild(selectGroup)
+
+ --assume tree group by default
+ --if parenttype is tree then this group is already a node on that tree
+ elseif (parenttype ~= "tree") or isRoot then
+ local tree = gui:Create("TreeGroup")
+ InjectInfo(tree, options, group, path, rootframe, appName)
+ tree:EnableButtonTooltips(false)
+
+ tree.width = "fill"
+ tree.height = "fill"
+
+ tree:SetCallback("OnGroupSelected", GroupSelected)
+ tree:SetCallback("OnButtonEnter", TreeOnButtonEnter)
+ tree:SetCallback("OnButtonLeave", TreeOnButtonLeave)
+
+ local status = AceConfigDialog:GetStatusTable(appName, path)
+ if not status.groups then
+ status.groups = {}
+ end
+ local treedefinition = BuildGroups(group, options, path, appName, true)
+ tree:SetStatusTable(status.groups)
+
+ tree:SetTree(treedefinition)
+ tree:SetUserData("tree",treedefinition)
+
+ for i = 1, #treedefinition do
+ local entry = treedefinition[i]
+ if not entry.disabled then
+ tree:SelectByValue((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or entry.value)
+ break
+ end
+ end
+
+ container:AddChild(tree)
+ end
+ end
+end
+
+local old_CloseSpecialWindows
+
+
+local function RefreshOnUpdate(this)
+ for appName in pairs(this.closing) do
+ if AceConfigDialog.OpenFrames[appName] then
+ AceConfigDialog.OpenFrames[appName]:Hide()
+ end
+ if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then
+ for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do
+ if not widget:IsVisible() then
+ widget:ReleaseChildren()
+ end
+ end
+ end
+ this.closing[appName] = nil
+ end
+
+ if this.closeAll then
+ for k, v in pairs(AceConfigDialog.OpenFrames) do
+ if not this.closeAllOverride[k] then
+ v:Hide()
+ end
+ end
+ this.closeAll = nil
+ wipe(this.closeAllOverride)
+ end
+
+ for appName in pairs(this.apps) do
+ if AceConfigDialog.OpenFrames[appName] then
+ local user = AceConfigDialog.OpenFrames[appName]:GetUserDataTable()
+ AceConfigDialog:Open(appName, unpack(user.basepath or emptyTbl))
+ end
+ if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then
+ for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do
+ local user = widget:GetUserDataTable()
+ if widget:IsVisible() then
+ AceConfigDialog:Open(widget:GetUserData("appName"), widget, unpack(user.basepath or emptyTbl))
+ end
+ end
+ end
+ this.apps[appName] = nil
+ end
+ this:SetScript("OnUpdate", nil)
+end
+
+-- Upgrade the OnUpdate script as well, if needed.
+if AceConfigDialog.frame:GetScript("OnUpdate") then
+ AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
+end
+
+--- Close all open options windows
+function AceConfigDialog:CloseAll()
+ AceConfigDialog.frame.closeAll = true
+ AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
+ if next(self.OpenFrames) then
+ return true
+ end
+end
+
+--- Close a specific options window.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+function AceConfigDialog:Close(appName)
+ if self.OpenFrames[appName] then
+ AceConfigDialog.frame.closing[appName] = true
+ AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
+ return true
+ end
+end
+
+-- Internal -- Called by AceConfigRegistry
+function AceConfigDialog:ConfigTableChanged(event, appName)
+ AceConfigDialog.frame.apps[appName] = true
+ AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
+end
+
+reg.RegisterCallback(AceConfigDialog, "ConfigTableChange", "ConfigTableChanged")
+
+--- Sets the default size of the options window for a specific application.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param width The default width
+-- @param height The default height
+function AceConfigDialog:SetDefaultSize(appName, width, height)
+ local status = AceConfigDialog:GetStatusTable(appName)
+ if type(width) == "number" and type(height) == "number" then
+ status.width = width
+ status.height = height
+ end
+end
+
+--- Open an option window at the specified path (if any).
+-- This function can optionally feed the group into a pre-created container
+-- instead of creating a new container frame.
+-- @paramsig appName [, container][, ...]
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param container An optional container frame to feed the options into
+-- @param ... The path to open after creating the options window (see `:SelectGroup` for details)
+function AceConfigDialog:Open(appName, container, ...)
+ if not old_CloseSpecialWindows then
+ old_CloseSpecialWindows = CloseSpecialWindows
+ CloseSpecialWindows = function()
+ local found = old_CloseSpecialWindows()
+ return self:CloseAll() or found
+ end
+ end
+ local app = reg:GetOptionsTable(appName)
+ if not app then
+ error(("%s isn't registed with AceConfigRegistry, unable to open config"):format(appName), 2)
+ end
+ local options = app("dialog", MAJOR)
+
+ local f
+
+ local path = new()
+ local name = GetOptionsMemberValue("name", options, options, path, appName)
+
+ --If an optional path is specified add it to the path table before feeding the options
+ --as container is optional as well it may contain the first element of the path
+ if type(container) == "string" then
+ tinsert(path, container)
+ container = nil
+ end
+ for n = 1, select("#",...) do
+ tinsert(path, (select(n, ...)))
+ end
+
+ local option = options
+ if type(container) == "table" and container.type == "BlizOptionsGroup" and #path > 0 then
+ for i = 1, #path do
+ option = options.args[path[i]]
+ end
+ name = format("%s - %s", name, GetOptionsMemberValue("name", option, options, path, appName))
+ end
+
+ --if a container is given feed into that
+ if container then
+ f = container
+ f:ReleaseChildren()
+ f:SetUserData("appName", appName)
+ f:SetUserData("iscustom", true)
+ if #path > 0 then
+ f:SetUserData("basepath", copy(path))
+ end
+ local status = AceConfigDialog:GetStatusTable(appName)
+ if not status.width then
+ status.width = 700
+ end
+ if not status.height then
+ status.height = 500
+ end
+ if f.SetStatusTable then
+ f:SetStatusTable(status)
+ end
+ if f.SetTitle then
+ f:SetTitle(name or "")
+ end
+ else
+ if not self.OpenFrames[appName] then
+ f = gui:Create("Frame")
+ self.OpenFrames[appName] = f
+ else
+ f = self.OpenFrames[appName]
+ end
+ f:ReleaseChildren()
+ f:SetCallback("OnClose", FrameOnClose)
+ f:SetUserData("appName", appName)
+ if #path > 0 then
+ f:SetUserData("basepath", copy(path))
+ end
+ f:SetTitle(name or "")
+ local status = AceConfigDialog:GetStatusTable(appName)
+ f:SetStatusTable(status)
+ end
+
+ self:FeedGroup(appName,options,f,f,path,true)
+ if f.Show then
+ f:Show()
+ end
+ del(path)
+
+ if AceConfigDialog.frame.closeAll then
+ -- close all is set, but thats not good, since we're just opening here, so force it
+ AceConfigDialog.frame.closeAllOverride[appName] = true
+ end
+end
+
+-- convert pre-39 BlizOptions structure to the new format
+if oldminor and oldminor < 39 and AceConfigDialog.BlizOptions then
+ local old = AceConfigDialog.BlizOptions
+ local newOpt = {}
+ for key, widget in pairs(old) do
+ local appName = widget:GetUserData("appName")
+ if not newOpt[appName] then newOpt[appName] = {} end
+ newOpt[appName][key] = widget
+ end
+ AceConfigDialog.BlizOptions = newOpt
+else
+ AceConfigDialog.BlizOptions = AceConfigDialog.BlizOptions or {}
+end
+
+local function FeedToBlizPanel(widget, event)
+ local path = widget:GetUserData("path")
+ AceConfigDialog:Open(widget:GetUserData("appName"), widget, unpack(path or emptyTbl))
+end
+
+local function ClearBlizPanel(widget, event)
+ local appName = widget:GetUserData("appName")
+ AceConfigDialog.frame.closing[appName] = true
+ AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
+end
+
+--- Add an option table into the Blizzard Interface Options panel.
+-- You can optionally supply a descriptive name to use and a parent frame to use,
+-- as well as a path in the options table.\\
+-- If no name is specified, the appName will be used instead.
+--
+-- If you specify a proper `parent` (by name), the interface options will generate a
+-- tree layout. Note that only one level of children is supported, so the parent always
+-- has to be a head-level note.
+--
+-- This function returns a reference to the container frame registered with the Interface
+-- Options. You can use this reference to open the options with the API function
+-- `InterfaceOptionsFrame_OpenToCategory`.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param name A descriptive name to display in the options tree (defaults to appName)
+-- @param parent The parent to use in the interface options tree.
+-- @param ... The path in the options table to feed into the interface options panel.
+-- @return The reference to the frame registered into the Interface Options.
+-- @return The category ID to pass to Settings.OpenToCategory (or InterfaceOptionsFrame_OpenToCategory)
+function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...)
+ local BlizOptions = AceConfigDialog.BlizOptions
+
+ local key = appName
+ for n = 1, select("#", ...) do
+ key = key.."\001"..select(n, ...)
+ end
+
+ if not BlizOptions[appName] then
+ BlizOptions[appName] = {}
+ end
+
+ if not BlizOptions[appName][key] then
+ local group = gui:Create("BlizOptionsGroup")
+ BlizOptions[appName][key] = group
+
+ group:SetTitle(name or appName)
+ group:SetUserData("appName", appName)
+ if select("#", ...) > 0 then
+ local path = {}
+ for n = 1, select("#",...) do
+ tinsert(path, (select(n, ...)))
+ end
+ group:SetUserData("path", path)
+ end
+ group:SetCallback("OnShow", FeedToBlizPanel)
+ group:SetCallback("OnHide", ClearBlizPanel)
+ if Settings and Settings.RegisterCanvasLayoutCategory then
+ local categoryName = name or appName
+ if parent then
+ local category = Settings.GetCategory(parent)
+ if not category then
+ error(("The parent category '%s' was not found"):format(parent), 2)
+ end
+ local subcategory = Settings.RegisterCanvasLayoutSubcategory(category, group.frame, categoryName)
+
+ -- force the generated ID to be used for subcategories, as these can have very simple names like "Profiles"
+ group:SetName(subcategory.ID, parent)
+ else
+ local category = Settings.RegisterCanvasLayoutCategory(group.frame, categoryName)
+ -- using appName here would be cleaner, but would not be 100% compatible
+ -- but for top-level categories it should be fine, as these are typically addon names
+ category.ID = categoryName
+ group:SetName(categoryName, parent)
+ Settings.RegisterAddOnCategory(category)
+ end
+ else
+ group:SetName(name or appName, parent)
+ InterfaceOptions_AddCategory(group.frame)
+ end
+ return group.frame, group.frame.name
+ else
+ error(("%s has already been added to the Blizzard Options Window with the given path"):format(appName), 2)
+ end
+end
diff --git a/Broker2FuBar/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.xml b/Broker2FuBar/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.xml
new file mode 100644
index 0000000..068be6f
--- /dev/null
+++ b/Broker2FuBar/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/Broker2FuBar/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua b/Broker2FuBar/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua
new file mode 100644
index 0000000..175224d
--- /dev/null
+++ b/Broker2FuBar/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua
@@ -0,0 +1,372 @@
+--- 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.\\
+-- Such functions receive three arguments: "uiType", "uiName", "appName". \\
+-- * 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.\\
+-- * The **appName** field is the options table name as given at registration time \\
+--
+-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName".
+-- @class file
+-- @name AceConfigRegistry-3.0
+-- @release $Id: AceConfigRegistry-3.0.lua 1296 2022-11-04 18:50:10Z nevcairiel $
+local CallbackHandler = LibStub("CallbackHandler-1.0")
+
+local MAJOR, MINOR = "AceConfigRegistry-3.0", 21
+local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not AceConfigRegistry then return end
+
+AceConfigRegistry.tables = AceConfigRegistry.tables or {}
+
+if not AceConfigRegistry.callbacks then
+ AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
+end
+
+-- Lua APIs
+local tinsert, tconcat = table.insert, table.concat
+local strfind, strmatch = string.find, string.match
+local type, tostring, select, pairs = type, tostring, select, pairs
+local error, assert = error, assert
+
+-----------------------------------------------------------------------
+-- Validating options table consistency:
+
+
+AceConfigRegistry.validated = {
+ -- list of options table names ran through :ValidateOptionsTable automatically.
+ -- CLEARED ON PURPOSE, since newer versions may have newer validators
+ cmd = {},
+ dropdown = {},
+ dialog = {},
+}
+
+
+
+local function err(msg, errlvl, ...)
+ local t = {}
+ for i=select("#",...),1,-1 do
+ tinsert(t, (select(i, ...)))
+ end
+ error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2)
+end
+
+
+local isstring={["string"]=true, _="string"}
+local isstringfunc={["string"]=true,["function"]=true, _="string or funcref"}
+local istable={["table"]=true, _="table"}
+local ismethodtable={["table"]=true,["string"]=true,["function"]=true, _="methodname, funcref or table"}
+local optstring={["nil"]=true,["string"]=true, _="string"}
+local optstringfunc={["nil"]=true,["string"]=true,["function"]=true, _="string or funcref"}
+local optstringnumberfunc={["nil"]=true,["string"]=true,["number"]=true,["function"]=true, _="string, number or funcref"}
+local optnumber={["nil"]=true,["number"]=true, _="number"}
+local optmethodfalse={["nil"]=true,["string"]=true,["function"]=true,["boolean"]={[false]=true}, _="methodname, funcref or false"}
+local optmethodnumber={["nil"]=true,["string"]=true,["function"]=true,["number"]=true, _="methodname, funcref or number"}
+local optmethodtable={["nil"]=true,["string"]=true,["function"]=true,["table"]=true, _="methodname, funcref or table"}
+local optmethodbool={["nil"]=true,["string"]=true,["function"]=true,["boolean"]=true, _="methodname, funcref or boolean"}
+local opttable={["nil"]=true,["table"]=true, _="table"}
+local optbool={["nil"]=true,["boolean"]=true, _="boolean"}
+local optboolnumber={["nil"]=true,["boolean"]=true,["number"]=true, _="boolean or number"}
+local optstringnumber={["nil"]=true,["string"]=true,["number"]=true, _="string or number"}
+
+local basekeys={
+ type=isstring,
+ name=isstringfunc,
+ desc=optstringfunc,
+ descStyle=optstring,
+ order=optmethodnumber,
+ validate=optmethodfalse,
+ confirm=optmethodbool,
+ confirmText=optstring,
+ disabled=optmethodbool,
+ hidden=optmethodbool,
+ guiHidden=optmethodbool,
+ dialogHidden=optmethodbool,
+ dropdownHidden=optmethodbool,
+ cmdHidden=optmethodbool,
+ tooltipHyperlink=optstringfunc,
+ icon=optstringnumberfunc,
+ iconCoords=optmethodtable,
+ handler=opttable,
+ get=optmethodfalse,
+ set=optmethodfalse,
+ func=optmethodfalse,
+ arg={["*"]=true},
+ width=optstringnumber,
+}
+
+local typedkeys={
+ header={
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ },
+ description={
+ image=optstringnumberfunc,
+ imageCoords=optmethodtable,
+ imageHeight=optnumber,
+ imageWidth=optnumber,
+ fontSize=optstringfunc,
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ },
+ group={
+ args=istable,
+ plugins=opttable,
+ inline=optbool,
+ cmdInline=optbool,
+ guiInline=optbool,
+ dropdownInline=optbool,
+ dialogInline=optbool,
+ childGroups=optstring,
+ },
+ execute={
+ image=optstringnumberfunc,
+ imageCoords=optmethodtable,
+ imageHeight=optnumber,
+ imageWidth=optnumber,
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ },
+ input={
+ pattern=optstring,
+ usage=optstring,
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ multiline=optboolnumber,
+ },
+ toggle={
+ tristate=optbool,
+ image=optstringnumberfunc,
+ imageCoords=optmethodtable,
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ },
+ tristate={
+ },
+ range={
+ min=optnumber,
+ softMin=optnumber,
+ max=optnumber,
+ softMax=optnumber,
+ step=optnumber,
+ bigStep=optnumber,
+ isPercent=optbool,
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ },
+ select={
+ values=ismethodtable,
+ sorting=optmethodtable,
+ style={
+ ["nil"]=true,
+ ["string"]={dropdown=true,radio=true},
+ _="string: 'dropdown' or 'radio'"
+ },
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ itemControl=optstring,
+ },
+ multiselect={
+ values=ismethodtable,
+ style=optstring,
+ tristate=optbool,
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ },
+ color={
+ hasAlpha=optmethodbool,
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ },
+ keybinding={
+ control=optstring,
+ dialogControl=optstring,
+ dropdownControl=optstring,
+ },
+}
+
+local function validateKey(k,errlvl,...)
+ errlvl=(errlvl or 0)+1
+ if type(k)~="string" then
+ err("["..tostring(k).."] - key is not a string", errlvl,...)
+ end
+ if strfind(k, "[%c\127]") then
+ err("["..tostring(k).."] - key name contained control characters", errlvl,...)
+ end
+end
+
+local function validateVal(v, oktypes, errlvl,...)
+ errlvl=(errlvl or 0)+1
+ local isok=oktypes[type(v)] or oktypes["*"]
+
+ if not isok then
+ err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl,...)
+ end
+ if type(isok)=="table" then -- isok was a table containing specific values to be tested for!
+ if not isok[v] then
+ err(": did not expect "..type(v).." value '"..tostring(v).."'", errlvl,...)
+ end
+ end
+end
+
+local function validate(options,errlvl,...)
+ errlvl=(errlvl or 0)+1
+ -- basic consistency
+ if type(options)~="table" then
+ err(": expected a table, got a "..type(options), errlvl,...)
+ end
+ if type(options.type)~="string" then
+ err(".type: expected a string, got a "..type(options.type), errlvl,...)
+ end
+
+ -- get type and 'typedkeys' member
+ local tk = typedkeys[options.type]
+ if not tk then
+ err(".type: unknown type '"..options.type.."'", errlvl,...)
+ end
+
+ -- make sure that all options[] are known parameters
+ for k,v in pairs(options) do
+ if not (tk[k] or basekeys[k]) then
+ err(": unknown parameter", errlvl,tostring(k),...)
+ end
+ end
+
+ -- verify that required params are there, and that everything is the right type
+ for k,oktypes in pairs(basekeys) do
+ validateVal(options[k], oktypes, errlvl,k,...)
+ end
+ for k,oktypes in pairs(tk) do
+ validateVal(options[k], oktypes, errlvl,k,...)
+ end
+
+ -- extra logic for groups
+ if options.type=="group" then
+ for k,v in pairs(options.args) do
+ validateKey(k,errlvl,"args",...)
+ validate(v, errlvl,k,"args",...)
+ end
+ if options.plugins then
+ for plugname,plugin in pairs(options.plugins) do
+ if type(plugin)~="table" then
+ err(": expected a table, got '"..tostring(plugin).."'", errlvl,tostring(plugname),"plugins",...)
+ end
+ for k,v in pairs(plugin) do
+ validateKey(k,errlvl,tostring(plugname),"plugins",...)
+ validate(v, errlvl,k,tostring(plugname),"plugins",...)
+ end
+ end
+ end
+ end
+end
+
+
+--- Validates basic structure and integrity of an options table \\
+-- Does NOT verify that get/set etc actually exist, since they can be defined at any depth
+-- @param options The table to be validated
+-- @param name The name of the table to be validated (shown in any error message)
+-- @param errlvl (optional number) error level offset, default 0 (=errors point to the function calling :ValidateOptionsTable)
+function AceConfigRegistry:ValidateOptionsTable(options,name,errlvl)
+ errlvl=(errlvl or 0)+1
+ name = name or "Optionstable"
+ if not options.name then
+ options.name=name -- bit of a hack, the root level doesn't really need a .name :-/
+ end
+ validate(options,errlvl,name)
+end
+
+--- Fires a "ConfigTableChange" callback for those listening in on it, allowing config GUIs to refresh.
+-- You should call this function if your options table changed from any outside event, like a game event
+-- or a timer.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+function AceConfigRegistry:NotifyChange(appName)
+ if not AceConfigRegistry.tables[appName] then return end
+ AceConfigRegistry.callbacks:Fire("ConfigTableChange", appName)
+end
+
+-- -------------------------------------------------------------------
+-- Registering and retreiving options tables:
+
+
+-- validateGetterArgs: helper function for :GetOptionsTable (or, rather, the getter functions returned by it)
+
+local function validateGetterArgs(uiType, uiName, errlvl)
+ errlvl=(errlvl or 0)+2
+ if uiType~="cmd" and uiType~="dropdown" and uiType~="dialog" then
+ error(MAJOR..": Requesting options table: 'uiType' - invalid configuration UI type, expected 'cmd', 'dropdown' or 'dialog'", errlvl)
+ end
+ if not strmatch(uiName, "[A-Za-z]%-[0-9]") then -- Expecting e.g. "MyLib-1.2"
+ error(MAJOR..": Requesting options table: 'uiName' - badly formatted or missing version number. Expected e.g. 'MyLib-1.2'", errlvl)
+ end
+end
+
+--- Register an options table with the config registry.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param options The options table, OR a function reference that generates it on demand. \\
+-- See the top of the page for info on arguments passed to such functions.
+-- @param skipValidation Skip options table validation (primarily useful for extremely huge options, with a noticeable slowdown)
+function AceConfigRegistry:RegisterOptionsTable(appName, options, skipValidation)
+ if type(options)=="table" then
+ if options.type~="group" then -- quick sanity checker
+ error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - missing type='group' member in root group", 2)
+ end
+ AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
+ errlvl=(errlvl or 0)+1
+ validateGetterArgs(uiType, uiName, errlvl)
+ if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then
+ AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable
+ AceConfigRegistry.validated[uiType][appName] = true
+ end
+ return options
+ end
+ elseif type(options)=="function" then
+ AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
+ errlvl=(errlvl or 0)+1
+ validateGetterArgs(uiType, uiName, errlvl)
+ local tab = assert(options(uiType, uiName, appName))
+ if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then
+ AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable
+ AceConfigRegistry.validated[uiType][appName] = true
+ end
+ return tab
+ end
+ else
+ error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - expected table or function reference", 2)
+ end
+end
+
+--- Returns an iterator of ["appName"]=funcref pairs
+function AceConfigRegistry:IterateOptionsTables()
+ return pairs(AceConfigRegistry.tables)
+end
+
+
+
+
+--- Query the registry for a specific options table.
+-- If only appName is given, a function is returned which you
+-- can call with (uiType,uiName) to get the table.\\
+-- If uiType&uiName are given, the table is returned.
+-- @param appName The application name as given to `:RegisterOptionsTable()`
+-- @param uiType The type of UI to get the table for, one of "cmd", "dropdown", "dialog"
+-- @param uiName The name of the library/addon querying for the table, e.g. "MyLib-1.0"
+function AceConfigRegistry:GetOptionsTable(appName, uiType, uiName)
+ local f = AceConfigRegistry.tables[appName]
+ if not f then
+ return nil
+ end
+
+ if uiType then
+ return f(uiType,uiName,1) -- get the table for us
+ else
+ return f -- return the function
+ end
+end
diff --git a/Broker2FuBar/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.xml b/Broker2FuBar/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.xml
new file mode 100644
index 0000000..5989072
--- /dev/null
+++ b/Broker2FuBar/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/Broker2FuBar/libs/AceConsole-3.0/AceConsole-3.0.lua b/Broker2FuBar/libs/AceConsole-3.0/AceConsole-3.0.lua
new file mode 100644
index 0000000..8ce5f8b
--- /dev/null
+++ b/Broker2FuBar/libs/AceConsole-3.0/AceConsole-3.0.lua
@@ -0,0 +1,246 @@
+--- **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 1284 2022-09-25 09:15:30Z 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
+
+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 str 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 _
+ 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
diff --git a/Broker2FuBar/libs/AceConsole-3.0/AceConsole-3.0.xml b/Broker2FuBar/libs/AceConsole-3.0/AceConsole-3.0.xml
new file mode 100644
index 0000000..f6ae8a6
--- /dev/null
+++ b/Broker2FuBar/libs/AceConsole-3.0/AceConsole-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/Broker2FuBar/libs/AceDB-3.0/AceDB-3.0.lua b/Broker2FuBar/libs/AceDB-3.0/AceDB-3.0.lua
new file mode 100644
index 0000000..9e84705
--- /dev/null
+++ b/Broker2FuBar/libs/AceDB-3.0/AceDB-3.0.lua
@@ -0,0 +1,740 @@
+--- **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.
+-- * **locale** Locale specific data, based on the locale of the players game client.
+-- * **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 1284 2022-09-25 09:15:30Z nevcairiel $
+local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 27
+local AceDB = 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, rawset, rawget = setmetatable, rawset, rawget
+
+-- WoW APIs
+local _G = _G
+
+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,k2)
+ if k2 == nil then return nil end
+ local tbl = {}
+ copyDefaults(tbl, v)
+ rawset(t, k2, 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,k2) return k2~=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
+local localeKey = GetLocale():lower()
+
+local regionTable = { "US", "KR", "EU", "TW", "CN" }
+local regionKey = regionTable[GetCurrentRegion()]
+local factionrealmregionKey = factionrealmKey .. " - " .. regionKey
+
+-- 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,
+ ["factionrealmregion"] = factionrealmregionKey,
+ ["profile"] = profileKey,
+ ["locale"] = localeKey,
+ ["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, got %q."):format(type(defaults)), 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, got %q."):format(type(name)), 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, got %q."):format(type(tbl)), 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, got %q."):format(type(name)), 2)
+ end
+
+ if self.keys.profile == name then
+ error(("Cannot delete the active profile (%q) in an AceDBObject."):format(name), 2)
+ end
+
+ if not rawget(self.profiles, name) and not silent then
+ error(("Cannot delete profile %q as it does not exist."):format(name), 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
+
+ -- switch all characters that use this profile back to the default
+ if self.sv.profileKeys then
+ for key, profile in pairs(self.sv.profileKeys) do
+ if profile == name then
+ self.sv.profileKeys[key] = nil
+ end
+ 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, got %q."):format(type(name)), 2)
+ end
+
+ if name == self.keys.profile then
+ error(("Cannot have the same source and destination profiles (%q)."):format(name), 2)
+ end
+
+ if not rawget(self.profiles, name) and not silent then
+ error(("Cannot copy profile %q as it does not exist."):format(name), 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, got %q."):format(type(defaultProfile)), 2)
+ end
+
+ local sv = self.sv
+ for k,v in pairs(sv) do
+ sv[k] = nil
+ end
+
+ 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, got %q."):format(type(name)), 2)
+ end
+ if defaults and type(defaults) ~= "table" then
+ error(("Usage: AceDBObject:RegisterNamespace(name, defaults): 'defaults' - table or nil expected, got %q."):format(type(defaults)), 2)
+ end
+ if self.children and self.children[name] then
+ error(("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - a namespace called %q already exists."):format(name), 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, got %q."):format(type(name)), 2)
+ end
+ if not silent and not (self.children and self.children[name]) then
+ error(("Usage: AceDBObject:GetNamespace(name): 'name' - namespace %q does not exist."):format(name), 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, got %q."):format(type(tbl)), 2)
+ end
+
+ if defaults and type(defaults) ~= "table" then
+ error(("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaults' - table expected, got %q."):format(type(defaults)), 2)
+ end
+
+ if defaultProfile and type(defaultProfile) ~= "string" and defaultProfile ~= true then
+ error(("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaultProfile' - string or true expected, got %q."):format(type(defaultProfile)), 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
diff --git a/Broker2FuBar/libs/AceDB-3.0/AceDB-3.0.xml b/Broker2FuBar/libs/AceDB-3.0/AceDB-3.0.xml
new file mode 100644
index 0000000..28998e5
--- /dev/null
+++ b/Broker2FuBar/libs/AceDB-3.0/AceDB-3.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/Broker2FuBar/libs/AceGUI-3.0/AceGUI-3.0.lua b/Broker2FuBar/libs/AceGUI-3.0/AceGUI-3.0.lua
new file mode 100644
index 0000000..7d9a2cf
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/AceGUI-3.0.lua
@@ -0,0 +1,1020 @@
+--- **AceGUI-3.0** provides access to numerous widgets which can be used to create GUIs.
+-- AceGUI is used by AceConfigDialog to create the option GUIs, but you can use it by itself
+-- to create any custom GUI. There are more extensive examples in the test suite in the Ace3
+-- stand-alone distribution.
+--
+-- **Note**: When using AceGUI-3.0 directly, please do not modify the frames of the widgets directly,
+-- as any "unknown" change to the widgets will cause addons that get your widget out of the widget pool
+-- to misbehave. If you think some part of a widget should be modifiable, please open a ticket, and we"ll
+-- implement a proper API to modify it.
+-- @usage
+-- local AceGUI = LibStub("AceGUI-3.0")
+-- -- Create a container frame
+-- local f = AceGUI:Create("Frame")
+-- f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
+-- f:SetTitle("AceGUI-3.0 Example")
+-- f:SetStatusText("Status Bar")
+-- f:SetLayout("Flow")
+-- -- Create a button
+-- local btn = AceGUI:Create("Button")
+-- btn:SetWidth(170)
+-- btn:SetText("Button !")
+-- btn:SetCallback("OnClick", function() print("Click!") end)
+-- -- Add the button to the container
+-- f:AddChild(btn)
+-- @class file
+-- @name AceGUI-3.0
+-- @release $Id: AceGUI-3.0.lua 1288 2022-09-25 14:19:00Z funkehdude $
+local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 41
+local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR)
+
+if not AceGUI then return end -- No upgrade needed
+
+-- Lua APIs
+local tinsert, wipe = table.insert, table.wipe
+local select, pairs, next, type = select, pairs, next, type
+local error, assert = error, assert
+local setmetatable, rawget = setmetatable, rawget
+local math_max, math_min, math_ceil = math.max, math.min, math.ceil
+
+-- WoW APIs
+local UIParent = UIParent
+
+AceGUI.WidgetRegistry = AceGUI.WidgetRegistry or {}
+AceGUI.LayoutRegistry = AceGUI.LayoutRegistry or {}
+AceGUI.WidgetBase = AceGUI.WidgetBase or {}
+AceGUI.WidgetContainerBase = AceGUI.WidgetContainerBase or {}
+AceGUI.WidgetVersions = AceGUI.WidgetVersions or {}
+AceGUI.tooltip = AceGUI.tooltip or CreateFrame("GameTooltip", "AceGUITooltip", UIParent, "GameTooltipTemplate")
+
+-- local upvalues
+local WidgetRegistry = AceGUI.WidgetRegistry
+local LayoutRegistry = AceGUI.LayoutRegistry
+local WidgetVersions = AceGUI.WidgetVersions
+
+--[[
+ xpcall safecall implementation
+]]
+local xpcall = xpcall
+
+local function errorhandler(err)
+ return geterrorhandler()(err)
+end
+
+local function safecall(func, ...)
+ if func then
+ return xpcall(func, errorhandler, ...)
+ end
+end
+
+-- Recycling functions
+local newWidget, delWidget
+do
+ -- Version Upgrade in Minor 29
+ -- Internal Storage of the objects changed, from an array table
+ -- to a hash table, and additionally we introduced versioning on
+ -- the widgets which would discard all widgets from a pre-29 version
+ -- anyway, so we just clear the storage now, and don't try to
+ -- convert the storage tables to the new format.
+ -- This should generally not cause *many* widgets to end up in trash,
+ -- since once dialogs are opened, all addons should be loaded already
+ -- and AceGUI should be on the latest version available on the users
+ -- setup.
+ -- -- nevcairiel - Nov 2nd, 2009
+ if oldminor and oldminor < 29 and AceGUI.objPools then
+ AceGUI.objPools = nil
+ end
+
+ AceGUI.objPools = AceGUI.objPools or {}
+ local objPools = AceGUI.objPools
+ --Returns a new instance, if none are available either returns a new table or calls the given contructor
+ function newWidget(widgetType)
+ if not WidgetRegistry[widgetType] then
+ error("Attempt to instantiate unknown widget type", 2)
+ end
+
+ if not objPools[widgetType] then
+ objPools[widgetType] = {}
+ end
+
+ local newObj = next(objPools[widgetType])
+ if not newObj then
+ newObj = WidgetRegistry[widgetType]()
+ newObj.AceGUIWidgetVersion = WidgetVersions[widgetType]
+ else
+ objPools[widgetType][newObj] = nil
+ -- if the widget is older then the latest, don't even try to reuse it
+ -- just forget about it, and grab a new one.
+ if not newObj.AceGUIWidgetVersion or newObj.AceGUIWidgetVersion < WidgetVersions[widgetType] then
+ return newWidget(widgetType)
+ end
+ end
+ return newObj
+ end
+ -- Releases an instance to the Pool
+ function delWidget(obj,widgetType)
+ if not objPools[widgetType] then
+ objPools[widgetType] = {}
+ end
+ if objPools[widgetType][obj] then
+ error("Attempt to Release Widget that is already released", 2)
+ end
+ objPools[widgetType][obj] = true
+ end
+end
+
+
+-------------------
+-- API Functions --
+-------------------
+
+-- Gets a widget Object
+
+--- Create a new Widget of the given type.
+-- This function will instantiate a new widget (or use one from the widget pool), and call the
+-- OnAcquire function on it, before returning.
+-- @param type The type of the widget.
+-- @return The newly created widget.
+function AceGUI:Create(widgetType)
+ if WidgetRegistry[widgetType] then
+ local widget = newWidget(widgetType)
+
+ if rawget(widget, "Acquire") then
+ widget.OnAcquire = widget.Acquire
+ widget.Acquire = nil
+ elseif rawget(widget, "Aquire") then
+ widget.OnAcquire = widget.Aquire
+ widget.Aquire = nil
+ end
+
+ if rawget(widget, "Release") then
+ widget.OnRelease = rawget(widget, "Release")
+ widget.Release = nil
+ end
+
+ if widget.OnAcquire then
+ widget:OnAcquire()
+ else
+ error(("Widget type %s doesn't supply an OnAcquire Function"):format(widgetType))
+ end
+ -- Set the default Layout ("List")
+ safecall(widget.SetLayout, widget, "List")
+ safecall(widget.ResumeLayout, widget)
+ return widget
+ end
+end
+
+--- Releases a widget Object.
+-- This function calls OnRelease on the widget and places it back in the widget pool.
+-- Any data on the widget is being erased, and the widget will be hidden.\\
+-- If this widget is a Container-Widget, all of its Child-Widgets will be releases as well.
+-- @param widget The widget to release
+function AceGUI:Release(widget)
+ if widget.isQueuedForRelease then return end
+ widget.isQueuedForRelease = true
+ safecall(widget.PauseLayout, widget)
+ widget.frame:Hide()
+ widget:Fire("OnRelease")
+ safecall(widget.ReleaseChildren, widget)
+
+ if widget.OnRelease then
+ widget:OnRelease()
+-- else
+-- error(("Widget type %s doesn't supply an OnRelease Function"):format(widget.type))
+ end
+ for k in pairs(widget.userdata) do
+ widget.userdata[k] = nil
+ end
+ for k in pairs(widget.events) do
+ widget.events[k] = nil
+ end
+ widget.width = nil
+ widget.relWidth = nil
+ widget.height = nil
+ widget.relHeight = nil
+ widget.noAutoHeight = nil
+ widget.frame:ClearAllPoints()
+ widget.frame:Hide()
+ widget.frame:SetParent(UIParent)
+ widget.frame.width = nil
+ widget.frame.height = nil
+ if widget.content then
+ widget.content.width = nil
+ widget.content.height = nil
+ end
+ widget.isQueuedForRelease = nil
+ delWidget(widget, widget.type)
+end
+
+--- Check if a widget is currently in the process of being released
+-- This function check if this widget, or any of its parents (in which case it'll be released shortly as well)
+-- are currently being released. This allows addon to handle any callbacks accordingly.
+-- @param widget The widget to check
+function AceGUI:IsReleasing(widget)
+ if widget.isQueuedForRelease then
+ return true
+ end
+
+ if widget.parent and widget.parent.AceGUIWidgetVersion then
+ return AceGUI:IsReleasing(widget.parent)
+ end
+
+ return false
+end
+
+-----------
+-- Focus --
+-----------
+
+
+--- Called when a widget has taken focus.
+-- e.g. Dropdowns opening, Editboxes gaining kb focus
+-- @param widget The widget that should be focused
+function AceGUI:SetFocus(widget)
+ if self.FocusedWidget and self.FocusedWidget ~= widget then
+ safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
+ end
+ self.FocusedWidget = widget
+end
+
+
+--- Called when something has happened that could cause widgets with focus to drop it
+-- e.g. titlebar of a frame being clicked
+function AceGUI:ClearFocus()
+ if self.FocusedWidget then
+ safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
+ self.FocusedWidget = nil
+ end
+end
+
+-------------
+-- Widgets --
+-------------
+--[[
+ Widgets must provide the following functions
+ OnAcquire() - Called when the object is acquired, should set everything to a default hidden state
+
+ And the following members
+ frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes
+ type - the type of the object, same as the name given to :RegisterWidget()
+
+ Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet
+ It will be cleared automatically when a widget is released
+ Placing values directly into a widget object should be avoided
+
+ If the Widget can act as a container for other Widgets the following
+ content - frame or derivitive that children will be anchored to
+
+ The Widget can supply the following Optional Members
+ :OnRelease() - Called when the object is Released, should remove any additional anchors and clear any data
+ :OnWidthSet(width) - Called when the width of the widget is changed
+ :OnHeightSet(height) - Called when the height of the widget is changed
+ Widgets should not use the OnSizeChanged events of thier frame or content members, use these methods instead
+ AceGUI already sets a handler to the event
+ :LayoutFinished(width, height) - called after a layout has finished, the width and height will be the width and height of the
+ area used for controls. These can be nil if the layout used the existing size to layout the controls.
+
+]]
+
+--------------------------
+-- Widget Base Template --
+--------------------------
+do
+ local WidgetBase = AceGUI.WidgetBase
+
+ WidgetBase.SetParent = function(self, parent)
+ local frame = self.frame
+ frame:SetParent(nil)
+ frame:SetParent(parent.content)
+ self.parent = parent
+ end
+
+ WidgetBase.SetCallback = function(self, name, func)
+ if type(func) == "function" then
+ self.events[name] = func
+ end
+ end
+
+ WidgetBase.Fire = function(self, name, ...)
+ if self.events[name] then
+ local success, ret = safecall(self.events[name], self, name, ...)
+ if success then
+ return ret
+ end
+ end
+ end
+
+ WidgetBase.SetWidth = function(self, width)
+ self.frame:SetWidth(width)
+ self.frame.width = width
+ if self.OnWidthSet then
+ self:OnWidthSet(width)
+ end
+ end
+
+ WidgetBase.SetRelativeWidth = function(self, width)
+ if width <= 0 or width > 1 then
+ error(":SetRelativeWidth(width): Invalid relative width.", 2)
+ end
+ self.relWidth = width
+ self.width = "relative"
+ end
+
+ WidgetBase.SetHeight = function(self, height)
+ self.frame:SetHeight(height)
+ self.frame.height = height
+ if self.OnHeightSet then
+ self:OnHeightSet(height)
+ end
+ end
+
+ --[[ WidgetBase.SetRelativeHeight = function(self, height)
+ if height <= 0 or height > 1 then
+ error(":SetRelativeHeight(height): Invalid relative height.", 2)
+ end
+ self.relHeight = height
+ self.height = "relative"
+ end ]]
+
+ WidgetBase.IsVisible = function(self)
+ return self.frame:IsVisible()
+ end
+
+ WidgetBase.IsShown= function(self)
+ return self.frame:IsShown()
+ end
+
+ WidgetBase.Release = function(self)
+ AceGUI:Release(self)
+ end
+
+ WidgetBase.IsReleasing = function(self)
+ return AceGUI:IsReleasing(self)
+ end
+
+ WidgetBase.SetPoint = function(self, ...)
+ return self.frame:SetPoint(...)
+ end
+
+ WidgetBase.ClearAllPoints = function(self)
+ return self.frame:ClearAllPoints()
+ end
+
+ WidgetBase.GetNumPoints = function(self)
+ return self.frame:GetNumPoints()
+ end
+
+ WidgetBase.GetPoint = function(self, ...)
+ return self.frame:GetPoint(...)
+ end
+
+ WidgetBase.GetUserDataTable = function(self)
+ return self.userdata
+ end
+
+ WidgetBase.SetUserData = function(self, key, value)
+ self.userdata[key] = value
+ end
+
+ WidgetBase.GetUserData = function(self, key)
+ return self.userdata[key]
+ end
+
+ WidgetBase.IsFullHeight = function(self)
+ return self.height == "fill"
+ end
+
+ WidgetBase.SetFullHeight = function(self, isFull)
+ if isFull then
+ self.height = "fill"
+ else
+ self.height = nil
+ end
+ end
+
+ WidgetBase.IsFullWidth = function(self)
+ return self.width == "fill"
+ end
+
+ WidgetBase.SetFullWidth = function(self, isFull)
+ if isFull then
+ self.width = "fill"
+ else
+ self.width = nil
+ end
+ end
+
+-- local function LayoutOnUpdate(this)
+-- this:SetScript("OnUpdate",nil)
+-- this.obj:PerformLayout()
+-- end
+
+ local WidgetContainerBase = AceGUI.WidgetContainerBase
+
+ WidgetContainerBase.PauseLayout = function(self)
+ self.LayoutPaused = true
+ end
+
+ WidgetContainerBase.ResumeLayout = function(self)
+ self.LayoutPaused = nil
+ end
+
+ WidgetContainerBase.PerformLayout = function(self)
+ if self.LayoutPaused then
+ return
+ end
+ safecall(self.LayoutFunc, self.content, self.children)
+ end
+
+ --call this function to layout, makes sure layed out objects get a frame to get sizes etc
+ WidgetContainerBase.DoLayout = function(self)
+ self:PerformLayout()
+-- if not self.parent then
+-- self.frame:SetScript("OnUpdate", LayoutOnUpdate)
+-- end
+ end
+
+ 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()
+ end
+
+ WidgetContainerBase.AddChildren = function(self, ...)
+ for i = 1, select("#", ...) do
+ local child = select(i, ...)
+ tinsert(self.children, child)
+ child:SetParent(self)
+ child.frame:Show()
+ end
+ self:DoLayout()
+ end
+
+ WidgetContainerBase.ReleaseChildren = function(self)
+ local children = self.children
+ for i = 1,#children do
+ AceGUI:Release(children[i])
+ children[i] = nil
+ end
+ end
+
+ WidgetContainerBase.SetLayout = function(self, Layout)
+ self.LayoutFunc = AceGUI:GetLayout(Layout)
+ end
+
+ WidgetContainerBase.SetAutoAdjustHeight = function(self, adjust)
+ if adjust then
+ self.noAutoHeight = nil
+ else
+ self.noAutoHeight = true
+ end
+ end
+
+ local function FrameResize(this)
+ local self = this.obj
+ if this:GetWidth() and this:GetHeight() then
+ if self.OnWidthSet then
+ self:OnWidthSet(this:GetWidth())
+ end
+ if self.OnHeightSet then
+ self:OnHeightSet(this:GetHeight())
+ end
+ end
+ end
+
+ local function ContentResize(this)
+ if this:GetWidth() and this:GetHeight() then
+ this.width = this:GetWidth()
+ this.height = this:GetHeight()
+ this.obj:DoLayout()
+ end
+ end
+
+ setmetatable(WidgetContainerBase, {__index=WidgetBase})
+
+ --One of these function should be called on each Widget Instance as part of its creation process
+
+ --- Register a widget-class as a container for newly created widgets.
+ -- @param widget The widget class
+ function AceGUI:RegisterAsContainer(widget)
+ widget.children = {}
+ widget.userdata = {}
+ widget.events = {}
+ widget.base = WidgetContainerBase
+ widget.content.obj = widget
+ widget.frame.obj = widget
+ widget.content:SetScript("OnSizeChanged", ContentResize)
+ widget.frame:SetScript("OnSizeChanged", FrameResize)
+ setmetatable(widget, {__index = WidgetContainerBase})
+ widget:SetLayout("List")
+ return widget
+ end
+
+ --- Register a widget-class as a widget.
+ -- @param widget The widget class
+ function AceGUI:RegisterAsWidget(widget)
+ widget.userdata = {}
+ widget.events = {}
+ widget.base = WidgetBase
+ widget.frame.obj = widget
+ widget.frame:SetScript("OnSizeChanged", FrameResize)
+ setmetatable(widget, {__index = WidgetBase})
+ return widget
+ end
+end
+
+
+
+
+------------------
+-- Widget API --
+------------------
+
+--- Registers a widget Constructor, this function returns a new instance of the Widget
+-- @param Name The name of the widget
+-- @param Constructor The widget constructor function
+-- @param Version The version of the widget
+function AceGUI:RegisterWidgetType(Name, Constructor, Version)
+ assert(type(Constructor) == "function")
+ assert(type(Version) == "number")
+
+ local oldVersion = WidgetVersions[Name]
+ if oldVersion and oldVersion >= Version then return end
+
+ WidgetVersions[Name] = Version
+ WidgetRegistry[Name] = Constructor
+end
+
+--- Registers a Layout Function
+-- @param Name The name of the layout
+-- @param LayoutFunc Reference to the layout function
+function AceGUI:RegisterLayout(Name, LayoutFunc)
+ assert(type(LayoutFunc) == "function")
+ if type(Name) == "string" then
+ Name = Name:upper()
+ end
+ LayoutRegistry[Name] = LayoutFunc
+end
+
+--- Get a Layout Function from the registry
+-- @param Name The name of the layout
+function AceGUI:GetLayout(Name)
+ if type(Name) == "string" then
+ Name = Name:upper()
+ end
+ return LayoutRegistry[Name]
+end
+
+AceGUI.counts = AceGUI.counts or {}
+
+--- A type-based counter to count the number of widgets created.
+-- This is used by widgets that require a named frame, e.g. when a Blizzard
+-- Template requires it.
+-- @param type The widget type
+function AceGUI:GetNextWidgetNum(widgetType)
+ if not self.counts[widgetType] then
+ self.counts[widgetType] = 0
+ end
+ self.counts[widgetType] = self.counts[widgetType] + 1
+ return self.counts[widgetType]
+end
+
+--- Return the number of created widgets for this type.
+-- In contrast to GetNextWidgetNum, the number is not incremented.
+-- @param widgetType The widget type
+function AceGUI:GetWidgetCount(widgetType)
+ return self.counts[widgetType] or 0
+end
+
+--- Return the version of the currently registered widget type.
+-- @param widgetType The widget type
+function AceGUI:GetWidgetVersion(widgetType)
+ return WidgetVersions[widgetType]
+end
+
+-------------
+-- Layouts --
+-------------
+
+--[[
+ A Layout is a func that takes 2 parameters
+ content - the frame that widgets will be placed inside
+ children - a table containing the widgets to layout
+]]
+
+-- Very simple Layout, Children are stacked on top of each other down the left side
+AceGUI:RegisterLayout("List",
+ function(content, children)
+ local height = 0
+ local width = content.width or content:GetWidth() or 0
+ for i = 1, #children do
+ local child = children[i]
+
+ local frame = child.frame
+ frame:ClearAllPoints()
+ frame:Show()
+ if i == 1 then
+ frame:SetPoint("TOPLEFT", content)
+ else
+ frame:SetPoint("TOPLEFT", children[i-1].frame, "BOTTOMLEFT")
+ end
+
+ if child.width == "fill" then
+ child:SetWidth(width)
+ frame:SetPoint("RIGHT", content)
+
+ if child.DoLayout then
+ child:DoLayout()
+ end
+ elseif child.width == "relative" then
+ child:SetWidth(width * child.relWidth)
+
+ if child.DoLayout then
+ child:DoLayout()
+ end
+ end
+
+ height = height + (frame.height or frame:GetHeight() or 0)
+ end
+ safecall(content.obj.LayoutFinished, content.obj, nil, height)
+ end)
+
+-- A single control fills the whole content area
+AceGUI:RegisterLayout("Fill",
+ function(content, children)
+ if children[1] then
+ children[1]:SetWidth(content:GetWidth() or 0)
+ children[1]:SetHeight(content:GetHeight() or 0)
+ children[1].frame:ClearAllPoints()
+ children[1].frame:SetAllPoints(content)
+ children[1].frame:Show()
+ safecall(content.obj.LayoutFinished, content.obj, nil, children[1].frame:GetHeight())
+ end
+ end)
+
+local layoutrecursionblock = nil
+local function safelayoutcall(object, func, ...)
+ layoutrecursionblock = true
+ object[func](object, ...)
+ layoutrecursionblock = nil
+end
+
+AceGUI:RegisterLayout("Flow",
+ function(content, children)
+ if layoutrecursionblock then return end
+ --used height so far
+ local height = 0
+ --width used in the current row
+ local usedwidth = 0
+ --height of the current row
+ local rowheight = 0
+ local rowoffset = 0
+
+ local width = content.width or content:GetWidth() or 0
+
+ --control at the start of the row
+ local rowstart
+ local rowstartoffset
+ local isfullheight
+
+ local frameoffset
+ local lastframeoffset
+ local oversize
+ for i = 1, #children do
+ local child = children[i]
+ oversize = nil
+ local frame = child.frame
+ local frameheight = frame.height or frame:GetHeight() or 0
+ local framewidth = frame.width or frame:GetWidth() or 0
+ lastframeoffset = frameoffset
+ -- HACK: Why did we set a frameoffset of (frameheight / 2) ?
+ -- That was moving all widgets half the widgets size down, is that intended?
+ -- Actually, it seems to be neccessary for many cases, we'll leave it in for now.
+ -- If widgets seem to anchor weirdly with this, provide a valid alignoffset for them.
+ -- TODO: Investigate moar!
+ frameoffset = child.alignoffset or (frameheight / 2)
+
+ if child.width == "relative" then
+ framewidth = width * child.relWidth
+ end
+
+ frame:Show()
+ frame:ClearAllPoints()
+ if i == 1 then
+ -- anchor the first control to the top left
+ frame:SetPoint("TOPLEFT", content)
+ rowheight = frameheight
+ rowoffset = frameoffset
+ rowstart = frame
+ rowstartoffset = frameoffset
+ usedwidth = framewidth
+ if usedwidth > width then
+ oversize = true
+ end
+ else
+ -- if there isn't available width for the control start a new row
+ -- if a control is "fill" it will be on a row of its own full width
+ if usedwidth == 0 or ((framewidth) + usedwidth > width) or child.width == "fill" then
+ if isfullheight then
+ -- a previous row has already filled the entire height, there's nothing we can usefully do anymore
+ -- (maybe error/warn about this?)
+ break
+ end
+ --anchor the previous row, we will now know its height and offset
+ rowstart:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -(height + (rowoffset - rowstartoffset) + 3))
+ height = height + rowheight + 3
+ --save this as the rowstart so we can anchor it after the row is complete and we have the max height and offset of controls in it
+ rowstart = frame
+ rowstartoffset = frameoffset
+ rowheight = frameheight
+ rowoffset = frameoffset
+ usedwidth = framewidth
+ if usedwidth > width then
+ oversize = true
+ end
+ -- put the control on the current row, adding it to the width and checking if the height needs to be increased
+ else
+ --handles cases where the new height is higher than either control because of the offsets
+ --math.max(rowheight-rowoffset+frameoffset, frameheight-frameoffset+rowoffset)
+
+ --offset is always the larger of the two offsets
+ rowoffset = math_max(rowoffset, frameoffset)
+ rowheight = math_max(rowheight, rowoffset + (frameheight / 2))
+
+ frame:SetPoint("TOPLEFT", children[i-1].frame, "TOPRIGHT", 0, frameoffset - lastframeoffset)
+ usedwidth = framewidth + usedwidth
+ end
+ end
+
+ if child.width == "fill" then
+ safelayoutcall(child, "SetWidth", width)
+ frame:SetPoint("RIGHT", content)
+
+ usedwidth = 0
+ rowstart = frame
+
+ if child.DoLayout then
+ child:DoLayout()
+ end
+ rowheight = frame.height or frame:GetHeight() or 0
+ rowoffset = child.alignoffset or (rowheight / 2)
+ rowstartoffset = rowoffset
+ elseif child.width == "relative" then
+ safelayoutcall(child, "SetWidth", width * child.relWidth)
+
+ if child.DoLayout then
+ child:DoLayout()
+ end
+ elseif oversize then
+ if width > 1 then
+ frame:SetPoint("RIGHT", content)
+ end
+ end
+
+ if child.height == "fill" then
+ frame:SetPoint("BOTTOM", content)
+ isfullheight = true
+ end
+ end
+
+ --anchor the last row, if its full height needs a special case since its height has just been changed by the anchor
+ if isfullheight then
+ rowstart:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -height)
+ elseif rowstart then
+ rowstart:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -(height + (rowoffset - rowstartoffset) + 3))
+ end
+
+ height = height + rowheight + 3
+ safecall(content.obj.LayoutFinished, content.obj, nil, height)
+ end)
+
+-- Get alignment method and value. Possible alignment methods are a callback, a number, "start", "middle", "end", "fill" or "TOPLEFT", "BOTTOMRIGHT" etc.
+local GetCellAlign = function (dir, tableObj, colObj, cellObj, cell, child)
+ local fn = cellObj and (cellObj["align" .. dir] or cellObj.align)
+ or colObj and (colObj["align" .. dir] or colObj.align)
+ or tableObj["align" .. dir] or tableObj.align
+ or "CENTERLEFT"
+ local val
+ child, cell = child or 0, cell or 0
+
+ if type(fn) == "string" then
+ fn = fn:lower()
+ fn = dir == "V" and (fn:sub(1, 3) == "top" and "start" or fn:sub(1, 6) == "bottom" and "end" or fn:sub(1, 6) == "center" and "middle")
+ or dir == "H" and (fn:sub(-4) == "left" and "start" or fn:sub(-5) == "right" and "end" or fn:sub(-6) == "center" and "middle")
+ or fn
+ val = (fn == "start" or fn == "fill") and 0 or fn == "end" and cell - child or (cell - child) / 2
+ elseif type(fn) == "function" then
+ val = fn(child or 0, cell, dir)
+ else
+ val = fn
+ end
+
+ return fn, math_max(0, math_min(val, cell))
+end
+
+-- Get width or height for multiple cells combined
+local GetCellDimension = function (dir, laneDim, from, to, space)
+ local dim = 0
+ for cell=from,to do
+ dim = dim + (laneDim[cell] or 0)
+ end
+ return dim + math_max(0, to - from) * (space or 0)
+end
+
+--[[ Options
+============
+Container:
+ - columns ({col, col, ...}): Column settings. "col" can be a number (<= 0: content width, <1: rel. width, <10: weight, >=10: abs. width) or a table with column setting.
+ - space, spaceH, spaceV: Overall, horizontal and vertical spacing between cells.
+ - align, alignH, alignV: Overall, horizontal and vertical cell alignment. See GetCellAlign() for possible values.
+Columns:
+ - width: Fixed column width (nil or <=0: content width, <1: rel. width, >=1: abs. width).
+ - min or 1: Min width for content based width
+ - max or 2: Max width for content based width
+ - weight: Flexible column width. The leftover width after accounting for fixed-width columns is distributed to weighted columns according to their weights.
+ - align, alignH, alignV: Overwrites the container setting for alignment.
+Cell:
+ - colspan: Makes a cell span multiple columns.
+ - rowspan: Makes a cell span multiple rows.
+ - align, alignH, alignV: Overwrites the container and column setting for alignment.
+]]
+AceGUI:RegisterLayout("Table",
+ function (content, children)
+ local obj = content.obj
+ obj:PauseLayout()
+
+ local tableObj = obj:GetUserData("table")
+ local cols = tableObj.columns
+ local spaceH = tableObj.spaceH or tableObj.space or 0
+ local spaceV = tableObj.spaceV or tableObj.space or 0
+ local totalH = (content:GetWidth() or content.width or 0) - spaceH * (#cols - 1)
+
+ -- We need to reuse these because layout events can come in very frequently
+ local layoutCache = obj:GetUserData("layoutCache")
+ if not layoutCache then
+ layoutCache = {{}, {}, {}, {}, {}, {}}
+ obj:SetUserData("layoutCache", layoutCache)
+ end
+ local t, laneH, laneV, rowspans, rowStart, colStart = unpack(layoutCache)
+
+ -- Create the grid
+ local n, slotFound = 0
+ for i,child in ipairs(children) do
+ if child:IsShown() then
+ repeat
+ n = n + 1
+ local col = (n - 1) % #cols + 1
+ local row = math_ceil(n / #cols)
+ local rowspan = rowspans[col]
+ local cell = rowspan and rowspan.child or child
+ local cellObj = cell:GetUserData("cell")
+ slotFound = not rowspan
+
+ -- Rowspan
+ if not rowspan and cellObj and cellObj.rowspan then
+ rowspan = {child = child, from = row, to = row + cellObj.rowspan - 1}
+ rowspans[col] = rowspan
+ end
+ if rowspan and i == #children then
+ rowspan.to = row
+ end
+
+ -- Colspan
+ local colspan = math_max(0, math_min((cellObj and cellObj.colspan or 1) - 1, #cols - col))
+ n = n + colspan
+
+ -- Place the cell
+ if not rowspan or rowspan.to == row then
+ t[n] = cell
+ rowStart[cell] = rowspan and rowspan.from or row
+ colStart[cell] = col
+
+ if rowspan then
+ rowspans[col] = nil
+ end
+ end
+ until slotFound
+ end
+ end
+
+ local rows = math_ceil(n / #cols)
+
+ -- Determine fixed size cols and collect weights
+ local extantH, totalWeight = totalH, 0
+ for col,colObj in ipairs(cols) do
+ laneH[col] = 0
+
+ if type(colObj) == "number" then
+ colObj = {[colObj >= 1 and colObj < 10 and "weight" or "width"] = colObj}
+ cols[col] = colObj
+ end
+
+ if colObj.weight then
+ -- Weight
+ totalWeight = totalWeight + (colObj.weight or 1)
+ else
+ if not colObj.width or colObj.width <= 0 then
+ -- Content width
+ for row=1,rows do
+ local child = t[(row - 1) * #cols + col]
+ if child then
+ local f = child.frame
+ f:ClearAllPoints()
+ local childH = f:GetWidth() or 0
+
+ laneH[col] = math_max(laneH[col], childH - GetCellDimension("H", laneH, colStart[child], col - 1, spaceH))
+ end
+ end
+
+ laneH[col] = math_max(colObj.min or colObj[1] or 0, math_min(laneH[col], colObj.max or colObj[2] or laneH[col]))
+ else
+ -- Rel./Abs. width
+ laneH[col] = colObj.width < 1 and colObj.width * totalH or colObj.width
+ end
+ extantH = math_max(0, extantH - laneH[col])
+ end
+ end
+
+ -- Determine sizes based on weight
+ local scale = totalWeight > 0 and extantH / totalWeight or 0
+ for col,colObj in pairs(cols) do
+ if colObj.weight then
+ laneH[col] = scale * colObj.weight
+ end
+ end
+
+ -- Arrange children
+ for row=1,rows do
+ local rowV = 0
+
+ -- Horizontal placement and sizing
+ for col=1,#cols do
+ local child = t[(row - 1) * #cols + col]
+ if child then
+ local colObj = cols[colStart[child]]
+ local cellObj = child:GetUserData("cell")
+ local offsetH = GetCellDimension("H", laneH, 1, colStart[child] - 1, spaceH) + (colStart[child] == 1 and 0 or spaceH)
+ local cellH = GetCellDimension("H", laneH, colStart[child], col, spaceH)
+
+ local f = child.frame
+ f:ClearAllPoints()
+ local childH = f:GetWidth() or 0
+
+ local alignFn, align = GetCellAlign("H", tableObj, colObj, cellObj, cellH, childH)
+ f:SetPoint("LEFT", content, offsetH + align, 0)
+ if child:IsFullWidth() or alignFn == "fill" or childH > cellH then
+ f:SetPoint("RIGHT", content, "LEFT", offsetH + align + cellH, 0)
+ end
+
+ if child.DoLayout then
+ child:DoLayout()
+ end
+
+ rowV = math_max(rowV, (f:GetHeight() or 0) - GetCellDimension("V", laneV, rowStart[child], row - 1, spaceV))
+ end
+ end
+
+ laneV[row] = rowV
+
+ -- Vertical placement and sizing
+ for col=1,#cols do
+ local child = t[(row - 1) * #cols + col]
+ if child then
+ local colObj = cols[colStart[child]]
+ local cellObj = child:GetUserData("cell")
+ local offsetV = GetCellDimension("V", laneV, 1, rowStart[child] - 1, spaceV) + (rowStart[child] == 1 and 0 or spaceV)
+ local cellV = GetCellDimension("V", laneV, rowStart[child], row, spaceV)
+
+ local f = child.frame
+ local childV = f:GetHeight() or 0
+
+ local alignFn, align = GetCellAlign("V", tableObj, colObj, cellObj, cellV, childV)
+ if child:IsFullHeight() or alignFn == "fill" then
+ f:SetHeight(cellV)
+ end
+ f:SetPoint("TOP", content, 0, -(offsetV + align))
+ end
+ end
+ end
+
+ -- Calculate total height
+ local totalV = GetCellDimension("V", laneV, 1, #laneV, spaceV)
+
+ -- Cleanup
+ for _,v in pairs(layoutCache) do wipe(v) end
+
+ safecall(obj.LayoutFinished, obj, nil, totalV)
+ obj:ResumeLayout()
+ end)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/AceGUI-3.0.xml b/Broker2FuBar/libs/AceGUI-3.0/AceGUI-3.0.xml
new file mode 100644
index 0000000..ae22c90
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/AceGUI-3.0.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua
new file mode 100644
index 0000000..bf1eae7
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua
@@ -0,0 +1,143 @@
+--[[-----------------------------------------------------------------------------
+BlizOptionsGroup Container
+Simple container widget for the integration of AceGUI into the Blizzard Interface Options
+-------------------------------------------------------------------------------]]
+local Type, Version = "BlizOptionsGroup", 26
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local CreateFrame = CreateFrame
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+
+local function OnShow(frame)
+ frame.obj:Fire("OnShow")
+end
+
+local function OnHide(frame)
+ frame.obj:Fire("OnHide")
+end
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+
+local function okay(frame)
+ frame.obj:Fire("okay")
+end
+
+local function cancel(frame)
+ frame.obj:Fire("cancel")
+end
+
+local function default(frame)
+ frame.obj:Fire("default")
+end
+
+local function refresh(frame)
+ frame.obj:Fire("refresh")
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetName()
+ self:SetTitle()
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ local contentwidth = width - 63
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - 26
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end,
+
+ ["SetName"] = function(self, name, parent)
+ self.frame.name = name
+ self.frame.parent = parent
+ end,
+
+ ["SetTitle"] = function(self, title)
+ local content = self.content
+ content:ClearAllPoints()
+ if not title or title == "" then
+ content:SetPoint("TOPLEFT", 10, -10)
+ self.label:SetText("")
+ else
+ content:SetPoint("TOPLEFT", 10, -40)
+ self.label:SetText(title)
+ end
+ content:SetPoint("BOTTOMRIGHT", -10, 10)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
+ frame:Hide()
+
+ -- support functions for the Blizzard Interface Options
+ frame.okay = okay
+ frame.cancel = cancel
+ frame.default = default
+ frame.refresh = refresh
+
+ -- 10.0 support function aliases (cancel has been removed)
+ frame.OnCommit = okay
+ frame.OnDefault = default
+ frame.OnRefresh = refresh
+
+ frame:SetScript("OnHide", OnHide)
+ frame:SetScript("OnShow", OnShow)
+
+ local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
+ label:SetPoint("TOPLEFT", 10, -15)
+ label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)
+ label:SetJustifyH("LEFT")
+ label:SetJustifyV("TOP")
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, frame)
+ content:SetPoint("TOPLEFT", 10, -10)
+ content:SetPoint("BOTTOMRIGHT", -10, 10)
+
+ local widget = {
+ label = label,
+ frame = frame,
+ content = content,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua
new file mode 100644
index 0000000..2322e3d
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua
@@ -0,0 +1,157 @@
+--[[-----------------------------------------------------------------------------
+DropdownGroup Container
+Container controlled by a dropdown on the top.
+-------------------------------------------------------------------------------]]
+local Type, Version = "DropdownGroup", 22
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local assert, pairs, type = assert, pairs, type
+
+-- WoW APIs
+local CreateFrame = CreateFrame
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function SelectedGroup(self, event, value)
+ local group = self.parentgroup
+ local status = group.status or group.localstatus
+ status.selected = value
+ self.parentgroup:Fire("OnGroupSelected", value)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self.dropdown:SetText("")
+ self:SetDropdownWidth(200)
+ self:SetTitle("")
+ end,
+
+ ["OnRelease"] = function(self)
+ self.dropdown.list = nil
+ self.status = nil
+ for k in pairs(self.localstatus) do
+ self.localstatus[k] = nil
+ end
+ end,
+
+ ["SetTitle"] = function(self, title)
+ self.titletext:SetText(title)
+ self.dropdown.frame:ClearAllPoints()
+ if title and title ~= "" then
+ self.dropdown.frame:SetPoint("TOPRIGHT", -2, 0)
+ else
+ self.dropdown.frame:SetPoint("TOPLEFT", -1, 0)
+ end
+ end,
+
+ ["SetGroupList"] = function(self,list,order)
+ self.dropdown:SetList(list,order)
+ end,
+
+ ["SetStatusTable"] = function(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ end,
+
+ ["SetGroup"] = function(self,group)
+ self.dropdown:SetValue(group)
+ local status = self.status or self.localstatus
+ status.selected = group
+ self:Fire("OnGroupSelected", group)
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ local contentwidth = width - 26
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - 63
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end,
+
+ ["LayoutFinished"] = function(self, width, height)
+ self:SetHeight((height or 0) + 63)
+ end,
+
+ ["SetDropdownWidth"] = function(self, width)
+ self.dropdown:SetWidth(width)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local PaneBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 5, bottom = 3 }
+}
+
+local function Constructor()
+ local frame = CreateFrame("Frame")
+ frame:SetHeight(100)
+ frame:SetWidth(100)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ titletext:SetPoint("TOPLEFT", 4, -5)
+ titletext:SetPoint("TOPRIGHT", -4, -5)
+ titletext:SetJustifyH("LEFT")
+ titletext:SetHeight(18)
+
+ local dropdown = AceGUI:Create("Dropdown")
+ dropdown.frame:SetParent(frame)
+ dropdown.frame:SetFrameLevel(dropdown.frame:GetFrameLevel() + 2)
+ dropdown:SetCallback("OnValueChanged", SelectedGroup)
+ dropdown.frame:SetPoint("TOPLEFT", -1, 0)
+ dropdown.frame:Show()
+ dropdown:SetLabel("")
+
+ local border = CreateFrame("Frame", nil, frame, "BackdropTemplate")
+ border:SetPoint("TOPLEFT", 0, -26)
+ border:SetPoint("BOTTOMRIGHT", 0, 3)
+ border:SetBackdrop(PaneBackdrop)
+ border:SetBackdropColor(0.1,0.1,0.1,0.5)
+ border:SetBackdropBorderColor(0.4,0.4,0.4)
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, border)
+ content:SetPoint("TOPLEFT", 10, -10)
+ content:SetPoint("BOTTOMRIGHT", -10, 10)
+
+ local widget = {
+ frame = frame,
+ localstatus = {},
+ titletext = titletext,
+ dropdown = dropdown,
+ border = border,
+ content = content,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ dropdown.parentgroup = widget
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua
new file mode 100644
index 0000000..ca90890
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua
@@ -0,0 +1,318 @@
+--[[-----------------------------------------------------------------------------
+Frame Container
+-------------------------------------------------------------------------------]]
+local Type, Version = "Frame", 30
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs, assert, type = pairs, assert, type
+local wipe = table.wipe
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Button_OnClick(frame)
+ PlaySound(799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
+ frame.obj:Hide()
+end
+
+local function Frame_OnShow(frame)
+ frame.obj:Fire("OnShow")
+end
+
+local function Frame_OnClose(frame)
+ frame.obj:Fire("OnClose")
+end
+
+local function Frame_OnMouseDown(frame)
+ AceGUI:ClearFocus()
+end
+
+local function Title_OnMouseDown(frame)
+ frame:GetParent():StartMoving()
+ AceGUI:ClearFocus()
+end
+
+local function MoverSizer_OnMouseUp(mover)
+ local frame = mover:GetParent()
+ frame:StopMovingOrSizing()
+ local self = frame.obj
+ local status = self.status or self.localstatus
+ status.width = frame:GetWidth()
+ status.height = frame:GetHeight()
+ status.top = frame:GetTop()
+ status.left = frame:GetLeft()
+end
+
+local function SizerSE_OnMouseDown(frame)
+ frame:GetParent():StartSizing("BOTTOMRIGHT")
+ AceGUI:ClearFocus()
+end
+
+local function SizerS_OnMouseDown(frame)
+ frame:GetParent():StartSizing("BOTTOM")
+ AceGUI:ClearFocus()
+end
+
+local function SizerE_OnMouseDown(frame)
+ frame:GetParent():StartSizing("RIGHT")
+ AceGUI:ClearFocus()
+end
+
+local function StatusBar_OnEnter(frame)
+ frame.obj:Fire("OnEnterStatusBar")
+end
+
+local function StatusBar_OnLeave(frame)
+ frame.obj:Fire("OnLeaveStatusBar")
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self.frame:SetParent(UIParent)
+ self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ self.frame:SetFrameLevel(100) -- Lots of room to draw under it
+ self:SetTitle()
+ self:SetStatusText()
+ self:ApplyStatus()
+ self:Show()
+ self:EnableResize(true)
+ end,
+
+ ["OnRelease"] = function(self)
+ self.status = nil
+ wipe(self.localstatus)
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ local contentwidth = width - 34
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - 57
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end,
+
+ ["SetTitle"] = function(self, title)
+ self.titletext:SetText(title)
+ self.titlebg:SetWidth((self.titletext:GetWidth() or 0) + 10)
+ end,
+
+ ["SetStatusText"] = function(self, text)
+ self.statustext:SetText(text)
+ end,
+
+ ["Hide"] = function(self)
+ self.frame:Hide()
+ end,
+
+ ["Show"] = function(self)
+ self.frame:Show()
+ end,
+
+ ["EnableResize"] = function(self, state)
+ local func = state and "Show" or "Hide"
+ self.sizer_se[func](self.sizer_se)
+ self.sizer_s[func](self.sizer_s)
+ self.sizer_e[func](self.sizer_e)
+ end,
+
+ -- called to set an external table to store status in
+ ["SetStatusTable"] = function(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ self:ApplyStatus()
+ end,
+
+ ["ApplyStatus"] = function(self)
+ local status = self.status or self.localstatus
+ local frame = self.frame
+ self:SetWidth(status.width or 700)
+ self:SetHeight(status.height or 500)
+ frame:ClearAllPoints()
+ if status.top and status.left then
+ frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top)
+ frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0)
+ else
+ frame:SetPoint("CENTER")
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local FrameBackdrop = {
+ bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
+ edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
+ tile = true, tileSize = 32, edgeSize = 32,
+ insets = { left = 8, right = 8, top = 8, bottom = 8 }
+}
+
+local PaneBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 5, bottom = 3 }
+}
+
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
+ frame:Hide()
+
+ frame:EnableMouse(true)
+ frame:SetMovable(true)
+ frame:SetResizable(true)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ frame:SetFrameLevel(100) -- Lots of room to draw under it
+ frame:SetBackdrop(FrameBackdrop)
+ frame:SetBackdropColor(0, 0, 0, 1)
+ if frame.SetResizeBounds then -- WoW 10.0
+ frame:SetResizeBounds(400, 200)
+ else
+ frame:SetMinResize(400, 200)
+ end
+ frame:SetToplevel(true)
+ frame:SetScript("OnShow", Frame_OnShow)
+ frame:SetScript("OnHide", Frame_OnClose)
+ frame:SetScript("OnMouseDown", Frame_OnMouseDown)
+
+ local closebutton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
+ closebutton:SetScript("OnClick", Button_OnClick)
+ closebutton:SetPoint("BOTTOMRIGHT", -27, 17)
+ closebutton:SetHeight(20)
+ closebutton:SetWidth(100)
+ closebutton:SetText(CLOSE)
+
+ local statusbg = CreateFrame("Button", nil, frame, "BackdropTemplate")
+ statusbg:SetPoint("BOTTOMLEFT", 15, 15)
+ statusbg:SetPoint("BOTTOMRIGHT", -132, 15)
+ statusbg:SetHeight(24)
+ statusbg:SetBackdrop(PaneBackdrop)
+ statusbg:SetBackdropColor(0.1,0.1,0.1)
+ statusbg:SetBackdropBorderColor(0.4,0.4,0.4)
+ statusbg:SetScript("OnEnter", StatusBar_OnEnter)
+ statusbg:SetScript("OnLeave", StatusBar_OnLeave)
+
+ local statustext = statusbg:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ statustext:SetPoint("TOPLEFT", 7, -2)
+ statustext:SetPoint("BOTTOMRIGHT", -7, 2)
+ statustext:SetHeight(20)
+ statustext:SetJustifyH("LEFT")
+ statustext:SetText("")
+
+ local titlebg = frame:CreateTexture(nil, "OVERLAY")
+ titlebg:SetTexture(131080) -- Interface\\DialogFrame\\UI-DialogBox-Header
+ titlebg:SetTexCoord(0.31, 0.67, 0, 0.63)
+ titlebg:SetPoint("TOP", 0, 12)
+ titlebg:SetWidth(100)
+ titlebg:SetHeight(40)
+
+ local title = CreateFrame("Frame", nil, frame)
+ title:EnableMouse(true)
+ title:SetScript("OnMouseDown", Title_OnMouseDown)
+ title:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
+ title:SetAllPoints(titlebg)
+
+ local titletext = title:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ titletext:SetPoint("TOP", titlebg, "TOP", 0, -14)
+
+ local titlebg_l = frame:CreateTexture(nil, "OVERLAY")
+ titlebg_l:SetTexture(131080) -- Interface\\DialogFrame\\UI-DialogBox-Header
+ titlebg_l:SetTexCoord(0.21, 0.31, 0, 0.63)
+ titlebg_l:SetPoint("RIGHT", titlebg, "LEFT")
+ titlebg_l:SetWidth(30)
+ titlebg_l:SetHeight(40)
+
+ local titlebg_r = frame:CreateTexture(nil, "OVERLAY")
+ titlebg_r:SetTexture(131080) -- Interface\\DialogFrame\\UI-DialogBox-Header
+ titlebg_r:SetTexCoord(0.67, 0.77, 0, 0.63)
+ titlebg_r:SetPoint("LEFT", titlebg, "RIGHT")
+ titlebg_r:SetWidth(30)
+ titlebg_r:SetHeight(40)
+
+ local sizer_se = CreateFrame("Frame", nil, frame)
+ sizer_se:SetPoint("BOTTOMRIGHT")
+ sizer_se:SetWidth(25)
+ sizer_se:SetHeight(25)
+ sizer_se:EnableMouse()
+ sizer_se:SetScript("OnMouseDown",SizerSE_OnMouseDown)
+ sizer_se:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
+
+ local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
+ line1:SetWidth(14)
+ line1:SetHeight(14)
+ line1:SetPoint("BOTTOMRIGHT", -8, 8)
+ line1:SetTexture(137057) -- Interface\\Tooltips\\UI-Tooltip-Border
+ local x = 0.1 * 14/17
+ line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
+
+ local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
+ line2:SetWidth(8)
+ line2:SetHeight(8)
+ line2:SetPoint("BOTTOMRIGHT", -8, 8)
+ line2:SetTexture(137057) -- Interface\\Tooltips\\UI-Tooltip-Border
+ x = 0.1 * 8/17
+ line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
+
+ local sizer_s = CreateFrame("Frame", nil, frame)
+ sizer_s:SetPoint("BOTTOMRIGHT", -25, 0)
+ sizer_s:SetPoint("BOTTOMLEFT")
+ sizer_s:SetHeight(25)
+ sizer_s:EnableMouse(true)
+ sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown)
+ sizer_s:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
+
+ local sizer_e = CreateFrame("Frame", nil, frame)
+ sizer_e:SetPoint("BOTTOMRIGHT", 0, 25)
+ sizer_e:SetPoint("TOPRIGHT")
+ sizer_e:SetWidth(25)
+ sizer_e:EnableMouse(true)
+ sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown)
+ sizer_e:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, frame)
+ content:SetPoint("TOPLEFT", 17, -27)
+ content:SetPoint("BOTTOMRIGHT", -17, 40)
+
+ local widget = {
+ localstatus = {},
+ titletext = titletext,
+ statustext = statustext,
+ titlebg = titlebg,
+ sizer_se = sizer_se,
+ sizer_s = sizer_s,
+ sizer_e = sizer_e,
+ content = content,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ closebutton.obj, statusbg.obj = widget, widget
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua
new file mode 100644
index 0000000..04b4d5d
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua
@@ -0,0 +1,103 @@
+--[[-----------------------------------------------------------------------------
+InlineGroup Container
+Simple container widget that creates a visible "box" with an optional title.
+-------------------------------------------------------------------------------]]
+local Type, Version = "InlineGroup", 22
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetWidth(300)
+ self:SetHeight(100)
+ self:SetTitle("")
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetTitle"] = function(self,title)
+ self.titletext:SetText(title)
+ end,
+
+
+ ["LayoutFinished"] = function(self, width, height)
+ if self.noAutoHeight then return end
+ self:SetHeight((height or 0) + 40)
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ local contentwidth = width - 20
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - 20
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local PaneBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 5, bottom = 3 }
+}
+
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ titletext:SetPoint("TOPLEFT", 14, 0)
+ titletext:SetPoint("TOPRIGHT", -14, 0)
+ titletext:SetJustifyH("LEFT")
+ titletext:SetHeight(18)
+
+ local border = CreateFrame("Frame", nil, frame, "BackdropTemplate")
+ border:SetPoint("TOPLEFT", 0, -17)
+ border:SetPoint("BOTTOMRIGHT", -1, 3)
+ border:SetBackdrop(PaneBackdrop)
+ border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
+ border:SetBackdropBorderColor(0.4, 0.4, 0.4)
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, border)
+ content:SetPoint("TOPLEFT", 10, -10)
+ content:SetPoint("BOTTOMRIGHT", -10, 10)
+
+ local widget = {
+ frame = frame,
+ content = content,
+ titletext = titletext,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua
new file mode 100644
index 0000000..be6052f
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua
@@ -0,0 +1,215 @@
+--[[-----------------------------------------------------------------------------
+ScrollFrame Container
+Plain container that scrolls its content and doesn't grow in height.
+-------------------------------------------------------------------------------]]
+local Type, Version = "ScrollFrame", 26
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs, assert, type = pairs, assert, type
+local min, max, floor = math.min, math.max, math.floor
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+local function FixScrollOnUpdate(frame)
+ frame:SetScript("OnUpdate", nil)
+ frame.obj:FixScroll()
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function ScrollFrame_OnMouseWheel(frame, value)
+ frame.obj:MoveScroll(value)
+end
+
+local function ScrollFrame_OnSizeChanged(frame)
+ frame:SetScript("OnUpdate", FixScrollOnUpdate)
+end
+
+local function ScrollBar_OnScrollValueChanged(frame, value)
+ frame.obj:SetScroll(value)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetScroll(0)
+ self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
+ end,
+
+ ["OnRelease"] = function(self)
+ self.status = nil
+ for k in pairs(self.localstatus) do
+ self.localstatus[k] = nil
+ end
+ self.scrollframe:SetPoint("BOTTOMRIGHT")
+ self.scrollbar:Hide()
+ self.scrollBarShown = nil
+ self.content.height, self.content.width, self.content.original_width = nil, nil, nil
+ end,
+
+ ["SetScroll"] = function(self, value)
+ local status = self.status or self.localstatus
+ local viewheight = self.scrollframe:GetHeight()
+ local height = self.content:GetHeight()
+ local offset
+
+ if viewheight > height then
+ offset = 0
+ else
+ offset = floor((height - viewheight) / 1000.0 * value)
+ end
+ self.content:ClearAllPoints()
+ self.content:SetPoint("TOPLEFT", 0, offset)
+ self.content:SetPoint("TOPRIGHT", 0, offset)
+ status.offset = offset
+ status.scrollvalue = value
+ end,
+
+ ["MoveScroll"] = function(self, value)
+ local status = self.status or self.localstatus
+ local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
+
+ if self.scrollBarShown then
+ local diff = height - viewheight
+ local delta = 1
+ if value < 0 then
+ delta = -1
+ end
+ self.scrollbar:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
+ end
+ end,
+
+ ["FixScroll"] = function(self)
+ if self.updateLock then return end
+ self.updateLock = true
+ local status = self.status or self.localstatus
+ local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
+ local offset = status.offset or 0
+ -- Give us a margin of error of 2 pixels to stop some conditions that i would blame on floating point inaccuracys
+ -- No-one is going to miss 2 pixels at the bottom of the frame, anyhow!
+ if viewheight < height + 2 then
+ if self.scrollBarShown then
+ self.scrollBarShown = nil
+ self.scrollbar:Hide()
+ self.scrollbar:SetValue(0)
+ self.scrollframe:SetPoint("BOTTOMRIGHT")
+ if self.content.original_width then
+ self.content.width = self.content.original_width
+ end
+ self:DoLayout()
+ end
+ else
+ if not self.scrollBarShown then
+ self.scrollBarShown = true
+ self.scrollbar:Show()
+ self.scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
+ if self.content.original_width then
+ self.content.width = self.content.original_width - 20
+ end
+ self:DoLayout()
+ end
+ local value = (offset / (viewheight - height) * 1000)
+ if value > 1000 then value = 1000 end
+ self.scrollbar:SetValue(value)
+ self:SetScroll(value)
+ if value < 1000 then
+ self.content:ClearAllPoints()
+ self.content:SetPoint("TOPLEFT", 0, offset)
+ self.content:SetPoint("TOPRIGHT", 0, offset)
+ status.offset = offset
+ end
+ end
+ self.updateLock = nil
+ end,
+
+ ["LayoutFinished"] = function(self, width, height)
+ self.content:SetHeight(height or 0 + 20)
+
+ -- update the scrollframe
+ self:FixScroll()
+
+ -- schedule another update when everything has "settled"
+ self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
+ end,
+
+ ["SetStatusTable"] = function(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ if not status.scrollvalue then
+ status.scrollvalue = 0
+ end
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ content.width = width - (self.scrollBarShown and 20 or 0)
+ content.original_width = width
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ content.height = height
+ end
+}
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ local num = AceGUI:GetNextWidgetNum(Type)
+
+ local scrollframe = CreateFrame("ScrollFrame", nil, frame)
+ scrollframe:SetPoint("TOPLEFT")
+ scrollframe:SetPoint("BOTTOMRIGHT")
+ scrollframe:EnableMouseWheel(true)
+ scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
+ scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
+
+ local scrollbar = CreateFrame("Slider", ("AceConfigDialogScrollFrame%dScrollBar"):format(num), scrollframe, "UIPanelScrollBarTemplate")
+ scrollbar:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, -16)
+ scrollbar:SetPoint("BOTTOMLEFT", scrollframe, "BOTTOMRIGHT", 4, 16)
+ scrollbar:SetMinMaxValues(0, 1000)
+ scrollbar:SetValueStep(1)
+ scrollbar:SetValue(0)
+ scrollbar:SetWidth(16)
+ scrollbar:Hide()
+ -- set the script as the last step, so it doesn't fire yet
+ scrollbar:SetScript("OnValueChanged", ScrollBar_OnScrollValueChanged)
+
+ local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
+ scrollbg:SetAllPoints(scrollbar)
+ scrollbg:SetColorTexture(0, 0, 0, 0.4)
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, scrollframe)
+ content:SetPoint("TOPLEFT")
+ content:SetPoint("TOPRIGHT")
+ content:SetHeight(400)
+ scrollframe:SetScrollChild(content)
+
+ local widget = {
+ localstatus = { scrollvalue = 0 },
+ scrollframe = scrollframe,
+ scrollbar = scrollbar,
+ content = content,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ scrollframe.obj, scrollbar.obj = widget, widget
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua
new file mode 100644
index 0000000..6e23abc
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua
@@ -0,0 +1,69 @@
+--[[-----------------------------------------------------------------------------
+SimpleGroup Container
+Simple container widget that just groups widgets.
+-------------------------------------------------------------------------------]]
+local Type, Version = "SimpleGroup", 20
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetWidth(300)
+ self:SetHeight(100)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["LayoutFinished"] = function(self, width, height)
+ if self.noAutoHeight then return end
+ self:SetHeight(height or 0)
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ content:SetWidth(width)
+ content.width = width
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ content:SetHeight(height)
+ content.height = height
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, frame)
+ content:SetPoint("TOPLEFT")
+ content:SetPoint("BOTTOMRIGHT")
+
+ local widget = {
+ frame = frame,
+ content = content,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua
new file mode 100644
index 0000000..8a5756f
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua
@@ -0,0 +1,535 @@
+--[[-----------------------------------------------------------------------------
+TabGroup Container
+Container that uses tabs on top to switch between groups.
+-------------------------------------------------------------------------------]]
+local Type, Version = "TabGroup", 38
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs, ipairs, assert, type, wipe = pairs, ipairs, assert, type, table.wipe
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame, UIParent = CreateFrame, UIParent
+local _G = _G
+
+-- local upvalue storage used by BuildTabs
+local widths = {}
+local rowwidths = {}
+local rowends = {}
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+
+local function PanelTemplates_TabResize(tab, padding, absoluteSize, minWidth, maxWidth, absoluteTextSize)
+ local tabName = tab:GetName();
+
+ local buttonMiddle = tab.Middle or tab.middleTexture or _G[tabName.."Middle"];
+ local buttonMiddleDisabled = tab.MiddleDisabled or (tabName and _G[tabName.."MiddleDisabled"]);
+ local left = tab.Left or tab.leftTexture or _G[tabName.."Left"];
+ local sideWidths = 2 * left:GetWidth();
+ local tabText = tab.Text or _G[tab:GetName().."Text"];
+ local highlightTexture = tab.HighlightTexture or (tabName and _G[tabName.."HighlightTexture"]);
+
+ local width, tabWidth;
+ local textWidth;
+ if ( absoluteTextSize ) then
+ textWidth = absoluteTextSize;
+ else
+ tabText:SetWidth(0);
+ textWidth = tabText:GetWidth();
+ end
+ -- If there's an absolute size specified then use it
+ if ( absoluteSize ) then
+ if ( absoluteSize < sideWidths) then
+ width = 1;
+ tabWidth = sideWidths
+ else
+ width = absoluteSize - sideWidths;
+ tabWidth = absoluteSize
+ end
+ tabText:SetWidth(width);
+ else
+ -- Otherwise try to use padding
+ if ( padding ) then
+ width = textWidth + padding;
+ else
+ width = textWidth + 24;
+ end
+ -- If greater than the maxWidth then cap it
+ if ( maxWidth and width > maxWidth ) then
+ if ( padding ) then
+ width = maxWidth + padding;
+ else
+ width = maxWidth + 24;
+ end
+ tabText:SetWidth(width);
+ else
+ tabText:SetWidth(0);
+ end
+ if (minWidth and width < minWidth) then
+ width = minWidth;
+ end
+ tabWidth = width + sideWidths;
+ end
+
+ if ( buttonMiddle ) then
+ buttonMiddle:SetWidth(width);
+ end
+ if ( buttonMiddleDisabled ) then
+ buttonMiddleDisabled:SetWidth(width);
+ end
+
+ tab:SetWidth(tabWidth);
+
+ if ( highlightTexture ) then
+ highlightTexture:SetWidth(tabWidth);
+ end
+end
+
+local function PanelTemplates_DeselectTab(tab)
+ local name = tab:GetName();
+
+ local left = tab.Left or _G[name.."Left"];
+ local middle = tab.Middle or _G[name.."Middle"];
+ local right = tab.Right or _G[name.."Right"];
+ left:Show();
+ middle:Show();
+ right:Show();
+ --tab:UnlockHighlight();
+ tab:Enable();
+ local text = tab.Text or _G[name.."Text"];
+ text:SetPoint("CENTER", tab, "CENTER", (tab.deselectedTextX or 0), (tab.deselectedTextY or 2));
+
+ local leftDisabled = tab.LeftDisabled or _G[name.."LeftDisabled"];
+ local middleDisabled = tab.MiddleDisabled or _G[name.."MiddleDisabled"];
+ local rightDisabled = tab.RightDisabled or _G[name.."RightDisabled"];
+ leftDisabled:Hide();
+ middleDisabled:Hide();
+ rightDisabled:Hide();
+end
+
+local function PanelTemplates_SelectTab(tab)
+ local name = tab:GetName();
+
+ local left = tab.Left or _G[name.."Left"];
+ local middle = tab.Middle or _G[name.."Middle"];
+ local right = tab.Right or _G[name.."Right"];
+ left:Hide();
+ middle:Hide();
+ right:Hide();
+ --tab:LockHighlight();
+ tab:Disable();
+ tab:SetDisabledFontObject(GameFontHighlightSmall);
+ local text = tab.Text or _G[name.."Text"];
+ text:SetPoint("CENTER", tab, "CENTER", (tab.selectedTextX or 0), (tab.selectedTextY or -3));
+
+ local leftDisabled = tab.LeftDisabled or _G[name.."LeftDisabled"];
+ local middleDisabled = tab.MiddleDisabled or _G[name.."MiddleDisabled"];
+ local rightDisabled = tab.RightDisabled or _G[name.."RightDisabled"];
+ leftDisabled:Show();
+ middleDisabled:Show();
+ rightDisabled:Show();
+
+ if GameTooltip:IsOwned(tab) then
+ GameTooltip:Hide();
+ end
+end
+
+local function PanelTemplates_SetDisabledTabState(tab)
+ local name = tab:GetName();
+ local left = tab.Left or _G[name.."Left"];
+ local middle = tab.Middle or _G[name.."Middle"];
+ local right = tab.Right or _G[name.."Right"];
+ left:Show();
+ middle:Show();
+ right:Show();
+ --tab:UnlockHighlight();
+ tab:Disable();
+ tab.text = tab:GetText();
+ -- Gray out text
+ tab:SetDisabledFontObject(GameFontDisableSmall);
+ local leftDisabled = tab.LeftDisabled or _G[name.."LeftDisabled"];
+ local middleDisabled = tab.MiddleDisabled or _G[name.."MiddleDisabled"];
+ local rightDisabled = tab.RightDisabled or _G[name.."RightDisabled"];
+ leftDisabled:Hide();
+ middleDisabled:Hide();
+ rightDisabled:Hide();
+end
+
+local function UpdateTabLook(frame)
+ if frame.disabled then
+ PanelTemplates_SetDisabledTabState(frame)
+ elseif frame.selected then
+ PanelTemplates_SelectTab(frame)
+ else
+ PanelTemplates_DeselectTab(frame)
+ end
+end
+
+local function Tab_SetText(frame, text)
+ frame:_SetText(text)
+ local width = frame.obj.frame.width or frame.obj.frame:GetWidth() or 0
+ PanelTemplates_TabResize(frame, 0, nil, nil, width, frame:GetFontString():GetStringWidth())
+end
+
+local function Tab_SetSelected(frame, selected)
+ frame.selected = selected
+ UpdateTabLook(frame)
+end
+
+local function Tab_SetDisabled(frame, disabled)
+ frame.disabled = disabled
+ UpdateTabLook(frame)
+end
+
+local function BuildTabsOnUpdate(frame)
+ local self = frame.obj
+ self:BuildTabs()
+ frame:SetScript("OnUpdate", nil)
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Tab_OnClick(frame)
+ if not (frame.selected or frame.disabled) then
+ PlaySound(841) -- SOUNDKIT.IG_CHARACTER_INFO_TAB
+ frame.obj:SelectTab(frame.value)
+ end
+end
+
+local function Tab_OnEnter(frame)
+ local self = frame.obj
+ self:Fire("OnTabEnter", self.tabs[frame.id].value, frame)
+end
+
+local function Tab_OnLeave(frame)
+ local self = frame.obj
+ self:Fire("OnTabLeave", self.tabs[frame.id].value, frame)
+end
+
+local function Tab_OnShow(frame)
+ _G[frame:GetName().."HighlightTexture"]:SetWidth(frame:GetTextWidth() + 30)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetTitle()
+ end,
+
+ ["OnRelease"] = function(self)
+ self.status = nil
+ for k in pairs(self.localstatus) do
+ self.localstatus[k] = nil
+ end
+ self.tablist = nil
+ for _, tab in pairs(self.tabs) do
+ tab:Hide()
+ end
+ end,
+
+ ["CreateTab"] = function(self, id)
+ local tabname = ("AceGUITabGroup%dTab%d"):format(self.num, id)
+ local tab = CreateFrame("Button", tabname, self.border)
+ tab:SetSize(115, 24)
+ tab.deselectedTextY = -3
+ tab.selectedTextY = -2
+
+ tab.LeftDisabled = tab:CreateTexture(tabname .. "LeftDisabled", "BORDER")
+ tab.LeftDisabled:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
+ tab.LeftDisabled:SetSize(20, 24)
+ tab.LeftDisabled:SetPoint("BOTTOMLEFT", 0, -3)
+ tab.LeftDisabled:SetTexCoord(0, 0.15625, 0, 1.0)
+
+ tab.MiddleDisabled = tab:CreateTexture(tabname .. "MiddleDisabled", "BORDER")
+ tab.MiddleDisabled:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
+ tab.MiddleDisabled:SetSize(88, 24)
+ tab.MiddleDisabled:SetPoint("LEFT", tab.LeftDisabled, "RIGHT")
+ tab.MiddleDisabled:SetTexCoord(0.15625, 0.84375, 0, 1.0)
+
+ tab.RightDisabled = tab:CreateTexture(tabname .. "RightDisabled", "BORDER")
+ tab.RightDisabled:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
+ tab.RightDisabled:SetSize(20, 24)
+ tab.RightDisabled:SetPoint("LEFT", tab.MiddleDisabled, "RIGHT")
+ tab.RightDisabled:SetTexCoord(0.84375, 1.0, 0, 1.0)
+
+ tab.Left = tab:CreateTexture(tabname .. "Left", "BORDER")
+ tab.Left:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
+ tab.Left:SetSize(20, 24)
+ tab.Left:SetPoint("TOPLEFT")
+ tab.Left:SetTexCoord(0, 0.15625, 0, 1.0)
+
+ tab.Middle = tab:CreateTexture(tabname .. "Middle", "BORDER")
+ tab.Middle:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
+ tab.Middle:SetSize(88, 24)
+ tab.Middle:SetPoint("LEFT", tab.Left, "RIGHT")
+ tab.Middle:SetTexCoord(0.15625, 0.84375, 0, 1.0)
+
+ tab.Right = tab:CreateTexture(tabname .. "Right", "BORDER")
+ tab.Right:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
+ tab.Right:SetSize(20, 24)
+ tab.Right:SetPoint("LEFT", tab.Middle, "RIGHT")
+ tab.Right:SetTexCoord(0.84375, 1.0, 0, 1.0)
+
+ tab.Text = tab:CreateFontString(tabname .. "Text")
+ tab:SetFontString(tab.Text)
+
+ tab:SetNormalFontObject(GameFontNormalSmall)
+ tab:SetHighlightFontObject(GameFontHighlightSmall)
+ tab:SetDisabledFontObject(GameFontHighlightSmall)
+ tab:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight", "ADD")
+ tab.HighlightTexture = tab:GetHighlightTexture()
+ tab.HighlightTexture:ClearAllPoints()
+ tab.HighlightTexture:SetPoint("LEFT", tab, "LEFT", 10, -4)
+ tab.HighlightTexture:SetPoint("RIGHT", tab, "RIGHT", -10, -4)
+ _G[tabname .. "HighlightTexture"] = tab.HighlightTexture
+
+ tab.obj = self
+ tab.id = id
+
+ tab.text = tab.Text -- compat
+ tab.text:ClearAllPoints()
+ tab.text:SetPoint("LEFT", 14, -3)
+ tab.text:SetPoint("RIGHT", -12, -3)
+
+ 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.SetSelected = Tab_SetSelected
+ tab.SetDisabled = Tab_SetDisabled
+
+ return tab
+ end,
+
+ ["SetTitle"] = function(self, text)
+ self.titletext:SetText(text or "")
+ if text and text ~= "" then
+ self.alignoffset = 25
+ else
+ self.alignoffset = 18
+ end
+ self:BuildTabs()
+ end,
+
+ ["SetStatusTable"] = function(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ end,
+
+ ["SelectTab"] = function(self, value)
+ local status = self.status or self.localstatus
+ local found
+ for i, v in ipairs(self.tabs) do
+ if v.value == value then
+ v:SetSelected(true)
+ found = true
+ else
+ v:SetSelected(false)
+ end
+ end
+ status.selected = value
+ if found then
+ self:Fire("OnGroupSelected",value)
+ end
+ end,
+
+ ["SetTabs"] = function(self, tabs)
+ self.tablist = tabs
+ self:BuildTabs()
+ end,
+
+
+ ["BuildTabs"] = function(self)
+ local hastitle = (self.titletext:GetText() and self.titletext:GetText() ~= "")
+ local tablist = self.tablist
+ local tabs = self.tabs
+
+ if not tablist then return end
+
+ local width = self.frame.width or self.frame:GetWidth() or 0
+
+ wipe(widths)
+ wipe(rowwidths)
+ wipe(rowends)
+
+ --Place Text into tabs and get thier initial width
+ for i, v in ipairs(tablist) do
+ local tab = tabs[i]
+ if not tab then
+ tab = self:CreateTab(i)
+ tabs[i] = tab
+ end
+
+ tab:Show()
+ tab:SetText(v.text)
+ tab:SetDisabled(v.disabled)
+ tab.value = v.value
+
+ 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
+
+ for i = (#tablist)+1, #tabs, 1 do
+ tabs[i]:Hide()
+ end
+
+ --First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout
+ local numtabs = #tablist
+ local numrows = 1
+ local usedwidth = 0
+
+ for i = 1, #tablist do
+ --If this is not the first tab of a row and there isn't room for it
+ if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then
+ rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
+ rowends[numrows] = i - 1
+ numrows = numrows + 1
+ usedwidth = 0
+ end
+ usedwidth = usedwidth + widths[i]
+ end
+ rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
+ rowends[numrows] = #tablist
+
+ --Fix for single tabs being left on the last row, move a tab from the row above if applicable
+ if numrows > 1 then
+ --if the last row has only one tab
+ if rowends[numrows-1] == numtabs-1 then
+ --if there are more than 2 tabs in the 2nd last row
+ if (numrows == 2 and rowends[numrows-1] > 2) or (rowends[numrows] - rowends[numrows-1] > 2) then
+ --move 1 tab from the second last row to the last, if there is enough space
+ if (rowwidths[numrows] + widths[numtabs-1]) <= width then
+ rowends[numrows-1] = rowends[numrows-1] - 1
+ rowwidths[numrows] = rowwidths[numrows] + widths[numtabs-1]
+ rowwidths[numrows-1] = rowwidths[numrows-1] - widths[numtabs-1]
+ end
+ end
+ end
+ end
+
+ --anchor the rows as defined and resize tabs to fill thier row
+ local starttab = 1
+ for row, endtab in ipairs(rowends) do
+ local first = true
+ for tabno = starttab, endtab do
+ local tab = tabs[tabno]
+ tab:ClearAllPoints()
+ if first then
+ tab:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -(hastitle and 14 or 7)-(row-1)*20 )
+ first = false
+ else
+ tab:SetPoint("LEFT", tabs[tabno-1], "RIGHT", -10, 0)
+ end
+ end
+
+ -- equal padding for each tab to fill the available width,
+ -- if the used space is above 75% already
+ -- the 18 pixel is the typical width of a scrollbar, so we can have a tab group inside a scrolling frame,
+ -- and not have the tabs jump around funny when switching between tabs that need scrolling and those that don't
+ local padding = 0
+ if not (numrows == 1 and rowwidths[1] < width*0.75 - 18) then
+ padding = (width - rowwidths[row]) / (endtab - starttab+1)
+ end
+
+ for i = starttab, endtab do
+ PanelTemplates_TabResize(tabs[i], padding + 4, nil, nil, width, tabs[i]:GetFontString():GetStringWidth())
+ end
+ starttab = endtab + 1
+ end
+
+ self.borderoffset = (hastitle and 17 or 10)+((numrows)*20)
+ self.border:SetPoint("TOPLEFT", 1, -self.borderoffset)
+ end,
+
+ ["OnWidthSet"] = function(self, width)
+ local content = self.content
+ local contentwidth = width - 60
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ self:BuildTabs(self)
+ self.frame:SetScript("OnUpdate", BuildTabsOnUpdate)
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - (self.borderoffset + 23)
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end,
+
+ ["LayoutFinished"] = function(self, width, height)
+ if self.noAutoHeight then return end
+ self:SetHeight((height or 0) + (self.borderoffset + 23))
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local PaneBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 5, bottom = 3 }
+}
+
+local function Constructor()
+ local num = AceGUI:GetNextWidgetNum(Type)
+ local frame = CreateFrame("Frame",nil,UIParent)
+ frame:SetHeight(100)
+ frame:SetWidth(100)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
+ titletext:SetPoint("TOPLEFT", 14, 0)
+ titletext:SetPoint("TOPRIGHT", -14, 0)
+ titletext:SetJustifyH("LEFT")
+ titletext:SetHeight(18)
+ titletext:SetText("")
+
+ local border = CreateFrame("Frame", nil, frame, "BackdropTemplate")
+ border:SetPoint("TOPLEFT", 1, -27)
+ border:SetPoint("BOTTOMRIGHT", -1, 3)
+ border:SetBackdrop(PaneBackdrop)
+ border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
+ border:SetBackdropBorderColor(0.4, 0.4, 0.4)
+
+ local content = CreateFrame("Frame", nil, border)
+ content:SetPoint("TOPLEFT", 10, -7)
+ content:SetPoint("BOTTOMRIGHT", -10, 7)
+
+ local widget = {
+ num = num,
+ frame = frame,
+ localstatus = {},
+ alignoffset = 18,
+ titletext = titletext,
+ border = border,
+ borderoffset = 27,
+ tabs = {},
+ content = content,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua
new file mode 100644
index 0000000..ca9b2df
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua
@@ -0,0 +1,719 @@
+--[[-----------------------------------------------------------------------------
+TreeGroup Container
+Container that uses a tree control to switch between groups.
+-------------------------------------------------------------------------------]]
+local Type, Version = "TreeGroup", 47
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type
+local math_min, math_max, floor = math.min, math.max, math.floor
+local select, tremove, unpack, tconcat = select, table.remove, unpack, table.concat
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+-- Recycling functions
+local new, del
+do
+ local pool = setmetatable({},{__mode='k'})
+ function new()
+ local t = next(pool)
+ if t then
+ pool[t] = nil
+ return t
+ else
+ return {}
+ end
+ end
+ function del(t)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ pool[t] = true
+ end
+end
+
+local DEFAULT_TREE_WIDTH = 175
+local DEFAULT_TREE_SIZABLE = true
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+local function GetButtonUniqueValue(line)
+ local parent = line.parent
+ if parent and parent.value then
+ return GetButtonUniqueValue(parent).."\001"..line.value
+ else
+ return line.value
+ end
+end
+
+local function UpdateButton(button, treeline, selected, canExpand, isExpanded)
+ local self = button.obj
+ local toggle = button.toggle
+ local text = treeline.text or ""
+ local icon = treeline.icon
+ local iconCoords = treeline.iconCoords
+ local level = treeline.level
+ local value = treeline.value
+ local uniquevalue = treeline.uniquevalue
+ local disabled = treeline.disabled
+
+ button.treeline = treeline
+ button.value = value
+ button.uniquevalue = uniquevalue
+ if selected then
+ button:LockHighlight()
+ button.selected = true
+ else
+ button:UnlockHighlight()
+ button.selected = false
+ end
+ button.level = level
+ if ( level == 1 ) then
+ button:SetNormalFontObject("GameFontNormal")
+ button:SetHighlightFontObject("GameFontHighlight")
+ button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2)
+ else
+ button:SetNormalFontObject("GameFontHighlightSmall")
+ button:SetHighlightFontObject("GameFontHighlightSmall")
+ button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2)
+ end
+
+ if disabled then
+ button:EnableMouse(false)
+ button.text:SetText("|cff808080"..text..FONT_COLOR_CODE_CLOSE)
+ else
+ button.text:SetText(text)
+ button:EnableMouse(true)
+ end
+
+ if icon then
+ button.icon:SetTexture(icon)
+ button.icon:SetPoint("LEFT", 8 * level, (level == 1) and 0 or 1)
+ else
+ button.icon:SetTexture(nil)
+ end
+
+ if iconCoords then
+ button.icon:SetTexCoord(unpack(iconCoords))
+ else
+ button.icon:SetTexCoord(0, 1, 0, 1)
+ end
+
+ if canExpand then
+ if not isExpanded then
+ toggle:SetNormalTexture(130838) -- Interface\\Buttons\\UI-PlusButton-UP
+ toggle:SetPushedTexture(130836) -- Interface\\Buttons\\UI-PlusButton-DOWN
+ else
+ toggle:SetNormalTexture(130821) -- Interface\\Buttons\\UI-MinusButton-UP
+ toggle:SetPushedTexture(130820) -- Interface\\Buttons\\UI-MinusButton-DOWN
+ end
+ toggle:Show()
+ else
+ toggle:Hide()
+ end
+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.icon = v.icon
+ line.iconCoords = v.iconCoords
+ 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
+
+--fire an update after one frame to catch the treeframes height
+local function FirstFrameUpdate(frame)
+ local self = frame.obj
+ frame:SetScript("OnUpdate", nil)
+ self:RefreshTree(nil, true)
+end
+
+local function BuildUniqueValue(...)
+ local n = select('#', ...)
+ if n == 1 then
+ return ...
+ else
+ return (...).."\001"..BuildUniqueValue(select(2,...))
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Expand_OnClick(frame)
+ local button = frame.button
+ local self = button.obj
+ local status = (self.status or self.localstatus).groups
+ status[button.uniquevalue] = not status[button.uniquevalue]
+ self:RefreshTree()
+end
+
+local function Button_OnClick(frame)
+ local self = frame.obj
+ self:Fire("OnClick", frame.uniquevalue, frame.selected)
+ if not frame.selected then
+ self:SetSelected(frame.uniquevalue)
+ frame.selected = true
+ frame:LockHighlight()
+ self:RefreshTree()
+ end
+ AceGUI:ClearFocus()
+end
+
+local function Button_OnDoubleClick(button)
+ local self = button.obj
+ local status = (self.status or self.localstatus).groups
+ status[button.uniquevalue] = not status[button.uniquevalue]
+ self:RefreshTree()
+end
+
+local function Button_OnEnter(frame)
+ local self = frame.obj
+ self:Fire("OnButtonEnter", frame.uniquevalue, frame)
+
+ if self.enabletooltips then
+ local tooltip = AceGUI.tooltip
+ tooltip:SetOwner(frame, "ANCHOR_NONE")
+ tooltip:ClearAllPoints()
+ tooltip:SetPoint("LEFT",frame,"RIGHT")
+ tooltip:SetText(frame.text:GetText() or "", 1, .82, 0, true)
+
+ tooltip:Show()
+ end
+end
+
+local function Button_OnLeave(frame)
+ local self = frame.obj
+ self:Fire("OnButtonLeave", frame.uniquevalue, frame)
+
+ if self.enabletooltips then
+ AceGUI.tooltip:Hide()
+ end
+end
+
+local function OnScrollValueChanged(frame, value)
+ if frame.obj.noupdate then return end
+ local self = frame.obj
+ local status = self.status or self.localstatus
+ status.scrollvalue = floor(value + 0.5)
+ self:RefreshTree()
+ AceGUI:ClearFocus()
+end
+
+local function Tree_OnSizeChanged(frame)
+ frame.obj:RefreshTree()
+end
+
+local function Tree_OnMouseWheel(frame, delta)
+ local self = frame.obj
+ if self.showscroll then
+ local scrollbar = self.scrollbar
+ local min, max = scrollbar:GetMinMaxValues()
+ local value = scrollbar:GetValue()
+ local newvalue = math_min(max,math_max(min,value - delta))
+ if value ~= newvalue then
+ scrollbar:SetValue(newvalue)
+ end
+ end
+end
+
+local function Dragger_OnLeave(frame)
+ frame:SetBackdropColor(1, 1, 1, 0)
+end
+
+local function Dragger_OnEnter(frame)
+ frame:SetBackdropColor(1, 1, 1, 0.8)
+end
+
+local function Dragger_OnMouseDown(frame)
+ local treeframe = frame:GetParent()
+ treeframe:StartSizing("RIGHT")
+end
+
+local function Dragger_OnMouseUp(frame)
+ local treeframe = frame:GetParent()
+ local self = treeframe.obj
+ local treeframeParent = treeframe:GetParent()
+ treeframe:StopMovingOrSizing()
+ --treeframe:SetScript("OnUpdate", nil)
+ treeframe:SetUserPlaced(false)
+ --Without this :GetHeight will get stuck on the current height, causing the tree contents to not resize
+ treeframe:SetHeight(0)
+ treeframe:ClearAllPoints()
+ treeframe:SetPoint("TOPLEFT", treeframeParent, "TOPLEFT",0,0)
+ treeframe:SetPoint("BOTTOMLEFT", treeframeParent, "BOTTOMLEFT",0,0)
+
+ local status = self.status or self.localstatus
+ status.treewidth = treeframe:GetWidth()
+
+ treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth())
+ -- recalculate the content width
+ treeframe.obj:OnWidthSet(status.fullwidth)
+ -- update the layout of the content
+ treeframe.obj:DoLayout()
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetTreeWidth(DEFAULT_TREE_WIDTH, DEFAULT_TREE_SIZABLE)
+ self:EnableButtonTooltips(true)
+ self.frame:SetScript("OnUpdate", FirstFrameUpdate)
+ end,
+
+ ["OnRelease"] = function(self)
+ self.status = nil
+ self.tree = nil
+ self.frame:SetScript("OnUpdate", nil)
+ for k, v in pairs(self.localstatus) do
+ if k == "groups" then
+ for k2 in pairs(v) do
+ v[k2] = nil
+ end
+ else
+ self.localstatus[k] = nil
+ end
+ end
+ self.localstatus.scrollvalue = 0
+ self.localstatus.treewidth = DEFAULT_TREE_WIDTH
+ self.localstatus.treesizable = DEFAULT_TREE_SIZABLE
+ end,
+
+ ["EnableButtonTooltips"] = function(self, enable)
+ self.enabletooltips = enable
+ end,
+
+ ["CreateButton"] = function(self)
+ local num = AceGUI:GetNextWidgetNum("TreeGroupButton")
+ local button = CreateFrame("Button", ("AceGUI30TreeButton%d"):format(num), self.treeframe, "OptionsListButtonTemplate")
+ button.obj = self
+
+ local icon = button:CreateTexture(nil, "OVERLAY")
+ icon:SetWidth(14)
+ icon:SetHeight(14)
+ button.icon = icon
+
+ button:SetScript("OnClick",Button_OnClick)
+ button:SetScript("OnDoubleClick", Button_OnDoubleClick)
+ button:SetScript("OnEnter",Button_OnEnter)
+ button:SetScript("OnLeave",Button_OnLeave)
+
+ button.toggle.button = button
+ button.toggle:SetScript("OnClick",Expand_OnClick)
+
+ button.text:SetHeight(14) -- Prevents text wrapping
+
+ return button
+ end,
+
+ ["SetStatusTable"] = function(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ if not status.groups then
+ status.groups = {}
+ end
+ if not status.scrollvalue then
+ status.scrollvalue = 0
+ end
+ if not status.treewidth then
+ status.treewidth = DEFAULT_TREE_WIDTH
+ end
+ if status.treesizable == nil then
+ status.treesizable = DEFAULT_TREE_SIZABLE
+ end
+ self:SetTreeWidth(status.treewidth,status.treesizable)
+ self:RefreshTree()
+ end,
+
+ --sets the tree to be displayed
+ ["SetTree"] = function(self, tree, filter)
+ self.filter = filter
+ if tree then
+ assert(type(tree) == "table")
+ end
+ self.tree = tree
+ self:RefreshTree()
+ end,
+
+ ["BuildLevel"] = function(self, tree, level, parent)
+ local groups = (self.status or self.localstatus).groups
+
+ for i, v in ipairs(tree) do
+ if v.children then
+ 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,
+
+ ["RefreshTree"] = function(self,scrollToSelection,fromOnUpdate)
+ local buttons = self.buttons
+ local lines = self.lines
+
+ for i, v in ipairs(buttons) do
+ v:Hide()
+ end
+ while lines[1] do
+ local t = tremove(lines)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ del(t)
+ end
+
+ if not self.tree then return end
+ --Build the list of visible entries from the tree and status tables
+ local status = self.status or self.localstatus
+ local groupstatus = status.groups
+ local tree = self.tree
+
+ local treeframe = self.treeframe
+
+ status.scrollToSelection = status.scrollToSelection or scrollToSelection -- needs to be cached in case the control hasn't been drawn yet (code bails out below)
+
+ self:BuildLevel(tree, 1)
+
+ local numlines = #lines
+
+ local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18))
+ if maxlines <= 0 then return end
+
+ if self.frame:GetParent() == UIParent and not fromOnUpdate then
+ self.frame:SetScript("OnUpdate", FirstFrameUpdate)
+ return
+ end
+
+ local first, last
+
+ scrollToSelection = status.scrollToSelection
+ status.scrollToSelection = nil
+
+ if numlines <= maxlines then
+ --the whole tree fits in the frame
+ status.scrollvalue = 0
+ self:ShowScroll(false)
+ first, last = 1, numlines
+ else
+ self:ShowScroll(true)
+ --scrolling will be needed
+ self.noupdate = true
+ self.scrollbar:SetMinMaxValues(0, numlines - maxlines)
+ --check if we are scrolled down too far
+ if numlines - status.scrollvalue < maxlines then
+ status.scrollvalue = numlines - maxlines
+ end
+ self.noupdate = nil
+ first, last = status.scrollvalue+1, status.scrollvalue + maxlines
+ --show selection?
+ if scrollToSelection and status.selected then
+ local show
+ for i,line in ipairs(lines) do -- find the line number
+ if line.uniquevalue==status.selected then
+ show=i
+ end
+ end
+ if not show then
+ -- selection was deleted or something?
+ elseif show>=first and show<=last then
+ -- all good
+ else
+ -- scrolling needed!
+ if show 100 and status.treewidth > maxtreewidth then
+ self:SetTreeWidth(maxtreewidth, status.treesizable)
+ end
+ if treeframe.SetResizeBounds then
+ treeframe:SetResizeBounds(100, 1, maxtreewidth, 1600)
+ else
+ treeframe:SetMaxResize(maxtreewidth, 1600)
+ end
+ end,
+
+ ["OnHeightSet"] = function(self, height)
+ local content = self.content
+ local contentheight = height - 20
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end,
+
+ ["SetTreeWidth"] = function(self, treewidth, resizable)
+ if not resizable then
+ if type(treewidth) == 'number' then
+ resizable = false
+ elseif type(treewidth) == 'boolean' then
+ resizable = treewidth
+ treewidth = DEFAULT_TREE_WIDTH
+ else
+ resizable = false
+ treewidth = DEFAULT_TREE_WIDTH
+ end
+ end
+ self.treeframe:SetWidth(treewidth)
+ self.dragger:EnableMouse(resizable)
+
+ local status = self.status or self.localstatus
+ status.treewidth = treewidth
+ status.treesizable = resizable
+
+ -- recalculate the content width
+ if status.fullwidth then
+ self:OnWidthSet(status.fullwidth)
+ end
+ end,
+
+ ["GetTreeWidth"] = function(self)
+ local status = self.status or self.localstatus
+ return status.treewidth or DEFAULT_TREE_WIDTH
+ end,
+
+ ["LayoutFinished"] = function(self, width, height)
+ if self.noAutoHeight then return end
+ self:SetHeight((height or 0) + 20)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local PaneBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 5, bottom = 3 }
+}
+
+local DraggerBackdrop = {
+ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
+ edgeFile = nil,
+ tile = true, tileSize = 16, edgeSize = 1,
+ insets = { left = 3, right = 3, top = 7, bottom = 7 }
+}
+
+local function Constructor()
+ local num = AceGUI:GetNextWidgetNum(Type)
+ local frame = CreateFrame("Frame", nil, UIParent)
+
+ local treeframe = CreateFrame("Frame", nil, frame, "BackdropTemplate")
+ treeframe:SetPoint("TOPLEFT")
+ treeframe:SetPoint("BOTTOMLEFT")
+ treeframe:SetWidth(DEFAULT_TREE_WIDTH)
+ treeframe:EnableMouseWheel(true)
+ treeframe:SetBackdrop(PaneBackdrop)
+ treeframe:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
+ treeframe:SetBackdropBorderColor(0.4, 0.4, 0.4)
+ treeframe:SetResizable(true)
+ if treeframe.SetResizeBounds then -- WoW 10.0
+ treeframe:SetResizeBounds(100, 1, 400, 1600)
+ else
+ treeframe:SetMinResize(100, 1)
+ treeframe:SetMaxResize(400, 1600)
+ end
+ treeframe:SetScript("OnUpdate", FirstFrameUpdate)
+ treeframe:SetScript("OnSizeChanged", Tree_OnSizeChanged)
+ treeframe:SetScript("OnMouseWheel", Tree_OnMouseWheel)
+
+ local dragger = CreateFrame("Frame", nil, treeframe, "BackdropTemplate")
+ dragger:SetWidth(8)
+ dragger:SetPoint("TOP", treeframe, "TOPRIGHT")
+ dragger:SetPoint("BOTTOM", treeframe, "BOTTOMRIGHT")
+ dragger:SetBackdrop(DraggerBackdrop)
+ dragger:SetBackdropColor(1, 1, 1, 0)
+ dragger:SetScript("OnEnter", Dragger_OnEnter)
+ dragger:SetScript("OnLeave", Dragger_OnLeave)
+ dragger:SetScript("OnMouseDown", Dragger_OnMouseDown)
+ dragger:SetScript("OnMouseUp", Dragger_OnMouseUp)
+
+ local scrollbar = CreateFrame("Slider", ("AceConfigDialogTreeGroup%dScrollBar"):format(num), treeframe, "UIPanelScrollBarTemplate")
+ scrollbar:SetScript("OnValueChanged", nil)
+ scrollbar:SetPoint("TOPRIGHT", -10, -26)
+ scrollbar:SetPoint("BOTTOMRIGHT", -10, 26)
+ scrollbar:SetMinMaxValues(0,0)
+ scrollbar:SetValueStep(1)
+ scrollbar:SetValue(0)
+ scrollbar:SetWidth(16)
+ scrollbar:SetScript("OnValueChanged", OnScrollValueChanged)
+
+ local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
+ scrollbg:SetAllPoints(scrollbar)
+ scrollbg:SetColorTexture(0,0,0,0.4)
+
+ local border = CreateFrame("Frame", nil, frame, "BackdropTemplate")
+ border:SetPoint("TOPLEFT", treeframe, "TOPRIGHT")
+ border:SetPoint("BOTTOMRIGHT")
+ border:SetBackdrop(PaneBackdrop)
+ border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
+ border:SetBackdropBorderColor(0.4, 0.4, 0.4)
+
+ --Container Support
+ local content = CreateFrame("Frame", nil, border)
+ content:SetPoint("TOPLEFT", 10, -10)
+ content:SetPoint("BOTTOMRIGHT", -10, 10)
+
+ local widget = {
+ frame = frame,
+ lines = {},
+ levels = {},
+ buttons = {},
+ hasChildren = {},
+ localstatus = { groups = {}, scrollvalue = 0 },
+ filter = false,
+ treeframe = treeframe,
+ dragger = dragger,
+ scrollbar = scrollbar,
+ border = border,
+ content = content,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ treeframe.obj, dragger.obj, scrollbar.obj = widget, widget, widget
+
+ return AceGUI:RegisterAsContainer(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua
new file mode 100644
index 0000000..5729bfd
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua
@@ -0,0 +1,336 @@
+local AceGUI = LibStub("AceGUI-3.0")
+
+-- Lua APIs
+local pairs, assert, type = pairs, assert, type
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+----------------
+-- Main Frame --
+----------------
+--[[
+ Events :
+ OnClose
+
+]]
+do
+ local Type = "Window"
+ local Version = 8
+
+ local function frameOnShow(this)
+ this.obj:Fire("OnShow")
+ end
+
+ local function frameOnClose(this)
+ this.obj:Fire("OnClose")
+ end
+
+ local function closeOnClick(this)
+ PlaySound(799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
+ this.obj:Hide()
+ end
+
+ local function frameOnMouseDown(this)
+ AceGUI:ClearFocus()
+ end
+
+ local function titleOnMouseDown(this)
+ this:GetParent():StartMoving()
+ AceGUI:ClearFocus()
+ end
+
+ local function frameOnMouseUp(this)
+ local frame = this:GetParent()
+ frame:StopMovingOrSizing()
+ local self = frame.obj
+ local status = self.status or self.localstatus
+ status.width = frame:GetWidth()
+ status.height = frame:GetHeight()
+ status.top = frame:GetTop()
+ status.left = frame:GetLeft()
+ end
+
+ local function sizerseOnMouseDown(this)
+ this:GetParent():StartSizing("BOTTOMRIGHT")
+ AceGUI:ClearFocus()
+ end
+
+ local function sizersOnMouseDown(this)
+ this:GetParent():StartSizing("BOTTOM")
+ AceGUI:ClearFocus()
+ end
+
+ local function sizereOnMouseDown(this)
+ this:GetParent():StartSizing("RIGHT")
+ AceGUI:ClearFocus()
+ end
+
+ local function sizerOnMouseUp(this)
+ this:GetParent():StopMovingOrSizing()
+ end
+
+ local function SetTitle(self,title)
+ self.titletext:SetText(title)
+ end
+
+ local function SetStatusText(self,text)
+ -- self.statustext:SetText(text)
+ end
+
+ local function Hide(self)
+ self.frame:Hide()
+ end
+
+ local function Show(self)
+ self.frame:Show()
+ end
+
+ local function OnAcquire(self)
+ self.frame:SetParent(UIParent)
+ self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ self:ApplyStatus()
+ self:EnableResize(true)
+ self:Show()
+ end
+
+ local function OnRelease(self)
+ self.status = nil
+ for k in pairs(self.localstatus) do
+ self.localstatus[k] = nil
+ end
+ end
+
+ -- called to set an external table to store status in
+ local function SetStatusTable(self, status)
+ assert(type(status) == "table")
+ self.status = status
+ self:ApplyStatus()
+ end
+
+ local function ApplyStatus(self)
+ local status = self.status or self.localstatus
+ local frame = self.frame
+ self:SetWidth(status.width or 700)
+ self:SetHeight(status.height or 500)
+ if status.top and status.left then
+ frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top)
+ frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0)
+ else
+ frame:SetPoint("CENTER",UIParent,"CENTER")
+ end
+ end
+
+ local function OnWidthSet(self, width)
+ local content = self.content
+ local contentwidth = width - 34
+ if contentwidth < 0 then
+ contentwidth = 0
+ end
+ content:SetWidth(contentwidth)
+ content.width = contentwidth
+ end
+
+
+ local function OnHeightSet(self, height)
+ local content = self.content
+ local contentheight = height - 57
+ if contentheight < 0 then
+ contentheight = 0
+ end
+ content:SetHeight(contentheight)
+ content.height = contentheight
+ end
+
+ local function EnableResize(self, state)
+ local func = state and "Show" or "Hide"
+ self.sizer_se[func](self.sizer_se)
+ self.sizer_s[func](self.sizer_s)
+ self.sizer_e[func](self.sizer_e)
+ end
+
+ local function Constructor()
+ local frame = CreateFrame("Frame",nil,UIParent)
+ local self = {}
+ self.type = "Window"
+
+ self.Hide = Hide
+ self.Show = Show
+ self.SetTitle = SetTitle
+ self.OnRelease = OnRelease
+ self.OnAcquire = OnAcquire
+ self.SetStatusText = SetStatusText
+ self.SetStatusTable = SetStatusTable
+ self.ApplyStatus = ApplyStatus
+ self.OnWidthSet = OnWidthSet
+ self.OnHeightSet = OnHeightSet
+ self.EnableResize = EnableResize
+
+ self.localstatus = {}
+
+ self.frame = frame
+ frame.obj = self
+ frame:SetWidth(700)
+ frame:SetHeight(500)
+ frame:SetPoint("CENTER",UIParent,"CENTER",0,0)
+ frame:EnableMouse()
+ frame:SetMovable(true)
+ frame:SetResizable(true)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ frame:SetScript("OnMouseDown", frameOnMouseDown)
+
+ frame:SetScript("OnShow",frameOnShow)
+ frame:SetScript("OnHide",frameOnClose)
+ if frame.SetResizeBounds then -- WoW 10.0
+ frame:SetResizeBounds(240,240)
+ else
+ frame:SetMinResize(240,240)
+ end
+ frame:SetToplevel(true)
+
+ local titlebg = frame:CreateTexture(nil, "BACKGROUND")
+ titlebg:SetTexture(251966) -- Interface\\PaperDollInfoFrame\\UI-GearManager-Title-Background
+ titlebg:SetPoint("TOPLEFT", 9, -6)
+ titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24)
+
+ local dialogbg = frame:CreateTexture(nil, "BACKGROUND")
+ dialogbg:SetTexture(137056) -- Interface\\Tooltips\\UI-Tooltip-Background
+ dialogbg:SetPoint("TOPLEFT", 8, -24)
+ dialogbg:SetPoint("BOTTOMRIGHT", -6, 8)
+ dialogbg:SetVertexColor(0, 0, 0, .75)
+
+ local topleft = frame:CreateTexture(nil, "BORDER")
+ topleft:SetTexture(251963) -- Interface\\PaperDollInfoFrame\\UI-GearManager-Border
+ topleft:SetWidth(64)
+ topleft:SetHeight(64)
+ topleft:SetPoint("TOPLEFT")
+ topleft:SetTexCoord(0.501953125, 0.625, 0, 1)
+
+ local topright = frame:CreateTexture(nil, "BORDER")
+ topright:SetTexture(251963) -- Interface\\PaperDollInfoFrame\\UI-GearManager-Border
+ topright:SetWidth(64)
+ topright:SetHeight(64)
+ topright:SetPoint("TOPRIGHT")
+ topright:SetTexCoord(0.625, 0.75, 0, 1)
+
+ local top = frame:CreateTexture(nil, "BORDER")
+ top:SetTexture(251963) -- Interface\\PaperDollInfoFrame\\UI-GearManager-Border
+ top:SetHeight(64)
+ top:SetPoint("TOPLEFT", topleft, "TOPRIGHT")
+ top:SetPoint("TOPRIGHT", topright, "TOPLEFT")
+ top:SetTexCoord(0.25, 0.369140625, 0, 1)
+
+ local bottomleft = frame:CreateTexture(nil, "BORDER")
+ bottomleft:SetTexture(251963) -- Interface\\PaperDollInfoFrame\\UI-GearManager-Border
+ bottomleft:SetWidth(64)
+ bottomleft:SetHeight(64)
+ bottomleft:SetPoint("BOTTOMLEFT")
+ bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1)
+
+ local bottomright = frame:CreateTexture(nil, "BORDER")
+ bottomright:SetTexture(251963) -- Interface\\PaperDollInfoFrame\\UI-GearManager-Border
+ bottomright:SetWidth(64)
+ bottomright:SetHeight(64)
+ bottomright:SetPoint("BOTTOMRIGHT")
+ bottomright:SetTexCoord(0.875, 1, 0, 1)
+
+ local bottom = frame:CreateTexture(nil, "BORDER")
+ bottom:SetTexture(251963) -- Interface\\PaperDollInfoFrame\\UI-GearManager-Border
+ bottom:SetHeight(64)
+ bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT")
+ bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT")
+ bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1)
+
+ local left = frame:CreateTexture(nil, "BORDER")
+ left:SetTexture(251963) -- Interface\\PaperDollInfoFrame\\UI-GearManager-Border
+ left:SetWidth(64)
+ left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT")
+ left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT")
+ left:SetTexCoord(0.001953125, 0.125, 0, 1)
+
+ local right = frame:CreateTexture(nil, "BORDER")
+ right:SetTexture(251963) -- Interface\\PaperDollInfoFrame\\UI-GearManager-Border
+ right:SetWidth(64)
+ right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT")
+ right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT")
+ right:SetTexCoord(0.1171875, 0.2421875, 0, 1)
+
+ local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
+ close:SetPoint("TOPRIGHT", 2, 1)
+ close:SetScript("OnClick", closeOnClick)
+ self.closebutton = close
+ close.obj = self
+
+ local titletext = frame:CreateFontString(nil, "ARTWORK")
+ titletext:SetFontObject(GameFontNormal)
+ titletext:SetPoint("TOPLEFT", 12, -8)
+ titletext:SetPoint("TOPRIGHT", -32, -8)
+ self.titletext = titletext
+
+ local title = CreateFrame("Button", nil, frame)
+ title:SetPoint("TOPLEFT", titlebg)
+ title:SetPoint("BOTTOMRIGHT", titlebg)
+ title:EnableMouse()
+ title:SetScript("OnMouseDown",titleOnMouseDown)
+ title:SetScript("OnMouseUp", frameOnMouseUp)
+ self.title = title
+
+ local sizer_se = CreateFrame("Frame",nil,frame)
+ sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
+ sizer_se:SetWidth(25)
+ sizer_se:SetHeight(25)
+ sizer_se:EnableMouse()
+ sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown)
+ sizer_se:SetScript("OnMouseUp", sizerOnMouseUp)
+ self.sizer_se = sizer_se
+
+ local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
+ self.line1 = line1
+ line1:SetWidth(14)
+ line1:SetHeight(14)
+ line1:SetPoint("BOTTOMRIGHT", -8, 8)
+ line1:SetTexture(137057) -- Interface\\Tooltips\\UI-Tooltip-Border
+ local x = 0.1 * 14/17
+ line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
+
+ local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
+ self.line2 = line2
+ line2:SetWidth(8)
+ line2:SetHeight(8)
+ line2:SetPoint("BOTTOMRIGHT", -8, 8)
+ line2:SetTexture(137057) -- Interface\\Tooltips\\UI-Tooltip-Border
+ x = 0.1 * 8/17
+ line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
+
+ local sizer_s = CreateFrame("Frame",nil,frame)
+ sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0)
+ sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
+ sizer_s:SetHeight(25)
+ sizer_s:EnableMouse()
+ sizer_s:SetScript("OnMouseDown",sizersOnMouseDown)
+ sizer_s:SetScript("OnMouseUp", sizerOnMouseUp)
+ self.sizer_s = sizer_s
+
+ local sizer_e = CreateFrame("Frame",nil,frame)
+ sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25)
+ sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
+ sizer_e:SetWidth(25)
+ sizer_e:EnableMouse()
+ sizer_e:SetScript("OnMouseDown",sizereOnMouseDown)
+ sizer_e:SetScript("OnMouseUp", sizerOnMouseUp)
+ self.sizer_e = sizer_e
+
+ --Container Support
+ local content = CreateFrame("Frame",nil,frame)
+ self.content = content
+ content.obj = self
+ content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32)
+ content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13)
+
+ AceGUI:RegisterAsContainer(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(Type,Constructor,Version)
+end
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua
new file mode 100644
index 0000000..8e650ce
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua
@@ -0,0 +1,103 @@
+--[[-----------------------------------------------------------------------------
+Button Widget
+Graphical Button.
+-------------------------------------------------------------------------------]]
+local Type, Version = "Button", 24
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local _G = _G
+local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Button_OnClick(frame, ...)
+ AceGUI:ClearFocus()
+ PlaySound(852) -- SOUNDKIT.IG_MAINMENU_OPTION
+ frame.obj:Fire("OnClick", ...)
+end
+
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ -- restore default values
+ self:SetHeight(24)
+ self:SetWidth(200)
+ self:SetDisabled(false)
+ self:SetAutoWidth(false)
+ self:SetText()
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetText"] = function(self, text)
+ self.text:SetText(text)
+ if self.autoWidth then
+ self:SetWidth(self.text:GetStringWidth() + 30)
+ end
+ end,
+
+ ["SetAutoWidth"] = function(self, autoWidth)
+ self.autoWidth = autoWidth
+ if self.autoWidth then
+ self:SetWidth(self.text:GetStringWidth() + 30)
+ end
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.frame:Disable()
+ else
+ self.frame:Enable()
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
+ local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
+ frame:Hide()
+
+ frame:EnableMouse(true)
+ frame:SetScript("OnClick", Button_OnClick)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+
+ local text = frame:GetFontString()
+ text:ClearAllPoints()
+ text:SetPoint("TOPLEFT", 15, -1)
+ text:SetPoint("BOTTOMRIGHT", -15, 1)
+ text:SetJustifyV("MIDDLE")
+
+ local widget = {
+ text = text,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua
new file mode 100644
index 0000000..6e64292
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua
@@ -0,0 +1,292 @@
+--[[-----------------------------------------------------------------------------
+Checkbox Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "CheckBox", 26
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local select, pairs = select, pairs
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+local function AlignImage(self)
+ local img = self.image:GetTexture()
+ self.text:ClearAllPoints()
+ if not img then
+ self.text:SetPoint("LEFT", self.checkbg, "RIGHT")
+ self.text:SetPoint("RIGHT")
+ else
+ self.text:SetPoint("LEFT", self.image, "RIGHT", 1, 0)
+ self.text:SetPoint("RIGHT")
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function CheckBox_OnMouseDown(frame)
+ local self = frame.obj
+ if not self.disabled then
+ if self.image:GetTexture() then
+ self.text:SetPoint("LEFT", self.image,"RIGHT", 2, -1)
+ else
+ self.text:SetPoint("LEFT", self.checkbg, "RIGHT", 1, -1)
+ end
+ end
+ AceGUI:ClearFocus()
+end
+
+local function CheckBox_OnMouseUp(frame)
+ local self = frame.obj
+ if not self.disabled then
+ self:ToggleChecked()
+
+ if self.checked then
+ PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
+ else -- for both nil and false (tristate)
+ PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
+ end
+
+ self:Fire("OnValueChanged", self.checked)
+ AlignImage(self)
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetType()
+ self:SetValue(false)
+ self:SetTriState(nil)
+ -- height is calculated from the width and required space for the description
+ self:SetWidth(200)
+ self:SetImage()
+ self:SetDisabled(nil)
+ self:SetDescription(nil)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["OnWidthSet"] = function(self, width)
+ if self.desc then
+ self.desc:SetWidth(width - 30)
+ if self.desc:GetText() and self.desc:GetText() ~= "" then
+ self:SetHeight(28 + self.desc:GetStringHeight())
+ end
+ end
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.frame:Disable()
+ self.text:SetTextColor(0.5, 0.5, 0.5)
+ SetDesaturation(self.check, true)
+ if self.desc then
+ self.desc:SetTextColor(0.5, 0.5, 0.5)
+ end
+ else
+ self.frame:Enable()
+ self.text:SetTextColor(1, 1, 1)
+ if self.tristate and self.checked == nil then
+ SetDesaturation(self.check, true)
+ else
+ SetDesaturation(self.check, false)
+ end
+ if self.desc then
+ self.desc:SetTextColor(1, 1, 1)
+ end
+ end
+ end,
+
+ ["SetValue"] = function(self, value)
+ local check = self.check
+ self.checked = value
+ if value then
+ SetDesaturation(check, false)
+ check:Show()
+ else
+ --Nil is the unknown tristate value
+ if self.tristate and value == nil then
+ SetDesaturation(check, true)
+ check:Show()
+ else
+ SetDesaturation(check, false)
+ check:Hide()
+ end
+ end
+ self:SetDisabled(self.disabled)
+ end,
+
+ ["GetValue"] = function(self)
+ return self.checked
+ end,
+
+ ["SetTriState"] = function(self, enabled)
+ self.tristate = enabled
+ self:SetValue(self:GetValue())
+ end,
+
+ ["SetType"] = function(self, type)
+ local checkbg = self.checkbg
+ local check = self.check
+ local highlight = self.highlight
+
+ local size
+ if type == "radio" then
+ size = 16
+ checkbg:SetTexture(130843) -- Interface\\Buttons\\UI-RadioButton
+ checkbg:SetTexCoord(0, 0.25, 0, 1)
+ check:SetTexture(130843) -- Interface\\Buttons\\UI-RadioButton
+ check:SetTexCoord(0.25, 0.5, 0, 1)
+ check:SetBlendMode("ADD")
+ highlight:SetTexture(130843) -- Interface\\Buttons\\UI-RadioButton
+ highlight:SetTexCoord(0.5, 0.75, 0, 1)
+ else
+ size = 24
+ checkbg:SetTexture(130755) -- Interface\\Buttons\\UI-CheckBox-Up
+ checkbg:SetTexCoord(0, 1, 0, 1)
+ check:SetTexture(130751) -- Interface\\Buttons\\UI-CheckBox-Check
+ check:SetTexCoord(0, 1, 0, 1)
+ check:SetBlendMode("BLEND")
+ highlight:SetTexture(130753) -- Interface\\Buttons\\UI-CheckBox-Highlight
+ highlight:SetTexCoord(0, 1, 0, 1)
+ end
+ checkbg:SetHeight(size)
+ checkbg:SetWidth(size)
+ end,
+
+ ["ToggleChecked"] = function(self)
+ local value = self:GetValue()
+ if self.tristate then
+ --cycle in true, nil, false order
+ if value then
+ self:SetValue(nil)
+ elseif value == nil then
+ self:SetValue(false)
+ else
+ self:SetValue(true)
+ end
+ else
+ self:SetValue(not self:GetValue())
+ end
+ end,
+
+ ["SetLabel"] = function(self, label)
+ self.text:SetText(label)
+ end,
+
+ ["SetDescription"] = function(self, desc)
+ if desc then
+ if not self.desc then
+ local f = self.frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
+ f:ClearAllPoints()
+ f:SetPoint("TOPLEFT", self.checkbg, "TOPRIGHT", 5, -21)
+ f:SetWidth(self.frame.width - 30)
+ f:SetPoint("RIGHT", self.frame, "RIGHT", -30, 0)
+ f:SetJustifyH("LEFT")
+ f:SetJustifyV("TOP")
+ self.desc = f
+ end
+ self.desc:Show()
+ --self.text:SetFontObject(GameFontNormal)
+ self.desc:SetText(desc)
+ self:SetHeight(28 + self.desc:GetStringHeight())
+ else
+ if self.desc then
+ self.desc:SetText("")
+ self.desc:Hide()
+ end
+ --self.text:SetFontObject(GameFontHighlight)
+ self:SetHeight(24)
+ end
+ end,
+
+ ["SetImage"] = function(self, path, ...)
+ local image = self.image
+ image:SetTexture(path)
+
+ if image:GetTexture() then
+ local n = select("#", ...)
+ if n == 4 or n == 8 then
+ image:SetTexCoord(...)
+ else
+ image:SetTexCoord(0, 1, 0, 1)
+ end
+ end
+ AlignImage(self)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Button", nil, UIParent)
+ frame:Hide()
+
+ frame:EnableMouse(true)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ frame:SetScript("OnMouseDown", CheckBox_OnMouseDown)
+ frame:SetScript("OnMouseUp", CheckBox_OnMouseUp)
+
+ local checkbg = frame:CreateTexture(nil, "ARTWORK")
+ checkbg:SetWidth(24)
+ checkbg:SetHeight(24)
+ checkbg:SetPoint("TOPLEFT")
+ checkbg:SetTexture(130755) -- Interface\\Buttons\\UI-CheckBox-Up
+
+ local check = frame:CreateTexture(nil, "OVERLAY")
+ check:SetAllPoints(checkbg)
+ check:SetTexture(130751) -- Interface\\Buttons\\UI-CheckBox-Check
+
+ local text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
+ text:SetJustifyH("LEFT")
+ text:SetHeight(18)
+ text:SetPoint("LEFT", checkbg, "RIGHT")
+ text:SetPoint("RIGHT")
+
+ local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
+ highlight:SetTexture(130753) -- Interface\\Buttons\\UI-CheckBox-Highlight
+ highlight:SetBlendMode("ADD")
+ highlight:SetAllPoints(checkbg)
+
+ local image = frame:CreateTexture(nil, "OVERLAY")
+ image:SetHeight(16)
+ image:SetWidth(16)
+ image:SetPoint("LEFT", checkbg, "RIGHT", 1, 0)
+
+ local widget = {
+ checkbg = checkbg,
+ check = check,
+ text = text,
+ highlight = highlight,
+ image = image,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua
new file mode 100644
index 0000000..699d583
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua
@@ -0,0 +1,186 @@
+--[[-----------------------------------------------------------------------------
+ColorPicker Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "ColorPicker", 25
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+local function ColorCallback(self, r, g, b, a, isAlpha)
+ if not self.HasAlpha then
+ a = 1
+ end
+ self:SetColor(r, g, b, a)
+ if ColorPickerFrame:IsVisible() then
+ --colorpicker is still open
+ self:Fire("OnValueChanged", r, g, b, a)
+ else
+ --colorpicker is closed, color callback is first, ignore it,
+ --alpha callback is the final call after it closes so confirm now
+ if isAlpha then
+ self:Fire("OnValueConfirmed", r, g, b, a)
+ end
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function ColorSwatch_OnClick(frame)
+ ColorPickerFrame:Hide()
+ local self = frame.obj
+ if not self.disabled then
+ ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG")
+ ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10)
+ ColorPickerFrame:SetClampedToScreen(true)
+
+ ColorPickerFrame.func = function()
+ local r, g, b = ColorPickerFrame:GetColorRGB()
+ local a = 1 - OpacitySliderFrame:GetValue()
+ ColorCallback(self, r, g, b, a)
+ end
+
+ ColorPickerFrame.hasOpacity = self.HasAlpha
+ ColorPickerFrame.opacityFunc = function()
+ local r, g, b = ColorPickerFrame:GetColorRGB()
+ local a = 1 - OpacitySliderFrame:GetValue()
+ ColorCallback(self, r, g, b, a, true)
+ end
+
+ local r, g, b, a = self.r, self.g, self.b, self.a
+ if self.HasAlpha then
+ ColorPickerFrame.opacity = 1 - (a or 0)
+ end
+ ColorPickerFrame:SetColorRGB(r, g, b)
+
+ ColorPickerFrame.cancelFunc = function()
+ ColorCallback(self, r, g, b, a, true)
+ end
+
+ ColorPickerFrame:Show()
+ end
+ AceGUI:ClearFocus()
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetHeight(24)
+ self:SetWidth(200)
+ self:SetHasAlpha(false)
+ self:SetColor(0, 0, 0, 1)
+ self:SetDisabled(nil)
+ self:SetLabel(nil)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetLabel"] = function(self, text)
+ self.text:SetText(text)
+ end,
+
+ ["SetColor"] = function(self, r, g, b, a)
+ self.r = r
+ self.g = g
+ self.b = b
+ self.a = a or 1
+ self.colorSwatch:SetVertexColor(r, g, b, a)
+ end,
+
+ ["SetHasAlpha"] = function(self, HasAlpha)
+ self.HasAlpha = HasAlpha
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if self.disabled then
+ self.frame:Disable()
+ self.text:SetTextColor(0.5, 0.5, 0.5)
+ else
+ self.frame:Enable()
+ self.text:SetTextColor(1, 1, 1)
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Button", nil, UIParent)
+ frame:Hide()
+
+ frame:EnableMouse(true)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ frame:SetScript("OnClick", ColorSwatch_OnClick)
+
+ local colorSwatch = frame:CreateTexture(nil, "OVERLAY")
+ colorSwatch:SetWidth(19)
+ colorSwatch:SetHeight(19)
+ colorSwatch:SetTexture(130939) -- Interface\\ChatFrame\\ChatFrameColorSwatch
+ colorSwatch:SetPoint("LEFT")
+
+ local texture = frame:CreateTexture(nil, "BACKGROUND")
+ colorSwatch.background = texture
+ texture:SetWidth(16)
+ texture:SetHeight(16)
+ texture:SetColorTexture(1, 1, 1)
+ texture:SetPoint("CENTER", colorSwatch)
+ texture:Show()
+
+ local checkers = frame:CreateTexture(nil, "BACKGROUND")
+ colorSwatch.checkers = checkers
+ checkers:SetWidth(14)
+ checkers:SetHeight(14)
+ checkers:SetTexture(188523) -- Tileset\\Generic\\Checkers
+ checkers:SetTexCoord(.25, 0, 0.5, .25)
+ checkers:SetDesaturated(true)
+ checkers:SetVertexColor(1, 1, 1, 0.75)
+ checkers:SetPoint("CENTER", colorSwatch)
+ checkers:Show()
+
+ local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight")
+ text:SetHeight(24)
+ text:SetJustifyH("LEFT")
+ text:SetTextColor(1, 1, 1)
+ text:SetPoint("LEFT", colorSwatch, "RIGHT", 2, 0)
+ text:SetPoint("RIGHT")
+
+ --local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
+ --highlight:SetTexture(136810) -- Interface\\QuestFrame\\UI-QuestTitleHighlight
+ --highlight:SetBlendMode("ADD")
+ --highlight:SetAllPoints(frame)
+
+ local widget = {
+ colorSwatch = colorSwatch,
+ text = text,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua
new file mode 100644
index 0000000..0ad94f8
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua
@@ -0,0 +1,471 @@
+--[[ $Id: AceGUIWidget-DropDown-Items.lua 1272 2022-08-29 15:56:35Z nevcairiel $ ]]--
+
+local AceGUI = LibStub("AceGUI-3.0")
+
+-- Lua APIs
+local select, assert = select, assert
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame = CreateFrame
+
+local function fixlevels(parent,...)
+ local i = 1
+ local child = select(i, ...)
+ while child do
+ child:SetFrameLevel(parent:GetFrameLevel()+1)
+ fixlevels(child, child:GetChildren())
+ i = i + 1
+ child = select(i, ...)
+ end
+end
+
+local function fixstrata(strata, parent, ...)
+ local i = 1
+ local child = select(i, ...)
+ parent:SetFrameStrata(strata)
+ while child do
+ fixstrata(strata, child, child:GetChildren())
+ i = i + 1
+ child = select(i, ...)
+ end
+end
+
+-- ItemBase is the base "class" for all dropdown items.
+-- Each item has to use ItemBase.Create(widgetType) to
+-- create an initial 'self' value.
+-- ItemBase will add common functions and ui event handlers.
+-- Be sure to keep basic usage when you override functions.
+
+local ItemBase = {
+ -- NOTE: The ItemBase version is added to each item's version number
+ -- to ensure proper updates on ItemBase changes.
+ -- Use at least 1000er steps.
+ version = 2000,
+ counter = 0,
+}
+
+function ItemBase.Frame_OnEnter(this)
+ local self = this.obj
+
+ if self.useHighlight then
+ self.highlight:Show()
+ end
+ self:Fire("OnEnter")
+
+ if self.specialOnEnter then
+ self.specialOnEnter(self)
+ end
+end
+
+function ItemBase.Frame_OnLeave(this)
+ local self = this.obj
+
+ self.highlight:Hide()
+ self:Fire("OnLeave")
+
+ if self.specialOnLeave then
+ self.specialOnLeave(self)
+ end
+end
+
+-- exported, AceGUI callback
+function ItemBase.OnAcquire(self)
+ self.frame:SetToplevel(true)
+ self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
+end
+
+-- exported, AceGUI callback
+function ItemBase.OnRelease(self)
+ self:SetDisabled(false)
+ self.pullout = nil
+ self.frame:SetParent(nil)
+ self.frame:ClearAllPoints()
+ self.frame:Hide()
+end
+
+-- exported
+-- NOTE: this is called by a Dropdown-Pullout.
+-- Do not call this method directly
+function ItemBase.SetPullout(self, pullout)
+ self.pullout = pullout
+
+ self.frame:SetParent(nil)
+ self.frame:SetParent(pullout.itemFrame)
+ self.parent = pullout.itemFrame
+ fixlevels(pullout.itemFrame, pullout.itemFrame:GetChildren())
+end
+
+-- exported
+function ItemBase.SetText(self, text)
+ self.text:SetText(text or "")
+end
+
+-- exported
+function ItemBase.GetText(self)
+ return self.text:GetText()
+end
+
+-- exported
+function ItemBase.SetPoint(self, ...)
+ self.frame:SetPoint(...)
+end
+
+-- exported
+function ItemBase.Show(self)
+ self.frame:Show()
+end
+
+-- exported
+function ItemBase.Hide(self)
+ self.frame:Hide()
+end
+
+-- exported
+function ItemBase.SetDisabled(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.useHighlight = false
+ self.text:SetTextColor(.5, .5, .5)
+ else
+ self.useHighlight = true
+ self.text:SetTextColor(1, 1, 1)
+ end
+end
+
+-- exported
+-- NOTE: this is called by a Dropdown-Pullout.
+-- Do not call this method directly
+function ItemBase.SetOnLeave(self, func)
+ self.specialOnLeave = func
+end
+
+-- exported
+-- NOTE: this is called by a Dropdown-Pullout.
+-- Do not call this method directly
+function ItemBase.SetOnEnter(self, func)
+ self.specialOnEnter = func
+end
+
+function ItemBase.Create(type)
+ -- NOTE: Most of the following code is copied from AceGUI-3.0/Dropdown widget
+ local count = AceGUI:GetNextWidgetNum(type)
+ local frame = CreateFrame("Button", "AceGUI30DropDownItem"..count)
+ local self = {}
+ self.frame = frame
+ frame.obj = self
+ self.type = type
+
+ self.useHighlight = true
+
+ frame:SetHeight(17)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ local text = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
+ text:SetTextColor(1,1,1)
+ text:SetJustifyH("LEFT")
+ text:SetPoint("TOPLEFT",frame,"TOPLEFT",18,0)
+ text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-8,0)
+ self.text = text
+
+ local highlight = frame:CreateTexture(nil, "OVERLAY")
+ highlight:SetTexture(136810) -- Interface\\QuestFrame\\UI-QuestTitleHighlight
+ highlight:SetBlendMode("ADD")
+ highlight:SetHeight(14)
+ highlight:ClearAllPoints()
+ highlight:SetPoint("RIGHT",frame,"RIGHT",-3,0)
+ highlight:SetPoint("LEFT",frame,"LEFT",5,0)
+ highlight:Hide()
+ self.highlight = highlight
+
+ local check = frame:CreateTexture(nil, "OVERLAY")
+ check:SetWidth(16)
+ check:SetHeight(16)
+ check:SetPoint("LEFT",frame,"LEFT",3,-1)
+ check:SetTexture(130751) -- Interface\\Buttons\\UI-CheckBox-Check
+ check:Hide()
+ self.check = check
+
+ local sub = frame:CreateTexture(nil, "OVERLAY")
+ sub:SetWidth(16)
+ sub:SetHeight(16)
+ sub:SetPoint("RIGHT",frame,"RIGHT",-3,-1)
+ sub:SetTexture(130940) -- Interface\\ChatFrame\\ChatFrameExpandArrow
+ sub:Hide()
+ self.sub = sub
+
+ frame:SetScript("OnEnter", ItemBase.Frame_OnEnter)
+ frame:SetScript("OnLeave", ItemBase.Frame_OnLeave)
+
+ self.OnAcquire = ItemBase.OnAcquire
+ self.OnRelease = ItemBase.OnRelease
+
+ self.SetPullout = ItemBase.SetPullout
+ self.GetText = ItemBase.GetText
+ self.SetText = ItemBase.SetText
+ self.SetDisabled = ItemBase.SetDisabled
+
+ self.SetPoint = ItemBase.SetPoint
+ self.Show = ItemBase.Show
+ self.Hide = ItemBase.Hide
+
+ self.SetOnLeave = ItemBase.SetOnLeave
+ self.SetOnEnter = ItemBase.SetOnEnter
+
+ return self
+end
+
+-- Register a dummy LibStub library to retrieve the ItemBase, so other addons can use it.
+local IBLib = LibStub:NewLibrary("AceGUI-3.0-DropDown-ItemBase", ItemBase.version)
+if IBLib then
+ IBLib.GetItemBase = function() return ItemBase end
+end
+
+--[[
+ Template for items:
+
+-- Item:
+--
+do
+ local widgetType = "Dropdown-Item-"
+ local widgetVersion = 1
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
+--]]
+
+-- Item: Header
+-- A single text entry.
+-- Special: Different text color and no highlight
+do
+ local widgetType = "Dropdown-Item-Header"
+ local widgetVersion = 1
+
+ local function OnEnter(this)
+ local self = this.obj
+ self:Fire("OnEnter")
+
+ if self.specialOnEnter then
+ self.specialOnEnter(self)
+ end
+ end
+
+ local function OnLeave(this)
+ local self = this.obj
+ self:Fire("OnLeave")
+
+ if self.specialOnLeave then
+ self.specialOnLeave(self)
+ end
+ end
+
+ -- exported, override
+ local function SetDisabled(self, disabled)
+ ItemBase.SetDisabled(self, disabled)
+ if not disabled then
+ self.text:SetTextColor(1, 1, 0)
+ end
+ end
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ self.SetDisabled = SetDisabled
+
+ self.frame:SetScript("OnEnter", OnEnter)
+ self.frame:SetScript("OnLeave", OnLeave)
+
+ self.text:SetTextColor(1, 1, 0)
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
+
+-- Item: Execute
+-- A simple button
+do
+ local widgetType = "Dropdown-Item-Execute"
+ local widgetVersion = 1
+
+ local function Frame_OnClick(this, button)
+ local self = this.obj
+ if self.disabled then return end
+ self:Fire("OnClick")
+ if self.pullout then
+ self.pullout:Close()
+ end
+ end
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ self.frame:SetScript("OnClick", Frame_OnClick)
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
+
+-- Item: Toggle
+-- Some sort of checkbox for dropdown menus.
+-- Does not close the pullout on click.
+do
+ local widgetType = "Dropdown-Item-Toggle"
+ local widgetVersion = 4
+
+ local function UpdateToggle(self)
+ if self.value then
+ self.check:Show()
+ else
+ self.check:Hide()
+ end
+ end
+
+ local function OnRelease(self)
+ ItemBase.OnRelease(self)
+ self:SetValue(nil)
+ end
+
+ local function Frame_OnClick(this, button)
+ local self = this.obj
+ if self.disabled then return end
+ self.value = not self.value
+ if self.value then
+ PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
+ else
+ PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
+ end
+ UpdateToggle(self)
+ self:Fire("OnValueChanged", self.value)
+ end
+
+ -- exported
+ local function SetValue(self, value)
+ self.value = value
+ UpdateToggle(self)
+ end
+
+ -- exported
+ local function GetValue(self)
+ return self.value
+ end
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ self.frame:SetScript("OnClick", Frame_OnClick)
+
+ self.SetValue = SetValue
+ self.GetValue = GetValue
+ self.OnRelease = OnRelease
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
+
+-- Item: Menu
+-- Shows a submenu on mouse over
+-- Does not close the pullout on click
+do
+ local widgetType = "Dropdown-Item-Menu"
+ local widgetVersion = 2
+
+ local function OnEnter(this)
+ local self = this.obj
+ self:Fire("OnEnter")
+
+ if self.specialOnEnter then
+ self.specialOnEnter(self)
+ end
+
+ self.highlight:Show()
+
+ if not self.disabled and self.submenu then
+ self.submenu:Open("TOPLEFT", self.frame, "TOPRIGHT", self.pullout:GetRightBorderWidth(), 0, self.frame:GetFrameLevel() + 100)
+ end
+ end
+
+ local function OnHide(this)
+ local self = this.obj
+ if self.submenu then
+ self.submenu:Close()
+ end
+ end
+
+ -- exported
+ local function SetMenu(self, menu)
+ assert(menu.type == "Dropdown-Pullout")
+ self.submenu = menu
+ end
+
+ -- exported
+ local function CloseMenu(self)
+ self.submenu:Close()
+ end
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ self.sub:Show()
+
+ self.frame:SetScript("OnEnter", OnEnter)
+ self.frame:SetScript("OnHide", OnHide)
+
+ self.SetMenu = SetMenu
+ self.CloseMenu = CloseMenu
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
+
+-- Item: Separator
+-- A single line to separate items
+do
+ local widgetType = "Dropdown-Item-Separator"
+ local widgetVersion = 2
+
+ -- exported, override
+ local function SetDisabled(self, disabled)
+ ItemBase.SetDisabled(self, disabled)
+ self.useHighlight = false
+ end
+
+ local function Constructor()
+ local self = ItemBase.Create(widgetType)
+
+ self.SetDisabled = SetDisabled
+
+ local line = self.frame:CreateTexture(nil, "OVERLAY")
+ line:SetHeight(1)
+ line:SetColorTexture(.5, .5, .5)
+ line:SetPoint("LEFT", self.frame, "LEFT", 10, 0)
+ line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0)
+
+ self.text:Hide()
+
+ self.useHighlight = false
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
+end
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua
new file mode 100644
index 0000000..3d8dd11
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua
@@ -0,0 +1,732 @@
+--[[ $Id: AceGUIWidget-DropDown.lua 1284 2022-09-25 09:15:30Z nevcairiel $ ]]--
+local AceGUI = LibStub("AceGUI-3.0")
+
+-- Lua APIs
+local min, max, floor = math.min, math.max, math.floor
+local select, pairs, ipairs, type, tostring = select, pairs, ipairs, type, tostring
+local tsort = table.sort
+
+-- WoW APIs
+local PlaySound = PlaySound
+local UIParent, CreateFrame = UIParent, CreateFrame
+local _G = _G
+
+local function fixlevels(parent,...)
+ local i = 1
+ local child = select(i, ...)
+ while child do
+ child:SetFrameLevel(parent:GetFrameLevel()+1)
+ fixlevels(child, child:GetChildren())
+ i = i + 1
+ child = select(i, ...)
+ end
+end
+
+local function fixstrata(strata, parent, ...)
+ local i = 1
+ local child = select(i, ...)
+ parent:SetFrameStrata(strata)
+ while child do
+ fixstrata(strata, child, child:GetChildren())
+ i = i + 1
+ child = select(i, ...)
+ end
+end
+
+do
+ local widgetType = "Dropdown-Pullout"
+ local widgetVersion = 5
+
+ --[[ Static data ]]--
+
+ local backdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
+ edgeSize = 32,
+ tileSize = 32,
+ tile = true,
+ insets = { left = 11, right = 12, top = 12, bottom = 11 },
+ }
+ local sliderBackdrop = {
+ bgFile = "Interface\\Buttons\\UI-SliderBar-Background",
+ edgeFile = "Interface\\Buttons\\UI-SliderBar-Border",
+ tile = true, tileSize = 8, edgeSize = 8,
+ insets = { left = 3, right = 3, top = 3, bottom = 3 }
+ }
+
+ local defaultWidth = 200
+ local defaultMaxHeight = 600
+
+ --[[ UI Event Handlers ]]--
+
+ -- HACK: This should be no part of the pullout, but there
+ -- is no other 'clean' way to response to any item-OnEnter
+ -- Used to close Submenus when an other item is entered
+ local function OnEnter(item)
+ local self = item.pullout
+ for k, v in ipairs(self.items) do
+ if v.CloseMenu and v ~= item then
+ v:CloseMenu()
+ end
+ end
+ end
+
+ -- See the note in Constructor() for each scroll related function
+ local function OnMouseWheel(this, value)
+ this.obj:MoveScroll(value)
+ end
+
+ local function OnScrollValueChanged(this, value)
+ this.obj:SetScroll(value)
+ end
+
+ local function OnSizeChanged(this)
+ this.obj:FixScroll()
+ end
+
+ --[[ Exported methods ]]--
+
+ -- exported
+ local function SetScroll(self, value)
+ local status = self.scrollStatus
+ local frame, child = self.scrollFrame, self.itemFrame
+ local height, viewheight = frame:GetHeight(), child:GetHeight()
+
+ local offset
+ if height > viewheight then
+ offset = 0
+ else
+ offset = floor((viewheight - height) / 1000 * value)
+ end
+ child:ClearAllPoints()
+ child:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, offset)
+ child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", self.slider:IsShown() and -12 or 0, offset)
+ status.offset = offset
+ status.scrollvalue = value
+ end
+
+ -- exported
+ local function MoveScroll(self, value)
+ local status = self.scrollStatus
+ local frame, child = self.scrollFrame, self.itemFrame
+ local height, viewheight = frame:GetHeight(), child:GetHeight()
+
+ if height > viewheight then
+ self.slider:Hide()
+ else
+ self.slider:Show()
+ local diff = height - viewheight
+ local delta = 1
+ if value < 0 then
+ delta = -1
+ end
+ self.slider:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
+ end
+ end
+
+ -- exported
+ local function FixScroll(self)
+ local status = self.scrollStatus
+ local frame, child = self.scrollFrame, self.itemFrame
+ local height, viewheight = frame:GetHeight(), child:GetHeight()
+ local offset = status.offset or 0
+
+ if viewheight < height then
+ self.slider:Hide()
+ child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, offset)
+ self.slider:SetValue(0)
+ else
+ self.slider:Show()
+ local value = (offset / (viewheight - height) * 1000)
+ if value > 1000 then value = 1000 end
+ self.slider:SetValue(value)
+ self:SetScroll(value)
+ if value < 1000 then
+ child:ClearAllPoints()
+ child:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, offset)
+ child:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -12, offset)
+ status.offset = offset
+ end
+ end
+ end
+
+ -- exported, AceGUI callback
+ local function OnAcquire(self)
+ self.frame:SetParent(UIParent)
+ --self.itemFrame:SetToplevel(true)
+ end
+
+ -- exported, AceGUI callback
+ local function OnRelease(self)
+ self:Clear()
+ self.frame:ClearAllPoints()
+ self.frame:Hide()
+ end
+
+ -- exported
+ local function AddItem(self, item)
+ self.items[#self.items + 1] = item
+
+ local h = #self.items * 16
+ self.itemFrame:SetHeight(h)
+ self.frame:SetHeight(min(h + 34, self.maxHeight)) -- +34: 20 for scrollFrame placement (10 offset) and +14 for item placement
+
+ item.frame:SetPoint("LEFT", self.itemFrame, "LEFT")
+ item.frame:SetPoint("RIGHT", self.itemFrame, "RIGHT")
+
+ item:SetPullout(self)
+ item:SetOnEnter(OnEnter)
+ end
+
+ -- exported
+ local function Open(self, point, relFrame, relPoint, x, y)
+ local items = self.items
+ local frame = self.frame
+ local itemFrame = self.itemFrame
+
+ frame:SetPoint(point, relFrame, relPoint, x, y)
+
+
+ local height = 8
+ for i, item in pairs(items) do
+ item:SetPoint("TOP", itemFrame, "TOP", 0, -2 + (i - 1) * -16)
+ item:Show()
+
+ height = height + 16
+ end
+ itemFrame:SetHeight(height)
+ fixstrata("TOOLTIP", frame, frame:GetChildren())
+ frame:Show()
+ self:Fire("OnOpen")
+ end
+
+ -- exported
+ local function Close(self)
+ self.frame:Hide()
+ self:Fire("OnClose")
+ end
+
+ -- exported
+ local function Clear(self)
+ local items = self.items
+ for i, item in pairs(items) do
+ AceGUI:Release(item)
+ items[i] = nil
+ end
+ end
+
+ -- exported
+ local function IterateItems(self)
+ return ipairs(self.items)
+ end
+
+ -- exported
+ local function SetHideOnLeave(self, val)
+ self.hideOnLeave = val
+ end
+
+ -- exported
+ local function SetMaxHeight(self, height)
+ self.maxHeight = height or defaultMaxHeight
+ if self.frame:GetHeight() > height then
+ self.frame:SetHeight(height)
+ elseif (self.itemFrame:GetHeight() + 34) < height then
+ self.frame:SetHeight(self.itemFrame:GetHeight() + 34) -- see :AddItem
+ end
+ end
+
+ -- exported
+ local function GetRightBorderWidth(self)
+ return 6 + (self.slider:IsShown() and 12 or 0)
+ end
+
+ -- exported
+ local function GetLeftBorderWidth(self)
+ return 6
+ end
+
+ --[[ Constructor ]]--
+
+ local function Constructor()
+ local count = AceGUI:GetNextWidgetNum(widgetType)
+ local frame = CreateFrame("Frame", "AceGUI30Pullout"..count, UIParent, "BackdropTemplate")
+ local self = {}
+ self.count = count
+ self.type = widgetType
+ self.frame = frame
+ frame.obj = self
+
+ self.OnAcquire = OnAcquire
+ self.OnRelease = OnRelease
+
+ self.AddItem = AddItem
+ self.Open = Open
+ self.Close = Close
+ self.Clear = Clear
+ self.IterateItems = IterateItems
+ self.SetHideOnLeave = SetHideOnLeave
+
+ self.SetScroll = SetScroll
+ self.MoveScroll = MoveScroll
+ self.FixScroll = FixScroll
+
+ self.SetMaxHeight = SetMaxHeight
+ self.GetRightBorderWidth = GetRightBorderWidth
+ self.GetLeftBorderWidth = GetLeftBorderWidth
+
+ self.items = {}
+
+ self.scrollStatus = {
+ scrollvalue = 0,
+ }
+
+ self.maxHeight = defaultMaxHeight
+
+ frame:SetBackdrop(backdrop)
+ frame:SetBackdropColor(0, 0, 0)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ frame:SetClampedToScreen(true)
+ frame:SetWidth(defaultWidth)
+ frame:SetHeight(self.maxHeight)
+ --frame:SetToplevel(true)
+
+ -- NOTE: The whole scroll frame code is copied from the AceGUI-3.0 widget ScrollFrame
+ local scrollFrame = CreateFrame("ScrollFrame", nil, frame)
+ local itemFrame = CreateFrame("Frame", nil, scrollFrame)
+
+ self.scrollFrame = scrollFrame
+ self.itemFrame = itemFrame
+
+ scrollFrame.obj = self
+ itemFrame.obj = self
+
+ local slider = CreateFrame("Slider", "AceGUI30PulloutScrollbar"..count, scrollFrame, "BackdropTemplate")
+ slider:SetOrientation("VERTICAL")
+ slider:SetHitRectInsets(0, 0, -10, 0)
+ slider:SetBackdrop(sliderBackdrop)
+ slider:SetWidth(8)
+ slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
+ slider:SetFrameStrata("FULLSCREEN_DIALOG")
+ self.slider = slider
+ slider.obj = self
+
+ scrollFrame:SetScrollChild(itemFrame)
+ scrollFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", 6, -12)
+ scrollFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -6, 12)
+ scrollFrame:EnableMouseWheel(true)
+ scrollFrame:SetScript("OnMouseWheel", OnMouseWheel)
+ scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
+ scrollFrame:SetToplevel(true)
+ scrollFrame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ itemFrame:SetPoint("TOPLEFT", scrollFrame, "TOPLEFT", 0, 0)
+ itemFrame:SetPoint("TOPRIGHT", scrollFrame, "TOPRIGHT", -12, 0)
+ itemFrame:SetHeight(400)
+ itemFrame:SetToplevel(true)
+ itemFrame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ slider:SetPoint("TOPLEFT", scrollFrame, "TOPRIGHT", -16, 0)
+ slider:SetPoint("BOTTOMLEFT", scrollFrame, "BOTTOMRIGHT", -16, 0)
+ slider:SetScript("OnValueChanged", OnScrollValueChanged)
+ slider:SetMinMaxValues(0, 1000)
+ slider:SetValueStep(1)
+ slider:SetValue(0)
+
+ scrollFrame:Show()
+ itemFrame:Show()
+ slider:Hide()
+
+ self:FixScroll()
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
+end
+
+do
+ local widgetType = "Dropdown"
+ local widgetVersion = 36
+
+ --[[ Static data ]]--
+
+ --[[ UI event handler ]]--
+
+ local function Control_OnEnter(this)
+ this.obj.button:LockHighlight()
+ this.obj:Fire("OnEnter")
+ end
+
+ local function Control_OnLeave(this)
+ this.obj.button:UnlockHighlight()
+ this.obj:Fire("OnLeave")
+ end
+
+ local function Dropdown_OnHide(this)
+ local self = this.obj
+ if self.open then
+ self.pullout:Close()
+ end
+ end
+
+ local function Dropdown_TogglePullout(this)
+ local self = this.obj
+ if self.open then
+ self.open = nil
+ self.pullout:Close()
+ AceGUI:ClearFocus()
+ else
+ self.open = true
+ self.pullout:SetWidth(self.pulloutWidth or self.frame:GetWidth())
+ self.pullout:Open("TOPLEFT", self.frame, "BOTTOMLEFT", 0, self.label:IsShown() and -2 or 0)
+ AceGUI:SetFocus(self)
+ end
+ end
+
+ local function OnPulloutOpen(this)
+ local self = this.userdata.obj
+ local value = self.value
+
+ if not self.multiselect then
+ for i, item in this:IterateItems() do
+ item:SetValue(item.userdata.value == value)
+ end
+ end
+
+ self.open = true
+ self:Fire("OnOpened")
+ end
+
+ local function OnPulloutClose(this)
+ local self = this.userdata.obj
+ self.open = nil
+ self:Fire("OnClosed")
+ end
+
+ local function ShowMultiText(self)
+ local text
+ for i, widget in self.pullout:IterateItems() do
+ if widget.type == "Dropdown-Item-Toggle" then
+ if widget:GetValue() then
+ if text then
+ text = text..", "..widget:GetText()
+ else
+ text = widget:GetText()
+ end
+ end
+ end
+ end
+ self:SetText(text)
+ end
+
+ local function OnItemValueChanged(this, event, checked)
+ local self = this.userdata.obj
+
+ if self.multiselect then
+ self:Fire("OnValueChanged", this.userdata.value, checked)
+ ShowMultiText(self)
+ else
+ if checked then
+ self:SetValue(this.userdata.value)
+ self:Fire("OnValueChanged", this.userdata.value)
+ else
+ this:SetValue(true)
+ end
+ if self.open then
+ self.pullout:Close()
+ end
+ end
+ end
+
+ --[[ Exported methods ]]--
+
+ -- exported, AceGUI callback
+ local function OnAcquire(self)
+ local pullout = AceGUI:Create("Dropdown-Pullout")
+ self.pullout = pullout
+ pullout.userdata.obj = self
+ pullout:SetCallback("OnClose", OnPulloutClose)
+ pullout:SetCallback("OnOpen", OnPulloutOpen)
+ self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1)
+ fixlevels(self.pullout.frame, self.pullout.frame:GetChildren())
+
+ self:SetHeight(44)
+ self:SetWidth(200)
+ self:SetLabel()
+ self:SetPulloutWidth(nil)
+ self.list = {}
+ end
+
+ -- exported, AceGUI callback
+ local function OnRelease(self)
+ if self.open then
+ self.pullout:Close()
+ end
+ AceGUI:Release(self.pullout)
+ self.pullout = nil
+
+ self:SetText("")
+ self:SetDisabled(false)
+ self:SetMultiselect(false)
+
+ self.value = nil
+ self.list = nil
+ self.open = nil
+ self.hasClose = nil
+
+ self.frame:ClearAllPoints()
+ self.frame:Hide()
+ end
+
+ -- exported
+ local function SetDisabled(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.text:SetTextColor(0.5,0.5,0.5)
+ self.button:Disable()
+ self.button_cover:Disable()
+ self.label:SetTextColor(0.5,0.5,0.5)
+ else
+ self.button:Enable()
+ self.button_cover:Enable()
+ self.label:SetTextColor(1,.82,0)
+ self.text:SetTextColor(1,1,1)
+ end
+ end
+
+ -- exported
+ local function ClearFocus(self)
+ if self.open then
+ self.pullout:Close()
+ end
+ end
+
+ -- exported
+ local function SetText(self, text)
+ self.text:SetText(text or "")
+ end
+
+ -- exported
+ local function SetLabel(self, text)
+ if text and text ~= "" then
+ self.label:SetText(text)
+ self.label:Show()
+ self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,-14)
+ self:SetHeight(40)
+ self.alignoffset = 26
+ else
+ self.label:SetText("")
+ self.label:Hide()
+ self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,0)
+ self:SetHeight(26)
+ self.alignoffset = 12
+ end
+ end
+
+ -- exported
+ local function SetValue(self, value)
+ self:SetText(self.list[value] or "")
+ self.value = value
+ end
+
+ -- exported
+ local function GetValue(self)
+ return self.value
+ end
+
+ -- exported
+ local function SetItemValue(self, item, value)
+ if not self.multiselect then return end
+ for i, widget in self.pullout:IterateItems() do
+ if widget.userdata.value == item then
+ if widget.SetValue then
+ widget:SetValue(value)
+ end
+ end
+ end
+ ShowMultiText(self)
+ end
+
+ -- exported
+ local function SetItemDisabled(self, item, disabled)
+ for i, widget in self.pullout:IterateItems() do
+ if widget.userdata.value == item then
+ widget:SetDisabled(disabled)
+ end
+ end
+ end
+
+ local function AddListItem(self, value, text, itemType)
+ if not itemType then itemType = "Dropdown-Item-Toggle" end
+ local exists = AceGUI:GetWidgetVersion(itemType)
+ if not exists then error(("The given item type, %q, does not exist within AceGUI-3.0"):format(tostring(itemType)), 2) end
+
+ local item = AceGUI:Create(itemType)
+ item:SetText(text)
+ item.userdata.obj = self
+ item.userdata.value = value
+ item:SetCallback("OnValueChanged", OnItemValueChanged)
+ self.pullout:AddItem(item)
+ end
+
+ local function AddCloseButton(self)
+ if not self.hasClose then
+ local close = AceGUI:Create("Dropdown-Item-Execute")
+ close:SetText(CLOSE)
+ self.pullout:AddItem(close)
+ self.hasClose = true
+ end
+ end
+
+ -- exported
+ local sortlist = {}
+ local function sortTbl(x,y)
+ local num1, num2 = tonumber(x), tonumber(y)
+ if num1 and num2 then -- numeric comparison, either two numbers or numeric strings
+ return num1 < num2
+ else -- compare everything else tostring'ed
+ return tostring(x) < tostring(y)
+ end
+ end
+ local function SetList(self, list, order, itemType)
+ self.list = list or {}
+ self.pullout:Clear()
+ self.hasClose = nil
+ if not list then return end
+
+ if type(order) ~= "table" then
+ for v in pairs(list) do
+ sortlist[#sortlist + 1] = v
+ end
+ tsort(sortlist, sortTbl)
+
+ for i, key in ipairs(sortlist) do
+ AddListItem(self, key, list[key], itemType)
+ sortlist[i] = nil
+ end
+ else
+ for i, key in ipairs(order) do
+ AddListItem(self, key, list[key], itemType)
+ end
+ end
+ if self.multiselect then
+ ShowMultiText(self)
+ AddCloseButton(self)
+ end
+ end
+
+ -- exported
+ local function AddItem(self, value, text, itemType)
+ self.list[value] = text
+ AddListItem(self, value, text, itemType)
+ end
+
+ -- exported
+ local function SetMultiselect(self, multi)
+ self.multiselect = multi
+ if multi then
+ ShowMultiText(self)
+ AddCloseButton(self)
+ end
+ end
+
+ -- exported
+ local function GetMultiselect(self)
+ return self.multiselect
+ end
+
+ local function SetPulloutWidth(self, width)
+ self.pulloutWidth = width
+ end
+
+ --[[ Constructor ]]--
+
+ local function Constructor()
+ local count = AceGUI:GetNextWidgetNum(widgetType)
+ local frame = CreateFrame("Frame", nil, UIParent)
+ local dropdown = CreateFrame("Frame", "AceGUI30DropDown"..count, frame, "UIDropDownMenuTemplate")
+
+ local self = {}
+ self.type = widgetType
+ self.frame = frame
+ self.dropdown = dropdown
+ self.count = count
+ frame.obj = self
+ dropdown.obj = self
+
+ self.OnRelease = OnRelease
+ self.OnAcquire = OnAcquire
+
+ self.ClearFocus = ClearFocus
+
+ self.SetText = SetText
+ self.SetValue = SetValue
+ self.GetValue = GetValue
+ self.SetList = SetList
+ self.SetLabel = SetLabel
+ self.SetDisabled = SetDisabled
+ self.AddItem = AddItem
+ self.SetMultiselect = SetMultiselect
+ self.GetMultiselect = GetMultiselect
+ self.SetItemValue = SetItemValue
+ self.SetItemDisabled = SetItemDisabled
+ self.SetPulloutWidth = SetPulloutWidth
+
+ self.alignoffset = 26
+
+ frame:SetScript("OnHide",Dropdown_OnHide)
+
+ dropdown:ClearAllPoints()
+ dropdown:SetPoint("TOPLEFT",frame,"TOPLEFT",-15,0)
+ dropdown:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",17,0)
+ dropdown:SetScript("OnHide", nil)
+
+ local left = _G[dropdown:GetName() .. "Left"]
+ local middle = _G[dropdown:GetName() .. "Middle"]
+ local right = _G[dropdown:GetName() .. "Right"]
+
+ middle:ClearAllPoints()
+ right:ClearAllPoints()
+
+ middle:SetPoint("LEFT", left, "RIGHT", 0, 0)
+ middle:SetPoint("RIGHT", right, "LEFT", 0, 0)
+ right:SetPoint("TOPRIGHT", dropdown, "TOPRIGHT", 0, 17)
+
+ local button = _G[dropdown:GetName() .. "Button"]
+ self.button = button
+ button.obj = self
+ button:SetScript("OnEnter",Control_OnEnter)
+ button:SetScript("OnLeave",Control_OnLeave)
+ button:SetScript("OnClick",Dropdown_TogglePullout)
+
+ local button_cover = CreateFrame("BUTTON",nil,self.frame)
+ self.button_cover = button_cover
+ button_cover.obj = self
+ button_cover:SetPoint("TOPLEFT",self.frame,"BOTTOMLEFT",0,25)
+ button_cover:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT")
+ button_cover:SetScript("OnEnter",Control_OnEnter)
+ button_cover:SetScript("OnLeave",Control_OnLeave)
+ button_cover:SetScript("OnClick",Dropdown_TogglePullout)
+
+ local text = _G[dropdown:GetName() .. "Text"]
+ self.text = text
+ text.obj = self
+ text:ClearAllPoints()
+ text:SetPoint("RIGHT", right, "RIGHT" ,-43, 2)
+ text:SetPoint("LEFT", left, "LEFT", 25, 2)
+
+ local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
+ label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
+ label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
+ label:SetJustifyH("LEFT")
+ label:SetHeight(18)
+ label:Hide()
+ self.label = label
+
+ AceGUI:RegisterAsWidget(self)
+ return self
+ end
+
+ AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
+end
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua
new file mode 100644
index 0000000..85a32a0
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua
@@ -0,0 +1,259 @@
+--[[-----------------------------------------------------------------------------
+EditBox Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "EditBox", 28
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local tostring, pairs = tostring, pairs
+
+-- WoW APIs
+local PlaySound = PlaySound
+local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo
+local CreateFrame, UIParent = CreateFrame, UIParent
+local _G = _G
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+if not AceGUIEditBoxInsertLink then
+ -- upgradeable hook
+ hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
+end
+
+function _G.AceGUIEditBoxInsertLink(text)
+ for i = 1, AceGUI:GetWidgetCount(Type) do
+ local editbox = _G["AceGUI-3.0EditBox"..i]
+ if editbox and editbox:IsVisible() and editbox:HasFocus() then
+ editbox:Insert(text)
+ return true
+ end
+ end
+end
+
+local function ShowButton(self)
+ if not self.disablebutton then
+ self.button:Show()
+ self.editbox:SetTextInsets(0, 20, 3, 3)
+ end
+end
+
+local function HideButton(self)
+ self.button:Hide()
+ self.editbox:SetTextInsets(0, 0, 3, 3)
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function Frame_OnShowFocus(frame)
+ frame.obj.editbox:SetFocus()
+ frame:SetScript("OnShow", nil)
+end
+
+local function EditBox_OnEscapePressed(frame)
+ AceGUI:ClearFocus()
+end
+
+local function EditBox_OnEnterPressed(frame)
+ local self = frame.obj
+ local value = frame:GetText()
+ local cancel = self:Fire("OnEnterPressed", value)
+ if not cancel then
+ PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
+ HideButton(self)
+ end
+end
+
+local function EditBox_OnReceiveDrag(frame)
+ local self = frame.obj
+ local type, id, info = GetCursorInfo()
+ local name
+ if type == "item" then
+ name = info
+ elseif type == "spell" then
+ name = GetSpellInfo(id, info)
+ elseif type == "macro" then
+ name = GetMacroInfo(id)
+ end
+ if name then
+ self:SetText(name)
+ self:Fire("OnEnterPressed", name)
+ ClearCursor()
+ HideButton(self)
+ AceGUI:ClearFocus()
+ end
+end
+
+local function EditBox_OnTextChanged(frame)
+ local self = frame.obj
+ local value = frame:GetText()
+ if tostring(value) ~= tostring(self.lasttext) then
+ self:Fire("OnTextChanged", value)
+ self.lasttext = value
+ ShowButton(self)
+ end
+end
+
+local function EditBox_OnFocusGained(frame)
+ AceGUI:SetFocus(frame.obj)
+end
+
+local function Button_OnClick(frame)
+ local editbox = frame.obj.editbox
+ editbox:ClearFocus()
+ EditBox_OnEnterPressed(editbox)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ -- height is controlled by SetLabel
+ self:SetWidth(200)
+ self:SetDisabled(false)
+ self:SetLabel()
+ self:SetText()
+ self:DisableButton(false)
+ self:SetMaxLetters(0)
+ end,
+
+ ["OnRelease"] = function(self)
+ self:ClearFocus()
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.editbox:EnableMouse(false)
+ self.editbox:ClearFocus()
+ self.editbox:SetTextColor(0.5,0.5,0.5)
+ self.label:SetTextColor(0.5,0.5,0.5)
+ else
+ self.editbox:EnableMouse(true)
+ self.editbox:SetTextColor(1,1,1)
+ self.label:SetTextColor(1,.82,0)
+ end
+ end,
+
+ ["SetText"] = function(self, text)
+ self.lasttext = text or ""
+ self.editbox:SetText(text or "")
+ self.editbox:SetCursorPosition(0)
+ HideButton(self)
+ end,
+
+ ["GetText"] = function(self, text)
+ return self.editbox:GetText()
+ end,
+
+ ["SetLabel"] = function(self, text)
+ if text and text ~= "" then
+ self.label:SetText(text)
+ self.label:Show()
+ self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18)
+ self:SetHeight(44)
+ self.alignoffset = 30
+ else
+ self.label:SetText("")
+ self.label:Hide()
+ self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0)
+ self:SetHeight(26)
+ self.alignoffset = 12
+ end
+ end,
+
+ ["DisableButton"] = function(self, disabled)
+ self.disablebutton = disabled
+ if disabled then
+ HideButton(self)
+ end
+ end,
+
+ ["SetMaxLetters"] = function (self, num)
+ self.editbox:SetMaxLetters(num or 0)
+ end,
+
+ ["ClearFocus"] = function(self)
+ self.editbox:ClearFocus()
+ self.frame:SetScript("OnShow", nil)
+ end,
+
+ ["SetFocus"] = function(self)
+ self.editbox:SetFocus()
+ if not self.frame:IsShown() then
+ self.frame:SetScript("OnShow", Frame_OnShowFocus)
+ end
+ end,
+
+ ["HighlightText"] = function(self, from, to)
+ self.editbox:HighlightText(from, to)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local num = AceGUI:GetNextWidgetNum(Type)
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:Hide()
+
+ local editbox = CreateFrame("EditBox", "AceGUI-3.0EditBox"..num, frame, "InputBoxTemplate")
+ editbox:SetAutoFocus(false)
+ editbox:SetFontObject(ChatFontNormal)
+ editbox:SetScript("OnEnter", Control_OnEnter)
+ editbox:SetScript("OnLeave", Control_OnLeave)
+ editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed)
+ editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed)
+ editbox:SetScript("OnTextChanged", EditBox_OnTextChanged)
+ editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
+ editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
+ editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained)
+ editbox:SetTextInsets(0, 0, 3, 3)
+ editbox:SetMaxLetters(256)
+ editbox:SetPoint("BOTTOMLEFT", 6, 0)
+ editbox:SetPoint("BOTTOMRIGHT")
+ editbox:SetHeight(19)
+
+ local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
+ label:SetPoint("TOPLEFT", 0, -2)
+ label:SetPoint("TOPRIGHT", 0, -2)
+ label:SetJustifyH("LEFT")
+ label:SetHeight(18)
+
+ local button = CreateFrame("Button", nil, editbox, "UIPanelButtonTemplate")
+ button:SetWidth(40)
+ button:SetHeight(20)
+ button:SetPoint("RIGHT", -2, 0)
+ button:SetText(OKAY)
+ button:SetScript("OnClick", Button_OnClick)
+ button:Hide()
+
+ local widget = {
+ alignoffset = 30,
+ editbox = editbox,
+ label = label,
+ button = button,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ editbox.obj, button.obj = widget, widget
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua
new file mode 100644
index 0000000..670cd4e
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua
@@ -0,0 +1,78 @@
+--[[-----------------------------------------------------------------------------
+Heading Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "Heading", 20
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetText()
+ self:SetFullWidth()
+ self:SetHeight(18)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetText"] = function(self, text)
+ self.label:SetText(text or "")
+ if text and text ~= "" then
+ self.left:SetPoint("RIGHT", self.label, "LEFT", -5, 0)
+ self.right:Show()
+ else
+ self.left:SetPoint("RIGHT", -3, 0)
+ self.right:Hide()
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:Hide()
+
+ local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
+ label:SetPoint("TOP")
+ label:SetPoint("BOTTOM")
+ label:SetJustifyH("CENTER")
+
+ local left = frame:CreateTexture(nil, "BACKGROUND")
+ left:SetHeight(8)
+ left:SetPoint("LEFT", 3, 0)
+ left:SetPoint("RIGHT", label, "LEFT", -5, 0)
+ left:SetTexture(137057) -- Interface\\Tooltips\\UI-Tooltip-Border
+ left:SetTexCoord(0.81, 0.94, 0.5, 1)
+
+ local right = frame:CreateTexture(nil, "BACKGROUND")
+ right:SetHeight(8)
+ right:SetPoint("RIGHT", -3, 0)
+ right:SetPoint("LEFT", label, "RIGHT", 5, 0)
+ right:SetTexture(137057) -- Interface\\Tooltips\\UI-Tooltip-Border
+ right:SetTexCoord(0.81, 0.94, 0.5, 1)
+
+ local widget = {
+ label = label,
+ left = left,
+ right = right,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua
new file mode 100644
index 0000000..092697e
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua
@@ -0,0 +1,140 @@
+--[[-----------------------------------------------------------------------------
+Icon Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "Icon", 21
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local select, pairs, print = select, pairs, print
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function Button_OnClick(frame, button)
+ frame.obj:Fire("OnClick", button)
+ AceGUI:ClearFocus()
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetHeight(110)
+ self:SetWidth(110)
+ self:SetLabel()
+ self:SetImage(nil)
+ self:SetImageSize(64, 64)
+ self:SetDisabled(false)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetLabel"] = function(self, text)
+ if text and text ~= "" then
+ self.label:Show()
+ self.label:SetText(text)
+ self:SetHeight(self.image:GetHeight() + 25)
+ else
+ self.label:Hide()
+ self:SetHeight(self.image:GetHeight() + 10)
+ end
+ end,
+
+ ["SetImage"] = function(self, path, ...)
+ local image = self.image
+ image:SetTexture(path)
+
+ if image:GetTexture() then
+ local n = select("#", ...)
+ if n == 4 or n == 8 then
+ image:SetTexCoord(...)
+ else
+ image:SetTexCoord(0, 1, 0, 1)
+ end
+ end
+ end,
+
+ ["SetImageSize"] = function(self, width, height)
+ self.image:SetWidth(width)
+ self.image:SetHeight(height)
+ --self.frame:SetWidth(width + 30)
+ if self.label:IsShown() then
+ self:SetHeight(height + 25)
+ else
+ self:SetHeight(height + 10)
+ end
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.frame:Disable()
+ self.label:SetTextColor(0.5, 0.5, 0.5)
+ self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
+ else
+ self.frame:Enable()
+ self.label:SetTextColor(1, 1, 1)
+ self.image:SetVertexColor(1, 1, 1, 1)
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Button", nil, UIParent)
+ frame:Hide()
+
+ frame:EnableMouse(true)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ frame:SetScript("OnClick", Button_OnClick)
+
+ local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlight")
+ label:SetPoint("BOTTOMLEFT")
+ label:SetPoint("BOTTOMRIGHT")
+ label:SetJustifyH("CENTER")
+ label:SetJustifyV("TOP")
+ label:SetHeight(18)
+
+ local image = frame:CreateTexture(nil, "BACKGROUND")
+ image:SetWidth(64)
+ image:SetHeight(64)
+ image:SetPoint("TOP", 0, -5)
+
+ local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
+ highlight:SetAllPoints(image)
+ highlight:SetTexture(136580) -- Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight
+ highlight:SetTexCoord(0, 1, 0.23, 0.77)
+ highlight:SetBlendMode("ADD")
+
+ local widget = {
+ label = label,
+ image = image,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(...) end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua
new file mode 100644
index 0000000..76a2cf9
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua
@@ -0,0 +1,94 @@
+--[[-----------------------------------------------------------------------------
+InteractiveLabel Widget
+-------------------------------------------------------------------------------]]
+local Type, Version = "InteractiveLabel", 21
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local select, pairs = select, pairs
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function Label_OnClick(frame, button)
+ frame.obj:Fire("OnClick", button)
+ AceGUI:ClearFocus()
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:LabelOnAcquire()
+ self:SetHighlight()
+ self:SetHighlightTexCoord()
+ self:SetDisabled(false)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetHighlight"] = function(self, ...)
+ self.highlight:SetTexture(...)
+ end,
+
+ ["SetHighlightTexCoord"] = function(self, ...)
+ local c = select("#", ...)
+ if c == 4 or c == 8 then
+ self.highlight:SetTexCoord(...)
+ else
+ self.highlight:SetTexCoord(0, 1, 0, 1)
+ end
+ end,
+
+ ["SetDisabled"] = function(self,disabled)
+ self.disabled = disabled
+ if disabled then
+ self.frame:EnableMouse(false)
+ self.label:SetTextColor(0.5, 0.5, 0.5)
+ else
+ self.frame:EnableMouse(true)
+ self.label:SetTextColor(1, 1, 1)
+ end
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ -- create a Label type that we will hijack
+ local label = AceGUI:Create("Label")
+
+ local frame = label.frame
+ frame:EnableMouse(true)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ frame:SetScript("OnMouseDown", Label_OnClick)
+
+ local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
+ highlight:SetTexture(nil)
+ highlight:SetAllPoints()
+ highlight:SetBlendMode("ADD")
+
+ label.highlight = highlight
+ label.type = Type
+ label.LabelOnAcquire = label.OnAcquire
+ for method, func in pairs(methods) do
+ label[method] = func
+ end
+
+ return label
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
+
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua
new file mode 100644
index 0000000..96f7e5b
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua
@@ -0,0 +1,245 @@
+--[[-----------------------------------------------------------------------------
+Keybinding Widget
+Set Keybindings in the Config UI.
+-------------------------------------------------------------------------------]]
+local Type, Version = "Keybinding", 26
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function Keybinding_OnClick(frame, button)
+ if button == "LeftButton" or button == "RightButton" then
+ local self = frame.obj
+ if self.waitingForKey then
+ frame:EnableKeyboard(false)
+ frame:EnableMouseWheel(false)
+ self.msgframe:Hide()
+ frame:UnlockHighlight()
+ self.waitingForKey = nil
+ else
+ frame:EnableKeyboard(true)
+ frame:EnableMouseWheel(true)
+ self.msgframe:Show()
+ frame:LockHighlight()
+ self.waitingForKey = true
+ end
+ end
+ AceGUI:ClearFocus()
+end
+
+local ignoreKeys = {
+ ["BUTTON1"] = true, ["BUTTON2"] = true,
+ ["UNKNOWN"] = true,
+ ["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true,
+ ["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true,
+}
+local function Keybinding_OnKeyDown(frame, key)
+ local self = frame.obj
+ if self.waitingForKey then
+ local keyPressed = key
+ if keyPressed == "ESCAPE" then
+ keyPressed = ""
+ else
+ if ignoreKeys[keyPressed] then return end
+ if IsShiftKeyDown() then
+ keyPressed = "SHIFT-"..keyPressed
+ end
+ if IsControlKeyDown() then
+ keyPressed = "CTRL-"..keyPressed
+ end
+ if IsAltKeyDown() then
+ keyPressed = "ALT-"..keyPressed
+ end
+ end
+
+ frame:EnableKeyboard(false)
+ frame:EnableMouseWheel(false)
+ self.msgframe:Hide()
+ frame:UnlockHighlight()
+ self.waitingForKey = nil
+
+ if not self.disabled then
+ self:SetKey(keyPressed)
+ self:Fire("OnKeyChanged", keyPressed)
+ end
+ end
+end
+
+local function Keybinding_OnMouseDown(frame, button)
+ if button == "LeftButton" or button == "RightButton" then
+ return
+ elseif button == "MiddleButton" then
+ button = "BUTTON3"
+ elseif button == "Button4" then
+ button = "BUTTON4"
+ elseif button == "Button5" then
+ button = "BUTTON5"
+ end
+ Keybinding_OnKeyDown(frame, button)
+end
+
+local function Keybinding_OnMouseWheel(frame, direction)
+ local button
+ if direction >= 0 then
+ button = "MOUSEWHEELUP"
+ else
+ button = "MOUSEWHEELDOWN"
+ end
+ Keybinding_OnKeyDown(frame, button)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetWidth(200)
+ self:SetLabel("")
+ self:SetKey("")
+ self.waitingForKey = nil
+ self.msgframe:Hide()
+ self:SetDisabled(false)
+ self.button:EnableKeyboard(false)
+ self.button:EnableMouseWheel(false)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.button:Disable()
+ self.label:SetTextColor(0.5,0.5,0.5)
+ else
+ self.button:Enable()
+ self.label:SetTextColor(1,1,1)
+ end
+ end,
+
+ ["SetKey"] = function(self, key)
+ if (key or "") == "" then
+ self.button:SetText(NOT_BOUND)
+ self.button:SetNormalFontObject("GameFontNormal")
+ else
+ self.button:SetText(key)
+ self.button:SetNormalFontObject("GameFontHighlight")
+ end
+ end,
+
+ ["GetKey"] = function(self)
+ local key = self.button:GetText()
+ if key == NOT_BOUND then
+ key = nil
+ end
+ return key
+ end,
+
+ ["SetLabel"] = function(self, label)
+ self.label:SetText(label or "")
+ if (label or "") == "" then
+ self.alignoffset = nil
+ self:SetHeight(24)
+ else
+ self.alignoffset = 30
+ self:SetHeight(44)
+ end
+ end,
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+
+local ControlBackdrop = {
+ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
+ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 3, right = 3, top = 3, bottom = 3 }
+}
+
+local function keybindingMsgFixWidth(frame)
+ frame:SetWidth(frame.msg:GetWidth() + 10)
+ frame:SetScript("OnUpdate", nil)
+end
+
+local function Constructor()
+ local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type)
+
+ local frame = CreateFrame("Frame", nil, UIParent)
+ local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate")
+
+ button:EnableMouse(true)
+ button:EnableMouseWheel(false)
+ button:RegisterForClicks("AnyDown")
+ button:SetScript("OnEnter", Control_OnEnter)
+ button:SetScript("OnLeave", Control_OnLeave)
+ button:SetScript("OnClick", Keybinding_OnClick)
+ button:SetScript("OnKeyDown", Keybinding_OnKeyDown)
+ button:SetScript("OnMouseDown", Keybinding_OnMouseDown)
+ button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel)
+ button:SetPoint("BOTTOMLEFT")
+ button:SetPoint("BOTTOMRIGHT")
+ button:SetHeight(24)
+ button:EnableKeyboard(false)
+
+ local text = button:GetFontString()
+ text:SetPoint("LEFT", 7, 0)
+ text:SetPoint("RIGHT", -7, 0)
+
+ local label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
+ label:SetPoint("TOPLEFT")
+ label:SetPoint("TOPRIGHT")
+ label:SetJustifyH("CENTER")
+ label:SetHeight(18)
+
+ local msgframe = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
+ msgframe:SetHeight(30)
+ msgframe:SetBackdrop(ControlBackdrop)
+ msgframe:SetBackdropColor(0,0,0)
+ msgframe:SetFrameStrata("FULLSCREEN_DIALOG")
+ msgframe:SetFrameLevel(1000)
+ msgframe:SetToplevel(true)
+
+ local msg = msgframe:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ msg:SetText("Press a key to bind, ESC to clear the binding or click the button again to cancel.")
+ msgframe.msg = msg
+ msg:SetPoint("TOPLEFT", 5, -5)
+ msgframe:SetScript("OnUpdate", keybindingMsgFixWidth)
+ msgframe:SetPoint("BOTTOM", button, "TOP")
+ msgframe:Hide()
+
+ local widget = {
+ button = button,
+ label = label,
+ msgframe = msgframe,
+ frame = frame,
+ alignoffset = 30,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ button.obj = widget
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua
new file mode 100644
index 0000000..6bbcf3b
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua
@@ -0,0 +1,179 @@
+--[[-----------------------------------------------------------------------------
+Label Widget
+Displays text and optionally an icon.
+-------------------------------------------------------------------------------]]
+local Type, Version = "Label", 28
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local max, select, pairs = math.max, select, pairs
+
+-- WoW APIs
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+
+local function UpdateImageAnchor(self)
+ if self.resizing then return end
+ local frame = self.frame
+ local width = frame.width or frame:GetWidth() or 0
+ local image = self.image
+ local label = self.label
+ local height
+
+ label:ClearAllPoints()
+ image:ClearAllPoints()
+
+ if self.imageshown then
+ local imagewidth = image:GetWidth()
+ if (width - imagewidth) < 200 or (label:GetText() or "") == "" then
+ -- image goes on top centered when less than 200 width for the text, or if there is no text
+ image:SetPoint("TOP")
+ label:SetPoint("TOP", image, "BOTTOM")
+ label:SetPoint("LEFT")
+ label:SetWidth(width)
+ height = image:GetHeight() + label:GetStringHeight()
+ else
+ -- image on the left
+ image:SetPoint("TOPLEFT")
+ if image:GetHeight() > label:GetStringHeight() then
+ label:SetPoint("LEFT", image, "RIGHT", 4, 0)
+ else
+ label:SetPoint("TOPLEFT", image, "TOPRIGHT", 4, 0)
+ end
+ label:SetWidth(width - imagewidth - 4)
+ height = max(image:GetHeight(), label:GetStringHeight())
+ end
+ else
+ -- no image shown
+ label:SetPoint("TOPLEFT")
+ label:SetWidth(width)
+ height = label:GetStringHeight()
+ end
+
+ -- avoid zero-height labels, since they can used as spacers
+ if not height or height == 0 then
+ height = 1
+ end
+
+ self.resizing = true
+ frame:SetHeight(height)
+ frame.height = height
+ self.resizing = nil
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ -- set the flag to stop constant size updates
+ self.resizing = true
+ -- height is set dynamically by the text and image size
+ self:SetWidth(200)
+ self:SetText()
+ self:SetImage(nil)
+ self:SetImageSize(16, 16)
+ self:SetColor()
+ self:SetFontObject()
+ self:SetJustifyH("LEFT")
+ self:SetJustifyV("TOP")
+
+ -- reset the flag
+ self.resizing = nil
+ -- run the update explicitly
+ UpdateImageAnchor(self)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["OnWidthSet"] = function(self, width)
+ UpdateImageAnchor(self)
+ end,
+
+ ["SetText"] = function(self, text)
+ self.label:SetText(text)
+ UpdateImageAnchor(self)
+ end,
+
+ ["SetColor"] = function(self, r, g, b)
+ if not (r and g and b) then
+ r, g, b = 1, 1, 1
+ end
+ self.label:SetVertexColor(r, g, b)
+ end,
+
+ ["SetImage"] = function(self, path, ...)
+ local image = self.image
+ image:SetTexture(path)
+
+ if image:GetTexture() then
+ self.imageshown = true
+ local n = select("#", ...)
+ if n == 4 or n == 8 then
+ image:SetTexCoord(...)
+ else
+ image:SetTexCoord(0, 1, 0, 1)
+ end
+ else
+ self.imageshown = nil
+ end
+ UpdateImageAnchor(self)
+ end,
+
+ ["SetFont"] = function(self, font, height, flags)
+ if not self.fontObject then
+ self.fontObject = CreateFont("AceGUI30LabelFont" .. AceGUI:GetNextWidgetNum(Type))
+ end
+ self.fontObject:SetFont(font, height, flags)
+ self:SetFontObject(self.fontObject)
+ end,
+
+ ["SetFontObject"] = function(self, font)
+ self.label:SetFontObject(font or GameFontHighlightSmall)
+ UpdateImageAnchor(self)
+ end,
+
+ ["SetImageSize"] = function(self, width, height)
+ self.image:SetWidth(width)
+ self.image:SetHeight(height)
+ UpdateImageAnchor(self)
+ end,
+
+ ["SetJustifyH"] = function(self, justifyH)
+ self.label:SetJustifyH(justifyH)
+ end,
+
+ ["SetJustifyV"] = function(self, justifyV)
+ self.label:SetJustifyV(justifyV)
+ end,
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:Hide()
+
+ local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightSmall")
+ local image = frame:CreateTexture(nil, "BACKGROUND")
+
+ -- create widget
+ local widget = {
+ label = label,
+ image = image,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua
new file mode 100644
index 0000000..c33a986
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua
@@ -0,0 +1,369 @@
+local Type, Version = "MultiLineEditBox", 32
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local pairs = pairs
+
+-- WoW APIs
+local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor
+local CreateFrame, UIParent = CreateFrame, UIParent
+local _G = _G
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+
+if not AceGUIMultiLineEditBoxInsertLink then
+ -- upgradeable hook
+ hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIMultiLineEditBoxInsertLink(...) end)
+end
+
+function _G.AceGUIMultiLineEditBoxInsertLink(text)
+ for i = 1, AceGUI:GetWidgetCount(Type) do
+ local editbox = _G[("MultiLineEditBox%uEdit"):format(i)]
+ if editbox and editbox:IsVisible() and editbox:HasFocus() then
+ editbox:Insert(text)
+ return true
+ end
+ end
+end
+
+
+local function Layout(self)
+ self:SetHeight(self.numlines * 14 + (self.disablebutton and 19 or 41) + self.labelHeight)
+
+ if self.labelHeight == 0 then
+ self.scrollBar:SetPoint("TOP", self.frame, "TOP", 0, -23)
+ else
+ self.scrollBar:SetPoint("TOP", self.label, "BOTTOM", 0, -19)
+ end
+
+ if self.disablebutton then
+ self.scrollBar:SetPoint("BOTTOM", self.frame, "BOTTOM", 0, 21)
+ self.scrollBG:SetPoint("BOTTOMLEFT", 0, 4)
+ else
+ self.scrollBar:SetPoint("BOTTOM", self.button, "TOP", 0, 18)
+ self.scrollBG:SetPoint("BOTTOMLEFT", self.button, "TOPLEFT")
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function OnClick(self) -- Button
+ self = self.obj
+ self.editBox:ClearFocus()
+ if not self:Fire("OnEnterPressed", self.editBox:GetText()) then
+ self.button:Disable()
+ end
+end
+
+local function OnCursorChanged(self, _, y, _, cursorHeight) -- EditBox
+ self, y = self.obj.scrollFrame, -y
+ local offset = self:GetVerticalScroll()
+ if y < offset then
+ self:SetVerticalScroll(y)
+ else
+ y = y + cursorHeight - self:GetHeight()
+ if y > offset then
+ self:SetVerticalScroll(y)
+ end
+ end
+end
+
+local function OnEditFocusLost(self) -- EditBox
+ self:HighlightText(0, 0)
+ self.obj:Fire("OnEditFocusLost")
+end
+
+local function OnEnter(self) -- EditBox / ScrollFrame
+ self = self.obj
+ if not self.entered then
+ self.entered = true
+ self:Fire("OnEnter")
+ end
+end
+
+local function OnLeave(self) -- EditBox / ScrollFrame
+ self = self.obj
+ if self.entered then
+ self.entered = nil
+ self:Fire("OnLeave")
+ end
+end
+
+local function OnMouseUp(self) -- ScrollFrame
+ self = self.obj.editBox
+ self:SetFocus()
+ self:SetCursorPosition(self:GetNumLetters())
+end
+
+local function OnReceiveDrag(self) -- EditBox / ScrollFrame
+ local type, id, info = GetCursorInfo()
+ if type == "spell" then
+ info = GetSpellInfo(id, info)
+ elseif type ~= "item" then
+ return
+ end
+ ClearCursor()
+ self = self.obj
+ local editBox = self.editBox
+ if not editBox:HasFocus() then
+ editBox:SetFocus()
+ editBox:SetCursorPosition(editBox:GetNumLetters())
+ end
+ editBox:Insert(info)
+ self.button:Enable()
+end
+
+local function OnSizeChanged(self, width, height) -- ScrollFrame
+ self.obj.editBox:SetWidth(width)
+end
+
+local function OnTextChanged(self, userInput) -- EditBox
+ if userInput then
+ self = self.obj
+ self:Fire("OnTextChanged", self.editBox:GetText())
+ self.button:Enable()
+ end
+end
+
+local function OnTextSet(self) -- EditBox
+ self:HighlightText(0, 0)
+ self:SetCursorPosition(self:GetNumLetters())
+ self:SetCursorPosition(0)
+ self.obj.button:Disable()
+end
+
+local function OnVerticalScroll(self, offset) -- ScrollFrame
+ local editBox = self.obj.editBox
+ editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight())
+end
+
+local function OnScrollRangeChanged(self, xrange, yrange)
+ if yrange == 0 then
+ self.obj.editBox:SetHitRectInsets(0, 0, 0, 0)
+ else
+ OnVerticalScroll(self, self:GetVerticalScroll())
+ end
+end
+
+local function OnShowFocus(frame)
+ frame.obj.editBox:SetFocus()
+ frame:SetScript("OnShow", nil)
+end
+
+local function OnEditFocusGained(frame)
+ AceGUI:SetFocus(frame.obj)
+ frame.obj:Fire("OnEditFocusGained")
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self.editBox:SetText("")
+ self:SetDisabled(false)
+ self:SetWidth(200)
+ self:DisableButton(false)
+ self:SetNumLines()
+ self.entered = nil
+ self:SetMaxLetters(0)
+ end,
+
+ ["OnRelease"] = function(self)
+ self:ClearFocus()
+ end,
+
+ ["SetDisabled"] = function(self, disabled)
+ local editBox = self.editBox
+ if disabled then
+ editBox:ClearFocus()
+ editBox:EnableMouse(false)
+ editBox:SetTextColor(0.5, 0.5, 0.5)
+ self.label:SetTextColor(0.5, 0.5, 0.5)
+ self.scrollFrame:EnableMouse(false)
+ self.button:Disable()
+ else
+ editBox:EnableMouse(true)
+ editBox:SetTextColor(1, 1, 1)
+ self.label:SetTextColor(1, 0.82, 0)
+ self.scrollFrame:EnableMouse(true)
+ end
+ end,
+
+ ["SetLabel"] = function(self, text)
+ if text and text ~= "" then
+ self.label:SetText(text)
+ if self.labelHeight ~= 10 then
+ self.labelHeight = 10
+ self.label:Show()
+ end
+ elseif self.labelHeight ~= 0 then
+ self.labelHeight = 0
+ self.label:Hide()
+ end
+ Layout(self)
+ end,
+
+ ["SetNumLines"] = function(self, value)
+ if not value or value < 4 then
+ value = 4
+ end
+ self.numlines = value
+ Layout(self)
+ end,
+
+ ["SetText"] = function(self, text)
+ self.editBox:SetText(text)
+ end,
+
+ ["GetText"] = function(self)
+ return self.editBox:GetText()
+ end,
+
+ ["SetMaxLetters"] = function (self, num)
+ self.editBox:SetMaxLetters(num or 0)
+ end,
+
+ ["DisableButton"] = function(self, disabled)
+ self.disablebutton = disabled
+ if disabled then
+ self.button:Hide()
+ else
+ self.button:Show()
+ end
+ Layout(self)
+ end,
+
+ ["ClearFocus"] = function(self)
+ self.editBox:ClearFocus()
+ self.frame:SetScript("OnShow", nil)
+ end,
+
+ ["SetFocus"] = function(self)
+ self.editBox:SetFocus()
+ if not self.frame:IsShown() then
+ self.frame:SetScript("OnShow", OnShowFocus)
+ end
+ end,
+
+ ["HighlightText"] = function(self, from, to)
+ self.editBox:HighlightText(from, to)
+ end,
+
+ ["GetCursorPosition"] = function(self)
+ return self.editBox:GetCursorPosition()
+ end,
+
+ ["SetCursorPosition"] = function(self, ...)
+ return self.editBox:SetCursorPosition(...)
+ end,
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local backdrop = {
+ bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
+ edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16,
+ insets = { left = 4, right = 3, top = 4, bottom = 3 }
+}
+
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+ frame:Hide()
+
+ local widgetNum = AceGUI:GetNextWidgetNum(Type)
+
+ local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
+ label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, -4)
+ label:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -4)
+ label:SetJustifyH("LEFT")
+ label:SetText(ACCEPT)
+ label:SetHeight(10)
+
+ local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate")
+ button:SetPoint("BOTTOMLEFT", 0, 4)
+ button:SetHeight(22)
+ button:SetWidth(label:GetStringWidth() + 24)
+ button:SetText(ACCEPT)
+ button:SetScript("OnClick", OnClick)
+ button:Disable()
+
+ local text = button:GetFontString()
+ text:ClearAllPoints()
+ text:SetPoint("TOPLEFT", button, "TOPLEFT", 5, -5)
+ text:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -5, 1)
+ text:SetJustifyV("MIDDLE")
+
+ local scrollBG = CreateFrame("Frame", nil, frame, "BackdropTemplate")
+ scrollBG:SetBackdrop(backdrop)
+ scrollBG:SetBackdropColor(0, 0, 0)
+ scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
+
+ local scrollFrame = CreateFrame("ScrollFrame", ("%s%dScrollFrame"):format(Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
+
+ local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"]
+ scrollBar:ClearAllPoints()
+ scrollBar:SetPoint("TOP", label, "BOTTOM", 0, -19)
+ scrollBar:SetPoint("BOTTOM", button, "TOP", 0, 18)
+ scrollBar:SetPoint("RIGHT", frame, "RIGHT")
+
+ scrollBG:SetPoint("TOPRIGHT", scrollBar, "TOPLEFT", 0, 19)
+ scrollBG:SetPoint("BOTTOMLEFT", button, "TOPLEFT")
+
+ scrollFrame:SetPoint("TOPLEFT", scrollBG, "TOPLEFT", 5, -6)
+ scrollFrame:SetPoint("BOTTOMRIGHT", scrollBG, "BOTTOMRIGHT", -4, 4)
+ scrollFrame:SetScript("OnEnter", OnEnter)
+ scrollFrame:SetScript("OnLeave", OnLeave)
+ scrollFrame:SetScript("OnMouseUp", OnMouseUp)
+ scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag)
+ scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
+ scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll)
+ scrollFrame:HookScript("OnScrollRangeChanged", OnScrollRangeChanged)
+
+ local editBox = CreateFrame("EditBox", ("%s%dEdit"):format(Type, widgetNum), scrollFrame)
+ editBox:SetAllPoints()
+ editBox:SetFontObject(ChatFontNormal)
+ editBox:SetMultiLine(true)
+ editBox:EnableMouse(true)
+ editBox:SetAutoFocus(false)
+ editBox:SetCountInvisibleLetters(false)
+ editBox:SetScript("OnCursorChanged", OnCursorChanged)
+ editBox:SetScript("OnEditFocusLost", OnEditFocusLost)
+ editBox:SetScript("OnEnter", OnEnter)
+ editBox:SetScript("OnEscapePressed", editBox.ClearFocus)
+ editBox:SetScript("OnLeave", OnLeave)
+ editBox:SetScript("OnMouseDown", OnReceiveDrag)
+ editBox:SetScript("OnReceiveDrag", OnReceiveDrag)
+ editBox:SetScript("OnTextChanged", OnTextChanged)
+ editBox:SetScript("OnTextSet", OnTextSet)
+ editBox:SetScript("OnEditFocusGained", OnEditFocusGained)
+
+
+ scrollFrame:SetScrollChild(editBox)
+
+ local widget = {
+ button = button,
+ editBox = editBox,
+ frame = frame,
+ label = label,
+ labelHeight = 10,
+ numlines = 4,
+ scrollBar = scrollBar,
+ scrollBG = scrollBG,
+ scrollFrame = scrollFrame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ button.obj, editBox.obj, scrollFrame.obj = widget, widget, widget
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type, Constructor, Version)
diff --git a/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua
new file mode 100644
index 0000000..8989608
--- /dev/null
+++ b/Broker2FuBar/libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua
@@ -0,0 +1,280 @@
+--[[-----------------------------------------------------------------------------
+Slider Widget
+Graphical Slider, like, for Range values.
+-------------------------------------------------------------------------------]]
+local Type, Version = "Slider", 23
+local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
+if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
+
+-- Lua APIs
+local min, max, floor = math.min, math.max, math.floor
+local tonumber, pairs = tonumber, pairs
+
+-- WoW APIs
+local PlaySound = PlaySound
+local CreateFrame, UIParent = CreateFrame, UIParent
+
+--[[-----------------------------------------------------------------------------
+Support functions
+-------------------------------------------------------------------------------]]
+local function UpdateText(self)
+ local value = self.value or 0
+ if self.ispercent then
+ self.editbox:SetText(("%s%%"):format(floor(value * 1000 + 0.5) / 10))
+ else
+ self.editbox:SetText(floor(value * 100 + 0.5) / 100)
+ end
+end
+
+local function UpdateLabels(self)
+ local min_value, max_value = (self.min or 0), (self.max or 100)
+ if self.ispercent then
+ self.lowtext:SetFormattedText("%s%%", (min_value * 100))
+ self.hightext:SetFormattedText("%s%%", (max_value * 100))
+ else
+ self.lowtext:SetText(min_value)
+ self.hightext:SetText(max_value)
+ end
+end
+
+--[[-----------------------------------------------------------------------------
+Scripts
+-------------------------------------------------------------------------------]]
+local function Control_OnEnter(frame)
+ frame.obj:Fire("OnEnter")
+end
+
+local function Control_OnLeave(frame)
+ frame.obj:Fire("OnLeave")
+end
+
+local function Frame_OnMouseDown(frame)
+ frame.obj.slider:EnableMouseWheel(true)
+ AceGUI:ClearFocus()
+end
+
+local function Slider_OnValueChanged(frame, newvalue)
+ local self = frame.obj
+ if not frame.setup then
+ if self.step and self.step > 0 then
+ local min_value = self.min or 0
+ newvalue = floor((newvalue - min_value) / self.step + 0.5) * self.step + min_value
+ end
+ if newvalue ~= self.value and not self.disabled then
+ self.value = newvalue
+ self:Fire("OnValueChanged", newvalue)
+ end
+ if self.value then
+ UpdateText(self)
+ end
+ end
+end
+
+local function Slider_OnMouseUp(frame)
+ local self = frame.obj
+ self:Fire("OnMouseUp", self.value)
+end
+
+local function Slider_OnMouseWheel(frame, v)
+ local self = frame.obj
+ if not self.disabled then
+ local value = self.value
+ if v > 0 then
+ value = min(value + (self.step or 1), self.max)
+ else
+ value = max(value - (self.step or 1), self.min)
+ end
+ self.slider:SetValue(value)
+ end
+end
+
+local function EditBox_OnEscapePressed(frame)
+ frame:ClearFocus()
+end
+
+local function EditBox_OnEnterPressed(frame)
+ local self = frame.obj
+ local value = frame:GetText()
+ if self.ispercent then
+ value = value:gsub('%%', '')
+ value = tonumber(value) / 100
+ else
+ value = tonumber(value)
+ end
+
+ if value then
+ PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
+ self.slider:SetValue(value)
+ self:Fire("OnMouseUp", value)
+ end
+end
+
+local function EditBox_OnEnter(frame)
+ frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
+end
+
+local function EditBox_OnLeave(frame)
+ frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
+end
+
+--[[-----------------------------------------------------------------------------
+Methods
+-------------------------------------------------------------------------------]]
+local methods = {
+ ["OnAcquire"] = function(self)
+ self:SetWidth(200)
+ self:SetHeight(44)
+ self:SetDisabled(false)
+ self:SetIsPercent(nil)
+ self:SetSliderValues(0,100,1)
+ self:SetValue(0)
+ self.slider:EnableMouseWheel(false)
+ end,
+
+ -- ["OnRelease"] = nil,
+
+ ["SetDisabled"] = function(self, disabled)
+ self.disabled = disabled
+ if disabled then
+ self.slider:EnableMouse(false)
+ self.label:SetTextColor(.5, .5, .5)
+ self.hightext:SetTextColor(.5, .5, .5)
+ self.lowtext:SetTextColor(.5, .5, .5)
+ --self.valuetext:SetTextColor(.5, .5, .5)
+ self.editbox:SetTextColor(.5, .5, .5)
+ self.editbox:EnableMouse(false)
+ self.editbox:ClearFocus()
+ else
+ self.slider:EnableMouse(true)
+ self.label:SetTextColor(1, .82, 0)
+ self.hightext:SetTextColor(1, 1, 1)
+ self.lowtext:SetTextColor(1, 1, 1)
+ --self.valuetext:SetTextColor(1, 1, 1)
+ self.editbox:SetTextColor(1, 1, 1)
+ self.editbox:EnableMouse(true)
+ end
+ end,
+
+ ["SetValue"] = function(self, value)
+ self.slider.setup = true
+ self.slider:SetValue(value)
+ self.value = value
+ UpdateText(self)
+ self.slider.setup = nil
+ end,
+
+ ["GetValue"] = function(self)
+ return self.value
+ end,
+
+ ["SetLabel"] = function(self, text)
+ self.label:SetText(text)
+ end,
+
+ ["SetSliderValues"] = function(self, min_value, max_value, step)
+ local frame = self.slider
+ frame.setup = true
+ self.min = min_value
+ self.max = max_value
+ self.step = step
+ frame:SetMinMaxValues(min_value or 0,max_value or 100)
+ UpdateLabels(self)
+ frame:SetValueStep(step or 1)
+ if self.value then
+ frame:SetValue(self.value)
+ end
+ frame.setup = nil
+ end,
+
+ ["SetIsPercent"] = function(self, value)
+ self.ispercent = value
+ UpdateLabels(self)
+ UpdateText(self)
+ end
+}
+
+--[[-----------------------------------------------------------------------------
+Constructor
+-------------------------------------------------------------------------------]]
+local SliderBackdrop = {
+ bgFile = "Interface\\Buttons\\UI-SliderBar-Background",
+ edgeFile = "Interface\\Buttons\\UI-SliderBar-Border",
+ tile = true, tileSize = 8, edgeSize = 8,
+ insets = { left = 3, right = 3, top = 6, bottom = 6 }
+}
+
+local ManualBackdrop = {
+ bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
+ tile = true, edgeSize = 1, tileSize = 5,
+}
+
+local function Constructor()
+ local frame = CreateFrame("Frame", nil, UIParent)
+
+ frame:EnableMouse(true)
+ frame:SetScript("OnMouseDown", Frame_OnMouseDown)
+
+ local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ label:SetPoint("TOPLEFT")
+ label:SetPoint("TOPRIGHT")
+ label:SetJustifyH("CENTER")
+ label:SetHeight(15)
+
+ local slider = CreateFrame("Slider", nil, frame, "BackdropTemplate")
+ slider:SetOrientation("HORIZONTAL")
+ slider:SetHeight(15)
+ slider:SetHitRectInsets(0, 0, -10, 0)
+ slider:SetBackdrop(SliderBackdrop)
+ slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal")
+ slider:SetPoint("TOP", label, "BOTTOM")
+ slider:SetPoint("LEFT", 3, 0)
+ slider:SetPoint("RIGHT", -3, 0)
+ slider:SetValue(0)
+ slider:SetScript("OnValueChanged",Slider_OnValueChanged)
+ slider:SetScript("OnEnter", Control_OnEnter)
+ slider:SetScript("OnLeave", Control_OnLeave)
+ slider:SetScript("OnMouseUp", Slider_OnMouseUp)
+ slider:SetScript("OnMouseWheel", Slider_OnMouseWheel)
+
+ local lowtext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
+ lowtext:SetPoint("TOPLEFT", slider, "BOTTOMLEFT", 2, 3)
+
+ local hightext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
+ hightext:SetPoint("TOPRIGHT", slider, "BOTTOMRIGHT", -2, 3)
+
+ local editbox = CreateFrame("EditBox", nil, frame, "BackdropTemplate")
+ editbox:SetAutoFocus(false)
+ editbox:SetFontObject(GameFontHighlightSmall)
+ editbox:SetPoint("TOP", slider, "BOTTOM")
+ editbox:SetHeight(14)
+ editbox:SetWidth(70)
+ editbox:SetJustifyH("CENTER")
+ editbox:EnableMouse(true)
+ editbox:SetBackdrop(ManualBackdrop)
+ editbox:SetBackdropColor(0, 0, 0, 0.5)
+ editbox:SetBackdropBorderColor(0.3, 0.3, 0.30, 0.80)
+ editbox:SetScript("OnEnter", EditBox_OnEnter)
+ editbox:SetScript("OnLeave", EditBox_OnLeave)
+ editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed)
+ editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed)
+
+ local widget = {
+ label = label,
+ slider = slider,
+ lowtext = lowtext,
+ hightext = hightext,
+ editbox = editbox,
+ alignoffset = 25,
+ frame = frame,
+ type = Type
+ }
+ for method, func in pairs(methods) do
+ widget[method] = func
+ end
+ slider.obj, editbox.obj = widget, widget
+
+ return AceGUI:RegisterAsWidget(widget)
+end
+
+AceGUI:RegisterWidgetType(Type,Constructor,Version)
diff --git a/Broker2FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua b/Broker2FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua
new file mode 100644
index 0000000..bd04241
--- /dev/null
+++ b/Broker2FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua
@@ -0,0 +1,207 @@
+--[[ $Id: CallbackHandler-1.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ ]]
+local MAJOR, MINOR = "CallbackHandler-1.0", 7
+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 error = error
+local setmetatable, rawget = setmetatable, rawget
+local next, select, pairs, type, tostring = next, select, pairs, type, tostring
+
+local xpcall = xpcall
+
+local function errorhandler(err)
+ return geterrorhandler()(err)
+end
+
+local function Dispatch(handlers, ...)
+ local index, method = next(handlers)
+ if not method then return end
+ repeat
+ xpcall(method, errorhandler, ...)
+ index, method = next(handlers, index)
+ until not method
+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(_self, target, RegisterName, UnregisterName, UnregisterAllName)
+
+ RegisterName = RegisterName or "RegisterCallback"
+ UnregisterName = UnregisterName or "UnregisterCallback"
+ if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
+ UnregisterAllName = "UnregisterAllCallbacks"
+ end
+
+ -- we declare all objects and exported APIs inside this closure to quickly gain access
+ -- to e.g. function names, the "target" parameter, etc
+
+
+ -- Create the registry object
+ local events = setmetatable({}, meta)
+ local registry = { recurse=0, events=events }
+
+ -- registry:Fire() - fires the given event/message into the registry
+ function registry:Fire(eventname, ...)
+ if not rawget(events, eventname) or not next(events[eventname]) then return end
+ local oldrecurse = registry.recurse
+ registry.recurse = oldrecurse + 1
+
+ Dispatch(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 event,callbacks in pairs(registry.insertQueue) do
+ local first = not rawget(events, event) or not next(events[event]) -- test for empty before. not test for one member after. that one member may have been overwritten.
+ for object,func in pairs(callbacks) do
+ events[event][object] = func
+ -- fire OnUsed callback?
+ if first and registry.OnUsed then
+ registry.OnUsed(registry, target, event)
+ 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.
+
diff --git a/Broker2FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml b/Broker2FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml
new file mode 100644
index 0000000..a5b22a7
--- /dev/null
+++ b/Broker2FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/Broker2FuBar/libs/LibDataBroker-1.1/LibDataBroker-1.1.lua b/Broker2FuBar/libs/LibDataBroker-1.1/LibDataBroker-1.1.lua
new file mode 100644
index 0000000..f47c0cd
--- /dev/null
+++ b/Broker2FuBar/libs/LibDataBroker-1.1/LibDataBroker-1.1.lua
@@ -0,0 +1,90 @@
+
+assert(LibStub, "LibDataBroker-1.1 requires LibStub")
+assert(LibStub:GetLibrary("CallbackHandler-1.0", true), "LibDataBroker-1.1 requires CallbackHandler-1.0")
+
+local lib, oldminor = LibStub:NewLibrary("LibDataBroker-1.1", 4)
+if not lib then return end
+oldminor = oldminor or 0
+
+
+lib.callbacks = lib.callbacks or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
+lib.attributestorage, lib.namestorage, lib.proxystorage = lib.attributestorage or {}, lib.namestorage or {}, lib.proxystorage or {}
+local attributestorage, namestorage, callbacks = lib.attributestorage, lib.namestorage, lib.callbacks
+
+if oldminor < 2 then
+ lib.domt = {
+ __metatable = "access denied",
+ __index = function(self, key) return attributestorage[self] and attributestorage[self][key] end,
+ }
+end
+
+if oldminor < 3 then
+ lib.domt.__newindex = function(self, key, value)
+ if not attributestorage[self] then attributestorage[self] = {} end
+ if attributestorage[self][key] == value then return end
+ attributestorage[self][key] = value
+ local name = namestorage[self]
+ if not name then return end
+ callbacks:Fire("LibDataBroker_AttributeChanged", name, key, value, self)
+ callbacks:Fire("LibDataBroker_AttributeChanged_"..name, name, key, value, self)
+ callbacks:Fire("LibDataBroker_AttributeChanged_"..name.."_"..key, name, key, value, self)
+ callbacks:Fire("LibDataBroker_AttributeChanged__"..key, name, key, value, self)
+ end
+end
+
+if oldminor < 2 then
+ function lib:NewDataObject(name, dataobj)
+ if self.proxystorage[name] then return end
+
+ if dataobj then
+ assert(type(dataobj) == "table", "Invalid dataobj, must be nil or a table")
+ self.attributestorage[dataobj] = {}
+ for i,v in pairs(dataobj) do
+ self.attributestorage[dataobj][i] = v
+ dataobj[i] = nil
+ end
+ end
+ dataobj = setmetatable(dataobj or {}, self.domt)
+ self.proxystorage[name], self.namestorage[dataobj] = dataobj, name
+ self.callbacks:Fire("LibDataBroker_DataObjectCreated", name, dataobj)
+ return dataobj
+ end
+end
+
+if oldminor < 1 then
+ function lib:DataObjectIterator()
+ return pairs(self.proxystorage)
+ end
+
+ function lib:GetDataObjectByName(dataobjectname)
+ return self.proxystorage[dataobjectname]
+ end
+
+ function lib:GetNameByDataObject(dataobject)
+ return self.namestorage[dataobject]
+ end
+end
+
+if oldminor < 4 then
+ local next = pairs(attributestorage)
+ function lib:pairs(dataobject_or_name)
+ local t = type(dataobject_or_name)
+ assert(t == "string" or t == "table", "Usage: ldb:pairs('dataobjectname') or ldb:pairs(dataobject)")
+
+ local dataobj = self.proxystorage[dataobject_or_name] or dataobject_or_name
+ assert(attributestorage[dataobj], "Data object not found")
+
+ return next, attributestorage[dataobj], nil
+ end
+
+ local ipairs_iter = ipairs(attributestorage)
+ function lib:ipairs(dataobject_or_name)
+ local t = type(dataobject_or_name)
+ assert(t == "string" or t == "table", "Usage: ldb:ipairs('dataobjectname') or ldb:ipairs(dataobject)")
+
+ local dataobj = self.proxystorage[dataobject_or_name] or dataobject_or_name
+ assert(attributestorage[dataobj], "Data object not found")
+
+ return ipairs_iter, attributestorage[dataobj], 0
+ end
+end
diff --git a/Broker2FuBar/libs/LibDataBroker-1.1/README.textile b/Broker2FuBar/libs/LibDataBroker-1.1/README.textile
new file mode 100644
index 0000000..ef16fed
--- /dev/null
+++ b/Broker2FuBar/libs/LibDataBroker-1.1/README.textile
@@ -0,0 +1,13 @@
+LibDataBroker is a small WoW addon library designed to provide a "MVC":http://en.wikipedia.org/wiki/Model-view-controller interface for use in various addons.
+LDB's primary goal is to "detach" plugins for TitanPanel and FuBar from the display addon.
+Plugins can provide data into a simple table, and display addons can receive callbacks to refresh their display of this data.
+LDB also provides a place for addons to register "quicklaunch" functions, removing the need for authors to embed many large libraries to create minimap buttons.
+Users who do not wish to be "plagued" by these buttons simply do not install an addon to render them.
+
+Due to it's simple generic design, LDB can be used for any design where you wish to have an addon notified of changes to a table.
+
+h2. Links
+
+* "API documentation":http://github.com/tekkub/libdatabroker-1-1/wikis/api
+* "Data specifications":http://github.com/tekkub/libdatabroker-1-1/wikis/data-specifications
+* "Addons using LDB":http://github.com/tekkub/libdatabroker-1-1/wikis/addons-using-ldb
diff --git a/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.lua b/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.lua
new file mode 100644
index 0000000..722888a
--- /dev/null
+++ b/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.lua
@@ -0,0 +1,2273 @@
+--[[
+Name: LibFuBarPlugin-3.0
+Revision: $Rev: 63 $
+Developed by: ckknight (ckknight@gmail.com) and Arrowmaster
+Website: http://www.wowace.com/
+Description: Plugin for FuBar.
+Dependencies: LibStub
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "LibFuBarPlugin-3.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 63 $"):match("%d+"))
+
+if not LibStub then error(MAJOR_VERSION .. " requires LibStub") end
+
+local FuBarPlugin, oldMinor = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
+if not FuBarPlugin then
+ return
+end
+local oldLib
+if oldMinor then
+ oldLib = {}
+ for k, v in pairs(FuBarPlugin) do
+ oldLib[k] = v
+ FuBarPlugin[k] = nil
+ end
+end
+
+local SHOW_FUBAR_ICON = "Show FuBar icon"
+local SHOW_FUBAR_ICON_DESC = "Show the FuBar plugin's icon on the panel."
+local SHOW_FUBAR_TEXT = "Show FuBar text"
+local SHOW_FUBAR_TEXT_DESC = "Show the FuBar plugin's text on the panel."
+local SHOW_COLORED_FUBAR_TEXT = "Show colored FuBar text"
+local SHOW_COLORED_FUBAR_TEXT_DESC = "Allow the FuBar plugin to color its text on the panel."
+local DETACH_FUBAR_TOOLTIP = "Detach FuBar tooltip"
+local DETACH_FUBAR_TOOLTIP_DESC = "Detach the FuBar tooltip from the panel."
+local LOCK_FUBAR_TOOLTIP = "Lock tooltip"
+local LOCK_FUBAR_TOOLTIP_DESC = "Lock the tooltips position. When the tooltip is locked, you must use Alt to access it with your mouse."
+local POSITION_ON_FUBAR = "Position on FuBar"
+local POSITION_ON_FUBAR_DESC = "Position the FuBar plugin on the panel."
+local POSITION_LEFT = "Left"
+local POSITION_RIGHT = "Right"
+local POSITION_CENTER = "Center"
+local ATTACH_PLUGIN_TO_MINIMAP = "Attach FuBar plugin to minimap"
+local ATTACH_PLUGIN_TO_MINIMAP_DESC = "Attach the FuBar plugin to the minimap instead of the panel."
+local HIDE_FUBAR_PLUGIN = "Hide FuBar plugin"
+local HIDE_MINIMAP_BUTTON = "Hide minimap button"
+local HIDE_FUBAR_PLUGIN_DESC = "Hide the FuBar plugin from the panel or minimap, leaving the addon running."
+local OTHER = "Other"
+local CLOSE = "Close"
+local CLOSE_DESC = "Close the menu."
+
+if GetLocale() == "zhCN" then
+ SHOW_FUBAR_ICON = "显示FuBar图标"
+ SHOW_FUBAR_ICON_DESC = "在面板上显示FuBar插件的图标."
+ SHOW_FUBAR_TEXT = "显示FuBar文字"
+ SHOW_FUBAR_TEXT_DESC = "在面板上显示Fubar插件文字标题"
+ SHOW_COLORED_FUBAR_TEXT = "显示彩色文字"
+ SHOW_COLORED_FUBAR_TEXT_DESC = "允许插件显示彩色文字."
+ DETACH_FUBAR_TOOLTIP = "独立提示信息"
+ DETACH_FUBAR_TOOLTIP_DESC = "从面板上独立显示信息"
+ LOCK_FUBAR_TOOLTIP = "锁定提示信息"
+ LOCK_FUBAR_TOOLTIP_DESC = "锁定提示信息位置.当提示信息被锁定时,你必须要按Alt-鼠标方可查看."
+ POSITION_ON_FUBAR = "位置"
+ POSITION_ON_FUBAR_DESC = "FuBar插件在面板上的位置."
+ POSITION_LEFT = "居左"
+ POSITION_RIGHT = "居右"
+ POSITION_CENTER = "居中"
+ ATTACH_PLUGIN_TO_MINIMAP = "依附在小地图"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "插件图标依附在小地图而不显示在面板上."
+ HIDE_FUBAR_PLUGIN = "隐藏FuBar插件"
+ HIDE_MINIMAP_BUTTON = "隐藏小地图按钮"
+ HIDE_FUBAR_PLUGIN_DESC = "隐藏在面板或小地图上的FuBar插件,暂定插件工作."
+ OTHER = "其他"
+ CLOSE = "关闭"
+ CLOSE_DESC = "关闭目录."
+elseif GetLocale() == "zhTW" then
+ SHOW_FUBAR_ICON = "顯示圖示"
+ SHOW_FUBAR_ICON_DESC = "在面板上顯示插件圖示。"
+ SHOW_FUBAR_TEXT = "顯示文字"
+ SHOW_FUBAR_TEXT_DESC = "在面板上顯示插件文字。"
+ SHOW_COLORED_FUBAR_TEXT = "允許彩色文字"
+ SHOW_COLORED_FUBAR_TEXT_DESC = "允許插件在面板上使用彩色文字。"
+ DETACH_FUBAR_TOOLTIP = "獨立提示訊息"
+ DETACH_FUBAR_TOOLTIP_DESC = "從面板上獨立提示訊息。"
+ LOCK_FUBAR_TOOLTIP = "鎖定提示訊息"
+ LOCK_FUBAR_TOOLTIP_DESC = "鎖定提示訊息位置。當提示訊息鎖定時,需要用Alt鍵使用提示訊息的功能。"
+ POSITION_ON_FUBAR = "位置"
+ POSITION_ON_FUBAR_DESC = "插件在面板上的位置。"
+ POSITION_LEFT = "靠左"
+ POSITION_RIGHT = "靠右"
+ POSITION_CENTER = "置中"
+ ATTACH_PLUGIN_TO_MINIMAP = "依附在小地圖"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "插件圖標依附在小地圖而不顯示在面板上。"
+ HIDE_FUBAR_PLUGIN = "隱藏插件"
+ HIDE_MINIMAP_BUTTON = "隱藏小地圖按鈕"
+ HIDE_FUBAR_PLUGIN_DESC = "在面板或小地圖上隱藏該插件,但保持執行狀態。"
+ OTHER = "其他"
+ CLOSE = "關閉"
+ CLOSE_DESC = "關閉選單。"
+elseif GetLocale() == "koKR" then
+ SHOW_FUBAR_ICON = "FuBar 아이콘 표시"
+ SHOW_FUBAR_ICON_DESC = "FuBar 패널에 플러그인 아이콘을 표시합니다."
+ SHOW_FUBAR_TEXT = "FuBar 텍스트 표시"
+ SHOW_FUBAR_TEXT_DESC = "FuBar 페널에 플러그인 텍스트를 표시합니다."
+ SHOW_COLORED_FUBAR_TEXT = "색상화된 FuBar 텍스트 표시"
+ SHOW_COLORED_FUBAR_TEXT_DESC = "패널의 FuBar 플러그인의 텍스트 색상을 허용합니다."
+ DETACH_FUBAR_TOOLTIP = "FuBar 툴팁 분리"
+ DETACH_FUBAR_TOOLTIP_DESC = "패널에서 FuBar 툴팁을 분리합니다."
+ LOCK_FUBAR_TOOLTIP = "툴팁 고정"
+ LOCK_FUBAR_TOOLTIP_DESC = "툴팁 위치를 고정시킵니다. 툴팁이 고정되어 있을때, 마우스로 접근하기 위해 Alt키를 사용하여야 합니다."
+ POSITION_ON_FUBAR = "FuBar 위치"
+ POSITION_ON_FUBAR_DESC = "패널 위의 FuBar 플러그인의 위치를 설정합니다."
+ POSITION_LEFT = "좌측"
+ POSITION_RIGHT = "우측"
+ POSITION_CENTER = "중앙"
+ ATTACH_PLUGIN_TO_MINIMAP = "FuBar 플러그인 미니맵 표시"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "FuBar 플러그인을 패널 대신 미니맵에 표시합니다."
+ HIDE_FUBAR_PLUGIN = "FuBar 플러그인 숨김"
+ HIDE_MINIMAP_BUTTON = "미니맵 버튼 숨김"
+ HIDE_FUBAR_PLUGIN_DESC = "FuBar 플러그인을 패널이나 미니맵으로 부터 숨김니다."
+ OTHER = "기타"
+ CLOSE = "닫기"
+ CLOSE_DESC = "메뉴를 닫습니다."
+elseif GetLocale() == "frFR" then
+ SHOW_FUBAR_ICON = "Afficher l'icône FuBar"
+ SHOW_FUBAR_ICON_DESC = "Affiche l'icône du plugin FuBar sur le panneau."
+ SHOW_FUBAR_TEXT = "Afficher le texte FuBar"
+ SHOW_FUBAR_TEXT_DESC = "Affiche le texte du plugin FuBar sur le panneau."
+ SHOW_COLORED_FUBAR_TEXT = "Afficher le texte FuBar coloré"
+ SHOW_COLORED_FUBAR_TEXT_DESC = "Autorise le plugin FuBar à colorer son texte sur le panneau."
+ DETACH_FUBAR_TOOLTIP = "Détacher l'infobulle FuBar"
+ DETACH_FUBAR_TOOLTIP_DESC = "Détache l'infobulle FuBar du panneau."
+ LOCK_FUBAR_TOOLTIP = "Verrouiller l'infobulle"
+ LOCK_FUBAR_TOOLTIP_DESC = "Verrouille l'infobulle dans sa position actuelle. Quand l'infobulle est verrouillée, vous devez utiliser la touche Alt pour y interagir avec la souris."
+ POSITION_ON_FUBAR = "Position sur FuBar"
+ POSITION_ON_FUBAR_DESC = "Position du plugin FuBar sur le panneau."
+ POSITION_LEFT = "Gauche"
+ POSITION_RIGHT = "Droite"
+ POSITION_CENTER = "Centre"
+ ATTACH_PLUGIN_TO_MINIMAP = "Attacher le plugin FuBar sur la minicarte"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "Attache le plugin FuBar sur la minicarte au lieu du panneau."
+ HIDE_FUBAR_PLUGIN = "Masquer le plugin FuBar"
+ HIDE_MINIMAP_BUTTON = "Masquer le bouton de la minicarte"
+ HIDE_FUBAR_PLUGIN_DESC = "Masque le plugin FuBar du panneau ou de la minicarte, laissant l'addon fonctionner."
+ OTHER = "Autre"
+ CLOSE = "Fermer"
+ CLOSE_DESC = "Ferme le menu."
+elseif GetLocale() == "ruRU" then
+ SHOW_FUBAR_ICON = "Показ иконку"
+ SHOW_FUBAR_ICON_DESC = "Показывать иконку плагина на панели."
+ SHOW_FUBAR_TEXT = "Показ текста"
+ SHOW_FUBAR_TEXT_DESC = "Показывать текст плагина на панели."
+ SHOW_COLORED_FUBAR_TEXT = "Показ цветового текста"
+ SHOW_COLORED_FUBAR_TEXT_DESC = "Позволить плагину использовать его цвета в тексте."
+ DETACH_FUBAR_TOOLTIP = "Отделить подсказку"
+ DETACH_FUBAR_TOOLTIP_DESC = "Отделить всплывающую подсказку от панели."
+ LOCK_FUBAR_TOOLTIP = "Закрепить подсказку"
+ LOCK_FUBAR_TOOLTIP_DESC = "Закрепить позицию всплывающей подсказки. Когда всплывающая подсказка закреплена, используйте Alt для отображения ее у мыши."
+ POSITION_ON_FUBAR = "Позиция"
+ POSITION_ON_FUBAR_DESC = "Позиция плагина на панели."
+ POSITION_LEFT = "Слева"
+ POSITION_RIGHT = "Справа"
+ POSITION_CENTER = "По центру"
+ ATTACH_PLUGIN_TO_MINIMAP = "Закрепить у мини-карты"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "Закрепить плагин у мини-карты вместо панели."
+ HIDE_FUBAR_PLUGIN = "Скрыть плагин"
+ HIDE_MINIMAP_BUTTON = "Скрыть кнопку у мини-карты"
+ HIDE_FUBAR_PLUGIN_DESC = "Скрыть плагин с панели или мини-карты, но оставить аддон в рабочем состоянии."
+ OTHER = "Другое"
+ CLOSE = "Закрыть"
+ CLOSE_DESC = "Закрыть меню."
+end
+
+-- #AUTODOC_NAMESPACE FuBarPlugin
+
+local newList, del
+do
+ local pool = setmetatable({}, {__mode = 'kv'})
+
+ function newList(...)
+ local t = next(pool)
+ local n = select('#', ...)
+ if t then
+ pool[t] = nil
+ for i = 1, n do
+ t[i] = select(i, ...)
+ end
+ else
+ t = { ... }
+ end
+
+ return t, n
+ end
+
+ function del(t)
+ if not t then
+ error(("Bad argument #1 to `del'. Expected %q, got %q."):format("table", type(t)), 2)
+ end
+ if pool[t] then
+ local _, ret = pcall(error, "Error, double-free syndrome.", 3)
+ geterrorhandler()(ret)
+ end
+ setmetatable(t, nil)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t[true] = true
+ t[true] = nil
+ pool[t] = true
+ end
+end
+
+FuBarPlugin.pluginToFrame = oldLib and oldLib.pluginToFrame or {}
+local pluginToFrame = FuBarPlugin.pluginToFrame
+FuBarPlugin.pluginToMinimapFrame = oldLib and oldLib.pluginToMinimapFrame or {}
+local pluginToMinimapFrame = FuBarPlugin.pluginToMinimapFrame
+FuBarPlugin.pluginToPanel = oldLib and oldLib.pluginToPanel or {}
+local pluginToPanel = FuBarPlugin.pluginToPanel
+FuBarPlugin.pluginToOptions = oldLib and oldLib.pluginToOptions or {}
+local pluginToOptions = FuBarPlugin.pluginToOptions
+FuBarPlugin.folderNames = oldLib and oldLib.folderNames or {}
+local folderNames = FuBarPlugin.folderNames
+
+local RockConfig
+local Tablet20
+local Dewdrop20
+local AceConfigRegistry30
+local AceConfigDialog30
+local AceConfigDropdown30
+
+FuBarPlugin.MinimapContainer = oldLib and oldLib.MinimapContainer or {}
+local MinimapContainer = FuBarPlugin.MinimapContainer
+
+local epsilon = 1e-5
+
+FuBarPlugin.mixinTargets = oldLib and oldLib.mixinTargets or {}
+local mixinTargets = FuBarPlugin.mixinTargets
+local mixins = {
+ "SetFuBarOption",
+ "GetTitle",
+ "GetName",
+ "GetCategory",
+ "SetFontSize",
+ "GetFrame",
+ "Show",
+ "Hide",
+ "GetPanel",
+ "IsFuBarTextColored",
+ "ToggleFuBarTextColored",
+ "IsFuBarMinimapAttached",
+ "ToggleFuBarMinimapAttached",
+ "UpdateFuBarPlugin",
+ "UpdateFuBarText",
+ "UpdateFuBarTooltip",
+ "SetFuBarIcon",
+ "GetFuBarIcon",
+ "CheckWidth",
+ "SetFuBarText",
+ "GetFuBarText",
+ "IsFuBarIconShown",
+ "ToggleFuBarIconShown",
+ "ShowFuBarIcon",
+ "HideFuBarIcon",
+ "IsFuBarTextShown",
+ "ToggleFuBarTextShown",
+ "ShowFuBarText",
+ "HideFuBarText",
+ "IsFuBarTooltipDetached",
+ "ToggleFuBarTooltipDetached",
+ "DetachFuBarTooltip",
+ "ReattachFuBarTooltip",
+ "GetDefaultPosition",
+ "SetPanel",
+ "IsDisabled",
+ "CreateBasicPluginFrame",
+ "CreatePluginChildFrame",
+ "OpenMenu"
+}
+
+-- #AUTODOC_NAMESPACE FuBarPlugin
+
+--[[---------------------------------------------------------------------------
+Notes:
+ *Set metadata about a certain plugin.
+ ; tooltipType : string -
+ : "GameTooltip"
+ :: Use Blizzard's GameTooltip. (default if not given)
+ : "Tablet-2.0"
+ :: Use Tablet-2.0.
+ : "Custom"
+ :: LibFuBarPlugin-3.0 will not provide any extra mechanisms, all done manually.
+ ; configType : string -
+ : "LibRockConfig-1.0"
+ :: Use LibRockConfig-1.0 to show configuration. (default if not given)
+ : "Dewdrop-2.0"
+ :: Use Dewdrop-2.0.
+ : "AceConfigDialog-3.0"
+ :: Use AceConfigDialog-3.0.
+ : "AceConfigDropdown-3.0"
+ :: Use AceConfigDropdown-3.0.
+ : "None"
+ :: No config (and will register RightButtonUp for OnFuBarClick)
+ ; hasNoText : boolean - If set to true, then it will be a text-less frame.
+ ; iconPath : string - the path of the icon to show.
+ ; hasNoColor : boolean - If set to true, then it is assumed that no color will be in the text (and thus not show the menu item)
+ ; cannotHideText : boolean - If set to true, then the menu item to hide text will not be shown.
+ ; overrideMenu : boolean - If set to true, then the menu will not show any of the standard menu items
+ ; hideMenuTitle : boolean - If set to true, the plugins name will not be added to the top of the menu as a header.
+ ; defaultPosition : string -
+ : "LEFT"
+ ::show on the left. (default if not given)
+ : "CENTER"
+ ::show in the center.
+ : "RIGHT"
+ ::show on the right.
+ : "MINIMAP"
+ ::show on the minimap.
+ ; defaultMinimapPosition : number - Angle on the minimap, in degrees. [0, 360)
+ ; clickableTooltip : boolean - Whether you can drag your mouse onto the tooltip and click a line
+ ; tooltipHiddenWhenEmpty : boolean - Whether the detached tooltip is hidden when it is empty.
+ ; cannotDetachTooltip : boolean - Whether the tooltip cannot be detached from the plugin text.
+ ::Normally, a tooltip can detach (if using Tablet-2.0). This should be set if there is no relevant data in the tooltip.
+ ; independentProfile : boolean - If set to true, then the profile setting will not be stripped from .OnMenuRequest, and FuBar will not set the plugin's profile when it changes.
+ ::non-FuBar-centric plugins should set this to true.
+Arguments:
+ string - the key to set
+ value - the value to set said key to.
+Example:
+ self:SetFuBarOption('tooltipType', "Tablet-2.0")
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:SetFuBarOption(key, value)
+ local pluginToOptions_self = pluginToOptions[self]
+ if not pluginToOptions_self then
+ pluginToOptions_self = {}
+ pluginToOptions[self] = pluginToOptions_self
+ end
+
+ pluginToOptions_self[key] = value
+
+ if key == 'tooltipType' then
+ if value == "Tablet-2.0" then
+ Tablet20 = LibStub("Tablet-2.0", true)
+ if not Tablet20 then
+ error(("Cannot specify %q = %q if %q is not loaded."):format(key, value, value), 2)
+ end
+ end
+ end
+ if key == 'configType' then
+ if value == "Dewdrop-2.0" then
+ Dewdrop20 = LibStub("Dewdrop-2.0", true)
+ if not Dewdrop20 then
+ error(("Cannot specify %q = %q if %q is not loaded."):format(key, value, value), 2)
+ end
+ elseif value == "AceConfigDialog-3.0" then
+ AceConfigRegistry30 = LibStub("AceConfigRegistry-3.0", true)
+ AceConfigDialog30 = LibStub("AceConfigDialog-3.0", true)
+ if not AceConfigDialog30 then
+ error(("Cannot specify %q = %q if %q is not loaded."):format(key, value, value), 2)
+ end
+ elseif value == "AceConfigDropdown-3.0" then
+ AceConfigRegistry30 = LibStub("AceConfigRegistry-3.0", true)
+ AceConfigDropdown30 = LibStub("AceConfigDropdown-3.0", true)
+ if not AceConfigDropdown30 then
+ error(("Cannot specify %q = %q if %q is not loaded."):format(key, value, value), 2)
+ end
+ end
+ end
+end
+
+local function getPluginOption(object, key, default)
+ local pluginToOptions_object = pluginToOptions[object]
+ if pluginToOptions_object == nil then
+ return default
+ end
+ local value = pluginToOptions_object[key]
+ if value == nil then
+ return default
+ end
+ return value
+end
+
+local good = nil
+local function CheckFuBar()
+ if not good then
+ if FuBar then
+ local version = FuBar.version
+ if type(version) == "string" then
+ local num = version:match("^(%d+%.?%d*)")
+ if num then
+ num = tonumber(num)
+ good = num > 2
+ end
+ end
+ end
+ end
+ return good
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string - the localized name of the plugin, not including the "FuBar - " part.
+Example
+ local title = self:GetTitle()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetTitle()
+ local name = self.title or self.name
+ if type(name) ~= "string" then
+ error("You must provide self.title or self.name", 2)
+ end
+ local title = name:match("[Ff][Uu][Bb][Aa][Rr]%s*%-%s*(.-)%s*$") or name
+ return title:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "")
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string - name of the plugin.
+Notes:
+ This is here for FuBar core to communicate properly.
+Example:
+ local name = self:GetName()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetName()
+ return self.name
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string - category of the plugin.
+Notes:
+ This is here for FuBar core to communicate properly.
+Example:
+ local category = self:GetCategory()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetCategory()
+ return self.category or OTHER
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ frame - frame for the plugin.
+Notes:
+ This is here for FuBar core to communicate properly.
+Example:
+ local frame = self:GetFrame()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetFrame()
+ return pluginToFrame[self]
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ object - panel for the plugin.
+Notes:
+ This is here for FuBar core to communicate properly.
+Example:
+ local panel = self:GetPanel()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetPanel()
+ return pluginToPanel[self]
+end
+
+local function getLazyDatabaseValueDefault(object, value, ...)
+ local object_db = object.db
+ if type(object_db) ~= "table" then
+ return value
+ end
+ local current = object_db.profile
+ for i = 1, select('#', ...) do
+ -- traverse through, make sure tables exist.
+ if type(current) ~= "table" then
+ return value
+ end
+ current = current[(select(i, ...))]
+ end
+ if current == nil then
+ return value
+ else
+ return current
+ end
+end
+
+local function getLazyDatabaseValue(object, ...)
+ return getLazyDatabaseValueDefault(object, nil, ...)
+end
+
+local function setLazyDatabaseValue(object, value, ...)
+ local object_db = object.db
+ if type(object_db) ~= "table" then
+ return nil
+ end
+ local current = object_db.profile
+ if type(current) ~= "table" then
+ return nil
+ end
+ local n = select('#', ...)
+ for i = 1, n-1 do
+ -- traverse through, create tables if necessary.
+ local nextOne = current[(select(i, ...))]
+ if type(nextOne) ~= "table" then
+ if nextOne ~= nil then
+ return nil
+ end
+ nextOne = {}
+ current[(select(i, ...))] = nextOne
+ end
+ current = nextOne
+ end
+ current[select(n, ...)] = value
+ return true
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ boolean - whether the text has color applied.
+Example:
+ local colored = self:IsFuBarTextColored()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:IsFuBarTextColored()
+ return not getLazyDatabaseValue(self, 'uncolored')
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Toggles whether the text has color applied
+Example:
+ self:ToggleTextColored()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ToggleFuBarTextColored()
+ if not setLazyDatabaseValue(self, not getLazyDatabaseValue(self, 'uncolored') or nil, 'uncolored') then
+ error(("%s: Cannot change text color if self.db is not available."):format(self:GetTitle()), 2)
+ end
+ self:UpdateFuBarText()
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ boolean - whether the plugin is attached to the minimap.
+Example:
+ local attached = self:IsMinimapAttached()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:IsFuBarMinimapAttached()
+ if not CheckFuBar() then
+ return true
+ end
+ return pluginToPanel[self] == MinimapContainer
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Toggles whether the plugin is attached to the minimap.
+Example:
+ self:ToggleMinimapAttached()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ToggleFuBarMinimapAttached()
+ if CheckFuBar() and not getPluginOption(self, 'cannotAttachToMinimap', false) then
+ local panel = pluginToPanel[self]
+ local value = panel == MinimapContainer
+ if value then
+ panel:RemovePlugin(self)
+ local defaultPosition = getPluginOption(self, 'defaultPosition', "LEFT")
+ FuBar:GetPanel(1):AddPlugin(self, nil, defaultPosition == "MINIMAP" and "LEFT" or defaultPosition)
+ else
+ if panel then
+ panel:RemovePlugin(self)
+ end
+ MinimapContainer:AddPlugin(self)
+ end
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Calls :UpdateFuBarText() and :UpdateFuBarTooltip(), in that order.
+Example:
+ self:UpdateFuBarPlugin()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:UpdateFuBarPlugin()
+ self:UpdateFuBarText()
+ self:UpdateFuBarTooltip()
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Calls :OnUpdateFuBarText() if it is available and the plugin is not disabled.
+ * It is expected to update the icon in :OnUpdateFuBarText as well as text.
+Example:
+ self:UpdateFuBarText()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:UpdateFuBarText()
+ if type(self.OnUpdateFuBarText) == "function" then
+ if not self:IsDisabled() then
+ self:OnUpdateFuBarText()
+ end
+ elseif self:IsFuBarTextShown() then
+ self:SetFuBarText(self:GetTitle())
+ end
+end
+
+local function Tablet20_point(frame)
+ if frame:GetTop() > GetScreenHeight() / 2 then
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 3 then
+ return "TOPLEFT", "BOTTOMLEFT"
+ elseif x < GetScreenWidth() * 2 / 3 then
+ return "TOP", "BOTTOM"
+ else
+ return "TOPRIGHT", "BOTTOMRIGHT"
+ end
+ else
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 3 then
+ return "BOTTOMLEFT", "TOPLEFT"
+ elseif x < GetScreenWidth() * 2 / 3 then
+ return "BOTTOM", "TOP"
+ else
+ return "BOTTOMRIGHT", "TOPRIGHT"
+ end
+ end
+end
+
+local function RegisterTablet20(self)
+ local frame = pluginToFrame[self]
+ if not Tablet20:IsRegistered(frame) then
+ local db = getLazyDatabaseValue(self)
+ if db and not db.detachedTooltip then
+ db.detachedTooltip = {}
+ end
+ Tablet20:Register(frame,
+ 'children', function()
+ Tablet20:SetTitle(self:GetTitle())
+ if type(self.OnUpdateFuBarTooltip) == "function" then
+ if not self:IsDisabled() then
+ self:OnUpdateFuBarTooltip()
+ end
+ end
+ end,
+ 'clickable', getPluginOption(self, 'clickableTooltip', false),
+ 'data', CheckFuBar() and FuBar.db.profile.tooltip or db and db.detachedTooltip or {},
+ 'detachedData', db and db.detachedTooltip or {},
+ 'point', Tablet20_point,
+ 'menu', self.OnMenuRequest and function(level, value, valueN_1, valueN_2, valueN_3, valueN_4)
+ if level == 1 then
+ local name = tostring(self)
+ if not name:find('^table:') then
+ name = name:gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
+ LibStub("Dewdrop-2.0"):AddLine(
+ 'text', name,
+ 'isTitle', true
+ )
+ end
+ end
+ if type(self.OnMenuRequest) == "function" then
+ self:OnMenuRequest(level, value, true, valueN_1, valueN_2, valueN_3, valueN_4)
+ elseif type(self.OnMenuRequest) == "table" then
+ LibStub("Dewdrop-2.0"):FeedAceOptionsTable(self.OnMenuRequest)
+ end
+ end,
+ 'hideWhenEmpty', getPluginOption(self, 'tooltipHiddenWhenEmpty', false)
+ )
+ local func = pluginToFrame[self]:GetScript("OnEnter")
+ frame:SetScript("OnEnter", function(this, ...)
+ -- HACK
+ func(this, ...)
+
+ if FuBar and FuBar.IsHidingTooltipsInCombat and FuBar:IsHidingTooltipsInCombat() and InCombatLockdown() then
+ if Tablet20:IsAttached(this) then
+ Tablet20:Close(this)
+ end
+ end
+ end)
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Calls :OnUpdateFuBarTooltip() if it is available, the plugin is not disabled, and the tooltip is shown.
+Example:
+ self:UpdateFuBarTooltip()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:UpdateFuBarTooltip()
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+
+ if tooltipType == "GameTooltip" then
+ local frame = self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self]
+ if not GameTooltip:IsOwned(frame) then
+ return
+ end
+ GameTooltip:Hide()
+
+ local anchor
+ if frame:GetTop() > GetScreenHeight() / 2 then
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 2 then
+ anchor = "ANCHOR_BOTTOMRIGHT"
+ else
+ anchor = "ANCHOR_BOTTOMLEFT"
+ end
+ else
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 2 then
+ anchor = "ANCHOR_TOPLEFT"
+ else
+ anchor = "ANCHOR_TOPRIGHT"
+ end
+ end
+ GameTooltip:SetOwner(frame, anchor)
+ if type(self.OnUpdateFuBarTooltip) == "function" and not self:IsDisabled() then
+ self:OnUpdateFuBarTooltip()
+ end
+ GameTooltip:Show()
+ return
+ elseif tooltipType == "Custom" then
+ if type(self.OnUpdateFuBarTooltip) == "function" and not self:IsDisabled() then
+ self:OnUpdateFuBarTooltip()
+ end
+ return
+ elseif tooltipType == "Tablet-2.0" then
+ RegisterTablet20(self)
+ if self:IsFuBarMinimapAttached() and not self:IsFuBarTooltipDetached() and pluginToMinimapFrame[self] then
+ Tablet20:Refresh(pluginToMinimapFrame[self])
+ else
+ Tablet20:Refresh(pluginToFrame[self])
+ end
+ elseif tooltipType == "None" then
+ return
+ else
+ error(("Unknown %s option for %q: %q"):format(MAJOR_VERSION, 'tooltipType', tostring(tooltipType)), 2)
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Shows the plugin, enables the plugin if previously disabled, and calls :UpdateFuBarPlugin().
+Example:
+ self:Show()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:Show(panelId)
+ if pluginToFrame[self]:IsShown() or (pluginToMinimapFrame[self] and pluginToMinimapFrame[self]:IsShown()) then
+ return
+ end
+ if panelId ~= false then
+ setLazyDatabaseValue(self, nil, 'hidden')
+ end
+ if self.IsActive and not self:IsActive() then
+ self.panelIdTmp = panelId
+ self:ToggleActive()
+ self.panelIdTmp = nil
+ setLazyDatabaseValue(self, nil, 'disabled')
+ elseif not getLazyDatabaseValue(self, 'hidden') then
+ if panelId == 0 or not CheckFuBar() then
+ -- MinimapContainer:AddPlugin(self)
+ -- Hide Masque button
+ else
+ FuBar:ShowPlugin(self, panelId or self.panelIdTmp)
+ end
+ if not getPluginOption(self, 'userDefinedFrame', false) then
+ if not self:IsFuBarTextShown() then
+ local text = pluginToFrame[self].text
+ text:SetText("")
+ text:SetWidth(epsilon)
+ text:Hide()
+ end
+ if not self:IsFuBarIconShown() then
+ local icon = pluginToFrame[self].icon
+ icon:SetWidth(epsilon)
+ icon:Hide()
+ end
+ end
+ if getPluginOption(self, 'tooltipType', "GameTooltip") == "Tablet-2.0"
+ and not getPluginOption(self, 'cannotDetachTooltip', false)
+ and getLazyDatabaseValue(self, 'detachedTooltip', 'detached') then
+ self:UpdateFuBarTooltip()
+ Tablet20:Open(pluginToFrame[self])
+ end
+ self:UpdateFuBarPlugin()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Hides the plugin, disables the plugin if cannot hide without standby.
+Arguments:
+ [optional] boolean - internal variable. Do not set this.
+Example:
+ self:Hide()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:Hide(check)
+ if not pluginToFrame[self]:IsShown() and (not pluginToMinimapFrame[self] or not pluginToMinimapFrame[self]:IsShown()) then
+ return
+ end
+ local hideWithoutStandby = getPluginOption(self, 'hideWithoutStandby', false)
+ if hideWithoutStandby and check ~= false then
+ setLazyDatabaseValue(self, true, 'hidden')
+ end
+ if not hideWithoutStandby then
+ if getPluginOption(self, 'tooltipType', "GameTooltip") == "Tablet-2.0" and not getPluginOption(self, 'cannotDetachTooltip', false) and self:IsFuBarTooltipDetached() and getLazyDatabaseValue(self, 'detachedTooltip', 'detached') then
+ self:ReattachTooltip()
+ setLazyDatabaseValue(self, true, 'detachedTooltip', 'detached')
+ end
+ if self.IsActive and self:IsActive() and self.ToggleActive and (not CheckFuBar() or not FuBar:IsChangingProfile()) then
+ self:ToggleActive()
+ end
+ end
+ if pluginToPanel[self] then
+ pluginToPanel[self]:RemovePlugin(self)
+ end
+ pluginToFrame[self]:Hide()
+ if pluginToMinimapFrame[self] then
+ pluginToMinimapFrame[self]:Hide()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Sets the path to the icon for the plugin.
+Arguments:
+ string or nil - The path to the icon. If nil, then no icon.
+Example:
+ self:SetFuBarIcon("Interface\\AddOns\\MyAddon\\otherIcon")
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:SetFuBarIcon(path)
+ if not path then
+ return
+ end
+ if not pluginToFrame[self] or not pluginToFrame[self].icon then
+ return
+ end
+ if path:match([[^Interface\Icons\]]) then
+ pluginToFrame[self].icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ pluginToFrame[self].icon:SetTexCoord(0, 1, 0, 1)
+ end
+ pluginToFrame[self].icon:SetTexture(path)
+ if pluginToMinimapFrame[self] and pluginToMinimapFrame[self].icon then
+ if path:match([[^Interface\Icons\]]) then
+ pluginToMinimapFrame[self].icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ pluginToMinimapFrame[self].icon:SetTexCoord(0, 1, 0, 1)
+ end
+ pluginToMinimapFrame[self].icon:SetTexture(path)
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string or nil - The path to the icon for the plugin. If nil, then no icon.
+Example:
+ local path = self:GetFuBarIcon()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetFuBarIcon()
+ if getPluginOption(self, 'iconPath', false) then
+ return pluginToFrame[self] and pluginToFrame[self].icon and pluginToFrame[self].icon:GetTexture()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Checks the current width of the icon and text, then updates frame to expand/shrink to it if necessary.
+Arguments:
+ [optional] boolean - if true, Shrink/expand no matter what, otherwise if the width is less than 8 pixels smaller, don't shrink.
+Example:
+ self:CheckWidth(true)
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:CheckWidth(force)
+ local frame = pluginToFrame[self]
+ if not frame then
+ return
+ end
+ local icon = frame.icon
+ local text = frame.text
+ if (not icon or not icon:IsShown()) and (not text or not text:IsShown()) then
+ return
+ end
+
+ local db = getLazyDatabaseValue(self)
+
+ if (db and not self:IsFuBarIconShown()) or not getPluginOption(self, 'iconPath', false) then
+ icon:SetWidth(epsilon)
+ end
+ local width
+ if not getPluginOption(self, 'hasNoText', false) then
+ text:SetHeight(0)
+ text:SetWidth(500)
+ width = text:GetStringWidth() + 1
+ text:SetWidth(width)
+ text:SetHeight(text:GetHeight())
+ end
+ local panel = pluginToPanel[self]
+ if getPluginOption(self, 'hasNoText', false) or not text:IsShown() then
+ frame:SetWidth(icon:GetWidth())
+ if panel and panel:GetPluginSide(self) == "CENTER" then
+ panel:UpdateCenteredPosition()
+ end
+ elseif force or not frame.textWidth or frame.textWidth < width or frame.textWidth - 8 > width then
+ frame.textWidth = width
+ text:SetWidth(width)
+ if icon and icon:IsShown() then
+ frame:SetWidth(width + icon:GetWidth())
+ else
+ frame:SetWidth(width)
+ end
+ if panel and panel:GetPluginSide(self) == "CENTER" then
+ panel:UpdateCenteredPosition()
+ end
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Sets the text of the plugin. Should only be called from within :OnFuBarUpdateText()
+Arguments:
+ string - text to set the plugin to. If not given, set to title.
+Example:
+ myAddon.OnFuBarUpdateText = function(self)
+ self:SetFuBarText("Hello")
+ fend
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:SetFuBarText(text)
+ local frame = pluginToFrame[self]
+ if not frame or not frame.text then
+ return
+ end
+ if text == "" then
+ if getPluginOption(self, 'iconPath', false) then
+ self:ShowFuBarIcon()
+ else
+ text = self:GetTitle()
+ end
+ end
+ if not self:IsFuBarTextColored() then
+ text = text:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "")
+ end
+ frame.text:SetText(text)
+ self:CheckWidth()
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string - The current text of the plugin.
+Example:
+ local text = self:GetFuBarText()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetFuBarText()
+ local frame = pluginToFrame[self]
+ if not frame or not frame.text then
+ error(("%s: Cannot get text without a text frame."):format(self:GetTitle()), 2)
+ end
+ if not getPluginOption(self, 'hasNoText', false) then
+ return frame.text:GetText() or ""
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ boolean - whether the icon for the plugin is showing.
+Example:
+ local isIconShowing = self:IsFuBarIconShown()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:IsFuBarIconShown()
+ if not getPluginOption(self, 'iconPath', false) then
+ return false
+ elseif getPluginOption(self, 'hasNoText', false) then
+ return true
+ end
+ return not not getLazyDatabaseValueDefault(self, true, 'showIcon')
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Toggles whether the icon for the plugin is showing.
+Example:
+ self:ToggleFuBarIconShown()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ToggleFuBarIconShown()
+ local frame = pluginToFrame[self]
+ local icon = frame and frame.icon
+ local text = frame and frame.text
+ if not icon then
+ error(("%s: Cannot toggle icon without an icon frame."):format(self:GetTitle()), 2)
+ elseif not text then
+ error(("%s: Cannot toggle icon without a text frame."):format(self:GetTitle()), 2)
+ elseif not getPluginOption(self, 'iconPath', false) then
+ error(("%s: Cannot show icon unless 'iconPath' is set."):format(self:GetTitle()), 2)
+ elseif getPluginOption(self, 'hasNoText', false) then
+ error(("%s: Cannot show icon if 'hasNoText' is set."):format(self:GetTitle()), 2)
+ elseif not getLazyDatabaseValue(self) then
+ error(("%s: Cannot hide icon if self.db is not available."):format(self:GetTitle()), 2)
+ end
+ local value = not self:IsFuBarIconShown()
+ setLazyDatabaseValue(self, value, 'showIcon')
+ if value then
+ if not self:IsFuBarTextShown() and text:IsShown() and text:GetText() == self:GetTitle() then
+ text:Hide()
+ text:SetText("")
+ end
+ icon:Show()
+ icon:SetWidth(pluginToFrame[self].icon:GetHeight())
+ self:UpdateFuBarText()
+ else
+ if not text:IsShown() or not text:GetText() or text:GetText() == "" then
+ text:Show()
+ text:SetText(self:GetTitle())
+ end
+ icon:Hide()
+ icon:SetWidth(epsilon)
+ end
+ self:CheckWidth(true)
+ return value
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Shows the icon of the plugin if hidden.
+Example:
+ self:ShowFuBarIcon()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ShowFuBarIcon()
+ if not self:IsFuBarIconShown() then
+ self:ToggleFuBarIconShown()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Hides the icon of the plugin if shown.
+Example:
+ self:HideFuBarIcon()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:HideFuBarIcon()
+ if self:IsFuBarIconShown() then
+ self:ToggleFuBarIconShown()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ boolean - whether the text for the plugin is showing.
+Example:
+ local isTextShowing = self:IsFuBarTextShown()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:IsFuBarTextShown()
+ if getPluginOption(self, 'hasNoText', false) then
+ return false
+ elseif not getPluginOption(self, 'iconPath', false) then
+ return true
+ end
+ return not not getLazyDatabaseValueDefault(self, true, 'showText')
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Toggles whether the text for the plugin is showing.
+Example:
+ self:ToggleFuBarTextShown()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ToggleFuBarTextShown()
+ local frame = pluginToFrame[self]
+ local icon = frame and frame.icon
+ local text = frame and frame.text
+ if not icon then
+ error(("%s: Cannot toggle text without an icon frame."):format(self:GetTitle()), 2)
+ elseif not text then
+ error(("%s: Cannot toggle text without a text frame."):format(self:GetTitle()), 2)
+ elseif getPluginOption(self, 'cannotHideText', false) then
+ error(("%s: Cannot toggle text if 'cannotHideText' is set."):format(self:GetTitle()), 2)
+ elseif not getPluginOption(self, 'iconPath', false) then
+ error(("%s: Cannot toggle text unless 'iconPath' is set."):format(self:GetTitle()), 2)
+ elseif getPluginOption(self, 'hasNoText', false) then
+ error(("%s: Cannot toggle text if 'hasNoText' is set."):format(self:GetTitle()), 2)
+ elseif not getLazyDatabaseValue(self) then
+ error(("%s: Cannot toggle text if self.db is not available."):format(self:GetTitle()), 2)
+ end
+ local value = not self:IsFuBarTextShown()
+ setLazyDatabaseValue(self, value, 'showText')
+ if value then
+ text:Show()
+ self:UpdateFuBarText()
+ else
+ text:SetText("")
+ text:SetWidth(epsilon)
+ text:Hide()
+ self:ShowFuBarIcon()
+ end
+ self:CheckWidth(true)
+ return value
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Shows the text of the plugin if hidden.
+Example:
+ self:ShowFuBarText()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ShowFuBarText()
+ if not self:IsFuBarTextShown() then
+ self:ToggleFuBarTextShown()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Hides the text of the plugin if shown.
+Example:
+ self:HideFuBarText()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:HideFuBarText()
+ if self:IsFuBarTextShown() then
+ self:ToggleFuBarTextShown()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string - default position of the plugin.
+Notes:
+ This is here for FuBar core to communicate properly.
+Example:
+ local pos = self:GetDefaultPosition()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetDefaultPosition()
+ return getPluginOption(self, 'defaultPosition', "LEFT")
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ boolean - Whether the tooltip is detached.
+Example:
+ local detached = self:IsFuBarTooltipDetached()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:IsFuBarTooltipDetached()
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType ~= "Tablet-2.0" then
+ return
+ end
+
+ RegisterTablet20(self)
+ return not Tablet20:IsAttached(pluginToFrame[self])
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Toggles whether the tooltip is detached.
+Example:
+ self:ToggleFuBarTooltipDetached()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ToggleFuBarTooltipDetached()
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType ~= "Tablet-2.0" then
+ return
+ end
+
+ RegisterTablet20(self)
+ if Tablet20:IsAttached(pluginToFrame[self]) then
+ Tablet20:Open(pluginToFrame[self])
+ Tablet20:Detach(pluginToFrame[self])
+ else
+ Tablet20:Attach(pluginToFrame[self])
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Detaches the tooltip from the plugin.
+ * This does nothing if already detached.
+Example:
+ self:DetachFuBarTooltip()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:DetachFuBarTooltip()
+ if not self:IsFuBarTooltipDetached() then
+ self:ToggleFuBarTooltipDetached()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Reattaches the tooltip to the plugin.
+ This does nothing if already attached.
+Example:
+ self:ReattachFuBarTooltip()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ReattachFuBarTooltip()
+ if self:IsFuBarTooltipDetached() then
+ self:ToggleFuBarTooltipDetached()
+ end
+end
+
+local function IsCorrectPanel(panel)
+ if type(panel) ~= "table" then
+ return false
+ elseif type(panel.AddPlugin) ~= "function" then
+ return false
+ elseif type(panel.RemovePlugin) ~= "function" then
+ return false
+ elseif type(panel.GetNumPlugins) ~= "function" then
+ return false
+ elseif type(panel:GetNumPlugins()) ~= "number" then
+ return false
+ elseif type(panel.GetPlugin) ~= "function" then
+ return false
+ elseif type(panel.HasPlugin) ~= "function" then
+ return false
+ elseif type(panel.GetPluginSide) ~= "function" then
+ return false
+ end
+ return true
+end
+
+-- #NODOC
+-- this is used internally by FuBar
+function FuBarPlugin:SetPanel(panel)
+ pluginToPanel[self] = panel
+end
+
+-- #NODOC
+-- this is used internally by FuBar
+function FuBarPlugin:SetFontSize(size)
+ if getPluginOption(self, 'userDefinedFrame', false) then
+ error(("%sYou must provide a :SetFontSize(size) method if you have 'userDefinedFrame' set."):format(self.name and self.name .. ": " or ""), 2)
+ end
+ if getPluginOption(self, 'iconPath', false) then
+ local frame = pluginToFrame[self]
+ local icon = frame and frame.icon
+ if not icon then
+ error(("%sno icon frame found."):format(self.name and self.name .. ": " or ""), 2)
+ end
+ icon:SetWidth(size + 3)
+ icon:SetHeight(size + 3)
+ end
+ if not getPluginOption(self, 'hasNoText', false) then
+ local frame = pluginToFrame[self]
+ local text = frame and frame.text
+ if not text then
+ error(("%sno text frame found."):format(self.name and self.name .. ": " or ""), 2)
+ end
+ local font, _, flags = text:GetFont()
+ text:SetFont(font, size, flags)
+ end
+ self:CheckWidth()
+end
+
+local function IsLoadOnDemand(plugin)
+ return IsAddOnLoadOnDemand(folderNames[plugin] or "")
+end
+
+-- #NODOC
+-- this is used internally by FuBar.
+function FuBarPlugin:IsDisabled()
+ return type(self.IsActive) == "function" and not self:IsActive() or false
+end
+
+function FuBarPlugin:Embed(target)
+ local stack = debugstack(5, 1, 0)
+ local folder = stack:match("[Oo%.][Nn%.][Ss%.]/([^/]+)/")
+ if not folder then
+ local partFolder = stack:match("...([^/]+)/")
+ if partFolder then
+ local partFolder_len = #partFolder
+ for i = 1, GetNumAddOns() do
+ local name = GetAddOnInfo(i)
+ if #name >= partFolder_len then
+ local partName = name:sub(-partFolder_len)
+ if partName == partFolder then
+ folder = name
+ end
+ end
+ end
+ end
+ if not folder then
+ for i = 6, 3, -1 do
+ folder = debugstack(i, 1, 0):match("/AddOns/(.*)/")
+ if folder then
+ break
+ end
+ end
+ end
+ end
+ folderNames[target] = folder
+
+ for _,name in pairs(mixins) do
+ target[name] = FuBarPlugin[name]
+ end
+ FuBarPlugin.mixinTargets[target] = true
+end
+
+local frame_OnClick, frame_OnDoubleClick, frame_OnMouseDown, frame_OnMouseUp, frame_OnReceiveDrag, frame_OnEnter, frame_OnLeave
+--[[---------------------------------------------------------------------------
+Arguments:
+ [optional] string - name of the frame
+Returns:
+ frame - a frame with the basic scripts to be considered a plugin frame.
+Example:
+ MyPlugin.frame = MyPlugin:CreateBasicPluginFrame("FuBar_MyPluginFrame")
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:CreateBasicPluginFrame(name)
+ local frame = CreateFrame("Button", name, UIParent)
+ frame:SetFrameStrata("HIGH")
+ frame:SetFrameLevel(7)
+ frame:EnableMouse(true)
+ frame:EnableMouseWheel(true)
+ frame:SetMovable(true)
+ frame:SetWidth(150)
+ frame:SetHeight(24)
+ frame:SetPoint("CENTER", UIParent, "CENTER")
+ frame.self = self
+ if getPluginOption(self, 'configType', "LibRockConfig-1.0") == "None" then
+ frame:RegisterForClicks("LeftButtonUp", "RightButtonUp")
+ else
+ frame:RegisterForClicks("LeftButtonUp")
+ end
+ if not frame_OnEnter then
+ function frame_OnEnter(this)
+ local self = this.self
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "GameTooltip" then
+ GameTooltip:SetOwner(self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self], "ANCHOR_CURSOR")
+ self:UpdateFuBarTooltip()
+ end
+ if type(self.OnFuBarEnter) == "function" then
+ self:OnFuBarEnter()
+ end
+ end
+ end
+ frame:SetScript("OnEnter", frame_OnEnter)
+ if not frame_OnLeave then
+ function frame_OnLeave(this)
+ local self = this.self
+ if type(self.OnFuBarLeave) == "function" then
+ self:OnFuBarLeave()
+ end
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "GameTooltip" and GameTooltip:IsOwned(self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self]) then
+ GameTooltip:Hide()
+ end
+ end
+ end
+ frame:SetScript("OnLeave", frame_OnLeave)
+ if not frame_OnClick then
+ function frame_OnClick(this, button)
+ local self = this.self
+ if self:IsFuBarMinimapAttached() and this.dragged then return end
+ if type(self.OnFuBarClick) == "function" then
+ self:OnFuBarClick(button)
+ end
+ end
+ end
+ frame:SetScript("OnClick", frame_OnClick)
+ if not frame_OnDoubleClick then
+ function frame_OnDoubleClick(this, button)
+ local self = this.self
+ if type(self.OnFuBarDoubleClick) == "function" then
+ self:OnFuBarDoubleClick(button)
+ end
+ end
+ end
+ frame:SetScript("OnDoubleClick", frame_OnDoubleClick)
+ if not frame_OnMouseDown then
+ function frame_OnMouseDown(this, button)
+ local self = this.self
+ if button == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then
+ self:OpenMenu()
+ return
+ else
+ if type(self.OnFuBarMouseDown) == "function" then
+ self:OnFuBarMouseDown(button)
+ end
+ end
+ end
+ end
+ frame:SetScript("OnMouseDown", frame_OnMouseDown)
+ if not frame_OnMouseUp then
+ function frame_OnMouseUp(this, button)
+ local self = this.self
+ if type(self.OnFuBarMouseUp) == "function" then
+ self:OnFuBarMouseUp(button)
+ end
+ end
+ end
+ frame:SetScript("OnMouseUp", frame_OnMouseUp)
+ if not frame_OnReceiveDrag then
+ function frame_OnReceiveDrag(this)
+ local self = this.self
+ if (self:IsFuBarMinimapAttached() and not this.dragged) and type(self.OnReceiveDrag) == "function" then
+ self:OnFuBarReceiveDrag()
+ end
+ end
+ end
+ frame:SetScript("OnReceiveDrag", frame_OnReceiveDrag)
+ return frame
+end
+
+local child_OnEnter, child_OnLeave, child_OnClick, child_OnDoubleClick, child_OnMouseDown, child_OnMouseUp, child_OnReceiveDrag
+--[[---------------------------------------------------------------------------
+Arguments:
+ string - type of the frame, e.g. "Frame", "Button", etc.
+ [optional] string - name of the frame
+ [optional] frame - parent frame
+Returns:
+ frame - a child frame that can be manipulated and used
+Example:
+ local child = self:CreatePluginChildFrame("Frame", nil, self.frame)
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:CreatePluginChildFrame(frameType, name, parent)
+ local child = CreateFrame(frameType, name, parent)
+ if parent then
+ child:SetFrameLevel(parent:GetFrameLevel() + 2)
+ end
+ child.self = self
+ if not child_OnEnter then
+ function child_OnEnter(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:GetScript("OnEnter") then
+ frame:GetScript("OnEnter")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnEnter", child_OnEnter)
+ if not child_OnLeave then
+ function child_OnLeave(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:GetScript("OnLeave") then
+ frame:GetScript("OnLeave")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnLeave", child_OnLeave)
+ if child:HasScript("OnClick") then
+ if not child_OnClick then
+ function child_OnClick(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:HasScript("OnClick") and frame:GetScript("OnClick") then
+ frame:GetScript("OnClick")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnClick", child_OnClick)
+ end
+ if child:HasScript("OnDoubleClick") then
+ if not child_OnDoubleClick then
+ function child_OnDoubleClick(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:HasScript("OnDoubleClick") and frame:GetScript("OnDoubleClick") then
+ frame:GetScript("OnDoubleClick")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnDoubleClick", child_OnDoubleClick)
+ end
+ if not child_OnMouseDown then
+ function child_OnMouseDown(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:HasScript("OnMouseDown") and frame:GetScript("OnMouseDown") then
+ frame:GetScript("OnMouseDown")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnMouseDown", child_OnMouseDown)
+ if not child_OnMouseUp then
+ function child_OnMouseUp(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:HasScript("OnMouseUp") and frame:GetScript("OnMouseUp") then
+ frame:GetScript("OnMouseUp")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnMouseUp", child_OnMouseUp)
+ if not child_OnReceiveDrag then
+ function child_OnReceiveDrag(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:HasScript("OnReceiveDrag") and frame:GetScript("OnReceiveDrag") then
+ frame:GetScript("OnReceiveDrag")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnReceiveDrag", child_OnReceiveDrag)
+ return child
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Opens the configuration menu associated with this plugin.
+Example:
+ self:OpenMenu()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:OpenMenu(frame)
+ if not frame then
+ frame = self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self]
+ end
+ if not frame:IsVisible() then
+ frame = UIParent
+ end
+ local configType = getPluginOption(self, 'configType', "LibRockConfig-1.0")
+ if configType == "None" then
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "GameTooltip" then
+ if GameTooltip:IsOwned(frame) then
+ GameTooltip:Hide()
+ end
+ elseif tooltipType == "Custom" and type(self.CloseTooltip) == "function" then
+ self:CloseTooltip()
+ elseif tooltipType == "Tablet-2.0" and Tablet20 then
+ Tablet20:Close()
+ end
+ elseif configType == "Dewdrop-2.0" then
+ if not frame or not self:GetFrame() or Dewdrop20:IsOpen(frame) then
+ Dewdrop20:Close()
+ return
+ end
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "GameTooltip" then
+ if GameTooltip:IsOwned(frame) then
+ GameTooltip:Hide()
+ end
+ elseif tooltipType == "Custom" and type(self.CloseTooltip) == "function" then
+ self:CloseTooltip()
+ elseif tooltipType == "Tablet-2.0" and Tablet20 then
+ Tablet20:Close()
+ end
+
+ if not Dewdrop20:IsRegistered(self:GetFrame()) then
+ if type(self.OnMenuRequest) == "table" and (not self.OnMenuRequest.handler or self.OnMenuRequest.handler == self) and self.OnMenuRequest.type == "group" then
+ Dewdrop20:InjectAceOptionsTable(self, self.OnMenuRequest)
+ if self.OnMenuRequest.args and CheckFuBar() and not getPluginOption(self, 'independentProfile', false) then
+ self.OnMenuRequest.args.profile = nil
+ if self.OnMenuRequest.extraArgs then
+ self.OnMenuRequest.extraArgs.profile = nil
+ end
+ end
+ end
+ Dewdrop20:Register(self:GetFrame(),
+ 'children', type(self.OnMenuRequest) == "table" and self.OnMenuRequest or function(level, value, valueN_1, valueN_2, valueN_3, valueN_4)
+ if level == 1 then
+ -- if not getPluginOption(self, 'hideMenuTitle', false) then
+ -- Dewdrop20:AddLine(
+ -- 'text', self:GetTitle(),
+ -- 'isTitle', true
+ -- )
+ -- end
+
+ if self.OnMenuRequest then
+ self:OnMenuRequest(level, value, false, valueN_1, valueN_2, valueN_3, valueN_4)
+ end
+
+ if not getPluginOption(self, 'overrideMenu', false) then
+ if self.MenuSettings and not getPluginOption(self, 'hideMenuTitle', false) then
+ Dewdrop20:AddLine()
+ end
+ self:AddImpliedMenuOptions()
+ end
+ else
+ if not getPluginOption(self, 'overrideMenu', false) and self:AddImpliedMenuOptions() then
+ else
+ if self.OnMenuRequest then
+ self:OnMenuRequest(level, value, false, valueN_1, valueN_2, valueN_3, valueN_4)
+ end
+ end
+ end
+ if level == 1 then
+ Dewdrop20:AddLine(
+ 'text', CLOSE,
+ 'tooltipTitle', CLOSE,
+ 'tooltipText', CLOSE_DESC,
+ 'func', Dewdrop.Close,
+ 'arg1', Dewdrop
+ )
+ end
+ end,
+ 'point', function(frame)
+ local x, y = frame:GetCenter()
+ local leftRight
+ if x < GetScreenWidth() / 2 then
+ leftRight = "LEFT"
+ else
+ leftRight = "RIGHT"
+ end
+ if y < GetScreenHeight() / 2 then
+ return "BOTTOM" .. leftRight, "TOP" .. leftRight
+ else
+ return "TOP" .. leftRight, "BOTTOM" .. leftRight
+ end
+ end,
+ 'dontHook', true
+ )
+ end
+ if frame == self:GetFrame() then
+ Dewdrop20:Open(self:GetFrame())
+ elseif frame ~= UIParent then
+ Dewdrop20:Open(frame, self:GetFrame())
+ else
+ Dewdrop20:Open(frame, self:GetFrame(), 'cursorX', true, 'cursorY', true)
+ end
+ elseif configType == "LibRockConfig-1.0" then
+ if not RockConfig then
+ RockConfig = Rock and Rock("LibRockConfig-1.0", false, true)
+ end
+ if RockConfig then
+ RockConfig.OpenConfigMenu(self)
+ end
+ elseif configType == "AceConfigDialog-3.0" then
+ if not AceConfigDialog30 then
+ AceConfigDialog30 = LibStub("AceConfigDialog-3.0", true)
+ end
+ if AceConfigDialog30 then
+ AceConfigDialog30:Open(getPluginOption(self, 'aceConfig30', self.name))
+ end
+ elseif configType == "AceConfigDropdown-3.0" then
+ if not AceConfigDropdown30 then
+ AceConfigDropdown30 = LibStub("AceConfigDropdown-3.0", true)
+ end
+ if AceConfigDropdown30 then
+ -- TODO: finalize this once AceConfigDropdown-3.0 exists
+ end
+ else
+ -- TODO: add more possibilities
+ end
+end
+
+function FuBarPlugin.OnEmbedInitialize(FuBarPlugin, self)
+ if not self.frame then
+ local name = MAJOR_VERSION .. "_" .. self:GetTitle() .. "_" .. "Frame"
+ local frame = _G[name]
+ if not frame or not _G[name .. "Text"] or not _G[name .. "Icon"] then
+ frame = FuBarPlugin.CreateBasicPluginFrame(self, name)
+
+ local icon = frame:CreateTexture(name .. "Icon", "ARTWORK")
+ frame.icon = icon
+ icon:SetWidth(16)
+ icon:SetHeight(16)
+ icon:SetPoint("LEFT", frame, "LEFT")
+
+ local text = frame:CreateFontString(name .. "Text", "ARTWORK")
+ frame.text = text
+ text:SetWidth(134)
+ text:SetHeight(24)
+ text:SetPoint("LEFT", icon, "RIGHT", 0, 1)
+ text:SetFontObject(GameFontNormal)
+ end
+ pluginToFrame[self] = frame
+ else
+ pluginToFrame[self] = self.frame
+ if not pluginToOptions[self] then
+ pluginToOptions[self] = {}
+ end
+ pluginToOptions[self].userDefinedFrame = true
+ end
+
+ local frame = pluginToFrame[self]
+ frame.plugin = self
+ frame:SetParent(UIParent)
+ frame:SetPoint("RIGHT", UIParent, "LEFT", -5, 0)
+ frame:Hide()
+
+ local iconPath = getPluginOption(self, 'iconPath', false)
+ if iconPath then
+ self:SetFuBarIcon(iconPath)
+ end
+
+ local registerCallback = rawget(self, "db") and rawget(rawget(self, "db"), "callbacks") and rawget(rawget(self, "db"), "RegisterCallback") or nil
+ if type(registerCallback) == "function" then
+ registerCallback(FuBarPlugin, "OnProfileChanged", "OnEmbedProfileEnable", self)
+ registerCallback(FuBarPlugin, "OnProfileCopied", "OnEmbedProfileEnable", self)
+ registerCallback(FuBarPlugin, "OnProfileReset", "OnEmbedProfileEnable", self)
+ end
+ if CheckFuBar() then
+ FuBar:RegisterPlugin(self)
+ end
+end
+
+local CheckShow = function(self, panelId)
+ if not pluginToFrame[self]:IsShown() and (not pluginToMinimapFrame[self] or not pluginToMinimapFrame[self]:IsShown()) then
+ self:Show(panelId)
+ end
+end
+
+local schedules = {}
+local f = CreateFrame("Frame")
+f:SetScript("OnUpdate", function(this)
+ for i,v in ipairs(schedules) do
+ local success, ret = pcall(unpack(v))
+ if not success then
+ geterrorhandler()(ret)
+ end
+ schedules[i] = del(v)
+ end
+ f:Hide()
+end)
+
+--local recheckPlugins
+--local AceConsole
+local notFirst = {}
+function FuBarPlugin.OnEmbedEnable(FuBarPlugin, self)
+ if not getPluginOption(self, 'userDefinedFrame', false) then
+ local icon = pluginToFrame[self].icon
+ if self:IsFuBarIconShown() then
+ icon:Show()
+ else
+ icon:Hide()
+ end
+ end
+ self:CheckWidth(true)
+
+ if not getPluginOption(self, 'hideWithoutStandby', false) or (getLazyDatabaseValue(self) and not getLazyDatabaseValue(self, 'hidden')) then
+ if notFirst[self] then
+ CheckShow(self, self.panelIdTmp)
+ else
+ notFirst[self] = true
+ schedules[#schedules+1] = newList(CheckShow, self, self.panelIdTmp)
+ f:Show()
+ end
+ end
+
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "Tablet-2.0" and not getPluginOption(self, 'cannotDetachTooltip', false) and getLazyDatabaseValue(self, 'detachedTooltip', 'detached') then
+ schedules[#schedules+1] = newList(self.DetachFuBarTooltip, self)
+ f:Show()
+ end
+
+ if IsLoadOnDemand(self) and CheckFuBar() then
+ if not FuBar.db.profile.loadOnDemand then
+ FuBar.db.profile.loadOnDemand = {}
+ end
+ if not FuBar.db.profile.loadOnDemand[folderNames[self]] then
+ FuBar.db.profile.loadOnDemand[folderNames[self]] = {}
+ end
+ FuBar.db.profile.loadOnDemand[folderNames[self]].disabled = nil
+ end
+ --[[
+ if CheckFuBar() and AceLibrary:HasInstance("AceConsole-2.0") then
+ if not recheckPlugins then
+ if not AceConsole then
+ AceConsole = AceLibrary("AceConsole-2.0")
+ end
+ recheckPlugins = function()
+ for k,v in pairs(AceConsole.registry) do
+ if type(v) == "table" and v.args and AceOO.inherits(v.handler, FuBarPlugin) and not v.handler.independentProfile then
+ v.args.profile = nil
+ end
+ end
+ end
+ end
+ FuBarPlugin:ScheduleEvent("FuBarPlugin-recheckPlugins", recheckPlugins, 0)
+ end
+ ]]
+end
+
+function FuBarPlugin.OnEmbedDisable(FuBarPlugin, self)
+ self:Hide(false)
+
+ if IsLoadOnDemand(self) and CheckFuBar() then
+ if not FuBar.db.profile.loadOnDemand then
+ FuBar.db.profile.loadOnDemand = {}
+ end
+ if not FuBar.db.profile.loadOnDemand[folderNames[self]] then
+ FuBar.db.profile.loadOnDemand[folderNames[self]] = {}
+ end
+ FuBar.db.profile.loadOnDemand[folderNames[self]].disabled = true
+ end
+end
+
+function FuBarPlugin.OnEmbedProfileEnable(FuBarPlugin, self)
+ self:UpdateFuBarPlugin()
+ if getLazyDatabaseValue(self) then
+ if not getLazyDatabaseValue(self, 'detachedTooltip') then
+ setLazyDatabaseValue(self, {}, 'detachedTooltip')
+ end
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "Tablet-2.0" and Tablet20 then
+ if Tablet20.registry[pluginToFrame[self]] then
+ Tablet20:UpdateDetachedData(pluginToFrame[self], getLazyDatabaseValue(self, 'detachedTooltip'))
+ else
+ RegisterTablet20(self)
+ end
+ end
+ if MinimapContainer:HasPlugin(self) then
+ MinimapContainer:ReadjustLocation(self)
+ end
+ end
+end
+
+-- #NODOC
+function FuBarPlugin.GetEmbedRockConfigOptions(FuBarPlugin, self)
+ return 'icon', {
+ type = 'boolean',
+ name = SHOW_FUBAR_ICON,
+ desc = SHOW_FUBAR_ICON_DESC,
+ set = "ToggleFuBarIconShown",
+ get = "IsFuBarIconShown",
+ hidden = function()
+ return not getPluginOption(self, 'iconPath', false) or getPluginOption(self, 'hasNoText', false) or self:IsDisabled() or self:IsFuBarMinimapAttached() or not getLazyDatabaseValue(self)
+ end,
+ order = -13.7,
+ handler = self,
+ }, 'text', {
+ type = 'boolean',
+ name = SHOW_FUBAR_TEXT,
+ desc = SHOW_FUBAR_TEXT_DESC,
+ set = "ToggleFuBarTextShown",
+ get = "IsFuBarTextShown",
+ hidden = function()
+ return getPluginOption(self, 'cannotHideText', false) or not getPluginOption(self, 'iconPath', false) or getPluginOption(self, 'hasNoText') or self:IsDisabled() or self:IsFuBarMinimapAttached() or not getLazyDatabaseValue(self)
+ end,
+ order = -13.6,
+ handler = self,
+ }, 'colorText', {
+ type = 'boolean',
+ name = SHOW_COLORED_FUBAR_TEXT,
+ desc = SHOW_COLORED_FUBAR_TEXT_DESC,
+ set = "ToggleFuBarTextColored",
+ get = "IsFuBarTextColored",
+ hidden = function()
+ return getPluginOption(self, 'userDefinedFrame', false) or getPluginOption(self, 'hasNoText', false) or getPluginOption(self, 'hasNoColor', false) or self:IsDisabled() or self:IsFuBarMinimapAttached() or not getLazyDatabaseValue(self)
+ end,
+ order = -13.5,
+ handler = self,
+ }, 'detachTooltip', {
+ type = 'boolean',
+ name = DETACH_FUBAR_TOOLTIP,
+ desc = DETACH_FUBAR_TOOLTIP_DESC,
+ get = "IsFuBarTooltipDetached",
+ set = "ToggleFuBarTooltipDetached",
+ hidden = function()
+ return not Tablet20 or getPluginOption(self, 'tooltipType', "GameTooltip") ~= "Tablet-2.0" or self:IsDisabled()
+ end,
+ order = -13.4,
+ handler = self,
+ }, 'lockTooltip', {
+ type = 'boolean',
+ name = LOCK_FUBAR_TOOLTIP,
+ desc = LOCK_FUBAR_TOOLTIP_DESC,
+ get = function()
+ return Tablet20:IsLocked(pluginToFrame[self])
+ end,
+ set = function()
+ return Tablet20:ToggleLocked(pluginToFrame[self])
+ end,
+ disabled = function()
+ return not self:IsFuBarTooltipDetached()
+ end,
+ hidden = function()
+ return not Tablet20 or getPluginOption(self, 'tooltipType', "GameTooltip") ~= "Tablet-2.0" or getPluginOption(self, 'cannotDetachTooltip', false) or self:IsDisabled()
+ end,
+ order = -13.3,
+ handler = self,
+ }, 'position', {
+ type = 'choice',
+ name = POSITION_ON_FUBAR,
+ desc = POSITION_ON_FUBAR_DESC,
+ choices = {
+ LEFT = POSITION_LEFT,
+ CENTER = POSITION_CENTER,
+ RIGHT = POSITION_RIGHT
+ },
+ choiceSort = {
+ "LEFT",
+ "CENTER",
+ "RIGHT",
+ },
+ get = function()
+ return self:GetPanel() and self:GetPanel():GetPluginSide(self)
+ end,
+ set = function(value)
+ if self:GetPanel() then
+ self:GetPanel():SetPluginSide(self, value)
+ end
+ end,
+ hidden = function()
+ return self:IsFuBarMinimapAttached() or self:IsDisabled() or not pluginToPanel[self]
+ end,
+ order = -13.2,
+ handler = self,
+ }, 'minimapAttach', {
+ type = 'boolean',
+ name = ATTACH_PLUGIN_TO_MINIMAP,
+ desc = ATTACH_PLUGIN_TO_MINIMAP_DESC,
+ get = "IsFuBarMinimapAttached",
+ set = "ToggleFuBarMinimapAttached",
+ hidden = function()
+ return (getPluginOption(self, 'cannotAttachToMinimap', false) and not self:IsFuBarMinimapAttached()) or not CheckFuBar() or self:IsDisabled()
+ end,
+ order = -13.1,
+ handler = self,
+ }, 'hide', {
+ type = 'boolean',
+ name = function()
+ if self:IsFuBarMinimapAttached() then
+ return HIDE_MINIMAP_BUTTON
+ else
+ return HIDE_FUBAR_PLUGIN
+ end
+ end,
+ desc = HIDE_FUBAR_PLUGIN_DESC,
+ get = function()
+ return not pluginToFrame[self]:IsShown() and (not pluginToMinimapFrame[self] or not pluginToMinimapFrame[self]:IsShown())
+ end,
+ set = function(value)
+ if not value then
+ self:Show()
+ else
+ self:Hide()
+ end
+ end,
+ hidden = function()
+ return not getPluginOption(self, 'hideWithoutStandby', false) or self:IsDisabled()
+ end,
+ order = -13,
+ handler = self,
+ }
+end
+
+local plugins = MinimapContainer.plugins or {}
+for k in pairs(MinimapContainer) do
+ MinimapContainer[k] = nil
+end
+MinimapContainer.plugins = plugins
+
+local minimap_OnMouseDown, minimap_OnMouseUp
+function MinimapContainer:AddPlugin(plugin)
+ if CheckFuBar() and FuBar:IsChangingProfile() then
+ return
+ end
+ if pluginToPanel[plugin] then
+ pluginToPanel[plugin]:RemovePlugin(plugin)
+ end
+ pluginToPanel[plugin] = self
+ if not pluginToMinimapFrame[plugin] then
+ local frame = CreateFrame("Button", pluginToFrame[plugin]:GetName() .. "MinimapButton", Minimap)
+ pluginToMinimapFrame[plugin] = frame
+ plugin.minimapFrame = frame
+ frame.plugin = plugin
+ frame:SetWidth(31)
+ frame:SetHeight(31)
+ frame:SetFrameStrata("BACKGROUND")
+ frame:SetFrameLevel(4)
+ frame:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight")
+ local icon = frame:CreateTexture(frame:GetName() .. "Icon", "BACKGROUND")
+ plugin.minimapIcon = icon
+ local path = plugin:GetFuBarIcon() or (pluginToFrame[plugin].icon and pluginToFrame[plugin].icon:GetTexture()) or "Interface\\Icons\\INV_Misc_QuestionMark"
+ icon:SetTexture(path)
+ if type(path) == "string" and path:sub(1, 16) == "Interface\\Icons\\" then
+ icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
+ else
+ icon:SetTexCoord(0, 1, 0, 1)
+ end
+ icon:SetWidth(20)
+ icon:SetHeight(20)
+ icon:SetPoint("TOPLEFT", frame, "TOPLEFT", 7, -5)
+ local overlay = frame:CreateTexture(frame:GetName() .. "Overlay","OVERLAY")
+ overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder")
+ overlay:SetWidth(53)
+ overlay:SetHeight(53)
+ overlay:SetPoint("TOPLEFT",frame,"TOPLEFT")
+ frame:EnableMouse(true)
+ if getPluginOption(plugin, 'configType', "LibRockConfig-1.0") == "None" then
+ frame:RegisterForClicks("LeftButtonUp", "RightButtonUp")
+ else
+ frame:RegisterForClicks("LeftButtonUp")
+ end
+
+ frame.self = plugin
+ if not frame_OnEnter then
+ function frame_OnEnter(this)
+ if type(this.self.OnFuBarEnter) == "function" then
+ this.self:OnFuBarEnter()
+ end
+ end
+ end
+ frame:SetScript("OnEnter", frame_OnEnter)
+ if not frame_OnLeave then
+ function frame_OnLeave(this)
+ if type(this.self.OnFuBarLeave) == "function" then
+ this.self:OnFuBarLeave()
+ end
+ end
+ end
+ frame:SetScript("OnLeave", frame_OnLeave)
+ if not frame_OnClick then
+ function frame_OnClick(this, arg1)
+ if this.self:IsMinimapAttached() and this.dragged then return end
+ if type(this.self.OnFuBarClick) == "function" then
+ this.self:OnFuBarClick(arg1)
+ end
+ end
+ end
+ frame:SetScript("OnClick", frame_OnClick)
+ if not frame_OnDoubleClick then
+ function frame_OnDoubleClick(this, arg1)
+ if type(this.self.OnFuBarDoubleClick) == "function" then
+ this.self:OnFuBarDoubleClick(arg1)
+ end
+ end
+ end
+ frame:SetScript("OnDoubleClick", frame_OnDoubleClick)
+ if not frame_OnReceiveDrag then
+ function frame_OnReceiveDrag(this)
+ if this.self:IsMinimapAttached() and this.dragged then return end
+ if type(this.self.OnFuBarReceiveDrag) == "function" then
+ this.self:OnFuBarReceiveDrag()
+ end
+ end
+ end
+ frame:SetScript("OnReceiveDrag", frame_OnReceiveDrag)
+ if not minimap_OnMouseDown then
+ function minimap_OnMouseDown(this, arg1)
+ this.dragged = false
+ if arg1 == "LeftButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then
+ HideDropDownMenu(1)
+ if type(this.self.OnFuBarMouseDown) == "function" then
+ this.self:OnFuBarMouseDown(arg1)
+ end
+ elseif arg1 == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then
+ this.self:OpenMenu(this)
+ else
+ HideDropDownMenu(1)
+ if type(this.self.OnFuBarMouseDown) == "function" then
+ this.self:OnFuBarMouseDown(arg1)
+ end
+ end
+ if this.self.OnFuBarClick or this.self.OnFuBarMouseDown or this.self.OnFuBarMouseUp or this.self.OnFuBarDoubleClick then
+ local minimapIconTexture = this.self.minimapIcon:GetTexture()
+ if type(minimapIconTexture) == "string" and minimapIconTexture:sub(1, 16) == "Interface\\Icons\\" then
+ this.self.minimapIcon:SetTexCoord(0.14, 0.86, 0.14, 0.86)
+ else
+ this.self.minimapIcon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
+ end
+ end
+ end
+ end
+ frame:SetScript("OnMouseDown", minimap_OnMouseDown)
+ if not minimap_OnMouseUp then
+ function minimap_OnMouseUp(this, arg1)
+ if not this.dragged and type(this.self.OnFuBarMouseUp) == "function" then
+ this.self:OnFuBarMouseUp(arg1)
+ end
+ local minimapIconTexture = this.self.minimapIcon:GetTexture()
+ if type(minimapIconTexture) == "string" and minimapIconTexture:sub(1, 16) == "Interface\\Icons\\" then
+ this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ this.self.minimapIcon:SetTexCoord(0, 1, 0, 1)
+ end
+ end
+ end
+ frame:SetScript("OnMouseUp", minimap_OnMouseUp)
+ frame:RegisterForDrag("LeftButton")
+ frame:SetScript("OnDragStart", self.OnDragStart)
+ frame:SetScript("OnDragStop", self.OnDragStop)
+
+ if getPluginOption(plugin, 'tooltipType', "GameTooltip") == "Tablet-2.0" then
+ -- Note that we have to do this after :SetScript("OnEnter"), etc,
+ -- so that Tablet-2.0 can override it properly.
+ RegisterTablet20(plugin)
+ Tablet20:Register(frame, pluginToFrame[plugin])
+ end
+ end
+ pluginToFrame[plugin]:Hide()
+ pluginToMinimapFrame[plugin]:Show()
+ self:ReadjustLocation(plugin)
+ table.insert(self.plugins, plugin)
+ local exists = false
+ return true
+end
+
+function MinimapContainer:RemovePlugin(index)
+ if CheckFuBar() and FuBar:IsChangingProfile() then
+ return
+ end
+ if type(index) == "table" then
+ index = self:IndexOfPlugin(index)
+ if not index then
+ return
+ end
+ end
+ local t = self.plugins
+ local plugin = t[index]
+ assert(pluginToPanel[plugin] == self, "Plugin has improper panel field")
+ plugin:SetPanel(nil)
+ table.remove(t, index)
+ return true
+end
+
+function MinimapContainer:ReadjustLocation(plugin)
+ local frame = pluginToMinimapFrame[plugin]
+ if plugin.db and plugin.db.profile.minimapPositionWild then
+ frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", plugin.db.profile.minimapPositionX, plugin.db.profile.minimapPositionY)
+ elseif not plugin.db and plugin.minimapPositionWild then
+ frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", plugin.minimapPositionX, plugin.minimapPositionY)
+ else
+ local position
+ if plugin.db then
+ position = plugin.db.profile.minimapPosition or getPluginOption(plugin, 'defaultMinimapPosition', nil) or math.random(1, 360)
+ else
+ position = plugin.minimapPosition or getPluginOption(plugin, 'defaultMinimapPosition', nil) or math.random(1, 360)
+ end
+ local angle = math.rad(position or 0)
+ local x,y
+ local minimapShape = GetMinimapShape and GetMinimapShape() or "ROUND"
+ local cos = math.cos(angle)
+ local sin = math.sin(angle)
+
+ local round = true
+ if minimapShape == "ROUND" then
+ -- do nothing
+ elseif minimapShape == "SQUARE" then
+ round = false
+ elseif minimapShape == "CORNER-TOPRIGHT" then
+ if cos < 0 or sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-TOPLEFT" then
+ if cos > 0 or sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-BOTTOMRIGHT" then
+ if cos < 0 or sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-BOTTOMLEFT" then
+ if cos > 0 or sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-LEFT" then
+ if cos > 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-RIGHT" then
+ if cos < 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-TOP" then
+ if sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-BOTTOM" then
+ if sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-TOPRIGHT" then
+ if cos < 0 and sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-TOPLEFT" then
+ if cos > 0 and sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-BOTTOMRIGHT" then
+ if cos < 0 and sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-BOTTOMLEFT" then
+ if cos > 0 and sin > 0 then
+ round = false
+ end
+ end
+
+ if round then
+ x = cos * 80
+ y = sin * 80
+ else
+ x = 80 * 2^0.5 * cos
+ y = 80 * 2^0.5 * sin
+ if x < -80 then
+ x = -80
+ elseif x > 80 then
+ x = 80
+ end
+ if y < -80 then
+ y = -80
+ elseif y > 80 then
+ y = 80
+ end
+ end
+ frame:SetPoint("CENTER", Minimap, "CENTER", x, y)
+ end
+end
+
+function MinimapContainer:GetPlugin(index)
+ return self.plugins[index]
+end
+
+function MinimapContainer:GetNumPlugins()
+ return #self.plugins
+end
+
+function MinimapContainer:IndexOfPlugin(plugin)
+ for i,p in ipairs(self.plugins) do
+ if p == plugin then
+ return i, "MINIMAP"
+ end
+ end
+end
+
+function MinimapContainer:HasPlugin(plugin)
+ return self:IndexOfPlugin(plugin) ~= nil
+end
+
+function MinimapContainer:GetPluginSide(plugin)
+ local index = self:IndexOfPlugin(plugin)
+ assert(index, "Plugin not in panel")
+ return "MINIMAP"
+end
+
+function MinimapContainer.OnDragStart(this)
+ this.dragged = true
+ this:LockHighlight()
+ this:SetScript("OnUpdate", MinimapContainer.OnUpdate)
+ local minimapIconTexture = this.self.minimapIcon:GetTexture()
+ if type(minimapIconTexture) == "string" and minimapIconTexture:sub(1, 16) == "Interface\\Icons\\" then
+ this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ this.self.minimapIcon:SetTexCoord(0, 1, 0, 1)
+ end
+end
+
+function MinimapContainer.OnDragStop(this)
+ this:SetScript("OnUpdate", nil)
+ this:UnlockHighlight()
+end
+
+function MinimapContainer.OnUpdate(this, elapsed)
+ if not IsAltKeyDown() then
+ local mx, my = Minimap:GetCenter()
+ local px, py = GetCursorPosition()
+ local scale = UIParent:GetEffectiveScale()
+ px, py = px / scale, py / scale
+ local position = math.deg(math.atan2(py - my, px - mx))
+ if position <= 0 then
+ position = position + 360
+ elseif position > 360 then
+ position = position - 360
+ end
+ if this.self.db then
+ this.self.db.profile.minimapPosition = position
+ this.self.db.profile.minimapPositionX = nil
+ this.self.db.profile.minimapPositionY = nil
+ this.self.db.profile.minimapPositionWild = nil
+ else
+ this.self.minimapPosition = position
+ this.self.minimapPositionX = nil
+ this.self.minimapPositionY = nil
+ this.self.minimapPositionWild = nil
+ end
+ else
+ local px, py = GetCursorPosition()
+ local scale = UIParent:GetEffectiveScale()
+ px, py = px / scale, py / scale
+ if this.self.db then
+ this.self.db.profile.minimapPositionX = px
+ this.self.db.profile.minimapPositionY = py
+ this.self.db.profile.minimapPosition = nil
+ this.self.db.profile.minimapPositionWild = true
+ else
+ this.self.minimapPositionX = px
+ this.self.minimapPositionY = py
+ this.self.minimapPosition = nil
+ this.self.minimapPositionWild = true
+ end
+ end
+ MinimapContainer:ReadjustLocation(this.self)
+end
+
+for target,_ in pairs(mixinTargets) do
+ for _,name in pairs(mixins) do
+ if not target[name] or target[name] == oldLib[name] then
+ target[name] = FuBarPlugin[name]
+ end
+ end
+end
diff --git a/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.toc b/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.toc
new file mode 100644
index 0000000..7545574
--- /dev/null
+++ b/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.toc
@@ -0,0 +1,15 @@
+## Interface: 100002
+## Title: Lib: FuBarPlugin-3.0
+## Notes: A library to provide a means create a FuBar-compatible plugin.
+## Notes-zhTW: 一個提供支援FuBar所需功能的插件。
+## Notes-esES: Una biblioteca para crear plugins compatibles con Fubar.
+## Author: ckknight
+## eMail: ckknight@gmail.com
+## X-Credits: Arrowmaster
+## Version: 3.0
+## X-Category: Library
+## OptionalDeps: FuBar
+## X-License: LGPL v2.1
+
+LibStub\LibStub.lua
+lib.xml
diff --git a/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibStub/LibStub.lua b/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibStub/LibStub.lua
new file mode 100644
index 0000000..0a41ac0
--- /dev/null
+++ b/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibStub/LibStub.lua
@@ -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
diff --git a/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibStub/LibStub.toc b/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibStub/LibStub.toc
new file mode 100644
index 0000000..fd93b15
--- /dev/null
+++ b/Broker2FuBar/libs/LibFuBarPlugin-3.0/LibStub/LibStub.toc
@@ -0,0 +1,9 @@
+## Interface: 100002
+## Title: Lib: LibStub
+## Notes: Universal Library Stub
+## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
+## X-Website: http://jira.wowace.com/browse/LS
+## X-Category: Library
+## X-License: Public Domain
+
+LibStub.lua
diff --git a/Broker2FuBar/libs/LibFuBarPlugin-3.0/lib.xml b/Broker2FuBar/libs/LibFuBarPlugin-3.0/lib.xml
new file mode 100644
index 0000000..a817c51
--- /dev/null
+++ b/Broker2FuBar/libs/LibFuBarPlugin-3.0/lib.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/Broker2FuBar/libs/LibStub/LibStub.lua b/Broker2FuBar/libs/LibStub/LibStub.lua
new file mode 100644
index 0000000..7e7b76d
--- /dev/null
+++ b/Broker2FuBar/libs/LibStub/LibStub.lua
@@ -0,0 +1,51 @@
+-- $Id: LibStub.lua 103 2014-10-16 03:02:50Z mikk $
+-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/addons/libstub/ for more info
+-- LibStub is hereby placed in the Public Domain
+-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
+local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
+local LibStub = _G[LIBSTUB_MAJOR]
+
+-- Check to see is this version of the stub is obsolete
+if not LibStub or LibStub.minor < LIBSTUB_MINOR then
+ LibStub = LibStub or {libs = {}, minors = {} }
+ _G[LIBSTUB_MAJOR] = LibStub
+ LibStub.minor = LIBSTUB_MINOR
+
+ -- LibStub:NewLibrary(major, minor)
+ -- major (string) - the major version of the library
+ -- minor (string or number ) - the minor version of the library
+ --
+ -- returns nil if a newer or same version of the lib is already present
+ -- returns empty library object or old library object if upgrade is needed
+ function LibStub:NewLibrary(major, minor)
+ assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
+ minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
+
+ local oldminor = self.minors[major]
+ if oldminor and oldminor >= minor then return nil end
+ self.minors[major], self.libs[major] = minor, self.libs[major] or {}
+ return self.libs[major], oldminor
+ end
+
+ -- LibStub:GetLibrary(major, [silent])
+ -- major (string) - the major version of the library
+ -- silent (boolean) - if true, library is optional, silently return nil if its not found
+ --
+ -- throws an error if the library can not be found (except silent is set)
+ -- returns the library object if found
+ function LibStub:GetLibrary(major, silent)
+ if not self.libs[major] and not silent then
+ error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
+ end
+ return self.libs[major], self.minors[major]
+ end
+
+ -- LibStub:IterateLibraries()
+ --
+ -- Returns an iterator for the currently registered libraries
+ function LibStub:IterateLibraries()
+ return pairs(self.libs)
+ end
+
+ setmetatable(LibStub, { __call = LibStub.GetLibrary })
+end
diff --git a/Broker2FuBar/options.lua b/Broker2FuBar/options.lua
new file mode 100644
index 0000000..74164d1
--- /dev/null
+++ b/Broker2FuBar/options.lua
@@ -0,0 +1,163 @@
+local addon = LibStub("AceAddon-3.0"):GetAddon("Broker2FuBar")
+
+addon.objectOptions = {
+ enable_ = {
+ name = 'Enable',
+ desc = 'Only the selected LibDataBroker objects are wrapped into FuBar plugins.',
+ type = 'multiselect',
+ get = function(info, name)
+ return info.handler:IsObjectEnabled(name)
+ end,
+ set = function(info, name, value)
+ info.handler:EnableObject(name, value)
+ end,
+ values = addon.registry,
+ order = 0,
+ },
+}
+
+addon.options = {
+ type = 'group',
+ name = addon.name,
+ handler = addon,
+ args = {
+ plugin = {
+ name = 'Settings',
+ type = 'group',
+ args = addon.objectOptions
+ }
+ },
+}
+
+-- What follow is an adaptation from FBP's config table
+
+local SHOW_FUBAR_ICON = "Show FuBar icon"
+local SHOW_FUBAR_ICON_DESC = "Show the FuBar plugin's icon on the panel."
+local SHOW_FUBAR_TEXT = "Show FuBar text"
+local SHOW_FUBAR_TEXT_DESC = "Show the FuBar plugin's text on the panel."
+local POSITION_ON_FUBAR = "Position on FuBar"
+local POSITION_ON_FUBAR_DESC = "Position the FuBar plugin on the panel."
+local POSITION_LEFT = "Left"
+local POSITION_RIGHT = "Right"
+local POSITION_CENTER = "Center"
+local ATTACH_PLUGIN_TO_MINIMAP = "Attach FuBar plugin to minimap"
+local ATTACH_PLUGIN_TO_MINIMAP_DESC = "Attach the FuBar plugin to the minimap instead of the panel."
+
+if GetLocale() == "zhCN" then
+ SHOW_FUBAR_ICON = "显示FuBar图标"
+ SHOW_FUBAR_ICON_DESC = "在面板上显示FuBar插件的图标."
+ SHOW_FUBAR_TEXT = "显示FuBar文字"
+ SHOW_FUBAR_TEXT_DESC = "在面板上显示Fubar插件文字标题"
+ POSITION_ON_FUBAR = "位置"
+ POSITION_ON_FUBAR_DESC = "FuBar插件在面板上的位置."
+ POSITION_LEFT = "居左"
+ POSITION_RIGHT = "居右"
+ POSITION_CENTER = "居中"
+ ATTACH_PLUGIN_TO_MINIMAP = "依附在小地图"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "插件图标依附在小地图而不显示在面板上."
+elseif GetLocale() == "zhTW" then
+ SHOW_FUBAR_ICON = "顯示圖示"
+ SHOW_FUBAR_ICON_DESC = "在面板上顯示插件圖示。"
+ SHOW_FUBAR_TEXT = "顯示文字"
+ SHOW_FUBAR_TEXT_DESC = "在面板上顯示插件文字。"
+ POSITION_ON_FUBAR = "位置"
+ POSITION_ON_FUBAR_DESC = "插件在面板上的位置。"
+ POSITION_LEFT = "靠左"
+ POSITION_RIGHT = "靠右"
+ POSITION_CENTER = "置中"
+ ATTACH_PLUGIN_TO_MINIMAP = "依附在小地圖"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "插件圖標依附在小地圖而不顯示在面板上。"
+elseif GetLocale() == "koKR" then
+ SHOW_FUBAR_ICON = "FuBar 아이콘 표시"
+ SHOW_FUBAR_ICON_DESC = "FuBar 패널에 플러그인 아이콘을 표시합니다."
+ SHOW_FUBAR_TEXT = "FuBar 텍스트 표시"
+ SHOW_FUBAR_TEXT_DESC = "FuBar 페널에 플러그인 텍스트를 표시합니다."
+ POSITION_ON_FUBAR = "FuBar 위치"
+ POSITION_ON_FUBAR_DESC = "패널 위의 FuBar 플러그인의 위치를 설정합니다."
+ POSITION_LEFT = "좌측"
+ POSITION_RIGHT = "우측"
+ POSITION_CENTER = "중앙"
+ ATTACH_PLUGIN_TO_MINIMAP = "FuBar 플러그인 미니맵 표시"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "FuBar 플러그인을 패널 대신 미니맵에 표시합니다."
+elseif GetLocale() == "frFR" then
+ SHOW_FUBAR_ICON = "Afficher l'icône FuBar"
+ SHOW_FUBAR_ICON_DESC = "Affiche l'icône du plugin FuBar sur le panneau."
+ SHOW_FUBAR_TEXT = "Afficher le texte FuBar"
+ SHOW_FUBAR_TEXT_DESC = "Affiche le texte du plugin FuBar sur le panneau."
+ POSITION_ON_FUBAR = "Position sur FuBar"
+ POSITION_ON_FUBAR_DESC = "Position du plugin FuBar sur le panneau."
+ POSITION_LEFT = "Gauche"
+ POSITION_RIGHT = "Droite"
+ POSITION_CENTER = "Centre"
+ ATTACH_PLUGIN_TO_MINIMAP = "Attacher le plugin FuBar sur la minicarte"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "Attache le plugin FuBar sur la minicarte au lieu du panneau."
+end
+
+addon.objectOptionsMetaTable = { __index = {
+ type = 'group',
+ hidden = function(info)
+ return not info.handler:IsEnabled()
+ end,
+ args = {
+ icon = {
+ type = 'toggle',
+ name = SHOW_FUBAR_ICON,
+ desc = SHOW_FUBAR_ICON_DESC,
+ set = "ToggleFuBarIconShown",
+ get = "IsFuBarIconShown",
+ hidden = function(info)
+ return not info.handler.data_object.icon or not info.handler.data_object.text or info.handler:IsDisabled() or info.handler:IsFuBarMinimapAttached()
+ end,
+ width = 'double',
+ order = -13.7,
+ },
+ text = {
+ type = 'toggle',
+ name = SHOW_FUBAR_TEXT,
+ desc = SHOW_FUBAR_TEXT_DESC,
+ set = "ToggleFuBarTextShown",
+ get = "IsFuBarTextShown",
+ hidden = function(info)
+ return not info.handler.data_object.icon or not info.handler.data_object.text or info.handler:IsDisabled() or info.handler:IsFuBarMinimapAttached()
+ end,
+ width = 'double',
+ order = -13.6,
+ },
+ position = {
+ type = 'select',
+ name = POSITION_ON_FUBAR,
+ desc = POSITION_ON_FUBAR_DESC,
+ values = {
+ LEFT = POSITION_LEFT,
+ CENTER = POSITION_CENTER,
+ RIGHT = POSITION_RIGHT
+ },
+ get = function(info)
+ local self = info.handler
+ return self:GetPanel() and self:GetPanel():GetPluginSide(self)
+ end,
+ set = function(info, value)
+ local self = info.handler
+ if self:GetPanel() then
+ self:GetPanel():SetPluginSide(self, value)
+ end
+ end,
+ hidden = function(info)
+ return info.handler:IsFuBarMinimapAttached() or info.handler:IsDisabled()
+ end,
+ order = -13.2,
+ },
+ minimapAttach = {
+ type = 'toggle',
+ name = ATTACH_PLUGIN_TO_MINIMAP,
+ desc = ATTACH_PLUGIN_TO_MINIMAP_DESC,
+ get = "IsFuBarMinimapAttached",
+ set = "ToggleFuBarMinimapAttached",
+ hidden = function(info)
+ return info.handler:IsDisabled()
+ end,
+ width = 'double',
+ order = -13.1,
+ },
+ }
+}}
diff --git a/Broker2FuBar/pluginPrototype.lua b/Broker2FuBar/pluginPrototype.lua
new file mode 100644
index 0000000..a8372c7
--- /dev/null
+++ b/Broker2FuBar/pluginPrototype.lua
@@ -0,0 +1,77 @@
+local addon = LibStub("AceAddon-3.0"):GetAddon("Broker2FuBar")
+local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
+local lfbp = LibStub:GetLibrary("LibFuBarPlugin-3.0")
+
+addon.pluginPrototype = {}
+addon.pluginPrototypeMetatable = { __index = addon.pluginPrototype }
+
+local pluginPrototype = addon.pluginPrototype
+
+function pluginPrototype:Initialize()
+ self:SetFuBarOption('tooltipType', self.data_object.tooltip and 'Custom' or 'GameTooltip')
+ self:SetFuBarOption('configType', 'None')
+ self:SetFuBarOption('iconPath', self.data_object.icon)
+ lfbp:OnEmbedInitialize(self)
+end
+
+function pluginPrototype:Enable()
+ if self.enabled then return end
+ self.enabled = true
+ ldb.RegisterCallback(self, "LibDataBroker_AttributeChanged_"..self.data_object_name.."_text", "OnUpdateFuBarText")
+ ldb.RegisterCallback(self, "LibDataBroker_AttributeChanged_"..self.data_object_name.."_icon", "OnUpdateFuBarIcon")
+ ldb.RegisterCallback(self, "LibDataBroker_AttributeChanged_"..self.data_object_name.."_tooltip", "OnUpdateFuBarTooltip")
+ self:OnUpdateFuBarText()
+ self:OnUpdateFuBarIcon()
+ lfbp:OnEmbedEnable(self)
+end
+
+function pluginPrototype:Disable()
+ if not self.enabled then return end
+ self.enabled = false
+ ldb.UnregisterAllCallbacks(self)
+ lfbp:OnEmbedDisable(self)
+end
+
+function pluginPrototype:IsEnabled()
+ return self.enabled
+end
+
+function pluginPrototype:OnUpdateFuBarText()
+ self:SetFuBarText(self.data_object.text)
+end
+
+function pluginPrototype:OnUpdateFuBarIcon()
+ -- this isn't an official fubar method, note
+ self:SetFuBarIcon(self.data_object.icon)
+end
+
+function pluginPrototype:OnFuBarClick(button, down)
+ local frame = self:IsFuBarMinimapAttached() and lfbp.pluginToMinimapFrame[self] or lfbp.pluginToFrame[self] or self:GetFrame()
+ if self.data_object.OnClick then
+ self.data_object.OnClick(frame, button, down)
+ end
+end
+
+function pluginPrototype:OnFuBarEnter(motion)
+ local frame = self:IsFuBarMinimapAttached() and lfbp.pluginToMinimapFrame[self] or lfbp.pluginToFrame[self] or self:GetFrame()
+ if self.data_object.OnEnter then
+ self.data_object.OnEnter(frame, motion)
+ end
+end
+
+function pluginPrototype:OnFuBarLeave(motion)
+ local frame = self:IsFuBarMinimapAttached() and lfbp.pluginToMinimapFrame[self] or lfbp.pluginToFrame[self] or self:GetFrame()
+ if self.data_object.OnLeave then
+ self.data_object.OnLeave(frame, motion)
+ end
+end
+
+function pluginPrototype:OnUpdateFuBarTooltip()
+ if self.data_object.tooltip then
+ self.data_object.tooltip:Show()
+ elseif self.data_object.OnTooltipShow then
+ self.data_object.OnTooltipShow(GameTooltip)
+ elseif not self.data_object.OnEnter then
+ GameTooltip:AddLine(self.data_object.label or self.data_object_name)
+ end
+end
diff --git a/FuBar/FuBar-Locale-deDE.lua b/FuBar/FuBar-Locale-deDE.lua
new file mode 100644
index 0000000..4eca224
--- /dev/null
+++ b/FuBar/FuBar-Locale-deDE.lua
@@ -0,0 +1,64 @@
+local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("FuBar")
+L:AddTranslations("deDE", function() return {
+ ["Others"] = "Sonstiges",
+ ["Available plugins in the %q category."] = "Auswählbare Plugins in der %q Kategorie.",
+
+ ["Default"] = "Default",
+ ["Overflow plugins"] = "Plugins umbrechen",
+ ["Let plugins overflow onto another panel"] = "Erlaubt es Plugins, in andere Leisten umzubrechen",
+ ["Create new panel"] = "Neue Leiste erstellen",
+ ["Create"] = "Erstelle",
+ ["Auto-adjust frames"] = "Frames automatisch anpassen",
+ ["Toggle auto-adjustment of Blizzard's frames"] = "Automatische Anpassung der Blizzard-Frames umschalten",
+ ["Auto-hide top panels"] = "Auto-Ausblenden oben",
+ ["Toggle auto-hiding of the top panels"] = "automatisches Ausblenden der oberen Leisten umschalten",
+ ["Auto-hide bottom panels"] = "Auto-Ausblenden unten",
+ ["Toggle auto-hiding of the bottom panels"] = "Automatisches Ausblenden der unteren Leisten umschalten",
+ ["Background"] = "Hintergrund",
+ ["Background of the panels"] = "Hintergrund der Leiste",
+ ["Change the color of the panels, if texture is set to None"] = "Farbe der Leiste ändern, wenn die Textureeinstellung auf 'Nichts' steht",
+ ["Texture"] = "Textur",
+ ["Change the texture of the panels"] = "ändert den Hintergrund der Leisten",
+ ["Spacing"] = "Abstände",
+ ["Spacing between plugins"] = "Abstand zwischen Plugins",
+ ["Left-aligned spacing"] = "Abstand links",
+ ["Set spacing between left-aligned plugins"] = "Legt den Abstand zwischen linksseitig ausgerichteten Plugins fest",
+ ["Center-aligned spacing"] = "Abstand mittig",
+ ["Set spacing between center-aligned plugins"] = "Legt den Abstand zwischen mittig ausgerichteten Plugins fest",
+ ["Right-aligned spacing"] = "Abstand rechts",
+ ["Set spacing between right-aligned plugins"] = "Legt den Abstand zwischen rechtsseitig ausgerichteten Plugins fest",
+ ["Font size"] = "Schriftgröße",
+ ["Panel font size"] = "Schriftgröße der Leiste",
+ ["Set font size for the plugins on the panel"] = "Legt die Schriftgröße innerhalb der Leiste fest",
+ ["Tooltip font size"] = "Tooltip-Schriftgröße",
+ ["Set font size for the tooltip"] = "Legt die Schriftgröße innerhalb des Tooltips fest",
+ ["Transparency"] = "Transparenz",
+ ["Panel transparency"] = "Transparenz der Leiste",
+ ["Set transparency of the panels"] = "Legt die Transparenz der Leiste fest",
+ ["Tooltip transparency"] = "Tooltip-Transparenz",
+ ["Set transparency of the tooltip"] = "Legt die Transparenz des Tooltips fest",
+ ["Thickness"] = "Dicke",
+ ["Set thickness between the panels"] = "Legt die Dicke der Leiste fest",
+ ["Tooltip"] = "Tooltip",
+ ["Tooltip settings"] = "Tooltip Einstellungen",
+ ["Hide in combat"] = "Verstecke im Kampf",
+ ["Prevent tooltips from showing in combat"] = "Verhindere das Anzeigen von Tooltips im Kampf",
+ ["Plugins"] = "Plugins",
+ ["Plugins that can be shown on the bar."] = "Plugins die auf der Leiste angezeigt werden können",
+ ["Are you sure?"] = "Bist du sicher?",
+ ["Remove"] = "Entferne",
+ ["A panel that modules can plug into."] = "Eine Leiste in die Module eingefügt werden können.",
+
+ ChatCommands = { "/fubar" },
+
+ ["Attach"] = "Verankern",
+ ["Lock panel"] = "Leiste verriegeln",
+ ["Remove panel"] = "Leiste entfernen",
+ ["Attach to top"] = "An oberen Bildschirmrand anheften",
+ ["Attach to bottom"] = "An unteren Bildschirmrand anheften",
+ ["Detach panel"] = "Leiste lösen",
+ ["Close"] = "Schließen",
+ ["Close the menu."] = "Menü schließen",
+
+ ["Are you sure you want to remove this panel?"] = "Bist Du sicher, dass Du diese Leiste entfernen willst?",
+} end)
diff --git a/FuBar/FuBar-Locale-enUS.lua b/FuBar/FuBar-Locale-enUS.lua
new file mode 100644
index 0000000..d89ce01
--- /dev/null
+++ b/FuBar/FuBar-Locale-enUS.lua
@@ -0,0 +1,68 @@
+local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("FuBar")
+L:AddTranslations("enUS", function() return {
+ ["Others"] = true,
+ ["Available plugins in the %q category."] = true,
+ ["Available plugins in the all categories."] = true,
+
+ ["Default"] = true,
+ ["Overflow plugins"] = true,
+ ["Let plugins overflow onto another panel"] = true,
+ ["Create new panel"] = true,
+ ["Create"] = true,
+ ["Auto-adjust frames"] = true,
+ ["Toggle auto-adjustment of Blizzard's frames"] = true,
+ ["Auto-hide top panels"] = true,
+ ["Toggle auto-hiding of the top panels"] = true,
+ ["Auto-hide bottom panels"] = true,
+ ["Toggle auto-hiding of the bottom panels"] = true,
+ ["Background"] = true,
+ ["Background of the panels"] = true,
+ ["Change the color of the panels, if texture is set to None"] = true,
+ ["Texture"] = true,
+ ["Change the texture of the panels"] = true,
+ ["Spacing"] = true,
+ ["Spacing between plugins"] = true,
+ ["Left-aligned spacing"] = true,
+ ["Set spacing between left-aligned plugins"] = true,
+ ["Center-aligned spacing"] = true,
+ ["Set spacing between center-aligned plugins"] = true,
+ ["Right-aligned spacing"] = true,
+ ["Set spacing between right-aligned plugins"] = true,
+ ["Font size"] = true,
+ ["Panel font size"] = true,
+ ["Set font size for the plugins on the panel"] = true,
+ ["Tooltip font size"] = true,
+ ["Set font size for the tooltip"] = true,
+ ["Transparency"] = true,
+ ["Panel transparency"] = true,
+ ["Set transparency of the panels"] = true,
+ ["Tooltip transparency"] = true,
+ ["Set transparency of the tooltip"] = true,
+ ["Thickness"] = true,
+ ["Set thickness between the panels"] = true,
+ ["Tooltip"] = true,
+ ["Tooltip settings"] = true,
+ ["Hide in combat"] = true,
+ ["Prevent tooltips from showing in combat"] = true,
+ ["Plugins"] = true,
+ ["Plugins that can be shown on the bar."] = true,
+ ["All categories"] = true,
+ ["Are you sure?"] = true,
+ ["Remove"] = true,
+ ["A panel that modules can plug into."] = true,
+
+ ChatCommands = { "/fubar" },
+
+ ["Attach"] = true,
+ ["Lock panel"] = true,
+ ["Remove panel"] = true,
+ ["Attach to top"] = true,
+ ["Attach to bottom"] = true,
+ ["Detach panel"] = true,
+ ["Close"] = true,
+ ["Close the menu."] = true,
+
+ ["Bar #%d"] = true,
+
+ ["Are you sure you want to remove this panel?"] = true,
+} end)
diff --git a/FuBar/FuBar-Locale-esES.lua b/FuBar/FuBar-Locale-esES.lua
new file mode 100644
index 0000000..0b55c6f
--- /dev/null
+++ b/FuBar/FuBar-Locale-esES.lua
@@ -0,0 +1,58 @@
+local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("FuBar")
+L:AddTranslations("esES", function() return {
+ ["Others"] = "Otros",
+ ["Available plugins in the %q category."] = "Plugins disponibles en la categor\195\173a %q.",
+
+ ["Default"] = "Por defecto",
+ ["Overflow plugins"] = "Superponer plugins",
+ ["Let plugins overflow onto another panel"] = "Permite que los plugins se superpongan sobre otro panel",
+ ["Create new panel"] = "Crear nuevo panel",
+ ["Auto-adjust frames"] = "Auto-ajustar marcos",
+ ["Toggle auto-adjustment of blizzard's frames"] = "Alterna el auto-ajuste de los marcos de Blizzard",
+ ["Auto-hide top panels"] = "Auto-ocultar los paneles superiores",
+ ["Toggle auto-hiding of the top panels"] = "Alterna la auto-ocultaci\195\179n de los paneles superiores",
+ ["Auto-hide bottom panels"] = "Auto-ocultar los paneles inferiores",
+ ["Toggle auto-hiding of the bottom panels"] = "Alterna la auto-ocultaci\195\179n de los paneles inferiores",
+ ["Background"] = "Fondo",
+ ["Background of the panels"] = "Fondo de los paneles",
+ ["Change the color of the panels, if texture is set to None"] = "Cambia el color de los paneles, si la textura est\195\161 establecida en Ninguna",
+ ["Texture"] = "Textura",
+ ["Change the texture of the panels"] = "Cambia la textura de los paneles",
+ ["Spacing"] = "Espaciado",
+ ["Spacing between plugins"] = "Espaciado entre plugins",
+ ["Left-aligned spacing"] = "Espaciado de los alineados a la izquierda",
+ ["Set spacing between left-aligned plugins"] = "Establece el espaciado entre los plugins alineados a la izquierda",
+ ["Center-aligned spacing"] = "Espaciado de los alineados al centro",
+ ["Set spacing between center-aligned plugins"] = "Establece el espaciado entre los plugins alineados al centro",
+ ["Right-aligned spacing"] = "Espaciado de los alineados a la drecha",
+ ["Set spacing between right-aligned plugins"] = "Establece el espaciado entre los plugins alineados a la derecha",
+ ["Font size"] = "Tama\195\177o de fuente",
+ ["Panel font size"] = "Tama\195\177o de fuente del panel",
+ ["Set font size for the plugins on the panel"] = "Establece el tama\195\177o de fuente de los plugins en el panel",
+ ["Tooltip font size"] = "Tama\195\177o de fuente de los tooltip",
+ ["Set font size for the tooltip"] = "Establece el tama\195\177o de fuente de los tooltip",
+ ["Transparency"] = "Transparencia",
+ ["Panel transparency"] = "Transparencia del panel",
+ ["Set transparency of the panels"] = "Establece la transparencia de los paneles",
+ ["Tooltip transparency"] = "Transparencia de los tooltip",
+ ["Set transparency of the tooltip"] = "Establece la transparencia de los tooltip",
+ ["Thickness"] = "Grosor",
+ ["Set thickness between the panels"] = "Establece el grosor de los paneles",
+ ["Tooltip"] = "Tooltip",
+ ["Tooltip settings"] = "Ajustes de tooltip",
+ ["Hide in combat"] = "Ocultar en combate",
+ ["Prevent tooltips from showing in combat"] = "Oculta los tooltips cuando entras en combate",
+
+ ChatCommands = { "/fubar" },
+
+ ["Attach"] = "Adjuntar",
+ ["Lock panel"] = "Bloquear panel",
+ ["Remove panel"] = "Eliminar panel",
+ ["Attach to top"] = "Adjuntar arriba",
+ ["Attach to bottom"] = "Adjuntar abajo",
+ ["Detach panel"] = "Separar panel",
+ ["Close"] = "Cerrar",
+ ["Close the menu."] = "Cierra el men\195\186",
+
+ ["Are you sure you want to remove this panel?"] = "\194\191Seguro que quieres eliminar este panel?",
+} end)
diff --git a/FuBar/FuBar-Locale-frFR.lua b/FuBar/FuBar-Locale-frFR.lua
new file mode 100644
index 0000000..3b56391
--- /dev/null
+++ b/FuBar/FuBar-Locale-frFR.lua
@@ -0,0 +1,68 @@
+local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("FuBar")
+L:AddTranslations("frFR", function() return {
+ ["Others"] = "Autres",
+ ["Available plugins in the %q category."] = "Plugins disponibles dans la catégorie %q.",
+ ["Available plugins in the all categories."] = "Plugins disponibles dans toutes les catégories.",
+
+ ["Default"] = "Défaut",
+ ["Overflow plugins"] = "Migration des plugins",
+ ["Let plugins overflow onto another panel"] = "Autorise les plugins à se placer sur un autre panneau si l'autre est pleine.",
+ ["Create new panel"] = "Créer un nouveau panneau",
+ ["Create"] = "Créer",
+ ["Auto-adjust frames"] = "Ajuster auto. les fenêtres",
+ ["Toggle auto-adjustment of Blizzard's frames"] = "Ajuste automatiquement ou non les fenêtres de Blizzard.",
+ ["Auto-hide top panels"] = "Masquer auto. les panneaux du haut",
+ ["Toggle auto-hiding of the top panels"] = "Masque automatiquement ou non les panneaux en haut de l'écran.",
+ ["Auto-hide bottom panels"] = "Masquer auto. les panneaux du bas",
+ ["Toggle auto-hiding of the bottom panels"] = "Masque automatiquement ou non les panneaux en bas de l'écran.",
+ ["Background"] = "Arrière-plan",
+ ["Background of the panels"] = "Configure l'arrière-plan des panneaux.",
+ ["Change the texture of the panels"] = "Change la texture des panneaux.",
+ ["Texture"] = "Texture",
+ ["Change the color of the panels, if texture is set to None"] = "Détermine la couleur des panneaux si aucune texture n'est choisie.",
+ ["Spacing"] = "Espacement",
+ ["Spacing between plugins"] = "Espacement entre les plugins",
+ ["Left-aligned spacing"] = "Espacement entre alignés à gauche",
+ ["Set spacing between left-aligned plugins"] = "Détermine l'espacement entre les plugins alignés à gauche.",
+ ["Center-aligned spacing"] = "Espacement entre alignés au centre",
+ ["Set spacing between center-aligned plugins"] = "Détermine l'espacement entre les plugins alignés au centre.",
+ ["Right-aligned spacing"] = "Espacement entre alignés à droite",
+ ["Set spacing between right-aligned plugins"] = "Détermine l'espacement entre les plugins alignés à droite.",
+ ["Font size"] = "Taille de la police",
+ ["Panel font size"] = "Taille de la police - Panneau",
+ ["Set font size for the plugins on the panel"] = "Détermine la taille de la police des plugins sur le panneau.",
+ ["Tooltip font size"] = "Taille de la police - Bulle",
+ ["Set font size for the tooltip"] = "Détermine la taille de la police de la bulle.",
+ ["Transparency"] = "Transparence",
+ ["Panel transparency"] = "Transparence du panneau",
+ ["Set transparency of the panels"] = "Détermine la transparence des panneaux.",
+ ["Tooltip transparency"] = "Transparence de la bulle",
+ ["Set transparency of the tooltip"] = "Détermine la transparence de la bulle.",
+ ["Thickness"] = "Épaisseur",
+ ["Set thickness between the panels"] = "Détermine l'épaisseur entre les panneaux.",
+ ["Tooltip"] = "Infobulle",
+ ["Tooltip settings"] = "Paramètres de l'infobulle.",
+ ["Hide in combat"] = "Cacher en combat",
+ ["Prevent tooltips from showing in combat"] = "Empêche l'infobulle de se montrer pendant les combats.",
+ ["Plugins"] = "Plugins",
+ ["Plugins that can be shown on the bar."] = "Les plugins pouvant être affichés sur le panneau.",
+ ["All categories"] = "Toutes les catégories",
+ ["Are you sure?"] = "Êtes-vous sûr ?",
+ ["Remove"] = "Enlever",
+ ["A panel that modules can plug into."] = "Un panneau entièrement modulable.",
+
+ ChatCommands = { "/fubar" },
+
+ ["Attach"] = "Attacher",
+ ["Lock panel"] = "Verrouiller le panneau",
+ ["Remove panel"] = "Enlever le panneau",
+ ["Attach to top"] = "Attacher en haut",
+ ["Attach to bottom"] = "Attacher en bas",
+ ["Detach panel"] = "Détacher le panneau",
+ ["Close"] = "Fermer",
+ ["Close the menu."] = "Ferme le menu.",
+
+ ["Bar #%d"] = "Barre #%d",
+
+ ["Are you sure you want to remove this panel?"] = "Êtes-vous sûr de vouloir enlever ce panneau ?",
+} end)
diff --git a/FuBar/FuBar-Locale-koKR.lua b/FuBar/FuBar-Locale-koKR.lua
new file mode 100644
index 0000000..df82a9d
--- /dev/null
+++ b/FuBar/FuBar-Locale-koKR.lua
@@ -0,0 +1,61 @@
+local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("FuBar")
+L:AddTranslations("koKR", function() return {
+ ["Others"] = "기타",
+ ["Available plugins in the %q category."] = "%q 분류에서 이용 가능한 플러그인",
+ ["Plugins"] = "플러그인",
+ ["Plugins that can be shown on the bar."] = "바 위에 표시할 플러그인",
+
+ ["Default"] = "기본",
+ ["Overflow plugins"] = "플러그인 넘침",
+ ["Let plugins overflow onto another panel"] = "플러그인이 패널을 넘칠경우 다른 패널로 이동합니다",
+ ["Create new panel"] = "새 패널 생성",
+ ["Create"] = "생성",
+ ["Auto-adjust frames"] = "프레임 자동 조절",
+ ["Toggle auto-adjustment of Blizzard's frames"] = "블리자드 창의 자동 자동 위치 조절 기능을 토글합니다",
+ ["Auto-hide top panels"] = "패널 자동 숨김(상단)",
+ ["Toggle auto-hiding of the top panels"] = "상단 패널의 자동 숨김 기능을 토글합니다",
+ ["Auto-hide bottom panels"] = "패널 자동 숨김(하단)",
+ ["Toggle auto-hiding of the bottom panels"] = "하단 패널의 자동 숨김 기능을 토글합니다",
+ ["Background"] = "배경",
+ ["Background of the panels"] = "패널의 배경",
+ ["Change the color of the panels, if texture is set to None"] = "텍스쳐가 None으로 설정되어 있다면 패널의 색상을 변경합니다.",
+ ["Texture"] = "텍스쳐",
+ ["Change the texture of the panels"] = "패널의 텍스쳐 변경",
+ ["Spacing"] = "간격",
+ ["Spacing between plugins"] = "플러그인 사이 간격",
+ ["Left-aligned spacing"] = "좌측 정렬된 간격",
+ ["Set spacing between left-aligned plugins"] = "좌측 정렬된 플러그인 간의 간격을 설정합니다",
+ ["Center-aligned spacing"] = "중앙 정렬된 간격",
+ ["Set spacing between center-aligned plugins"] = "중앙 정렬된 플러그인 간의 간격을 설정합니다",
+ ["Right-aligned spacing"] = "우측 정렬된 간격",
+ ["Set spacing between right-aligned plugins"] = "우측 정렬된 플러그인 간의 간격을 설정합니다",
+ ["Font size"] = "글자 크기",
+ ["Panel font size"] = "패널 글자 크기",
+ ["Set font size for the plugins on the panel"] = "패널에 플러그인의 글자 크기 설정",
+ ["Tooltip font size"] = "툴팁 글자 크기",
+ ["Set font size for the tooltip"] = "툴팁 글자 크기 설정",
+ ["Transparency"] = "투명도",
+ ["Panel transparency"] = "패널 투명도",
+ ["Set transparency of the panels"] = "패널의 투명도 설정",
+ ["Tooltip transparency"] = "툴팁 투명도",
+ ["Set transparency of the tooltip"] = "툴팁의 투명도 설정",
+ ["Thickness"] = "굵기",
+ ["Set thickness between the panels"] = "패널 사이 굵기 설정",
+ ["Tooltip"] = "툴팁",
+ ["Tooltip settings"] = "툴팁 설정",
+ ["Hide in combat"] = "전투중 숨기기",
+ ["Prevent tooltips from showing in combat"] = "전투중에는 툴팁을 표시하지 않습니다.",
+
+ ChatCommands = { "/fubar" },
+
+ ["Attach"] = "붙임",
+ ["Lock panel"] = "패널 고정",
+ ["Remove panel"] = "패널 제거",
+ ["Attach to top"] = "상단에 붙임",
+ ["Attach to bottom"] = "하단에 붙임",
+ ["Detach panel"] = "패널 분리",
+ ["Close"] = "닫기",
+ ["Close the menu."] = "메뉴를 닫습니다.",
+
+ ["Are you sure you want to remove this panel?"] = "정말로 이 패널을 제거 하시겠습니까?",
+} end)
diff --git a/FuBar/FuBar-Locale-ruRU.lua b/FuBar/FuBar-Locale-ruRU.lua
new file mode 100644
index 0000000..cde631d
--- /dev/null
+++ b/FuBar/FuBar-Locale-ruRU.lua
@@ -0,0 +1,69 @@
+-- Translated by StingerSoft
+local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("FuBar")
+L:AddTranslations("ruRU", function() return {
+ ["Others"] = "Другие",
+ ["Available plugins in the %q category."] = "Доступные плагины в категории: %q.",
+ ["Available plugins in the all categories."] = "Доступные плагины во всех категориях.",
+
+ ["Default"] = "По умолчанию",
+ ["Overflow plugins"] = "Переполнение плагинов",
+ ["Let plugins overflow onto another panel"] = "Разрешить переполнение плагинов, перенося их на другую панель",
+ ["Create new panel"] = "Создать новую панель",
+ ["Create"] = "Создать",
+ ["Auto-adjust frames"] = "Выравнивать фреймы",
+ ["Toggle auto-adjustment of Blizzard's frames"] = "Стандартные фреймы будут автоматически подстраиваться под панели",
+ ["Auto-hide top panels"] = "Скрывать верхнюю панель",
+ ["Toggle auto-hiding of the top panels"] = "Верхняя панель будет автоматически прятаться при неиспользовании",
+ ["Auto-hide bottom panels"] = "Скрывать нижнюю панель",
+ ["Toggle auto-hiding of the bottom panels"] = "Нижняя панель будет автоматически прятаться при неиспользовании",
+ ["Background"] = "Фон",
+ ["Background of the panels"] = "Фон панелей",
+ ["Change the color of the panels, if texture is set to None"] = "Изменение цвета панелей, если не установлена текстура",
+ ["Texture"] = "Текстура",
+ ["Change the texture of the panels"] = "Изменение текстуры панелей",
+ ["Spacing"] = "Расстояния",
+ ["Spacing between plugins"] = "Расстояние между плагинами",
+ ["Left-aligned spacing"] = "По левому краю",
+ ["Set spacing between left-aligned plugins"] = "Изменение расстояния между плагинами с левой стороны",
+ ["Center-aligned spacing"] = "По центру",
+ ["Set spacing between center-aligned plugins"] = "Изменение расстояния между плагинами в центре",
+ ["Right-aligned spacing"] = "По правому краю",
+ ["Set spacing between right-aligned plugins"] = "Изменение расстояния между плагинами с правой стороны",
+ ["Font size"] = "Размер шрифта",
+ ["Panel font size"] = "Размер шрифта панелей",
+ ["Set font size for the plugins on the panel"] = "Установка размера шрифта плагинов на панели",
+ ["Tooltip font size"] = "Размер шрифта подсказки",
+ ["Set font size for the tooltip"] = "Установка размера шрифта в подсказках",
+ ["Transparency"] = "Прозрачность",
+ ["Panel transparency"] = "Прозрачность панели",
+ ["Set transparency of the panels"] = "Установка необходимого уровеня прозрачности панелей",
+ ["Tooltip transparency"] = "Прозрачность подсказки",
+ ["Set transparency of the tooltip"] = "Установка необходимого уровеня прозрачности подсказки",
+ ["Thickness"] = "Толщина",
+ ["Set thickness between the panels"] = "Изменение толщины панелей",
+ ["Tooltip"] = "Подсказки",
+ ["Tooltip settings"] = "Настройки подсказкок",
+ ["Hide in combat"] = "Скрывать в бою",
+ ["Prevent tooltips from showing in combat"] = "Не отображать подсказки во время боя",
+ ["Plugins"] = "Плагины",
+ ["Plugins that can be shown on the bar."] = "Плагины, которые будут отображатся на панели",
+ ["All categories"] = "Все категории",
+ ["Are you sure?"] = "Вы уверены?",
+ ["Remove"] = "Удалить",
+ ["A panel that modules can plug into."] = "Панель для сбора/вывода различных модификаций.",
+
+ ChatCommands = { "/fubar" },
+
+ ["Attach"] = "Прикрепить",
+ ["Lock panel"] = "Фиксировать панель",
+ ["Remove panel"] = "Убрать панель",
+ ["Attach to top"] = "Расположить сверху",
+ ["Attach to bottom"] = "Расположить снизу",
+ ["Detach panel"] = "Отстыковать панель",
+ ["Close"] = "Закрыть",
+ ["Close the menu."] = "Закрыть меню.",
+
+ ["Bar #%d"] = "Панель #%d",
+
+ ["Are you sure you want to remove this panel?"] = "Вы уверены, что вы хотите удалить данную панель?",
+} end)
diff --git a/FuBar/FuBar-Locale-zhCN.lua b/FuBar/FuBar-Locale-zhCN.lua
new file mode 100644
index 0000000..adfd753
--- /dev/null
+++ b/FuBar/FuBar-Locale-zhCN.lua
@@ -0,0 +1,58 @@
+local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("FuBar")
+L:AddTranslations("zhCN", function() return {
+ ["Others"] = "其他",
+ ["Available plugins in the %q category."] = "在%q分类下可用的插件",
+
+ ["Default"] = "默认",
+ ["Overflow plugins"] = "溢出插件",
+ ["Let plugins overflow onto another panel"] = "将溢出的插件自动转换到另一面板上",
+ ["Create new panel"] = "创建新面板",
+ ["Auto-adjust frames"] = "自动调整框体",
+ ["Toggle auto-adjustment of Blizzard's frames"] = "切换是否自动调整暴雪框体",
+ ["Auto-hide top panels"] = "自动隐藏顶部面板",
+ ["Toggle auto-hiding of the top panels"] = "切换是否自动自动隐藏顶部面板",
+ ["Auto-hide bottom panels"] = "自动隐藏底部面板",
+ ["Toggle auto-hiding of the bottom panels"] = "切换是否自动自动隐藏底部面板",
+ ["Background"] = "背景",
+ ["Background of the panels"] = "面板背景",
+ ["Change the color of the panels, if texture is set to None"] = "如没有设置面板的材质,则可更改它的颜色",
+ ["Texture"] = "材质",
+ ["Change the texture of the panels"] = "改变面板贴图材质",
+ ["Spacing"] = "间距",
+ ["Spacing between plugins"] = "插件的显示间距",
+ ["Left-aligned spacing"] = "左侧对齐间距",
+ ["Set spacing between left-aligned plugins"] = "设置左侧对齐插件的显示间距",
+ ["Center-aligned spacing"] = "中央对齐间距",
+ ["Set spacing between center-aligned plugins"] = "设置中央对齐插件的显示间距",
+ ["Right-aligned spacing"] = "右侧对齐间距",
+ ["Set spacing between right-aligned plugins"] = "设置右侧对齐插件的显示间距",
+ ["Font size"] = "字体大小",
+ ["Panel font size"] = "面板字体大小",
+ ["Set font size for the plugins on the panel"] = "设置面板上插件的字体显示大小",
+ ["Tooltip font size"] = "信息条字体大小",
+ ["Set font size for the tooltip"] = "设置信息条的字体显示大小",
+ ["Transparency"] = "透明度",
+ ["Panel transparency"] = "面板透明度",
+ ["Set transparency of the panels"] = "设置面板透明度",
+ ["Tooltip transparency"] = "提示透明度",
+ ["Set transparency of the tooltip"] = "设置提示透明度",
+ ["Thickness"] = "高度",
+ ["Set thickness between the panels"] = "设置面板高度",
+ ["Tooltip"] = "提示",
+ ["Tooltip settings"] = "提示设置",
+ ["Hide in combat"] = "战斗中隐藏",
+ ["Prevent tooltips from showing in combat"] = "在战斗中不显示提示",
+
+ ChatCommands = { "/fubar" },
+
+ ["Attach"] = "依附",
+ ["Lock panel"] = "锁定面板",
+ ["Remove panel"] = "移除面板",
+ ["Attach to top"] = "依附于屏幕顶部",
+ ["Attach to bottom"] = "依附于屏幕底部",
+ ["Detach panel"] = "解除面板依附",
+ ["Close"] = "关闭",
+ ["Close the menu."] = "关闭菜单",
+
+ ["Are you sure you want to remove this panel?"] = "确定要移除此面板吗?",
+} end)
diff --git a/FuBar/FuBar-Locale-zhTW.lua b/FuBar/FuBar-Locale-zhTW.lua
new file mode 100644
index 0000000..6440227
--- /dev/null
+++ b/FuBar/FuBar-Locale-zhTW.lua
@@ -0,0 +1,68 @@
+local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("FuBar")
+L:AddTranslations("zhTW", function() return {
+ ["Others"] = "其他",
+ ["Available plugins in the %q category."] = "在%q類別的可用插件。",
+ ["Available plugins in the all categories."] = "在所有類別的可用插件。",
+
+ ["Default"] = "預設",
+ ["Overflow plugins"] = "自動安排插件",
+ ["Let plugins overflow onto another panel"] = "將放不下的插件自動轉換到另一面板上",
+ ["Create new panel"] = "新建面板",
+ ["Create"] = "新建",
+ ["Auto-adjust frames"] = "調整系統框架",
+ ["Toggle auto-adjustment of Blizzard's frames"] = "切換是否自動調整 Blizzard 框架",
+ ["Auto-hide top panels"] = "自動隱藏頂部面板",
+ ["Toggle auto-hiding of the top panels"] = "切換是否自動隱藏頂部面板",
+ ["Auto-hide bottom panels"] = "自動隱藏底部面板",
+ ["Toggle auto-hiding of the bottom panels"] = "切換是否自動隱藏底部面板",
+ ["Background"] = "背景",
+ ["Background of the panels"] = "面板背景",
+ ["Change the color of the panels, if texture is set to None"] = "如果沒有使用貼圖紋理,改變面板顏色",
+ ["Texture"] = "紋理",
+ ["Change the texture of the panels"] = "改變面板貼圖紋理",
+ ["Spacing"] = "間距",
+ ["Spacing between plugins"] = "插件的顯示間距",
+ ["Left-aligned spacing"] = "左側對齊間距",
+ ["Set spacing between left-aligned plugins"] = "設定左側對齊插件的顯示間距",
+ ["Center-aligned spacing"] = "中央對齊間距",
+ ["Set spacing between center-aligned plugins"] = "設定中央對齊插件的顯示間距",
+ ["Right-aligned spacing"] = "右側對齊間距",
+ ["Set spacing between right-aligned plugins"] = "設定右側對齊插件的顯示間距",
+ ["Font size"] = "字型大小",
+ ["Panel font size"] = "面板字型大小",
+ ["Set font size for the plugins on the panel"] = "設定面板上插件的字型顯示大小",
+ ["Tooltip font size"] = "提示訊息字體大小",
+ ["Set font size for the tooltip"] = "設定提示訊息的字體顯示大小",
+ ["Transparency"] = "透明度",
+ ["Panel transparency"] = "面板透明度",
+ ["Set transparency of the panels"] = "設定面板透明度",
+ ["Tooltip transparency"] = "提示訊息透明度",
+ ["Set transparency of the tooltip"] = "設定提示訊息透明度",
+ ["Thickness"] = "高度",
+ ["Set thickness between the panels"] = "設定面板高度",
+ ["Tooltip"] = "提示訊息",
+ ["Tooltip settings"] = "提示訊息設定",
+ ["Hide in combat"] = "戰鬥中隱藏",
+ ["Prevent tooltips from showing in combat"] = "在戰鬥中隱藏提示訊息",
+ ["Plugins"] = "插件",
+ ["Plugins that can be shown on the bar."] = "可以在面板上顯示的插件。",
+ ["All categories"] = "所有類別",
+ ["Are you sure?"] = "你確定嗎?",
+ ["Remove"] = "移除",
+ ["A panel that modules can plug into."] = "插件式訊息面板。",
+
+ ChatCommands = { "/fubar" },
+
+ ["Attach"] = "依附",
+ ["Lock panel"] = "鎖定面板",
+ ["Remove panel"] = "移除面板",
+ ["Attach to top"] = "依附於螢幕頂部",
+ ["Attach to bottom"] = "依附於螢幕底部",
+ ["Detach panel"] = "浮動面板",
+ ["Close"] = "關閉",
+ ["Close the menu."] = "關閉選單。",
+
+ ["Bar #%d"] = "面板 #%d",
+
+ ["Are you sure you want to remove this panel?"] = "確定要移除此面板嗎?",
+} end)
diff --git a/FuBar/FuBar.lua b/FuBar/FuBar.lua
new file mode 100644
index 0000000..22447f0
--- /dev/null
+++ b/FuBar/FuBar.lua
@@ -0,0 +1,1615 @@
+local MAJOR_VERSION = "3.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 40 $"):match("%d+"))
+
+local Jostle = Rock("LibJostle-3.0", false, true)
+local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("FuBar")
+
+FuBar = Rock:NewAddon("FuBar", "LibRockDB-1.0", "LibRockEvent-1.0", "LibRockTimer-1.0", "LibRockHook-1.0", "LibRockConfig-1.0")
+local FuBar = FuBar
+FuBar.title = "FuBar"
+FuBar.version = MAJOR_VERSION .. "." .. MINOR_VERSION
+FuBar.date = string.gsub("$Date: 2010-12-06 10:20:43 +0000 (Mon, 06 Dec 2010) $", "^.-(%d%d%d%d%-%d%d%-%d%d).-$", "%1")
+
+FuBar:SetDatabase("FuBar2DB")
+
+local _G = _G
+local plugins = {}
+
+local FuBar_Panel = FuBar_Panel
+_G.FuBar_Panel = nil
+
+if not FUBAR_DEFAULTS then
+ FUBAR_DEFAULTS = function()
+ return {
+ fontSize = 12,
+ adjust = true,
+ panels = {
+ [1] = {
+ attachPoint = "TOP",
+ plugins = {
+ left = {
+ "LocationFu",
+ "ExperienceFu",
+ "PerformanceFu",
+ },
+ center = {},
+ right = {
+ "ClockFu",
+ "VolumeFu",
+ }
+ }
+ },
+ [2] = {
+ attachPoint = "BOTTOM"
+ }
+ }
+ }
+ end
+end
+
+local localizedCategory = setmetatable({["All categories"] = L["All categories"]}, { __index = function(self, category)
+ if type(category) ~= "string" then
+ return L["Others"]
+ end
+ local ret = Rock:GetLocalizedCategory(category)
+ if ret == UNKNOWN or ret == "Unknown" then
+ ret = L["Others"]
+ end
+ self[category] = ret
+ return ret
+end } )
+
+local basePluginFrame
+
+local alreadyEnabled = false
+
+local backgrounds = {
+ ["Interface\\AddOns\\FuBar\\background"] = L["Default"],
+ [true] = NONE or "None"
+}
+
+local function safecall(func, ...)
+ local success, ret = pcall(func, ...)
+ if not success then
+ geterrorhandler()(ret)
+ end
+end
+
+function FuBar:RegisterSkin(name, bgFile)
+ if type(name) ~= "string" then
+ error("You must provide a name for your skin")
+ elseif type(bgFile) ~= "string" then
+ error("You must provide a file for your skin")
+ end
+ if not backgrounds[bgFile] then
+ backgrounds[bgFile] = name
+ end
+end
+
+local function SetBackground(bgFile)
+ if backgrounds[bgFile] then
+ FuBar.db.profile.skin = bgFile
+ if bgFile == true then
+ FuBar_Panel:SetBackgroundColor(FuBar.db.profile.skinR, FuBar.db.profile.skinG, FuBar.db.profile.skinB)
+ else
+ FuBar_Panel:SetBackground(bgFile)
+ end
+ end
+end
+
+local function GetBackground()
+ return backgrounds[FuBar.db.profile.skin] and FuBar.db.profile.skin or "Interface\\AddOns\\FuBar\\background"
+end
+
+local function GetBackgroundColor()
+ return FuBar.db.profile.skinR, FuBar.db.profile.skinG, FuBar.db.profile.skinB
+end
+local function SetBackgroundColor(r,g,b)
+ FuBar.db.profile.skinR, FuBar.db.profile.skinG, FuBar.db.profile.skinB = r,g,b
+ if FuBar.db.profile.skin == true then
+ FuBar_Panel:SetBackgroundColor(r, g, b)
+ end
+end
+
+local newList, del, unpackDictAndDel = Rock:GetRecyclingFunctions("FuBar", "newList", "del", "unpackDictAndDel")
+
+local toBeLoaded
+
+local optionsTable_args = {
+ overflow = {
+ type = 'boolean',
+ name = L["Overflow plugins"],
+ desc = L["Let plugins overflow onto another panel"],
+ get = "IsOverflowing",
+ set = "ToggleOverflowing",
+ },
+ create = {
+ type = 'execute',
+ name = L["Create new panel"],
+ desc = L["Create new panel"],
+ buttonText = L["Create"],
+ func = "new",
+ handler = FuBar_Panel
+ },
+ adjust = {
+ type = 'boolean',
+ name = L["Auto-adjust frames"],
+ desc = L["Toggle auto-adjustment of Blizzard's frames"],
+ get = "IsAdjust",
+ set = "ToggleAdjust",
+ },
+ autohideTop = {
+ type = 'boolean',
+ name = L["Auto-hide top panels"],
+ desc = L["Toggle auto-hiding of the top panels"],
+ get = "IsAutoHidingTop",
+ set = "ToggleAutoHidingTop",
+ },
+ autohideBottom = {
+ type = 'boolean',
+ name = L["Auto-hide bottom panels"],
+ desc = L["Toggle auto-hiding of the bottom panels"],
+ get = "IsAutoHidingBottom",
+ set = "ToggleAutoHidingBottom",
+ },
+ background = {
+ type = 'group',
+ name = L["Background"],
+ desc = L["Background of the panels"],
+ args = {
+ texture = {
+ type = 'choice',
+ name = L["Texture"],
+ desc = L["Change the texture of the panels"],
+ get = GetBackground,
+ set = SetBackground,
+ choices = backgrounds,
+ },
+ color = {
+ type = 'color',
+ name = type(COLOR) == "string" and COLOR or "Color",
+ desc = L["Change the color of the panels, if texture is set to None"],
+ get = GetBackgroundColor,
+ set = SetBackgroundColor,
+ }
+ }
+ },
+ spacing = {
+ type = 'group',
+ name = L["Spacing"],
+ desc = L["Spacing between plugins"],
+ args = {
+ left = {
+ type = 'number',
+ name = L["Left-aligned spacing"],
+ desc = L["Set spacing between left-aligned plugins"],
+ max = 40,
+ min = 0,
+ step = 1,
+ get = "GetLeftSpacing",
+ set = "SetLeftSpacing",
+ },
+ center = {
+ type = 'number',
+ name = L["Center-aligned spacing"],
+ desc = L["Set spacing between center-aligned plugins"],
+ max = 40,
+ min = 0,
+ step = 1,
+ get = "GetCenterSpacing",
+ set = "SetCenterSpacing",
+ },
+ right = {
+ type = 'number',
+ name = L["Right-aligned spacing"],
+ desc = L["Set spacing between right-aligned plugins"],
+ max = 40,
+ min = 0,
+ step = 1,
+ get = "GetRightSpacing",
+ set = "SetRightSpacing",
+ },
+ }
+ },
+ fontsize = {
+ type = 'number',
+ name = L["Font size"],
+ desc = L["Set font size for the plugins on the panel"],
+ max = 24,
+ min = 7,
+ step = 1,
+ get = "GetFontSize",
+ set = "SetFontSize",
+ },
+ transparency = {
+ type = 'number',
+ name = L["Transparency"],
+ desc = L["Set transparency of the panels"],
+ max = 1,
+ min = 0,
+ step = 0.01,
+ bigStep = 0.05,
+ isPercent = true,
+ get = "GetTransparency",
+ set = "SetTransparency",
+ },
+ thickness = {
+ type = 'number',
+ name = L["Thickness"],
+ desc = L["Set thickness between the panels"],
+ max = 20,
+ min = 0,
+ step = 1,
+ get = "GetThickness",
+ set = "SetThickness",
+ },
+ tooltip = {
+ type = 'group',
+ name = L["Tooltip"],
+ desc = L["Tooltip settings"],
+ args = {
+ transparency = {
+ type = 'number',
+ name = L["Transparency"],
+ desc = L["Set transparency of the tooltip"],
+ max = 1,
+ min = 0,
+ step = 0.01,
+ bigStep = 0.05,
+ isPercent = true,
+ get = function()
+ return Rock("Tablet-2.0"):GetTransparency(FuBar.db.profile.tooltip)
+ end,
+ set = function(value)
+ return Rock("Tablet-2.0"):SetTransparency(FuBar.db.profile.tooltip, value)
+ end,
+ },
+ fontSize = {
+ type = 'number',
+ name = L["Font size"],
+ desc = L["Set font size for the tooltip"],
+ max = 2,
+ min = 0.5,
+ step = 0.01,
+ bigStep = 0.05,
+ isPercent = true,
+ get = function()
+ return Rock("Tablet-2.0"):GetFontSizePercent(FuBar.db.profile.tooltip)
+ end,
+ set = function(value)
+ return Rock("Tablet-2.0"):SetFontSizePercent(FuBar.db.profile.tooltip, value)
+ end,
+ },
+ hideInCombat = {
+ type = 'boolean',
+ name = L["Hide in combat"],
+ desc = L["Prevent tooltips from showing in combat"],
+ get = "IsHidingTooltipsInCombat",
+ set = "ToggleHidingTooltipsInCombat",
+ }
+ },
+ hidden = function()
+ return not Rock:HasLibrary("Tablet-2.0", true)
+ end
+ }
+}
+
+local barOpts
+do
+ local attachChoices = {
+ TOP = L["Attach to top"],
+ BOTTOM = L["Attach to bottom"],
+ NONE = L["Detach panel"],
+ }
+
+ local args_attach = {
+ type = 'choice',
+ name = L["Attach"],
+ desc = "Attachment point.",
+ choices = attachChoices,
+ get = function(key)
+ return FuBar:GetPanel(key):GetAttachPoint()
+ end,
+ set = function(key, ...)
+ return FuBar:GetPanel(key):SetAttachPoint(...)
+ end,
+ }
+ local args_lock = {
+ type = 'boolean',
+ name = L["Lock panel"],
+ desc = L["Lock panel"],
+ get = function(key)
+ return FuBar:GetPanel(key):IsLocked()
+ end,
+ set = function(key, ...)
+ return FuBar:GetPanel(key):ToggleLocked(...)
+ end,
+ }
+ local args_remove = {
+ type = 'execute',
+ name = L["Remove panel"],
+ desc = L["Remove panel"],
+ buttonText = L["Remove"],
+ confirmText = L["Are you sure?"],
+ func = function(key)
+ return FuBar:GetPanel(key):del()
+ end,
+ disabled = function(key)
+ return FuBar:GetNumPanels() <= 1
+ end,
+ }
+
+ local category_choiceDescs = function(panelID, cat)
+ local choiceDescs = newList()
+
+ for _,plugin in ipairs(plugins) do
+ local category = localizedCategory[plugin:GetCategory()]
+ if category == cat or cat == L["All categories"] then
+ choiceDescs[plugin] = plugin.notes
+ end
+ end
+ for _,plugin in ipairs(toBeLoaded) do
+ local lod = FuBar.db.profile.loadOnDemand[plugin[1]]
+
+ local category = localizedCategory[lod.category]
+ if category == cat or cat == L["All categories"] then
+ choiceDescs[plugin] = plugin[2]
+ end
+ end
+ return "@dict", unpackDictAndDel(choiceDescs)
+ end
+
+ local category_choices = function(panelID, cat)
+ local choices = newList()
+
+ for _,plugin in ipairs(plugins) do
+ local category = localizedCategory[plugin:GetCategory()]
+ if category == cat or cat == L["All categories"] then
+ choices[plugin] = plugin:GetTitle()
+ end
+ end
+ for _, plugin in ipairs(toBeLoaded) do
+ local lod = FuBar.db.profile.loadOnDemand[plugin[1]]
+
+ local category = localizedCategory[lod.category]
+ if category == cat or cat == L["All categories"] then
+ choices[plugin[1]] = lod.title
+ end
+ end
+ return "@dict", unpackDictAndDel(choices)
+ end
+
+ local function category_get(panelID, category, key)
+ if type(key) == "string" then
+ -- to be loaded
+ return false
+ else
+ if key:GetPanel() == FuBar:GetPanel(panelID) then
+ return true
+ elseif key:GetPanel() then
+ return "HALF"
+ else
+ return false
+ end
+ end
+ end
+ local function category_set(panelID, category, key, value)
+ if type(key) == "string" then
+ -- to be loaded
+ FuBar_Panel.selectedPanel = FuBar:GetPanel(panelID)
+ FuBar:LoadPlugin(key)
+ else
+ if value then
+ if key:GetPanel() then
+ key:Hide()
+ end
+ key:Show(panelID or 1)
+ else
+ key:Hide(panelID or 1)
+ end
+ end
+ end
+
+ local categoryOpts = setmetatable({}, {__index=function(self, category)
+ self[category] = {
+ type = 'multichoice',
+ name = category,
+ desc = category == L["All categories"] and L["Available plugins in the all categories."] or L["Available plugins in the %q category."]:format(category),
+ choices = category_choices,
+ choiceDescs = category_choiceDescs,
+ get = category_get,
+ set = category_set,
+ passValue2 = category,
+ order = category == L["All categories"] and 50 or 100,
+ }
+ return self[category]
+ end})
+
+ local args_plugins = {
+ type = 'group',
+ groupType = 'inline',
+ name = L["Plugins"],
+ desc = L["Plugins that can be shown on the bar."],
+ args = function(key)
+ local args = newList()
+
+ local menuTitles = newList()
+ for _,plugin in ipairs(plugins) do
+ local alreadyExists = false
+ local category = localizedCategory[plugin:GetCategory()]
+ menuTitles[category] = true
+ end
+ for _,name in ipairs(toBeLoaded) do
+ local category = localizedCategory[FuBar.db.profile.loadOnDemand[name[1]].category]
+ menuTitles[category] = true
+ end
+ for name in pairs(menuTitles) do
+ args[name] = categoryOpts[name]
+ end
+ if next(menuTitles, next(menuTitles, nil)) ~= nil then
+ -- don't do it if we only have one category
+ args[L["All categories"]] = categoryOpts[L["All categories"]]
+ end
+ menuTitles = del(menuTitles)
+
+ return "@dict", unpackDictAndDel(args)
+ end,
+ order = 200,
+ }
+
+ barOpts = setmetatable({}, {__index=function(self, key)
+ self[key] = {
+ name = (L["Bar #%d"]):format(key),
+ desc = (L["Bar #%d"]):format(key),
+ type = 'group',
+ child_child_passValue = key,
+ child_passValue = key,
+ passValue = key,
+ args = {
+ attach = args_attach,
+ lock = args_lock,
+ remove = args_remove,
+ plugins = args_plugins,
+ },
+ }
+ return self[key]
+ end})
+end
+local optionsTable = {
+ name = "FuBar",
+ desc = L["A panel that modules can plug into."],
+ handler = FuBar,
+ type = 'group',
+ icon = [[Interface\Icons\INV_Gizmo_SuperSapperCharge]],
+ args = function()
+ local t = newList()
+ for k,v in pairs(optionsTable_args) do
+ t[k] = v
+ end
+ for i = 1, FuBar:GetNumPanels() do
+ t["bar" .. i] = barOpts[i]
+ end
+ return "@dict", unpackDictAndDel(t)
+ end
+}
+
+--FuBar:RegisterChatCommand(L["ChatCommands"], optionsTable, "FUBAR")
+
+function FuBar:GetScaledCursorPosition()
+ local x, y = GetCursorPosition()
+ local scale = GetScreenHeight() / 768
+ return x * scale, y * scale
+end
+
+function FuBar:Reset()
+ self:RemoveEventListener("PLAYER_LOGOUT")
+ FuBar2DB = {}
+ ReloadUI()
+end
+
+function FuBar:GetPanel(panelId)
+ return FuBar_Panel.instances[panelId]
+end
+
+function FuBar:GetNumPanels()
+ return #FuBar_Panel.instances
+end
+
+function FuBar:GetBottommostTopPanel()
+ local bottom = GetScreenHeight()
+ local best
+ for i = 1, self:GetNumPanels() do
+ local panel = self:GetPanel(i)
+ if panel:GetAttachPoint() == "TOP" and panel.frame:GetBottom() < bottom then
+ bottom = panel.frame:GetBottom()
+ best = panel
+ end
+ end
+ return best
+end
+
+function FuBar:GetTopmostBottomPanel()
+ local top = 0
+ local best
+ for i = 1, self:GetNumPanels() do
+ local panel = self:GetPanel(i)
+ if panel:GetAttachPoint() == "BOTTOM" and panel.frame:GetTop() > top then
+ top = panel.frame:GetTop()
+ best = panel
+ end
+ end
+ return best
+end
+
+local isChangingProfile, previousProfile
+
+function FuBar:IsChangingProfile()
+ return isChangingProfile
+end
+
+function FuBar:IsAdjust()
+ return self.db.profile.adjust
+end
+
+function FuBar:ToggleAdjust()
+ self.db.profile.adjust = not self.db.profile.adjust
+ self:UpdateJostleAdjustments()
+ return self.db.profile.adjust
+end
+
+function FuBar:IsOverflowing()
+ do return false end
+ return not self.db.profile.overflow
+end
+
+function FuBar:ToggleOverflowing()
+ self.db.profile.overflow = not self.db.profile.overflow
+ for i = 1, self:GetNumPanels() do
+ self:GetPanel(i):CheckForOverlap()
+ end
+ return not self.db.profile.overflow
+end
+
+function FuBar:UpdateJostleAdjustments()
+ if not Jostle then
+ return
+ end
+ if not self.db.profile.adjust then
+ Jostle:DisableTopAdjusting()
+ Jostle:DisableBottomAdjusting()
+ else
+ if self:IsAutoHidingTop() then
+ Jostle:DisableTopAdjusting()
+ else
+ Jostle:EnableTopAdjusting()
+ end
+ if self:IsAutoHidingBottom() then
+ Jostle:DisableBottomAdjusting()
+ else
+ Jostle:EnableBottomAdjusting()
+ end
+ end
+end
+
+function FuBar:IsAutoHidingTop()
+ return self.db.profile.autohideTop
+end
+
+local autohideTopTime, autohideBottomTime
+
+function FuBar:ToggleAutoHidingTop()
+ self.db.profile.autohideTop = not self.db.profile.autohideTop
+ self:UpdateJostleAdjustments()
+ if not self.db.profile.autohideTop then
+ for i = 1, self:GetNumPanels() do
+ if self:GetPanel(i):GetAttachPoint() == "TOP" then
+ local frame = _G["FuBarFrame" .. i]
+ frame:SetAlpha(1)
+ frame:SetFrameStrata("BACKGROUND")
+ end
+ end
+ else
+ self:AddTimer("FuBar_AutoHideTop", 1, "OnUpdate_AutoHideTop")
+ end
+ autohideTopTime = GetTime()
+ return self.db.profile.autohideTop
+end
+
+function FuBar:IsAutoHidingBottom()
+ return self.db.profile.autohideBottom
+end
+
+function FuBar:ToggleAutoHidingBottom()
+ self.db.profile.autohideBottom = not self.db.profile.autohideBottom
+ self:UpdateJostleAdjustments()
+ if not self.db.profile.autohideBottom then
+ for i = 1, self:GetNumPanels() do
+ if self:GetPanel(i):GetAttachPoint() == "BOTTOM" then
+ local frame = _G["FuBarFrame" .. i]
+ frame:SetAlpha(1)
+ frame:SetFrameStrata("BACKGROUND")
+ end
+ end
+ else
+ self:AddTimer("FuBar_AutoHideBottom", 1, "OnUpdate_AutoHideBottom")
+ end
+ autohideBottomTime = GetTime()
+ return self.db.profile.autohideBottom
+end
+
+function FuBar:GetFontSize()
+ if not self.db.profile then
+ return 12
+ end
+ return self.db.profile.fontSize or 12
+end
+
+function FuBar:SetFontSize(size)
+ size = size or 12
+ self.db.profile.fontSize = size
+ for i,plugin in ipairs(plugins) do
+ if type(plugin.SetFontSize) ~= "function" then
+ table.remove(plugins, i)
+ i = i - 1
+ else
+ plugin:SetFontSize(size)
+ end
+ end
+ for i = 1, self:GetNumPanels() do
+ self:GetPanel(i):UpdateTexture()
+ end
+ self:Update()
+ if Jostle then
+ Jostle:Refresh()
+ end
+end
+
+function FuBar:GetLeftSpacing()
+ if not self.db.profile then
+ return 20
+ end
+ return self.db.profile.leftSpacing or 20
+end
+
+function FuBar:SetLeftSpacing(size)
+ self.db.profile.leftSpacing = size
+ self:Update()
+end
+
+function FuBar:GetCenterSpacing()
+ if not self.db.profile then
+ return 20
+ end
+ return self.db.profile.centerSpacing or 20
+end
+
+function FuBar:SetCenterSpacing(size)
+ self.db.profile.centerSpacing = size
+ self:Update()
+end
+
+function FuBar:GetRightSpacing()
+ if not self.db.profile then
+ return 20
+ end
+ return self.db.profile.rightSpacing or 20
+end
+
+function FuBar:SetRightSpacing(size)
+ self.db.profile.rightSpacing = size
+ self:Update()
+end
+
+function FuBar:SetThickness(size)
+ self.db.profile.thickness = size
+ for i = 1, self:GetNumPanels() do
+ self:GetPanel(i):UpdateTexture()
+ end
+ self:Update()
+ if Jostle then
+ Jostle:Refresh()
+ end
+end
+
+function FuBar:GetThickness(size)
+ if not self.db.profile then
+ return 5
+ end
+ return self.db.profile.thickness or 5
+end
+
+function FuBar:GetTransparency()
+ return self.db.profile.transparency or 0.8
+end
+
+function FuBar:SetTransparency(value)
+ self.db.profile.transparency = value
+ for i = 1, self:GetNumPanels() do
+ self:GetPanel(i):UpdateTexture()
+ end
+end
+
+local function CheckLoadCondition(loadCondition)
+ return RunScript("(function()"..loadCondition.." end)()")
+end
+
+local function _IsCorrectPlugin(plugin)
+ if type(plugin) ~= "table" then
+ return false
+ elseif type(plugin.GetName) ~= "function" then
+ return false
+ elseif type(plugin.GetTitle) ~= "function" then
+ return false
+ elseif type(plugin.GetCategory) ~= "function" then
+ return false
+ elseif type(plugin.SetFontSize) ~= "function" then
+ return false
+ elseif type(plugin.GetFrame) ~= "function" then
+ return false
+ elseif type(plugin.Show) ~= "function" then
+ return false
+ elseif type(plugin.Hide) ~= "function" then
+ return false
+ elseif type(plugin.GetPanel) ~= "function" then
+ return false
+ elseif type(plugin:GetName()) ~= "string" then
+ return false
+ elseif type(plugin:GetTitle()) ~= "string" then
+ return false
+ elseif type(plugin:GetCategory()) ~= "string" then
+ return false
+ end
+ local frame = plugin:GetFrame()
+ if type(frame) ~= "table" then
+ return false
+ elseif type(frame[0]) ~= "userdata" then
+ return false
+ elseif type(frame.GetObjectType) ~= "function" then
+ return false
+ elseif type(frame:GetObjectType()) ~= "string" then
+ return false
+ end
+ return true
+end
+
+local function IsCorrectPlugin(plugin)
+ local ret, msg = pcall(_IsCorrectPlugin, plugin)
+ if ret then
+ return msg
+ end
+end
+
+local function _IsCorrectPanel(panel)
+ if type(panel) ~= "table" then
+ return false
+ elseif type(panel.AddPlugin) ~= "function" then
+ return false
+ elseif type(panel.RemovePlugin) ~= "function" then
+ return false
+ elseif type(panel.GetNumPlugins) ~= "function" then
+ return false
+ elseif type(panel:GetNumPlugins()) ~= "number" then
+ return false
+ elseif type(panel.GetPlugin) ~= "function" then
+ return false
+ elseif type(panel.HasPlugin) ~= "function" then
+ return false
+ elseif type(panel.GetPluginSide) ~= "function" then
+ return false
+ end
+ return true
+end
+
+local function IsCorrectPanel(panel)
+ local ret, msg = pcall(_IsCorrectPanel, panel)
+ if ret then
+ return msg
+ end
+end
+
+local n
+local mt = {
+ __newindex = function(self, k, v)
+ rawset(self, k, v)
+ n[k] = v
+ end,
+}
+
+local function LoadAddOnWrapper(addon)
+ local o = _G
+ n = {}
+ local oldmt = getmetatable(o)
+ setmetatable(o, mt)
+ local success, ret = pcall(LoadAddOn, addon)
+ setmetatable(o, oldmt)
+ if not success then
+ geterrorhandler()(ret)
+ return
+ elseif not ret then
+ DEFAULT_CHAT_FRAME:AddMessage("Error loading LoadOnDemand plugin " .. addon)
+ return
+ end
+
+ local dependencies
+ local plugin
+ for k,v in pairs(n) do
+ if IsCorrectPlugin(v) then
+ if plugin then
+ if not dependencies then
+ dependencies = {}
+ end
+ table.insert(dependencies, plugin)
+ end
+ plugin = v
+ end
+ end
+ if not plugin then
+ DEFAULT_CHAT_FRAME:AddMessage("Error loading LoadOnDemand plugin " .. addon)
+ return
+ end
+ return ret, plugin, dependencies
+end
+
+local t = {}
+local function CleanDB()
+ local self = FuBar
+ if not self.db.profile.panels then
+ self.db.profile.panels = { { plugins = {}, attachPoint = "TOP" } }
+ end
+ for _,panel in ipairs(self.db.profile.panels) do
+ if panel and panel.plugins then
+ for _,part in pairs(panel.plugins) do
+ if part then
+ for i,plugin in ipairs(part) do
+ if t[plugin] then
+ i = i - 1
+ table.remove(part, i)
+ else
+ t[plugin] = true
+ end
+ end
+ end
+ end
+ end
+ end
+ for k in pairs(t) do
+ t[k] = nil
+ end
+end
+
+local function copyTable(t)
+ if type(t) == "table" then
+ local ret = {}
+ for k, v in pairs(t) do
+ ret[copyTable(k)] = copyTable(v)
+ end
+ return ret
+ else
+ return t
+ end
+end
+
+function FuBar:OnInitialize()
+ if not self.db.account.firstTimeWoW21 then
+ self.db.account.firstTimeWoW21 = true
+ SetCVar("scriptErrors", "1")
+ end
+ toBeLoaded = {}
+ self:SetConfigTable(optionsTable)
+ self:SetConfigSlashCommand("/FuBar", "/Fu")
+ optionsTable.extraArgs.active = nil
+
+ if not next(FuBar.db.profile) then
+ local def
+ local profile = self:GetProfile()
+ if profile:find("^char/") or profile:find("^class/") then
+ local class = select(2, UnitClass("player"))
+ def = _G["FUBAR_DEFAULTS_" .. class] or FUBAR_DEFAULTS
+ else
+ def = FUBAR_DEFAULTS
+ end
+ if type(def) == "function" then
+ def = def()
+ end
+ def = copyTable(def)
+ for k,v in pairs(def) do
+ FuBar.db.profile[k] = v
+ end
+ end
+
+ if type(self.db.profile.loadOnDemand) ~= "table" then
+ self.db.profile.loadOnDemand = {}
+ end
+
+ if type(self.db.profile.tooltip) ~= "table" then
+ self.db.profile.tooltip = {}
+ end
+ self.db.profile.tooltip.r = nil -- in case some evil person made it non-black
+ self.db.profile.tooltip.g = nil
+ self.db.profile.tooltip.b = nil
+ if type(self.db.profile.skinR) ~= "number" then
+ self.db.profile.skinR = 0
+ end
+ if type(self.db.profile.skinG) ~= "number" then
+ self.db.profile.skinG = 0
+ end
+ if type(self.db.profile.skinB) ~= "number" then
+ self.db.profile.skinB = 0
+ end
+
+ self:SetFontSize(self:GetFontSize())
+
+ local menuTitles = {}
+ local titles = {}
+
+ self:AddTimer(0, "LoadLoadOnDemandPlugins")
+
+ CleanDB()
+
+ self:AddEventListener("ADDON_LOADED", "OnLibraryLoad")
+end
+
+function FuBar:LoadPlugin(name)
+ local loaded, plugin, dependencies = LoadAddOnWrapper(name)
+ if loaded then
+ if type(plugin.SetLoadOnDemand) == "function" then
+ plugin:SetLoadOnDemand(true)
+ end
+ self.db.profile.loadOnDemand[name] = {
+ title = plugin:GetTitle(),
+ category = plugin:GetCategory(),
+ disabled = nil,
+ condition = type(plugin.GetLoadCondition) == "function" and plugin:GetLoadCondition() or nil,
+ }
+ plugin:Show(FuBar_Panel.selectedPanel or false)
+ if dependencies then
+ for _,v in ipairs(dependencies) do
+ if type(v.SetLoadOnDemand) == "function" then
+ v:SetLoadOnDemand(true)
+ end
+ self.db.profile.loadOnDemand[name].disabled = nil
+ for j,u in ipairs(toBeLoaded) do
+ if u[1] == v:GetTitle() then
+ table.remove(toBeLoaded, j)
+ break
+ end
+ end
+ if v.hideWithoutStandby then
+ v:EnableApp()
+ else
+ v:Show(panelId or false)
+ end
+ end
+ end
+ self:SetFontSize(self:GetFontSize())
+ for i,n in ipairs(toBeLoaded) do
+ if n[1] == name then
+ table.remove(toBeLoaded, i)
+ break
+ end
+ end
+ self.db.profile.loadOnDemand[name].disabled = nil
+ end
+end
+
+function FuBar:OnEnable()
+ if alreadyEnabled then
+ ReloadUI()
+ return
+ end
+ alreadyEnabled = true
+
+ if type(self.db.profile.panels) ~= "table" then
+ self.db.profile.panels = {}
+ end
+
+ if type(self.db.profile.minimap) ~= "table" then
+ self.db.profile.minimap = {}
+ end
+
+ for i = #self.db.profile.panels, 1, -1 do
+ if self.db.profile.panels[i] then
+ FuBar_Panel:new()
+ end
+ end
+
+ self:CheckResolution()
+
+ if self:GetNumPanels() == 0 then
+ FuBar_Panel:new()
+ end
+
+ if FuBar.db.profile.skin ~= nil then
+ SetBackground(FuBar.db.profile.skin)
+ end
+
+ self:AddEventListener("CVAR_UPDATE", "OnCVarUpdate")
+
+ DisableAddOn("FuBar-compat-1.2")
+
+ self:AddSecureHook("RestartGx")
+
+ local function func()
+ if FuBar.db.profile.skin ~= nil then
+ SetBackground(FuBar.db.profile.skin)
+ end
+
+ if not self:SetupPlugins() then
+ self:AddTimer(0, func)
+ return
+ end
+ self:Update()
+
+ self:AddTimer("FuBar_AutoHideTop", 1, "OnUpdate_AutoHideTop")
+ self:AddTimer("FuBar_AutoHideBottom", 1, "OnUpdate_AutoHideBottom")
+ end
+ self:AddTimer(1, func)
+
+ self:UpdateJostleAdjustments()
+
+ if self.db.profile.skin and backgrounds[self.db.profile.skin] then
+ FuBar_Panel:SetBackground(self.db.profile.skin)
+ end
+end
+
+function FuBar:OnLibraryLoad()
+ if not Jostle and Rock("LibJostle-3.0", false, true) then
+ Jostle = Rock("LibJostle-3.0", false, true)
+ FuBar_Panel:OnJostleLoad(Jostle)
+ end
+end
+
+local function findFuBarDep(...)
+ for i = 1, select("#", ...) do
+ local dep = select(i, ...)
+ if dep == "FuBar" then
+ return true
+ end
+ end
+end
+
+local function isFuBarDependent(name)
+ local data = GetAddOnMetadata(name, "X-FuBar-Dependent")
+ data = tonumber(data) or data
+ if data and data ~= 0 then
+ return true
+ end
+ return findFuBarDep(GetAddOnDependencies(name))
+end
+
+function FuBar:LoadLoadOnDemandPlugins()
+ for i = 1, GetNumAddOns() do
+ local name, _, notes, enabled, loadable = GetAddOnInfo(i)
+ if IsAddOnLoadOnDemand(i) and enabled and loadable and not IsAddOnLoaded(i) then
+ if isFuBarDependent(name) then
+ if not self.db.profile.loadOnDemand[name] then
+ self:LoadPlugin(name)
+ elseif not self.db.profile.loadOnDemand[name].disabled and (not self.db.profile.loadOnDemand[name].condition or CheckLoadCondition(self.db.profile.loadOnDemand[name].condition)) then
+ self:LoadPlugin(name)
+ else
+ table.insert(toBeLoaded, {name, notes})
+ end
+ end
+ end
+ end
+end
+
+function FuBar:RestartGx()
+ self:AddTimer(0, "Update")
+end
+
+function FuBar:OnCVarUpdate()
+ if arg1 == "USE_UISCALE" then
+ self:AddTimer(0, "CheckResolution")
+ end
+end
+
+local lastScreenWidth = GetScreenWidth()
+function FuBar:CheckResolution()
+ local screenWidth = GetScreenWidth()
+ if lastScreenWidth ~= screenWidth then
+ for i = 1, self:GetNumPanels() do
+ self:GetPanel(i):Update()
+ end
+ lastScreenWidth = screenWidth
+ if Jostle then
+ Jostle:Refresh()
+ end
+ end
+end
+
+local inTopPanel, inBottomPanel
+
+function FuBar:OnUpdate_AutoHideTop()
+ if not inTopPanel and self:IsAutoHidingTop() then
+-- for i = 1, self:GetNumPanels() do
+-- if Dewdrop:IsOpen(self:GetPanel(i).frame) then
+-- self:AddTimer("FuBar_AutoHideTop", 1, "OnUpdate_AutoHideTop")
+-- return
+-- end
+-- end
+ for i = 1, self:GetNumPanels() do
+ if self:GetPanel(i):GetAttachPoint() == "TOP" then
+ local frame = _G["FuBarFrame" .. i]
+ frame:SetAlpha(0)
+ frame:SetFrameStrata("BACKGROUND")
+ end
+ end
+ end
+end
+
+function FuBar:OnUpdate_AutoHideBottom()
+ if not inBottomPanel and self:IsAutoHidingBottom() then
+-- for i = 1, self:GetNumPanels() do
+-- if Dewdrop:IsOpen(self:GetPanel(i).frame) then
+-- self:AddTimer("FuBar_AutoHideBottom", 1, "OnUpdate_AutoHideBottom")
+-- return
+-- end
+-- end
+ for i = 1, self:GetNumPanels() do
+ if self:GetPanel(i):GetAttachPoint() == "BOTTOM" then
+ local frame = _G["FuBarFrame" .. i]
+ frame:SetAlpha(0)
+ frame:SetFrameStrata("BACKGROUND")
+ end
+ end
+ end
+end
+
+function FuBar:IsHidingTooltipsInCombat()
+ return self.db.profile.hidingTooltipsInCombat
+end
+
+function FuBar:ToggleHidingTooltipsInCombat()
+ self.db.profile.hidingTooltipsInCombat = not self.db.profile.hidingTooltipsInCombat
+end
+
+local doneSetupPlugins, pluginsToSetup
+
+function FuBar:OnDisable()
+ for i = 1, self:GetNumPanels() do
+ self:GetPanel(i).frame:Hide()
+ end
+end
+
+function FuBar:GetNumPlugins()
+ return #plugins
+end
+
+function FuBar:GetPlugin(i)
+ return plugins[i]
+end
+
+function FuBar:RegisterPlugin(plugin)
+ if not IsCorrectPlugin(plugin) then
+ return
+ end
+ table.insert(plugins, plugin)
+
+ local frame = plugin:GetFrame()
+ local downTime
+ if frame:HasScript("OnClick") then
+ local OnClick = frame:GetScript("OnClick")
+ frame:SetScript("OnClick", function(f, arg1, ...)
+ if OnClick and (not downTime or GetTime() < downTime + 0.5) and (not f.stopClick or GetTime() > f.stopClick) then
+ OnClick(f, arg1, ...)
+ end
+ downTime = nil
+ end)
+ end
+ local OnMouseDown = frame:GetScript("OnMouseDown")
+ frame:SetScript("OnMouseDown", function(f, arg1, ...)
+ if arg1 == "LeftButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then
+ downTime = GetTime()
+ FuBar:Plugin_StartDrag(plugin)
+ end
+ if OnMouseDown then
+ OnMouseDown(f, arg1, ...)
+ end
+ end)
+ local OnMouseUp = frame:GetScript("OnMouseUp")
+ frame:SetScript("OnMouseUp", function(f, arg1, ...)
+ if arg1 == "LeftButton" then
+ if not FuBar:Plugin_StopDrag(plugin) then
+ if OnMouseUp then
+ OnMouseUp(f, arg1, ...)
+ end
+ else
+ f.stopClick = GetTime() + 0.05
+ end
+ elseif OnMouseUp then
+ OnMouseUp(f, arg1, ...)
+ end
+ end)
+ local OnEnter = frame:GetScript("OnEnter")
+ frame:SetScript("OnEnter", function(f, arg1, ...)
+ FuBar:Panel_OnEnter(plugin)
+ if OnEnter then
+ OnEnter(f, arg1, ...)
+ end
+ end)
+ local OnLeave = frame:GetScript("OnLeave")
+ frame:SetScript("OnLeave", function(f, arg1, ...)
+ FuBar:Panel_OnLeave(plugin)
+ if OnLeave then
+ OnLeave(f, arg1, ...)
+ end
+ end)
+end
+
+function FuBar:Update()
+ for panelId = 1, self:GetNumPanels() do
+ self:GetPanel(panelId):Update()
+ end
+end
+
+function FuBar:SetupPlugins()
+ doneSetupPlugins = true
+ if pluginsToSetup then
+ for i = 1, self:GetNumPanels() do
+ local panel = self:GetPanel(i)
+ for h = 1, 3 do
+ local side
+ if h == 1 then
+ side = "LEFT"
+ elseif h == 2 then
+ side = "CENTER"
+ else
+ side = "RIGHT"
+ end
+ local order = panel:GetSavedOrder(side)
+ for _,name in ipairs(order) do
+ for plugin in pairs(pluginsToSetup) do
+ if not plugin:IsDisabled() and plugin:GetTitle() == name then
+ if not panel:AddPlugin(plugin, nil, side) then
+ doneSetupPlugins = false
+ return
+ end
+ pluginsToSetup[plugin] = nil
+ break
+ end
+ end
+ end
+ end
+ end
+
+ local order = self.db.profile.detached
+ if order then
+ for name in pairs(order) do
+ for plugin in pairs(pluginsToSetup) do
+ if not plugin:IsDisabled() and plugin:GetTitle() == name then
+ pluginsToSetup[plugin] = nil
+ plugin:Show(0)
+ break
+ end
+ end
+ end
+ else
+ self.db.profile.detached = {}
+ end
+
+ for plugin in pairs(pluginsToSetup) do
+ if type(plugin.GetDefaultPosition) == "function" and plugin:GetDefaultPosition() == "MINIMAP" then
+ plugin:Show(0)
+ else
+ self.lastPanelId = (self.lastPanelId or 0) + 1
+ if self.lastPanelId > self:GetNumPanels() then
+ self.lastPanelId = 1
+ end
+ self:GetPanel(self.lastPanelId):AddPlugin(plugin, nil, type(plugin.GetDefaultPosition) == "function" and plugin:GetDefaultPosition() or "LEFT", true)
+ end
+ end
+
+ pluginsToSetup = nil
+ end
+ return true
+end
+
+function FuBar:ShowPlugin(plugin, panelId)
+ if type(plugin) ~= "table" then
+ error(("Bad argument #2 to `ShowPlugin'. Expected %q, got %q."):format("table", type(plugin)), 2)
+ end
+ if panelID and type(panelId) ~= "number" then
+ error(("Bad argument #3 to `ShowPlugin'. Expected %q or %q, got %q."):format("number", "nil", type(panelId)), 2)
+ end
+ if doneSetupPlugins then
+ if not panelId then
+ doneSetupPlugins = false
+ pluginsToSetup = {}
+ pluginsToSetup[plugin] = true
+ local function func()
+ if not self:SetupPlugins() then
+ self:AddTimer(0, func)
+ return
+ end
+ self:Update()
+ end
+ func()
+ else
+ local pos = type(plugin.GetDefaultPosition) == "function" and plugin:GetDefaultPosition() or "LEFT"
+ if not self:GetPanel(panelId) then
+ panelId = nil
+ for i, panel in ipairs(self.db.profile.panels) do
+ if panel.plugins then
+ for _,part in pairs(panel.plugins) do
+ for _, plug in ipairs(part) do
+ if plug == plugin:GetTitle() then
+ panelId = i
+ break
+ end
+ end
+ if panelId then
+ break
+ end
+ end
+ end
+ if panelId then
+ break
+ end
+ end
+ if not panelId then
+ panelId = 1
+ end
+ end
+ self:GetPanel(panelId):AddPlugin(plugin, nil, pos, true)
+ end
+ else
+ if not pluginsToSetup then
+ pluginsToSetup = {}
+ end
+ pluginsToSetup[plugin] = true
+ end
+end
+
+local previousPosition_panel, previousPosition_index, previousPosition_side, previousPosition_x, previousPosition_y
+
+function FuBar:Plugin_StartDrag(plugin)
+ local panel = plugin:GetPanel()
+ if not panel then error(plugin:GetTitle() .. ": You must be attached to a panel.") end
+
+ self:Panel_OnLeave()
+ local index, side = panel:IndexOfPlugin(plugin)
+
+ if index then
+ if not panel:IsLocked() then
+ if index < panel:GetNumPlugins(side) then
+ local frame = panel:GetPlugin(index + 1, side):GetFrame()
+ local x, y = frame:GetLeft(), frame:GetBottom()
+ frame:ClearAllPoints()
+ frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", x, y)
+ end
+
+ previousPosition_panel = panel
+ previousPosition_index = index
+ previousPosition_side = side
+ previousPosition_x, previousPosition_y = self:GetScaledCursorPosition()
+
+ FuBar_Panel:PreventUpdate()
+ panel:RemovePlugin(index, side)
+ plugin:GetFrame():StartMoving()
+ end
+ end
+end
+
+function FuBar:Plugin_StopDrag(plugin)
+ plugin:GetFrame():StopMovingOrSizing()
+ if previousPosition_panel and not previousPosition_panel:IsLocked() then
+ local insertAt
+ local panel = previousPosition_panel
+ local side = previousPosition_side
+ local x, y = self:GetScaledCursorPosition()
+ local px, py = previousPosition_x, previousPosition_y
+
+ for panelId = 1, self:GetNumPanels() do
+ local p = self:GetPanel(panelId)
+ local frame = p.frame
+ local x1, x2, y1, y2 = frame:GetLeft(), frame:GetRight(), frame:GetBottom(), frame:GetTop()
+ if x1 <= x and x <= x2 and y1 <= y and y <= y2 then
+ panel = p
+ break
+ end
+ end
+
+ if panel:GetNumPlugins(side) == 0 then
+ insertAt = 1
+ else
+ for i = 1, panel:GetNumPlugins(side) + 1 do
+ local left, right
+ local leftPlugin
+ local rightPlugin
+
+ leftPlugin = panel:GetPlugin(i - 1, side)
+ rightPlugin = panel:GetPlugin(i, side)
+
+ if side == "RIGHT" then
+ leftPlugin, rightPlugin = rightPlugin, leftPlugin
+ end
+ left = leftPlugin and leftPlugin:GetFrame():GetCenter() or 0
+ right = rightPlugin and rightPlugin:GetFrame():GetCenter() or GetScreenWidth()
+ if left <= x and x <= right then
+ insertAt = i
+ break
+ end
+ end
+ end
+ if not insertAt then
+ insertAt = panel:GetNumPlugins(side) + 1
+ end
+
+ panel:AddPlugin(plugin, insertAt, side)
+ FuBar_Panel:StopPreventUpdate()
+ previousPosition_panel:Update()
+ panel:Update()
+ previousPosition_panel = nil
+ previousPosition_index = nil
+ previousPosition_side = nil
+ previousPosition_x = nil
+ previousPosition_y = nil
+ if math.abs(px - x) <= 5 and math.abs(py - y) <= 5 then
+ return false
+ else
+ return true
+ end
+ end
+end
+
+function FuBar:Panel_OnEnter(plugin)
+ local point = plugin
+ if type(plugin) == "table" then
+ point = plugin:GetPanel():GetAttachPoint()
+ end
+ if point == "TOP" then
+ inTopPanel = true
+ self:RemoveTimer("FuBar_AutoHideTop")
+ elseif point == "BOTTOM" then
+ inBottomPanel = true
+ self:RemoveTimer("FuBar_AutoHideBottom")
+ else
+ return
+ end
+ for i = 1, self:GetNumPanels() do
+ local panel = self:GetPanel(i)
+ if panel:GetAttachPoint() == point then
+ panel.frame:SetAlpha(1)
+ panel.frame:SetFrameStrata("BACKGROUND")
+ end
+ end
+end
+
+function FuBar:Panel_OnLeave(plugin)
+ local point = plugin
+ if type(plugin) == "table" then
+ if not plugin:GetPanel() then
+ return
+ end
+ point = plugin:GetPanel():GetAttachPoint()
+ end
+ if point == "TOP" then
+ inTopPanel = false
+ self:AddTimer("FuBar_AutoHideTop", 1, "OnUpdate_AutoHideTop")
+ elseif point == "BOTTOM" then
+ inBottomPanel = false
+ self:AddTimer("FuBar_AutoHideBottom", 1, "OnUpdate_AutoHideBottom")
+ end
+end
+
+function FuBar:OnProfileEnable(oldName, _, copyFrom)
+ isChangingProfile = true
+ if not next(FuBar.db.profile) then
+ local def
+ local profile = self:GetProfile()
+ if profile:find("^char/") or profile:find("^class/") then
+ local class = select(2, UnitClass("player"))
+ def = _G["FUBAR_DEFAULTS_" .. class] or FUBAR_DEFAULTS
+ else
+ def = FUBAR_DEFAULTS
+ end
+ if type(def) == "function" then
+ def = def()
+ end
+ def = copyTable(def)
+ for k,v in pairs(def) do
+ FuBar.db.profile[k] = v
+ end
+ end
+
+ if type(self.db.profile.loadOnDemand) ~= "table" then
+ self.db.profile.loadOnDemand = {}
+ end
+
+ if type(self.db.profile.tooltip) ~= "table" then
+ self.db.profile.tooltip = {}
+ end
+
+ if type(self.db.profile.panels) ~= "table" then
+ self.db.profile.panels = {}
+ end
+
+ CleanDB()
+
+ doneSetupPlugins = false
+ pluginsToSetup = {}
+ for i,plugin in ipairs(plugins) do
+ pluginsToSetup[plugin] = true
+ local frame = plugin:GetFrame()
+ frame:Hide()
+ frame:ClearAllPoints()
+ plugin:SetPanel(nil)
+ end
+
+ for i = self:GetNumPanels(), 1, -1 do
+ self:GetPanel(i):del(true)
+ end
+
+ for i = #self.db.profile.panels, 1, -1 do
+ if self.db.profile.panels[i] then
+ FuBar_Panel:new()
+ end
+ end
+
+ if self:GetNumPanels() == 0 then
+ FuBar_Panel:new()
+ end
+
+ self:CheckResolution()
+
+ for i = 1, GetNumAddOns() do
+ local name, _, notes, enabled, loadable = GetAddOnInfo(i)
+ if IsAddOnLoadOnDemand(i) and enabled and loadable and not IsAddOnLoaded(i) then
+ if findFuBarDep(GetAddOnDependencies(name)) then
+ if not self.db.profile.loadOnDemand[name] then
+ self:LoadPlugin(name)
+ elseif not self.db.profile.loadOnDemand[name].disabled and (not self.db.profile.loadOnDemand[name].condition or CheckLoadCondition(self.db.profile.loadOnDemand[name].condition)) then
+ self:LoadPlugin(name)
+ else
+ local exists = false
+ for _,n in ipairs(toBeLoaded) do
+ if n[1] == name then
+ exists = true
+ break
+ end
+ end
+ if not exists then
+ table.insert(toBeLoaded, {name, notes})
+ end
+ end
+ end
+ end
+ end
+
+ for i,plugin in ipairs(plugins) do
+ if plugin.IsDisabled and plugin:IsDisabled() and plugin:GetPanel() then
+ plugin:GetPanel():RemovePlugin(plugin)
+ end
+ end
+
+ local name = self:GetProfile()
+ for _,plugin in ipairs(plugins) do
+ if not plugin.independentProfile then
+ if type(plugin.CopyProfileFrom) ~= "function" then
+ if type(plugin.SetProfile) == "function" then
+ safecall(plugin.SetProfile, plugin, name, copyFrom)
+ end
+ elseif type(plugin.SetProfile) == "function" then
+ if copyFrom then
+ safecall(plugin.CopyProfileFrom, plugin, copyFrom)
+ else
+ safecall(plugin.SetProfile, plugin, name)
+ end
+ end
+ end
+ end
+
+ self:SetFontSize(self:GetFontSize())
+
+ local function func()
+ if not self:SetupPlugins() then
+ self:AddTimer(0, func)
+ return
+ end
+ self:Update()
+ end
+ self:AddTimer(0, func)
+
+ isChangingProfile = false
+end
diff --git a/FuBar/FuBar.toc b/FuBar/FuBar.toc
new file mode 100644
index 0000000..8f6eeb2
--- /dev/null
+++ b/FuBar/FuBar.toc
@@ -0,0 +1,52 @@
+## Interface: 100002
+## Title: FuBar 4.0
+## Notes: A panel that modules can plug into.
+## Notes-ruRU: Панели для отображения различных плагинов.
+## Notes-deDE: Eine Leiste in der sich Module einbinden können.
+## Notes-frFR: Un panneau entièrement modulable.
+## Notes-zhCN: 插件式信息面板。
+## Notes-zhTW: 插件式訊息面板。
+## Notes-esES: Un panel donde puedes colocar plugins
+## Author: ckknight
+## X-eMail: ckknight AT gmail DOT com
+## X-Website: http://www.wowace.com/
+## X-Category: Interface Enhancements
+## SavedVariables: FuBar2DB
+## OptionalDeps: LibRock-1.0, LibRockEvent-1.0, LibRockTimer-1.0, LibRockLocale-1.0, LibRockHook-1.0, LibRockConfig-1.0, LibRockDB-1.0, LibJostle-3.0
+## X-WoWIPortal: ckknight
+## X-Donate: PayPal:ckknight AT gmail DOT com
+## X-Curse-Packaged-Version: r40
+## X-Curse-Project-Name: FuBar 4.0
+## X-Curse-Project-ID: fubar
+## X-Curse-Repository-ID: wow/fubar/mainline
+
+libs\LibStub\LibStub.lua
+libs\CallbackHandler-1.0\CallbackHandler-1.0.xml
+libs\LibSharedMedia-3.0\LibSharedMedia-3.0\lib.xml
+
+#@no-lib-strip@
+libs\AceLibrary\AceLibrary.lua
+libs\LibRock-1.0\lib.xml
+libs\LibRockConfig-1.0\lib.xml
+libs\LibRockEvent-1.0\lib.xml
+libs\LibRockLocale-1.0\lib.xml
+libs\LibRockHook-1.0\lib.xml
+libs\LibRockDB-1.0\lib.xml
+libs\LibRockTimer-1.0\lib.xml
+libs\LibJostle-3.0\lib.xml
+libs\LibFuBarPlugin-3.0\lib.xml
+libs\Dewdrop-2.0\Dewdrop-2.0.lua
+libs\Tablet-2.0\Tablet-2.0.lua
+#@end-no-lib-strip@
+
+FuBar-Locale-enUS.lua
+FuBar-Locale-ruRU.lua
+FuBar-Locale-deDE.lua
+FuBar-Locale-frFR.lua
+FuBar-Locale-koKR.lua
+FuBar-Locale-zhCN.lua
+FuBar-Locale-zhTW.lua
+FuBar-Locale-esES.lua
+
+FuBar_Panel.lua
+FuBar.lua
diff --git a/FuBar/FuBar_Panel.lua b/FuBar/FuBar_Panel.lua
new file mode 100644
index 0000000..f6eeef1
--- /dev/null
+++ b/FuBar/FuBar_Panel.lua
@@ -0,0 +1,1284 @@
+local Jostle = Rock("LibJostle-3.0", false, true)
+
+local SPACING_FROM_SIDES = 5
+
+local bgFile = [[Interface\AddOns\FuBar\background]]
+local bgR, bgG, bgB
+
+local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("FuBar")
+
+local _G = _G
+
+FuBar_Panel = {}
+local FuBar_Panel = FuBar_Panel
+local FuBar_Panel_id = 0
+local FuBar_Panel_instances = {}
+FuBar_Panel.instances = FuBar_Panel_instances
+
+function FuBar_Panel:OnJostleLoad(instance)
+ Jostle = instance
+ for i,v in ipairs(FuBar_Panel_instances) do
+ if v.data.attachPoint == 'TOP' then
+ Jostle:RegisterTop(v.frame)
+ elseif self.data.attachPoint == 'BOTTOM' then
+ Jostle:RegisterBottom(v.frame)
+ end
+ end
+ Jostle:Refresh()
+end
+
+local FuBar_Panel_mt = {__index=FuBar_Panel}
+function FuBar_Panel:new(...)
+ local t = setmetatable({}, FuBar_Panel_mt)
+ t:init(...)
+ return t
+end
+
+function FuBar_Panel:SetBackground(bg)
+ if bgFile ~= bg then
+ bgFile = bg
+ bgR, bgG, bgB = nil, nil, nil
+ for _,v in ipairs(FuBar_Panel_instances) do
+ v:UpdateTexture()
+ end
+ end
+end
+
+function FuBar_Panel:SetBackgroundColor(r,g,b)
+ if bgR ~= r or bgG ~= g or bgB ~= b then
+ bgFile = nil
+ bgR, bgG, bgB = r, g, b
+ for _,v in ipairs(FuBar_Panel_instances) do
+ v:UpdateTexture()
+ end
+ end
+end
+
+function FuBar_Panel:IsBackground(bg)
+ return bgFile == bg
+end
+
+function FuBar_Panel:GetBackgroundColor()
+ return bgR, bgG, bgB
+end
+
+local frame_OnMouseUp = function(this, arg1)
+ if arg1 == "RightButton" then
+ this.panel:OpenMenu()
+ elseif arg1 == "LeftButton" then
+ this.panel:StopDrag()
+ HideDropDownMenu(1)
+ end
+end
+local frame_OnMouseDown = function(this, arg1)
+ if arg1 == "LeftButton" then
+ this.panel:StartDrag()
+ end
+end
+local frame_OnDragStart = function(this)
+ this.panel:StartDrag()
+end
+local frame_OnDragStop = function(this)
+ this.panel:StopDrag()
+end
+local frame_OnEnter = function(this)
+ FuBar:Panel_OnEnter(this.panel:GetAttachPoint())
+end
+local frame_OnLeave = function(this)
+ FuBar:Panel_OnLeave(this.panel:GetAttachPoint())
+end
+local frame_OnSizeChanged = function(this)
+ local panel = this.panel
+ if this.lastWidth == GetScreenWidth() then
+ panel.data.widthPercent = panel.frame:GetWidth() / GetScreenWidth()
+ else
+ this.lastWidth = GetScreenWidth()
+ end
+ panel:UpdateCenteredPosition()
+ panel:UpdateTexture()
+end
+local left_OnEnter = function(this)
+ if not this.panel:IsLocked() then
+ SetCursor("ATTACK_ERROR_CURSOR")
+ end
+end
+local left_OnLeave = ResetCursor
+local right_OnEnter = left_OnEnter
+local right_OnLeave = left_OnLeave
+local left_OnMouseDown = function(this, arg1)
+ if arg1 == "LeftButton" then
+ this.panel:StartSizing('LEFT')
+ end
+end
+local left_OnMouseUp = function(this, arg1)
+ if arg1 == "RightButton" then
+ this.panel:OpenMenu()
+ elseif arg1 == "LeftButton" then
+ this.panel:StopDrag()
+ end
+end
+local right_OnMouseDown = function(this, arg1)
+ if arg1 == "LeftButton" then
+ this.panel:StartSizing('RIGHT')
+ end
+end
+local right_OnMouseUp = left_OnMouseUp
+
+local backdropsPerPanel = ceil(GetScreenWidth() / 256)
+
+local topTexture
+local bottomTexture
+
+function FuBar_Panel:init(attachPoint)
+ FuBar_Panel_id = FuBar_Panel_id + 1
+
+ if type(FuBar.db.profile.panels) ~= "table" then
+ FuBar.db.profile.panels = {}
+ end
+ if type(FuBar.db.profile.panels[FuBar_Panel_id]) ~= "table" then
+ table.insert(FuBar.db.profile.panels, {})
+ end
+ if type(FuBar.db.profile.detached) ~= "table" then
+ FuBar.db.profile.detached = {}
+ end
+
+ self.data = FuBar.db.profile.panels[FuBar_Panel_id]
+ if not self.data then
+ FuBar.db.profile.panels[FuBar_Panel_id] = {}
+ self.data = FuBar.db.profile.panels[FuBar_Panel_id]
+ end
+ self.id = FuBar_Panel_id
+ self.plugins = {
+ left = {},
+ center = {},
+ right = {},
+ }
+
+ self.frame = _G["FuBarFrame" .. self.id]
+ if not self.frame then
+ local frame = CreateFrame("Frame", "FuBarFrame" .. self.id, UIParent)
+ self.frame = frame
+
+ if not topTexture then
+ topTexture = frame:CreateTexture("FuBarFrameTopTexture", "ARTWORK")
+ bottomTexture = frame:CreateTexture("FuBarFrameBottomTexture", "ARTWORK")
+ topTexture:SetTexture(1, 1, 1)
+ topTexture:SetGradient("VERTICAL", CreateColor(1, 1, 1, 0), CreateColor(1, 1, 1, 0.5 * FuBar:GetTransparency()))
+ bottomTexture:SetTexture(1, 1, 1)
+ bottomTexture:SetGradient("VERTICAL", CreateColor(1, 1, 1, 0.5 * FuBar:GetTransparency()), CreateColor(1, 1, 1, 0))
+ topTexture:Hide()
+ bottomTexture:Hide()
+ end
+
+ frame:SetFrameStrata("BACKGROUND")
+ frame:SetFrameLevel(6)
+ frame:EnableMouse(true)
+ frame:SetMovable(true)
+ frame:SetResizable(true)
+ frame:SetWidth(500)
+ frame:SetHeight(24)
+ frame:SetPoint('TOP', UIParent, 'TOP')
+ local left = CreateFrame("Frame", frame:GetName() .. 'LEFT', frame)
+ left:SetPoint('TOPLEFT', frame, 'TOPLEFT')
+ left:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMLEFT', 5, 0)
+ left:EnableMouse(true)
+ left:Show()
+ local right = CreateFrame("Frame", frame:GetName() .. 'RIGHT', frame)
+ right:SetPoint('TOPRIGHT', frame, 'TOPRIGHT')
+ right:SetPoint('BOTTOMLEFT', frame, 'BOTTOMRIGHT', -5, 0)
+ right:EnableMouse(true)
+ right:Show()
+ frame.left = left
+ frame.right = right
+ frame.lastWidth = GetScreenWidth()
+ frame:SetScript("OnMouseUp", frame_OnMouseUp)
+ frame:SetScript("OnMouseDown", frame_OnMouseDown)
+ frame:SetScript("OnDragStart", frame_OnDragStart)
+ frame:SetScript("OnDragStop", frame_OnDragStop)
+ frame:SetScript("OnEnter", frame_OnEnter)
+ frame:SetScript("OnLeave", frame_OnLeave)
+ frame:SetScript("OnSizeChanged", frame_OnSizeChanged)
+ left:SetScript("OnEnter", left_OnEnter)
+ left:SetScript("OnLeave", left_OnLeave)
+ right:SetScript("OnEnter", right_OnEnter)
+ right:SetScript("OnLeave", right_OnLeave)
+ left:SetScript("OnMouseDown", left_OnMouseDown)
+ left:SetScript("OnMouseUp", left_OnMouseUp)
+ right:SetScript("OnMouseDown", right_OnMouseDown)
+ right:SetScript("OnMouseUp", right_OnMouseUp)
+
+ frame.bgTextures = {}
+ local lastTexture
+ for i = 1, backdropsPerPanel do
+ local texture = frame:CreateTexture(frame:GetName() .. "Texture" .. i, "BACKGROUND")
+ texture:SetWidth(256)
+ texture:SetHeight(256)
+ if not lastTexture then
+ texture:SetPoint('TOPLEFT', frame, 'TOPLEFT')
+ else
+ texture:SetPoint('LEFT', lastTexture, 'RIGHT')
+ end
+ if bgFile then
+ texture:SetTexture(bgFile)
+ else
+ texture:SetTexture(bgR, bgG, bgB)
+ end
+ table.insert(frame.bgTextures, texture)
+ lastTexture = texture
+ end
+ end
+
+ self.bgTextures = self.frame.bgTextures
+ self.frame.panel = self
+ self.frame.left.panel = self
+ self.frame.right.panel = self
+
+ if not FuBar_Panel_instances[self.id] then
+ table.insert(FuBar_Panel_instances, self)
+ else
+ FuBar_Panel_instances[self.id] = self
+ end
+
+ if not self.data.attachPoint then
+ self.data.attachPoint = attachPoint or 'TOP'
+ end
+
+ if not self.data.plugins then
+ self.data.plugins = {
+ left = {},
+ right = {},
+ center = {},
+ }
+ end
+
+ if not self.frame:IsShown() then
+ self.frame:Show()
+ end
+
+ self.stopUpdates = nil
+
+ for _,v in ipairs(FuBar_Panel_instances) do
+ v:Update()
+ v:UpdateTexture()
+ end
+ if self.data.attachPoint == 'TOP' then
+ if Jostle then
+ Jostle:RegisterTop(self.frame)
+ end
+ self.frame:SetFrameStrata("BACKGROUND")
+ self.frame:SetFrameLevel(6)
+ elseif self.data.attachPoint == 'BOTTOM' then
+ if Jostle then
+ Jostle:RegisterBottom(self.frame)
+ end
+ self.frame:SetFrameStrata("BACKGROUND")
+ self.frame:SetFrameLevel(6)
+ else
+ self.frame:SetFrameStrata("BACKGROUND")
+ self.frame:SetFrameLevel(1)
+ end
+ FuBar:DispatchEvent("ChangedPanels")
+ local AceEvent = Rock("AceEvent-2.0", true, true)
+ if AceEvent then
+ AceEvent:TriggerEvent("FuBar_ChangedPanels")
+ end
+ if Jostle then
+ Jostle:Refresh()
+ end
+end
+
+function FuBar_Panel:del(force)
+ assert(force or FuBar_Panel_id > 1, "Cannot destroy only panel.")
+
+ if topTexture.attachedTo == self then
+ topTexture:ClearAllPoints()
+ topTexture:Hide()
+ topTexture.attachedTo = nil
+ end
+ if bottomTexture.attachedTo == self then
+ bottomTexture:ClearAllPoints()
+ bottomTexture:Hide()
+ bottomTexture.attachedTo = nil
+ end
+
+ for h = 1, 3 do
+ local t, position
+ if h == 1 then
+ t = self.plugins.left
+ position = 'LEFT'
+ elseif h == 2 then
+ t = self.plugins.center
+ position = 'CENTER'
+ else
+ t = self.plugins.right
+ position = 'RIGHT'
+ end
+ for i = #t, 1, -1 do
+ local plugin = t[i]
+ self:RemovePlugin(i, position)
+ plugin:Hide()
+ end
+ end
+
+ for i = self.id + 1, FuBar_Panel_id do
+ if FuBar_Panel_instances[i]:GetAttachPoint() == self.data.attachPoint then
+ self:SwitchWithPanel(i)
+ end
+ end
+
+ if Jostle then
+ Jostle:Unregister(self.frame)
+ end
+ if not force then
+ self:SetAttachPoint('NONE')
+ end
+ self.frame:Hide()
+
+ if not force then
+ table.remove(FuBar.db.profile.panels, self.id)
+ end
+ self.data = nil
+ self.plugins = nil
+ table.remove(FuBar_Panel_instances, self.id)
+
+ FuBar_Panel_id = FuBar_Panel_id - 1
+ FuBar:DispatchEvent("ChangedPanels")
+ local AceEvent = Rock("AceEvent-2.0", true, true)
+ if AceEvent then
+ AceEvent:TriggerEvent("FuBar_ChangedPanels")
+ end
+ for i = 1, FuBar_Panel_id do
+ local panel = FuBar_Panel_instances[i]
+ panel.id = i
+ panel:UpdateTexture()
+ panel:Update()
+ end
+
+ if Jostle then
+ Jostle:Refresh()
+ end
+end
+
+function FuBar_Panel:WarnDestroy()
+ if self:GetNumPlugins('LEFT') + self:GetNumPlugins('CENTER') + self:GetNumPlugins('RIGHT') == 0 then
+ self:del()
+ else
+ if not StaticPopupDialogs["FUBAR_DESTROY_PANEL"] then
+ StaticPopupDialogs["FUBAR_DESTROY_PANEL"] = {
+ text = L["Are you sure you want to remove this panel?"],
+ button1 = L["Remove panel"],
+ button2 = CANCEL,
+ timeout = 0,
+ whileDead = 1,
+ hideOnEscape = 1,
+ }
+ end
+ StaticPopupDialogs["FUBAR_DESTROY_PANEL"].OnAccept = function()
+ self:del()
+ end
+ StaticPopup_Show("FUBAR_DESTROY_PANEL")
+ end
+end
+
+function FuBar_Panel:SwitchWithPanel(id, preventUpdate)
+ local other = FuBar_Panel_instances[id]
+ if not other or self.data.attachPoint ~= other.data.attachPoint then
+ return
+ end
+ other.id, self.id = self.id, other.id
+ other.frame, self.frame = self.frame, other.frame
+ self.frame.panel = self
+ other.frame.panel = other
+ self.frame.left.panel = self
+ other.frame.right.panel = other
+ FuBar_Panel_instances[other.id] = other
+ FuBar_Panel_instances[self.id] = self
+ FuBar.db.profile.panels[other.id], FuBar.db.profile.panels[self.id] = FuBar.db.profile.panels[self.id], FuBar.db.profile.panels[other.id]
+ self.bgTextures, other.bgTextures = other.bgTextures, self.bgTextures
+ if not preventUpdate then
+ other:Update()
+ self:Update()
+ end
+ for i = 1, FuBar_Panel_id do
+ FuBar_Panel_instances[i]:UpdateTexture()
+ end
+ FuBar:DispatchEvent("ChangedPanels")
+ local AceEvent = Rock("AceEvent-2.0", true, true)
+ if AceEvent then
+ AceEvent:TriggerEvent("FuBar_ChangedPanels")
+ end
+ if Jostle then
+ Jostle:Refresh()
+ end
+end
+
+function FuBar_Panel:GetAttachPoint()
+ if not self.data then
+ ReloadUI()
+ return
+ end
+ return self.data.attachPoint
+end
+
+function FuBar_Panel:SetAttachPoint(point)
+ if self.data.attachPoint == point then
+ return
+ end
+ if Jostle then
+ Jostle:Unregister(self.frame)
+ end
+ if point == 'NONE' then
+ self.data.yPercent = 0.5 - (FuBarFrame1:GetHeight()/2 / GetScreenHeight())
+ self.frame:SetFrameStrata("BACKGROUND")
+ self.frame:SetFrameLevel(1)
+ elseif point == 'TOP' or point == 'BOTTOM' then
+ self.data.yPercent = nil
+ self.frame:SetFrameStrata("BACKGROUND")
+ self.frame:SetFrameLevel(6)
+ else
+ assert(false, "Improper attach point given: " .. point)
+ end
+
+ local previous = self.data.attachPoint
+ self.data.attachPoint = point
+ for i = self.id, FuBar_Panel_id do
+ local panel = FuBar_Panel_instances[i]
+ if previous == panel:GetAttachPoint() or point == panel:GetAttachPoint() then
+ panel:Update()
+ end
+ end
+ self:Update()
+
+ if Jostle then
+ Jostle:Refresh()
+ end
+
+ if self:IsLocked() then
+ self:ToggleLocked()
+ end
+
+ if Jostle then
+ if self.data.attachPoint == 'TOP' then
+ Jostle:RegisterTop(self.frame)
+ elseif self.data.attachPoint == 'BOTTOM' then
+ Jostle:RegisterBottom(self.frame)
+ end
+ end
+
+ for i = 1, FuBar_Panel_id do
+ FuBar_Panel_instances[i]:UpdateTexture()
+ end
+
+ FuBar:DispatchEvent("ChangedPanels")
+ local AceEvent = Rock("AceEvent-2.0", true, true)
+ if AceEvent then
+ AceEvent:TriggerEvent("FuBar_ChangedPanels")
+ end
+ if Jostle then
+ Jostle:Refresh()
+ end
+
+ if FuBar:IsAutoHidingTop() then
+ FuBar:ToggleAutoHidingTop()
+ FuBar:ToggleAutoHidingTop()
+ end
+ if FuBar:IsAutoHidingBottom() then
+ FuBar:ToggleAutoHidingBottom()
+ FuBar:ToggleAutoHidingBottom()
+ end
+end
+
+function FuBar_Panel:IsLocked()
+ return self.data and self.data.lock
+end
+
+function FuBar_Panel:ToggleLocked()
+ if self.data then
+ self.data.lock = not self.data.lock
+ return self.data.lock
+ end
+end
+
+function FuBar_Panel:GetPositionFromEdge()
+ local num = 1
+ local set = 0
+ if self.data.attachPoint == 'TOP' then
+ for i = 1, FuBar_Panel_id do
+ local panel = FuBar_Panel_instances[i]
+ if panel == self then
+ set = num
+ num = num + 1
+ elseif panel and panel:GetAttachPoint() == 'TOP' then
+ num = num + 1
+ end
+ end
+ elseif self.data.attachPoint == 'BOTTOM' then
+ for i = 1, FuBar_Panel_id do
+ local panel = FuBar_Panel_instances[i]
+ if panel == self then
+ set = num
+ num = num + 1
+ elseif panel and panel:GetAttachPoint() == 'BOTTOM' then
+ num = num + 1
+ end
+ end
+ else
+ return
+ end
+ return num - set
+end
+
+function FuBar_Panel:UpdateTexture()
+ if topTexture.attachedTo == self then
+ topTexture:ClearAllPoints()
+ topTexture:Hide()
+ topTexture.attachedTo = nil
+ end
+ if bottomTexture.attachedTo == self then
+ bottomTexture:ClearAllPoints()
+ bottomTexture:Hide()
+ bottomTexture.attachedTo = nil
+ end
+ local point = self:GetAttachPoint()
+ local height = FuBar:GetFontSize() + FuBar:GetThickness()
+ self.frame:SetHeight(height)
+
+ local uiscale = 768 / GetScreenHeight()
+ local texsize = 256 / uiscale
+ local realLeft = self.frame:GetLeft() or 0
+ local left = mod(self.frame:GetLeft() or 0, texsize)
+ local width = self.frame:GetWidth() or 0
+ local fromEdge = self:GetPositionFromEdge()
+ if fromEdge and self.bgTextures then
+ local y1, y2
+ if self.data.attachPoint == 'TOP' then
+ y1, y2 = 1-((height) / texsize) * fromEdge, 1-(height / 256) * (fromEdge - 1)
+ else
+ y1, y2 = ((height + 2) / texsize) * (fromEdge - 1), ((height+2) / 256) * fromEdge
+ end
+ for i,texture in ipairs(self.bgTextures) do
+ if bgFile then
+ texture:SetTexture(bgFile)
+ else
+ texture:SetTexture(bgR, bgG, bgB)
+ end
+ local x = (i - 1) * texsize
+ local xr = i * texsize
+ texture:Show()
+ texture:SetHeight(height)
+ local x1, x2 = 0, 1
+ local changed = false
+ if i == 1 then
+ x1 = left / texsize
+ texture:SetWidth(texsize - left)
+ changed = true
+ end
+ if width + left < xr then
+ if i == 1 then
+ texture:SetWidth(width)
+ x2 = mod(width + left - x, texsize) / texsize
+ else
+ texture:SetWidth(mod(width + left - x, texsize))
+ x2 = mod(width + left - x, texsize) / texsize
+ end
+ elseif not changed then
+ texture:SetWidth(texsize)
+ end
+ texture:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', x + x1*texsize - left, 0)
+ texture:SetTexCoord(x1, x2, y1, y2)
+ texture:SetVertexColor(1, 1, 1, FuBar:GetTransparency())
+ end
+ elseif self.bgTextures then
+ local y1, y2 = 0.5 - height / texsize / 2, 0.5 + height / texsize / 2
+ for i,texture in ipairs(self.bgTextures) do
+ if bgFile then
+ texture:SetTexture(bgFile)
+ else
+ texture:SetTexture(bgR, bgG, bgB)
+ end
+ local x = (i - 1) * texsize
+ local xr = i * texsize
+ texture:Show()
+ texture:SetHeight(height)
+ local changed = false
+ local x1, x2 = 0, 1
+ if width < xr then
+ texture:SetWidth(mod(width - x, texsize))
+ x2 = mod(width - x, texsize) / texsize
+ else
+ texture:SetWidth(texsize)
+ end
+ texture:SetTexCoord(x1, x2, y1, y2)
+ texture:SetVertexColor(1, 1, 1, FuBar:GetTransparency())
+ end
+ end
+end
+
+function FuBar_Panel:AddPlugin(plugin, index, side, isDefaultSide)
+ if FuBar:IsChangingProfile() then
+ return
+ end
+ if side == "MINIMAP" then
+ side = "LEFT"
+ end
+ if plugin:GetPanel() then
+ plugin:GetPanel():RemovePlugin(plugin)
+ end
+ plugin:SetPanel(self)
+ if FuBar.db.profile.detached then
+ FuBar.db.profile.detached[plugin:GetTitle()] = nil
+ end
+ plugin:GetFrame():SetParent(self.frame)
+
+ if not FuBar.db.profile.places then
+ FuBar.db.profile.places = {}
+ end
+ if FuBar.db.profile.places.left and FuBar.db.profile.places.left[plugin:GetTitle()] then
+ FuBar.db.profile.places.left[plugin:GetTitle()] = nil
+ if not side or isDefaultSide then
+ side = 'LEFT'
+ end
+ end
+ if FuBar.db.profile.places.center and FuBar.db.profile.places.center[plugin:GetTitle()] then
+ FuBar.db.profile.places.center[plugin:GetTitle()] = nil
+ if not side or isDefaultSide then
+ side = 'CENTER'
+ end
+ end
+ if FuBar.db.profile.places.right and FuBar.db.profile.places.right[plugin:GetTitle()] then
+ FuBar.db.profile.places.right[plugin:GetTitle()] = nil
+ if not side or isDefaultSide then
+ side = 'RIGHT'
+ end
+ end
+ if not side then
+ side = 'LEFT'
+ end
+ local positioned = false
+ for h = 1, 3 do
+ local t, dt
+ if h == 1 then
+ t = self.plugins.left
+ dt = self.data.plugins.left
+ elseif h == 2 then
+ t = self.plugins.center
+ dt = self.data.plugins.center
+ else
+ t = self.plugins.right
+ dt = self.data.plugins.right
+ end
+ for i, value in ipairs(dt) do
+ if value == plugin:GetTitle() then
+ for j = i - 1, 1, -1 do
+ local otherName = dt[j]
+ for k, p in ipairs(t) do
+ if p:GetTitle() == otherName then
+ table.insert(t, k + 1, plugin)
+ positioned = true
+ break
+ end
+ end
+ if positioned then
+ break
+ end
+ end
+ if not positioned then
+ table.insert(t, 1, plugin)
+ positioned = true
+ end
+ break
+ end
+ end
+ if positioned then
+ break
+ end
+ end
+
+ if not positioned then
+ local title = plugin:GetTitle()
+ local t, dt
+ if side == 'RIGHT' then
+ t, dt = self.plugins.right, self.data.plugins.right
+ elseif side == 'CENTER' then
+ t, dt = self.plugins.center, self.data.plugins.center
+ else
+ t, dt = self.plugins.left, self.data.plugins.left
+ end
+ if not index then
+ table.insert(t, plugin)
+ table.insert(dt, title)
+ else
+ if index == 1 then
+ table.insert(t, index, plugin)
+ table.insert(dt, 1, title)
+ else
+ table.insert(t, index, plugin)
+ local name = t[index - 1]:GetTitle()
+ local done = false
+ for k, v in ipairs(dt) do
+ if name == v then
+ table.insert(dt, k + 1, title)
+ done = true
+ break
+ end
+ end
+ if not done then
+ table.insert(dt, title)
+ end
+ end
+ end
+ end
+ plugin:GetFrame():Show()
+ if plugin.minimapFrame then
+ plugin.minimapFrame:Hide()
+ end
+ if not positioned then
+ assert(self:GetPluginSide(plugin) == side, ("Assertion failed: %q == %q"):format(self:GetPluginSide(plugin), side))
+ end
+ self:Update()
+ Rock("LibRockConfig-1.0"):RefreshConfigMenu(FuBar)
+ return true
+end
+
+function FuBar_Panel:RemovePlugin(index, side)
+ if FuBar:IsChangingProfile() then
+ return
+ end
+ if type(index) == "table" then
+ index, side = self:IndexOfPlugin(index)
+ if not index then
+ return
+ end
+ end
+
+ local t, dt
+ if not FuBar.db.profile.places then
+ FuBar.db.profile.places = {}
+ end
+ if side == 'RIGHT' then
+ if not FuBar.db.profile.places.right then
+ FuBar.db.profile.places.right = {}
+ end
+ t, dt = self.plugins.right, self.data.plugins.right
+ FuBar.db.profile.places.right[t[index]:GetTitle()] = true
+ elseif side == 'CENTER' then
+ if not FuBar.db.profile.places.center then
+ FuBar.db.profile.places.center = {}
+ end
+ t, dt = self.plugins.center, self.data.plugins.center
+ FuBar.db.profile.places.center[t[index]:GetTitle()] = true
+ else
+ if not FuBar.db.profile.places.left then
+ FuBar.db.profile.places.left = {}
+ end
+ t, dt = self.plugins.left, self.data.plugins.left
+ FuBar.db.profile.places.left[t[index]:GetTitle()] = true
+ end
+
+ local plugin = t[index]
+ assert(plugin:GetPanel() == self, "Plugin has improper panel field")
+ plugin:SetPanel(nil)
+ if not self.stopUpdates then
+ plugin:GetFrame():Hide()
+ if plugin.minimapFrame then
+ plugin.minimapFrame:Hide()
+ end
+ end
+ for i = 1, #dt do
+ if dt[i] == plugin:GetTitle() then
+ table.remove(dt, i)
+ end
+ end
+ table.remove(t, index)
+ FuBar.db.profile.detached[plugin:GetTitle()] = true
+ self:Update()
+ Rock("LibRockConfig-1.0"):RefreshConfigMenu(FuBar)
+end
+
+function FuBar_Panel:GetPlugin(index, side)
+ if not self.plugins then
+ ReloadUI()
+ return
+ end
+ if side == 'RIGHT' then
+ return self.plugins.right[index]
+ elseif side == 'CENTER' then
+ return self.plugins.center[index]
+ else
+ return self.plugins.left[index]
+ end
+end
+
+function FuBar_Panel:GetNumPlugins(side)
+ if side == 'RIGHT' then
+ return #self.plugins.right
+ elseif side == 'CENTER' then
+ return #self.plugins.center
+ else
+ return #self.plugins.left
+ end
+end
+
+function FuBar_Panel:IndexOfPlugin(plugin)
+ for i = 1, self:GetNumPlugins('LEFT') do
+ if self.plugins.left[i] == plugin then
+ return i, 'LEFT'
+ end
+ end
+ for i = 1, self:GetNumPlugins('CENTER') do
+ if self.plugins.center[i] == plugin then
+ return i, 'CENTER'
+ end
+ end
+ for i = 1, self:GetNumPlugins('RIGHT') do
+ if self.plugins.right[i] == plugin then
+ return i, 'RIGHT'
+ end
+ end
+end
+
+function FuBar_Panel:HasPlugin(plugin)
+ return self:IndexOfPlugin(plugin) ~= nil
+end
+
+function FuBar_Panel:GetPluginSide(plugin)
+ local index, side = self:IndexOfPlugin(plugin)
+ assert(index, "Plugin not in panel")
+ return side
+end
+
+function FuBar_Panel:SetPluginSide(plugin, side)
+ local oldSide = self:GetPluginSide(plugin)
+ if oldSide ~= side then
+ self:RemovePlugin(plugin)
+ self:AddPlugin(plugin, nil, side)
+ self:Update()
+ end
+end
+
+function FuBar_Panel:PreventUpdate()
+ self.stopUpdates = true
+end
+
+function FuBar_Panel:StopPreventUpdate(code)
+ self.stopUpdates = false
+end
+
+function FuBar_Panel:Update()
+ if self.stopUpdates then
+ return
+ end
+ if not self.data.widthPercent or self.data.widthPercent > 1 then
+ self.data.widthPercent = 1
+ end
+ local width = self.data.widthPercent * GetScreenWidth()
+ self.frame:SetWidth(width)
+
+ if not self.data.xPercent or not self.data.yPercent then
+ self.data.xPercent = 0.5 - self.data.widthPercent / 2
+ self.data.yPercent = 0.5
+ end
+ if self:GetAttachPoint() == 'TOP' then
+ self.frame:ClearAllPoints()
+ local hasTop = nil
+ for i = self.id - 1, 1, -1 do
+ if FuBar_Panel_instances[i] and FuBar_Panel_instances[i]:GetAttachPoint() == 'TOP' then
+ hasTop = FuBar_Panel_instances[i]
+ break
+ end
+ end
+
+ if not hasTop then
+ self.frame:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', self.data.xPercent * GetScreenWidth(), 1)
+ else
+ self.frame:SetPoint('TOPLEFT', hasTop.frame, 'BOTTOMLEFT', self.data.xPercent * GetScreenWidth() - (hasTop.frame:GetLeft() or 0), 0)
+ end
+ elseif self:GetAttachPoint(panelId) == 'BOTTOM' then
+ self.frame:ClearAllPoints()
+ local hasBottom = nil
+ for i = self.id - 1, 1, -1 do
+ if FuBar_Panel_instances[i] and FuBar_Panel_instances[i]:GetAttachPoint() == 'BOTTOM' then
+ hasBottom = FuBar_Panel_instances[i]
+ break
+ end
+ end
+ if not hasBottom then
+ self.frame:SetPoint('BOTTOMLEFT', UIParent, 'BOTTOMLEFT', self.data.xPercent * GetScreenWidth(), -1)
+ else
+ self.frame:SetPoint('BOTTOMLEFT', hasBottom.frame, 'TOPLEFT', self.data.xPercent * GetScreenWidth() - hasBottom.frame:GetLeft(), 0)
+ end
+ else
+ self.frame:ClearAllPoints()
+ self.frame:SetPoint('BOTTOMLEFT', UIParent, 'BOTTOMLEFT', self.data.xPercent * GetScreenWidth(), self.data.yPercent * GetScreenHeight())
+ end
+
+ local num = 0
+
+ for h = 1, 3 do
+ local t, side
+ if h == 1 then
+ t = self.plugins.left
+ side = 'LEFT'
+ elseif h == 2 then
+ t = self.plugins.center
+ side = 'CENTER'
+ else
+ t = self.plugins.right
+ side = 'RIGHT'
+ end
+ local i = 1
+ while i <= self:GetNumPlugins(side) do
+ assert(t[i], "nil plugin spot")
+ if type(t[i].IsDisabled) == "function" and t[i]:IsDisabled() then
+ self:RemovePlugin(i, side)
+ i = i - 1
+ end
+ i = i + 1
+ end
+ end
+
+ for h = 1, 3 do
+ local t, side
+ if h == 1 then
+ t = self.plugins.left
+ side = 'LEFT'
+ elseif h == 2 then
+ t = self.plugins.center
+ side = 'CENTER'
+ else
+ t = self.plugins.right
+ side = 'RIGHT'
+ end
+ for i = 1, self:GetNumPlugins(side) do
+ t[i]:CheckWidth()
+ t[i]:GetFrame():SetParent(self.frame)
+ t[i]:GetFrame():ClearAllPoints()
+ end
+ end
+
+ for h = 1, 3 do
+ local t, side, alpha, bravo, sideSpacing, spacing
+ if h == 1 then
+ t = self.plugins.left
+ side = 'LEFT'
+ alpha, bravo = 'LEFT', 'RIGHT'
+ sideSpacing = SPACING_FROM_SIDES
+ spacing = FuBar:GetLeftSpacing()
+ elseif h == 2 then
+ t = self.plugins.center
+ side = 'CENTER'
+ alpha, bravo = 'LEFT', 'RIGHT'
+ sideSpacing = SPACING_FROM_SIDES
+ spacing = FuBar:GetCenterSpacing()
+ else
+ t = self.plugins.right
+ side = 'RIGHT'
+ alpha, bravo = 'RIGHT', 'LEFT'
+ sideSpacing = -SPACING_FROM_SIDES
+ spacing = -FuBar:GetRightSpacing()
+ end
+ for i = 1, self:GetNumPlugins(side) do
+ t[i]:GetFrame():Show()
+ if i == 1 then
+ t[i]:GetFrame():SetPoint(alpha, self.frame, alpha, sideSpacing, 0)
+ else
+ if t[i]:GetFrame() == t[i-1]:GetFrame() then
+ t[i]:GetFrame():SetPoint(alpha, self.frame, bravo, spacing, 0)
+ else
+ t[i]:GetFrame():SetPoint(alpha, t[i-1]:GetFrame(), bravo, spacing, 0)
+ end
+ end
+ end
+ end
+
+ self:UpdateCenteredPosition()
+ self:CheckForOverlap()
+end
+
+function FuBar_Panel:UpdateCenteredPosition()
+ if self:GetPlugin(1, 'CENTER') then
+ local num = self:GetNumPlugins('CENTER')
+ local width = num * FuBar:GetCenterSpacing()
+ for i = 1, num do
+ width = width + self.plugins.center[i]:GetFrame():GetWidth()
+ end
+
+ local frame = self:GetPlugin(1, 'CENTER'):GetFrame()
+ frame:ClearAllPoints()
+ frame:SetPoint('LEFT', self.frame, 'LEFT', (self.data.widthPercent * GetScreenWidth() - width) / 2, 0)
+ end
+end
+
+function FuBar_Panel:GetSavedOrder(side)
+ local key
+ if side == 'RIGHT' then
+ key = "right"
+ elseif side == 'CENTER' then
+ key = "center"
+ else
+ key = "left"
+ end
+ if not self.data.plugins[key] then
+ self.data.plugins[key] = {}
+ end
+ return self.data.plugins[key]
+end
+
+function FuBar_Panel:ResetSavedOrder(side)
+ local t
+ if side == 'RIGHT' then
+ t = self.data.plugins.right
+ elseif side == 'CENTER' then
+ t = self.data.plugins.center
+ else
+ t = self.data.plugins.left
+ end
+ for key in pairs(t) do
+ t[key] = nil
+ end
+end
+
+function FuBar_Panel:OpenMenu()
+ FuBar:OpenConfigMenu("bar" .. self.id)
+end
+
+local closePanel
+function FuBar_Panel:StartSizing(direction)
+ DropDownList1:Hide()
+ if not self:IsLocked() then
+ local x, y = FuBar:GetScaledCursorPosition()
+ local left, right = self.frame:GetLeft(), self.frame:GetRight()
+ if self:GetAttachPoint() ~= 'NONE' then
+ self.lastWidth = self.frame:GetWidth()
+ end
+ self.frame:StartSizing(direction)
+ self.sizeFrom = direction
+ closePanel = nil
+ for i = self.id + 1, FuBar_Panel_id do
+ local panel = FuBar_Panel_instances[i]
+ if panel:GetAttachPoint() == self:GetAttachPoint() then
+ closePanel = panel
+ local x, y = closePanel.frame:GetLeft(), closePanel.frame:GetBottom()
+ closePanel.frame:ClearAllPoints()
+ closePanel.frame:SetPoint('BOTTOMLEFT', UIParent, 'BOTTOMLEFT', x, y)
+ break
+ end
+ end
+ end
+end
+
+local lastX, lastY
+
+function FuBar_Panel:StartDrag()
+ if not self:IsLocked() and self:GetAttachPoint() == 'NONE' then
+ self.frame:StartMoving()
+ elseif not self:IsLocked() then
+ self.frame:StartMoving()
+ closePanel = nil
+ for i = self.id + 1, FuBar_Panel_id do
+ local panel = FuBar_Panel_instances[i]
+ if panel and panel:GetAttachPoint() == self:GetAttachPoint() then
+ closePanel = panel
+ local x, y = closePanel.frame:GetLeft(), closePanel.frame:GetBottom()
+ closePanel.frame:ClearAllPoints()
+ closePanel.frame:SetPoint('BOTTOMLEFT', UIParent, 'BOTTOMLEFT', x, y)
+ break
+ end
+ end
+ lastX, lastY = self.frame:GetCenter()
+ end
+end
+
+function FuBar_Panel:StopDrag()
+ self.frame:StopMovingOrSizing()
+ local x, y = self.frame:GetCenter()
+ local offsetX = 0
+ if self.frame:GetWidth() < 50 then
+ if self.sizeFrom == 'LEFT' then
+ offsetX = self.frame:GetWidth() - 50
+ end
+ self.frame:SetWidth(50)
+ elseif self.frame:GetWidth() > GetScreenWidth() then
+ if self.sizeFrom == 'RIGHT' then
+ offsetX = self.frame:GetWidth() - self.frame:GetRight()
+ else
+ offsetX = -self.frame:GetLeft()
+ end
+ self.frame:SetWidth(GetScreenWidth())
+ end
+ self.sizeFrom = nil
+ self.data.xPercent = (self.frame:GetLeft() + offsetX) / GetScreenWidth()
+ self.data.yPercent = self.frame:GetBottom() / GetScreenHeight()
+ self.data.widthPercent = self.frame:GetWidth() / GetScreenWidth()
+ if self.data.xPercent < 0 then
+ self.data.xPercent = 0
+ elseif self.data.xPercent + self.data.widthPercent > 1 then
+ self.data.xPercent = 1 - self.data.widthPercent
+ end
+ self:Update()
+ if closePanel then
+ closePanel:Update()
+ closePanel = nil
+ end
+ if lastY then
+ if self:GetAttachPoint() == 'TOP' then
+ if y < GetScreenHeight() / 2 then
+ self:SetAttachPoint('BOTTOM')
+ end
+ else
+ if y > GetScreenHeight() /2 then
+ self:SetAttachPoint('TOP')
+ end
+ end
+ if self:GetAttachPoint() == 'TOP' then
+ local position = 0
+ for i = 1, FuBar_Panel_id do
+ if i ~= self.id then
+ local other = FuBar_Panel_instances[i]
+ if other:GetAttachPoint() == 'TOP' then
+ if y <= select(2, other.frame:GetCenter()) then
+ position = i
+ end
+ end
+ else
+ if y <= lastY then
+ position = i
+ end
+ end
+ end
+ lastY = nil
+ if position < self.id then
+ position = position + 1
+ end
+ local shift = position - self.id
+ local num = 0
+ if shift < 0 then
+ for i = 1, -shift do
+ num = num + 1
+ if FuBar_Panel_instances[self.id - num]:GetAttachPoint() == 'TOP' then
+ self:SwitchWithPanel(self.id - num)
+ num = 0
+ end
+ end
+ elseif shift > 0 then
+ for i = 1, shift do
+ num = num + 1
+ if FuBar_Panel_instances[self.id + num]:GetAttachPoint() == 'TOP' then
+ self:SwitchWithPanel(self.id + num)
+ num = 0
+ end
+ end
+ end
+ elseif self:GetAttachPoint() == 'BOTTOM' then
+ local position = 0
+ for i = 1, FuBar_Panel_id do
+ if i ~= self.id then
+ local other = FuBar_Panel_instances[i]
+ if other:GetAttachPoint() == 'BOTTOM' then
+ if y >= select(2, other.frame:GetCenter()) then
+ position = i
+ end
+ end
+ else
+ if y >= lastY then
+ position = i
+ end
+ end
+ end
+ lastY = nil
+ if position < self.id then
+ position = position + 1
+ end
+ local shift = position - self.id
+ local num = 0
+ if shift < 0 then
+ for i = 1, -shift do
+ num = num + 1
+ if FuBar_Panel_instances[self.id - num]:GetAttachPoint() == 'BOTTOM' then
+ self:SwitchWithPanel(self.id - num)
+ num = 0
+ end
+ end
+ elseif shift > 0 then
+ for i = 1, shift do
+ num = num + 1
+ if FuBar_Panel_instances[self.id + num]:GetAttachPoint() == 'BOTTOM' then
+ self:SwitchWithPanel(self.id + num)
+ num = 0
+ end
+ end
+ end
+ end
+ end
+ self:UpdateTexture()
+end
+
+function FuBar_Panel:HasOverlap()
+ local leftNum, centerNum, rightNum = self:GetNumPlugins('LEFT'), self:GetNumPlugins('CENTER'), self:GetNumPlugins('RIGHT')
+ local left = self:GetPlugin(leftNum, 'LEFT')
+ local right = self:GetPlugin(rightNum, 'RIGHT')
+ local centerLeft = self:GetPlugin(1, 'CENTER')
+ local centerRight = self:GetPlugin(centerNum, 'CENTER')
+
+ if centerLeft then
+ if left and left.frame:GetRight() and centerLeft.frame:GetLeft() then
+ if left and left.frame:GetRight() >= centerLeft.frame:GetLeft() - 5 then
+ return true
+ end
+ end
+ return right and right.frame:GetLeft() and centerRight.frame:GetRight() and right.frame:GetLeft() <= centerRight.frame:GetRight() + 5
+ elseif left and right then
+ if left.frame:GetRight() and right.frame:GetLeft() then
+ return left.frame:GetRight() >= right.frame:GetLeft() - 5
+ end
+ elseif left then
+ if left.frame:GetRight() and self.frame:GetRight() then
+ return left.frame:GetRight() > self.frame:GetRight() - 5
+ end
+ elseif right then
+ if right.frame:GetLeft() and self.frame:GetLeft() then
+ return right.frame:GetLeft() < self.frame:GetLeft() + 5
+ end
+ end
+
+ return false
+end
+
+local loadTime = GetTime() + 8
+function FuBar_Panel:CheckForOverlap()
+ if loadTime > GetTime() then
+ if not self.overlapTimer then
+ self.overlapTimer = true
+ FuBar:AddTimer("FuBar_Panel:CheckForOverlap", loadTime - GetTime(), self.CheckForOverlap, self)
+ end
+ return
+ end
+ self.overlapTimer = nil
+ if FuBar:IsOverflowing() and self:HasOverlap() then
+ local side = 'CENTER'
+ local plugin = self:GetPlugin(self:GetNumPlugins(side), side)
+ if not plugin then
+ side = 'LEFT'
+ plugin = self:GetPlugin(self:GetNumPlugins(side), side)
+ if not plugin then
+ side = 'RIGHT'
+ plugin = self:GetPlugin(self:GetNumPlugins(side), side)
+ end
+ end
+ local panel
+ for i = self.id + 1, FuBar_Panel_id do
+ if FuBar_Panel_instances[i]:GetAttachPoint() == self:GetAttachPoint() then
+ panel = FuBar_Panel_instances[i]
+ end
+ end
+ if not panel then
+ panel = FuBar_Panel:new(self:GetAttachPoint())
+ end
+ FuBar_Panel:PreventUpdate()
+ self:RemovePlugin(plugin)
+ panel:AddPlugin(plugin, 1, side)
+ FuBar_Panel:StopPreventUpdate()
+ panel:Update()
+ self:Update()
+ end
+end
diff --git a/FuBar/LICENSE.txt b/FuBar/LICENSE.txt
new file mode 100644
index 0000000..4301cb1
--- /dev/null
+++ b/FuBar/LICENSE.txt
@@ -0,0 +1,2 @@
+
+All Rights Reserved unless otherwise explicitly stated.
\ No newline at end of file
diff --git a/FuBar/background.tga b/FuBar/background.tga
new file mode 100644
index 0000000..107bfca
Binary files /dev/null and b/FuBar/background.tga differ
diff --git a/FuBar/libs/AceLibrary/AceLibrary.lua b/FuBar/libs/AceLibrary/AceLibrary.lua
new file mode 100644
index 0000000..961cc68
--- /dev/null
+++ b/FuBar/libs/AceLibrary/AceLibrary.lua
@@ -0,0 +1,802 @@
+--[[
+Name: AceLibrary
+Revision: $Rev: 1091 $
+Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team)
+Inspired By: Iriel (iriel@vigilance-committee.org)
+ Tekkub (tekkub@gmail.com)
+ Revision: $Rev: 1091 $
+Website: http://www.wowace.com/
+Documentation: http://www.wowace.com/index.php/AceLibrary
+SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceLibrary
+Description: Versioning library to handle other library instances, upgrading,
+ and proper access.
+ It also provides a base for libraries to work off of, providing
+ proper error tools. It is handy because all the errors occur in the
+ file that called it, not in the library file itself.
+Dependencies: None
+License: LGPL v2.1
+]]
+
+local ACELIBRARY_MAJOR = "AceLibrary"
+local ACELIBRARY_MINOR = 90000 + tonumber(("$Revision: 1091 $"):match("(%d+)"))
+
+local _G = _G
+local previous = _G[ACELIBRARY_MAJOR]
+if previous and not previous:IsNewVersion(ACELIBRARY_MAJOR, ACELIBRARY_MINOR) then return end
+
+do
+ -- 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
+end
+local LibStub = _G.LibStub
+
+-- If you don't want AceLibrary to enable libraries that are LoadOnDemand but
+-- disabled in the addon screen, set this to true.
+local DONT_ENABLE_LIBRARIES = nil
+
+local function safecall(func,...)
+ local success, err = pcall(func,...)
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("\n(.-: )in.-\n") or "") .. err) end
+end
+
+-- @table AceLibrary
+-- @brief System to handle all versioning of libraries.
+local AceLibrary = {}
+local AceLibrary_mt = {}
+setmetatable(AceLibrary, AceLibrary_mt)
+
+local function error(self, message, ...)
+ if type(self) ~= "table" then
+ return _G.error(("Bad argument #1 to `error' (table expected, got %s)"):format(type(self)), 2)
+ end
+
+ local stack = debugstack()
+ if not message then
+ local second = stack:match("\n(.-)\n")
+ message = "error raised! " .. second
+ else
+ local arg = { ... } -- not worried about table creation, as errors don't happen often
+
+ for i = 1, #arg do
+ arg[i] = tostring(arg[i])
+ end
+ for i = 1, 10 do
+ table.insert(arg, "nil")
+ end
+ message = message:format(unpack(arg))
+ end
+
+ if getmetatable(self) and getmetatable(self).__tostring then
+ message = ("%s: %s"):format(tostring(self), message)
+ elseif type(rawget(self, 'GetLibraryVersion')) == "function" and AceLibrary:HasInstance(self:GetLibraryVersion()) then
+ message = ("%s: %s"):format(self:GetLibraryVersion(), message)
+ elseif type(rawget(self, 'class')) == "table" and type(rawget(self.class, 'GetLibraryVersion')) == "function" and AceLibrary:HasInstance(self.class:GetLibraryVersion()) then
+ message = ("%s: %s"):format(self.class:GetLibraryVersion(), message)
+ end
+
+ local first = stack:gsub("\n.*", "")
+ local file = first:gsub(".*\\(.*).lua:%d+: .*", "%1")
+ file = file:gsub("([%(%)%.%*%+%-%[%]%?%^%$%%])", "%%%1")
+
+
+ local i = 0
+ for s in stack:gmatch("\n([^\n]*)") do
+ i = i + 1
+ if not s:find(file .. "%.lua:%d+:") and not s:find("%(tail call%)") then
+ file = s:gsub("^.*\\(.*).lua:%d+: .*", "%1")
+ file = file:gsub("([%(%)%.%*%+%-%[%]%?%^%$%%])", "%%%1")
+ break
+ end
+ end
+ local j = 0
+ for s in stack:gmatch("\n([^\n]*)") do
+ j = j + 1
+ if j > i and not s:find(file .. "%.lua:%d+:") and not s:find("%(tail call%)") then
+ return _G.error(message, j+1)
+ end
+ end
+ return _G.error(message, 2)
+end
+
+local type = type
+local function argCheck(self, arg, num, kind, kind2, kind3, kind4, kind5)
+ if type(num) ~= "number" then
+ return error(self, "Bad argument #3 to `argCheck' (number expected, got %s)", type(num))
+ elseif type(kind) ~= "string" then
+ return error(self, "Bad argument #4 to `argCheck' (string expected, got %s)", type(kind))
+ end
+ arg = type(arg)
+ if arg ~= kind and arg ~= kind2 and arg ~= kind3 and arg ~= kind4 and arg ~= kind5 then
+ local stack = debugstack()
+ local func = stack:match("`argCheck'.-([`<].-['>])")
+ if not func then
+ func = stack:match("([`<].-['>])")
+ end
+ if kind5 then
+ return error(self, "Bad argument #%s to %s (%s, %s, %s, %s, or %s expected, got %s)", tonumber(num) or 0/0, func, kind, kind2, kind3, kind4, kind5, arg)
+ elseif kind4 then
+ return error(self, "Bad argument #%s to %s (%s, %s, %s, or %s expected, got %s)", tonumber(num) or 0/0, func, kind, kind2, kind3, kind4, arg)
+ elseif kind3 then
+ return error(self, "Bad argument #%s to %s (%s, %s, or %s expected, got %s)", tonumber(num) or 0/0, func, kind, kind2, kind3, arg)
+ elseif kind2 then
+ return error(self, "Bad argument #%s to %s (%s or %s expected, got %s)", tonumber(num) or 0/0, func, kind, kind2, arg)
+ else
+ return error(self, "Bad argument #%s to %s (%s expected, got %s)", tonumber(num) or 0/0, func, kind, arg)
+ end
+ end
+end
+
+local pcall
+do
+ local function check(self, ret, ...)
+ if not ret then
+ local s = ...
+ return error(self, (s:gsub(".-%.lua:%d-: ", "")))
+ else
+ return ...
+ end
+ end
+
+ function pcall(self, func, ...)
+ return check(self, _G.pcall(func, ...))
+ end
+end
+
+local recurse = {}
+local function addToPositions(t, major)
+ if not AceLibrary.positions[t] or AceLibrary.positions[t] == major then
+ rawset(t, recurse, true)
+ AceLibrary.positions[t] = major
+ for k,v in pairs(t) do
+ if type(v) == "table" and not rawget(v, recurse) then
+ addToPositions(v, major)
+ end
+ if type(k) == "table" and not rawget(k, recurse) then
+ addToPositions(k, major)
+ end
+ end
+ local mt = getmetatable(t)
+ if mt and not rawget(mt, recurse) then
+ addToPositions(mt, major)
+ end
+ rawset(t, recurse, nil)
+ end
+end
+
+local function svnRevisionToNumber(text)
+ local kind = type(text)
+ if kind == "number" or tonumber(text) then
+ return tonumber(text)
+ elseif kind == "string" then
+ if text:find("^%$Revision: (%d+) %$$") then
+ return tonumber((text:match("^%$Revision: (%d+) %$$")))
+ elseif text:find("^%$Rev: (%d+) %$$") then
+ return tonumber((text:match("^%$Rev: (%d+) %$$")))
+ elseif text:find("^%$LastChangedRevision: (%d+) %$$") then
+ return tonumber((text:match("^%$LastChangedRevision: (%d+) %$$")))
+ end
+ end
+ return nil
+end
+
+local crawlReplace
+do
+ local recurse = {}
+ local function func(t, to, from)
+ if recurse[t] then
+ return
+ end
+ recurse[t] = true
+ local mt = getmetatable(t)
+ setmetatable(t, nil)
+ rawset(t, to, rawget(t, from))
+ rawset(t, from, nil)
+ for k,v in pairs(t) do
+ if v == from then
+ t[k] = to
+ elseif type(v) == "table" then
+ if not recurse[v] then
+ func(v, to, from)
+ end
+ end
+
+ if type(k) == "table" then
+ if not recurse[k] then
+ func(k, to, from)
+ end
+ end
+ end
+ setmetatable(t, mt)
+ if mt then
+ if mt == from then
+ setmetatable(t, to)
+ elseif not recurse[mt] then
+ func(mt, to, from)
+ end
+ end
+ end
+ function crawlReplace(t, to, from)
+ func(t, to, from)
+ for k in pairs(recurse) do
+ recurse[k] = nil
+ end
+ end
+end
+
+-- @function destroyTable
+-- @brief remove all the contents of a table
+-- @param t table to destroy
+local function destroyTable(t)
+ setmetatable(t, nil)
+ for k,v in pairs(t) do
+ t[k] = nil
+ end
+end
+
+local function isFrame(frame)
+ return type(frame) == "table" and type(rawget(frame, 0)) == "userdata" and type(rawget(frame, 'IsFrameType')) == "function" and getmetatable(frame) and type(rawget(getmetatable(frame), '__index')) == "function"
+end
+
+-- @function copyTable
+-- @brief Create a shallow copy of a table and return it.
+-- @param from The table to copy from
+-- @return A shallow copy of the table
+local function copyTable(from, to)
+ if not to then
+ to = {}
+ end
+ for k,v in pairs(from) do
+ to[k] = v
+ end
+ setmetatable(to, getmetatable(from))
+ return to
+end
+
+-- @function deepTransfer
+-- @brief Fully transfer all data, keeping proper previous table
+-- backreferences stable.
+-- @param to The table with which data is to be injected into
+-- @param from The table whose data will be injected into the first
+-- @param saveFields If available, a shallow copy of the basic data is saved
+-- in here.
+-- @param list The account of table references
+-- @param list2 The current status on which tables have been traversed.
+local deepTransfer
+do
+ -- @function examine
+ -- @brief Take account of all the table references to be shared
+ -- between the to and from tables.
+ -- @param to The table with which data is to be injected into
+ -- @param from The table whose data will be injected into the first
+ -- @param list An account of the table references
+ local function examine(to, from, list, major)
+ list[from] = to
+ for k,v in pairs(from) do
+ if rawget(to, k) and type(from[k]) == "table" and type(to[k]) == "table" and not list[from[k]] then
+ if from[k] == to[k] then
+ list[from[k]] = to[k]
+ elseif AceLibrary.positions[from[v]] ~= major and AceLibrary.positions[from[v]] then
+ list[from[k]] = from[k]
+ elseif not list[from[k]] then
+ examine(to[k], from[k], list, major)
+ end
+ end
+ end
+ return list
+ end
+
+ function deepTransfer(to, from, saveFields, major, list, list2)
+ setmetatable(to, nil)
+ if not list then
+ list = {}
+ list2 = {}
+ examine(to, from, list, major)
+ end
+ list2[to] = to
+ for k,v in pairs(to) do
+ if type(rawget(from, k)) ~= "table" or type(v) ~= "table" or isFrame(v) then
+ if saveFields then
+ saveFields[k] = v
+ end
+ to[k] = nil
+ elseif v ~= _G then
+ if saveFields then
+ saveFields[k] = copyTable(v)
+ end
+ end
+ end
+ for k in pairs(from) do
+ if rawget(to, k) and to[k] ~= from[k] and AceLibrary.positions[to[k]] == major and from[k] ~= _G then
+ if not list2[to[k]] then
+ deepTransfer(to[k], from[k], nil, major, list, list2)
+ end
+ to[k] = list[to[k]] or list2[to[k]]
+ else
+ rawset(to, k, from[k])
+ end
+ end
+ setmetatable(to, getmetatable(from))
+ local mt = getmetatable(to)
+ if mt then
+ if list[mt] then
+ setmetatable(to, list[mt])
+ elseif mt.__index and list[mt.__index] then
+ mt.__index = list[mt.__index]
+ end
+ end
+ destroyTable(from)
+ end
+end
+
+local function TryToEnable(addon)
+ if DONT_ENABLE_LIBRARIES then return end
+ local isondemand = IsAddOnLoadOnDemand(addon)
+ if isondemand then
+ local _, _, _, enabled = GetAddOnInfo(addon)
+ EnableAddOn(addon)
+ local _, _, _, _, loadable = GetAddOnInfo(addon)
+ if not loadable and not enabled then
+ DisableAddOn(addon)
+ end
+
+ return loadable
+ end
+end
+
+-- @method TryToLoadStandalone
+-- @brief Attempt to find and load a standalone version of the requested library
+-- @param major A string representing the major version
+-- @return If library is found and loaded, true is return. If not loadable, false is returned.
+-- If the library has been requested previously, nil is returned.
+local function TryToLoadStandalone(major)
+ if not AceLibrary.scannedlibs then AceLibrary.scannedlibs = {} end
+ if AceLibrary.scannedlibs[major] then return end
+
+ AceLibrary.scannedlibs[major] = true
+
+ local name, _, _, enabled, loadable = GetAddOnInfo(major)
+
+ loadable = (enabled and loadable) or TryToEnable(name)
+
+ local loaded = false
+ if loadable then
+ loaded = true
+ LoadAddOn(name)
+ end
+
+ local field = "X-AceLibrary-" .. major
+ for i = 1, GetNumAddOns() do
+ if GetAddOnMetadata(i, field) then
+ name, _, _, enabled, loadable = GetAddOnInfo(i)
+
+ loadable = (enabled and loadable) or TryToEnable(name)
+ if loadable then
+ loaded = true
+ LoadAddOn(name)
+ end
+ end
+ end
+ return loaded
+end
+
+-- @method IsNewVersion
+-- @brief Obtain whether the supplied version would be an upgrade to the
+-- current version. This allows for bypass code in library
+-- declaration.
+-- @param major A string representing the major version
+-- @param minor An integer or an svn revision string representing the minor version
+-- @return whether the supplied version would be newer than what is
+-- currently available.
+function AceLibrary:IsNewVersion(major, minor)
+ argCheck(self, major, 2, "string")
+ TryToLoadStandalone(major)
+
+ if type(minor) == "string" then
+ local m = svnRevisionToNumber(minor)
+ if m then
+ minor = m
+ else
+ _G.error(("Bad argument #3 to `IsNewVersion'. Must be a number or SVN revision string. %q is not appropriate"):format(minor), 2)
+ end
+ end
+ argCheck(self, minor, 3, "number")
+ local lib, oldMinor = LibStub:GetLibrary(major, true)
+ if lib then
+ return oldMinor < minor
+ end
+ local data = self.libs[major]
+ if not data then
+ return true
+ end
+ return data.minor < minor
+end
+
+-- @method HasInstance
+-- @brief Returns whether an instance exists. This allows for optional support of a library.
+-- @param major A string representing the major version.
+-- @param minor (optional) An integer or an svn revision string representing the minor version.
+-- @return Whether an instance exists.
+function AceLibrary:HasInstance(major, minor)
+ argCheck(self, major, 2, "string")
+ if minor ~= false then
+ TryToLoadStandalone(major)
+ end
+
+ local lib, ver = LibStub:GetLibrary(major, true)
+ if not lib and self.libs[major] then
+ lib, ver = self.libs[major].instance, self.libs[major].minor
+ end
+ if minor then
+ if type(minor) == "string" then
+ local m = svnRevisionToNumber(minor)
+ if m then
+ minor = m
+ else
+ _G.error(("Bad argument #3 to `HasInstance'. Must be a number or SVN revision string. %q is not appropriate"):format(minor), 2)
+ end
+ end
+ argCheck(self, minor, 3, "number")
+ if not lib then
+ return false
+ end
+ return ver == minor
+ end
+ return not not lib
+end
+
+-- @method GetInstance
+-- @brief Returns the library with the given major/minor version.
+-- @param major A string representing the major version.
+-- @param minor (optional) An integer or an svn revision string representing the minor version.
+-- @return The library with the given major/minor version.
+function AceLibrary:GetInstance(major, minor)
+ argCheck(self, major, 2, "string")
+
+ if minor ~= false then
+ TryToLoadStandalone(major)
+ end
+
+ local data, ver = LibStub:GetLibrary(major, true)
+
+ if not data then
+ if self.libs[major] then
+ data, ver = self.libs[major].instance, self.libs[major].minor
+ else
+ _G.error(("Cannot find a library instance of %s."):format(major), 2)
+ return
+ end
+ end
+ if minor then
+ if type(minor) == "string" then
+ local m = svnRevisionToNumber(minor)
+ if m then
+ minor = m
+ else
+ _G.error(("Bad argument #3 to `GetInstance'. Must be a number or SVN revision string. %q is not appropriate"):format(minor), 2)
+ end
+ end
+ argCheck(self, minor, 2, "number")
+ if ver ~= minor then
+ _G.error(("Cannot find a library instance of %s, minor version %d."):format(major, minor), 2)
+ end
+ end
+ --print(major, data)
+ return data
+end
+
+-- Syntax sugar. AceLibrary("FooBar-1.0")
+AceLibrary_mt.__call = AceLibrary.GetInstance
+
+local donothing = function() end
+
+local AceEvent
+
+local tmp = {}
+
+-- @method Register
+-- @brief Registers a new version of a given library.
+-- @param newInstance the library to register
+-- @param major the major version of the library
+-- @param minor the minor version of the library
+-- @param activateFunc (optional) A function to be called when the library is
+-- fully activated. Takes the arguments
+-- (newInstance [, oldInstance, oldDeactivateFunc]). If
+-- oldInstance is given, you should probably call
+-- oldDeactivateFunc(oldInstance).
+-- @param deactivateFunc (optional) A function to be called by a newer library's
+-- activateFunc.
+-- @param externalFunc (optional) A function to be called whenever a new
+-- library is registered.
+function AceLibrary:Register(newInstance, major, minor, activateFunc, deactivateFunc, externalFunc)
+ argCheck(self, newInstance, 2, "table")
+ argCheck(self, major, 3, "string")
+ if major ~= ACELIBRARY_MAJOR then
+ for k,v in pairs(_G) do
+ if v == newInstance then
+ geterrorhandler()((debugstack():match("(.-: )in.-\n") or "") .. ("Cannot register library %q. It is part of the global table in _G[%q]."):format(major, k))
+ end
+ end
+ end
+ if major ~= ACELIBRARY_MAJOR and not major:find("^[%a%-][%a%d%-]*%-%d+%.%d+$") then
+ _G.error(string.format("Bad argument #3 to `Register'. Must be in the form of \"Name-1.0\". %q is not appropriate", major), 2)
+ end
+ if type(minor) == "string" then
+ local m = svnRevisionToNumber(minor)
+ if m then
+ minor = m
+ else
+ _G.error(("Bad argument #4 to `Register'. Must be a number or SVN revision string. %q is not appropriate"):format(minor), 2)
+ end
+ end
+ argCheck(self, minor, 4, "number")
+ if math.floor(minor) ~= minor or minor < 0 then
+ error(self, "Bad argument #4 to `Register' (integer >= 0 expected, got %s)", minor)
+ end
+ argCheck(self, activateFunc, 5, "function", "nil")
+ argCheck(self, deactivateFunc, 6, "function", "nil")
+ argCheck(self, externalFunc, 7, "function", "nil")
+ if not deactivateFunc then
+ deactivateFunc = donothing
+ end
+ local data = self.libs[major]
+ if not data then
+ -- This is new
+ if LibStub:GetLibrary(major, true) then
+ error(self, "Cannot register library %q. It is already registered with LibStub.", major)
+ end
+ local instance = LibStub:NewLibrary(major, minor)
+ copyTable(newInstance, instance)
+ crawlReplace(instance, instance, newInstance)
+ destroyTable(newInstance)
+ if AceLibrary == newInstance then
+ self = instance
+ AceLibrary = instance
+ end
+ self.libs[major] = {
+ instance = instance,
+ minor = minor,
+ deactivateFunc = deactivateFunc,
+ externalFunc = externalFunc,
+ }
+ rawset(instance, 'GetLibraryVersion', function(self)
+ return major, minor
+ end)
+ if not rawget(instance, 'error') then
+ rawset(instance, 'error', error)
+ end
+ if not rawget(instance, 'argCheck') then
+ rawset(instance, 'argCheck', argCheck)
+ end
+ if not rawget(instance, 'pcall') then
+ rawset(instance, 'pcall', pcall)
+ end
+ addToPositions(instance, major)
+ if activateFunc then
+ safecall(activateFunc, instance, nil, nil) -- no old version, so explicit nil
+ end
+
+ if externalFunc then
+ for k, data_instance in LibStub:IterateLibraries() do -- all libraries
+ tmp[k] = data_instance
+ end
+ for k, data in pairs(self.libs) do -- Ace libraries which may not have been registered with LibStub
+ tmp[k] = data.instance
+ end
+ for k, data_instance in pairs(tmp) do
+ if k ~= major then
+ safecall(externalFunc, instance, k, data_instance)
+ end
+ tmp[k] = nil
+ end
+ end
+
+ for k,data in pairs(self.libs) do -- only Ace libraries
+ if k ~= major and data.externalFunc then
+ safecall(data.externalFunc, data.instance, major, instance)
+ end
+ end
+ if major == "AceEvent-2.0" then
+ AceEvent = instance
+ end
+ if AceEvent then
+ AceEvent.TriggerEvent(self, "AceLibrary_Register", major, instance)
+ end
+
+ return instance
+ end
+ if minor <= data.minor then
+ -- This one is already obsolete, raise an error.
+ _G.error(("Obsolete library registered. %s is already registered at version %d. You are trying to register version %d. Hint: if not AceLibrary:IsNewVersion(%q, %d) then return end"):format(major, data.minor, minor, major, minor), 2)
+ return
+ end
+ local instance = data.instance
+ -- This is an update
+ local oldInstance = {}
+
+ local libStubInstance = LibStub:GetLibrary(major, true)
+ if not libStubInstance then -- non-LibStub AceLibrary registered the library
+ -- pass
+ elseif libStubInstance ~= instance then
+ error(self, "Cannot register library %q. It is already registered with LibStub.", major)
+ else
+ LibStub:NewLibrary(major, minor) -- upgrade the minor version
+ end
+
+ addToPositions(newInstance, major)
+ local isAceLibrary = (AceLibrary == newInstance)
+ local old_error, old_argCheck, old_pcall
+ if isAceLibrary then
+ self = instance
+ AceLibrary = instance
+
+ old_error = instance.error
+ old_argCheck = instance.argCheck
+ old_pcall = instance.pcall
+
+ self.error = error
+ self.argCheck = argCheck
+ self.pcall = pcall
+ end
+ deepTransfer(instance, newInstance, oldInstance, major)
+ crawlReplace(instance, instance, newInstance)
+ local oldDeactivateFunc = data.deactivateFunc
+ data.minor = minor
+ data.deactivateFunc = deactivateFunc
+ data.externalFunc = externalFunc
+ rawset(instance, 'GetLibraryVersion', function()
+ return major, minor
+ end)
+ if not rawget(instance, 'error') then
+ rawset(instance, 'error', error)
+ end
+ if not rawget(instance, 'argCheck') then
+ rawset(instance, 'argCheck', argCheck)
+ end
+ if not rawget(instance, 'pcall') then
+ rawset(instance, 'pcall', pcall)
+ end
+ if isAceLibrary then
+ for _,v in pairs(self.libs) do
+ local i = type(v) == "table" and v.instance
+ if type(i) == "table" then
+ if not rawget(i, 'error') or i.error == old_error then
+ rawset(i, 'error', error)
+ end
+ if not rawget(i, 'argCheck') or i.argCheck == old_argCheck then
+ rawset(i, 'argCheck', argCheck)
+ end
+ if not rawget(i, 'pcall') or i.pcall == old_pcall then
+ rawset(i, 'pcall', pcall)
+ end
+ end
+ end
+ end
+ if activateFunc then
+ safecall(activateFunc, instance, oldInstance, oldDeactivateFunc)
+ else
+ safecall(oldDeactivateFunc, oldInstance)
+ end
+ oldInstance = nil
+
+ if externalFunc then
+ for k, data_instance in LibStub:IterateLibraries() do -- all libraries
+ tmp[k] = data_instance
+ end
+ for k, data in pairs(self.libs) do -- Ace libraries which may not have been registered with LibStub
+ tmp[k] = data.instance
+ end
+ for k, data_instance in pairs(tmp) do
+ if k ~= major then
+ safecall(externalFunc, instance, k, data_instance)
+ end
+ tmp[k] = nil
+ end
+ end
+
+ return instance
+end
+
+function AceLibrary:IterateLibraries()
+ local t = {}
+ for major, instance in LibStub:IterateLibraries() do
+ t[major] = instance
+ end
+ for major, data in pairs(self.libs) do
+ t[major] = data.instance
+ end
+ return pairs(t)
+end
+
+local function manuallyFinalize(major, instance)
+ if AceLibrary.libs[major] then
+ -- don't work on Ace libraries
+ return
+ end
+ local finalizedExternalLibs = AceLibrary.finalizedExternalLibs
+ if finalizedExternalLibs[major] then
+ return
+ end
+ finalizedExternalLibs[major] = true
+
+ for k,data in pairs(AceLibrary.libs) do -- only Ace libraries
+ if k ~= major and data.externalFunc then
+ safecall(data.externalFunc, data.instance, major, instance)
+ end
+ end
+end
+
+-- @function Activate
+-- @brief The activateFunc for AceLibrary itself. Called when
+-- AceLibrary properly registers.
+-- @param self Reference to AceLibrary
+-- @param oldLib (optional) Reference to an old version of AceLibrary
+-- @param oldDeactivate (optional) Function to deactivate the old lib
+local function activate(self, oldLib, oldDeactivate)
+ AceLibrary = self
+ if not self.libs then
+ self.libs = oldLib and oldLib.libs or {}
+ self.scannedlibs = oldLib and oldLib.scannedlibs or {}
+ end
+ if not self.positions then
+ self.positions = oldLib and oldLib.positions or setmetatable({}, { __mode = "k" })
+ end
+ self.finalizedExternalLibs = oldLib and oldLib.finalizedExternalLibs or {}
+ self.frame = oldLib and oldLib.frame or CreateFrame("Frame")
+ self.frame:UnregisterAllEvents()
+ self.frame:RegisterEvent("ADDON_LOADED")
+ self.frame:SetScript("OnEvent", function()
+ for major, instance in LibStub:IterateLibraries() do
+ manuallyFinalize(major, instance)
+ end
+ end)
+ for major, instance in LibStub:IterateLibraries() do
+ manuallyFinalize(major, instance)
+ end
+
+ -- Expose the library in the global environment
+ _G[ACELIBRARY_MAJOR] = self
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+if not previous then
+ previous = AceLibrary
+end
+if not previous.libs then
+ previous.libs = {}
+end
+AceLibrary.libs = previous.libs
+if not previous.positions then
+ previous.positions = setmetatable({}, { __mode = "k" })
+end
+AceLibrary.positions = previous.positions
+AceLibrary:Register(AceLibrary, ACELIBRARY_MAJOR, ACELIBRARY_MINOR, activate, nil)
diff --git a/FuBar/libs/AceLibrary/AceLibrary.toc b/FuBar/libs/AceLibrary/AceLibrary.toc
new file mode 100644
index 0000000..42a63f1
--- /dev/null
+++ b/FuBar/libs/AceLibrary/AceLibrary.toc
@@ -0,0 +1,15 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r1101
+## X-Curse-Project-Name: Ace2
+## X-Curse-Project-ID: ace2
+## X-Curse-Repository-ID: wow/ace2/mainline
+
+## Title: Lib: AceLibrary
+## Notes: AddOn development framework
+## Author: Ace Development Team
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-License: LGPL v2.1 + MIT for AceOO-2.0
+
+AceLibrary.lua
+
diff --git a/FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua b/FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua
new file mode 100644
index 0000000..bd04241
--- /dev/null
+++ b/FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua
@@ -0,0 +1,207 @@
+--[[ $Id: CallbackHandler-1.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ ]]
+local MAJOR, MINOR = "CallbackHandler-1.0", 7
+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 error = error
+local setmetatable, rawget = setmetatable, rawget
+local next, select, pairs, type, tostring = next, select, pairs, type, tostring
+
+local xpcall = xpcall
+
+local function errorhandler(err)
+ return geterrorhandler()(err)
+end
+
+local function Dispatch(handlers, ...)
+ local index, method = next(handlers)
+ if not method then return end
+ repeat
+ xpcall(method, errorhandler, ...)
+ index, method = next(handlers, index)
+ until not method
+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(_self, target, RegisterName, UnregisterName, UnregisterAllName)
+
+ RegisterName = RegisterName or "RegisterCallback"
+ UnregisterName = UnregisterName or "UnregisterCallback"
+ if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
+ UnregisterAllName = "UnregisterAllCallbacks"
+ end
+
+ -- we declare all objects and exported APIs inside this closure to quickly gain access
+ -- to e.g. function names, the "target" parameter, etc
+
+
+ -- Create the registry object
+ local events = setmetatable({}, meta)
+ local registry = { recurse=0, events=events }
+
+ -- registry:Fire() - fires the given event/message into the registry
+ function registry:Fire(eventname, ...)
+ if not rawget(events, eventname) or not next(events[eventname]) then return end
+ local oldrecurse = registry.recurse
+ registry.recurse = oldrecurse + 1
+
+ Dispatch(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 event,callbacks in pairs(registry.insertQueue) do
+ local first = not rawget(events, event) or not next(events[event]) -- test for empty before. not test for one member after. that one member may have been overwritten.
+ for object,func in pairs(callbacks) do
+ events[event][object] = func
+ -- fire OnUsed callback?
+ if first and registry.OnUsed then
+ registry.OnUsed(registry, target, event)
+ 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.
+
diff --git a/FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml b/FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml
new file mode 100644
index 0000000..1aad3a2
--- /dev/null
+++ b/FuBar/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml
@@ -0,0 +1,4 @@
+
+
+
\ No newline at end of file
diff --git a/FuBar/libs/Dewdrop-2.0/Dewdrop-2.0.lua b/FuBar/libs/Dewdrop-2.0/Dewdrop-2.0.lua
new file mode 100644
index 0000000..ff748a9
--- /dev/null
+++ b/FuBar/libs/Dewdrop-2.0/Dewdrop-2.0.lua
@@ -0,0 +1,3511 @@
+--[[
+Name: Dewdrop-2.0
+Revision: $Rev: 326 $
+Author(s): ckknight (ckknight@gmail.com)
+Website: http://ckknight.wowinterface.com/
+Documentation: http://wiki.wowace.com/index.php/Dewdrop-2.0
+SVN: http://svn.wowace.com/root/trunk/DewdropLib/Dewdrop-2.0
+Description: A library to provide a clean dropdown menu interface.
+Dependencies: AceLibrary
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "Dewdrop-2.0"
+local MINOR_VERSION = tonumber(strmatch("$Revision: 326 $", "%d+")) + 90000
+
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+local Dewdrop = {}
+
+local SharedMedia
+
+local CLOSE = "Close"
+local CLOSE_DESC = "Close the menu."
+local VALIDATION_ERROR = "Validation error."
+local USAGE_TOOLTIP = "Usage: %s."
+local RANGE_TOOLTIP = "Note that you can scroll your mouse wheel while over the slider to step by one."
+local RESET_KEYBINDING_DESC = "Hit escape to clear the keybinding."
+local KEY_BUTTON1 = "Left Mouse"
+local KEY_BUTTON2 = "Right Mouse"
+local DISABLED = "Disabled"
+local DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?"
+
+if GetLocale() == "deDE" then
+ CLOSE = "Schlie\195\159en"
+ CLOSE_DESC = "Men\195\188 schlie\195\159en."
+ VALIDATION_ERROR = "Validierungsfehler."
+ USAGE_TOOLTIP = "Benutzung: %s."
+ RANGE_TOOLTIP = "Beachte das du mit dem Mausrad scrollen kannst solange du mit dem Mauszeiger \195\188ber dem Schieberegler bist, um feinere Spr\195\188nge zu machen."
+ RESET_KEYBINDING_DESC = "Escape dr\195\188cken, um die Tastenbelegung zu l\195\182schen."
+ KEY_BUTTON1 = "Linke Maustaste"
+ KEY_BUTTON2 = "Rechte Maustaste"
+ DISABLED = "Deaktiviert"
+ DEFAULT_CONFIRM_MESSAGE = "Bist du sicher das du `%s' machen willst?"
+elseif GetLocale() == "koKR" then
+ CLOSE = "닫기"
+ CLOSE_DESC = "메뉴를 닫습니다."
+ VALIDATION_ERROR = "오류 확인."
+ USAGE_TOOLTIP = "사용법: %s."
+ RANGE_TOOLTIP = "알림 : 슬라이더 위에서 마우스 휠을 사용하면 한단계씩 조절할 수 있습니다."
+ RESET_KEYBINDING_DESC = "단축키를 해제하려면 ESC키를 누르세요."
+ KEY_BUTTON1 = "왼쪽 마우스"
+ KEY_BUTTON2 = "오른쪽 마우스"
+ DISABLED = "비활성화됨"
+ DEFAULT_CONFIRM_MESSAGE = "정말로 `%s' 실행을 하시겠습니까 ?"
+elseif GetLocale() == "frFR" then
+ CLOSE = "Fermer"
+ CLOSE_DESC = "Ferme le menu."
+ VALIDATION_ERROR = "Erreur de validation."
+ USAGE_TOOLTIP = "Utilisation : %s."
+ RANGE_TOOLTIP = "Vous pouvez aussi utiliser la molette de la souris pour pour modifier progressivement."
+ RESET_KEYBINDING_DESC = "Appuyez sur la touche Echappement pour effacer le raccourci."
+ KEY_BUTTON1 = "Clic gauche"
+ KEY_BUTTON2 = "Clic droit"
+ DISABLED = "D\195\169sactiv\195\169"
+ DEFAULT_CONFIRM_MESSAGE = "\195\138tes-vous s\195\187r de vouloir effectuer '%s' ?"
+elseif GetLocale() == "esES" then
+ CLOSE = "Cerrar"
+ CLOSE_DESC = "Cierra el menú."
+ VALIDATION_ERROR = "Error de validación."
+ USAGE_TOOLTIP = "Uso: %s."
+ RANGE_TOOLTIP = "Puedes desplazarte verticalmente con la rueda del ratón sobre el desplazador."
+ RESET_KEYBINDING_DESC = "Pulsa Escape para borrar la asignación de tecla."
+ KEY_BUTTON1 = "Clic Izquierdo"
+ KEY_BUTTON2 = "Clic Derecho"
+ DISABLED = "Desactivado"
+ DEFAULT_CONFIRM_MESSAGE = "¿Estás seguro de querer realizar `%s'?"
+elseif GetLocale() == "zhTW" then
+ CLOSE = "關閉"
+ CLOSE_DESC = "關閉選單。"
+ VALIDATION_ERROR = "驗證錯誤。"
+ USAGE_TOOLTIP = "用法: %s。"
+ RANGE_TOOLTIP = "你可以在捲動條上使用滑鼠滾輪來捲動。"
+ RESET_KEYBINDING_DESC = "按Esc鍵清除快捷鍵。"
+ KEY_BUTTON1 = "滑鼠左鍵"
+ KEY_BUTTON2 = "滑鼠右鍵"
+ DISABLED = "停用"
+ DEFAULT_CONFIRM_MESSAGE = "是否執行「%s」?"
+elseif GetLocale() == "zhCN" then
+ CLOSE = "关闭"
+ CLOSE_DESC = "关闭菜单"
+ VALIDATION_ERROR = "验证错误."
+ USAGE_TOOLTIP = "用法: %s."
+ RANGE_TOOLTIP = "你可以在滚动条上使用鼠标滚轮来翻页."
+ RESET_KEYBINDING_DESC = "按ESC键清除按键绑定"
+ KEY_BUTTON1 = "鼠标左键"
+ KEY_BUTTON2 = "鼠标右键"
+ DISABLED = "禁用"
+ DEFAULT_CONFIRM_MESSAGE = "是否执行'%s'?"
+elseif GetLocale() == "ruRU" then
+ CLOSE = "Закрыть"
+ CLOSE_DESC = "Закрыть меню."
+ VALIDATION_ERROR = "Ошибка проверки данных."
+ USAGE_TOOLTIP = "Используйте: %s."
+ RANGE_TOOLTIP = "Используйте колесо мыши для прокрутки ползунка."
+ RESET_KEYBINDING_DESC = "Нажмите клавишу Escape для очистки клавиши."
+ KEY_BUTTON1 = "ЛКМ"
+ KEY_BUTTON2 = "ПКМ"
+ DISABLED = "Отключено"
+ DEFAULT_CONFIRM_MESSAGE = "Вы уверены что вы хотите выполнять `%s'?"
+end
+
+Dewdrop.KEY_BUTTON1 = KEY_BUTTON1
+Dewdrop.KEY_BUTTON2 = KEY_BUTTON2
+
+local function new(...)
+ local t = {}
+ for i = 1, select('#', ...), 2 do
+ local k = select(i, ...)
+ if k then
+ t[k] = select(i+1, ...)
+ else
+ break
+ end
+ end
+ return t
+end
+
+local tmp
+do
+ local t = {}
+ function tmp(...)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ for i = 1, select('#', ...), 2 do
+ local k = select(i, ...)
+ if k then
+ t[k] = select(i+1, ...)
+ else
+ break
+ end
+ end
+ return t
+ end
+end
+local tmp2
+do
+ local t = {}
+ function tmp2(...)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ for i = 1, select('#', ...), 2 do
+ local k = select(i, ...)
+ if k then
+ t[k] = select(i+1, ...)
+ else
+ break
+ end
+ end
+ return t
+ end
+end
+local levels
+local buttons
+
+
+-- Secure frame handling:
+-- Rather than using secure buttons in the menu (has problems), we have one
+-- master secureframe that we pop onto menu items on mouseover. This requires
+-- some dark magic with OnLeave etc, but it's not too bad.
+
+local eventFrame = CreateFrame("Button")
+local secureFrame
+local createSecureFrame
+
+local function secureFrame_Show(self)
+ local owner = self.owner
+
+ if self.secure then -- Leftovers from previos owner, clean up! ("Shouldn't" happen but does..)
+ for k,v in pairs(self.secure) do
+ self:SetAttribute(k, nil)
+ end
+ end
+ self.secure = owner.secure; -- Grab hold of new secure data
+
+ local scale = owner:GetEffectiveScale()
+
+ self:SetPoint("TOPLEFT", nil, "BOTTOMLEFT", owner:GetLeft() * scale, owner:GetTop() * scale)
+ self:SetPoint("BOTTOMRIGHT", nil, "BOTTOMLEFT", owner:GetRight() * scale, owner:GetBottom() * scale)
+ self:EnableMouse(true)
+ for k,v in pairs(self.secure) do
+ self:SetAttribute(k, v)
+ end
+
+ secureFrame:SetFrameStrata(owner:GetFrameStrata())
+ secureFrame:SetFrameLevel(owner:GetFrameLevel()+1)
+
+ self:Show()
+end
+
+local function secureFrame_Hide(self)
+ self:Hide()
+ if self.secure then
+ for k,v in pairs(self.secure) do
+ self:SetAttribute(k, nil)
+ end
+ end
+ self.secure = nil
+end
+
+eventFrame:SetScript("OnEvent",
+ function(this, event)
+ if event=="PLAYER_REGEN_ENABLED" then
+ createSecureFrame()
+ secureFrame.combat = false
+ if not secureFrame:IsShown() and secureFrame.owner then
+ secureFrame_Show(secureFrame)
+ end
+ elseif event=="PLAYER_REGEN_DISABLED" and secureFrame then
+ secureFrame.combat = true
+ if secureFrame:IsShown() then
+ secureFrame_Hide(secureFrame)
+ end
+ end
+ end
+)
+eventFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
+eventFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
+
+function createSecureFrame()
+ if secureFrame or InCombatLockdown() then return end
+ secureFrame = CreateFrame("Button", nil, nil, "SecureActionButtonTemplate")
+ secureFrame:Hide()
+
+secureFrame:SetScript("OnLeave",
+ function(this)
+ local owner=this.owner
+ this:Deactivate()
+ owner:GetScript("OnLeave")(owner)
+ end
+)
+
+-- secureFrame:HookScript("OnClick",
+-- function(this)
+-- local realthis = this
+-- this = this.owner
+-- this:GetScript("OnClick")(this)
+-- end
+-- )
+
+function secureFrame:IsOwnedBy(frame)
+ return self.owner == frame
+end
+
+function secureFrame:Activate(owner)
+ if self.owner then -- "Shouldn't" happen but apparently it does and I cba to troubleshoot...
+ if not self.combat then
+ secureFrame_Hide(self)
+ end
+ end
+ self.owner = owner
+ if not self.combat then
+ secureFrame_Show(self)
+ end
+end
+
+function secureFrame:Deactivate()
+ if not self.combat then
+ secureFrame_Hide(self)
+ end
+ self.owner = nil
+end
+
+end
+createSecureFrame()
+-- END secure frame utilities
+
+
+-- Underline on mouseover - use a single global underline that we move around, no point in creating lots of copies
+local underlineFrame = CreateFrame("Frame", nil)
+underlineFrame.tx = underlineFrame:CreateTexture()
+underlineFrame.tx:SetTexture(1,1,0.5,0.75)
+underlineFrame:SetScript("OnHide", function(this) this:Hide(); end)
+underlineFrame:SetScript("OnShow", function(this) -- change sizing on the fly to catch runtime uiscale changes
+ underlineFrame.tx:SetPoint("TOPLEFT", -1, -2/this:GetEffectiveScale())
+ underlineFrame.tx:SetPoint("RIGHT", 1,0)
+ underlineFrame.tx:SetHeight(0.6 / this:GetEffectiveScale());
+end)
+underlineFrame:SetHeight(1)
+
+-- END underline on mouseover
+
+
+local function GetScaledCursorPosition()
+ local x, y = GetCursorPosition()
+ local scale = UIParent:GetEffectiveScale()
+ return x / scale, y / scale
+end
+
+local function StartCounting(self, level)
+ for i = level, 1, -1 do
+ if levels[i] then
+ levels[i].count = 3
+ end
+ end
+end
+
+local function StopCounting(self, level)
+ for i = level, 1, -1 do
+ if levels[i] then
+ levels[i].count = nil
+ end
+ end
+end
+
+local function OnUpdate(self, elapsed)
+ for _,level in ipairs(levels) do
+ local count = level.count
+ if count then
+ count = count - elapsed
+ if count < 0 then
+ level.count = nil
+ self:Close(level.num)
+ else
+ level.count = count
+ end
+ end
+ end
+end
+
+local function CheckDualMonitor(self, frame)
+ local ratio = GetScreenWidth() / GetScreenHeight()
+ if ratio >= 2.4 and frame:GetRight() > GetScreenWidth() / 2 and frame:GetLeft() < GetScreenWidth() / 2 then
+ local offsetx
+ if GetCursorPosition() / GetScreenHeight() * 768 < GetScreenWidth() / 2 then
+ offsetx = GetScreenWidth() / 2 - frame:GetRight()
+ else
+ offsetx = GetScreenWidth() / 2 - frame:GetLeft()
+ end
+ local point, parent, relativePoint, x, y = frame:GetPoint(1)
+ frame:SetPoint(point, parent, relativePoint, (x or 0) + offsetx, y or 0)
+ end
+end
+
+local function CheckSize(self, level)
+ if not level.buttons then
+ return
+ end
+ local height = 20
+ for _, button in ipairs(level.buttons) do
+ height = height + button:GetHeight()
+ end
+ level:SetHeight(height)
+ local width = 160
+ for _, button in ipairs(level.buttons) do
+ local extra = 1
+ if button.hasArrow or button.hasColorSwatch then
+ extra = extra + 16
+ end
+ if not button.notCheckable then
+ extra = extra + 24
+ end
+ button.text:SetFont(STANDARD_TEXT_FONT, button.textHeight)
+ if button.text:GetStringWidth() + extra > width then
+ width = button.text:GetStringWidth() + extra
+ end
+ end
+ level:SetWidth(width + 20)
+ if level:GetLeft() and level:GetRight() and level:GetTop() and level:GetBottom() and (level:GetLeft() < 0 or level:GetRight() > GetScreenWidth() or level:GetTop() > GetScreenHeight() or level:GetBottom() < 0) then
+ level:ClearAllPoints()
+ local parent = level.parent or level:GetParent()
+ if type(parent) ~= "table" then
+ parent = UIParent
+ end
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ end
+ local dirty = false
+ if not level:GetRight() then
+ self:Close()
+ return
+ end
+ if level:GetRight() > GetScreenWidth() and level.lastDirection == "RIGHT" then
+ level.lastDirection = "LEFT"
+ dirty = true
+ elseif level:GetLeft() < 0 and level.lastDirection == "LEFT" then
+ level.lastDirection = "RIGHT"
+ dirty = true
+ end
+ if level:GetTop() > GetScreenHeight() and level.lastVDirection == "UP" then
+ level.lastVDirection = "DOWN"
+ dirty = true
+ elseif level:GetBottom() < 0 and level.lastVDirection == "DOWN" then
+ level.lastVDirection = "UP"
+ dirty = true
+ end
+ if dirty then
+ level:ClearAllPoints()
+ local parent = level.parent or level:GetParent()
+ if type(parent) ~= "table" then
+ parent = UIParent
+ end
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ end
+ if level:GetTop() > GetScreenHeight() then
+ local top = level:GetTop()
+ local point, parent, relativePoint, x, y = level:GetPoint(1)
+ level:ClearAllPoints()
+ level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) + GetScreenHeight() - top)
+ elseif level:GetBottom() < 0 then
+ local bottom = level:GetBottom()
+ local point, parent, relativePoint, x, y = level:GetPoint(1)
+ level:ClearAllPoints()
+ level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) - bottom)
+ end
+ CheckDualMonitor(self, level)
+ if mod(level.num, 5) == 0 then
+ local left, bottom = level:GetLeft(), level:GetBottom()
+ level:ClearAllPoints()
+ level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
+ end
+end
+
+local Open
+local OpenSlider
+local OpenEditBox
+local Refresh
+local Clear
+local function ReleaseButton(self, level, index)
+ if not level.buttons then
+ return
+ end
+ if not level.buttons[index] then
+ return
+ end
+ local button = level.buttons[index]
+ button:Hide()
+ if button.highlight then
+ button.highlight:Hide()
+ end
+-- button.arrow:SetVertexColor(1, 1, 1)
+-- button.arrow:SetHeight(16)
+-- button.arrow:SetWidth(16)
+ table.remove(level.buttons, index)
+ table.insert(buttons, button)
+ for k in pairs(button) do
+ if k ~= 0 and k ~= "text" and k ~= "check" and k ~= "arrow" and k ~= "colorSwatch" and k ~= "highlight" and k ~= "radioHighlight" then
+ button[k] = nil
+ end
+ end
+ return true
+end
+
+local function Scroll(self, level, down)
+ if down then
+ if level:GetBottom() < 0 then
+ local point, parent, relativePoint, x, y = level:GetPoint(1)
+ level:SetPoint(point, parent, relativePoint, x, y + 50)
+ if level:GetBottom() > 0 then
+ level:SetPoint(point, parent, relativePoint, x, y + 50 - level:GetBottom())
+ end
+ end
+ else
+ if level:GetTop() > GetScreenHeight() then
+ local point, parent, relativePoint, x, y = level:GetPoint(1)
+ level:SetPoint(point, parent, relativePoint, x, y - 50)
+ if level:GetTop() < GetScreenHeight() then
+ level:SetPoint(point, parent, relativePoint, x, y - 50 + GetScreenHeight() - level:GetTop())
+ end
+ end
+ end
+end
+
+local function getArgs(t, str, num, ...)
+ local x = t[str .. num]
+ if x == nil then
+ return ...
+ else
+ return x, getArgs(t, str, num + 1, ...)
+ end
+end
+
+local sliderFrame
+local editBoxFrame
+
+local normalFont
+local lastSetFont
+local justSetFont = false
+local regionTmp = {}
+local function fillRegionTmp(...)
+ for i = 1, select('#', ...) do
+ regionTmp[i] = select(i, ...)
+ end
+end
+
+local function showGameTooltip(this)
+ if this.tooltipTitle or this.tooltipText then
+ GameTooltip_SetDefaultAnchor(GameTooltip, this)
+ local disabled = not this.isTitle and this.disabled
+ local font
+ if this.tooltipTitle then
+ if SharedMedia and SharedMedia:IsValid("font", this.tooltipTitle) then
+ font = SharedMedia:Fetch("font", this.tooltipTitle)
+ end
+ if disabled then
+ GameTooltip:SetText(this.tooltipTitle, 0.5, 0.5, 0.5, 1)
+ else
+ GameTooltip:SetText(this.tooltipTitle, 1, 1, 1, 1)
+ end
+ if this.tooltipText then
+ if not font and SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then
+ font = SharedMedia:Fetch("font", this.tooltipText)
+ end
+ if disabled then
+ GameTooltip:AddLine(this.tooltipText, (NORMAL_FONT_COLOR.r + 0.5) / 2, (NORMAL_FONT_COLOR.g + 0.5) / 2, (NORMAL_FONT_COLOR.b + 0.5) / 2, 1)
+ else
+ GameTooltip:AddLine(this.tooltipText, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
+ end
+ end
+ else
+ if SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then
+ font = SharedMedia:Fetch("font", this.tooltipText)
+ end
+ if disabled then
+ GameTooltip:SetText(this.tooltipText, 0.5, 0.5, 0.5, 1)
+ else
+ GameTooltip:SetText(this.tooltipText, 1, 1, 1, 1)
+ end
+ end
+ if font then
+ fillRegionTmp(GameTooltip:GetRegions())
+ lastSetFont = font
+ justSetFont = true
+ for i,v in ipairs(regionTmp) do
+ if v.SetFont then
+ local norm,size,outline = v:GetFont()
+ v:SetFont(font, size, outline)
+ if not normalFont then
+ normalFont = norm
+ end
+ end
+ regionTmp[i] = nil
+ end
+ elseif not normalFont then
+ fillRegionTmp(GameTooltip:GetRegions())
+ for i,v in ipairs(regionTmp) do
+ if v.GetFont and not normalFont then
+ normalFont = v:GetFont()
+ end
+ regionTmp[i] = nil
+ end
+ end
+ GameTooltip:Show()
+ end
+ if this.tooltipFunc then
+ GameTooltip:SetOwner(this, "ANCHOR_NONE")
+ GameTooltip:SetPoint("TOPLEFT", this, "TOPRIGHT", 5, 0)
+ this.tooltipFunc(getArgs(this, 'tooltipArg', 1))
+ GameTooltip:Show()
+ end
+end
+
+local tmpt = setmetatable({}, {mode='v'})
+local numButtons = 0
+local function AcquireButton(self, level)
+ if not levels[level] then
+ return
+ end
+ level = levels[level]
+ if not level.buttons then
+ level.buttons = {}
+ end
+ local button
+ if #buttons == 0 then
+ numButtons = numButtons + 1
+ button = CreateFrame("Button", "Dewdrop20Button" .. numButtons, nil)
+ button:SetFrameStrata("FULLSCREEN_DIALOG")
+ button:SetHeight(16)
+ local highlight = button:CreateTexture(nil, "BACKGROUND")
+ highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
+ button.highlight = highlight
+ highlight:SetBlendMode("ADD")
+ highlight:SetAllPoints(button)
+ highlight:Hide()
+ local check = button:CreateTexture(nil, "ARTWORK")
+ button.check = check
+ check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
+ check:SetPoint("CENTER", button, "LEFT", 12, 0)
+ check:SetWidth(24)
+ check:SetHeight(24)
+ local radioHighlight = button:CreateTexture(nil, "ARTWORK")
+ button.radioHighlight = radioHighlight
+ radioHighlight:SetTexture("Interface\\Buttons\\UI-RadioButton")
+ radioHighlight:SetAllPoints(check)
+ radioHighlight:SetBlendMode("ADD")
+ radioHighlight:SetTexCoord(0.5, 0.75, 0, 1)
+ radioHighlight:Hide()
+ button:SetScript("OnEnter", function(this)
+ if (sliderFrame and sliderFrame:IsShown() and sliderFrame.mouseDown and sliderFrame.level == this.level.num + 1) or (editBoxFrame and editBoxFrame:IsShown() and editBoxFrame.mouseDown and editBoxFrame.level == this.level.num + 1) then
+ for i = 1, this.level.num do
+ Refresh(self, levels[i])
+ end
+ return
+ end
+ self:Close(this.level.num + 1)
+ if not this.disabled then
+ if this.secure then
+ secureFrame:Activate(this)
+ elseif this.hasSlider then
+ OpenSlider(self, this)
+ elseif this.hasEditBox then
+ OpenEditBox(self, this)
+ elseif this.hasArrow then
+ Open(self, this, nil, this.level.num + 1, this.value)
+ end
+ end
+ if not this.level then -- button reclaimed
+ return
+ end
+ StopCounting(self, this.level.num + 1)
+ if not this.disabled then
+ highlight:Show()
+ if this.isRadio then
+ button.radioHighlight:Show()
+ end
+ if this.mouseoverUnderline then
+ underlineFrame:SetParent(this)
+ underlineFrame:SetPoint("BOTTOMLEFT",this.text,0,0)
+ underlineFrame:SetWidth(this.text:GetWidth())
+ underlineFrame:Show()
+ end
+ end
+ showGameTooltip(this)
+ end)
+ button:SetScript("OnHide", function(this)
+ if this.secure and secureFrame:IsOwnedBy(this) then
+ secureFrame:Deactivate()
+ end
+ end)
+ button:SetScript("OnLeave", function(this)
+ if this.secure and secureFrame:IsShown() then
+ return; -- it's ok, we didn't actually mouse out of the button, only onto the secure frame on top of it
+ end
+ underlineFrame:Hide()
+ if not this.selected then
+ highlight:Hide()
+ end
+ button.radioHighlight:Hide()
+ if this.level then
+ StartCounting(self, this.level.num)
+ end
+ GameTooltip:Hide()
+ end)
+ local first = true
+ button:SetScript("OnClick", function(this)
+ if not this.disabled then
+ if this.hasColorSwatch then
+ local func = button.colorFunc
+ local hasOpacity = this.hasOpacity
+ local this = this
+ for k in pairs(tmpt) do
+ tmpt[k] = nil
+ end
+ for i = 1, 1000 do
+ local x = this['colorArg'..i]
+ if x == nil then
+ break
+ else
+ tmpt[i] = x
+ end
+ end
+ ColorPickerFrame.func = function()
+ if func then
+ local r,g,b = ColorPickerFrame:GetColorRGB()
+ local a = hasOpacity and 1 - OpacitySliderFrame:GetValue() or nil
+ local n = #tmpt
+ tmpt[n+1] = r
+ tmpt[n+2] = g
+ tmpt[n+3] = b
+ tmpt[n+4] = a
+ func(unpack(tmpt))
+ tmpt[n+1] = nil
+ tmpt[n+2] = nil
+ tmpt[n+3] = nil
+ tmpt[n+4] = nil
+ end
+ end
+ ColorPickerFrame.hasOpacity = this.hasOpacity
+ ColorPickerFrame.opacityFunc = ColorPickerFrame.func
+ ColorPickerFrame.opacity = 1 - this.opacity
+ ColorPickerFrame:SetColorRGB(this.r, this.g, this.b)
+ local r, g, b, a = this.r, this.g, this.b, this.opacity
+ ColorPickerFrame.cancelFunc = function()
+ if func then
+ local n = #tmpt
+ tmpt[n+1] = r
+ tmpt[n+2] = g
+ tmpt[n+3] = b
+ tmpt[n+4] = a
+ func(unpack(tmpt))
+ for i = 1, n+4 do
+ tmpt[i] = nil
+ end
+ end
+ end
+ self:Close(1)
+ ShowUIPanel(ColorPickerFrame)
+ elseif this.func then
+ local level = this.level
+ if type(this.func) == "string" then
+ if type(this.arg1[this.func]) ~= "function" then
+ self:error("Cannot call method %q", this.func)
+ end
+ this.arg1[this.func](this.arg1, getArgs(this, 'arg', 2))
+ else
+ this.func(getArgs(this, 'arg', 1))
+ end
+ if this.closeWhenClicked then
+ self:Close()
+ elseif level:IsShown() then
+ for i = 1, level.num do
+ Refresh(self, levels[i])
+ end
+ local value = levels[level.num].value
+ for i = level.num-1, 1, -1 do
+ local level = levels[i]
+ local good = false
+ for _,button in ipairs(level.buttons) do
+ if button.value == value then
+ good = true
+ break
+ end
+ end
+ if not good then
+ Dewdrop:Close(i+1)
+ end
+ value = levels[i].value
+ end
+ end
+ elseif this.closeWhenClicked then
+ self:Close()
+ end
+ end
+ end)
+ local text = button:CreateFontString(nil, "ARTWORK")
+ button.text = text
+ text:SetFontObject(GameFontHighlightSmall)
+ button.text:SetFont(STANDARD_TEXT_FONT, UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT)
+ button:SetScript("OnMouseDown", function(this, type)
+ if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then
+ text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 1 or 25, -1)
+ end
+ end)
+ button:SetScript("OnMouseUp", function(this)
+ if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then
+ text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 0 or 24, 0)
+ end
+ end)
+ local arrow = button:CreateTexture(nil, "ARTWORK")
+ button.arrow = arrow
+ arrow:SetPoint("LEFT", button, "RIGHT", -16, 0)
+ arrow:SetWidth(16)
+ arrow:SetHeight(16)
+ arrow:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
+ local colorSwatch = button:CreateTexture(nil, "ARTWORK")
+ button.colorSwatch = colorSwatch
+ colorSwatch:SetWidth(20)
+ colorSwatch:SetHeight(20)
+ colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
+ local texture = button:CreateTexture(nil, "OVERLAY")
+ colorSwatch.texture = texture
+ texture:SetTexture("Interface\\Buttons\\WHITE8X8")
+ texture:SetWidth(11.5)
+ texture:SetHeight(11.5)
+ texture:Show()
+ texture:SetPoint("CENTER", colorSwatch, "CENTER")
+ colorSwatch:SetPoint("RIGHT", button, "RIGHT", 0, 0)
+ else
+ button = table.remove(buttons)
+ end
+ button:ClearAllPoints()
+ button:SetParent(level)
+ button:SetFrameStrata(level:GetFrameStrata())
+ button:SetFrameLevel(level:GetFrameLevel() + 1)
+ button:SetPoint("LEFT", level, "LEFT", 10, 0)
+ button:SetPoint("RIGHT", level, "RIGHT", -10, 0)
+ if #level.buttons == 0 then
+ button:SetPoint("TOP", level, "TOP", 0, -10)
+ else
+ button:SetPoint("TOP", level.buttons[#level.buttons], "BOTTOM", 0, 0)
+ end
+ button.text:SetPoint("LEFT", button, "LEFT", 24, 0)
+ button:Show()
+ button.level = level
+ table.insert(level.buttons, button)
+ if not level.parented then
+ level.parented = true
+ level:ClearAllPoints()
+ if level.num == 1 then
+ if level.parent ~= UIParent and type(level.parent) == "table" then
+ level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT")
+ else
+ level:SetPoint("CENTER", UIParent, "CENTER")
+ end
+ else
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPLEFT", level.parent, "TOPRIGHT", 5, 10)
+ else
+ level:SetPoint("BOTTOMLEFT", level.parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT", -5, 10)
+ else
+ level:SetPoint("BOTTOMRIGHT", level.parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ end
+ level:SetFrameStrata("FULLSCREEN_DIALOG")
+ end
+ button:SetAlpha(1)
+ return button
+end
+
+local numLevels = 0
+local function AcquireLevel(self, level)
+ if not levels[level] then
+ for i = #levels + 1, level, -1 do
+ local i = i
+ numLevels = numLevels + 1
+ local frame = CreateFrame("Button", "Dewdrop20Level" .. numLevels, nil)
+ if i == 1 then
+ local old_CloseSpecialWindows = CloseSpecialWindows
+ function CloseSpecialWindows()
+ local found = old_CloseSpecialWindows()
+ if levels[1]:IsShown() then
+ self:Close()
+ return 1
+ end
+ return found
+ end
+ end
+ levels[i] = frame
+ frame.num = i
+ frame:SetParent(UIParent)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ frame:Hide()
+ frame:SetWidth(180)
+ frame:SetHeight(10)
+ frame:SetFrameLevel(i * 3)
+ frame:SetScript("OnHide", function()
+ self:Close(level + 1)
+ end)
+ if frame.SetTopLevel then
+ frame:SetTopLevel(true)
+ end
+ frame:EnableMouse(true)
+ frame:EnableMouseWheel(true)
+ local backdrop = CreateFrame("Frame", nil, frame, "BackdropTemplate")
+ backdrop:SetAllPoints(frame)
+ backdrop:SetBackdrop(tmp(
+ 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
+ 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
+ 'tile', true,
+ 'insets', tmp2(
+ 'left', 5,
+ 'right', 5,
+ 'top', 5,
+ 'bottom', 5
+ ),
+ 'tileSize', 16,
+ 'edgeSize', 16
+ ))
+ backdrop:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
+ backdrop:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
+ frame:SetScript("OnClick", function()
+ self:Close(i)
+ end)
+ frame:SetScript("OnEnter", function()
+ StopCounting(self, i)
+ end)
+ frame:SetScript("OnLeave", function()
+ StartCounting(self, i)
+ end)
+ frame:SetScript("OnMouseWheel", function(this, arg1)
+ Scroll(self, frame, arg1 < 0)
+ end)
+ if i == 1 then
+ frame:SetScript("OnUpdate", function(this, arg1)
+ OnUpdate(self, arg1)
+ end)
+ levels[1].lastDirection = "RIGHT"
+ levels[1].lastVDirection = "DOWN"
+ else
+ levels[i].lastDirection = levels[i - 1].lastDirection
+ levels[i].lastVDirection = levels[i - 1].lastVDirection
+ end
+ end
+ end
+ local fullscreenFrame = GetUIPanel("fullscreen")
+ local l = levels[level]
+ local strata, framelevel = l:GetFrameStrata(), l:GetFrameLevel()
+ if fullscreenFrame then
+ l:SetParent(fullscreenFrame)
+ else
+ l:SetParent(UIParent)
+ end
+ l:SetFrameStrata(strata)
+ l:SetFrameLevel(framelevel)
+ l:SetAlpha(1)
+ return l
+end
+
+local function validateOptions(options, position, baseOptions, fromPass)
+ if not baseOptions then
+ baseOptions = options
+ end
+ if type(options) ~= "table" then
+ return "Options must be a table.", position
+ end
+ local kind = options.type
+ if type(kind) ~= "string" then
+ return '"type" must be a string.', position
+ elseif kind ~= "group" and kind ~= "range" and kind ~= "text" and kind ~= "execute" and kind ~= "toggle" and kind ~= "color" and kind ~= "dragLink" and kind ~= "header" then
+ return '"type" must either be "range", "text", "group", "toggle", "execute", "color", "dragLink", or "header".', position
+ end
+ if options.aliases then
+ if type(options.aliases) ~= "table" and type(options.aliases) ~= "string" then
+ return '"alias" must be a table or string', position
+ end
+ end
+ if not fromPass then
+ if kind == "execute" then
+ if type(options.func) ~= "string" and type(options.func) ~= "function" then
+ return '"func" must be a string or function', position
+ end
+ elseif kind == "range" or kind == "text" or kind == "toggle" then
+ if type(options.set) ~= "string" and type(options.set) ~= "function" then
+ return '"set" must be a string or function', position
+ end
+ if kind == "text" and options.get == false then
+ elseif type(options.get) ~= "string" and type(options.get) ~= "function" then
+ return '"get" must be a string or function', position
+ end
+ elseif kind == "group" and options.pass then
+ if options.pass ~= true then
+ return '"pass" must be either nil, true, or false', position
+ end
+ if not options.func then
+ if type(options.set) ~= "string" and type(options.set) ~= "function" then
+ return '"set" must be a string or function', position
+ end
+ if type(options.get) ~= "string" and type(options.get) ~= "function" then
+ return '"get" must be a string or function', position
+ end
+ elseif type(options.func) ~= "string" and type(options.func) ~= "function" then
+ return '"func" must be a string or function', position
+ end
+ end
+ end
+ if options ~= baseOptions then
+ if kind == "header" then
+ elseif type(options.desc) ~= "string" then
+ return '"desc" must be a string', position
+ elseif options.desc:len() == 0 then
+ return '"desc" cannot be a 0-length string', position
+ end
+ end
+ if options ~= baseOptions or kind == "range" or kind == "text" or kind == "toggle" or kind == "color" then
+ if options.type == "header" and not options.cmdName and not options.name then
+ elseif options.cmdName then
+ if type(options.cmdName) ~= "string" then
+ return '"cmdName" must be a string or nil', position
+ elseif options.cmdName:len() == 0 then
+ return '"cmdName" cannot be a 0-length string', position
+ end
+ if type(options.guiName) ~= "string" then
+ if not options.guiNameIsMap then
+ return '"guiName" must be a string or nil', position
+ end
+ elseif options.guiName:len() == 0 then
+ return '"guiName" cannot be a 0-length string', position
+ end
+ else
+ if type(options.name) ~= "string" then
+ return '"name" must be a string', position
+ elseif options.name:len() == 0 then
+ return '"name" cannot be a 0-length string', position
+ end
+ end
+ end
+ if options.guiNameIsMap then
+ if type(options.guiNameIsMap) ~= "boolean" then
+ return '"guiNameIsMap" must be a boolean or nil', position
+ elseif options.type ~= "toggle" then
+ return 'if "guiNameIsMap" is true, then "type" must be set to \'toggle\'', position
+ elseif type(options.map) ~= "table" then
+ return '"map" must be a table', position
+ end
+ end
+ if options.message and type(options.message) ~= "string" then
+ return '"message" must be a string or nil', position
+ end
+ if options.error and type(options.error) ~= "string" then
+ return '"error" must be a string or nil', position
+ end
+ if options.current and type(options.current) ~= "string" then
+ return '"current" must be a string or nil', position
+ end
+ if options.order then
+ if type(options.order) ~= "number" or (-1 < options.order and options.order < 0.999) then
+ return '"order" must be a non-zero number or nil', position
+ end
+ end
+ if options.disabled then
+ if type(options.disabled) ~= "function" and type(options.disabled) ~= "string" and options.disabled ~= true then
+ return '"disabled" must be a function, string, or boolean', position
+ end
+ end
+ if options.cmdHidden then
+ if type(options.cmdHidden) ~= "function" and type(options.cmdHidden) ~= "string" and options.cmdHidden ~= true then
+ return '"cmdHidden" must be a function, string, or boolean', position
+ end
+ end
+ if options.guiHidden then
+ if type(options.guiHidden) ~= "function" and type(options.guiHidden) ~= "string" and options.guiHidden ~= true then
+ return '"guiHidden" must be a function, string, or boolean', position
+ end
+ end
+ if options.hidden then
+ if type(options.hidden) ~= "function" and type(options.hidden) ~= "string" and options.hidden ~= true then
+ return '"hidden" must be a function, string, or boolean', position
+ end
+ end
+ if kind == "text" then
+ if type(options.validate) == "table" then
+ local t = options.validate
+ local iTable = nil
+ for k,v in pairs(t) do
+ if type(k) == "number" then
+ if iTable == nil then
+ iTable = true
+ elseif not iTable then
+ return '"validate" must either have all keys be indexed numbers or strings', position
+ elseif k < 1 or k > #t then
+ return '"validate" numeric keys must be indexed properly. >= 1 and <= #t', position
+ end
+ else
+ if iTable == nil then
+ iTable = false
+ elseif iTable then
+ return '"validate" must either have all keys be indexed numbers or strings', position
+ end
+ end
+ if type(v) ~= "string" then
+ return '"validate" values must all be strings', position
+ end
+ end
+ if options.multiToggle and options.multiToggle ~= true then
+ return '"multiToggle" must be a boolean or nil if "validate" is a table', position
+ end
+ elseif options.validate == "keybinding" then
+ -- no other checks
+ else
+ if type(options.usage) ~= "string" then
+ return '"usage" must be a string', position
+ elseif options.validate and type(options.validate) ~= "string" and type(options.validate) ~= "function" then
+ return '"validate" must be a string, function, or table', position
+ end
+ end
+ if options.multiToggle and type(options.validate) ~= "table" then
+ return '"validate" must be a table if "multiToggle" is true', position
+ end
+ elseif kind == "range" then
+ if options.min or options.max then
+ if type(options.min) ~= "number" then
+ return '"min" must be a number', position
+ elseif type(options.max) ~= "number" then
+ return '"max" must be a number', position
+ elseif options.min >= options.max then
+ return '"min" must be less than "max"', position
+ end
+ end
+ if options.step then
+ if type(options.step) ~= "number" then
+ return '"step" must be a number', position
+ elseif options.step < 0 then
+ return '"step" must be nonnegative', position
+ end
+ end
+ if options.bigStep then
+ if type(options.bigStep) ~= "number" then
+ return '"bigStep" must be a number', position
+ elseif options.bigStep < 0 then
+ return '"bigStep" must be nonnegative', position
+ end
+ end
+ if options.isPercent and options.isPercent ~= true then
+ return '"isPercent" must either be nil, true, or false', position
+ end
+ elseif kind == "toggle" then
+ if options.map then
+ if type(options.map) ~= "table" then
+ return '"map" must be a table', position
+ elseif type(options.map[true]) ~= "string" then
+ return '"map[true]" must be a string', position
+ elseif type(options.map[false]) ~= "string" then
+ return '"map[false]" must be a string', position
+ end
+ end
+ elseif kind == "color" then
+ if options.hasAlpha and options.hasAlpha ~= true then
+ return '"hasAlpha" must be nil, true, or false', position
+ end
+ elseif kind == "group" then
+ if options.pass and options.pass ~= true then
+ return '"pass" must be nil, true, or false', position
+ end
+ if type(options.args) ~= "table" then
+ return '"args" must be a table', position
+ end
+ for k,v in pairs(options.args) do
+ if type(k) ~= "number" then
+ if type(k) ~= "string" then
+ return '"args" keys must be strings or numbers', position
+ elseif k:len() == 0 then
+ return '"args" keys must not be 0-length strings.', position
+ end
+ end
+ if type(v) ~= "table" then
+ return '"args" values must be tables', position and position .. "." .. k or k
+ end
+ local newposition
+ if position then
+ newposition = position .. ".args." .. k
+ else
+ newposition = "args." .. k
+ end
+ local err, pos = validateOptions(v, newposition, baseOptions, options.pass)
+ if err then
+ return err, pos
+ end
+ end
+ elseif kind == "execute" then
+ if type(options.confirm) ~= "string" and type(options.confirm) ~= "boolean" and type(options.confirm) ~= "nil" then
+ return '"confirm" must be a string, boolean, or nil', position
+ end
+ end
+ if options.icon and type(options.icon) ~= "string" then
+ return'"icon" must be a string', position
+ end
+ if options.iconWidth or options.iconHeight then
+ if type(options.iconWidth) ~= "number" or type(options.iconHeight) ~= "number" then
+ return '"iconHeight" and "iconWidth" must be numbers', position
+ end
+ end
+ if options.iconCoordLeft or options.iconCoordRight or options.iconCoordTop or options.iconCoordBottom then
+ if type(options.iconCoordLeft) ~= "number" or type(options.iconCoordRight) ~= "number" or type(options.iconCoordTop) ~= "number" or type(options.iconCoordBottom) ~= "number" then
+ return '"iconCoordLeft", "iconCoordRight", "iconCoordTop", and "iconCoordBottom" must be numbers', position
+ end
+ end
+end
+
+local validatedOptions
+
+local values
+local mysort_args
+local mysort
+local othersort
+local othersort_validate
+
+local baseFunc, currentLevel
+
+local function confirmPopup(message, func, ...)
+ if not StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"] then
+ StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"] = {}
+ end
+ local t = StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"]
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t.text = message
+ t.button1 = ACCEPT or "Accept"
+ t.button2 = CANCEL or "Cancel"
+ t.OnAccept = function()
+ func(unpack(t))
+ end
+ for i = 1, select('#', ...) do
+ t[i] = select(i, ...)
+ end
+ t.timeout = 0
+ t.whileDead = 1
+ t.hideOnEscape = 1
+
+ Dewdrop:Close()
+ StaticPopup_Show("DEWDROP20_CONFIRM_DIALOG")
+end
+
+
+local function getMethod(settingname, handler, v, methodName, ...) -- "..." is simply returned straight out cause you can't do "a,b,c = 111,f(),222"
+ assert(v and type(v)=="table")
+ assert(methodName and type(methodName)=="string")
+
+ local method = v[methodName]
+ if type(method)=="function" then
+ return method, ...
+ elseif type(method)=="string" then
+ if not handler then
+ Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method)
+ elseif not handler[method] then
+ Dewdrop:error("[%s] 'handler' method %q not defined", tostring(settingname), method)
+ end
+ return handler[method], handler, ...
+ end
+
+ Dewdrop:error("[%s] Missing %q directive", tostring(settingname), methodName)
+end
+
+local function callMethod(settingname, handler, v, methodName, ...)
+ assert(v and type(v)=="table")
+ assert(methodName and type(methodName)=="string")
+
+ local method = v[methodName]
+ if type(method)=="function" then
+ local success, ret,ret2,ret3,ret4 = pcall(v[methodName], ...)
+ if not success then
+ geterrorhandler()(ret)
+ return nil
+ end
+ return ret,ret2,ret3,ret4
+
+ elseif type(method)=="string" then
+
+ local neg = method:match("^~(.-)$")
+ if neg then
+ method = neg
+ end
+ if not handler then
+ Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method)
+ elseif not handler[method] then
+ Dewdrop:error("[%s] 'handler' (%q) method %q not defined", tostring(settingname), handler.name or "(unnamed)", method)
+ end
+ local success, ret,ret2,ret3,ret4 = pcall(handler[method], handler, ...)
+ if not success then
+ geterrorhandler()(ret)
+ return nil
+ end
+ if neg then
+ return not ret
+ end
+ return ret,ret2,ret3,ret4
+ elseif method == false then
+ return nil
+ end
+
+ Dewdrop:error("[%s] Missing %q directive in %q", tostring(settingname), methodName, v.name or "(unnamed)")
+end
+
+local function skip1Nil(...)
+ if select(1,...)==nil then
+ return select(2,...)
+ end
+ return ...
+end
+
+function Dewdrop:FeedAceOptionsTable(options, difference)
+ self:argCheck(options, 2, "table")
+ self:argCheck(difference, 3, "nil", "number")
+ if not currentLevel then
+ self:error("Cannot call `FeedAceOptionsTable' outside of a Dewdrop declaration")
+ end
+ if not difference then
+ difference = 0
+ end
+ if not validatedOptions then
+ validatedOptions = {}
+ end
+ if not validatedOptions[options] then
+ local err, position = validateOptions(options)
+
+ if err then
+ if position then
+ Dewdrop:error(position .. ": " .. err)
+ else
+ Dewdrop:error(err)
+ end
+ end
+
+ validatedOptions[options] = true
+ end
+ local level = levels[currentLevel]
+ if not level then
+ self:error("Improper level given")
+ end
+ if not values then
+ values = {}
+ else
+ for k,v in pairs(values) do
+ values[k] = nil
+ end
+ end
+
+ local current = level
+ while current do -- this traverses from higher level numbers to lower, building "values" with leaf nodes first and trunk nodes later
+ if current.num == difference + 1 then
+ break
+ end
+ table.insert(values, current.value)
+ current = levels[current.num - 1]
+ end
+
+ local realOptions = options
+ local handler = options.handler
+ local passTable
+ local passValue
+ while #values > 0 do -- This loop traverses values from the END (trunk nodes first, then onto leaf nodes)
+ if options.pass then
+ if options.get and options.set then
+ passTable = options
+ elseif not passTable then
+ passTable = options
+ end
+ else
+ passTable = nil
+ end
+ local value = table.remove(values)
+ options = options.args and options.args[value]
+ if not options then
+ return
+ end
+ handler = options.handler or handler
+ passValue = passTable and value or nil
+ end
+
+ if options.type == "group" then
+ local hidden = options.hidden
+ if type(hidden) == "function" or type(hidden) == "string" then
+ hidden = callMethod(options.name or "(options root)", handler, options, "hidden", options.passValue) or false
+ end
+ if hidden then
+ return
+ end
+ local disabled = options.disabled
+ if type(disabled) == "function" or type(disabled) == "string" then
+ disabled = callMethod(options.name or "(options root)", handler, options, "disabled", options.passValue) or false
+ end
+ if disabled then
+ self:AddLine(
+ 'text', DISABLED,
+ 'disabled', true
+ )
+ return
+ end
+ for k in pairs(options.args) do
+ table.insert(values, k)
+ end
+ if options.pass then
+ if options.get and options.set then
+ passTable = options
+ elseif not passTable then
+ passTable = options
+ end
+ else
+ passTable = nil
+ end
+ if not mysort then
+ mysort = function(a, b)
+ local alpha, bravo = mysort_args[a], mysort_args[b]
+ local alpha_order = alpha.order or 100
+ local bravo_order = bravo.order or 100
+ local alpha_name = alpha.guiName or alpha.name
+ local bravo_name = bravo.guiName or bravo.name
+ if alpha_order == bravo_order then
+ if not alpha_name then
+ return bravo_name
+ elseif not bravo_name then
+ return false
+ else
+ return alpha_name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper() < bravo_name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper()
+ end
+ else
+ if alpha_order < 0 then
+ if bravo_order > 0 then
+ return false
+ end
+ else
+ if bravo_order < 0 then
+ return true
+ end
+ end
+ return alpha_order < bravo_order
+ end
+ end
+ end
+ mysort_args = options.args
+ table.sort(values, mysort)
+ mysort_args = nil
+ local hasBoth = #values >= 1 and (options.args[values[1]].order or 100) > 0 and (options.args[values[#values]].order or 100) < 0
+ local last_order = 1
+ for _,k in ipairs(values) do
+ local v = options.args[k]
+
+ local handler = v.handler or handler
+ if hasBoth and last_order > 0 and (v.order or 100) < 0 then
+ hasBoth = false
+ self:AddLine()
+ end
+ local hidden, disabled = v.guiHidden or v.hidden, v.disabled
+
+ if type(hidden) == "function" or type(hidden) == "string" then
+ hidden = callMethod(k, handler, v, "hidden", v.passValue) or false
+ end
+ if not hidden then
+ if type(disabled) == "function" or type(disabled) == "string" then
+ disabled = callMethod(k, handler, v, "disabled", v.passValue) or false
+ end
+ local name = (v.guiIconOnly and v.icon) and "" or (v.guiName or v.name)
+ local desc = v.guiDesc or v.desc
+ local iconHeight = v.iconHeight or 16
+ local iconWidth = v.iconWidth or 16
+ local iconCoordLeft = v.iconCoordLeft
+ local iconCoordRight = v.iconCoordRight
+ local iconCoordBottom = v.iconCoordBottom
+ local iconCoordTop = v.iconCoordTop
+ local tooltipTitle, tooltipText
+ tooltipTitle = name
+ if name ~= desc then
+ tooltipText = desc
+ end
+ if type(v.usage) == "string" and v.usage:trim():len() > 0 then
+ if tooltipText then
+ tooltipText = tooltipText .. "\n\n" .. USAGE_TOOLTIP:format(v.usage)
+ else
+ tooltipText = USAGE_TOOLTIP:format(v.usage)
+ end
+ end
+ local v_p = passTable
+ if not v_p or (v.type ~= "execute" and v.get and v.set) or (v.type == "execute" and v.func) then
+ v_p = v
+ end
+ local passValue = v.passValue or (v_p~=v and k) or nil
+ if v.type == "toggle" then
+ local checked = callMethod(name, handler, v_p, "get", passValue) or false
+ local checked_arg = checked
+ if type(v_p.get)=="string" and v_p.get:match("^~") then
+ checked_arg = not checked
+ end
+ local func, arg1, arg2, arg3 = getMethod(name, handler, v_p, "set", skip1Nil(passValue, not checked_arg))
+ if v.guiNameIsMap then
+ checked = checked and true or false
+ name = tostring(v.map and v.map[checked]):gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
+ tooltipTitle = name
+ checked = true--nil
+ end
+ self:AddLine(
+ 'text', name,
+ 'checked', checked,
+ 'isRadio', v.isRadio,
+ 'func', func,
+ 'arg1', arg1,
+ 'arg2', arg2,
+ 'arg3', arg3,
+ 'disabled', disabled,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText
+ )
+ elseif v.type == "execute" then
+ local func, arg1, arg2, arg3, arg4
+ local confirm = v.confirm
+ if confirm == true then
+ confirm = DEFAULT_CONFIRM_MESSAGE:format(tooltipText or tooltipTitle)
+ func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue)
+ elseif type(confirm) == "string" then
+ func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue)
+ else
+ func,arg1,arg2 = getMethod(name, handler, v_p, "func", passValue)
+ end
+ self:AddLine(
+ 'text', name,
+ 'checked', checked,
+ 'func', func,
+ 'arg1', arg1,
+ 'arg2', arg2,
+ 'arg3', arg3,
+ 'arg4', arg4,
+ 'disabled', disabled,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ elseif v.type == "range" then
+ local sliderValue
+ sliderValue = callMethod(name, handler, v_p, "get", passValue) or 0
+ local sliderFunc, sliderArg1, sliderArg2 = getMethod(name, handler, v_p, "set", passValue)
+ if tooltipText then
+ tooltipText = format("%s\n\n%s", tooltipText, RANGE_TOOLTIP)
+ else
+ tooltipText = RANGE_TOOLTIP
+ end
+ self:AddLine(
+ 'text', name,
+ 'hasArrow', true,
+ 'hasSlider', true,
+ 'sliderMin', v.min or 0,
+ 'sliderMax', v.max or 1,
+ 'sliderStep', v.step or 0,
+ 'sliderBigStep', v.bigStep or nil,
+ 'sliderIsPercent', v.isPercent or false,
+ 'sliderValue', sliderValue,
+ 'sliderFunc', sliderFunc,
+ 'sliderArg1', sliderArg1,
+ 'sliderArg2', sliderArg2,
+ 'fromAceOptions', true,
+ 'disabled', disabled,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ elseif v.type == "color" then
+ local r,g,b,a = callMethod(name, handler, v_p, "get", passValue)
+ if not r then
+ r,g,b,a = 0,0,0,0
+ end
+ local colorFunc, colorArg1, colorArg2 = getMethod(name, handler, v_p, "set", passValue)
+ self:AddLine(
+ 'text', name,
+ 'hasArrow', true,
+ 'hasColorSwatch', true,
+ 'r', r,
+ 'g', g,
+ 'b', b,
+ 'opacity', v.hasAlpha and a or nil,
+ 'hasOpacity', v.hasAlpha,
+ 'colorFunc', colorFunc,
+ 'colorArg1', colorArg1,
+ 'colorArg2', colorArg2,
+ 'disabled', disabled,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText
+ )
+ elseif v.type == "text" then
+ if type(v.validate) == "table" then
+ local func,arg1,arg2
+ if v.onClick then
+ func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue)
+ end
+ local checked
+ if v.isChecked then
+ checked = callMethod(name, handler, v, "isChecked", passValue) or false
+ end
+ self:AddLine(
+ 'text', name,
+ 'hasArrow', true,
+ 'value', k,
+ 'func', func,
+ 'arg1', arg1,
+ 'arg2', arg2,
+ 'mouseoverUnderline', func and true or nil,
+ 'disabled', disabled,
+ 'checked', checked,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ else
+ local editBoxText
+ editBoxText = callMethod(name, handler, v_p, "get", passValue) or ""
+ local editBoxFunc, editBoxArg1, editBoxArg2 = getMethod(name, handler, v_p, "set", passValue)
+
+ local editBoxValidateFunc, editBoxValidateArg1
+
+ if v.validate and v.validate ~= "keybinding" then
+ if v.validate == "keybinding" then
+ if tooltipText then
+ tooltipText = format("%s\n\n%s", tooltipText, RESET_KEYBINDING_DESC)
+ else
+ tooltipText = RESET_KEYBINDING_DESC
+ end
+ else
+ editBoxValidateFunc, editBoxValidateArg1 = getMethod(name, handler, v, "validate") -- no passvalue!
+ end
+ end
+
+ self:AddLine(
+ 'text', name,
+ 'hasArrow', true,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom,
+ 'hasEditBox', true,
+ 'editBoxText', editBoxText,
+ 'editBoxFunc', editBoxFunc,
+ 'editBoxArg1', editBoxArg1,
+ 'editBoxArg2', editBoxArg2,
+ 'editBoxValidateFunc', editBoxValidateFunc,
+ 'editBoxValidateArg1', editBoxValidateArg1,
+ 'editBoxIsKeybinding', v.validate == "keybinding",
+ 'editBoxKeybindingOnly', v.keybindingOnly,
+ 'editBoxKeybindingExcept', v.keybindingExcept,
+ 'disabled', disabled,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText
+ )
+ end
+ elseif v.type == "group" then
+ local func,arg1,arg2
+ if v.onClick then
+ func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue)
+ end
+ local checked
+ if v.isChecked then
+ checked = callMethod(name, handler, v, "isChecked", passValue) or false
+ end
+ self:AddLine(
+ 'text', name,
+ 'hasArrow', true,
+ 'value', k,
+ 'func', func,
+ 'arg1', arg1,
+ 'arg2', arg2,
+ 'mouseoverUnderline', func and true or nil,
+ 'disabled', disabled,
+ 'checked', checked,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ elseif v.type == "header" then
+ if name == "" or not name then
+ self:AddLine(
+ 'isTitle', true,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ else
+ self:AddLine(
+ 'text', name,
+ 'isTitle', true,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ end
+ end
+ end
+ last_order = v.order or 100
+ end
+ elseif options.type == "text" and type(options.validate) == "table" then
+ local current
+ local options_p = passTable
+ if not options_p or (options.get and options.set) then
+ options_p = options
+ passTable = nil
+ passValue = nil
+ end
+ local multiToggle = options.multiToggle
+ local passValue = options.passValue or passValue
+ if not multiToggle then
+ current = callMethod(k, handler, options_p, "get", passValue)
+ end
+ local indexed = true
+ for k,v in pairs(options.validate) do
+ if type(k) ~= "number" then
+ indexed = false
+ end
+ table.insert(values, k)
+ end
+ if not indexed then
+ if not othersort then
+ othersort = function(alpha, bravo)
+ return othersort_validate[alpha]:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper() < othersort_validate[bravo]:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper()
+ end
+ end
+ othersort_validate = options.validate
+ table.sort(values, othersort)
+ othersort_validate = nil
+ end
+ for _,k in ipairs(values) do
+ local v = options.validate[k]
+ if type(k) == "number" then
+ k = v
+ end
+ local func, arg1, arg2, arg3, arg4 = getMethod(k, handler, options_p, "set", skip1Nil(passValue, k))
+ local checked
+ if multiToggle then
+ checked = callMethod(k, handler, options_p, "get", skip1Nil(passValue, k)) or false
+ if arg2 == nil then
+ arg2 = not checked
+ elseif arg3 == nil then
+ arg3 = not checked
+ else
+ arg4 = not checked
+ end
+ else
+ checked = (k == current or (type(k) == "string" and type(current) == "string" and k:lower() == current:lower()))
+ if checked then
+ func, arg1, arg2, arg3, arg4 = nil, nil, nil, nil, nil
+ end
+ end
+ local tooltipTitle
+ local tooltipText
+ if options.validateDesc then
+ tooltipTitle = v
+ tooltipText = options.validateDesc[k]
+ else
+ tooltipTitle = options.guiName or options.name
+ tooltipText = v
+ end
+ self:AddLine(
+ 'text', v,
+ 'func', func,
+ 'arg1', arg1,
+ 'arg2', arg2,
+ 'arg3', arg3,
+ 'arg4', arg4,
+ 'isRadio', not multiToggle,
+ 'checked', checked,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText
+ )
+ end
+ for k in pairs(values) do
+ values[k] = nil
+ end
+ else
+ return false
+ end
+ return true
+end
+
+function Dewdrop:FeedTable(s, difference)
+ self:argCheck(s, 2, "table")
+ self:argCheck(difference, 3, "nil", "number")
+ if not currentLevel then
+ self:error("Cannot call `FeedTable' outside of a Dewdrop declaration")
+ end
+ if not difference then
+ difference = 0
+ end
+ local level = levels[currentLevel]
+ if not level then
+ self:error("Improper level given")
+ end
+ if not values then
+ values = {}
+ else
+ for k,v in pairs(values) do
+ values[k] = nil
+ end
+ end
+ local t = s.subMenu and s or {subMenu = s}
+ local current = level
+ while current do
+ if current.num == difference + 1 then
+ break
+ end
+ table.insert(values, current.value)
+ current = levels[current.num - 1]
+ end
+
+ while #values > 0 do
+ local value = table.remove(values)
+ t = t.subMenu and t.subMenu[value]
+ if not t then
+ return
+ end
+ end
+
+ if t.subMenu or current.num == 1 then
+ for k in pairs(t.subMenu) do
+ table.insert(values, k)
+ end
+ table.sort(values)
+ for _,k in ipairs(values) do
+ local argTable = {"value", k}
+ for key, val in pairs(t.subMenu[k]) do
+ table.insert(argTable, key)
+ table.insert(argTable, val)
+ end
+ self:AddLine(unpack(argTable))
+ end
+ for k in pairs(values) do
+ values[k] = nil
+ end
+ return false
+ end
+ return true
+end
+
+function Refresh(self, level)
+ if type(level) == "number" then
+ level = levels[level]
+ end
+ if not level then
+ return
+ end
+ if baseFunc then
+ Clear(self, level)
+ currentLevel = level.num
+ if type(baseFunc) == "table" then
+ if currentLevel == 1 then
+ local handler = baseFunc.handler
+ if handler then
+ local name = tostring(handler)
+ if not name:find('^table:') and not handler.hideMenuTitle then
+ name = name:gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
+ self:AddLine(
+ 'text', name,
+ 'isTitle', true
+ )
+ end
+ end
+-- elseif level.parentText then
+-- self:AddLine(
+-- 'text', level.parentText,
+-- 'tooltipTitle', level.parentTooltipTitle,
+-- 'tooltipText', level.parentTooltipText,
+-- 'tooltipFunc', level.parentTooltipFunc,
+-- 'isTitle', true
+-- )
+ end
+ self:FeedAceOptionsTable(baseFunc)
+ if currentLevel == 1 then
+ self:AddLine(
+ 'text', CLOSE,
+ 'tooltipTitle', CLOSE,
+ 'tooltipText', CLOSE_DESC,
+ 'closeWhenClicked', true
+ )
+ end
+ else
+-- if level.parentText then
+-- self:AddLine(
+-- 'text', level.parentText,
+-- 'tooltipTitle', level.parentTooltipTitle,
+-- 'tooltipText', level.parentTooltipText,
+-- 'tooltipFunc', level.parentTooltipFunc,
+-- 'isTitle', true
+-- )
+-- end
+ baseFunc(currentLevel, level.value, levels[level.num - 1] and levels[level.num - 1].value, levels[level.num - 2] and levels[level.num - 2].value, levels[level.num - 3] and levels[level.num - 3].value, levels[level.num - 4] and levels[level.num - 4].value)
+ end
+ currentLevel = nil
+ CheckSize(self, level)
+ end
+end
+
+function Dewdrop:Refresh(level)
+ self:argCheck(level, 2, "number", "nil")
+ if not level then
+ for k,v in pairs(levels) do
+ Refresh(self, v)
+ end
+ else
+ Refresh(self, levels[level])
+ end
+end
+
+function OpenSlider(self, parent)
+ if not sliderFrame then
+ sliderFrame = CreateFrame("Frame", nil, nil, "BackdropTemplate")
+ sliderFrame:SetWidth(100)
+ sliderFrame:SetHeight(170)
+ sliderFrame:SetScale(UIParent:GetScale())
+ sliderFrame:SetBackdrop(tmp(
+ 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
+ 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
+ 'tile', true,
+ 'insets', tmp2(
+ 'left', 5,
+ 'right', 5,
+ 'top', 5,
+ 'bottom', 5
+ ),
+ 'tileSize', 16,
+ 'edgeSize', 16
+ ))
+ sliderFrame:SetFrameStrata("FULLSCREEN_DIALOG")
+ if sliderFrame.SetTopLevel then
+ sliderFrame:SetTopLevel(true)
+ end
+ sliderFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
+ sliderFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
+ sliderFrame:EnableMouse(true)
+ sliderFrame:EnableMouseWheel(true)
+ sliderFrame:Hide()
+ sliderFrame:SetPoint("CENTER", UIParent, "CENTER")
+ local slider = CreateFrame("Slider", nil, sliderFrame, "BackdropTemplate")
+ sliderFrame.slider = slider
+ slider:SetOrientation("VERTICAL")
+ slider:SetMinMaxValues(0, 1)
+ slider:SetValueStep(0.000000001)
+ slider:SetValue(0.5)
+ slider:SetWidth(16)
+ slider:SetHeight(128)
+ slider:SetPoint("LEFT", sliderFrame, "LEFT", 15, 0)
+ slider:SetBackdrop(tmp(
+ 'bgFile', "Interface\\Buttons\\UI-SliderBar-Background",
+ 'edgeFile', "Interface\\Buttons\\UI-SliderBar-Border",
+ 'tile', true,
+ 'edgeSize', 8,
+ 'tileSize', 8,
+ 'insets', tmp2(
+ 'left', 3,
+ 'right', 3,
+ 'top', 3,
+ 'bottom', 3
+ )
+ ))
+ local texture = slider:CreateTexture()
+ slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
+ local text = slider:CreateFontString(nil, "ARTWORK")
+ sliderFrame.topText = text
+ text:SetFontObject(GameFontGreenSmall)
+ text:SetText("100%")
+ text:SetPoint("BOTTOM", slider, "TOP")
+ local text = slider:CreateFontString(nil, "ARTWORK")
+ sliderFrame.bottomText = text
+ text:SetFontObject(GameFontGreenSmall)
+ text:SetText("0%")
+ text:SetPoint("TOP", slider, "BOTTOM")
+ local editBox = CreateFrame("EditBox", nil, sliderFrame)
+ sliderFrame.currentText = editBox
+ editBox:SetFontObject(ChatFontNormal)
+ editBox:SetHeight(13)
+ editBox:SetPoint("RIGHT", sliderFrame, "RIGHT", -16, 0)
+ editBox:SetPoint("LEFT", slider, "RIGHT", 12, 0)
+ editBox:SetText("50%")
+ editBox:SetJustifyH("CENTER")
+
+ local width = editBox:GetWidth()/2 + 10
+ local left = editBox:CreateTexture(nil, "BACKGROUND")
+ left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left")
+ left:SetTexCoord(0, width / 256, 0, 1)
+ left:SetWidth(width)
+ left:SetHeight(32)
+ left:SetPoint("LEFT", editBox, "LEFT", -10, 0)
+ local right = editBox:CreateTexture(nil, "BACKGROUND")
+ right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right")
+ right:SetTexCoord(1 - width / 256, 1, 0, 1)
+ right:SetWidth(width)
+ right:SetHeight(32)
+ right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0)
+
+ local changed = false
+ local inside = false
+ slider:SetScript("OnValueChanged", function()
+ if sliderFrame.changing then
+ return
+ end
+ changed = true
+ local done = false
+ if sliderFrame.parent and sliderFrame.parent.sliderFunc then
+ local min = sliderFrame.parent.sliderMin or 0
+ local max = sliderFrame.parent.sliderMax or 1
+ local step
+ if sliderFrame.fineStep then
+ step = sliderFrame.parent.sliderStep or (max - min) / 100
+ else
+ step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100
+ end
+ local value = (1 - slider:GetValue()) * (max - min) + min
+ if step > 0 then
+ value = math.floor((value - min) / step + 0.5) * step + min
+ if value > max then
+ value = max
+ elseif value < min then
+ value = min
+ end
+ end
+ if value == sliderFrame.lastValue then
+ return
+ end
+ sliderFrame.lastValue = value
+ local text = sliderFrame.parent.sliderFunc(getArgs(sliderFrame.parent, 'sliderArg', 1, value))
+ if sliderFrame.parent.fromAceOptions then
+ text = nil
+ elseif type(text) == "string" or type(text) == "number" then
+ sliderFrame.currentText:SetText(text)
+ done = true
+ end
+ end
+ if not done then
+ local min = sliderFrame.parent.sliderMin or 0
+ local max = sliderFrame.parent.sliderMax or 1
+ local step
+ if sliderFrame.fineStep then
+ step = sliderFrame.parent.sliderStep or (max - min) / 100
+ else
+ step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100
+ end
+ local value = (1 - slider:GetValue()) * (max - min) + min
+ if step > 0 then
+ value = math.floor((value - min) / step + 0.5) * step + min
+ if value > max then
+ value = max
+ elseif value < min then
+ value = min
+ end
+ end
+ if sliderFrame.parent.sliderIsPercent then
+ sliderFrame.currentText:SetText(string.format("%.0f%%", value * 100))
+ else
+ if step < 0.1 then
+ sliderFrame.currentText:SetText(string.format("%.2f", value))
+ elseif step < 1 then
+ sliderFrame.currentText:SetText(string.format("%.1f", value))
+ else
+ sliderFrame.currentText:SetText(string.format("%.0f", value))
+ end
+ end
+ end
+ end)
+ local function onEnter()
+ StopCounting(self, sliderFrame.level)
+ showGameTooltip(sliderFrame.parent)
+ end
+ local function onLeave()
+ GameTooltip:Hide()
+ end
+ sliderFrame:SetScript("OnEnter", onEnter)
+ sliderFrame:SetScript("OnLeave", function()
+ GameTooltip:Hide()
+ if changed then
+ local parent = sliderFrame.parent
+ local sliderFunc = parent.sliderFunc
+ for i = 1, sliderFrame.level - 1 do
+ Refresh(self, levels[i])
+ end
+ local newParent
+ for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
+ if button.sliderFunc == sliderFunc then
+ newParent = button
+ break
+ end
+ end
+ if newParent then
+ OpenSlider(self, newParent)
+ else
+ sliderFrame:Hide()
+ end
+ end
+ end)
+ editBox:SetScript("OnEnter", onEnter)
+ editBox:SetScript("OnLeave", onLeave)
+ slider:SetScript("OnMouseDown", function()
+ sliderFrame.mouseDown = true
+ GameTooltip:Hide()
+ end)
+ slider:SetScript("OnMouseUp", function()
+ sliderFrame.mouseDown = false
+ if changed--[[ and not inside]] then
+ local parent = sliderFrame.parent
+ local sliderFunc = parent.sliderFunc
+ for i = 1, sliderFrame.level - 1 do
+ Refresh(self, levels[i])
+ end
+ local newParent
+ for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
+ if button.sliderFunc == sliderFunc then
+ newParent = button
+ break
+ end
+ end
+ if newParent then
+ OpenSlider(self, newParent)
+ else
+ sliderFrame:Hide()
+ end
+ end
+ if inside then
+ showGameTooltip(sliderFrame.parent)
+ end
+ end)
+ slider:SetScript("OnEnter", function()
+ inside = true
+ StopCounting(self, sliderFrame.level)
+ showGameTooltip(sliderFrame.parent)
+ end)
+ slider:SetScript("OnLeave", function()
+ inside = false
+ GameTooltip:Hide()
+ if changed and not sliderFrame.mouseDown then
+ local parent = sliderFrame.parent
+ local sliderFunc = parent.sliderFunc
+ for i = 1, sliderFrame.level - 1 do
+ Refresh(self, levels[i])
+ end
+ local newParent
+ for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
+ if button.sliderFunc == sliderFunc then
+ newParent = button
+ break
+ end
+ end
+ if newParent then
+ OpenSlider(self, newParent)
+ else
+ sliderFrame:Hide()
+ end
+
+ changed = false
+ end
+ end)
+ sliderFrame:SetScript("OnMouseWheel", function(t, a1)
+ local arg1 = a1 or arg1
+ local up = arg1 > 0
+
+ local min = sliderFrame.parent.sliderMin or 0
+ local max = sliderFrame.parent.sliderMax or 1
+ local step = sliderFrame.parent.sliderStep or (max - min) / 100
+ if step <= 0 then
+ step = (max - min) / 100
+ end
+
+ local value = (1 - slider:GetValue()) * (max - min) + min
+ if up then
+ value = value + step
+ else
+ value = value - step
+ end
+ if value > max then
+ value = max
+ elseif value < min then
+ value = min
+ end
+ sliderFrame.fineStep = true
+ if max<=min then
+ slider:SetValue(0)
+ else
+ slider:SetValue(1 - (value - min) / (max - min))
+ end
+ sliderFrame.fineStep = nil
+ end)
+ slider:SetScript("OnMouseWheel", sliderFrame:GetScript("OnMouseWheel"))
+ editBox:SetScript("OnEnterPressed", function(t, a1)
+ local value = editBox:GetNumber()
+
+ if sliderFrame.parent.sliderIsPercent then
+ value = value / 100
+ end
+
+ local min = sliderFrame.parent.sliderMin or 0
+ local max = sliderFrame.parent.sliderMax or 1
+
+ if value > max then
+ value = max
+ elseif value < min then
+ value = min
+ end
+ sliderFrame.fineStep = true
+ if max <= min then
+ slider:SetValue(0)
+ else
+ slider:SetValue(1 - (value - min) / (max - min))
+ end
+ sliderFrame.fineStep = nil
+
+ StartCounting(self, sliderFrame.level)
+ end)
+ editBox:SetScript("OnEscapePressed", function()
+ self:Close(sliderFrame.level)
+ StartCounting(self, sliderFrame.level)
+ end)
+ editBox:SetAutoFocus(false)
+ end
+ sliderFrame.parent = parent
+ sliderFrame.level = parent.level.num + 1
+ sliderFrame.parentValue = parent.level.value
+ sliderFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3)
+ sliderFrame.slider:SetFrameLevel(sliderFrame:GetFrameLevel() + 1)
+ sliderFrame.currentText:SetFrameLevel(sliderFrame:GetFrameLevel() + 1)
+ sliderFrame.currentText:ClearFocus()
+ sliderFrame.changing = true
+ if not parent.sliderMin or not parent.sliderMax then
+ return
+ end
+
+ if parent.arrow then
+-- parent.arrow:SetVertexColor(0.2, 0.6, 0)
+-- parent.arrow:SetHeight(24)
+-- parent.arrow:SetWidth(24)
+ parent.selected = true
+ parent.highlight:Show()
+ end
+
+ sliderFrame:SetClampedToScreen(false)
+ if not parent.sliderValue then
+ parent.sliderValue = (parent.sliderMin + parent.sliderMax) / 2
+ end
+ if parent.sliderMax <= parent.sliderMin then
+ sliderFrame.slider:SetValue(0)
+ else
+ sliderFrame.slider:SetValue(1 - (parent.sliderValue - parent.sliderMin) / (parent.sliderMax - parent.sliderMin))
+ end
+ sliderFrame.changing = false
+ sliderFrame.bottomText:SetText(parent.sliderMinText or "0")
+ sliderFrame.topText:SetText(parent.sliderMaxText or "1")
+ local text
+ if parent.sliderFunc and not parent.fromAceOptions then
+ text = parent.sliderFunc(getArgs(parent, 'sliderArg', 1, parent.sliderValue))
+ end
+ if type(text) == "number" or type(text) == "string" then
+ sliderFrame.currentText:SetText(text)
+ elseif parent.sliderIsPercent then
+ sliderFrame.currentText:SetText(string.format("%.0f%%", parent.sliderValue * 100))
+ else
+ if parent.sliderStep < 0.1 then
+ sliderFrame.currentText:SetText(string.format("%.2f", parent.sliderValue))
+ elseif parent.sliderStep < 1 then
+ sliderFrame.currentText:SetText(string.format("%.1f", parent.sliderValue))
+ else
+ sliderFrame.currentText:SetText(string.format("%.0f", parent.sliderValue))
+ end
+ end
+
+
+ sliderFrame.lastValue = parent.sliderValue
+
+ local level = parent.level
+ sliderFrame:Show()
+ sliderFrame:ClearAllPoints()
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ local dirty
+ if level.lastDirection == "RIGHT" then
+ if sliderFrame:GetRight() > GetScreenWidth() then
+ level.lastDirection = "LEFT"
+ dirty = true
+ end
+ elseif sliderFrame:GetLeft() < 0 then
+ level.lastDirection = "RIGHT"
+ dirty = true
+ end
+ if level.lastVDirection == "DOWN" then
+ if sliderFrame:GetBottom() < 0 then
+ level.lastVDirection = "UP"
+ dirty = true
+ end
+ elseif sliderFrame:GetTop() > GetScreenWidth() then
+ level.lastVDirection = "DOWN"
+ dirty = true
+ end
+ if dirty then
+ sliderFrame:ClearAllPoints()
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ end
+ local left, bottom = sliderFrame:GetLeft(), sliderFrame:GetBottom()
+ sliderFrame:ClearAllPoints()
+ sliderFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
+ if mod(level.num, 5) == 0 then
+ local left, bottom = level:GetLeft(), level:GetBottom()
+ level:ClearAllPoints()
+ level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
+ end
+ sliderFrame:SetClampedToScreen(true)
+end
+
+function OpenEditBox(self, parent)
+ if not editBoxFrame then
+ editBoxFrame = CreateFrame("Frame", nil, nil, "BackdropTemplate")
+ editBoxFrame:SetWidth(200)
+ editBoxFrame:SetHeight(40)
+ editBoxFrame:SetScale(UIParent:GetScale())
+ editBoxFrame:SetBackdrop(tmp(
+ 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
+ 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
+ 'tile', true,
+ 'insets', tmp2(
+ 'left', 5,
+ 'right', 5,
+ 'top', 5,
+ 'bottom', 5
+ ),
+ 'tileSize', 16,
+ 'edgeSize', 16
+ ))
+ editBoxFrame:SetFrameStrata("FULLSCREEN_DIALOG")
+ if editBoxFrame.SetTopLevel then
+ editBoxFrame:SetTopLevel(true)
+ end
+ editBoxFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
+ editBoxFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
+ editBoxFrame:EnableMouse(true)
+ editBoxFrame:EnableMouseWheel(true)
+ editBoxFrame:Hide()
+ editBoxFrame:SetPoint("CENTER", UIParent, "CENTER")
+
+ local editBox = CreateFrame("EditBox", nil, editBoxFrame)
+ editBoxFrame.editBox = editBox
+ editBox:SetFontObject(ChatFontNormal)
+ editBox:SetWidth(160)
+ editBox:SetHeight(13)
+ editBox:SetPoint("CENTER", editBoxFrame, "CENTER", 0, 0)
+
+ local left = editBox:CreateTexture(nil, "BACKGROUND")
+ left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left")
+ left:SetTexCoord(0, 100 / 256, 0, 1)
+ left:SetWidth(100)
+ left:SetHeight(32)
+ left:SetPoint("LEFT", editBox, "LEFT", -10, 0)
+ local right = editBox:CreateTexture(nil, "BACKGROUND")
+ right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right")
+ right:SetTexCoord(156/256, 1, 0, 1)
+ right:SetWidth(100)
+ right:SetHeight(32)
+ right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0)
+
+ editBox:SetScript("OnEnterPressed", function()
+ if editBoxFrame.parent and editBoxFrame.parent.editBoxValidateFunc then
+ local t = editBox.realText or editBox:GetText() or ""
+ local result = editBoxFrame.parent.editBoxValidateFunc(getArgs(editBoxFrame.parent, 'editBoxValidateArg', 1, t))
+ if not result then
+ UIErrorsFrame:AddMessage(VALIDATION_ERROR, 1, 0, 0)
+ return
+ end
+ end
+ if editBoxFrame.parent and editBoxFrame.parent.editBoxFunc then
+ local t
+ if editBox.realText ~= "NONE" then
+ t = editBox.realText or editBox:GetText() or ""
+ end
+ editBoxFrame.parent.editBoxFunc(getArgs(editBoxFrame.parent, 'editBoxArg', 1, t))
+ end
+ self:Close(editBoxFrame.level)
+ for i = 1, editBoxFrame.level - 1 do
+ Refresh(self, levels[i])
+ end
+ StartCounting(self, editBoxFrame.level-1)
+ end)
+ editBox:SetScript("OnEscapePressed", function()
+ self:Close(editBoxFrame.level)
+ StartCounting(self, editBoxFrame.level-1)
+ end)
+ editBox:SetScript("OnReceiveDrag", function(this)
+ if GetCursorInfo then
+ local type, alpha, bravo = GetCursorInfo()
+ local text
+ if type == "spell" then
+ text = GetSpellName(alpha, bravo)
+ elseif type == "item" then
+ text = bravo
+ end
+ if not text then
+ return
+ end
+ ClearCursor()
+ editBox:SetText(text)
+ end
+ end)
+ local changing = false
+ local skipNext = false
+
+ function editBox:SpecialSetText(text)
+ local oldText = editBox:GetText() or ""
+ if not text then
+ text = ""
+ end
+ if text ~= oldText then
+ changing = true
+ self:SetText(tostring(text))
+ changing = false
+ skipNext = true
+ end
+ end
+
+ editBox:SetScript("OnTextChanged", function()
+ if skipNext then
+ skipNext = false
+ elseif not changing and editBoxFrame.parent and editBoxFrame.parent.editBoxChangeFunc then
+ local t
+ if editBox.realText ~= "NONE" then
+ t = editBox.realText or editBox:GetText() or ""
+ end
+ local text = editBoxFrame.parent.editBoxChangeFunc(getArgs(editBoxFrame.parent, 'editBoxChangeArg', 1, t))
+ if text then
+ editBox:SpecialSetText(text)
+ end
+ end
+ end)
+ editBoxFrame:SetScript("OnEnter", function()
+ StopCounting(self, editBoxFrame.level)
+ showGameTooltip(editBoxFrame.parent)
+ end)
+ editBoxFrame:SetScript("OnLeave", function()
+ GameTooltip:Hide()
+ end)
+ editBox:SetScript("OnEnter", function()
+ StopCounting(self, editBoxFrame.level)
+ showGameTooltip(editBoxFrame.parent)
+ end)
+ editBox:SetScript("OnLeave", function()
+ GameTooltip:Hide()
+ end)
+ editBoxFrame:SetScript("OnKeyDown", function(this, a1)
+ if not editBox.keybinding then
+ return
+ end
+ local arg1 = a1 or arg1
+ local screenshotKey = GetBindingKey("SCREENSHOT")
+ if screenshotKey and arg1 == screenshotKey then
+ Screenshot()
+ return
+ end
+
+ if arg1 == "LeftButton" then
+ arg1 = "BUTTON1"
+ elseif arg1 == "RightButton" then
+ arg1 = "BUTTON2"
+ elseif arg1 == "MiddleButton" then
+ arg1 = "BUTTON3"
+ elseif arg1 == "Button4" then
+ arg1 = "BUTTON4"
+ elseif arg1 == "Button5" then
+ arg1 = "BUTTON5"
+ end
+ if arg1 == "UNKNOWN" then
+ return
+ elseif arg1 == "SHIFT" or arg1 == "CTRL" or arg1 == "ALT" then
+ return
+ elseif arg1 == "ENTER" then
+ if editBox.keybindingOnly and not editBox.keybindingOnly[editBox.realText] then
+ return editBox:GetScript("OnEscapePressed")()
+ elseif editBox.keybindingExcept and editBox.keybindingExcept[editBox.realText] then
+ return editBox:GetScript("OnEscapePressed")()
+ else
+ return editBox:GetScript("OnEnterPressed")()
+ end
+ elseif arg1 == "ESCAPE" then
+ if editBox.realText == "NONE" then
+ return editBox:GetScript("OnEscapePressed")()
+ else
+ editBox:SpecialSetText(NONE or "NONE")
+ editBox.realText = "NONE"
+ return
+ end
+ elseif editBox.keybindingOnly and not editBox.keybindingOnly[arg1] then
+ return
+ elseif editBox.keybindingExcept and editBox.keybindingExcept[arg1] then
+ return
+ end
+ local s = GetBindingText(arg1, "KEY_")
+ if s == "BUTTON1" then
+ s = KEY_BUTTON1
+ elseif s == "BUTTON2" then
+ s = KEY_BUTTON2
+ end
+ local real = arg1
+ if IsShiftKeyDown() then
+ s = "Shift-" .. s
+ real = "SHIFT-" .. real
+ end
+ if IsControlKeyDown() then
+ s = "Ctrl-" .. s
+ real = "CTRL-" .. real
+ end
+ if IsAltKeyDown() then
+ s = "Alt-" .. s
+ real = "ALT-" .. real
+ end
+ if editBox:GetText() ~= s then
+ editBox:SpecialSetText("-")
+ editBox:SpecialSetText(s)
+ editBox.realText = real
+ return editBox:GetScript("OnTextChanged")()
+ end
+ end)
+ editBoxFrame:SetScript("OnMouseDown", editBoxFrame:GetScript("OnKeyDown"))
+ editBox:SetScript("OnMouseDown", function(this, ...)
+ if GetCursorInfo and (CursorHasItem() or CursorHasSpell()) then
+ return editBox:GetScript("OnReceiveDrag")(this, ...)
+ end
+ return editBoxFrame:GetScript("OnKeyDown")(this, ...)
+ end)
+ editBoxFrame:SetScript("OnMouseWheel", function(t, a1)
+ local arg1 = a1 or arg1
+ local up = arg1 > 0
+ arg1 = up and "MOUSEWHEELUP" or "MOUSEWHEELDOWN"
+ return editBoxFrame:GetScript("OnKeyDown")(t or this, arg1)
+ end)
+ editBox:SetScript("OnMouseWheel", editBoxFrame:GetScript("OnMouseWheel"))
+ end
+ editBoxFrame.parent = parent
+ editBoxFrame.level = parent.level.num + 1
+ editBoxFrame.parentValue = parent.level.value
+ editBoxFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3)
+ editBoxFrame.editBox:SetFrameLevel(editBoxFrame:GetFrameLevel() + 1)
+ editBoxFrame.editBox.realText = nil
+ editBoxFrame:SetClampedToScreen(false)
+
+ editBoxFrame.editBox:SpecialSetText("")
+ if parent.editBoxIsKeybinding then
+ local s = parent.editBoxText
+ if s == "" then
+ s = "NONE"
+ end
+ editBoxFrame.editBox.realText = s
+ if s and s ~= "NONE" then
+ local alpha,bravo = s:match("^(.+)%-(.+)$")
+ if not bravo then
+ alpha = nil
+ bravo = s
+ end
+ bravo = GetBindingText(bravo, "KEY_")
+ if alpha then
+ editBoxFrame.editBox:SpecialSetText(alpha:upper() .. "-" .. bravo)
+ else
+ editBoxFrame.editBox:SpecialSetText(bravo)
+ end
+ else
+ editBoxFrame.editBox:SpecialSetText(NONE or "NONE")
+ end
+ else
+ editBoxFrame.editBox:SpecialSetText(parent.editBoxText)
+ end
+
+ editBoxFrame.editBox.keybinding = parent.editBoxIsKeybinding
+ editBoxFrame.editBox.keybindingOnly = parent.editBoxKeybindingOnly
+ editBoxFrame.editBox.keybindingExcept = parent.editBoxKeybindingExcept
+ editBoxFrame.editBox:EnableKeyboard(not parent.editBoxIsKeybinding)
+ editBoxFrame:EnableKeyboard(parent.editBoxIsKeybinding)
+
+ if parent.arrow then
+-- parent.arrow:SetVertexColor(0.2, 0.6, 0)
+-- parent.arrow:SetHeight(24)
+-- parent.arrow:SetWidth(24)
+ parent.selected = true
+ parent.highlight:Show()
+ end
+
+ local level = parent.level
+ editBoxFrame:Show()
+ editBoxFrame:ClearAllPoints()
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ local dirty
+ if level.lastDirection == "RIGHT" then
+ if editBoxFrame:GetRight() > GetScreenWidth() then
+ level.lastDirection = "LEFT"
+ dirty = true
+ end
+ elseif editBoxFrame:GetLeft() < 0 then
+ level.lastDirection = "RIGHT"
+ dirty = true
+ end
+ if level.lastVDirection == "DOWN" then
+ if editBoxFrame:GetBottom() < 0 then
+ level.lastVDirection = "UP"
+ dirty = true
+ end
+ elseif editBoxFrame:GetTop() > GetScreenWidth() then
+ level.lastVDirection = "DOWN"
+ dirty = true
+ end
+ if dirty then
+ editBoxFrame:ClearAllPoints()
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ end
+ local left, bottom = editBoxFrame:GetLeft(), editBoxFrame:GetBottom()
+ editBoxFrame:ClearAllPoints()
+ editBoxFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
+ if mod(level.num, 5) == 0 then
+ local left, bottom = level:GetLeft(), level:GetBottom()
+ level:ClearAllPoints()
+ level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
+ end
+ editBoxFrame:SetClampedToScreen(true)
+end
+
+function Dewdrop:EncodeKeybinding(text)
+ if text == nil or text == "NONE" then
+ return nil
+ end
+ text = tostring(text):upper()
+ local shift, ctrl, alt
+ local modifier
+ while true do
+ if text == "-" then
+ break
+ end
+ modifier, text = strsplit('-', text, 2)
+ if text then
+ if modifier ~= "SHIFT" and modifier ~= "CTRL" and modifier ~= "ALT" then
+ return false
+ end
+ if modifier == "SHIFT" then
+ if shift then
+ return false
+ end
+ shift = true
+ end
+ if modifier == "CTRL" then
+ if ctrl then
+ return false
+ end
+ ctrl = true
+ end
+ if modifier == "ALT" then
+ if alt then
+ return false
+ end
+ alt = true
+ end
+ else
+ text = modifier
+ break
+ end
+ end
+ if not text:find("^F%d+$") and text ~= "CAPSLOCK" and text:len() ~= 1 and (text:len() == 0 or text:byte() < 128 or text:len() > 4) and not _G["KEY_" .. text] and text ~= "BUTTON1" and text ~= "BUTTON2" then
+ return false
+ end
+ local s = GetBindingText(text, "KEY_")
+ if s == "BUTTON1" then
+ s = KEY_BUTTON1
+ elseif s == "BUTTON2" then
+ s = KEY_BUTTON2
+ end
+ if shift then
+ s = "Shift-" .. s
+ end
+ if ctrl then
+ s = "Ctrl-" .. s
+ end
+ if alt then
+ s = "Alt-" .. s
+ end
+ return s
+end
+
+function Dewdrop:IsOpen(parent)
+ self:argCheck(parent, 2, "table", "string", "nil")
+ return levels[1] and levels[1]:IsShown() and (not parent or parent == levels[1].parent or parent == levels[1]:GetParent())
+end
+
+function Dewdrop:GetOpenedParent()
+ return (levels[1] and levels[1]:IsShown()) and (levels[1].parent or levels[1]:GetParent())
+end
+
+function Open(self, parent, func, level, value, point, relativePoint, cursorX, cursorY)
+ self:Close(level)
+ if DewdropLib then
+ local d = DewdropLib:GetInstance('1.0')
+ local ret, val = pcall(d, IsOpen, d)
+ if ret and val then
+ DewdropLib:GetInstance('1.0'):Close()
+ end
+ end
+ if type(parent) == "table" then
+ parent:GetCenter()
+ end
+ local frame = AcquireLevel(self, level)
+ if level == 1 then
+ frame.lastDirection = "RIGHT"
+ frame.lastVDirection = "DOWN"
+ else
+ frame.lastDirection = levels[level - 1].lastDirection
+ frame.lastVDirection = levels[level - 1].lastVDirection
+ end
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ frame:ClearAllPoints()
+ frame.parent = parent
+ frame:SetPoint("LEFT", UIParent, "RIGHT", 10000, 0)
+ frame:Show()
+ if level == 1 then
+ baseFunc = func
+ end
+ levels[level].value = value
+-- levels[level].parentText = parent.text and parent.text:GetText() or nil
+-- levels[level].parentTooltipTitle = parent.tooltipTitle
+-- levels[level].parentTooltipText = parent.tooltipText
+-- levels[level].parentTooltipFunc = parent.tooltipFunc
+ if type(parent) == "table" and parent.arrow then
+-- parent.arrow:SetVertexColor(0.2, 0.6, 0)
+-- parent.arrow:SetHeight(24)
+-- parent.arrow:SetWidth(24)
+ parent.selected = true
+ parent.highlight:Show()
+ end
+ relativePoint = relativePoint or point
+ Refresh(self, levels[level])
+ if point or (cursorX and cursorY) then
+ frame:ClearAllPoints()
+ if cursorX and cursorY then
+ local curX, curY = GetScaledCursorPosition()
+ if curY < GetScreenHeight() / 2 then
+ point, relativePoint = "BOTTOM", "BOTTOM"
+ else
+ point, relativePoint = "TOP", "TOP"
+ end
+ if curX < GetScreenWidth() / 2 then
+ point, relativePoint = point .. "LEFT", relativePoint .. "RIGHT"
+ else
+ point, relativePoint = point .. "RIGHT", relativePoint .. "LEFT"
+ end
+ end
+ frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint)
+ if cursorX and cursorY then
+ local left = frame:GetLeft()
+ local width = frame:GetWidth()
+ local bottom = frame:GetBottom()
+ local height = frame:GetHeight()
+ local curX, curY = GetScaledCursorPosition()
+ frame:ClearAllPoints()
+ relativePoint = relativePoint or point
+ if point == "BOTTOM" or point == "TOP" then
+ if curX < GetScreenWidth() / 2 then
+ point = point .. "LEFT"
+ else
+ point = point .. "RIGHT"
+ end
+ elseif point == "CENTER" then
+ if curX < GetScreenWidth() / 2 then
+ point = "LEFT"
+ else
+ point = "RIGHT"
+ end
+ end
+ local xOffset, yOffset = 0, 0
+ if curY > GetScreenHeight() / 2 then
+ yOffset = -height
+ end
+ if curX > GetScreenWidth() / 2 then
+ xOffset = -width
+ end
+ frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left + xOffset, curY - bottom + yOffset)
+ if level == 1 then
+ frame.lastDirection = "RIGHT"
+ end
+ elseif cursorX then
+ local left = frame:GetLeft()
+ local width = frame:GetWidth()
+ local curX, curY = GetScaledCursorPosition()
+ frame:ClearAllPoints()
+ relativePoint = relativePoint or point
+ if point == "BOTTOM" or point == "TOP" then
+ if curX < GetScreenWidth() / 2 then
+ point = point .. "LEFT"
+ else
+ point = point .. "RIGHT"
+ end
+ elseif point == "CENTER" then
+ if curX < GetScreenWidth() / 2 then
+ point = "LEFT"
+ else
+ point = "RIGHT"
+ end
+ end
+ frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left - width / 2, 0)
+ if level == 1 then
+ frame.lastDirection = "RIGHT"
+ end
+ elseif cursorY then
+ local bottom = frame:GetBottom()
+ local height = frame:GetHeight()
+ local curX, curY = GetScaledCursorPosition()
+ frame:ClearAllPoints()
+ relativePoint = relativePoint or point
+ if point == "LEFT" or point == "RIGHT" then
+ if curX < GetScreenHeight() / 2 then
+ point = point .. "BOTTOM"
+ else
+ point = point .. "TOP"
+ end
+ elseif point == "CENTER" then
+ if curX < GetScreenHeight() / 2 then
+ point = "BOTTOM"
+ else
+ point = "TOP"
+ end
+ end
+ frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, 0, curY - bottom - height / 2)
+ if level == 1 then
+ frame.lastDirection = "DOWN"
+ end
+ end
+ if (strsub(point, 1, 3) ~= strsub(relativePoint, 1, 3)) then
+ if frame:GetBottom() < 0 then
+ local point, parent, relativePoint, x, y = frame:GetPoint(1)
+ local change = GetScreenHeight() - frame:GetTop()
+ local otherChange = -frame:GetBottom()
+ if otherChange < change then
+ change = otherChange
+ end
+ frame:SetPoint(point, parent, relativePoint, x, y + change)
+ elseif frame:GetTop() > GetScreenHeight() then
+ local point, parent, relativePoint, x, y = frame:GetPoint(1)
+ local change = GetScreenHeight() - frame:GetTop()
+ local otherChange = -frame:GetBottom()
+ if otherChange < change then
+ change = otherChange
+ end
+ frame:SetPoint(point, parent, relativePoint, x, y + change)
+ end
+ end
+ end
+ CheckDualMonitor(self, frame)
+ frame:SetClampedToScreen(true)
+ frame:SetClampedToScreen(false)
+ StartCounting(self, level)
+end
+
+function Dewdrop:IsRegistered(parent)
+ self:argCheck(parent, 2, "table", "string")
+ return not not self.registry[parent]
+end
+
+function Dewdrop:Register(parent, ...)
+ self:argCheck(parent, 2, "table", "string")
+ if self.registry[parent] then
+ self:Unregister(parent)
+ end
+ local info = new(...)
+ if type(info.children) == "table" then
+ local err, position = validateOptions(info.children)
+
+ if err then
+ if position then
+ Dewdrop:error(position .. ": " .. err)
+ else
+ Dewdrop:error(err)
+ end
+ end
+ end
+ self.registry[parent] = info
+ if not info.dontHook and not self.onceRegistered[parent] and type(parent) == "table" then
+ if parent:HasScript("OnMouseUp") then
+ local script = parent:GetScript("OnMouseUp")
+ parent:SetScript("OnMouseUp", function(this, ...)
+ local arg1 = ...
+ if script then
+ script(this, ...)
+ end
+ if arg1 == "RightButton" and self.registry[parent] then
+ if self:IsOpen(parent) then
+ self:Close()
+ else
+ self:Open(parent)
+ end
+ end
+ end)
+ end
+ if parent:HasScript("OnMouseDown") then
+ local script = parent:GetScript("OnMouseDown")
+ parent:SetScript("OnMouseDown", function(this, ...)
+ if script then
+ script(this, ...)
+ end
+ if self.registry[parent] then
+ self:Close()
+ end
+ end)
+ end
+ end
+ self.onceRegistered[parent] = true
+end
+
+function Dewdrop:Unregister(parent)
+ self:argCheck(parent, 2, "table", "string")
+ self.registry[parent] = nil
+end
+
+function Dewdrop:Open(parent, ...)
+ self:argCheck(parent, 2, "table", "string")
+ local info
+ local k1 = ...
+ if type(k1) == "table" and k1[0] and k1.IsObjectType and self.registry[k1] then
+ info = tmp(select(2, ...))
+ for k,v in pairs(self.registry[k1]) do
+ if info[k] == nil then
+ info[k] = v
+ end
+ end
+ else
+ info = tmp(...)
+ if self.registry[parent] then
+ for k,v in pairs(self.registry[parent]) do
+ if info[k] == nil then
+ info[k] = v
+ end
+ end
+ end
+ end
+ local point = info.point
+ local relativePoint = info.relativePoint
+ local cursorX = info.cursorX
+ local cursorY = info.cursorY
+ if type(point) == "function" then
+ local b
+ point, b = point(parent)
+ if b then
+ relativePoint = b
+ end
+ end
+ if type(relativePoint) == "function" then
+ relativePoint = relativePoint(parent)
+ end
+ Open(self, parent, info.children, 1, nil, point, relativePoint, cursorX, cursorY)
+end
+
+function Clear(self, level)
+ if level then
+ if level.buttons then
+ for i = #level.buttons, 1, -1 do
+ ReleaseButton(self, level, i)
+ end
+ end
+ end
+end
+
+function Dewdrop:Close(level)
+ if DropDownList1:IsShown() then
+ DropDownList1:Hide()
+ end
+ if DewdropLib then
+ local d = DewdropLib:GetInstance('1.0')
+ local ret, val = pcall(d, IsOpen, d)
+ if ret and val then
+ DewdropLib:GetInstance('1.0'):Close()
+ end
+ end
+ self:argCheck(level, 2, "number", "nil")
+ if not level then
+ level = 1
+ end
+ if level == 1 and levels[level] then
+ levels[level].parented = false
+ end
+ if level > 1 and levels[level-1].buttons then
+ local buttons = levels[level-1].buttons
+ for _,button in ipairs(buttons) do
+-- button.arrow:SetWidth(16)
+-- button.arrow:SetHeight(16)
+ button.selected = nil
+ button.highlight:Hide()
+-- button.arrow:SetVertexColor(1, 1, 1)
+ end
+ end
+ if sliderFrame and sliderFrame.level >= level then
+ sliderFrame:Hide()
+ end
+ if editBoxFrame and editBoxFrame.level >= level then
+ editBoxFrame:Hide()
+ end
+ for i = level, #levels do
+ Clear(self, levels[level])
+ levels[i]:Hide()
+ levels[i]:ClearAllPoints()
+ levels[i]:SetPoint("CENTER", UIParent, "CENTER")
+ levels[i].value = nil
+ end
+end
+
+function Dewdrop:AddSeparator(level)
+ level = levels[level or currentLevel]
+ if not level or not level.buttons then return; end
+
+ local prevbutton = level.buttons[#level.buttons]
+ if not prevbutton then return; end
+
+ if prevbutton.disabled and prevbutton.text:GetText() == "" then
+ return
+ end
+ self:AddLine("text", "", "disabled", true)
+end
+
+function Dewdrop:AddLine(...)
+ local info = tmp(...)
+ local level = info.level or currentLevel
+ info.level = nil
+ local button = AcquireButton(self, level)
+ if not next(info) then
+ info.disabled = true
+ end
+ button.disabled = info.isTitle or info.notClickable or info.disabled or (self.combat and info.secure)
+ button.isTitle = info.isTitle
+ button.notClickable = info.notClickable
+ if button.isTitle then
+ button.text:SetFontObject(GameFontNormalSmall)
+ elseif button.notClickable then
+ button.text:SetFontObject(GameFontHighlightSmall)
+ elseif button.disabled then
+ button.text:SetFontObject(GameFontDisableSmall)
+ else
+ button.text:SetFontObject(GameFontHighlightSmall)
+ end
+ if info.disabled then
+ button.arrow:SetDesaturated(true)
+ button.check:SetDesaturated(true)
+ else
+ button.arrow:SetDesaturated(false)
+ button.check:SetDesaturated(false)
+ end
+ if info.textR and info.textG and info.textB then
+ button.textR = info.textR
+ button.textG = info.textG
+ button.textB = info.textB
+ button.text:SetTextColor(button.textR, button.textG, button.textB)
+ else
+ button.text:SetTextColor(button.text:GetFontObject():GetTextColor())
+ end
+ button.notCheckable = info.notCheckable
+ button.text:SetPoint("LEFT", button, "LEFT", button.notCheckable and 0 or 24, 0)
+ button.checked = not info.notCheckable and info.checked
+ button.mouseoverUnderline = info.mouseoverUnderline
+ button.isRadio = not info.notCheckable and info.isRadio
+ if info.isRadio then
+ button.check:Show()
+ button.check:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
+ if button.checked then
+ button.check:SetTexCoord(0.25, 0.5, 0, 1)
+ button.check:SetVertexColor(1, 1, 1, 1)
+ else
+ button.check:SetTexCoord(0, 0.25, 0, 1)
+ button.check:SetVertexColor(1, 1, 1, 0.5)
+ end
+ button.radioHighlight:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
+ button.check:SetWidth(16)
+ button.check:SetHeight(16)
+ elseif info.icon then
+ button.check:Show()
+ button.check:SetTexture(info.icon)
+ if info.iconWidth and info.iconHeight then
+ button.check:SetWidth(info.iconWidth)
+ button.check:SetHeight(info.iconHeight)
+ else
+ button.check:SetWidth(16)
+ button.check:SetHeight(16)
+ end
+ if info.iconCoordLeft and info.iconCoordRight and info.iconCoordTop and info.iconCoordBottom then
+ button.check:SetTexCoord(info.iconCoordLeft, info.iconCoordRight, info.iconCoordTop, info.iconCoordBottom)
+ elseif info.icon:find("^Interface\\Icons\\") then
+ button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ button.check:SetTexCoord(0, 1, 0, 1)
+ end
+ button.check:SetVertexColor(1, 1, 1, 1)
+ else
+ if button.checked then
+ if info.checkIcon then
+ button.check:SetWidth(16)
+ button.check:SetHeight(16)
+ button.check:SetTexture(info.checkIcon)
+ if info.checkIcon:find("^Interface\\Icons\\") then
+ button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ button.check:SetTexCoord(0, 1, 0, 1)
+ end
+ else
+ button.check:SetWidth(24)
+ button.check:SetHeight(24)
+ button.check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
+ button.check:SetTexCoord(0, 1, 0, 1)
+ end
+ button.check:SetVertexColor(1, 1, 1, 1)
+ else
+ button.check:SetVertexColor(1, 1, 1, 0)
+ end
+ end
+ if not button.disabled then
+ button.func = info.func
+ button.secure = info.secure
+ end
+ button.hasColorSwatch = info.hasColorSwatch
+ if button.hasColorSwatch then
+ button.colorSwatch:Show()
+ button.colorSwatch.texture:Show()
+ button.r = info.r or 1
+ button.g = info.g or 1
+ button.b = info.b or 1
+ button.colorSwatch.texture:SetVertexColor(button.r, button.g, button.b)
+ button.checked = false
+ button.func = nil
+ button.colorFunc = info.colorFunc
+ local i = 1
+ while true do
+ local k = "colorArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ button.hasOpacity = info.hasOpacity
+ button.opacity = info.opacity or 1
+ else
+ button.colorSwatch:Hide()
+ button.colorSwatch.texture:Hide()
+ end
+ button.hasArrow = not button.hasColorSwatch and (info.value or info.hasSlider or info.hasEditBox) and info.hasArrow
+ if button.hasArrow then
+ button.arrow:SetAlpha(1)
+ if info.hasSlider then
+ button.hasSlider = true
+ button.sliderMin = info.sliderMin or 0
+ button.sliderMax = info.sliderMax or 1
+ button.sliderStep = info.sliderStep or 0
+ button.sliderBigStep = info.sliderBigStep or button.sliderStep
+ if button.sliderBigStep < button.sliderStep then
+ button.sliderBigStep = button.sliderStep
+ end
+ button.sliderIsPercent = info.sliderIsPercent and true or false
+ button.sliderMinText = info.sliderMinText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMin * 100) or button.sliderMin
+ button.sliderMaxText = info.sliderMaxText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMax * 100) or button.sliderMax
+ button.sliderFunc = info.sliderFunc
+ button.sliderValue = info.sliderValue
+ button.fromAceOptions = info.fromAceOptions
+ local i = 1
+ while true do
+ local k = "sliderArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ elseif info.hasEditBox then
+ button.hasEditBox = true
+ button.editBoxText = info.editBoxText or ""
+ button.editBoxFunc = info.editBoxFunc
+ local i = 1
+ while true do
+ local k = "editBoxArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ button.editBoxChangeFunc = info.editBoxChangeFunc
+ local i = 1
+ while true do
+ local k = "editBoxChangeArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ button.editBoxValidateFunc = info.editBoxValidateFunc
+ local i = 1
+ while true do
+ local k = "editBoxValidateArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ button.editBoxIsKeybinding = info.editBoxIsKeybinding
+ button.editBoxKeybindingOnly = info.editBoxKeybindingOnly
+ button.editBoxKeybindingExcept = info.editBoxKeybindingExcept
+ else
+ button.value = info.value
+ local l = levels[level+1]
+ if l and info.value == l.value then
+-- button.arrow:SetWidth(24)
+-- button.arrow:SetHeight(24)
+ button.selected = true
+ button.highlight:Show()
+ end
+ end
+ else
+ button.arrow:SetAlpha(0)
+ end
+ local i = 1
+ while true do
+ local k = "arg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ button.closeWhenClicked = info.closeWhenClicked
+ button.textHeight = info.textHeight or UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT or 10
+ local font,_ = button.text:GetFont()
+ button.text:SetFont(STANDARD_TEXT_FONT or "Fonts\\FRIZQT__.TTF", button.textHeight)
+ button:SetHeight(button.textHeight + 6)
+ button.text:SetPoint("RIGHT", button.arrow, (button.hasColorSwatch or button.hasArrow) and "LEFT" or "RIGHT")
+ button.text:SetJustifyH(info.justifyH or "LEFT")
+ button.text:SetText(info.text)
+ button.tooltipTitle = info.tooltipTitle
+ button.tooltipText = info.tooltipText
+ button.tooltipFunc = info.tooltipFunc
+ local i = 1
+ while true do
+ local k = "tooltipArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ if not button.tooltipTitle and not button.tooltipText and not button.tooltipFunc and not info.isTitle then
+ button.tooltipTitle = info.text
+ end
+ if type(button.func) == "string" then
+ if type(button.arg1) ~= "table" then
+ self:error("Cannot call method %q on a non-table", button.func)
+ end
+ if type(button.arg1[button.func]) ~= "function" then
+ self:error("Method %q nonexistant.", button.func)
+ end
+ end
+end
+
+function Dewdrop:InjectAceOptionsTable(handler, options)
+ self:argCheck(handler, 2, "table")
+ self:argCheck(options, 3, "table")
+ if tostring(options.type):lower() ~= "group" then
+ self:error('Cannot inject into options table argument #3 if its type is not "group"')
+ end
+ if options.handler ~= nil and options.handler ~= handler then
+ self:error("Cannot inject into options table argument #3 if it has a different handler than argument #2")
+ end
+ options.handler = handler
+ local class = handler.class
+ if not AceLibrary:HasInstance("AceOO-2.0") or not class then
+ if Rock then
+ -- possible Rock object
+ for mixin in Rock:IterateObjectMixins(handler) do
+ if type(mixin.GetAceOptionsDataTable) == "function" then
+ local t = mixin:GetAceOptionsDataTable(handler)
+ for k,v in pairs(t) do
+ if type(options.args) ~= "table" then
+ options.args = {}
+ end
+ if options.args[k] == nil then
+ options.args[k] = v
+ end
+ end
+ end
+ end
+ end
+ else
+ -- Ace2 object
+ while class and class ~= AceLibrary("AceOO-2.0").Class do
+ if type(class.GetAceOptionsDataTable) == "function" then
+ local t = class:GetAceOptionsDataTable(handler)
+ for k,v in pairs(t) do
+ if type(options.args) ~= "table" then
+ options.args = {}
+ end
+ if options.args[k] == nil then
+ options.args[k] = v
+ end
+ end
+ end
+ local mixins = class.mixins
+ if mixins then
+ for mixin in pairs(mixins) do
+ if type(mixin.GetAceOptionsDataTable) == "function" then
+ local t = mixin:GetAceOptionsDataTable(handler)
+ for k,v in pairs(t) do
+ if type(options.args) ~= "table" then
+ options.args = {}
+ end
+ if options.args[k] == nil then
+ options.args[k] = v
+ end
+ end
+ end
+ end
+ end
+ class = class.super
+ end
+ end
+ return options
+end
+
+function Dewdrop:OnTooltipHide()
+ if lastSetFont then
+ if lastSetFont == normalFont then
+ lastSetFont = nil
+ return
+ end
+ fillRegionTmp(GameTooltip:GetRegions())
+ for i,v in ipairs(regionTmp) do
+ if v.GetFont then
+ local font,size,outline = v:GetFont()
+ if font == lastSetFont then
+ v:SetFont(normalFont, size, outline)
+ end
+ end
+ regionTmp[i] = nil
+ end
+ lastSetFont = nil
+ end
+end
+
+local function activate(self, oldLib, oldDeactivate)
+ Dewdrop = self
+ if oldLib and oldLib.registry then
+ self.registry = oldLib.registry
+ self.onceRegistered = oldLib.onceRegistered
+ else
+ self.registry = {}
+ self.onceRegistered = {}
+
+ local WorldFrame_OnMouseDown = WorldFrame:GetScript("OnMouseDown")
+ local WorldFrame_OnMouseUp = WorldFrame:GetScript("OnMouseUp")
+ local oldX, oldY, clickTime
+ WorldFrame:SetScript("OnMouseDown", function(this, ...)
+ oldX,oldY = GetCursorPosition()
+ clickTime = GetTime()
+ if WorldFrame_OnMouseDown then
+ WorldFrame_OnMouseDown(this, ...)
+ end
+ end)
+
+ WorldFrame:SetScript("OnMouseUp", function(this, ...)
+ local x,y = GetCursorPosition()
+ if not oldX or not oldY or not x or not y or not clickTime then
+ self:Close()
+ if WorldFrame_OnMouseUp then
+ WorldFrame_OnMouseUp(this, ...)
+ end
+ return
+ end
+ local d = math.abs(x - oldX) + math.abs(y - oldY)
+ if d <= 5 and GetTime() - clickTime < 0.5 then
+ self:Close()
+ end
+ if WorldFrame_OnMouseUp then
+ WorldFrame_OnMouseUp(this, ...)
+ end
+ end)
+
+ hooksecurefunc(DropDownList1, "Show", function()
+ if levels[1] and levels[1]:IsVisible() then
+ self:Close()
+ end
+ end)
+
+ hooksecurefunc("HideDropDownMenu", function()
+ if levels[1] and levels[1]:IsVisible() then
+ self:Close()
+ end
+ end)
+
+ -- hooksecurefunc("CloseDropDownMenus", function()
+ -- if levels[1] and levels[1]:IsVisible() then
+ -- local stack = debugstack()
+ -- print(stack)
+ -- if not stack:find("`TargetFrame_OnHide'") then
+ -- -- self:Close()
+ -- end
+ -- end
+ -- end)
+ end
+
+ self.frame = oldLib and oldLib.frame or CreateFrame("Frame")
+ self.frame:UnregisterAllEvents()
+ self.frame:RegisterEvent("PLAYER_REGEN_ENABLED")
+ self.frame:RegisterEvent("PLAYER_REGEN_DISABLED")
+ self.frame:Hide()
+ self.frame:SetScript("OnEvent", function(this, event)
+ this:Show()
+ if event=="PLAYER_REGEN_ENABLED" then -- track combat state for secure frame operations
+ self.combat = false
+ elseif event=="PLAYER_REGEN_DISABLED" then
+ self.combat = true
+ end
+ end)
+ self.frame:SetScript("OnUpdate", function(this)
+ this:Hide()
+ self:Refresh(1)
+ end)
+ self.hookedTooltip = true
+ if not oldLib or not oldLib.hookedTooltip then
+ local OnTooltipHide = GameTooltip:GetScript("OnHide")
+ GameTooltip:SetScript("OnHide", function(this, ...)
+ if OnTooltipHide then
+ OnTooltipHide(this, ...)
+ end
+ if type(self.OnTooltipHide) == "function" then
+ self:OnTooltipHide()
+ end
+ end)
+ end
+ levels = {}
+ buttons = {}
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+local function external(lib, major, instance)
+ if major == "LibSharedMedia-3.0" then
+ SharedMedia = instance
+ end
+end
+
+AceLibrary:Register(Dewdrop, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)
diff --git a/FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.lua b/FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.lua
new file mode 100644
index 0000000..722888a
--- /dev/null
+++ b/FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.lua
@@ -0,0 +1,2273 @@
+--[[
+Name: LibFuBarPlugin-3.0
+Revision: $Rev: 63 $
+Developed by: ckknight (ckknight@gmail.com) and Arrowmaster
+Website: http://www.wowace.com/
+Description: Plugin for FuBar.
+Dependencies: LibStub
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "LibFuBarPlugin-3.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 63 $"):match("%d+"))
+
+if not LibStub then error(MAJOR_VERSION .. " requires LibStub") end
+
+local FuBarPlugin, oldMinor = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
+if not FuBarPlugin then
+ return
+end
+local oldLib
+if oldMinor then
+ oldLib = {}
+ for k, v in pairs(FuBarPlugin) do
+ oldLib[k] = v
+ FuBarPlugin[k] = nil
+ end
+end
+
+local SHOW_FUBAR_ICON = "Show FuBar icon"
+local SHOW_FUBAR_ICON_DESC = "Show the FuBar plugin's icon on the panel."
+local SHOW_FUBAR_TEXT = "Show FuBar text"
+local SHOW_FUBAR_TEXT_DESC = "Show the FuBar plugin's text on the panel."
+local SHOW_COLORED_FUBAR_TEXT = "Show colored FuBar text"
+local SHOW_COLORED_FUBAR_TEXT_DESC = "Allow the FuBar plugin to color its text on the panel."
+local DETACH_FUBAR_TOOLTIP = "Detach FuBar tooltip"
+local DETACH_FUBAR_TOOLTIP_DESC = "Detach the FuBar tooltip from the panel."
+local LOCK_FUBAR_TOOLTIP = "Lock tooltip"
+local LOCK_FUBAR_TOOLTIP_DESC = "Lock the tooltips position. When the tooltip is locked, you must use Alt to access it with your mouse."
+local POSITION_ON_FUBAR = "Position on FuBar"
+local POSITION_ON_FUBAR_DESC = "Position the FuBar plugin on the panel."
+local POSITION_LEFT = "Left"
+local POSITION_RIGHT = "Right"
+local POSITION_CENTER = "Center"
+local ATTACH_PLUGIN_TO_MINIMAP = "Attach FuBar plugin to minimap"
+local ATTACH_PLUGIN_TO_MINIMAP_DESC = "Attach the FuBar plugin to the minimap instead of the panel."
+local HIDE_FUBAR_PLUGIN = "Hide FuBar plugin"
+local HIDE_MINIMAP_BUTTON = "Hide minimap button"
+local HIDE_FUBAR_PLUGIN_DESC = "Hide the FuBar plugin from the panel or minimap, leaving the addon running."
+local OTHER = "Other"
+local CLOSE = "Close"
+local CLOSE_DESC = "Close the menu."
+
+if GetLocale() == "zhCN" then
+ SHOW_FUBAR_ICON = "显示FuBar图标"
+ SHOW_FUBAR_ICON_DESC = "在面板上显示FuBar插件的图标."
+ SHOW_FUBAR_TEXT = "显示FuBar文字"
+ SHOW_FUBAR_TEXT_DESC = "在面板上显示Fubar插件文字标题"
+ SHOW_COLORED_FUBAR_TEXT = "显示彩色文字"
+ SHOW_COLORED_FUBAR_TEXT_DESC = "允许插件显示彩色文字."
+ DETACH_FUBAR_TOOLTIP = "独立提示信息"
+ DETACH_FUBAR_TOOLTIP_DESC = "从面板上独立显示信息"
+ LOCK_FUBAR_TOOLTIP = "锁定提示信息"
+ LOCK_FUBAR_TOOLTIP_DESC = "锁定提示信息位置.当提示信息被锁定时,你必须要按Alt-鼠标方可查看."
+ POSITION_ON_FUBAR = "位置"
+ POSITION_ON_FUBAR_DESC = "FuBar插件在面板上的位置."
+ POSITION_LEFT = "居左"
+ POSITION_RIGHT = "居右"
+ POSITION_CENTER = "居中"
+ ATTACH_PLUGIN_TO_MINIMAP = "依附在小地图"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "插件图标依附在小地图而不显示在面板上."
+ HIDE_FUBAR_PLUGIN = "隐藏FuBar插件"
+ HIDE_MINIMAP_BUTTON = "隐藏小地图按钮"
+ HIDE_FUBAR_PLUGIN_DESC = "隐藏在面板或小地图上的FuBar插件,暂定插件工作."
+ OTHER = "其他"
+ CLOSE = "关闭"
+ CLOSE_DESC = "关闭目录."
+elseif GetLocale() == "zhTW" then
+ SHOW_FUBAR_ICON = "顯示圖示"
+ SHOW_FUBAR_ICON_DESC = "在面板上顯示插件圖示。"
+ SHOW_FUBAR_TEXT = "顯示文字"
+ SHOW_FUBAR_TEXT_DESC = "在面板上顯示插件文字。"
+ SHOW_COLORED_FUBAR_TEXT = "允許彩色文字"
+ SHOW_COLORED_FUBAR_TEXT_DESC = "允許插件在面板上使用彩色文字。"
+ DETACH_FUBAR_TOOLTIP = "獨立提示訊息"
+ DETACH_FUBAR_TOOLTIP_DESC = "從面板上獨立提示訊息。"
+ LOCK_FUBAR_TOOLTIP = "鎖定提示訊息"
+ LOCK_FUBAR_TOOLTIP_DESC = "鎖定提示訊息位置。當提示訊息鎖定時,需要用Alt鍵使用提示訊息的功能。"
+ POSITION_ON_FUBAR = "位置"
+ POSITION_ON_FUBAR_DESC = "插件在面板上的位置。"
+ POSITION_LEFT = "靠左"
+ POSITION_RIGHT = "靠右"
+ POSITION_CENTER = "置中"
+ ATTACH_PLUGIN_TO_MINIMAP = "依附在小地圖"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "插件圖標依附在小地圖而不顯示在面板上。"
+ HIDE_FUBAR_PLUGIN = "隱藏插件"
+ HIDE_MINIMAP_BUTTON = "隱藏小地圖按鈕"
+ HIDE_FUBAR_PLUGIN_DESC = "在面板或小地圖上隱藏該插件,但保持執行狀態。"
+ OTHER = "其他"
+ CLOSE = "關閉"
+ CLOSE_DESC = "關閉選單。"
+elseif GetLocale() == "koKR" then
+ SHOW_FUBAR_ICON = "FuBar 아이콘 표시"
+ SHOW_FUBAR_ICON_DESC = "FuBar 패널에 플러그인 아이콘을 표시합니다."
+ SHOW_FUBAR_TEXT = "FuBar 텍스트 표시"
+ SHOW_FUBAR_TEXT_DESC = "FuBar 페널에 플러그인 텍스트를 표시합니다."
+ SHOW_COLORED_FUBAR_TEXT = "색상화된 FuBar 텍스트 표시"
+ SHOW_COLORED_FUBAR_TEXT_DESC = "패널의 FuBar 플러그인의 텍스트 색상을 허용합니다."
+ DETACH_FUBAR_TOOLTIP = "FuBar 툴팁 분리"
+ DETACH_FUBAR_TOOLTIP_DESC = "패널에서 FuBar 툴팁을 분리합니다."
+ LOCK_FUBAR_TOOLTIP = "툴팁 고정"
+ LOCK_FUBAR_TOOLTIP_DESC = "툴팁 위치를 고정시킵니다. 툴팁이 고정되어 있을때, 마우스로 접근하기 위해 Alt키를 사용하여야 합니다."
+ POSITION_ON_FUBAR = "FuBar 위치"
+ POSITION_ON_FUBAR_DESC = "패널 위의 FuBar 플러그인의 위치를 설정합니다."
+ POSITION_LEFT = "좌측"
+ POSITION_RIGHT = "우측"
+ POSITION_CENTER = "중앙"
+ ATTACH_PLUGIN_TO_MINIMAP = "FuBar 플러그인 미니맵 표시"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "FuBar 플러그인을 패널 대신 미니맵에 표시합니다."
+ HIDE_FUBAR_PLUGIN = "FuBar 플러그인 숨김"
+ HIDE_MINIMAP_BUTTON = "미니맵 버튼 숨김"
+ HIDE_FUBAR_PLUGIN_DESC = "FuBar 플러그인을 패널이나 미니맵으로 부터 숨김니다."
+ OTHER = "기타"
+ CLOSE = "닫기"
+ CLOSE_DESC = "메뉴를 닫습니다."
+elseif GetLocale() == "frFR" then
+ SHOW_FUBAR_ICON = "Afficher l'icône FuBar"
+ SHOW_FUBAR_ICON_DESC = "Affiche l'icône du plugin FuBar sur le panneau."
+ SHOW_FUBAR_TEXT = "Afficher le texte FuBar"
+ SHOW_FUBAR_TEXT_DESC = "Affiche le texte du plugin FuBar sur le panneau."
+ SHOW_COLORED_FUBAR_TEXT = "Afficher le texte FuBar coloré"
+ SHOW_COLORED_FUBAR_TEXT_DESC = "Autorise le plugin FuBar à colorer son texte sur le panneau."
+ DETACH_FUBAR_TOOLTIP = "Détacher l'infobulle FuBar"
+ DETACH_FUBAR_TOOLTIP_DESC = "Détache l'infobulle FuBar du panneau."
+ LOCK_FUBAR_TOOLTIP = "Verrouiller l'infobulle"
+ LOCK_FUBAR_TOOLTIP_DESC = "Verrouille l'infobulle dans sa position actuelle. Quand l'infobulle est verrouillée, vous devez utiliser la touche Alt pour y interagir avec la souris."
+ POSITION_ON_FUBAR = "Position sur FuBar"
+ POSITION_ON_FUBAR_DESC = "Position du plugin FuBar sur le panneau."
+ POSITION_LEFT = "Gauche"
+ POSITION_RIGHT = "Droite"
+ POSITION_CENTER = "Centre"
+ ATTACH_PLUGIN_TO_MINIMAP = "Attacher le plugin FuBar sur la minicarte"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "Attache le plugin FuBar sur la minicarte au lieu du panneau."
+ HIDE_FUBAR_PLUGIN = "Masquer le plugin FuBar"
+ HIDE_MINIMAP_BUTTON = "Masquer le bouton de la minicarte"
+ HIDE_FUBAR_PLUGIN_DESC = "Masque le plugin FuBar du panneau ou de la minicarte, laissant l'addon fonctionner."
+ OTHER = "Autre"
+ CLOSE = "Fermer"
+ CLOSE_DESC = "Ferme le menu."
+elseif GetLocale() == "ruRU" then
+ SHOW_FUBAR_ICON = "Показ иконку"
+ SHOW_FUBAR_ICON_DESC = "Показывать иконку плагина на панели."
+ SHOW_FUBAR_TEXT = "Показ текста"
+ SHOW_FUBAR_TEXT_DESC = "Показывать текст плагина на панели."
+ SHOW_COLORED_FUBAR_TEXT = "Показ цветового текста"
+ SHOW_COLORED_FUBAR_TEXT_DESC = "Позволить плагину использовать его цвета в тексте."
+ DETACH_FUBAR_TOOLTIP = "Отделить подсказку"
+ DETACH_FUBAR_TOOLTIP_DESC = "Отделить всплывающую подсказку от панели."
+ LOCK_FUBAR_TOOLTIP = "Закрепить подсказку"
+ LOCK_FUBAR_TOOLTIP_DESC = "Закрепить позицию всплывающей подсказки. Когда всплывающая подсказка закреплена, используйте Alt для отображения ее у мыши."
+ POSITION_ON_FUBAR = "Позиция"
+ POSITION_ON_FUBAR_DESC = "Позиция плагина на панели."
+ POSITION_LEFT = "Слева"
+ POSITION_RIGHT = "Справа"
+ POSITION_CENTER = "По центру"
+ ATTACH_PLUGIN_TO_MINIMAP = "Закрепить у мини-карты"
+ ATTACH_PLUGIN_TO_MINIMAP_DESC = "Закрепить плагин у мини-карты вместо панели."
+ HIDE_FUBAR_PLUGIN = "Скрыть плагин"
+ HIDE_MINIMAP_BUTTON = "Скрыть кнопку у мини-карты"
+ HIDE_FUBAR_PLUGIN_DESC = "Скрыть плагин с панели или мини-карты, но оставить аддон в рабочем состоянии."
+ OTHER = "Другое"
+ CLOSE = "Закрыть"
+ CLOSE_DESC = "Закрыть меню."
+end
+
+-- #AUTODOC_NAMESPACE FuBarPlugin
+
+local newList, del
+do
+ local pool = setmetatable({}, {__mode = 'kv'})
+
+ function newList(...)
+ local t = next(pool)
+ local n = select('#', ...)
+ if t then
+ pool[t] = nil
+ for i = 1, n do
+ t[i] = select(i, ...)
+ end
+ else
+ t = { ... }
+ end
+
+ return t, n
+ end
+
+ function del(t)
+ if not t then
+ error(("Bad argument #1 to `del'. Expected %q, got %q."):format("table", type(t)), 2)
+ end
+ if pool[t] then
+ local _, ret = pcall(error, "Error, double-free syndrome.", 3)
+ geterrorhandler()(ret)
+ end
+ setmetatable(t, nil)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t[true] = true
+ t[true] = nil
+ pool[t] = true
+ end
+end
+
+FuBarPlugin.pluginToFrame = oldLib and oldLib.pluginToFrame or {}
+local pluginToFrame = FuBarPlugin.pluginToFrame
+FuBarPlugin.pluginToMinimapFrame = oldLib and oldLib.pluginToMinimapFrame or {}
+local pluginToMinimapFrame = FuBarPlugin.pluginToMinimapFrame
+FuBarPlugin.pluginToPanel = oldLib and oldLib.pluginToPanel or {}
+local pluginToPanel = FuBarPlugin.pluginToPanel
+FuBarPlugin.pluginToOptions = oldLib and oldLib.pluginToOptions or {}
+local pluginToOptions = FuBarPlugin.pluginToOptions
+FuBarPlugin.folderNames = oldLib and oldLib.folderNames or {}
+local folderNames = FuBarPlugin.folderNames
+
+local RockConfig
+local Tablet20
+local Dewdrop20
+local AceConfigRegistry30
+local AceConfigDialog30
+local AceConfigDropdown30
+
+FuBarPlugin.MinimapContainer = oldLib and oldLib.MinimapContainer or {}
+local MinimapContainer = FuBarPlugin.MinimapContainer
+
+local epsilon = 1e-5
+
+FuBarPlugin.mixinTargets = oldLib and oldLib.mixinTargets or {}
+local mixinTargets = FuBarPlugin.mixinTargets
+local mixins = {
+ "SetFuBarOption",
+ "GetTitle",
+ "GetName",
+ "GetCategory",
+ "SetFontSize",
+ "GetFrame",
+ "Show",
+ "Hide",
+ "GetPanel",
+ "IsFuBarTextColored",
+ "ToggleFuBarTextColored",
+ "IsFuBarMinimapAttached",
+ "ToggleFuBarMinimapAttached",
+ "UpdateFuBarPlugin",
+ "UpdateFuBarText",
+ "UpdateFuBarTooltip",
+ "SetFuBarIcon",
+ "GetFuBarIcon",
+ "CheckWidth",
+ "SetFuBarText",
+ "GetFuBarText",
+ "IsFuBarIconShown",
+ "ToggleFuBarIconShown",
+ "ShowFuBarIcon",
+ "HideFuBarIcon",
+ "IsFuBarTextShown",
+ "ToggleFuBarTextShown",
+ "ShowFuBarText",
+ "HideFuBarText",
+ "IsFuBarTooltipDetached",
+ "ToggleFuBarTooltipDetached",
+ "DetachFuBarTooltip",
+ "ReattachFuBarTooltip",
+ "GetDefaultPosition",
+ "SetPanel",
+ "IsDisabled",
+ "CreateBasicPluginFrame",
+ "CreatePluginChildFrame",
+ "OpenMenu"
+}
+
+-- #AUTODOC_NAMESPACE FuBarPlugin
+
+--[[---------------------------------------------------------------------------
+Notes:
+ *Set metadata about a certain plugin.
+ ; tooltipType : string -
+ : "GameTooltip"
+ :: Use Blizzard's GameTooltip. (default if not given)
+ : "Tablet-2.0"
+ :: Use Tablet-2.0.
+ : "Custom"
+ :: LibFuBarPlugin-3.0 will not provide any extra mechanisms, all done manually.
+ ; configType : string -
+ : "LibRockConfig-1.0"
+ :: Use LibRockConfig-1.0 to show configuration. (default if not given)
+ : "Dewdrop-2.0"
+ :: Use Dewdrop-2.0.
+ : "AceConfigDialog-3.0"
+ :: Use AceConfigDialog-3.0.
+ : "AceConfigDropdown-3.0"
+ :: Use AceConfigDropdown-3.0.
+ : "None"
+ :: No config (and will register RightButtonUp for OnFuBarClick)
+ ; hasNoText : boolean - If set to true, then it will be a text-less frame.
+ ; iconPath : string - the path of the icon to show.
+ ; hasNoColor : boolean - If set to true, then it is assumed that no color will be in the text (and thus not show the menu item)
+ ; cannotHideText : boolean - If set to true, then the menu item to hide text will not be shown.
+ ; overrideMenu : boolean - If set to true, then the menu will not show any of the standard menu items
+ ; hideMenuTitle : boolean - If set to true, the plugins name will not be added to the top of the menu as a header.
+ ; defaultPosition : string -
+ : "LEFT"
+ ::show on the left. (default if not given)
+ : "CENTER"
+ ::show in the center.
+ : "RIGHT"
+ ::show on the right.
+ : "MINIMAP"
+ ::show on the minimap.
+ ; defaultMinimapPosition : number - Angle on the minimap, in degrees. [0, 360)
+ ; clickableTooltip : boolean - Whether you can drag your mouse onto the tooltip and click a line
+ ; tooltipHiddenWhenEmpty : boolean - Whether the detached tooltip is hidden when it is empty.
+ ; cannotDetachTooltip : boolean - Whether the tooltip cannot be detached from the plugin text.
+ ::Normally, a tooltip can detach (if using Tablet-2.0). This should be set if there is no relevant data in the tooltip.
+ ; independentProfile : boolean - If set to true, then the profile setting will not be stripped from .OnMenuRequest, and FuBar will not set the plugin's profile when it changes.
+ ::non-FuBar-centric plugins should set this to true.
+Arguments:
+ string - the key to set
+ value - the value to set said key to.
+Example:
+ self:SetFuBarOption('tooltipType', "Tablet-2.0")
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:SetFuBarOption(key, value)
+ local pluginToOptions_self = pluginToOptions[self]
+ if not pluginToOptions_self then
+ pluginToOptions_self = {}
+ pluginToOptions[self] = pluginToOptions_self
+ end
+
+ pluginToOptions_self[key] = value
+
+ if key == 'tooltipType' then
+ if value == "Tablet-2.0" then
+ Tablet20 = LibStub("Tablet-2.0", true)
+ if not Tablet20 then
+ error(("Cannot specify %q = %q if %q is not loaded."):format(key, value, value), 2)
+ end
+ end
+ end
+ if key == 'configType' then
+ if value == "Dewdrop-2.0" then
+ Dewdrop20 = LibStub("Dewdrop-2.0", true)
+ if not Dewdrop20 then
+ error(("Cannot specify %q = %q if %q is not loaded."):format(key, value, value), 2)
+ end
+ elseif value == "AceConfigDialog-3.0" then
+ AceConfigRegistry30 = LibStub("AceConfigRegistry-3.0", true)
+ AceConfigDialog30 = LibStub("AceConfigDialog-3.0", true)
+ if not AceConfigDialog30 then
+ error(("Cannot specify %q = %q if %q is not loaded."):format(key, value, value), 2)
+ end
+ elseif value == "AceConfigDropdown-3.0" then
+ AceConfigRegistry30 = LibStub("AceConfigRegistry-3.0", true)
+ AceConfigDropdown30 = LibStub("AceConfigDropdown-3.0", true)
+ if not AceConfigDropdown30 then
+ error(("Cannot specify %q = %q if %q is not loaded."):format(key, value, value), 2)
+ end
+ end
+ end
+end
+
+local function getPluginOption(object, key, default)
+ local pluginToOptions_object = pluginToOptions[object]
+ if pluginToOptions_object == nil then
+ return default
+ end
+ local value = pluginToOptions_object[key]
+ if value == nil then
+ return default
+ end
+ return value
+end
+
+local good = nil
+local function CheckFuBar()
+ if not good then
+ if FuBar then
+ local version = FuBar.version
+ if type(version) == "string" then
+ local num = version:match("^(%d+%.?%d*)")
+ if num then
+ num = tonumber(num)
+ good = num > 2
+ end
+ end
+ end
+ end
+ return good
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string - the localized name of the plugin, not including the "FuBar - " part.
+Example
+ local title = self:GetTitle()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetTitle()
+ local name = self.title or self.name
+ if type(name) ~= "string" then
+ error("You must provide self.title or self.name", 2)
+ end
+ local title = name:match("[Ff][Uu][Bb][Aa][Rr]%s*%-%s*(.-)%s*$") or name
+ return title:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "")
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string - name of the plugin.
+Notes:
+ This is here for FuBar core to communicate properly.
+Example:
+ local name = self:GetName()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetName()
+ return self.name
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string - category of the plugin.
+Notes:
+ This is here for FuBar core to communicate properly.
+Example:
+ local category = self:GetCategory()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetCategory()
+ return self.category or OTHER
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ frame - frame for the plugin.
+Notes:
+ This is here for FuBar core to communicate properly.
+Example:
+ local frame = self:GetFrame()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetFrame()
+ return pluginToFrame[self]
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ object - panel for the plugin.
+Notes:
+ This is here for FuBar core to communicate properly.
+Example:
+ local panel = self:GetPanel()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetPanel()
+ return pluginToPanel[self]
+end
+
+local function getLazyDatabaseValueDefault(object, value, ...)
+ local object_db = object.db
+ if type(object_db) ~= "table" then
+ return value
+ end
+ local current = object_db.profile
+ for i = 1, select('#', ...) do
+ -- traverse through, make sure tables exist.
+ if type(current) ~= "table" then
+ return value
+ end
+ current = current[(select(i, ...))]
+ end
+ if current == nil then
+ return value
+ else
+ return current
+ end
+end
+
+local function getLazyDatabaseValue(object, ...)
+ return getLazyDatabaseValueDefault(object, nil, ...)
+end
+
+local function setLazyDatabaseValue(object, value, ...)
+ local object_db = object.db
+ if type(object_db) ~= "table" then
+ return nil
+ end
+ local current = object_db.profile
+ if type(current) ~= "table" then
+ return nil
+ end
+ local n = select('#', ...)
+ for i = 1, n-1 do
+ -- traverse through, create tables if necessary.
+ local nextOne = current[(select(i, ...))]
+ if type(nextOne) ~= "table" then
+ if nextOne ~= nil then
+ return nil
+ end
+ nextOne = {}
+ current[(select(i, ...))] = nextOne
+ end
+ current = nextOne
+ end
+ current[select(n, ...)] = value
+ return true
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ boolean - whether the text has color applied.
+Example:
+ local colored = self:IsFuBarTextColored()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:IsFuBarTextColored()
+ return not getLazyDatabaseValue(self, 'uncolored')
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Toggles whether the text has color applied
+Example:
+ self:ToggleTextColored()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ToggleFuBarTextColored()
+ if not setLazyDatabaseValue(self, not getLazyDatabaseValue(self, 'uncolored') or nil, 'uncolored') then
+ error(("%s: Cannot change text color if self.db is not available."):format(self:GetTitle()), 2)
+ end
+ self:UpdateFuBarText()
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ boolean - whether the plugin is attached to the minimap.
+Example:
+ local attached = self:IsMinimapAttached()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:IsFuBarMinimapAttached()
+ if not CheckFuBar() then
+ return true
+ end
+ return pluginToPanel[self] == MinimapContainer
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Toggles whether the plugin is attached to the minimap.
+Example:
+ self:ToggleMinimapAttached()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ToggleFuBarMinimapAttached()
+ if CheckFuBar() and not getPluginOption(self, 'cannotAttachToMinimap', false) then
+ local panel = pluginToPanel[self]
+ local value = panel == MinimapContainer
+ if value then
+ panel:RemovePlugin(self)
+ local defaultPosition = getPluginOption(self, 'defaultPosition', "LEFT")
+ FuBar:GetPanel(1):AddPlugin(self, nil, defaultPosition == "MINIMAP" and "LEFT" or defaultPosition)
+ else
+ if panel then
+ panel:RemovePlugin(self)
+ end
+ MinimapContainer:AddPlugin(self)
+ end
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Calls :UpdateFuBarText() and :UpdateFuBarTooltip(), in that order.
+Example:
+ self:UpdateFuBarPlugin()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:UpdateFuBarPlugin()
+ self:UpdateFuBarText()
+ self:UpdateFuBarTooltip()
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Calls :OnUpdateFuBarText() if it is available and the plugin is not disabled.
+ * It is expected to update the icon in :OnUpdateFuBarText as well as text.
+Example:
+ self:UpdateFuBarText()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:UpdateFuBarText()
+ if type(self.OnUpdateFuBarText) == "function" then
+ if not self:IsDisabled() then
+ self:OnUpdateFuBarText()
+ end
+ elseif self:IsFuBarTextShown() then
+ self:SetFuBarText(self:GetTitle())
+ end
+end
+
+local function Tablet20_point(frame)
+ if frame:GetTop() > GetScreenHeight() / 2 then
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 3 then
+ return "TOPLEFT", "BOTTOMLEFT"
+ elseif x < GetScreenWidth() * 2 / 3 then
+ return "TOP", "BOTTOM"
+ else
+ return "TOPRIGHT", "BOTTOMRIGHT"
+ end
+ else
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 3 then
+ return "BOTTOMLEFT", "TOPLEFT"
+ elseif x < GetScreenWidth() * 2 / 3 then
+ return "BOTTOM", "TOP"
+ else
+ return "BOTTOMRIGHT", "TOPRIGHT"
+ end
+ end
+end
+
+local function RegisterTablet20(self)
+ local frame = pluginToFrame[self]
+ if not Tablet20:IsRegistered(frame) then
+ local db = getLazyDatabaseValue(self)
+ if db and not db.detachedTooltip then
+ db.detachedTooltip = {}
+ end
+ Tablet20:Register(frame,
+ 'children', function()
+ Tablet20:SetTitle(self:GetTitle())
+ if type(self.OnUpdateFuBarTooltip) == "function" then
+ if not self:IsDisabled() then
+ self:OnUpdateFuBarTooltip()
+ end
+ end
+ end,
+ 'clickable', getPluginOption(self, 'clickableTooltip', false),
+ 'data', CheckFuBar() and FuBar.db.profile.tooltip or db and db.detachedTooltip or {},
+ 'detachedData', db and db.detachedTooltip or {},
+ 'point', Tablet20_point,
+ 'menu', self.OnMenuRequest and function(level, value, valueN_1, valueN_2, valueN_3, valueN_4)
+ if level == 1 then
+ local name = tostring(self)
+ if not name:find('^table:') then
+ name = name:gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
+ LibStub("Dewdrop-2.0"):AddLine(
+ 'text', name,
+ 'isTitle', true
+ )
+ end
+ end
+ if type(self.OnMenuRequest) == "function" then
+ self:OnMenuRequest(level, value, true, valueN_1, valueN_2, valueN_3, valueN_4)
+ elseif type(self.OnMenuRequest) == "table" then
+ LibStub("Dewdrop-2.0"):FeedAceOptionsTable(self.OnMenuRequest)
+ end
+ end,
+ 'hideWhenEmpty', getPluginOption(self, 'tooltipHiddenWhenEmpty', false)
+ )
+ local func = pluginToFrame[self]:GetScript("OnEnter")
+ frame:SetScript("OnEnter", function(this, ...)
+ -- HACK
+ func(this, ...)
+
+ if FuBar and FuBar.IsHidingTooltipsInCombat and FuBar:IsHidingTooltipsInCombat() and InCombatLockdown() then
+ if Tablet20:IsAttached(this) then
+ Tablet20:Close(this)
+ end
+ end
+ end)
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Calls :OnUpdateFuBarTooltip() if it is available, the plugin is not disabled, and the tooltip is shown.
+Example:
+ self:UpdateFuBarTooltip()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:UpdateFuBarTooltip()
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+
+ if tooltipType == "GameTooltip" then
+ local frame = self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self]
+ if not GameTooltip:IsOwned(frame) then
+ return
+ end
+ GameTooltip:Hide()
+
+ local anchor
+ if frame:GetTop() > GetScreenHeight() / 2 then
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 2 then
+ anchor = "ANCHOR_BOTTOMRIGHT"
+ else
+ anchor = "ANCHOR_BOTTOMLEFT"
+ end
+ else
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 2 then
+ anchor = "ANCHOR_TOPLEFT"
+ else
+ anchor = "ANCHOR_TOPRIGHT"
+ end
+ end
+ GameTooltip:SetOwner(frame, anchor)
+ if type(self.OnUpdateFuBarTooltip) == "function" and not self:IsDisabled() then
+ self:OnUpdateFuBarTooltip()
+ end
+ GameTooltip:Show()
+ return
+ elseif tooltipType == "Custom" then
+ if type(self.OnUpdateFuBarTooltip) == "function" and not self:IsDisabled() then
+ self:OnUpdateFuBarTooltip()
+ end
+ return
+ elseif tooltipType == "Tablet-2.0" then
+ RegisterTablet20(self)
+ if self:IsFuBarMinimapAttached() and not self:IsFuBarTooltipDetached() and pluginToMinimapFrame[self] then
+ Tablet20:Refresh(pluginToMinimapFrame[self])
+ else
+ Tablet20:Refresh(pluginToFrame[self])
+ end
+ elseif tooltipType == "None" then
+ return
+ else
+ error(("Unknown %s option for %q: %q"):format(MAJOR_VERSION, 'tooltipType', tostring(tooltipType)), 2)
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Shows the plugin, enables the plugin if previously disabled, and calls :UpdateFuBarPlugin().
+Example:
+ self:Show()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:Show(panelId)
+ if pluginToFrame[self]:IsShown() or (pluginToMinimapFrame[self] and pluginToMinimapFrame[self]:IsShown()) then
+ return
+ end
+ if panelId ~= false then
+ setLazyDatabaseValue(self, nil, 'hidden')
+ end
+ if self.IsActive and not self:IsActive() then
+ self.panelIdTmp = panelId
+ self:ToggleActive()
+ self.panelIdTmp = nil
+ setLazyDatabaseValue(self, nil, 'disabled')
+ elseif not getLazyDatabaseValue(self, 'hidden') then
+ if panelId == 0 or not CheckFuBar() then
+ -- MinimapContainer:AddPlugin(self)
+ -- Hide Masque button
+ else
+ FuBar:ShowPlugin(self, panelId or self.panelIdTmp)
+ end
+ if not getPluginOption(self, 'userDefinedFrame', false) then
+ if not self:IsFuBarTextShown() then
+ local text = pluginToFrame[self].text
+ text:SetText("")
+ text:SetWidth(epsilon)
+ text:Hide()
+ end
+ if not self:IsFuBarIconShown() then
+ local icon = pluginToFrame[self].icon
+ icon:SetWidth(epsilon)
+ icon:Hide()
+ end
+ end
+ if getPluginOption(self, 'tooltipType', "GameTooltip") == "Tablet-2.0"
+ and not getPluginOption(self, 'cannotDetachTooltip', false)
+ and getLazyDatabaseValue(self, 'detachedTooltip', 'detached') then
+ self:UpdateFuBarTooltip()
+ Tablet20:Open(pluginToFrame[self])
+ end
+ self:UpdateFuBarPlugin()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Hides the plugin, disables the plugin if cannot hide without standby.
+Arguments:
+ [optional] boolean - internal variable. Do not set this.
+Example:
+ self:Hide()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:Hide(check)
+ if not pluginToFrame[self]:IsShown() and (not pluginToMinimapFrame[self] or not pluginToMinimapFrame[self]:IsShown()) then
+ return
+ end
+ local hideWithoutStandby = getPluginOption(self, 'hideWithoutStandby', false)
+ if hideWithoutStandby and check ~= false then
+ setLazyDatabaseValue(self, true, 'hidden')
+ end
+ if not hideWithoutStandby then
+ if getPluginOption(self, 'tooltipType', "GameTooltip") == "Tablet-2.0" and not getPluginOption(self, 'cannotDetachTooltip', false) and self:IsFuBarTooltipDetached() and getLazyDatabaseValue(self, 'detachedTooltip', 'detached') then
+ self:ReattachTooltip()
+ setLazyDatabaseValue(self, true, 'detachedTooltip', 'detached')
+ end
+ if self.IsActive and self:IsActive() and self.ToggleActive and (not CheckFuBar() or not FuBar:IsChangingProfile()) then
+ self:ToggleActive()
+ end
+ end
+ if pluginToPanel[self] then
+ pluginToPanel[self]:RemovePlugin(self)
+ end
+ pluginToFrame[self]:Hide()
+ if pluginToMinimapFrame[self] then
+ pluginToMinimapFrame[self]:Hide()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Sets the path to the icon for the plugin.
+Arguments:
+ string or nil - The path to the icon. If nil, then no icon.
+Example:
+ self:SetFuBarIcon("Interface\\AddOns\\MyAddon\\otherIcon")
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:SetFuBarIcon(path)
+ if not path then
+ return
+ end
+ if not pluginToFrame[self] or not pluginToFrame[self].icon then
+ return
+ end
+ if path:match([[^Interface\Icons\]]) then
+ pluginToFrame[self].icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ pluginToFrame[self].icon:SetTexCoord(0, 1, 0, 1)
+ end
+ pluginToFrame[self].icon:SetTexture(path)
+ if pluginToMinimapFrame[self] and pluginToMinimapFrame[self].icon then
+ if path:match([[^Interface\Icons\]]) then
+ pluginToMinimapFrame[self].icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ pluginToMinimapFrame[self].icon:SetTexCoord(0, 1, 0, 1)
+ end
+ pluginToMinimapFrame[self].icon:SetTexture(path)
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string or nil - The path to the icon for the plugin. If nil, then no icon.
+Example:
+ local path = self:GetFuBarIcon()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetFuBarIcon()
+ if getPluginOption(self, 'iconPath', false) then
+ return pluginToFrame[self] and pluginToFrame[self].icon and pluginToFrame[self].icon:GetTexture()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Checks the current width of the icon and text, then updates frame to expand/shrink to it if necessary.
+Arguments:
+ [optional] boolean - if true, Shrink/expand no matter what, otherwise if the width is less than 8 pixels smaller, don't shrink.
+Example:
+ self:CheckWidth(true)
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:CheckWidth(force)
+ local frame = pluginToFrame[self]
+ if not frame then
+ return
+ end
+ local icon = frame.icon
+ local text = frame.text
+ if (not icon or not icon:IsShown()) and (not text or not text:IsShown()) then
+ return
+ end
+
+ local db = getLazyDatabaseValue(self)
+
+ if (db and not self:IsFuBarIconShown()) or not getPluginOption(self, 'iconPath', false) then
+ icon:SetWidth(epsilon)
+ end
+ local width
+ if not getPluginOption(self, 'hasNoText', false) then
+ text:SetHeight(0)
+ text:SetWidth(500)
+ width = text:GetStringWidth() + 1
+ text:SetWidth(width)
+ text:SetHeight(text:GetHeight())
+ end
+ local panel = pluginToPanel[self]
+ if getPluginOption(self, 'hasNoText', false) or not text:IsShown() then
+ frame:SetWidth(icon:GetWidth())
+ if panel and panel:GetPluginSide(self) == "CENTER" then
+ panel:UpdateCenteredPosition()
+ end
+ elseif force or not frame.textWidth or frame.textWidth < width or frame.textWidth - 8 > width then
+ frame.textWidth = width
+ text:SetWidth(width)
+ if icon and icon:IsShown() then
+ frame:SetWidth(width + icon:GetWidth())
+ else
+ frame:SetWidth(width)
+ end
+ if panel and panel:GetPluginSide(self) == "CENTER" then
+ panel:UpdateCenteredPosition()
+ end
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Sets the text of the plugin. Should only be called from within :OnFuBarUpdateText()
+Arguments:
+ string - text to set the plugin to. If not given, set to title.
+Example:
+ myAddon.OnFuBarUpdateText = function(self)
+ self:SetFuBarText("Hello")
+ fend
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:SetFuBarText(text)
+ local frame = pluginToFrame[self]
+ if not frame or not frame.text then
+ return
+ end
+ if text == "" then
+ if getPluginOption(self, 'iconPath', false) then
+ self:ShowFuBarIcon()
+ else
+ text = self:GetTitle()
+ end
+ end
+ if not self:IsFuBarTextColored() then
+ text = text:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "")
+ end
+ frame.text:SetText(text)
+ self:CheckWidth()
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string - The current text of the plugin.
+Example:
+ local text = self:GetFuBarText()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetFuBarText()
+ local frame = pluginToFrame[self]
+ if not frame or not frame.text then
+ error(("%s: Cannot get text without a text frame."):format(self:GetTitle()), 2)
+ end
+ if not getPluginOption(self, 'hasNoText', false) then
+ return frame.text:GetText() or ""
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ boolean - whether the icon for the plugin is showing.
+Example:
+ local isIconShowing = self:IsFuBarIconShown()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:IsFuBarIconShown()
+ if not getPluginOption(self, 'iconPath', false) then
+ return false
+ elseif getPluginOption(self, 'hasNoText', false) then
+ return true
+ end
+ return not not getLazyDatabaseValueDefault(self, true, 'showIcon')
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Toggles whether the icon for the plugin is showing.
+Example:
+ self:ToggleFuBarIconShown()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ToggleFuBarIconShown()
+ local frame = pluginToFrame[self]
+ local icon = frame and frame.icon
+ local text = frame and frame.text
+ if not icon then
+ error(("%s: Cannot toggle icon without an icon frame."):format(self:GetTitle()), 2)
+ elseif not text then
+ error(("%s: Cannot toggle icon without a text frame."):format(self:GetTitle()), 2)
+ elseif not getPluginOption(self, 'iconPath', false) then
+ error(("%s: Cannot show icon unless 'iconPath' is set."):format(self:GetTitle()), 2)
+ elseif getPluginOption(self, 'hasNoText', false) then
+ error(("%s: Cannot show icon if 'hasNoText' is set."):format(self:GetTitle()), 2)
+ elseif not getLazyDatabaseValue(self) then
+ error(("%s: Cannot hide icon if self.db is not available."):format(self:GetTitle()), 2)
+ end
+ local value = not self:IsFuBarIconShown()
+ setLazyDatabaseValue(self, value, 'showIcon')
+ if value then
+ if not self:IsFuBarTextShown() and text:IsShown() and text:GetText() == self:GetTitle() then
+ text:Hide()
+ text:SetText("")
+ end
+ icon:Show()
+ icon:SetWidth(pluginToFrame[self].icon:GetHeight())
+ self:UpdateFuBarText()
+ else
+ if not text:IsShown() or not text:GetText() or text:GetText() == "" then
+ text:Show()
+ text:SetText(self:GetTitle())
+ end
+ icon:Hide()
+ icon:SetWidth(epsilon)
+ end
+ self:CheckWidth(true)
+ return value
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Shows the icon of the plugin if hidden.
+Example:
+ self:ShowFuBarIcon()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ShowFuBarIcon()
+ if not self:IsFuBarIconShown() then
+ self:ToggleFuBarIconShown()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Hides the icon of the plugin if shown.
+Example:
+ self:HideFuBarIcon()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:HideFuBarIcon()
+ if self:IsFuBarIconShown() then
+ self:ToggleFuBarIconShown()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ boolean - whether the text for the plugin is showing.
+Example:
+ local isTextShowing = self:IsFuBarTextShown()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:IsFuBarTextShown()
+ if getPluginOption(self, 'hasNoText', false) then
+ return false
+ elseif not getPluginOption(self, 'iconPath', false) then
+ return true
+ end
+ return not not getLazyDatabaseValueDefault(self, true, 'showText')
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Toggles whether the text for the plugin is showing.
+Example:
+ self:ToggleFuBarTextShown()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ToggleFuBarTextShown()
+ local frame = pluginToFrame[self]
+ local icon = frame and frame.icon
+ local text = frame and frame.text
+ if not icon then
+ error(("%s: Cannot toggle text without an icon frame."):format(self:GetTitle()), 2)
+ elseif not text then
+ error(("%s: Cannot toggle text without a text frame."):format(self:GetTitle()), 2)
+ elseif getPluginOption(self, 'cannotHideText', false) then
+ error(("%s: Cannot toggle text if 'cannotHideText' is set."):format(self:GetTitle()), 2)
+ elseif not getPluginOption(self, 'iconPath', false) then
+ error(("%s: Cannot toggle text unless 'iconPath' is set."):format(self:GetTitle()), 2)
+ elseif getPluginOption(self, 'hasNoText', false) then
+ error(("%s: Cannot toggle text if 'hasNoText' is set."):format(self:GetTitle()), 2)
+ elseif not getLazyDatabaseValue(self) then
+ error(("%s: Cannot toggle text if self.db is not available."):format(self:GetTitle()), 2)
+ end
+ local value = not self:IsFuBarTextShown()
+ setLazyDatabaseValue(self, value, 'showText')
+ if value then
+ text:Show()
+ self:UpdateFuBarText()
+ else
+ text:SetText("")
+ text:SetWidth(epsilon)
+ text:Hide()
+ self:ShowFuBarIcon()
+ end
+ self:CheckWidth(true)
+ return value
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Shows the text of the plugin if hidden.
+Example:
+ self:ShowFuBarText()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ShowFuBarText()
+ if not self:IsFuBarTextShown() then
+ self:ToggleFuBarTextShown()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Hides the text of the plugin if shown.
+Example:
+ self:HideFuBarText()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:HideFuBarText()
+ if self:IsFuBarTextShown() then
+ self:ToggleFuBarTextShown()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string - default position of the plugin.
+Notes:
+ This is here for FuBar core to communicate properly.
+Example:
+ local pos = self:GetDefaultPosition()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:GetDefaultPosition()
+ return getPluginOption(self, 'defaultPosition', "LEFT")
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ boolean - Whether the tooltip is detached.
+Example:
+ local detached = self:IsFuBarTooltipDetached()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:IsFuBarTooltipDetached()
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType ~= "Tablet-2.0" then
+ return
+ end
+
+ RegisterTablet20(self)
+ return not Tablet20:IsAttached(pluginToFrame[self])
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Toggles whether the tooltip is detached.
+Example:
+ self:ToggleFuBarTooltipDetached()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ToggleFuBarTooltipDetached()
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType ~= "Tablet-2.0" then
+ return
+ end
+
+ RegisterTablet20(self)
+ if Tablet20:IsAttached(pluginToFrame[self]) then
+ Tablet20:Open(pluginToFrame[self])
+ Tablet20:Detach(pluginToFrame[self])
+ else
+ Tablet20:Attach(pluginToFrame[self])
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Detaches the tooltip from the plugin.
+ * This does nothing if already detached.
+Example:
+ self:DetachFuBarTooltip()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:DetachFuBarTooltip()
+ if not self:IsFuBarTooltipDetached() then
+ self:ToggleFuBarTooltipDetached()
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Reattaches the tooltip to the plugin.
+ This does nothing if already attached.
+Example:
+ self:ReattachFuBarTooltip()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:ReattachFuBarTooltip()
+ if self:IsFuBarTooltipDetached() then
+ self:ToggleFuBarTooltipDetached()
+ end
+end
+
+local function IsCorrectPanel(panel)
+ if type(panel) ~= "table" then
+ return false
+ elseif type(panel.AddPlugin) ~= "function" then
+ return false
+ elseif type(panel.RemovePlugin) ~= "function" then
+ return false
+ elseif type(panel.GetNumPlugins) ~= "function" then
+ return false
+ elseif type(panel:GetNumPlugins()) ~= "number" then
+ return false
+ elseif type(panel.GetPlugin) ~= "function" then
+ return false
+ elseif type(panel.HasPlugin) ~= "function" then
+ return false
+ elseif type(panel.GetPluginSide) ~= "function" then
+ return false
+ end
+ return true
+end
+
+-- #NODOC
+-- this is used internally by FuBar
+function FuBarPlugin:SetPanel(panel)
+ pluginToPanel[self] = panel
+end
+
+-- #NODOC
+-- this is used internally by FuBar
+function FuBarPlugin:SetFontSize(size)
+ if getPluginOption(self, 'userDefinedFrame', false) then
+ error(("%sYou must provide a :SetFontSize(size) method if you have 'userDefinedFrame' set."):format(self.name and self.name .. ": " or ""), 2)
+ end
+ if getPluginOption(self, 'iconPath', false) then
+ local frame = pluginToFrame[self]
+ local icon = frame and frame.icon
+ if not icon then
+ error(("%sno icon frame found."):format(self.name and self.name .. ": " or ""), 2)
+ end
+ icon:SetWidth(size + 3)
+ icon:SetHeight(size + 3)
+ end
+ if not getPluginOption(self, 'hasNoText', false) then
+ local frame = pluginToFrame[self]
+ local text = frame and frame.text
+ if not text then
+ error(("%sno text frame found."):format(self.name and self.name .. ": " or ""), 2)
+ end
+ local font, _, flags = text:GetFont()
+ text:SetFont(font, size, flags)
+ end
+ self:CheckWidth()
+end
+
+local function IsLoadOnDemand(plugin)
+ return IsAddOnLoadOnDemand(folderNames[plugin] or "")
+end
+
+-- #NODOC
+-- this is used internally by FuBar.
+function FuBarPlugin:IsDisabled()
+ return type(self.IsActive) == "function" and not self:IsActive() or false
+end
+
+function FuBarPlugin:Embed(target)
+ local stack = debugstack(5, 1, 0)
+ local folder = stack:match("[Oo%.][Nn%.][Ss%.]/([^/]+)/")
+ if not folder then
+ local partFolder = stack:match("...([^/]+)/")
+ if partFolder then
+ local partFolder_len = #partFolder
+ for i = 1, GetNumAddOns() do
+ local name = GetAddOnInfo(i)
+ if #name >= partFolder_len then
+ local partName = name:sub(-partFolder_len)
+ if partName == partFolder then
+ folder = name
+ end
+ end
+ end
+ end
+ if not folder then
+ for i = 6, 3, -1 do
+ folder = debugstack(i, 1, 0):match("/AddOns/(.*)/")
+ if folder then
+ break
+ end
+ end
+ end
+ end
+ folderNames[target] = folder
+
+ for _,name in pairs(mixins) do
+ target[name] = FuBarPlugin[name]
+ end
+ FuBarPlugin.mixinTargets[target] = true
+end
+
+local frame_OnClick, frame_OnDoubleClick, frame_OnMouseDown, frame_OnMouseUp, frame_OnReceiveDrag, frame_OnEnter, frame_OnLeave
+--[[---------------------------------------------------------------------------
+Arguments:
+ [optional] string - name of the frame
+Returns:
+ frame - a frame with the basic scripts to be considered a plugin frame.
+Example:
+ MyPlugin.frame = MyPlugin:CreateBasicPluginFrame("FuBar_MyPluginFrame")
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:CreateBasicPluginFrame(name)
+ local frame = CreateFrame("Button", name, UIParent)
+ frame:SetFrameStrata("HIGH")
+ frame:SetFrameLevel(7)
+ frame:EnableMouse(true)
+ frame:EnableMouseWheel(true)
+ frame:SetMovable(true)
+ frame:SetWidth(150)
+ frame:SetHeight(24)
+ frame:SetPoint("CENTER", UIParent, "CENTER")
+ frame.self = self
+ if getPluginOption(self, 'configType', "LibRockConfig-1.0") == "None" then
+ frame:RegisterForClicks("LeftButtonUp", "RightButtonUp")
+ else
+ frame:RegisterForClicks("LeftButtonUp")
+ end
+ if not frame_OnEnter then
+ function frame_OnEnter(this)
+ local self = this.self
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "GameTooltip" then
+ GameTooltip:SetOwner(self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self], "ANCHOR_CURSOR")
+ self:UpdateFuBarTooltip()
+ end
+ if type(self.OnFuBarEnter) == "function" then
+ self:OnFuBarEnter()
+ end
+ end
+ end
+ frame:SetScript("OnEnter", frame_OnEnter)
+ if not frame_OnLeave then
+ function frame_OnLeave(this)
+ local self = this.self
+ if type(self.OnFuBarLeave) == "function" then
+ self:OnFuBarLeave()
+ end
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "GameTooltip" and GameTooltip:IsOwned(self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self]) then
+ GameTooltip:Hide()
+ end
+ end
+ end
+ frame:SetScript("OnLeave", frame_OnLeave)
+ if not frame_OnClick then
+ function frame_OnClick(this, button)
+ local self = this.self
+ if self:IsFuBarMinimapAttached() and this.dragged then return end
+ if type(self.OnFuBarClick) == "function" then
+ self:OnFuBarClick(button)
+ end
+ end
+ end
+ frame:SetScript("OnClick", frame_OnClick)
+ if not frame_OnDoubleClick then
+ function frame_OnDoubleClick(this, button)
+ local self = this.self
+ if type(self.OnFuBarDoubleClick) == "function" then
+ self:OnFuBarDoubleClick(button)
+ end
+ end
+ end
+ frame:SetScript("OnDoubleClick", frame_OnDoubleClick)
+ if not frame_OnMouseDown then
+ function frame_OnMouseDown(this, button)
+ local self = this.self
+ if button == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then
+ self:OpenMenu()
+ return
+ else
+ if type(self.OnFuBarMouseDown) == "function" then
+ self:OnFuBarMouseDown(button)
+ end
+ end
+ end
+ end
+ frame:SetScript("OnMouseDown", frame_OnMouseDown)
+ if not frame_OnMouseUp then
+ function frame_OnMouseUp(this, button)
+ local self = this.self
+ if type(self.OnFuBarMouseUp) == "function" then
+ self:OnFuBarMouseUp(button)
+ end
+ end
+ end
+ frame:SetScript("OnMouseUp", frame_OnMouseUp)
+ if not frame_OnReceiveDrag then
+ function frame_OnReceiveDrag(this)
+ local self = this.self
+ if (self:IsFuBarMinimapAttached() and not this.dragged) and type(self.OnReceiveDrag) == "function" then
+ self:OnFuBarReceiveDrag()
+ end
+ end
+ end
+ frame:SetScript("OnReceiveDrag", frame_OnReceiveDrag)
+ return frame
+end
+
+local child_OnEnter, child_OnLeave, child_OnClick, child_OnDoubleClick, child_OnMouseDown, child_OnMouseUp, child_OnReceiveDrag
+--[[---------------------------------------------------------------------------
+Arguments:
+ string - type of the frame, e.g. "Frame", "Button", etc.
+ [optional] string - name of the frame
+ [optional] frame - parent frame
+Returns:
+ frame - a child frame that can be manipulated and used
+Example:
+ local child = self:CreatePluginChildFrame("Frame", nil, self.frame)
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:CreatePluginChildFrame(frameType, name, parent)
+ local child = CreateFrame(frameType, name, parent)
+ if parent then
+ child:SetFrameLevel(parent:GetFrameLevel() + 2)
+ end
+ child.self = self
+ if not child_OnEnter then
+ function child_OnEnter(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:GetScript("OnEnter") then
+ frame:GetScript("OnEnter")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnEnter", child_OnEnter)
+ if not child_OnLeave then
+ function child_OnLeave(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:GetScript("OnLeave") then
+ frame:GetScript("OnLeave")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnLeave", child_OnLeave)
+ if child:HasScript("OnClick") then
+ if not child_OnClick then
+ function child_OnClick(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:HasScript("OnClick") and frame:GetScript("OnClick") then
+ frame:GetScript("OnClick")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnClick", child_OnClick)
+ end
+ if child:HasScript("OnDoubleClick") then
+ if not child_OnDoubleClick then
+ function child_OnDoubleClick(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:HasScript("OnDoubleClick") and frame:GetScript("OnDoubleClick") then
+ frame:GetScript("OnDoubleClick")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnDoubleClick", child_OnDoubleClick)
+ end
+ if not child_OnMouseDown then
+ function child_OnMouseDown(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:HasScript("OnMouseDown") and frame:GetScript("OnMouseDown") then
+ frame:GetScript("OnMouseDown")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnMouseDown", child_OnMouseDown)
+ if not child_OnMouseUp then
+ function child_OnMouseUp(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:HasScript("OnMouseUp") and frame:GetScript("OnMouseUp") then
+ frame:GetScript("OnMouseUp")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnMouseUp", child_OnMouseUp)
+ if not child_OnReceiveDrag then
+ function child_OnReceiveDrag(this, ...)
+ local self = this.self
+ local frame = pluginToFrame[self]
+ if frame:HasScript("OnReceiveDrag") and frame:GetScript("OnReceiveDrag") then
+ frame:GetScript("OnReceiveDrag")(frame, ...)
+ end
+ end
+ end
+ child:SetScript("OnReceiveDrag", child_OnReceiveDrag)
+ return child
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ Opens the configuration menu associated with this plugin.
+Example:
+ self:OpenMenu()
+-----------------------------------------------------------------------------]]
+function FuBarPlugin:OpenMenu(frame)
+ if not frame then
+ frame = self:IsFuBarMinimapAttached() and pluginToMinimapFrame[self] or pluginToFrame[self]
+ end
+ if not frame:IsVisible() then
+ frame = UIParent
+ end
+ local configType = getPluginOption(self, 'configType', "LibRockConfig-1.0")
+ if configType == "None" then
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "GameTooltip" then
+ if GameTooltip:IsOwned(frame) then
+ GameTooltip:Hide()
+ end
+ elseif tooltipType == "Custom" and type(self.CloseTooltip) == "function" then
+ self:CloseTooltip()
+ elseif tooltipType == "Tablet-2.0" and Tablet20 then
+ Tablet20:Close()
+ end
+ elseif configType == "Dewdrop-2.0" then
+ if not frame or not self:GetFrame() or Dewdrop20:IsOpen(frame) then
+ Dewdrop20:Close()
+ return
+ end
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "GameTooltip" then
+ if GameTooltip:IsOwned(frame) then
+ GameTooltip:Hide()
+ end
+ elseif tooltipType == "Custom" and type(self.CloseTooltip) == "function" then
+ self:CloseTooltip()
+ elseif tooltipType == "Tablet-2.0" and Tablet20 then
+ Tablet20:Close()
+ end
+
+ if not Dewdrop20:IsRegistered(self:GetFrame()) then
+ if type(self.OnMenuRequest) == "table" and (not self.OnMenuRequest.handler or self.OnMenuRequest.handler == self) and self.OnMenuRequest.type == "group" then
+ Dewdrop20:InjectAceOptionsTable(self, self.OnMenuRequest)
+ if self.OnMenuRequest.args and CheckFuBar() and not getPluginOption(self, 'independentProfile', false) then
+ self.OnMenuRequest.args.profile = nil
+ if self.OnMenuRequest.extraArgs then
+ self.OnMenuRequest.extraArgs.profile = nil
+ end
+ end
+ end
+ Dewdrop20:Register(self:GetFrame(),
+ 'children', type(self.OnMenuRequest) == "table" and self.OnMenuRequest or function(level, value, valueN_1, valueN_2, valueN_3, valueN_4)
+ if level == 1 then
+ -- if not getPluginOption(self, 'hideMenuTitle', false) then
+ -- Dewdrop20:AddLine(
+ -- 'text', self:GetTitle(),
+ -- 'isTitle', true
+ -- )
+ -- end
+
+ if self.OnMenuRequest then
+ self:OnMenuRequest(level, value, false, valueN_1, valueN_2, valueN_3, valueN_4)
+ end
+
+ if not getPluginOption(self, 'overrideMenu', false) then
+ if self.MenuSettings and not getPluginOption(self, 'hideMenuTitle', false) then
+ Dewdrop20:AddLine()
+ end
+ self:AddImpliedMenuOptions()
+ end
+ else
+ if not getPluginOption(self, 'overrideMenu', false) and self:AddImpliedMenuOptions() then
+ else
+ if self.OnMenuRequest then
+ self:OnMenuRequest(level, value, false, valueN_1, valueN_2, valueN_3, valueN_4)
+ end
+ end
+ end
+ if level == 1 then
+ Dewdrop20:AddLine(
+ 'text', CLOSE,
+ 'tooltipTitle', CLOSE,
+ 'tooltipText', CLOSE_DESC,
+ 'func', Dewdrop.Close,
+ 'arg1', Dewdrop
+ )
+ end
+ end,
+ 'point', function(frame)
+ local x, y = frame:GetCenter()
+ local leftRight
+ if x < GetScreenWidth() / 2 then
+ leftRight = "LEFT"
+ else
+ leftRight = "RIGHT"
+ end
+ if y < GetScreenHeight() / 2 then
+ return "BOTTOM" .. leftRight, "TOP" .. leftRight
+ else
+ return "TOP" .. leftRight, "BOTTOM" .. leftRight
+ end
+ end,
+ 'dontHook', true
+ )
+ end
+ if frame == self:GetFrame() then
+ Dewdrop20:Open(self:GetFrame())
+ elseif frame ~= UIParent then
+ Dewdrop20:Open(frame, self:GetFrame())
+ else
+ Dewdrop20:Open(frame, self:GetFrame(), 'cursorX', true, 'cursorY', true)
+ end
+ elseif configType == "LibRockConfig-1.0" then
+ if not RockConfig then
+ RockConfig = Rock and Rock("LibRockConfig-1.0", false, true)
+ end
+ if RockConfig then
+ RockConfig.OpenConfigMenu(self)
+ end
+ elseif configType == "AceConfigDialog-3.0" then
+ if not AceConfigDialog30 then
+ AceConfigDialog30 = LibStub("AceConfigDialog-3.0", true)
+ end
+ if AceConfigDialog30 then
+ AceConfigDialog30:Open(getPluginOption(self, 'aceConfig30', self.name))
+ end
+ elseif configType == "AceConfigDropdown-3.0" then
+ if not AceConfigDropdown30 then
+ AceConfigDropdown30 = LibStub("AceConfigDropdown-3.0", true)
+ end
+ if AceConfigDropdown30 then
+ -- TODO: finalize this once AceConfigDropdown-3.0 exists
+ end
+ else
+ -- TODO: add more possibilities
+ end
+end
+
+function FuBarPlugin.OnEmbedInitialize(FuBarPlugin, self)
+ if not self.frame then
+ local name = MAJOR_VERSION .. "_" .. self:GetTitle() .. "_" .. "Frame"
+ local frame = _G[name]
+ if not frame or not _G[name .. "Text"] or not _G[name .. "Icon"] then
+ frame = FuBarPlugin.CreateBasicPluginFrame(self, name)
+
+ local icon = frame:CreateTexture(name .. "Icon", "ARTWORK")
+ frame.icon = icon
+ icon:SetWidth(16)
+ icon:SetHeight(16)
+ icon:SetPoint("LEFT", frame, "LEFT")
+
+ local text = frame:CreateFontString(name .. "Text", "ARTWORK")
+ frame.text = text
+ text:SetWidth(134)
+ text:SetHeight(24)
+ text:SetPoint("LEFT", icon, "RIGHT", 0, 1)
+ text:SetFontObject(GameFontNormal)
+ end
+ pluginToFrame[self] = frame
+ else
+ pluginToFrame[self] = self.frame
+ if not pluginToOptions[self] then
+ pluginToOptions[self] = {}
+ end
+ pluginToOptions[self].userDefinedFrame = true
+ end
+
+ local frame = pluginToFrame[self]
+ frame.plugin = self
+ frame:SetParent(UIParent)
+ frame:SetPoint("RIGHT", UIParent, "LEFT", -5, 0)
+ frame:Hide()
+
+ local iconPath = getPluginOption(self, 'iconPath', false)
+ if iconPath then
+ self:SetFuBarIcon(iconPath)
+ end
+
+ local registerCallback = rawget(self, "db") and rawget(rawget(self, "db"), "callbacks") and rawget(rawget(self, "db"), "RegisterCallback") or nil
+ if type(registerCallback) == "function" then
+ registerCallback(FuBarPlugin, "OnProfileChanged", "OnEmbedProfileEnable", self)
+ registerCallback(FuBarPlugin, "OnProfileCopied", "OnEmbedProfileEnable", self)
+ registerCallback(FuBarPlugin, "OnProfileReset", "OnEmbedProfileEnable", self)
+ end
+ if CheckFuBar() then
+ FuBar:RegisterPlugin(self)
+ end
+end
+
+local CheckShow = function(self, panelId)
+ if not pluginToFrame[self]:IsShown() and (not pluginToMinimapFrame[self] or not pluginToMinimapFrame[self]:IsShown()) then
+ self:Show(panelId)
+ end
+end
+
+local schedules = {}
+local f = CreateFrame("Frame")
+f:SetScript("OnUpdate", function(this)
+ for i,v in ipairs(schedules) do
+ local success, ret = pcall(unpack(v))
+ if not success then
+ geterrorhandler()(ret)
+ end
+ schedules[i] = del(v)
+ end
+ f:Hide()
+end)
+
+--local recheckPlugins
+--local AceConsole
+local notFirst = {}
+function FuBarPlugin.OnEmbedEnable(FuBarPlugin, self)
+ if not getPluginOption(self, 'userDefinedFrame', false) then
+ local icon = pluginToFrame[self].icon
+ if self:IsFuBarIconShown() then
+ icon:Show()
+ else
+ icon:Hide()
+ end
+ end
+ self:CheckWidth(true)
+
+ if not getPluginOption(self, 'hideWithoutStandby', false) or (getLazyDatabaseValue(self) and not getLazyDatabaseValue(self, 'hidden')) then
+ if notFirst[self] then
+ CheckShow(self, self.panelIdTmp)
+ else
+ notFirst[self] = true
+ schedules[#schedules+1] = newList(CheckShow, self, self.panelIdTmp)
+ f:Show()
+ end
+ end
+
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "Tablet-2.0" and not getPluginOption(self, 'cannotDetachTooltip', false) and getLazyDatabaseValue(self, 'detachedTooltip', 'detached') then
+ schedules[#schedules+1] = newList(self.DetachFuBarTooltip, self)
+ f:Show()
+ end
+
+ if IsLoadOnDemand(self) and CheckFuBar() then
+ if not FuBar.db.profile.loadOnDemand then
+ FuBar.db.profile.loadOnDemand = {}
+ end
+ if not FuBar.db.profile.loadOnDemand[folderNames[self]] then
+ FuBar.db.profile.loadOnDemand[folderNames[self]] = {}
+ end
+ FuBar.db.profile.loadOnDemand[folderNames[self]].disabled = nil
+ end
+ --[[
+ if CheckFuBar() and AceLibrary:HasInstance("AceConsole-2.0") then
+ if not recheckPlugins then
+ if not AceConsole then
+ AceConsole = AceLibrary("AceConsole-2.0")
+ end
+ recheckPlugins = function()
+ for k,v in pairs(AceConsole.registry) do
+ if type(v) == "table" and v.args and AceOO.inherits(v.handler, FuBarPlugin) and not v.handler.independentProfile then
+ v.args.profile = nil
+ end
+ end
+ end
+ end
+ FuBarPlugin:ScheduleEvent("FuBarPlugin-recheckPlugins", recheckPlugins, 0)
+ end
+ ]]
+end
+
+function FuBarPlugin.OnEmbedDisable(FuBarPlugin, self)
+ self:Hide(false)
+
+ if IsLoadOnDemand(self) and CheckFuBar() then
+ if not FuBar.db.profile.loadOnDemand then
+ FuBar.db.profile.loadOnDemand = {}
+ end
+ if not FuBar.db.profile.loadOnDemand[folderNames[self]] then
+ FuBar.db.profile.loadOnDemand[folderNames[self]] = {}
+ end
+ FuBar.db.profile.loadOnDemand[folderNames[self]].disabled = true
+ end
+end
+
+function FuBarPlugin.OnEmbedProfileEnable(FuBarPlugin, self)
+ self:UpdateFuBarPlugin()
+ if getLazyDatabaseValue(self) then
+ if not getLazyDatabaseValue(self, 'detachedTooltip') then
+ setLazyDatabaseValue(self, {}, 'detachedTooltip')
+ end
+ local tooltipType = getPluginOption(self, 'tooltipType', "GameTooltip")
+ if tooltipType == "Tablet-2.0" and Tablet20 then
+ if Tablet20.registry[pluginToFrame[self]] then
+ Tablet20:UpdateDetachedData(pluginToFrame[self], getLazyDatabaseValue(self, 'detachedTooltip'))
+ else
+ RegisterTablet20(self)
+ end
+ end
+ if MinimapContainer:HasPlugin(self) then
+ MinimapContainer:ReadjustLocation(self)
+ end
+ end
+end
+
+-- #NODOC
+function FuBarPlugin.GetEmbedRockConfigOptions(FuBarPlugin, self)
+ return 'icon', {
+ type = 'boolean',
+ name = SHOW_FUBAR_ICON,
+ desc = SHOW_FUBAR_ICON_DESC,
+ set = "ToggleFuBarIconShown",
+ get = "IsFuBarIconShown",
+ hidden = function()
+ return not getPluginOption(self, 'iconPath', false) or getPluginOption(self, 'hasNoText', false) or self:IsDisabled() or self:IsFuBarMinimapAttached() or not getLazyDatabaseValue(self)
+ end,
+ order = -13.7,
+ handler = self,
+ }, 'text', {
+ type = 'boolean',
+ name = SHOW_FUBAR_TEXT,
+ desc = SHOW_FUBAR_TEXT_DESC,
+ set = "ToggleFuBarTextShown",
+ get = "IsFuBarTextShown",
+ hidden = function()
+ return getPluginOption(self, 'cannotHideText', false) or not getPluginOption(self, 'iconPath', false) or getPluginOption(self, 'hasNoText') or self:IsDisabled() or self:IsFuBarMinimapAttached() or not getLazyDatabaseValue(self)
+ end,
+ order = -13.6,
+ handler = self,
+ }, 'colorText', {
+ type = 'boolean',
+ name = SHOW_COLORED_FUBAR_TEXT,
+ desc = SHOW_COLORED_FUBAR_TEXT_DESC,
+ set = "ToggleFuBarTextColored",
+ get = "IsFuBarTextColored",
+ hidden = function()
+ return getPluginOption(self, 'userDefinedFrame', false) or getPluginOption(self, 'hasNoText', false) or getPluginOption(self, 'hasNoColor', false) or self:IsDisabled() or self:IsFuBarMinimapAttached() or not getLazyDatabaseValue(self)
+ end,
+ order = -13.5,
+ handler = self,
+ }, 'detachTooltip', {
+ type = 'boolean',
+ name = DETACH_FUBAR_TOOLTIP,
+ desc = DETACH_FUBAR_TOOLTIP_DESC,
+ get = "IsFuBarTooltipDetached",
+ set = "ToggleFuBarTooltipDetached",
+ hidden = function()
+ return not Tablet20 or getPluginOption(self, 'tooltipType', "GameTooltip") ~= "Tablet-2.0" or self:IsDisabled()
+ end,
+ order = -13.4,
+ handler = self,
+ }, 'lockTooltip', {
+ type = 'boolean',
+ name = LOCK_FUBAR_TOOLTIP,
+ desc = LOCK_FUBAR_TOOLTIP_DESC,
+ get = function()
+ return Tablet20:IsLocked(pluginToFrame[self])
+ end,
+ set = function()
+ return Tablet20:ToggleLocked(pluginToFrame[self])
+ end,
+ disabled = function()
+ return not self:IsFuBarTooltipDetached()
+ end,
+ hidden = function()
+ return not Tablet20 or getPluginOption(self, 'tooltipType', "GameTooltip") ~= "Tablet-2.0" or getPluginOption(self, 'cannotDetachTooltip', false) or self:IsDisabled()
+ end,
+ order = -13.3,
+ handler = self,
+ }, 'position', {
+ type = 'choice',
+ name = POSITION_ON_FUBAR,
+ desc = POSITION_ON_FUBAR_DESC,
+ choices = {
+ LEFT = POSITION_LEFT,
+ CENTER = POSITION_CENTER,
+ RIGHT = POSITION_RIGHT
+ },
+ choiceSort = {
+ "LEFT",
+ "CENTER",
+ "RIGHT",
+ },
+ get = function()
+ return self:GetPanel() and self:GetPanel():GetPluginSide(self)
+ end,
+ set = function(value)
+ if self:GetPanel() then
+ self:GetPanel():SetPluginSide(self, value)
+ end
+ end,
+ hidden = function()
+ return self:IsFuBarMinimapAttached() or self:IsDisabled() or not pluginToPanel[self]
+ end,
+ order = -13.2,
+ handler = self,
+ }, 'minimapAttach', {
+ type = 'boolean',
+ name = ATTACH_PLUGIN_TO_MINIMAP,
+ desc = ATTACH_PLUGIN_TO_MINIMAP_DESC,
+ get = "IsFuBarMinimapAttached",
+ set = "ToggleFuBarMinimapAttached",
+ hidden = function()
+ return (getPluginOption(self, 'cannotAttachToMinimap', false) and not self:IsFuBarMinimapAttached()) or not CheckFuBar() or self:IsDisabled()
+ end,
+ order = -13.1,
+ handler = self,
+ }, 'hide', {
+ type = 'boolean',
+ name = function()
+ if self:IsFuBarMinimapAttached() then
+ return HIDE_MINIMAP_BUTTON
+ else
+ return HIDE_FUBAR_PLUGIN
+ end
+ end,
+ desc = HIDE_FUBAR_PLUGIN_DESC,
+ get = function()
+ return not pluginToFrame[self]:IsShown() and (not pluginToMinimapFrame[self] or not pluginToMinimapFrame[self]:IsShown())
+ end,
+ set = function(value)
+ if not value then
+ self:Show()
+ else
+ self:Hide()
+ end
+ end,
+ hidden = function()
+ return not getPluginOption(self, 'hideWithoutStandby', false) or self:IsDisabled()
+ end,
+ order = -13,
+ handler = self,
+ }
+end
+
+local plugins = MinimapContainer.plugins or {}
+for k in pairs(MinimapContainer) do
+ MinimapContainer[k] = nil
+end
+MinimapContainer.plugins = plugins
+
+local minimap_OnMouseDown, minimap_OnMouseUp
+function MinimapContainer:AddPlugin(plugin)
+ if CheckFuBar() and FuBar:IsChangingProfile() then
+ return
+ end
+ if pluginToPanel[plugin] then
+ pluginToPanel[plugin]:RemovePlugin(plugin)
+ end
+ pluginToPanel[plugin] = self
+ if not pluginToMinimapFrame[plugin] then
+ local frame = CreateFrame("Button", pluginToFrame[plugin]:GetName() .. "MinimapButton", Minimap)
+ pluginToMinimapFrame[plugin] = frame
+ plugin.minimapFrame = frame
+ frame.plugin = plugin
+ frame:SetWidth(31)
+ frame:SetHeight(31)
+ frame:SetFrameStrata("BACKGROUND")
+ frame:SetFrameLevel(4)
+ frame:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight")
+ local icon = frame:CreateTexture(frame:GetName() .. "Icon", "BACKGROUND")
+ plugin.minimapIcon = icon
+ local path = plugin:GetFuBarIcon() or (pluginToFrame[plugin].icon and pluginToFrame[plugin].icon:GetTexture()) or "Interface\\Icons\\INV_Misc_QuestionMark"
+ icon:SetTexture(path)
+ if type(path) == "string" and path:sub(1, 16) == "Interface\\Icons\\" then
+ icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
+ else
+ icon:SetTexCoord(0, 1, 0, 1)
+ end
+ icon:SetWidth(20)
+ icon:SetHeight(20)
+ icon:SetPoint("TOPLEFT", frame, "TOPLEFT", 7, -5)
+ local overlay = frame:CreateTexture(frame:GetName() .. "Overlay","OVERLAY")
+ overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder")
+ overlay:SetWidth(53)
+ overlay:SetHeight(53)
+ overlay:SetPoint("TOPLEFT",frame,"TOPLEFT")
+ frame:EnableMouse(true)
+ if getPluginOption(plugin, 'configType', "LibRockConfig-1.0") == "None" then
+ frame:RegisterForClicks("LeftButtonUp", "RightButtonUp")
+ else
+ frame:RegisterForClicks("LeftButtonUp")
+ end
+
+ frame.self = plugin
+ if not frame_OnEnter then
+ function frame_OnEnter(this)
+ if type(this.self.OnFuBarEnter) == "function" then
+ this.self:OnFuBarEnter()
+ end
+ end
+ end
+ frame:SetScript("OnEnter", frame_OnEnter)
+ if not frame_OnLeave then
+ function frame_OnLeave(this)
+ if type(this.self.OnFuBarLeave) == "function" then
+ this.self:OnFuBarLeave()
+ end
+ end
+ end
+ frame:SetScript("OnLeave", frame_OnLeave)
+ if not frame_OnClick then
+ function frame_OnClick(this, arg1)
+ if this.self:IsMinimapAttached() and this.dragged then return end
+ if type(this.self.OnFuBarClick) == "function" then
+ this.self:OnFuBarClick(arg1)
+ end
+ end
+ end
+ frame:SetScript("OnClick", frame_OnClick)
+ if not frame_OnDoubleClick then
+ function frame_OnDoubleClick(this, arg1)
+ if type(this.self.OnFuBarDoubleClick) == "function" then
+ this.self:OnFuBarDoubleClick(arg1)
+ end
+ end
+ end
+ frame:SetScript("OnDoubleClick", frame_OnDoubleClick)
+ if not frame_OnReceiveDrag then
+ function frame_OnReceiveDrag(this)
+ if this.self:IsMinimapAttached() and this.dragged then return end
+ if type(this.self.OnFuBarReceiveDrag) == "function" then
+ this.self:OnFuBarReceiveDrag()
+ end
+ end
+ end
+ frame:SetScript("OnReceiveDrag", frame_OnReceiveDrag)
+ if not minimap_OnMouseDown then
+ function minimap_OnMouseDown(this, arg1)
+ this.dragged = false
+ if arg1 == "LeftButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then
+ HideDropDownMenu(1)
+ if type(this.self.OnFuBarMouseDown) == "function" then
+ this.self:OnFuBarMouseDown(arg1)
+ end
+ elseif arg1 == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then
+ this.self:OpenMenu(this)
+ else
+ HideDropDownMenu(1)
+ if type(this.self.OnFuBarMouseDown) == "function" then
+ this.self:OnFuBarMouseDown(arg1)
+ end
+ end
+ if this.self.OnFuBarClick or this.self.OnFuBarMouseDown or this.self.OnFuBarMouseUp or this.self.OnFuBarDoubleClick then
+ local minimapIconTexture = this.self.minimapIcon:GetTexture()
+ if type(minimapIconTexture) == "string" and minimapIconTexture:sub(1, 16) == "Interface\\Icons\\" then
+ this.self.minimapIcon:SetTexCoord(0.14, 0.86, 0.14, 0.86)
+ else
+ this.self.minimapIcon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
+ end
+ end
+ end
+ end
+ frame:SetScript("OnMouseDown", minimap_OnMouseDown)
+ if not minimap_OnMouseUp then
+ function minimap_OnMouseUp(this, arg1)
+ if not this.dragged and type(this.self.OnFuBarMouseUp) == "function" then
+ this.self:OnFuBarMouseUp(arg1)
+ end
+ local minimapIconTexture = this.self.minimapIcon:GetTexture()
+ if type(minimapIconTexture) == "string" and minimapIconTexture:sub(1, 16) == "Interface\\Icons\\" then
+ this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ this.self.minimapIcon:SetTexCoord(0, 1, 0, 1)
+ end
+ end
+ end
+ frame:SetScript("OnMouseUp", minimap_OnMouseUp)
+ frame:RegisterForDrag("LeftButton")
+ frame:SetScript("OnDragStart", self.OnDragStart)
+ frame:SetScript("OnDragStop", self.OnDragStop)
+
+ if getPluginOption(plugin, 'tooltipType', "GameTooltip") == "Tablet-2.0" then
+ -- Note that we have to do this after :SetScript("OnEnter"), etc,
+ -- so that Tablet-2.0 can override it properly.
+ RegisterTablet20(plugin)
+ Tablet20:Register(frame, pluginToFrame[plugin])
+ end
+ end
+ pluginToFrame[plugin]:Hide()
+ pluginToMinimapFrame[plugin]:Show()
+ self:ReadjustLocation(plugin)
+ table.insert(self.plugins, plugin)
+ local exists = false
+ return true
+end
+
+function MinimapContainer:RemovePlugin(index)
+ if CheckFuBar() and FuBar:IsChangingProfile() then
+ return
+ end
+ if type(index) == "table" then
+ index = self:IndexOfPlugin(index)
+ if not index then
+ return
+ end
+ end
+ local t = self.plugins
+ local plugin = t[index]
+ assert(pluginToPanel[plugin] == self, "Plugin has improper panel field")
+ plugin:SetPanel(nil)
+ table.remove(t, index)
+ return true
+end
+
+function MinimapContainer:ReadjustLocation(plugin)
+ local frame = pluginToMinimapFrame[plugin]
+ if plugin.db and plugin.db.profile.minimapPositionWild then
+ frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", plugin.db.profile.minimapPositionX, plugin.db.profile.minimapPositionY)
+ elseif not plugin.db and plugin.minimapPositionWild then
+ frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", plugin.minimapPositionX, plugin.minimapPositionY)
+ else
+ local position
+ if plugin.db then
+ position = plugin.db.profile.minimapPosition or getPluginOption(plugin, 'defaultMinimapPosition', nil) or math.random(1, 360)
+ else
+ position = plugin.minimapPosition or getPluginOption(plugin, 'defaultMinimapPosition', nil) or math.random(1, 360)
+ end
+ local angle = math.rad(position or 0)
+ local x,y
+ local minimapShape = GetMinimapShape and GetMinimapShape() or "ROUND"
+ local cos = math.cos(angle)
+ local sin = math.sin(angle)
+
+ local round = true
+ if minimapShape == "ROUND" then
+ -- do nothing
+ elseif minimapShape == "SQUARE" then
+ round = false
+ elseif minimapShape == "CORNER-TOPRIGHT" then
+ if cos < 0 or sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-TOPLEFT" then
+ if cos > 0 or sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-BOTTOMRIGHT" then
+ if cos < 0 or sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-BOTTOMLEFT" then
+ if cos > 0 or sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-LEFT" then
+ if cos > 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-RIGHT" then
+ if cos < 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-TOP" then
+ if sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-BOTTOM" then
+ if sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-TOPRIGHT" then
+ if cos < 0 and sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-TOPLEFT" then
+ if cos > 0 and sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-BOTTOMRIGHT" then
+ if cos < 0 and sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-BOTTOMLEFT" then
+ if cos > 0 and sin > 0 then
+ round = false
+ end
+ end
+
+ if round then
+ x = cos * 80
+ y = sin * 80
+ else
+ x = 80 * 2^0.5 * cos
+ y = 80 * 2^0.5 * sin
+ if x < -80 then
+ x = -80
+ elseif x > 80 then
+ x = 80
+ end
+ if y < -80 then
+ y = -80
+ elseif y > 80 then
+ y = 80
+ end
+ end
+ frame:SetPoint("CENTER", Minimap, "CENTER", x, y)
+ end
+end
+
+function MinimapContainer:GetPlugin(index)
+ return self.plugins[index]
+end
+
+function MinimapContainer:GetNumPlugins()
+ return #self.plugins
+end
+
+function MinimapContainer:IndexOfPlugin(plugin)
+ for i,p in ipairs(self.plugins) do
+ if p == plugin then
+ return i, "MINIMAP"
+ end
+ end
+end
+
+function MinimapContainer:HasPlugin(plugin)
+ return self:IndexOfPlugin(plugin) ~= nil
+end
+
+function MinimapContainer:GetPluginSide(plugin)
+ local index = self:IndexOfPlugin(plugin)
+ assert(index, "Plugin not in panel")
+ return "MINIMAP"
+end
+
+function MinimapContainer.OnDragStart(this)
+ this.dragged = true
+ this:LockHighlight()
+ this:SetScript("OnUpdate", MinimapContainer.OnUpdate)
+ local minimapIconTexture = this.self.minimapIcon:GetTexture()
+ if type(minimapIconTexture) == "string" and minimapIconTexture:sub(1, 16) == "Interface\\Icons\\" then
+ this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ this.self.minimapIcon:SetTexCoord(0, 1, 0, 1)
+ end
+end
+
+function MinimapContainer.OnDragStop(this)
+ this:SetScript("OnUpdate", nil)
+ this:UnlockHighlight()
+end
+
+function MinimapContainer.OnUpdate(this, elapsed)
+ if not IsAltKeyDown() then
+ local mx, my = Minimap:GetCenter()
+ local px, py = GetCursorPosition()
+ local scale = UIParent:GetEffectiveScale()
+ px, py = px / scale, py / scale
+ local position = math.deg(math.atan2(py - my, px - mx))
+ if position <= 0 then
+ position = position + 360
+ elseif position > 360 then
+ position = position - 360
+ end
+ if this.self.db then
+ this.self.db.profile.minimapPosition = position
+ this.self.db.profile.minimapPositionX = nil
+ this.self.db.profile.minimapPositionY = nil
+ this.self.db.profile.minimapPositionWild = nil
+ else
+ this.self.minimapPosition = position
+ this.self.minimapPositionX = nil
+ this.self.minimapPositionY = nil
+ this.self.minimapPositionWild = nil
+ end
+ else
+ local px, py = GetCursorPosition()
+ local scale = UIParent:GetEffectiveScale()
+ px, py = px / scale, py / scale
+ if this.self.db then
+ this.self.db.profile.minimapPositionX = px
+ this.self.db.profile.minimapPositionY = py
+ this.self.db.profile.minimapPosition = nil
+ this.self.db.profile.minimapPositionWild = true
+ else
+ this.self.minimapPositionX = px
+ this.self.minimapPositionY = py
+ this.self.minimapPosition = nil
+ this.self.minimapPositionWild = true
+ end
+ end
+ MinimapContainer:ReadjustLocation(this.self)
+end
+
+for target,_ in pairs(mixinTargets) do
+ for _,name in pairs(mixins) do
+ if not target[name] or target[name] == oldLib[name] then
+ target[name] = FuBarPlugin[name]
+ end
+ end
+end
diff --git a/FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.toc b/FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.toc
new file mode 100644
index 0000000..2c6ed5d
--- /dev/null
+++ b/FuBar/libs/LibFuBarPlugin-3.0/LibFuBarPlugin-3.0.toc
@@ -0,0 +1,20 @@
+## Interface: 100002
+## LoadOnDemand: 1
+## Title: Lib: FuBarPlugin-3.0
+## Notes: A library to provide a means create a FuBar-compatible plugin.
+## Notes-zhTW: 一個提供支援FuBar所需功能的插件。
+## Notes-esES: Una biblioteca para crear plugins compatibles con Fubar.
+## Author: ckknight
+## eMail: ckknight@gmail.com
+## X-Credits: Arrowmaster
+## Version: 3.0
+## X-Category: Library
+## OptionalDeps: FuBar
+## X-License: LGPL v2.1
+## X-Curse-Packaged-Version: r64
+## X-Curse-Project-Name: LibFuBarPlugin-3.0
+## X-Curse-Project-ID: libfubarplugin-3-0
+## X-Curse-Repository-ID: wow/libfubarplugin-3-0/mainline
+
+LibStub\LibStub.lua
+lib.xml
diff --git a/FuBar/libs/LibFuBarPlugin-3.0/lib.xml b/FuBar/libs/LibFuBarPlugin-3.0/lib.xml
new file mode 100644
index 0000000..a817c51
--- /dev/null
+++ b/FuBar/libs/LibFuBarPlugin-3.0/lib.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/FuBar/libs/LibJostle-3.0/CHANGES.txt b/FuBar/libs/LibJostle-3.0/CHANGES.txt
new file mode 100644
index 0000000..e96e934
--- /dev/null
+++ b/FuBar/libs/LibJostle-3.0/CHANGES.txt
@@ -0,0 +1,87 @@
+------------------------------------------------------------------------
+r71 | MysticalOS | 2019-10-04 21:20:31 +0000 (Fri, 04 Oct 2019) | 1 line
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+
+Revert StatusTrackingBarManager fix. Although it works super well, it also throws action blocked errors. The only other solution I could find to avoid breaking StatusTrackingBarManager was no longer supporting moving MainMenuBar at all. I�ll leave that decision up to someone else. :D
+------------------------------------------------------------------------
+r70 | MysticalOS | 2019-10-04 03:52:38 +0000 (Fri, 04 Oct 2019) | 1 line
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+
+Fix libJostle breaking StatusTrackingBarManager in patch 8.2.5+
+------------------------------------------------------------------------
+r69 | mitch0 | 2019-08-15 10:24:12 +0000 (Thu, 15 Aug 2019) | 1 line
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+
+fix missing UnitHasVehicleUI for classic
+------------------------------------------------------------------------
+r68 | mitch0 | 2018-08-27 06:16:38 +0000 (Mon, 27 Aug 2018) | 1 line
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+
+reverting vehicle ui fixes...
+------------------------------------------------------------------------
+r67 | mitch0 | 2018-08-25 09:53:31 +0000 (Sat, 25 Aug 2018) | 1 line
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+
+try to fix vehicle ui (based on changes made by yess in ChocolateBar)
+------------------------------------------------------------------------
+r66 | mitch0 | 2018-08-15 14:08:42 +0000 (Wed, 15 Aug 2018) | 1 line
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+
+adding UIWidgetTopCenterContainerFrame
+------------------------------------------------------------------------
+r65 | yess | 2018-07-27 15:33:24 +0000 (Fri, 27 Jul 2018) | 1 line
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+
+Fix unresponsive action bars after exiting a vehicular UI
+------------------------------------------------------------------------
+r64 | elkano | 2018-07-24 20:08:27 +0000 (Tue, 24 Jul 2018) | 3 lines
+Changed paths:
+ M /trunk/LibJostle-3.0.toc
+ M /trunk/lib.xml
+
+- updated TOC for WoW 8.0.x
+- fixed load order for LibStub in lib.xml
+- removed reference to non-existant externals.xml
+------------------------------------------------------------------------
+r63 | yess | 2018-07-24 13:05:52 +0000 (Tue, 24 Jul 2018) | 1 line
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+ M /trunk/LibJostle-3.0.toc
+ M /trunk/lib.xml
+
+Set MainMenuBar user placed.
+------------------------------------------------------------------------
+r62 | yess | 2018-07-22 18:31:05 +0000 (Sun, 22 Jul 2018) | 1 line
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+
+fix MainMenuBar moving to the center when it is placed on the left side.
+------------------------------------------------------------------------
+r61 | yess | 2018-07-19 16:20:09 +0000 (Thu, 19 Jul 2018) | 1 line
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+
+Add MicroButtonAndBagsBar
+------------------------------------------------------------------------
+r60 | yess | 2016-08-08 04:23:23 +0000 (Mon, 08 Aug 2016) | 1 line
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+
+Add OrderHallCommandBar support
+------------------------------------------------------------------------
+r59 | yess | 2016-08-05 13:41:57 +0000 (Fri, 05 Aug 2016) | 2 lines
+Changed paths:
+ M /trunk/LibJostle-3.0.lua
+ M /trunk/LibJostle-3.0.toc
+
+BuffFrame, PlayerFrame and TargetFrame should now properly rearrange after a loading screen.
+Removed PLAYER_AURAS_CHANGED event as this was replaced by UNIT_AURA in patch 3.02 and does no longer seem necessary.
+------------------------------------------------------------------------
+
diff --git a/FuBar/libs/LibJostle-3.0/LICENSE.txt b/FuBar/libs/LibJostle-3.0/LICENSE.txt
new file mode 100644
index 0000000..df241c1
--- /dev/null
+++ b/FuBar/libs/LibJostle-3.0/LICENSE.txt
@@ -0,0 +1,205 @@
+GNU Lesser General Public License
+
+
+
+
+
+Version 2.1, February 1999
+
+
+Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+Preamble
+
+ The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
+
+ We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
+
+ For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
+
+ Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
+
+ Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
+
+1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
+
+ You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+
+
+a) The modified work must itself be a software library.
+b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
+c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
+d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
+
+
+ (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
+
+ These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+ Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
+
+ In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
+
+ Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
+
+4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
+
+
+ If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
+
+5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
+
+Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
+
+6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
+
+a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
+
+b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
+
+c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
+
+d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
+
+e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
+
+
+ For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+ It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
+
+7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
+
+
+a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
+
+b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
+
+8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
+
+10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
+
+11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
+
+14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+
+
+
+
+<one line to give the library's name and an idea of what it does.>
+Copyright (C) <year> <name of author>
+
+
+
+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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:
+
+
+
+Yoyodyne, Inc., hereby disclaims all copyright interest in
+the library `Frob' (a library for tweaking knobs) written
+by James Random Hacker.
+
+signature of Ty Coon, 1 April 1990
+Ty Coon, President of Vice
+
+
+That's all there is to it!
\ No newline at end of file
diff --git a/FuBar/libs/LibJostle-3.0/LibJostle-3.0.lua b/FuBar/libs/LibJostle-3.0/LibJostle-3.0.lua
new file mode 100644
index 0000000..9e953d5
--- /dev/null
+++ b/FuBar/libs/LibJostle-3.0/LibJostle-3.0.lua
@@ -0,0 +1,556 @@
+--[[
+Name: LibJostle-3.0
+Revision: $Rev: 71 $
+Author(s): ckknight (ckknight@gmail.com)
+Website: http://ckknight.wowinterface.com/
+Documentation: http://www.wowace.com/addons/libjostle-3-0/
+SVN: svn://svn.wowace.com/wow/libjostle-3-0/mainline/trunk
+Description: A library to handle rearrangement of Blizzard's frames when bars are added to the sides of the screen.
+License: LGPL v2.1
+--]]
+
+local MAJOR_VERSION = "LibJostle-3.0"
+local MINOR_VERSION = tonumber(("$Revision: 71 $"):match("(%d+)")) + 90000
+
+if not LibStub then error(MAJOR_VERSION .. " requires LibStub") end
+
+local oldLib = LibStub:GetLibrary(MAJOR_VERSION, true)
+local Jostle = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
+if not Jostle then
+ return
+end
+
+local blizzardFrames = {
+ 'PlayerFrame',
+ 'TargetFrame',
+ 'MinimapCluster',
+ 'PartyMemberFrame1',
+ 'TicketStatusFrame',
+ 'WorldStateAlwaysUpFrame',
+ 'MainMenuBar',
+ 'MultiBarRight',
+ 'CT_PlayerFrame_Drag',
+ 'CT_TargetFrame_Drag',
+ 'Gypsy_PlayerFrameCapsule',
+ 'Gypsy_TargetFrameCapsule',
+ 'ConsolidatedBuffs',
+ 'BuffFrame',
+ -- 'DEFAULT_CHAT_FRAME',
+ -- 'ChatFrame2',
+ 'GroupLootFrame1',
+ 'TutorialFrameParent',
+ 'FramerateLabel',
+ 'DurabilityFrame',
+ 'CastingBarFrame',
+ 'OrderHallCommandBar',
+ 'MicroButtonAndBagsBar',
+ 'UIWidgetTopCenterContainerFrame',
+ 'StatusTrackingBarManager',
+}
+local blizzardFramesData = {}
+
+local _G = _G
+-- classic compat:
+local UnitHasVehicleUI = UnitHasVehicleUI or function() return false end
+
+
+Jostle.hooks = oldLib and oldLib.hooks or {}
+Jostle.topFrames = oldLib and oldLib.topFrames or {}
+Jostle.bottomFrames = oldLib and oldLib.bottomFrames or {}
+Jostle.topAdjust = oldLib and oldLib.topAdjust
+Jostle.bottomAdjust = oldLib and oldLib.bottomAdjust
+if Jostle.topAdjust == nil then
+ Jostle.topAdjust = true
+end
+if Jostle.bottomAdjust == nil then
+ Jostle.bottomAdjust = true
+end
+
+if not Jostle.hooks.WorldMapFrame_Hide then
+ Jostle.hooks.WorldMapFrame_Hide = true
+ hooksecurefunc(WorldMapFrame, "Hide", function()
+ if Jostle.WorldMapFrame_Hide then
+ Jostle:WorldMapFrame_Hide()
+ end
+ end)
+end
+
+if not Jostle.hooks.TicketStatusFrame_OnEvent then
+ Jostle.hooks.TicketStatusFrame_OnEvent = true
+ hooksecurefunc("TicketStatusFrame_OnEvent", function()
+ if Jostle.TicketStatusFrame_OnEvent then
+ Jostle:TicketStatusFrame_OnEvent()
+ end
+ end)
+end
+
+if FCF_UpdateCombatLogPosition and not Jostle.hooks.FCF_UpdateCombatLogPosition then
+ Jostle.hooks.FCF_UpdateCombatLogPosition = true
+ hooksecurefunc("FCF_UpdateCombatLogPosition", function()
+ if Jostle.FCF_UpdateCombatLogPosition then
+ Jostle:FCF_UpdateCombatLogPosition()
+ end
+ end)
+end
+
+if not Jostle.hooks.UIParent_ManageFramePositions then
+ Jostle.hooks.UIParent_ManageFramePositions = true
+ hooksecurefunc("UIParent_ManageFramePositions", function()
+ if Jostle.UIParent_ManageFramePositions then
+ Jostle:UIParent_ManageFramePositions()
+ end
+ end)
+end
+
+Jostle.frame = oldLib and oldLib.frame or CreateFrame("Frame")
+local JostleFrame = Jostle.frame
+local start = GetTime()
+local nextTime = 0
+local fullyInitted = false
+
+JostleFrame:SetScript("OnUpdate", function(this, elapsed)
+ local now = GetTime()
+ if now - start >= 3 then
+ fullyInitted = true
+ for k,v in pairs(blizzardFramesData) do
+ blizzardFramesData[k] = nil
+ end
+ this:SetScript("OnUpdate", function(this, elapsed)
+ if GetTime() >= nextTime then
+ Jostle:Refresh()
+ this:Hide()
+ end
+ end)
+ end
+end)
+function JostleFrame:Schedule(time)
+ time = time or 0
+ nextTime = GetTime() + time
+ self:Show()
+end
+JostleFrame:UnregisterAllEvents()
+JostleFrame:SetScript("OnEvent", function(this, event, ...)
+ return Jostle[event](Jostle, ...)
+end)
+JostleFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
+JostleFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
+JostleFrame:RegisterEvent("PLAYER_CONTROL_GAINED")
+JostleFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
+JostleFrame:RegisterEvent("ACTIONBAR_UPDATE_STATE")
+
+function Jostle:ACTIONBAR_UPDATE_STATE()
+ self:Refresh(MainMenuBar)
+end
+
+function Jostle:PLAYER_ENTERING_WORLD()
+ self:Refresh(BuffFrame, PlayerFrame, TargetFrame)
+end
+
+function Jostle:WorldMapFrame_Hide()
+ JostleFrame:Schedule()
+end
+
+function Jostle:TicketStatusFrame_OnEvent()
+ self:Refresh(TicketStatusFrame, ConsolidatedBuffs)
+end
+
+function Jostle:FCF_UpdateDockPosition()
+ self:Refresh(DEFAULT_CHAT_FRAME)
+end
+
+function Jostle:FCF_UpdateCombatLogPosition()
+ self:Refresh(ChatFrame2)
+end
+
+function Jostle:UIParent_ManageFramePositions()
+ self:Refresh(GroupLootFrame1, TutorialFrameParent, FramerateLabel, DurabilityFrame)
+end
+
+function Jostle:PlayerFrame_SequenceFinished()
+ self:Refresh(PlayerFrame)
+end
+
+function Jostle:GetScreenTop()
+ local bottom = GetScreenHeight()
+ for _,frame in ipairs(self.topFrames) do
+ if frame.IsShown and frame:IsShown() and frame.GetBottom and frame:GetBottom() and frame:GetBottom() < bottom then
+ bottom = frame:GetBottom()
+ end
+ end
+ return bottom
+end
+
+function Jostle:GetScreenBottom()
+ local top = 0
+ for _,frame in ipairs(self.bottomFrames) do
+ if frame.IsShown and frame:IsShown() and frame.GetTop and frame:GetTop() and frame:GetTop() > top then
+ top = frame:GetTop()
+ end
+ end
+ return top
+end
+
+function Jostle:RegisterTop(frame)
+ for k,f in ipairs(self.bottomFrames) do
+ if f == frame then
+ table.remove(self.bottomFrames, k)
+ break
+ end
+ end
+ for _,f in ipairs(self.topFrames) do
+ if f == frame then
+ return
+ end
+ end
+ table.insert(self.topFrames, frame)
+ JostleFrame:Schedule()
+ return true
+end
+
+function Jostle:RegisterBottom(frame)
+ for k,f in ipairs(self.topFrames) do
+ if f == frame then
+ table.remove(self.topFrames, k)
+ break
+ end
+ end
+ for _,f in ipairs(self.bottomFrames) do
+ if f == frame then
+ return
+ end
+ end
+ table.insert(self.bottomFrames, frame)
+ JostleFrame:Schedule()
+ return true
+end
+
+function Jostle:Unregister(frame)
+ for k,f in ipairs(self.topFrames) do
+ if f == frame then
+ table.remove(self.topFrames, k)
+ JostleFrame:Schedule()
+ return true
+ end
+ end
+ for k,f in ipairs(self.bottomFrames) do
+ if f == frame then
+ table.remove(self.bottomFrames, k)
+ JostleFrame:Schedule()
+ return true
+ end
+ end
+end
+
+function Jostle:IsTopAdjusting()
+ return self.topAdjust
+end
+
+function Jostle:EnableTopAdjusting()
+ if not self.topAdjust then
+ self.topAdjust = not self.topAdjust
+ JostleFrame:Schedule()
+ end
+end
+
+function Jostle:DisableTopAdjusting()
+ if self.topAdjust then
+ self.topAdjust = not self.topAdjust
+ JostleFrame:Schedule()
+ end
+end
+
+function Jostle:IsBottomAdjusting()
+ return self.bottomAdjust
+end
+
+function Jostle:EnableBottomAdjusting()
+ if not self.bottomAdjust then
+ self.bottomAdjust = not self.bottomAdjust
+ JostleFrame:Schedule()
+ end
+end
+
+function Jostle:DisableBottomAdjusting()
+ if self.bottomAdjust then
+ self.bottomAdjust = not self.bottomAdjust
+ JostleFrame:Schedule()
+ end
+end
+
+local tmp = {}
+local queue = {}
+local inCombat = false
+function Jostle:ProcessQueue()
+ if not inCombat and HasFullControl() then
+ for k in pairs(queue) do
+ self:Refresh(k)
+ queue[k] = nil
+ end
+ end
+end
+function Jostle:PLAYER_CONTROL_GAINED()
+ self:ProcessQueue()
+end
+
+function Jostle:PLAYER_REGEN_ENABLED()
+ inCombat = false
+ self:ProcessQueue()
+end
+
+function Jostle:PLAYER_REGEN_DISABLED()
+ inCombat = true
+end
+
+local function isClose(alpha, bravo)
+ return math.abs(alpha - bravo) < 0.1
+end
+
+function Jostle:Refresh(...)
+ if not fullyInitted then
+ return
+ end
+
+ local screenHeight = GetScreenHeight()
+ local topOffset = self:IsTopAdjusting() and self:GetScreenTop() or screenHeight
+ local bottomOffset = self:IsBottomAdjusting() and self:GetScreenBottom() or 0
+ if topOffset ~= screenHeight or bottomOffset ~= 0 then
+ JostleFrame:Schedule(10)
+ end
+
+ local frames
+ if select('#', ...) >= 1 then
+ for k in pairs(tmp) do
+ tmp[k] = nil
+ end
+ for i = 1, select('#', ...) do
+ tmp[i] = select(i, ...)
+ end
+ frames = tmp
+ else
+ frames = blizzardFrames
+ end
+
+ if inCombat or not HasFullControl() and not UnitHasVehicleUI("player") then
+ for _,frame in ipairs(frames) do
+ if type(frame) == "string" then
+ frame = _G[frame]
+ end
+ if frame then
+ queue[frame] = true
+ end
+ end
+ return
+ end
+
+ local screenHeight = GetScreenHeight()
+ for _,frame in ipairs(frames) do
+ if type(frame) == "string" then
+ frame = _G[frame]
+ end
+
+ local framescale = frame and frame.GetScale and frame:GetScale() or 1
+
+ if frame and not blizzardFramesData[frame] and frame.GetTop and frame:GetCenter() and select(2, frame:GetCenter()) then
+ if select(2, frame:GetCenter()) <= screenHeight / 2 or frame == MultiBarRight then
+ blizzardFramesData[frame] = {y = frame:GetBottom(), top = false}
+ else
+ blizzardFramesData[frame] = {y = frame:GetTop() - screenHeight / framescale, top = true}
+ end
+ if frame == MinimapCluster then
+ blizzardFramesData[frame].lastX = GetScreenWidth() - MinimapCluster:GetWidth()
+ blizzardFramesData[frame].lastY = GetScreenHeight()
+ blizzardFramesData[frame].lastScale = 1
+ end
+ end
+ end
+
+ for _,frame in ipairs(frames) do
+ if type(frame) == "string" then
+ frame = _G[frame]
+ end
+
+ local framescale = frame and frame.GetScale and frame:GetScale() or 1
+
+ if ((frame and frame.IsUserPlaced and not frame:IsUserPlaced()) or ((frame == DEFAULT_CHAT_FRAME or frame == ChatFrame2) and SIMPLE_CHAT == "1") or frame == FramerateLabel) and (frame ~= ChatFrame2 or SIMPLE_CHAT == "1") then
+ local frameData = blizzardFramesData[frame]
+ if (select(2, frame:GetPoint(1)) ~= UIParent and select(2, frame:GetPoint(1)) ~= WorldFrame) then
+ -- do nothing
+ elseif frame == PlayerFrame and (CT_PlayerFrame_Drag or Gypsy_PlayerFrameCapsule) then
+ -- do nothing
+ elseif frame == TargetFrame and (CT_TargetFrame_Drag or Gypsy_TargetFrameCapsule) then
+ -- do nothing
+ elseif frame == PartyMemberFrame1 and (CT_MovableParty1_Drag or Gypsy_PartyFrameCapsule) then
+ -- do nothing
+ elseif frame == MainMenuBar and Gypsy_HotBarCapsule then
+ -- do nothing
+ elseif frame == MinimapCluster and select(3, frame:GetPoint(1)) ~= "TOPRIGHT" then
+ -- do nothing
+ elseif frame == DurabilityFrame and DurabilityFrame:IsShown() and (DurabilityFrame:GetLeft() > GetScreenWidth() or DurabilityFrame:GetRight() < 0 or DurabilityFrame:GetBottom() > GetScreenHeight() or DurabilityFrame:GetTop() < 0) then
+ DurabilityFrame:Hide()
+ elseif frame == FramerateLabel and ((frameData.lastX and not isClose(frameData.lastX, frame:GetLeft())) or not isClose(WorldFrame:GetHeight() * WorldFrame:GetScale(), UIParent:GetHeight() * UIParent:GetScale())) then
+ -- do nothing
+ elseif frame == PlayerFrame or frame == MainMenuBar or frame == TargetFrame or frame == ConsolidatedBuffs or frame == BuffFrame or frame == CastingBarFrame or frame == TutorialFrameParent or frame == FramerateLabel or frame == DurabilityFrame or frame == WatchFrame or not (frameData.lastScale and frame.GetScale and frameData.lastScale == frame:GetScale()) or not (frameData.lastX and frameData.lastY and (not isClose(frameData.lastX, frame:GetLeft()) or not isClose(frameData.lastY, frame:GetTop()))) then
+ local anchor
+ local anchorAlt
+ local width, height = GetScreenWidth(), GetScreenHeight()
+ local x
+
+ if frame:GetRight() and frame:GetLeft() then
+ local anchorFrame = UIParent
+ if frame == GroupLootFrame1 or frame == FramerateLabel then
+ x = 0
+ anchor = ""
+ elseif frame:GetRight() / framescale <= width / 2 then
+ x = frame:GetLeft() / framescale
+ anchor = "LEFT"
+ else
+ x = frame:GetRight() - width / framescale
+ anchor = "RIGHT"
+ end
+ local y = blizzardFramesData[frame].y
+ local offset = 0
+ if blizzardFramesData[frame].top then
+ anchor = "TOP" .. anchor
+ offset = ( topOffset - height ) / framescale
+ else
+ anchor = "BOTTOM" .. anchor
+ offset = bottomOffset / framescale
+ end
+ -- if frame == MinimapCluster and not MinimapBorderTop:IsShown() then
+ -- offset = offset + MinimapBorderTop:GetHeight() * 3/5
+ if frame == ConsolidatedBuffs and TicketStatusFrame:IsShown() then
+ offset = offset - TicketStatusFrame:GetHeight() * TicketStatusFrame:GetScale()
+ -- elseif frame == DEFAULT_CHAT_FRAME then
+ -- y = MainMenuBar:GetHeight() * MainMenuBar:GetScale() + 32
+ -- if StanceBarFrame and (PetActionBarFrame:IsShown() or StanceBarFrame:IsShown()) then
+ -- offset = offset + StanceBarFrame:GetHeight() * StanceBarFrame:GetScale()
+ -- end
+ -- if MultiBarBottomLeft:IsShown() then
+ -- offset = offset + MultiBarBottomLeft:GetHeight() * MultiBarBottomLeft:GetScale() - 21
+ -- end
+ -- elseif frame == ChatFrame2 then
+ -- y = MainMenuBar:GetHeight() * MainMenuBar:GetScale() + 32
+ -- if MultiBarBottomRight:IsShown() then
+ -- offset = offset + MultiBarBottomRight:GetHeight() * MultiBarBottomRight:GetScale() - 21
+ -- end
+ elseif frame == GroupLootFrame1 or frame == TutorialFrameParent or frame == FramerateLabel then
+ if MultiBarBottomLeft:IsShown() or MultiBarBottomRight:IsShown() then
+ offset = offset + MultiBarBottomLeft:GetHeight() * MultiBarBottomLeft:GetScale()
+ end
+ elseif frame == DurabilityFrame or frame == WatchFrame then
+ anchorFrame = MinimapCluster
+ x = 0
+ y = 0
+ offset = 0
+ if frame == WatchFrame and DurabilityFrame:IsShown() then
+ y = y - DurabilityFrame:GetHeight() * DurabilityFrame:GetScale()
+ end
+ if frame == DurabilityFrame then
+ x = -20
+ end
+ anchor = "TOPRIGHT"
+ anchorAlt = "BOTTOMRIGHT"
+ if MultiBarRight:IsShown() then
+ x = x - MultiBarRight:GetWidth() * MultiBarRight:GetScale()
+ if MultiBarLeft:IsShown() then
+ x = x - MultiBarLeft:GetWidth() * MultiBarLeft:GetScale()
+ end
+ end
+ elseif frame == OrderHallCommandBar and OrderHallCommandBar:IsShown() then
+ anchorAlt = "TOPLEFT"
+ anchor = "TOPLEFT"
+ end
+ if frame == FramerateLabel then
+ anchorFrame = WorldFrame
+ end
+ frame:ClearAllPoints()
+ frame:SetPoint(anchor, anchorFrame, anchorAlt or anchor, x, y + offset)
+ --Calling ClearAllPoints() on MainMenuBar causes StatusTrackingBarManager to hide in 8.2.5+
+ --This fixes it, but also throw action blocked errors any time you enter combat, even if you never perform frame updates in combat here
+ --MainMenuBar execution path becomes tainted calling StatusTrackingBarManager:UpdateBarsShown()
+ --Sadly, no other fix i found could work. If you call ClearAllPoints() on MainMenuBar you break StatusTrackingBarManager
+ --if frame == MainMenuBar then
+ -- StatusTrackingBarManager:UpdateBarsShown()
+ --end
+ blizzardFramesData[frame].lastX = frame:GetLeft()
+ blizzardFramesData[frame].lastY = frame:GetTop()
+ blizzardFramesData[frame].lastScale = framescale
+
+ if frame == OrderHallCommandBar then
+ frame:SetPoint("RIGHT", "UIParent" ,"RIGHT",0, 0);
+ end
+ end
+ end
+ end
+ end
+end
+
+local function compat()
+ local Jostle20 = {}
+ function Jostle20:RegisterTop(...)
+ Jostle:RegisterTop(...)
+ end
+ function Jostle20:RegisterBottom(...)
+ Jostle:RegisterBottom(...)
+ end
+ function Jostle20:GetScreenTop(...)
+ Jostle:GetScreenTop(...)
+ end
+ function Jostle20:GetScreenBottom(...)
+ Jostle:GetScreenBottom(...)
+ end
+ function Jostle20:Unregister(...)
+ Jostle:Unregister(...)
+ end
+ function Jostle20:IsTopAdjusting(...)
+ Jostle:IsTopAdjusting(...)
+ end
+ function Jostle20:EnableTopAdjusting(...)
+ Jostle:EnableTopAdjusting(...)
+ end
+ function Jostle20:DisableTopAdjusting(...)
+ Jostle:DisableTopAdjusting(...)
+ end
+ function Jostle20:IsBottomAdjusting(...)
+ Jostle:IsBottomAdjusting(...)
+ end
+ function Jostle20:EnableBottomAdjusting(...)
+ Jostle:EnableBottomAdjusting(...)
+ end
+ function Jostle20:DisableBottomAdjusting(...)
+ Jostle:DisableBottomAdjusting(...)
+ end
+ function Jostle20:Refresh(...)
+ Jostle:Refresh(...)
+ end
+ local function activate(self, oldLib)
+ Jostle20 = self
+ if oldLib and oldLib.topFrames and oldLib.bottomFrames then
+ for i,v in ipairs(oldLib.topFrames) do
+ Jostle:RegisterTop(v)
+ end
+ for i,v in ipairs(oldLib.bottomFrames) do
+ Jostle:RegisterBottom(v)
+ end
+ end
+ end
+ local function external(self, instance, major)
+ if major == "AceEvent-2.0" then
+ instance:embed(self)
+
+ self:UnregisterAllEvents()
+ self:CancelAllScheduledEvents()
+ end
+ end
+ AceLibrary:Register(Jostle20, "Jostle-2.0", MINOR_VERSION*1000, activate, external)
+ Jostle20 = AceLibrary("Jostle-2.0")
+end
+if AceLibrary then
+ compat()
+elseif Rock then
+ function Jostle:OnLibraryLoad(major, version)
+ if major == "AceLibrary" then
+ compat()
+ end
+ end
+end
diff --git a/FuBar/libs/LibJostle-3.0/LibJostle-3.0.toc b/FuBar/libs/LibJostle-3.0/LibJostle-3.0.toc
new file mode 100644
index 0000000..6251b98
--- /dev/null
+++ b/FuBar/libs/LibJostle-3.0/LibJostle-3.0.toc
@@ -0,0 +1,11 @@
+## Interface: 100002
+## LoadOnDemand: 1
+## Title: Lib: Jostle-3.0
+## Notes: A library to handle rearrangement of blizzard's frames when bars are added to the sides of the screen.
+## Author: ckknight
+## X-eMail: ckknight@gmail.com
+## X-License: LGPL v2.1
+## X-Category: Library
+## X-AceLibrary-Jostle-2.0: true
+
+lib.xml
diff --git a/FuBar/libs/LibJostle-3.0/LibStub/LibStub.lua b/FuBar/libs/LibJostle-3.0/LibStub/LibStub.lua
new file mode 100644
index 0000000..7e7b76d
--- /dev/null
+++ b/FuBar/libs/LibJostle-3.0/LibStub/LibStub.lua
@@ -0,0 +1,51 @@
+-- $Id: LibStub.lua 103 2014-10-16 03:02:50Z mikk $
+-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/addons/libstub/ for more info
+-- LibStub is hereby placed in the Public Domain
+-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
+local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
+local LibStub = _G[LIBSTUB_MAJOR]
+
+-- Check to see is this version of the stub is obsolete
+if not LibStub or LibStub.minor < LIBSTUB_MINOR then
+ LibStub = LibStub or {libs = {}, minors = {} }
+ _G[LIBSTUB_MAJOR] = LibStub
+ LibStub.minor = LIBSTUB_MINOR
+
+ -- LibStub:NewLibrary(major, minor)
+ -- major (string) - the major version of the library
+ -- minor (string or number ) - the minor version of the library
+ --
+ -- returns nil if a newer or same version of the lib is already present
+ -- returns empty library object or old library object if upgrade is needed
+ function LibStub:NewLibrary(major, minor)
+ assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
+ minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
+
+ local oldminor = self.minors[major]
+ if oldminor and oldminor >= minor then return nil end
+ self.minors[major], self.libs[major] = minor, self.libs[major] or {}
+ return self.libs[major], oldminor
+ end
+
+ -- LibStub:GetLibrary(major, [silent])
+ -- major (string) - the major version of the library
+ -- silent (boolean) - if true, library is optional, silently return nil if its not found
+ --
+ -- throws an error if the library can not be found (except silent is set)
+ -- returns the library object if found
+ function LibStub:GetLibrary(major, silent)
+ if not self.libs[major] and not silent then
+ error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
+ end
+ return self.libs[major], self.minors[major]
+ end
+
+ -- LibStub:IterateLibraries()
+ --
+ -- Returns an iterator for the currently registered libraries
+ function LibStub:IterateLibraries()
+ return pairs(self.libs)
+ end
+
+ setmetatable(LibStub, { __call = LibStub.GetLibrary })
+end
diff --git a/FuBar/libs/LibJostle-3.0/LibStub/LibStub.toc b/FuBar/libs/LibJostle-3.0/LibStub/LibStub.toc
new file mode 100644
index 0000000..4dcb91d
--- /dev/null
+++ b/FuBar/libs/LibJostle-3.0/LibStub/LibStub.toc
@@ -0,0 +1,9 @@
+## Interface: 100002
+## Title: Lib: LibStub
+## Notes: Universal Library Stub
+## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
+## X-Website: http://www.wowace.com/addons/libstub/
+## X-Category: Library
+## X-License: Public Domain
+
+LibStub.lua
diff --git a/FuBar/libs/LibJostle-3.0/LibStub/tests/test.lua b/FuBar/libs/LibJostle-3.0/LibStub/tests/test.lua
new file mode 100644
index 0000000..645a08b
--- /dev/null
+++ b/FuBar/libs/LibJostle-3.0/LibStub/tests/test.lua
@@ -0,0 +1,41 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
+assert(lib) -- should return the library table
+assert(not oldMinor) -- should not return the old minor, since it didn't exist
+
+-- the following is to create data and then be able to check if the same data exists after the fact
+function lib:MyMethod()
+end
+local MyMethod = lib.MyMethod
+lib.MyTable = {}
+local MyTable = lib.MyTable
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
+assert(not newLib) -- should not return since out of date
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
+assert(not newLib) -- should not return since out of date
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
+assert(newLib) -- library table
+assert(rawequal(newLib, lib)) -- should be the same reference as the previous
+assert(newOldMinor == 1) -- should return the minor version of the previous version
+
+assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
+assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
+assert(newLib) -- library table
+assert(newOldMinor == 2) -- previous version was 2
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number)
+assert(newLib)
+assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)
+
+local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
+assert(newLib)
+assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)
\ No newline at end of file
diff --git a/FuBar/libs/LibJostle-3.0/LibStub/tests/test2.lua b/FuBar/libs/LibJostle-3.0/LibStub/tests/test2.lua
new file mode 100644
index 0000000..af431dd
--- /dev/null
+++ b/FuBar/libs/LibJostle-3.0/LibStub/tests/test2.lua
@@ -0,0 +1,27 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+for major, library in LibStub:IterateLibraries() do
+ -- check that MyLib doesn't exist yet, by iterating through all the libraries
+ assert(major ~= "MyLib")
+end
+
+assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
+assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
+local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
+assert(lib) -- check it exists
+assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
+
+assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
+
+local count=0
+for major, library in LibStub:IterateLibraries() do
+ -- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
+ if major == "MyLib" then -- we found it!
+ count = count +1
+ assert(rawequal(library, lib)) -- verify that the references are equal
+ end
+end
+assert(count == 1) -- verify that we actually found it, and only once
diff --git a/FuBar/libs/LibJostle-3.0/LibStub/tests/test3.lua b/FuBar/libs/LibJostle-3.0/LibStub/tests/test3.lua
new file mode 100644
index 0000000..01aabb8
--- /dev/null
+++ b/FuBar/libs/LibJostle-3.0/LibStub/tests/test3.lua
@@ -0,0 +1,14 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+local proxy = newproxy() -- non-string
+
+assert(not pcall(LibStub.NewLibrary, LibStub, proxy, 1)) -- should error, proxy is not a string, it's userdata
+local success, ret = pcall(LibStub.GetLibrary, proxy, true)
+assert(not success or not ret) -- either error because proxy is not a string or because it's not actually registered.
+
+assert(not pcall(LibStub.NewLibrary, LibStub, "Something", "No number in here")) -- should error, minor has no string in it.
+
+assert(not LibStub:GetLibrary("Something", true)) -- shouldn't've created it from the above statement
\ No newline at end of file
diff --git a/FuBar/libs/LibJostle-3.0/LibStub/tests/test4.lua b/FuBar/libs/LibJostle-3.0/LibStub/tests/test4.lua
new file mode 100644
index 0000000..15a9c9c
--- /dev/null
+++ b/FuBar/libs/LibJostle-3.0/LibStub/tests/test4.lua
@@ -0,0 +1,41 @@
+debugstack = debug.traceback
+strmatch = string.match
+
+loadfile("../LibStub.lua")()
+
+
+-- Pretend like loaded libstub is old and doesn't have :IterateLibraries
+assert(LibStub.minor)
+LibStub.minor = LibStub.minor - 0.0001
+LibStub.IterateLibraries = nil
+
+loadfile("../LibStub.lua")()
+
+assert(type(LibStub.IterateLibraries)=="function")
+
+
+-- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created
+LibStub.IterateLibraries = 123
+
+loadfile("../LibStub.lua")()
+
+assert(LibStub.IterateLibraries == 123)
+
+
+-- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created
+LibStub.minor = LibStub.minor + 0.0001
+
+loadfile("../LibStub.lua")()
+
+assert(LibStub.IterateLibraries == 123)
+
+
+-- Again with a huge number
+LibStub.minor = LibStub.minor + 1234567890
+
+loadfile("../LibStub.lua")()
+
+assert(LibStub.IterateLibraries == 123)
+
+
+print("OK")
\ No newline at end of file
diff --git a/FuBar/libs/LibJostle-3.0/lib.xml b/FuBar/libs/LibJostle-3.0/lib.xml
new file mode 100644
index 0000000..9fdef56
--- /dev/null
+++ b/FuBar/libs/LibJostle-3.0/lib.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
diff --git a/FuBar/libs/LibRock-1.0/LibRock-1.0.lua b/FuBar/libs/LibRock-1.0/LibRock-1.0.lua
new file mode 100644
index 0000000..d46d185
--- /dev/null
+++ b/FuBar/libs/LibRock-1.0/LibRock-1.0.lua
@@ -0,0 +1,2946 @@
+--[[
+Name: LibRock-1.0
+Revision: $Rev: 298 $
+Developed by: ckknight (ckknight@gmail.com)
+Website: http://www.wowace.com/
+Description: Library to allow for library and addon creation and easy table recycling functions.
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "LibRock-1.0"
+local MINOR_VERSION = tonumber(("$Revision: 298 $"):match("(%d+)")) + 90000
+
+local _G = _G
+local GetLocale = _G.GetLocale
+local CATEGORIES
+if GetLocale() == "deDE" then
+ CATEGORIES = {
+ ["Action Bars"] = "Aktionsleisten",
+ ["Auction"] = "Auktion",
+ ["Audio"] = "Audio",
+ ["Battlegrounds/PvP"] = "Schlachtfeld/PvP",
+ ["Buffs"] = "Stärkungszauber",
+ ["Chat/Communication"] = "Chat/Kommunikation",
+ ["Druid"] = "Druide",
+ ["Hunter"] = "Jäger",
+ ["Mage"] = "Magier",
+ ["Paladin"] = "Paladin",
+ ["Priest"] = "Priester",
+ ["Rogue"] = "Schurke",
+ ["Shaman"] = "Schamane",
+ ["Warlock"] = "Hexenmeister",
+ ["Warrior"] = "Krieger",
+ ["Healer"] = "Heiler",
+ ["Tank"] = "Tank",
+ ["Caster"] = "Zauberer",
+ ["Combat"] = "Kampf",
+ ["Compilations"] = "Zusammenstellungen",
+ ["Data Export"] = "Datenexport",
+ ["Development Tools"] = "Entwicklungstools",
+ ["Guild"] = "Gilde",
+ ["Frame Modification"] = "Frameveränderungen",
+ ["Interface Enhancements"] = "Interfaceverbesserungen",
+ ["Inventory"] = "Inventar",
+ ["Library"] = "Bibliotheken",
+ ["Map"] = "Karte",
+ ["Mail"] = "Post",
+ ["Miscellaneous"] = "Diverses",
+ ["Quest"] = "Quest",
+ ["Raid"] = "Schlachtzug",
+ ["Tradeskill"] = "Beruf",
+ ["UnitFrame"] = "Einheiten-Fenster",
+ }
+elseif GetLocale() == "frFR" then
+ CATEGORIES = {
+ ["Action Bars"] = "Barres d'action",
+ ["Auction"] = "Hôtel des ventes",
+ ["Audio"] = "Audio",
+ ["Battlegrounds/PvP"] = "Champs de bataille/JcJ",
+ ["Buffs"] = "Buffs",
+ ["Chat/Communication"] = "Chat/Communication",
+ ["Druid"] = "Druide",
+ ["Hunter"] = "Chasseur",
+ ["Mage"] = "Mage",
+ ["Paladin"] = "Paladin",
+ ["Priest"] = "Prêtre",
+ ["Rogue"] = "Voleur",
+ ["Shaman"] = "Chaman",
+ ["Warlock"] = "Démoniste",
+ ["Warrior"] = "Guerrier",
+ ["Healer"] = "Soigneur",
+ ["Tank"] = "Tank",
+ ["Caster"] = "Casteur",
+ ["Combat"] = "Combat",
+ ["Compilations"] = "Compilations",
+ ["Data Export"] = "Exportation de données",
+ ["Development Tools"] = "Outils de développement",
+ ["Guild"] = "Guilde",
+ ["Frame Modification"] = "Modification des fenêtres",
+ ["Interface Enhancements"] = "Améliorations de l'interface",
+ ["Inventory"] = "Inventaire",
+ ["Library"] = "Bibliothèques",
+ ["Map"] = "Carte",
+ ["Mail"] = "Courrier",
+ ["Miscellaneous"] = "Divers",
+ ["Quest"] = "Quêtes",
+ ["Raid"] = "Raid",
+ ["Tradeskill"] = "Métiers",
+ ["UnitFrame"] = "Fenêtres d'unité",
+ }
+elseif GetLocale() == "koKR" then
+ CATEGORIES = {
+ ["Action Bars"] = "액션바",
+ ["Auction"] = "경매",
+ ["Audio"] = "음향",
+ ["Battlegrounds/PvP"] = "전장/PvP",
+ ["Buffs"] = "버프",
+ ["Chat/Communication"] = "대화/의사소통",
+ ["Druid"] = "드루이드",
+ ["Hunter"] = "사냥꾼",
+ ["Mage"] = "마법사",
+ ["Paladin"] = "성기사",
+ ["Priest"] = "사제",
+ ["Rogue"] = "도적",
+ ["Shaman"] = "주술사",
+ ["Warlock"] = "흑마법사",
+ ["Warrior"] = "전사",
+ ["Healer"] = "힐러",
+ ["Tank"] = "탱커",
+ ["Caster"] = "캐스터",
+ ["Combat"] = "전투",
+ ["Compilations"] = "복합",
+ ["Data Export"] = "자료 출력",
+ ["Development Tools"] = "개발 도구",
+ ["Guild"] = "길드",
+ ["Frame Modification"] = "구조 변경",
+ ["Interface Enhancements"] = "인터페이스 강화",
+ ["Inventory"] = "인벤토리",
+ ["Library"] = "라이브러리",
+ ["Map"] = "지도",
+ ["Mail"] = "우편",
+ ["Miscellaneous"] = "기타",
+ ["Quest"] = "퀘스트",
+ ["Raid"] = "공격대",
+ ["Tradeskill"] = "전문기술",
+ ["UnitFrame"] = "유닛 프레임",
+ }
+elseif GetLocale() == "zhTW" then
+ CATEGORIES = {
+ ["Action Bars"] = "動作列",
+ ["Auction"] = "拍賣",
+ ["Audio"] = "音效",
+ ["Battlegrounds/PvP"] = "戰場/PvP",
+ ["Buffs"] = "增益",
+ ["Chat/Communication"] = "聊天/通訊",
+ ["Druid"] = "德魯伊",
+ ["Hunter"] = "獵人",
+ ["Mage"] = "法師",
+ ["Paladin"] = "聖騎士",
+ ["Priest"] = "牧師",
+ ["Rogue"] = "盜賊",
+ ["Shaman"] = "薩滿",
+ ["Warlock"] = "術士",
+ ["Warrior"] = "戰士",
+ ["Healer"] = "治療者",
+ ["Tank"] = "坦克",
+ ["Caster"] = "施法者",
+ ["Combat"] = "戰鬥",
+ ["Compilations"] = "整合",
+ ["Data Export"] = "資料匯出",
+ ["Development Tools"] = "開發工具",
+ ["Guild"] = "公會",
+ ["Frame Modification"] = "框架修改",
+ ["Interface Enhancements"] = "介面增強",
+ ["Inventory"] = "庫存",
+ ["Library"] = "程式庫",
+ ["Map"] = "地圖",
+ ["Mail"] = "郵件",
+ ["Miscellaneous"] = "雜項",
+ ["Quest"] = "任務",
+ ["Raid"] = "團隊",
+ ["Tradeskill"] = "交易技能",
+ ["UnitFrame"] = "頭像框架",
+ }
+elseif GetLocale() == "zhCN" then
+ CATEGORIES = {
+ ["Action Bars"] = "动作条",
+ ["Auction"] = "拍卖",
+ ["Audio"] = "音频",
+ ["Battlegrounds/PvP"] = "战场/PvP",
+ ["Buffs"] = "增益魔法",
+ ["Chat/Communication"] = "聊天/交流",
+ ["Druid"] = "德鲁伊",
+ ["Hunter"] = "猎人",
+ ["Mage"] = "法师",
+ ["Paladin"] = "圣骑士",
+ ["Priest"] = "牧师",
+ ["Rogue"] = "潜行者",
+ ["Shaman"] = "萨满祭司",
+ ["Warlock"] = "术士",
+ ["Warrior"] = "战士",
+ ["Healer"] = "治疗",
+ ["Tank"] = "坦克",
+ ["Caster"] = "远程输出",
+ ["Combat"] = "战斗",
+ ["Compilations"] = "编译",
+ ["Data Export"] = "数据导出",
+ ["Development Tools"] = "开发工具",
+ ["Guild"] = "公会",
+ ["Frame Modification"] = "框架修改",
+ ["Interface Enhancements"] = "界面增强",
+ ["Inventory"] = "背包",
+ ["Library"] = "库",
+ ["Map"] = "地图",
+ ["Mail"] = "邮件",
+ ["Miscellaneous"] = "杂项",
+ ["Quest"] = "任务",
+ ["Raid"] = "团队",
+ ["Tradeskill"] = "商业技能",
+ ["UnitFrame"] = "头像框架",
+ }
+elseif GetLocale() == "esES" then
+ CATEGORIES = {
+ ["Action Bars"] = "Barras de Acción",
+ ["Auction"] = "Subasta",
+ ["Audio"] = "Audio",
+ ["Battlegrounds/PvP"] = "Campos de Batalla/JcJ",
+ ["Buffs"] = "Buffs",
+ ["Chat/Communication"] = "Chat/Comunicación",
+ ["Druid"] = "Druida",
+ ["Hunter"] = "Cazador",
+ ["Mage"] = "Mago",
+ ["Paladin"] = "Paladín",
+ ["Priest"] = "Sacerdote",
+ ["Rogue"] = "Pícaro",
+ ["Shaman"] = "Chamán",
+ ["Warlock"] = "Brujo",
+ ["Warrior"] = "Guerrero",
+ ["Healer"] = "Sanador",
+ ["Tank"] = "Tanque",
+ ["Caster"] = "Conjurador",
+ ["Combat"] = "Combate",
+ ["Compilations"] = "Compilaciones",
+ ["Data Export"] = "Exportar Datos",
+ ["Development Tools"] = "Herramientas de Desarrollo",
+ ["Guild"] = "Hermandad",
+ ["Frame Modification"] = "Modificación de Marcos",
+ ["Interface Enhancements"] = "Mejoras de la Interfaz",
+ ["Inventory"] = "Inventario",
+ ["Library"] = "Biblioteca",
+ ["Map"] = "Mapa",
+ ["Mail"] = "Correo",
+ ["Miscellaneous"] = "Misceláneo",
+ ["Quest"] = "Misión",
+ ["Raid"] = "Banda",
+ ["Tradeskill"] = "Habilidad de Comercio",
+ ["UnitFrame"] = "Marco de Unidades",
+ }
+else -- enUS
+ CATEGORIES = {
+ ["Action Bars"] = "Action Bars",
+ ["Auction"] = "Auction",
+ ["Audio"] = "Audio",
+ ["Battlegrounds/PvP"] = "Battlegrounds/PvP",
+ ["Buffs"] = "Buffs",
+ ["Chat/Communication"] = "Chat/Communication",
+ ["Druid"] = "Druid",
+ ["Hunter"] = "Hunter",
+ ["Mage"] = "Mage",
+ ["Paladin"] = "Paladin",
+ ["Priest"] = "Priest",
+ ["Rogue"] = "Rogue",
+ ["Shaman"] = "Shaman",
+ ["Warlock"] = "Warlock",
+ ["Warrior"] = "Warrior",
+ ["Healer"] = "Healer",
+ ["Tank"] = "Tank",
+ ["Caster"] = "Caster",
+ ["Combat"] = "Combat",
+ ["Compilations"] = "Compilations",
+ ["Data Export"] = "Data Export",
+ ["Development Tools"] = "Development Tools",
+ ["Guild"] = "Guild",
+ ["Frame Modification"] = "Frame Modification",
+ ["Interface Enhancements"] = "Interface Enhancements",
+ ["Inventory"] = "Inventory",
+ ["Library"] = "Library",
+ ["Map"] = "Map",
+ ["Mail"] = "Mail",
+ ["Miscellaneous"] = "Miscellaneous",
+ ["Quest"] = "Quest",
+ ["Raid"] = "Raid",
+ ["Tradeskill"] = "Tradeskill",
+ ["UnitFrame"] = "UnitFrame",
+ }
+end
+
+local select = _G.select
+local tostring = _G.tostring
+local pairs = _G.pairs
+local ipairs = _G.ipairs
+local error = _G.error
+local setmetatable = _G.setmetatable
+local getmetatable = _G.getmetatable
+local type = _G.type
+local pcall = _G.pcall
+local next = _G.next
+local tonumber = _G.tonumber
+local strmatch = _G.strmatch
+local table_remove = _G.table.remove
+local debugstack = _G.debugstack
+local LoadAddOn = _G.LoadAddOn
+local GetAddOnInfo = _G.GetAddOnInfo
+local GetAddOnMetadata = _G.GetAddOnMetadata
+local GetNumAddOns = _G.GetNumAddOns
+local DisableAddOn = _G.DisableAddOn
+local EnableAddOn = _G.EnableAddOn
+local IsAddOnLoadOnDemand = _G.IsAddOnLoadOnDemand
+local IsLoggedIn = _G.IsLoggedIn
+local geterrorhandler = _G.geterrorhandler
+local assert = _G.assert
+local table_sort = _G.table.sort
+local table_concat = _G.table.concat
+
+-- #AUTODOC_NAMESPACE Rock
+
+
+local LibStub = _G.LibStub
+
+local Rock = LibStub:GetLibrary(MAJOR_VERSION, true) or _G.Rock
+local oldRock
+if not Rock then
+ Rock = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
+ if not Rock then
+ return
+ end
+ Rock.name = MAJOR_VERSION
+else
+ Rock, oldRock = Rock:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
+ if not Rock then
+ return
+ end
+end
+_G.Rock = Rock
+
+local L = setmetatable({}, {__index=function(self,key) self[key] = key; return key end})
+if GetLocale() == "zhCN" then
+ L["Advanced options"] = "高级选项"
+ L["Advanced options for developers and power users."] = "开发者与高级用户的高级选项"
+ L["Unit tests"] = "框体测试"
+ L["Enable unit tests to be run. This is for developers only.\n\nYou must ReloadUI for changes to take effect."] = "开启框体测试,仅供开发者使用。\n\n需要重载用户界面。"
+ L["Contracts"] = "侦错协定"
+ L["Enable contracts to be run. This is for developers and anyone wanting to file a bug. Do not file a bug unless contracts are enabled. This will slightly slow down your addons if enabled."] = "启用侦错协定,这是给插件作者用来通报错误所使用。"
+ L["Reload UI"] = "重载UI"
+ L["Reload the User Interface for some changes to take effect."] = "部分功能更改需要重载用户界面才会生效。"
+ L["Reload"] = "重载"
+ L["Give donation"] = "捐赠"
+ L["Donate"] = "捐赠"
+ L["Give a much-needed donation to the author of this addon."] = "给插件作者捐赠支持插件开发。"
+ L["File issue"] = "通报错误"
+ L["Report"] = "报告"
+ L["File a bug or request a new feature or an improvement to this addon."] = "发送错误报告或请求新功能及要改进的部分。"
+ L["Press Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar."] = "Ctrl-C复制网址,Alt-Tab切换到桌面,打开浏览器,在地址栏贴上网址。"
+ L["Press Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar."] = "Cmd-C复制网址,Cmd-Tab切换到电脑桌面,打开浏览器,在地址栏贴上网址。"
+ L["Enabled"] = "开启"
+ L["Enable or disable this addon."] = "启用这个插件。"
+
+elseif GetLocale() == "zhTW" then
+ L["Advanced options"] = "進階選項"
+ L["Advanced options for developers and power users."] = "插件作者、進階用戶選項"
+ L["Unit tests"] = "單元測試"
+ L["Enable unit tests to be run. This is for developers only.\n\nYou must ReloadUI for changes to take effect."] = "啟用單元測試,這是給插件作者使用的功能。\n\n需要重載介面才能使用。"
+ L["Contracts"] = "偵錯協定"
+ L["Enable contracts to be run. This is for developers and anyone wanting to file a bug. Do not file a bug unless contracts are enabled. This will slightly slow down your addons if enabled."] = "啟用偵錯協定,這是給插件作者用來通報錯誤所使用。"
+ L["Reload UI"] = "重載介面"
+ L["Reload the User Interface for some changes to take effect."] = "重新載入使用者介面,部分功能才會生效。"
+ L["Reload"] = "重載"
+ L["Give donation"] = "捐贈"
+ L["Donate"] = "捐贈"
+ L["Give a much-needed donation to the author of this addon."] = "捐贈金錢給插件作者。"
+ L["File issue"] = "通報錯誤"
+ L["Report"] = "報告"
+ L["File a bug or request a new feature or an improvement to this addon."] = "發出錯誤報告或請求新功能及要改進的部分。"
+ L["Press Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar."] = "Ctrl-C複製網址,Alt-Tab切換到電腦桌面,打開瀏覽器,在網址列貼上網址。"
+ L["Press Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar."] = "Cmd-C複製網址,Cmd-Tab切換到電腦桌面,打開瀏覽器,在網址列貼上網址。"
+ L["Enabled"] = "啟用"
+ L["Enable or disable this addon."] = "啟用這個插件。"
+elseif GetLocale() == "koKR" then
+ L["Advanced options"] = "상세 옵션"
+ L["Advanced options for developers and power users."] = "개발자와 파워 사용자를 위한 상세 옵션입니다."
+ L["Unit tests"] = "유닛 테스트"
+ L["Enable unit tests to be run. This is for developers only.\n\nYou must ReloadUI for changes to take effect."] = "유닛 테스트를 사용합니다. 이것은 개발자만을 위한 옵션입니다.\n\n변경된 결과를 적용하기 위해 당신의 UI를 재실행 합니다."
+ L["Contracts"] = "계약"
+ L["Enable contracts to be run. This is for developers and anyone wanting to file a bug. Do not file a bug unless contracts are enabled. This will slightly slow down your addons if enabled."] = "계약을 사용합니다. 이것은 개발자와 버그 파일을 알릴 분이면 누구나 사용 가능합니다. 계약이 가능하지 않으면 버그 파일을 보내지 마십시오. 이것은 당신의 애드온 속도를 약간 떨어뜨립니다."
+ L["Reload UI"] = "UI 재실행"
+ L["Reload the User Interface for some changes to take effect."] = "변경된 결과를 적용하기 위해 사용자 인터페이스를 재실행합니다."
+ L["Reload"] = "재실행"
+ L["Give donation"] = "기부"
+ L["Donate"] = "기부"
+ L["Give a much-needed donation to the author of this addon."] = "이 애드온의 제작자에게 필요한 기부를 합니다."
+ L["File issue"] = "파일 이슈"
+ L["Report"] = "보고"
+ L["File a bug or request a new feature or an improvement to this addon."] = "버그 파일을 알리거나 새로운 기능 또는 이 애드온에 대한 개선을 부탁합니다."
+ L["Press Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar."] = "Ctrl-C로 복사합니다. Alt-Tab 눌려 게임으로 부터 나간후 웹 브라우저를 엽니다. 복사된 링크를 주소 창에 붙여넣기 합니다."
+ L["Press Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar."] = "Cmd-C로 복사합니다. Cmd-Tab 눌려 게임으로 부터 나간후 웹 브라우저를 엽니다. 복사된 링크를 주소 창에 붙여넣기 합니다."
+ L["Enabled"] = "사용"
+ L["Enable or disable this addon."] = "이 애드온을 사용하거나 사용하지 않습니다."
+elseif GetLocale() == "frFR" then
+ L["Advanced options"] = "Options avancées"
+ L["Advanced options for developers and power users."] = "Options avancées à l'attention des développeurs et des utilisateurs expérimentés."
+ L["Reload UI"] = "Recharger IU"
+ L["Reload the User Interface for some changes to take effect."] = "Recharge l'interface utilisateur afin que certains changements prennent effet."
+ L["Reload"] = "Recharger"
+ L["Give donation"] = "Faire un don"
+ L["Donate"] = "Don"
+ L["Give a much-needed donation to the author of this addon."] = "Permet de faire un don bien mérité à l'auteur de cet addon."
+ L["File issue"] = "Problème"
+ L["Report"] = "Signaler"
+ L["File a bug or request a new feature or an improvement to this addon."] = "Permet de signaler un bogue ou de demander une amélioration à cet addon."
+ L["Press Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar."] = "Ctrl-C pour copier, puis Alt-Tab pour sortir du jeu. Ouvrez votre navigateur internet et collez le lien dans la barre d'adresse."
+ L["Press Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar."] = "Cmd-C pour copier, puis Alt-Tab pour sortir du jeu. Ouvrez votre navigateur internet et collez le lien dans la barre d'adresse."
+ L["Enabled"] = "Activé"
+ L["Enable or disable this addon."] = "Active ou désactive cet addon."
+end
+
+local isStandalone = debugstack():match("[Oo%.][Nn%.][Ss%.]\\([^\\]+)\\") == MAJOR_VERSION or nil
+local unitTestDB, enableContracts
+
+local weakKey = { __mode = 'k' }
+
+-- frame to manage events from
+Rock.frame = oldRock and oldRock.frame or _G.CreateFrame("Frame")
+local frame = Rock.frame
+-- dict of libraries in { ["major"] = object } form
+Rock.libraries = oldRock and oldRock.libraries or { [MAJOR_VERSION] = Rock }
+local libraries = Rock.libraries
+-- set of libraries which have gone through the finalization process in { [object] = true } form
+Rock.finalizedLibraries = setmetatable(oldRock and oldRock.finalizedLibraries or { }, weakKey)
+local finalizedLibraries = Rock.finalizedLibraries
+-- set of libraries which have been tried to be loaded.
+Rock.scannedLibraries = oldRock and oldRock.scannedLibraries or {}
+local scannedLibraries = Rock.scannedLibraries
+-- exportedMethods[library] = { "method1", "method2" }
+Rock.exportedMethods = setmetatable(oldRock and oldRock.exportedMethods or {}, weakKey)
+local exportedMethods = Rock.exportedMethods
+-- mixinToObject[mixin][object] = true
+Rock.mixinToObject = setmetatable(oldRock and oldRock.mixinToObject or {}, weakKey)
+local mixinToObject = Rock.mixinToObject
+-- dict of addons in { ["name"] = object } form
+Rock.addons = oldRock and oldRock.addons or {}
+local addons = Rock.addons
+-- set of libraries that should be finalized before ADDON_LOADED.
+Rock.pendingLibraries = setmetatable(oldRock and oldRock.pendingLibraries or { }, weakKey)
+local pendingLibraries = Rock.pendingLibraries
+-- list of addons in order of created that need to be initialized by ADDON_LOADED.
+Rock.pendingAddons = oldRock and oldRock.pendingAddons or {}
+local pendingAddons = Rock.pendingAddons
+-- dictionary of addons to their folder names
+Rock.addonToFolder = oldRock and oldRock.addonToFolder or {}
+local addonToFolder = Rock.addonToFolder
+-- set of folders which have been loaded
+Rock.foldersLoaded = oldRock and oldRock.foldersLoaded or {}
+local foldersLoaded = Rock.foldersLoaded
+-- list of addons in order of created that need to be enabled by PLAYER_LOGIN.
+Rock.pendingAddonsEnable = oldRock and oldRock.pendingAddonsEnable or {}
+local pendingAddonsEnable = Rock.pendingAddonsEnable
+-- set of addons which have been enabled at least once.
+Rock.addonsAlreadyEnabled = oldRock and oldRock.addonsAlreadyEnabled or {}
+local addonsAlreadyEnabled = Rock.addonsAlreadyEnabled
+-- set of addons which have no database and are set to be inactive.
+Rock.inactiveAddons = oldRock and oldRock.inactiveAddons or {}
+local inactiveAddons = Rock.inactiveAddons
+-- set of addons which are currently enabled (not necessarily should be)
+Rock.currentlyEnabledAddons = oldRock and oldRock.currentlyEnabledAddons or {}
+local currentlyEnabledAddons = Rock.currentlyEnabledAddons
+-- dictionary of namespace to list of functions which will be run.
+Rock.unitTests = oldRock and oldRock.unitTests or {}
+local unitTests = Rock.unitTests
+-- metatable for addons
+Rock.addon_mt = oldRock and oldRock.addon_mt or {}
+local addon_mt = Rock.addon_mt
+for k in pairs(addon_mt) do
+ addon_mt[k] = nil
+end
+function addon_mt:__tostring()
+ return tostring(self.name)
+end
+
+local function better_tostring(self)
+ if type(self) == "table" and self.name then
+ return tostring(self.name)
+ end
+ return tostring(self)
+end
+
+local function figureCurrentAddon(pos)
+ local stack = debugstack(pos+1, 1, 0)
+ local folder = stack:match("[Oo%.][Nn%.][Ss%.]\\([^\\]+)\\")
+ if folder then
+ return folder
+ end
+
+ local partFolder = stack:match("...([^\\]+)\\")
+ if partFolder then
+ local partFolder_len = #partFolder
+ for i = 1, GetNumAddOns() do
+ local name = GetAddOnInfo(i)
+ if #name >= partFolder_len then
+ local partName = name:sub(-partFolder_len)
+ if partName == partFolder then
+ return name
+ end
+ end
+ end
+ end
+ return nil
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ string - the localized name of the given category.
+Arguments:
+ string - the English name of the category.
+Example:
+ local uf = Rock:GetLocalizedCategory("UnitFrame")
+-----------------------------------------------------------------------------]]
+function Rock:GetLocalizedCategory(name)
+ if type(name) ~= "string" then
+ error(("Bad argument #2 to `GetLocalizedCategory'. Expected %q, got %q."):format("string", type(name)), 2)
+ end
+ local cat = CATEGORIES[name]
+ if cat then
+ return cat
+ end
+ local name_lower = name:lower()
+ for k in pairs(CATEGORIES) do
+ if k:lower() == name_lower then
+ return k
+ end
+ end
+ return _G.UNKNOWN or "Unknown"
+end
+
+local weak = {__mode = 'kv'}
+
+Rock.recycleData = oldRock and oldRock.recycleData or {}
+local recycleData = Rock.recycleData
+if recycleData.pools then
+ setmetatable(recycleData.pools, weak)
+end
+if recycleData.debugPools then
+ setmetatable(recycleData.debugPools, weak)
+end
+if recycleData.newList then
+ setmetatable(recycleData.newList, weak)
+end
+if recycleData.newDict then
+ setmetatable(recycleData.newDict, weak)
+end
+if recycleData.newSet then
+ setmetatable(recycleData.newSet, weak)
+end
+if recycleData.del then
+ setmetatable(recycleData.del, weak)
+end
+
+local tmp = {}
+local function myUnpack(t, start)
+ if not start then
+ start = 1
+ end
+ local value = t[start]
+ if value == nil then
+ return
+ end
+ t[start] = nil
+ return value, myUnpack(t, start+1)
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Returns functions for the specified namespace based on what is provided.
+ * function types:
+ ; "newList" : to create a list
+ ; "newDict" : to create a dictionary
+ ; "newSet" : to create a set
+ ; "del" : to delete a table
+ ; "unpackListAndDel" : deletes a table and returns what its contents were as a list, in order.
+ ; "unpackSetAndDel" : deletes a table and returns what its contents were as a set, in no particular order.
+ ; "unpackDictAndDel" : deletes a table and returns what its contents were as a dictionary, in no particular order.
+ * If you provide "Debug" as the last argument, then the namespace can be debugged with ''':DebugRecycle'''
+ * It is '''not recommended''' to use table recycling with tables that have more than 128 keys, as it is typically faster to let lua's garbage collector handle it.
+Arguments:
+ string - the namespace. ''Note: this doesn't necessarily have to be a string.''
+Example:
+ local newList, newDict, newSet, del, unpackListAndDel, unpackSetAndDel, unpackDictAndDel = Rock:GetRecyclingFunctions("MyNamespace", "newList", "newDict", "newSet", "del", "unpackListAndDel", "unpackSetAndDel", "unpackDictAndDel")
+
+ local t = newList('alpha', 'bravo') -- same as t = {'alpha', 'bravo'}
+ local u = newDict('alpha', 'bravo') -- same as t = {['alpha'] = 'bravo'}
+ local v = newSet('alpha', 'bravo') -- same as t = {['alpha'] = true, ['bravo'] = true}
+ t = del(t) -- you want to clear your reference as well as deleting.
+ u = del(u)
+ v = del(v)
+
+ -- for debugging
+ local newList = Rock:GetRecyclingFunctions("MyNamespace", "newList", "Debug")
+ local t = newList()
+ Rock:DebugRecycle("MyNamespace")
+ t = del(t)
+
+ -- unpacking functions
+ unpackListAndDel(newList(...)) => ...
+ unpackSetAndDel(newSet(...)) => ...
+ unpackDictAndDel(newDict(...)) => ...
+ newList(unpackListAndDel(t)) => t
+ newSet(unpackSetAndDel(t)) => t
+ newDict(unpackDictAndDel(t)) => t
+ -- as you can see, they are inverses of each other.
+-----------------------------------------------------------------------------]]
+function Rock:GetRecyclingFunctions(namespace, ...)
+ local pools = recycleData.pools
+ if not pools then
+ pools = setmetatable({}, weak)
+ recycleData.pools = pools
+ end
+ if namespace == "newList" or namespace == "newSet" or namespace == "newDict" or namespace == "del" or namespace == "unpackListAndDel" or namespace == "unpackSetAndDel" or namespace == "unpackDictAndDel" then
+ error(("Bad argument #2 to `GetRecyclingFunctions'. Cannot be %q"):format(namespace), 2)
+ end
+ local pool = pools[namespace]
+ if not pool then
+ pool = setmetatable({}, weak)
+ pools[namespace] = pool
+ end
+ local n = select('#', ...)
+ local debug = select(n, ...) == "Debug"
+ if debug then
+ n = n - 1
+ local debugPools = recycleData.debugPools
+ if not debugPools then
+ debugPools = setmetatable({}, weak)
+ recycleData.debugPools = debugPools
+ end
+ debug = debugPools[namespace]
+ if not debug then
+ debug = { num = 0 }
+ debugPools[namespace] = debug
+ end
+ elseif recycleData.debugPools and recycleData.debugPools[namespace] then
+ debug = recycleData.debugPools[namespace]
+ end
+ for i = 1, n do
+ local func = select(i, ...)
+ local recycleData_func = recycleData[func]
+ if not recycleData_func then
+ recycleData_func = setmetatable({}, weak)
+ recycleData[func] = recycleData_func
+ end
+ if func == "newList" then
+ local newList = recycleData_func[namespace]
+ if not newList then
+ function newList(...)
+ local t = next(pool)
+ local n = select('#', ...)
+ if t then
+ pool[t] = nil
+ for i = 1, n do
+ t[i] = select(i, ...)
+ end
+ else
+ t = { ... }
+ end
+
+ if debug then
+ debug[t] = debugstack(2)
+ debug.num = debug.num + 1
+ end
+
+ return t, n
+ end
+ recycleData_func[namespace] = newList
+ end
+ tmp[i] = newList
+ elseif func == "newDict" then
+ local newDict = recycleData_func[namespace]
+ if not newDict then
+ function newDict(...)
+ local t = next(pool)
+ if t then
+ pool[t] = nil
+ else
+ t = {}
+ end
+
+ for i = 1, select('#', ...), 2 do
+ t[select(i, ...)] = select(i+1, ...)
+ end
+
+ if debug then
+ debug[t] = debugstack(2)
+ debug.num = debug.num + 1
+ end
+
+ return t
+ end
+ recycleData_func[namespace] = newDict
+ end
+ tmp[i] = newDict
+ elseif func == "newSet" then
+ local newSet = recycleData_func[namespace]
+ if not newSet then
+ function newSet(...)
+ local t = next(pool)
+ if t then
+ pool[t] = nil
+ else
+ t = {}
+ end
+
+ for i = 1, select('#', ...) do
+ t[select(i, ...)] = true
+ end
+
+ if debug then
+ debug[t] = debugstack(2)
+ debug.num = debug.num + 1
+ end
+
+ return t
+ end
+ recycleData_func[namespace] = newSet
+ end
+ tmp[i] = newSet
+ elseif func == "del" then
+ local del = recycleData_func[namespace]
+ if not del then
+ function del(t)
+ if not t then
+ error(("Bad argument #1 to `del'. Expected %q, got %q."):format("table", type(t)), 2)
+ end
+ if pool[t] then
+ local _, ret = pcall(error, "Error, double-free syndrome.", 3)
+ geterrorhandler()(ret)
+ end
+ setmetatable(t, nil)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t[true] = true
+ t[true] = nil
+ pool[t] = true
+
+ if debug then
+ debug[t] = nil
+ debug.num = debug.num - 1
+ end
+ return nil
+ end
+ recycleData_func[namespace] = del
+ end
+ tmp[i] = del
+ elseif func == "unpackListAndDel" then
+ local unpackListAndDel = recycleData_func[namespace]
+ if not unpackListAndDel then
+ local function f(t, start, finish)
+ if start > finish then
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t[true] = true
+ t[true] = nil
+ pool[t] = true
+ return
+ end
+ return t[start], f(t, start+1, finish)
+ end
+ function unpackListAndDel(t, start, finish)
+ if not t then
+ error(("Bad argument #1 to `unpackListAndDel'. Expected %q, got %q."):format("table", type(t)), 2)
+ end
+ if not start then
+ start = 1
+ end
+ if not finish then
+ finish = #t
+ end
+ setmetatable(t, nil)
+ if debug then
+ debug[t] = nil
+ debug.num = debug.num - 1
+ end
+ return f(t, start, finish)
+ end
+ end
+ tmp[i] = unpackListAndDel
+ elseif func == "unpackSetAndDel" then
+ local unpackSetAndDel = recycleData_func[namespace]
+ if not unpackSetAndDel then
+ local function f(t, current)
+ current = next(t, current)
+ if current == nil then
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t[true] = true
+ t[true] = nil
+ pool[t] = true
+ return
+ end
+ return current, f(t, current)
+ end
+ function unpackSetAndDel(t)
+ if not t then
+ error(("Bad argument #1 to `unpackListAndDel'. Expected %q, got %q."):format("table", type(t)), 2)
+ end
+ setmetatable(t, nil)
+ if debug then
+ debug[t] = nil
+ debug.num = debug.num - 1
+ end
+ return f(t, nil)
+ end
+ end
+ tmp[i] = unpackSetAndDel
+ elseif func == "unpackDictAndDel" then
+ local unpackDictAndDel = recycleData_func[namespace]
+ if not unpackDictAndDel then
+ local function f(t, current)
+ local value
+ current, value = next(t, current)
+ if current == nil then
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t[true] = true
+ t[true] = nil
+ pool[t] = true
+ return
+ end
+ return current, value, f(t, current)
+ end
+ function unpackDictAndDel(t)
+ if not t then
+ error(("Bad argument #1 to `unpackListAndDel'. Expected %q, got %q."):format("table", type(t)), 2)
+ end
+ setmetatable(t, nil)
+ if debug then
+ debug[t] = nil
+ debug.num = debug.num - 1
+ end
+ return f(t, nil)
+ end
+ end
+ tmp[i] = unpackDictAndDel
+ else
+ error(("Bad argument #%d to `GetRecyclingFunctions': %q, %q, %q, %q, %q, %q, or %q expected, got %s"):format(i+2, "newList", "newDict", "newSet", "del", "unpackListAndDel", "unpackSetAndDel", "unpackDictAndDel", type(func) == "string" and ("%q"):format(func) or tostring(func)), 2)
+ end
+ end
+ return myUnpack(tmp)
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Prints information about the specified recycling namespace, including what tables are still in play and where they come from and how many there are.
+ * This goes in tandem with ''':GetRecyclingFunctions'''
+Arguments:
+ string - the namespace. ''Note: this doesn't necessarily have to be a string.''
+Example:
+ local newList = Rock:GetRecyclingFunctions("MyNamespace", "newList", "Debug")
+ local t = newList()
+ Rock:DebugRecycle("MyNamespace")
+ t = del(t)
+-----------------------------------------------------------------------------]]
+function Rock:DebugRecycle(namespace)
+ local debug = recycleData.debugPools and recycleData.debugPools[namespace]
+ if not debug then
+ return
+ end
+ for k, v in pairs(debug) do
+ if k ~= "num" then
+ _G.DEFAULT_CHAT_FRAME:AddMessage(v)
+ _G.DEFAULT_CHAT_FRAME:AddMessage("------")
+ end
+ end
+ _G.DEFAULT_CHAT_FRAME:AddMessage(("%s: %d tables in action."):format(tostring(namespace), debug.num))
+end
+
+local newList, del, unpackListAndDel, unpackDictAndDel = Rock:GetRecyclingFunctions(MAJOR_VERSION, "newList", "del", "unpackListAndDel", "unpackDictAndDel")
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Adds a unit test for the specified namespace
+ * The function provided is called, and it should be where tests are performed, if a problem occurs, an error should fire. If no problems occur, it should return silently.
+ * You can have as many tests per namespace as you want.
+Arguments:
+ string - the namespace.
+ function - the function to call.
+Example:
+ Rock:AddUnitTest("LibMonkey-1.0", function()
+ local LibMonkey = Rock("LibMonkey-1.0")
+ assert(LibMonkey:Fling() == "Poo")
+ end)
+-----------------------------------------------------------------------------]]
+function Rock:AddUnitTest(namespace, func)
+ if not isStandalone then
+ return
+ end
+ if type(namespace) ~= "string" then
+ error(("Bad argument #2 to `AddUnitTest'. Expected %q, got %q."):format("string", type(namespace)), 2)
+ end
+ if namespace:find("^Lib[A-Z]") then
+ local addon = figureCurrentAddon(2)
+ if addon ~= namespace then
+ return
+ end
+ end
+ if type(func) ~= "function" then
+ error(("Bad argument #3 to `AddUnitTest'. Expected %q, got %q."):format("function", type(func)), 2)
+ end
+ local addon = figureCurrentAddon(2)
+ if libraries[namespace] and addon ~= namespace then
+ -- only work on standalone libraries.
+ return
+ end
+ local unitTests_namespace = unitTests[namespace]
+ if not unitTests_namespace then
+ unitTests_namespace = newList()
+ unitTests[namespace] = unitTests_namespace
+ end
+ if not unitTests_namespace.addon then
+ unitTests_namespace.addon = addon
+ end
+ if unitTestDB and not unitTestDB[namespace] then
+ return
+ end
+ unitTests_namespace[#unitTests_namespace+1] = func
+end
+
+local LibRockEvent
+local LibRockModuleCore
+local OpenDonationFrame, OpenIssueFrame
+function Rock:OnLibraryLoad(major, library)
+ if major == "LibRockEvent-1.0" then
+ LibRockEvent = library
+ LibRockEvent:Embed(Rock)
+ elseif major == "LibRockModuleCore-1.0" then
+ LibRockModuleCore = library
+ elseif major == "LibRockConfig-1.0" then
+ if isStandalone then
+ library.rockOptions.args.advanced = {
+ type = 'group',
+ groupType = 'inline',
+ name = L["Advanced options"],
+ desc = L["Advanced options for developers and power users."],
+ order = -1,
+ args = {
+ unitTests = {
+ type = 'multichoice',
+ name = L["Unit tests"],
+ desc = L["Enable unit tests to be run. This is for developers only.\n\nYou must ReloadUI for changes to take effect."],
+ get = function(key)
+ return unitTestDB[key]
+ end,
+ set = function(key, value)
+ unitTestDB[key] = value or nil
+ end,
+ choices = function()
+ local t = newList()
+ for k in pairs(unitTests) do
+ t[k] = k
+ end
+ return "@dict", unpackDictAndDel(t)
+ end
+ },
+ contracts = {
+ type = 'boolean',
+ name = L["Contracts"],
+ desc = L["Enable contracts to be run. This is for developers and anyone wanting to file a bug. Do not file a bug unless contracts are enabled. This will slightly slow down your addons if enabled."],
+ get = function()
+ return enableContracts
+ end,
+ set = function(value)
+ _G.LibRock_1_0DB.contracts = value or nil
+ enableContracts = value
+ end,
+ }
+ }
+ }
+ end
+ library.rockOptions.args.reloadui = {
+ type = 'execute',
+ name = L["Reload UI"],
+ desc = L["Reload the User Interface for some changes to take effect."],
+ buttonText = L["Reload"],
+ func = function()
+ _G.ReloadUI()
+ end,
+ order = -2,
+ }
+ Rock.donate = "Paypal:ckknight AT gmail DOT com"
+ library.rockOptions.args.donate = {
+ type = 'execute',
+ name = L["Give donation"],
+ buttonText = L["Donate"],
+ desc = L["Give a much-needed donation to the author of this addon."],
+ func = OpenDonationFrame,
+ passValue = Rock,
+ order = -3,
+ }
+ Rock.issueTracker = "Wowace:10027"
+ library.rockOptions.args.issue = {
+ type = 'execute',
+ name = L["File issue"],
+ buttonText = L["Report"],
+ desc = L["File a bug or request a new feature or an improvement to this addon."],
+ func = OpenIssueFrame,
+ passValue = Rock,
+ order = -4,
+ }
+ end
+end
+
+addon_mt.__index = {}
+local addon_mt___index = addon_mt.__index
+--[[---------------------------------------------------------------------------
+#FORCE_DOC
+Notes:
+ * This is exported to all addons.
+ * This information is retrieved from LibRockModuleCore-1.0 if it is a module, otherwise from LibRockDB-1.0 if it uses that as a mixin, otherwise it keeps a variable locally.
+Returns:
+ boolean - whether the addon is in an active state or not.
+Example:
+ local active = MyAddon:IsActive()
+-----------------------------------------------------------------------------]]
+function addon_mt___index:IsActive()
+ if LibRockModuleCore then
+ local core = LibRockModuleCore:HasModule(self)
+ if core then
+ return core:IsModuleActive(self)
+ end
+ end
+
+ local self_db = self.db
+ if self_db then
+ local disabled
+ local self_db_raw = self_db.raw
+ if self_db_raw then
+ local self_db_raw_disabled = self_db_raw.disabled
+ if self_db_raw_disabled then
+ local profile = type(self.GetProfile) == "function" and select(2, self:GetProfile()) or false
+ disabled = self_db_raw_disabled[profile]
+ end
+ else
+ return false
+ end
+ return not disabled
+ end
+
+ return not inactiveAddons[self]
+end
+--[[---------------------------------------------------------------------------
+#FORCE_DOC
+Notes:
+ * This is exported to all addons.
+ * If it enables the addon, it will call :OnEnable(first) on the addon and :OnEmbedEnable(addon, first) on all its mixins.
+ * If it disables the addon, it will call :OnDisable(first) on the addon and :OnEmbedDisable(addon, first) on all its mixins.
+ * This information is stored by LibRockModuleCore-1.0 if it is a module, otherwise from LibRockDB-1.0 if it uses that as a mixin, otherwise it keeps a variable locally.
+Arguments:
+ [optional] boolean - whether the addon should be in an active state or not. Default: not :IsActive()
+Returns:
+ boolean - whether the addon is in an active state or not.
+Example:
+ MyAddon:ToggleActive() -- switch
+ MyAddon:ToggleActive(true) -- force on
+ MyAddon:ToggleActive(false) -- force off
+-----------------------------------------------------------------------------]]
+function addon_mt___index:ToggleActive(state)
+ if state and state ~= true then
+ error(("Bad argument #2 to `ToggleActive'. Expected %q or %q, got %q."):format("boolean", "nil", type(state)), 2)
+ end
+ if LibRockModuleCore then
+ local core = LibRockModuleCore:HasModule(self)
+ if core then
+ return core:ToggleModuleActive(self, state)
+ end
+ end
+
+ local self_db = self.db
+ if self_db then
+ local self_db_raw = self_db.raw
+ if not self_db_raw then
+ error("Error saving to database with `ToggleActive'. db.raw not available.", 2)
+ end
+ local self_db_raw_disabled = self_db_raw.disabled
+ if not self_db_raw_disabled then
+ self_db_raw_disabled = newList()
+ self_db_raw.disabled = self_db_raw_disabled
+ end
+ local profile = type(self.GetProfile) == "function" and select(2, self:GetProfile()) or false
+ if state == nil then
+ state = not not self_db_raw_disabled[profile]
+ elseif (not self_db_raw_disabled[profile]) == state then
+ return
+ end
+ self_db_raw_disabled[profile] = not state or nil
+ if next(self_db_raw_disabled) == nil then
+ self_db_raw.disabled = del(self_db_raw_disabled)
+ end
+ else
+ if state == nil then
+ state = not not inactiveAddons[self]
+ elseif (not inactiveAddons[self]) == state then
+ return
+ end
+ inactiveAddons[self] = not state or nil
+ end
+
+ Rock:RecheckEnabledStates()
+
+ return state
+end
+
+local function noop() end
+
+do
+ local preconditions = setmetatable({}, weakKey)
+ local postconditions = setmetatable({}, weakKey)
+ local postconditionsOld = setmetatable({}, weakKey)
+
+ local currentMethod = nil
+
+ local function hook(object, method)
+ local object_method = object[method]
+ object[method] = function(...)
+ local pre = preconditions[object_method]
+ local post = postconditions[object_method]
+ if pre then
+ local old_currentMethod = currentMethod
+ currentMethod = method
+ pre(...)
+ currentMethod = old_currentMethod
+ end
+ if not post then
+ return object_method(...)
+ end
+ local oldFunc = postconditionsOld[object_method]
+ local old
+ if oldFunc then
+ old = newList()
+ oldFunc(old, ...)
+ end
+
+ local old_currentMethod = currentMethod
+ currentMethod = nil
+ local ret, n = newList(object_method(...))
+
+ currentMethod = method
+ if old then
+ post(old, ret, ...)
+ old = del(old)
+ else
+ post(ret, ...)
+ end
+ currentMethod = old_currentMethod
+ return unpackListAndDel(ret, 1, n)
+ end
+ end
+
+ local function precondition(object, method, func)
+ if type(object) ~= "table" then
+ error(("Bad argument #1 to `precondition'. Expected %q, got %q."):format("table", type(object)), 2)
+ end
+ if type(object[method]) ~= "function" then
+ error(("Method %q not found on object %s. Expected %q, got %q."):format(tostring(method), tostring(object), "function", type(object[method])), 2)
+ end
+ if type(func) ~= "function" then
+ error(("Bad argument #3 to `precondition'. Expected %q, got %q."):format("function", type(func)), 2)
+ end
+
+ local object_method = object[method]
+ if preconditions[object_method] then
+ error("Cannot call `preconditon' on the same method twice.", 2)
+ end
+ preconditions[object_method] = func
+
+ if not postconditions[object_method] then
+ hook(object, method)
+ end
+ end
+
+ local function postcondition(object, method, func, fillOld)
+ if type(object) ~= "table" then
+ error(("Bad argument #1 to `postcondition'. Expected %q, got %q."):format("table", type(object)), 2)
+ end
+ if type(object[method]) ~= "function" then
+ error(("Method %q not found on object %s. Expected %q, got %q."):format(tostring(method), tostring(object), "function", type(object[method])), 2)
+ end
+ if type(func) ~= "function" then
+ error(("Bad argument #3 to `postcondition'. Expected %q, got %q."):format("function", type(func)), 2)
+ end
+ if fillOld and type(fillOld) ~= "function" then
+ error(("Bad argument #4 to `postcondition'. Expected %q or %q, got %q."):format("function", "nil", type(func)), 2)
+ end
+
+ local object_method = object[method]
+ if postconditions[object_method] then
+ error("Cannot call `postcondition' on the same method twice.", 2)
+ end
+ postconditions[object_method] = func
+ postconditionsOld[object_method] = fillOld
+
+ if not preconditions[object_method] then
+ hook(object, method)
+ end
+ end
+
+ local function argCheck(value, position, ...)
+ if not currentMethod then
+ error("Cannot call `argCheck' outside of a pre/post-condition.", 2)
+ end
+ if type(position) ~= "number" then
+ error(("Bad argument #2 to `argCheck'. Expected %q, got %q"):format("number", type(position)), 2)
+ end
+ local type_value = type(value)
+ for i = 1, select('#', ...) do
+ local v = select(i, ...)
+ if type(v) ~= "string" then
+ error(("Bad argument #%d to `argCheck'. Expected %q, got %q"):format(i+1, "string", type(v)), 2)
+ end
+ if v == type_value then
+ return
+ end
+ end
+ local t = newList(...)
+ t[#t] = nil
+ for i,v in ipairs(t) do
+ t[i] = ("%q"):format(v)
+ end
+ local s
+ if #t == 0 then
+ s = ("%q"):format((...))
+ elseif #t == 1 then
+ s = ("%q or %q"):format(...)
+ else
+ s = table_concat(t, ", ") .. ", or " .. ("%q"):format(select(#t+1, ...))
+ end
+ t = del(t)
+
+ error(("Bad argument #%d to `%s'. Expected %s, got %q."):format(position, tostring(currentMethod), s, type_value), 4)
+ end
+
+ --[[---------------------------------------------------------------------------
+ Notes:
+ * Returns functions for the specified namespace based on what is provided.
+ * function types:
+ ; "precondition" : to set the pre-condition for a method.
+ ; "postcondition" : to set the post-condition for a method.
+ ; "argCheck" : to check the type of an argument, to be executed within a pre-condition.
+ * preconditon is in the form of precondition(object, "methodName", func(self, ...))
+ * postcondition is in the form of either postcondition(object, "methodName", func(returnValues, self, ...)) or postcondition(object, "methodName", func(oldValues, returnValues, self, ...), populateOld(oldValues, self, ...))
+ ** returnValues is the list of return values, empty if no return values were sent.
+ ** if the populateOld function is provided, then the empty oldValues table is provided and expected to be filled, and then given to the func.
+ * argCheck is in the form of argCheck(value, n, "type1" [, "type2", ...])
+ ** value is the value provided to the function you're checking.
+ ** n is the argument position. ''Note: 1 is the position of `self'. 2 would be the first "real" position.''
+ ** the tuple of types can be any string, but specifically "nil", "boolean", "string", "number", "function", "userdata", "table", etc.
+ Arguments:
+ string - the namespace. ''Note: this doesn't necessarily have to be a string.''
+ Example:
+ local precondition, postcondition, argCheck = Rock:GetRecyclingFunctions("Stack", "precondition", "postcondition", "argCheck")
+
+ local stack = {}
+ stack.IsEmpty = function(self)
+ return self[1] == nil
+ end
+ stack.GetLength = function(self)
+ return #self
+ end
+ stack.Push = function(self, value)
+ self[#self+1] = value
+ end
+ precondition(stack, "Push", function(self, value)
+ argCheck(value, 2, "string") -- only accept strings, no other values
+ end)
+ postcondition(stack, "Push", function(old, ret, self, value)
+ assert(self:GetLength() == old.length+1)
+ assert(not self:IsEmpty())
+ end, function(old, self)
+ old.length = self:GetLength()
+ end)
+ stack.Pop = function(self)
+ local value = self[#self]
+ self[#self] = nil
+ return value
+ end
+ precondition(stack, "Pop", function(self)
+ assert(self:GetLength() >= 1)
+ end)
+ postcondition(stack, "Pop", function(old, ret, self)
+ assert(self:GetLength() == old.length-1)
+ end, function(old, self)
+ old.length = self:GetLength()
+ end)
+ stack.Peek = function(self)
+ return self[#self]
+ end
+ precondition(stack, "Peek", function(self)
+ assert(self:GetLength() >= 1)
+ end)
+ postcondition(stack, "Peek", function(old, ret, self)
+ assert(self:GetLength() == old.length)
+ end, function(old, self)
+ old.length = self:GetLength()
+ end)
+
+ local t = setmetatable({}, {__index=stack})
+ t:Push("Alpha")
+ t:Push("Bravo")
+ t:Push(5) -- error, only strings
+ assert(t:Pop() == "Bravo")
+ assert(t:Pop() == "Alpha")
+ t:Pop() -- error, out of values
+ -----------------------------------------------------------------------------]]
+ function Rock:GetContractFunctions(namespace, ...)
+ if namespace == "precondition" or namespace == "postcondition" or namespace == "argCheck" then
+ error(("Bad argument #2 to `GetContractFunctions'. Cannot be %q."):format(namespace), 2)
+ end
+ local t = newList()
+ if enableContracts then
+ for i = 1, select('#', ...) do
+ local v = select(i, ...)
+ if v == "precondition" then
+ t[i] = precondition
+ elseif v == "postcondition" then
+ t[i] = postcondition
+ elseif v == "argCheck" then
+ t[i] = argCheck
+ else
+ error(("Bad argument #%d to `GetContractFunctions'. Expected %q, %q, or %q, got %q."):format(i+2, "precondition", "postcondition", "argCheck", tostring(v)))
+ end
+ end
+ else
+ for i = 1, select('#', ...) do
+ t[i] = noop
+ end
+ end
+ return unpackListAndDel(t)
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * convert a revision string to a number
+Arguments:
+ string - revision string
+Returns:
+ string or number - the string given or the number retrieved from it.
+-----------------------------------------------------------------------------]]
+local function coerceRevisionToNumber(version)
+ if type(version) == "string" then
+ return tonumber(version:match("(%-?%d+)")) or version
+ else
+ return version
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * try to enable the standalone library specified
+Arguments:
+ string - name of the library.
+Returns:
+ boolean - whether the library is properly enabled and loadable.
+-----------------------------------------------------------------------------]]
+local function TryToEnable(addon)
+ local islod = IsAddOnLoadOnDemand(addon)
+ if islod then
+ local _, _, _, enabled = GetAddOnInfo(addon)
+ EnableAddOn(addon)
+ local _, _, _, _, loadable = GetAddOnInfo(addon)
+ if not loadable and not enabled then
+ DisableAddOn(addon)
+ end
+
+ return loadable
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * try to load the standalone library specified
+Arguments:
+ string - name of the library.
+Returns:
+ boolean - whether the library is loaded.
+-----------------------------------------------------------------------------]]
+local function TryToLoadStandalone(major)
+ major = major:lower()
+ if scannedLibraries[major] then
+ return
+ end
+ scannedLibraries[major] = true
+ local name, _, _, enabled, loadable, state = GetAddOnInfo(major)
+ if state == "MISSING" or not IsAddOnLoadOnDemand(major) then
+ -- backwards compatibility for X-AceLibrary
+ local field = "X-AceLibrary-" .. major
+ local loaded
+ for i = 1, GetNumAddOns() do
+ if GetAddOnMetadata(i, field) then
+ name, _, _, enabled, loadable = GetAddOnInfo(i)
+
+ loadable = (enabled and loadable) or TryToEnable(name)
+ if loadable then
+ loaded = true
+ LoadAddOn(name)
+ end
+ end
+ end
+
+ return loaded
+ elseif (enabled and loadable) or TryToEnable(major) then
+ LoadAddOn(major)
+ return true
+ else
+ return false
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Return the LibStub library, casing is unimportant.
+Arguments:
+ string - name of the library.
+Returns:
+ table or nil - library
+ number - minor version
+-----------------------------------------------------------------------------]]
+local function GetLibStubLibrary(major)
+ local lib, minor = LibStub:GetLibrary(major, true)
+ if lib then
+ return lib, minor
+ end
+ major = major:lower()
+ for m, lib in LibStub:IterateLibraries() do
+ if m:lower() == major then
+ return LibStub:GetLibrary(m)
+ end
+ end
+ return nil, nil
+end
+
+local finishLibraryRegistration
+--[[---------------------------------------------------------------------------
+Notes:
+ * create a new library if the version provided is not out of date.
+Arguments:
+ string - name of the library.
+ number - version of the library.
+Returns:
+ library, oldLibrary
+ * table or nil - the library with which to manipulate
+ * table or nil - the old version of the library to upgrade from
+Example:
+ local LibMonkey, oldLib = Rock:NewLibrary("LibMonkey-1.0", 50)
+ if not LibMonkey then
+ -- opt out now, out of date
+ return
+ end
+-----------------------------------------------------------------------------]]
+function Rock:NewLibrary(major, version)
+ if type(major) ~= "string" then
+ error(("Bad argument #2 to `NewLibrary'. Expected %q, got %q."):format("string", type(major)), 2)
+ end
+ if not major:match("^Lib[A-Z][A-Za-z%d%-]*%-%d+%.%d+$") then
+ error(("Bad argument #2 to `NewLibrary'. Must match %q, got %q."):format("^Lib[A-Z][A-Za-z%d%-]*%-%d+%.%d+$", major), 2)
+ end
+ TryToLoadStandalone(major)
+ version = coerceRevisionToNumber(version)
+ if type(version) ~= "number" then
+ error(("Bad argument #3 to `NewLibrary'. Expected %q, got %q."):format("number", type(version)), 2)
+ end
+ local library, oldMinor = LibStub:GetLibrary(major, true)
+ if oldMinor and oldMinor >= version then
+ -- in case LibStub is acting funny
+ return nil, nil
+ end
+ local library, oldMinor = LibStub:NewLibrary(major, version)
+ if not library then
+ return nil, nil
+ end
+ local unitTests_major = unitTests[major]
+ if unitTests_major then
+ for k,v in pairs(unitTests_major) do
+ unitTests_major[k] = nil
+ end
+ end
+ for k, v in pairs(recycleData) do
+ v[major] = nil
+ end
+ local mixinToObject_library = mixinToObject[library]
+
+ local oldLib
+ if oldMinor then
+ -- previous version exists
+ local mixins = newList()
+ for mixin, objectSet in pairs(mixinToObject) do
+ if objectSet[library] then
+ mixins[mixin] = true
+ end
+ end
+ for mixin in pairs(mixins) do
+ mixin:Unembed(library)
+ end
+ mixins = del(mixins)
+ oldLib = newList()
+ for k, v in pairs(library) do
+ oldLib[k] = v
+ library[k] = nil
+ end
+ setmetatable(oldLib, getmetatable(library))
+ setmetatable(library, nil)
+ end
+ finishLibraryRegistration(major, version, library, figureCurrentAddon(2))
+
+ return library, oldLib
+end
+function finishLibraryRegistration(major, version, library, folder)
+ library.name = major
+
+ libraries[major] = library
+ pendingLibraries[library] = folder
+ local exportedMethods_library = exportedMethods[library]
+ if exportedMethods_library then
+ local mixinToObject_library = mixinToObject[library]
+ if mixinToObject_library then
+ for object in pairs(mixinToObject_library) do
+ for _,v in ipairs(exportedMethods_library) do
+ object[v] = nil
+ end
+ end
+ end
+ exportedMethods[library] = del(exportedMethods_library)
+ end
+ if library ~= Rock then
+ Rock:Embed(library)
+ end
+
+ frame:Show()
+end
+if not oldRock then
+ finishLibraryRegistration(MAJOR_VERSION, MINOR_VERSION, Rock, figureCurrentAddon(1))
+end
+
+-- #NODOC
+local function __removeLibrary(libName)
+ libraries[libName] = nil
+ if LibStub.libs then
+ LibStub.libs[libName] = nil
+ end
+ if LibStub.minors then
+ LibStub.minors[libName] = nil
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * properly finalizes the library, essentially stating that it has loaded properly.
+ * This will call :OnLibraryLoad("major", library) on every other library
+ * This will also call :OnLibraryLoad("major", library) on the library provided, using every other library as the arguments.
+ * An error will occur if this is not done before ADDON_LOADED.
+Arguments:
+ string - name of the library.
+Example:
+ local LibMonkey, oldLib = Rock:NewLibrary("LibMonkey-1.0", 50)
+ if not LibMonkey then
+ -- opt out now, out of date
+ return
+ end
+ Rock:FinalizeLibrary("LibMonkey-1.0")
+-----------------------------------------------------------------------------]]
+function Rock:FinalizeLibrary(major)
+ if type(major) ~= "string" then
+ error(("Bad argument #2 to `FinalizeLibrary'. Expected %q, got %q."):format("string", type(major)), 2)
+ end
+ local library = libraries[major]
+ if not library then
+ error(("Bad argument #2 to `FinalizeLibrary'. %q is not a library."):format("string", major), 2)
+ end
+ pendingLibraries[library] = nil
+ local library_OnLibraryLoad = library.OnLibraryLoad
+ if library_OnLibraryLoad then
+ for maj, lib in LibStub:IterateLibraries() do -- for all libraries
+ if maj ~= major then
+ local success, ret = pcall(library_OnLibraryLoad, library, maj, lib)
+ if not success then
+ geterrorhandler()(ret)
+ break
+ end
+ end
+ end
+ end
+ if finalizedLibraries[library] then
+ return
+ end
+ finalizedLibraries[library] = true
+ for maj, lib in pairs(libraries) do -- just Rock libraries
+ if maj ~= major then
+ local lib_OnLibraryLoad = lib.OnLibraryLoad
+ if lib_OnLibraryLoad then
+ local success, ret = pcall(lib_OnLibraryLoad, lib, major, library)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+ end
+ end
+ if LibRockEvent then
+ self:DispatchEvent("LibraryLoad", major, library)
+ end
+end
+
+local function manualFinalize(major, library)
+ if libraries[major] then -- non-Rock libraries only
+ return
+ end
+ if finalizedLibraries[library] then -- don't do it twice
+ return
+ end
+ finalizedLibraries[library] = true
+ for maj, lib in pairs(libraries) do -- just Rock libraries
+ if maj ~= major then
+ local lib_OnLibraryLoad = lib.OnLibraryLoad
+ if lib_OnLibraryLoad then
+ local success, ret = pcall(lib_OnLibraryLoad, lib, major, library)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+ end
+ end
+ if LibRockEvent then
+ Rock:DispatchEvent("LibraryLoad", major, library)
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ string - name of the library.
+ [optional] boolean - whether to not load a library if it is not found. Default: false
+ [optional] boolean - whether to not error if a library is not found. Default: false
+Returns:
+ library
+ * table or nil - the library requested
+Example:
+ local LibMonkey = Rock:GetLibrary("LibMonkey-1.0")
+ -- or
+ local LibMonkey = Rock("LibMonkey-1.0")
+-----------------------------------------------------------------------------]]
+function Rock:GetLibrary(major, dontLoad, dontError)
+ if type(major) ~= "string" then
+ error(("Bad argument #2 to `GetLibrary'. Expected %q, got %q."):format("string", type(major)), 2)
+ end
+ if dontLoad and dontLoad ~= true then
+ error(("Bad argument #3 to `GetLibrary'. Expected %q or %q, got %q."):format("boolean", "nil", type(dontLoad)), 2)
+ end
+ if dontError and dontError ~= true then
+ error(("Bad argument #4 to `GetLibrary'. Expected %q or %q, got %q."):format("boolean", "nil", type(dontError)), 2)
+ end
+ if not dontLoad then
+ TryToLoadStandalone(major)
+ end
+
+ local library = GetLibStubLibrary(major)
+ if not library then
+ if dontError then
+ return nil
+ end
+ error(("Library %q not found."):format(major), 2)
+ end
+
+ return library
+end
+
+setmetatable(Rock, { __call = Rock.GetLibrary })
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ string - name of the library.
+Returns:
+ boolean - whether the library exists and is a proper mixin which can be embedded.
+Example:
+ local isMixin = Rock:IsLibraryMixin("LibMonkey-1.0")
+-----------------------------------------------------------------------------]]
+function Rock:IsLibraryMixin(name)
+ local library = self:GetLibrary(name, false, true)
+ if not library then
+ return false
+ end
+ return not not (exportedMethods[library] or type(rawget(library, 'embed')) == "function" or type(rawget(library, 'Embed')) == "function")
+end
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ string - name of the library.
+ [optional] boolean - whether to not load a library if it is not found. Default: false
+Returns:
+ library
+ * table or nil - the library requested
+Example:
+ local hasLibMonkey = Rock:HasLibrary("LibMonkey-1.0")
+-----------------------------------------------------------------------------]]
+function Rock:HasLibrary(major, dontLoad)
+ if type(major) ~= "string" then
+ error(("Bad argument #2 to `HasLibrary'. Expected %q, got %q."):format("string", type(major)), 2)
+ end
+ if dontLoad and dontLoad ~= true then
+ error(("Bad argument #3 to `HasLibrary'. Expected %q or %q, got %q."):format("boolean", "nil", type(dontLoad)), 2)
+ end
+ if not dontLoad then
+ TryToLoadStandalone(major)
+ end
+ return not not GetLibStubLibrary(major)
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * This is exported to all libraries
+Returns:
+ major, minor
+ * string - name of the library
+ * number - version of the library
+Example:
+ local major, minor = Rock:GetLibraryVersion() -- will be "LibRock-1.0", 12345
+ local major, minor = LibMonkey:GetLibraryVersion() -- will be "LibMonkey-1.0", 50
+-----------------------------------------------------------------------------]]
+function Rock:GetLibraryVersion()
+ if type(self) ~= "table" then
+ return nil, nil
+ end
+ local major
+ local name = self.name
+ if name and GetLibStubLibrary(name) == self then
+ major = name
+ else
+ for m, instance in LibStub:IterateLibraries() do
+ if instance == self then
+ major = m
+ break
+ end
+ end
+ if not major then
+ return nil, nil
+ end
+ end
+ local _, minor = GetLibStubLibrary(major)
+ return major, minor
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ an iterator to traverse all registered libraries.
+Example:
+ for major, library in Rock:IterateLibraries() do
+ -- do something with major and library
+ end
+-----------------------------------------------------------------------------]]
+function Rock:IterateLibraries()
+ return LibStub:IterateLibraries()
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * This is exported to all libraries
+ * Allows you to set precisely what methods for the library to export.
+ * This automatically turns a library into a mixin.
+Arguments:
+ tuple - the list of method names to export.
+Example:
+ local LibMonkey = Rock:NewLibrary("LibMonkey-1.0", 50)
+ LibMonkey.FlingPoo = function(self)
+ return "Splat!"
+ end
+ LibMonkey:SetExportedMethods("FlingPoo")
+ -- later
+ local Darwin = Rock:NewAddon("Darwin", "LibMonkey-1.0")
+ assert(Darwin:FlingPoo() == "Splat!")
+-----------------------------------------------------------------------------]]
+function Rock:SetExportedMethods(...)
+ if exportedMethods[self] then
+ error("Cannot call `SetExportedMethods' more than once.", 2)
+ end
+ local t = newList(...)
+ if #t == 0 then
+ error("Must supply at least 1 method to `SetExportedMethods'.", 2)
+ end
+ for i,v in ipairs(t) do
+ if type(self[v]) ~= "function" then
+ error(("Bad argument #%d to `SetExportedMethods'. Method %q does not exist."):format(i+1, tostring(v)), 2)
+ end
+ end
+ exportedMethods[self] = t
+
+ local mixinToObject_library = mixinToObject[self]
+ if mixinToObject_library then
+ for object in pairs(mixinToObject_library) do
+ for _,method in ipairs(t) do
+ object[method] = self[method]
+ end
+ end
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * This is exported to all libraries
+ * Embeds all the methods previously set to export onto a table.
+ * This will call :OnEmbed(object) on the library if it is available.
+Arguments:
+ table - the table with which to export methods onto.
+Returns:
+ The table provided, after embedding.
+Example:
+ local LibMonkey = Rock:NewLibrary("LibMonkey-1.0", 50)
+ LibMonkey.FlingPoo = function(self)
+ return "Splat!"
+ end
+ LibMonkey:SetExportedMethods("FlingPoo")
+ -- later
+ local Darwin = {}
+ Rock("LibMonkey-1.0"):Embed(Darwin)
+ assert(Darwin:FlingPoo() == "Splat!")
+-----------------------------------------------------------------------------]]
+function Rock:Embed(object)
+ if not exportedMethods[self] then
+ error(("Cannot call `Embed' for library %q if `SetExportedMethods' has not been called."):format(tostring(self.name)), 2)
+ end
+ if type(object) ~= "table" then
+ error(("Bad argument #2 to `Embed'. Expected %q, got %q."):format("table", type(object)), 2)
+ end
+
+ for i,v in ipairs(exportedMethods[self]) do
+ if type(self[v]) ~= "function" then
+ error(("Problem embedding method %q from library %q. Expected %q, got %q."):format(tostring(v), better_tostring(self), "function", type(self[v])))
+ end
+ object[v] = self[v]
+ end
+
+ if not mixinToObject[self] then
+ -- weak because objects come and go
+ mixinToObject[self] = setmetatable(newList(), weakKey)
+ end
+ if mixinToObject[self][object] then
+ error(("Cannot embed library %q into the same object %q more than once."):format(better_tostring(self), better_tostring(object)), 2)
+ end
+ mixinToObject[self][object] = true
+ if type(rawget(object, 'mixins')) == "table" then
+ object.mixins[self] = true
+ end
+
+ local self_OnEmbed = self.OnEmbed
+ if self_OnEmbed then
+ local success, ret = pcall(self_OnEmbed, self, object)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+
+ return object
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * This is exported to all libraries
+ * Unembeds all the methods previously set to export onto a table.
+ * This will error if the library is not embedded on the object
+ * This will call :OnUnembed(object) on the library if it is available.
+Arguments:
+ table - the table with which to export methods onto.
+Returns:
+ The table provided, after embedding.
+Example:
+ local LibMonkey = Rock:NewLibrary("LibMonkey-1.0", 50)
+ LibMonkey.FlingPoo = function(self)
+ return "Splat!"
+ end
+ LibMonkey:SetExportedMethods("FlingPoo")
+ -- later
+ local Darwin = {}
+ Rock("LibMonkey-1.0"):Embed(Darwin)
+ assert(Darwin:FlingPoo() == "Splat!")
+ Rock("LibMonkey-1.0"):Unembed(Darwin)
+ assert(Darwin.FlingPoo == nil)
+-----------------------------------------------------------------------------]]
+function Rock:Unembed(object)
+ if not exportedMethods[self] then
+ error(("Cannot call `Unembed' for library %q if `SetExportedMethods' has not been called."):format(better_tostring(self)), 2)
+ end
+
+ if not mixinToObject[self] or not mixinToObject[self][object] then
+ error(("Cannot unembed library %q from object %q, since it is not embedded originally."):format(better_tostring(self), better_tostring(object)), 2)
+ end
+ local mixinToObject_self = mixinToObject[self]
+ mixinToObject_self[object] = nil
+ if not next(mixinToObject_self) then
+ mixinToObject[self] = del(mixinToObject_self)
+ end
+
+ local mixin_OnUnembed = self.OnUnembed
+ if mixin_OnUnembed then
+ local success, ret = pcall(mixin_OnUnembed, self, object)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+
+ for i,v in ipairs(exportedMethods[self]) do
+ object[v] = nil
+ end
+end
+
+local function embedAce2Mixin(mixin, object)
+ if not mixinToObject[mixin] then
+ mixinToObject[mixin] = setmetatable(newList(), weakKey)
+ end
+ mixinToObject[mixin][object] = true
+ mixin:embed(object)
+end
+
+local function embedLibStubMixin(mixin, object)
+ if not mixinToObject[mixin] then
+ mixinToObject[mixin] = setmetatable(newList(), weakKey)
+ end
+ mixinToObject[mixin][object] = true
+ mixin:Embed(object)
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * create a new addon with the specified name.
+Arguments:
+ string - name of the addon.
+ tuple - list of mixins with which to embed into this addon.
+Returns:
+ addon
+ * table - the addon with which to manipulate
+Example:
+ local MyAddon = Rock:NewAddon("MyAddon", "Mixin-1.0", "OtherMixin-2.0")
+-----------------------------------------------------------------------------]]
+function Rock:NewAddon(name, ...)
+ if type(name) ~= "string" then
+ error(("Bad argument #2 to `NewAddon'. Expected %q, got %q"):format("string", type(name)), 2)
+ end
+ if name:match("^Lib[A-Z]") then
+ error(("Bad argument #2 to `NewAddon'. Cannot start with %q, got %q."):format("Lib", name), 2)
+ end
+ if self == Rock and name:match("_") then
+ error(("Bad argument #2 to `NewAddon'. Cannot contain underscores, got %q."):format(name), 2)
+ end
+
+ if addons[name] then
+ error(("Bad argument #2 to `NewAddon'. Addon %q already created."):format(name), 2)
+ end
+ local addon = setmetatable(newList(), addon_mt)
+ addon.name = name
+
+ local mixinSet = newList()
+
+ for i = 1, select('#', ...) do
+ local libName = select(i, ...)
+ if mixinSet[libName] then
+ error(("Bad argument #%d to `NewAddon'. %q already stated."):format(i+2, tostring(libName)), 2)
+ end
+ mixinSet[libName] = true
+ TryToLoadStandalone(libName)
+ local library = Rock:GetLibrary(libName, false, true)
+ if not library then
+ error(("Bad argument #%d to `NewAddon'. Library %q is not found."):format(i+2, tostring(libName)), 2)
+ end
+
+ local style = 'rock'
+
+ if not exportedMethods[library] then
+ local good = false
+ if AceLibrary then
+ local AceOO = AceLibrary:HasInstance("AceOO-2.0", false) and AceLibrary("AceOO-2.0")
+ if AceOO and AceOO.inherits(library, AceOO.Mixin) then
+ good = true
+ style = 'ace2'
+ end
+ end
+ if not good and type(rawget(library, 'Embed')) == "function" then
+ good = true
+ style = 'libstub'
+ end
+ if not good then
+ error(("Bad argument #%d to `NewAddon'. Library %q is not a mixin."):format(i+2, tostring(libName)), 2)
+ end
+ end
+
+ if library == Rock then
+ error(("Bad argument #%d to `NewAddon'. Cannot use %q as a mixin."):format(i+2, tostring(libName)), 2)
+ end
+
+ if style == 'rock' then
+ library:Embed(addon)
+ elseif style == 'ace2' then
+ embedAce2Mixin(library, addon)
+ elseif style == 'libstub' then
+ embedLibStubMixin(library, addon)
+ end
+ end
+
+ mixinSet = del(mixinSet)
+
+ addons[name] = addon
+ pendingAddons[#pendingAddons+1] = addon
+ pendingAddonsEnable[#pendingAddonsEnable+1] = addon
+ addonToFolder[addon] = figureCurrentAddon(self == Rock and 2 or 4)
+
+ frame:Show()
+
+ return addon
+end
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ string - name of the addon.
+Returns:
+ addon
+ * table or nil - the addon requested
+Example:
+ local MyAddon = Rock:GetAddon("MyAddon")
+-----------------------------------------------------------------------------]]
+function Rock:GetAddon(name)
+ if type(name) ~= "string" then
+ return nil
+ end
+ local addon = addons[name]
+ if addon then
+ return addon
+ end
+ name = name:lower()
+ for k, v in pairs(addons) do
+ if k:lower() == name then
+ return v
+ end
+ end
+ return nil
+end
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ string or table - name of the addon or the addon itself.
+Returns:
+ boolean - whether the addon requested exists.
+Example:
+ local hasMyAddon = Rock:HasAddon("MyAddon")
+ -- or
+ local hasMyAddon = Rock:HasAddon(MyAddon)
+-----------------------------------------------------------------------------]]
+function Rock:HasAddon(name)
+ if type(name) == "string" then
+ local addon = addons[name]
+ if addon then
+ return true
+ end
+ name = name:lower()
+ for k, v in pairs(addons) do
+ if k:lower() == name then
+ return true
+ end
+ end
+ elseif type(name) == "table" then
+ for k,v in pairs(addons) do
+ if v == name then
+ return true
+ end
+ end
+ end
+ return false
+end
+
+--[[---------------------------------------------------------------------------
+Returns:
+ an iterator to traverse all addons created with Rock.
+Example:
+ for name, addon in Rock:IterateAddons() do
+ -- do something with name and addon
+ end
+-----------------------------------------------------------------------------]]
+function Rock:IterateAddons()
+ return pairs(addons)
+end
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ string - major version of the mixin library
+Returns:
+ an iterator to traverse all objects that the given mixin has embedded into
+Example:
+ local LibMonkey = Rock:NewLibrary("LibMonkey-1.0")
+ local Darwin = Rock:NewAddon("Darwin", "LibMonkey-1.0")
+ for object in LibMonkey:IterateMixinObjects("LibMonkey-1.0") do
+ assert(object == Darwin)
+ end
+-----------------------------------------------------------------------------]]
+function Rock:IterateMixinObjects(mixinName)
+ local mixin
+ if type(mixinName) == "table" then
+ mixin = mixinName
+ else
+ if type(mixinName) ~= "string" then
+ error(("Bad argument #2 to `IterateMixinObjects'. Expected %q or %q, got %q."):format("table", "string", type(mixinName)), 2)
+ end
+ mixin = libraries[mixinName]
+ end
+ local mixinToObject_mixin = mixinToObject[mixin]
+ if not mixinToObject_mixin then
+ return noop
+ end
+ return pairs(mixinToObject_mixin)
+end
+
+local function iter(object, mixin)
+ mixin = next(mixinToObject, mixin)
+ if not mixin then
+ return nil
+ elseif mixinToObject[mixin][object] then
+ return mixin
+ end
+ return iter(object, mixin) -- try next mixin
+end
+--[[---------------------------------------------------------------------------
+Returns:
+ an iterator to traverse all mixins that an object has embedded
+Example:
+ local LibMonkey = Rock:NewLibrary("LibMonkey-1.0")
+ local Darwin = Rock:NewAddon("Darwin", "LibMonkey-1.0")
+ for mixin in Rock:IterateObjectMixins(Darwin) do
+ assert(mixin == LibMonkey)
+ end
+-----------------------------------------------------------------------------]]
+function Rock:IterateObjectMixins(object)
+ if type(object) ~= "table" then
+ error(("Bad argument #2 to `IterateObjectMixins'. Expected %q, got %q."):format("table", type(object)), 2)
+ end
+ return iter, object, nil
+end
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ table - the object to check
+ string - the mixin to check
+Returns:
+ boolean - whether the object has the given mixin embedded into it.
+Example:
+ local LibMonkey = Rock:NewLibrary("LibMonkey-1.0")
+ local Darwin = Rock:NewAddon("Darwin", "LibMonkey-1.0")
+ assert(Rock:DoesObjectUseMixin(Darwin, "LibMonkey-1.0"))
+-----------------------------------------------------------------------------]]
+function Rock:DoesObjectUseMixin(object, mixinName)
+ if type(object) ~= "table" then
+ error(("Bad argument #2 to `IterateObjectMixins'. Expected %q, got %q."):format("table", type(object)), 2)
+ end
+ local mixin
+ if type(mixinName) == "table" then
+ mixin = mixinName
+ else
+ if type(mixinName) ~= "string" then
+ error(("Bad argument #3 to `IterateMiDoesObjectUseMixininObjects'. Expected %q or %q, got %q."):format("table", "string", type(mixinName)), 2)
+ end
+ mixin = libraries[mixinName]
+ end
+ if not mixin then
+ return false
+ end
+
+ local mixinToObject_mixin = mixinToObject[mixin]
+ if not mixinToObject_mixin then
+ return false
+ end
+ return not not mixinToObject_mixin[object]
+end
+
+Rock.UID_NUM = oldRock and oldRock.UID_NUM or 0
+--[[---------------------------------------------------------------------------
+Notes:
+ * This UID is not unique across sessions. If you save a UID in a saved variable, the same UID can be generated in another session.
+Returns:
+ number - a unique number.
+Example:
+ local UID = Rock:GetUID()
+-----------------------------------------------------------------------------]]
+function Rock:GetUID()
+ local num = Rock.UID_NUM + 1
+ Rock.UID_NUM = num
+ return num
+end
+
+local function unobfuscateEmail(email)
+ return email:gsub(" AT ", "@"):gsub(" DOT ", ".")
+end
+local function fix(char)
+ return ("%%%02x"):format(char:byte())
+end
+local function urlencode(text)
+ return text:gsub("[^0-9A-Za-z]", fix)
+end
+
+local url
+local function makeURLFrame()
+ makeURLFrame = nil
+ local function bumpFrameLevels(frame, amount)
+ frame:SetFrameLevel(frame:GetFrameLevel()+amount)
+ local children = newList(frame:GetChildren())
+ for _,v in ipairs(children) do
+ bumpFrameLevels(v, amount)
+ end
+ children = del(children)
+ end
+ -- some code borrowed from Prat here
+ StaticPopupDialogs["ROCK_SHOW_URL"] = {
+ text = not IsMacClient() and L["Press Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar."] or L["Press Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar."],
+ button2 = ACCEPT,
+ hasEditBox = 1,
+ hasWideEditBox = 1,
+ showAlert = 1, -- HACK : it's the only way I found to make de StaticPopup have sufficient width to show WideEditBox :(
+
+ OnShow = function()
+ local editBox = _G[self:GetName() .. "WideEditBox"]
+ editBox:SetText(url)
+ editBox:SetFocus()
+ editBox:HighlightText(0)
+ editBox:SetScript("OnTextChanged", function(...) StaticPopup_EditBoxOnTextChanged(...) end)
+
+ local button = _G[self:GetName() .. "Button2"]
+ button:ClearAllPoints()
+ button:SetWidth(200)
+ button:SetPoint("CENTER", editBox, "CENTER", 0, -30)
+
+ _G[self:GetName() .. "AlertIcon"]:Hide() -- HACK : we hide the false AlertIcon
+ self:SetFrameStrata("FULLSCREEN_DIALOG")
+ bumpFrameLevels(self, 30)
+ end,
+ OnHide = function()
+ local editBox = _G[self:GetName() .. "WideEditBox"]
+ editBox:SetScript("OnTextChanged", nil)
+ self:SetFrameStrata("DIALOG")
+ bumpFrameLevels(self, -30)
+ end,
+ OnAccept = function() end,
+ OnCancel = function() end,
+ EditBoxOnEscapePressed = function() self:GetParent():Hide() end,
+ EditBoxOnTextChanged = function()
+ self:SetText(url)
+ self:SetFocus()
+ self:HighlightText(0)
+ end,
+ timeout = 0,
+ whileDead = 1,
+ hideOnEscape = 1
+ }
+end
+
+function OpenDonationFrame(this)
+ if makeURLFrame then
+ makeURLFrame()
+ end
+
+ local donate = this.donate
+ if type(donate) ~= "string" then
+ donate = "Wowace"
+ end
+ local style, data = (":"):split(donate, 2)
+ style = style:lower()
+ if style ~= "website" and style ~= "paypal" then
+ style = "wowace"
+ end
+ if style == "wowace" then
+ url = "http://www.wowace.com/wiki/Donations"
+ elseif style == "website" then
+ url = data
+ else -- PayPal
+ local text = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" .. urlencode(unobfuscateEmail(data))
+ local name
+ if type(this.title) == "string" then
+ name = this.title
+ elseif type(this.name) == "string" then
+ name = this.name
+ end
+ if name == MAJOR_VERSION then
+ name = "Rock"
+ end
+ if name then
+ name = name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "")
+ text = text .. "&item_name=" .. urlencode(name)
+ end
+ url = text
+ end
+
+ StaticPopup_Show("ROCK_SHOW_URL")
+end
+function OpenIssueFrame(this)
+ if makeURLFrame then
+ makeURLFrame()
+ end
+
+ local issueTracker = this.issueTracker
+ if type(issueTracker) ~= "string" then
+ return
+ end
+ local style, data = (":"):split(issueTracker, 2)
+ style = style:lower()
+ if style ~= "website" and style ~= "wowace" then
+ return
+ end
+ if style == "wowace" then
+ url = "http://jira.wowace.com/secure/CreateIssue.jspa?pid=" .. data
+ elseif style == "website" then
+ url = data
+ end
+
+ StaticPopup_Show("ROCK_SHOW_URL")
+end
+local function donate_hidden(addon)
+ return type(addon.donate) ~= "string"
+end
+
+local function issue_hidden(addon)
+ return type(addon.issueTracker) ~= "string"
+end
+
+-- #NODOC
+function Rock:GetRockConfigOptions(addon)
+ return 'active', {
+ type = 'boolean',
+ name = L["Enabled"],
+ desc = L["Enable or disable this addon."],
+ get = 'IsActive',
+ set = 'ToggleActive',
+ handler = addon,
+ order = -1,
+ }, 'donate', {
+ type = 'execute',
+ name = L["Give donation"],
+ buttonText = L["Donate"],
+ desc = L["Give a much-needed donation to the author of this addon."],
+ func = OpenDonationFrame,
+ hidden = donate_hidden,
+ passValue = addon,
+ order = -2,
+ }, 'issue', {
+ type = 'execute',
+ name = L["File issue"],
+ buttonText = L["Report"],
+ desc = L["File a bug or request a new feature or an improvement to this addon."],
+ func = OpenIssueFrame,
+ hidden = issue_hidden,
+ passValue = addon,
+ order = -3,
+ }
+end
+
+local function initAddon(addon, name)
+ name = addonToFolder[addon] or name or ""
+ -- TOC checks
+ if addon.title == nil then
+ addon.title = GetAddOnMetadata(name, "Title")
+ end
+ if type(addon.title) == "string" then
+ addon.title = addon.title:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):gsub("%-Rock%-$", ""):trim()
+ end
+ if addon.notes == nil then
+ addon.notes = GetAddOnMetadata(name, "Notes")
+ end
+ if type(addon.notes) == "string" then
+ addon.notes = addon.notes:trim()
+ end
+ if addon.version == nil then
+ addon.version = GetAddOnMetadata(name, "Version")
+ end
+ if type(addon.version) == "string" then
+ addon.version = addon.version:trim()
+ end
+ if addon.author == nil then
+ addon.author = GetAddOnMetadata(name, "Author")
+ end
+ if type(addon.author) == "string" then
+ addon.author = addon.author:trim()
+ end
+ if addon.credits == nil then
+ addon.credits = GetAddOnMetadata(name, "X-Credits")
+ end
+ if type(addon.credits) == "string" then
+ addon.credits = addon.credits:trim()
+ end
+ if addon.donate == nil then
+ addon.donate = GetAddOnMetadata(name, "X-Donate")
+ end
+ if type(addon.donate) == "string" then
+ addon.donate = addon.donate:trim()
+ end
+ if addon.issueTracker == nil then
+ addon.issueTracker = GetAddOnMetadata(name, "X-IssueTracker")
+ end
+ if type(addon.issueTracker) == "string" then
+ addon.issueTracker = addon.issueTracker:trim()
+ end
+ if addon.category == nil then
+ addon.category = GetAddOnMetadata(name, "X-Category")
+ end
+ if type(addon.category) == "string" then
+ addon.category = addon.category:trim()
+ end
+ if addon.email == nil then
+ addon.email = GetAddOnMetadata(name, "X-eMail") or GetAddOnMetadata(name, "X-Email")
+ end
+ if type(addon.email) == "string" then
+ addon.email = addon.email:trim()
+ end
+ if addon.license == nil then
+ addon.license = GetAddOnMetadata(name, "X-License")
+ end
+ if type(addon.license) == "string" then
+ addon.license = addon.license:trim()
+ end
+ if addon.website == nil then
+ addon.website = GetAddOnMetadata(name, "X-Website")
+ end
+ if type(addon.website) == "string" then
+ addon.website = addon.website:trim()
+ end
+
+ for mixin in Rock:IterateObjectMixins(addon) do
+ local mixin_OnEmbedInitialize = mixin.OnEmbedInitialize
+ if mixin_OnEmbedInitialize then
+ local success, ret = pcall(mixin_OnEmbedInitialize, mixin, addon)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+ end
+
+ local addon_OnInitialize = addon.OnInitialize
+ if addon_OnInitialize then
+ local success, ret = pcall(addon_OnInitialize, addon)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+
+ if LibRockEvent then
+ Rock:DispatchEvent("AddonInitialized", addon)
+ end
+end
+
+
+local function manualEnable(addon)
+ for i,v in ipairs(pendingAddons) do
+ if v == addon then
+ return
+ end
+ end
+ if currentlyEnabledAddons[addon] then
+ return false
+ end
+ currentlyEnabledAddons[addon] = true
+
+ local first = not addonsAlreadyEnabled[addon]
+ addonsAlreadyEnabled[addon] = true
+
+ for mixin in Rock:IterateObjectMixins(addon) do
+ local mixin_OnEmbedEnable = mixin.OnEmbedEnable
+ if mixin_OnEmbedEnable then
+ local success, ret = pcall(mixin_OnEmbedEnable, mixin, addon, first)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+ end
+ local addon_OnEnable = addon.OnEnable
+ if addon_OnEnable then
+ local success, ret = pcall(addon_OnEnable, addon, first)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+
+ if LibRockEvent then
+ Rock:DispatchEvent("AddonEnabled", addon, first)
+ end
+
+ return true, first
+end
+
+local function manualDisable(addon)
+ if not currentlyEnabledAddons[addon] then
+ return false
+ end
+ currentlyEnabledAddons[addon] = nil
+
+ for mixin in Rock:IterateObjectMixins(addon) do
+ local mixin_OnEmbedDisable = mixin.OnEmbedDisable
+ if mixin_OnEmbedDisable then
+ local success, ret = pcall(mixin_OnEmbedDisable, mixin, addon)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+ end
+ local addon_OnDisable = addon.OnDisable
+ if addon_OnDisable then
+ local success, ret = pcall(addon_OnDisable, addon)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+
+ if LibRockEvent then
+ Rock:DispatchEvent("AddonDisabled", addon)
+ end
+ return true
+end
+
+local function enableAddon(addon)
+ for i,v in ipairs(pendingAddons) do
+ if v == addon then
+ return
+ end
+ end
+ if addon_mt___index.IsActive(addon) then
+ manualEnable(addon)
+ end
+end
+
+-- #NODOC
+-- This is used by internal Rock libraries after updating the active state.
+function Rock:RecheckEnabledStates()
+ local changed = false
+ for _,addon in pairs(addons) do
+ local good = true
+ for _,a in ipairs(pendingAddonsEnable) do
+ if addon == a then
+ good = false
+ break
+ end
+ end
+ if good then
+ if addon_mt___index.IsActive(addon) then
+ if manualEnable(addon) then
+ changed = true
+ end
+ else
+ if manualDisable(addon) then
+ changed = true
+ end
+ end
+ end
+ end
+ if changed then
+ return self:RecheckEnabledStates()
+ end
+end
+
+frame:UnregisterAllEvents()
+frame:RegisterEvent("ADDON_LOADED")
+frame:RegisterEvent("PLAYER_LOGIN")
+local function runMainAddonLoadedChunk(name)
+ local tmp = newList()
+ tmp, pendingAddons = pendingAddons, tmp
+ for i, addon in ipairs(tmp) do
+ local folder = addonToFolder[addon]
+ if name and folder and not foldersLoaded[folder] then
+ for j = i, #tmp do
+ pendingAddons[#pendingAddons+1] = tmp[j]
+ tmp[j] = nil
+ end
+ break
+ end
+ initAddon(addon, name)
+ end
+
+ if IsLoggedIn() then
+ for i, addon in ipairs(tmp) do
+ for j, v in ipairs(pendingAddonsEnable) do
+ if v == addon then
+ table_remove(pendingAddonsEnable, i)
+ break
+ end
+ end
+ enableAddon(addon)
+ end
+ for i, addon in ipairs(pendingAddonsEnable) do
+ local good = true
+ for j, v in ipairs(pendingAddons) do
+ if v == addon then
+ good = false
+ break
+ end
+ end
+ if not good then
+ break
+ end
+ pendingAddonsEnable[i] = nil
+ enableAddon(addon)
+ end
+ end
+ tmp = del(tmp)
+ for library, addonName in pairs(pendingLibraries) do
+ if not name or foldersLoaded[addonName] then
+ local success, ret = pcall(error, ("Library %q not finalized before ADDON_LOADED."):format(better_tostring(library)), 3)
+ geterrorhandler()(ret)
+ Rock:FinalizeLibrary((library:GetLibraryVersion()))
+ end
+ end
+
+ if isStandalone then
+ local LibRock_1_0DB = _G.LibRock_1_0DB
+ if type(LibRock_1_0DB) ~= "table" then
+ LibRock_1_0DB = {}
+ _G.LibRock_1_0DB = LibRock_1_0DB
+ end
+ if type(LibRock_1_0DB.unitTests) ~= "table" then
+ LibRock_1_0DB.unitTests = {}
+ end
+ enableContracts = LibRock_1_0DB.contracts or false
+ unitTestDB = LibRock_1_0DB.unitTests
+ for namespace, data in pairs(unitTests) do
+ if not unitTestDB[namespace] then
+ if data then
+ del(data)
+ unitTests[namespace] = false
+ end
+ elseif data and (not name or data.addon == name) then
+ local stats = newList()
+ for i,v in ipairs(data) do
+ data[i] = nil
+
+ local libs = newList()
+ for k,v in pairs(libraries) do
+ libs[k] = v
+ end
+
+ local success, ret = pcall(v)
+ if not success then
+ geterrorhandler()(ret)
+ stats[i] = ret
+ else
+ stats[i] = false
+ end
+
+ for k in pairs(libraries) do
+ if not libs[k] then
+ __removeLibrary(k)
+ end
+ end
+ libs = del(libs)
+ end
+ del(data)
+ unitTests[namespace] = false
+ if #stats >= 1 then
+ local pass, fail = 0, 0
+ for i,v in ipairs(stats) do
+ if v then
+ fail = fail + 1
+ else
+ pass = pass + 1
+ end
+ end
+
+ local color
+ if fail == 0 then
+ _G.DEFAULT_CHAT_FRAME:AddMessage(("|cff00ff00%s: %d unit test(s) passed."):format(namespace, pass))
+ elseif pass > 0 then
+ _G.DEFAULT_CHAT_FRAME:AddMessage(("|cffff0000%s: %d unit test(s) passed, %d unit test(s) failed."):format(namespace, pass, fail))
+ else
+ _G.DEFAULT_CHAT_FRAME:AddMessage(("|cffff0000%s: %d unit test(s) failed."):format(namespace, fail))
+ end
+ for i,v in ipairs(stats) do
+ if v then
+ _G.DEFAULT_CHAT_FRAME:AddMessage(("|cffff0000%s|r"):format(tostring(v)))
+ end
+ end
+ if fail > 0 then
+ _G.DEFAULT_CHAT_FRAME:AddMessage("|cffff0000----------|r")
+ end
+ end
+ stats = del(stats)
+ end
+ end
+ end
+ if isStandalone and name == MAJOR_VERSION then
+ Rock("LibRockEvent-1.0", false, true) -- load if possible
+ Rock("LibRockConsole-1.0", false, true) -- load if possible - I like the default chat commands
+ Rock("LibRockComm-1.0", false, true) -- load if possible - has version checking and the like
+ Rock("LibRockConfig-1.0", false, true) -- load if possible - LibRock-1.0 registers with it.
+ end
+
+ for major, library in LibStub:IterateLibraries() do
+ manualFinalize(major, library)
+ end
+
+end
+
+frame:Show()
+frame:SetScript("OnUpdate", function(this, elapsed)
+ -- capture all un-initialized addons.
+ runMainAddonLoadedChunk()
+ this:SetScript("OnUpdate", nil)
+end)
+frame:SetScript("OnEvent", function(this, event, ...)
+ if event == "ADDON_LOADED" then
+ -- this creates a new table and flushes the old in case someone LoDs an addon inside ADDON_LOADED.
+ local name = ...
+ foldersLoaded[name] = true
+ runMainAddonLoadedChunk(name)
+ frame:Show()
+ elseif event == "PLAYER_LOGIN" then
+ for i, addon in ipairs(pendingAddonsEnable) do
+ local good = true
+ for _, a in ipairs(pendingAddons) do
+ if a == addon then
+ good = false
+ break
+ end
+ end
+ if good then
+ pendingAddonsEnable[i] = nil
+ enableAddon(addon)
+ end
+ end
+ end
+end)
+
+Rock:SetExportedMethods("SetExportedMethods", "Embed", "Unembed", "GetLibraryVersion")
+
+Rock:FinalizeLibrary(MAJOR_VERSION)
+
+for major, library in LibStub:IterateLibraries() do
+ manualFinalize(major, library)
+end
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- test recycling
+ local newList, newDict, newSet, del = Rock:GetRecyclingFunctions(MAJOR_VERSION .. "_UnitTest", "newList", "newDict", "newSet", "del", "Debug")
+ local t = newList("Alpha", "Bravo", "Charlie")
+ assert(t[1] == "Alpha")
+ assert(t[2] == "Bravo")
+ assert(t[3] == "Charlie")
+ t = del(t)
+ t = newList("Alpha", "Bravo", "Charlie")
+ -- check recycled table
+ assert(t[1] == "Alpha")
+ assert(t[2] == "Bravo")
+ assert(t[3] == "Charlie")
+ t = del(t)
+ t = newDict("Alpha", "Bravo", "Charlie", "Delta")
+ assert(t.Alpha == "Bravo")
+ assert(t.Charlie == "Delta")
+ t = del(t)
+ t = newSet("Alpha", "Bravo", "Charlie")
+ assert(t.Alpha)
+ assert(t.Bravo)
+ assert(t.Charlie)
+ t = del(t)
+
+ local debug = recycleData.debugPools[MAJOR_VERSION .. "_UnitTest"]
+ assert(debug.num == 0)
+ t = newList()
+ assert(debug.num == 1)
+ t[1] = newList()
+ assert(debug.num == 2)
+ t[2] = newList()
+ assert(debug.num == 3)
+ t[1] = del(t[1])
+ assert(debug.num == 2)
+ t[2] = del(t[2])
+ assert(debug.num == 1)
+ t = del(t)
+ assert(debug.num == 0)
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- test :GetUID()
+ local t = {}
+ for i = 1, 10000 do
+ local uid = Rock:GetUID()
+ if t[i] then
+ error(("UID match for iteration %d, UID %s"):format(i, uid))
+ end
+ t[i] = true
+ end
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- test basic creation and deletion
+ assert(not LibStub:GetLibrary("LibRockFakeLib-1.0", true))
+ assert(not Rock:HasLibrary("LibRockFakeLib-1.0"))
+ local lib = Rock:NewLibrary("LibRockFakeLib-1.0", 1)
+ Rock:FinalizeLibrary("LibRockFakeLib-1.0")
+ lib = nil
+ assert(LibStub:GetLibrary("LibRockFakeLib-1.0", true))
+ assert(Rock:HasLibrary("LibRockFakeLib-1.0"))
+ local good = false
+ for _, lib in pairs(libraries) do
+ if lib.name == "LibRockFakeLib-1.0" then
+ good = true
+ break
+ end
+ end
+ assert(good)
+ __removeLibrary("LibRockFakeLib-1.0")
+ for _, lib in pairs(libraries) do
+ assert(lib.name ~= "LibRockFakeLib-1.0")
+ end
+ assert(not LibStub:GetLibrary("LibRockFakeLib-1.0", true))
+ assert(not Rock:HasLibrary("LibRockFakeLib-1.0"))
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- test library creation and the like
+ assert(not Rock:HasLibrary("LibRockFakeLib-1.0"))
+ for name in Rock:IterateLibraries() do
+ assert(name ~= "LibRockFakeLib-1.0")
+ end
+
+ local myLib, oldLib = Rock:NewLibrary("LibRockFakeLib-1.0", 1)
+ assert(myLib)
+ assert(myLib.name == "LibRockFakeLib-1.0")
+ assert(not oldLib)
+
+ assert(myLib:GetLibraryVersion() == "LibRockFakeLib-1.0")
+ assert(select(2, myLib:GetLibraryVersion()) == 1)
+
+ local good = false
+ for name in Rock:IterateLibraries() do
+ if name == "LibRockFakeLib-1.0" then
+ good = true
+ break
+ end
+ end
+ assert(good)
+ assert(Rock:HasLibrary("LibRockFakeLib-1.0"))
+ assert(Rock:GetLibrary("LibRockFakeLib-1.0") == myLib)
+ assert(Rock("LibRockFakeLib-1.0") == myLib)
+
+ assert(not Rock:IsLibraryMixin("LibRockFakeLib-1.0"))
+ function myLib:DoSomething()
+ return "Something"
+ end
+ myLib:SetExportedMethods("DoSomething")
+ assert(Rock:IsLibraryMixin("LibRockFakeLib-1.0"))
+ local t = {}
+ assert(not Rock:DoesObjectUseMixin(t, "LibRockFakeLib-1.0"))
+ assert(not t.DoSomething)
+ for mixin in Rock:IterateObjectMixins(t) do
+ assert(false)
+ end
+ for object in Rock:IterateMixinObjects("LibRockFakeLib-1.0") do
+ assert(false)
+ end
+ myLib:Embed(t)
+ assert(t:DoSomething() == "Something")
+ assert(Rock:DoesObjectUseMixin(t, "LibRockFakeLib-1.0"))
+ for mixin in Rock:IterateObjectMixins(t) do
+ assert(mixin == myLib)
+ end
+ for object in Rock:IterateMixinObjects("LibRockFakeLib-1.0") do
+ assert(object == t)
+ end
+
+ Rock:FinalizeLibrary("LibRockFakeLib-1.0")
+
+ local myNewLib, oldLib = Rock:NewLibrary("LibRockFakeLib-1.0", 2)
+ assert(myNewLib == myLib)
+ assert(oldLib)
+ assert(Rock:GetLibrary("LibRockFakeLib-1.0") == myLib)
+
+ function myLib:DoSomething()
+ return "Something else"
+ end
+ function myLib:TrySomething()
+ return "Blah"
+ end
+ myLib:SetExportedMethods("DoSomething", "TrySomething")
+ assert(Rock:IsLibraryMixin("LibRockFakeLib-1.0"))
+ assert(t:DoSomething() == "Something else")
+ assert(t:TrySomething() == "Blah")
+ assert(Rock:DoesObjectUseMixin(t, "LibRockFakeLib-1.0"))
+ for mixin in Rock:IterateObjectMixins(t) do
+ assert(mixin == myLib)
+ end
+ for object in Rock:IterateMixinObjects("LibRockFakeLib-1.0") do
+ assert(object == t)
+ end
+
+ Rock:FinalizeLibrary("LibRockFakeLib-1.0")
+
+ local myNewLib, oldLib = Rock:NewLibrary("LibRockFakeLib-1.0", 3)
+ assert(myNewLib == myLib)
+ assert(oldLib)
+ assert(Rock:GetLibrary("LibRockFakeLib-1.0") == myLib)
+
+ function myLib:DoSomething()
+ return "Something"
+ end
+ myLib:SetExportedMethods("DoSomething")
+ assert(Rock:IsLibraryMixin("LibRockFakeLib-1.0"))
+ assert(t:DoSomething() == "Something")
+ assert(t.TrySomething == nil)
+ assert(Rock:DoesObjectUseMixin(t, "LibRockFakeLib-1.0"))
+ for mixin in Rock:IterateObjectMixins(t) do
+ assert(mixin == myLib)
+ end
+ for object in Rock:IterateMixinObjects("LibRockFakeLib-1.0") do
+ assert(object == t)
+ end
+
+ Rock:FinalizeLibrary("LibRockFakeLib-1.0")
+
+ assert(not Rock:NewLibrary("LibRockFakeLib-1.0", 2)) -- out of date
+ assert(not Rock:NewLibrary("LibRockFakeLib-1.0", 3)) -- same revision
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ assert(not Rock:HasAddon("RockFakeAddon"))
+ for name in Rock:IterateAddons() do
+ assert(name ~= "RockFakeAddon")
+ end
+
+ local myAddon = Rock:NewAddon("RockFakeAddon")
+
+ assert(myAddon)
+ assert(myAddon.name == "RockFakeAddon")
+
+ local good = false
+ for name in Rock:IterateAddons() do
+ if name == "RockFakeAddon" then
+ good = true
+ break
+ end
+ end
+ assert(good)
+ assert(Rock:HasAddon("RockFakeAddon"))
+ assert(Rock:GetAddon("RockFakeAddon") == myAddon)
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- test :OnLibraryLoad
+ local lib = Rock:NewLibrary("LibRockFakeLib-1.0", 1)
+ local triggered = false
+ function lib:OnLibraryLoad(major, instance)
+ if major == "LibRockFakeLib-2.0" then
+ triggered = true
+ end
+ end
+ Rock:FinalizeLibrary("LibRockFakeLib-1.0")
+
+ local lib = Rock:NewLibrary("LibRockFakeLib-2.0", 1)
+ assert(not triggered)
+ Rock:FinalizeLibrary("LibRockFakeLib-2.0")
+ assert(triggered)
+ triggered = false
+ local lib = Rock:NewLibrary("LibRockFakeLib-2.0", 2)
+ assert(not triggered)
+ Rock:FinalizeLibrary("LibRockFakeLib-2.0")
+ assert(not triggered)
+end)
diff --git a/FuBar/libs/LibRock-1.0/LibRock-1.0.toc b/FuBar/libs/LibRock-1.0/LibRock-1.0.toc
new file mode 100644
index 0000000..7b10de7
--- /dev/null
+++ b/FuBar/libs/LibRock-1.0/LibRock-1.0.toc
@@ -0,0 +1,17 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r298
+## X-Curse-Project-Name: LibRock-1.0
+## X-Curse-Project-ID: librock-1-0
+## X-Curse-Repository-ID: wow/librock-1-0/mainline
+
+## Title: Lib: Rock-1.0
+## Notes: AddOn development framework
+## Author: ckknight
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-Donate: Paypal:ckknight AT gmail DOT com
+## X-eMail: ckknight AT gmail DOT com
+## SavedVariables: LibRock_1_0DB
+## OptionalDeps: !BugGrabber, !Swatter
+
+lib.xml
diff --git a/FuBar/libs/LibRock-1.0/LibStub/LibStub.lua b/FuBar/libs/LibRock-1.0/LibStub/LibStub.lua
new file mode 100644
index 0000000..cfc97de
--- /dev/null
+++ b/FuBar/libs/LibRock-1.0/LibStub/LibStub.lua
@@ -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
diff --git a/FuBar/libs/LibRock-1.0/lib.xml b/FuBar/libs/LibRock-1.0/lib.xml
new file mode 100644
index 0000000..482eddc
--- /dev/null
+++ b/FuBar/libs/LibRock-1.0/lib.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/FuBar/libs/LibRockConfig-1.0/LibRockConfig-1.0.lua b/FuBar/libs/LibRockConfig-1.0/LibRockConfig-1.0.lua
new file mode 100644
index 0000000..9ad23d1
--- /dev/null
+++ b/FuBar/libs/LibRockConfig-1.0/LibRockConfig-1.0.lua
@@ -0,0 +1,7831 @@
+--[[
+Name: LibRockConfig-1.0
+Revision: $Rev: 401 $
+Developed by: ckknight (ckknight@gmail.com)
+Credits: Nargiddley, inspiration and some code taken from Waterfall-1.0
+Website: http://www.wowace.com/
+Description: Library to allow for easy configuration.
+Dependencies: LibRock-1.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "LibRockConfig-1.0"
+local MINOR_VERSION = tonumber(("$Revision: 401 $"):match("(%d+)")) + 90000
+
+if not Rock then error(MAJOR_VERSION .. " requires LibRock-1.0") end
+
+local RockConfig, oldLib = Rock:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
+if not RockConfig then
+ return
+end
+
+local WotLK = not not ToggleAchievementFrame
+
+local SET_NORMAL_FONT_OBJECT = WotLK and "SetNormalFontObject" or "SetTextFontObject"
+
+local KEY_BUTTON1 = "Left Mouse"
+local KEY_BUTTON2 = "Right Mouse"
+local KEYBINDING_COLON = "Keybinding: "
+local ADDON_PREFERENCES = "Addon Preferences"
+local FUBAR_OPTIONS = "FuBar options"
+local USAGE_COLON = "Usage: "
+local SHOW_MINIMAP_ICON = "Show minimap icon"
+local SHOW_MINIMAP_ICON_DESC = "Whether to show the minimap icon or not."
+local SCALE = "Scale"
+local SCALE_DESC = "Set the scale of the preferences window."
+local COPY = "Copy"
+local PASTE = "Paste"
+local SAVE = "Save"
+local FADEOUT_TRANSPARENCY = "Fadeout transparency"
+local FADEOUT_TRANSPARENCY_DESC = "The transparency for when your mouse is not over the preferences window."
+local FADEIN_TRANSPARENCY = "Fadein transparency"
+local FADEIN_TRANSPARENCY_DESC = "The transparency for when your mouse is over the preferences window."
+local HIDE_IN_COMBAT = "Hide in combat"
+local HIDE_IN_COMBAT_DESC = "Hide preferences window in combat and prevent misclicks in "
+if GetLocale() == "deDE" then
+ KEY_BUTTON1 = "Linke Maustaste"
+ KEY_BUTTON2 = "Rechte Maustaste"
+elseif GetLocale() == "koKR" then
+ KEY_BUTTON1 = "왼쪽 마우스"
+ KEY_BUTTON2 = "오른쪽 마우스"
+ KEYBINDING_COLON = "단축키: "
+ ADDON_PREFERENCES = "애드온 선택"
+ FUBAR_OPTIONS = "FuBar 옵션"
+ USAGE_COLON = "명령어: "
+ SHOW_MINIMAP_ICON = "미니맵 아이콘 표시"
+ SHOW_MINIMAP_ICON_DESC = "미니맵 아이콘을 표시하거나 숨김니다."
+ SCALE = "크기"
+ SCALE_DESC = "선택 창의 크기를 설정합니다."
+ COPY = "복사"
+ PASTE = "붙여넣기"
+ FADEOUT_TRANSPARENCY = "사라짐 투명도"
+ FADEOUT_TRANSPARENCY_DESC = "당신의 마우스가 선택 창 위에 있지 않을때의 투명도를 설정합니다."
+ FADEIN_TRANSPARENCY = "밝아짐 투명도"
+ FADEIN_TRANSPARENCY_DESC = "당신의 마우스가 선택 창 위에 있을때의 투명도를 설정합니다."
+ HIDE_IN_COMBAT = "전투중 숨김"
+ HIDE_IN_COMBAT_DESC = "전투중 선택 창을 숨겨 클릭실수를 방지합니다."
+elseif GetLocale() == "frFR" then
+ KEY_BUTTON1 = "Clic gauche"
+ KEY_BUTTON2 = "Clic droit"
+ KEYBINDING_COLON = "Raccourci : "
+ ADDON_PREFERENCES = "Préférences"
+ FUBAR_OPTIONS = "Options FuBar"
+ USAGE_COLON = "Utilisation : "
+ SHOW_MINIMAP_ICON = "Afficher l'icône sur la minicarte"
+ SHOW_MINIMAP_ICON_DESC = "Affiche ou cache l'icône sur la minicarte."
+ SCALE = "Échelle"
+ SCALE_DESC = "Modifie l'échelle de la fenêtre de configuration."
+ COPY = "Copier"
+ PASTE = "Coller"
+ FADEOUT_TRANSPARENCY = "Transparence de fenêtre inactive"
+ FADEOUT_TRANSPARENCY_DESC = "La transparence de la fenêtre lorsque votre souris ne la survole pas."
+ FADEIN_TRANSPARENCY = "Transparence de fenêtre active"
+ FADEIN_TRANSPARENCY_DESC = "La transparence de la fenêtre lorsque votre souris la survole."
+ HIDE_IN_COMBAT = "Masquer en combat"
+ HIDE_IN_COMBAT_DESC = "Masque la fenêtre des préférences en combat afin d'éviter les fausses manœuvres."
+elseif GetLocale() == "esES" then
+ KEY_BUTTON1 = "Clic Izquierdo"
+ KEY_BUTTON2 = "Clic Derecho"
+elseif GetLocale() == "zhTW" then
+ --*******************************
+ -- zhTW Chinses Traditional localiation
+ -- 2007/Oct/8 addded huge zhTW updates
+ -- by 蕾艾莎塔@奧妮克希亞
+ --*******************************
+
+ KEY_BUTTON1 = "滑鼠左鍵"
+ KEY_BUTTON2 = "滑鼠右鍵"
+ KEYBINDING_COLON = "快捷鍵設定: "
+ ADDON_PREFERENCES = "插件設定"
+ FUBAR_OPTIONS = "FuBar 選項"
+ USAGE_COLON = "用法: "
+ SHOW_MINIMAP_ICON = "顯示小地圖圖示"
+ SHOW_MINIMAP_ICON_DESC = "是否顯示小地圖邊的圖示。"
+ SCALE = "縮放"
+ SCALE_DESC = "調整設定視窗的縮放比例。"
+ COPY = "複製"
+ PASTE = "貼上"
+ SAVE = "儲存"
+ FADEOUT_TRANSPARENCY = "移出時透明度"
+ FADEOUT_TRANSPARENCY_DESC = "當你的游標不在設定視窗上時的透明度。"
+ FADEIN_TRANSPARENCY = "移入時透明度"
+ FADEIN_TRANSPARENCY_DESC = "當你的游標在設定視窗上時的透明度。"
+ HIDE_IN_COMBAT = "戰鬥中隱藏"
+ HIDE_IN_COMBAT_DESC = "進入戰鬥時隱藏設定視窗,避免誤按。"
+elseif GetLocale() == "zhCN" then
+ KEY_BUTTON1 = "鼠标左键"
+ KEY_BUTTON2 = "鼠标右键"
+
+ KEYBINDING_COLON = "按键绑定: "
+ ADDON_PREFERENCES = "插件参数"
+ FUBAR_OPTIONS = "FuBar 选项"
+ USAGE_COLON = "用法: "
+ SHOW_MINIMAP_ICON = "显示小地图图标"
+ SHOW_MINIMAP_ICON_DESC = "选择是否显示小地图按钮。"
+ SCALE = "缩放"
+ SCALE_DESC = "设置参数窗口的缩放。"
+ COPY = "复制"
+ PASTE = "粘贴"
+ FADEOUT_TRANSPARENCY = "移出时透明度"
+ FADEOUT_TRANSPARENCY_DESC = "当你的鼠标移出参数窗口时的透明度。"
+ FADEIN_TRANSPARENCY = "移入时透明度"
+ FADEIN_TRANSPARENCY_DESC = "当你的鼠标移入参数窗口时的透明度。"
+ HIDE_IN_COMBAT = "战斗中隐藏"
+ HIDE_IN_COMBAT_DESC = "进入战斗时隐藏设置窗口以避免错误点击"
+end
+
+--[[---------------------------------------------------------------------------
+== LibRockConfig-1.0 table documentation ==
+
+=== Miscellaneous notes ===
+* Ordering
+** -1 is the very last value, -2 comes before that, -10000 comes before that, and 10000 comes before that.
+** 1 is the very first value, 2 comes after that, 10000 comes after that, and -10000 comes after that.
+** An order of 0 is an error.
+** If two orders are equal, then they should be sorted alphabetically.
+* If you provide method names, you can use "~IsGood" instead of function() return not self:IsGood() end.
+* If any function or method returns "@dict", "@list", or "@set", followed by a tuple, it will automatically turn the tuple into the proper table type (a dict, list, or set), which will later be automatically recycled.
+==== Fields for all types ====
+; name ''Note: this should be a few words describing the option in "Sentence case", not in "Title Case".''
+: string - name of the option
+: function - function which returns the name
+; desc ''Note: this should be a full sentence in "Sentence case".''
+: string - description of the option
+: function - function which returns the description
+; [handler]
+: nil - inherit from the parent option's handler if possible, otherwise inherit from the object which registered it.
+: table - object on which to call methods
+; [disabled]
+: nil or false - enabled (default)
+: true - the option is disabled.
+: function - function which returns a boolean, stating whether the option is disabled.
+: string - method name which returns a boolean, stating whether the option is disabled.
+; [hidden]
+: nil or false - shown (default)
+: true - the option is hidden.
+: function - function which returns a boolean, stating whether the option is hidden.
+: string - method name which returns a boolean, stating whether the option is hidden.
+; [order]
+: nil - order of 100. (default)
+: number - the order of the option
+: function - function which returns a number.
+: string - method name which returns a number.
+; [icon]
+: nil - no icon. (default)
+: string - path to the icon.
+: function - function which returns the path to the icon.
+; [iconSize]
+: nil - 100%. (default)
+: number - size of the icon as a percentage, e.g. 0.5 is 50%, 2 is 200%.
+: string - method name which returns the size of the icon.
+: function - function which returns the size of the icon.
+; [passValue]
+: nil - don't pass any values
+: value - pass the given value to any functions/methods belonging to the current option.
+; [passValue2]
+: nil - don't pass any more values (only pass the passValue field)
+: value - pass the given value to any functions/methods belonging to the current option.
+; [passValueN] ''Note: Where N is a number from 2-inf.''
+: nil - don't pass any more values (only pass the previous passValue fields)
+: value - pass the given value to any functions/methods belonging to the current option.
+
+=== execute ===
+The execute type acts as a button, there is no state, but merely an action that will occur when it is triggered.
+==== Fields ====
+; func
+: function - function that will be called.
+: string - method name that will be called.
+; buttonText ''Note: this should only be one word or so, e.g. "Click", "Okay", or "Remove". If more than one word, it should be in "Sentence case", not "Title Case".''
+: string - name of the text on the button
+: function - function which returns the text on the button
+; [confirmText] ''Note: this should be a small phrase, specific if possible.
+: nil - no confirmation.
+: string - Add a confirmation message with a checkbox, showing one's desire.
+: function - function that should return the confirmation message.
+==== Example ====
+ {
+ type = 'execute',
+ name = "My button",
+ desc = "Click the button to get a pony!",
+ buttonText = "Pony",
+ func = function()
+ message("You got a pony!")
+ end,
+ confirm = "Are you sure you want a pony?",
+ }
+
+=== number ===
+The number type allows you to select a number between a specific range.
+==== Fields ====
+; get
+: number - the number the value will always be. (not recommended, use a function)
+: function - function that will return a number.
+: string - method name that will return a number.
+; set
+: function - function that will set the value of a number. ''This works in tandem with get, which should return said number.''
+: string - method name that will set the value of a number.
+; [isPercent]
+: nil or false - not a percentage (default)
+: true - the value is a percentage. ''If a value is a percentage, it will show to the user as 100x larger with a percent sign.''
+: function - function that will return whether the value is a percentage.
+: string - method name that will return whether the value is a percentage.
+; [min]
+: nil - 0 (default)
+: number - the minimum value.
+: function - function which returns the minimum value.
+: string - method name which returns the minimum value.
+; [max]
+: nil - 1 (default)
+: number - the maximum value.
+: function - function which returns the maximum value.
+: string - method name which returns the maximum value.
+; [step]
+: nil - (max - min)/100 (default)
+: number - the smallest stepsize between values. ''e.g. from [0, 1] with a step of 0.01 cannot ever have a value of 0.005, it would round up to 0.01.''
+: function - function which returns the step size.
+: string - method name which returns the step size.
+; [bigStep]
+: nil - same as step (default)
+: number - the stepsize when dragging the slider, for a less specific measurement.
+: function - function which returns the larger step size.
+: string - method name which returns the larger step size.
+; [stepBasis]
+: nil - same as min (default)
+: number - the basis for the step movement, so that the base number does not have to be dependent on the minimum value (which may be an odd number).
+: function - function which returns the step basis.
+: string - method name which returns the step basis.
+==== Example ====
+ local num = 0
+ {
+ type = 'number',
+ name = "It's a number!",
+ desc = "A very special number.",
+ get = function()
+ return num
+ end,
+ set = function(value)
+ num = value
+ end,
+ isPercent = true,
+ step = 0.01,
+ bigStep = 0.05,
+ min = 0.01, -- minimum of 1%
+ max = 1, -- maximum of 100%
+ stepBasis = 0.05, -- so that steps go 0.01, 0.05, 0.10, 0.15 instead of 0.01, 0.06, 0.11, 0.16.
+ }
+=== boolean ===
+The boolean type allows you to switch a toggle on and off.
+==== Fields ====
+; get
+: boolean - the boolean the value will always be. (not recommended, use a function)
+: string - can only be "HALF", anything else is an error. Means to show that it is only partially true.
+: function - function that will return a boolean (or "HALF")
+: string - method name that will return a boolean.
+; set
+: function - function that will set the value of a boolean. ''This works in tandem with get, which should return said boolean.''
+: string - method name that will set the value of a boolean.
+
+=== color ===
+The color type allows you to select a color, possibly with alpha.
+==== Fields ====
+; get
+: function - function that will return the value for a color (in format specified by colorType).
+: string - method name that will return the value for a color (in format specified by colorType).
+; set
+: function - function that will set the value of a color (in format specified by colorType). ''This works in tandem with get, which should return said color.''
+: string - method name that will set the value of a color (in format specified by colorType).
+; [hasAlpha]
+: nil or false - only use red, green, and blue, without alpha level.
+: true - only use red, green, blue, and alpha.
+: function - function which returns whether alpha is used.
+: string - method name which returns whether alpha is used.
+; [colorType]
+: nil - use the default (either "tuple" or "tuple:rgba", based on hasAlpha)
+: string - use a specific color type. (see below for the list)
+: function - function which returns a specific color type.
+==== Color types ====
+* Without alpha
+** 'tuple' - values work as an r, g, b tuple, e.g. 1, 0, 0 is red. (default)
+** 'hex' - values work as an "rrggbb" hex string, e.g. "ff0000" is red.
+** 'number' - values work as a serialized number, e.g. 16711680 is red and ("%06x"):format(16711680) == "ff0000".
+* With alpha
+** 'tuple:rgba' - values work as an r, g, b, a tuple, e.g. 1, 0, 0, 1 is red. (default)
+** 'tuple:argb' - values work as an a, r, g, b tuple, e.g. 1, 1, 0, 0 is red.
+** 'hex:rgba' - values work as an "rrggbbaa" hex string, e.g. "ff0000ff" is red.
+** 'hex:argb' - values work as an "aarrggbb" hex string, e.g. "ffff0000" is red.
+** ''Note: numbers cannot be serialized properly with alpha, as there are not enough bits to represent by an IEEE-754 double.''
+==== Example ====
+ local r, g, b
+ {
+ type = 'color',
+ name = "The colors",
+ desc = "Some description of color.",
+ hasAlpha = false
+ colorType = 'tuple'
+ get = function()
+ return r, g, b
+ end,
+ set = function(r_, g_, b_)
+ r, g, b = r_, g_, b_
+ end,
+ }
+Or
+ local color = "ff0000ff"
+ {
+ type = 'color',
+ name = "The colors",
+ desc = "Some description of color.",
+ hasAlpha = true
+ colorType = 'hex:rgba'
+ get = function()
+ return color
+ end,
+ set = function(value)
+ color = value
+ end,
+ }
+
+=== choice ===
+The choice type allows you to select a value from a list of values.
+==== Fields ====
+; get
+: value - the current value.
+: function - function that will return the current value.
+: string - method name that will return the current value.
+; set
+: function - function that will set the current value. ''This works in tandem with get, which should return said value.''
+: string - method name that will set the current value.
+; choices
+: table - dictionary in backendValue = "value to show the user" format.
+: function - function which returns a choices dictionary.
+: string - method name which returns a choices dictionary.
+; [choiceType]
+: nil - guess either "list" or "dict" based on what choices is.
+: "list" - the choices is a list, do not sort automatically and treat all the values as the backend values.
+: "dict" - the choices is a dictionary, sort alphabetically and treat the keys as the backend values.
+; [choiceDescs]
+: nil - no description for each choice.
+: table - dictionary in backendValue = "Description for choice" format.
+: function - function which returns choiceDescs dictionary.
+: string - method name which returns choiceDescs dictionary.
+; [choiceIcons]
+: nil - no icons for choices.
+: table - dictionary in backendValue = "Icon\\path" format.
+: function - function which returns choiceIcons dictionary.
+: string - method name which returns choiceIcons dictionary.
+; [choiceFonts]
+: nil - default font. (default)
+: table - dictionary in backendValue = "Font\\path" format.
+: function - function which returns choiceFonts dictionary.
+: string - method name which returns choiceFonts dictionary.
+; [choiceTextures]
+: nil - no textures for choices.
+: table - dictionary in backendValue = "Texture\\path" format.
+: function - function which returns choiceTextures dictionary.
+: string - method name which returns choiceTextures dictionary.
+; [choiceOrder]
+: nil - no predefined order
+: table - list of backendValues, specifying the order of the choices.
+: function - function which returns choiceOrder list.
+: string - method name which returns choiceOrder list.
+==== Example ====
+ local choice = "alpha"
+ {
+ name = "Choices, choices",
+ desc = "Here's a description for the choices",
+ type = 'choice',
+ get = function()
+ return choice
+ end,
+ set = function(value)
+ choice = value
+ end,
+ choices = {
+ alpha = "Alpha",
+ bravo = "Bravo",
+ charlie = "Charlie",
+ },
+ choiceOrder = { "alpha", "bravo", "charlie" },
+ }
+
+=== multichoice ===
+The multichoice type allows you to select multiple values from a list of values.
+==== Fields ====
+; get
+: function - function that will return a boolean (or "HALF"), stating whether a given key is enabled.
+: string - method name that will return a boolean (or "HALF"), stating whether a given key is enabled.
+; set
+: function - function that will set a boolean for the given key. ''This works in tandem with get, which should return said boolean for the given key.''
+: string - method name that will set a boolean for the given key.
+; choices
+: table - dictionary inbackendValue = "value to show the user" format.
+: function - function which returns a choices dictionary.
+: string - method name which returns a choices dictionary.
+; [choiceType]
+: nil - guess either "list" or "dict" based on what choices is.
+: "list" - the choices is a list, do not sort automatically and treat all the values as the backend values.
+: "dict" - the choices is a dictionary, sort alphabetically and treat the keys as the backend values.
+; [choiceDescs]
+: nil - no description for each choice.
+: table - dictionary inbackendValue = "Description for choice" format.
+: function - function which returns choiceDescs dictionary.
+: string - method name which returns choiceDescs dictionary.
+; [choiceIcons]
+: nil - no icons for choices.
+: table - dictionary inbackendValue = "Icon\\path" format.
+: function - function which returns choiceIcons dictionary.
+: string - method name which returns choiceIcons dictionary.
+; [choiceFonts]
+: nil - default font. (default)
+: table - dictionary inbackendValue = "Font\\path" format.
+: function - function which returns choiceFonts dictionary.
+: string - method name which returns choiceFonts dictionary.
+; [choiceTextures]
+: nil - no textures for choices.
+: table - dictionary inbackendValue = "Texture\\path" format.
+: function - function which returns choiceTextures dictionary.
+: string - method name which returns choiceTextures dictionary.
+; [choiceOrder]
+: nil - no predefined order
+: table - list of backendValues, specifying the order of the choices.
+: function - function which returns choiceOrder list.
+: string - method name which returns choiceOrder list.
+==== Example ====
+ local choices = {}
+ {
+ name = "Choices, choices",
+ desc = "Here's a description for the choices",
+ type = 'multichoice',
+ get = function(key)
+ return choices[key]
+ end,
+ set = function(key, value)
+ choices[key] = value
+ end,
+ choices = {
+ alpha = "Alpha",
+ bravo = "Bravo",
+ charlie = "Charlie",
+ },
+ choiceOrder = { "alpha", "bravo", "charlie" },
+ }
+
+=== string ===
+The string type allows you to enter arbitrary text.
+==== Fields ====
+; get
+: false - do not show a default value. ''Note: this causes the set to act like a one-way execute with input.''
+: function - function that will return the current string.
+: string - method name that will return the current string.
+; set
+: function - function that will set the current string. ''This works in tandem with get, which should return said string.''
+: string - method name that will set the current string.
+; [onChange]
+: nil - do not call a function when the text changes.
+: function - function that is called when the text changes.
+: string - method name that is called when the text changes.
+; [multiline]
+: nil or false - just a single line. (default)
+: true - use multiple lines.
+: function - function that will return whether multiple lines are used.
+: string - method name that will return whether multiple lines are used.
+; [validate]
+: nil - no validation (default)
+: function - function that will be passed the string and should return true for a proper string and false, "message" for an improper string.
+: string - method name that will be passed the string and should return true for a proper string and false, "message" for an improper string.
+; usage
+: string - usage text to be displayed.
+: function - function to return usage text.
+; [syntaxHighlighter]
+: nil - no highlighting (default)
+: function - function that will be passed the string and should return a new string with colors embedded.
+: string - method name that will be passed the string and should return a new string with colors embedded.
+==== Example ====
+ local text = "Hello"
+ {
+ name = "Teckst Bocks",
+ desc = "Here's the desc",
+ type = 'string',
+ get = function()
+ return text
+ end,
+ set = function(value)
+ text = value
+ end,
+ onChange = function(value)
+ -- do something here
+ end,
+ usage = "Some text",
+ }
+or
+ local text = "Alpha"
+ {
+ name = "Teckst Bocks",
+ desc = "Here's the desc",
+ type = 'string',
+ get = function()
+ return text
+ end,
+ set = function(value)
+ text = value
+ end,
+ validate = function(value)
+ if #value <= 4 then
+ return false, "Must be at least 5 characters long."
+ else
+ return true,
+ end
+ end,
+ usage = "Some text at least 5 characters long.",
+ }
+
+=== keybinding ===
+The keybinding type allows you to enter a keybinding.
+==== Fields ====
+; get
+: false - do not show a default value.
+: function - function that will return the current key binding.
+: string - method name that will return the current key binding.
+; set ''Note: this can receive either false or a string, where false is no binding.''
+: function - function that will set the current key binding. ''This works in tandem with get, which should return said string.''
+: string - method name that will set the current key binding.
+; [keybindingExcept]
+: nil - accept everything (or pass on to keybindingOnly).
+: table - a set of keybindings which will not be accepted.
+: function - function which returns a set of keybindings.
+: string - method name which returns a set of keybindings.
+; [keybindingOnly]
+: nil - accept everything (or pass on to keybindingExcept).
+: table - a set of keybindings which are the only ones to be accepted.
+: function - function which returns a set of keybindings.
+: string - method name which returns a set of keybindings.
+
+=== group ===
+The group type provides a tree-like structure to your options, allowing options to be suboptions of said group.
+==== Fields ====
+; args
+: table - dictionary of sub-options in someName = { suboption } format. Keys can be anything unique.
+; [child_]
+: value - this will essentially implant = value onto the child table.
+; [child_child_]
+: value - this will essentially implant = value onto the child's child table, ad nauseum.
+; [groupType]
+: nil or "normal" : to show in a normal tree fashion.
+: "tab" : show in tab format. -- TODO- actually implement this
+: "inline" : show inline in the other options, in a collapseable group.
+==== Example ====
+ values = {}
+ {
+ type = 'group',
+ name = "My subgroup",
+ desc = "Description for the subgroup",
+ child_get = function(key)
+ return values[key]
+ end,
+ child_set = function(key, value)
+ values[key] = value
+ end,
+ args = {
+ {
+ type = 'boolean',
+ name = "Some value",
+ desc = "Some description",
+ passValue = "blah",
+ },
+ {
+ type = 'string',
+ name = "Some other value",
+ desc = "Some other description",
+ usage = "Some text",
+ passValue = "blarg",
+ },
+ }
+ }
+-----------------------------------------------------------------------------]]
+
+-- #AUTODOC_NAMESPACE RockConfig
+
+RockConfig.data = setmetatable(oldLib and oldLib.data or {}, {__mode='k'})
+local data = RockConfig.data
+
+local _G = _G
+local Rock = _G.Rock
+local assert = _G.assert
+local error = _G.error
+local pcall = _G.pcall
+local select = _G.select
+local ipairs = _G.ipairs
+local pairs = _G.pairs
+local unpack = _G.unpack
+local tostring = _G.tostring
+local next = _G.next
+local type = _G.type
+local setmetatable = _G.setmetatable
+local math_min = _G.math.min
+local math_max = _G.math.max
+local math_floor = _G.math.floor
+local math_abs = _G.math.abs
+local table_sort = _G.table.sort
+local table_concat = _G.table.concat
+local table_insert = _G.table.insert
+local geterrorhandler = _G.geterrorhandler
+local CreateFrame = _G.CreateFrame
+local UIParent = _G.UIParent
+local ChatFontNormal = _G.ChatFontNormal
+local GameFontNormal = _G.GameFontNormal
+local GameFontDisableSmall = _G.GameFontDisableSmall
+local GameFontDisable = _G.GameFontDisable
+local GameFontHighlightSmall = _G.GameFontHighlightSmall
+local GameFontHighlight = _G.GameFontHighlight
+local GameTooltip = _G.GameTooltip
+local GRAY_FONT_COLOR = _G.GRAY_FONT_COLOR
+local HIGHLIGHT_FONT_COLOR = _G.HIGHLIGHT_FONT_COLOR
+local NORMAL_FONT_COLOR = _G.NORMAL_FONT_COLOR
+local SetDesaturation = _G.SetDesaturation
+local GetMouseFocus = _G.GetMouseFocus
+
+local newList, newDict, newSet, del, unpackListAndDel = Rock:GetRecyclingFunctions(MAJOR_VERSION, "newList", "newDict", "newSet", "del", "unpackListAndDel")
+
+local precondition, postcondition, argCheck = Rock:GetContractFunctions(MAJOR_VERSION, "precondition", "postcondition", "argCheck")
+
+local function toliteral(v)
+ if type(v) == "string" then
+ return ("%q"):format(v)
+ else
+ return tostring(v)
+ end
+end
+
+-- small value that's used.
+local epsilon = 1e-5
+
+local validateConfigTable
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Sets the configuration table for the current object
+ * This will call Rock:GetRockConfigOptions(addon) expecting an unpacked dict as the return. The values of said dict will be placed into the extraArgs section of the configTable.
+ * This will also call mixin:GetEmbedRockConfigOptions(addon), in the same mechansim as the above process.
+Arguments:
+ table - a configuration table.
+Example:
+ MyAddon:SetConfigTable({
+ ...
+ })
+-----------------------------------------------------------------------------]]
+function RockConfig:SetConfigTable(configTable)
+ data[self] = configTable
+
+ if Rock:HasAddon(self) and Rock.GetRockConfigOptions then
+ local opts = newDict(Rock:GetRockConfigOptions(self))
+ if next(opts) ~= nil then
+ local configTable_extraArgs = configTable.extraArgs
+ if not configTable_extraArgs then
+ configTable_extraArgs = newList()
+ configTable.extraArgs = configTable_extraArgs
+ end
+ for k,v in pairs(opts) do
+ configTable_extraArgs[k] = v
+ end
+ end
+ opts = del(opts)
+ end
+ for mixin in Rock:IterateObjectMixins(self) do
+ if mixin.GetEmbedRockConfigOptions then
+ local opts = newDict(mixin:GetEmbedRockConfigOptions(self))
+ if next(opts) ~= nil then
+ local configTable_extraArgs = configTable.extraArgs
+ if not configTable_extraArgs then
+ configTable_extraArgs = newList()
+ configTable.extraArgs = configTable_extraArgs
+ end
+ for k,v in pairs(opts) do
+ configTable_extraArgs[k] = v
+ end
+ end
+ opts = del(opts)
+ end
+ end
+end
+precondition(RockConfig, 'SetConfigTable', function(self, configTable)
+ if data[self] then
+ error("Cannot call `SetConfigTable' more than once.", 3)
+ end
+ local result, path = validateConfigTable(self, configTable)
+ if result then
+ error(("Config error: %s for path `%s'"):format(result, path), 3)
+ end
+end)
+
+local createBase
+local base
+
+-- hook the escape button so it closes the config window
+local orig_CloseSpecialWindows = _G.CloseSpecialWindows
+function _G.CloseSpecialWindows()
+ local found = orig_CloseSpecialWindows()
+ if base and base:IsShown() then
+ base:Hide()
+ return true
+ end
+ return found
+end
+
+local getTreeLine, releaseTreeLine, sortTreeLineSections
+
+local saveState, restoreState
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ tuple - the path to open to.
+Notes:
+ * Opens the configuration menu to the current object's configuration
+ * This must be called after `SetConfigTable'.
+Example:
+ MyAddon:OpenConfigMenu()
+-----------------------------------------------------------------------------]]
+function RockConfig:OpenConfigMenu(...)
+ if not base then
+ createBase()
+ elseif base:IsShown() then
+ base:Hide()
+ end
+
+ if RockConfig.hideInCombat and InCombatLockdown() then
+ base:Hide()
+ return
+ end
+
+ if UIParent:IsShown() then
+ base:SetParent(UIParent)
+ base:SetScale(RockConfig.scale or 1)
+ base:SetFrameLevel(1)
+ base:SetFrameStrata("FULLSCREEN_DIALOG")
+ else
+ base:SetParent(nil)
+ base:SetScale((RockConfig.scale or 1) * UIParent:GetScale())
+ base:SetFrameLevel(1)
+ base:SetFrameStrata("FULLSCREEN_DIALOG")
+ end
+
+ base.titleText:SetText('-----')
+
+ local found
+ if data[self] then
+ if self == RockConfig and restoreState() then
+ -- pass
+ else
+ base.addonChooser:Select(self)
+ local line = base.treeView.sections[1]
+ for i = 1, select('#', ...) do
+ local breadcrumb = select(i, ...)
+ local good = false
+ local sections = line.sections
+ if sections then
+ for k,v in pairs(sections) do
+ if v[i+1] == breadcrumb then
+ v:Click()
+ if v.expand:IsShown() then
+ line = v
+ good = true
+ end
+ break
+ end
+ end
+ end
+ if not good then
+ break
+ end
+ end
+ end
+ end
+
+ base.treeView:Reposition()
+
+ base:Show()
+end
+precondition(RockConfig, 'OpenConfigMenu', function(self)
+ if RockConfig ~= self and not data[self] then
+ error("Cannot call `OpenConfigMenu' before calling `AddConfigTable'.", 3)
+ end
+end)
+
+local currentlyMovingSlider = false
+
+local refreshConfigMenu
+local refreshConfigMenu_frame
+local refreshConfigMenu_object
+--[[---------------------------------------------------------------------------
+Notes:
+ * Refreshes the config menu if it is open to the current object.
+ * This will do nothing if the menu is closed or if it is open on a different object.
+ * This is very useful to call if a setting has changed not in response to someone setting an option.
+Example:
+ Rock("LibRockConfig-1.0"):RefreshConfigMenu(MyAddon)
+-----------------------------------------------------------------------------]]
+function RockConfig:RefreshConfigMenu(object)
+ if not data[object] and object ~= false then
+ return
+ end
+ if not base or not base:IsShown() then
+ return
+ end
+ if base.addonChooser.value ~= object then
+ return
+ end
+
+ if not refreshConfigMenu_frame then
+ refreshConfigMenu_frame = CreateFrame("Frame")
+ refreshConfigMenu_frame:SetScript("OnUpdate", function(this)
+ if not currentlyMovingSlider then
+ refreshConfigMenu(refreshConfigMenu_object)
+ this:Hide()
+ end
+ end)
+ end
+ refreshConfigMenu_object = object or nil
+ refreshConfigMenu_frame:Show()
+end
+precondition(RockConfig, 'RefreshConfigMenu', function(self, object)
+ if object ~= false then
+ argCheck(object, 2, "table")
+ end
+end)
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ [optional] table - addon which the config menu could be open to
+Returns:
+ boolean - whether the config menu is open to the given addon
+Example:
+ local isOpen = Rock("LibRockConfig-1.0"):IsConfigMenuOpen(MyAddon)
+-----------------------------------------------------------------------------]]
+function RockConfig:IsConfigMenuOpen(object)
+ if not data[object] and object then
+ return false
+ end
+ if not base or not base:IsShown() then
+ return false
+ end
+ return base.addonChooser.value == object or not object
+end
+precondition(RockConfig, 'IsConfigMenuOpen', function(self, object)
+ argCheck(object, 2, "table", "nil")
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Creates slash commands that link to the addon's configuration menu.
+Example:
+ MyAddon:SetConfigSlashCommand("/MyAddon")
+-----------------------------------------------------------------------------]]
+function RockConfig:SetConfigSlashCommand(...)
+ local function handler()
+ RockConfig.OpenConfigMenu(self)
+ end
+
+ local name = self.name
+ if type(name) == "string" then
+ name = name:upper()
+ else
+ name = tostring(self):upper()
+ end
+
+ local i = 0
+ for j = 1, select('#', ...) do
+ local command = select(j, ...)
+ if command then
+ i = i + 1
+ _G["SLASH_"..name..i] = command
+ local command_lower = command:lower()
+ if command_lower ~= command then
+ i = i + 1
+ _G["SLASH_"..name..i] = command_lower
+ end
+ end
+ end
+ _G.hash_SlashCmdList[name] = nil
+ _G.SlashCmdList[name] = handler
+
+ if self.slashCommand == nil then
+ self.slashCommand = (...)
+ end
+end
+precondition(RockConfig, 'SetConfigSlashCommand', function(self, ...)
+ argCheck(self, 1, "table")
+ if self == RockConfig then
+ error(("Bad argument #1 to `SetConfigSlashCommand'. Cannot be %s."):format(MAJOR_VERSION), 3)
+ end
+ for i = 1, select('#', ...) do
+ local v = select(i, ...)
+ argCheck(v, i+1, "string")
+ if not v:match("^/[A-Za-z0-9]") then
+ error(("Bad argument #%d to `SetConfigSlashCommand'. Must be in the form of %q, got %q."):format(i+1, "/word", v), 3)
+ end
+ end
+end)
+
+
+local caches = {}
+local cacheFuncs = {}
+local function getCachedPath(path)
+ for k,v in pairs(caches) do
+ if #k == #path then
+ local good = true
+ for i = 1, #path do
+ if path[i] ~= k[i] then
+ good = false
+ break
+ end
+ end
+ if good then
+ return newList(true, unpack(v))
+ end
+ end
+ end
+end
+
+local cacheTimes = setmetatable({}, {__mode = 'k'})
+local function setCachedPath(path, ...)
+ for k,v in pairs(caches) do
+ if #k == #path then
+ local good = true
+ for i = 1, #path do
+ if path[i] ~= k[i] then
+ good = false
+ break
+ end
+ end
+ if good then
+ caches[k] = del(v)
+ del(k)
+ end
+ end
+ end
+ local k = newList(unpack(path))
+ caches[k] = newList(...)
+ if not cacheTimes[path[1]] then
+ cacheTimes[path[1]] = GetTime()
+ end
+ if #path == 2 and select('#', ...) == 1 and type(...) == "table" and type(data[path[1]][path[2]]) == "function" then
+ cacheFuncs[k] = data[path[1]][path[2]]
+ data[path[1]][path[2]] = (...)
+ end
+end
+
+local cacheFrame = CreateFrame("Frame")
+local nextTime = 0
+cacheFrame:SetScript("OnUpdate", function(this, elapsed)
+ local currentTime = GetTime()
+ if currentTime < nextTime then
+ return
+ end
+ nextTime = currentTime + 1
+ for k, v in pairs(caches) do
+ local addon = k[1]
+ if RockConfig:IsConfigMenuOpen(addon) then
+ cacheTimes[addon] = currentTime
+ else
+ if cacheTimes[addon] + 180 < currentTime and not InCombatLockdown() then
+ if cacheFuncs[k] then
+ data[k[1]][k[2]] = cacheFuncs[k]
+ cacheFuncs[k] = nil
+ end
+ caches[k] = del(v)
+ del(k)
+ end
+ end
+ end
+end)
+
+local transformReturnTable
+do
+ local temporaryPool = setmetatable({}, {__mode='k'})
+
+ function transformReturnTable(path, tmp)
+ if tmp[2] == "@cache" then
+-- Rock("LibRockConsole-1.0"):Print("Add cache", unpack(path))
+-- Rock("LibRockConsole-1.0"):Print(unpack(tmp))
+ table.remove(tmp, 2)
+ transformReturnTable(path, tmp)
+ setCachedPath(path, tmp[2])
+ elseif tmp[2] == "@dict" then
+ local t = newDict(unpack(tmp, 3, #tmp))
+ tmp[2] = t
+ temporaryPool[t] = true
+ for i = 3, #tmp do
+ tmp[i] = nil
+ end
+ elseif tmp[2] == "@list" then
+ local t = newList(unpack(tmp, 3, #tmp))
+ tmp[2] = t
+ temporaryPool[t] = true
+ for i = 3, #tmp do
+ tmp[i] = nil
+ end
+ elseif tmp[2] == "@set" then
+ local t = newSet(unpack(tmp, 3, #tmp))
+ tmp[2] = t
+ temporaryPool[t] = true
+ for i = 3, #tmp do
+ tmp[i] = nil
+ end
+ end
+ end
+
+ local f = CreateFrame("Frame", nil, UIParent)
+ f:SetScript("OnUpdate", function()
+ for k in pairs(temporaryPool) do
+ temporaryPool[k] = del(k)
+ end
+ temporaryPool[true] = true
+ temporaryPool[true] = nil
+ end)
+end
+
+local function __getPassValues(configTables, rest, current, tableKey)
+ local key
+ if not current then
+ key = "passValue"
+ current = 1
+ else
+ key = "passValue" .. current
+ end
+ for i,v in ipairs(configTables) do
+ local passValue = v[("child_"):rep(i-1) .. key]
+ if passValue ~= nil then
+ return passValue, __getPassValues(configTables, rest, current + 1)
+ end
+ end
+ if current == 1 then
+ if configTables[2] and configTables[2].pass then
+ if rest then
+ return tableKey, unpack(rest)
+ else
+ return tableKey
+ end
+ end
+ end
+ if rest then
+ return unpack(rest)
+ else
+ return
+ end
+end
+
+local getConfigTable
+--[[---------------------------------------------------------------------------
+Arguments:
+ table - the current configTable
+ table - a list of the rest of the values to be returned.
+Returns:
+ tuple - a tuple of values
+Example:
+ local configTable = { passValue = "hello", passValue2 = "there", passValue3 = "dolly" }
+ getPassValues(configTable, nil) => "hello", "there", "dolly"
+ getPassValues(configTable, { "alpha" }) => "alpha", "hello", "there", "dolly"
+ getPassValues(configTable, { "alpha", "bravo" }) => "alpha", "bravo", "hello", "there", "dolly"
+-----------------------------------------------------------------------------]]
+local function getPassValues(path, rest)
+ local configTables = newList(getConfigTable(path))
+ local results = newList(__getPassValues(configTables, rest, nil, path[#path]))
+ del(configTables)
+ return unpackListAndDel(results)
+end
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ table - a list of the current path.
+Notes:
+ Paths are in the form of [1] = object, [2] = firstArg, [3] = secondArg, ad nauseum.
+Returns:
+ A configTable or nil
+Example:
+ local configTable = getConfigTable({ MyAddon, 'stuff' })
+-----------------------------------------------------------------------------]]
+function getConfigTable(path)
+ local configTable = data[path[1]]
+ if not configTable then
+ if type(path[1].type) == "string" then
+ configTable = path[1]
+ else
+ return nil
+ end
+ end
+ if type(configTable) == "function" then
+ local tmpPath = newList(path[1])
+ local tmp = getCachedPath(tmpPath)
+ if not tmp then
+ tmp = newList(pcall(configTable))
+ if not tmp[1] then
+ geterrorhandler()(tmp[2])
+ tmp = del(tmp)
+ tmpPath = del(tmpPath)
+ return nil
+ end
+
+ transformReturnTable(tmpPath, tmp)
+ end
+ tmpPath = del(tmpPath)
+ configTable = tmp[2]
+ tmp = del(tmp)
+ end
+ local t = newList(configTable)
+ for i = 2, #path do
+ if configTable.type ~= "group" then
+ local good = false
+ if not configTable.type then
+ for j = 2, #t do
+ local ct = t[j]
+ local ct_type = ct[("child_"):rep(j-1) .. "type"]
+ if ct_type == "group" then
+ good = true
+ break
+ elseif ct_type then
+ break
+ end
+ end
+ end
+ if not good then
+ t = del(t)
+ break
+ end
+ end
+ local configTable_args = configTable.args
+ if not configTable_args then
+ for j = 2, #t do
+ local ct = t[j]
+ configTable_args = ct[("child_"):rep(j-1) .. "args"]
+ if configTable_args then
+ break
+ end
+ end
+ if not configTable_args then
+ t = del(t)
+ break
+ end
+ end
+ if type(configTable_args) == "function" then
+ local tmpPath = newList()
+ for j = 1, i-1 do
+ tmpPath[j*2-1] = path[j]
+ tmpPath[j*2] = 'args'
+ end
+ local tmp = getCachedPath(tmpPath)
+ if not tmp then
+ tmp = newList(pcall(configTable_args, __getPassValues(t)))
+ if not tmp[1] then
+ geterrorhandler()(tmp[2])
+ tmp = del(tmp)
+ tmpPath = del(tmpPath)
+ return nil
+ end
+
+ transformReturnTable(tmpPath, tmp)
+ end
+ configTable_args = tmp[2]
+ tmp = del(tmp)
+ tmpPath = del(tmpPath)
+ end
+ local v = path[i]
+ configTable = configTable_args[v]
+
+ if type(configTable) == "function" then
+ local tmpPath = newList()
+ for j = 1, i-1 do
+ tmpPath[i*2 - 1] = path[j]
+ tmpPath[i*2] = 'args'
+ end
+ tmpPath[#tmpPath+1] = path[i]
+ local tmp = getCachedPath(tmpPath)
+ if not tmp then
+ tmp = newList(pcall(configTable))
+ if not tmp[1] then
+ geterrorhandler()(tmp[2])
+ tmp = del(tmp)
+ tmpPath = del(tmpPath)
+ return nil
+ end
+
+ transformReturnTable(tmpPath, tmp)
+ end
+ tmpPath = del(tmpPath)
+ configTable = tmp[2]
+ tmp = del(tmp)
+ end
+
+ table_insert(t, 1, configTable)
+ if not configTable then
+ t = del(t)
+ break
+ end
+ end
+ if t then
+ return unpackListAndDel(t)
+ end
+
+ configTable = data[path[1]] or path[1]
+ t = newList(configTable)
+ for i = 2, #path do
+ if configTable.type ~= "group" then
+ local good = false
+ if not configTable.type then
+ for j = 2, #t do
+ local ct = t[j]
+ local ct_type = ct[("child_"):rep(j-1) .. "type"]
+ if ct_type == "group" then
+ good = true
+ break
+ elseif ct_type then
+ break
+ end
+ end
+ end
+ if not good then
+ t = del(t)
+ return nil
+ end
+ end
+ local configTable_args
+ if i == 2 then
+ configTable_args = configTable.extraArgs
+ else
+ configTable_args = configTable.args
+ end
+ if not configTable_args then
+ for j = 2, #t do
+ local ct = t[j]
+ configTable_args = ct[("child_"):rep(j-1) .. "args"]
+ if configTable_args then
+ break
+ end
+ end
+ if not configTable_args then
+ t = del(t)
+ return nil
+ end
+ end
+ local v = path[i]
+ configTable = configTable_args[v]
+
+ if type(configTable) == "function" then
+ local tmpPath = newList()
+ for j = 1, i-1 do
+ tmpPath[i*2 - 1] = path[j]
+ tmpPath[i*2] = 'args'
+ end
+ tmpPath[#tmpPath+1] = path[i]
+ local tmp = getCachedPath(tmpPath)
+ if not tmp then
+ tmp = newList(pcall(configTable))
+ if not tmp[1] then
+ geterrorhandler()(tmp[2])
+ tmp = del(tmp)
+ tmpPath = del(tmpPath)
+ return nil
+ end
+
+ transformReturnTable(tmpPath, tmp)
+ end
+ tmpPath = del(tmpPath)
+ configTable = tmp[2]
+ tmp = del(tmp)
+ end
+
+ table_insert(t, 1, configTable)
+ if not configTable then
+ t = del(t)
+ return nil
+ end
+ end
+ return unpackListAndDel(t)
+end
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ table - a list of the current path.
+Returns:
+ boolean - whether the path leads to a configTable
+Example:
+ local has = hasConfigTable({ MyAddon, 'stuff' })
+-----------------------------------------------------------------------------]]
+local function hasConfigTable(path)
+ return not not getConfigTable(path)
+end
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ table - a list of the current path
+Notes:
+ If possible, the names from the configTables are used instead of the keys themselves.
+Returns:
+ string - a string representation of the path, in a way that is most humanly-readable.
+Example:
+ assert(getPathString({ MyAddon, 'settings', 'color' }) == "My Addon->General settings->Color")
+-----------------------------------------------------------------------------]]
+local function getPathString(path)
+ local t = newList()
+ for i = 1, #path do
+ local v = path[i]
+
+ local tmp = newList(unpack(path, 1, i))
+ local configTable = getConfigTable(tmp)
+ tmp = del(tmp)
+
+ local name = configTable and configTable.name
+
+ if type(name) ~= "string" then
+ if type(v) == "table" then
+ name = v.name
+ end
+ if type(name) ~= "string" then
+ name = tostring(v)
+ end
+ end
+ t[i] = name
+ end
+ local s = table_concat(t, "->")
+ t = del(t)
+ return s
+end
+
+do
+ local function myPathString(configTable, currentPath)
+ if not currentPath then
+ local path = newList(configTable)
+ local s = getPathString(path)
+ path = del(path)
+ return s
+ else
+ return getPathString(currentPath)
+ end
+ end
+ local function check(object, configTable, currentPath, field, canBeString, optional, typecheck)
+ local guiField = "gui" .. field:sub(1, 1):upper() .. field:sub(2)
+ local configTable_field = configTable[guiField]
+ if configTable_field == nil then
+ configTable_field = configTable[field]
+ end
+ if configTable_field == nil and currentPath then
+ local tables = newList(getConfigTable(currentPath))
+ for i = 2, #tables do
+ local v = tables[i]
+ local ct = v[("child_"):rep(i-1) .. guiField]
+ if ct == nil then
+ ct = v[("child_"):rep(i-1) .. field]
+ end
+ if ct ~= nil then
+ configTable_field = ct
+ break
+ end
+ end
+ if configTable_field == nil and #tables >= 2 and tables[2].pass then
+ configTable_field = tables[2][guiField]
+ if configTable_field == nil then
+ configTable_field = tables[2][field]
+ end
+ end
+ tables = del(tables)
+ end
+ local type_configTable_field = type(configTable_field)
+ if type_configTable_field == "function" then
+ return
+ end
+ if not canBeString and type_configTable_field == "string" then
+ local tables = newList(getConfigTable(currentPath))
+ local handler = object
+ for i,v in ipairs(tables) do
+ local h = v.handler
+ if type(h) == "table" then
+ handler = h
+ break
+ end
+ end
+ tables = del(tables)
+ local methodName = configTable_field:match("^~(.*)$") or configTable_field
+ local handler_methodName = handler[methodName]
+ if type(handler_methodName) ~= "function" then
+ return ('Method %q not found, got %q.'):format(methodName, type(handler_methodName)), myPathString(configTable, currentPath)
+ end
+ return
+ end
+ if optional and type_configTable_field == "nil" then
+ return
+ end
+ if not typecheck then
+ if type_configTable_field == "nil" then
+ return ('%s must be non-nil.'):format(field), myPathString(configTable, currentPath)
+ else
+ return
+ end
+ end
+ local types = newSet((";"):split(typecheck))
+ if types then
+ local good = false
+ if types["boolean"] and (type_configTable_field == "nil" or configTable_field == 1) then
+ good = true
+ elseif (types["dict"] or types["set"] or types["list"]) and type_configTable_field == "table" then
+ good = true
+ elseif types[type_configTable_field] then
+ good = true
+ end
+ types = del(types)
+ if good then
+ return
+ end
+ end
+ return ('%s must be a %q, got %q.'):format(field, typecheck, type_configTable_field), myPathString(configTable, currentPath)
+ end
+ function validateConfigTable(object, configTable, currentPath)
+ local configTable_type = configTable.type
+ if configTable_type == nil and currentPath then
+ local tables = newList(getConfigTable(currentPath))
+ for i = 2, #tables do
+ local v = tables[i]
+ local ct = v[("child_"):rep(i-1) .. "type"]
+ if ct ~= nil then
+ configTable_type = ct
+ break
+ end
+ end
+ tables = del(tables)
+ end
+ if type(configTable_type) == "function" then
+ -- pass
+ elseif type(configTable_type) ~= "string" then
+ return ('type must be a "string", got %q'):format(type(configTable_type)), myPathString(configTable, currentPath)
+ else
+ if not currentPath then
+ if configTable_type ~= "group" then
+ return 'type must be "group"', myPathString(configTable, currentPath)
+ end
+ else
+ if configTable_type ~= "execute" and configTable_type ~= "boolean" and configTable_type ~= "number" and configTable_type ~= "color" and configTable_type ~= "choice" and configTable_type ~= "multichoice" and configTable_type ~= "string" and configTable_type ~= "keybinding" and configTable_type ~= "group" and configTable_type ~= "toggle" and configTable_type ~= "range" and configTable_type ~= "text" and configTable_type ~= "header" then
+ return ('type %q is not valid'):format(configTable_type), myPathString(configTable, currentPath)
+ end
+ end
+ end
+
+ local checks = newList()
+ checks[#checks+1] = newList('handler', false, true, "table")
+ if configTable_type ~= "header" then
+ checks[#checks+1] = newList('name', true, false, "string")
+ checks[#checks+1] = newList('desc', true, false, "string")
+ end
+ checks[#checks+1] = newList('disabled', false, true)
+ checks[#checks+1] = newList('hidden', false, true)
+ checks[#checks+1] = newList('order', false, true, "number")
+ checks[#checks+1] = newList('icon', true, true, "string")
+ checks[#checks+1] = newList('iconSize', false, true, "number")
+ checks[#checks+1] = newList('iconTexCoord', false, true, "table")
+
+ if configTable_type == "execute" then
+ checks[#checks+1] = newList('func', false, false, "function")
+ checks[#checks+1] = newList('buttonText', true, true, "string")
+ checks[#checks+1] = newList('confirmText', true, true, "string")
+ elseif configTable_type == "number" then
+ checks[#checks+1] = newList('get', false, false, "number")
+ checks[#checks+1] = newList('set', false, false, "function")
+ checks[#checks+1] = newList('isPercent', false, true, "boolean")
+ checks[#checks+1] = newList('min', false, true, "number")
+ checks[#checks+1] = newList('max', false, true, "number")
+ checks[#checks+1] = newList('step', false, true, "number")
+ checks[#checks+1] = newList('bigStep', false, true, "number")
+ checks[#checks+1] = newList('stepBasis', false, true, "number")
+ elseif configTable_type == "boolean" then
+ checks[#checks+1] = newList('get', false, false, "boolean;string")
+ checks[#checks+1] = newList('set', false, false, "function")
+ elseif configTable_type == "color" then
+ checks[#checks+1] = newList('get', false, false, "function")
+ checks[#checks+1] = newList('set', false, false, "function")
+ checks[#checks+1] = newList('hasAlpha', false, true, "boolean")
+ checks[#checks+1] = newList('colorType', true, true, "string")
+ elseif configTable_type == "choice" then
+ checks[#checks+1] = newList('get', false, false)
+ checks[#checks+1] = newList('set', false, false, "function")
+ checks[#checks+1] = newList('choices', false, false, "table")
+ checks[#checks+1] = newList('choiceType', true, true, "string")
+ checks[#checks+1] = newList('choiceDescs', false, true, "table")
+ checks[#checks+1] = newList('choiceIcons', false, true, "table")
+ checks[#checks+1] = newList('choiceIconTexCoords', false, true, "table")
+ checks[#checks+1] = newList('choiceFonts', false, true, "table")
+ checks[#checks+1] = newList('choiceTextures', false, true, "table")
+ checks[#checks+1] = newList('choiceOrder', false, true, "table")
+ elseif configTable_type == "multichoice" then
+ checks[#checks+1] = newList('get', false, false, "function")
+ checks[#checks+1] = newList('set', false, false, "function")
+ checks[#checks+1] = newList('choices', false, false, "table")
+ checks[#checks+1] = newList('choiceType', true, true, "string")
+ checks[#checks+1] = newList('choiceDescs', false, true, "table")
+ checks[#checks+1] = newList('choiceIcons', false, true, "table")
+ checks[#checks+1] = newList('choiceIconTexCoords', false, true, "table")
+ checks[#checks+1] = newList('choiceFonts', false, true, "table")
+ checks[#checks+1] = newList('choiceTextures', false, true, "table")
+ checks[#checks+1] = newList('choiceOrder', false, true, "table")
+ elseif configTable_type == "string" then
+ checks[#checks+1] = newList('get', false, false, "string;boolean;number")
+ checks[#checks+1] = newList('set', false, false, "function")
+ checks[#checks+1] = newList('multiline', false, true, "boolean")
+ checks[#checks+1] = newList('validate', false, true, "function")
+ checks[#checks+1] = newList('syntaxHighlighter', false, true, "function")
+ checks[#checks+1] = newList('usage', true, false, "string")
+ elseif configTable_type == "keybinding" then
+ checks[#checks+1] = newList('get', false, false, "string;boolean")
+ checks[#checks+1] = newList('set', false, false, "function")
+ checks[#checks+1] = newList('keybindingOnly', false, true, "table")
+ checks[#checks+1] = newList('keybindingExcept', false, true, "table")
+ elseif configTable_type == "group" then
+ checks[#checks+1] = newList('args', false, false, "table")
+ checks[#checks+1] = newList('extraArgs', false, true, "table")
+ checks[#checks+1] = newList('groupType', true, true, "string")
+ end
+
+ local ret, path
+ for i,v in ipairs(checks) do
+ ret, path = check(object, configTable, currentPath, unpack(v))
+ if ret then
+ break
+ end
+ end
+ for i,v in ipairs(checks) do
+ del(v)
+ end
+ checks = del(checks)
+ if ret then
+ return ret, path
+ end
+
+ if configTable_type == "group" then
+ local args = configTable.args
+ if type(args) == "table" then
+ for k,v in pairs(args) do
+ local p
+ if currentPath then
+ p = newList(unpack(currentPath))
+ else
+ p = newList(configTable)
+ end
+ p[#p+1] = k
+ ret, path = validateConfigTable(object, v, p)
+ p = del(p)
+ if ret then
+ return ret, path
+ end
+ end
+ end
+ end
+ end
+end
+
+local getConfigField
+
+local function transformConfigField(path, field, canBeString, optional, typecheck, t)
+ if field == 'type' then
+ if t[2] == 'toggle' then
+ t[2] = 'boolean'
+ return
+ elseif t[2] == 'range' then
+ t[2] = 'number'
+ return
+ elseif t[2] == 'text' then
+ local validate_type = getConfigField(path, 'validate', false, true, nil, true, true)
+ if validate_type == "table" then
+ local multiToggle = getConfigField(path, 'multiToggle', false, true, nil, true)
+ if multiToggle then
+ t[2] = 'multichoice'
+ else
+ t[2] = 'choice'
+ end
+ elseif validate_type == "string" then
+ local validate = getConfigField(path, 'validate', true, true, nil, true)
+ if validate == "keybinding" then
+ t[2] = 'keybinding'
+ else
+ t[2] = 'string'
+ end
+ else
+ t[2] = 'string'
+ end
+ return
+ end
+ elseif field == 'buttonText' then
+ if t[2] == nil then
+ t[2] = _G.OKAY
+ end
+ elseif field == 'choices' then
+ if t[2] == nil then
+ local type = getConfigField(path, 'type', true, true, nil, true)
+ if type == 'text' then
+ t[2] = getConfigField(path, 'validate', false, true, nil, true)
+ end
+ return
+ end
+ elseif field == 'choiceDescs' then
+ if t[2] == nil then
+ local type = getConfigField(path, 'type', true, true, nil, true)
+ if type == 'text' then
+ t[2] = getConfigField(path, 'validateDesc', false, true, nil, true)
+ end
+ return
+ end
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * This takes a value off of a configTable, and if a function should be executed, then that should happen, though literal values are quite acceptable.
+ * This makes general situations such as name = "Hello" as well as name = function() return "Hello" end both work equally.
+Arguments:
+ table - a list of the current path
+ string - the name of the field we're looking at
+ [optional] boolean - whether the field can be a literal string instead of a reference to a method name.
+ [optional] boolean or value - whether the field is optional, if a non-boolean is provided, then that will be the value returned if the field returns nil.
+ [optional] string - the type (or types separated by semicolon) that the resultant field must be.
+Returns:
+ value or tuple - if executing a function, this will return the tuple that is returned, otherwise return the literal value.
+Example:
+ local value = getConfigField(path, 'get', false, false, "string") -- get the value off the path that must be a string and cannot be optional.
+ local r, g, b, a = getConfigField(path, 'get', false, false) -- get the value off the path that you expect to be an r, g, b, a sequence. Note: this must be typechecked manually.
+ local name = getConfigField(path, 'name', true, false) -- get the name off the path, the name can be a literal string, cannot be a method.
+ local hasAlpha = getConfigField(path, 'hasAlpha', false, true, "boolean") -- get hasAlpha off the path, can be nil/true/false.
+ local order = getConfigField(path, 'order', false, 100, "number") -- get order off the path, if nil is provided, it will return 100.
+-----------------------------------------------------------------------------]]
+function getConfigField(path, field, canBeString, optional, typecheck, dontTransform, getType)
+ local guiField = "gui" .. field:sub(1, 1):upper() .. field:sub(2)
+ local t = newList(getConfigTable(path))
+
+ if #t == 0 then
+ t = del(t)
+ local _, ret = pcall(error, ("%s: Cannot find path `%s'."):format(MAJOR_VERSION, getPathString(path)))
+ geterrorhandler()(ret)
+ return nil
+ end
+
+ local func
+ local handler = path[1]
+ for i = #t, 1, -1 do
+ local configTable = t[i]
+ local f = configTable[("child_"):rep(i-1) .. guiField]
+ if f == nil then
+ f = configTable[("child_"):rep(i-1) .. field]
+ end
+ if f ~= nil then
+ func = f
+ end
+ local h = configTable.handler
+ if h ~= nil then
+ handler = h
+ end
+ end
+
+ local configTable = t[1]
+
+ if func == nil and field ~= 'pass' and #path > 1 then
+ local superpath = newList(unpack(path, 1, #path-1))
+ local pass = getConfigField(superpath, 'pass', false, true)
+ if pass then
+ func = t[2][guiField]
+ if func == nil then
+ func = t[2][field]
+ end
+ end
+ superpath = del(superpath)
+ end
+ t = del(t)
+
+ if type(func) == "string" and not canBeString then
+ if getType then
+ return "string", "method"
+ end
+ if type(handler) ~= "table" then
+ local _, ret = pcall(error, ("%s: Handler not given for method %q for `%s'."):format(MAJOR_VERSION, func, getPathString(path)))
+ geterrorhandler()(ret)
+ return nil
+ end
+ local negate = false
+ local handler_func = handler[func]
+ if type(handler_func) ~= "function" then
+ local realFunc = func:match("^~(.*)$")
+ if not realFunc then
+ local _, ret = pcall(error, ("%s: Unknown method %q for `%s'."):format(MAJOR_VERSION, func, getPathString(path)))
+ geterrorhandler()(ret)
+ return nil
+ end
+ negate = true
+ handler_func = handler[realFunc]
+ if type(handler_func) ~= "function" then
+ local _, ret = pcall(error, ("%s: Unknown method %q for `%s'."):format(MAJOR_VERSION, realFunc, getPathString(path)))
+ geterrorhandler()(ret)
+ return nil
+ end
+ end
+
+ local tmpPath = newList()
+ for i = 1, #path-1 do
+ tmpPath[i*2 - 1] = path[i]
+ tmpPath[i*2] = 'args'
+ end
+ tmpPath[#tmpPath+1] = path[#path]
+ tmpPath[#tmpPath+1] = field
+ local tmp = getCachedPath(tmpPath)
+ if not tmp then
+ tmp = newList(pcall(handler_func, handler, getPassValues(path)))
+ if not tmp[1] then
+ geterrorhandler()(tmp[2])
+ tmp = del(tmp)
+ tmpPath = del(tmpPath)
+ return nil
+ end
+
+ transformReturnTable(tmpPath, tmp)
+ end
+ tmpPath = del(tmpPath)
+ if not dontTransform then
+ transformConfigField(path, field, canBeString, optional, typecheck, tmp)
+ end
+
+ if negate then
+ tmp[2] = not tmp[2]
+ for i = 3, #tmp do
+ tmp[i] = nil
+ end
+ end
+
+ local value = tmp[2]
+ if optional and value == nil then
+ if optional ~= true then
+ tmp = del(tmp)
+ return optional
+ end
+ elseif typecheck then
+ local types = newSet((";"):split(typecheck))
+ local type_value = type(value)
+ if not types[type_value] then
+ if types["boolean"] and (type_value == "nil" or value == 1) then
+ -- pass
+ elseif (types["dict"] or types["set"] or types["list"]) and type_value == "table" then
+ -- pass
+ else
+ local t = newList()
+ for k in pairs(types) do
+ t[#t+1] = ("%q"):format(k)
+ end
+ local s = table_concat(t, ", ")
+ t = del(t)
+ local _, ret = pcall(error, ("%s: Bad return from method %q for `%s'. Expected %s, got %q (%s)."):format(MAJOR_VERSION, func, getPathString(path), s, type_value, toliteral(value)))
+ geterrorhandler()(ret)
+ end
+ end
+ types = del(types)
+ end
+ return unpackListAndDel(tmp, 2, #tmp)
+ elseif type(func) == "function" then
+ if getType then
+ return "function"
+ end
+
+ local tmpPath = newList()
+ for i = 1, #path-1 do
+ tmpPath[i*2 - 1] = path[i]
+ tmpPath[i*2] = 'args'
+ end
+ tmpPath[#tmpPath+1] = path[#path]
+ tmpPath[#tmpPath+1] = field
+ local tmp = getCachedPath(tmpPath)
+ if not tmp then
+ tmp = newList(pcall(func, getPassValues(path)))
+ if not tmp[1] then
+ geterrorhandler()(tmp[2])
+ tmp = del(tmp)
+ tmpPath = del(tmpPath)
+ return nil
+ end
+
+ transformReturnTable(tmpPath, tmp)
+ end
+ tmpPath = del(tmpPath)
+ if not dontTransform then
+ transformConfigField(path, field, canBeString, optional, typecheck, tmp)
+ end
+
+ local value = tmp[2]
+ if optional and value == nil then
+ if optional ~= true then
+ tmp = del(tmp)
+ return optional
+ end
+ elseif typecheck then
+ local types = newSet((";"):split(typecheck))
+ local type_value = type(value)
+ if not types[type_value] then
+ if types["boolean"] and (type_value == "nil" or value == 1) then
+ -- pass
+ elseif (types["dict"] or types["set"] or types["list"]) and type_value == "table" then
+ -- pass
+ else
+ local t = newList()
+ for k in pairs(types) do
+ t[#t+1] = ("%q"):format(tostring(k))
+ end
+ local s = table_concat(t, ", ")
+ t = del(t)
+ local _, ret = pcall(error, ("%s: Bad return from function %q for `%s'. Expected %s, got %q (%s)."):format(MAJOR_VERSION, field, getPathString(path), s, type_value, toliteral(value)))
+ geterrorhandler()(ret)
+ end
+ end
+ types = del(types)
+ end
+ return unpackListAndDel(tmp, 2, #tmp)
+ else
+ if getType then
+ return type(func)
+ end
+ if not dontTransform then
+ local tmp = newList(true, func)
+ transformConfigField(path, field, canBeString, optional, typecheck, tmp)
+ func = tmp[2]
+ tmp = del(tmp)
+ end
+ if func == nil then
+ if not optional then
+ local _, ret = pcall(error, ("%s: Field %q not found for `%s'."):format(MAJOR_VERSION, field, getPathString(path)))
+ geterrorhandler()(ret)
+ return nil
+ elseif optional ~= true then
+ return optional
+ else
+ return func
+ end
+ end
+ if typecheck then
+ local types = newSet((";"):split(typecheck))
+ local type_func = type(func)
+ if not types[type_func] then
+ if types["boolean"] and (type_func == "nil" or value == 1) then
+ -- pass
+ elseif (types["dict"] or types["set"] or types["list"]) and type_func == "table" then
+ -- pass
+ else
+ local t = newList()
+ for k in pairs(types) do
+ t[#t+1] = ("%q"):format(tostring(k))
+ end
+ local s = table_concat(t, ", ")
+ t = del(t)
+ local _, ret = pcall(error, ("%s: Bad value for field %q for `%s'. Expected %s, got %q (%s)."):format(MAJOR_VERSION, field, getPathString(path), s, type_func, toliteral(func)))
+ geterrorhandler()(ret)
+ end
+ end
+ types = del(types)
+ end
+ return func
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * This calls a function or method on the configTable of the given path.
+Arguments:
+ table - a list of the current path
+ string - the name of the field we're looking at
+ [optional] table - A list of values that are to be passed in.
+ [optional] boolean - if set to true, if the function does not exist, no error is raised.
+Returns:
+ success, ret
+ boolean - whether the function executed properly, without errors.
+ tuple - results from the function call.
+Example:
+ callConfigField(path, 'set', { 1, 1, 0, 1 }) -- passes four values along, not just 1
+ callConfigField(path, 'set', { "text" }) -- passes along text.
+ local success, ret = callConfigField(path, 'get', { key }) -- used in multichoice
+-----------------------------------------------------------------------------]]
+local function callConfigField(path, field, values, optional)
+ local guiField = "gui" .. field:sub(1, 1):upper() .. field:sub(2)
+ local t = newList(getConfigTable(path))
+
+ if #t == 0 then
+ t = del(t)
+ local _, ret = pcall(error, ("%s: Cannot find path `%s'."):format(MAJOR_VERSION, getPathString(path)))
+ geterrorhandler()(ret)
+ return nil
+ end
+
+ local func
+ local handler = path[1]
+ for i = #t, 1, -1 do
+ local configTable = t[i]
+ local f = configTable[("child_"):rep(i-1) .. guiField]
+ if f == nil then
+ f = configTable[("child_"):rep(i-1) .. field]
+ end
+ if f ~= nil then
+ func = f
+ end
+ local h = configTable.handler
+ if h ~= nil then
+ handler = h
+ end
+ end
+
+ local configTable = t[1]
+
+ if func == nil and field ~= 'pass' and #path > 1 then
+ local superpath = newList(unpack(path, 1, #path-1))
+ local pass = getConfigField(superpath, 'pass', false, true)
+ if pass then
+ func = t[2][guiField]
+ if func == nil then
+ func = t[2][field]
+ end
+ end
+ superpath = del(superpath)
+ end
+
+ t = del(t)
+
+ if type(func) == "string" then
+ if type(handler) ~= "table" then
+ local _, ret = pcall(error, ("%s: Handler not given for method %q for `%s'."):format(MAJOR_VERSION, func, getPathString(path)))
+ geterrorhandler()(ret)
+ return nil
+ end
+
+ local negate = false
+ local handler_func = handler[func]
+ if type(handler_func) ~= "function" then
+ local realFunc = func:match("^~(.*)$")
+ if not realFunc then
+ local _, ret = pcall(error, ("%s: Unknown method %q for `%s'."):format(MAJOR_VERSION, func, getPathString(path)))
+ geterrorhandler()(ret)
+ return nil
+ end
+ negate = true
+ handler_func = handler[realFunc]
+ if type(handler_func) ~= "function" then
+ local _, ret = pcall(error, ("%s: Unknown method %q for `%s'."):format(MAJOR_VERSION, realFunc, getPathString(path)))
+ geterrorhandler()(ret)
+ return nil
+ end
+ end
+
+ local tmpPath = newList()
+ for i = 1, #path-1 do
+ tmpPath[i*2 - 1] = path[i]
+ tmpPath[i*2] = 'args'
+ end
+ tmpPath[#tmpPath+1] = path[#path]
+ tmpPath[#tmpPath+1] = field
+ local tmp = getCachedPath(tmpPath)
+ if not tmp then
+ tmp = newList(pcall(handler_func, handler, getPassValues(path, values)))
+ if not tmp[1] then
+ geterrorhandler()(tmp[2])
+ tmp = del(tmp)
+ tmpPath = del(tmpPath)
+ return nil
+ end
+
+ transformReturnTable(tmpPath, tmp)
+ end
+ tmpPath = del(tmpPath)
+
+ if negate then
+ tmp[2] = not tmp[2]
+ for i = 3, #tmp do
+ tmp[i] = nil
+ end
+ end
+
+ return true, unpackListAndDel(tmp, 2, #tmp)
+ elseif type(func) == "function" then
+ local tmpPath = newList()
+ for i = 1, #path-1 do
+ tmpPath[i*2 - 1] = path[i]
+ tmpPath[i*2] = 'args'
+ end
+ tmpPath[#tmpPath+1] = path[#path]
+ tmpPath[#tmpPath+1] = field
+ local tmp = getCachedPath(tmpPath)
+ if not tmp then
+ tmp = newList(pcall(func, getPassValues(path, values)))
+ if not tmp[1] then
+ geterrorhandler()(tmp[2])
+ tmp = del(tmp)
+ tmpPath = del(tmpPath)
+ return nil
+ end
+
+ transformReturnTable(tmpPath, tmp)
+ end
+ tmpPath = del(tmpPath)
+
+ return true, unpackListAndDel(tmp, 2, #tmp)
+ else
+ if not optional then
+ local _, ret = pcall(error, ("%s: Field %q not found for `%s'."):format(MAJOR_VERSION, field, getPathString(path)))
+ geterrorhandler()(ret)
+ return nil
+ end
+ return nil, true
+ end
+end
+
+local removeSections
+
+local mainPane_Reposition
+
+if oldLib and oldLib.base then
+ oldLib.base:Hide()
+ oldLib.base:UnregisterAllEvents()
+end
+
+local function recheckThirdPartyOptions()
+ local list = newList()
+ local AceConsole = Rock("AceConsole-2.0", true, true)
+ if AceConsole then
+ for k,v in pairs(AceConsole.registry) do
+ list[v] = true
+ end
+ end
+ local FuBarPlugin20 = Rock("FuBarPlugin-2.0", true, true)
+ if FuBarPlugin20 and FuBarPlugin20.registry then
+ for k in pairs(FuBarPlugin20.registry) do
+ if type(k) == "table" and k.OnMenuRequest then
+ list[k.OnMenuRequest] = true
+ end
+ end
+ end
+ for k in pairs(list) do
+ if type(k) == "table" and k.type == 'group' and type(k.args) == "table" and k.handler and not data[k.handler] then
+ local addonName = k.handler.name
+ if not k.name or k.name == "" then
+ k.name = addonName
+ end
+ if k.name ~= "Niagara" and k.name ~= "DeuceCommander" then
+ if not k.desc or k.desc == "" then
+ if not k.handler.notes or k.handler.notes == "" then
+ k.desc = addonName
+ else
+ k.desc = k.handler.notes
+ end
+ end
+ if not k.icon and (k.handler.hasIcon or k.handler.icon) then
+ if type(k.handler.hasIcon) == "string" then
+ k.icon = k.handler.hasIcon
+ elseif type(k.handler.icon) == "string" then
+ k.icon = k.handler.icon
+ end
+ end
+ end
+ else
+ list[k] = nil
+ end
+ end
+ for k in pairs(list) do
+ local good = true
+ for l in pairs(list) do
+ if k ~= l then
+ for m,n in pairs(l.args) do
+ if n == k then
+ good = false
+ break
+ end
+ end
+ if not good then
+ break
+ end
+ end
+ end
+ if good then
+ for _,l in pairs(data) do
+ if type(l.args) == "table" then
+ for m,n in pairs(l.args) do
+ if n == k then
+ good = false
+ break
+ end
+ end
+ if not good then
+ break
+ end
+ end
+ end
+ end
+ if good and not data[k.handler] then
+ RockConfig.SetConfigTable(k.handler, k)
+ end
+ list[k] = nil
+ end
+ list = del(list)
+
+ if base.treeView then
+ RockConfig:RefreshConfigMenu(false)
+ end
+end
+
+local function base_OnEvent(base, event)
+ if event == "ADDON_LOADED" then
+ recheckThirdPartyOptions()
+ elseif event == "PLAYER_REGEN_DISABLED" then
+ if RockConfig.hideInCombat then
+ base:Hide()
+ end
+ end
+end
+
+local function recalculateSavedPosition()
+ if not base then
+ return
+ end
+ local x, y = base:GetCenter()
+ x = x - GetScreenWidth()/2/base:GetScale()
+ y = y - GetScreenHeight()/2/base:GetScale()
+ base:ClearAllPoints()
+ base:SetPoint("CENTER", UIParent, "CENTER", x, y)
+ local width, height = base:GetWidth(), base:GetHeight()
+ RockConfig.x = x
+ RockConfig.y = y
+ RockConfig.width = width
+ RockConfig.height = height
+end
+
+local pullout -- choice pullout
+
+local strataList = {}
+local function makeBackground(frame)
+ if not frame then
+ frame = base
+ end
+ strataList[frame] = true
+ frame:SetFrameStrata("BACKGROUND")
+ local t = newList(frame:GetChildren())
+ for i,v in ipairs(t) do
+ makeBackground(v)
+ end
+ t = del(t)
+end
+local function makeForeground()
+ for k in pairs(strataList) do
+ k:SetFrameStrata("FULLSCREEN_DIALOG")
+ strataList[k] = nil
+ end
+end
+
+-- bubble up OnEnter
+local function SubControl_OnEnter(this, ...)
+ local parent = this:GetParent()
+ if not parent or parent == base then
+ return
+ end
+ local OnEnter = parent:GetScript("OnEnter")
+ if OnEnter then
+ return OnEnter(parent, ...)
+ end
+ return SubControl_OnEnter(this, ...)
+end
+
+-- bubble up OnLeave
+local function SubControl_OnLeave(this, ...)
+ local parent = this:GetParent()
+ if not parent or parent == base then
+ return
+ end
+ local OnLeave = parent:GetScript("OnLeave")
+ if OnLeave then
+ return OnLeave(parent, ...)
+ end
+ return SubControl_OnLeave(this, ...)
+end
+
+-- create the pullout frame, only called once.
+local function makePullout()
+ makePullout = nil
+ local mainPane = base.mainPane
+ pullout = CreateFrame("Frame", mainPane:GetName() .. "_ChoicePullout", mainPane, BackdropTemplateMixin and "BackdropTemplate")
+ pullout:SetFrameLevel(20)
+ local bg = newList()
+ bg.bgFile = [[Interface\Buttons\WHITE8X8]]
+ bg.edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]]
+ bg.tile = true
+ bg.edgeSize = 16
+ bg.tileSize = 16
+ bg.insets = newList()
+ bg.insets.left = 3
+ bg.insets.right = 3
+ bg.insets.top = 3
+ bg.insets.bottom = 3
+ pullout:SetBackdrop(bg)
+ bg.insets = del(bg.insets)
+ bg = del(bg)
+ pullout:SetBackdropColor(0, 0, 0)
+ pullout:SetFrameStrata("FULLSCREEN_DIALOG")
+ pullout:SetFrameLevel(20)
+ pullout:EnableMouseWheel(true)
+ pullout:SetScript("OnMouseWheel", function(this, up)
+ if up < 0 then
+ local bottom = this:GetBottom()
+ if bottom < 0 then
+ for i = 1, this:GetNumPoints() do
+ local point, frame, relpoint, xdiff, ydiff = this:GetPoint(i)
+ if point == "TOP" then
+ local y = math.min(17, -bottom)
+ this:SetPoint(point, frame, relpoint, xdiff, ydiff + y)
+ end
+ end
+ end
+ else
+ local top = this:GetTop()
+ local screenHeight = GetScreenHeight()
+ if top > screenHeight then
+ for i = 1, this:GetNumPoints() do
+ local point, frame, relpoint, xdiff, ydiff = this:GetPoint(i)
+ if point == "TOP" then
+ local y = math.min(17, top - screenHeight)
+ this:SetPoint(point, frame, relpoint, xdiff, ydiff - y)
+ end
+ end
+ end
+ end
+ end)
+ pullout:Hide()
+end
+
+local buildPullout
+
+-- when a line is clicked, set the value, update
+local function Dropdown_LineClicked(this)
+ local parent = this:GetParent().parent
+ if parent == base.addonChooser then
+ if parent.value == this.value then
+ return
+ end
+ this:GetParent():Hide()
+ parent:Select(this.value)
+ return
+ elseif parent.isMulti then
+ local value = not this.check:IsShown() or this.check.half
+ local t = newList(this.value, not not value)
+ callConfigField(parent, 'set', t)
+ t = del(t)
+ else
+ if parent.value == this.value then
+ return
+ end
+ local t = newList(this.value)
+ callConfigField(parent, 'set', t)
+ t = del(t)
+ end
+
+ refreshConfigMenu(parent[1])
+end
+
+-- if using radio buttons, show the highlight
+local function Dropdown_LineEnter(this)
+ local pullout = this:GetParent()
+ if not pullout.parent.isMulti then
+ this.checkHighlight:Show()
+ end
+ _G.GameTooltip_SetDefaultAnchor(GameTooltip, this)
+
+ local name, desc
+ if pullout.parent ~= base.addonChooser then
+ local choiceDescs = getConfigField(pullout.parent, 'choiceDescs', false, true, "table")
+ if not choiceDescs then
+ desc = this.text:GetText()
+ name = this:GetParent().parent.label.text:GetText()
+ else
+ name = this.text:GetText()
+ desc = choiceDescs[this.value]
+ end
+ else
+ name = this.text:GetText()
+ local t = newList(this.value)
+ desc = getConfigField(t, 'desc', true, false, "string")
+ t = del(t)
+ end
+ GameTooltip:SetText(name, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b, 1)
+ if name ~= desc and desc then
+ GameTooltip:AddLine(desc, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
+ end
+ GameTooltip:Show()
+end
+
+-- if using radio buttons, hide the highlight
+local function Dropdown_LineLeave(this)
+ if not this:GetParent().parent.isMulti then
+ this.checkHighlight:Hide()
+ end
+
+ GameTooltip:Hide()
+end
+
+-- fetch or create a button on the pullout
+local function getPulloutButton(num)
+ local button = pullout[num]
+ if button then
+ button:Show()
+
+ return button
+ end
+ button = CreateFrame("Button", pullout:GetName() .. "_Button" .. num, pullout)
+ pullout[num] = button
+ button:SetHeight(17)
+ button:SetPoint("LEFT", pullout, "LEFT", 6, 0)
+ button:SetPoint("RIGHT", pullout, "RIGHT", -6, 0)
+
+ local text = button:CreateFontString(button:GetName() .. "_Text", "OVERLAY", "GameFontHighlightSmall")
+ button.text = text
+ text:SetJustifyH("LEFT")
+ button:SetFontString(text)
+
+ local highlight = button:CreateTexture(button:GetName() .. "_Highlight", "OVERLAY")
+ button.highlight = highlight
+ highlight:SetTexture([[Interface\QuestFrame\UI-QuestTitleHighlight]])
+ highlight:SetVertexColor(1, 1, 1, 0.5)
+ highlight:SetBlendMode("ADD")
+ highlight:SetAllPoints(button)
+ button:SetHighlightTexture(highlight)
+
+ local check = button:CreateTexture("OVERLAY")
+ button.check = check
+ check:SetWidth(16)
+ check:SetHeight(16)
+ check:SetPoint("LEFT", button, "LEFT", 0, 0)
+ check:SetTexture([[Interface\Buttons\UI-RadioButton]])
+ check:SetTexCoord(0, 0.25, 0, 1)
+
+ -- highlight for radio buttons only
+ local checkHighlight = button:CreateTexture("OVERLAY")
+ button.checkHighlight = checkHighlight
+ checkHighlight:SetAllPoints(check)
+ checkHighlight:SetTexture([[Interface\Buttons\UI-RadioButton]])
+ checkHighlight:SetBlendMode("ADD")
+ checkHighlight:SetTexCoord(0.5, 0.75, 0, 1)
+ checkHighlight:Hide()
+
+ local icon = button:CreateTexture(button:GetName() .. "_Icon", "ARTWORK")
+ button.icon = icon
+ icon:SetWidth(epsilon)
+ icon:SetHeight(16)
+ icon:SetPoint("LEFT", check, "RIGHT", 0, 0)
+
+ text:SetPoint("LEFT", icon, "RIGHT", 0, 0)
+ text:SetPoint("TOP", button, "TOP", 0, 0)
+ text:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 0, 0)
+
+ local texture = button:CreateTexture(button:GetName() .. "_Texture", "ARTWORK")
+ button.texture = texture
+ texture:SetVertexColor(1, 1, 1, 0.5)
+ texture:SetPoint("LEFT", icon, "RIGHT", 0, 0)
+ texture:SetPoint("RIGHT", button, "RIGHT", -1, 0)
+ texture:SetPoint("TOP", button, "TOP", 0, -1)
+ texture:SetPoint("BOTTOM", button, "BOTTOM", 0, 1)
+
+ button:SetScript("OnClick", Dropdown_LineClicked)
+ button:SetScript("OnEnter", Dropdown_LineEnter)
+ button:SetScript("OnLeave", Dropdown_LineLeave)
+
+ return button
+end
+
+local choiceSort__choices
+-- sort choices alphabetically
+local function choiceSort(alpha, bravo)
+ local alpha_v, bravo_v = choiceSort__choices[alpha], choiceSort__choices[bravo]
+ local type_alpha_v = type(alpha_v)
+ local type_bravo_v = type(bravo_v)
+ if type_alpha_v ~= type_bravo_v then
+ return type_alpha_v < type_bravo_v
+ end
+ if type_alpha_v == "string" then
+ return alpha_v:lower() < bravo_v:lower()
+ elseif type_alpha_v == "number" then
+ return alpha_v < bravo_v
+ elseif type_alpha_v == "boolean" then
+ return not alpha_v
+ else
+ return tostring(alpha_v) < tostring(bravo_v)
+ end
+end
+
+local function isList(choices)
+ local n = #choices
+ if n == 0 then
+ return false
+ end
+ for k,v in pairs(choices) do
+ if type(k) ~= "number" or k <= 0 or k > n then
+ return false
+ end
+ end
+ return true
+end
+
+-- build the pullout's buttons based on the control
+function buildPullout(this)
+ for i,v in ipairs(pullout) do
+ pullout[i]:Hide()
+ end
+
+ local isAddonChooser = this == base.addonChooser
+
+ local choices, choiceType, choiceOrder
+ if not isAddonChooser then
+ choices = getConfigField(this, 'choices', false, false, "table")
+ choiceType = getConfigField(this, 'choiceType', true, isList(choices) and "list" or "dict", "string")
+ if choiceType == "dict" then
+ choiceOrder = getConfigField(this, 'choiceOrder', false, true, "table")
+ end
+ end
+
+ local choiceIcons, choiceIconTexCoords, choiceFonts, choiceTextures
+
+ local keys = newList()
+ if isAddonChooser then
+ choices = newList()
+ choiceIcons = newList()
+ for k,v in pairs(data) do
+ keys[#keys + 1] = k
+ local t = newList(k)
+ choices[k] = getConfigField(t, 'name', true, false, "string")
+ choiceIcons[k] = getConfigField(t, 'icon', true, true, "string")
+ t = del(t)
+ end
+
+ choiceSort__choices = choices
+ table_sort(keys, choiceSort)
+ choiceSort__choices = nil
+ choiceType = "dict"
+ else
+ if choiceType == "dict" then
+ if choiceOrder then
+ for i,k in ipairs(choiceOrder) do
+ keys[#keys+1] = k
+ end
+ else
+ for k,v in pairs(choices) do
+ keys[#keys+1] = k
+ end
+ choiceSort__choices = choices
+ table_sort(keys, choiceSort)
+ choiceSort__choices = nil
+ end
+ else
+ for i,v in ipairs(choices) do
+ keys[#keys+1] = v
+ end
+ end
+
+ choiceIcons = getConfigField(this, 'choiceIcons', false, true, "table")
+ choiceIconTexCoords = getConfigField(this, 'choiceIconTexCoords', false, true, "table")
+ choiceFonts = getConfigField(this, 'choiceFonts', false, true, "table")
+ choiceTextures = getConfigField(this, 'choiceTextures', false, true, "table")
+ end
+
+ local totalHeight = 10 -- 5 on the top and bottom
+ local isMulti = not isAddonChooser and this.isMulti
+ local value = isMulti and this.values or this.value
+ local last = pullout
+ for i,k in ipairs(keys) do
+ local button = getPulloutButton(i)
+ if choiceType == "dict" then
+ button.text:SetText(choices[k])
+ else
+ button.text:SetText(k)
+ end
+ if choiceIcons then
+ button.icon:SetWidth(16)
+ local icon = choiceIcons[k]
+ button.icon:SetTexture(icon)
+ local texCoord = choiceIconTexCoords and choiceIconTexCoords[k]
+ if texCoord then
+ button.icon:SetTexCoord(unpack(texCoord))
+ else
+ if icon and icon:find([[^Interface\Icons\]]) then
+ button.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
+ else
+ button.icon:SetTexCoord(0, 1, 0, 1)
+ end
+ end
+ else
+ button.icon:SetWidth(epsilon)
+ button.icon:SetTexture(nil)
+ end
+ if choiceTextures then
+ button.texture:SetTexture(choiceTextures[k])
+ else
+ button.texture:SetTexture(nil)
+ end
+ if choiceFonts and choiceFonts[k] then
+ local _, size, flags = GameFontHighlightSmall:GetFont()
+ button.text:SetFont(choiceFonts[k], size, flags)
+ else
+ button.text:SetFont(GameFontHighlightSmall:GetFont())
+ end
+ if last == pullout then
+ button:SetPoint("TOP", pullout, "TOP", 0, -5)
+ else
+ button:SetPoint("TOP", last, "BOTTOM", 0, 0)
+ end
+
+ SetDesaturation(button.check, false)
+ button.check.half = nil
+ if isMulti then
+ button.check:SetTexture([[Interface\Buttons\UI-CheckBox-Check]])
+ button.check:SetTexCoord(0, 1, 0, 1)
+ if value[k] then
+ button.check:Show()
+ if value[k] == "HALF" then
+ button.check.half = true
+ SetDesaturation(button.check, true)
+ end
+ else
+ button.check:Hide()
+ end
+ else
+ button.check:SetTexture([[Interface\Buttons\UI-RadioButton]])
+ button.check:Show()
+ if value == k then
+ -- shows full radio
+ button.check:SetTexCoord(0.25, 0.5, 0, 1)
+ else
+ -- shows empty radio
+ button.check:SetTexCoord(0, 0.25, 0, 1)
+ end
+ end
+ button.value = k
+ totalHeight = totalHeight + button:GetHeight()
+ last = button
+ end
+ if isAddonChooser then
+ choices = del(choices)
+ choiceIcons = del(choiceIcons)
+ end
+ pullout:SetHeight(totalHeight)
+end
+
+local nextFreeScroll = 0
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Creates the config menu frame
+ * This is called only once.
+-----------------------------------------------------------------------------]]
+function createBase()
+ createBase = nil
+ base = CreateFrame("Frame", MAJOR_VERSION .. "_Frame", UIParent, BackdropTemplateMixin and "BackdropTemplate")
+ RockConfig.base = base
+ base:RegisterEvent("ADDON_LOADED")
+ base:RegisterEvent("PLAYER_REGEN_DISABLED")
+ base:SetScript("OnEvent", base_OnEvent)
+ local currentAlpha = 1
+ local hasEntered = false
+ local isDragging = false
+ local function inFocus()
+ local frame = GetMouseFocus()
+ if frame == WorldFrame or frame == UIParent or not frame or frame == base then
+ return true
+ end
+ while true do
+ frame = frame:GetParent()
+ if frame == base then
+ return true
+ elseif frame == UIParent or not frame then
+ return false
+ end
+ end
+ end
+ base:SetScript("OnUpdate", function(this, elapsed)
+ local maxAlpha = RockConfig.maxAlpha
+ local minAlpha = RockConfig.minAlpha
+ if not maxAlpha then
+ maxAlpha = 1
+ RockConfig.maxAlpha = maxAlpha
+ end
+ if not minAlpha then
+ minAlpha = 0.25
+ RockConfig.minAlpha = minAlpha
+ end
+ if ((MouseIsOver(this) or pullout and pullout:IsShown() and MouseIsOver(pullout)) and inFocus()) or isDragging then
+ hasEntered = true
+ if currentAlpha < maxAlpha then
+ currentAlpha = currentAlpha + elapsed/((maxAlpha - minAlpha)/5)
+ end
+ if currentAlpha >= maxAlpha then
+ currentAlpha = maxAlpha
+ end
+ if next(strataList) then
+ makeForeground()
+ end
+ elseif hasEntered then
+ if currentAlpha > minAlpha then
+ currentAlpha = currentAlpha - elapsed/((maxAlpha - minAlpha)/5)
+ end
+ if currentAlpha <= minAlpha then
+ currentAlpha = minAlpha
+ if not next(strataList) then
+ makeBackground()
+ end
+ end
+ end
+ this:SetAlpha(currentAlpha)
+ end)
+ recheckThirdPartyOptions()
+ do
+ base:Hide()
+ local x = RockConfig.x or 0
+ local y = RockConfig.y or 0
+ local width = RockConfig.width or GetScreenWidth()*3/5
+ local height = RockConfig.height or GetScreenHeight()*3/5
+ base:SetWidth(width)
+ base:SetHeight(height)
+ base:SetPoint("CENTER", UIParent, "CENTER", x, y)
+ base:SetScale(RockConfig.scale or 1)
+ base:EnableMouse(true)
+ base:SetMovable(true)
+ base:SetResizable(true)
+ base:SetResizeBounds(600, 300)
+ base:SetFrameLevel(1)
+ base:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ local bg = newDict(
+ 'bgFile', [[Interface\DialogFrame\UI-DialogBox-Background]],
+ 'edgeFile', [[Interface\DialogFrame\UI-DialogBox-Border]],
+ 'tile', true,
+ 'tileSize', 32,
+ 'edgeSize', 32,
+ 'insets', newDict(
+ 'left', 5,
+ 'right', 6,
+ 'top', 5,
+ 'bottom', 6
+ )
+ )
+ base:SetBackdrop(bg)
+ bg.insets = del(bg.insets)
+ bg = del(bg)
+ base:SetBackdropColor(0, 0, 0)
+ base:SetClampedToScreen(true)
+
+ local header = CreateFrame("Frame", base:GetName() .. "_Header", base)
+ base.header = header
+ header:SetHeight(34.56)
+ header:SetClampedToScreen(true)
+ local left = header:CreateTexture(header:GetName() .. "_TextureLeft", "ARTWORK")
+ header.left = left
+ left:SetPoint("TOPLEFT")
+ left:SetPoint("BOTTOMLEFT")
+ left:SetWidth(11.54)
+ left:SetTexture([[Interface\DialogFrame\UI-DialogBox-Header]])
+ left:SetTexCoord(0.235, 0.28, 0.04, 0.58)
+ local right = header:CreateTexture(header:GetName() .. "_TextureRight", "ARTWORK")
+ header.right = right
+ right:SetPoint("TOPRIGHT")
+ right:SetPoint("BOTTOMRIGHT")
+ right:SetWidth(11.54)
+ right:SetTexture([[Interface\DialogFrame\UI-DialogBox-Header]])
+ right:SetTexCoord(0.715, 0.76, 0.04, 0.58)
+ local center = header:CreateTexture(header:GetName() .. "_TextureCenter", "ARTWORK")
+ header.center = center
+ center:SetPoint("TOPLEFT", left, "TOPRIGHT")
+ center:SetPoint("BOTTOMRIGHT", right, "BOTTOMLEFT")
+ center:SetTexture([[Interface\DialogFrame\UI-DialogBox-Header]])
+ center:SetTexCoord(0.28, 0.715, 0.04, 0.58)
+
+ local closeButton = CreateFrame("Button", base:GetName() .. "_CloseButton", base, "UIPanelCloseButton")
+ base.closeButton = closeButton
+ closeButton:SetFrameLevel(5)
+ closeButton:SetScript("OnClick", function(this)
+ this:GetParent():Hide()
+ end)
+ closeButton:SetPoint("TOPRIGHT", base, "TOPRIGHT", -5, -5)
+
+ base:SetScript("OnHide", function(this)
+ makeForeground()
+ saveState()
+ removeSections(base.treeView)
+ currentAlpha = 1
+ hasEntered = false
+ end)
+
+ header:EnableMouse(true)
+ header:RegisterForDrag("LeftButton")
+ header:SetScript("OnDragStart", function(this)
+ isDragging = true
+ this:GetParent():StartMoving()
+ end)
+ header:SetScript("OnDragStop", function(this)
+ isDragging = false
+ this:GetParent():StopMovingOrSizing()
+ recalculateSavedPosition()
+ end)
+
+ local titleText = header:CreateFontString(header:GetName() .. "_FontString", "OVERLAY", "GameFontNormal")
+ base.titleText = titleText
+ titleText:SetText('-----')
+ titleText:SetPoint("CENTER", base, "TOP", 0, -8)
+ titleText:SetHeight(26)
+ titleText:SetShadowColor(0, 0, 0)
+ titleText:SetShadowOffset(1, -1)
+
+ header:SetPoint("LEFT", titleText, "LEFT", -32, 0)
+ header:SetPoint("RIGHT", titleText, "RIGHT", 32, 0)
+
+ local sizer_se = CreateFrame("Frame", base:GetName() .. "_SizerSoutheast", base)
+ base.sizer_se = sizer_se
+ sizer_se:SetPoint("BOTTOMRIGHT", base, "BOTTOMRIGHT", 0, 0)
+ sizer_se:SetWidth(25)
+ sizer_se:SetHeight(25)
+ sizer_se:EnableMouse(true)
+ sizer_se:RegisterForDrag("LeftButton")
+ sizer_se:SetScript("OnDragStart", function(this)
+ isDragging = true
+ this:GetParent():StartSizing("BOTTOMRIGHT")
+ end)
+ sizer_se:SetScript("OnDragStop", function(this)
+ isDragging = false
+ this:GetParent():StopMovingOrSizing()
+ recalculateSavedPosition()
+ end)
+ local line1 = sizer_se:CreateTexture(sizer_se:GetName() .. "_Line1", "BACKGROUND")
+ line1:SetWidth(14)
+ line1:SetHeight(14)
+ line1:SetPoint("BOTTOMRIGHT", -10, 10)
+ line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
+ local x = 0.1 * 14/17
+ line1:SetTexCoord(1/32 - x, 0.5, 1/32, 0.5 + x, 1/32, 0.5 - x, 1/32 + x, 0.5)
+
+ local line2 = sizer_se:CreateTexture(sizer_se:GetName() .. "_Line2", "BACKGROUND")
+ line2:SetWidth(11)
+ line2:SetHeight(11)
+ line2:SetPoint("BOTTOMRIGHT", -10, 10)
+ line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
+ local x = 0.1 * 11/17
+ line2:SetTexCoord(1/32 - x, 0.5, 1/32, 0.5 + x, 1/32, 0.5 - x, 1/32 + x, 0.5)
+
+ local line3 = sizer_se:CreateTexture(sizer_se:GetName() .. "_Line3", "BACKGROUND")
+ line3:SetWidth(8)
+ line3:SetHeight(8)
+ line3:SetPoint("BOTTOMRIGHT", -10, 10)
+ line3:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
+ local x = 0.1 * 8/17
+ line3:SetTexCoord(1/32 - x, 0.5, 1/32, 0.5 + x, 1/32, 0.5 - x, 1/32 + x, 0.5)
+
+ local sizer_s = CreateFrame("Frame", base:GetName() .. "_SizerSouth", base)
+ base.sizer_s = sizer_s
+ sizer_s:SetPoint("BOTTOMRIGHT", base, "BOTTOMRIGHT", -25, 0)
+ sizer_s:SetPoint("BOTTOMLEFT", base, "BOTTOMLEFT", 0, 0)
+ sizer_s:SetHeight(25)
+ sizer_s:EnableMouse(true)
+ sizer_s:RegisterForDrag("LeftButton")
+ sizer_s:SetScript("OnDragStart", function(this)
+ isDragging = true
+ this:GetParent():StartSizing("BOTTOM")
+ end)
+ sizer_s:SetScript("OnDragStop", function(this)
+ isDragging = false
+ this:GetParent():StopMovingOrSizing()
+ recalculateSavedPosition()
+ end)
+
+ local sizer_e = CreateFrame("Frame", base:GetName() .. "_SizerEast", base)
+ base.sizer_e = sizer_e
+ sizer_e:SetPoint("BOTTOMRIGHT", base, "BOTTOMRIGHT", 0, 25)
+ sizer_e:SetPoint("TOPRIGHT", base, "TOPRIGHT", 0, 0)
+ sizer_e:SetWidth(25)
+ sizer_e:EnableMouse(true)
+ sizer_e:RegisterForDrag("LeftButton")
+ sizer_e:SetScript("OnDragStart", function(this)
+ isDragging = true
+ this:GetParent():StartSizing("RIGHT")
+ end)
+ sizer_e:SetScript("OnDragStop", function(this)
+ isDragging = false
+ this:GetParent():StopMovingOrSizing()
+ recalculateSavedPosition()
+ end)
+ end
+
+ -- tree view
+ local treeView = CreateFrame("Frame", base:GetName() .. "_TreeView", base, "BackdropTemplate")
+ do
+ base.treeView = treeView
+ treeView:SetPoint("LEFT", base, "LEFT", 14, 0)
+ treeView:SetPoint("TOP", base, "TOP", 0, -33)
+ treeView:SetPoint("BOTTOMLEFT", base, "BOTTOMLEFT", 14, 14)
+ treeView:SetWidth(200)
+ treeView:SetResizeBounds(120, 0, 300, 10000)
+
+ local scrollFrame = CreateFrame("ScrollFrame", treeView:GetName() .. "_ScrollFrame", treeView)
+ local scrollChild = CreateFrame("Frame", scrollFrame:GetName() .. "_Frame", scrollFrame)
+ local scrollBar = CreateFrame("Slider", scrollFrame:GetName() .. "_ScrollBar", scrollFrame, "UIPanelScrollBarTemplate")
+ local bg = newDict(
+ 'bgFile', [[Interface\Tooltips\UI-Tooltip-Background]],
+ 'edgeFile', [[Interface\Tooltips\UI-Tooltip-Border]],
+ 'tile', true,
+ 'tileSize', 16,
+ 'edgeSize', 16,
+ 'insets', newDict(
+ 'left', 3,
+ 'right', 3,
+ 'top', 3,
+ 'bottom', 3
+ )
+ )
+ treeView:SetBackdrop(bg)
+ bg.insets = del(bg.insets)
+ bg = del(bg)
+ treeView:SetBackdropBorderColor(0.6, 0.6, 0.6)
+ treeView:SetBackdropColor(0.1, 0.1, 0.1)
+ treeView:SetScript("OnSizeChanged", function(this)
+ this:Reposition()
+ end)
+ treeView:SetFrameLevel(2)
+ treeView:SetFrameStrata("FULLSCREEN_DIALOG")
+ treeView:SetResizable(true)
+
+ treeView.scrollFrame = scrollFrame
+ treeView.scrollChild = scrollChild
+ treeView.scrollBar = scrollBar
+
+ scrollFrame:SetScrollChild(scrollChild)
+ scrollFrame:SetPoint("TOPLEFT", treeView, "TOPLEFT", 8, -12)
+ scrollFrame:SetPoint("BOTTOMRIGHT", treeView, "BOTTOMRIGHT", -28, 12)
+ scrollFrame:EnableMouseWheel(true)
+ scrollFrame:SetScript("OnMouseWheel", function(this, change)
+ local childHeight = scrollChild:CalculateHeight()
+ local frameHeight = scrollFrame:GetHeight()
+ if childHeight <= frameHeight then
+ return
+ end
+
+ local diff = frameHeight - childHeight
+
+ local delta = 1
+ if change < 0 then
+ delta = -1
+ end
+
+ local value = scrollBar:GetValue() + delta*(24/diff)
+ if value < 0 then
+ value = 0
+ elseif value > 1 then
+ value = 1
+ end
+ scrollBar:SetValue(value) -- will trigger OnValueChanged
+ end)
+
+ scrollChild:SetHeight(1)
+ scrollChild:SetWidth(1)
+
+ function scrollChild:CalculateHeight()
+ local top = self:GetTop()
+ if not top then
+ return 0
+ end
+
+ local current = treeView
+
+ local bottom = top
+
+ local sections = current.sections
+ while sections do
+ local section
+ for i,v in ipairs(sections) do
+ local b = v:GetBottom()
+ if b and b < bottom then
+ bottom = b
+ section = v
+ end
+ end
+ if not section then
+ break
+ end
+ current = section
+ sections = current.sections
+ end
+
+ return top - bottom
+ end
+
+ scrollBar:SetPoint("TOPLEFT", scrollFrame, "TOPRIGHT", 0, -16)
+ scrollBar:SetPoint("BOTTOMLEFT", scrollFrame, "BOTTOMRIGHT", 0, 16)
+ scrollBar:SetMinMaxValues(0, 1)
+ scrollBar:SetValueStep(epsilon)
+ scrollBar:SetValue(0)
+ scrollBar:SetWidth(16)
+ scrollBar:SetScript("OnValueChanged", function(this)
+ local max = scrollChild:CalculateHeight() - scrollFrame:GetHeight()
+
+ local val = scrollBar:GetValue() * max
+
+ if math_abs(scrollFrame:GetVerticalScroll() - val) < 1 then
+ return
+ end
+
+ scrollFrame:SetVerticalScroll(val)
+ end)
+ scrollBar:EnableMouseWheel(true)
+ scrollBar:SetScript("OnMouseWheel", function(this, ...)
+ scrollFrame:GetScript("OnMouseWheel")(scrollFrame, ...)
+ end)
+
+ local function reposition(sections, last, depth)
+ if not sections then
+ return last
+ end
+ for i,v in ipairs(sections) do
+ v:ClearAllPoints()
+ v:SetPoint("LEFT", scrollFrame, "LEFT", depth*16, 0)
+ v:SetPoint("RIGHT", scrollFrame, "RIGHT")
+ if not last then
+ v:SetPoint("TOP", scrollChild, "TOP")
+ else
+ v:SetPoint("TOP", last, "BOTTOM")
+ end
+ last = v
+ if v.sections then
+ last = reposition(v.sections, last, depth+1)
+ end
+ end
+ return last
+ end
+
+ local function treeView_OnUpdate(this)
+ this:SetScript("OnUpdate", nil)
+ this:Reposition()
+ end
+ treeView:SetScript("OnUpdate", treeView_OnUpdate)
+
+ local switch = false
+ function treeView:Reposition()
+ if not switch then
+ treeView:SetScript("OnUpdate", treeView_OnUpdate)
+ end
+ switch = not switch
+ reposition(self.sections, nil, 0)
+
+ local height = scrollChild:CalculateHeight()
+
+ if height == 0 then
+ treeView:SetScript("OnUpdate", treeView_OnUpdate)
+ return
+ end
+ if height < scrollFrame:GetHeight() then
+ scrollBar:Hide()
+ scrollFrame:SetPoint("BOTTOMRIGHT", treeView, "BOTTOMRIGHT", -8, 12)
+ scrollBar:SetValue(0)
+ scrollFrame:SetVerticalScroll(0)
+ else
+ scrollBar:Show()
+ scrollFrame:SetPoint("BOTTOMRIGHT", treeView, "BOTTOMRIGHT", -28, 12)
+ end
+ end
+ end
+
+ local addonChooser = CreateFrame("Frame", base:GetName() .. "_AddonChooser", base)
+ do
+ base.addonChooser = addonChooser
+ addonChooser:SetPoint("LEFT", base, "LEFT", 14, 0)
+ addonChooser:SetPoint("TOP", base, "TOP", 0, -16)
+ addonChooser:SetPoint("BOTTOM", treeView, "TOP", 0, 0)
+ addonChooser:SetPoint("RIGHT", treeView, "RIGHT", 0, 0)
+
+ addonChooser:SetScript("OnEnter", function(this)
+ -- show tooltip about choosing addons
+ end)
+ addonChooser:SetScript("OnLeave", function(this)
+ GameTooltip:Hide()
+ end)
+
+ local text = CreateFrame("Button", addonChooser:GetName() .. "_Text", addonChooser, "BackdropTemplate")
+ addonChooser.text = text
+ local fs = text:CreateFontString(text:GetName() .. "_FontString", "OVERLAY", "ChatFontNormal")
+ text.fs = fs
+ fs:SetJustifyH("LEFT")
+ text:SetHeight(24)
+ text:SetScript("OnEnter", SubControl_OnEnter)
+ text:SetScript("OnLeave", SubControl_OnLeave)
+ local bg = newDict(
+ 'bgFile', [[Interface\Tooltips\UI-Tooltip-Background]],
+ 'edgeFile', [[Interface\Tooltips\UI-Tooltip-Border]],
+ 'tile', true,
+ 'tileSize', 16,
+ 'edgeSize', 16,
+ 'insets', newDict(
+ 'left', 3,
+ 'right', 3,
+ 'top', 3,
+ 'bottom', 3
+ )
+ )
+ text:SetBackdrop(bg)
+ bg.insets = del(bg.insets)
+ bg = del(bg)
+ text:SetBackdropBorderColor(0.6, 0.6, 0.6)
+ text:SetBackdropColor(0.1, 0.1, 0.1)
+
+ local icon = text:CreateTexture(text:GetName() .. "_Icon", "ARTWORK")
+ text.icon = icon
+ icon:SetWidth(16)
+ icon:SetHeight(16)
+ icon:SetPoint("LEFT", 5, 0)
+ fs:SetPoint("LEFT", icon, "RIGHT", 0, 0)
+ fs:SetPoint("RIGHT", -5, 0)
+
+ text:SetPoint("LEFT")
+
+ local button = CreateFrame("Button", addonChooser:GetName() .. "_Button", addonChooser)
+ addonChooser.button = button
+ text:SetPoint("RIGHT", button, "LEFT")
+ button:SetWidth(24)
+ button:SetHeight(24)
+ button:SetScript("OnEnter", SubControl_OnEnter)
+ button:SetScript("OnLeave", SubControl_OnLeave)
+ button:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up")
+ button:GetNormalTexture():SetTexCoord(0.09, 0.91, 0.09, 0.91)
+ button:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down")
+ button:GetPushedTexture():SetTexCoord(0.09, 0.91, 0.09, 0.91)
+ button:SetDisabledTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled")
+ button:GetDisabledTexture():SetTexCoord(0.09, 0.91, 0.09, 0.91)
+ button:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight", "ADD")
+ button:GetHighlightTexture():SetTexCoord(0.09, 0.91, 0.09, 0.91)
+ button:SetPoint("RIGHT")
+ button:SetScript("OnClick", function(this, arg1)
+ SetButtonPulse(this, 0, 1)
+ if makePullout then
+ makePullout()
+ end
+ local shown = pullout:IsShown()
+ pullout:Hide()
+ local parent = this:GetParent()
+ if pullout.parent == parent and shown then
+ -- click to hide after it's been opened
+ return
+ end
+ pullout.parent = parent
+ pullout:SetFrameStrata("FULLSCREEN_DIALOG")
+ pullout:SetPoint("TOP", parent.text, "BOTTOM")
+ pullout:SetPoint("LEFT", parent.text, "LEFT")
+ pullout:SetPoint("RIGHT", parent.text, "RIGHT")
+ pullout:Show()
+ pullout:SetHeight(50)
+
+ buildPullout(parent)
+ end)
+
+ text:EnableMouse(true)
+ text:SetScript("OnClick", function(this, arg1)
+ button:Click()
+ end)
+
+ local pulsed = false
+ function addonChooser:Select(addon)
+ if not data[addon] then
+ return
+ end
+ if not pulsed and addon == RockConfig then
+ SetButtonPulse(button, 60, 1)
+ else
+ SetButtonPulse(button, 0, 1)
+ end
+ pulsed = true
+
+ self.value = addon
+
+ local treeView = base.treeView
+ removeSections(treeView)
+ local addonPath = newList(addon)
+ local name = getConfigField(addonPath, 'name', true, false, "string")
+ self.text.fs:SetText(name)
+ local icon = getConfigField(addonPath, 'icon', true, true, "string")
+ self.text.icon:SetTexture(icon)
+ if icon and icon:find([[^Interface\Icons]]) then
+ self.text.icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ self.text.icon:SetTexCoord(0, 1, 0, 1)
+ end
+ getTreeLine(addonPath)
+ addonPath = del(addonPath)
+
+ local treeView_firstSection = treeView.sections[1]
+ if treeView_firstSection then
+ treeView_firstSection:Click()
+ end
+
+ treeView:Reposition()
+ end
+ end
+
+ -- main pane
+ local mainPane = CreateFrame("Frame", base:GetName() .. "_MainPane", base, BackdropTemplateMixin and "BackdropTemplate")
+ do
+ base.mainPane = mainPane
+
+ local inFunc = nil
+ local function paneOnSizeChanged(this)
+ if inFunc then
+ return
+ end
+ inFunc = true
+ mainPane:Reposition()
+ inFunc = nil
+ end
+
+ local bg = newDict(
+ 'bgFile', [[Interface\Tooltips\UI-Tooltip-Background]],
+ 'edgeFile', [[Interface\Tooltips\UI-Tooltip-Border]],
+ 'tile', true,
+ 'tileSize', 16,
+ 'edgeSize', 16,
+ 'insets', newDict(
+ 'left', 3,
+ 'right', 3,
+ 'top', 3,
+ 'bottom', 3
+ )
+ )
+ mainPane:SetBackdrop(bg)
+ bg.insets = del(bg.insets)
+ bg = del(bg)
+ mainPane:SetBackdropBorderColor(0.6, 0.6, 0.6)
+ mainPane:SetBackdropColor(0.1, 0.1, 0.1)
+ mainPane:SetFrameLevel(2)
+ mainPane:SetFrameStrata("FULLSCREEN_DIALOG")
+ mainPane:SetScript("OnSizeChanged", paneOnSizeChanged)
+
+ local scrollFrame = CreateFrame("ScrollFrame", mainPane:GetName() .. "_ScrollFrame", mainPane)
+ local scrollChild = CreateFrame("Frame", mainPane:GetName() .. "_ScrollChild", scrollFrame)
+ local scrollBar = CreateFrame("Slider", mainPane:GetName() .. "_ScrollBar", scrollFrame, "UIPanelScrollBarTemplate")
+ mainPane.scrollFrame = scrollFrame
+ mainPane.scrollChild = scrollChild
+ mainPane.scrollBar = scrollBar
+
+ scrollFrame:SetScrollChild(scrollChild)
+ scrollFrame:SetPoint("TOPLEFT", mainPane, "TOPLEFT", 9, -9)
+ scrollFrame:SetPoint("BOTTOMRIGHT", mainPane, "BOTTOMRIGHT", -28, 12)
+ scrollFrame:EnableMouseWheel(true)
+ scrollFrame:SetScript("OnMouseWheel", function(this, change)
+ local childHeight = scrollChild:CalculateHeight()
+ local frameHeight = scrollFrame:GetHeight()
+ if childHeight <= frameHeight then
+ return
+ end
+
+ nextFreeScroll = GetTime() + 1
+
+ local diff = childHeight - frameHeight
+
+ local delta = 1
+ if change > 0 then
+ delta = -1
+ end
+
+ local value = scrollBar:GetValue() + delta*24/diff
+ if value < 0 then
+ value = 0
+ elseif value > 1 then
+ value = 1
+ end
+ scrollBar:SetValue(value) -- will trigger OnValueChanged
+ end)
+ scrollFrame:SetScript("OnSizeChanged", paneOnSizeChanged)
+
+ scrollChild:SetHeight(1)
+ scrollChild:SetWidth(1)
+
+ local first = true
+ function scrollChild:CalculateHeight()
+ local controls = mainPane.controls
+ if #controls == 0 then
+ return 0
+ else
+ local top = self:GetTop()
+ if not top then
+ return 0
+ end
+ local bottom = top
+ for i,v in ipairs(controls) do
+ local val = v:GetBottom()
+ if val and val < bottom then
+ bottom = val
+ end
+ end
+ return top - bottom
+ end
+ end
+ _G.scrollChild = scrollChild
+
+ scrollBar:SetPoint("TOPLEFT", scrollFrame, "TOPRIGHT", 0, -16)
+ scrollBar:SetPoint("BOTTOMLEFT", scrollFrame, "BOTTOMRIGHT", 0, 16)
+ scrollBar:SetMinMaxValues(0, 1)
+ scrollBar:SetValueStep(epsilon)
+ scrollBar:SetValue(0)
+ scrollBar:SetWidth(16)
+ scrollBar:SetScript("OnValueChanged", function(this)
+ local max = scrollChild:CalculateHeight() - scrollFrame:GetHeight()
+
+ local val = scrollBar:GetValue() * max
+
+ if math_abs(scrollFrame:GetVerticalScroll() - val) < 1 then
+ return
+ end
+
+ scrollFrame:SetVerticalScroll(val)
+
+ scrollFrame:UpdateScrollChildRect()
+ end)
+ scrollBar:EnableMouseWheel(true)
+ scrollBar:SetScript("OnMouseWheel", function(this, ...)
+ scrollFrame:GetScript("OnMouseWheel")(scrollFrame, ...)
+ end)
+
+ mainPane.controls = {}
+
+ mainPane:SetPoint("LEFT", treeView, "RIGHT", -3, 0)
+ mainPane:SetPoint("TOP", base, "TOP", 0, -33)
+ mainPane:SetPoint("BOTTOMRIGHT", base, "BOTTOMRIGHT", -14, 14)
+ local function mainPane_OnUpdate(this)
+ this:SetScript("OnUpdate", nil)
+ this:Reposition()
+ end
+ mainPane:SetScript("OnUpdate", mainPane_OnUpdate)
+
+ local switch = false
+ function mainPane:Reposition()
+ mainPane_Reposition(self)
+ local height = scrollChild:CalculateHeight()
+ if height == 0 then
+ mainPane:SetScript("OnUpdate", mainPane_OnUpdate)
+ return
+ end
+ if not switch then
+ mainPane:SetScript("OnUpdate", mainPane_OnUpdate)
+ end
+ switch = not switch
+ if height < scrollFrame:GetHeight() then
+ scrollBar:Hide()
+ scrollFrame:SetPoint("BOTTOMRIGHT", mainPane, "BOTTOMRIGHT", -9, 12)
+ scrollBar:SetValue(0)
+ scrollFrame:SetVerticalScroll(0)
+ else
+ scrollBar:Show()
+ scrollFrame:SetPoint("BOTTOMRIGHT", mainPane, "BOTTOMRIGHT", -28, 12)
+ end
+
+ local label = self.controls[1] and self.controls[1].label
+ if not label then
+ return
+ end
+ local labelWidth = label:GetWidth()
+ local paneWidth = scrollFrame:GetWidth() - labelWidth - 8
+ for i,v in ipairs(self.controls) do
+ if v.SizeChanged then
+ v:SizeChanged(paneWidth)
+ end
+ end
+
+ scrollBar:GetScript("OnValueChanged")(scrollBar)
+ end
+ end
+
+ do
+ local sizer = CreateFrame("Frame", treeView:GetName() .. "_Sizer", treeView)
+ treeView.sizer = sizer
+ sizer:SetPoint("TOPLEFT", treeView, "TOPRIGHT", -5, 0)
+ sizer:SetPoint("BOTTOMRIGHT", mainPane, "BOTTOMLEFT", 5, 0)
+ sizer:EnableMouse(true)
+ sizer:RegisterForDrag("LeftButton")
+ sizer:SetScript("OnDragStart", function(this)
+ this:GetParent():StartSizing("RIGHT")
+ end)
+ sizer:SetScript("OnDragStop", function(this)
+ this:GetParent():StopMovingOrSizing()
+
+ treeView:ClearAllPoints()
+ treeView:SetPoint("LEFT", base, "LEFT", 14, 0)
+ treeView:SetPoint("TOP", base, "TOP", 0, -33)
+ treeView:SetPoint("BOTTOMLEFT", base, "BOTTOMLEFT", 14, 14)
+ end)
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Shows a tooltip, with the given information.
+Arguments:
+ Frame - the frame to be the owner
+ string - the name of the item being hovered over, act as title.
+ string - the descripiton of the item being hovered over, acts as the text.
+Example:
+ showTooltip(control, "Alpha", "Description of alpha")
+-----------------------------------------------------------------------------]]
+local function showTooltip(frame, name, desc, isDisabled)
+ _G.GameTooltip_SetDefaultAnchor(GameTooltip, frame)
+
+ if isDisabled then
+ GameTooltip:SetText(name, GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b, 1)
+ else
+ GameTooltip:SetText(name, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b, 1)
+ end
+ if name ~= desc then
+ if isDisabled then
+ GameTooltip:AddLine(desc, GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b, 1)
+ else
+ GameTooltip:AddLine(desc, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
+ end
+ end
+ GameTooltip:Show()
+end
+
+local clearMainPane, populateMainPane
+
+do
+ -- tree stuff
+ local selectedTreeLine
+
+ local TreeLine_Unselect, TreeLine_OnClick, TreeLine_OnExpandClick
+
+ -- fill a list with a tree holding the expanded trees
+ local function fillExpandedList(currentLine, expanded, num)
+ if not num then
+ num = 1
+ end
+ if not currentLine.sections then
+ return
+ end
+ for i,v in ipairs(currentLine.sections) do
+ if v.expand:IsShown() and v.expand:GetNormalTexture():GetTexture() ~= [[Interface\Buttons\UI-PlusButton-UP]] then
+ local t = newList()
+ expanded[v[num]] = t
+ fillExpandedList(v, t, num+1)
+ end
+ end
+ end
+
+ -- expand the lines based on a table created by fillExpandedList
+ local function expandTreeLines(currentLine, expanded, num)
+ if not num then
+ num = 1
+ end
+ if not currentLine.sections then
+ return
+ end
+ for i,v in ipairs(currentLine.sections) do
+ local v_num = v[num]
+ local var = expanded[v_num]
+ if var then
+ if v:IsEnabled() == 1 and v.expand:IsShown() then
+ local tex = v.expand:GetNormalTexture():GetTexture()
+ TreeLine_OnExpandClick(v.expand, true)
+ expandTreeLines(v, var, num+1)
+ end
+ expanded[v_num] = del(var)
+ end
+ end
+ end
+
+ local pulloutPath, pulloutYDiff, treeView_scroll, treeView_scrollval, mainPane_scroll, mainPane_scrollval, selectedPath, expandedList, currentAddon
+ function saveState()
+ if pulloutPath then
+ pulloutPath = del(pulloutPath)
+ end
+ pulloutPath = nil
+ pulloutYDiff = nil
+ if pullout and pullout:IsShown() then
+ pulloutPath = newList(unpack(pullout.parent))
+ for i = 1, pullout:GetNumPoints() do
+ local point, frame, relpoint, xdiff, ydiff = pullout:GetPoint(i)
+ if point == "TOP" then
+ pulloutYDiff = ydiff
+ break
+ end
+ end
+ end
+
+ treeView_scroll = base.treeView.scrollBar:GetValue()
+ treeView_scrollval = base.treeView.scrollFrame:GetVerticalScroll()
+ mainPane_scroll = base.mainPane.scrollBar:GetValue()
+ mainPane_scrollval = base.mainPane.scrollFrame:GetVerticalScroll()
+
+ if selectedPath then
+ selectedPath = del(selectedPath)
+ end
+ if selectedTreeLine then
+ selectedPath = newList(unpack(selectedTreeLine))
+ end
+
+ local treeView = base.treeView
+ if expandedList then
+ expandedList = del(expandedList)
+ end
+ expandedList = newList()
+ fillExpandedList(treeView, expandedList)
+
+ currentAddon = base.addonChooser.value
+ end
+
+ function restoreState()
+ local treeView = base.treeView
+ removeSections(treeView)
+
+ if not currentAddon then
+ return false
+ end
+ base.addonChooser:Select(currentAddon)
+ local ret = false
+ if expandedList then
+ expandTreeLines(treeView, expandedList)
+ expandedList = del(expandedList)
+ ret = true
+ end
+ if not treeView.sections then
+ return false
+ end
+
+ if selectedPath then
+ local current = treeView
+ local last
+ for i,v in ipairs(selectedPath) do
+ local sections = current.sections
+ last = current
+ current = nil
+ if not sections then
+ break
+ end
+ for j, u in ipairs(sections) do
+ if u[i] == v then
+ current = u
+ break
+ end
+ end
+ if not current then
+ break
+ end
+ end
+ if current == treeView then
+ current = nil
+ end
+ if last == treeView then
+ last = nil
+ end
+ if current or last then
+ TreeLine_OnClick(current or last, true)
+ end
+ selectedPath = del(selectedPath)
+ end
+
+ if treeView_scroll and treeView.scrollBar:IsShown() then
+ treeView.scrollBar:SetValue(treeView_scroll)
+ treeView.scrollFrame:SetVerticalScroll(treeView_scrollval)
+ end
+
+ local mainPane = base.mainPane
+
+ if mainPane_scroll and mainPane.scrollBar:IsShown() then
+ mainPane.scrollBar:SetValue(mainPane_scroll)
+ mainPane.scrollFrame:SetVerticalScroll(mainPane_scrollval)
+ end
+
+ if pulloutPath then
+ for _, control in ipairs(base.mainPane.controls) do
+ for i,v in ipairs(pulloutPath) do
+ if v ~= control[i] then
+ if control[i] == nil then
+ if control.type == 'group' and control.groupType == 'inline' then
+ local control_controls = control.controls
+ control = nil
+ for _, subControl in ipairs(control_controls) do
+ if subControl[i] == v then
+ control = subControl
+ break
+ end
+ end
+ end
+ if not control then
+ break
+ end
+ else
+ control = nil
+ break
+ end
+ end
+ end
+ if control then
+ if control.button and control.type == 'choice' then
+ control.button:Click()
+ for i = 1, pullout:GetNumPoints() do
+ local point, frame, relpoint, xdiff, ydiff = pullout:GetPoint(i)
+ if point == "TOP" then
+ pullout:SetPoint(point, frame, relpoint, xdiff, pulloutYDiff)
+ break
+ end
+ end
+ end
+ break
+ end
+ end
+ pulloutPath = del(pulloutPath)
+ pulloutYDiff = nil
+ end
+ return ret
+ end
+
+ --[[---------------------------------------------------------------------------
+ Notes:
+ * Refreshes the controls inside the main pane, rechecking existence and the current values of all of them.
+ Example:
+ refreshConfigMenu()
+ -----------------------------------------------------------------------------]]
+ function refreshConfigMenu(object)
+ if object and not data[object] then
+ return
+ end
+ if base.addonChooser.value ~= object then
+ return
+ end
+
+ local fixStrata = false
+ if next(strataList) then
+ fixStrata = true
+ makeForeground()
+ end
+
+ saveState()
+
+ if selectedTreeLine then
+ TreeLine_Unselect(selectedTreeLine)
+ end
+
+ restoreState()
+
+ if fixStrata then
+ makeBackground()
+ end
+ end
+
+ -- show the highlight and tooltip
+ local function TreeLine_OnEnter(this)
+ if this:IsEnabled() == 1 then
+ this.highlight:SetAlpha(1)
+ this.highlight:Show()
+ end
+
+ local name = this.text:GetText()
+ local desc = this.desc
+ if not desc then
+ desc = getConfigField(this, 'desc', true, false, "string")
+ this.desc = desc
+ end
+ showTooltip(this, name, desc, this:IsEnabled() ~= 1)
+ end
+
+ -- hide the highlight (unless selected) and tooltip
+ local function TreeLine_OnLeave(this)
+ if this ~= selectedTreeLine then
+ this.highlight:Hide()
+ else
+ this.highlight:SetAlpha(0.7)
+ end
+ GameTooltip:Hide()
+ end
+
+ -- unselect the line, thus clearing any results from it
+ function TreeLine_Unselect(this)
+ this.highlight:Hide()
+ selectedTreeLine = nil
+ base.titleText:SetText('-----')
+
+ clearMainPane(base.mainPane)
+ end
+
+ -- select the line
+ function TreeLine_OnClick(this, dontExpand)
+ if this:IsEnabled() ~= 1 then
+ return
+ end
+ local last_selectedTreeLine = selectedTreeLine
+ if selectedTreeLine then
+ TreeLine_Unselect(selectedTreeLine)
+ end
+
+ selectedTreeLine = this
+ if GetMouseFocus() == this then
+ this.highlight:SetAlpha(1)
+ else
+ this.highlight:SetAlpha(0.7)
+ end
+ this.highlight:Show()
+
+ local t = newList()
+ for i = 1, #this do
+ -- double-check existence of config tables, just in case
+ -- also track breadcrumbs so the title is nice
+ local path = newList(unpack(this, 1, i))
+ if not hasConfigTable(path) then
+ TreeLine_Unselect(this)
+ t = del(t)
+ path = del(path)
+ return
+ end
+ t[i] = getConfigField(path, 'name', true, false, "string")
+ path = del(path)
+ end
+ base.titleText:SetText(table_concat(t, " -> "))
+ t = del(t)
+
+ if this.expand:IsShown() and dontExpand ~= true then
+ if this == last_selectedTreeLine then
+ this.expand:Click()
+ else
+ TreeLine_OnExpandClick(this.expand, true)
+ end
+ end
+
+ populateMainPane(this)
+ end
+
+ -- clear a tree
+ function removeSections(treeLine, object)
+ local sections = treeLine.sections
+ if sections then
+ for i,v in ipairs(sections) do
+ if not object or v[1] == object then
+ removeSections(v)
+ releaseTreeLine(v)
+ if object then
+ table.remove(sections, i)
+ return
+ end
+ end
+ end
+ treeLine.sections = del(sections)
+ end
+ end
+
+ local plusButtonUpTextureFileId = GetFileIDFromPath([[Interface\Buttons\UI-PlusButton-UP]])
+ -- expand a tree, create the sub-sections
+ function TreeLine_OnExpandClick(this, openOnly)
+ if not this:IsShown() then
+ return
+ end
+ local treeLine = this:GetParent()
+ local tex = this:GetNormalTexture():GetTexture()
+
+ local expand = (tex == plusButtonUpTextureFileId)
+ if openOnly == true or openOnly == false then
+ if openOnly then
+ if not expand then
+ return
+ end
+ else
+ if expand then
+ return
+ end
+ end
+ end
+ if expand then
+ this:SetNormalTexture([[Interface\Buttons\UI-MinusButton-UP]])
+ this:SetPushedTexture([[Interface\Buttons\UI-MinusButton-Down]])
+ this:SetDisabledTexture([[Interface\Buttons\UI-MinusButton-Disabled]])
+ --this:SetHighlightTexture([[Interface\Buttons\UI-MinusButton-Hilight]])
+ local args = getConfigField(treeLine, 'args', false, false, "table")
+ for k,v in pairs(args) do
+ local t = newList(unpack(treeLine))
+ t[#t+1] = k
+ local v_type = getConfigField(t, 'type', true, false, "string")
+ if v_type == 'group' then
+ local v_groupType = getConfigField(t, 'groupType', true, "normal", "string")
+ if v_groupType ~= "inline" then
+ getTreeLine(t)
+ end
+ end
+ t = del(t)
+ end
+ if #treeLine == 1 then
+ local extraArgs = getConfigField(treeLine, 'extraArgs', false, true, "table")
+ if extraArgs then
+ for k,v in pairs(extraArgs) do
+ if args[k] == nil then
+ local t = newList(unpack(treeLine))
+ t[#t+1] = k
+ local v_type = getConfigField(t, 'type', true, false, "string")
+ if v_type == 'group' then
+ local v_groupType = getConfigField(t, 'groupType', true, "normal", "string")
+ if v_groupType ~= "inline" then
+ getTreeLine(t)
+ end
+ end
+ t = del(t)
+ end
+ end
+ end
+ end
+ sortTreeLineSections(treeLine)
+ else
+ this:SetNormalTexture([[Interface\Buttons\UI-PlusButton-UP]])
+ this:SetPushedTexture([[Interface\Buttons\UI-PlusButton-Down]])
+ this:SetDisabledTexture([[Interface\Buttons\UI-PlusButton-Disabled]])
+ this:SetHighlightTexture([[Interface\Buttons\UI-PlusButton-Hilight]])
+ removeSections(treeLine)
+ end
+ base.treeView:Reposition()
+
+ local scrollValue = base.treeView.scrollFrame:GetVerticalScroll()
+
+ local max = base.treeView.scrollChild:CalculateHeight() - base.treeView.scrollFrame:GetHeight()
+
+ base.treeView.scrollBar:SetValue(scrollValue/max)
+ end
+
+ local treeLinesDisabled = {}
+ local function frame_IsEnabled(this)
+ return treeLinesDisabled[this] and 0 or 1
+ end
+ local function frame_Disable(this)
+ if treeLinesDisabled[this] then
+ return
+ end
+ treeLinesDisabled[this] = true
+ local tex = this.expand:GetNormalTexture():GetTexture()
+ TreeLine_OnExpandClick(this.expand, false)
+ this.expand:Disable()
+ this.expand:EnableMouse(false)
+ this.text:SetFontObject(GameFontDisable)
+ this:SetPushedTextOffset(0, 0)
+ this.highlight:Hide()
+ if selectedTreeLine == this then
+ TreeLine_Unselect(this)
+ end
+ end
+ local function frame_Enable(this)
+ if not treeLinesDisabled[this] then
+ return
+ end
+ treeLinesDisabled[this] = nil
+ this.expand:Enable()
+ this.expand:EnableMouse(true)
+ this.text:SetFontObject(GameFontHighlight)
+ this:SetPushedTextOffset(1.45, -1.45)
+ end
+
+ local pool = {}
+ -- remove a tree line, put it in the pool
+ function releaseTreeLine(frame)
+ if selectedTreeLine == frame then
+ TreeLine_Unselect(frame)
+ end
+ frame:Hide()
+ frame:Enable()
+ frame:ClearAllPoints()
+ frame.highlight:Hide()
+ frame.expand:Show()
+ frame.expand:SetNormalTexture([[Interface\Buttons\UI-PlusButton-UP]])
+ frame.expand:SetPushedTexture([[Interface\Buttons\UI-PlusButton-Down]])
+ frame.expand:SetDisabledTexture([[Interface\Buttons\UI-PlusButton-Disabled]])
+ frame.expand:SetHighlightTexture([[Interface\Buttons\UI-PlusButton-Hilight]])
+ frame.icon:SetTexture(nil)
+ frame.icon:SetWidth(16)
+ frame.icon:SetHeight(16)
+ frame.desc = nil
+ for i = 1, #frame do
+ frame[i] = nil
+ end
+ pool[frame] = true
+ return nil
+ end
+
+ local treeLineNum = 0
+ -- create a preliminary tree line
+ local function _getTreeLine()
+ local frame = next(pool)
+ if frame then
+ pool[frame] = nil
+ frame:Show()
+ return frame
+ end
+ treeLineNum = treeLineNum + 1
+ frame = CreateFrame("Button", base.treeView:GetName() .. "_TreeLine" .. treeLineNum, base.treeView.scrollChild)
+ local text = frame:CreateFontString(frame:GetName() .. "_Text", "OVERLAY", "GameFontHighlight")
+ frame.text = text
+ text:SetJustifyH("LEFT")
+ frame:SetFontString(text)
+ frame:SetHeight(16)
+ frame:EnableMouse(true)
+ frame:SetScript("OnEnter", TreeLine_OnEnter)
+ frame:SetScript("OnLeave", TreeLine_OnLeave)
+ frame:SetScript("OnClick", TreeLine_OnClick)
+ frame:SetFrameLevel(10)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+
+ frame.Enable = frame_Enable
+ frame.Disable = frame_Disable
+ frame.IsEnabled = frame_IsEnabled
+
+ local highlight = frame:CreateTexture(frame:GetName() .. "_Highlight", "BACKGROUND")
+ frame.highlight = highlight
+ highlight:SetTexture([[Interface\QuestFrame\UI-QuestTitleHighlight]])
+ highlight:SetBlendMode("ADD")
+ highlight:SetAllPoints(frame)
+ highlight:Hide()
+
+ local expand = CreateFrame("Button", frame:GetName() .. "_Expand", frame)
+ frame.expand = expand
+ expand:SetNormalTexture([[Interface\Buttons\UI-PlusButton-UP]])
+ expand:SetPushedTexture([[Interface\Buttons\UI-PlusButton-Down]])
+ expand:SetDisabledTexture([[Interface\Buttons\UI-PlusButton-Disabled]])
+ expand:SetHighlightTexture([[Interface\Buttons\UI-PlusButton-Hilight]])
+ expand:SetScript("OnClick", TreeLine_OnExpandClick)
+ expand:SetFrameLevel(21)
+ expand:SetWidth(16)
+ expand:SetHeight(16)
+
+ local icon = frame:CreateTexture(frame:GetName() .. "_Icon", "OVERLAY")
+ frame.icon = icon
+ icon:SetWidth(16)
+ icon:SetHeight(16)
+ icon:SetPoint("LEFT", expand, "RIGHT", 1, 0)
+
+ expand:SetPoint("LEFT", frame, "LEFT", 0, 0)
+ text:SetPoint("LEFT", icon, "RIGHT", 0, 0)
+ text:SetPoint("RIGHT", frame, "RIGHT", 0, 0)
+
+ return frame
+ end
+
+ -- fetch a preliminary tree line and set it up
+ function getTreeLine(path)
+ if not hasConfigTable(path) then
+ return nil
+ end
+ local hidden = getConfigField(path, 'hidden', false, true)
+ if hidden then
+ return
+ end
+ local parent = base.treeView
+ for i = 1, #path-1 do
+ local u = path[i]
+ local good = false
+ if not parent.sections then
+ return nil
+ end
+ for k,v in pairs(parent.sections) do
+ if v[i] == u then
+ parent = v
+ good = true
+ break
+ end
+ end
+ if not good then
+ return nil
+ end
+ end
+ local line = _getTreeLine()
+ local sections = parent.sections
+ if not sections then
+ sections = newList()
+ parent.sections = sections
+ end
+ sections[#sections+1] = line
+ for i,v in ipairs(path) do
+ line[i] = v
+ end
+ local hasChild = false
+ local args = getConfigField(path, 'args', false, false, "table")
+ if not args then
+ -- error occurred
+ sections[#sections] = releaseTreeLine(line)
+ return
+ end
+ for k,v in pairs(args) do
+ local t = newList(unpack(path))
+ t[#t+1] = k
+ local v_type = getConfigField(t, 'type', true, false, "string")
+ if v_type == "group" then
+ local v_groupType = getConfigField(t, 'groupType', true, "normal", "string")
+ if v_groupType ~= "inline" then
+ local v_hidden = getConfigField(t, 'hidden', false, true)
+ if not v_hidden then
+ hasChild = true
+ end
+ end
+ end
+ t = del(t)
+ if hasChild then
+ break
+ end
+ end
+ if not hasChild and #path == 1 then
+ local extraArgs = getConfigField(path, 'extraArgs', false, true, "table")
+ if extraArgs then
+ for k,v in pairs(extraArgs) do
+ if args[k] == nil then
+ local t = newList(unpack(path))
+ t[#t+1] = k
+ local v_type = getConfigField(t, 'type', true, false, "string")
+ if v_type == "group" then
+ local v_groupType = getConfigField(t, 'groupType', true, "normal", "string")
+ if v_groupType ~= "inline" then
+ hasChild = true
+ end
+ end
+ t = del(t)
+ if hasChild then
+ break
+ end
+ end
+ end
+ end
+ end
+ if not hasChild then
+ line.expand:Hide()
+ end
+ line.text:SetText(getConfigField(path, 'name', true, false, "string"))
+ local icon = #path >= 2 and getConfigField(path, 'icon', true, true, "string")
+ if icon then
+ line.icon:SetTexture(icon)
+ if icon:find([[^Interface\Icons\]]) then
+ line.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
+ else
+ line.icon:SetTexCoord(0, 1, 0, 1)
+ end
+ local size = getConfigField(path, 'iconSize', false, 1, "number")
+ line.icon:SetWidth(size*16)
+ line.icon:SetHeight(size*16)
+
+ local texCoord = getConfigField(path, 'iconTexCoord', false, true, "table")
+ if texCoord then
+ line.icon:SetTexCoord(unpack(texCoord))
+ else
+ line.icon:SetTexCoord(0, 1, 0, 1)
+ end
+ else
+ line.icon:SetWidth(epsilon)
+ end
+ local disabled = getConfigField(path, 'disabled', false, true)
+ if disabled then
+ line:Disable()
+ end
+ return line
+ end
+
+ do
+ -- helping sorting function for the groups.
+ local function treeLineSort(alpha, bravo)
+ local alpha_order = getConfigField(alpha, 'order', false, 100, "number")
+ local bravo_order = getConfigField(bravo, 'order', false, 100, "number")
+ if alpha_order == bravo_order then
+ return alpha.text:GetText():lower() < bravo.text:GetText():lower()
+ else
+ if alpha_order < 0 then
+ if bravo_order < 0 then
+ return alpha_order < bravo_order
+ else
+ return false
+ end
+ else
+ if bravo_order < 0 then
+ return true
+ else
+ return alpha_order < bravo_order
+ end
+ end
+ end
+ end
+ -- sort the sub-trees of the given tree line
+ function sortTreeLineSections(treeLine)
+ local sections = treeLine.sections
+ if not sections then
+ return
+ end
+
+ table_sort(sections, treeLineSort)
+ end
+ end
+end
+
+do
+ local releaseLabel, getLabel
+ do
+ local labelPool = {}
+ -- remove a label, put it in the pool
+ function releaseLabel(frame)
+ frame:Enable()
+ frame:Hide()
+ frame:ClearAllPoints()
+ for i = 1, #frame do
+ frame[i] = nil
+ end
+ labelPool[frame] = true
+ frame.text:SetText(nil)
+ frame.icon:SetTexture(nil)
+ return nil
+ end
+
+ -- show tooltip
+ local function Label_OnEnter(this)
+ local control = this.control
+ local name = this.text:GetText()
+ local desc = control.desc
+ if not desc then
+ desc = getConfigField(control, 'desc', true, false, "string")
+ control.desc = desc
+ end
+ showTooltip(control, name, desc, this:IsEnabled() ~= 1)
+ end
+
+ -- hide tooltip
+ local function Label_OnLeave(this)
+ GameTooltip:Hide()
+ end
+
+ local labelsDisabled = {}
+ -- fake enable function, turn non-gray
+ local function Label_Enable(this)
+ if not labelsDisabled[this] then
+ return
+ end
+ labelsDisabled[this] = nil
+ this.text:SetFontObject(GameFontNormal)
+ end
+ -- fake disable function, turn gray
+ local function Label_Disable(this)
+ if labelsDisabled[this] then
+ return
+ end
+ labelsDisabled[this] = true
+ this.text:SetFontObject(GameFontDisable)
+ end
+ -- fake check enable function. Note: this returns 0 and 1 because Blizzard does this.
+ local function Label_IsEnabled(this)
+ return labelsDisabled[this] and 0 or 1
+ end
+ local labelNum = 0
+ -- create a preliminary label
+ local function _getLabel()
+ local frame = next(labelPool)
+ if frame then
+ labelPool[frame] = nil
+ frame:Show()
+ return frame
+ end
+ local mainPane = base.mainPane
+ labelNum = labelNum + 1
+ frame = CreateFrame("Frame", mainPane:GetName() .. "_Label" .. labelNum, mainPane.scrollChild)
+ local text = frame:CreateFontString(frame:GetName() .. "_FontString", "OVERLAY", "GameFontNormal")
+ frame.text = text
+ text:SetPoint("LEFT")
+ text:SetJustifyH("LEFT")
+ local icon = frame:CreateTexture(frame:GetName() .. "_Icon", "ARTWORK")
+ frame.icon = icon
+ icon:SetPoint("RIGHT", text, "LEFT", -1, 0)
+
+ frame:SetScript("OnEnter", Label_OnEnter)
+ frame:SetScript("OnLeave", Label_OnLeave)
+ frame:EnableMouse(true)
+ frame.IsEnabled = Label_IsEnabled
+ frame.Enable = Label_Enable
+ frame.Disable = Label_Disable
+
+ return frame
+ end
+ -- fetch and set up a label
+ function getLabel(path, control)
+ local frame = _getLabel()
+
+ local mainPane = base.mainPane
+ control.label = frame
+ frame.control = control
+ for i,v in ipairs(path) do
+ frame[i] = v
+ end
+ local name = getConfigField(frame, 'name', true, false, "string")
+ frame.text:SetText(name)
+ local icon = getConfigField(frame, 'icon', true, true, "string")
+ if icon then
+ frame.icon:Show()
+ frame.icon:SetTexture(icon)
+ if icon:find([[^Interface\Icons\]]) then
+ frame.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
+ else
+ frame.icon:SetTexCoord(0, 1, 0, 1)
+ end
+ local size = getConfigField(frame, 'iconSize', false, 1, "number")
+ frame.icon:SetWidth(16*size)
+ frame.icon:SetHeight(16*size)
+
+ local texCoord = getConfigField(frame, 'iconTexCoord', false, true, "table")
+ if texCoord then
+ frame.icon:SetTexCoord(unpack(texCoord))
+ else
+ frame.icon:SetTexCoord(0, 1, 0, 1)
+ end
+ else
+ frame.icon:Hide()
+ end
+ return frame
+ end
+ end
+
+ -- show a tooltip on hover
+ local function Control_OnEnter(this)
+ local name = this.label.text:GetText()
+ local desc = this.desc
+ if not desc then
+ desc = getConfigField(this, 'desc', true, false, "string")
+ this.desc = desc
+ end
+ showTooltip(this, name, desc, this:IsEnabled() ~= 1)
+ end
+
+ -- hide tooltip on unhover
+ local function Control_OnLeave(this)
+ GameTooltip:Hide()
+ end
+
+ local function recolorEditBoxStyle(editBox, r, g, b, a)
+ editBox.line1:SetVertexColor(r*3/4, g*3/4, b*3/4, a or 1)
+ editBox.line2:SetVertexColor(r*3/4, g*3/4, b*3/4, a or 1)
+ editBox.line3:SetVertexColor(r*3/8, g*3/8, b*3/8, a or 1)
+ editBox.line4:SetVertexColor(r*3/8, g*3/8, b*3/8, a or 1)
+ end
+
+ local function styleEditBox(editBox)
+ local isMultiLine = editBox:IsMultiLine()
+ local line1 = editBox.line1 or editBox:CreateTexture(editBox:GetName() .. "_Line1", "BACKGROUND")
+ editBox.line1 = line1
+ line1:SetTexture([[Interface\Buttons\WHITE8X8]])
+ line1:SetHeight(1)
+ line1:SetPoint("TOPLEFT", editBox, "BOTTOMLEFT", 0, 1)
+ line1:SetPoint("TOPRIGHT", editBox, "BOTTOMRIGHT", 0, 1)
+
+ local line2 = editBox.line2 or editBox:CreateTexture(editBox:GetName() .. "_Line2", "BACKGROUND")
+ editBox.line2 = line2
+ line2:SetTexture([[Interface\Buttons\WHITE8X8]])
+ line2:SetWidth(1)
+ line2:SetPoint("TOPLEFT", editBox, "TOPRIGHT", 0, isMultiLine and 3 or 0)
+ line2:SetPoint("BOTTOMLEFT", editBox, "BOTTOMRIGHT", 0, 0)
+
+ local line3 = editBox.line3 or editBox:CreateTexture(editBox:GetName() .. "_Line3", "BACKGROUND")
+ editBox.line3 = line3
+ line3:SetTexture([[Interface\Buttons\WHITE8X8]])
+ line3:SetHeight(1)
+ line3:SetPoint("BOTTOMLEFT", editBox, "TOPLEFT", 0, isMultiLine and 2 or -1)
+ line3:SetPoint("BOTTOMRIGHT", editBox, "TOPRIGHT", 0, isMultiLine and 2 or -1)
+
+ local line4 = editBox.line4 or editBox:CreateTexture(editBox:GetName() .. "_Line4", "BACKGROUND")
+ editBox.line4 = line4
+ line4:SetTexture([[Interface\Buttons\WHITE8X8]])
+ line4:SetWidth(1)
+ line4:SetPoint("TOPRIGHT", editBox, "TOPLEFT", 0, isMultiLine and 3 or 0)
+ line4:SetPoint("BOTTOMRIGHT", editBox, "BOTTOMLEFT", 0, 0)
+
+ recolorEditBoxStyle(editBox, 1, 1, 1, 1)
+ end
+
+ local releaseExecuteControl, getExecuteControl
+ do
+ -- button
+ local pool = {}
+ -- remove a button and put it in the pool
+ function releaseExecuteControl(frame)
+ frame:Hide()
+ frame:Enable()
+ frame.button:Enable()
+ frame.confirmButton:Hide()
+ frame.confirmButton:SetChecked(false)
+ frame:ClearAllPoints()
+ for i = 1, #frame do
+ frame[i] = nil
+ end
+ frame.desc = nil
+ pool[frame] = true
+ return nil
+ end
+ -- when pressed, the button should look pressed
+ local function button_OnMouseDown(this)
+ if this:IsEnabled() == 1 then
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ end
+ end
+ -- when depressed, return to normal
+ local function button_OnMouseUp(this)
+ if this:IsEnabled() == 1 then
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ end
+ end
+ local executeControlsDisabled = {}
+ -- fake enable check
+ local function frame_IsEnabled(this)
+ return executeControlsDisabled[this] and 0 or 1
+ end
+ -- when disabled, turn gray
+ local function frame_Disable(this)
+ if executeControlsDisabled[this] then
+ return
+ end
+ executeControlsDisabled[this] = true
+ this.label:Disable()
+ this.button:Disable()
+ this.confirmButton:Disable()
+ this.confirmButton:EnableMouse(false)
+ this.confirmButton.text:SetFontObject(GameFontDisableSmall)
+ end
+ -- when enabled, return to normal
+ local function frame_Enable(this)
+ if not executeControlsDisabled[this] then
+ return
+ end
+ executeControlsDisabled[this] = nil
+ this.label:Enable()
+ this.button:Enable()
+ this.confirmButton:Enable()
+ if this.confirmButton:IsShown() and not this.confirmButton:GetChecked() then
+ this.button:Disable()
+ end
+ this.confirmButton:EnableMouse(true)
+ this.confirmButton.text:SetFontObject(GameFontNormalSmall)
+ end
+
+ local function confirmButton_OnClick(this)
+ if this:GetChecked() then
+ this:GetParent().button:Enable()
+ else
+ this:GetParent().button:Disable()
+ end
+ end
+
+ local function button_Disable(this)
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this:__Disable()
+ this:EnableMouse(false)
+ end
+
+ local function button_Enable(this)
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this:__Enable()
+ this:EnableMouse(true)
+ end
+
+ -- call the actual function
+ local function button_OnClick(this)
+ callConfigField(this:GetParent(), 'func')
+ refreshConfigMenu(this:GetParent()[1])
+ end
+ local executeControlNum = 0
+ -- create a preliminary button
+ local function _getExecuteControl()
+ local frame = next(pool)
+ if frame then
+ pool[frame] = nil
+ frame:Show()
+ return frame
+ end
+ executeControlNum = executeControlNum + 1
+ local mainPane = base.mainPane
+ frame = CreateFrame("Frame", mainPane:GetName() .. "_ExecuteControl" .. executeControlNum, mainPane.scrollChild)
+
+ local button = CreateFrame("Button", frame:GetName() .. "_Button", frame)
+ frame.button = button
+ local left = button:CreateTexture(button:GetName() .. "_LeftTexture", "BACKGROUND")
+ button.left = left
+ local middle = button:CreateTexture(button:GetName() .. "_MiddleTexture", "BACKGROUND")
+ button.middle = middle
+ local right = button:CreateTexture(button:GetName() .. "_RightTexture", "BACKGROUND")
+ button.right = right
+ left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+
+ left:SetPoint("TOPLEFT")
+ left:SetPoint("BOTTOMLEFT")
+ left:SetWidth(12)
+ left:SetTexCoord(0, 0.09375, 0, 0.6875)
+
+ right:SetPoint("TOPRIGHT")
+ right:SetPoint("BOTTOMRIGHT")
+ right:SetWidth(12)
+ right:SetTexCoord(0.53125, 0.625, 0, 0.6875)
+
+ middle:SetPoint("TOPLEFT", left, "TOPRIGHT")
+ middle:SetPoint("BOTTOMRIGHT", right, "BOTTOMLEFT")
+ middle:SetTexCoord(0.09375, 0.53125, 0, 0.6875)
+
+ button:SetScript("OnMouseDown", button_OnMouseDown)
+ button:SetScript("OnMouseUp", button_OnMouseUp)
+
+ button.__Enable = button.Enable
+ button.__Disable = button.Disable
+ button.Enable = button_Enable
+ button.Disable = button_Disable
+
+ frame.IsEnabled = frame_IsEnabled
+ frame.Disable = frame_Disable
+ frame.Enable = frame_Enable
+
+ local text = button:CreateFontString(button:GetName() .. "_FontString", "ARTWORK")
+ button:SetFontString(text)
+ button.text = text
+ text:SetPoint("LEFT", button, "LEFT", 7, 0)
+ text:SetPoint("RIGHT", button, "RIGHT", -7, 0)
+
+ button[SET_NORMAL_FONT_OBJECT](button, GameFontNormal)
+ button:SetHighlightFontObject(GameFontHighlight)
+ button:SetDisabledFontObject(GameFontDisable)
+ local highlight = button:CreateTexture(button:GetName() .. "_Highlight", "OVERLAY", "UIPanelButtonHighlightTexture")
+ button:SetHighlightTexture(highlight)
+
+ button:SetScript("OnClick", button_OnClick)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ button:SetScript("OnEnter", SubControl_OnEnter)
+ button:SetScript("OnLeave", SubControl_OnLeave)
+
+ frame:EnableMouse(true)
+ button:EnableMouse(true)
+
+ frame:SetHeight(24)
+ button:SetAllPoints()
+
+ local confirmButton = CreateFrame("CheckButton", frame:GetName() .. "_ConfirmButton", frame, "UICheckButtonTemplate")
+ frame.confirmButton = confirmButton
+ confirmButton:SetPoint("LEFT")
+ confirmButton.text = _G[confirmButton:GetName() .. "Text"]
+ confirmButton.text:SetText("Pants")
+ confirmButton:Hide()
+ confirmButton:SetScript("OnEnter", SubControl_OnEnter)
+ confirmButton:SetScript("OnLeave", SubControl_OnLeave)
+ confirmButton:SetScript("OnClick", confirmButton_OnClick)
+
+ frame.type = 'execute'
+
+ return frame
+ end
+ -- fetch and set up a button
+ function getExecuteControl(path, parent)
+ local frame = _getExecuteControl()
+
+ local controls = parent.controls
+ controls[#controls+1] = frame
+ for i,v in ipairs(path) do
+ frame[i] = v
+ end
+ local buttonText = getConfigField(frame, 'buttonText', true, false, "string")
+ frame.button.text:SetText(buttonText)
+ local confirmText = getConfigField(frame, 'confirmText', true, true, "string")
+ frame.button:ClearAllPoints()
+ if confirmText then
+ frame.confirmButton.text:SetText(confirmText)
+ frame.confirmButton:Show()
+ frame.button:SetPoint("LEFT", frame.confirmButton.text, "RIGHT", 3, 0)
+ frame.button:SetPoint("TOP")
+ frame.button:SetPoint("BOTTOM")
+ frame.button:SetPoint("RIGHT")
+ frame.button:Disable()
+ else
+ frame.button:SetAllPoints()
+ end
+ return frame
+ end
+ end
+
+ local getBooleanControl, releaseBooleanControl
+ do
+ local pool = {}
+ -- remove a checkbox, put in the pool
+ function releaseBooleanControl(frame)
+ frame:Hide()
+ frame:Enable()
+ frame:ClearAllPoints()
+ for i = 1, #frame do
+ frame[i] = nil
+ end
+ frame.desc = nil
+ SetDesaturation(frame.button.check, false)
+ frame.button.check.half = nil
+ pool[frame] = true
+ return nil
+ end
+
+ -- when clicked, change the state
+ local function button_OnClick(this)
+ local newValue = not this.check:IsShown() or this.check.half
+
+ local t = newList(not not newValue)
+ callConfigField(this:GetParent(), 'set', t)
+ t = del(t)
+
+ refreshConfigMenu(this:GetParent()[1])
+ end
+ -- show a depression
+ local function button_OnMouseDown(this)
+ this.checkbox:SetTexture([[Interface\Buttons\UI-CheckBox-Down]])
+ end
+ -- show undepression
+ local function button_OnMouseUp(this)
+ this.checkbox:SetTexture([[Interface\Buttons\UI-CheckBox-Up]])
+ end
+ -- fake enable check
+ local booleanControlsDisabled = {}
+ local function frame_IsEnabled(this)
+ return booleanControlsDisabled[this] and 0 or 1
+ end
+ -- turn gray, including the checkbox.
+ local function frame_Disable(this)
+ if booleanControlsDisabled[this] then
+ return
+ end
+ booleanControlsDisabled[this] = true
+ this.button.checkbox:SetTexture([[Interface\Buttons\UI-CheckBox-Disabled]])
+ SetDesaturation(this.button.check, true)
+ this.label:Disable()
+ this.button:Disable()
+ this.button:EnableMouse(false)
+ end
+ -- turn normal colors
+ local function frame_Enable(this)
+ if not booleanControlsDisabled[this] then
+ return
+ end
+ booleanControlsDisabled[this] = nil
+ this.button.checkbox:SetTexture([[Interface\Buttons\UI-CheckBox-Up]])
+ SetDesaturation(this.button.check, false)
+ this.label:Enable()
+ this.button:Enable()
+ this.button:EnableMouse(true)
+ end
+ local booleanControlNum = 0
+ -- create a preliminary checkbox
+ local function _getBooleanControl()
+ local frame = next(pool)
+ if frame then
+ pool[frame] = nil
+ frame:Show()
+ return frame
+ end
+ booleanControlNum = booleanControlNum + 1
+ local mainPane = base.mainPane
+ frame = CreateFrame("Frame", mainPane:GetName() .. "_BooleanControl" .. booleanControlNum, mainPane.scrollChild)
+ frame:EnableMouse(true)
+ frame:SetHeight(24)
+ local button = CreateFrame("Button", frame:GetName() .. "_Button", frame)
+ frame.button = button
+ button:SetAllPoints()
+ local highlight = button:CreateTexture(button:GetName() .. "_Highlight", "OVERLAY")
+ highlight:SetTexture([[Interface\QuestFrame\UI-QuestTitleHighlight]])
+ highlight:SetVertexColor(1, 1, 1, 0.5)
+ highlight:SetBlendMode("ADD")
+ highlight:SetAllPoints(frame)
+ button:SetHighlightTexture(highlight)
+
+ local checkbox = button:CreateTexture(button:GetName() .. "_Texture", "BACKGROUND")
+ button.checkbox = checkbox
+ checkbox:SetHeight(24)
+ checkbox:SetWidth(24)
+ checkbox:SetTexture([[Interface\Buttons\UI-CheckBox-Up]])
+ checkbox:SetPoint("CENTER")
+ checkbox:SetTexCoord(0.12, 0.88, 0.12, 0.88)
+
+ local check = button:CreateTexture(button:GetName() .. "_Check", "ARTWORK")
+ button.check = check
+ check:SetHeight(24)
+ check:SetWidth(24)
+ check:SetTexture([[Interface\Buttons\UI-CheckBox-Check]])
+ check:SetPoint("CENTER")
+ check:Hide()
+ check:SetTexCoord(0.12, 0.88, 0.12, 0.88)
+
+ button:SetScript("OnClick", button_OnClick)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ button:SetScript("OnEnter", SubControl_OnEnter)
+ button:SetScript("OnLeave", SubControl_OnLeave)
+
+ button:SetScript("OnMouseDown", button_OnMouseDown)
+ button:SetScript("OnMouseUp", button_OnMouseUp)
+ frame.IsEnabled = frame_IsEnabled
+ frame.Disable = frame_Disable
+ frame.Enable = frame_Enable
+
+ frame.type = 'boolean'
+
+ return frame
+ end
+
+ -- fetch and set up a checkbox
+ function getBooleanControl(path, parent)
+ local frame = _getBooleanControl()
+
+ local controls = parent.controls
+ controls[#controls+1] = frame
+ for i,v in ipairs(path) do
+ frame[i] = v
+ end
+ local ret = getConfigField(frame, 'get', false, false, "boolean;string")
+ if ret then
+ frame.button.check:Show()
+ if ret == "HALF" then
+ frame.button.check.half = true
+ SetDesaturation(frame.button.check, true)
+ end
+ else
+ frame.button.check:Hide()
+ end
+ return frame
+ end
+ end
+
+ local getNumberControl, releaseNumberControl
+ do
+ local pool = {}
+ -- remove a slider and put in the pool
+ function releaseNumberControl(frame)
+ frame:Hide()
+ frame:Enable()
+ frame:ClearAllPoints()
+ for i = 1, #frame do
+ frame[i] = nil
+ end
+ pool[frame] = true
+ frame.desc = nil
+ return nil
+ end
+
+ -- make sure the slider's value and the edit box are the proper value, with step and everything properly checked.
+ local function fixSliderValue(this)
+ if this.changing then
+ return
+ end
+ local min = this.min
+ local max = this.max
+ local step = this.step
+ local stepBasis = this.stepBasis
+ local value = getConfigField(this, 'get', false, (min+max)/2, "number")
+
+ value = math_floor((value - stepBasis) / step + 0.5) * step + stepBasis
+
+ local fakeValue = (value - min) / (max - min)
+ this.changing = true
+ this.slider:SetValue(fakeValue)
+
+ this.editBox:ClearFocus()
+ if this.isPercent then
+ this.editBox:SetText(tostring(value*100) .. "%")
+ else
+ this.editBox:SetText(value)
+ end
+ this.changing = nil
+ end
+
+ local numberControlsDisabled = {}
+ -- fake enable check.
+ local function frame_IsEnabled(this)
+ return numberControlsDisabled[this] and 0 or 1
+ end
+ -- fake enable function, turns things normal from gray
+ local function frame_Enable(this)
+ if not numberControlsDisabled[this] then
+ return
+ end
+ numberControlsDisabled[this] = nil
+ this.slider:EnableMouse(true)
+ this.editBox:EnableMouse(true)
+ this.slider.lowText:SetFontObject(GameFontHighlightSmall)
+ this.slider.highText:SetFontObject(GameFontHighlightSmall)
+ this.editBox:SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b)
+ recolorEditBoxStyle(this.editBox, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b)
+
+ if this:IsShown() then
+ fixSliderValue(this)
+ end
+
+ this.label:Enable()
+ end
+ -- fake disable function, turns things gray
+ local function frame_Disable(this)
+ if numberControlsDisabled[this] then
+ return
+ end
+ numberControlsDisabled[this] = true
+ this.slider:EnableMouse(false)
+ this.editBox:EnableMouse(false)
+ this.slider.lowText:SetFontObject(GameFontDisableSmall)
+ this.slider.highText:SetFontObject(GameFontDisableSmall)
+ this.editBox:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b)
+ recolorEditBoxStyle(this.editBox, GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b)
+
+ this.editBox:ClearFocus()
+
+ this.label:Disable()
+ end
+
+ local changedValue = false
+ -- when the value's changed, make sure everything's up to date.
+ local function slider_OnValueChanged(this, fakeValue)
+ local parent = this:GetParent()
+ if parent.changing then
+ return
+ end
+ local min = parent.min
+ local max = parent.max
+ local bigStep = parent.bigStep
+ local value = fakeValue*(max - min) + min
+ local stepBasis = parent.stepBasis
+
+ value = math_floor((value - stepBasis) / bigStep + 0.5) * bigStep + stepBasis
+
+ if value == parent.lastValue then
+ return
+ end
+
+ parent.lastValue = value
+ local t = newList(value)
+ callConfigField(parent, 'set', t)
+ t = del(t)
+
+ fixSliderValue(parent)
+ changedValue = true
+ end
+
+ local function slider_OnMouseDown(this)
+ currentlyMovingSlider = true
+ end
+
+ -- refix things
+ local function slider_OnMouseUp(this)
+ currentlyMovingSlider = false
+ if changedValue then
+ changedValue = false
+ refreshConfigMenu(this:GetParent()[1])
+ else
+ fixSliderValue(this:GetParent())
+ end
+ end
+
+ -- mousewheel changes the slider by one step
+ local function frame_OnMouseWheel(this, change)
+ if nextFreeScroll > GetTime() or this:IsEnabled() ~= 1 then
+ base.mainPane.scrollFrame:GetScript("OnMouseWheel")(base.mainPane.scrollFrame, change)
+ return
+ end
+ local min = this.min
+ local max = this.max
+ local step = this.step
+ local value = this.slider:GetValue()*(max - min) + min
+ local stepBasis = this.stepBasis
+
+ local delta = step
+ if change < 0 then
+ delta = -delta
+ end
+ value = value + delta
+
+ value = math_floor((value - stepBasis) / step + 0.5) * step + stepBasis
+
+ if value < min then
+ value = min
+ elseif value > max then
+ value = max
+ end
+
+ if value == this.lastValue then
+ fixSliderValue(this)
+ return
+ end
+
+ this.lastValue = value
+ local t = newList(value)
+ callConfigField(this, 'set', t)
+ t = del(t)
+
+ refreshConfigMenu(this[1])
+ end
+
+ -- if escape is pressed, the text should go back to the previous
+ local function editBox_OnEscapePressed(this)
+ this:ClearFocus()
+ end
+ -- if enter is pressed, it should update
+ local function editBox_OnEnterPressed(this)
+ local value = this:GetNumber()
+ this:ClearFocus()
+ local parent = this:GetParent()
+ if parent.isPercent then
+ value = value / 100
+ end
+
+ local min, max, step, stepBasis = parent.min, parent.max, parent.step, parent.stepBasis
+
+ value = math_floor((value - stepBasis) / step + 0.5) * step + stepBasis
+
+ if value < min then
+ value = min
+ elseif value > max then
+ value = max
+ end
+
+ if value ~= parent.lastValue then
+ parent.lastValue = value
+
+ local t = newList(value)
+ callConfigField(parent, 'set', t)
+ t = del(t)
+
+ refreshConfigMenu(parent[1])
+ else
+ fixSliderValue(parent)
+ end
+ end
+ -- if the edit box gains focus and is a percentage, strip the percent sign.
+ local function editBox_OnEditFocusGained(this)
+ if this:GetParent():IsEnabled() ~= 1 then
+ this:ClearFocus()
+ return
+ end
+ local text = this:GetText()
+ if text:find("%%$") then
+ this:SetText(text:sub(1, -2))
+ end
+ end
+ -- if focus is lost, fix the value to go back to normal
+ local function editBox_OnEditFocusLost(this)
+ fixSliderValue(this:GetParent())
+ end
+
+ local numberControlNum = 0
+ -- create a preliminary slider
+ local function _getNumberControl()
+ local frame = next(pool)
+ if frame then
+ pool[frame] = nil
+ frame:Show()
+ return frame
+ end
+ numberControlNum = numberControlNum + 1
+ local mainPane = base.mainPane
+ frame = CreateFrame("Frame", mainPane:GetName() .. "_NumberControl" .. numberControlNum, mainPane.scrollChild)
+ frame:SetHeight(20)
+ frame:EnableMouse(true)
+ frame:EnableMouseWheel(true)
+
+ local slider = CreateFrame("Slider", frame:GetName() .. "_Slider", frame, BackdropTemplateMixin and "BackdropTemplate")
+ frame.slider = slider
+ slider:SetOrientation("HORIZONTAL")
+ slider:EnableMouse(true)
+ slider:SetHeight(17)
+ slider:SetPoint("TOPLEFT")
+ slider:SetHitRectInsets(0, 0, 0, 0)
+ local bg = newList()
+ bg.bgFile = [[Interface\Buttons\UI-SliderBar-Background]]
+ bg.edgeFile = [[Interface\Buttons\UI-SliderBar-Border]]
+ bg.tile = true
+ bg.edgeSize = 8
+ bg.tileSize = 8
+ bg.insets = newList()
+ bg.insets.left = 3
+ bg.insets.right = 3
+ bg.insets.top = 6
+ bg.insets.bottom = 6
+ slider:SetBackdrop(bg)
+ bg.insets = del(bg.insets)
+ bg = del(bg)
+ slider:SetThumbTexture([[Interface\Buttons\UI-SliderBar-Button-Horizontal]])
+
+ local text = slider:CreateFontString(slider:GetName() .. "_LowText", "ARTWORK", "GameFontHighlightSmall")
+ slider.lowText = text
+ text:SetText("0%")
+ text:SetPoint("TOPLEFT", slider, "BOTTOMLEFT", 2, 3)
+ local text = slider:CreateFontString(slider:GetName() .. "_HighText", "ARTWORK", "GameFontHighlightSmall")
+ slider.highText = text
+ text:SetText("100%")
+ text:SetPoint("TOPRIGHT", slider, "BOTTOMRIGHT", -2, 3)
+
+ -- edit box is made so that someone can type in easily
+ local editBox = CreateFrame("EditBox", frame:GetName() .. "_EditBox", frame)
+ frame.editBox = editBox
+ editBox:SetFontObject(ChatFontNormal)
+ editBox:SetHeight(17)
+ editBox:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -1, 0)
+ editBox:SetText("50%")
+ editBox:SetJustifyH("CENTER")
+ editBox:SetWidth(48)
+
+ slider:SetPoint("RIGHT", editBox, "LEFT", -1, 0)
+
+ styleEditBox(editBox)
+
+ editBox:SetAutoFocus(false)
+ editBox:SetScript("OnEscapePressed", editBox_OnEscapePressed)
+ editBox:SetScript("OnEnterPressed", editBox_OnEnterPressed)
+
+ editBox:SetScript("OnEditFocusGained", editBox_OnEditFocusGained)
+ editBox:SetScript("OnEditFocusLost", editBox_OnEditFocusLost)
+
+ frame.type = 'number'
+ slider:SetValueStep(epsilon)
+ slider:SetScript("OnValueChanged", slider_OnValueChanged)
+ slider:SetScript("OnMouseDown", slider_OnMouseDown)
+ slider:SetScript("OnMouseUp", slider_OnMouseUp)
+ frame:SetScript("OnMouseWheel", frame_OnMouseWheel)
+
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ slider:SetScript("OnEnter", SubControl_OnEnter)
+ slider:SetScript("OnLeave", SubControl_OnLeave)
+ editBox:SetScript("OnEnter", SubControl_OnEnter)
+ editBox:SetScript("OnLeave", SubControl_OnLeave)
+ frame.Disable = frame_Disable
+ frame.Enable = frame_Enable
+ frame.IsEnabled = frame_IsEnabled
+
+ return frame
+ end
+
+ -- fetch and set up a slider
+ function getNumberControl(path, parent)
+ local frame = _getNumberControl()
+
+ local controls = parent.controls
+ controls[#controls+1] = frame
+ for i,v in ipairs(path) do
+ frame[i] = v
+ end
+ local min = getConfigField(frame, 'min', false, 0, "number")
+ local max = getConfigField(frame, 'max', false, 1, "number")
+ local value = getConfigField(frame, 'get', false, (min + max)/2, "number")
+ local step = getConfigField(frame, 'step', false, (max - min)/100, "number")
+ local bigStep = getConfigField(frame, 'bigStep', false, step, "number")
+ local stepBasis = getConfigField(frame, 'stepBasis', false, min, "number")
+ local isPercent = getConfigField(frame, 'isPercent', false, true, "boolean")
+ frame.slider:SetMinMaxValues(0, 1)
+ frame.min = min
+ frame.max = max
+ frame.step = step
+ frame.bigStep = bigStep
+ frame.stepBasis = stepBasis
+ frame.lastValue = value
+ frame.isPercent = isPercent
+
+ frame.changing = true
+
+ if isPercent then
+ frame.slider.lowText:SetText(min*100 .. "%")
+ frame.slider.highText:SetText(max*100 .. "%")
+ else
+ frame.slider.lowText:SetText(min)
+ frame.slider.highText:SetText(max)
+ end
+
+ frame.changing = nil
+ fixSliderValue(frame)
+
+ return frame
+ end
+ end
+
+ local getColorControl, releaseColorControl
+ do
+ local pool = {}
+ -- remove a color picker and put it in the pool
+ function releaseColorControl(frame)
+ frame:Hide()
+ frame:Enable()
+ if _G.CurrentlyCopiedColor then
+ frame.pasteButton:Enable()
+ end
+ frame:ClearAllPoints()
+ for i = 1, #frame do
+ frame[i] = nil
+ end
+ frame.desc = nil
+ pool[frame] = true
+ return nil
+ end
+
+ -- seeing as it is multiple different frames, the width is computed dynamically to stretch across properly and smoothly.
+ local function frame_SizeChanged(this, width)
+ local extra = 3 --[[ space between hsl + rgb]] + 3 --[[ space on right]]
+ local hasAlpha = this.hasAlpha
+ local sliderWidth
+ extra = extra + 3 -- space between rgb + alpha
+ extra = extra + this.hueSlider.label:GetWidth()*3
+ extra = extra + this.hueSlider.editBox:GetWidth()*3
+ sliderWidth = (width - extra)/3 - 7
+
+ this.hueSlider:SetWidth(sliderWidth + 7)
+ for i = 1, 6 do
+ this.hueSlider["gradient" .. i]:SetWidth(sliderWidth/6)
+ end
+ this.hueSlider.checkers:SetWidth(sliderWidth)
+ this.lumSlider:SetWidth(sliderWidth + 7)
+ for i = 1, 2 do
+ this.lumSlider["gradient" .. i]:SetWidth(sliderWidth/2)
+ end
+ this.lumSlider.checkers:SetWidth(sliderWidth)
+ local tmp = newList('satSlider', 'redSlider', 'greenSlider', 'blueSlider')
+ if hasAlpha then
+ tmp[#tmp+1] = 'alphaSlider'
+ end
+ for i,v in ipairs(tmp) do
+ local slider = this[v]
+ slider:SetWidth(sliderWidth + 7)
+ slider.gradient:SetWidth(sliderWidth)
+ slider.checkers:SetWidth(sliderWidth)
+ end
+ tmp = del(tmp)
+ end
+
+ local colorControlsDisabled = {}
+ -- fake enable check
+ local function frame_IsEnabled(this)
+ return colorControlsDisabled[this] and 0 or 1
+ end
+ -- fake disable function, turn things gray, turn off the mouse
+ local function frame_Disable(this)
+ if colorControlsDisabled[this] then
+ return
+ end
+ colorControlsDisabled[this] = true
+ local tmp = newList("hue", "sat", "lum", "red", "green", "blue", "alpha")
+ for i,v in ipairs(tmp) do
+ local slider = this[v .. "Slider"]
+ slider.label:SetFontObject(GameFontDisable)
+ slider.editBox:SetTextColor(0.5, 0.5, 0.5)
+ recolorEditBoxStyle(slider.editBox, 0.5, 0.5, 0.5, 1)
+ slider:EnableMouse(false)
+ slider.editBox:EnableMouse(false)
+ end
+ tmp = del(tmp)
+ this.copyButton:Disable()
+ this.pasteButton:Disable()
+ this.label:Disable()
+ end
+ -- fake enable function, turn things normal color, turn on the mouse
+ local function frame_Enable(this)
+ if not colorControlsDisabled[this] then
+ return
+ end
+ colorControlsDisabled[this] = nil
+ local tmp = newList("hue", "sat", "lum", "red", "green", "blue", "alpha")
+ for i,v in ipairs(tmp) do
+ local slider = this[v .. "Slider"]
+ slider.label:SetFontObject(GameFontNormal)
+ slider.editBox:SetTextColor(1, 1, 1)
+ recolorEditBoxStyle(slider.editBox, 1, 1, 1, 1)
+ slider:EnableMouse(true)
+ slider.editBox:EnableMouse(true)
+ end
+ tmp = del(tmp)
+ this.copyButton:Enable()
+ if _G.CurrentlyCopiedColor then
+ this.pasteButton:Enable()
+ end
+ this.label:Enable()
+ end
+
+ -- helper function for hsl2rgb
+ local function func(v1, v2, h)
+ if h < 0 then
+ h = h + 1
+ elseif h > 1 then
+ h = h - 1
+ end
+ if h < 1/6 then
+ return v1 + (v2 - v1) * 6 * h
+ elseif h < 1/2 then
+ return v2
+ elseif h < 2/3 then
+ return v1 + (v2 - v1) * (2/3 - h) * 6
+ else
+ return v1
+ end
+ end
+
+ -- convert HSL to RGB
+ -- h is [0, 360], rest is [0, 1]
+ local function hsl2rgb(h, s, l)
+ if s == 0 then
+ return l, l, l
+ end
+
+ h = h / 360
+
+ local v2
+ if l < 0.5 then
+ v2 = l * (1+s)
+ else
+ v2 = (l + s) - (s * l)
+ end
+ local v1 = 2*l - v2
+
+ local r = func(v1, v2, h + 1/3)
+ local g = func(v1, v2, h)
+ local b = func(v1, v2, h - 1/3)
+ return r, g, b
+ end
+
+ -- convert RGB to HSL
+ -- inputs are [0, 1]
+ local function rgb2hsl(r, g, b)
+ local min = math_min(r, g, b)
+ local max = math_max(r, g, b)
+ local delta = max - min
+
+ local l = (max + min)/2
+
+ if delta == 0 then
+ return 0, 0, l
+ end
+
+ local s
+ if l < 0.5 then
+ s = delta / (max + min)
+ else
+ s = delta / (2 - max - min)
+ end
+
+ local deltaR = (max - r)/(6*delta) + 1/2
+ local deltaG = (max - g)/(6*delta) + 1/2
+ local deltaB = (max - b)/(6*delta) + 1/2
+
+ local h
+ if r == max then
+ h = deltaB - deltaG
+ elseif g == max then
+ h = 1/3 + deltaR - deltaB
+ elseif b == max then
+ h = 2/3 + deltaG - deltaR
+ end
+ if h < 0 then
+ h = h + 1
+ elseif h > 1 then
+ h = h - 1
+ end
+
+ return h*360, s, l
+ end
+
+ -- fix the colors of the sliders to reflect changes
+ local function refixColors(frame, useRGB)
+ local h, s, l, r, g, b
+ if not useRGB then
+ h = frame.hueSlider:GetValue()
+ s = frame.satSlider:GetValue()
+ l = frame.lumSlider:GetValue()
+ r, g, b = hsl2rgb(h, s, l)
+ else
+ r = frame.redSlider:GetValue()/255
+ g = frame.greenSlider:GetValue()/255
+ b = frame.blueSlider:GetValue()/255
+ h, s, l = rgb2hsl(r, g, b)
+ end
+
+ local hasAlpha = frame.hasAlpha
+ local a = hasAlpha and frame.alphaSlider:GetValue() or 1
+
+ frame.swatch:SetVertexColor(r, g, b, a)
+
+ local r1, g1, b1 = hsl2rgb(0, s, l)
+ local r2, g2, b2 = hsl2rgb(60, s, l)
+ frame.hueSlider.gradient1:SetGradient("HORIZONTAL", CreateColor(r1, g1, b1, a), CreateColor(r2, g2, b2, a))
+ local r1, g1, b1 = r2, g2, b2
+ local r2, g2, b2 = hsl2rgb(120, s, l)
+ frame.hueSlider.gradient2:SetGradient("HORIZONTAL", CreateColor(r1, g1, b1, a), CreateColor(r2, g2, b2, a))
+ local r1, g1, b1 = r2, g2, b2
+ local r2, g2, b2 = hsl2rgb(180, s, l)
+ frame.hueSlider.gradient3:SetGradient("HORIZONTAL", CreateColor(r1, g1, b1, a), CreateColor(r2, g2, b2, a))
+ local r1, g1, b1 = r2, g2, b2
+ local r2, g2, b2 = hsl2rgb(240, s, l)
+ frame.hueSlider.gradient4:SetGradient("HORIZONTAL", CreateColor(r1, g1, b1, a), CreateColor(r2, g2, b2, a))
+ local r1, g1, b1 = r2, g2, b2
+ local r2, g2, b2 = hsl2rgb(300, s, l)
+ frame.hueSlider.gradient5:SetGradient("HORIZONTAL", CreateColor(r1, g1, b1, a), CreateColor(r2, g2, b2, a))
+ local r1, g1, b1 = r2, g2, b2
+ local r2, g2, b2 = hsl2rgb(0, s, l)
+ frame.hueSlider.gradient6:SetGradient("HORIZONTAL", CreateColor(r1, g1, b1, a), CreateColor(r2, g2, b2, a))
+ frame.hueSlider.editBox:SetText(math_floor(h + 0.5) .. "º")
+
+ local r1, g1, b1 = hsl2rgb(h, 0, l)
+ local r2, g2, b2 = hsl2rgb(h, 1, l)
+ frame.satSlider.gradient:SetGradient("HORIZONTAL", CreateColor(r1, g1, b1, a), CreateColor(r2, g2, b2, a))
+ frame.satSlider.editBox:SetText(math_floor(s * 100 + 0.5) .. "%")
+
+ local r1, g1, b1 = hsl2rgb(h, s, 0)
+ local r2, g2, b2 = hsl2rgb(h, s, 0.5)
+ frame.lumSlider.gradient1:SetGradient("HORIZONTAL", CreateColor(r1, g1, b1, a), CreateColor(r2, g2, b2, a))
+ local r1, g1, b1 = r2, g2, b2
+ local r2, g2, b2 = hsl2rgb(h, s, 1)
+ frame.lumSlider.gradient2:SetGradient("HORIZONTAL", CreateColor(r1, g1, b1, a), CreateColor(r2, g2, b2, a))
+ frame.lumSlider.editBox:SetText(math_floor(l * 100 + 0.5) .. "%")
+
+ frame.redSlider.gradient:SetGradient("HORIZONTAL", CreateColor(0, g, b, a), CreateColor(1, g, b, a))
+ frame.redSlider.editBox:SetText(math_floor(r * 255 + 0.5))
+ frame.greenSlider.gradient:SetGradient("HORIZONTAL", CreateColor(r, 0, b, a), CreateColor(r, 1, b, a))
+ frame.greenSlider.editBox:SetText(math_floor(g * 255 + 0.5))
+ frame.blueSlider.gradient:SetGradient("HORIZONTAL", CreateColor(r, g, 0, a), CreateColor(r, g, 1, a))
+ frame.blueSlider.editBox:SetText(math_floor(b * 255 + 0.5))
+ if hasAlpha then
+ frame.alphaSlider.gradient:SetGradient("HORIZONTAL", CreateColor(r, g, b, 0), CreateColor(r, g, b, 1))
+ frame.alphaSlider.editBox:SetText(math_floor(a * 100 + 0.5) .. "%")
+ end
+ end
+
+ local changed = false
+ -- save results, refresh
+ local function save(frame)
+ if not changed then
+ return
+ end
+ changed = false
+ local r, g, b, a = frame.redSlider:GetValue() / 255, frame.greenSlider:GetValue() / 255, frame.blueSlider:GetValue() / 255, frame.alphaSlider:GetValue()
+
+ local colorType = frame.colorType
+ local t
+ if colorType == "tuple" then
+ t = newList(r, g, b)
+ elseif colorType == "tuple:rgba" then
+ t = newList(r, g, b, a)
+ elseif colorType == "tuple:argb" then
+ t = newList(r, g, b, a)
+ elseif colorType == "hex:rgba" or colorType == "hex:argb" or colorType == "hex" then
+ if colorType == "hex" then
+ t = newList(("%02x%02x%02x"):format(r * 255, g * 255, b * 255))
+ elseif colorType == "hex:rgba" then
+ t = newList(("%02x%02x%02x%02x"):format(r*255, g*255, b*255, a*255))
+ else
+ t = newList(("%02x%02x%02x%02x"):format(a*255, r*255, g*255, b*255))
+ end
+ elseif colorType == "number" then
+ t = newList(math_floor(r*255 * 256^2 + 0.5) + math_floor(g*255 * 256 + 0.5) + math_floor(b * 256 + 0.5))
+ else
+ -- should never occur
+ error(("Unknown colorType: %q"):format(tostring(colorType)))
+ end
+ callConfigField(frame, 'set', t)
+ t = del(t)
+
+ refreshConfigMenu(frame[1])
+ end
+
+ local changing = false
+ -- change colors, set a flag so that the data will be saved when the mouse is let go.
+ local function slider_OnValueChanged(this, value)
+ if changing then
+ return
+ end
+ changing = true
+ local frame = this:GetParent()
+ local kind = this.kind
+ if kind == "red" or kind == "green" or kind == "blue" then
+ local r, g, b = frame.redSlider:GetValue()/255, frame.greenSlider:GetValue()/255, frame.blueSlider:GetValue()/255
+ local h, s, l = rgb2hsl(r, g, b)
+ frame.hueSlider:SetValue(h)
+ frame.satSlider:SetValue(s)
+ frame.lumSlider:SetValue(l)
+ elseif kind == "hue" or kind == "sat" or kind == "lum" then
+ local h, s, l = frame.hueSlider:GetValue(), frame.satSlider:GetValue(), frame.lumSlider:GetValue()
+ local r, g, b = hsl2rgb(h, s, l)
+ frame.redSlider:SetValue(r*255)
+ frame.greenSlider:SetValue(g*255)
+ frame.blueSlider:SetValue(b*255)
+ end
+ refixColors(frame)
+ changing = false
+
+ changed = value
+ end
+ -- if the data has changed, save
+ local function slider_OnMouseUp(this)
+ save(this:GetParent())
+ end
+
+ -- mousewheel changes a slider by one step
+ local function slider_OnMouseWheel(this, change)
+ if nextFreeScroll > GetTime() then
+ base.mainPane.scrollFrame:GetScript("OnMouseWheel")(base.mainPane.scrollFrame, change)
+ return
+ end
+ local value = this:GetValue()
+ local step = this:GetValueStep()
+ local min, max = this:GetMinMaxValues()
+ if change > 0 then
+ value = value + step
+ if value > max then
+ value = max
+ end
+ else
+ value = value - step
+ if value < min then
+ value = min
+ end
+ end
+ if value ~= this:GetValue() then
+ this:SetValue(value)
+ end
+ save(this:GetParent())
+ end
+
+ -- if escape is presed, change the text to the original
+ local function editBox_OnEscapePressed(this)
+ this:ClearFocus()
+ end
+ -- if enter is pressed, update the slider, save
+ local function editBox_OnEnterPressed(this)
+ local value = this:GetNumber()
+ this:ClearFocus()
+ local min, max = this:GetParent():GetMinMaxValues()
+ local step = this:GetParent():GetValueStep()
+ if min == 0 and max == 1 then
+ -- percentage
+ value = value / 100
+ end
+
+ if value < min then
+ value = min
+ elseif value > max then
+ value = max
+ end
+
+ this:GetParent():SetValue(value)
+
+ save(this:GetParent():GetParent())
+ end
+
+ -- on focus, if the text ends in percent or degree, remove those
+ local function editBox_OnEditFocusGained(this)
+ if this:GetParent():GetParent():IsEnabled() ~= 1 then
+ this:ClearFocus()
+ return
+ end
+ local text = this:GetText()
+ if text:find("%%$") then
+ this:SetText(text:sub(1, -2))
+ elseif text:find("\194\186$") then -- degree
+ this:SetText(text:sub(1, -3))
+ end
+ end
+ -- fix the colors as well as the text if focus is lost
+ local function editBox_OnEditFocusLost(this)
+ refixColors(this:GetParent():GetParent())
+ end
+
+ -- when pressed, the button should look pressed
+ local function button_OnMouseDown(this)
+ if this:IsEnabled() == 1 then
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ end
+ end
+ -- when depressed, return to normal
+ local function button_OnMouseUp(this)
+ if this:IsEnabled() == 1 then
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ end
+ end
+
+ local function copyButton_OnClick(this)
+ local CurrentlyCopiedColor = _G.CurrentlyCopiedColor
+ if not CurrentlyCopiedColor then
+ CurrentlyCopiedColor = {}
+ _G.CurrentlyCopiedColor = CurrentlyCopiedColor
+ end
+ for k in pairs(CurrentlyCopiedColor) do
+ CurrentlyCopiedColor[k] = nil
+ end
+ local parent = this:GetParent()
+ CurrentlyCopiedColor.r = (parent.redSlider:GetValue() or 255)/255
+ CurrentlyCopiedColor.g = (parent.greenSlider:GetValue() or 255)/255
+ CurrentlyCopiedColor.b = (parent.blueSlider:GetValue() or 255)/255
+ CurrentlyCopiedColor.a = parent.alphaSlider:IsShown() and parent.alphaSlider:GetValue() or 1
+
+ refreshConfigMenu(parent[1])
+ end
+
+ local function pasteButton_OnClick(this)
+ changing = true
+ local frame = this:GetParent()
+ local CurrentlyCopiedColor = _G.CurrentlyCopiedColor
+ frame.redSlider:SetValue(CurrentlyCopiedColor.r*255)
+ frame.greenSlider:SetValue(CurrentlyCopiedColor.g*255)
+ frame.blueSlider:SetValue(CurrentlyCopiedColor.b*255)
+ if frame.alphaSlider:IsShown() then
+ frame.alphaSlider:SetValue(CurrentlyCopiedColor.a)
+ end
+ changing = false
+
+ changed = true
+ save(frame)
+ end
+
+ local function button_Disable(this)
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this:__Disable()
+ this:EnableMouse(false)
+ end
+
+ local function button_Enable(this)
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this:__Enable()
+ this:EnableMouse(true)
+ end
+
+ local colorControlNum = 0
+ -- create a color picker
+ local function _getColorControl()
+ local frame = next(pool)
+ if frame then
+ pool[frame] = nil
+ frame:Show()
+ return frame
+ end
+ colorControlNum = colorControlNum + 1
+ local mainPane = base.mainPane
+ frame = CreateFrame("Frame", mainPane:GetName() .. "_ColorControl" .. colorControlNum, mainPane.scrollChild)
+
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ frame:EnableMouse(true)
+ frame.SizeChanged = frame_SizeChanged
+
+ local tmp = newList("hue", "sat", "lum", "red", "green", "blue", "alpha")
+ local tmp_max = newList(359, 1, 1, 255, 255, 255, 1)
+ local tmp_step = newList(1, 0.01, 0.01, 1, 1, 1, 0.01)
+ local tmp_label = newList("H", "S", "L", "R", "G", "B", "A")
+ local maxLabelWidth = 0
+ for i, v in ipairs(tmp) do
+ -- make a slider for each value
+ local slider = CreateFrame("Slider", frame:GetName() .. "_" .. v .. "Slider", frame)
+ frame[v .. "Slider"] = slider
+ slider.kind = v
+ slider:SetMinMaxValues(0, tmp_max[i])
+ slider:SetValue(tmp_max[i])
+ slider:SetValueStep(tmp_step[i])
+ slider:SetOrientation("HORIZONTAL")
+ slider:SetHeight(16)
+ slider:SetWidth(71)
+ slider:SetScript("OnValueChanged", slider_OnValueChanged)
+ slider:SetScript("OnMouseUp", slider_OnMouseUp)
+ slider:EnableMouseWheel(true)
+ slider:SetScript("OnMouseWheel", slider_OnMouseWheel)
+
+ slider:SetScript("OnEnter", SubControl_OnEnter)
+ slider:SetScript("OnLeave", SubControl_OnLeave)
+
+ local label = slider:CreateFontString(slider:GetName() .. "_Label", "ARTWORK", "GameFontNormal")
+ slider.label = label
+ label:SetText(tmp_label[i])
+ local label_width = label:GetWidth()
+ if label_width > maxLabelWidth then
+ maxLabelWidth = label_width
+ end
+ label:SetHeight(16)
+ label:SetJustifyH("RIGHT")
+ slider:SetPoint("LEFT", label, "RIGHT")
+
+ if v ~= "hue" and v ~= "lum" then
+ -- hue requires 6 gradients, lum requires 2
+ local gradient = slider:CreateTexture(slider:GetName() .. "_Gradient", "ARTWORK")
+ slider.gradient = gradient
+ gradient:SetHeight(16)
+ gradient:SetWidth(64)
+ gradient:SetPoint("CENTER", slider, "CENTER")
+ gradient:SetTexture([[Interface\Buttons\WHITE8X8]])
+ gradient:SetGradient("HORIZONTAL", CreateColor(0, 0, 0, 0), CreateColor(1, 1, 1, 1))
+ end
+
+ -- the checkers are shown behind, so that alpha colors can show.
+ local checkers = slider:CreateTexture(slider:GetName() .. "_Checkers", "BACKGROUND")
+ slider.checkers = checkers
+ checkers:SetHeight(16)
+ checkers:SetWidth(64)
+ checkers:SetPoint("CENTER")
+ checkers:SetTexture([[Tileset\Generic\Checkers]])
+ checkers:SetDesaturated(true)
+ checkers:SetTexCoord(0, 1, 0, 0.25)
+ checkers:SetVertexColor(1, 1, 1, 0.75)
+
+ local thumb = slider:CreateTexture(slider:GetName() .. "_Thumb")
+ slider.thumb = thumb
+ thumb:SetWidth(7)
+ thumb:SetHeight(24)
+ thumb:SetTexture([[Interface\Buttons\UI-ColorPicker-Buttons]])
+ thumb:SetTexCoord(0.25, 0.875, 1, 0.875, 0.25, 0, 1, 0)
+ slider:SetThumbTexture(thumb)
+
+ -- edit box is available so people can type in the value they want
+ local editBox = CreateFrame("EditBox", slider:GetName() .. "_EditBox", slider)
+ slider.editBox = editBox
+ editBox:SetFontObject(ChatFontNormal)
+ editBox:SetHeight(17)
+ editBox:SetPoint("LEFT", slider, "RIGHT", 0, 0)
+ editBox:SetText("100%")
+ editBox:SetJustifyH("CENTER")
+ editBox:SetWidth(36)
+ editBox:SetTextInsets(-5, -5, 0, 0)
+
+ editBox:SetScript("OnEnter", SubControl_OnEnter)
+ editBox:SetScript("OnLeave", SubControl_OnLeave)
+
+ styleEditBox(editBox)
+
+ editBox:SetAutoFocus(false)
+ editBox:SetScript("OnEscapePressed", editBox_OnEscapePressed)
+ editBox:SetScript("OnEnterPressed", editBox_OnEnterPressed)
+
+ editBox:SetScript("OnEditFocusGained", editBox_OnEditFocusGained)
+ editBox:SetScript("OnEditFocusLost", editBox_OnEditFocusLost)
+ end
+ for i,v in ipairs(tmp) do
+ local slider = frame[v .. "Slider"]
+ local label = slider.label
+ label:SetWidth(maxLabelWidth)
+ end
+ tmp = del(tmp)
+ tmp_max = del(tmp_max)
+ tmp_step = del(tmp_step)
+ tmp_label = del(tmp_label)
+ local hueSlider = frame.hueSlider
+ for i = 1, 6 do
+ -- hue requires 6 gradients because the progression isn't linear on an RGB scale.
+ local gradient = hueSlider:CreateTexture(hueSlider:GetName() .. "_Gradient" .. i, "ARTWORK")
+ hueSlider["gradient" .. i] = gradient
+ gradient:SetHeight(16)
+ gradient:SetWidth(64 / 6)
+ if i == 1 then
+ gradient:SetPoint("LEFT", hueSlider, "LEFT", 3.5, 0)
+ else
+ gradient:SetPoint("LEFT", hueSlider["gradient" .. (i-1)], "RIGHT")
+ end
+ gradient:SetTexture([[Interface\Buttons\WHITE8X8]])
+ gradient:SetGradient("HORIZONTAL", CreateColor(0, 0, 0, 0), CreateColor(1, 1, 1, 1))
+ end
+ local lumSlider = frame.lumSlider
+ for i = 1, 2 do
+ -- lum requires 2 gradients because the progression isn't linear on an RGB scale.
+ local gradient = lumSlider:CreateTexture(lumSlider:GetName() .. "_Gradient" .. i, "ARTWORK")
+ lumSlider["gradient" .. i] = gradient
+ gradient:SetHeight(16)
+ gradient:SetWidth(64 / 2)
+ if i == 1 then
+ gradient:SetPoint("LEFT", lumSlider, "LEFT", 3.5, 0)
+ else
+ gradient:SetPoint("LEFT", lumSlider["gradient" .. (i-1)], "RIGHT")
+ end
+ gradient:SetTexture([[Interface\Buttons\WHITE8X8]])
+ gradient:SetGradient("HORIZONTAL", CreateColor(0, 0, 0, 0), CreateColor(1, 1, 1, 1))
+ end
+
+ local swatch = frame:CreateTexture(frame:GetName() .. "_Swatch", "ARTWORK")
+ frame.swatch = swatch
+ swatch:SetWidth(32)
+ swatch:SetHeight(32)
+ swatch:SetTexture([[Interface\Buttons\WHITE8X8]])
+ swatch:SetVertexColor(1, 1, 1, 1)
+
+ local swatchUnder = frame:CreateTexture(frame:GetName() .. "_SwatchUnder", "BACKGROUND")
+ frame.swatchUnder = swatchUnder
+ swatchUnder:SetWidth(32)
+ swatchUnder:SetHeight(32)
+ swatchUnder:SetPoint("CENTER", swatch, swatch)
+ swatchUnder:SetTexture([[Tileset\Generic\Checkers]])
+ swatchUnder:SetDesaturated(true)
+ swatchUnder:SetTexCoord(0, 0.5, 0, 0.5)
+ swatchUnder:SetVertexColor(1, 1, 1, 0.75)
+
+ for i = 1, 2 do
+ local button = CreateFrame("Button", frame:GetName() .. (i == 1 and "_button" or "_PasteButton"), frame)
+ if i == 1 then
+ frame.copyButton = button
+ else
+ frame.pasteButton = button
+ end
+ local left = button:CreateTexture(button:GetName() .. "_LeftTexture", "BACKGROUND")
+ button.left = left
+ local middle = button:CreateTexture(button:GetName() .. "_MiddleTexture", "BACKGROUND")
+ button.middle = middle
+ local right = button:CreateTexture(button:GetName() .. "_RightTexture", "BACKGROUND")
+ button.right = right
+ left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+
+ left:SetPoint("TOPLEFT")
+ left:SetPoint("BOTTOMLEFT")
+ left:SetWidth(12)
+ left:SetTexCoord(0, 0.09375, 0, 0.6875)
+
+ right:SetPoint("TOPRIGHT")
+ right:SetPoint("BOTTOMRIGHT")
+ right:SetWidth(12)
+ right:SetTexCoord(0.53125, 0.625, 0, 0.6875)
+
+ middle:SetPoint("TOPLEFT", left, "TOPRIGHT")
+ middle:SetPoint("BOTTOMRIGHT", right, "BOTTOMLEFT")
+ middle:SetTexCoord(0.09375, 0.53125, 0, 0.6875)
+
+ button:SetScript("OnMouseDown", button_OnMouseDown)
+ button:SetScript("OnMouseUp", button_OnMouseUp)
+
+ local text = button:CreateFontString(button:GetName() .. "_FontString", "ARTWORK")
+ button:SetFontString(text)
+ button.text = text
+ text:SetPoint("LEFT", button, "LEFT", 7, 0)
+ text:SetPoint("RIGHT", button, "RIGHT", -7, 0)
+
+ button[SET_NORMAL_FONT_OBJECT](button, GameFontNormal)
+ button:SetHighlightFontObject(GameFontHighlight)
+ button:SetDisabledFontObject(GameFontDisable)
+
+ if i == 1 then
+ text:SetText(COPY)
+ else
+ text:SetText(PASTE)
+ end
+
+ local highlight = button:CreateTexture(button:GetName() .. "_Highlight", "OVERLAY", "UIPanelButtonHighlightTexture")
+ button:SetHighlightTexture(highlight)
+
+ button:SetScript("OnClick", i == 1 and copyButton_OnClick or pasteButton_OnClick)
+ button:SetScript("OnEnter", SubControl_OnEnter)
+ button:SetScript("OnLeave", SubControl_OnLeave)
+
+ button.__Disable = button.Disable
+ button.__Enable = button.Enable
+ button.Disable = button_Disable
+ button.Enable = button_Enable
+
+ if i == 1 then
+ button:SetPoint("TOPLEFT", swatch, "TOPRIGHT", 3, 2)
+ else
+ button:SetPoint("BOTTOMLEFT", swatch, "BOTTOMRIGHT", 3, -2)
+ end
+ button:SetPoint("RIGHT", frame, "RIGHT", 0, 0)
+ button:SetHeight(18)
+ end
+
+ hueSlider.label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0)
+ frame.satSlider.label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, -19)
+ lumSlider.label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, -38)
+ frame.redSlider.label:SetPoint("LEFT", hueSlider.editBox, "RIGHT", 3, 0)
+ frame.greenSlider.label:SetPoint("LEFT", frame.satSlider.editBox, "RIGHT", 3, 0)
+ frame.blueSlider.label:SetPoint("LEFT", lumSlider.editBox, "RIGHT", 3, 0)
+ frame.alphaSlider.label:SetPoint("LEFT", frame.redSlider.editBox, "RIGHT", 3, 0)
+
+ frame.IsEnabled = frame_IsEnabled
+ frame.Disable = frame_Disable
+ frame.Enable = frame_Enable
+
+ frame.type = 'color'
+ frame:SetHeight(64)
+
+ refixColors(frame)
+ return frame
+ end
+
+ local t = {}
+ for i = 0, 9 do
+ t[tostring(i):byte()] = i
+ end
+ do
+ local a_byte = ('a'):byte()
+ local A_byte = ('A'):byte()
+ for i = 10, 15 do
+ t[a_byte+i-10] = i
+ t[A_byte+i-10] = i
+ end
+ end
+ -- turn hexadecimal (0-9, A-F) bytes into a number [0, 255]
+ local function hexBytesToNumber(alpha, bravo)
+ local alpha_num = t[alpha] or 15
+ local bravo_num = t[bravo] or 15
+
+ return alpha_num*16 + bravo_num
+ end
+ -- make sure that a value is within the given range
+ local function fixRange(num, min, max)
+ if not num or not min or not max then
+ return num
+ end
+ if num < min then
+ return min
+ elseif num > max then
+ return max
+ else
+ return num
+ end
+ end
+
+ -- fetch and set up a color picker
+ function getColorControl(path, parent)
+ local frame = _getColorControl()
+
+ local controls = parent.controls
+ controls[#controls+1] = frame
+ for i,v in ipairs(path) do
+ frame[i] = v
+ end
+ local hasAlpha = not not getConfigField(frame, 'hasAlpha', false, true, "boolean")
+ frame.hasAlpha = hasAlpha
+ local colorType = getConfigField(frame, 'colorType', false, hasAlpha and "tuple:rgba" or "tuple", "string")
+ frame.colorType = colorType
+ if hasAlpha then
+ if colorType ~= "tuple:rgba" and colorType ~= "hex:rgba" and colorType ~= "tuple:argb" and colorType ~= "hex:argb" then
+ error(("%s: Bad result from field %q for `%s'. Expected %q, %q, %q, or %q, got %q."):format(MAJOR_VERSION, 'colorType', getPathString(frame), "tuple:rgba", "hex:rgba", "tuple:argb", "hex:argb", colorType))
+ end
+ else
+ if colorType ~= "tuple" and colorType ~= "hex" and colorType ~= "number" then
+ error(("%s: Bad result from field %q for `%s'. Expected %q, %q, or %q, got %q."):format(MAJOR_VERSION, 'colorType', getPathString(frame), "tuple", "hex", "number", colorType))
+ end
+ end
+ local c1, c2, c3, c4 = getConfigField(frame, 'get', false, false)
+ local r, g, b, a
+ if colorType == "tuple" then
+ r, g, b = c1, c2, c3
+ elseif colorType == "tuple:rgba" then
+ r, g, b, a = c1, c2, c3, c4
+ elseif colorType == "tuple:argb" then
+ a, r, g, b = c1, c2, c3, c4
+ elseif colorType == "hex:rgba" or "hex:argb" or colorType == "hex" then
+ if type(c1) ~= "string" then
+ error(("%s: Bad result from field %q for `%s'. Expected %q, got %q."):format(MAJOR_VERSION, 'get', getPathString(path), "string", type(c1)))
+ end
+ local n = hasAlpha and 8 or 6
+ if #c1 ~= n then
+ error(("%s: Bad result from field %q for `%s'. Expected %d-byte string, got %d-byte string."):format(MAJOR_VERSION, 'get', getPathString(path), n, #c1))
+ end
+ local r1, r2, g1, g2, b1, b2, a1, a2
+ if colorType == "hex" then
+ r1, r2, g1, g2, b1, b2 = c1:byte(1, 6)
+ elseif colorType == "hex:rgba" then
+ r1, r2, g1, g2, b1, b2, a1, a2 = c1:byte(1, 8)
+ else -- hex:argb
+ a1, a2, r1, r2, g1, g2, b1, b2 = c1:byte(1, 8)
+ end
+ r, g, b, a = hexBytesToNumber(r1, r2), hexBytesToNumber(g1, g2), hexBytesToNumber(b1, b2), hasAlpha and hexBytesToNumber(a1, a2)
+
+ r, g, b, a = r/255, g/255, b/255, hasAlpha and a/255
+ else -- number
+ if type(c1) ~= "number" then
+ error(("%s: Bad result from field %q for `%s'. Expected %q, got %q."):format(MAJOR_VERSION, 'get', getPathString(path), "number", type(c1)))
+ end
+ r = math_floor(c1/256^2)
+ g = math_floor(c1/256) % 256
+ b = math_floor(c1) % 256
+ end
+ r, g, b, a = fixRange(r, 0, 1) or 1, fixRange(g, 0, 1) or 1, fixRange(b, 0, 1) or 1, hasAlpha and fixRange(a, 0, 1) or 1
+
+ changing = true
+ local h, s, l = rgb2hsl(r, g, b)
+ frame.hueSlider:SetValue(h)
+ frame.satSlider:SetValue(s)
+ frame.lumSlider:SetValue(l)
+ frame.redSlider:SetValue(r*255)
+ frame.greenSlider:SetValue(g*255)
+ frame.blueSlider:SetValue(b*255)
+ frame.swatch:ClearAllPoints()
+ if hasAlpha then
+ frame.alphaSlider:Show()
+ frame.alphaSlider:SetValue(a)
+ frame.swatch:SetPoint("TOPLEFT", frame.alphaSlider, "BOTTOMLEFT", 4, -6)
+ else
+ frame.alphaSlider:Hide()
+ frame.swatch:SetPoint("LEFT", frame.greenSlider.editBox, "RIGHT", 3, 0)
+ end
+
+ if not _G.CurrentlyCopiedColor then
+ frame.pasteButton:Disable()
+ else
+ local CurrentlyCopiedColor = _G.CurrentlyCopiedColor
+ frame.pasteButton.text:SetTextColor(CurrentlyCopiedColor.r, CurrentlyCopiedColor.g, CurrentlyCopiedColor.b, hasAlpha and CurrentlyCopiedColor.a or 1)
+ end
+ changing = false
+
+ refixColors(frame, true)
+
+ return frame
+ end
+ end
+
+ local getChoiceControl, releaseChoiceControl
+ do
+ local pool = {}
+ -- remove a choice dropdown and put it in the pool
+ function releaseChoiceControl(frame)
+ frame:Hide()
+ frame:Enable()
+ frame:ClearAllPoints()
+ for i = 1, #frame do
+ frame[i] = nil
+ end
+ frame.desc = nil
+ frame.value = nil
+ if frame.values then
+ frame.values = del(frame.values)
+ end
+ frame.text.icon:SetTexture(nil)
+ frame.text.icon:SetWidth(epsilon)
+ frame.text.icon:SetHeight(16)
+ pool[frame] = true
+ return nil
+ end
+
+ local choiceControlsDisabled = {}
+ -- fake check enable function
+ local function frame_IsEnabled(this)
+ return choiceControlsDisabled[this] and 0 or 1
+ end
+ -- fake enable function, enable the mouse, turn normal color
+ local function frame_Enable(this)
+ if not choiceControlsDisabled[this] then
+ return
+ end
+ choiceControlsDisabled[this] = nil
+
+ this.text.fs:SetTextColor(1, 1, 1)
+ this.button:Enable()
+ this.button:EnableMouse(true)
+ this.label:Enable()
+ end
+ -- fake disable function, disable the mouse, turn gray
+ local function frame_Disable(this)
+ if choiceControlsDisabled[this] then
+ return
+ end
+ choiceControlsDisabled[this] = true
+
+ this.text.fs:SetTextColor(0.5, 0.5, 0.5)
+ this.button:Disable()
+ this.button:EnableMouse(false)
+ this.label:Disable()
+ end
+
+ -- toggle the pullout menu
+ local function button_OnClick(this)
+ if makePullout then
+ makePullout()
+ end
+ local shown = pullout:IsShown()
+ pullout:Hide()
+ local parent = this:GetParent()
+ if pullout.parent == parent and shown then
+ -- click to hide after it's been opened
+ return
+ end
+ pullout.parent = parent
+ pullout:SetFrameStrata("FULLSCREEN_DIALOG")
+ pullout:SetPoint("TOP", parent.text, "BOTTOM")
+ pullout:SetPoint("LEFT", parent.text, "LEFT")
+ pullout:SetPoint("RIGHT", parent.text, "RIGHT")
+ pullout:Show()
+ pullout:SetHeight(50)
+
+ buildPullout(parent)
+ end
+
+ local function text_OnClick(this)
+ this:GetParent().button:Click()
+ end
+
+ -- if the control is hidden and the pullout is set to it, remove that relationship
+ local function frame_OnHide(this)
+ if pullout and pullout.parent == this then
+ pullout:Hide()
+ pullout.parent = nil
+ end
+ end
+
+ local choiceControlNum = 0
+ -- create a preliminary choice dropdown
+ local function _getChoiceControl()
+ local frame = next(pool)
+ if frame then
+ pool[frame] = nil
+ frame:Show()
+ return frame
+ end
+ choiceControlNum = choiceControlNum + 1
+ local mainPane = base.mainPane
+ frame = CreateFrame("Frame", mainPane:GetName() .. "_ChoiceControl" .. choiceControlNum, mainPane.scrollChild)
+ frame.IsEnabled = frame_IsEnabled
+ frame.Enable = frame_Enable
+ frame.Disable = frame_Disable
+ frame:EnableMouse(true)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ frame:SetScript("OnHide", frame_OnHide)
+
+ local text = CreateFrame("Button", frame:GetName() .. "_Text", frame, BackdropTemplateMixin and "BackdropTemplate")
+ frame.text = text
+ local fs = text:CreateFontString(text:GetName() .. "_FontString", "OVERLAY", "ChatFontNormal")
+ text.fs = fs
+ fs:SetJustifyH("LEFT")
+ text:SetHeight(24)
+ text:SetScript("OnEnter", SubControl_OnEnter)
+ text:SetScript("OnLeave", SubControl_OnLeave)
+ local bg = newList()
+ bg.bgFile = [[Interface\Tooltips\UI-Tooltip-Background]]
+ bg.edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]]
+ bg.tile = true
+ bg.edgeSize = 16
+ bg.tileSize = 16
+ bg.insets = newList()
+ bg.insets.left = 3
+ bg.insets.right = 3
+ bg.insets.top = 3
+ bg.insets.bottom = 3
+ text:SetBackdrop(bg)
+ bg.insets = del(bg.insets)
+ bg = del(bg)
+ text:SetBackdropColor(0, 0, 0)
+
+ local icon = text:CreateTexture(text:GetName() .. "_Icon", "ARTWORK")
+ text.icon = icon
+ icon:SetWidth(epsilon)
+ icon:SetHeight(16)
+ icon:SetPoint("LEFT", 5, 0)
+ fs:SetPoint("LEFT", icon, "RIGHT", 0, 0)
+ fs:SetPoint("RIGHT", -5, 0)
+
+ local texture = text:CreateTexture(text:GetName() .. "_Texture", "ARTWORK")
+ text.texture = texture
+ texture:SetVertexColor(1, 1, 1, 0.5)
+ texture:SetPoint("LEFT", icon, "RIGHT", 0, 0)
+ texture:SetPoint("RIGHT", -5, 0)
+ texture:SetPoint("TOP", 0, -4)
+ texture:SetPoint("BOTTOM", 0, 4)
+
+ text:SetPoint("LEFT")
+
+ local button = CreateFrame("Button", frame:GetName() .. "_Button", frame)
+ frame.button = button
+ text:SetPoint("RIGHT", button, "LEFT")
+ button:SetWidth(24)
+ button:SetHeight(24)
+ button:SetScript("OnEnter", SubControl_OnEnter)
+ button:SetScript("OnLeave", SubControl_OnLeave)
+ button:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up")
+ button:GetNormalTexture():SetTexCoord(0.09, 0.91, 0.09, 0.91)
+ button:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down")
+ button:GetPushedTexture():SetTexCoord(0.09, 0.91, 0.09, 0.91)
+ button:SetDisabledTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled")
+ button:GetDisabledTexture():SetTexCoord(0.09, 0.91, 0.09, 0.91)
+ button:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight", "ADD")
+ button:GetHighlightTexture():SetTexCoord(0.09, 0.91, 0.09, 0.91)
+ button:SetPoint("RIGHT")
+ button:SetScript("OnClick", button_OnClick)
+ text:SetScript("OnClick", text_OnClick)
+ frame.type = 'choice'
+ frame:SetHeight(24)
+
+ return frame
+ end
+
+ -- fetch and set up a choice dropdown
+ function getChoiceControl(path, isMulti, parent)
+ local frame = _getChoiceControl()
+ frame.text.texture:SetTexture(nil)
+
+ local controls = parent.controls
+ controls[#controls+1] = frame
+ for i,v in ipairs(path) do
+ frame[i] = v
+ end
+
+ frame.isMulti = isMulti or nil
+ local choices = getConfigField(frame, 'choices', false, false, "table")
+ local choiceType = getConfigField(frame, 'choiceType', true, isList(choices) and "list" or "dict", "string")
+ if not isMulti then
+ -- set the text based on the single result
+ local ret = getConfigField(frame, 'get', false, false)
+ frame.value = ret
+ if choiceType == "dict" then
+ frame.text.fs:SetText(choices[ret])
+ else
+ frame.text.fs:SetText(ret)
+ end
+
+ if ret then
+ local choiceIcons = getConfigField(frame, 'choiceIcons', false, true, "table")
+ if choiceIcons and choiceIcons[ret] then
+ frame.text.icon:SetWidth(16)
+ local icon = choiceIcons[ret]
+ frame.text.icon:SetTexture(icon)
+ if icon and icon:find([[^Interface\Icons\]]) then
+ frame.text.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
+ else
+ frame.text.icon:SetTexCoord(0, 1, 0, 1)
+ end
+ end
+
+ local choiceFonts = getConfigField(frame, 'choiceFonts', false, true, "table")
+ if choiceFonts and choiceFonts[ret] then
+ local _, size, flags = ChatFontNormal:GetFont()
+ frame.text.fs:SetFont(choiceFonts[ret], size, flags)
+ else
+ frame.text.fs:SetFont(ChatFontNormal:GetFont())
+ end
+
+ local choiceTextures = getConfigField(frame, 'choiceTextures', false, true, "table")
+ if choiceTextures and choiceTextures[ret] then
+ frame.text.texture:SetTexture(choiceTextures[ret])
+ end
+ end
+ else
+ -- set the text based on a concatenation of all the true values (or show None)
+ local keys = newList()
+ if choiceType == "dict" then
+ for k,v in pairs(choices) do
+ keys[#keys+1] = k
+ end
+ choiceSort__choices = choices
+ table_sort(keys, choiceSort)
+ choiceSort__choices = nil
+ else
+ for i,v in ipairs(choices) do
+ keys[i] = v
+ end
+ end
+
+ local values = newList()
+ frame.values = values
+
+ local t = newList()
+ for _,k in ipairs(keys) do
+ local tmp = newList(k)
+ local success, ret = callConfigField(frame, 'get', tmp)
+ if success and ret then
+ if ret ~= "HALF" then
+ values[k] = true
+ if choiceType == "dict" then
+ t[#t+1] = choices[k]
+ else
+ t[#t+1] = k
+ end
+ else
+ values[k] = "HALF"
+ end
+ end
+ tmp = del(tmp)
+ end
+
+ local s
+ if #t == 0 then
+ s = _G.NONE
+ else
+ s = table_concat(t, ", ")
+ end
+ frame.text.icon:SetWidth(epsilon)
+ frame.text.fs:SetFont(ChatFontNormal:GetFont())
+ frame.text.fs:SetText(s)
+ end
+ return frame
+ end
+ end
+
+ local getStringControl, releaseStringControl
+ do
+ local pool = {}
+ -- remove an edit box, put in the pool
+ function releaseStringControl(frame)
+ frame:Hide()
+ frame:Enable()
+ frame:ClearAllPoints()
+ local editBox = frame.editBox
+ if editBox:IsMultiLine() then
+ editBox:SetMultiLine(false)
+ editBox:SetScript("OnTextChanged", editBox_OnTextChanged)
+ editBox:SetScript("OnEnterPressed", editBox_OnEnterPressed)
+ editBox:ClearAllPoints()
+ editBox:SetPoint("LEFT")
+ editBox:SetPoint("TOP")
+ editBox:SetPoint("BOTTOM")
+ editBox:SetPoint("RIGHT")
+ frame.saveButton:Hide()
+ frame:SetHeight(24)
+ frame.warning:Hide()
+ end
+ for i = 1, #frame do
+ frame[i] = nil
+ end
+ frame.desc = nil
+ frame.value = nil
+ frame.validationIssue = nil
+ pool[frame] = true
+ return nil
+ end
+
+ -- show a tooltip on hover
+ local function frame_OnEnter(this)
+ local name = this.label.text:GetText()
+ local desc = this.desc
+ if not desc then
+ desc = getConfigField(this, 'desc', true, false, "string")
+ local usage = getConfigField(this, 'usage', true, false, "string")
+ desc = desc .. "\n\n" .. USAGE_COLON .. usage
+ this.desc = desc
+ end
+ if this.validationIssue then
+ desc = desc .. "\n\n|cffff7f7f" .. this.validationIssue
+ end
+ showTooltip(this, name, desc, this:IsEnabled() ~= 1)
+ end
+
+ local stringControlsDisabled = {}
+ -- fake enable check
+ local function frame_IsEnabled(this)
+ return stringControlsDisabled[this] and 0 or 1
+ end
+ -- fake disable method, turn gray and disable focus
+ local function frame_Disable(this)
+ if stringControlsDisabled[this] then
+ return
+ end
+ stringControlsDisabled[this] = true
+ this.editBox:SetTextColor(0.5, 0.5, 0.5, 1)
+ recolorEditBoxStyle(this.editBox, 0.5, 0.5, 0.5, 1)
+ this.editBox:EnableMouse(false)
+ this.label:Disable()
+ end
+ -- fake disable method, turn white and enable focus ability
+ local function frame_Enable(this)
+ if not stringControlsDisabled[this] then
+ return
+ end
+ stringControlsDisabled[this] = nil
+ this.editBox:SetTextColor(1, 1, 1, 1)
+ recolorEditBoxStyle(this.editBox, 1, 1, 1, 1)
+ this.editBox:EnableMouse(true)
+ this.label:Enable()
+ end
+
+ local hasFocus, lastText
+ -- set the text back to default if focus is lost
+ local function editBox_OnEditFocusLost(this)
+ if hasFocus == this then
+ hasFocus = nil
+ lastText = nil
+ end
+ this:SetText(tostring(this:GetParent().value or ''))
+ end
+ local function editBox_OnEditFocusGained(this)
+ hasFocus = this
+ lastText = this:GetText()
+ end
+ -- clear focus on escape, reset to default
+ local function editBox_OnEscapePressed(this)
+ this:ClearFocus()
+ end
+ local dontCall = false
+
+ local function stripColors__handler(x, y)
+ if #x%2 == 0 then
+ return x
+ else
+ return x .. y
+ end
+ end
+ local function stripColors(text)
+ return text:gsub("(|*)(|c%x%x%x%x%x%x%x%x)", stripColors__handler):gsub("(|*)(|r)", stripColors__handler)
+ end
+
+ local function highlight(this, text)
+ if hasFocus == this and lastText ~= this:GetText() then
+ dontCall = true
+ local tmp = newList(text)
+ local success, ret, problem = callConfigField(this:GetParent(), 'syntaxHighlighter', tmp, true)
+ tmp = del(tmp)
+ if success and ret then
+ lastText = ret:gsub("(|*)|r", stripColors__handler)
+ local position = this:GetCursorPosition()
+ local skip = 0
+ local colorText = this:GetText()
+ for i = 1, position do
+ if colorText:byte(i) == ("|"):byte() then
+ if colorText:byte(i+1) == ("c"):byte() then
+ skip = skip + 10
+ elseif colorText:byte(i+1) == ("r"):byte() then
+ skip = skip + 2
+ end
+ end
+ end
+ position = position - skip
+ this:SetText(lastText)
+
+ local betterPosition = 0
+ for i = 1, position do
+ betterPosition = betterPosition + 1
+ while lastText:byte(betterPosition) == ("|"):byte() do
+ if lastText:byte(betterPosition+1) == ("c"):byte() then
+ betterPosition = betterPosition + 10
+ elseif lastText:byte(betterPosition+1) == ("r"):byte() then
+ betterPosition = betterPosition + 2
+ else
+ break
+ end
+ end
+ end
+
+ this:SetCursorPosition(betterPosition)
+ end
+ dontCall = false
+ end
+ end
+ local function editBox_OnTextChanged(this, ...)
+ if dontCall then
+ return
+ end
+ local parent = this:GetParent()
+ local text = stripColors(this:GetText() or '')
+ local tmp = newList(text)
+ local success, ret, problem = callConfigField(parent, 'validate', tmp, true)
+ tmp = del(tmp)
+ if success then
+ if ret then
+ parent.validationIssue = nil
+ this:SetPoint("RIGHT", parent, "RIGHT")
+ parent.warning:Hide()
+ else
+ parent.validationIssue = problem
+ this:SetPoint("RIGHT", parent.warning, "LEFT")
+ parent.warning:Show()
+ end
+ if GameTooltip:IsOwned(parent) then
+ parent:GetScript("OnEnter")(parent)
+ end
+ end
+ local tmp = newList(text)
+ callConfigField(parent, 'onChange', tmp, true)
+ tmp = del(tmp)
+
+ highlight(this, text)
+ end
+ local fs = UIParent:CreateFontString(nil, "ARTWORK")
+ local function editBox_OnMultilineTextChanged(this, ...)
+ if dontCall then
+ return
+ end
+ local parent = this:GetParent()
+ local text = stripColors(this:GetText() or '')
+ fs:SetFontObject(this:GetFontObject())
+ fs:SetWidth(parent:GetWidth())
+ fs:SetText(text)
+ local height = fs:GetHeight() + 6
+ if height < 42 then
+ height = 42
+ end
+ parent:SetHeight(height + 18)
+ local tmp = newList(text)
+ local success, ret, problem = callConfigField(parent, 'validate', tmp, true)
+ tmp = del(tmp)
+ if success then
+ if ret then
+ parent.validationIssue = nil
+ this:SetPoint("RIGHT", parent, "RIGHT")
+ parent.warning:Hide()
+ else
+ parent.validationIssue = problem
+ this:SetPoint("RIGHT", parent.warning, "LEFT")
+ parent.warning:Show()
+ end
+ if GameTooltip:IsOwned(parent) then
+ parent:GetScript("OnEnter")(parent)
+ end
+ end
+ if parent.validationIssue then
+ return
+ end
+ local tmp = newList(text)
+ callConfigField(parent, 'onChange', tmp, true)
+ tmp = del(tmp)
+
+ highlight(this, text)
+ if this.inlineGroup and this.inlineGroup.label then
+ this.inlineGroup:Reposition()
+ end
+ end
+ -- on enter, save the data, clear focus
+ local function editBox_OnEnterPressed(this)
+ local parent = this:GetParent()
+ local text = this:GetText()
+ if parent.value == text then
+ this:ClearFocus()
+ return
+ end
+ if parent.validationIssue then
+ return
+ end
+ text = stripColors(text)
+ local tmp = newList(text)
+ callConfigField(parent, 'set', tmp)
+ tmp = del(tmp)
+
+ refreshConfigMenu(parent[1])
+ end
+
+ local function editBox_OnReceiveDrag(this)
+ local type, alpha, bravo = GetCursorInfo()
+ local text
+ if type == "spell" then
+ text = GetSpellName(alpha, bravo)
+ elseif type == "item" then
+ text = bravo
+ end
+ if not text then
+ return
+ end
+ ClearCursor()
+ this:SetText(text)
+ end
+
+ local function editBox_OnMouseDown(this, arg1)
+ if arg1 == "LeftButton" then
+ if GetCursorInfo() and (CursorHasItem() or CursorHasSpell()) then
+ return editBox_OnReceiveDrag(this)
+ end
+ end
+ end
+
+ local function button_Disable(this)
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this:__Disable()
+ this:EnableMouse(false)
+ end
+
+ local function button_Enable(this)
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this:__Enable()
+ this:EnableMouse(true)
+ end
+
+ -- when pressed, the button should look pressed
+ local function button_OnMouseDown(this)
+ if this:IsEnabled() == 1 then
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ end
+ end
+ -- when depressed, return to normal
+ local function button_OnMouseUp(this)
+ if this:IsEnabled() == 1 then
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ end
+ end
+
+ local function saveButton_OnClick(this)
+ local parent = this:GetParent()
+ local editBox = parent.editBox
+ local text = editBox:GetText()
+ if parent.value == text then
+ editBox:ClearFocus()
+ return
+ end
+ if parent.validationIssue then
+ return
+ end
+ text = stripColors(text)
+ local tmp = newList(text)
+ callConfigField(parent, 'set', tmp)
+ tmp = del(tmp)
+
+ refreshConfigMenu(parent[1])
+ end
+
+ local stringControlNum = 0
+ -- create a preliminary edit box
+ -- TODO: support multi-line
+ local function _getStringControl()
+ local frame = next(pool)
+ if frame then
+ pool[frame] = nil
+ frame:Show()
+ return frame
+ end
+ stringControlNum = stringControlNum + 1
+ local mainPane = base.mainPane
+ frame = CreateFrame("Frame", mainPane:GetName() .. "_StringControl" .. stringControlNum, mainPane.scrollChild)
+
+ frame.Disable = frame_Disable
+ frame.Enable = frame_Enable
+ frame.IsEnabled = frame_IsEnabled
+
+ frame.type = 'string'
+ frame:SetHeight(24)
+ frame:EnableMouse(true)
+
+ local editBox = CreateFrame("EditBox", frame:GetName() .. "_EditBox", frame)
+ frame.editBox = editBox
+ editBox:SetAutoFocus(false)
+ editBox:SetFontObject(ChatFontNormal)
+
+ editBox:SetScript("OnEscapePressed", editBox_OnEscapePressed)
+ editBox:SetScript("OnTextChanged", editBox_OnTextChanged)
+ editBox:SetScript("OnEnterPressed", editBox_OnEnterPressed)
+ editBox:SetScript("OnEditFocusLost", editBox_OnEditFocusLost)
+ editBox:SetScript("OnEditFocusGained", editBox_OnEditFocusGained)
+ editBox:SetScript("OnReceiveDrag", editBox_OnReceiveDrag)
+ editBox:SetScript("OnMouseDown", editBox_OnMouseDown)
+ frame:SetScript("OnEnter", frame_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ editBox:SetScript("OnEnter", SubControl_OnEnter)
+ editBox:SetScript("OnLeave", SubControl_OnLeave)
+
+ local warning = frame:CreateTexture(frame:GetName() .. "_Warning", "ARTWORK")
+ frame.warning = warning
+ warning:Hide()
+ warning:SetTexture([[Interface\DialogFrame\DialogAlertIcon]])
+ warning:SetWidth(24)
+ warning:SetHeight(24)
+ warning:SetPoint("RIGHT")
+
+ return frame
+ end
+
+ -- fetch and set up an edit box
+ function getStringControl(path, parent)
+ local frame = _getStringControl()
+
+ local controls = parent.controls
+ controls[#controls+1] = frame
+ for i,v in ipairs(path) do
+ frame[i] = v
+ end
+ local editBox = frame.editBox
+ if getConfigField(frame, 'multiline', false, true, "boolean") then
+ editBox:SetMultiLine(true)
+ editBox:ClearAllPoints()
+ editBox:SetPoint("LEFT", frame, "LEFT", 1, 0)
+ editBox:SetPoint("TOP", frame, "TOP", 0, -3)
+ editBox:SetPoint("BOTTOM", frame, "BOTTOM", 0, 18)
+ editBox:SetPoint("RIGHT", frame, "RIGHT", -1, 0)
+ frame:SetHeight(42)
+ editBox:SetScript("OnTextChanged", editBox_OnMultilineTextChanged)
+ editBox:SetScript("OnEnterPressed", nil)
+ if parent:GetName():match("Inline") then
+ editBox.inlineGroup = parent
+ end
+
+ if not frame.saveButton then
+ local button = CreateFrame("Button", frame:GetName() .. (i == 1 and "_button" or "_PasteButton"), frame)
+ frame.saveButton = button
+ local left = button:CreateTexture(button:GetName() .. "_LeftTexture", "BACKGROUND")
+ button.left = left
+ local middle = button:CreateTexture(button:GetName() .. "_MiddleTexture", "BACKGROUND")
+ button.middle = middle
+ local right = button:CreateTexture(button:GetName() .. "_RightTexture", "BACKGROUND")
+ button.right = right
+ left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+
+ left:SetPoint("TOPLEFT")
+ left:SetPoint("BOTTOMLEFT")
+ left:SetWidth(12)
+ left:SetTexCoord(0, 0.09375, 0, 0.6875)
+
+ right:SetPoint("TOPRIGHT")
+ right:SetPoint("BOTTOMRIGHT")
+ right:SetWidth(12)
+ right:SetTexCoord(0.53125, 0.625, 0, 0.6875)
+
+ middle:SetPoint("TOPLEFT", left, "TOPRIGHT")
+ middle:SetPoint("BOTTOMRIGHT", right, "BOTTOMLEFT")
+ middle:SetTexCoord(0.09375, 0.53125, 0, 0.6875)
+
+ button:SetScript("OnMouseDown", button_OnMouseDown)
+ button:SetScript("OnMouseUp", button_OnMouseUp)
+
+ local text = button:CreateFontString(button:GetName() .. "_FontString", "ARTWORK")
+ button:SetFontString(text)
+ button.text = text
+ text:SetPoint("LEFT", button, "LEFT", 7, 0)
+ text:SetPoint("RIGHT", button, "RIGHT", -7, 0)
+
+ button[SET_NORMAL_FONT_OBJECT](button, GameFontNormal)
+ button:SetHighlightFontObject(GameFontHighlight)
+ button:SetDisabledFontObject(GameFontDisable)
+
+ text:SetText(SAVE)
+
+ local highlight = button:CreateTexture(button:GetName() .. "_Highlight", "OVERLAY", "UIPanelButtonHighlightTexture")
+ button:SetHighlightTexture(highlight)
+
+ button:SetScript("OnClick", saveButton_OnClick)
+ button:SetScript("OnEnter", SubControl_OnEnter)
+ button:SetScript("OnLeave", SubControl_OnLeave)
+
+ button.__Disable = button.Disable
+ button.__Enable = button.Enable
+ button.Disable = button_Disable
+ button.Enable = button_Enable
+
+ button:SetPoint("TOPRIGHT", editBox, "BOTTOMRIGHT", 0, 0)
+ button:SetWidth(100)
+ button:SetHeight(18)
+ else
+ local button = frame.saveButton
+ button:Show()
+ end
+ else
+ editBox:SetScript("OnTextChanged", editBox_OnTextChanged)
+ editBox:SetScript("OnEnterPressed", editBox_OnEnterPressed)
+ editBox:SetPoint("LEFT", frame, "LEFT", 1, 0)
+ editBox:SetPoint("TOP", frame, "TOP", 0, 0)
+ editBox:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0)
+ editBox:SetPoint("RIGHT", frame, "RIGHT", -1, 0)
+ end
+
+ styleEditBox(editBox)
+
+ local ret = getConfigField(frame, 'get', false, false, "string;boolean;number") or ''
+ local tmp = newList(ret)
+ local success, r = callConfigField(frame, 'syntaxHighlighter', tmp, true)
+ if success then
+ ret = r
+ end
+ ret = tostring(ret or '')
+ frame.editBox:SetText(ret)
+ frame.value = ret
+
+ return frame
+ end
+ end
+
+ local releaseKeybindingControl, getKeybindingControl
+ do
+ local currentLock = nil
+ local button_Unclick
+ -- button
+ local pool = {}
+ -- remove a button and put it in the pool
+ function releaseKeybindingControl(frame)
+ if currentLock == frame then
+ button_Unclick(frame)
+ end
+ frame:Hide()
+ frame:Enable()
+ frame.button:Enable()
+ frame:ClearAllPoints()
+ for i = 1, #frame do
+ frame[i] = nil
+ end
+ frame.desc = nil
+ frame.previousText = nil
+ pool[frame] = true
+ return nil
+ end
+ -- when pressed, the button should look pressed
+ local function button_OnMouseDown(this)
+ if this:IsEnabled() == 1 then
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Down]])
+ end
+ end
+ -- when depressed, return to normal
+ local function button_OnMouseUp(this)
+ if this:IsEnabled() == 1 then
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ end
+ end
+ local keybindingControlsDisabled = {}
+ -- fake enable check
+ local function frame_IsEnabled(this)
+ return keybindingControlsDisabled[this] and 0 or 1
+ end
+ -- when disabled, turn gray
+ local function frame_Disable(this)
+ if keybindingControlsDisabled[this] then
+ return
+ end
+ keybindingControlsDisabled[this] = true
+ this.label:Disable()
+ this.button:Disable()
+ end
+ -- when enabled, return to normal
+ local function frame_Enable(this)
+ if not keybindingControlsDisabled[this] then
+ return
+ end
+ keybindingControlsDisabled[this] = nil
+ this.label:Enable()
+ this.button:Enable()
+ end
+
+ local function button_Disable(this)
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Disabled]])
+ this:__Disable()
+ this:EnableMouse(false)
+ end
+
+ local function button_Enable(this)
+ this.left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this.right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ this:__Enable()
+ this:EnableMouse(true)
+ end
+
+ function button_Unclick(this)
+ this:UnlockHighlight()
+ this:EnableKeyboard(false)
+ this:SetText(this.previousText)
+ currentLock = nil
+ end
+ -- call the actual function
+ local function button_OnClick(this)
+ if currentLock then--and currentLock ~= this then
+ button_Unclick(currentLock)
+ return
+ end
+ this:LockHighlight()
+ this:EnableKeyboard(true)
+ currentLock = this
+ this.previousText = this.text:GetText()
+ this.text:SetText(BIND_KEY_TO_COMMAND:format(this:GetParent().label.text:GetText()))
+ end
+
+ local function button_OnKeyDown(this, key)
+ if currentLock ~= this then
+ return
+ end
+
+ if key == "SHIFT" or key == "ALT" or key == "CTRL" or key == "LSHIFT" or key == "RSHIFT" or key == "LALT" or key == "RALT" or key == "LCTRL" or key == "RCTRL" or key == "UNKNOWN" then
+ return
+ end
+
+ local keybind = key
+ if key == "ESCAPE" then
+ key = false
+ keybind = false
+ else
+ if IsShiftKeyDown() then
+ key = "SHIFT-" .. key
+ end
+ if IsControlKeyDown() then
+ key = "CTRL-" .. key
+ end
+ if IsAltKeyDown() then
+ key = "ALT-" .. key
+ end
+ end
+
+ local parent = this:GetParent()
+ local keybindingOnly = getConfigField(parent, 'keybindingOnly', false, true, "table")
+ if keybindingOnly then
+ if not keybindingOnly[keybind] then
+ return
+ end
+ else
+ local keybindingExcept = getConfigField(parent, 'keybindingExcept', false, true, "table")
+ if keybindingExcept and keybindingExcept[keybind] then
+ return
+ end
+ end
+
+ local t = newList(key)
+ callConfigField(parent, 'set', t)
+ t = del(t)
+ button_Unclick(this)
+ refreshConfigMenu(parent[1])
+ end
+
+ local function button_OnMouseDown(this, button)
+ if currentLock ~= this then
+ return
+ end
+ local key
+ if button == "LeftButton" then
+ key = "BUTTON1"
+ elseif button == "RightButton" then
+ key = "BUTTON2"
+ elseif button == "MiddleButton" then
+ key = "BUTTON3"
+ elseif button == "MouseButton4" then
+ key = "BUTTON4"
+ elseif button == "MouseButton5" then
+ key = "BUTTON5"
+ else
+ return
+ end
+
+ return button_OnKeyDown(this, key)
+ end
+ local keybindingControlNum = 0
+ -- create a preliminary button
+ local function _getKeybindingControl()
+ local frame = next(pool)
+ if frame then
+ pool[frame] = nil
+ frame:Show()
+ return frame
+ end
+ keybindingControlNum = keybindingControlNum + 1
+ local mainPane = base.mainPane
+ frame = CreateFrame("Frame", mainPane:GetName() .. "_KeybindingControl" .. keybindingControlNum, mainPane.scrollChild)
+
+ local button = CreateFrame("Button", frame:GetName() .. "_Button", frame)
+ frame.button = button
+ local left = button:CreateTexture(button:GetName() .. "_LeftTexture", "BACKGROUND")
+ button.left = left
+ local middle = button:CreateTexture(button:GetName() .. "_MiddleTexture", "BACKGROUND")
+ button.middle = middle
+ local right = button:CreateTexture(button:GetName() .. "_RightTexture", "BACKGROUND")
+ button.right = right
+ left:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ middle:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+ right:SetTexture([[Interface\Buttons\UI-Panel-Button-Up]])
+
+ left:SetPoint("TOPLEFT")
+ left:SetPoint("BOTTOMLEFT")
+ left:SetWidth(12)
+ left:SetTexCoord(0, 0.09375, 0, 0.6875)
+
+ right:SetPoint("TOPRIGHT")
+ right:SetPoint("BOTTOMRIGHT")
+ right:SetWidth(12)
+ right:SetTexCoord(0.53125, 0.625, 0, 0.6875)
+
+ middle:SetPoint("TOPLEFT", left, "TOPRIGHT")
+ middle:SetPoint("BOTTOMRIGHT", right, "BOTTOMLEFT")
+ middle:SetTexCoord(0.09375, 0.53125, 0, 0.6875)
+
+ button:SetScript("OnMouseDown", button_OnMouseDown)
+ button:SetScript("OnMouseUp", button_OnMouseUp)
+
+ button.__Enable = button.Enable
+ button.__Disable = button.Disable
+ button.Enable = button_Enable
+ button.Disable = button_Disable
+
+ frame.IsEnabled = frame_IsEnabled
+ frame.Disable = frame_Disable
+ frame.Enable = frame_Enable
+
+ local text = button:CreateFontString(button:GetName() .. "_FontString", "ARTWORK")
+ button:SetFontString(text)
+ button.text = text
+ text:SetPoint("LEFT", button, "LEFT", 7, 0)
+ text:SetPoint("RIGHT", button, "RIGHT", -7, 0)
+
+ button[SET_NORMAL_FONT_OBJECT](button, GameFontNormal)
+ button:SetHighlightFontObject(GameFontHighlight)
+ button:SetDisabledFontObject(GameFontDisable)
+ local highlight = button:CreateTexture(button:GetName() .. "_Highlight", "OVERLAY", "UIPanelButtonHighlightTexture")
+ button:SetHighlightTexture(highlight)
+
+ button:SetScript("OnClick", button_OnClick)
+ frame:SetScript("OnEnter", Control_OnEnter)
+ frame:SetScript("OnLeave", Control_OnLeave)
+ button:SetScript("OnEnter", SubControl_OnEnter)
+ button:SetScript("OnLeave", SubControl_OnLeave)
+ button:SetScript("OnMouseDown", button_OnMouseDown)
+ button:SetScript("OnKeyDown", button_OnKeyDown)
+
+ frame:EnableMouse(true)
+ button:EnableMouse(true)
+
+ frame:SetHeight(24)
+ button:SetAllPoints()
+
+ frame.type = 'keybinding'
+
+ return frame
+ end
+ -- fetch and set up a button
+ function getKeybindingControl(path, parent)
+ local frame = _getKeybindingControl()
+
+ local controls = parent.controls
+ controls[#controls+1] = frame
+ for i,v in ipairs(path) do
+ frame[i] = v
+ end
+ local keybind = getConfigField(frame, 'get', false, true, "string;boolean")
+ if not keybind then
+ frame.button.text:SetText(KEYBINDING_COLON .. NOT_BOUND)
+ else
+ local alt, rest = keybind:match("^(ALT)%-(.*)$")
+ if alt then
+ keybind = rest
+ end
+ local ctrl, rest = keybind:match("^(CTRL)%-(.*)$")
+ if ctrl then
+ keybind = rest
+ end
+ local shift, rest = keybind:match("^(SHIFT)%-(.*)$")
+ if shift then
+ keybind = rest
+ end
+ local text
+ if keybind == "BUTTON1" then
+ text = KEY_BUTTON1
+ elseif keybind == "BUTTON2" then
+ text = KEY_BUTTON2
+ else
+ text = GetBindingText(keybind, "KEY_")
+ end
+ if shift then
+ text = "Shift-" .. text
+ end
+ if ctrl then
+ text = "Ctrl-" .. text
+ end
+ if alt then
+ text = "Alt-" .. text
+ end
+ frame.button.text:SetText(KEYBINDING_COLON .. text)
+ end
+ frame.button:SetAllPoints()
+ return frame
+ end
+ end
+
+ local releaseInlineGroupControl, getInlineGroupControl
+ do
+ local pool = {}
+ -- remove a control and put it in the pool
+ function releaseInlineGroupControl(frame)
+ frame:Hide()
+ frame:Enable()
+ frame:ClearAllPoints()
+ for i = 1, #frame do
+ frame[i] = nil
+ end
+ frame.desc = nil
+ frame.parent = nil
+ clearMainPane(frame)
+ pool[frame] = true
+ return nil
+ end
+
+ local inlineGroupControlsDisabled = {}
+ -- fake enable check
+ local function frame_IsEnabled(this)
+ return inlineGroupControlsDisabled[this] and 0 or 1
+ end
+ -- when disabled, turn gray
+ local function frame_Disable(this)
+ if inlineGroupControlsDisabled[this] then
+ return
+ end
+ inlineGroupControlsDisabled[this] = true
+
+ this.label:Disable()
+ this.vertLineLeft:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b)
+ this.vertLineRight:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b)
+ this.horizLineTop:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b)
+ this.horizLineBottom:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b)
+
+ for i,v in ipairs(this.controls) do
+ v:Disable()
+ end
+ end
+ -- when enabled, return to normal
+ local function frame_Enable(this)
+ if not inlineGroupControlsDisabled[this] then
+ return
+ end
+ inlineGroupControlsDisabled[this] = nil
+
+ this.label:Enable()
+ this.vertLineLeft:SetVertexColor(NORMAL_FONT_COLOR.r/2, NORMAL_FONT_COLOR.g/2, NORMAL_FONT_COLOR.b/2)
+ this.vertLineRight:SetVertexColor(NORMAL_FONT_COLOR.r/2, NORMAL_FONT_COLOR.g/2, NORMAL_FONT_COLOR.b/2)
+ this.horizLineTop:SetVertexColor(NORMAL_FONT_COLOR.r/2, NORMAL_FONT_COLOR.g/2, NORMAL_FONT_COLOR.b/2)
+ this.horizLineBottom:SetVertexColor(NORMAL_FONT_COLOR.r/2, NORMAL_FONT_COLOR.g/2, NORMAL_FONT_COLOR.b/2)
+
+ for i,v in ipairs(this.controls) do
+ local disabled = getConfigField(v, 'disabled', false, true)
+ if not disabled then
+ v:Enable()
+ end
+ end
+ end
+
+ local function frame_Reposition(this)
+ local parent = this.parent
+
+ this.horizLineTop:SetPoint("LEFT", this.label.text, "RIGHT", 9, 0)
+
+ local controls = this.controls
+ local maxLabelWidth = 0
+ for i, v in ipairs(controls) do
+ local label = v.label
+ label.text:SetWidth(0)
+ label:ClearAllPoints()
+ local label_width = label.text:GetWidth()
+ if label.icon:IsShown() then
+ label_width = label_width + label.icon:GetWidth() + 1
+ end
+ if label_width > maxLabelWidth then
+ maxLabelWidth = label_width
+ end
+ end
+ local last
+ local height = 27
+ local yOffset = -24
+ for i,v in ipairs(controls) do
+ local label = v.label
+ label:SetWidth(maxLabelWidth)
+ label:SetHeight(math_min(24, v:GetHeight()))
+ height = height + 3 + v:GetHeight()
+ label:SetPoint("LEFT", this.vertLineLeft, "LEFT", 6, 0)
+ v:SetPoint("LEFT", label, "RIGHT", 8, 0)
+ v:SetPoint("RIGHT", this.vertLineRight, "RIGHT", -6, 0)
+ v:SetPoint("TOP", label, "TOP")
+
+ if not last then
+ label:SetPoint("TOP", this, "TOP", 0, yOffset)
+ else
+ label:SetPoint("TOP", last, "BOTTOM", 0, yOffset)
+ end
+
+ last = v
+ yOffset = -3
+ end
+ this:SetHeight(height)
+ if this.parent:GetName():match("Inline") then
+ this.parent:Reposition()
+ end
+ end
+
+ local function frame_SizeChanged(this, paneWidth)
+ local label = this.controls[1] and this.controls[1].label
+ if not label then
+ return
+ end
+ local labelWidth = label:GetWidth()
+ local paneWidth = base.mainPane.scrollFrame:GetWidth() - labelWidth - 22
+ for i,v in ipairs(this.controls) do
+ if v.SizeChanged then
+ v:SizeChanged(paneWidth)
+ end
+ end
+ end
+
+ local inlineGroupControlNum = 0
+ -- create a preliminary button
+ local function _getInlineGroupControl()
+ local frame = next(pool)
+ if frame then
+ pool[frame] = nil
+ frame:Show()
+ return frame
+ end
+ inlineGroupControlNum = inlineGroupControlNum + 1
+ local mainPane = base.mainPane
+ frame = CreateFrame("Frame", mainPane:GetName() .. "_InlineGroupControl" .. inlineGroupControlNum, mainPane.scrollChild)
+
+ local horizLineTop = frame:CreateTexture(frame:GetName() .. "_HorizontalLineTop", "BACKGROUND")
+ frame.horizLineTop = horizLineTop
+ local horizLineBottom = frame:CreateTexture(frame:GetName() .. "_HorizontalLineBottom", "BACKGROUND")
+ frame.horizLineBottom = horizLineBottom
+ local vertLineLeft = frame:CreateTexture(frame:GetName() .. "_VerticalLineLeft", "BACKGROUND")
+ frame.vertLineLeft = vertLineLeft
+ local vertLineRight = frame:CreateTexture(frame:GetName() .. "_VerticalLineRight", "BACKGROUND")
+ frame.vertLineRight = vertLineRight
+ horizLineTop:SetTexture([[Interface\Buttons\WHITE8X8]])
+ horizLineTop:SetHeight(1)
+ horizLineBottom:SetTexture([[Interface\Buttons\WHITE8X8]])
+ horizLineBottom:SetHeight(1)
+ vertLineLeft:SetTexture([[Interface\Buttons\WHITE8X8]])
+ vertLineLeft:SetWidth(1)
+ vertLineRight:SetTexture([[Interface\Buttons\WHITE8X8]])
+ vertLineRight:SetWidth(1)
+ horizLineTop:SetVertexColor(NORMAL_FONT_COLOR.r/2, NORMAL_FONT_COLOR.g/2, NORMAL_FONT_COLOR.b/2)
+ horizLineBottom:SetVertexColor(NORMAL_FONT_COLOR.r/2, NORMAL_FONT_COLOR.g/2, NORMAL_FONT_COLOR.b/2)
+ vertLineLeft:SetVertexColor(NORMAL_FONT_COLOR.r/2, NORMAL_FONT_COLOR.g/2, NORMAL_FONT_COLOR.b/2)
+ vertLineRight:SetVertexColor(NORMAL_FONT_COLOR.r/2, NORMAL_FONT_COLOR.g/2, NORMAL_FONT_COLOR.b/2)
+ horizLineTop:SetPoint("TOP", frame, "TOP", 0, -12)
+ horizLineTop:SetPoint("RIGHT", vertLineRight, "RIGHT")
+ vertLineLeft:SetPoint("BOTTOM", 0, 3)
+ vertLineLeft:SetPoint("TOP", frame, "TOP", 0, -24)
+ vertLineRight:SetPoint("BOTTOM", 0, 3)
+ vertLineRight:SetPoint("TOP", frame, "TOP", 0, -12)
+ horizLineBottom:SetPoint("BOTTOMLEFT", vertLineLeft, "BOTTOMLEFT")
+ horizLineBottom:SetPoint("BOTTOMRIGHT", vertLineRight, "BOTTOMRIGHT")
+
+ frame.IsEnabled = frame_IsEnabled
+ frame.Disable = frame_Disable
+ frame.Enable = frame_Enable
+
+ frame.Reposition = frame_Reposition
+ frame.SizeChanged = frame_SizeChanged
+
+ frame:EnableMouse(true)
+
+ frame.type = 'group'
+ frame.groupType = 'inline'
+
+ frame:SetHeight(24)
+
+ frame.controls = {}
+
+ return frame
+ end
+ -- fetch and set up a button
+ function getInlineGroupControl(path, parent)
+ local frame = _getInlineGroupControl()
+ frame.parent = parent
+
+ local controls = parent.controls
+ controls[#controls+1] = frame
+ for i,v in ipairs(path) do
+ frame[i] = v
+ end
+ if parent == base.mainPane then
+ frame.vertLineLeft:SetPoint("LEFT", parent.scrollFrame, "LEFT", 3, 0)
+ frame.vertLineRight:SetPoint("RIGHT", parent.scrollFrame, "RIGHT", -3, 0)
+ else
+ frame.vertLineLeft:SetPoint("LEFT", parent.vertLineLeft, "LEFT", 6, 0)
+ frame.vertLineRight:SetPoint("RIGHT", parent.vertLineRight, "RIGHT", -6, 0)
+ end
+
+ return frame
+ end
+ end
+
+ -- clear the main pane of all controls
+ function clearMainPane(parent)
+ local controls = parent.controls
+
+ for i,v in ipairs(controls) do
+ local v_type = v.type
+ if v_type == 'execute' then
+ controls[i] = releaseExecuteControl(v)
+ elseif v_type == 'boolean' then
+ controls[i] = releaseBooleanControl(v)
+ elseif v_type == 'number' then
+ controls[i] = releaseNumberControl(v)
+ elseif v_type == 'color' then
+ controls[i] = releaseColorControl(v)
+ elseif v_type == 'choice' then
+ controls[i] = releaseChoiceControl(v, false)
+ elseif v_type == 'multichoice' then
+ controls[i] = releaseChoiceControl(v, true)
+ elseif v_type == 'string' then
+ controls[i] = releaseStringControl(v)
+ elseif v_type == 'keybinding' then
+ controls[i] = releaseKeybindingControl(v)
+ elseif v_type == 'group' and v.groupType == 'inline' then
+ controls[i] = releaseInlineGroupControl(v)
+ else
+ error(("Unknown control type: %q"):format(tostring(v_type)))
+ end
+ v.label = releaseLabel(v.label)
+ end
+ end
+
+ -- sorting helper function
+ local function myFunc(alpha, bravo)
+ local alpha_order = getConfigField(alpha, 'order', false, 100, "number")
+ local bravo_order = getConfigField(bravo, 'order', false, 100, "number")
+ if alpha_order == bravo_order then
+ return alpha.label.text:GetText():lower() < bravo.label.text:GetText():lower()
+ else
+ if alpha_order < 0 then
+ if bravo_order < 0 then
+ return alpha_order < bravo_order
+ else
+ return false
+ end
+ else
+ if bravo_order < 0 then
+ return true
+ else
+ return alpha_order < bravo_order
+ end
+ end
+ end
+ end
+ -- sort the controls within the main pane
+ local function sortMainPaneSections(parent)
+ table_sort(parent.controls, myFunc)
+ end
+
+ -- populate the main pane with controls based on the path
+ function populateMainPane(path, parent)
+ if not parent then
+ parent = base.mainPane
+ end
+ local args = getConfigField(path, 'args', false, false, "table")
+ local extraArgs
+ if #path == 1 then
+ extraArgs = getConfigField(path, 'extraArgs', false, true, "table")
+ if extraArgs then
+ local realArgs = args
+ args = newList()
+ for k,v in pairs(extraArgs) do
+ args[k] = v
+ end
+ for k,v in pairs(realArgs) do
+ args[k] = v
+ end
+ end
+ end
+
+ for k,v in pairs(args) do
+ local t = newList(unpack(path))
+ t[#t+1] = k
+ local v_type = getConfigField(t, 'type', true, false, "string")
+ local hidden = getConfigField(t, 'hidden', false, true)
+ if not hidden then
+ local frame
+ local inlineGroup = false
+ if v_type == 'execute' then
+ frame = getExecuteControl(t, parent)
+ elseif v_type == 'boolean' then
+ frame = getBooleanControl(t, parent)
+ elseif v_type == 'number' then
+ frame = getNumberControl(t, parent)
+ elseif v_type == 'color' then
+ frame = getColorControl(t, parent)
+ elseif v_type == 'choice' then
+ frame = getChoiceControl(t, false, parent)
+ elseif v_type == 'multichoice' then
+ frame = getChoiceControl(t, true, parent)
+ elseif v_type == 'string' then
+ frame = getStringControl(t, parent)
+ elseif v_type == 'keybinding' then
+ frame = getKeybindingControl(t, parent)
+ elseif v_type == 'group' then
+ local v_groupType = getConfigField(t, 'groupType', true, "normal", "string")
+ if v_groupType == "inline" then
+ frame = getInlineGroupControl(t, parent)
+ inlineGroup = true
+ end
+ elseif v_type == 'header' then
+ -- HACK
+ -- pass
+ else
+ local _, ret = pcall(error, ("Config error: type %s is not valid for path `%s'"):format(toliteral(v_type), getPathString(t)))
+ geterrorhandler()(ret)
+ end
+ if frame then
+ getLabel(t, frame)
+ if inlineGroup then
+ populateMainPane(t, frame)
+ end
+ local disabled = getConfigField(t, 'disabled', false, true)
+ if disabled then
+ frame:Disable()
+ end
+ end
+ end
+ t = del(t)
+ end
+
+ if extraArgs then
+ args = del(args)
+ end
+
+ sortMainPaneSections(parent)
+
+ parent:Reposition()
+ end
+
+ -- reposition the controls in the main pane
+ function mainPane_Reposition(mainPane)
+ local scrollChild = mainPane.scrollChild
+ local scrollFrame = mainPane.scrollFrame
+ local controls = mainPane.controls
+ local maxLabelWidth = 0
+ for i, v in ipairs(controls) do
+ local label = v.label
+ label.text:SetWidth(0)
+ label:ClearAllPoints()
+ local label_width = label.text:GetWidth()
+ if label.icon:IsShown() then
+ label_width = label_width + label.icon:GetWidth() + 1
+ end
+ if label_width > maxLabelWidth then
+ maxLabelWidth = label_width
+ end
+ end
+ local last
+ local yOffset = 0
+ for i,v in ipairs(controls) do
+ local label = v.label
+ label:SetWidth(maxLabelWidth)
+ label:SetHeight(math_min(24, v:GetHeight()))
+ label:SetPoint("LEFT", scrollFrame, "LEFT")
+ v:SetPoint("LEFT", label, "RIGHT", 8, 0)
+ v:SetPoint("RIGHT", scrollFrame, "RIGHT")
+ v:SetPoint("TOP", label, "TOP")
+
+ if not last then
+ label:SetPoint("TOP", scrollChild, "TOP", 0, yOffset)
+ else
+ label:SetPoint("TOP", last, "BOTTOM", 0, yOffset)
+ end
+
+ last = v
+ yOffset = -3
+ end
+ end
+end
+
+function RockConfig:OnUnembed(object)
+ data[object] = nil
+end
+
+local tmp
+
+local usingFuBarPlugin = false
+
+RockConfig.rockOptions = {
+ type = 'group',
+ name = ADDON_PREFERENCES,
+ desc = ADDON_PREFERENCES,
+ icon = [[Interface\Icons\INV_Misc_Gear_06]],
+ args = {
+ minimapButton = {
+ type = 'boolean',
+ name = SHOW_MINIMAP_ICON,
+ desc = SHOW_MINIMAP_ICON_DESC,
+ get = function()
+ return RockConfig.minimapButton:IsShown()
+ end,
+ set = function(value)
+ if value then
+ RockConfig.minimapButton:Show()
+ else
+ RockConfig.minimapButton:Hide()
+ end
+ end,
+ hidden = function()
+ return usingFuBarPlugin
+ end
+ },
+ scale = {
+ type = 'number',
+ name = SCALE,
+ desc = SCALE_DESC,
+ get = function()
+ return RockConfig.scale
+ end,
+ set = function(value)
+ RockConfig.scale = value
+ if not tmp then
+ tmp = CreateFrame("Frame")
+ tmp:SetScript("OnUpdate", function(this)
+ if base and base:IsShown() then
+ if UIParent:IsShown() then
+ base:SetScale(RockConfig.scale)
+ else
+ base:SetScale(RockConfig.scale * UIParent:GetEffectiveScale())
+ end
+ end
+ this:Hide()
+ end)
+ end
+ tmp:Show()
+ end,
+ min = 0.5,
+ max = 2,
+ isPercent = true,
+ step = 0.01,
+ bigStep = 0.05,
+ },
+ minAlpha = {
+ type = 'number',
+ name = FADEOUT_TRANSPARENCY,
+ desc = FADEOUT_TRANSPARENCY_DESC,
+ get = function()
+ return RockConfig.minAlpha or 0.25
+ end,
+ set = function(value)
+ RockConfig.minAlpha = value
+ end,
+ min = 0,
+ max = function()
+ return RockConfig.maxAlpha or 1
+ end,
+ isPercent = true,
+ step = 0.01,
+ bigStep = 0.05,
+ stepBasis = 0,
+ },
+ maxAlpha = {
+ type = 'number',
+ name = FADEIN_TRANSPARENCY,
+ desc = FADEIN_TRANSPARENCY_DESC,
+ get = function()
+ return RockConfig.maxAlpha or 1
+ end,
+ set = function(value)
+ RockConfig.maxAlpha = value
+ end,
+ min = function()
+ return math.max(RockConfig.minAlpha or 0.25, 0.25)
+ end,
+ max = 1,
+ isPercent = true,
+ step = 0.01,
+ bigStep = 0.05,
+ stepBasis = 0,
+ },
+ hideInCombat = {
+ type = 'boolean',
+ name = HIDE_IN_COMBAT,
+ desc = HIDE_IN_COMBAT_DESC,
+ get = function()
+ return RockConfig.hideInCombat
+ end,
+ set = function(value)
+ RockConfig.hideInCombat = value
+ if InCombatLockdown() then
+ base:Hide()
+ end
+ end,
+ }
+ },
+}
+if oldLib and oldLib.rockOptions then
+ for k,v in pairs(oldLib.rockOptions) do
+ if not RockConfig.rockOptions[k] then
+ RockConfig.rockOptions[k] = v
+ end
+ end
+end
+RockConfig:SetConfigTable(RockConfig.rockOptions)
+
+if oldLib then
+ RockConfig.x = oldLib.x or 0
+ RockConfig.y = oldLib.y or 0
+ RockConfig.width = oldLib.width or GetScreenWidth()*3/5
+ RockConfig.height = oldLib.height or GetScreenHeight()*3/5
+ RockConfig.scale = oldLib.scale or 1
+ RockConfig.minAlpha = oldLib.minAlpha or 0.25
+ RockConfig.maxAlpha = oldLib.maxAlpha or 1
+ for i = 1, 9 do
+ RockConfig["sv" .. i] = oldLib["sv" .. i]
+ end
+end
+
+_G.hash_SlashCmdList["ROCK"] = nil
+_G.SlashCmdList["ROCK"] = function()
+ RockConfig:OpenConfigMenu()
+end
+_G["SLASH_ROCK1"] = "/rock"
+_G["SLASH_ROCK2"] = "/Rock"
+_G["SLASH_ROCK3"] = "/rockconfig"
+_G["SLASH_ROCK4"] = "/RockConfig"
+
+
+local variablesLoaded = false
+local function loadFuBarPlugin()
+ if not variablesLoaded then
+ return
+ end
+ loadFuBarPlugin = nil
+ local FuBarPlugin = Rock("LibFuBarPlugin-3.0")
+ FuBarPlugin:Embed(RockConfig)
+ RockConfig:SetFuBarOption('iconPath', [[Interface\Icons\INV_Misc_Gear_06]])
+ RockConfig:SetFuBarOption('hasNoText', true)
+ RockConfig:SetFuBarOption('defaultPosition', "MINIMAP")
+ RockConfig:SetFuBarOption('hideWithoutStandby', true)
+ local minimapButton = RockConfig.minimapButton
+ local shown = minimapButton:IsShown()
+ minimapButton:Hide()
+ if minimapButton.framePosition then
+ RockConfig.minimapPosition = minimapButton.framePosition
+ else
+ RockConfig.minimapPosition = 157
+ RockConfig.minimapPositionWild = true
+ RockConfig.minimapPositionX = minimapButton.framePositionX
+ RockConfig.minimapPositionY = minimapButton.framePositionY
+ end
+ usingFuBarPlugin = true
+ RockConfig.title = ADDON_PREFERENCES
+ RockConfig.rockOptions.args.fubar = {
+ name = FUBAR_OPTIONS,
+ desc = FUBAR_OPTIONS,
+ type = 'group',
+ groupType = 'inline',
+ args = newDict(FuBarPlugin:GetEmbedRockConfigOptions(RockConfig)),
+ }
+ function RockConfig:OnUpdateFuBarTooltip()
+ GameTooltip:SetText(ADDON_PREFERENCES)
+ end
+ function RockConfig:OnFuBarClick()
+ self:OpenConfigMenu()
+ end
+ if FuBarPlugin.OnEmbedInitialize then
+ FuBarPlugin:OnEmbedInitialize(RockConfig)
+ end
+ if FuBarPlugin.OnEmbedEnable then
+ FuBarPlugin:OnEmbedEnable(RockConfig, true)
+ end
+ if shown then
+ --RockConfig:Show() -- HACK
+ end
+end
+
+do
+ -- minimap button
+ local frame = CreateFrame("Button", MAJOR_VERSION .. "_MinimapButton", Minimap)
+ RockConfig.minimapButton = frame
+ if oldLib and oldLib.minimapButton then
+ oldLib.minimapButton:UnregisterAllEvents()
+ oldLib.minimapButton:Hide()
+ end
+ frame:Hide() -- HACK
+ frame:SetClampedToScreen(true)
+ frame:SetWidth(31)
+ frame:SetHeight(31)
+ frame:SetFrameStrata("BACKGROUND")
+ frame:SetFrameLevel(4)
+ frame:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight")
+ local icon = frame:CreateTexture(frame:GetName() .. "Icon", "BACKGROUND")
+ frame.icon = icon
+ icon:SetTexture([[Interface\Icons\INV_Misc_Gear_06]])
+ icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ icon:SetWidth(20)
+ icon:SetHeight(20)
+ icon:SetPoint("TOPLEFT", frame, "TOPLEFT", 7, -5)
+ local overlay = frame:CreateTexture(frame:GetName() .. "Overlay","OVERLAY")
+ overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder")
+ overlay:SetWidth(53)
+ overlay:SetHeight(53)
+ overlay:SetPoint("TOPLEFT", frame, "TOPLEFT")
+ frame:EnableMouse(true)
+ frame:RegisterForClicks("LeftButtonUp", "RightButtonUp")
+
+ frame:SetScript("OnEnter", function(this)
+ local anchor
+ if this:GetTop() > GetScreenHeight() / 2 then
+ local x = this:GetCenter()
+ if x < GetScreenWidth() / 2 then
+ anchor = "ANCHOR_BOTTOMRIGHT"
+ else
+ anchor = "ANCHOR_BOTTOMLEFT"
+ end
+ else
+ local x = this:GetCenter()
+ if x < GetScreenWidth() / 2 then
+ anchor = "ANCHOR_TOPLEFT"
+ else
+ anchor = "ANCHOR_TOPRIGHT"
+ end
+ end
+ GameTooltip:SetOwner(this, anchor)
+ GameTooltip:SetText(ADDON_PREFERENCES)
+ end)
+ frame:SetScript("OnLeave", function(this)
+ GameTooltip:Hide()
+ end)
+
+ frame:SetScript("OnClick", function(this)
+ if this.dragged then
+ return
+ end
+ if base and base:IsShown() then
+ base:Hide()
+ else
+ RockConfig:OpenConfigMenu()
+ end
+ end)
+
+ frame:SetScript("OnMouseDown", function(this, button)
+ if button ~= "LeftButton" then
+ return
+ end
+ this.dragged = nil
+
+ this.icon:SetTexCoord(0.14, 0.86, 0.14, 0.86)
+ end)
+ frame:SetScript("OnMouseUp", function(this, button)
+ if button ~= "LeftButton" then
+ return
+ end
+ this.icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ end)
+ frame:RegisterForDrag("LeftButton")
+ local frame_OnUpdate
+ frame:SetScript("OnDragStart", function(this)
+ this.dragged = true
+ if GameTooltip:IsOwned(this) then
+ GameTooltip:Hide()
+ end
+ this:LockHighlight()
+ this:SetScript("OnUpdate", frame_OnUpdate)
+ this.icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ end)
+ frame:SetScript("OnDragStop", function(this)
+ this:SetScript("OnUpdate", nil)
+ this:UnlockHighlight()
+ end)
+
+ frame.framePosition = 157
+ if oldLib and oldLib.minimapButton then
+ if oldLib.minimapButton:IsShown() then
+ frame:Show()
+ else
+ frame:Hide()
+ end
+ frame.framePosition = oldLib.minimapButton.framePosition
+ frame.framePositionX = oldLib.minimapButton.framePositionX
+ frame.framePositionY = oldLib.minimapButton.framePositionY
+ end
+ local function Readjust(this)
+ if this.framePosition then
+ local angle = math.rad(this.framePosition)
+ local x,y
+ local minimapShape = GetMinimapShape and GetMinimapShape() or "ROUND"
+ local cos = math.cos(angle)
+ local sin = math.sin(angle)
+
+ local round = true
+ if minimapShape == "ROUND" then
+ -- do nothing
+ elseif minimapShape == "SQUARE" then
+ round = false
+ elseif minimapShape == "CORNER-TOPRIGHT" then
+ if cos < 0 or sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-TOPLEFT" then
+ if cos > 0 or sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-BOTTOMRIGHT" then
+ if cos < 0 or sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-BOTTOMLEFT" then
+ if cos > 0 or sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-LEFT" then
+ if cos > 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-RIGHT" then
+ if cos < 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-TOP" then
+ if sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-BOTTOM" then
+ if sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-TOPRIGHT" then
+ if cos < 0 and sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-TOPLEFT" then
+ if cos > 0 and sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-BOTTOMRIGHT" then
+ if cos < 0 and sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-BOTTOMLEFT" then
+ if cos > 0 and sin < 0 then
+ round = false
+ end
+ end
+
+ if round then
+ x = cos * 80
+ y = sin * 80
+ else
+ x = 110 * cos
+ y = 110 * sin
+ x = math.max(-82, math.min(x, 84))
+ y = math.max(-86, math.min(y, 82))
+ end
+ frame:SetPoint("CENTER", Minimap, "CENTER", x, y)
+ else
+ frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", this.framePositionX, this.framePositionY)
+ end
+ end
+
+ function frame_OnUpdate(this)
+ if not IsAltKeyDown() then
+ local mx, my = Minimap:GetCenter()
+ local px, py = GetCursorPosition()
+ local scale = this:GetEffectiveScale()
+ px, py = px / scale, py / scale
+ local position = math.floor(math.deg(math.atan2(py - my, px - mx)) + 0.5)
+ if position <= 0 then
+ position = position + 360
+ elseif position > 360 then
+ position = position - 360
+ end
+ this.framePosition = position
+ this.framePositionX, this.framePositionY = nil, nil
+ else
+ local px, py = GetCursorPosition()
+ local scale = this:GetEffectiveScale()
+ px, py = math.floor(px/scale + 0.5), math.floor(py/scale + 0.5)
+ this.framePosition = nil
+ this.framePositionX, this.framePositionY = px, py
+ end
+
+ Readjust(this)
+ end
+
+ frame:RegisterEvent("PLAYER_LOGOUT")
+ frame:RegisterEvent("VARIABLES_LOADED")
+ frame:SetScript("OnEvent", function(this, event, ...)
+ if event == "VARIABLES_LOADED" then
+ variablesLoaded = true
+ local var = TALENT_FRAME_WAS_SHOWN
+ if var then
+ TALENT_FRAME_WAS_SHOWN = 1
+ end
+ if type(var) == "string" then
+ local sv = newList()
+ local hidden, framePositionX, framePositionY, x, y, width, height, scale, minAlpha, maxAlpha, hideInCombat
+ hidden, framePositionX, framePositionY, x, y, width, height, scale, minAlpha, maxAlpha, hideInCombat, sv[1], sv[2], sv[3], sv[4], sv[5], sv[6], sv[7], sv[8], sv[9] = var:match("^1;(H?)(%-?%d+),(%-?%d+);(%-?%d+),(%-?%d+),(%-?%d+),(%-?%d+),(%-?%d+);(%d+),(%d+);([01]);(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*)$")
+ if not hidden then
+ hidden, framePositionX, x, y, width, height, scale, minAlpha, maxAlpha, hideInCombat, sv[1], sv[2], sv[3], sv[4], sv[5], sv[6], sv[7], sv[8], sv[9] = var:match("^1;(H?)(%-?%d+);(%-?%d+),(%-?%d+),(%-?%d+),(%-?%d+),(%-?%d+);(%d+),(%d+);([01]);(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*)$")
+ if not hidden then
+ hideInCombat = "0"
+ hidden, framePositionX, framePositionY, x, y, width, height, scale, minAlpha, maxAlpha, sv[1], sv[2], sv[3], sv[4], sv[5], sv[6], sv[7], sv[8], sv[9] = var:match("^1;(H?)(%-?%d+),(%-?%d+);(%-?%d+),(%-?%d+),(%-?%d+),(%-?%d+),(%-?%d+);(%d+),(%d+);(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*)$")
+ if not hidden then
+ hidden, framePositionX, x, y, width, height, scale, minAlpha, maxAlpha, sv[1], sv[2], sv[3], sv[4], sv[5], sv[6], sv[7], sv[8], sv[9] = var:match("^1;(H?)(%-?%d+);(%-?%d+),(%-?%d+),(%-?%d+),(%-?%d+),(%-?%d+);(%d+),(%d+);(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*)$")
+ end
+ end
+ end
+ hideInCombat = hideInCombat == "1"
+ if framePositionX then
+ framePositionX, framePositionY, x, y, width, height, scale, minAlpha, maxAlpha = tonumber(framePositionX), tonumber(framePositionY), tonumber(x), tonumber(y), tonumber(width), tonumber(height), tonumber(scale), tonumber(minAlpha), tonumber(maxAlpha)
+ if scale then
+ scale = scale / 100
+ if scale < 0.5 or scale > 2 then
+ scale = 1
+ end
+ end
+ if minAlpha then
+ minAlpha = minAlpha / 100
+ if minAlpha < 0 or minAlpha > 1 then
+ minAlpha = 0.25
+ end
+ end
+ if maxAlpha then
+ maxAlpha = maxAlpha / 100
+ if maxAlpha < 0.25 or maxAlpha < minAlpha or maxAlpha > 1 then
+ maxAlpha = 1
+ end
+ end
+ if bravo then
+ this.framePosition = nil
+ this.framePositionX, this.framePositionY = framePositionX, framePositionY
+ else
+ this.framePosition = framePositionX
+ this.framePositionX, this.framePositionY = nil
+ end
+ if hidden == "H" then
+ this:Hide()
+ end
+ RockConfig.x = x
+ RockConfig.y = y
+ RockConfig.width = width
+ RockConfig.height = height
+ RockConfig.scale = scale
+ RockConfig.minAlpha = minAlpha
+ RockConfig.maxAlpha = maxAlpha
+ RockConfig.hideInCombat = hideInCombat
+ end
+ for i,v in ipairs(sv) do
+ if v == "" then
+ v = nil
+ elseif tonumber(v) then
+ v = tonumber(v)
+ end
+ RockConfig["sv" .. i] = v
+ end
+ sv = del(sv)
+ end
+
+ if Rock:HasLibrary("LibFuBarPlugin-3.0") and loadFuBarPlugin then
+ loadFuBarPlugin()
+ else
+ Readjust(this)
+ end
+ elseif event == "PLAYER_LOGOUT" then
+ local x = RockConfig.x or 0
+ local y = RockConfig.y or 0
+ local width = RockConfig.width or GetScreenWidth()*3/5
+ local height = RockConfig.height or GetScreenHeight()*3/5
+ local scale = RockConfig.scale or 1
+ local minAlpha = RockConfig.minAlpha or 0.25
+ local maxAlpha = RockConfig.maxAlpha or 1
+ local framePosition, framePositionX, framePositionY
+ local hideInCombat = RockConfig.hideInCombat and "1" or "0"
+ if usingFuBarPlugin then
+ if not RockConfig.minimapPositionWild then
+ framePosition = RockConfig.minimapPosition
+ else
+ framePositionX, framePositionY = RockConfig.minimapPositionX, RockConfig.minimapPositionY
+ end
+ else
+ if this.framePosition then
+ framePosition = this.framePosition
+ else
+ framePositionX, framePositionY = this.framePositionX, this.framePositionY
+ end
+ end
+ local hidden
+ if usingFuBarPlugin then
+ local FuBarPlugin = Rock("LibFuBarPlugin-3.0")
+ if FuBarPlugin.pluginToFrame and FuBarPlugin.pluginToFrame[RockConfig] and FuBarPlugin.pluginToMinimapFrame then
+ hidden = not FuBarPlugin.pluginToFrame[RockConfig]:IsShown() and (not FuBarPlugin.pluginToMinimapFrame[RockConfig] or not FuBarPlugin.pluginToMinimapFrame[RockConfig]:IsShown())
+ end
+ else
+ hidden = not this:IsShown()
+ end
+ if framePosition then
+ TALENT_FRAME_WAS_SHOWN = ("1;%s%.0f;%.0f,%.0f,%.0f,%.0f,%.0f;%.0f,%.0f;%s;%s,%s,%s,%s,%s,%s,%s,%s,%s"):format(hidden and "H" or "", framePosition, x, y, width, height, scale*100, minAlpha*100, maxAlpha*100, hideInCombat, tostring(RockConfig.sv1 or ""), tostring(RockConfig.sv2 or ""), tostring(RockConfig.sv3 or ""), tostring(RockConfig.sv4 or ""), tostring(RockConfig.sv5 or ""), tostring(RockConfig.sv6 or ""), tostring(RockConfig.sv7 or ""), tostring(RockConfig.sv8 or ""), tostring(RockConfig.sv9 or ""))
+ else
+ TALENT_FRAME_WAS_SHOWN = ("1;%s%.0f,%.0f;%.0f,%.0f,%.0f,%.0f,%.0f;%.0f,%.0f;%s;%s,%s,%s,%s,%s,%s,%s,%s,%s"):format(hidden and "H" or "", framePositionX, framePositionY, x, y, width, height, scale*100, minAlpha*100, maxAlpha*100, hideInCombat, tostring(RockConfig.sv1 or ""), tostring(RockConfig.sv2 or ""), tostring(RockConfig.sv3 or ""), tostring(RockConfig.sv4 or ""), tostring(RockConfig.sv5 or ""), tostring(RockConfig.sv6 or ""), tostring(RockConfig.sv7 or ""), tostring(RockConfig.sv8 or ""), tostring(RockConfig.sv9 or ""))
+ end
+ end
+ end)
+
+ Readjust(frame)
+end
+
+if ScriptErrors then
+ ScriptErrors:SetFrameStrata("FULLSCREEN_DIALOG")
+ ScriptErrorsButton:SetFrameStrata("FULLSCREEN_DIALOG")
+end
+
+RockConfig:SetExportedMethods("SetConfigTable", "OpenConfigMenu", "SetConfigSlashCommand")
+
+function RockConfig:OnLibraryLoad(major, instance)
+ if major == "LibFuBarPlugin-3.0" then
+ if loadFuBarPlugin then
+ loadFuBarPlugin()
+ end
+ end
+end
+
+Rock:FinalizeLibrary(MAJOR_VERSION)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- simple registration
+ local t = { name = MAJOR_VERSION .. "_UnitTest" }
+ RockConfig:Embed(t)
+ assert(not getConfigTable({t}))
+ assert(not hasConfigTable({t}))
+ local value = false
+
+ local val = true
+ function t:OtherGet()
+ assert(t == self)
+ return val
+ end
+ function t:OtherSet(value)
+ assert(t == self)
+ val = value
+ end
+ function t:AntiSet(value)
+ assert(t == self)
+ val = not value
+ end
+
+ t:SetConfigTable {
+ type = 'group',
+ name = MAJOR_VERSION .. "_UnitTest",
+ desc = MAJOR_VERSION .. "_UnitTest",
+ args = {
+ {
+ type = 'boolean',
+ name = "Name",
+ desc = "Desc",
+ get = function(alpha, bravo)
+ assert(alpha == "Alpha")
+ assert(bravo == "Bravo")
+ return value
+ end,
+ set = function(alpha, bravo, val)
+ assert(alpha == "Alpha")
+ assert(bravo == "Bravo")
+ value = val
+ end,
+ passValue = "Alpha",
+ passValue2 = "Bravo",
+ passValue4 = "Delta", -- should do nothing
+ },
+ {
+ type = 'boolean',
+ name = "Other Name",
+ desc = "Other Desc",
+ get = "OtherGet",
+ set = "OtherSet",
+ },
+ {
+ type = 'boolean',
+ name = "Anti Name",
+ desc = "Anti Desc",
+ get = "~OtherGet",
+ set = "AntiSet",
+ },
+ }
+ }
+
+ assert(getConfigTable({t}))
+ assert(hasConfigTable({t}))
+ assert(not getConfigTable({t, 'blah'}))
+ assert(not hasConfigTable({t, 'blah'}))
+
+ -- test passValues
+ local configTable = getConfigTable({t, 1})
+ local tmp = {getPassValues({t, 1})}
+ assert(#tmp == 2)
+ assert(tmp[1] == "Alpha")
+ assert(tmp[2] == "Bravo")
+
+ assert(getPathString({t, 1}) == MAJOR_VERSION .. "_UnitTest->Name")
+
+ assert(getConfigField({t}, 'name', true, nil, "string") == MAJOR_VERSION .. "_UnitTest")
+ assert(getConfigField({t}, 'desc', true, nil, "string") == MAJOR_VERSION .. "_UnitTest")
+ assert(getConfigField({t, 1}, 'name', true, nil, "string") == "Name")
+ assert(getConfigField({t, 1}, 'desc', true, nil, "string") == "Desc")
+
+ -- test functions
+ assert(getConfigField({t, 1}, 'get', false, nil, "boolean") == false)
+ assert(select(2, callConfigField({t, 1}, 'get')) == false)
+ callConfigField({t, 1}, 'set', {true})
+ assert(getConfigField({t, 1}, 'get', false, nil, "boolean") == true)
+ assert(select(2, callConfigField({t, 1}, 'get')) == true)
+ callConfigField({t, 1}, 'set', {false})
+ assert(getConfigField({t, 1}, 'get', false, nil, "boolean") == false)
+ assert(select(2, callConfigField({t, 1}, 'get')) == false)
+
+ -- test methods
+ assert(getConfigField({t, 2}, 'get', false, nil, "boolean") == true)
+ assert(select(2, callConfigField({t, 2}, 'get')) == true)
+ callConfigField({t, 2}, 'set', {false})
+ assert(getConfigField({t, 2}, 'get', false, nil, "boolean") == false)
+ assert(select(2, callConfigField({t, 2}, 'get')) == false)
+ callConfigField({t, 2}, 'set', {true})
+ assert(getConfigField({t, 2}, 'get', false, nil, "boolean") == true)
+ assert(select(2, callConfigField({t, 2}, 'get')) == true)
+
+ -- test negated methods
+ assert(getConfigField({t, 3}, 'get', false, nil, "boolean") == false)
+ assert(select(2, callConfigField({t, 3}, 'get')) == false)
+ callConfigField({t, 3}, 'set', {true})
+ assert(getConfigField({t, 3}, 'get', false, nil, "boolean") == true)
+ assert(select(2, callConfigField({t, 3}, 'get')) == true)
+ callConfigField({t, 3}, 'set', {false})
+ assert(getConfigField({t, 3}, 'get', false, nil, "boolean") == false)
+ assert(select(2, callConfigField({t, 3}, 'get')) == false)
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ local t = { name = MAJOR_VERSION .. "_UnitTest" }
+ RockConfig:Embed(t)
+ assert(not getConfigTable({t}))
+ assert(not hasConfigTable({t}))
+ local value = false
+ t:SetConfigTable {
+ type = 'group',
+ name = MAJOR_VERSION .. "_UnitTest",
+ desc = MAJOR_VERSION .. "_UnitTest",
+ child_type = 'group',
+ args = {
+ alpha = { name = 'alpha', desc = 'alpha', args = { pants = { name = 'pants', desc = 'pants', type = 'boolean', get = function() end, set = function() end } }},
+ bravo = { name = 'bravo', desc = 'bravo', type = 'boolean', args = { pants = {} }, get = function() end, set = function() end }
+ }
+ }
+ assert(hasConfigTable({t}))
+ assert(hasConfigTable({t, 'alpha'}))
+ assert(hasConfigTable({t, 'bravo'}))
+ assert(hasConfigTable({t, 'alpha', 'pants'}))
+ assert(not hasConfigTable({t, 'bravo', 'pants'}))
+end)
diff --git a/FuBar/libs/LibRockConfig-1.0/LibRockConfig-1.0.toc b/FuBar/libs/LibRockConfig-1.0/LibRockConfig-1.0.toc
new file mode 100644
index 0000000..22988bb
--- /dev/null
+++ b/FuBar/libs/LibRockConfig-1.0/LibRockConfig-1.0.toc
@@ -0,0 +1,18 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r401
+## X-Curse-Project-Name: LibRockConfig-1.0
+## X-Curse-Project-ID: librockconfig-1-0
+## X-Curse-Repository-ID: wow/librockconfig-1-0/mainline
+
+## Title: Lib: RockConfig-1.0
+## Notes: Configuration library
+## Notes-frFR: Librairie de configuration
+## Author: ckknight
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-Donate: Paypal:ckknight AT gmail DOT com
+## X-eMail: ckknight AT gmail DOT com
+## X-License: LGPL v2.1
+## LoadOnDemand: 1
+
+lib.xml
diff --git a/FuBar/libs/LibRockConfig-1.0/lib.xml b/FuBar/libs/LibRockConfig-1.0/lib.xml
new file mode 100644
index 0000000..fba1296
--- /dev/null
+++ b/FuBar/libs/LibRockConfig-1.0/lib.xml
@@ -0,0 +1,4 @@
+
+
+
\ No newline at end of file
diff --git a/FuBar/libs/LibRockDB-1.0/LibRockDB-1.0.lua b/FuBar/libs/LibRockDB-1.0/LibRockDB-1.0.lua
new file mode 100644
index 0000000..18f0bca
--- /dev/null
+++ b/FuBar/libs/LibRockDB-1.0/LibRockDB-1.0.lua
@@ -0,0 +1,2014 @@
+--[[
+Name: LibRockDB-1.0
+Revision: $Rev: 240 $
+Developed by: ckknight (ckknight@gmail.com)
+Website: http://www.wowace.com/
+Description: Library to allow for fast, clean, and featureful saved variable access.
+Dependencies: LibRock-1.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "LibRockDB-1.0"
+local MINOR_VERSION = tonumber(("$Revision: 240 $"):match("(%d+)")) + 90000
+
+if not Rock then error(MAJOR_VERSION .. " requires LibRock-1.0") end
+
+local RockDB, oldLib = Rock:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
+if not RockDB then
+ return
+end
+
+-- #AUTODOC_NAMESPACE RockDB
+
+local _G = _G
+local Rock = _G.Rock
+local pairs = _G.pairs
+local next = _G.next
+local geterrorhandler = _G.geterrorhandler
+local pcall = _G.pcall
+local rawset = _G.rawset
+local error = _G.error
+local type = _G.type
+local tostring = _G.tostring
+local rawget = _G.rawget
+local setmetatable = _G.setmetatable
+local GetAddOnInfo = _G.GetAddOnInfo
+local GetNumAddOns = _G.GetNumAddOns
+local debugstack = _G.debugstack
+local assert = _G.assert
+local select = _G.select
+local ipairs = _G.ipairs
+
+local L = setmetatable({}, {__index=function(self,key) self[key] = key; return key end})
+
+if GetLocale() == "zhTW" then
+ L["Character: "] = "角色: "
+ L["%s of %s"] = "%s - %s"
+ L["Realm: "] = "伺服器: "
+ L["Class: "] = "職業: "
+ L["Default"] = "預設"
+ L["Alternative"] = "替代"
+ L["Profile"] = "記錄檔"
+ L["Set profile for this addon."] = "設定插件的記錄檔。"
+ L["Choose"] = "選擇"
+ L["Choose a profile."] = "選擇記錄檔。"
+ L["Copy from"] = "複製"
+ L["Copy settings from another profile."] = "由其他記錄檔度複製設定。"
+ L["Other"] = "其他"
+ L["Choose another profile."] = "選擇另一個記錄檔。"
+ L[""] = "<記錄檔名稱>"
+ L["Remove"] = "刪除"
+ L["Removes a profile. Note that no check is made whether this profile is in use by other characters or not."] = "刪除記錄檔。注意,有可能別的角色也使用這個記錄檔。"
+ L["Reset profile"] = "重設記錄檔"
+ L["Clear all settings of the current profile."] = "清除目前的記錄檔上的所有設定。"
+ L["Reset all settings."] = "重設所有設定。"
+ L["Reset"] = "重設"
+elseif GetLocale() == "koKR" then
+ L["Character: "] = "캐릭터: "
+ L["%s of %s"] = "%s - %s"
+ L["Realm: "] = "서버: "
+ L["Class: "] = "직업: "
+ L["Default"] = "기본값"
+ L["Alternative"] = "대체"
+ L["Profile"] = "프로필"
+ L["Set profile for this addon."] = "이 애드온을 위한 프로필을 설정합니다."
+ L["Choose"] = "선택"
+ L["Choose a profile."] = "프로필을 선택합니다."
+ L["Copy from"] = "복사"
+ L["Copy settings from another profile."] = "세팅된 다른 프로필을 복사합니다."
+ L["Other"] = "기타"
+ L["Choose another profile."] = "다른 프로필을 선택합니다."
+ L[""] = "<프로필 이름>"
+ L["Remove"] = "삭제"
+ L["Removes a profile. Note that no check is made whether this profile is in use by other characters or not."] = "프로필을 삭제합니다."
+ L["Reset profile"] = "프로필 초기화"
+ L["Clear all settings of the current profile."] = "모든 세팅에서 현재 프로필을 제거합니다."
+ L["Reset all settings."] = "모든 세팅 초기화"
+ L["Reset"] = "초기화"
+elseif GetLocale() == "frFR" then
+ L["Character: "] = "Personnage : "
+ L["%s of %s"] = "%s de %s"
+ L["Realm: "] = "Royaume : "
+ L["Class: "] = "Classe : "
+ L["Default"] = "Défaut"
+ L["Alternative"] = "Alternative"
+ L["Profile"] = "Profil"
+ L["Set profile for this addon."] = "Détermine le profil à utiliser pour cet addon."
+ L["Choose"] = "Choisir"
+ L["Choose a profile."] = "Permet de choisir un profil."
+ L["Copy from"] = "Copier à partir de"
+ L["Copy settings from another profile."] = "Copie les paramètres d'un autre profil."
+ L["Other"] = "Autre"
+ L["Choose another profile."] = "Permet de choisir un autre profil."
+ L[""] = ""
+ L["Remove"] = "Enlever"
+ L["Removes a profile. Note that no check is made whether this profile is in use by other characters or not."] = "Enlève un profil. Notez qu'aucune vérification n'est faites pour savoir si ce profil est utilisé par un autre personnage ou pas."
+ L["Reset profile"] = "Réinitialiser le profil"
+ L["Clear all settings of the current profile."] = "Efface tous les paramètres du profil actuel."
+ L["Reset all settings."] = "Réinitialiser tous les paramètres"
+ L["Reset"] = "Réinitialiser"
+elseif GetLocale() == "zhCN" then
+ L["Character: "] = "角色: "
+ L["%s of %s"] = "%s - %s"
+ L["Realm: "] = "服务器: "
+ L["Class: "] = "职业: "
+ L["Default"] = "默认值"
+ L["Alternative"] = "替换"
+ L["Profile"] = "个人配置"
+ L["Set profile for this addon."] = "设置插件的个人配置。"
+ L["Choose"] = "选择"
+ L["Choose a profile."] = "选择配置文件。"
+ L["Copy from"] = "复制"
+ L["Copy settings from another profile."] = "从其他配置文件复制设置。"
+ L["Other"] = "其他"
+ L["Choose another profile."] = "选择其他配置文件。"
+ L[""] = "<个人配置文件名>"
+ L["Remove"] = "删除"
+ L["Removes a profile. Note that no check is made whether this profile is in use by other characters or not."] = "删除此配置。注意:有可能其他角色使用了。"
+ L["Reset profile"] = "重置个人配置"
+ L["Clear all settings of the current profile."] = "清除当前个人配置上所有设置。"
+ L["Reset all settings."] = "重置全部设置。"
+ L["Reset"] = "重置"
+end
+
+RockDB.frame = oldLib and oldLib.frame or _G.CreateFrame("Frame")
+local frame = RockDB.frame
+frame:UnregisterAllEvents()
+-- dictionary of object to { init = true/false, dbName = "GlobalDB", charName = "CharDB", db = _G[dbName], charDB = _G[charName], defaults = { ["dataType"] = { --[[ stuff ]] } }, namespaces = { ["namespace"] = dbTable }, namespaceDefaults = { ["namespace"] = { ["dataType"] = { --[[ stuff]] } } } }
+RockDB.data = setmetatable(oldLib and oldLib.data or {}, {__mode='k'})
+local data = RockDB.data
+
+local newList, del, newDict, unpackDictAndDel = Rock:GetRecyclingFunctions(MAJOR_VERSION, "newList", "del", "newDict", "unpackDictAndDel")
+
+local precondition, postcondition, argCheck = Rock:GetContractFunctions(MAJOR_VERSION, "precondition", "postcondition", "argCheck")
+
+local _,race = _G.UnitRace("player")
+local faction
+if race == "Orc" or race == "Scourge" or race == "Troll" or race == "Tauren" or race == "BloodElf" then
+ faction = _G.FACTION_HORDE
+else
+ faction = _G.FACTION_ALLIANCE
+end
+local server = _G.GetRealmName():trim()
+local _,classID = _G.UnitClass("player")
+classID = classID:sub(1, 1) .. classID:sub(2):lower() -- Warrior instead of WARRIOR
+local charID = _G.UnitName("player") .. " - " .. server
+local realmID = server .. " - " .. faction
+
+local function figureCurrentAddon(pos)
+ local stack = debugstack(pos+1, 1, 0)
+ local folder = stack:match("[Oo%.][Nn%.][Ss%.]\\([^\\]+)\\")
+ if folder then
+ return folder
+ end
+
+ local partFolder = stack:match("...([^\\]+)\\")
+ if partFolder then
+ local partFolder_len = #partFolder
+ for i = 1, GetNumAddOns() do
+ local name = GetAddOnInfo(i)
+ if #name >= partFolder_len then
+ local partName = name:sub(-partFolder_len)
+ if partName == partFolder then
+ return name
+ end
+ end
+ end
+ end
+ return nil
+end
+
+local function caseInsensitiveLookup(t, key)
+ if not t then
+ return nil
+ end
+ local value = t[key]
+ if value ~= nil then
+ return key, value
+ end
+ local key_lower = key:lower()
+ for k,v in pairs(t) do
+ if type(k) == "string" and k:lower() == key then
+ return k, v
+ end
+ end
+ return nil, nil
+end
+
+local function fixKeyCasing(t, key)
+ local value = t[key]
+ if value ~= nil then
+ return
+ end
+ local key_lower = key:lower()
+ for k,v in pairs(t) do
+ if type(k) == "string" and k:lower() == key then
+ t[k] = nil
+ t[key] = v
+ return
+ end
+ end
+end
+
+local function cleanDefaults(t, defaults, blocker)
+ if defaults then
+ for k,v in pairs(t) do
+ if (not blocker or (blocker[k] == nil and blocker['*'] == nil and blocker['**'] == nil)) and (defaults[k] ~= nil or defaults['*'] ~= nil or defaults['**'] ~= nil) then
+ local u = defaults[k]
+ if u == nil then
+ u = defaults['*']
+ if u == nil then
+ u = defaults['**']
+ end
+ end
+ if v == u then
+ t[k] = nil
+ elseif type(v) == "table" and type(u) == "table" then
+ if cleanDefaults(v, u) then
+ t[k] = del(v)
+ else
+ local w = defaults['**']
+ if w ~= u then
+ if cleanDefaults(v, w, u) then
+ t[k] = del(v)
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ return t and next(t) == nil
+end
+
+local function inheritDefaults(t, defaults)
+ if not defaults then
+ return t
+ end
+ for k,v in pairs(defaults) do
+ if k == "*" or k == "**" then
+ local v = v
+ if type(v) == "table" then
+ local mt = newList()
+ function mt:__index(key)
+ if key == nil then
+ return nil
+ end
+ local value = newList()
+ self[key] = value
+ inheritDefaults(value, v)
+ return value
+ end
+ setmetatable(t, mt)
+ for key in pairs(t) do
+ if (defaults[key] == nil or key == k) and type(t[key]) == "table" then
+ inheritDefaults(t[key], v)
+ end
+ end
+ else
+ local mt = newList()
+ function mt:__index(key)
+ if key == nil then
+ return nil
+ end
+ self[key] = v
+ return v
+ end
+ setmetatable(t, mt)
+ end
+ else
+ if type(v) == "table" then
+ if type(rawget(t, k)) ~= "table" then
+ t[k] = newList()
+ end
+ inheritDefaults(t[k], v)
+ if type(defaults["**"] == "table") then
+ inheritDefaults(t[k], defaults["**"])
+ end
+ elseif rawget(t, k) == nil then
+ t[k] = v
+ end
+ end
+ end
+ return t
+end
+
+local db_mt = { __index = function(object_db, key)
+ local object = rawget(object_db, 'object')
+ local data_object = data[object]
+ if not data_object then
+ if key == "raw" then
+ return
+ end
+ error("Must call `SetDatabase' before accessing the db object", 2)
+ end
+ local db = data_object.db
+ if not db then
+ if key == "raw" then
+ return
+ end
+ error("Cannot access db object before ADDON_LOADED", 2)
+ end
+ if key == "char" then
+ local charDB = data_object.charDB
+ if charDB then
+ if type(charDB.global) ~= "table" then
+ charDB.global = newList()
+ end
+ rawset(object_db, 'char', charDB.global)
+ else
+ if type(db.chars) ~= "table" then
+ db.chars = newList()
+ end
+ if type(db.chars[charID]) ~= "table" then
+ db.chars[charID] = newList()
+ end
+ rawset(object_db, 'char', db.chars[charID])
+ end
+ if data_object.defaults and data_object.defaults.char then
+ inheritDefaults(object_db.char, data_object.defaults.char)
+ end
+ return object_db.char
+ elseif key == "account" then
+ if type(db.account) ~= "table" then
+ db.account = newList()
+ end
+ rawset(object_db, 'account', db.account)
+ if data_object.defaults and data_object.defaults.account then
+ inheritDefaults(object_db.account, data_object.defaults.account)
+ end
+ return object_db.account
+ elseif key == "realm" or key == "server" or key == "faction" or key == "class" or key == "profile" then
+ local key_plural, id
+ if key == "realm" then
+ key_plural, id = "realms", realmID
+ elseif key == "server" then
+ key_plural, id = "servers", server
+ elseif key == "faction" then
+ key_plural, id = "factions", faction
+ elseif key == "class" then
+ key_plural, id = "classes", classID
+ elseif key == "profile" then
+ key_plural = "profiles"
+ id = db.currentProfile and db.currentProfile[charID] or data_object.defaultProfile
+ if id == "char" then
+ id = "char/" .. charID
+ elseif id == "class" then
+ id = "class/" .. classID
+ elseif id == "realm" then
+ id = "realm/" .. realmID
+ end
+ if db[key_plural] then
+ fixKeyCasing(db[key_plural], id)
+ end
+ end
+ if type(db[key_plural]) ~= "table" then
+ db[key_plural] = newList()
+ end
+ if type(db[key_plural][id]) ~= "table" then
+ db[key_plural][id] = newList()
+ end
+ rawset(object_db, key, db[key_plural][id])
+ if data_object.defaults and data_object.defaults[key] then
+ inheritDefaults(object_db[key], data_object.defaults[key])
+ end
+ return object_db[key]
+ elseif key == "raw" or key == "namespaces" or key == "defaults" then
+ return nil
+ end
+ error(("Cannot access key %q in db table. You may want to use db.profile[%q]"):format(tostring(key), tostring(key)), 2)
+end, __newindex = function(object_db, key, value)
+ error(("Cannot access key %q in db table. You may want to use db.profile[%q]"):format(tostring(key), tostring(key)), 2)
+end }
+
+local namespace_db_mt = { __index = function(object_nsdb, key)
+ local object = rawget(object_nsdb, 'object')
+ if not object then
+ error("Must call `SetDatabase' before accessing the db object", 2)
+ end
+ local namespace = rawget(object_nsdb, 'namespace')
+ if not namespace then
+ error("Must call `SetDatabase' before accessing the db object", 2)
+ end
+ local data_object = data[object]
+ if not data_object then
+ error("Must call `SetDatabase' before accessing the db object", 2)
+ end
+ local db = data_object.db
+ if not db then
+ error("Cannot access db object before ADDON_LOADED", 2)
+ end
+ if key == "char" then
+ local charDB = data_object.charDB
+ if charDB then
+ if type(charDB.namespaces) ~= "table" then
+ charDB.namespaces = newList()
+ end
+ if type(charDB.namespaces[namespace]) ~= "table" then
+ charDB.namespaces[namespace] = newList()
+ end
+ rawset(object_nsdb, 'char', charDB.namespaces[namespace])
+ else
+ if type(db.namespaces) ~= "table" then
+ db.namespaces = newList()
+ end
+ if type(db.namespaces[namespace]) ~= "table" then
+ db.namespaces[namespace] = newList()
+ end
+ if type(db.namespaces[namespace].chars) ~= "table" then
+ db.namespaces[namespace].chars = newList()
+ end
+ if type(db.namespaces[namespace].chars[charID]) ~= "table" then
+ db.namespaces[namespace].chars[charID] = newList()
+ end
+ rawset(object_nsdb, 'char', db.namespaces[namespace].chars[charID])
+ end
+ if data_object.namespaceDefaults and data_object.namespaceDefaults[namespace] and data_object.namespaceDefaults[namespace].char then
+ inheritDefaults(object_nsdb.char, data_object.namespaceDefaults[namespace].char)
+ end
+ return object_nsdb.char
+ elseif key == "account" then
+ if type(db.namespaces) ~= "table" then
+ db.namespaces = newList()
+ end
+ if type(db.namespaces[namespace]) ~= "table" then
+ db.namespaces[namespace] = newList()
+ end
+ if type(db.namespaces[namespace].account) ~= "table" then
+ db.namespaces[namespace].account = newList()
+ end
+ rawset(object_nsdb, 'account', db.namespaces[namespace].account)
+ if data_object.namespaceDefaults and data_object.namespaceDefaults[namespace] and data_object.namespaceDefaults[namespace].account then
+ inheritDefaults(object_nsdb.account, data_object.namespaceDefaults[namespace].account)
+ end
+ return object_nsdb.account
+ elseif key == "realm" or key == "server" or key == "faction" or key == "class" or key == "profile" then
+ local key_plural, id
+ if key == "realm" then
+ key_plural, id = "realms", realmID
+ elseif key == "server" then
+ key_plural, id = "servers", server
+ elseif key == "faction" then
+ key_plural, id = "factions", faction
+ elseif key == "class" then
+ key_plural, id = "classes", classID
+ elseif key == "profile" then
+ key_plural = "profiles"
+ id = db.currentProfile and db.currentProfile[charID] or data_object.defaultProfile
+ if id == "char" then
+ id = "char/" .. charID
+ elseif id == "class" then
+ id = "class/" .. classID
+ elseif id == "realm" then
+ id = "realm/" .. realmID
+ end
+ if db.namespaces and db.namespaces[namespace] and db.namespaces[namespace][key_plural] then
+ fixKeyCasing(db.namespaces[namespace][key_plural], id)
+ end
+ end
+ if type(db.namespaces) ~= "table" then
+ db.namespaces = newList()
+ end
+ if type(db.namespaces[namespace]) ~= "table" then
+ db.namespaces[namespace] = newList()
+ end
+ if type(db.namespaces[namespace][key_plural]) ~= "table" then
+ db.namespaces[namespace][key_plural] = newList()
+ end
+ if type(db.namespaces[namespace][key_plural][id]) ~= "table" then
+ db.namespaces[namespace][key_plural][id] = newList()
+ end
+ rawset(object_nsdb, key, db.namespaces[namespace][key_plural][id])
+ if data_object.namespaceDefaults and data_object.namespaceDefaults[namespace] and data_object.namespaceDefaults[namespace][key] then
+ inheritDefaults(object_nsdb[key], data_object.namespaceDefaults[namespace][key])
+ end
+ return object_nsdb[key]
+ elseif key == "raw" or key == "namespaces" or key == "defaults" then
+ return nil
+ end
+ error(("Cannot access key %q in db table. You may want to use db.profile[%q]"):format(tostring(key), tostring(key)), 2)
+end, __newindex = function(object_db, key, value)
+ error(("Cannot access key %q in db table. You may want to use db.profile[%q]"):format(tostring(key), tostring(key)), 2)
+end }
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Sets a saved variable so as to correlate to the database table.
+ * Setting the charName is unnecessary if you never use char-specific data. If you do use them, it can be a good idea to have.
+ * This is to be called before ADDON_LOADED
+Arguments:
+ string - global name of the saved variable.
+ string - global name of the per-character saved variable.
+Example:
+ MyAddon:SetDatabase("MyAddonDB")
+ -- or
+ MyAddon:SetDatabase("MyAddonDB", "MyAddonCharDB")
+-----------------------------------------------------------------------------]]
+function RockDB:SetDatabase(dbName, charName)
+ local data_self = newList()
+ data[self] = data_self
+
+ data_self.addon = figureCurrentAddon(2)
+ data_self.dbName = dbName
+ data_self.charName = charName
+ data_self.defaultProfile = "Default"
+end
+precondition(RockDB, 'SetDatabase', function(self, dbName, charName)
+ local data_self = data[self]
+ if data_self then
+ error("Cannot call `SetDatabase' more than once.", 3)
+ end
+ argCheck(dbName, 2, "string")
+ argCheck(charName, 3, "string", "nil")
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Acquires a namespace within the database.
+ * This is especially handy for a module system to use, simply get a namespace with the same name as your module, and it acts as a fully functioning database.
+Arguments:
+ string - name of the namespace
+Example:
+ MyAddon_Bank.db = MyAddon:AcquireDBNamespace("Bank")
+-----------------------------------------------------------------------------]]
+function RockDB:GetDatabaseNamespace(namespace)
+ local data_self = data[self]
+
+ local data_self_namespaces = data_self.namespaces
+ if not data_self_namespaces then
+ data_self_namespaces = newList()
+ data_self.namespaces = data_self_namespaces
+ end
+
+ local data_self_namespaces_namespace = data_self_namespaces[namespace]
+ if not data_self_namespaces_namespace then
+ data_self_namespaces_namespace = newList()
+ data_self_namespaces[namespace] = data_self_namespaces_namespace
+ data_self_namespaces_namespace.object = self
+ data_self_namespaces_namespace.namespace = namespace
+
+ local data_self_namespaceDefaults = data_self.namespaceDefaults
+ if data_self_namespaceDefaults then
+ data_self_namespaces_namespace.defaults = data_self_namespaceDefaults[namespace]
+ end
+ end
+ setmetatable(data_self_namespaces_namespace, namespace_db_mt)
+ return data_self_namespaces_namespace
+end
+precondition(RockDB, 'GetDatabaseNamespace', function(self, namespace)
+ local data_self = data[self]
+ if not data_self then
+ error("Cannot call `GetDatabaseNamespace' before `SetDatabase'.", 3)
+ end
+ argCheck(namespace, 2, "string")
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Set default values for a specific database type.
+ * The defaults table can have subtables as well (as many as you want). This can be used to define your basic db structure.
+ * You can also set a whole table's default value by using the special key ['*'], which even works with tables.
+ * There is another key, ['**'], which does the same thing as ['*'] ''but'' also populates inside sibling nodes. For example, { ['**'] = { alpha = true, bravo = true, charlie = true}, monkey = { bravo = false } } makes monkey behave like { alpha = true, bravo = false, charlie = true }
+ * If you use the 'profile' dataType, it applies to ''all'' profiles.
+ * This is to be called between `SetDatabase' and ADDON_LOADED.
+Arguments:
+ string - "char", "class", "realm", "server", "account", "faction", or "profile" - correlates to the type of data you're working with.
+ table - the defaults
+Example:
+ MyAddon:SetDatabaseDefaults('char', {
+ alpha = {
+ bravo = {
+ charlie = true
+ }
+ }
+ })
+ assert(MyAddon.db.char.alpha.bravo.charlie == true)
+
+ MyAddon:SetDatabaseDefaults('realm', {
+ ['*'] = false -- special key
+ })
+ assert(MyAddon.db.realm.anyKeyHere == false)
+
+ MyAddon:SetDatabaseDefaults('class', {
+ colors = {
+ ['**'] = {
+ r = 1, g = 1, b = 1
+ },
+ crazyBoss = {
+ name = "The boss"
+ }
+ }
+ })
+ assert(MyAddon.db.class.colors.boss.r == 1)
+ MyAddon.db.class.colors.boss.r = 0
+ assert(MyAddon.db.class.colors.boss.r == 0)
+ assert(MyAddon.db.class.colors.otherBoss.r == 1)
+ assert(MyAddon.db.class.colors.crazyBoss.r == 1)
+ assert(MyAddon.db.class.colors.crazyBoss.name == "The boss")
+-----------------------------------------------------------------------------]]
+function RockDB:SetDatabaseDefaults(kind, defaults)
+ local data_self = data[self]
+
+ local data_self_defaults = data_self.defaults
+ if not data_self_defaults then
+ data_self_defaults = newList()
+ data_self.defaults = data_self_defaults
+ end
+ rawset(self.db, 'defaults', data_self_defaults)
+ data_self_defaults[kind] = defaults
+end
+precondition(RockDB, 'SetDatabaseDefaults', function(self, kind, defaults)
+ local data_self = data[self]
+ if not data_self then
+ error("Cannot call `SetDatabaseDefaults' before `SetDatabase'.", 3)
+ end
+ if data_self.init then
+ error("Cannot call `SetDatabaseDefaults' after ADDON_LOADED.", 3)
+ end
+ argCheck(kind, 2, "string")
+ if kind ~= "char" and kind ~= "class" and kind ~= "profile" and kind ~= "account" and kind ~= "realm" and kind ~= "faction" and kind ~= "server" then
+ error(("Bad argument #2 to `SetDatabaseDefaults'. Expected %q, %q, %q, %q, %q, %q, or %q, got %q)"):format("char", "class", "profile", "account", "realm", "server", "faction", kind), 3)
+ end
+ argCheck(defaults, 3, "table")
+ if data_self.defaults and data_self.defaults[kind] then
+ error(("Cannot call `SetDatabaseDefaults' for %q more than once."):format(kind), 3)
+ end
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Set default values for a specific database type for a specified namespace.
+ * The defaults table can have subtables as well (as many as you want). This can be used to define your basic db structure.
+ * You can also set a whole table's default value by using the special key ['*'], which even works with tables.
+ * There is another key, ['**'], which does the same thing as ['*'] ''but'' also populates inside sibling nodes. For example, { ['**'] = { alpha = true, bravo = true, charlie = true}, monkey = { bravo = false } } makes monkey behave like { alpha = true, bravo = false, charlie = true }
+ * If you use the 'profile' dataType, it applies to ''all'' profiles.
+ * This is to be called between :SetDatabase and ADDON_LOADED.
+Arguments:
+ string - name of the namespace
+ string - "char", "class", "realm", "server", "account", "faction", or "profile" - correlates to the type of data you're working with.
+ table - the defaults
+Example:
+ MyAddon:SetDatabaseNamespaceDefaults('Bank', 'char', {
+ value = 50
+ })
+
+ assert(MyAddon:GetDatabaseNamespace('Bank').char.value == 50)
+-----------------------------------------------------------------------------]]
+function RockDB:SetDatabaseNamespaceDefaults(namespace, kind, defaults)
+ local data_self = data[self]
+ local data_self_namespaceDefaults = data_self.namespaceDefaults
+ if not data_self_namespaceDefaults then
+ data_self_namespaceDefaults = newList()
+ data_self.namespaceDefaults = data_self_namespaceDefaults
+ end
+ local data_self_namespaceDefaults_namespace = data_self_namespaceDefaults[namespace]
+ if not data_self_namespaceDefaults_namespace then
+ data_self_namespaceDefaults_namespace = newList()
+ data_self_namespaceDefaults[namespace] = data_self_namespaceDefaults_namespace
+ end
+ data_self_namespaceDefaults_namespace[kind] = defaults
+
+ local data_self_namespaces = data_self.namespaces
+ if data_self_namespaces then
+ local data_self_namespaces_namespace = data_self_namespaces[namespace]
+ if data_self_namespaces_namespace then
+ rawset(data_self_namespaces_namespace, 'defaults', data_self_namespaceDefaults_namespace)
+ end
+ end
+end
+precondition(RockDB, 'SetDatabaseNamespaceDefaults', function(self, namespace, kind, defaults)
+ local data_self = data[self]
+ if not data_self then
+ error("Cannot call `SetDatabaseNamespaceDefaults' before `SetDatabase'.", 3)
+ end
+ argCheck(namespace, 2, "string")
+ argCheck(kind, 3, "string")
+ if kind ~= "char" and kind ~= "class" and kind ~= "profile" and kind ~= "account" and kind ~= "realm" and kind ~= "faction" and kind ~= "server" then
+ error(("Bad argument #3 to `SetDatabaseNamespaceDefaults'. Expected %q, %q, %q, %q, %q, %q, or %q, got %q)"):format("char", "class", "profile", "account", "realm", "server", "faction", kind), 3)
+ end
+ argCheck(defaults, 4, "table")
+ if data_self.namespaceDefaults and data_self.namespaceDefaults[namespace] and data_self.namespaceDefaults[namespace][kind] then
+ error(("Cannot call `SetDatabaseNamespaceDefaults' for %q : %q more than once."):format(namespace, kind), 3)
+ end
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Sets the default profile.
+ * If this is unspecified, "Default" is assumed.
+ * Can be any arbitrary name, but it's recommended to use "Default", "Alternative", "char", "class", or "realm".
+Arguments:
+ string - the name of the profile.
+Example:
+ MyAddon:SetDefaultProfile("char") -- will default to the character profile on a per-character basis.
+-----------------------------------------------------------------------------]]
+function RockDB:SetDefaultProfile(profile)
+ data[self].defaultProfile = profile
+end
+precondition(RockDB, 'SetDefaultProfile', function(self, profile)
+ local data_self = data[self]
+ if not data_self then
+ error("Cannot call `SetDefaultProfile' before `SetDatabase'.", 3)
+ end
+ if data_self.init then
+ error("Cannot call `SetDefaultProfile' after ADDON_LOADED.", 3)
+ end
+ argCheck(profile, 2, "string")
+end)
+
+-- #NODOC
+function RockDB:InitializeDatabase(object)
+ local data_object = data[object]
+ if not data_object then
+ error(("Must call `SetDatabase' before ADDON_LOADED for %s"):format(tostring(object)))
+ end
+ if data_object.init then
+ -- already initialized
+ return
+ end
+ data_object.init = true
+ local dbName = data_object.dbName
+ local db = _G[dbName]
+ if type(db) ~= "table" then
+ db = newList()
+ _G[dbName] = db
+ end
+ data_object.db = db
+ local charName = data_object.charName
+ local charDB
+ if charName then
+ charDB = _G[charName]
+ if type(charDB) ~= "table" then
+ charDB = newList()
+ _G[charName] = charDB
+ end
+ end
+ data_object.charDB = charDB
+ rawset(object.db, 'raw', db)
+end
+
+-- #NODOC
+function RockDB:UninitializeDatabase(object)
+ local data_object = data[object]
+ if not data_object then
+ return
+ end
+ local object_db = object.db
+ if not object_db then
+ return
+ end
+
+ local object_OnDatabaseCleanup = object.OnDatabaseCleanup
+ if object_OnDatabaseCleanup then
+ local success, ret = pcall(object_OnDatabaseCleanup, object)
+ if not success then
+ geterrorhandler(ret)
+ return
+ end
+ end
+
+ setmetatable(object_db, nil)
+
+ local db = data_object.db
+
+ local data_object_defaults = data_object.defaults
+ if data_object_defaults then
+ if object_db.char and cleanDefaults(object_db.char, data_object_defaults.char) then
+ local charName = data_object.charName
+ if charName then
+ if _G[charName] and _G[charName].global == object_db.char then
+ _G[charName].global = nil
+ if not next(_G[charName]) then
+ _G[charName] = nil
+ end
+ end
+ else
+ if db.chars then
+ db.chars[charID] = nil
+ if not next(db.chars) then
+ db.chars = nil
+ end
+ end
+ end
+ end
+ if object_db.account and cleanDefaults(object_db.account, data_object_defaults.account) then
+ db.account = nil
+ end
+ local kinds = newList("realm", "server", "faction", "class", "profile")
+ for _,key in ipairs(kinds) do
+ local key_plural, id
+ if key == "realm" then
+ key_plural, id = "realms", realmID
+ elseif key == "server" then
+ key_plural, id = "servers", server
+ elseif key == "faction" then
+ key_plural, id = "factions", faction
+ elseif key == "class" then
+ key_plural, id = "classes", classID
+ elseif key == "profile" then
+ key_plural = "profiles"
+ id = db.currentProfile and db.currentProfile[charID] or data_object.defaultProfile
+ if id == "char" then
+ id = "char/" .. charID
+ elseif id == "class" then
+ id = "class/" .. classID
+ elseif id == "realm" then
+ id = "realm/" .. realmID
+ end
+ if db[key_plural] then
+ fixKeyCasing(db[key_plural], id)
+ end
+ end
+ if object_db[key] and cleanDefaults(object_db[key], data_object_defaults[key]) and db[key_plural] then
+ db[key_plural][id] = nil
+ if not next(db[key_plural]) then
+ db[key_plural] = nil
+ end
+ end
+ end
+ kinds = del(kinds)
+ end
+
+ if not next(db) then
+ _G[data_object.dbName] = nil
+ return
+ end
+
+ local data_object_namespaceDefaults = data_object.namespaceDefaults
+ if not data_object_namespaceDefaults then
+ return
+ end
+ local data_object_namespaces = data_object.namespaces
+ if not data_object_namespaces then
+ return
+ end
+ for namespace, nsdb in pairs(data_object_namespaces) do
+ local data_object_namespaceDefaults_namespace = data_object_namespaceDefaults[namespace]
+ local db_namespaces_namespace = db.namespaces and db.namespaces[namespace]
+ if data_object_namespaceDefaults_namespace then
+ setmetatable(nsdb, nil)
+ if nsdb.char and cleanDefaults(nsdb.char, data_object_namespaceDefaults_namespace.char) then
+ local charName = data_object.charName
+ if charName then
+ if _G[charName] and _G[charName].namespaces and _G[charName].namespaces[namespace] == nsdb.char then
+ _G[charName].namespaces[namespace] = nil
+ if not next(_G[charName].namespaces) then
+ _G[charName].namespaces = nil
+ if not next(_G[charName]) then
+ _G[charName] = nil
+ end
+ end
+ end
+ else
+ if db_namespaces_namespace and db_namespaces_namespace.chars then
+ db_namespaces_namespace.chars[charID] = nil
+ if not next(db_namespaces_namespace.chars) then
+ db_namespaces_namespace.chars = nil
+ end
+ end
+ end
+ end
+ if db_namespaces_namespace then
+ if nsdb.account and cleanDefaults(nsdb.account, data_object_namespaceDefaults_namespace.account) then
+ db_namespaces_namespace.account = nil
+ end
+
+ local kinds = newList("realm", "server", "faction", "class", "profile")
+ for _,key in ipairs(kinds) do
+ local key_plural, id
+ if key == "realm" then
+ key_plural, id = "realms", realmID
+ elseif key == "server" then
+ key_plural, id = "servers", server
+ elseif key == "faction" then
+ key_plural, id = "factions", faction
+ elseif key == "class" then
+ key_plural, id = "classes", classID
+ elseif key == "profile" then
+ key_plural = "profiles"
+ id = db.currentProfile and db.currentProfile[charID] or data_object.defaultProfile
+ if id == "char" then
+ id = "char/" .. charID
+ elseif id == "class" then
+ id = "class/" .. classID
+ elseif id == "realm" then
+ id = "realm/" .. realmID
+ end
+ if db_namespaces_namespace[key_plural] then
+ fixKeyCasing(db_namespaces_namespace[key_plural], id)
+ end
+ end
+ if nsdb[key] and cleanDefaults(nsdb[key], data_object_namespaceDefaults_namespace[key]) and db_namespaces_namespace[key_plural] then
+ db_namespaces_namespace[key_plural][id] = nil
+ if not next(db_namespaces_namespace[key_plural]) then
+ db_namespaces_namespace[key_plural] = nil
+ end
+ end
+ end
+ kinds = del(kinds)
+ if not next(db_namespaces_namespace) then
+ db.namespaces[namespace] = nil
+ end
+ end
+ if db.namespaces then
+ if not next(db.namespaces) then
+ db.namespaces = nil
+ end
+ end
+ end
+ end
+
+ if not next(db) then
+ _G[data_object.dbName] = nil
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * If you are in a char, class, or realm profile, "short" will be "char", "class", or "realm" and "long" will be "char/Player of Realm Name", "class/Warlock", or "realm/My Realm - Horde". Otherwise, "short" and "long" will be equivalent.
+ * "Default" is the default profile unless specified by :SetDefaultProfile.
+ * This is only accurate after ADDON_LOADED.
+Returns:
+ ; "short" : string - The current profile, short-form.
+ ; "long" : string - The current profile, in its full, long form.
+Example:
+ local short, long = MyAddon:GetProfile()
+-----------------------------------------------------------------------------]]
+function RockDB:GetProfile()
+ local data_self = data[self]
+ if not data_self then
+ return nil
+ end
+ local db = data_self.db
+ if not db then
+ return nil
+ end
+ local profile = db.currentProfile and db.currentProfile[charID]
+ if not profile then
+ profile = data_self.defaultProfile
+ end
+
+ if profile == "char" then
+ return "char", "char/" .. charID
+ elseif profile == "class" then
+ return "class", "class/" .. classID
+ elseif profile == "realm" then
+ return "realm", "realm/" .. realmID
+ end
+ return profile, profile
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Set the current profile to the given profile name.
+ * If "profile" is "char", "realm", or "class", it gets set to the appropriate profile based on the current character.
+ * This will call :OnProfileDisable() if available, change the profile, then call :OnProfileEnable("oldName", oldData) if available. In turn, this will call any embeds :OnEmbedProfileDisable(self) and :OnProfileEnable(self, "oldName", oldData) if available.
+ * Defaults will properly transfer to the new profile without harm.
+Arguments:
+ string - the new profile name
+Example:
+ MyAddon:SetProfile("Monkey") -- for all your monkey-based goodness.
+ MyAddon:SetProfile("char") -- change to your character
+-----------------------------------------------------------------------------]]
+function RockDB:SetProfile(name)
+ local data_self = data[self]
+ local name_lower = name:lower()
+ if name_lower:match("^char/") then
+ name = "char"
+ name_lower = "char"
+ elseif name_lower:match("^realm/") then
+ name = "realm"
+ name_lower = "realm"
+ elseif name_lower:match("^class/") then
+ name = "class"
+ name_lower = "class"
+ end
+ local db = data_self.db
+ local db_currentProfile = db.currentProfile
+ local oldProfile = db_currentProfile and db_currentProfile[charID] or data_self.defaultProfile
+ if oldProfile:lower() == name_lower then
+ if oldProfile ~= name and oldProfile ~= data_self.defaultProfile then
+ -- casing difference
+ db_currentProfile[charID] = name
+ end
+ -- no change
+ return
+ end
+ local self_db = self.db
+ local oldProfileData = self_db.profile
+ local realName = name
+ if name_lower == "char" then
+ realName = name .. "/" .. charID
+ elseif name_lower == "realm" then
+ realName = name .. "/" .. realmID
+ elseif name_lower == "class" then
+ realName = name .. "/" .. classID
+ end
+ for mixin in Rock:IterateObjectMixins(self) do
+ local mixin_OnEmbedProfileDisable = mixin.OnEmbedProfileDisable
+ if mixin_OnEmbedProfileDisable then
+ local success, ret = pcall(mixin_OnEmbedProfileDisable, mixin, self, realName)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+ end
+ local self_OnProfileDisable = self.OnProfileDisable
+ if self_OnProfileDisable then
+ local success, ret = pcall(self_OnProfileDisable, self, realName)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+
+ if not db_currentProfile then
+ db_currentProfile = newList()
+ db.currentProfile = db_currentProfile
+ end
+ db_currentProfile[charID] = name ~= data_self.defaultProfile and name or nil
+ if not next(db_currentProfile) then
+ db.currentProfile = del(db_currentProfile)
+ end
+ rawset(self_db, 'profile', nil)
+ if data_self.namespaces then
+ for k,v in pairs(data_self.namespaces) do
+ rawset(v, 'profile', nil)
+ end
+ end
+
+ for mixin in Rock:IterateObjectMixins(self) do
+ local mixin_OnEmbedProfileEnable = mixin.OnEmbedProfileEnable
+ if mixin_OnEmbedProfileEnable then
+ local success, ret = pcall(mixin_OnEmbedProfileEnable, mixin, self, realName)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+ end
+ local self_OnProfileEnable = self.OnProfileEnable
+ if self_OnProfileEnable then
+ local success, ret = pcall(self_OnProfileEnable, self, realName)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+
+ if cleanDefaults(oldProfileData, data_self.defaults and data_self.defaults.profile) then
+ db.profiles[oldProfile] = del(oldProfileData)
+ if next(db.profiles) == nil then
+ db.profiles = del(db.profiles)
+ end
+ end
+
+ Rock:RecheckEnabledStates()
+end
+precondition(RockDB, 'SetProfile', function(self, name)
+ local data_self = data[self]
+ if not data_self then
+ error("Cannot call `SetProfile' before `SetDatabase'.", 3)
+ end
+ if not data_self.init then
+ error("Cannot call `SetProfile' before ADDON_LOADED.", 3)
+ end
+ argCheck(name, 2, "string")
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Deletes the given profile
+ * This will error if it is the current profile, as that cannot be deleted.
+Arguments:
+ string - the new profile name
+Example:
+ MyAddon:RemoveProfile("Monkey") -- remove all monkey-based goodness.
+-----------------------------------------------------------------------------]]
+function RockDB:RemoveProfile(profile)
+ local data_self = data[self]
+
+ local db = data_self.db
+
+ local currentProfile = db.currentProfile and db.currentProfile[charID] or data_self.defaultProfile
+ local profile_lower = profile:lower()
+ if currentProfile:lower() == profile_lower then
+ error(("Cannot delete profile %q, it is currently in use."):format(profile), 2)
+ end
+
+ local good = false
+ if db.profiles then
+ for k in pairs(db.profiles) do
+ if k:lower() == profile_lower then
+ db.profiles[k] = nil
+ end
+ end
+ if not next(db.profiles) then
+ db.profiles = del(db.profiles)
+ end
+ end
+
+ if db.namespaces then
+ for _,v in pairs(db.namespaces) do
+ if v.profiles then
+ for k in pairs(v.profiles) do
+ if k:lower() == profile_lower then
+ v.profiles[k] = nil
+ end
+ end
+ if not next(v.profiles) then
+ v.profiles = del(v.profiles)
+ end
+ end
+ end
+ end
+end
+precondition(RockDB, 'RemoveProfile', function(self, name)
+ local data_self = data[self]
+ if not data_self then
+ error("Cannot call `RemoveProfile' before `SetDatabase'.", 3)
+ end
+ if not data_self.init then
+ error("Cannot call `RemoveProfile' before ADDON_LOADED.", 3)
+ end
+ argCheck(name, 2, "string")
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Resets the database or a specific part of it.
+ * This will call :OnResetDatabase(kind, namespace) once complete.
+Arguments:
+ string or nil - the data type to reset. If nil, then it means all data types.
+ string or nil - the namespace to reset. If nil, then it means the whole database.
+Example:
+ MyAddon:RemoveProfile("Monkey") -- remove all monkey-based goodness.
+-----------------------------------------------------------------------------]]
+function RockDB:ResetDatabase(kind, namespace)
+ local data_self = data[self]
+ local self_db = self.db
+ local db = data_self.db
+ if not kind then
+ local kinds = newList("char", "class", "profile", "account", "realm", "faction", "server")
+ if not namespace then
+ local dbName = data_self.dbName
+ _G[dbName] = nil
+ local charName = data_self.charName
+ if charName then
+ _G[charName] = nil
+ end
+ data_self.init = nil
+ RockDB:InitializeDatabase(self)
+ for _,kind in ipairs(kinds) do
+ rawset(self_db, kind, nil)
+ end
+ if data_self.namespaces then
+ for k, v in pairs(data_self.namespaces) do
+ for _,kind in ipairs(kinds) do
+ rawset(v, kind, nil)
+ end
+ end
+ end
+ else
+ if db.namespaces then
+ db.namespaces[namespace] = nil
+ end
+ if data_self.namespaces and data_self.namespaces[namespace] then
+ for _,kind in ipairs(kinds) do
+ rawset(data_self.namespaces[namespace], kind, nil)
+ end
+ end
+ end
+ kinds = del(kinds)
+ else
+ if kind == "account" then
+ if not namespace then
+ db.account = nil
+ if db.namespaces then
+ for name,v in pairs(db.namespaces) do
+ v.account = nil
+ end
+ end
+ else
+ if db.namespaces and db.namespaces[namespace] then
+ db.namespaces[namespace].account = nil
+ end
+ end
+ elseif kind == "char" then
+ local charName = data_self.charName
+ if not namespace then
+ if charName then
+ _G[charName] = nil
+ else
+ if db.chars then
+ db.chars[charID] = nil
+ end
+ if db.namespaces then
+ for name,v in pairs(db.namespaces) do
+ if v.chars then
+ v.chars[charID] = nil
+ end
+ end
+ end
+ end
+ else
+ if charName then
+ local _G_charName = _G[charName]
+ if _G_charName and _G_charName.namespaces then
+ _G_charName.namespaces[namespace] = nil
+ end
+ else
+ if db.namespaces and db.namespaces[namespace] and db.namespaces[namespace].chars then
+ db.namespaces[namespace].chars[charID] = nil
+ end
+ end
+ end
+ else
+ local key_plural, id
+ if kind == "realm" then
+ key_plural, id = "realms", realmID
+ elseif kind == "server" then
+ key_plural, id = "servers", server
+ elseif kind == "faction" then
+ key_plural, id = "factions", faction
+ elseif kind == "class" then
+ key_plural, id = "classes", classID
+ elseif kind == "profile" then
+ key_plural = "profiles"
+ id = db.currentProfile and db.currentProfile[charID] or data_self.defaultProfile
+ if id == "char" then
+ id = "char/" .. charID
+ elseif id == "class" then
+ id = "class/" .. classID
+ elseif id == "realm" then
+ id = "realm/" .. realmID
+ end
+ if db[key_plural] then
+ fixKeyCasing(db[key_plural], id)
+ end
+ end
+ if not namespace then
+ if db[key_plural] then
+ db[key_plural][id] = nil
+ end
+ if db.namespaces then
+ for name,v in pairs(db.namespaces) do
+ if v[key_plural] then
+ v[key_plural][id] = nil
+ end
+ end
+ end
+ else
+ if db.namespaces and db.namespaces[namespace] and db.namespaces[namespace][key_plural] then
+ db.namespaces[namespace][key_plural][id] = nil
+ end
+ end
+ end
+ if not namespace then
+ rawset(self_db, kind, nil)
+ if data_self.namespaces then
+ for k, v in pairs(data_self.namespaces) do
+ rawset(v, kind, nil)
+ end
+ end
+ else
+ if data_self.namespaces and data_self.namespaces[namespace] then
+ rawset(data_self.namespaces[namespace], kind, nil)
+ end
+ end
+ end
+ Rock:RecheckEnabledStates()
+ local self_OnResetDatabase = self.OnResetDatabase
+ if self_OnResetDatabase then
+ local success, ret = pcall(self_OnResetDatabase, self, kind, namespace)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+end
+precondition(RockDB, 'ResetDatabase', function(self, kind, namespace)
+ local data_self = data[self]
+ if not data_self then
+ error("Cannot call `ResetDatabase' before `SetDatabase'.", 3)
+ end
+ if not data_self.init then
+ error("Cannot call `ResetDatabase' before ADDON_LOADED.", 3)
+ end
+ argCheck(kind, 2, "string", "nil")
+ if kind and kind ~= "char" and kind ~= "class" and kind ~= "profile" and kind ~= "account" and kind ~= "realm" and kind ~= "faction" and kind ~= "server" then
+ error(("Bad argument #2 to `SetDatabaseDefaults'. Expected %q, %q, %q, %q, %q, %q, or %q, got %q)"):format("char", "class", "profile", "account", "realm", "server", "faction", kind), 2)
+ end
+ argCheck(namespace, 3, "string", "nil")
+end)
+
+local function copy(t)
+ if type(t) ~= "table" then
+ return t
+ end
+ local u = newList()
+ for k,v in pairs(t) do
+ u[copy(k)] = copy(v)
+ end
+ return u
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Copy a profile from the given one to the current one.
+Arguments:
+ string - the profile name to copy from.
+Example:
+ MyAddon:CopyProfile("Monkey") -- copy from the Monkey profile to the current one
+-----------------------------------------------------------------------------]]
+function RockDB:CopyProfile(name)
+ local data_self = data[self]
+
+ local self_db = self.db
+ local db = data_self.db
+
+ if not db.profiles or not caseInsensitiveLookup(db.profiles, name) then
+ local good = false
+ if db.namespaces then
+ for _, ns in pairs(db.namespaces) do
+ if ns.profiles and caseInsensitiveLookup(ns.profiles, name) then
+ good = true
+ break
+ end
+ end
+ end
+ if not good then
+ error(("Cannot copy from profile %q, it does not exist."):format(name), 2)
+ end
+ end
+
+ local name_lower = name:lower()
+ local currentProfile = db.currentProfile and db.currentProfile[charID] or data_self.defaultProfile
+ if currentProfile:lower() == name_lower then
+ error(("Cannot copy from profile %q, it is currently in use."):format(name), 2)
+ end
+ local oldProfileData = self_db.profile
+ for mixin in Rock:IterateObjectMixins(self) do
+ local mixin_OnEmbedProfileDisable = mixin.OnEmbedProfileDisable
+ if mixin_OnEmbedProfileDisable then
+ local success, ret = pcall(mixin_OnEmbedProfileDisable, mixin, self, currentProfile)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+ end
+ local self_OnProfileDisable = self.OnProfileDisable
+ if self_OnProfileDisable then
+ local success, ret = pcall(self_OnProfileDisable, self, currentProfile)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+
+ for k,v in pairs(oldProfileData) do
+ oldProfileData[k] = nil
+ end
+
+ local _,copyFromData = caseInsensitiveLookup(db.profiles, name)
+ if copyFromData then
+ for k,v in pairs(copyFromData) do
+ oldProfileData[copy(k)] = copy(v)
+ end
+ end
+ inheritDefaults(oldProfileData, data_self.defaults and data_self.defaults.profile)
+ if data_self.namespaces then
+ for namespace,u in pairs(data_self.namespaces) do
+ local u_profile = u.profile
+ for k,v in pairs(u_profile) do
+ u_profile[k] = nil
+ end
+ if db.namespaces and db.namespaces[namespace] then
+ local _,copyFromData = caseInsensitiveLookup(db.namespaces[namespace].profiles, name)
+ if copyFromData then
+ for k,v in pairs(copyFromData) do
+ u_profile[copy(k)] = copy(v)
+ end
+ end
+ inheritDefaults(u_profile, data_self.namespaceDefaults and data_self.namespaceDefaults[namespace] and data_self.namespaceDefaults[namespace].profile)
+ end
+ end
+ end
+
+ for mixin in Rock:IterateObjectMixins(self) do
+ local mixin_OnEmbedProfileEnable = mixin.OnEmbedProfileEnable
+ if mixin_OnEmbedProfileEnable then
+ local success, ret = pcall(mixin_OnEmbedProfileEnable, mixin, self, oldProfileData, name)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+ end
+ local self_OnProfileEnable = self.OnProfileEnable
+ if self_OnProfileEnable then
+ local success, ret = pcall(self_OnProfileEnable, self, oldProfileData, name)
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+
+ Rock:RecheckEnabledStates()
+end
+precondition(RockDB, 'CopyProfile', function(self, name)
+ local data_self = data[self]
+ if not data_self then
+ error("Cannot call `CopyProfile' before `SetDatabase'.", 3)
+ end
+ if not data_self.init then
+ error("Cannot call `CopyProfile' before ADDON_LOADED.", 3)
+ end
+ argCheck(name, 2, "string")
+end)
+
+for object in Rock:IterateMixinObjects(RockDB) do
+ local object_db = object.db
+ if object_db then -- should exist
+ setmetatable(object_db, nil)
+ object_db.char = nil
+ object_db.account = nil
+ object_db.profile = nil
+ object_db.realm = nil
+ object_db.server = nil
+ object_db.faction = nil
+ object_db.class = nil
+ setmetatable(object_db, db_mt)
+ end
+ local data_object = data[object]
+ if data_object then
+ local data_object_namespaces = data_object.namespaces
+ if data_object_namespaces then
+ for namespace, nsdb in pairs(data_object_namespaces) do
+ setmetatable(nsdb, nil)
+ nsdb.char = nil
+ nsdb.account = nil
+ nsdb.profile = nil
+ nsdb.realm = nil
+ nsdb.server = nil
+ nsdb.faction = nil
+ nsdb.class = nil
+ setmetatable(nsdb, namespace_db_mt)
+ end
+ end
+ end
+end
+
+function RockDB:OnEmbedInitialize(object)
+ self:InitializeDatabase(object)
+end
+
+function RockDB:OnEmbed(object)
+ local object_db = newList()
+ object.db = object_db
+ object_db.object = object
+ setmetatable(object_db, db_mt)
+end
+
+function RockDB:OnUnembed(object)
+ RockDB:UninitializeDatabase(object)
+ object.db = nil
+ data[object] = nil
+end
+
+frame:RegisterEvent("ADDON_LOADED")
+frame:RegisterEvent("PLAYER_LOGOUT")
+frame:SetScript("OnEvent", function(this, event, ...)
+ if event == "ADDON_LOADED" then
+ local name = (...)
+ for object, v in pairs(data) do
+ if v.addon == name then
+ RockDB:InitializeDatabase(object)
+ end
+ end
+ elseif event == "PLAYER_LOGOUT" then
+ for object in Rock:IterateMixinObjects(RockDB) do
+ RockDB:UninitializeDatabase(object)
+ end
+ end
+end)
+
+local function GetProfile_proxy(addon, ...)
+ return addon:GetProfile(...)
+end
+local function SetProfile_proxy(addon, ...)
+ return addon:SetProfile(...)
+end
+local function CopyProfile_proxy(addon, ...)
+ return addon:CopyProfile(...)
+end
+local function RemoveProfile_proxy(addon, ...)
+ return addon:RemoveProfile(...)
+end
+local function ResetDatabase_proxy(addon, ...)
+ return addon:ResetDatabase(...)
+end
+local function GetProfileList(addon)
+ local t = newList()
+ t.char = L["Character: "] .. L["%s of %s"]:format(UnitName("player"), server)
+ t.realm = L["Realm: "] .. realmID
+ t.class = L["Class: "] .. classID
+ t.Default = L["Default"]
+ local addon_db = addon.db
+ local db = addon_db and addon_db.raw
+ if db then
+ if db.profiles then
+ for k in pairs(db.profiles) do
+ if not k:find("^char/") and not k:find("^realm/") and not k:find("^class/") and not t[k] then
+ t[k] = k
+ end
+ end
+ end
+ if db.namespaces then
+ for _,n in pairs(db.namespaces) do
+ if n.profiles then
+ for k in pairs(n.profiles) do
+ if not k:find("^char/") and not k:find("^realm/") and not k:find("^class/") and not t[k] then
+ t[k] = k
+ end
+ end
+ end
+ end
+ end
+ local curr = db.currentProfile and db.currentProfile[charID]
+ if curr and not t[curr] then
+ t[curr] = curr
+ end
+ end
+ if t.Alternative then
+ t.Alternative = L["Alternative"]
+ end
+ return "@dict", unpackDictAndDel(t)
+end
+local function GetProfileCopyList(addon)
+ local t = newList()
+ local addon_db = addon.db
+ local db = addon_db and addon_db.raw
+ if db then
+ local _,currentProfile = RockDB.GetProfile(addon)
+ if db.profiles then
+ for k in pairs(db.profiles) do
+ if currentProfile ~= k then
+ if k:find("^char/") then
+ local name = k:sub(6)
+ local player, realm = name:match("^(.*) %- (.*)$")
+ if player then
+ name = L["%s of %s"]:format(player, realm)
+ end
+ t[k] = L["Character: "] .. name
+ elseif k:find("^realm/") then
+ local name = k:sub(7)
+ t[k] = L["Realm: "] .. name
+ elseif k:find("^class/") then
+ local name = k:sub(7)
+ t[k] = L["Class: "] .. name
+ else
+ t[k] = k
+ end
+ end
+ end
+ end
+ if db.namespaces then
+ for _,n in pairs(db.namespaces) do
+ if n.profiles then
+ for k in pairs(n.profiles) do
+ if currentProfile ~= k then
+ if k:find('^char/') then
+ local name = k:sub(6)
+ local player, realm = name:match("^(.*) %- (.*)$")
+ if player then
+ name = L["%s of %s"]:format(player, realm)
+ end
+ t[k] = L["Character: "] .. name
+ elseif k:find('^realm/') then
+ local name = k:sub(7)
+ t[k] = L["Realm: "] .. name
+ elseif k:find('^class/') then
+ local name = k:sub(7)
+ t[k] = L["Class: "] .. name
+ else
+ t[k] = k
+ end
+ end
+ end
+ end
+ end
+ end
+ if t.Default then
+ t.Default = L["Default"]
+ end
+ if t.Alternative then
+ t.Alternative = L["Alternative"]
+ end
+ end
+ return "@dict", unpackDictAndDel(t)
+end
+local function IsCopyListDisabled(addon)
+ local t = newDict(select(2, GetProfileCopyList(addon)))
+ local disabled = next(t) == nil
+ t = del(t)
+ return disabled
+end
+
+-- #NODOC
+function RockDB:GetEmbedRockConfigOptions(addon)
+ return 'profile', {
+ type = 'group',
+ name = L["Profile"],
+ desc = L["Set profile for this addon."],
+ order = -1,
+ handler = addon,
+ args = {
+ choose = {
+ name = L["Choose"],
+ desc = L["Choose a profile."],
+ type = 'choice',
+ get = GetProfile_proxy,
+ set = SetProfile_proxy,
+ choices = GetProfileList,
+ passValue = addon
+ },
+ copy = {
+ name = L["Copy from"],
+ desc = L["Copy settings from another profile."],
+ type = 'choice',
+ get = false,
+ set = CopyProfile_proxy,
+ passValue = addon,
+ choices = GetProfileCopyList,
+ disabled = IsCopyListDisabled,
+ },
+ other = {
+ name = L["Other"],
+ desc = L["Choose another profile."],
+ usage = L[""],
+ type = 'string',
+ get = GetProfile_proxy,
+ set = SetProfile_proxy,
+ passValue = addon
+ },
+ remove = {
+ name = L["Remove"],
+ desc = L["Removes a profile. Note that no check is made whether this profile is in use by other characters or not."],
+ type = 'choice',
+ get = false,
+ set = RemoveProfile_proxy,
+ choices = GetProfileCopyList,
+ disabled = IsCopyListDisabled,
+ passValue = addon
+ },
+ reset = {
+ name = L["Reset profile"],
+ desc = L["Clear all settings of the current profile."],
+ type = 'execute',
+ func = ResetDatabase_proxy,
+ passValue = addon,
+ passValue2 = "profile",
+ confirmText = L["Reset all settings."],
+ buttonText = L["Reset"],
+ }
+ }
+ }
+end
+
+RockDB:SetExportedMethods("SetDatabase", "SetDefaultProfile", "SetDatabaseDefaults", "SetDatabaseNamespaceDefaults", "GetProfile", "SetProfile", "GetDatabaseNamespace", "RemoveProfile", "ResetDatabase", "CopyProfile")
+
+Rock:FinalizeLibrary(MAJOR_VERSION)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ local t = { name = MAJOR_VERSION .. "_UnitTest" }
+
+ RockDB:Embed(t)
+ assert(t.db)
+
+ t:SetDatabase(MAJOR_VERSION .. "_UnitTestDB")
+ RockDB:InitializeDatabase(t)
+ assert(type(_G[MAJOR_VERSION .. "_UnitTestDB"]) == "table")
+
+ _G[MAJOR_VERSION .. "_UnitTestDB"] = nil
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- standard access
+ local t = { name = MAJOR_VERSION .. "_UnitTest" }
+
+ RockDB:Embed(t)
+ assert(t.db)
+
+ t:SetDatabase(MAJOR_VERSION .. "_UnitTestDB")
+ RockDB:InitializeDatabase(t)
+ assert(type(_G[MAJOR_VERSION .. "_UnitTestDB"]) == "table")
+
+ local kinds = { "profile", "char", "account", "realm", "server", "faction", "class" }
+ for _, kind in ipairs(kinds) do
+ assert(not t.db[kind].Alpha)
+ t.db[kind].Alpha = true
+ assert(t.db[kind].Alpha)
+ assert(not t.db[kind].Bravo)
+ t.db[kind].Bravo = true
+ assert(t.db[kind].Bravo)
+ t.db[kind].Alpha = false
+ assert(not t.db[kind].Alpha)
+ assert(t.db[kind].Bravo)
+ end
+
+ RockDB:Unembed(t)
+ assert(_G[MAJOR_VERSION .. "_UnitTestDB"]) -- stuff changed, DB should still exist
+ _G[MAJOR_VERSION .. "_UnitTestDB"] = nil
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- w/ CharDB
+ local t = { name = MAJOR_VERSION .. "_UnitTest" }
+
+ RockDB:Embed(t)
+ assert(t.db)
+
+ t:SetDatabase(MAJOR_VERSION .. "_UnitTestDB", MAJOR_VERSION .. "_UnitTestCharDB")
+ RockDB:InitializeDatabase(t)
+ assert(type(_G[MAJOR_VERSION .. "_UnitTestDB"]) == "table")
+ assert(type(_G[MAJOR_VERSION .. "_UnitTestCharDB"]) == "table")
+
+ local kinds = { "profile", "char", "account", "realm", "server", "faction", "class" }
+ for _, kind in ipairs(kinds) do
+ assert(not t.db[kind].Alpha)
+ t.db[kind].Alpha = true
+ assert(t.db[kind].Alpha)
+ assert(not t.db[kind].Bravo)
+ t.db[kind].Bravo = true
+ assert(t.db[kind].Bravo)
+ t.db[kind].Alpha = false
+ assert(not t.db[kind].Alpha)
+ assert(t.db[kind].Bravo)
+ end
+
+ _G[MAJOR_VERSION .. "_UnitTestDB"] = nil
+ _G[MAJOR_VERSION .. "_UnitTestCharDB"] = nil
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- namespacing
+ local t = { name = MAJOR_VERSION .. "_UnitTest" }
+
+ RockDB:Embed(t)
+ assert(t.db)
+
+ t:SetDatabase(MAJOR_VERSION .. "_UnitTestDB")
+ RockDB:InitializeDatabase(t)
+ assert(type(_G[MAJOR_VERSION .. "_UnitTestDB"]) == "table")
+
+ local nsdb = t:GetDatabaseNamespace("MyNamespace")
+
+ local kinds = { "profile", "char", "account", "realm", "server", "faction", "class" }
+ for _, kind in ipairs(kinds) do
+ assert(not nsdb[kind].Alpha)
+ nsdb[kind].Alpha = true
+ assert(nsdb[kind].Alpha)
+ assert(not nsdb[kind].Bravo)
+ nsdb[kind].Bravo = true
+ assert(nsdb[kind].Bravo)
+ nsdb[kind].Alpha = false
+ assert(not nsdb[kind].Alpha)
+ assert(nsdb[kind].Bravo)
+ end
+
+ _G[MAJOR_VERSION .. "_UnitTestDB"] = nil
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- defaults
+ local t = { name = MAJOR_VERSION .. "_UnitTest" }
+
+ RockDB:Embed(t)
+ assert(t.db)
+
+ t:SetDatabase(MAJOR_VERSION .. "_UnitTestDB")
+ t:SetDatabaseDefaults("profile", {
+ alpha = {
+ bravo = "charlie"
+ },
+ delta = {
+ ['*'] = "echo",
+ foxtrot = "golf",
+ },
+ hotel = {
+ ['*'] = {},
+ india = "juliet",
+ },
+ kilo = {
+ ['**'] = {
+ lima = "mike",
+ },
+ november = {
+ oscar = "papa",
+ -- should have lima = "mike" as well
+ }
+ },
+ })
+ RockDB:InitializeDatabase(t)
+ assert(type(_G[MAJOR_VERSION .. "_UnitTestDB"]) == "table")
+
+ assert(t.db.profile.alpha.bravo == "charlie")
+ assert(t.db.profile.delta.foxtrot == "golf")
+ assert(t.db.profile.delta.dummy == "echo")
+ assert(t.db.profile.hotel.india == "juliet")
+ assert(type(t.db.profile.hotel.dummy) == "table")
+ assert(not next(t.db.profile.hotel.dummy))
+ t.db.profile.hotel.dummy.value = true
+ assert(t.db.profile.hotel.dummy.value == true)
+ assert(t.db.profile.kilo.dummy.lima == "mike")
+ assert(t.db.profile.kilo.dummy.oscar == nil)
+ assert(t.db.profile.kilo.november.lima == "mike")
+ assert(t.db.profile.kilo.november.oscar == "papa")
+ t.db.profile.hotel.dummy.value = nil
+
+ t:GetDatabaseNamespace("Bank")
+ t:SetDatabaseNamespaceDefaults("Bank", "profile", {
+ blah = true,
+ })
+
+ RockDB:Unembed(t)
+ assert(not _G[MAJOR_VERSION .. "_UnitTestDB"]) -- nothing changed, DB clear
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- defaults
+ local t = { name = MAJOR_VERSION .. "_UnitTest" }
+
+ RockDB:Embed(t)
+ assert(t.db)
+
+
+ t:SetDatabase(MAJOR_VERSION .. "_UnitTestDB")
+ t:SetDatabaseDefaults("profile", {
+ blah = true,
+ })
+ local nsdb = t:GetDatabaseNamespace("Bank")
+ t:SetDatabaseNamespaceDefaults("Bank", "profile", {
+ alpha = {
+ bravo = "charlie"
+ },
+ delta = {
+ ['*'] = "echo",
+ foxtrot = "golf",
+ },
+ hotel = {
+ ['*'] = {},
+ india = "juliet",
+ },
+ kilo = {
+ ['**'] = {
+ lima = "mike",
+ },
+ november = {
+ oscar = "papa",
+ -- should have lima = "mike" as well
+ }
+ },
+ })
+ RockDB:InitializeDatabase(t)
+ assert(type(_G[MAJOR_VERSION .. "_UnitTestDB"]) == "table")
+
+ assert(nsdb.profile.alpha.bravo == "charlie")
+ assert(nsdb.profile.delta.foxtrot == "golf")
+ assert(nsdb.profile.delta.dummy == "echo")
+ assert(nsdb.profile.hotel.india == "juliet")
+ assert(type(nsdb.profile.hotel.dummy) == "table")
+ assert(not next(nsdb.profile.hotel.dummy))
+ nsdb.profile.hotel.dummy.value = true
+ assert(nsdb.profile.hotel.dummy.value == true)
+ assert(nsdb.profile.kilo.dummy.lima == "mike")
+ assert(nsdb.profile.kilo.dummy.oscar == nil)
+ assert(nsdb.profile.kilo.november.lima == "mike")
+ assert(nsdb.profile.kilo.november.oscar == "papa")
+ nsdb.profile.hotel.dummy.value = nil
+
+ RockDB:Unembed(t)
+ assert(not _G[MAJOR_VERSION .. "_UnitTestDB"]) -- nothing changed, DB clear
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- changing profiles
+ local t = { name = MAJOR_VERSION .. "_UnitTest" }
+
+ RockDB:Embed(t)
+ assert(t.db)
+
+ t:SetDatabase(MAJOR_VERSION .. "_UnitTestDB")
+ RockDB:InitializeDatabase(t)
+ assert(type(_G[MAJOR_VERSION .. "_UnitTestDB"]) == "table")
+
+ assert(t:GetProfile() == "Default")
+ assert(select(2, t:GetProfile()) == "Default")
+ assert(not t.db.profile.alpha)
+ t.db.profile.alpha = "bravo"
+ assert(t.db.profile.alpha == "bravo")
+ t:SetProfile("Alternative")
+ assert(t:GetProfile() == "Alternative")
+ assert(select(2, t:GetProfile()) == "Alternative")
+ assert(not t.db.profile.alpha)
+ t.db.profile.alpha = "charlie"
+ assert(t.db.profile.alpha == "charlie")
+ t:SetProfile("Default")
+ assert(t:GetProfile() == "Default")
+ assert(select(2, t:GetProfile()) == "Default")
+ assert(t.db.profile.alpha == "bravo")
+
+ t:RemoveProfile("Alternative")
+ t:SetProfile("Alternative")
+ assert(t:GetProfile() == "Alternative")
+ assert(select(2, t:GetProfile()) == "Alternative")
+ assert(not t.db.profile.alpha)
+
+ t:SetProfile("char")
+ assert(t:GetProfile() == "char")
+ assert(select(2, t:GetProfile()):match("^char/."))
+ t:SetProfile("class")
+ assert(t:GetProfile() == "class")
+ assert(select(2, t:GetProfile()):match("^class/."))
+ t:SetProfile("realm")
+ assert(t:GetProfile() == "realm")
+ assert(select(2, t:GetProfile()):match("^realm/."))
+
+ _G[MAJOR_VERSION .. "_UnitTestDB"] = nil
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- copying profiles
+ local t = { name = MAJOR_VERSION .. "_UnitTest" }
+
+ RockDB:Embed(t)
+ assert(t.db)
+
+ t:SetDatabase(MAJOR_VERSION .. "_UnitTestDB")
+ RockDB:InitializeDatabase(t)
+ assert(type(_G[MAJOR_VERSION .. "_UnitTestDB"]) == "table")
+
+ assert(t:GetProfile() == "Default")
+ assert(select(2, t:GetProfile()) == "Default")
+ assert(not t.db.profile.alpha)
+ t.db.profile.alpha = "bravo"
+ assert(t.db.profile.alpha == "bravo")
+ t:SetProfile("Alternative")
+ assert(t:GetProfile() == "Alternative")
+ assert(select(2, t:GetProfile()) == "Alternative")
+ assert(not t.db.profile.alpha)
+ t.db.profile.alpha = "charlie"
+ assert(t.db.profile.alpha == "charlie")
+ t:SetProfile("Default")
+ assert(t:GetProfile() == "Default")
+ assert(select(2, t:GetProfile()) == "Default")
+ assert(t.db.profile.alpha == "bravo")
+ t:CopyProfile("Alternative")
+ assert(t:GetProfile() == "Default")
+ assert(select(2, t:GetProfile()) == "Default")
+ assert(t.db.profile.alpha == "charlie")
+
+ _G[MAJOR_VERSION .. "_UnitTestDB"] = nil
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- resetting database
+ local t = { name = MAJOR_VERSION .. "_UnitTest" }
+
+ RockDB:Embed(t)
+ assert(t.db)
+
+ t:SetDatabase(MAJOR_VERSION .. "_UnitTestDB")
+ RockDB:InitializeDatabase(t)
+ assert(type(_G[MAJOR_VERSION .. "_UnitTestDB"]) == "table")
+
+ assert(t.db.char.alpha == nil)
+ t.db.char.alpha = "bravo"
+ assert(t.db.char.alpha == "bravo")
+ t:ResetDatabase()
+ assert(t.db.char.alpha == nil)
+ t.db.char.alpha = "bravo"
+ assert(t.db.char.alpha == "bravo")
+ t:ResetDatabase("char")
+ assert(t.db.char.alpha == nil)
+
+ local nsdb = t:GetDatabaseNamespace("MyModule")
+ assert(nsdb.char.alpha == nil)
+ nsdb.char.alpha = "bravo"
+ assert(nsdb.char.alpha == "bravo")
+ t:ResetDatabase()
+ assert(nsdb.char.alpha == nil)
+ nsdb.char.alpha = "bravo"
+ assert(nsdb.char.alpha == "bravo")
+ t:ResetDatabase("char")
+ assert(nsdb.char.alpha == nil)
+
+ t.db.char.alpha = "bravo"
+ nsdb.char.alpha = "bravo"
+ assert(t.db.char.alpha == "bravo")
+ assert(nsdb.char.alpha == "bravo")
+ t:ResetDatabase("char", "MyModule")
+ assert(t.db.char.alpha == "bravo")
+ assert(nsdb.char.alpha == nil)
+ nsdb.char.alpha = "bravo"
+ assert(nsdb.char.alpha == "bravo")
+ t:ResetDatabase(nil, "MyModule")
+ assert(t.db.char.alpha == "bravo")
+ assert(nsdb.char.alpha == nil)
+
+ _G[MAJOR_VERSION .. "_UnitTestDB"] = nil
+end)
diff --git a/FuBar/libs/LibRockDB-1.0/LibRockDB-1.0.toc b/FuBar/libs/LibRockDB-1.0/LibRockDB-1.0.toc
new file mode 100644
index 0000000..769839e
--- /dev/null
+++ b/FuBar/libs/LibRockDB-1.0/LibRockDB-1.0.toc
@@ -0,0 +1,17 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r241
+## X-Curse-Project-Name: LibRockDB-1.0
+## X-Curse-Project-ID: librockdb-1-0
+## X-Curse-Repository-ID: wow/librockdb-1-0/mainline
+
+## Title: Lib: RockDB-1.0
+## Notes: Database library
+## Author: ckknight
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-Donate: Paypal:ckknight AT gmail DOT com
+## X-eMail: ckknight AT gmail DOT com
+## X-License: LGPL v2.1
+## LoadOnDemand: 1
+
+lib.xml
diff --git a/FuBar/libs/LibRockDB-1.0/lib.xml b/FuBar/libs/LibRockDB-1.0/lib.xml
new file mode 100644
index 0000000..a27a6a4
--- /dev/null
+++ b/FuBar/libs/LibRockDB-1.0/lib.xml
@@ -0,0 +1,4 @@
+
+
+
\ No newline at end of file
diff --git a/FuBar/libs/LibRockEvent-1.0/LibRockEvent-1.0.lua b/FuBar/libs/LibRockEvent-1.0/LibRockEvent-1.0.lua
new file mode 100644
index 0000000..e4d6a03
--- /dev/null
+++ b/FuBar/libs/LibRockEvent-1.0/LibRockEvent-1.0.lua
@@ -0,0 +1,708 @@
+--[[
+Name: LibRockEvent-1.0
+Revision: $Rev: 236 $
+Developed by: ckknight (ckknight@gmail.com)
+Website: http://www.wowace.com/
+Description: Library to allow for event handling and inter-addon communication.
+Dependencies: LibRock-1.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "LibRockEvent-1.0"
+local MINOR_VERSION = tonumber(("$Revision: 236 $"):match("(%d+)")) + 90000
+
+if not Rock then error(MAJOR_VERSION .. " requires LibRock-1.0") end
+
+local RockEvent, oldLib = Rock:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
+if not RockEvent then
+ return
+end
+local _G = _G
+local Rock = _G.Rock
+local error = _G.error
+local type = _G.type
+local geterrorhandler = _G.geterrorhandler
+local pcall = _G.pcall
+local tostring = _G.tostring
+local pairs = _G.pairs
+local next = _G.next
+local ipairs = _G.ipairs
+local select = _G.select
+local setmetatable = _G.setmetatable
+
+local weakKey = {__mode = 'k'}
+
+-- the frame to receive Blizzard events from
+RockEvent.frame = oldLib and oldLib.frame or _G.CreateFrame("Frame")
+local frame = RockEvent.frame
+-- events[namespace][eventName][object] = { callback = methodOrFunction, bucketDelay = nil/bucketNumber, n = numArgs, [1] = arg1, [n] = argn }
+RockEvent.events = oldLib and oldLib.events or {}
+local events = RockEvent.events
+-- multiEvents[namespace][{eventName = true, otherEventName = true}][object] = { callback = methodOrFunction, bucketDelay = nil/bucketNumber, n = numArgs, [1] = arg1, [n] = argn }
+RockEvent.multiEvents = oldLib and oldLib.multiEvents or {}
+local multiEvents = RockEvent.multiEvents
+
+frame:UnregisterAllEvents()
+frame:RegisterAllEvents()
+frame:RegisterEvent("ADDON_LOADED") -- HACK! WHAT THE FUCK! I DONT KNOW HOW THE FUCK THIS WORKS BUT I FUCKING SWEAR IT FIXES A BUG FOR ME! I'M SERIOUSLY WHAT THE FUCKING OVER THIS! WHAT THE FUCK!
+for namespace,v in pairs(events) do
+ setmetatable(v, nil)
+ for eventName,u in pairs(v) do
+ setmetatable(u, weakKey)
+ end
+end
+
+local newList, del = Rock:GetRecyclingFunctions(MAJOR_VERSION, "newList", "del")
+
+local precondition, postcondition, argCheck = Rock:GetContractFunctions(MAJOR_VERSION, "precondition", "postcondition", "argCheck")
+
+local LibRockTimer
+function RockEvent:OnLibraryLoad(major, instance)
+ if major == "LibRockTimer-1.0" then
+ LibRockTimer = instance
+ LibRockTimer:Embed(self)
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * adds a listener for an event specified by the "namespace"/"eventName" pair.
+ * to register for a Blizzard event, specify namespace as "Blizzard"
+ * Along with the normal arguments passed into the callback, the "namespace" and "eventName" are passed in.
+ * Bucketed events can be handled by setting the bucketDelay argument to a number, which is the amount of time to bucket events by. Bucket events will take the first argument passed in and store it in a set. If the set is non-empty by the time the specified delay is up, the callback will be called, passing along the set.
+ * It is recommended to only use the multiple event system when using buckets.
+ * If you wish to listen to events triggered by AceEvent-2.0, specify the namespace "AceEvent-2.0". e.g. "AceEvent-2.0", "SharedMedia_Registered".
+Arguments:
+ string - the namespace, could be "Blizzard" or the name of a library or addon. Optional, default: "Blizzard"
+ string or table - the name of the event or a table containing a set of events.
+ [optional] string or function - the callback (method name or function) to call. Default: "eventName",
+ [optional] number - if a number is provided, the bucketing delay. Default: nil
+ tuple - a list of arguments to pass into the start of the callback.
+Example:
+ MyAddon.PLAYER_LOGIN = function(self, namespace, event)
+ -- do something here.
+ end
+ MyAddon:AddEventListener("PLAYER_LOGIN") -- same as :AddEventListener("Blizzard", "PLAYER_LOGIN")
+ MyAddon.ADDON_LOADED = function(self, value, namespace, event)
+ assert(value == 50)
+ end
+ MyAddon:AddEventListener("ADDON_LOADED", nil, nil, 50)
+ -- buckets:
+ MyAddon.SomeEvent = function(self, namespace, event, data)
+ end
+ MyAddon:AddEventListener("MyAddon", "SomeEvent", nil, 1) -- bucketing by every second.
+ MyAddon:DispatchEvent("SomeEvent", "alpha")
+ -- half second later
+ MyAddon:DispatchEvent("SomeEvent", "bravo")
+ -- once the second has passed, MyAddon:SomeEvent("MyAddon", "SomeEvent", { ["alpha"] = true, ["bravo"] = true }) will be called.
+ -- multiple events:
+ MyAddon.Handler = function(self, namespace, event)
+ -- will receive SomeEvent and SomeOtherEvent
+ end
+ MyAddon:AddEventListener("SomeNamespace", { SomeEvent = true, SomeOtherEvent = true}, "Handler")
+-----------------------------------------------------------------------------]]
+function RockEvent:AddEventListener(namespace, eventName, callback, bucketDelay, ...)
+ if not eventName or type(namespace) == "table" or (type(namespace) == "string" and namespace:match("^[A-Z_]+$")) then
+ if bucketDelay == nil and select('#', ...) == 0 then
+ return RockEvent.AddEventListener(self, "Blizzard", namespace, eventName, callback)
+ else
+ return RockEvent.AddEventListener(self, "Blizzard", namespace, eventName, callback, bucketDelay, ...)
+ end
+ end
+ local isMulti = type(eventName) == "table"
+ if not callback then
+ callback = eventName
+ end
+ local isBucket = type(bucketDelay) == "number"
+ if isBucket and not LibRockTimer then
+ -- logistics issue
+ error(("Cannot use a bucketed event with `AddEventListener' unless library %q is available."):format("LibRockTimer-1.0"), 2)
+ end
+ local events_namespace
+ if isMulti then
+ events_namespace = multiEvents[namespace]
+ if not events_namespace then
+ events_namespace = newList()
+ multiEvents[namespace] = events_namespace
+ end
+ else
+ events_namespace = events[namespace]
+ if not events_namespace then
+ events_namespace = newList()
+ events[namespace] = events_namespace
+ end
+ end
+
+ local events_namespace_eventName = events_namespace[eventName]
+ if not events_namespace_eventName then
+ events_namespace_eventName = setmetatable(newList(), weakKey)
+ events_namespace[eventName] = events_namespace_eventName
+ end
+
+ local events_namespace_eventName_self = events_namespace_eventName[self]
+ if events_namespace_eventName_self then
+ del(events_namespace_eventName_self)
+ end
+ events_namespace_eventName_self = newList()
+ events_namespace_eventName[self] = events_namespace_eventName_self
+ events_namespace_eventName_self.object = self
+ events_namespace_eventName_self.namespace = namespace
+ events_namespace_eventName_self.eventName = eventName
+ events_namespace_eventName_self.callback = callback
+ if isBucket then
+ events_namespace_eventName_self.bucketDelay = bucketDelay
+ end
+
+ local n = select('#', ...)
+ if n >= 1 then
+ for i = 1, n do
+ events_namespace_eventName_self[i] = select(i, ...)
+ end
+ events_namespace_eventName_self.n = n
+ end
+
+ if isBucket then
+ events_namespace_eventName_self.bucketID = Rock:GetUID()
+ end
+end
+precondition(RockEvent, 'AddEventListener', function(self, namespace, eventName, callback, bucketDelay, ...)
+ if not eventName or type(namespace) == "table" or (type(namespace) == "string" and namespace:match("^[A-Z_]+$")) then
+ -- cause it returns right away
+ return
+ end
+ argCheck(namespace, 2, "string")
+ argCheck(eventName, 3, "string", "table")
+ if type(eventName) == "table" then
+ for k,v in pairs(eventName) do
+ if type(k) ~= "string" then
+ error(("Bad argument #3 to `AddEventListener'. All keys must be %q, got %q"):format("string", type(k)), 3)
+ elseif v ~= true then
+ error(("Bad argument #3 to `AddEventListener'. All values must be true, got %q"):format(type(v)), 3)
+ end
+ end
+ argCheck(callback, 4, "string", "function")
+ else
+ argCheck(callback, 4, "string", "function", "nil")
+ end
+ if not callback then
+ callback = eventName
+ end
+ if type(callback) == "string" and type(self[callback]) ~= "function" then
+ error(("Bad argument #4 to `AddEventListener'. %q is not a %q, got %q."):format(callback, "function", type(self[callback])), 3)
+ end
+ argCheck(bucketDelay, 5, "number", "nil")
+end)
+postcondition(RockEvent, 'AddEventListener', function(ret, self, namespace, eventName, callback, bucketDelay, ...)
+ if not eventName or type(namespace) == "table" or (type(namespace) == "string" and namespace:match("^[A-Z_]+$")) then
+ -- cause it returns right away
+ return
+ end
+
+ assert(self:HasEventListener(namespace, eventName))
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * remove the event listener for the specified "namespace"/"eventName" pair.
+Arguments:
+ string - the namespace, could be "Blizzard" or the name of a library or addon. Optional, default: "Blizzard"
+ string - the name of the event.
+Returns:
+ boolean - whether the event actually was removed.
+Example:
+ MyAddon:RemoveEventListener("PLAYER_LOGIN") -- same as :RemoveEventListener("Blizzard", "PLAYER_LOGIN")
+-----------------------------------------------------------------------------]]
+function RockEvent:RemoveEventListener(namespace, eventName)
+ if not eventName then
+ return RockEvent.RemoveEventListener(self, "Blizzard", namespace)
+ end
+ if type(namespace) ~= "string" then
+ error(("Bad argument #2 to `RemoveEventListener'. Expected %q, got %q."):format("string", type(namespace)), 2)
+ end
+ local isMulti = type(eventName) == "table"
+
+ local ret = false
+
+ local ev = isMulti and multiEvents or events
+
+ local ev_namespace = ev[namespace]
+ if ev_namespace then
+ local ev_namespace_eventName = ev_namespace[eventName]
+ if ev_namespace_eventName then
+ ret = ev_namespace_eventName[self]
+ if ret then
+ local bucketID = ret.bucketID
+ if bucketID then
+ RockEvent:RemoveTimer(bucketID)
+ end
+ local bucket = ret.bucket
+ if bucket then
+ del(bucket)
+ end
+ ev_namespace_eventName[self] = del(ret)
+ end
+ if not next(ev_namespace_eventName) then
+ ev_namespace[eventName] = del(ev_namespace_eventName)
+ end
+ end
+ if not next(ev_namespace) then
+ ev[namespace] = del(ev_namespace)
+ end
+ end
+
+ return not not ret
+end
+precondition(RockEvent, 'RemoveEventListener', function(self, namespace, eventName)
+ if not eventName then
+ -- cause it returns right away
+ return
+ end
+ argCheck(namespace, 2, "string")
+ argCheck(eventName, 3, "table", "string")
+end)
+postcondition(RockEvent, 'RemoveEventListener', function(ret, self, namespace, eventName)
+ assert(not self:HasEventListener(namespace, eventName))
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * remove all event listener for the specified namespace or for all namespaces.
+Arguments:
+ [optional] string - the namespace, could be "Blizzard" or the name of a library or addon. Default: all namespaces
+Example:
+ MyAddon:RemoveAllEventListeners()
+-----------------------------------------------------------------------------]]
+function RockEvent:RemoveAllEventListeners(namespace)
+ if namespace and type(namespace) ~= "string" then
+ error(("Bad argument #2 to `RemoveAllEventListeners'. Expected %q or %q, got %q."):format("string", "nil", type(namespace)), 2)
+ end
+
+ local t = newList(events, multiEvents)
+ for _,ev in ipairs(t) do
+ if namespace then
+ local ev_namespace = ev[namespace]
+ if ev_namespace then
+ local tmp = newList()
+ for eventName in pairs(ev_namespace) do
+ tmp[eventName] = true
+ end
+ for eventName in pairs(tmp) do
+ RockEvent.RemoveEventListener(self, namespace, eventName)
+ end
+ tmp = del(tmp)
+ end
+ else
+ local tmp = newList()
+ for namespace, ev_namespace in pairs(ev) do
+ tmp[namespace] = ev_namespace
+ end
+ for namespace, ev_namespace in pairs(tmp) do
+ local tmp2 = newList()
+ for eventName in pairs(ev_namespace) do
+ tmp2[eventName] = true
+ end
+ for eventName in pairs(tmp2) do
+ RockEvent.RemoveEventListener(self, namespace, eventName)
+ end
+ tmp2 = del(tmp2)
+ end
+ tmp = del(tmp)
+ end
+ end
+ t = del(t)
+end
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ string - the namespace. Optional, default: "Blizzard"
+ string - the name of the event.
+Returns:
+ boolean or function or string - false if not registered, otherwise the callback that the event is registered to. ''Note: if this is called on LibRockEvent-1.0 itself, it will only return true/false.
+Example:
+ local has = MyAddon:HasEventListener("PLAYER_LOGIN") -- same as :HasEventListener("Blizzard", "PLAYER_LOGIN")
+ local has = MyAddon:HasEventListener("MyAddon", "Kersplosion")
+-----------------------------------------------------------------------------]]
+function RockEvent:HasEventListener(namespace, eventName)
+ if not eventName then
+ return RockEvent.HasEventListener(self, "Blizzard", namespace)
+ end
+ local isMulti = type(eventName) == "table"
+
+ local ev = isMulti and multiEvents or events
+
+ local ev_namespace = ev[namespace]
+ if not ev_namespace then
+ return false
+ end
+
+ local ev_namespace_event = ev_namespace[eventName]
+ if not ev_namespace_event then
+ return false
+ elseif self == RockEvent then
+ return true
+ end
+
+ return ev_namespace_event[self] or false
+end
+precondition(RockEvent, 'HasEventListener', function(self, namespace, eventName)
+ if not eventName then
+ -- cause it returns right away
+ return
+ end
+ argCheck(namespace, 2, "string")
+ argCheck(eventName, 3, "table", "string")
+end)
+
+local function unpackWithExtras(t, start, finish, ...)
+ if start <= finish then
+ return t[start], unpackWithExtras(t, start+1, finish, ...)
+ else
+ return ...
+ end
+end
+
+local function bucketHandler(data)
+ local bucket = data.bucket
+ if not bucket then
+ return
+ end
+
+ RockEvent.currentUID = Rock:GetUID()
+ local namespace = data.namespace
+ local eventName = data.eventName
+ local callback = data.callback
+ local args_num = data.n
+ local shouldRemove = false
+ if type(callback) == "string" then -- method
+ local object = data.object
+ local object_method = object[callback]
+ if not object_method then -- did a typecheck before, just double-check existence
+ local success, ret = pcall(error, ("Error calling method %q on object %q. Method does not exist."):format(callback, tostring(object)))
+ geterrorhandler()(ret)
+ shouldRemove = true
+ else
+ local success, ret
+ if not args_num then
+ success, ret = pcall(object_method, object, namespace, eventName, bucket)
+ else
+ success, ret = pcall(object_method, object, unpackWithExtras(data, 1, args_num, namespace, eventName, bucket))
+ end
+ if not success then
+ geterrorhandler()(ret)
+ shouldRemove = true
+ end
+ end
+ else -- function
+ local success, ret
+ if not args_num then
+ success, ret = pcall(callback, namespace, eventName, bucket)
+ else
+ success, ret = pcall(callback, unpackWithExtras(data, 1, args_num, namespace, eventName, bucket))
+ end
+ if not success then
+ geterrorhandler()(ret)
+ shouldRemove = true
+ end
+ end
+ RockEvent:RemoveTimer(data.bucketID)
+ data.bucket = del(bucket)
+ if shouldRemove then
+ RockEvent.RemoveEventListener(data.object, namespace, eventName)
+ end
+ RockEvent.currentUID = nil
+end
+
+local function dispatch(namespace, event, ...)
+ local events_namespace = events[namespace]
+ local multiEvents_namespace = multiEvents[namespace]
+ if events_namespace or multiEvents_namespace then
+ local events_namespace_event = events_namespace and events_namespace[event]
+ local multiEvents_namespace_withEvent = newList()
+ if multiEvents_namespace then
+ for eventSet, v in pairs(multiEvents_namespace) do
+ if eventSet[event] then
+ multiEvents_namespace_withEvent[eventSet] = v
+ end
+ end
+ end
+ if events_namespace_event or next(multiEvents_namespace_withEvent) then
+ -- events are stored in the temporary tables in case some bright spark decides to remove the events upon calling.
+ local tmp1 = newList()
+ local tmp2 = newList()
+ if events_namespace_event then
+ for object, data in pairs(events_namespace_event) do
+ tmp1[#tmp1+1] = object
+ tmp2[#tmp2+1] = data
+ end
+ end
+ for eventSet, v in pairs(multiEvents_namespace_withEvent) do
+ for object, data in pairs(v) do
+ tmp1[#tmp1+1] = object
+ tmp2[#tmp2+1] = data
+ end
+ end
+
+ local lastUID = RockEvent.currentUID
+ RockEvent.currentUID = Rock:GetUID()
+ for i = 1, #tmp1 do
+ local object, data = tmp1[i], tmp2[i]
+ if data.bucketID then
+ local bucket = data.bucket
+ if not bucket then
+ bucket = newList()
+ data.bucket = bucket
+ RockEvent:AddTimer(data.bucketID, data.bucketDelay, bucketHandler, data)
+ end
+ bucket[(...) or false] = true
+ else
+ local args_num = data.n
+ local callback = data.callback
+ if type(callback) == "string" then
+ local object_method = object[callback]
+ if not object_method then -- did a typecheck before, just double-check existence
+ local success, ret = pcall(error, ("Error calling method %q on object %q. Method does not exist."):format(callback, tostring(object)))
+ geterrorhandler()(ret)
+ shouldRemove = true
+ else
+ local success, ret
+ if not args_num then
+ success, ret = pcall(object_method, object, namespace, event, ...)
+ else
+ success, ret = pcall(object_method, object, unpackWithExtras(data, 1, args_num, namespace, event, ...))
+ end
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+ else -- function
+ local success, ret
+ if not args_num then
+ success, ret = pcall(callback, namespace, event, ...)
+ else
+ success, ret = pcall(callback, unpackWithExtras(data, 1, args_num, namespace, event, ...))
+ end
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+ end
+ end
+ RockEvent.currentUID = lastUID
+ tmp1 = del(tmp1)
+ tmp2 = del(tmp2)
+ end
+ multiEvents_namespace_withEvent = del(multiEvents_namespace_withEvent)
+ end
+end
+--[[---------------------------------------------------------------------------
+Notes:
+ * dispatch an event, causing all addons which have registered for the event to have their callbacks called.
+ * events should be in the form of PascalCase. Only Blizzard's events should be in CONSTANT_CASE
+ * events are passed with the namespace as specified by object.name
+Arguments:
+ string - the name of the event.
+ tuple - list of arguments to pass.
+Example:
+ MyAddon:DispatchEvent("Kersplosion") -- dispatches "MyAddon","Kersplosion"
+-----------------------------------------------------------------------------]]
+function RockEvent:DispatchEvent(eventName, ...)
+ return dispatch(self.name, eventName, ...)
+end
+precondition(RockEvent, 'DispatchEvent', function(self, eventName, ...)
+ argCheck(eventName, 2, "string")
+ local namespace = self.name
+ if type(namespace) ~= "string" then
+ error(("Cannot call `DispatchEvent' without .name being a %q, got %q"):format("string", type(namespace)), 3)
+ end
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * dispatches an event with the specified namespace, causing all addons which have registered for the event to have their callbacks called.
+ * events should be in the form of PascalCase. Only Blizzard's events should be in CONSTANT_CASE
+ * events are passed with the namespace as specified by object.name
+ * this is for special cases only, e.g. debugging. It is highly recommended that ''':DispatchEvent''' is used instead.
+Arguments:
+ string - the namespace.
+ string - the name of the event.
+ tuple - list of arguments to pass.
+Example:
+ Rock("LibRockEvent-1.0"):DispatchNamespaceEvent("MyAddon", "Kersplosion") -- dispatches "MyAddon","Kersplosion"
+-----------------------------------------------------------------------------]]
+function RockEvent:DispatchNamespaceEvent(namespace, eventName, ...)
+ return dispatch(namespace, eventName, ...)
+end
+precondition(RockEvent, 'DispatchNamespaceEvent', function(self, namespace, eventName, ...)
+ argCheck(namespace, 2, "string")
+ argCheck(eventName, 3, "string")
+end)
+
+local AceEvent20
+
+local function SetupAceEvents()
+ if not AceEvent20 then
+ local AceLibrary = _G.AceLibrary
+ if AceLibrary and AceLibrary:HasInstance("AceEvent-2.0", false) then
+ AceEvent20 = AceLibrary("AceEvent-2.0")
+ function RockEvent:OnAceEvent(...)
+ local event = AceEvent20.currentEvent
+ if event:match("^[A-Z_]+$") then
+ return
+ end
+ dispatch("AceEvent-2.0", event, ...)
+ end
+ AceEvent20.RegisterAllEvents(RockEvent, "OnAceEvent")
+ end
+ end
+end
+
+frame:SetScript("OnEvent", function(this, event, ...)
+ if event == "ADDON_LOADED" then
+ SetupAceEvents()
+ end
+ return dispatch("Blizzard", event, ...)
+end)
+
+function RockEvent:OnUnembed(object)
+ self.RemoveAllEventListeners(object)
+end
+
+function RockEvent:OnEmbedDisable(object)
+ self.RemoveAllEventListeners(object)
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * The event "LibEvent-1.0","FullyInitialized" will be dispatched when the UI has fully initialized.
+ * Fully initialized means that it is post-PLAYER_LOGIN and all chat channels have been properly joined, which has no corresponding Blizzard event.
+Returns:
+ boolean - whether the UI has fully initialized
+Example:
+ local init = Rock("LibRockEvent-1.0"):IsFullyInitialized()
+-----------------------------------------------------------------------------]]
+function RockEvent:IsFullyInitialized()
+ return self.postInit
+end
+
+RockEvent.postInit = oldLib and oldLib.postInit or false
+if not RockEvent.postInit then
+ local frame = CreateFrame("Frame")
+ local function PLAYER_LOGIN()
+ PLAYER_LOGIN = nil
+
+ local nextTime = GetTime() + 10
+ frame:SetScript("OnUpdate", function(this, elapsed)
+ if GetTime() >= nextTime then
+ local major, minor = RockEvent:GetLibraryVersion()
+ if minor == MINOR_VERSION or minor == -MINOR_VERSION then -- HACK, remove the negative thing
+ -- make sure we've not upgraded
+ SetupAceEvents() -- Workaround for broken OptionalDeps
+ RockEvent.postInit = true
+ dispatch(MAJOR_VERSION, "FullyInitialized")
+ end
+ frame:UnregisterAllEvents()
+ frame:SetScript("OnEvent", nil)
+ frame:SetScript("OnUpdate", nil)
+ frame:Hide()
+ end
+ end)
+ local playerAlive = true
+ frame:SetScript("OnEvent", function(this, event)
+ if event == "PLAYER_ALIVE" then
+ nextTime = GetTime() + 1
+ playerAlive = false
+ this:UnregisterEvent("PLAYER_ALIVE")
+ elseif event == "CHAT_MSG_CHANNEL_NOTICE" then
+ nextTime = GetTime() + 0.15
+ elseif event == "LANGUAGE_LIST_CHANGED" then
+ if playerAlive then
+ playerAlive = false
+ this:UnregisterEvent("PLAYER_ALIVE")
+ this:RegisterEvent("MINIMAP_ZONE_CHANGED")
+ end
+ elseif event == "MINIMAP_ZONE_CHANGED" then
+ nextTime = GetTime() + 1
+ this:UnregisterEvent("MINIMAP_ZONE_CHANGED")
+ end
+ end)
+ frame:RegisterEvent("PLAYER_ALIVE")
+ frame:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE")
+ frame:RegisterEvent("LANGUAGE_LIST_CHANGED")
+ end
+
+ if IsLoggedIn() then
+ PLAYER_LOGIN()
+ else
+ frame:RegisterEvent("PLAYER_LOGIN")
+ frame:SetScript("OnEvent", PLAYER_LOGIN)
+ end
+end
+
+RockEvent:SetExportedMethods("AddEventListener", "RemoveEventListener", "RemoveAllEventListeners", "DispatchEvent", "HasEventListener")
+
+Rock:FinalizeLibrary(MAJOR_VERSION)
+
+Rock("LibRockTimer-1.0", false, true) -- load if possible
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ local t = {name = "RockEventUnitTest"}
+ RockEvent:Embed(t)
+ local triggered = false
+ function t:Alpha(ns, event, ...)
+ triggered = true
+ assert(ns == "RockEventUnitTest")
+ assert(event == "Alpha")
+ assert((...) == "Blah")
+ end
+ t:AddEventListener("RockEventUnitTest", "Alpha")
+ assert(t:HasEventListener("RockEventUnitTest", "Alpha"))
+ t:DispatchEvent("Alpha", "Blah")
+ assert(triggered)
+ triggered = false
+ RockEvent:DispatchNamespaceEvent("RockEventUnitTest", "Alpha", "Blah")
+ assert(triggered)
+ triggered = false
+ t:RemoveEventListener("RockEventUnitTest", "Alpha")
+ assert(not t:HasEventListener("RockEventUnitTest", "Alpha"))
+ RockEvent:DispatchNamespaceEvent("RockEventUnitTest", "Alpha", "Blah")
+ assert(not triggered)
+ t:AddEventListener("RockEventUnitTest", "Alpha")
+ assert(t:HasEventListener("RockEventUnitTest", "Alpha"))
+ RockEvent:DispatchNamespaceEvent("RockEventUnitTest", "Alpha", "Blah")
+ assert(triggered)
+ triggered = false
+ t:RemoveAllEventListeners()
+ assert(not t:HasEventListener("RockEventUnitTest", "Alpha"))
+ RockEvent:DispatchNamespaceEvent("RockEventUnitTest", "Alpha", "Blah")
+ assert(not triggered)
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ local t = {name = "RockEventUnitTest"}
+ RockEvent:Embed(t)
+ local triggered = false
+ function t:FAKE_BLIZZARD_EVENT(ns, event, ...)
+ triggered = true
+ assert(ns == "Blizzard")
+ assert(event == "FAKE_BLIZZARD_EVENT")
+ assert((...) == "Blah")
+ end
+ t:AddEventListener("FAKE_BLIZZARD_EVENT")
+ assert(t:HasEventListener("FAKE_BLIZZARD_EVENT"))
+ RockEvent:DispatchNamespaceEvent("Blizzard", "FAKE_BLIZZARD_EVENT", "Blah")
+ assert(triggered)
+ triggered = false
+ t:RemoveEventListener("FAKE_BLIZZARD_EVENT")
+ assert(not t:HasEventListener("FAKE_BLIZZARD_EVENT"))
+ RockEvent:DispatchNamespaceEvent("Blizzard", "FAKE_BLIZZARD_EVENT", "Blah")
+ assert(not triggered)
+ t:AddEventListener("FAKE_BLIZZARD_EVENT")
+ assert(t:HasEventListener("FAKE_BLIZZARD_EVENT"))
+ RockEvent:DispatchNamespaceEvent("Blizzard", "FAKE_BLIZZARD_EVENT", "Blah")
+ assert(triggered)
+ triggered = false
+ t:RemoveAllEventListeners()
+ assert(not t:HasEventListener("FAKE_BLIZZARD_EVENT"))
+ RockEvent:DispatchNamespaceEvent("Blizzard", "FAKE_BLIZZARD_EVENT", "Blah")
+ assert(not triggered)
+end)
diff --git a/FuBar/libs/LibRockEvent-1.0/LibRockEvent-1.0.toc b/FuBar/libs/LibRockEvent-1.0/LibRockEvent-1.0.toc
new file mode 100644
index 0000000..1a5a543
--- /dev/null
+++ b/FuBar/libs/LibRockEvent-1.0/LibRockEvent-1.0.toc
@@ -0,0 +1,17 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r236
+## X-Curse-Project-Name: LibRockEvent-1.0
+## X-Curse-Project-ID: librockevent-1-0
+## X-Curse-Repository-ID: wow/librockevent-1-0/mainline
+
+## Title: Lib: RockEvent-1.0
+## Notes: Event library
+## Author: ckknight
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-Donate: Paypal:ckknight AT gmail DOT com
+## X-eMail: ckknight AT gmail DOT com
+## X-License: LGPL v2.1
+## LoadOnDemand: 1
+
+lib.xml
diff --git a/FuBar/libs/LibRockEvent-1.0/lib.xml b/FuBar/libs/LibRockEvent-1.0/lib.xml
new file mode 100644
index 0000000..212aeb6
--- /dev/null
+++ b/FuBar/libs/LibRockEvent-1.0/lib.xml
@@ -0,0 +1,4 @@
+
+
+
\ No newline at end of file
diff --git a/FuBar/libs/LibRockHook-1.0/LibRockHook-1.0.lua b/FuBar/libs/LibRockHook-1.0/LibRockHook-1.0.lua
new file mode 100644
index 0000000..9ac71db
--- /dev/null
+++ b/FuBar/libs/LibRockHook-1.0/LibRockHook-1.0.lua
@@ -0,0 +1,803 @@
+--[[
+Name: LibRockHook-1.0
+Revision: $Rev: 228 $
+Developed by: ckknight (ckknight@gmail.com)
+Website: http://www.wowace.com/
+Description: Library to allow for safe hooking of functions, methods, and scripts.
+Dependencies: LibRock-1.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "LibRockHook-1.0"
+local MINOR_VERSION = tonumber(("$Revision: 228 $"):match("(%d+)")) + 90000
+
+if not Rock then error(MAJOR_VERSION .. " requires LibRock-1.0") end
+
+local RockHook, oldLib = Rock:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
+if not RockHook then
+ return
+end
+-- #AUTODOC_NAMESPACE RockHook
+
+local _G = _G
+local Rock = _G.Rock
+local error = _G.error
+local type = _G.type
+local hooksecurefunc = _G.hooksecurefunc
+local pairs = _G.pairs
+local next = _G.next
+
+RockHook.registry = oldLib and oldLib.registry or {}
+local registry = RockHook.registry
+RockHook.actives = oldLib and oldLib.actives or {}
+local actives = RockHook.actives
+RockHook.handlers = oldLib and oldLib.handlers or {}
+local handlers = RockHook.handlers
+RockHook.scripts = oldLib and oldLib.scripts or {}
+local scripts = RockHook.scripts
+
+local newList, del = Rock:GetRecyclingFunctions(MAJOR_VERSION, "newList", "del")
+
+local precondition, postcondition, argCheck = Rock:GetContractFunctions(MAJOR_VERSION, "precondition", "postcondition", "argCheck")
+
+local function createFunctionHook(self, func, handler, orig, secure)
+ if not secure then
+ if type(handler) == "string" then
+ -- The handler is a method, need to self it
+ local uid
+ uid = function(...)
+ if actives[uid] and self[handler] then
+ return self[handler](self, ...)
+ else
+ return orig(...)
+ end
+ end
+ return uid
+ else
+ -- The handler is a function, just call it
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return handler(...)
+ else
+ return orig(...)
+ end
+ end
+ return uid
+ end
+ else
+ -- secure hooks don't call the original method
+ if type(handler) == "string" then
+ -- The handler is a method, need to self it
+ local uid
+ uid = function(...)
+ if actives[uid] and self[handler] then
+ return self[handler](self, ...)
+ end
+ end
+ return uid
+ else
+ -- The handler is a function, just call it
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return handler(...)
+ end
+ end
+ return uid
+ end
+ end
+end
+
+local function hookFunction(self, func, handler, secure)
+ local orig = _G[func]
+
+ if not handler then
+ handler = func
+ end
+
+ local registry_self = registry[self]
+ local uid = registry_self[func]
+ if uid then
+ if actives[uid] then
+ -- We have an active hook from this source. Don't multi-hook
+ error(("%q already has an active hook from this source."):format(func), 4)
+ end
+
+ if handlers[uid] == handler then
+ -- The hook is inactive, so reactivate it
+ actives[uid] = true
+ return
+ else
+ self.hooks[func] = nil
+ registry_self[func] = nil
+ handlers[uid] = nil
+ uid = nil
+ end
+ end
+
+ uid = createFunctionHook(self, func, handler, orig, secure)
+ registry_self[func] = uid
+ actives[uid] = true
+ handlers[uid] = handler
+
+ if not secure then
+ _G[func] = uid
+ self.hooks[func] = orig
+ else
+ hooksecurefunc(func, uid)
+ end
+end
+
+local function createMethodHook(self, object, method, handler, orig, secure)
+ if not secure then
+ if type(handler) == "string" then
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return self[handler](self, ...)
+ else
+ return orig(...)
+ end
+ end
+ return uid
+ else
+ -- The handler is a function, just call it
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return handler(...)
+ else
+ return orig(...)
+ end
+ end
+ return uid
+ end
+ else
+ -- secure hooks don't call the original method
+ if type(handler) == "string" then
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return self[handler](self, ...)
+ end
+ end
+ return uid
+ else
+ -- The handler is a function, just call it
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return handler(...)
+ end
+ end
+ return uid
+ end
+ end
+end
+
+local function unhookFunction(self, func)
+ local registry_self = registry[self]
+ local uid = registry_self[func]
+ if not uid then
+ error(("Tried to unhook %q which is not currently hooked."):format(func), 3)
+ end
+
+ if actives[uid] then
+ -- See if we own the global function
+ if self.hooks[func] and _G[func] == uid then
+ _G[func] = self.hooks[func]
+ self.hooks[func] = nil
+ registry_self[func] = nil
+ handlers[uid] = nil
+ actives[uid] = nil
+ -- Magically all-done
+ else
+ actives[uid] = nil
+ end
+ end
+end
+
+local noop = function() end
+
+local function hookMethod(self, obj, method, handler, script, secure)
+ if not handler then
+ handler = method
+ end
+
+ local registry_self = registry[self]
+ local registry_self_obj = registry_self[obj]
+ local uid = registry_self_obj and registry_self_obj[method]
+ local self_hooks = self.hooks
+ if uid then
+ if actives[uid] then
+ -- We have an active hook from this source. Don't multi-hook
+ error(("%q already has an active hook from this source."):format(method), 4)
+ end
+
+ if handlers[uid] == handler then
+ -- The hook is inactive, reactivate it.
+ actives[uid] = true
+ return
+ else
+ if self_hooks[obj] then
+ self_hooks[obj][method] = nil
+ end
+ registry_self_obj[method] = nil
+ handlers[uid] = nil
+ actives[uid] = nil
+ scripts[uid] = nil
+ uid = nil
+ end
+ end
+
+ local orig
+ if script then
+ orig = obj:GetScript(method)
+ if type(orig) ~= "function" then
+ -- Sometimes there is not a original function for a script.
+ orig = noop
+ end
+ else
+ orig = obj[method]
+ end
+
+ local self_hooks_obj = self_hooks[obj]
+ if not self_hooks_obj then
+ self_hooks_obj = newList()
+ self_hooks[obj] = self_hooks_obj
+ end
+ local registry_self_obj = registry_self[obj]
+ if not registry_self_obj then
+ registry_self_obj = newList()
+ registry_self[obj] = registry_self_obj
+ end
+
+ local uid = createMethodHook(self, obj, method, handler, orig, secure)
+ registry_self_obj[method] = uid
+ actives[uid] = true
+ handlers[uid] = handler
+ scripts[uid] = script or nil
+
+ if script then
+ if not secure then
+ obj:SetScript(method, uid)
+ self_hooks_obj[method] = orig
+ else
+ obj:HookScript(method, uid)
+ end
+ else
+ if not secure then
+ obj[method] = uid
+ self_hooks_obj[method] = orig
+ else
+ hooksecurefunc(obj, method, uid)
+ end
+ end
+end
+
+local function unhookMethod(self, obj, method)
+ local registry_self = registry[self]
+ local registry_self_obj = registry_self and registry_self[obj]
+ local uid = registry_self_obj and registry_self_obj[method]
+ if not uid then
+ error(("Attempt to unhook a method %q that is not currently hooked."):format(method), 3)
+ end
+
+ local self_hooks = self.hooks
+
+ if actives[uid] then
+ if scripts[uid] then -- If this is a script
+ if obj:GetScript(method) == uid then
+ -- We own the script. Revert to normal.
+ if self_hooks[obj][method] == noop then
+ obj:SetScript(method, nil)
+ else
+ obj:SetScript(method, self_hooks[obj][method])
+ end
+ self_hooks[obj][method] = nil
+ registry_self_obj[method] = nil
+ handlers[uid] = nil
+ scripts[uid] = nil
+ actives[uid] = nil
+ else
+ actives[uid] = nil
+ end
+ else
+ if self_hooks[obj] and self_hooks[obj][method] and obj[method] == uid then
+ -- We own the method. Revert to normal.
+ obj[method] = self_hooks[obj][method]
+ self_hooks[obj][method] = nil
+ registry_self_obj[method] = nil
+ handlers[uid] = nil
+ actives[uid] = nil
+ else
+ actives[uid] = nil
+ end
+ end
+ end
+ if self_hooks[obj] and not next(self_hooks[obj]) then
+ self_hooks[obj] = del(self_hooks[obj])
+ end
+ if not next(registry_self_obj) then
+ registry_self[obj] = del(registry_self_obj)
+ end
+end
+
+local function hook(self, object, method, handler, secure, script)
+ if not script and type(object) == "string" then
+ method, handler = object, method
+ hookFunction(self, method, handler, secure)
+ else
+ hookMethod(self, object, method, handler, script, secure)
+ end
+end
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * hooks a function or method, replacing it with your own function.
+ * this adds the original function to self.hooks[func] or self.hooks[object][method], which should be called in most cases.
+Arguments:
+ table - object the method lives on. Optional, default: _G
+ string - the name of the method/function.
+ [optional] string or function - the callback to call when the function is normally called.
+Example:
+ function Blah()
+ return "Alpha"
+ end
+ assert(Blah() == "Alpha")
+ MyAddon:AddHook("Blah", function(...)
+ return MyAddon.hooks.Blah(...) .. "Bravo"
+ end)
+ assert(Blah() == "AlphaBravo")
+ -- for methods:
+ MyAddon:AddHook(ChatFrame1, "AddMessage", function(object, text, ...)
+ -- add the date to all messages of the first ChatFrame.
+ return MyAddon.hooks[object].AddMessage(object, date("%Y-%m-%d") .. " " .. text, ...)
+ end)
+-----------------------------------------------------------------------------]]
+function RockHook:AddHook(object, method, callback)
+ return hook(self, object, method, callback, false, false)
+end
+precondition(RockHook, 'AddHook', function(self, object, method, callback)
+ argCheck(object, 2, "table", "string")
+ if type(object) == "table" then
+ argCheck(method, 3, "string")
+ if type(object[method]) ~= "function" then
+ error(("Bad argument #3 to `AddHook'. %q is not a %q, got %q."):format(method, "function", type(object[method])), 3)
+ end
+ argCheck(callback, 4, "string", "function", "nil")
+ if not callback then
+ callback = method
+ end
+ else
+ if type(_G[object]) ~= "function" then
+ error(("Bad argument #2 to `AddHook'. %q is not a %q, got %q."):format(object, "function", type(_G[object])), 3)
+ end
+ argCheck(method, 3, "string", "function", "nil")
+ callback = method
+ if not callback then
+ callback = object
+ end
+ end
+ if type(callback) == "string" and type(self[callback]) ~= "function" then
+ error(("Bad argument #%d to `AddHook'. %q is not a %q, got %q."):format(type(object) == "table" and 4 or 3, callback, "function", type(self[callback])), 3)
+ end
+end)
+postcondition(RockHook, 'AddHook', function(ret, self, object, method, callback)
+ if type(object) == "table" then
+ assert(self:HasHook(object, method))
+ else
+ assert(self:HasHook(object))
+ end
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * hooks a function or method, having your callback called after the original function
+ * This is primarily used for hooking secure functions and maintaining the secure state.
+Arguments:
+ table - object the method lives on. Optional, default: _G
+ string - the name of the method/function.
+ [optional] string or function - the callback to call when the function is normally called.
+Example:
+ function Blah()
+ return "Alpha"
+ end
+ assert(Blah() == "Alpha")
+ MyAddon:AddSecureHook("Blah", function()
+ -- do something here
+ end)
+ assert(Blah() == "Alpha") -- still returns the old value, but your hook was called.
+-----------------------------------------------------------------------------]]
+function RockHook:AddSecureHook(object, method, callback)
+ return hook(self, object, method, callback, true, false)
+end
+precondition(RockHook, 'AddSecureHook', function(self, object, method, callback)
+ argCheck(object, 2, "table", "string")
+ if type(object) == "table" then
+ argCheck(method, 3, "string")
+ if type(object[method]) ~= "function" then
+ error(("Bad argument #3 to `AddSecureHook'. %q is not a %q, got %q."):format(method, "function", type(object[method])), 3)
+ end
+ argCheck(callback, 4, "string", "function", "nil")
+ if not callback then
+ callback = method
+ end
+ else
+ if type(_G[object]) ~= "function" then
+ error(("Bad argument #2 to `AddSecureHook'. %q is not a %q, got %q."):format(object, "function", type(_G[object])), 3)
+ end
+ argCheck(method, 3, "string", "function", "nil")
+ callback = method
+ if not callback then
+ callback = object
+ end
+ end
+ if type(callback) == "string" and type(self[callback]) ~= "function" then
+ error(("Bad argument #%d to `AddSecureHook'. %q is not a %q, got %q."):format(type(object) == "table" and 4 or 3, callback, "function", type(self[callback])), 3)
+ end
+end)
+postcondition(RockHook, 'AddSecureHook', function(ret, self, object, method, callback)
+ if type(object) == "table" then
+ assert(self:HasHook(object, method))
+ else
+ assert(self:HasHook(object))
+ end
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * hooks a frame's script, replacing it with your own function.
+ * this adds the original function to self.hooks[frame][script], which should be called in most cases.
+Arguments:
+ Frame - frame the script lives on.
+ string - the name of the script.
+ [optional] string or function - the callback to call when the function is normally called.
+Example:
+ MyAddon:AddScriptHook(frame, "OnMouseDown", function(object, ...)
+ -- do something
+ return RockTest.hooks[object].OnMouseDown(...)
+ end)
+-----------------------------------------------------------------------------]]
+function RockHook:AddScriptHook(frame, script, callback)
+ return hook(self, frame, script, callback, false, true)
+end
+precondition(RockHook, 'AddScriptHook', function(self, frame, script, callback)
+ argCheck(frame, 2, "table")
+ if type(rawget(frame, 0)) ~= "userdata" then
+ error("Bad argument #2 to `AddScriptHook'. Expected Frame.", 3)
+ end
+ argCheck(script, 3, "string")
+ if not frame:HasScript(script) then
+ error(("Bad argument #3 to `AddScriptHook'. %q is not a script."):format(script), 3)
+ end
+ argCheck(callback, 4, "string", "function", "nil")
+ if not callback then
+ callback = script
+ end
+ if type(callback) == "string" and type(self[callback]) ~= "function" then
+ error(("Bad argument #%d to `AddScriptHook'. %q is not a %q, got %q."):format(4, callback, "function", type(self[callback])), 3)
+ end
+end)
+postcondition(RockHook, 'AddScriptHook', function(ret, self, frame, script, callback)
+ assert(self:HasHook(frame, script))
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * hooks a frame's script, having your callback called after the original function
+ * This is primarily used for hooking secure scripts and maintaining the secure state.
+Arguments:
+ Frame - frame the script lives on.
+ string - the name of the script.
+ [optional] string or function - the callback to call when the function is normally called.
+Example:
+ MyAddon:AddSecureScriptHook(frame, "OnMouseDown", function(object, ...)
+ -- do something
+ end)
+-----------------------------------------------------------------------------]]
+function RockHook:AddSecureScriptHook(frame, script, callback)
+ return hook(self, frame, script, callback, true, true)
+end
+precondition(RockHook, 'AddSecureScriptHook', function(self, frame, script, callback)
+ argCheck(frame, 2, "table")
+ if type(rawget(frame, 0)) ~= "userdata" then
+ error("Bad argument #2 to `AddSecureScriptHook'. Expected Frame.", 3)
+ end
+ argCheck(script, 3, "string")
+ if not frame:HasScript(script) then
+ error(("Bad argument #3 to `AddSecureScriptHook'. %q is not a script."):format(script), 3)
+ end
+ argCheck(callback, 4, "string", "function", "nil")
+ if not callback then
+ callback = script
+ end
+ if type(callback) == "string" and type(self[callback]) ~= "function" then
+ error(("Bad argument #%d to `AddSecureScriptHook'. %q is not a %q, got %q."):format(4, callback, "function", type(self[callback])), 3)
+ end
+end)
+postcondition(RockHook, 'AddSecureScriptHook', function(ret, self, frame, script, callback)
+ assert(self:HasHook(frame, script))
+end)
+
+--[[---------------------------------------------------------------------------
+Arguments:
+ table or Frame - table the method lives on or frame the script lives on. Optional, default: _G.
+ string - the name of the function, script, or method.
+Returns:
+ false or function or string - false if not hooked, or function/string for the callback.
+Example:
+ local hook = MyAddon:HasHook(frame, "OnMouseDown")
+-----------------------------------------------------------------------------]]
+function RockHook:HasHook(object, method)
+ if type(object) == "string" then
+ if registry[self][object] and actives[registry[self][object]] then
+ return handlers[registry[self][object]]
+ end
+ else
+ if registry[self][object] and registry[self][object][method] and actives[registry[self][object][method]] then
+ return handlers[registry[self][object][method]]
+ end
+ end
+
+ return false
+end
+precondition(RockHook, 'HasHook', function(self, object, method)
+ argCheck(object, 2, "string", "table")
+ if type(object) == "table" then
+ argCheck(method, 3, "string")
+ end
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Unhooks a hooked function, script, or method
+Arguments:
+ table or Frame - table the method lives on or frame the script lives on. Optional, default: _G.
+ string - the name of the function, script, or method.
+Example:
+ MyAddon:RemoveHook("SomeGlobalFunction")
+ MyAddon:RemoveHook(frame, "OnMouseDown")
+-----------------------------------------------------------------------------]]
+function RockHook:RemoveHook(object, method)
+ if type(object) == "string" then
+ unhookFunction(self, object)
+ else
+ unhookMethod(self, object, method)
+ end
+end
+precondition(RockHook, 'RemoveHook', function(self, object, method)
+ argCheck(object, 2, "string", "table")
+ if type(object) == "table" then
+ argCheck(method, 3, "string")
+ end
+end)
+postcondition(RockHook, 'RemoveHook', function(ret, self, object, method)
+ if type(object) == "string" then
+ assert(not self:HasHook(object))
+ else
+ assert(not self:HasHook(object, method))
+ end
+end)
+
+--[[---------------------------------------------------------------------------
+Notes:
+ * Unhooks all hooked functions, scripts, and methods.
+Example:
+ MyAddon:RemoveAllHooks()
+-----------------------------------------------------------------------------]]
+function RockHook:RemoveAllHooks()
+ local registry_self = registry[self]
+ if type(registry_self) ~= "table" then
+ return
+ end
+ local tmp = newList()
+ for key, value in pairs(registry_self) do
+ tmp[key] = value
+ end
+ for key, value in pairs(tmp) do
+ if type(value) == "table" then
+ local tmp2 = newList()
+ for method in pairs(value) do
+ tmp2[method] = true
+ end
+ for method in pairs(tmp2) do
+ RockHook.RemoveHook(self, key, method)
+ end
+ tmp2 = del(tmp2)
+ else
+ RockHook.RemoveHook(self, key)
+ end
+ end
+ tmp = del(tmp)
+end
+
+function RockHook:OnEmbed(object)
+ object.hooks = newList()
+ registry[object] = newList()
+end
+
+function RockHook:OnUnembed(object)
+ self.RemoveAllHooks(object)
+ object.hooks = del(object.hooks)
+ registry[object] = del(registry[object])
+end
+
+function RockHook:OnEmbedDisable(object)
+ self.RemoveAllHooks(object)
+end
+
+RockHook:SetExportedMethods("AddHook", "AddSecureHook", "AddScriptHook", "AddSecureScriptHook", "HasHook", "RemoveHook", "RemoveAllHooks")
+
+Rock:FinalizeLibrary(MAJOR_VERSION)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- chat commands
+ local t = { name = "RockHookUnitTest" }
+
+ RockHook:Embed(t)
+
+ function t:SomeMethod(obj, ...)
+ return ...
+ end
+ local triggered = false
+ function t:SomeOtherMethod(obj)
+ triggered = true
+ end
+
+ local object = {}
+ function object:SomeMethod()
+ return "Alpha"
+ end
+ function object:SomeOtherMethod()
+ return "Charlie"
+ end
+
+ assert(not t:HasHook(object, "SomeMethod"))
+ assert(object:SomeMethod() == "Alpha")
+
+ t:AddHook(object, "SomeMethod")
+ assert(t:HasHook(object, "SomeMethod"))
+ assert(object:SomeMethod("Bravo") == "Bravo")
+ t:RemoveHook(object, "SomeMethod")
+ assert(not t:HasHook(object, "SomeMethod"))
+ assert(object:SomeMethod() == "Alpha")
+
+ t:AddHook(object, "SomeMethod")
+ assert(t:HasHook(object, "SomeMethod"))
+ assert(object:SomeMethod("Bravo") == "Bravo")
+ t:RemoveAllHooks()
+ assert(not t:HasHook(object, "SomeMethod"))
+ assert(object:SomeMethod() == "Alpha")
+
+ assert(not t:HasHook(object, "SomeOtherMethod"))
+ assert(object:SomeOtherMethod() == "Charlie")
+
+ t:AddSecureHook(object, "SomeOtherMethod")
+ assert(t:HasHook(object, "SomeOtherMethod"))
+ assert(not triggered)
+ assert(object:SomeOtherMethod() == "Charlie")
+ assert(triggered)
+ triggered = false
+ t:RemoveHook(object, "SomeOtherMethod")
+ assert(not t:HasHook(object, "SomeOtherMethod"))
+ assert(object:SomeOtherMethod() == "Charlie")
+ assert(not triggered)
+
+ t:AddSecureHook(object, "SomeOtherMethod")
+ assert(t:HasHook(object, "SomeOtherMethod"))
+ assert(not triggered)
+ assert(object:SomeOtherMethod() == "Charlie")
+ assert(triggered)
+ triggered = false
+ t:RemoveAllHooks()
+ assert(not t:HasHook(object, "SomeOtherMethod"))
+ assert(object:SomeOtherMethod() == "Charlie")
+ assert(not triggered)
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ -- chat commands
+ local t = { name = "RockHookUnitTest" }
+
+ RockHook:Embed(t)
+
+ local triggered = false
+ function t:OnShow(obj)
+ triggered = true
+ end
+
+ local frame = CreateFrame("Frame")
+ frame:Hide()
+ local normalTriggered = false
+ frame:SetScript("OnShow", function(this)
+ normalTriggered = true
+ end)
+
+ assert(not t:HasHook(frame, "OnShow"))
+ frame:Show()
+ assert(normalTriggered)
+ normalTriggered = false
+ assert(not triggered)
+ frame:Hide()
+
+ t:AddScriptHook(frame, "OnShow")
+ assert(t:HasHook(frame, "OnShow"))
+ frame:Show()
+ assert(not normalTriggered)
+ assert(triggered)
+ triggered = false
+ frame:Hide()
+ t:RemoveHook(frame, "OnShow")
+ assert(not t:HasHook(frame, "OnShow"))
+ frame:Show()
+ assert(normalTriggered)
+ normalTriggered = false
+ assert(not triggered)
+ frame:Hide()
+
+ t:AddScriptHook(frame, "OnShow")
+ assert(t:HasHook(frame, "OnShow"))
+ frame:Show()
+ assert(not normalTriggered)
+ assert(triggered)
+ triggered = false
+ frame:Hide()
+ t:RemoveAllHooks()
+ assert(not t:HasHook(frame, "OnShow"))
+ frame:Show()
+ assert(normalTriggered)
+ normalTriggered = false
+ assert(not triggered)
+ frame:Hide()
+ frame:Show()
+ local triggered = false
+ function t:OnHide(obj)
+ triggered = true
+ end
+
+ local normalTriggered = false
+ frame:SetScript("OnHide", function()
+ normalTriggered = true
+ end)
+
+ assert(not t:HasHook(frame, "OnHide"))
+ frame:Hide()
+ assert(normalTriggered)
+ normalTriggered = false
+ assert(not triggered)
+ frame:Show()
+
+ t:AddSecureScriptHook(frame, "OnHide")
+ assert(t:HasHook(frame, "OnHide"))
+ frame:Hide()
+ assert(normalTriggered)
+ normalTriggered = false
+ assert(triggered)
+ triggered = false
+ frame:Show()
+ t:RemoveHook(frame, "OnHide")
+ assert(not t:HasHook(frame, "OnHide"))
+ frame:Hide()
+ assert(normalTriggered)
+ normalTriggered = false
+ assert(not triggered)
+ frame:Show()
+
+ t:AddSecureScriptHook(frame, "OnHide")
+ assert(t:HasHook(frame, "OnHide"))
+ frame:Hide()
+ assert(normalTriggered)
+ normalTriggered = false
+ assert(triggered)
+ triggered = false
+ frame:Show()
+ t:RemoveAllHooks()
+ assert(not t:HasHook(frame, "OnHide"))
+ frame:Hide()
+ assert(normalTriggered)
+ normalTriggered = false
+ assert(not triggered)
+end)
+
diff --git a/FuBar/libs/LibRockHook-1.0/LibRockHook-1.0.toc b/FuBar/libs/LibRockHook-1.0/LibRockHook-1.0.toc
new file mode 100644
index 0000000..ecd29ae
--- /dev/null
+++ b/FuBar/libs/LibRockHook-1.0/LibRockHook-1.0.toc
@@ -0,0 +1,17 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r229
+## X-Curse-Project-Name: LibRockHook-1.0
+## X-Curse-Project-ID: librockhook-1-0
+## X-Curse-Repository-ID: wow/librockhook-1-0/mainline
+
+## Title: Lib: RockHook-1.0
+## Notes: Hooking library
+## Author: ckknight
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-Donate: Paypal:ckknight AT gmail DOT com
+## X-eMail: ckknight AT gmail DOT com
+## X-License: LGPL v2.1
+## LoadOnDemand: 1
+
+lib.xml
diff --git a/FuBar/libs/LibRockHook-1.0/lib.xml b/FuBar/libs/LibRockHook-1.0/lib.xml
new file mode 100644
index 0000000..9599c3b
--- /dev/null
+++ b/FuBar/libs/LibRockHook-1.0/lib.xml
@@ -0,0 +1,4 @@
+
+
+
\ No newline at end of file
diff --git a/FuBar/libs/LibRockLocale-1.0/LibRockLocale-1.0.lua b/FuBar/libs/LibRockLocale-1.0/LibRockLocale-1.0.lua
new file mode 100644
index 0000000..537f744
--- /dev/null
+++ b/FuBar/libs/LibRockLocale-1.0/LibRockLocale-1.0.lua
@@ -0,0 +1,612 @@
+--[[
+Name: LibRockLocale-1.0
+Revision: $Rev: 237 $
+Developed by: ckknight (ckknight@gmail.com)
+Website: http://www.wowace.com/
+Description: Localization library for addons to use to handle proper
+ localization and internationalization.
+Dependencies: LibRock-1.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "LibRockLocale-1.0"
+local MINOR_VERSION = tonumber(("$Revision: 237 $"):match("(%d+)")) + 90000
+
+if not Rock then error(MAJOR_VERSION .. " requires LibRock-1.0") end
+
+local RockLocale, oldLib = Rock:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
+if not RockLocale then
+ return
+end
+
+-- #AUTODOC_NAMESPACE prototype
+
+local _G = _G
+local Rock = _G.Rock
+local assert = _G.assert
+local GetLocale = _G.GetLocale
+local rawget = _G.rawget
+local rawset = _G.rawset
+local error = _G.error
+local type = _G.type
+local geterrorhandler = _G.geterrorhandler
+local pcall = _G.pcall
+local pairs = _G.pairs
+local setmetatable = _G.setmetatable
+local GetTime = _G.GetTime
+local next = _G.next
+
+RockLocale.namespaces = oldLib and oldLib.namespaces or {}
+local namespaces = RockLocale.namespaces
+RockLocale.namespaceData = setmetatable(oldLib and oldLib.namespaceData or {}, {__mode='k'})
+local namespaceData = RockLocale.namespaceData
+RockLocale.prototype = oldLib and oldLib.prototype or {}
+local prototype = RockLocale.prototype
+local prototype_mt = {}
+
+for k in pairs(prototype) do
+ for name, ns in pairs(namespaces) do
+ ns[k] = nil
+ end
+ prototype[k] = nil
+end
+
+local newList, del = Rock:GetRecyclingFunctions(MAJOR_VERSION, "newList", "del")
+
+local precondition, postcondition, argCheck = Rock:GetContractFunctions(MAJOR_VERSION, "precondition", "postcondition", "argCheck")
+
+local GAME_LOCALE = GetLocale()
+
+local namespacesToClear = setmetatable({}, {__mode='k'})
+for _,ns in pairs(namespaces) do
+ setmetatable(ns, nil)
+ namespacesToClear[ns] = true
+end
+local timeToNextClear = 0
+RockLocale.frame = oldLib and oldLib.frame or _G.CreateFrame("Frame")
+local frame = RockLocale.frame
+frame:Hide()
+frame:UnregisterAllEvents()
+frame:RegisterEvent("ADDON_LOADED")
+frame:RegisterEvent("PLAYER_LOGIN")
+local function scheduleClear(ns)
+ if ns ~= frame then
+ namespacesToClear[ns] = true
+ end
+ if next(namespacesToClear) then
+ timeToNextClear = GetTime() + 5
+ frame:Show()
+ end
+end
+frame:SetScript("OnEvent", scheduleClear)
+local function clearNamespace(ns)
+ local namespaceData_ns = namespaceData[ns]
+ local namespaceData_ns_currentTranslations = namespaceData_ns.currentTranslations
+ local namespaceData_ns_baseTranslations = namespaceData_ns.baseTranslations
+ for k, v in pairs(ns) do
+ if namespaceData_ns_currentTranslations and namespaceData_ns_currentTranslations[k] then
+ ns[k] = nil
+ elseif namespaceData_ns_baseTranslations and namespaceData_ns_baseTranslations[k] then
+ ns[k] = nil
+ end
+ end
+
+ if rawget(ns, 'reverse') then
+ ns.reverse = del(ns.reverse)
+ end
+
+ rawset(ns, true, true)
+ ns[true] = nil
+end
+frame:SetScript("OnUpdate", function(this, elapsed)
+ if GetTime() < timeToNextClear then
+ return
+ end
+ for ns in pairs(namespacesToClear) do
+ clearNamespace(ns)
+ namespacesToClear[ns] = nil
+ end
+ frame:Hide()
+end)
+
+--#FORCE_DOC
+--[[----------------------------------------------------------------------------------
+Notes:
+ * This is to be called on the LibRockLocale-1.0 library.
+Arguments:
+ string - the namespace to check
+Returns:
+ boolean - whether the namespace has been created or not
+Example:
+ local has = Rock("LibRockLocale-1.0"):HasTranslationNamespace("MyAddon")
+------------------------------------------------------------------------------------]]
+function RockLocale:HasTranslationNamespace(name)
+ return not not namespaces[name]
+end
+precondition(RockLocale, 'HasTranslationNamespace', function(self, name)
+ argCheck(name, 2, "string")
+end)
+
+--#FORCE_DOC
+--[[----------------------------------------------------------------------------------
+Notes:
+ * This is to be called on the LibRockLocale-1.0 library.
+ * This will create it if not existing already, or it will return what previously existed.
+Arguments:
+ string - the namespace to request
+ [optional] table - the table to populate. This is only if you're declaring a library.
+Returns:
+ table - The translation namespace.
+Example:
+ local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("MyAddon")
+------------------------------------------------------------------------------------]]
+function RockLocale:GetTranslationNamespace(name, tab)
+ local ns = namespaces[name]
+ if not tab then
+ if not ns then
+ ns = newList()
+ end
+ else
+ if ns and tab ~= namespaces[name] then
+ error(("Bad argument #3 to `GetTranslationNamespace'. Cannot provide a %q different from the namespace already registered."):format("table"), 2)
+ end
+ ns = tab
+ end
+ namespaces[name] = ns
+ local namespaceData_ns = namespaceData[ns]
+ if namespaceData_ns then
+ if not rawget(ns, 'AddTranslations') then
+ clearNamespace(ns)
+ namespaceData[ns] = del(namespaceData_ns)
+ namespaceData_ns = nil
+ else
+ return ns
+ end
+ end
+
+ namespaceData_ns = newList()
+ namespaceData[ns] = namespaceData_ns
+ namespaceData_ns.name = name
+
+ setmetatable(ns, nil)
+
+ for k, v in pairs(prototype) do
+ ns[k] = v
+ end
+ setmetatable(ns, prototype_mt)
+
+ scheduleClear(ns)
+
+ return ns
+end
+precondition(RockLocale, 'GetTranslationNamespace', function(self, name, tab)
+ argCheck(name, 2, "string")
+ argCheck(tab, 3, "table", "nil")
+end)
+postcondition(RockLocale, 'GetTranslationNamespace', function(ret, self, name, tab)
+ assert(self:HasTranslationNamespace(name))
+end)
+
+--#FORCE_DOC
+--[[----------------------------------------------------------------------------------
+Notes:
+ * This is to be called on a LibRockLocale-1.0 namespace.
+ * For the first (base) locale set you specify, the values can be true, which means "same as the key".
+Arguments:
+ string - the locale to specify, e.g. "enUS", "deDE", "frFR", "esES", "zhCN", "zhTW", or "koKR".
+ function - a function that will return a table. This will be called if the locale you specify is the proper one.
+Example:
+ local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("MyAddon")
+ L:AddTranslations("enUS", function() return {
+ ["Monkey"] = true, -- same as ["Monkey"] = "Monkey"
+ ["House"] = true, -- same as ["House"] = "House"
+ } end)
+ L:AddTranslations("deDE", function() return {
+ ["Monkey"] = "Affe",
+ -- not specifying House
+ } end)
+ -- assume we're deDE
+ assert(L["Monkey"] == "Affe") -- as we specified
+ assert(L["House"] == "House") -- fallback to the base locale (enUS)
+------------------------------------------------------------------------------------]]
+function prototype:AddTranslations(locale, func)
+ local namespaceData_self = namespaceData[self]
+
+ local namespaceData_self_baseLocale = namespaceData_self.baseLocale
+ if not namespaceData_self_baseLocale then
+ namespaceData_self_baseLocale = locale
+ namespaceData_self.baseLocale = namespaceData_self_baseLocale
+
+ local t = func()
+ func = nil
+ namespaceData_self.baseTranslations = t
+
+ for k,v in pairs(t) do
+ if v == true then
+ t[k] = k
+ end
+ end
+
+ if locale == GAME_LOCALE then
+ namespaceData_self.currentLocale = locale
+ namespaceData_self.currentTranslations = t
+ end
+ elseif locale == GAME_LOCALE then
+ if namespaceData_self_baseLocale == locale or locale == namespaceData_self.currentLocale then
+ error(("Bad argument #2 to `AddTranslations'. %q registered twice."):format(locale), 2)
+ end
+
+ namespaceData_self.currentLocale = locale
+
+ local t = func()
+ func = nil
+ namespaceData_self.currentTranslations = t
+ end
+end
+precondition(prototype, 'AddTranslations', function(self, locale, func)
+ argCheck(locale, 2, "string")
+ argCheck(func, 3, "function")
+end)
+
+--#FORCE_DOC
+--[[----------------------------------------------------------------------------------
+Notes:
+ * This is to be called on a LibRockLocale-1.0 namespace.
+ * This is to be called after adding translations.
+Arguments:
+ boolean - whether to be strict or not. false by default.
+Example:
+ local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("MyAddon")
+ L:AddTranslations("enUS", function() return {
+ ["Monkey"] = true, -- same as ["Monkey"] = "Monkey"
+ ["House"] = true, -- same as ["House"] = "House"
+ } end)
+ L:AddTranslations("deDE", function() return {
+ ["Monkey"] = "Affe",
+ -- not specifying House
+ } end)
+ L:SetStrictness(true)
+ -- assume we're deDE
+ assert(L["Monkey"] == "Affe") -- as we specified
+ local house = L["House"] -- pops an error, since we don't have the translation
+------------------------------------------------------------------------------------]]
+function prototype:SetStrictness(strict)
+ local namespaceData_self = namespaceData[self]
+ namespaceData_self.strict = strict
+
+ clearNamespace(self)
+end
+precondition(prototype, 'SetStrictness', function(self, strict)
+ argCheck(strict, 2, "boolean")
+end)
+
+--#FORCE_DOC
+--[[----------------------------------------------------------------------------------
+Notes:
+ * This is to be called on a LibRockLocale-1.0 namespace.
+ * This is to be called after adding translations.
+Arguments:
+ boolean - whether to be in debug mode or not. false by default.
+Example:
+ local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("MyAddon")
+ L:AddTranslations("enUS", function() return {
+ } end)
+ L:SetDebug(true)
+ -- assume we're enUS
+ assert(L["Monkey"] == "Monkey") -- no errors
+------------------------------------------------------------------------------------]]
+function prototype:SetDebug(debug)
+ local namespaceData_self = namespaceData[self]
+ namespaceData_self.debug = debug
+
+ clearNamespace(self)
+end
+precondition(prototype, 'SetDebug', function(self, debug)
+ argCheck(debug, 2, "boolean")
+end)
+
+--#FORCE_DOC
+--[[----------------------------------------------------------------------------------
+Notes:
+ * This is to be called on a LibRockLocale-1.0 namespace.
+ * This is to be called after adding translations.
+Arguments:
+ boolean or string - false if the translation doesn't exist, otherwise it returns the translation.
+Example:
+ local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("MyAddon")
+ L:AddTranslations("enUS", function() return {
+ ["Monkey"] = true, -- same as ["Monkey"] = "Monkey"
+ ["House"] = true, -- same as ["House"] = "House"
+ } end)
+ L:AddTranslations("deDE", function() return {
+ ["Monkey"] = "Affe",
+ -- not specifying House
+ } end)
+ -- assume we're deDE
+ assert(L:HasTranslation("Monkey") == "Affe") -- as we specified
+ assert(L["House"] == "House")
+ assert(not L:HasTranslation("House")) -- because not specified by the specific locale.
+------------------------------------------------------------------------------------]]
+function prototype:HasTranslation(key)
+ local namespaceData_self = namespaceData[self]
+ local namespaceData_self_currentTranslations = namespaceData_self.currentTranslations
+ if not namespaceData_self_currentTranslations then
+ return false
+ end
+
+ return namespaceData_self_currentTranslations[key]
+end
+
+--#FORCE_DOC
+--[[----------------------------------------------------------------------------------
+Notes:
+ * This is to be called on a LibRockLocale-1.0 namespace.
+ * This is to be called after adding translations.
+Arguments:
+ boolean - whether the translation exists on the base locale.
+Example:
+ local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("MyAddon")
+ L:AddTranslations("enUS", function() return {
+ ["Monkey"] = true, -- same as ["Monkey"] = "Monkey"
+ ["House"] = true, -- same as ["House"] = "House"
+ } end)
+ L:AddTranslations("deDE", function() return {
+ ["Monkey"] = "Affe",
+ -- not specifying House
+ } end)
+ -- assume we're deDE
+ assert(L:HasBaseTranslation("Monkey")) -- as we specified
+ assert(L["House"] == "House")
+ assert(L:HasBaseTranslation("House")) -- because it does exist, just not on the current locale.
+------------------------------------------------------------------------------------]]
+function prototype:HasBaseTranslation(key)
+ local namespaceData_self = namespaceData[self]
+ local namespaceData_self_baseTranslations = namespaceData_self.baseTranslations
+ if not namespaceData_self_baseTranslations then
+ return false
+ end
+ return not not namespaceData_self_baseTranslations[key]
+end
+
+local function initReverse(self)
+ local reverse = newList()
+ rawset(self, 'reverse', reverse)
+
+ local namespaceData_self = namespaceData[self]
+ local tmp = newList()
+ local namespaceData_self_baseTranslations = namespaceData_self.baseTranslations
+ if not namespaceData_self_baseTranslations then
+ return
+ end
+ if not namespaceData_self.strict then
+ for k,v in pairs(namespaceData_self_baseTranslations) do
+ tmp[k] = v
+ end
+ end
+ local namespaceData_self_currentTranslations = namespaceData_self.currentTranslations
+ if namespaceData_self_currentTranslations then
+ for k,v in pairs(namespaceData_self_currentTranslations) do
+ tmp[k] = v
+ end
+ end
+ for k,v in pairs(tmp) do
+ reverse[v] = k
+ end
+ tmp = del(tmp)
+end
+
+--#FORCE_DOC
+--[[----------------------------------------------------------------------------------
+Notes:
+ * This is to be accessed on a LibRockLocale-1.0 namespace.
+ * This is to be accessed after adding translations.
+ * This will error if the translation doesn't exist
+Arguments:
+ string - the translation key
+Returns:
+ string - the translated value
+Example:
+ local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("MyAddon")
+ L:AddTranslations("enUS", function() return {
+ ["Monkey"] = true, -- same as ["Monkey"] = "Monkey"
+ ["House"] = true, -- same as ["House"] = "House"
+ } end)
+ L:AddTranslations("deDE", function() return {
+ ["Monkey"] = "Affe",
+ -- not specifying House
+ } end)
+ -- assume we're deDE
+ assert(L["Monkey"] == "Affe") -- calling :__index("Monkey")
+ assert(L["House"] == "House") -- calling :__index("House")
+------------------------------------------------------------------------------------]]
+function prototype_mt:__index(key)
+ if key == "reverse" then
+ initReverse(self)
+ return self[key]
+ end
+
+ local namespaceData_self = namespaceData[self]
+ local namespaceData_self_currentTranslations = namespaceData_self.currentTranslations
+ if namespaceData_self_currentTranslations then
+ local value = namespaceData_self_currentTranslations[key]
+ if value then
+ rawset(self, key, value)
+ return value
+ end
+ end
+ if not namespaceData_self.strict then
+ local namespaceData_self_baseTranslations = namespaceData_self.baseTranslations
+ if namespaceData_self_baseTranslations then
+ local value = namespaceData_self_baseTranslations[key]
+ if value then
+ rawset(self, key, value)
+ return value
+ end
+ else
+ local _, ret = pcall(error, ("%s(%q): No translations registered"):format(MAJOR_VERSION, namespaceData_self.name), 3)
+ geterrorhandler()(ret)
+ rawset(self, key, key)
+ return key
+ end
+ end
+ if (type(key) == "string" and key:find("^On[A-Z]")) or key == 0 then
+ return nil
+ end
+ if not namespaceData_self.debug then
+ local _, ret
+ if namespaceData_self.strict then
+ _, ret = pcall(error, ("%s(%q): Translation %q does not exist for locale %s"):format(tostring(MAJOR_VERSION), tostring(namespaceData_self.name), tostring(key), tostring(namespaceData_self.currentLocale or namespaceData_self.baseLocale)), 3)
+ else
+ _, ret = pcall(error, ("%s(%q): Translation %q does not exist."):format(tostring(MAJOR_VERSION), tostring(namespaceData_self.name), tostring(key)), 3)
+ end
+ geterrorhandler()(ret)
+ end
+ rawset(self, key, key)
+ return key
+end
+
+function prototype_mt:__newindex(key, value)
+ if type(value) ~= "function" and (key ~= "name" or type(value) ~= "string") then
+ error(("Cannot change the values of a %q instance"):format(MAJOR_VERSION), 2)
+ end
+end
+
+--#FORCE_DOC
+--[[----------------------------------------------------------------------------------
+Notes:
+ * This is to be accessed on a LibRockLocale-1.0 namespace.
+ * This is to be accessed after adding translations.
+ * Unlike normal indexing, this will not error if a translation does not exist.
+ * This does follow the rules specified by :SetStrictness
+Example:
+ local L = Rock("LibRockLocale-1.0"):GetTranslationNamespace("MyAddon")
+ L:AddTranslations("enUS", function() return {
+ ["Monkey"] = true, -- same as ["Monkey"] = "Monkey"
+ ["House"] = true, -- same as ["House"] = "House"
+ } end)
+ L:AddTranslations("deDE", function() return {
+ ["Monkey"] = "Affe",
+ -- not specifying House
+ } end)
+ -- assume we're deDE
+ assert(L.reverse["Affe"] == "Monkey") -- because L["Monkey"] == "Affe"
+ assert(L.reverse["House"] == "House") -- because non-strict, L["House"] == "House", so the inverse is true
+ -- more generally:
+ assert(L.reverse[L[anything] ] == anything)
+ assert(L[L.reverse[anything] ] == anything)
+------------------------------------------------------------------------------------]]
+local function reverse() end; reverse = nil -- only for autodoc
+
+for name, ns in pairs(namespaces) do
+ for k, v in pairs(prototype) do
+ ns[k] = v
+ end
+ setmetatable(ns, prototype_mt)
+end
+
+Rock:FinalizeLibrary(MAJOR_VERSION)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ local base, other = GetLocale(), GetLocale() == "enUS" and "deDE" or "enUS"
+ assert(not RockLocale:HasTranslationNamespace(MAJOR_VERSION .. "UnitTest"))
+ local L = RockLocale:GetTranslationNamespace(MAJOR_VERSION .. "UnitTest")
+ assert(RockLocale:HasTranslationNamespace(MAJOR_VERSION .. "UnitTest"))
+ L:AddTranslations(base, function() return {
+ Monkey = true,
+ House = true,
+ } end)
+
+ L:AddTranslations(other, function() return {
+ Monkey = "Affe"
+ } end)
+
+ L = RockLocale:GetTranslationNamespace(MAJOR_VERSION .. "UnitTest")
+ assert(L:HasTranslation("Monkey") == "Monkey")
+ assert(L:HasTranslation("House") == "House")
+ assert(L:HasBaseTranslation("House"))
+ assert(not L:HasBaseTranslation("Louse"))
+ assert(L.Monkey == "Monkey")
+ assert(L.House == "House")
+ -- check for speed
+ assert(rawget(L, 'Monkey') == "Monkey")
+ assert(rawget(L, 'House') == "House")
+
+ assert(L.reverse.Monkey == "Monkey")
+ assert(L.reverse.House == "House")
+
+ clearNamespace(L)
+
+ assert(rawget(L, 'Monkey') == nil)
+ assert(rawget(L, 'House') == nil)
+ assert(L.Monkey == "Monkey")
+ assert(L.House == "House")
+ assert(rawget(L, 'Monkey') == "Monkey")
+ assert(rawget(L, 'House') == "House")
+
+ L = nil
+ assert(RockLocale:HasTranslationNamespace(MAJOR_VERSION .. "UnitTest"))
+ RockLocale.namespaces[MAJOR_VERSION .. "UnitTest"] = nil
+ collectgarbage('collect')
+ assert(not RockLocale:HasTranslationNamespace(MAJOR_VERSION .. "UnitTest"))
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ local base, other = GetLocale() == "enUS" and "deDE" or "enUS", GetLocale()
+ -- note, these tests only work properly if you're "enUS"
+ local L = RockLocale:GetTranslationNamespace(MAJOR_VERSION .. "UnitTest2")
+ L:AddTranslations(base, function() return {
+ Affe = true,
+ Haus = true,
+ } end)
+
+ L:AddTranslations(other, function() return {
+ Affe = "Monkey"
+ } end)
+
+ L = RockLocale:GetTranslationNamespace(MAJOR_VERSION .. "UnitTest2")
+ assert(L:HasTranslation("Affe") == "Monkey")
+ assert(not L:HasTranslation("Haus"))
+ assert(not L:HasTranslation("Maus"))
+
+ assert(L.Affe == "Monkey")
+ assert(L.Haus == "Haus")
+ -- check for speed
+ assert(rawget(L, 'Affe') == "Monkey")
+ assert(rawget(L, 'Haus') == "Haus")
+
+ assert(L.reverse.Monkey == "Affe")
+ assert(L.reverse.Affe == nil)
+ assert(L.reverse.Haus == "Haus")
+
+ RockLocale.namespaces[MAJOR_VERSION .. "UnitTest2"] = nil
+end)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ local fakeBabble = Rock:NewLibrary("LibFakeBabble-1.0", 1)
+ local L = RockLocale:GetTranslationNamespace("LibFakeBabble-1.0", fakeBabble)
+ L:AddTranslations(GetLocale(), function() return {
+ Monkey = true,
+ House = true,
+ } end)
+
+ Rock:FinalizeLibrary("LibFakeBabble-1.0")
+
+ assert(L.Monkey == "Monkey")
+ assert(L.House == "House")
+
+ local fakeBabble = Rock:NewLibrary("LibFakeBabble-1.0", 2)
+ local L = RockLocale:GetTranslationNamespace("LibFakeBabble-1.0", fakeBabble)
+ L:AddTranslations(GetLocale(), function() return {
+ Monkey = true,
+ House = true,
+ Cat = true,
+ } end)
+
+ Rock:FinalizeLibrary("LibFakeBabble-1.0")
+
+ assert(L.Monkey == "Monkey")
+ assert(L.House == "House")
+ assert(L.Cat == "Cat")
+
+ RockLocale.namespaces["LibFakeBabble-1.0"] = nil
+end)
diff --git a/FuBar/libs/LibRockLocale-1.0/LibRockLocale-1.0.toc b/FuBar/libs/LibRockLocale-1.0/LibRockLocale-1.0.toc
new file mode 100644
index 0000000..9db3b1f
--- /dev/null
+++ b/FuBar/libs/LibRockLocale-1.0/LibRockLocale-1.0.toc
@@ -0,0 +1,17 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r237
+## X-Curse-Project-Name: LibRockLocale-1.0
+## X-Curse-Project-ID: librocklocale-1-0
+## X-Curse-Repository-ID: wow/librocklocale-1-0/mainline
+
+## Title: Lib: RockLocale-1.0
+## Notes: Localization library
+## Author: ckknight
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-Donate: Paypal:ckknight AT gmail DOT com
+## X-eMail: ckknight AT gmail DOT com
+## X-License: LGPL v2.1
+## LoadOnDemand: 1
+
+lib.xml
diff --git a/FuBar/libs/LibRockLocale-1.0/lib.xml b/FuBar/libs/LibRockLocale-1.0/lib.xml
new file mode 100644
index 0000000..3bf63e6
--- /dev/null
+++ b/FuBar/libs/LibRockLocale-1.0/lib.xml
@@ -0,0 +1,4 @@
+
+
+
\ No newline at end of file
diff --git a/FuBar/libs/LibRockTimer-1.0/LibRockTimer-1.0.lua b/FuBar/libs/LibRockTimer-1.0/LibRockTimer-1.0.lua
new file mode 100644
index 0000000..c90746d
--- /dev/null
+++ b/FuBar/libs/LibRockTimer-1.0/LibRockTimer-1.0.lua
@@ -0,0 +1,448 @@
+--[[
+Name: LibRockTimer-1.0
+Revision: $Rev: 232 $
+Developed by: ckknight (ckknight@gmail.com)
+Website: http://www.wowace.com/
+Description: Library to allow for the creation of schedules.
+Dependencies: LibRock-1.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "LibRockTimer-1.0"
+local MINOR_VERSION = tonumber(("$Revision: 232 $"):match("(%d+)")) + 90000
+
+if not Rock then error(MAJOR_VERSION .. " requires LibRock-1.0") end
+
+local RockTimer, oldLib = Rock:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
+if not RockTimer then
+ return
+end
+
+local FREQUENCY = 20+1 -- Timers will not be fired more often than FREQUENCY-1 times per second.
+local NUM_BUCKETS = 131 -- Prime for good distribution
+
+local _G = _G
+local Rock = _G.Rock
+local assert = _G.assert
+local error = _G.error
+local GetTime = _G.GetTime
+local pairs = _G.pairs
+local unpack = _G.unpack
+local pcall = _G.pcall
+local tostring = _G.tostring
+local type = _G.type
+local select = _G.select
+local math_floor = _G.math.floor
+
+-- the frame to receive OnUpdates from
+RockTimer.frame = oldLib and oldLib.frame or _G.CreateFrame("Frame")
+local frame = RockTimer.frame
+-- timers[uid] = { object = objectThatCreatedIt, nextTime = nextTimeToRun, delay = delayTimeIfRepeating, callback = methodOrFunction, callback_type = type(callback), n = numberOfArguments, [1] = arg1, [n] = argn}
+RockTimer.timers = oldLib and oldLib.timers or {}
+local timers = RockTimer.timers
+
+local newList, del = Rock:GetRecyclingFunctions(MAJOR_VERSION, "newList", "del")
+
+local precondition, postcondition, argCheck = Rock:GetContractFunctions(MAJOR_VERSION, "precondition", "postcondition", "argCheck")
+
+local buckets = {}
+for i = -1, NUM_BUCKETS-1 do
+ buckets[i] = {}
+end
+
+for uid, timer in pairs(timers) do
+ local num
+ if timer.delay == 0 then
+ num = -1
+ else
+ num = math_floor(timer.nextTime * FREQUENCY) % NUM_BUCKETS
+ end
+ timer.bucket = num
+ buckets[num][uid] = true
+end
+
+local function toliteral(x)
+ if type(x) == "string" then
+ return ("%q"):format(x)
+ else
+ return tostring(x)
+ end
+end
+
+local function addTimer(object, uid, delay, repeating, callback, type_callback, ...)
+ local timer
+ if not uid then
+ timer = newList()
+ timers[timer] = timer
+ else
+ timer = timers[uid]
+ if not timer then
+ timer = newList()
+ timers[uid] = timer
+ else
+ for k in pairs(timer) do
+ timer[k] = nil
+ end
+ end
+ end
+ local nextTime = GetTime() + delay
+ timer.nextTime = nextTime
+ if repeating then
+ timer.delay = delay
+ end
+ local bucket
+ if delay == 0 then
+ bucket = -1
+ else
+ bucket = math_floor(nextTime * FREQUENCY) % NUM_BUCKETS
+ end
+ timer.bucket = bucket
+ buckets[bucket][uid] = true
+ timer.object = object
+ timer.callback = callback
+ timer.type_callback = type_callback
+ local n = select('#', ...)
+ timer.n = n
+ for i = 1, n do
+ timer[i] = select(i, ...)
+ end
+end
+
+--[[----------------------------------------------------------------------------------
+Notes:
+ * Add a timer that will fire in the allotted time.
+ * To fire on the next frame, specify a delay of 0.
+Arguments:
+ string or number - a unique identifier, to allow for easy removal later. Optional, default: nil.
+ number - the amount of seconds until the callback is fired. Must be either 0 or >= 0.05.
+ string or function - the method name or function to call.
+ tuple - a list of arguments to pass along.
+Example:
+ MyAddon:AddTimer(5, "SomethingToFireInFiveSeconds")
+ MyAddon:AddTimer(10, function(value) print("Kersplosion!x" .. value) end, 50)
+ MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")
+------------------------------------------------------------------------------------]]
+function RockTimer:AddTimer(uid, delay, callback, ...)
+ local type_delay = type(delay)
+ if type_delay == "function" or type_delay == "string" then
+ if callback == nil and select('#', ...) == 0 then
+ return RockTimer.AddTimer(self, nil, uid, delay)
+ else
+ return RockTimer.AddTimer(self, nil, uid, delay, callback, ...)
+ end
+ end
+
+ if not uid then
+ uid = Rock:GetUID()
+ end
+
+ return addTimer(self, uid, delay, false, callback, type(callback), ...)
+end
+precondition(RockTimer, "AddTimer", function(self, uid, delay, callback, ...)
+ local type_delay = type(delay)
+ if type_delay == "function" or type_delay == "string" then
+ -- because it returns anyway
+ return
+ end
+ argCheck(delay, 3, "number")
+ if delay < 0.05 and delay ~= 0 then
+ error(("Bad argument #3 to `AddTimer'. Cannot be less than 0.05 and not 0, got %s."):format(delay), 3)
+ end
+ argCheck(callback, 4, "function", "string")
+ if type(callback) == "string" and type(self[callback]) ~= "function" then
+ error(("Bad argument #4 to `AddTimer'. %q is not a %q, got %q."):format(callback, "function", type(self[callback])), 3)
+ end
+end)
+postcondition(RockTimer, "AddTimer", function(ret, self, uid, delay, callback, ...)
+ local type_delay = type(delay)
+ if type_delay == "function" or type_delay == "string" then
+ -- because it returns anyway
+ return
+ end
+ if uid then
+ assert(self:HasTimer(uid))
+ end
+end)
+
+--[[----------------------------------------------------------------------------------
+Notes:
+ * Add a timer that will fire in the allotted time and repeatedly every so often after that point.
+ * To fire on every frame, specify a delay of 0.
+ * This will run every `delay` that you set. This keeps track of the original starting time and goes by that instead of running every `delay` after each run, which actually, due to the lack of infinite framerate, would cause it to run every `delay` + epsilon seconds. Without lag spikes, this will run 10 times in 10 seconds for a delay of 1, instead of possibly 9 or 8 times, never catching up.
+ * If a lag spike occurs where multiple seconds are lost, all waiting timers will be run, but will not play a game of "catch-up", i.e. if you have a delay of 1, you lose 10 seconds, instead of running the timer 10x in the next 10 frames, it will run the next frame, somewhere between 0-1 seconds later (depending on the length of the lag spike, it stays in tune with the original time), and then every second after that.
+Arguments:
+ string or number - a unique identifier, to allow for easy removal later. Optional, default: nil.
+ number - the amount of seconds until the callback is fired. Must be either 0 or >= 0.05.
+ string or function - the method name or function to call.
+ tuple - a list of arguments to pass along.
+Example:
+ MyAddon:AddTimer(5, "SomethingToFireInFiveSeconds")
+ MyAddon:AddTimer(10, function(value) print("Kersplosion!x" .. value) end, 50)
+ MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")
+------------------------------------------------------------------------------------]]
+function RockTimer:AddRepeatingTimer(uid, delay, callback, ...)
+ local type_delay = type(delay)
+ if type_delay == "function" or type_delay == "string" then
+ if callback == nil and select('#', ...) == 0 then
+ return RockTimer.AddRepeatingTimer(self, nil, uid, delay)
+ else
+ return RockTimer.AddRepeatingTimer(self, nil, uid, delay, callback, ...)
+ end
+ end
+
+ if not uid then
+ uid = Rock:GetUID()
+ end
+
+ return addTimer(self, uid, delay, true, callback, type(callback), ...)
+end
+precondition(RockTimer, "AddRepeatingTimer", function(self, uid, delay, callback, ...)
+ local type_delay = type(delay)
+ if type_delay == "function" or type_delay == "string" then
+ -- because it returns anyway
+ return
+ end
+ argCheck(delay, 3, "number")
+ if delay < 0.05 and delay ~= 0 then
+ error(("Bad argument #3 to `AddRepeatingTimer'. Cannot be less than 0.05 and not 0, got %s."):format(delay), 3)
+ end
+ argCheck(callback, 4, "function", "string")
+ if type(callback) == "string" and type(self[callback]) ~= "function" then
+ error(("Bad argument #4 to `AddRepeatingTimer'. %q is not a %q, got %q."):format(callback, "function", type(self[callback])), 3)
+ end
+end)
+postcondition(RockTimer, "AddRepeatingTimer", function(ret, self, uid, delay, callback, ...)
+ local type_delay = type(delay)
+ if type_delay == "function" or type_delay == "string" then
+ -- because it returns anyway
+ return
+ end
+ if uid then
+ assert(self:HasTimer(uid))
+ end
+end)
+
+local tmp = {}
+local currentBucket = math_floor(GetTime() * FREQUENCY)
+local function OnUpdate(this, elapsed)
+ local now = GetTime()
+ local nowBucket = math_floor(now * FREQUENCY)
+ local max = -1
+ if nowBucket ~= currentBucket then
+ -- if we're looking at a new bucket
+ if currentBucket <= nowBucket - NUM_BUCKETS then -- occurs on lag spikes
+ -- causes every timer to be iterated.
+ currentBucket = currentBucket - NUM_BUCKETS + 1
+ else
+ currentBucket = currentBucket + 1
+ end
+
+ max = nowBucket - currentBucket
+ end
+
+ local soon = now + 1 -- +1 is safe as long as 1 < HZ < BUCKETS/2
+
+ for i = -1, max do
+ local bucketNum
+ if i == -1 then
+ -- check delay = 0
+ bucketNum = -1
+ else
+ bucketNum = (i + currentBucket) % NUM_BUCKETS
+ end
+ local bucket = buckets[bucketNum]
+
+ for uid in pairs(bucket) do
+ tmp[uid] = true
+ end
+ for uid in pairs(tmp) do
+ local timer = timers[uid]
+ if timer then
+ local nextTime = timer.nextTime
+ if soon >= nextTime then
+ local delay = timer.delay
+ if delay and delay ~= 0 then
+ local newNextTime = nextTime + delay
+ while newNextTime < now do
+ -- make sure to fire on the next correct time, skipping over any lagged times.
+ -- this occurs if there is a bad lag spike
+ newNextTime = newNextTime + delay
+ end
+ timer.nextTime = newNextTime
+
+ -- update the bucket
+ local newBucketNum = math_floor(newNextTime * FREQUENCY) % NUM_BUCKETS
+ bucket[uid] = nil
+ buckets[newBucketNum][uid] = true
+ end
+ RockTimer.currentUID = Rock:GetUID()
+ local callback = timer.callback
+ local type_callback = timer.type_callback
+ if type_callback == "string" then
+ local object = timer.object
+ local object_method = object[callback]
+ if not object_method then -- already did typecheck, just check existence
+ local success, ret = pcall(error, ("Error calling method %q on object %q. Method does not exist."):format(callback, tostring(object)))
+ geterrorhandler()(ret)
+ delay = nil
+ else
+ object_method(object, unpack(timer, 1, timer.n))
+--[[ local success, ret = pcall(object_method, object, unpack(timer, 1, timer.n))
+ if not success then
+ geterrorhandler()(ret)
+ delay = nil
+ end]]
+ end
+ else -- function
+ local success, ret = pcall(callback, unpack(timer, 1, timer.n))
+ if not success then
+ geterrorhandler()(ret)
+ delay = nil
+ end
+ end
+ RockTimer.currentUID = nil
+ if not delay then
+ -- not repeating
+ local newTimer = timers[uid]
+ if newTimer and newTimer.nextTime == nextTime then -- otherwise it's be manually reset
+ bucket[uid] = nil
+ timers[uid] = del(timer)
+ end
+ end
+ end
+ end
+ tmp[uid] = nil
+ end
+ end
+ currentBucket = nowBucket
+end
+frame:SetScript("OnUpdate", OnUpdate)
+
+--[[----------------------------------------------------------------------------------
+Notes:
+ * Remove a timer with the specified uid.
+Arguments:
+ string or number - a unique identifier.
+Returns:
+ boolean - whether the timer was actually removed.
+Example:
+ MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")
+ MyAddon:RemoveTimer("myUID")
+------------------------------------------------------------------------------------]]
+function RockTimer:RemoveTimer(uid)
+ local timer = timers[uid]
+ if not timer then
+ return false
+ else
+ local bucket = timer.bucket
+ if bucket then
+ buckets[bucket][timer] = nil
+ end
+ timers[uid] = del(timer)
+ return true
+ end
+end
+precondition(RockTimer, 'RemoveTimer', function(self, uid)
+ if not uid then
+ error(("Bad argument #2 to `RemoveTimer'. Expected non-false, got %s"):format(toliteral(uid)), 2)
+ end
+end)
+postcondition(RockTimer, 'RemoveTimer', function(ret, self, uid)
+ assert(not self:HasTimer(uid))
+end)
+
+--[[----------------------------------------------------------------------------------
+Notes:
+ * Remove all timers created by this object.
+Example:
+ MyAddon:RemoveAllTimers()
+------------------------------------------------------------------------------------]]
+function RockTimer:RemoveAllTimers()
+ for uid, timer in pairs(timers) do
+ if timer.object == self then
+ timers[uid] = del(timer)
+ end
+ end
+end
+
+--[[----------------------------------------------------------------------------------
+Notes:
+ * Remove a timer with the specified uid.
+Arguments:
+ string or number - a unique identifier.
+Returns:
+ boolean or number - false if the timer does not exist, otherwise the amount of time until the timer goes off.
+Example:
+ MyAddon:AddTimer("myUID", 0, "SomethingToFireNextFrame")
+ local hasTimer = MyAddon:HasTimer("myUID")
+------------------------------------------------------------------------------------]]
+function RockTimer:HasTimer(uid)
+ local timer = timers[uid]
+ if not timer then
+ return false
+ end
+ local nextTime = timer.nextTime
+ return nextTime - GetTime()
+end
+precondition(RockTimer, 'HasTimer', function(self, uid)
+ if not uid then
+ error(("Bad argument #2 to `HasTimer'. Expected non-false, got %s"):format(toliteral(uid)), 2)
+ end
+end)
+
+function RockTimer:OnUnembed(object)
+ self.RemoveAllTimers(object)
+end
+
+function RockTimer:OnEmbedDisable(object)
+ self.RemoveAllTimers(object)
+end
+
+RockTimer:SetExportedMethods("AddTimer", "AddRepeatingTimer", "RemoveTimer", "RemoveAllTimers", "HasTimer")
+
+Rock:FinalizeLibrary(MAJOR_VERSION)
+
+Rock:AddUnitTest(MAJOR_VERSION, function()
+ local t = {name = "RockTimerUnitTest"}
+ RockTimer:Embed(t)
+
+ local triggered = false
+ function t:Alpha(...)
+ triggered = true
+ assert((...) == "Blah")
+ end
+ local uid = Rock:GetUID()
+ assert(not t:HasTimer(uid))
+ t:AddTimer(uid, 0, "Alpha", "Blah")
+ assert(t:HasTimer(uid))
+ OnUpdate(frame, 0)
+ assert(triggered)
+ triggered = false
+ assert(not t:HasTimer(uid))
+
+ t:AddRepeatingTimer(uid, 0, "Alpha", "Blah")
+ assert(t:HasTimer(uid))
+ OnUpdate(frame, 0)
+ assert(triggered)
+ triggered = false
+ assert(t:HasTimer(uid))
+ OnUpdate(frame, 0)
+ assert(triggered)
+ triggered = false
+ assert(t:HasTimer(uid))
+ t:RemoveTimer(uid)
+ assert(not t:HasTimer(uid))
+
+ t:AddRepeatingTimer(uid, 0, "Alpha", "Blah")
+ assert(t:HasTimer(uid))
+ OnUpdate(frame, 0)
+ assert(triggered)
+ triggered = false
+ assert(t:HasTimer(uid))
+ OnUpdate(frame, 0)
+ assert(triggered)
+ triggered = false
+ assert(t:HasTimer(uid))
+ t:RemoveAllTimers(uid)
+ assert(not t:HasTimer(uid))
+end)
diff --git a/FuBar/libs/LibRockTimer-1.0/LibRockTimer-1.0.toc b/FuBar/libs/LibRockTimer-1.0/LibRockTimer-1.0.toc
new file mode 100644
index 0000000..1de7596
--- /dev/null
+++ b/FuBar/libs/LibRockTimer-1.0/LibRockTimer-1.0.toc
@@ -0,0 +1,17 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r233
+## X-Curse-Project-Name: LibRockTimer-1.0
+## X-Curse-Project-ID: librocktimer-1-0
+## X-Curse-Repository-ID: wow/librocktimer-1-0/mainline
+
+## Title: Lib: RockTimer-1.0
+## Notes: Timer library
+## Author: ckknight
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-Donate: Paypal:ckknight AT gmail DOT com
+## X-eMail: ckknight AT gmail DOT com
+## X-License: LGPL v2.1
+## LoadOnDemand: 1
+
+lib.xml
diff --git a/FuBar/libs/LibRockTimer-1.0/lib.xml b/FuBar/libs/LibRockTimer-1.0/lib.xml
new file mode 100644
index 0000000..ad0487f
--- /dev/null
+++ b/FuBar/libs/LibRockTimer-1.0/lib.xml
@@ -0,0 +1,4 @@
+
+
+
\ No newline at end of file
diff --git a/FuBar/libs/LibSharedMedia-3.0/CallbackHandler-1.0/CallbackHandler-1.0.lua b/FuBar/libs/LibSharedMedia-3.0/CallbackHandler-1.0/CallbackHandler-1.0.lua
new file mode 100644
index 0000000..3bd4a37
--- /dev/null
+++ b/FuBar/libs/LibSharedMedia-3.0/CallbackHandler-1.0/CallbackHandler-1.0.lua
@@ -0,0 +1,212 @@
+--[[ $Id: CallbackHandler-1.0.lua 1186 2018-07-21 14:19:18Z nevcairiel $ ]]
+local MAJOR, MINOR = "CallbackHandler-1.0", 7
+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 Dispatch(handlers, ...)
+ local index, method = next(handlers)
+ if not method then return end
+ repeat
+ xpcall(method, errorhandler, ...)
+ index, method = next(handlers, index)
+ until not method
+end
+
+--------------------------------------------------------------------------
+-- CallbackHandler:New
+--
+-- target - target object to embed public APIs in
+-- RegisterName - name of the callback registration API, default "RegisterCallback"
+-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback"
+-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
+
+function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName)
+
+ RegisterName = RegisterName or "RegisterCallback"
+ UnregisterName = UnregisterName or "UnregisterCallback"
+ if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
+ UnregisterAllName = "UnregisterAllCallbacks"
+ end
+
+ -- we declare all objects and exported APIs inside this closure to quickly gain access
+ -- to e.g. function names, the "target" parameter, etc
+
+
+ -- Create the registry object
+ local events = setmetatable({}, meta)
+ local registry = { recurse=0, events=events }
+
+ -- registry:Fire() - fires the given event/message into the registry
+ function registry:Fire(eventname, ...)
+ if not rawget(events, eventname) or not next(events[eventname]) then return end
+ local oldrecurse = registry.recurse
+ registry.recurse = oldrecurse + 1
+
+ Dispatch(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.
+
diff --git a/FuBar/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.toc b/FuBar/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.toc
new file mode 100644
index 0000000..d35af7e
--- /dev/null
+++ b/FuBar/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.toc
@@ -0,0 +1,18 @@
+## Interface: 100002
+## LoadOnDemand: 1
+
+## Title: Lib: SharedMedia-3.0
+## Notes: Shared handling of media data (fonts, sounds, textures, ...) between addons.
+## Author: Elkano
+## Version: 3.0-106
+## X-Website: http://www.wowace.com/projects/libsharedmedia-3-0/
+## X-Category: Library
+
+## X-Revision: 106
+## X-Date: 2018-08-02T11:29:41Z
+
+LibStub\LibStub.lua
+CallbackHandler-1.0\CallbackHandler-1.0.lua
+
+LibSharedMedia-3.0\lib.xml
+
diff --git a/FuBar/libs/LibSharedMedia-3.0/LibSharedMedia-3.0/LibSharedMedia-3.0.lua b/FuBar/libs/LibSharedMedia-3.0/LibSharedMedia-3.0/LibSharedMedia-3.0.lua
new file mode 100644
index 0000000..8129a82
--- /dev/null
+++ b/FuBar/libs/LibSharedMedia-3.0/LibSharedMedia-3.0/LibSharedMedia-3.0.lua
@@ -0,0 +1,301 @@
+--@curseforge-project-slug: libsharedmedia-3-0@
+--[[
+Name: LibSharedMedia-3.0
+Revision: $Revision: 128 $
+Author: Elkano (elkano@gmx.de)
+Inspired By: SurfaceLib by Haste/Otravi (troeks@gmail.com)
+Website: http://www.wowace.com/projects/libsharedmedia-3-0/
+Description: Shared handling of media data (fonts, sounds, textures, ...) between addons.
+Dependencies: LibStub, CallbackHandler-1.0
+License: LGPL v2.1
+]]
+
+local MAJOR, MINOR = "LibSharedMedia-3.0", 8020003 -- 8.2.0 v3 / increase manually on changes
+local lib = LibStub:NewLibrary(MAJOR, MINOR)
+
+if not lib then return end
+
+local _G = getfenv(0)
+
+local pairs = _G.pairs
+local type = _G.type
+
+local band = _G.bit.band
+local table_sort = _G.table.sort
+
+local RESTRICTED_FILE_ACCESS = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE -- starting with 8.2, some rules for file access have changed; classic still uses the old way
+
+local locale = GetLocale()
+local locale_is_western
+local LOCALE_MASK = 0
+lib.LOCALE_BIT_koKR = 1
+lib.LOCALE_BIT_ruRU = 2
+lib.LOCALE_BIT_zhCN = 4
+lib.LOCALE_BIT_zhTW = 8
+lib.LOCALE_BIT_western = 128
+
+local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
+
+lib.callbacks = lib.callbacks or CallbackHandler:New(lib)
+
+lib.DefaultMedia = lib.DefaultMedia or {}
+lib.MediaList = lib.MediaList or {}
+lib.MediaTable = lib.MediaTable or {}
+lib.MediaType = lib.MediaType or {}
+lib.OverrideMedia = lib.OverrideMedia or {}
+
+local defaultMedia = lib.DefaultMedia
+local mediaList = lib.MediaList
+local mediaTable = lib.MediaTable
+local overrideMedia = lib.OverrideMedia
+
+
+-- create mediatype constants
+lib.MediaType.BACKGROUND = "background" -- background textures
+lib.MediaType.BORDER = "border" -- border textures
+lib.MediaType.FONT = "font" -- fonts
+lib.MediaType.STATUSBAR = "statusbar" -- statusbar textures
+lib.MediaType.SOUND = "sound" -- sound files
+
+-- populate lib with default Blizzard data
+-- BACKGROUND
+if not lib.MediaTable.background then lib.MediaTable.background = {} end
+lib.MediaTable.background["None"] = [[]]
+lib.MediaTable.background["Blizzard Collections Background"] = [[Interface\Collections\CollectionsBackgroundTile]]
+lib.MediaTable.background["Blizzard Dialog Background"] = [[Interface\DialogFrame\UI-DialogBox-Background]]
+lib.MediaTable.background["Blizzard Dialog Background Dark"] = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]]
+lib.MediaTable.background["Blizzard Dialog Background Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]
+lib.MediaTable.background["Blizzard Garrison Background"] = [[Interface\Garrison\GarrisonUIBackground]]
+lib.MediaTable.background["Blizzard Garrison Background 2"] = [[Interface\Garrison\GarrisonUIBackground2]]
+lib.MediaTable.background["Blizzard Garrison Background 3"] = [[Interface\Garrison\GarrisonMissionUIInfoBoxBackgroundTile]]
+lib.MediaTable.background["Blizzard Low Health"] = [[Interface\FullScreenTextures\LowHealth]]
+lib.MediaTable.background["Blizzard Marble"] = [[Interface\FrameGeneral\UI-Background-Marble]]
+lib.MediaTable.background["Blizzard Out of Control"] = [[Interface\FullScreenTextures\OutOfControl]]
+lib.MediaTable.background["Blizzard Parchment"] = [[Interface\AchievementFrame\UI-Achievement-Parchment-Horizontal]]
+lib.MediaTable.background["Blizzard Parchment 2"] = [[Interface\AchievementFrame\UI-GuildAchievement-Parchment-Horizontal]]
+lib.MediaTable.background["Blizzard Rock"] = [[Interface\FrameGeneral\UI-Background-Rock]]
+lib.MediaTable.background["Blizzard Tabard Background"] = [[Interface\TabardFrame\TabardFrameBackground]]
+lib.MediaTable.background["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Background]]
+lib.MediaTable.background["Solid"] = [[Interface\Buttons\WHITE8X8]]
+lib.DefaultMedia.background = "None"
+
+-- BORDER
+if not lib.MediaTable.border then lib.MediaTable.border = {} end
+lib.MediaTable.border["None"] = [[]]
+lib.MediaTable.border["Blizzard Achievement Wood"] = [[Interface\AchievementFrame\UI-Achievement-WoodBorder]]
+lib.MediaTable.border["Blizzard Chat Bubble"] = [[Interface\Tooltips\ChatBubble-Backdrop]]
+lib.MediaTable.border["Blizzard Dialog"] = [[Interface\DialogFrame\UI-DialogBox-Border]]
+lib.MediaTable.border["Blizzard Dialog Gold"] = [[Interface\DialogFrame\UI-DialogBox-Gold-Border]]
+lib.MediaTable.border["Blizzard Party"] = [[Interface\CHARACTERFRAME\UI-Party-Border]]
+lib.MediaTable.border["Blizzard Tooltip"] = [[Interface\Tooltips\UI-Tooltip-Border]]
+lib.DefaultMedia.border = "None"
+
+-- FONT
+if not lib.MediaTable.font then lib.MediaTable.font = {} end
+local SML_MT_font = lib.MediaTable.font
+--[[
+All font files are currently in all clients, the following table depicts which font supports which charset as of 5.0.4
+Fonts were checked using langcover.pl from DejaVu fonts (http://sourceforge.net/projects/dejavu/) and FontForge (http://fontforge.org/)
+latin means check for: de, en, es, fr, it, pt
+
+file name latin koKR ruRU zhCN zhTW
+2002.ttf 2002 X X X - -
+2002B.ttf 2002 Bold X X X - -
+ARHei.ttf AR CrystalzcuheiGBK Demibold X - X X X
+ARIALN.TTF Arial Narrow X - X - -
+ARKai_C.ttf AR ZhongkaiGBK Medium (Combat) X - X X X
+ARKai_T.ttf AR ZhongkaiGBK Medium X - X X X
+bHEI00M.ttf AR Heiti2 Medium B5 - - - - X
+bHEI01B.ttf AR Heiti2 Bold B5 - - - - X
+bKAI00M.ttf AR Kaiti Medium B5 - - - - X
+bLEI00D.ttf AR Leisu Demi B5 - - - - X
+FRIZQT__.TTF Friz Quadrata TT X - - - -
+FRIZQT___CYR.TTF FrizQuadrataCTT x - X - -
+K_Damage.TTF YDIWingsM - X X - -
+K_Pagetext.TTF MoK X X X - -
+MORPHEUS.TTF Morpheus X - - - -
+MORPHEUS_CYR.TTF Morpheus X - X - -
+NIM_____.ttf Nimrod MT X - X - -
+SKURRI.TTF Skurri X - - - -
+SKURRI_CYR.TTF Skurri X - X - -
+
+WARNING: Although FRIZQT___CYR is available on western clients, it doesn't support special European characters e.g. é, ï, ö
+Due to this, we cannot use it as a replacement for FRIZQT__.TTF
+]]
+
+if locale == "koKR" then
+ LOCALE_MASK = lib.LOCALE_BIT_koKR
+--
+ SML_MT_font["굵은 글꼴"] = [[Fonts\2002B.TTF]]
+ SML_MT_font["기본 글꼴"] = [[Fonts\2002.TTF]]
+ SML_MT_font["데미지 글꼴"] = [[Fonts\K_Damage.TTF]]
+ SML_MT_font["퀘스트 글꼴"] = [[Fonts\K_Pagetext.TTF]]
+--
+ lib.DefaultMedia["font"] = "기본 글꼴" -- someone from koKR please adjust if needed
+--
+elseif locale == "zhCN" then
+ LOCALE_MASK = lib.LOCALE_BIT_zhCN
+--
+ SML_MT_font["伤害数字"] = [[Fonts\ARKai_C.ttf]]
+ SML_MT_font["默认"] = [[Fonts\ARKai_T.ttf]]
+ SML_MT_font["聊天"] = [[Fonts\ARHei.ttf]]
+--
+ lib.DefaultMedia["font"] = "默认" -- someone from zhCN please adjust if needed
+--
+elseif locale == "zhTW" then
+ LOCALE_MASK = lib.LOCALE_BIT_zhTW
+--
+ SML_MT_font["提示訊息"] = [[Fonts\bHEI00M.ttf]]
+ SML_MT_font["聊天"] = [[Fonts\bHEI01B.ttf]]
+ SML_MT_font["傷害數字"] = [[Fonts\bKAI00M.ttf]]
+ SML_MT_font["預設"] = [[Fonts\bLEI00D.ttf]]
+--
+ lib.DefaultMedia["font"] = "預設" -- someone from zhTW please adjust if needed
+
+elseif locale == "ruRU" then
+ LOCALE_MASK = lib.LOCALE_BIT_ruRU
+--
+ SML_MT_font["2002"] = [[Fonts\2002.TTF]]
+ SML_MT_font["2002 Bold"] = [[Fonts\2002B.TTF]]
+ SML_MT_font["AR CrystalzcuheiGBK Demibold"] = [[Fonts\ARHei.TTF]]
+ SML_MT_font["AR ZhongkaiGBK Medium (Combat)"] = [[Fonts\ARKai_C.TTF]]
+ SML_MT_font["AR ZhongkaiGBK Medium"] = [[Fonts\ARKai_T.TTF]]
+ SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
+ SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT___CYR.TTF]]
+ SML_MT_font["MoK"] = [[Fonts\K_Pagetext.TTF]]
+ SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS_CYR.TTF]]
+ SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]]
+ SML_MT_font["Skurri"] = [[Fonts\SKURRI_CYR.TTF]]
+--
+ lib.DefaultMedia.font = "Friz Quadrata TT"
+--
+else
+ LOCALE_MASK = lib.LOCALE_BIT_western
+ locale_is_western = true
+--
+ SML_MT_font["2002"] = [[Fonts\2002.TTF]]
+ SML_MT_font["2002 Bold"] = [[Fonts\2002B.TTF]]
+ SML_MT_font["AR CrystalzcuheiGBK Demibold"] = [[Fonts\ARHei.TTF]]
+ SML_MT_font["AR ZhongkaiGBK Medium (Combat)"] = [[Fonts\ARKai_C.TTF]]
+ SML_MT_font["AR ZhongkaiGBK Medium"] = [[Fonts\ARKai_T.TTF]]
+ SML_MT_font["Arial Narrow"] = [[Fonts\ARIALN.TTF]]
+ SML_MT_font["Friz Quadrata TT"] = [[Fonts\FRIZQT__.TTF]]
+ SML_MT_font["MoK"] = [[Fonts\K_Pagetext.TTF]]
+ SML_MT_font["Morpheus"] = [[Fonts\MORPHEUS_CYR.TTF]]
+ SML_MT_font["Nimrod MT"] = [[Fonts\NIM_____.ttf]]
+ SML_MT_font["Skurri"] = [[Fonts\SKURRI_CYR.TTF]]
+--
+ lib.DefaultMedia.font = "Friz Quadrata TT"
+--
+end
+
+-- STATUSBAR
+if not lib.MediaTable.statusbar then lib.MediaTable.statusbar = {} end
+lib.MediaTable.statusbar["Blizzard"] = [[Interface\TargetingFrame\UI-StatusBar]]
+lib.MediaTable.statusbar["Blizzard Character Skills Bar"] = [[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]]
+lib.MediaTable.statusbar["Blizzard Raid Bar"] = [[Interface\RaidFrame\Raid-Bar-Hp-Fill]]
+lib.MediaTable.statusbar["Solid"] = [[Interface\Buttons\WHITE8X8]]
+lib.DefaultMedia.statusbar = "Blizzard"
+
+-- SOUND
+if not lib.MediaTable.sound then lib.MediaTable.sound = {} end
+lib.MediaTable.sound["None"] = RESTRICTED_FILE_ACCESS and 1 or [[Interface\Quiet.ogg]] -- Relies on the fact that PlaySound[File] doesn't error on these values.
+lib.DefaultMedia.sound = "None"
+
+local function rebuildMediaList(mediatype)
+ local mtable = mediaTable[mediatype]
+ if not mtable then return end
+ if not mediaList[mediatype] then mediaList[mediatype] = {} end
+ local mlist = mediaList[mediatype]
+ -- list can only get larger, so simply overwrite it
+ local i = 0
+ for k in pairs(mtable) do
+ i = i + 1
+ mlist[i] = k
+ end
+ table_sort(mlist)
+end
+
+function lib:Register(mediatype, key, data, langmask)
+ if type(mediatype) ~= "string" then
+ error(MAJOR..":Register(mediatype, key, data, langmask) - mediatype must be string, got "..type(mediatype))
+ end
+ if type(key) ~= "string" then
+ error(MAJOR..":Register(mediatype, key, data, langmask) - key must be string, got "..type(key))
+ end
+ mediatype = mediatype:lower()
+ if mediatype == lib.MediaType.FONT and ((langmask and band(langmask, LOCALE_MASK) == 0) or not (langmask or locale_is_western)) then
+ -- ignore fonts that aren't flagged as supporting local glyphs on non-western clients
+ return false
+ end
+ if type(data) == "string" and (mediatype == lib.MediaType.BACKGROUND or mediatype == lib.MediaType.BORDER or mediatype == lib.MediaType.STATUSBAR or mediatype == lib.MediaType.SOUND) then
+ local path = data:lower()
+ if RESTRICTED_FILE_ACCESS and not path:find("^interface") then
+ -- files accessed via path only allowed from interface folder
+ return false
+ end
+ if mediatype == lib.MediaType.SOUND and not (path:find(".ogg", nil, true) or path:find(".mp3", nil, true)) then
+ -- Only ogg and mp3 are valid sounds.
+ return false
+ end
+ end
+ if not mediaTable[mediatype] then mediaTable[mediatype] = {} end
+ local mtable = mediaTable[mediatype]
+ if mtable[key] then return false end
+
+ mtable[key] = data
+ rebuildMediaList(mediatype)
+ self.callbacks:Fire("LibSharedMedia_Registered", mediatype, key)
+ return true
+end
+
+function lib:Fetch(mediatype, key, noDefault)
+ local mtt = mediaTable[mediatype]
+ local overridekey = overrideMedia[mediatype]
+ local result = mtt and ((overridekey and mtt[overridekey] or mtt[key]) or (not noDefault and defaultMedia[mediatype] and mtt[defaultMedia[mediatype]])) or nil
+ return result ~= "" and result or nil
+end
+
+function lib:IsValid(mediatype, key)
+ return mediaTable[mediatype] and (not key or mediaTable[mediatype][key]) and true or false
+end
+
+function lib:HashTable(mediatype)
+ return mediaTable[mediatype]
+end
+
+function lib:List(mediatype)
+ if not mediaTable[mediatype] then
+ return nil
+ end
+ if not mediaList[mediatype] then
+ rebuildMediaList(mediatype)
+ end
+ return mediaList[mediatype]
+end
+
+function lib:GetGlobal(mediatype)
+ return overrideMedia[mediatype]
+end
+
+function lib:SetGlobal(mediatype, key)
+ if not mediaTable[mediatype] then
+ return false
+ end
+ overrideMedia[mediatype] = (key and mediaTable[mediatype][key]) and key or nil
+ self.callbacks:Fire("LibSharedMedia_SetGlobal", mediatype, overrideMedia[mediatype])
+ return true
+end
+
+function lib:GetDefault(mediatype)
+ return defaultMedia[mediatype]
+end
+
+function lib:SetDefault(mediatype, key)
+ if mediaTable[mediatype] and mediaTable[mediatype][key] and not defaultMedia[mediatype] then
+ defaultMedia[mediatype] = key
+ return true
+ else
+ return false
+ end
+end
diff --git a/FuBar/libs/LibSharedMedia-3.0/LibSharedMedia-3.0/lib.xml b/FuBar/libs/LibSharedMedia-3.0/LibSharedMedia-3.0/lib.xml
new file mode 100644
index 0000000..7313228
--- /dev/null
+++ b/FuBar/libs/LibSharedMedia-3.0/LibSharedMedia-3.0/lib.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/FuBar/libs/LibSharedMedia-3.0/LibStub/LibStub.lua b/FuBar/libs/LibSharedMedia-3.0/LibStub/LibStub.lua
new file mode 100644
index 0000000..f5fc919
--- /dev/null
+++ b/FuBar/libs/LibSharedMedia-3.0/LibStub/LibStub.lua
@@ -0,0 +1,51 @@
+-- $Id: LibStub.lua 76 2007-09-03 01:50:17Z mikk $
+-- 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]
+
+-- Check to see is this version of the stub is obsolete
+if not LibStub or LibStub.minor < LIBSTUB_MINOR then
+ LibStub = LibStub or {libs = {}, minors = {} }
+ _G[LIBSTUB_MAJOR] = LibStub
+ LibStub.minor = LIBSTUB_MINOR
+
+ -- LibStub:NewLibrary(major, minor)
+ -- major (string) - the major version of the library
+ -- minor (string or number ) - the minor version of the library
+ --
+ -- returns nil if a newer or same version of the lib is already present
+ -- returns empty library object or old library object if upgrade is needed
+ function LibStub:NewLibrary(major, minor)
+ assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
+ minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
+
+ local oldminor = self.minors[major]
+ if oldminor and oldminor >= minor then return nil end
+ self.minors[major], self.libs[major] = minor, self.libs[major] or {}
+ return self.libs[major], oldminor
+ end
+
+ -- LibStub:GetLibrary(major, [silent])
+ -- major (string) - the major version of the library
+ -- silent (boolean) - if true, library is optional, silently return nil if its not found
+ --
+ -- throws an error if the library can not be found (except silent is set)
+ -- returns the library object if found
+ function LibStub:GetLibrary(major, silent)
+ if not self.libs[major] and not silent then
+ error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
+ end
+ return self.libs[major], self.minors[major]
+ end
+
+ -- LibStub:IterateLibraries()
+ --
+ -- Returns an iterator for the currently registered libraries
+ function LibStub:IterateLibraries()
+ return pairs(self.libs)
+ end
+
+ setmetatable(LibStub, { __call = LibStub.GetLibrary })
+end
diff --git a/FuBar/libs/LibSharedMedia-3.0/lib.xml b/FuBar/libs/LibSharedMedia-3.0/lib.xml
new file mode 100644
index 0000000..fd1c0cd
--- /dev/null
+++ b/FuBar/libs/LibSharedMedia-3.0/lib.xml
@@ -0,0 +1,5 @@
+
+
+
+
diff --git a/FuBar/libs/LibStub/LibStub.lua b/FuBar/libs/LibStub/LibStub.lua
new file mode 100644
index 0000000..7e7b76d
--- /dev/null
+++ b/FuBar/libs/LibStub/LibStub.lua
@@ -0,0 +1,51 @@
+-- $Id: LibStub.lua 103 2014-10-16 03:02:50Z mikk $
+-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/addons/libstub/ for more info
+-- LibStub is hereby placed in the Public Domain
+-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
+local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
+local LibStub = _G[LIBSTUB_MAJOR]
+
+-- Check to see is this version of the stub is obsolete
+if not LibStub or LibStub.minor < LIBSTUB_MINOR then
+ LibStub = LibStub or {libs = {}, minors = {} }
+ _G[LIBSTUB_MAJOR] = LibStub
+ LibStub.minor = LIBSTUB_MINOR
+
+ -- LibStub:NewLibrary(major, minor)
+ -- major (string) - the major version of the library
+ -- minor (string or number ) - the minor version of the library
+ --
+ -- returns nil if a newer or same version of the lib is already present
+ -- returns empty library object or old library object if upgrade is needed
+ function LibStub:NewLibrary(major, minor)
+ assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
+ minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
+
+ local oldminor = self.minors[major]
+ if oldminor and oldminor >= minor then return nil end
+ self.minors[major], self.libs[major] = minor, self.libs[major] or {}
+ return self.libs[major], oldminor
+ end
+
+ -- LibStub:GetLibrary(major, [silent])
+ -- major (string) - the major version of the library
+ -- silent (boolean) - if true, library is optional, silently return nil if its not found
+ --
+ -- throws an error if the library can not be found (except silent is set)
+ -- returns the library object if found
+ function LibStub:GetLibrary(major, silent)
+ if not self.libs[major] and not silent then
+ error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
+ end
+ return self.libs[major], self.minors[major]
+ end
+
+ -- LibStub:IterateLibraries()
+ --
+ -- Returns an iterator for the currently registered libraries
+ function LibStub:IterateLibraries()
+ return pairs(self.libs)
+ end
+
+ setmetatable(LibStub, { __call = LibStub.GetLibrary })
+end
diff --git a/FuBar/libs/Tablet-2.0/Tablet-2.0.lua b/FuBar/libs/Tablet-2.0/Tablet-2.0.lua
new file mode 100644
index 0000000..a66b6e7
--- /dev/null
+++ b/FuBar/libs/Tablet-2.0/Tablet-2.0.lua
@@ -0,0 +1,2981 @@
+--[[
+Name: Tablet-2.0
+Revision: $Rev: 216 $
+Author(s): ckknight (ckknight@gmail.com)
+Website: http://ckknight.wowinterface.com/
+Documentation: http://www.wowace.com/index.php/Tablet-2.0
+SVN: http://svn.wowace.com/wowace/trunk/TabletLib/Tablet-2.0
+Description: A library to provide an efficient, featureful tooltip-style display.
+Dependencies: AceLibrary, (optional) Dewdrop-2.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "Tablet-2.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 216 $"):match("(%d+)"))
+
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+local DEBUG = false
+
+local SCROLL_UP = "Scroll up"
+local SCROLL_DOWN = "Scroll down"
+local HINT = "Hint"
+local DETACH = "Detach"
+local DETACH_DESC = "Detach the tablet from its source."
+local SIZE = "Size"
+local SIZE_DESC = "Scale the tablet."
+local CLOSE_MENU = "Close menu"
+local CLOSE_MENU_DESC = "Close the menu."
+local COLOR = "Background color"
+local COLOR_DESC = "Set the background color."
+local LOCK = "Lock"
+local LOCK_DESC = "Lock the tablet in its current position. Alt+Right-click for menu or Alt+drag to drag it when locked."
+
+if GetLocale() == "deDE" then
+ SCROLL_UP = "Hochscrollen"
+ SCROLL_DOWN = "Runterscrollen"
+ HINT = "Hinweis"
+ DETACH = "L\195\182sen"
+ DETACH_DESC = "L\195\182st den Tooltip aus seiner Verankerung."
+ SIZE = "Gr\195\182\195\159e"
+ SIZE_DESC = "Gr\195\182\195\159e des Tooltips \195\164ndern."
+ CLOSE_MENU = "Menu schlie\195\159en"
+ CLOSE_MENU_DESC = "Schlie\195\159t das Menu."
+ COLOR = "Hintergrundfarbe"
+ COLOR_DESC = "Hintergrundfarbe setzen."
+ LOCK = "Sperren"
+ LOCK_DESC = "Sperrt die aktuelle Position vom Tooltip. Alt+Rechts-klick f\195\188rs Men\195\188 oder Alt+Verschieben f\195\188rs verschieben wenn es gesperrt ist."
+elseif GetLocale() == "koKR" then
+ SCROLL_UP = "위로 스크롤"
+ SCROLL_DOWN = "아래로 스크롤"
+ HINT = "힌트"
+ DETACH = "분리"
+ DETACH_DESC = "테이블을 분리합니다."
+ SIZE = "크기"
+ SIZE_DESC = "테이블의 크기입니다."
+ CLOSE_MENU = "메뉴 닫기"
+ CLOSE_MENU_DESC = "메뉴를 닫습니다."
+ COLOR = "배경 색상"
+ COLOR_DESC = "배경 색상을 설정합니다."
+ LOCK = "고정"
+ LOCK_DESC = "현재 위치에 테이블을 고정합니다. 알트+우클릭 : 메뉴열기, 알트+드래그 : 고정된것을 드래그합니다."
+elseif GetLocale() == "zhCN" then
+ SCROLL_UP = "向上翻转"
+ SCROLL_DOWN = "向上翻转"
+ HINT = "提示"
+ DETACH = "分离"
+ DETACH_DESC = "分离菜单为独立提示."
+ SIZE = "尺寸"
+ SIZE_DESC = "缩放菜单显示尺寸."
+ CLOSE_MENU = "关闭菜单"
+ CLOSE_MENU_DESC = "关闭菜单"
+ COLOR = "背景颜色"
+ COLOR_DESC = "设置菜单背景颜色."
+ LOCK = "锁定"
+ LOCK_DESC = "锁定菜单当前位置. alt+右键 将显示选项, alt+拖动 可以移动已锁定的菜单."
+elseif GetLocale() == "zhTW" then
+ SCROLL_UP = "向上翻捲"
+ SCROLL_DOWN = "向上翻捲"
+ HINT = "提示"
+ DETACH = "分離"
+ DETACH_DESC = "分離選單為獨立提示。"
+ SIZE = "尺寸"
+ SIZE_DESC = "縮放選單顯示尺寸。"
+ CLOSE_MENU = "關閉選單"
+ CLOSE_MENU_DESC = "關閉選單。"
+ COLOR = "背景顏色"
+ COLOR_DESC = "設定選單背景顏色。"
+ LOCK = "鎖定"
+ LOCK_DESC = "鎖定選單目前位置設定。Alt-右鍵將顯示選項,Alt-拖動可以移動已鎖定的選單。"
+elseif GetLocale() == "frFR" then
+ SCROLL_UP = "Parcourir vers le haut"
+ SCROLL_DOWN = "Parcourir vers le bas"
+ HINT = "Astuce"
+ DETACH = "D\195\169tacher"
+ DETACH_DESC = "Permet de d\195\169tacher le tableau de sa source."
+ SIZE = "Taille"
+ SIZE_DESC = "Permet de changer l'\195\169chelle du tableau."
+ CLOSE_MENU = "Fermer le menu"
+ CLOSE_MENU_DESC = "Ferme ce menu."
+ COLOR = "Couleur du fond"
+ COLOR_DESC = "Permet de d\195\169finir la couleur du fond."
+ LOCK = "Bloquer"
+ LOCK_DESC = "Bloque le tableau \195\160 sa position actuelle. Alt+clic-droit pour le menu ou Alt+glisser pour le d\195\169placer quand il est bloqu\195\169."
+elseif GetLocale() == "esES" then
+ SCROLL_UP = "Desplazar hacia arriba"
+ SCROLL_DOWN = "Desplazar hacia abajo"
+ HINT = "Consejo"
+ DETACH = "Separar"
+ DETACH_DESC = "Separa el tooltip de su fuente."
+ SIZE = "Tama\195\177o"
+ SIZE_DESC = "Escala el tooltip"
+ CLOSE_MENU = "Cerrar men\195\186"
+ CLOSE_MENU_DESC = "Cierra el men\195\186"
+ COLOR = "Color de fondo"
+ COLOR_DESC = "Establece el color de fondo"
+ LOCK = "Bloquear"
+ LOCK_DESC = "Bloquea el tooltip en su posici\195\179n actual. Clic+Alt para el men\195\186 y arrastra+Alt para arrastrarlo cuando est\195\161 bloqueado"
+elseif GetLocale() == "ruRU" then
+ SCROLL_UP = "Прокрутка вверх"
+ SCROLL_DOWN = "Прокрутка вниз"
+ HINT = "Совет"
+ DETACH = "Отделить"
+ DETACH_DESC = "Отделить планшет от его источника."
+ SIZE = "Размер"
+ SIZE_DESC = "Масштаб планшета."
+ CLOSE_MENU = "Закрыть меню"
+ CLOSE_MENU_DESC = "Закрыть меню."
+ COLOR = "Цвет фона"
+ COLOR_DESC = "Установить цвет фона."
+ LOCK = "Зафиксировать"
+ LOCK_DESC = "Зафиксировать планшет в его текущем позиции. Alt+ПКМ для меню или Alt+перетаскивание для перетаскивания когда планшет зафиксирован."
+end
+
+local start = GetTime()
+local wrap
+local GetProfileInfo
+if DEBUG then
+ local tree = {}
+ local treeMemories = {}
+ local treeTimes = {}
+ local memories = {}
+ local times = {}
+ function wrap(value, name)
+ if type(value) == "function" then
+ local oldFunction = value
+ memories[name] = 0
+ times[name] = 0
+ return function(self, ...)
+ local pos = #tree
+ tree[#tree+1] = name
+ treeMemories[#treeMemories+1] = 0
+ treeTimes[#treeTimes+1] = 0
+ local t, mem = GetTime(), gcinfo()
+ local r1, r2, r3, r4, r5, r6, r7, r8 = oldFunction(self, ...)
+ mem, t = gcinfo() - mem, GetTime() - t
+ if pos > 0 then
+ treeMemories[pos] = treeMemories[pos] + mem
+ treeTimes[pos] = treeTimes[pos] + t
+ end
+ local otherMem = table.remove(treeMemories)
+ if mem - otherMem > 0 then
+ memories[name] = memories[name] + mem - otherMem
+ end
+ times[name] = times[name] + t - table.remove(treeTimes)
+ table.remove(tree)
+ return r1, r2, r3, r4, r5, r6, r7, r8
+ end
+ end
+ end
+
+ function GetProfileInfo()
+ return GetTime() - start, times, memories
+ end
+else
+ function wrap(value)
+ return value
+ end
+end
+
+local function GetMainFrame()
+ if UIParent:IsShown() then
+ return UIParent
+ end
+ local f = GetUIPanel("fullscreen")
+ if f and f:IsShown() then
+ return f
+ end
+ return nil
+end
+GetMainFrame = wrap(GetMainFrame, "GetMainFrame")
+
+local MIN_TOOLTIP_SIZE = 200
+local TESTSTRING_EXTRA_WIDTH = 8
+local Tablet = {}
+local Dewdrop = nil
+local CleanCategoryPool
+local pool = {}
+
+local function del(t)
+ setmetatable(t, nil)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t[''] = true
+ t[''] = nil
+ pool[t] = true
+ return nil
+end
+
+local function copy(parent)
+ local t = next(pool)
+ if not t then
+ t = {}
+ else
+ pool[t] = nil
+ end
+ if parent then
+ for k,v in pairs(parent) do
+ t[k] = v
+ end
+ setmetatable(t, getmetatable(parent))
+ end
+ return t
+end
+
+local function new(...)
+ local t = next(pool)
+ if not t then
+ t = {}
+ else
+ pool[t] = nil
+ end
+
+ for i = 1, select('#', ...), 2 do
+ local k = select(i, ...)
+ if k then
+ t[k] = select(i+1, ...)
+ else
+ break
+ end
+ end
+ return t
+end
+
+local tmp
+tmp = setmetatable({}, {__index = function(self, key)
+ local t = {}
+ tmp[key] = function(...)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ for i = 1, select('#', ...), 2 do
+ local k = select(i, ...)
+ if k then
+ t[k] = select(i+1, ...)
+ else
+ break
+ end
+ end
+ return t
+ end
+ return tmp[key]
+end})
+
+local headerSize, normalSize
+if GameTooltipHeaderText then
+ -- headerSize = select(2,GameTooltipHeaderText:GetFont())
+ headerSize = 5
+else
+ headerSize = 14
+end
+if GameTooltipText then
+ normalSize = select(2,GameTooltipText:GetFont())
+else
+ normalSize = 12
+end
+local tooltip
+local testString
+local TabletData = {}
+local Category = {}
+local Line = {}
+local function getTestWidth(font, size, text)
+ if not testString then
+ return MIN_TOOLTIP_SIZE + 40
+ end
+ testString:SetWidth(0)
+ testString:SetFontObject(font)
+ local a,_,b = font:GetFont()
+ testString:SetFont(a, size, b)
+ testString:SetText(text)
+ return testString:GetStringWidth()-- + TESTSTRING_EXTRA_WIDTH
+end
+getTestWidth = wrap(getTestWidth, "getTestWidth")
+do
+ local TabletData_mt = { __index = TabletData }
+ function TabletData:new(tablet)
+ local self = new()
+ self.categories = new()
+ self.id = 0
+ self.width = 0 -- (MIN_TOOLTIP_SIZE - 20)*tablet.fontSizePercent
+ self.tablet = tablet
+ self.title = nil
+ self.titleR, self.titleG, self.titleB = nil, nil, nil
+ self.num_lines = 0
+ setmetatable(self, TabletData_mt)
+ return self
+ end
+ TabletData.new = wrap(TabletData.new, "TabletData:new")
+
+ function TabletData:checkMinWidth()
+ local min = self.minWidth or MIN_TOOLTIP_SIZE
+ local width = (min - 20)*self.tablet.fontSizePercent
+ if self.width < width then
+ self.width = width
+ end
+ end
+ TabletData.checkMinWidth = wrap(TabletData.checkMinWidth, "TabletData:checkMinWidth")
+
+ function TabletData:del()
+ for k, v in ipairs(self.categories) do
+ v:del()
+ end
+ del(self.categories)
+ del(self)
+ end
+ TabletData.del = wrap(TabletData.del, "TabletData:del")
+
+ function TabletData:Display()
+ if self.title and (self.tablet == tooltip or self.tablet.registration.showTitleWhenDetached) then
+ local info = new(
+ 'hideBlankLine', true,
+ 'text', self.title,
+ 'justify', "CENTER",
+ 'font', GameTooltipHeaderText,
+ 'isTitle', true
+ )
+ if self.titleR then
+ info.textR = self.titleR
+ info.textG = self.titleG
+ info.textB = self.titleB
+ end
+ self:AddCategory(info, 1)
+ del(info)
+ end
+ if self.tablet == tooltip or self.tablet.registration.showHintWhenDetached then
+ if self.hint then
+ self:AddCategory(nil):AddLine(
+ 'text', HINT .. ": " .. self.hint,
+ 'textR', 0,
+ 'textG', 1,
+ 'textB', 0,
+ 'wrap', true
+ )
+ end
+ end
+
+ local tabletData = self.tabletData
+ for k, v in ipairs(self.categories) do
+ local width
+ if v.columns <= 2 then
+ width = v.x1
+ else
+ width = (v.columns - 1)*20
+ for i = 1, v.columns do
+ width = width + v['x' .. i]
+ end
+ end
+ if self.width < width then
+ self.width = width
+ end
+ end
+
+ local good = false
+ local lastTitle = true
+ for k, v in ipairs(self.categories) do
+ if lastTitle then
+ v.hideBlankLine = true
+ lastTitle = false
+ end
+ if v:Display(self.tablet) and (not v.isTitle or not self.tablet.registration.hideWhenEmpty or next(self.categories, k)) then
+ good = true
+ end
+ if v.isTitle then
+ lastTitle = true
+ end
+ end
+ if not good then
+ if self.tablet == tooltip or not self.tablet.registration.hideWhenEmpty then
+ local width
+ local info = new(
+ 'hideBlankLine', true,
+ 'text', self.title,
+ 'justify', "CENTER",
+ 'font', GameTooltipHeaderText,
+ 'isTitle', true
+ )
+ local cat = self:AddCategory(info)
+ del(info)
+ self.width = self.categories[#self.categories].x1
+ cat:Display(self.tablet)
+ else
+ self.tablet:__Hide()
+ self.tablet.tmpHidden = true
+ end
+ else
+ self.tablet:__Show()
+ self.tablet.tmpHidden = nil
+ end
+ end
+ TabletData.Display = wrap(TabletData.Display, "TabletData:Display")
+
+ function TabletData:AddCategory(info, index)
+ local made = false
+ if not info then
+ made = true
+ info = new()
+ end
+ local cat = Category:new(self, info)
+ if index then
+ table.insert(self.categories, index, cat)
+ else
+ self.categories[#self.categories+1] = cat
+ end
+ if made then
+ del(info)
+ end
+ return cat
+ end
+ TabletData.AddCategory = wrap(TabletData.AddCategory, "TabletData:AddCategory")
+
+ function TabletData:SetHint(hint)
+ self.hint = hint
+ end
+ TabletData.SetHint = wrap(TabletData.SetHint, "TabletData:SetHint")
+
+ function TabletData:SetTitle(title)
+ self.title = title or "Title"
+ end
+ TabletData.SetTitle = wrap(TabletData.SetTitle, "TabletData:SetTitle")
+
+ function TabletData:SetTitleColor(r, g, b)
+ self.titleR = r
+ self.titleG = g
+ self.titleB = b
+ end
+ TabletData.SetTitleColor = wrap(TabletData.SetTitleColor, "TabletData:SetTitleColor")
+end
+do
+ local Category_mt = { __index = Category }
+ function Category:new(tabletData, info, superCategory)
+ local self = copy(info)
+ if superCategory and not self.noInherit then
+ self.superCategory = superCategory.superCategory
+ for k, v in pairs(superCategory) do
+ if k:find("^child_") then
+ local k = strsub(k, 7)
+ if self[k] == nil then
+ self[k] = v
+ end
+ end
+ end
+ self.columns = superCategory.columns
+ else
+ self.superCategory = self
+ end
+ self.tabletData = tabletData
+ self.lines = new()
+ if not self.columns then
+ self.columns = 1
+ end
+ for i = 1, self.columns do
+ self['x' .. i] = 0
+ end
+ setmetatable(self, Category_mt)
+ self.lastWasTitle = nil
+ local good = self.text
+ if not good then
+ for i = 2, self.columns do
+ if self['text' .. i] then
+ good = true
+ break
+ end
+ end
+ end
+ if good then
+ local x = new(
+ 'category', category,
+ 'text', self.text,
+ 'fakeChild', true,
+ 'func', self.func,
+ 'onEnterFunc', self.onEnterFunc,
+ 'onLeaveFunc', self.onLeaveFunc,
+ 'hasCheck', self.hasCheck,
+ 'checked', self.checked,
+ 'checkIcon', self.checkIcon,
+ 'isRadio', self.isRadio,
+ 'font', self.font,
+ 'size', self.size,
+ 'wrap', self.wrap,
+ 'catStart', true,
+ 'indentation', self.indentation,
+ 'noInherit', true,
+ 'justify', self.justify,
+ 'isTitle', self.isTitle
+ )
+ local i = 1
+ while true do
+ local k = 'arg' .. i
+ local v = self[k]
+ if v == nil then
+ break
+ end
+ x[k] = v
+ i = i + 1
+ end
+ i = 1
+ while true do
+ local k = 'onEnterArg' .. i
+ local v = self[k]
+ if v == nil then
+ break
+ end
+ x[k] = v
+ i = i + 1
+ end
+ i = 1
+ while true do
+ local k = 'onLeaveArg' .. i
+ local v = self[k]
+ if v == nil then
+ break
+ end
+ x[k] = v
+ i = i + 1
+ end
+ if self.isTitle then
+ x.textR = self.textR or 1
+ x.textG = self.textG or 0.823529
+ x.textB = self.textB or 0
+ else
+ x.textR = self.textR or 1
+ x.textG = self.textG or 1
+ x.textB = self.textB or 1
+ end
+ for i = 2, self.columns do
+ x['text' .. i] = self['text' .. i]
+ x['text' .. i .. 'R'] = self['text' .. i .. 'R'] or self['textR' .. i] or 1
+ x['text' .. i .. 'G'] = self['text' .. i .. 'G'] or self['textG' .. i] or 1
+ x['text' .. i .. 'B'] = self['text' .. i .. 'B'] or self['textB' .. i] or 1
+ x['font' .. i] = self['font' .. i]
+ x['size' .. i] = self['size' .. i]
+ x['justify' .. i] = self['justify' .. i]
+ end
+ if self.checkIcon and self.checkIcon:find("^Interface\\Icons\\") then
+ x.checkCoordLeft = self.checkCoordLeft or 0.05
+ x.checkCoordRight = self.checkCoordRight or 0.95
+ x.checkCoordTop = self.checkCoordTop or 0.05
+ x.checkCoordBottom = self.checkCoordBottom or 0.95
+ else
+ x.checkCoordLeft = self.checkCoordLeft or 0
+ x.checkCoordRight = self.checkCoordRight or 1
+ x.checkCoordTop = self.checkCoordTop or 0
+ x.checkCoordBottom = self.checkCoordBottom or 1
+ end
+ x.checkColorR = self.checkColorR or 1
+ x.checkColorG = self.checkColorG or 1
+ x.checkColorB = self.checkColorB or 1
+ self:AddLine(x)
+ del(x)
+ self.lastWasTitle = true
+ end
+ return self
+ end
+ Category.new = wrap(Category.new, "Category:new")
+
+ function Category:del()
+ local prev = garbageLine
+ for k, v in pairs(self.lines) do
+ v:del()
+ end
+ del(self.lines)
+ del(self)
+ end
+ Category.del = wrap(Category.del, "Category:del")
+
+ function Category:AddLine(...)
+ self.lastWasTitle = nil
+ local line
+ local k1 = ...
+ if type(k1) == "table" then
+ local k2 = select(2, ...)
+ Line:new(self, k1, k2)
+ else
+ local info = new(...)
+ Line:new(self, info)
+ info = del(info)
+ end
+ end
+ Category.AddLine = wrap(Category.AddLine, "Category:AddLine")
+
+ function Category:AddCategory(...)
+ local lastWasTitle = self.lastWasTitle
+ self.lastWasTitle = nil
+ local info
+ local k1 = ...
+ if type(k1) == "table" then
+ info = k1
+ else
+ info = new(...)
+ end
+ if lastWasTitle or #self.lines == 0 then
+ info.hideBlankLine = true
+ end
+ local cat = Category:new(self.tabletData, info, self)
+ self.lines[#self.lines+1] = cat
+ if info ~= k1 then
+ info = del(info)
+ end
+ return cat
+ end
+ Category.AddCategory = wrap(Category.AddCategory, "Category:AddCategory")
+
+ function Category:HasChildren()
+ local hasChildren = false
+ for k, v in ipairs(self.lines) do
+ if v.HasChildren then
+ if v:HasChildren() then
+ return true
+ end
+ end
+ if not v.fakeChild then
+ return true
+ end
+ end
+ return false
+ end
+ Category.HasChildren = wrap(Category.HasChildren, "Category:HasChildren")
+
+ local lastWasTitle = false
+ function Category:Display(tablet)
+ if not self.isTitle and not self.showWithoutChildren and not self:HasChildren() then
+ return false
+ end
+ if not self.hideBlankLine and not lastWasTitle then
+ local info = new(
+ 'blank', true,
+ 'fakeChild', true,
+ 'noInherit', true
+ )
+ self:AddLine(info, 1)
+ del(info)
+ end
+ local good = false
+ if #self.lines > 0 then
+ self.tabletData.id = self.tabletData.id + 1
+ self.id = self.tabletData.id
+ for k, v in ipairs(self.lines) do
+ if v:Display(tablet) then
+ good = true
+ end
+ end
+ end
+ lastWasTitle = self.isTitle
+ return good
+ end
+ Category.Display = wrap(Category.Display, "Category:Display")
+end
+do
+ local Line_mt = { __index = Line }
+ function Line:new(category, info, position)
+ local self = copy(info)
+ if not info.noInherit then
+ for k, v in pairs(category) do
+ if k:find("^child_") then
+ local k = strsub(k, 7)
+ if self[k] == nil then
+ self[k] = v
+ end
+ end
+ end
+ end
+ self.category = category
+ if position then
+ table.insert(category.lines, position, self)
+ else
+ category.lines[#category.lines+1] = self
+ end
+ setmetatable(self, Line_mt)
+ local n = category.tabletData.num_lines + 1
+ category.tabletData.num_lines = n
+ if n == 10 then
+ category.tabletData:checkMinWidth()
+ end
+ local columns = category.columns
+ if columns == 1 then
+ if not self.justify then
+ self.justify = "LEFT"
+ end
+ elseif columns == 2 then
+ self.justify = "LEFT"
+ self.justify2 = "RIGHT"
+ if self.wrap then
+ self.wrap2 = false
+ end
+ else
+ for i = 2, columns-1 do
+ if not self['justify' .. i] then
+ self['justify' .. i] = "CENTER"
+ end
+ end
+ if not self.justify then
+ self.justify = "LEFT"
+ end
+ if not self['justify' .. columns] then
+ self['justify' .. columns] = "RIGHT"
+ end
+ if self.wrap then
+ for i = 2, columns do
+ self['wrap' .. i] = false
+ end
+ else
+ for i = 2, columns do
+ if self['wrap' .. i] then
+ for j = i+1, columns do
+ self['wrap' .. i] = false
+ end
+ break
+ end
+ end
+ end
+ end
+ if not self.indentation or self.indentation < 0 then
+ self.indentation = 0
+ end
+ if not self.font then
+ self.font = GameTooltipText
+ end
+ for i = 2, columns do
+ if not self['font' .. i] then
+ self['font' .. i] = self.font
+ end
+ end
+ if not self.size then
+ self.size = select(2,self.font:GetFont())
+ end
+ for i = 2, columns do
+ if not self['size' .. i] then
+ self['size' .. i] = select(2,self['font' .. i]:GetFont())
+ end
+ end
+ if self.checkIcon and self.checkIcon:find("^Interface\\Icons\\") then
+ if not self.checkCoordLeft then
+ self.checkCoordLeft = 0.05
+ end
+ if not self.checkCoordRight then
+ self.checkCoordRight = 0.95
+ end
+ if not self.checkCoordTop then
+ self.checkCoordTop = 0.05
+ end
+ if not self.checkCoordBottom then
+ self.checkCoordBottom = 0.95
+ end
+ else
+ if not self.checkCoordLeft then
+ self.checkCoordLeft = 0
+ end
+ if not self.checkCoordRight then
+ self.checkCoordRight = 1
+ end
+ if not self.checkCoordTop then
+ self.checkCoordTop = 0
+ end
+ if not self.checkCoordBottom then
+ self.checkCoordBottom = 1
+ end
+ end
+ if not self.checkColorR then
+ self.checkColorR = 1
+ end
+ if not self.checkColorG then
+ self.checkColorG = 1
+ end
+ if not self.checkColorB then
+ self.checkColorB = 1
+ end
+
+ local fontSizePercent = category.tabletData.tablet.fontSizePercent
+
+ local w = 0
+ self.checkWidth = 0
+ testString = category.tabletData.tablet.buttons[1].col1
+ if self.text then
+ if not self.wrap then
+ local testWidth = getTestWidth(self.font, self.size * fontSizePercent, self.text)
+ local checkWidth = self.hasCheck and self.size * fontSizePercent or 0
+ self.checkWidth = checkWidth
+ w = testWidth + self.indentation * fontSizePercent + checkWidth
+ if category.superCategory.x1 < w then
+ category.superCategory.x1 = w
+ end
+ else
+ if columns == 1 then
+ local testWidth = getTestWidth(self.font, self.size * fontSizePercent, self.text)
+ local checkWidth = self.hasCheck and self.size * fontSizePercent or 0
+ self.checkWidth = checkWidth
+ w = testWidth + self.indentation * fontSizePercent + checkWidth
+ if w > (MIN_TOOLTIP_SIZE - 20) * fontSizePercent then
+ w = (MIN_TOOLTIP_SIZE - 20) * fontSizePercent
+ end
+ else
+ w = MIN_TOOLTIP_SIZE * fontSizePercent / 2
+ end
+ if category.superCategory.x1 < w then
+ category.superCategory.x1 = w
+ end
+ end
+ end
+ if columns == 2 and self.text2 then
+ if not self.wrap2 then
+ local testWidth = getTestWidth(self.font2, self.size2 * fontSizePercent, self.text2)
+ w = w + 40 * fontSizePercent + testWidth
+ if category.superCategory.x1 < w then
+ category.superCategory.x1 = w
+ end
+ else
+ w = w + 40 * fontSizePercent + MIN_TOOLTIP_SIZE * fontSizePercent / 2
+ if category.superCategory.x1 < w then
+ category.superCategory.x1 = w
+ end
+ end
+ elseif columns >= 3 then
+ if self.text2 then
+ if not self.wrap2 then
+ local testWidth = getTestWidth(self.font2, self.size2 * fontSizePercent, self.text2)
+ local w = testWidth
+ if category.superCategory.x2 < w then
+ category.superCategory.x2 = w
+ end
+ else
+ local w = MIN_TOOLTIP_SIZE / 2
+ if category.superCategory.x2 < w then
+ category.superCategory.x2 = w
+ end
+ end
+ end
+
+ for i = 3, columns do
+ local text = self['text' .. i]
+ if text then
+ local x_i = 'x' .. i
+ if not self['wrap' .. i] then
+ local testWidth = getTestWidth(self['font' .. i], self['size' .. i] * fontSizePercent, text)
+ local w = testWidth
+ if category.superCategory[x_i] < w then
+ category.superCategory[x_i] = w
+ end
+ else
+ local w = MIN_TOOLTIP_SIZE / 2
+ if category.superCategory[x_i] < w then
+ category.superCategory[x_i] = w
+ end
+ end
+ end
+ end
+ end
+ return self
+ end
+ Line.new = wrap(Line.new, "Line:new")
+
+ function Line:del()
+ del(self)
+ end
+ Line.del = wrap(Line.del, "Line:del")
+
+ function Line:Display(tablet)
+ tablet:AddLine(self)
+ return true
+ end
+ Line.Display = wrap(Line.Display, "Line:Display")
+end
+
+local fake_ipairs
+do
+ local function iter(tmp, i)
+ i = i + 1
+ local x = tmp[i]
+ tmp[i] = nil
+ if x then
+ return i, x
+ end
+ end
+
+ local tmp = {}
+ function fake_ipairs(...)
+ for i = 1, select('#', ...) do
+ tmp[i] = select(i, ...)
+ end
+ return iter, tmp, 0
+ end
+ fake_ipairs = wrap(fake_ipairs, "fake_ipairs")
+end
+
+local function argunpack(t, key, i)
+ if not i then
+ i = 1
+ end
+ local k = key .. i
+ local v = t[k]
+ if v then
+ return v, argunpack(t, key, i+1)
+ end
+end
+argunpack = wrap(argunpack, "argunpack")
+
+
+local delstring, newstring
+do
+ local cache = {}
+ function delstring(t)
+ cache[#cache+1] = t
+ t:SetText(nil)
+ t:ClearAllPoints()
+ t:Hide()
+ t:SetParent(UIParent)
+ return nil
+ end
+ delstring = wrap(delstring, "delstring")
+ function newstring(parent)
+ if #cache ~= 0 then
+ local t = cache[#cache]
+ cache[#cache] = nil
+ t:Show()
+ t:SetParent(parent)
+ return t
+ end
+ local t = parent:CreateFontString(nil, "ARTWORK")
+ return t
+ end
+ newstring = wrap(newstring, "newstring")
+end
+
+local function button_OnEnter(this, ...)
+ if type(this.self:GetScript("OnEnter")) == "function" then
+ this.self:GetScript("OnEnter")(this.self, ...)
+ end
+ this.highlight:Show()
+ if this.onEnterFunc then
+ local success, ret = pcall(this.onEnterFunc, argunpack(this, 'onEnterArg'))
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+end
+button_OnEnter = wrap(button_OnEnter, "button_OnEnter")
+
+local function button_OnLeave(this, ...)
+ if type(this.self:GetScript("OnLeave")) == "function" then
+ this.self:GetScript("OnLeave")(this.self, ...)
+ end
+ this.highlight:Hide()
+ if this.onLeaveFunc then
+ local success, ret = pcall(this.onLeaveFunc, argunpack(this, 'onLeaveArg'))
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+end
+button_OnLeave = wrap(button_OnLeave, "button_OnLeave")
+local lastMouseDown
+local function button_OnClick(this, arg1, ...)
+ if this.self:HasScript("OnClick") and type(this.self:GetScript("OnClick")) == "function" then
+ this.self:GetScript("OnClick")(this.self, arg1, ...)
+ end
+ if arg1 == "RightButton" then
+ if this.self:HasScript("OnClick") and type(this.self:GetScript("OnClick")) == "function" then
+ this.self:GetScript("OnClick")(this.self, arg1, ...)
+ end
+ elseif arg1 == "LeftButton" then
+ if this.self.preventClick == nil or GetTime() > this.self.preventClick and GetTime() < lastMouseDown + 0.5 then
+ this.self.preventClick = nil
+ this.self.updating = true
+ this.self.preventRefresh = true
+ local success, ret = pcall(this.func, argunpack(this, 'arg'))
+ if not success then
+ geterrorhandler()(ret)
+ end
+ if this.self and this.self.registration then
+ this.self.preventRefresh = false
+ this.self:children()
+ this.self.updating = false
+ end
+ end
+ end
+end
+button_OnClick = wrap(button_OnClick, "button_OnClick")
+local function button_OnMouseUp(this, arg1, ...)
+ if this.self:HasScript("OnMouseUp") and type(this.self:GetScript("OnMouseUp")) == "function" then
+ this.self:GetScript("OnMouseUp")(this.self, arg1, ...)
+ end
+ if arg1 ~= "RightButton" then
+ if this.clicked then
+ local a,b,c,d,e = this.check:GetPoint(1)
+ this.check:SetPoint(a,b,c,d-1,e+1)
+ this.clicked = false
+ end
+ end
+end
+button_OnMouseUp = wrap(button_OnMouseUp, "button_OnMouseUp")
+local function button_OnMouseDown(this, arg1, ...)
+ if this.self:HasScript("OnMouseDown") and type(this.self:GetScript("OnMouseDown")) == "function" then
+ this.self:GetScript("OnMouseDown")(this.self, arg1, ...)
+ end
+ lastMouseDown = GetTime()
+ if arg1 ~= "RightButton" then
+ local a,b,c,d,e = this.check:GetPoint(1)
+ this.check:SetPoint(a,b,c,d+1,e-1)
+ this.clicked = true
+ end
+end
+button_OnMouseDown = wrap(button_OnMouseDown, "button_OnMouseDown")
+local function button_OnDragStart(this, ...)
+ local parent = this:GetParent() and this:GetParent().tablet
+ if parent:GetScript("OnDragStart") then
+ return parent:GetScript("OnDragStart")(parent, ...)
+ end
+end
+button_OnDragStart = wrap(button_OnDragStart, "button_OnDragStart")
+local function button_OnDragStop(this, ...)
+ local parent = this:GetParent() and this:GetParent().tablet
+ if parent:GetScript("OnDragStop") then
+ return parent:GetScript("OnDragStop")(parent, ...)
+ end
+end
+button_OnDragStop = wrap(button_OnDragStop, "button_OnDragStop")
+
+local num_buttons = 0
+local function NewLine(self)
+ if self.maxLines <= self.numLines then
+ self.maxLines = self.maxLines + 1
+ num_buttons = num_buttons + 1
+ local button = CreateFrame("Button", "Tablet20Button" .. num_buttons, self.scrollChild)
+ button:SetFrameLevel(12)
+ button.indentation = 0
+ local check = button:CreateTexture(nil, "ARTWORK")
+ local col1 = newstring(button)
+ testString = col1
+ local highlight = button:CreateTexture(nil, "BACKGROUND")
+ highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
+ button.highlight = highlight
+ highlight:SetBlendMode("ADD")
+ highlight:SetAllPoints(button)
+ highlight:Hide()
+ self.buttons[#self.buttons+1] = button
+ button.check = check
+ button.col1 = col1
+ col1:SetWidth(0)
+ if self.maxLines == 1 then
+ col1:SetFontObject(GameTooltipHeaderText)
+ col1:SetJustifyH("CENTER")
+ button:SetPoint("TOPLEFT", self.scrollFrame, "TOPLEFT", 3, -5)
+ else
+ col1:SetFontObject(GameTooltipText)
+ button:SetPoint("TOPLEFT", self.buttons[self.maxLines - 1], "BOTTOMLEFT", 0, -2)
+ end
+ button:SetScript("OnEnter", button_OnEnter)
+ button:SetScript("OnLeave", button_OnLeave)
+ button.check = check
+ button.self = self
+ button:SetPoint("RIGHT", self.scrollFrame, "RIGHT", -7, 0)
+ check.shown = false
+ check:SetPoint("TOPLEFT", button, "TOPLEFT")
+ col1:SetPoint("TOPLEFT", check, "TOPLEFT")
+ local size = select(2,GameTooltipText:GetFont())
+ check:SetHeight(size * 1.5)
+ check:SetWidth(size * 1.5)
+ check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
+ check:SetAlpha(0)
+ if not button.clicked then
+ button:SetScript("OnMouseWheel", self:GetScript("OnMouseWheel"))
+ button:EnableMouseWheel(true)
+ button:Hide()
+ end
+ check:Show()
+ col1:Hide()
+ end
+end
+NewLine = wrap(NewLine, "NewLine")
+
+local function RecalculateTabletHeight(detached)
+ detached.height_ = nil
+ if detached.registration and detached.registration.positionFunc then
+ local height = detached:GetHeight()
+ if height > 0 then
+ detached.height_ = height
+ else
+ local top, bottom
+ for i = 1, detached:GetNumPoints() do
+ local a,b,c,d,e = detached:GetPoint(i)
+
+ if a:find("^TOP") then
+ if c:find("^TOP") then
+ top = b:GetTop()
+ elseif c:find("^BOTTOM") then
+ top = b:GetBottom()
+ else
+ top = select(2,b:GetCenter())
+ end
+ if top then
+ top = top + e
+ end
+ elseif a:find("^BOTTOM") then
+ if c:find("^TOP") then
+ bottom = b:GetTop()
+ elseif c:find("^BOTTOM") then
+ bottom = b:GetBottom()
+ else
+ bottom = select(2,b:GetCenter())
+ end
+ if bottom then
+ bottom = bottom + e
+ end
+ end
+ end
+ if top and bottom then
+ detached.height_ = top - bottom
+ end
+ end
+ end
+end
+RecalculateTabletHeight = wrap(RecalculateTabletHeight, "RecalculateTabletHeight")
+
+local function GetTooltipHeight(self)
+ RecalculateTabletHeight(self)
+ if self.height_ then
+ local height = self:GetTop() and self:GetBottom() and self:GetTop() - self:GetBottom() or self:GetHeight()
+ if height == 0 then
+ height = self.height_
+ end
+ return height
+ end
+ if self.registration.maxHeight then
+ return self.registration.maxHeight
+ end
+ if self == tooltip then
+ return GetScreenHeight()*3/4
+ else
+ return GetScreenHeight()*2/3
+ end
+end
+GetTooltipHeight = wrap(GetTooltipHeight, "GetTooltipHeight")
+
+local overFrame = nil
+local detachedTooltips = {}
+local AcquireDetachedFrame, ReleaseDetachedFrame
+local function AcquireFrame(self, registration, data, detachedData)
+ if not detachedData then
+ detachedData = data
+ end
+ if tooltip then
+ tooltip.data = data
+ tooltip.detachedData = detachedData
+ local fontSizePercent = tooltip.data and tooltip.data.fontSizePercent or 1
+ --local fontSizePercent = 1
+ local transparency = tooltip.data and tooltip.data.transparency or 0.8
+ local r = tooltip.data and tooltip.data.r or 0
+ local g = tooltip.data and tooltip.data.g or 0
+ local b = tooltip.data and tooltip.data.b or 0
+ tooltip:SetFontSizePercent(fontSizePercent)
+ tooltip:SetTransparency(transparency)
+ tooltip:SetColor(r, g, b)
+ tooltip:SetParent(GetMainFrame())
+ tooltip:SetFrameStrata(registration.strata or "TOOLTIP")
+ tooltip:SetFrameLevel(10)
+ for _,frame in fake_ipairs(tooltip:GetChildren()) do
+ frame:SetFrameLevel(12)
+ end
+ else
+ tooltip = CreateFrame("Frame", "Tablet20Frame", UIParent, "BackdropTemplate")
+ tooltip:SetParent(GetMainFrame())
+ self.tooltip = tooltip
+ tooltip.data = data
+ tooltip.detachedData = detachedData
+ tooltip:EnableMouse(true)
+ tooltip:EnableMouseWheel(true)
+ tooltip:SetFrameStrata(registration.strata or "TOOLTIP")
+ tooltip:SetFrameLevel(10)
+ local backdrop = new(
+ 'bgFile', "Interface\\Buttons\\WHITE8X8",
+ 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
+ 'tile', true,
+ 'tileSize', 16,
+ 'edgeSize', 16,
+ 'insets', new(
+ 'left', 3,
+ 'right', 3,
+ 'top', 3,
+ 'bottom', 3
+ )
+ )
+ tooltip:SetBackdrop(backdrop)
+ del(backdrop.insets)
+ del(backdrop)
+ tooltip:SetBackdropColor(0, 0, 0, 1)
+
+ tooltip.numLines = 0
+ tooltip.owner = nil
+ tooltip.fontSizePercent = tooltip.data and tooltip.data.fontSizePercent or 1
+ tooltip.maxLines = 0
+ tooltip.buttons = {}
+ tooltip.transparency = tooltip.data and tooltip.data.transparency or 0.75
+ tooltip:SetBackdropColor(0, 0, 0, tooltip.transparency)
+ tooltip:SetBackdropBorderColor(1, 1, 1, tooltip.transparency)
+
+ tooltip:SetScript("OnUpdate", function(this, elapsed)
+ if not tooltip.updating and (not tooltip.enteredFrame or (overFrame and not MouseIsOver(overFrame))) then
+ tooltip.scrollFrame:SetVerticalScroll(0)
+ tooltip.slider:SetValue(0)
+ tooltip:Hide()
+ tooltip.registration.tooltip = nil
+ tooltip.registration = nil
+ overFrame = nil
+ end
+ end)
+
+ tooltip:SetScript("OnEnter", function(this)
+ if tooltip.clickable then
+ tooltip.enteredFrame = true
+ overFrame = nil
+ end
+ end)
+
+ tooltip:SetScript("OnLeave", function(this)
+ if not tooltip.updating then
+ tooltip.enteredFrame = false
+ end
+ end)
+
+ tooltip:SetScript("OnMouseWheel", function(this, arg1)
+ tooltip.updating = true
+ tooltip:Scroll(arg1 < 0)
+ tooltip.updating = false
+ end)
+
+ local scrollFrame = CreateFrame("ScrollFrame", "Tablet20FrameScrollFrame", tooltip)
+ scrollFrame:SetFrameLevel(11)
+ local scrollChild = CreateFrame("Frame", "Tablet20FrameScrollChild", scrollFrame)
+ scrollChild.tablet = tooltip
+ scrollFrame:SetScrollChild(scrollChild)
+ tooltip.scrollFrame = scrollFrame
+ tooltip.scrollChild = scrollChild
+ scrollFrame:SetPoint("TOPLEFT", 5, -5)
+ scrollFrame:SetPoint("TOPRIGHT", -5, -5)
+ scrollFrame:SetPoint("BOTTOMLEFT", 5, 5)
+ scrollFrame:SetPoint("BOTTOMRIGHT", -5, 5)
+ scrollChild:SetWidth(1)
+ scrollChild:SetHeight(1)
+ local slider = CreateFrame("Slider", "Tablet20FrameSlider", scrollFrame, "BackdropTemplate")
+ tooltip.slider = slider
+ slider:SetOrientation("VERTICAL")
+ slider:SetMinMaxValues(0, 1)
+ slider:SetValueStep(0.001)
+ slider:SetValue(0)
+ slider:SetWidth(8)
+ slider:SetPoint("TOPRIGHT", 0, 0)
+ slider:SetPoint("BOTTOMRIGHT", 0, 0)
+ slider:SetBackdrop(new(
+ 'bgFile', "Interface\\Buttons\\UI-SliderBar-Background",
+ 'edgeFile', "Interface\\Buttons\\UI-SliderBar-Border",
+ 'tile', true,
+ 'edgeSize', 8,
+ 'tileSize', 8,
+ 'insets', new(
+ 'left', 3,
+ 'right', 3,
+ 'top', 3,
+ 'bottom', 3
+ )
+ ))
+ slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
+ slider:SetScript("OnEnter", tooltip:GetScript("OnEnter"))
+ slider:SetScript("OnLeave", tooltip:GetScript("OnLeave"))
+ slider.tablet = tooltip
+ slider:SetScript("OnValueChanged", function(this)
+ local max = this.tablet.scrollChild:GetHeight() - this.tablet:GetHeight()
+
+ local val = this:GetValue() * max
+
+ if math.abs(this.tablet.scrollFrame:GetVerticalScroll() - val) < 1 then
+ return
+ end
+
+ this.tablet.scrollFrame:SetVerticalScroll(val)
+ end)
+
+ NewLine(tooltip)
+
+ function tooltip:SetOwner(o)
+ self:Hide(o)
+ self.owner = o
+ end
+ tooltip.SetOwner = wrap(tooltip.SetOwner, "tooltip:SetOwner")
+
+ function tooltip:IsOwned(o)
+ return self.owner == o
+ end
+ tooltip.IsOwned = wrap(tooltip.IsOwned, "tooltip:IsOwned")
+
+ function tooltip:ClearLines(hide)
+ CleanCategoryPool(self)
+ for i = 1, self.numLines do
+ local button = self.buttons[i]
+ local check = button.check
+ if not button.clicked or hide then
+ button:Hide()
+ end
+ check.shown = false
+ check:SetAlpha(0)
+ end
+ self.numLines = 0
+ end
+ tooltip.ClearLines = wrap(tooltip.ClearLines, "tooltip:ClearLines")
+
+ function tooltip:NumLines()
+ return self.numLines
+ end
+
+ local lastWidth
+ local old_tooltip_Hide = tooltip.Hide
+ tooltip.__Hide = old_tooltip_Hide
+ function tooltip:Hide(newOwner)
+ if self == tooltip or newOwner == nil then
+ old_tooltip_Hide(self)
+ end
+ self:ClearLines(true)
+ self.owner = nil
+ self.lastWidth = nil
+ self.tmpHidden = nil
+ end
+ tooltip.Hide = wrap(tooltip.Hide, "tooltip:Hide")
+
+ local old_tooltip_Show = tooltip.Show
+ tooltip.__Show = old_tooltip_Show
+ function tooltip:Show(tabletData)
+ if self.owner == nil or self.notInUse then
+ return
+ end
+ if not self.tmpHidden then
+ old_tooltip_Show(self)
+ end
+
+ testString = self.buttons[1].col1
+
+ local maxWidth = tabletData and tabletData.width or self:GetWidth() - 20
+ local hasWrap = false
+ local numColumns
+
+ local height = 20
+ self:SetWidth(maxWidth + 20)
+
+ for i = 1, self.numLines do
+ local button = self.buttons[i]
+ local col1 = button.col1
+ local col2 = button.col2
+ local check = button.check
+ button:SetWidth(maxWidth)
+ button:SetHeight(col2 and math.max(col1:GetHeight(), col2:GetHeight()) or col1:GetHeight())
+ height = height + button:GetHeight() + 2
+ if i == 1 then
+ button:SetPoint("TOPLEFT", self.scrollChild, "TOPLEFT", 5, -5)
+ else
+ button:SetPoint("TOPLEFT", self.buttons[i - 1], "BOTTOMLEFT", 0, -2)
+ end
+ if button.clicked then
+ check:SetPoint("TOPLEFT", button, "TOPLEFT", button.indentation * self.fontSizePercent + (check.width - check:GetWidth()) / 2 + 1, -1)
+ else
+ check:SetPoint("TOPLEFT", button, "TOPLEFT", button.indentation * self.fontSizePercent + (check.width - check:GetWidth()) / 2, 0)
+ end
+ button:Show()
+ end
+ self.scrollFrame:SetFrameLevel(11)
+ self.scrollChild:SetWidth(maxWidth)
+ self.scrollChild:SetHeight(height)
+ local maxHeight = GetTooltipHeight(self)
+ if height > maxHeight then
+ height = maxHeight
+ self.slider:Show()
+ else
+ self.slider:Hide()
+ end
+ self:SetHeight(height)
+ self.scrollFrame:SetScrollChild(self.scrollChild)
+ local val = self.scrollFrame:GetVerticalScroll()
+ local max = self.scrollChild:GetHeight() - self:GetHeight()
+ if val > max then
+ val = max
+ end
+ if val < 0 then
+ val = 0
+ end
+ self.scrollFrame:SetVerticalScroll(val)
+ -- TODO: In Dragonflight both values are 0?
+ if max > 0 then
+ self.slider:SetValue(val / max)
+ else
+ self.slider:SetValue(0)
+ end
+ end
+ tooltip.Show = wrap(tooltip.Show, "tooltip:Show")
+
+ function tooltip:AddLine(info)
+ local category = info.category.superCategory
+ local maxWidth = category.tabletData.width
+ local text = info.blank and "\n" or info.text
+ local id = info.id
+ local func = info.func
+ local checked = info.checked
+ local isRadio = info.isRadio
+ local checkTexture = info.checkTexture
+ local fontSizePercent = self.fontSizePercent
+ if not info.font then
+ info.font = GameTooltipText
+ end
+ if not info.size then
+ info.size = select(2,info.font:GetFont())
+ end
+ local catStart = false
+ local columns = category and category.columns or 1
+ local x_total = 0
+ local x1, x2
+ if category then
+ for i = 1, category.columns do
+ x_total = x_total + category['x' .. i]
+ end
+ x1, x2 = category.x1, category.x2
+ else
+ x1, x2 = 0, 0
+ end
+
+ self.numLines = self.numLines + 1
+ NewLine(self)
+ local num = self.numLines
+
+ local button = self.buttons[num]
+ button:Show()
+ button.col1:Show()
+ button.indentation = info.indentation
+ local col1 = button.col1
+ local check = button.check
+ do -- if columns >= 1 then
+ col1:SetWidth(0)
+ col1:SetFontObject(info.font)
+ local font,_,flags = info.font:GetFont()
+ col1:SetFont(font, info.size * fontSizePercent, flags)
+ col1:SetText(text)
+ col1:SetJustifyH(info.justify)
+ col1:Show()
+
+ if info.textR and info.textG and info.textB then
+ col1:SetTextColor(info.textR, info.textG, info.textB)
+ else
+ col1:SetTextColor(1, 0.823529, 0)
+ end
+ if columns < 2 then
+ local i = 2
+ while true do
+ local col = button['col' .. i]
+ if col then
+ button['col' .. i] = delstring(col)
+ else
+ break
+ end
+ i = i + 1
+ end
+ else
+ local i = 2
+ while true do
+ local col = button['col' .. i]
+ if not col then
+ button['col' .. i] = newstring(button)
+ col = button['col' .. i]
+ end
+ col:SetFontObject(info['font' .. i])
+ col:SetText(info['text' .. i])
+ col:Show()
+ local r,g,b = info['text' .. i .. 'R']
+ if r then
+ g = info['text' .. i .. 'G']
+ if g then
+ b = info['text' .. i .. 'B']
+ end
+ end
+ if b then
+ col:SetTextColor(r, g, b)
+ else
+ col:SetTextColor(1, 0.823529, 0)
+ end
+ local a,_,b = info.font2:GetFont()
+ col:SetFont(a, info['size' .. i] * fontSizePercent, b)
+ col:SetJustifyH(info['justify' .. i])
+ if columns == i then
+ if i == 2 then
+ col:SetPoint("TOPLEFT", col1, "TOPRIGHT", 40 * fontSizePercent, 0)
+ col:SetPoint("TOPRIGHT", button, "TOPRIGHT", -5, 0)
+ else
+ local col2 = button.col2
+ col2:ClearAllPoints()
+ col2:SetPoint("TOPLEFT", col1, "TOPRIGHT", (20 - info.indentation) * fontSizePercent, 0)
+ end
+ i = i + 1
+ while true do
+ local col = button['col' .. i]
+ if col then
+ button['col' .. i] = delstring(col)
+ else
+ break
+ end
+ i = i + 1
+ end
+ break
+ end
+ i = i + 1
+ end
+ end
+ end
+
+ check:SetWidth(info.size * fontSizePercent)
+ check:SetHeight(info.size * fontSizePercent)
+ check.width = info.size * fontSizePercent
+ if info.hasCheck then
+ check.shown = true
+ check:Show()
+ if isRadio then
+ check:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
+ if info.checked then
+ check:SetAlpha(1)
+ check:SetTexCoord(0.25, 0.5, 0, 1)
+ else
+ check:SetAlpha(self.transparency)
+ check:SetTexCoord(0, 0.25, 0, 1)
+ end
+ check:SetVertexColor(1, 1, 1)
+ else
+ if info.checkIcon then
+ check:SetTexture(info.checkIcon)
+ check:SetTexCoord(info.checkCoordLeft, info.checkCoordRight, info.checkCoordTop, info.checkCoordBottom)
+ check:SetVertexColor(info.checkColorR, info.checkColorG, info.checkColorB)
+ else
+ check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
+ check:SetWidth(info.size * fontSizePercent * 1.5)
+ check:SetHeight(info.size * fontSizePercent * 1.5)
+ check.width = info.size * fontSizePercent * 1.2
+ check:SetTexCoord(0, 1, 0, 1)
+ check:SetVertexColor(1, 1, 1)
+ end
+ check:SetAlpha(info.checked and 1 or 0)
+ end
+ col1:SetPoint("TOPLEFT", check, "TOPLEFT", check.width, 0)
+ else
+ col1:SetPoint("TOPLEFT", check, "TOPLEFT")
+ end
+ local col2 = button.col2
+ if columns == 1 then
+ col1:SetWidth(maxWidth)
+ elseif columns == 2 then
+ if info.wrap then
+ col1:SetWidth(maxWidth - col2:GetWidth() - 40 * fontSizePercent)
+ col2:SetWidth(0)
+ elseif info.wrap2 then
+ col1:SetWidth(0)
+ col2:SetWidth(maxWidth - col1:GetWidth() - 40 * fontSizePercent)
+ else
+ col1:SetWidth(0)
+ col2:SetWidth(0)
+ end
+ col2:ClearAllPoints()
+ col2:SetPoint("TOPRIGHT", button, "TOPRIGHT", 0, 0)
+ if not info.text2 then
+ col1:SetJustifyH(info.justify or "LEFT")
+ end
+ else
+ col1:SetWidth(x1 - info.checkWidth)
+ col2:SetWidth(x2)
+ local num = (category.tabletData.width - x_total) / (columns - 1)
+ col2:SetPoint("TOPLEFT", col1, "TOPRIGHT", num - info.indentation * fontSizePercent, 0)
+ local last = col2
+ for i = 3, category.columns do
+ local col = button['col' .. i]
+ col:SetWidth(category['x' .. i])
+ col:SetPoint("TOPLEFT", last, "TOPRIGHT", num, 0)
+ last = col
+ end
+ end
+ button.func = nil
+ button.onEnterFunc = nil
+ button.onLeaveFunc = nil
+ button:SetFrameLevel(12) -- hack suggested on forum. Added 06/17/2007. (hC)
+ if not self.locked or IsAltKeyDown() then
+ local func = info.func
+ if func then
+ if type(func) == "string" then
+ if type(info.arg1) ~= "table" then
+ Tablet:error("Cannot call method " .. info.func .. " on a non-table")
+ end
+ func = info.arg1[func]
+ if type(func) ~= "function" then
+ Tablet:error("Method " .. info.func .. " nonexistant")
+ end
+ else
+ if type(func) ~= "function" then
+ Tablet:error("func must be a function or method")
+ end
+ end
+ button.func = func
+ local i = 1
+ while true do
+ local k = 'arg' .. i
+ if button[k] ~= nil then
+ button[k] = nil
+ else
+ break
+ end
+ i = i + 1
+ end
+ i = 1
+ while true do
+ local k = 'arg' .. i
+ local v = info[k]
+ if v == nil then
+ break
+ end
+ button[k] = v
+ i = i + 1
+ end
+ local onEnterFunc = info.onEnterFunc
+ if onEnterFunc then
+ if type(onEnterFunc) == "string" then
+ if type(info.onEnterArg1) ~= "table" then
+ Tablet:error("Cannot call method " .. info.onEnterFunc .. " on a non-table")
+ end
+ onEventFunc = info.onEnterArg1[onEnterFunc]
+ if type(onEnterFunc) ~= "function" then
+ Tablet:error("Method " .. info.onEnterFunc .. " nonexistant")
+ end
+ else
+ if type(onEnterFunc) ~= "function" then
+ Tablet:error("func must be a function or method")
+ end
+ end
+ button.onEnterFunc = onEnterFunc
+ local i = 1
+ while true do
+ local k = 'onEnterArg' .. i
+ if button[k] ~= nil then
+ button[k] = nil
+ else
+ break
+ end
+ i = i + 1
+ end
+ i = 1
+ while true do
+ local k = 'onEnterArg' .. i
+ local v = info[k]
+ if v == nil then
+ break
+ end
+ button[k] = v
+ i = i + 1
+ end
+ end
+ local onLeaveFunc = info.onLeaveFunc
+ if onLeaveFunc then
+ if type(onLeaveFunc) == "string" then
+ if type(info.onLeaveArg1) ~= "table" then
+ Tablet:error("Cannot call method " .. info.onLeaveFunc .. " on a non-table")
+ end
+ onLeaveFunc = info.onLeaveArg1[onLeaveFunc]
+ if type(onLeaveFunc) ~= "function" then
+ Tablet:error("Method " .. info.onLeaveFunc .. " nonexistant")
+ end
+ else
+ if type(onLeaveFunc) ~= "function" then
+ Tablet:error("func must be a function or method")
+ end
+ end
+ button.onLeaveFunc = onLeaveFunc
+ local i = 1
+ while true do
+ local k = 'onLeaveArg' .. i
+ if button[k] ~= nil then
+ button[k] = nil
+ else
+ break
+ end
+ i = i + 1
+ end
+ i = 1
+ while true do
+ local k = 'onLeaveArg' .. i
+ local v = info[k]
+ if v == nil then
+ break
+ end
+ button[k] = v
+ i = i + 1
+ end
+ end
+ button.self = self
+ button:SetScript("OnMouseUp", button_OnMouseUp)
+ button:SetScript("OnMouseDown", button_OnMouseDown)
+ button:RegisterForDrag("LeftButton")
+ button:SetScript("OnDragStart", button_OnDragStart)
+ button:SetScript("OnDragStop", button_OnDragStop)
+ button:SetScript("OnClick", button_OnClick)
+ if button.clicked then
+ button:SetButtonState("PUSHED")
+ end
+ button:EnableMouse(true)
+ else
+ button:SetScript("OnMouseDown", nil)
+ button:SetScript("OnMouseUp", nil)
+ button:RegisterForDrag()
+ button:SetScript("OnDragStart", nil)
+ button:SetScript("OnDragStop", nil)
+ button:SetScript("OnClick", nil)
+ button:EnableMouse(false)
+ end
+ else
+ button:SetScript("OnMouseDown", nil)
+ button:SetScript("OnMouseUp", nil)
+ button:RegisterForDrag()
+ button:SetScript("OnDragStart", nil)
+ button:SetScript("OnDragStop", nil)
+ button:SetScript("OnClick", nil)
+ button:EnableMouse(false)
+ end
+ end
+ tooltip.AddLine = wrap(tooltip.AddLine, "tooltip:AddLine")
+
+ function tooltip:SetFontSizePercent(percent)
+ local data, detachedData = self.data, self.detachedData
+ if detachedData and detachedData.detached then
+ data = detachedData
+ end
+ local lastSize = self.fontSizePercent
+ percent = tonumber(percent) or 1
+ if percent < 0.25 then
+ percent = 0.25
+ elseif percent > 4 then
+ percent = 4
+ end
+ self.fontSizePercent = percent
+ if data then
+ data.fontSizePercent = percent
+ end
+ local ratio = self.fontSizePercent / lastSize
+ for i = 1, self.numLines do
+ local button = self.buttons[i]
+ local j = 1
+ while true do
+ local col = button['col' .. j]
+ if not col then
+ break
+ end
+ local font, size, flags = col:GetFont()
+ col:SetFont(font, size * ratio, flags)
+ j = j + 1
+ end
+ local check = button.check
+ check.width = check.width * ratio
+ check:SetWidth(check:GetWidth() * ratio)
+ check:SetHeight(check:GetHeight() * ratio)
+ end
+ self:SetWidth((self:GetWidth() - 51) * ratio + 51)
+ self:SetHeight((self:GetHeight() - 51) * ratio + 51)
+ if self:IsShown() and self.children then
+ self:children()
+ self:Show()
+ end
+ end
+ tooltip.SetFontSizePercent = wrap(tooltip.SetFontSizePercent, "tooltip:SetFontSizePercent")
+
+ function tooltip:GetFontSizePercent()
+ return self.fontSizePercent
+ end
+
+ function tooltip:SetTransparency(alpha)
+ local data, detachedData = self.data, self.detachedData
+ if detachedData and detachedData.detached then
+ data = detachedData
+ end
+ self.transparency = alpha
+ if data then
+ data.transparency = alpha ~= 0.75 and alpha or nil
+ end
+ self:SetBackdropColor(self.r or 0, self.g or 0, self.b or 0, alpha)
+ self:SetBackdropBorderColor(1, 1, 1, alpha)
+ self.slider:SetBackdropColor(self.r or 0, self.g or 0, self.b or 0, alpha)
+ self.slider:SetBackdropBorderColor(1, 1, 1, alpha)
+ end
+ tooltip.SetTransparency = wrap(tooltip.SetTransparency, "tooltip:SetTransparency")
+
+ function tooltip:GetTransparency()
+ return self.transparency
+ end
+
+ function tooltip:SetColor(r, g, b)
+ local data, detachedData = self.data, self.detachedData
+ if detachedData and detachedData.detached then
+ data = detachedData
+ end
+ self.r = r
+ self.g = g
+ self.b = b
+ if data then
+ data.r = r ~= 0 and r or nil
+ data.g = g ~= 0 and g or nil
+ data.b = b ~= 0 and b or nil
+ end
+ self:SetBackdropColor(r or 0, g or 0, b or 0, self.transparency)
+ self:SetBackdropBorderColor(1, 1, 1, self.transparency)
+ end
+ tooltip.SetColor = wrap(tooltip.SetColor, "tooltip:SetColor")
+
+ function tooltip:GetColor()
+ return self.r, self.g, self.b
+ end
+
+ function tooltip:Scroll(down)
+ local val
+ local max = self.scrollChild:GetHeight() - self:GetHeight()
+ if down then
+ if IsShiftKeyDown() then
+ val = max
+ else
+ val = self.scrollFrame:GetVerticalScroll() + 36
+ if val > max then
+ val = max
+ end
+ end
+ else
+ if IsShiftKeyDown() then
+ val = 0
+ else
+ val = self.scrollFrame:GetVerticalScroll() - 36
+ if val < 0 then
+ val = 0
+ end
+ end
+ end
+ self.scrollFrame:SetVerticalScroll(val)
+ self.slider:SetValue(val/max)
+ end
+ tooltip.Scroll = wrap(tooltip.Scroll, "tooltip:Scroll")
+
+ function tooltip.Detach(tooltip)
+ local owner = tooltip.owner
+ tooltip:Hide()
+ if not tooltip.detachedData then
+ self:error("You cannot detach if detachedData is not present")
+ end
+ tooltip.detachedData.detached = true
+ local detached = AcquireDetachedFrame(self, tooltip.registration, tooltip.data, tooltip.detachedData)
+
+ detached.menu, tooltip.menu = tooltip.menu, nil
+ detached.runChildren = tooltip.runChildren
+ detached.children = tooltip.children
+ detached.minWidth = tooltip.minWidth
+ tooltip.runChildren = nil
+ tooltip.children = nil
+ tooltip.minWidth = nil
+ detached:SetOwner(owner)
+ detached:children()
+ detached:Show()
+ end
+ tooltip.Detach = wrap(tooltip.Detach, "tooltip:Detach")
+
+ end
+
+ tooltip.registration = registration
+ registration.tooltip = tooltip
+ return tooltip
+end
+AcquireFrame = wrap(AcquireFrame, "AcquireFrame")
+
+function ReleaseDetachedFrame(self, data, detachedData)
+ if not detachedData then
+ detachedData = data
+ end
+ for _, detached in ipairs(detachedTooltips) do
+ if detached.detachedData == detachedData then
+ detached.notInUse = true
+ detached:Hide()
+ detached.registration.tooltip = nil
+ detached.registration = nil
+ detached.detachedData = nil
+ end
+ end
+end
+ReleaseDetachedFrame = wrap(ReleaseDetachedFrame, "ReleaseDetachedFrame")
+
+local StartCheckingAlt, StopCheckingAlt
+do
+ local frame
+ function StartCheckingAlt(func)
+ if not frame then
+ frame = CreateFrame("Frame")
+ frame:SetScript("OnEvent", function(this, _, modifier)
+ if modifier == "LALT" or modifier == "RALT" then
+ this.func()
+ end
+ end)
+ end
+ frame:RegisterEvent("MODIFIER_STATE_CHANGED")
+ frame.func = func
+ end
+ StartCheckingAlt = wrap(StartCheckingAlt, "StartCheckingAlt")
+ function StopCheckingAlt()
+ if frame then
+ frame:UnregisterEvent("MODIFIER_STATE_CHANGED")
+ end
+ end
+ StopCheckingAlt = wrap(StopCheckingAlt, "StopCheckingAlt")
+end
+
+function AcquireDetachedFrame(self, registration, data, detachedData)
+ if not detachedData then
+ detachedData = data
+ end
+ for _, detached in ipairs(detachedTooltips) do
+ if detached.notInUse then
+ detached.data = data
+ detached.detachedData = detachedData
+ detached.notInUse = nil
+ local fontSizePercent = detachedData.fontSizePercent or 1
+ local transparency = detachedData.transparency or 0.75
+ local r = detachedData.r or 0
+ local g = detachedData.g or 0
+ local b = detachedData.b or 0
+ detached:SetFontSizePercent(fontSizePercent)
+ detached:SetTransparency(transparency)
+ detached:SetColor(r, g, b)
+ detached:ClearAllPoints()
+ detached:SetWidth(0)
+ detached:SetHeight(0)
+ if not registration.strata then
+ detached:SetFrameStrata("BACKGROUND")
+ end
+ if not registration.frameLevel then
+ detached:SetFrameLevel(10)
+ for _,frame in fake_ipairs(detached:GetChildren()) do
+ frame:SetFrameLevel(12)
+ end
+ end
+ detached:SetParent(registration.parent or GetMainFrame())
+ if registration.strata then
+ detached:SetFrameStrata(registration.strata)
+ end
+ if registration.frameLevel then
+ detached:SetFrameLevel(registration.frameLevel)
+ for _,frame in fake_ipairs(detached:GetChildren()) do
+ frame:SetFrameLevel(registration.frameLevel+2)
+ end
+ end
+ detached.height_ = nil
+ if registration.positionFunc then
+ registration.positionFunc(detached)
+ RecalculateTabletHeight(detached)
+ else
+ detached:SetPoint(detachedData.anchor or "CENTER", GetMainFrame(), detachedData.anchor or "CENTER", detachedData.offsetx or 0, detachedData.offsety or 0)
+ end
+ detached.registration = registration
+ registration.tooltip = detached
+ if registration.movable == false then
+ detached:RegisterForDrag()
+ else
+ detached:RegisterForDrag("LeftButton")
+ end
+ return detached
+ end
+ end
+
+ if not Dewdrop and AceLibrary:HasInstance("Dewdrop-2.0") then
+ Dewdrop = AceLibrary("Dewdrop-2.0")
+ end
+ StartCheckingAlt(function()
+ for _, detached in ipairs(detachedTooltips) do
+ if detached:IsShown() and detached.locked then
+ detached:EnableMouse(IsAltKeyDown())
+ detached:children()
+ if detached.moving then
+ local a1 = arg1
+ arg1 = "LeftButton"
+ if type(detached:GetScript("OnMouseUp")) == "function" then
+ detached:GetScript("OnMouseUp")(detached, arg1)
+ end
+ arg1 = a1
+ end
+ end
+ end
+ end)
+ if not tooltip then
+ AcquireFrame(self, {})
+ end
+ local detached = CreateFrame("Frame", "Tablet20DetachedFrame" .. (#detachedTooltips + 1), GetMainFrame(), "BackdropTemplate")
+ detachedTooltips[#detachedTooltips+1] = detached
+ detached.notInUse = true
+ detached:EnableMouse(not data.locked)
+ detached:EnableMouseWheel(true)
+ detached:SetMovable(true)
+ detached:SetPoint(data.anchor or "CENTER", GetMainFrame(), data.anchor or "CENTER", data.offsetx or 0, data.offsety or 0)
+
+ detached.numLines = 0
+ detached.owner = nil
+ detached.fontSizePercent = 1
+ detached.maxLines = 0
+ detached.buttons = {}
+ detached.transparency = 1
+ detached.r = 0
+ detached.g = 0
+ detached.b = 0
+ detached:SetFrameStrata(registration and registration.strata or "BACKGROUND")
+ detached:SetBackdrop(tmp.a(
+ 'bgFile', "Interface\\Buttons\\WHITE8X8",
+ 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
+ 'tile', true,
+ 'tileSize', 16,
+ 'edgeSize', 16,
+ 'insets', tmp.b(
+ 'left', 3,
+ 'right', 3,
+ 'top', 3,
+ 'bottom', 3
+ )
+ ))
+ detached.locked = detachedData.locked
+ detached:EnableMouse(not detached.locked)
+
+ local width = GetScreenWidth()
+ local height = GetScreenHeight()
+ if registration and registration.movable == false then
+ detached:RegisterForDrag()
+ else
+ detached:RegisterForDrag("LeftButton")
+ end
+ detached:SetScript("OnDragStart", function(this)
+ detached:StartMoving()
+ detached.moving = true
+ end)
+
+ detached:SetScript("OnDragStop", function(this)
+ detached:StopMovingOrSizing()
+ detached.moving = nil
+ detached:SetClampedToScreen(true)
+ detached:SetClampedToScreen(false)
+ local anchor
+ local offsetx
+ local offsety
+ if detached:GetTop() + detached:GetBottom() < height then
+ anchor = "BOTTOM"
+ offsety = detached:GetBottom()
+ if offsety < 0 then
+ offsety = 0
+ end
+ if offsety < MainMenuBar:GetTop() and MainMenuBar:IsVisible() then
+ offsety = MainMenuBar:GetTop()
+ end
+ local top = 0
+ if FuBar then
+ for i = 1, FuBar:GetNumPanels() do
+ local panel = FuBar:GetPanel(i)
+ if panel:GetAttachPoint() == "BOTTOM" then
+ if panel.frame:GetTop() > top then
+ top = panel.frame:GetTop()
+ break
+ end
+ end
+ end
+ end
+ if offsety < top then
+ offsety = top
+ end
+ else
+ anchor = "TOP"
+ offsety = detached:GetTop() - height
+ if offsety > 0 then
+ offsety = 0
+ end
+ local bottom = GetScreenHeight()
+ if FuBar then
+ for i = 1, FuBar:GetNumPanels() do
+ local panel = FuBar:GetPanel(i)
+ if panel:GetAttachPoint() == "TOP" then
+ if panel.frame:GetBottom() < bottom then
+ bottom = panel.frame:GetBottom()
+ break
+ end
+ end
+ end
+ end
+ bottom = bottom - GetScreenHeight()
+ if offsety > bottom then
+ offsety = bottom
+ end
+ end
+ if detached:GetLeft() + detached:GetRight() < width * 2 / 3 then
+ anchor = anchor .. "LEFT"
+ offsetx = detached:GetLeft()
+ if offsetx < 0 then
+ offsetx = 0
+ end
+ elseif detached:GetLeft() + detached:GetRight() < width * 4 / 3 then
+ if anchor == "" then
+ anchor = "CENTER"
+ end
+ offsetx = (detached:GetLeft() + detached:GetRight() - GetScreenWidth()) / 2
+ else
+ anchor = anchor .. "RIGHT"
+ offsetx = detached:GetRight() - width
+ if offsetx > 0 then
+ offsetx = 0
+ end
+ end
+ detached:ClearAllPoints()
+ detached:SetPoint(anchor, GetMainFrame(), anchor, offsetx, offsety)
+ local t = detached.detachedData
+ if t.anchor ~= anchor or math.abs(t.offsetx - offsetx) > 8 or math.abs(t.offsety - offsety) > 8 then
+ detached.preventClick = GetTime() + 0.05
+ end
+ t.anchor = anchor
+ t.offsetx = offsetx
+ t.offsety = offsety
+ detached:Show()
+ end)
+
+ if Dewdrop then
+ Dewdrop:Register(detached,
+ 'children', function(level, value)
+ if not detached.registration then
+ return
+ end
+ if detached.menu then
+ if type(detached.menu) == "function" then
+ detached.menu(level, value)
+ else
+ Dewdrop:FeedAceOptionsTable(detached.menu)
+ end
+ if level == 1 then
+ Dewdrop:AddLine()
+ end
+ end
+ if level == 1 then
+ if not detached.registration.cantAttach then
+ Dewdrop:AddLine(
+ 'text', DETACH,
+ 'tooltipTitle', DETACH,
+ 'tooltipText', DETACH_DESC,
+ 'checked', true,
+ 'arg1', detached,
+ 'func', "Attach",
+ 'closeWhenClicked', true
+ )
+ end
+ if not detached.registration.positionFunc then
+ Dewdrop:AddLine(
+ 'text', LOCK,
+ 'tooltipTitle', LOCK,
+ 'tooltipText', LOCK_DESC,
+ 'checked', detached:IsLocked(),
+ 'arg1', detached,
+ 'func', "Lock",
+ 'closeWhenClicked', not detached:IsLocked()
+ )
+ end
+ Dewdrop:AddLine(
+ 'text', COLOR,
+ 'tooltipTitle', COLOR,
+ 'tooltipText', COLOR_DESC,
+ 'hasColorSwatch', true,
+ 'r', detached.r,
+ 'g', detached.g,
+ 'b', detached.b,
+ 'hasOpacity', true,
+ 'opacity', detached.transparency,
+ 'colorFunc', function(r, g, b, a)
+ detached:SetColor(r, g, b)
+ detached:SetTransparency(a)
+ end
+ )
+ Dewdrop:AddLine(
+ 'text', SIZE,
+ 'tooltipTitle', SIZE,
+ 'tooltipText', SIZE_DESC,
+ 'hasArrow', true,
+ 'hasSlider', true,
+ 'sliderFunc', function(value)
+ detached:SetFontSizePercent(value)
+ end,
+ 'sliderMax', 2,
+ 'sliderMin', 0.5,
+ 'sliderStep', 0.05,
+ 'sliderIsPercent', true,
+ 'sliderValue', detached:GetFontSizePercent()
+ )
+ Dewdrop:AddLine(
+ 'text', CLOSE_MENU,
+ 'tooltipTitle', CLOSE_MENU,
+ 'tooltipText', CLOSE_MENU_DESC,
+ 'func', function()
+ Dewdrop:Close()
+ end
+ )
+ end
+ end,
+ 'point', function()
+ local x, y = detached:GetCenter()
+ if x < GetScreenWidth() / 2 then
+ if y < GetScreenHeight() / 2 then
+ return "BOTTOMLEFT", "BOTTOMRIGHT"
+ else
+ return "TOPLEFT", "TOPRIGHT"
+ end
+ else
+ if y < GetScreenHeight() / 2 then
+ return "BOTTOMRIGHT", "BOTTOMLEFT"
+ else
+ return "TOPRIGHT", "TOPLEFT"
+ end
+ end
+ end
+ )
+ end
+
+ local scrollFrame = CreateFrame("ScrollFrame", detached:GetName() .. "ScrollFrame", detached)
+ local scrollChild = CreateFrame("Frame", detached:GetName() .. "ScrollChild", scrollFrame)
+ scrollFrame:SetFrameLevel(11)
+ scrollFrame:SetScrollChild(scrollChild)
+ scrollChild.tablet = detached
+ detached.scrollFrame = scrollFrame
+ detached.scrollChild = scrollChild
+ scrollFrame:SetPoint("TOPLEFT", 5, -5)
+ scrollFrame:SetPoint("BOTTOMRIGHT", -5, 5)
+ scrollChild:SetWidth(1)
+ scrollChild:SetHeight(1)
+ local slider = CreateFrame("Slider", detached:GetName() .. "Slider", scrollFrame, "BackdropTemplate")
+ detached.slider = slider
+ slider:SetOrientation("VERTICAL")
+ slider:SetMinMaxValues(0, 1)
+ slider:SetValueStep(0.001)
+ slider:SetValue(0)
+ slider:SetWidth(8)
+ slider:SetPoint("TOPRIGHT", 0, 0)
+ slider:SetPoint("BOTTOMRIGHT", 0, 0)
+ slider:SetBackdrop(new(
+ 'bgFile', "Interface\\Buttons\\UI-SliderBar-Background",
+ 'edgeFile', "Interface\\Buttons\\UI-SliderBar-Border",
+ 'tile', true,
+ 'edgeSize', 8,
+ 'tileSize', 8,
+ 'insets', new(
+ 'left', 3,
+ 'right', 3,
+ 'top', 3,
+ 'bottom', 3
+ )
+ ))
+ slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
+ slider:SetScript("OnEnter", detached:GetScript("OnEnter"))
+ slider:SetScript("OnLeave", detached:GetScript("OnLeave"))
+ slider.tablet = detached
+ slider:SetScript("OnValueChanged", Tablet20FrameSlider:GetScript("OnValueChanged"))
+
+ NewLine(detached)
+
+ detached:SetScript("OnMouseWheel", function(this, arg1)
+ detached:Scroll(arg1 < 0)
+ end)
+
+ detached.SetTransparency = tooltip.SetTransparency
+ detached.GetTransparency = tooltip.GetTransparency
+ detached.SetColor = tooltip.SetColor
+ detached.GetColor = tooltip.GetColor
+ detached.SetFontSizePercent = tooltip.SetFontSizePercent
+ detached.GetFontSizePercent = tooltip.GetFontSizePercent
+ detached.SetOwner = tooltip.SetOwner
+ detached.IsOwned = tooltip.IsOwned
+ detached.ClearLines = tooltip.ClearLines
+ detached.NumLines = tooltip.NumLines
+ detached.__Hide = detached.Hide
+ detached.__Show = detached.Show
+ detached.Hide = tooltip.Hide
+ detached.Show = tooltip.Show
+ local old_IsShown = detached.IsShown
+ function detached:IsShown()
+ if self.tmpHidden then
+ return true
+ else
+ return old_IsShown(self)
+ end
+ end
+ detached.AddLine = tooltip.AddLine
+ detached.Scroll = tooltip.Scroll
+ function detached:IsLocked()
+ return self.locked
+ end
+ function detached:Lock()
+ self:EnableMouse(self.locked)
+ self.locked = not self.locked
+ if self.detachedData then
+ self.detachedData.locked = self.locked or nil
+ end
+ self:children()
+ end
+
+ function detached.Attach(detached)
+ if not detached then
+ self:error("Detached tooltip not given.")
+ end
+ if not detached.AddLine then
+ self:error("detached argument not a Tooltip.")
+ end
+ if not detached.owner then
+ self:error("Detached tooltip has no owner.")
+ end
+ if detached.notInUse then
+ self:error("Detached tooltip not in use.")
+ end
+ detached.menu = nil
+ detached.detachedData.detached = nil
+ detached:SetOwner(nil)
+ detached.notInUse = true
+ end
+
+ return AcquireDetachedFrame(self, registration, data, detachedData)
+end
+AcquireDetachedFrame = wrap(AcquireDetachedFrame, "AcquireDetachedFrame")
+
+function Tablet:Close(parent)
+ if not parent then
+ if tooltip and tooltip:IsShown() then
+ tooltip:Hide()
+ tooltip.registration.tooltip = nil
+ tooltip.registration = nil
+ tooltip.enteredFrame = false
+ end
+ return
+ else
+ self:argCheck(parent, 2, "table", "string")
+ end
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot close a tablet with an unregistered parent frame.")
+ end
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData and detachedData.detached then
+ ReleaseDetachedFrame(self, data, detachedData)
+ elseif tooltip and tooltip.data == data then
+ tooltip:Hide()
+ if tooltip.registration then
+ tooltip.registration.tooltip = nil
+ tooltip.registration = nil
+ end
+ end
+ if tooltip then tooltip.enteredFrame = false end
+end
+Tablet.Close = wrap(Tablet.Close, "Tablet:Close")
+
+local function frame_children(self)
+ if not self.preventRefresh and self:GetParent() and self:GetParent():IsShown() then
+ Tablet.currentFrame = self
+ Tablet.currentTabletData = TabletData:new(self)
+ Tablet.currentTabletData.minWidth = self.minWidth
+ self:ClearLines()
+ if self.runChildren then
+ self.runChildren()
+ end
+ Tablet.currentTabletData:Display(Tablet.currentFrame)
+ self:Show(Tablet.currentTabletData)
+ Tablet.currentTabletData:del()
+ Tablet.currentTabletData = nil
+ Tablet.currentFrame = nil
+ end
+end
+frame_children = wrap(frame_children, "frame_children")
+
+function Tablet:Open(fakeParent, parent)
+ self:argCheck(fakeParent, 2, "table", "string")
+ self:argCheck(parent, 3, "nil", "table", "string")
+ if not parent then
+ parent = fakeParent
+ end
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot open a tablet with an unregistered parent frame.")
+ end
+ local detachedData = info.detachedData
+ if detachedData then
+ for _, detached in ipairs(detachedTooltips) do
+ if not detached.notInUse and detached.detachedData == detachedData then
+ return
+ end
+ end
+ end
+ local data = info.data
+ local children = info.children
+ if not children then
+ return
+ end
+ local frame = AcquireFrame(self, info, data, detachedData)
+ frame.clickable = info.clickable
+ frame.menu = info.menu
+ frame.runChildren = info.children
+ frame.minWidth = info.minWidth
+ if not frame.children or not frame.childrenVer or frame.childrenVer < MINOR_VERSION then
+ frame.childrenVer = MINOR_VERSION
+ frame.children = frame_children
+ end
+ frame:SetOwner(fakeParent)
+ frame:children()
+ local point = info.point
+ local relativePoint = info.relativePoint
+ if type(point) == "function" then
+ local b
+ point, b = point(fakeParent)
+ if b then
+ relativePoint = b
+ end
+ end
+ if type(relativePoint) == "function" then
+ relativePoint = relativePoint(fakeParent)
+ end
+ if not point then
+ point = "CENTER"
+ end
+ if not relativePoint then
+ relativePoint = point
+ end
+ frame:ClearAllPoints()
+ if type(parent) ~= "string" then
+ frame:SetPoint(point, fakeParent, relativePoint)
+ end
+ local offsetx = 0
+ local offsety = 0
+ frame:SetClampedToScreen(true)
+ frame:SetClampedToScreen(false)
+ if frame:GetBottom() and frame:GetLeft() then
+ if frame:GetRight() > GetScreenWidth() then
+ offsetx = frame:GetRight() - GetScreenWidth()
+ elseif frame:GetLeft() < 0 then
+ offsetx = -frame:GetLeft()
+ end
+ local ratio = GetScreenWidth() / GetScreenHeight()
+ if ratio >= 2.4 and frame:GetRight() > GetScreenWidth() / 2 and frame:GetLeft() < GetScreenWidth() / 2 then
+ if frame:GetCenter() < GetScreenWidth() / 2 then
+ offsetx = frame:GetRight() - GetScreenWidth() / 2
+ else
+ offsetx = frame:GetLeft() - GetScreenWidth() / 2
+ end
+ end
+ if frame:GetBottom() < 0 then
+ offsety = frame:GetBottom()
+ elseif frame:GetTop() and frame:GetTop() > GetScreenHeight() then
+ offsety = frame:GetTop() - GetScreenHeight()
+ end
+ if MainMenuBar:IsVisible() and frame:GetBottom() < MainMenuBar:GetTop() and offsety < frame:GetBottom() - MainMenuBar:GetTop() then
+ offsety = frame:GetBottom() - MainMenuBar:GetTop()
+ end
+
+ if FuBar then
+ local top = 0
+ if FuBar then
+ for i = 1, FuBar:GetNumPanels() do
+ local panel = FuBar:GetPanel(i)
+ if panel:GetAttachPoint() == "BOTTOM" then
+ if panel.frame:GetTop() and panel.frame:GetTop() > top then
+ top = panel.frame:GetTop()
+ break
+ end
+ end
+ end
+ end
+ if frame:GetBottom() < top and offsety < frame:GetBottom() - top then
+ offsety = frame:GetBottom() - top
+ end
+ local bottom = GetScreenHeight()
+ if FuBar then
+ for i = 1, FuBar:GetNumPanels() do
+ local panel = FuBar:GetPanel(i)
+ if panel:GetAttachPoint() == "TOP" then
+ if panel.frame:GetBottom() and panel.frame:GetBottom() < bottom then
+ bottom = panel.frame:GetBottom()
+ break
+ end
+ end
+ end
+ end
+ if frame:GetTop() > bottom and offsety < frame:GetTop() - bottom then
+ offsety = frame:GetTop() - bottom
+ end
+ end
+ end
+ if type(fakeParent) ~= "string" then
+ frame:SetPoint(point, fakeParent, relativePoint, -offsetx, -offsety)
+ end
+
+ if detachedData and (info.cantAttach or detachedData.detached) and frame == tooltip then
+ detachedData.detached = false
+ frame:Detach()
+ end
+ if (not detachedData or not detachedData.detached) and GetMouseFocus() == fakeParent then
+ self.tooltip.enteredFrame = true
+ end
+ overFrame = type(fakeParent) == "table" and MouseIsOver(fakeParent) and fakeParent
+end
+Tablet.Open = wrap(Tablet.Open, "Tablet:Open")
+
+function Tablet:Register(parent, ...)
+ self:argCheck(parent, 2, "table", "string")
+ if self.registry[parent] then
+ self:Unregister(parent)
+ end
+ local info
+ local k1 = ...
+ if type(k1) == "table" and k1[0] then
+ if type(self.registry[k1]) ~= "table" then
+ self:error("Other parent not registered")
+ end
+ info = copy(self.registry[k1])
+ local v1 = select(2, ...)
+ if type(v1) == "function" then
+ info.point = v1
+ info.relativePoint = nil
+ end
+ else
+ info = new(...)
+ end
+ self.registry[parent] = info
+ info.data = info.data or info.detachedData or new()
+ info.detachedData = info.detachedData or info.data
+ local data = info.data
+ local detachedData = info.detachedData
+ if not self.onceRegistered[parent] and type(parent) == "table" and type(parent.SetScript) == "function" and not info.dontHook then
+ if not Dewdrop and AceLibrary:HasInstance("Dewdrop-2.0") then
+ Dewdrop = AceLibrary("Dewdrop-2.0")
+ end
+ local script = parent:GetScript("OnEnter")
+ parent:SetScript("OnEnter", function(...)
+ if script then
+ script(...)
+ end
+ if self.registry[parent] then
+ if (not data or not detachedData.detached) and (Dewdrop and not Dewdrop:IsOpen(parent)) then
+ self:Open(parent)
+ end
+ end
+ end)
+ if parent:HasScript("OnMouseDown") then
+ local script = parent:GetScript("OnMouseDown")
+ parent:SetScript("OnMouseDown", function(...)
+ if script then
+ script(...)
+ end
+ if self.registry[parent] and self.registry[parent].tooltip and self.registry[parent].tooltip == self.tooltip then
+ self.tooltip:Hide()
+ end
+ end)
+ end
+ if parent:HasScript("OnMouseWheel") then
+ local script = parent:GetScript("OnMouseWheel")
+ parent:SetScript("OnMouseWheel", function(this, arg1)
+ if script then
+ script(this, arg1)
+ end
+ if self.registry[parent] and self.registry[parent].tooltip then
+ self.registry[parent].tooltip:Scroll(arg1 < 0)
+ end
+ end)
+ end
+ end
+ self.onceRegistered[parent] = true
+ if GetMouseFocus() == parent then
+ self:Open(parent)
+ end
+end
+Tablet.Register = wrap(Tablet.Register, "Tablet:Register")
+
+function Tablet:Unregister(parent)
+ self:argCheck(parent, 2, "table", "string")
+ if not self.registry[parent] then
+ self:error("You cannot unregister a parent frame if it has not been registered already.")
+ end
+ self.registry[parent] = nil
+end
+Tablet.Unregister = wrap(Tablet.Unregister, "Tablet:Unregister")
+
+function Tablet:IsRegistered(parent)
+ self:argCheck(parent, 2, "table", "string")
+ return self.registry[parent] and true
+end
+Tablet.IsRegistered = wrap(Tablet.IsRegistered, "Tablet:IsRegistered")
+
+local _id = 0
+local addedCategory
+local depth = 0
+local categoryPool = {}
+function CleanCategoryPool(self)
+ for k,v in pairs(categoryPool) do
+ del(v)
+ categoryPool[k] = nil
+ end
+ _id = 0
+end
+CleanCategoryPool = wrap(CleanCategoryPool, "CleanCategoryPool")
+
+function Tablet:AddCategory(...)
+ if not self.currentFrame then
+ self:error("You must add categories in within a registration.")
+ end
+ local info = new(...)
+ local cat = self.currentTabletData:AddCategory(info)
+ info = del(info)
+ return cat
+end
+Tablet.AddCategory = wrap(Tablet.AddCategory, "Tablet:AddCategory")
+
+function Tablet:SetHint(text)
+ if not self.currentFrame then
+ self:error("You must set hint within a registration.")
+ end
+ self.currentTabletData:SetHint(text)
+end
+Tablet.SetHint = wrap(Tablet.SetHint, "Tablet:SetHint")
+
+function Tablet:SetTitle(text)
+ if not self.currentFrame then
+ self:error("You must set title within a registration.")
+ end
+ self.currentTabletData:SetTitle(text)
+end
+Tablet.SetTitle = wrap(Tablet.SetTitle, "Tablet:SetTitle")
+
+function Tablet:SetTitleColor(r, g, b)
+ if not self.currentFrame then
+ self:error("You must set title color within a registration.")
+ end
+ self:argCheck(r, 2, "number")
+ self:argCheck(g, 3, "number")
+ self:argCheck(b, 4, "number")
+ self.currentTabletData:SetTitleColor(r, g, b)
+end
+Tablet.SetTitleColor = wrap(Tablet.SetTitleColor, "Tablet:SetTitleColor")
+
+function Tablet:GetNormalFontSize()
+ return normalSize
+end
+Tablet.GetNormalFontSize = wrap(Tablet.GetNormalFontSize, "Tablet:GetNormalFontSize")
+
+function Tablet:GetHeaderFontSize()
+ return headerSize
+end
+Tablet.GetHeaderFontSize = wrap(Tablet.GetHeaderFontSize, "Tablet:GetHeaderFontSize")
+
+function Tablet:GetNormalFontObject()
+ return GameTooltipText
+end
+Tablet.GetNormalFontObject = wrap(Tablet.GetNormalFontObject, "Tablet:GetNormalFontObject")
+
+function Tablet:GetHeaderFontObject()
+ return GameTooltipHeaderText
+end
+Tablet.GetHeaderFontObject = wrap(Tablet.GetHeaderFontObject, "Tablet:GetHeaderFontObject")
+
+function Tablet:SetFontSizePercent(parent, percent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ if info.tooltip then
+ info.tooltip:SetFontSizePercent(percent)
+ else
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ detachedData.fontSizePercent = percent
+ else
+ data.fontSizePercent = percent
+ end
+ end
+ elseif type(parent) == "table" then
+ parent.fontSizePercent = percent
+ else
+ self:error("You cannot change font size with an unregistered parent frame.")
+ end
+end
+Tablet.SetFontSizePercent = wrap(Tablet.SetFontSizePercent, "Tablet:SetFontSizePercent")
+
+function Tablet:GetFontSizePercent(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ return detachedData.fontSizePercent or 1
+ else
+ return data.fontSizePercent or 1
+ end
+ elseif type(parent) == "table" then
+ return parent.fontSizePercent or 1
+ else
+ self:error("You cannot check font size with an unregistered parent frame.")
+ end
+end
+Tablet.GetFontSizePercent = wrap(Tablet.GetFontSizePercent, "Tablet:GetFontSizePercent")
+
+function Tablet:SetTransparency(parent, percent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ if info.tooltip then
+ info.tooltip:SetTransparency(percent)
+ else
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ detachedData.transparency = percent
+ elseif data then
+ data.transparency = percent
+ end
+ end
+ elseif type(parent) == "table" then
+ parent.transparency = percent
+ else
+ self:error("You cannot change transparency with an unregistered parent frame.")
+ end
+end
+Tablet.SetTransparency = wrap(Tablet.SetTransparency, "Tablet:SetTransparency")
+
+function Tablet:GetTransparency(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ return detachedData.transparency or 0.75
+ else
+ return data.transparency or 0.75
+ end
+ elseif type(parent) == "table" then
+ return parent.transparency or 0.75
+ else
+ self:error("You cannot get transparency with an unregistered parent frame.")
+ end
+end
+Tablet.GetTransparency = wrap(Tablet.GetTransparency, "Tablet:GetTransparency")
+
+function Tablet:SetColor(parent, r, g, b)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ if info.tooltip then
+ info.tooltip:SetColor(r, g, b)
+ else
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ detachedData.r = r
+ detachedData.g = g
+ detachedData.b = b
+ else
+ data.r = r
+ data.g = g
+ data.b = b
+ end
+ end
+ elseif type(parent) == "table" then
+ parent.r = r
+ parent.g = g
+ parent.b = b
+ else
+ self:error("You cannot change color with an unregistered parent frame.")
+ end
+end
+Tablet.SetColor = wrap(Tablet.SetColor, "Tablet:SetColor")
+
+function Tablet:GetColor(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ return detachedData.r or 0, detachedData.g or 0, detachedData.b or 0
+ else
+ return data.r or 0, data.g or 0, data.b or 0
+ end
+ elseif type(parent) == "table" then
+ return parent.r or 0, parent.g or 0, parent.b or 0
+ else
+ self:error("You must provide a registered parent frame to check color")
+ end
+end
+Tablet.GetColor = wrap(Tablet.GetColor, "Tablet:GetColor")
+
+function Tablet:Detach(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot detach tablet with an unregistered parent frame.")
+ end
+ if not info.detachedData then
+ self:error("You cannot detach tablet without a data field.")
+ end
+ if info.tooltip and info.tooltip == tooltip and tooltip.registration then
+ tooltip:Detach()
+ else
+ info.detachedData.detached = true
+ local detached = AcquireDetachedFrame(self, info, info.data, info.detachedData)
+
+ detached.menu = info.menu
+ detached.runChildren = info.children
+ detached.minWidth = info.minWidth
+ if not detached.children or not detached.childrenVer or detached.childrenVer < MINOR_VERSION then
+ detached.childrenVer = MINOR_VERSION
+ detached.children = frame_children
+ end
+ detached:SetOwner(parent)
+ detached:children()
+ end
+end
+Tablet.Detach = wrap(Tablet.Detach, "Tablet:Detach")
+
+function Tablet:Attach(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot detach tablet with an unregistered parent frame.")
+ end
+ if not info.detachedData then
+ self:error("You cannot attach tablet without a data field.")
+ end
+ if info.tooltip and info.tooltip ~= tooltip then
+ info.tooltip:Attach()
+ else
+ info.detachedData.detached = false
+ end
+end
+Tablet.Attach = wrap(Tablet.Attach, "Tablet:Attach")
+
+function Tablet:IsAttached(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot check tablet with an unregistered parent frame.")
+ end
+ return not info.detachedData or not info.detachedData.detached
+end
+Tablet.IsAttached = wrap(Tablet.IsAttached, "Tablet:IsAttached")
+
+function Tablet:Refresh(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot refresh tablet with an unregistered parent frame.")
+ end
+ local tt = info.tooltip
+ if tt and not tt.preventRefresh and tt:IsShown() then
+ tt.updating = true
+ tt:children()
+ tt.updating = false
+ end
+end
+Tablet.Refresh = wrap(Tablet.Refresh, "Tablet:Refresh")
+
+function Tablet:IsLocked(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot check tablet with an unregistered parent frame.")
+ end
+ return info.detachedData and info.detachedData.locked
+end
+Tablet.IsLocked = wrap(Tablet.IsLocked, "Tablet:IsLocked")
+
+function Tablet:ToggleLocked(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot lock tablet with an unregistered parent frame.")
+ end
+ if info.tooltip and info.tooltip ~= tooltip then
+ info.tooltip:Lock()
+ elseif info.detachedData then
+ info.detachedData.locked = info.detachedData.locked
+ end
+end
+Tablet.ToggleLocked = wrap(Tablet.ToggleLocked, "Tablet:ToggleLocked")
+
+function Tablet:UpdateDetachedData(parent, detachedData)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot update tablet with an unregistered parent frame.")
+ end
+ self:argCheck(detachedData, 3, "table")
+ if info.data == info.detachedData then
+ info.data = detachedData
+ end
+ info.detachedData = detachedData
+ if info.detachedData.detached then
+ self:Detach(parent)
+ elseif info.tooltip and info.tooltip.owner then
+ self:Attach(parent)
+ end
+end
+Tablet.UpdateDetachedData = wrap(Tablet.UpdateDetachedData, "Tablet:UpdateDetachedData")
+
+if DEBUG then
+ function Tablet:ListProfileInfo()
+ local duration, times, memories = GetProfileInfo()
+ if not duration or not time or not memories then
+ self:error("Problems")
+ end
+ local t = new()
+ for method in pairs(memories) do
+ t[#t+1] = method
+ end
+ table.sort(t, function(alpha, bravo)
+ if memories[alpha] ~= memories[bravo] then
+ return memories[alpha] < memories[bravo]
+ elseif times[alpha] ~= times[bravo] then
+ return times[alpha] < times[bravo]
+ else
+ return alpha < bravo
+ end
+ end)
+ local memory = 0
+ local time = 0
+ for _,method in ipairs(t) do
+ DEFAULT_CHAT_FRAME:AddMessage(format("%s || %.3f s || %.3f%% || %d KiB", method, times[method], times[method] / duration * 100, memories[method]))
+ memory = memory + memories[method]
+ time = time + times[method]
+ end
+ DEFAULT_CHAT_FRAME:AddMessage(format("%s || %.3f s || %.3f%% || %d KiB", "Total", time, time / duration * 100, memory))
+ del(t)
+ end
+ SLASH_TABLET1 = "/tablet"
+ SLASH_TABLET2 = "/tabletlib"
+ SlashCmdList["TABLET"] = function(msg)
+ AceLibrary(MAJOR_VERSION):ListProfileInfo()
+ end
+end
+
+local function activate(self, oldLib, oldDeactivate)
+ Tablet = self
+ if oldLib then
+ self.registry = oldLib.registry
+ self.onceRegistered = oldLib.onceRegistered
+ self.tooltip = oldLib.tooltip
+ self.currentFrame = oldLib.currentFrame
+ self.currentTabletData = oldLib.currentTabletData
+ else
+ self.registry = {}
+ self.onceRegistered = {}
+ end
+
+ tooltip = self.tooltip
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+local function deactivate(self)
+ StopCheckingAlt()
+end
+
+AceLibrary:Register(Tablet, MAJOR_VERSION, MINOR_VERSION, activate, deactivate)
diff --git a/FuBar_DurabilityFu/Changelog-FuBar_DurabilityFu-r127.txt b/FuBar_DurabilityFu/Changelog-FuBar_DurabilityFu-r127.txt
new file mode 100644
index 0000000..07f993b
--- /dev/null
+++ b/FuBar_DurabilityFu/Changelog-FuBar_DurabilityFu-r127.txt
@@ -0,0 +1,14 @@
+------------------------------------------------------------------------
+r127 | Zidomo | 2010-01-04 19:17:56 +0000 (Mon, 04 Jan 2010) | 1 line
+Changed paths:
+ M /trunk/FuBar_DurabilityFu.toc
+
+Push version to repackage with latest Dewdrop (r321). Which (finally) allows the standalone minimap button to provide an options menu. Which LDB displays + FuBar2Broker & original FuBar have already had.
+------------------------------------------------------------------------
+r126 | Zidomo | 2009-12-20 20:22:03 +0000 (Sun, 20 Dec 2009) | 1 line
+Changed paths:
+ M /trunk/.pkgmeta
+ M /trunk/FuBar_DurabilityFu.toc
+
+Remove LOD & change FuBar to opt from req dependency so it works with both FuBar as well as LDB displays + FuBar2Broker (it doesn't provide an option menu when a standalone minimap button). 30300 too. Update .pkgmeta. This works without issues in 3.3; will push a release later.
+------------------------------------------------------------------------
diff --git a/FuBar_DurabilityFu/DurabilityFu.lua b/FuBar_DurabilityFu/DurabilityFu.lua
new file mode 100644
index 0000000..ae2d690
--- /dev/null
+++ b/FuBar_DurabilityFu/DurabilityFu.lua
@@ -0,0 +1,467 @@
+
+DurabilityFu = AceLibrary("AceAddon-2.0"):new("FuBarPlugin-2.0", "AceDB-2.0", "AceEvent-2.0", "AceHook-2.1", "AceConsole-2.0")
+local DurabilityFu = DurabilityFu
+
+DurabilityFu.version = "3.00." .. string.sub("$Revision: 200 $", 12, -3)
+DurabilityFu.date = string.sub("$Date: 2022-11-16 23:20:00 +0100 (Wed, 16 Nov 2022) $", 8, 17)
+DurabilityFu.hasIcon = true
+DurabilityFu.canHideText = true
+
+local L = AceLibrary("AceLocale-2.2"):new("FuBar_DurabilityFu")
+
+local Tablet = AceLibrary("Tablet-2.0")
+local Abacus = AceLibrary("Abacus-2.0")
+local Crayon = AceLibrary("Crayon-2.0")
+
+local repairIndex = 0
+local itemStatus = {
+ -- value, max, cost, name, slot
+ { 0, 0, 0, INVTYPE_HEAD, "Head" },
+ { 0, 0, 0, INVTYPE_SHOULDER, "Shoulder" },
+ { 0, 0, 0, INVTYPE_CHEST, "Chest" },
+ { 0, 0, 0, INVTYPE_WAIST, "Waist" },
+ { 0, 0, 0, INVTYPE_LEGS, "Legs" },
+ { 0, 0, 0, INVTYPE_FEET, "Feet" },
+ { 0, 0, 0, INVTYPE_WRIST, "Wrist" },
+ { 0, 0, 0, INVTYPE_HAND, "Hands" },
+ { 0, 0, 0, INVTYPE_WEAPONMAINHAND, "MainHand" },
+ { 0, 0, 0, INVTYPE_WEAPONOFFHAND, "SecondaryHand" },
+ { 0, 0, 0, INVTYPE_RANGED, "Ranged" },
+ { 0, 0, 0, INVENTORY_TOOLTIP },
+}
+local INVENTORY_SLOT = 12
+local VALUE = 1
+local MAX = 2
+local COST = 3
+local NAME = 4
+local SLOT = 5
+
+-----------------------------------------------------------------------
+-- Initialization
+--
+
+function DurabilityFu:OnInitialize()
+ self:RegisterDB("DurabilityFuDB")
+ self:RegisterDefaults("profile", {
+ showMan = false,
+ showAverage = false,
+ showHealthy = false,
+ autoRepairEquipment = true,
+ showPopup = false,
+ useGuildBank = false,
+ })
+
+ self.OnMenuRequest = {
+ type = "group",
+ pass = true,
+ get = function(k)
+ return self.db.profile[k]
+ end,
+ set = function(k, v)
+ self.db.profile[k] = v
+ self:OnDataUpdate()
+ self:OnTextUpdate()
+ end,
+ args = {
+ showMan = {
+ type = "toggle",
+ name = L["Show the armored man"],
+ desc = L["Toggle whether to show Blizzard's armored man"],
+ set = "ToggleShowingMan"
+ },
+ showAverage = {
+ type = "toggle",
+ name = L["Show average value"],
+ desc = L["Toggle whether to show your average or minimum durability"],
+ },
+ showHealthy = {
+ type = "toggle",
+ name = L["Show healthy items"],
+ desc = L["Toggle whether to show items that are healthy (100% repaired)"],
+ },
+ autoRepairEquipment = {
+ type = "toggle",
+ name = L["Auto repair"],
+ desc = L["Toggle whether to auto repair all your equipment when you visit a repair vendor."],
+ },
+ showPopup = {
+ type = "toggle",
+ name = L["Show repair popup"],
+ desc = L["Toggle whether to show the repair popup at a vendor, reminding you that your equipment is damaged.\n\nWill only show if your equipment is damaged."],
+ disabled = function() return self.db.profile.autoRepairEquipment end,
+ },
+ useGuildBank = {
+ type = "toggle",
+ name = L["Use guild bank"],
+ desc = L["Use the guild banks money when repairing."],
+ },
+ },
+ handler = self,
+ }
+end
+
+function DurabilityFu:OnEnable()
+ self:RegisterEvent("PLAYER_UNGHOST", "OnBagUpdate")
+ self:RegisterEvent("PLAYER_DEAD", "OnBagUpdate")
+ self:RegisterEvent("PLAYER_REGEN_ENABLED", "OnBagUpdate")
+ self:RegisterEvent("UNIT_INVENTORY_CHANGED")
+ self:RegisterEvent("UPDATE_INVENTORY_ALERTS", 1)
+ self:RegisterEvent("MERCHANT_SHOW")
+ self:RegisterEvent("MERCHANT_CLOSED")
+
+ self:SecureHook(DurabilityFrame, "SetAlerts", "DurabilityFrame_SetAlerts")
+ self:SecureHook("RepairAllItems", "ScheduleUpdate")
+ self:DurabilityFrame_SetAlerts()
+end
+
+function DurabilityFu:OnDisable()
+ DurabilityFrameMixin:SetAlerts()
+end
+
+-----------------------------------------------------------------------
+-- Local utility
+--
+
+local function canRepair()
+ local cost, canRepair = GetRepairAllCost()
+ if not canRepair or cost == 0 then return end
+ local money = GetMoney()
+ local gbAmount = GetGuildBankWithdrawMoney()
+ local gbMoney = GetGuildBankMoney()
+ if IsInGuild() and DurabilityFu.db.profile.useGuildBank and ((gbAmount == -1 and gbMoney > cost) or gbAmount > cost) then
+ return 2, cost
+ elseif money > cost then
+ return 1, cost
+ end
+end
+
+local function doRepair()
+ local method, cost = canRepair()
+ if not method then return end
+ if method == 2 then
+ RepairAllItems(1)
+ DurabilityFu:Print(L["Auto-repaired equipment using guild bank: %s"], Abacus:FormatMoneyFull(cost))
+ elseif method == 1 then
+ RepairAllItems()
+ DurabilityFu:Print(L["Auto-repaired equipment: %s"], Abacus:FormatMoneyFull(cost))
+ end
+end
+
+local function showPopup(totalCost)
+ if totalCost <= 0 then return end
+ if not StaticPopupDialogs["DurabilityFuRepair"] then
+ StaticPopupDialogs["DurabilityFuRepair"] = {
+ button1 = YES,
+ button2 = NO,
+ showAlert = 1,
+ timeout = 0,
+ OnAccept = function()
+ doRepair()
+ end,
+ }
+ end
+ StaticPopupDialogs["DurabilityFuRepair"].text = L["You have equipment to repair, do you want to repair everything at the cost of %s now?"]:format(Abacus:FormatMoneyFull(totalCost, true))
+ StaticPopup_Show("DurabilityFuRepair")
+end
+
+function DurabilityFu:ToggleShowingMan(value)
+ if value == nil then
+ value = not self.db.profile.showMan
+ end
+ self.db.profile.showMan = value
+ self:DurabilityFrame_SetAlerts()
+end
+
+-----------------------------------------------------------------------
+-- Events and hooks
+--
+
+function DurabilityFu:MERCHANT_SHOW()
+ if CanMerchantRepair() then
+ local repair, cost = canRepair()
+ if not repair then return end
+ if self.db.profile.autoRepairEquipment then
+ doRepair()
+ elseif self.db.profile.showPopup then
+ showPopup(cost)
+ end
+ end
+end
+
+function DurabilityFu:MERCHANT_CLOSED()
+ StaticPopup_Hide("DurabilityFuRepair")
+end
+
+function DurabilityFu:UNIT_INVENTORY_CHANGED()
+ self:UpdateInventoryData(INVENTORY_ALERT_STATUS_SLOTS)
+ self:UpdateBagData()
+ self:UpdateTooltip()
+end
+
+function DurabilityFu:UPDATE_INVENTORY_ALERTS()
+ self:UpdateInventoryData(INVENTORY_ALERT_STATUS_SLOTS)
+ self:UpdateText()
+ self:UpdateTooltip()
+end
+
+function DurabilityFu:OnBagUpdate()
+ self:UpdateInventoryData()
+ self:UpdateBagData()
+ self:UpdateText()
+ self:UpdateTooltip()
+end
+
+function DurabilityFu:ScheduleUpdate()
+ self:ScheduleEvent(self.name, self.Update, 4, self)
+end
+
+function DurabilityFu:DurabilityFrame_SetAlerts()
+ if not self.db.profile.showMan then
+ DurabilityFrame:Hide()
+ end
+end
+
+-----------------------------------------------------------------------
+-- Data updating
+--
+
+function DurabilityFu:OnDataUpdate()
+ self:UpdateBagData()
+ self:UpdateInventoryData()
+end
+
+local lastUpdate
+function DurabilityFu:UpdateBagData()
+ if lastUpdate and GetTime() - lastUpdate < 1 then
+ return
+ end
+ lastUpdate = GetTime()
+ local minStatus = 1.0
+ local minValue = 0
+ local minMax = 0
+
+ itemStatus[INVENTORY_SLOT][VALUE] = 0
+ itemStatus[INVENTORY_SLOT][MAX] = 0
+ itemStatus[INVENTORY_SLOT][COST] = 0
+
+ for containerIndex = Enum.BagIndex.Backpack, Enum.BagIndex.Bag_4 do
+ for slotIndex = 1, C_Container.GetContainerNumSlots(containerIndex) do
+ local status, value, max, cost = self:GetStatus(slotIndex, containerIndex)
+ if not self.db.profile.showAverage then
+ if status and status < minStatus then
+ minStatus = status
+ minValue = value
+ minMax = max
+
+ if (repairIndex == 0 or status < self:GetPercent(itemStatus[repairIndex][VALUE], itemStatus[repairIndex][MAX])) and max ~= 0 then
+ repairIndex = INVENTORY_SLOT
+ end
+
+ itemStatus[INVENTORY_SLOT][VALUE] = value
+ itemStatus[INVENTORY_SLOT][MAX] = max
+ end
+ elseif cost then
+ itemStatus[INVENTORY_SLOT][VALUE] = itemStatus[INVENTORY_SLOT][VALUE] + value
+ itemStatus[INVENTORY_SLOT][MAX] = itemStatus[INVENTORY_SLOT][MAX] + max
+ end
+ if cost then
+ itemStatus[INVENTORY_SLOT][COST] = itemStatus[INVENTORY_SLOT][COST] + cost
+ end
+ end
+ end
+ if self.db.profile.showAverage then
+ local status = self:GetPercent(itemStatus[INVENTORY_SLOT][VALUE], itemStatus[INVENTORY_SLOT][MAX])
+ if (repairIndex == 0 or status < self:GetPercent(itemStatus[repairIndex][VALUE], itemStatus[repairIndex][MAX])) and itemStatus[INVENTORY_SLOT][MAX] ~= 0 then
+ repairIndex = INVENTORY_SLOT
+ end
+ end
+end
+
+local tmp = {}
+for i = 1, 11 do
+ tmp[i] = true
+end
+function DurabilityFu:UpdateInventoryData(toCheck)
+ if not toCheck then
+ toCheck = tmp
+ end
+
+ local minStatus = 1.0
+ local minValue = 0
+ local minMax = 0
+ local minIndex = 0
+
+ for index,_ in pairs(toCheck) do
+ local status, value, max, cost = self:GetStatus(index)
+ if status and status < minStatus then
+ minStatus = status
+ minValue = value
+ minMax = max
+ minIndex = index
+ end
+
+ itemStatus[index][VALUE] = value or 0
+ itemStatus[index][MAX] = max or 0
+ itemStatus[index][COST] = cost or 0
+ end
+
+ repairIndex = minIndex
+
+ self:DurabilityFrame_SetAlerts()
+end
+
+function DurabilityFu:GetPercent(quotient, denominator)
+ if denominator ~= 0 then
+ return quotient / denominator
+ else
+ return 1
+ end
+end
+
+function DurabilityFu:GetStatus(slotIndex, containerIndex)
+ local value, max, repairCost, hasItem, _
+ if containerIndex then
+ hasItem = C_Container.GetContainerItemInfo(containerIndex, slotIndex) ~= nil
+
+ if hasItem then
+ local tooltipData = C_TooltipInfo.GetBagItem(containerIndex, slotIndex)
+ if tooltipData then
+ TooltipUtil.SurfaceArgs(tooltipData)
+ repairCost = tooltipData.repairCost
+ end
+ end
+
+ value, max = C_Container.GetContainerItemDurability(containerIndex, slotIndex)
+ else
+ local slotName = itemStatus[slotIndex][SLOT] .. "Slot"
+
+ if slotName == 'RangedSlot' then
+ return
+ end
+
+ local id = GetInventorySlotInfo(slotName)
+
+ local tooltipData = C_TooltipInfo.GetInventoryItem("player", id)
+ if tooltipData then
+ hasItem = true
+ TooltipUtil.SurfaceArgs(tooltipData)
+ repairCost = tooltipData.repairCost
+
+ value, max = GetInventoryItemDurability(id)
+ end
+ end
+
+ if hasItem and value then
+ return self:GetPercent(value, max), value, max, repairCost
+ end
+end
+
+-----------------------------------------------------------------------
+-- UI
+--
+
+function DurabilityFu:OnTextUpdate()
+ local percent
+ if not self.db.profile.showAverage then
+ if repairIndex == 0 then
+ percent = 1
+ else
+ percent = self:GetPercent(itemStatus[repairIndex][VALUE], itemStatus[repairIndex][MAX])
+ end
+ else
+ local value = 0
+ local max = 0
+ for i,item in pairs(itemStatus) do
+ if i ~= INVENTORY_SLOT then
+ value = value + item[VALUE]
+ max = max + item[MAX]
+ end
+ end
+ percent = self:GetPercent(value, max)
+ end
+ self:SetText(string.format("|cff%s%d%%|r", Crayon:GetThresholdHexColor(percent), percent * 100))
+end
+
+do
+ local TEXT_FRIENDLY = FACTION_STANDING_LABEL5
+ local TEXT_HONORED = FACTION_STANDING_LABEL6
+ local TEXT_REVERED = FACTION_STANDING_LABEL7
+ local TEXT_EXALTED = FACTION_STANDING_LABEL8
+ function DurabilityFu:OnTooltipUpdate()
+ local cost = 0
+ local cat = Tablet:AddCategory(
+ "columns", 3,
+ "child_textR", 1,
+ "child_textG", 1,
+ "child_textB", 0
+ )
+
+ for index, item in pairs(itemStatus) do
+ if item[MAX] > 0 then
+ cost = cost + item[COST]
+ local percent = self:GetPercent(item[VALUE], item[MAX])
+ if self.db.profile.showHealthy or percent < 1 then
+ local r, g, b = Crayon:GetThresholdColor(percent)
+ cat:AddLine(
+ "text", item[NAME],
+ "text2", string.format("%.0f%%", percent * 100),
+ "text2R", r,
+ "text2G", g,
+ "text2B", b,
+ "text3", Abacus:FormatMoneyShort(item[COST], true)
+ )
+ end
+ end
+ end
+ local value = 0
+ local max = 0
+ for i,item in pairs(itemStatus) do
+ if i ~= INVENTORY_SLOT then
+ value = value + item[VALUE]
+ max = max + item[MAX]
+ end
+ end
+ cat = Tablet:AddCategory(
+ "columns", 2,
+ "text", L["Total"],
+ "child_textR", 1,
+ "child_textG", 1,
+ "child_textB", 0,
+ "child_text2R", 1,
+ "child_text2G", 1,
+ "child_text2B", 1
+ )
+ local r, g, b = Crayon:GetThresholdColor(value / max)
+ cat:AddLine(
+ "text", L["Percent"],
+ "text2", string.format("%.0f%%", value / max * 100),
+ "text2R", r,
+ "text2G", g,
+ "text2B", b
+ )
+
+ if cost > 0 then
+ cat:AddLine(
+ "text", L["Repair cost"],
+ "text2", Abacus:FormatMoneyFull(cost, true)
+ )
+ cat:AddLine(
+ "text", TEXT_FRIENDLY,
+ "text2", Abacus:FormatMoneyFull(cost * 0.95, true)
+ )
+ cat:AddLine(
+ "text", TEXT_HONORED,
+ "text2", Abacus:FormatMoneyFull(cost * 0.9, true)
+ )
+ cat:AddLine(
+ "text", TEXT_REVERED,
+ "text2", Abacus:FormatMoneyFull(cost * 0.85, true)
+ )
+ cat:AddLine(
+ "text", TEXT_EXALTED,
+ "text2", Abacus:FormatMoneyFull(cost * 0.80, true)
+ )
+ end
+ end
+end
+
diff --git a/FuBar_DurabilityFu/DurabilityFuLocale-deDE.lua b/FuBar_DurabilityFu/DurabilityFuLocale-deDE.lua
new file mode 100644
index 0000000..938907a
--- /dev/null
+++ b/FuBar_DurabilityFu/DurabilityFuLocale-deDE.lua
@@ -0,0 +1,29 @@
+local L = AceLibrary("AceLocale-2.2"):new("FuBar_DurabilityFu")
+
+L:RegisterTranslations("deDE", function() return {
+ ["Total"] = "Gesamt",
+ ["Percent"] = "Prozent",
+ ["Repair cost"] = "Reparaturkosten",
+ ["Repair"] = "Reparatur",
+ ["Equipment"] = "Ausrüstung",
+ ["Inventory"] = "Inventar",
+ ["Show the armored man"] = "Ausrüstungsfigur anzeigen",
+ ["Toggle whether to show Blizzard's armored man"] = "Anzeige der Ausrüstungsfigur ein/ausschalten.",
+ ["Show average value"] = "Mittelwert anzeigen",
+ ["Toggle whether to show your average or minimum durability"] = "Anzeige zwischen mittlerer oder minimaler Haltbarkeit umschalten.",
+ ["Show healthy items"] = "Unbeschädigte Gegenstände anzeigen",
+ ["Toggle whether to show items that are healthy (100% repaired)"] = "Anzeige unbeschädigter Gegenstände ein/ausschalten.",
+ ["Auto repair"] = "Automatische Reparatur",
+ ["Toggle whether to auto repair all your equipment when you visit a repair vendor."] = "Automatische Reparatur beim Besuch eines Reparaturhändlers ein/ausschalten.",
+ ["Show repair popup"] = "Reparatur Popup anzeigen",
+ ["Toggle whether to show the repair popup at a vendor, reminding you that your equipment is damaged.\n\nWill only show if your equipment is damaged."] = "Reparatur Popup beim Besuch eines Reparaturhändlers ein/ausschalten; erinnert Dich daran, daß Deine Ausrüstung beschädigt ist.\n\nWird nur angezeigt wenn Deine Ausrüstung beschädigt ist.",
+ ["Use guild bank"] = "Gildenbank benutzen",
+ ["Use the guild banks money when repairing."] = "Geld aus der Gildenbank zum reparieren benutzen.",
+
+ ["You have equipment to repair, do you want to repair everything at the cost of %s now?"] = "Du hast beschädigte Ausrüstung. Willst Du alles für %s reparieren?",
+
+ ["Cannot auto-repair equipment. Your money: %s. Needed: %s"] = "Automatische Reparatur nicht möglich. Dein Geld: %s. Benötigt: %s.",
+ ["Auto-repaired equipment: %s"] = "Ausrüstung automatisch repariert: %s",
+ ["Auto-repaired equipment using guild bank: %s"] = "Ausrüstung automatisch mittels Gildenbank repariert: %s",
+ ["AceConsole-Commands"] = {"/durfu", "/durabilityfu"}
+} end)
diff --git a/FuBar_DurabilityFu/DurabilityFuLocale-enUS.lua b/FuBar_DurabilityFu/DurabilityFuLocale-enUS.lua
new file mode 100644
index 0000000..fad87b3
--- /dev/null
+++ b/FuBar_DurabilityFu/DurabilityFuLocale-enUS.lua
@@ -0,0 +1,30 @@
+local L = AceLibrary("AceLocale-2.2"):new("FuBar_DurabilityFu")
+
+L:RegisterTranslations("enUS", function() return {
+ ["Total"] = true,
+ ["Percent"] = true,
+ ["Repair cost"] = true,
+ ["Repair"] = true,
+ ["Equipment"] = true,
+ ["Inventory"] = true,
+ ["Show the armored man"] = true,
+ ["Toggle whether to show Blizzard's armored man"] = true,
+ ["Show average value"] = true,
+ ["Toggle whether to show your average or minimum durability"] = true,
+ ["Show healthy items"] = true,
+ ["Toggle whether to show items that are healthy (100% repaired)"] = true,
+ ["Auto repair"] = true,
+ ["Toggle whether to auto repair all your equipment when you visit a repair vendor."] = true,
+ ["Show repair popup"] = true,
+ ["Toggle whether to show the repair popup at a vendor, reminding you that your equipment is damaged.\n\nWill only show if your equipment is damaged."] = true,
+ ["Use guild bank"] = true,
+ ["Use the guild banks money when repairing."] = true,
+
+ ["You have equipment to repair, do you want to repair everything at the cost of %s now?"] = true,
+
+ ["Cannot auto-repair equipment. Your money: %s. Needed: %s"] = true,
+ ["Auto-repaired equipment: %s"] = true,
+ ["Auto-repaired equipment using guild bank: %s"] = true,
+ ["AceConsole-Commands"] = {"/durfu", "/durabilityfu"}
+} end)
+
diff --git a/FuBar_DurabilityFu/DurabilityFuLocale-esES.lua b/FuBar_DurabilityFu/DurabilityFuLocale-esES.lua
new file mode 100644
index 0000000..8da6ac8
--- /dev/null
+++ b/FuBar_DurabilityFu/DurabilityFuLocale-esES.lua
@@ -0,0 +1,32 @@
+-- Spanish translation by shiftos
+
+local L = AceLibrary("AceLocale-2.2"):new("FuBar_DurabilityFu")
+
+L:RegisterTranslations("esES", function() return {
+ ["Total"] = "Total",
+ ["Percent"] = "Porcentaje",
+ ["Repair cost"] = "Costes de reparaci\195\179n",
+ ["Repair"] = "Reparar",
+ ["Equipment"] = "Equipo",
+ ["Inventory"] = "Inventario",
+ ["Show the armored man"] = "Mostrar el icono de da\195\177os",
+ ["Toggle whether to show Blizzard's armored man"] = "Determina si se muestra la silueta donde se muestran los da\195\177os a tu equipo (el hombre con armadura)",
+ ["Show average value"] = "Mostrar el valor medio",
+ ["Toggle whether to show your average or minimum durability"] = "Determina si se muestra tu durabilidad media o m\195\173nima",
+ ["Show healthy items"] = "Mostrar objetos intactos",
+ ["Toggle whether to show items that are healthy (100% repaired)"] = "Determina si se muestran los objetos no da\195\177ados (100% reparados)",
+ ["Auto repair"] = "Auto reparar",
+ ["Toggle whether to auto repair all your equipment when you visit a repair vendor."] = "Determina si reparar automaticamente todo tu equipo cuando visitas un vendedor que repare.",
+ ["Show repair popup"] = "Mostrar ventana emergente de reparar",
+ ["Toggle whether to show the repair popup at a vendor, reminding you that your equipment is damaged.\n\nWill only show if your equipment is damaged."] = "Determina si mostrar la ventana emergente de reparacion de un vendedor, recordando que su equipo esta da\195\177ado.\n\nSolo la mostrara si su equipo esta da\195\177ado.",
+ ["Use guild bank"] = "Usar banco de la Hermandad",
+ ["Use the guild banks money when repairing."] = "Usar el dinero de los bancos de la Hermandad al reparar",
+
+ ["You have equipment to repair, do you want to repair everything at the cost of %s now?"] = "Tienes equipo para reparar, \194\191deseas repararlo todo ahora con un coste de %?",
+
+ ["Cannot auto-repair equipment. Your money: %s. Needed: %s"] = "No puedo reparar automaticamente el equipo. Tu dinero: %s. Necesario: %s",
+ ["Auto-repaired equipment: %s"] = "Equipo Auto-Reparado: %s",
+ ["Auto-repaired equipment using guild bank: %s"] = "Equipo Auto-Reparado usando el banco de la Hermandad: %s",
+
+ ["AceConsole-Commands"] = {"/durfu", "/durabilityfu"}
+} end)
diff --git a/FuBar_DurabilityFu/DurabilityFuLocale-frFR.lua b/FuBar_DurabilityFu/DurabilityFuLocale-frFR.lua
new file mode 100644
index 0000000..56e92da
--- /dev/null
+++ b/FuBar_DurabilityFu/DurabilityFuLocale-frFR.lua
@@ -0,0 +1,29 @@
+local L = AceLibrary("AceLocale-2.2"):new("FuBar_DurabilityFu")
+
+L:RegisterTranslations("frFR", function() return {
+ ["Total"] = "Total",
+ ["Percent"] = "Pourcentage",
+ ["Repair cost"] = "Coût des réparations",
+ ["Repair"] = "Réparer",
+ ["Equipment"] = "Équipement",
+ ["Inventory"] = "Inventaire",
+ ["Show the armored man"] = "Afficher le pantin en armure",
+ ["Toggle whether to show Blizzard's armored man"] = "Affiche ou non le pantin en armure de Blizzard.",
+ ["Show average value"] = "Afficher la valeur moyenne",
+ ["Toggle whether to show your average or minimum durability"] = "Affiche la valeur moyenne de votre durabilité au lieu de la valeur minimale.",
+ ["Show healthy items"] = "Afficher les objects intacts",
+ ["Toggle whether to show items that are healthy (100% repaired)"] = "Affiche ou non les objets intacts (à 100% de durabilité).",
+ ["Auto repair"] = "Réparer auto.",
+ ["Toggle whether to auto repair all your equipment when you visit a repair vendor."] = "Répare ou non automatiquement votre équipement aux marchands-réparateurs.",
+ ["Show repair popup"] = "Afficher la fenêtre de réparation",
+ ["Toggle whether to show the repair popup at a vendor, reminding you that your equipment is damaged.\n\nWill only show if your equipment is damaged."] = "Affiche ou non la fenêtre de réparation aux vendeurs vous rappelant que votre équipement est endommagé.\n\nNe s'affichera que si votre équipement est endommagé.",
+ ["Use guild bank"] = "Utiliser la banque de guilde",
+ ["Use the guild banks money when repairing."] = "Utilise l'argent de la banque de guilde pour vos réparations.",
+
+ ["You have equipment to repair, do you want to repair everything at the cost of %s now?"] = "Votre équipement a besoin d'être réparé. Souhaitez-vous le faire maintenant pour %s ?",
+
+ ["Cannot auto-repair equipment. Your money: %s. Needed: %s"] = "Impossible de réparer auto. l'équipement. Votre argent : %s. Nécessaire : %s.",
+ ["Auto-repaired equipment: %s"] = "Réparation auto. de l'équipement : %s.",
+ ["Auto-repaired equipment using guild bank: %s"] = "Réparation auto. de l'équipement avec la banque de guilde : %s.",
+ ["AceConsole-Commands"] = {"/durfu", "/durabilityfu"}
+} end)
diff --git a/FuBar_DurabilityFu/DurabilityFuLocale-koKR.lua b/FuBar_DurabilityFu/DurabilityFuLocale-koKR.lua
new file mode 100644
index 0000000..340c4ba
--- /dev/null
+++ b/FuBar_DurabilityFu/DurabilityFuLocale-koKR.lua
@@ -0,0 +1,29 @@
+local L = AceLibrary("AceLocale-2.2"):new("FuBar_DurabilityFu")
+
+L:RegisterTranslations("koKR", function() return {
+ ["Total"] = "총계",
+ ["Percent"] = "비율",
+ ["Repair cost"] = "수리 비용",
+ ["Repair"] = "수리",
+ ["Equipment"] = "장비",
+ ["Inventory"] = "가방",
+ ["Show the armored man"] = "기본 갑옷 내구도 표시",
+ ["Toggle whether to show Blizzard's armored man"] = "Blizzard의 부위별 내구도 표시 토글",
+ ["Show average value"] = "평균 내구도 표시",
+ ["Toggle whether to show your average or minimum durability"] = "평균 혹은 최소 내구도 표시",
+ ["Show healthy items"] = "상태가 좋은 아이템 표시",
+ ["Toggle whether to show items that are healthy (100% repaired)"] = "100% 수리된 아이템 표시 토글",
+ ["Auto repair"] = "자동 수리",
+ ["Toggle whether to auto repair all your equipment when you visit a repair vendor."] = "수리할 수 있는 상인을 만나면 자동으로 수리 팝업창 띄우는 것을 전환합니다.",
+ ["Show repair popup"] = "수리 팝업창 보기",
+ ["Toggle whether to show the repair popup at a vendor, reminding you that your equipment is damaged.\n\nWill only show if your equipment is damaged."] = "상인을 만나면 내구도가 감소된 아이템을 기억했다가 수리 창 표시를 전환합니다.\n\n이것은 내구도가 감소한 아이템만 표시합니다.",
+ ["Use guild bank"] = "길드 은행 사용",
+ ["Use the guild banks money when repairing."] = "수리할 경우 길드 은행의 소지금을 사용합니다.",
+
+ ["You have equipment to repair, do you want to repair everything at the cost of %s now?"] = "당신은 장비수리가 필요한데, %s의 비용에 모두를 지금 수리 하실겁니까?",
+
+ ["Cannot auto-repair equipment. Your money: %s. Needed: %s"] = "착용장비를 자동 수리할 소지금이 부족합니다. 소지금: %s, 필요금액: %s",
+ ["Auto-repaired equipment: %s"] = "착용장비 자동 수리: %s",
+ ["Auto-repaired equipment using guild bank: %s"] = "길드 은행을 사용하여 착용장비 자동 수리: %s",
+ ["AceConsole-Commands"] = {"/durfu", "/durabilityfu"}
+} end)
diff --git a/FuBar_DurabilityFu/DurabilityFuLocale-ruRU.lua b/FuBar_DurabilityFu/DurabilityFuLocale-ruRU.lua
new file mode 100644
index 0000000..a1b805e
--- /dev/null
+++ b/FuBar_DurabilityFu/DurabilityFuLocale-ruRU.lua
@@ -0,0 +1,31 @@
+-- Russian Localization by Dr. Jet Cheshirsky
+local L = AceLibrary("AceLocale-2.2"):new("FuBar_DurabilityFu")
+
+L:RegisterTranslations("ruRU", function() return {
+ ["Total"] = "Всего",
+ ["Percent"] = "Процент",
+ ["Repair cost"] = "Стоимость починки",
+ ["Repair"] = "Починка",
+ ["Equipment"] = "Снаряжение",
+ ["Inventory"] = "Инвентарь",
+ ["Show the armored man"] = "Показать манекен",
+ ["Toggle whether to show Blizzard's armored man"] = "Вкл/Выкл показ стандартного манекена Blizzard",
+ ["Show average value"] = "Показать среднее значение",
+ ["Toggle whether to show your average or minimum durability"] = "Показывать среднюю или минимальную прочность",
+ ["Show healthy items"] = "Показывать неповреждённые вещи",
+ ["Toggle whether to show items that are healthy (100% repaired)"] = "Показывать ли неповреждённые (%100 прочности) вещи.",
+ ["Auto repair"] = "Автопочинка",
+ ["Toggle whether to auto repair all your equipment when you visit a repair vendor."] = "Вкл/выкл автоматическую починку всех ваших вещей при посещении торговца с опцией починки.",
+ ["Show repair popup"] = "Показать диалог починки",
+ ["Toggle whether to show the repair popup at a vendor, reminding you that your equipment is damaged.\n\nWill only show if your equipment is damaged."] = "Показывать ли диалог ремонта у продавца, напоминая что у вас есть повреждения.\n\nБудет показан только при наличии повреждений.",
+ ["Use guild bank"] = "Использовать гильдбанк",
+ ["Use the guild banks money when repairing."] = "Использовать деньги гильдейского банка при починке",
+
+ ["You have equipment to repair, do you want to repair everything at the cost of %s now?"] = "Вам нужно починить вещи, хотите починить всё за %s сейчас?",
+
+ ["Cannot auto-repair equipment. Your money: %s. Needed: %s"] = "Автопочинка невозможна. У вас денег: %s. Требуется: %s",
+ ["Auto-repaired equipment: %s"] = "Автоматически починено на %s",
+ ["Auto-repaired equipment using guild bank: %s"] = "Автоматически починено с использование денег гильдбанкана на %s",
+ ["AceConsole-Commands"] = {"/durfu", "/durabilityfu"}
+} end)
+
diff --git a/FuBar_DurabilityFu/DurabilityFuLocale-zhCN.lua b/FuBar_DurabilityFu/DurabilityFuLocale-zhCN.lua
new file mode 100644
index 0000000..9305a58
--- /dev/null
+++ b/FuBar_DurabilityFu/DurabilityFuLocale-zhCN.lua
@@ -0,0 +1,29 @@
+local L = AceLibrary("AceLocale-2.2"):new("FuBar_DurabilityFu")
+
+L:RegisterTranslations("zhCN", function() return {
+ ["Total"] = "总计",
+ ["Percent"] = "百分比",
+ ["Repair cost"] = "修理费用",
+ ["Repair"] = "修理",
+ ["Equipment"] = "装备",
+ ["Inventory"] = "背包",
+ ["Show the armored man"] = "显示装备损坏状态人偶",
+ ["Toggle whether to show Blizzard's armored man"] = "设置是否显示暴雪的装备损坏状态人偶",
+ ["Show average value"] = "显示平均值",
+ ["Toggle whether to show your average or minimum durability"] = "设置显示损坏度的平均值还是最小值",
+ ["Show healthy items"] = "显示完好物品",
+ ["Toggle whether to show items that are healthy (100% repaired)"] = "设置是否显示不需要修理的完好物品",
+ ["Auto repair"] = "自动修理",
+ ["Toggle whether to auto repair all your equipment when you visit a repair vendor."] = "设置当你和修理商人对话时是否自动修理物品。",
+ ["Show repair popup"] = "显示修理弹出窗口",
+ ["Toggle whether to show the repair popup at a vendor, reminding you that your equipment is damaged.\n\nWill only show if your equipment is damaged."] = "设置当你和修理商人对话时是否显示修理弹出窗口,提醒你有物品需要修理。\n\n只会在有物品损坏时显示。",
+ ["Use guild bank"] = "使用工会银行",
+ ["Use the guild banks money when repairing."] = "使用工会银行里的钱来修理装备",
+
+ ["You have equipment to repair, do you want to repair everything at the cost of %s now?"] = "你有待修的装备,修理费用需要%s,是否现在修理?",
+
+ ["Cannot auto-repair equipment. Your money: %s. Needed: %s"] = "不能自动修理你身上的装备. 你当前金钱: %s. 需要: %s",
+ ["Auto-repaired equipment: %s"] = "已自动修理的身上装备: %s",
+ ["Auto-repaired equipment using guild bank: %s"] = "已经自动使用工会银行修理身上的装备: %s",
+ ["AceConsole-Commands"] = {"/durfu", "/durabilityfu"}
+} end)
diff --git a/FuBar_DurabilityFu/DurabilityFuLocale-zhTW.lua b/FuBar_DurabilityFu/DurabilityFuLocale-zhTW.lua
new file mode 100644
index 0000000..c941ec7
--- /dev/null
+++ b/FuBar_DurabilityFu/DurabilityFuLocale-zhTW.lua
@@ -0,0 +1,30 @@
+local L = AceLibrary("AceLocale-2.2"):new("FuBar_DurabilityFu")
+
+L:RegisterTranslations("zhTW", function() return {
+ ["Total"] = "總計",
+ ["Percent"] = "百分比",
+ ["Repair cost"] = "修理費用",
+ ["Repair"] = "修理",
+ ["Equipment"] = "裝備",
+ ["Inventory"] = "背包",
+ ["Show the armored man"] = "顯示裝備損壞狀態人偶",
+ ["Toggle whether to show Blizzard's armored man"] = "設定是否顯示 Blizzard 的裝備損壞狀態人偶。",
+ ["Show average value"] = "顯示平均值",
+ ["Toggle whether to show your average or minimum durability"] = "設定顯示損壞度的平均值還是最小值。",
+ ["Show healthy items"] = "顯示完好物品",
+ ["Toggle whether to show items that are healthy (100% repaired)"] = "設定是否顯示不需要修理的完好物品。",
+ ["Auto repair"] = "自動修理",
+ ["Toggle whether to auto repair all your equipment when you visit a repair vendor."] = "設定當你和修理商人談話時是否自動修理物品。",
+ ["Show repair popup"] = "顯示修理彈出視窗",
+ ["Toggle whether to show the repair popup at a vendor, reminding you that your equipment is damaged.\n\nWill only show if your equipment is damaged."] = "設定當你和修理商人談話時是否顯示修理彈出視窗,提醒你有物品需要修理。\n\n只會在有物品損壞時顯示。",
+ ["Use guild bank"] = "使用公會銀行",
+ ["Use the guild banks money when repairing."] = "當修理時使用公會銀行",
+
+ ["You have equipment to repair, do you want to repair everything at the cost of %s now?"] = "你有待修的裝備,修理費用需要%s,是否現在修理?",
+
+ ["Cannot auto-repair equipment. Your money: %s. Needed: %s"] = "不能自動修理身上的裝備。你的金錢: %s。需要: %s",
+ ["Auto-repaired equipment: %s"] = "自動修理身上的裝備: %s",
+ ["Auto-repaired equipment using guild bank: %s"] = "使用公會銀行自動修理身上的裝備: %s",
+ ["AceConsole-Commands"] = {"/durfu", "/durabilityfu"}
+} end)
+
diff --git a/FuBar_DurabilityFu/FuBar_DurabilityFu.toc b/FuBar_DurabilityFu/FuBar_DurabilityFu.toc
new file mode 100644
index 0000000..2058152
--- /dev/null
+++ b/FuBar_DurabilityFu/FuBar_DurabilityFu.toc
@@ -0,0 +1,30 @@
+## Interface: 100002
+## Title: FuBar - |cffffffffDurability|r|cff00ff00Fu|r
+## Notes: Keeps track of durability and pops up a dialog to repair when you go to a vendor who can.
+## Notes-ruRU: Следит за прочностью вашего снаряжения и показывает диалог починки у торговца, умеющего чинить.
+## Notes-zhTW: 持續追蹤裝備耐久度,並在可修裝NPC處顯示是否要自動修裝的對話框。
+## Notes-esES: Vigila la durabilidad y muestra una ventana para reparar cuando vas a un vendedor.
+## Version: 2.14
+## X-eMail: ckknight AT gmail DOT com
+## X-Donate: PayPal:ckknight AT gmail DOT com
+## X-Website: http://www.wowace.com/
+## X-Category: Inventory
+## X-Website: http://ckknight.wowinterface.com/
+## OptionalDeps: FuBar, Ace2, Deformat, DewdropLib, GratuityLib, FuBarPlugin-2.0, TabletLib, CrayonLib
+## SavedVariables: DurabilityFuDB
+## X-Curse-Packaged-Version: r127
+## X-Curse-Project-Name: FuBar_DurabilityFu
+## X-Curse-Project-ID: fubar_durabilityfu
+## X-Curse-Repository-ID: wow/fubar_durabilityfu/mainline
+
+embeds.xml
+
+DurabilityFuLocale-enUS.lua
+DurabilityFuLocale-ruRU.lua
+DurabilityFuLocale-deDE.lua
+DurabilityFuLocale-frFR.lua
+DurabilityFuLocale-koKR.lua
+DurabilityFuLocale-zhCN.lua
+DurabilityFuLocale-zhTW.lua
+DurabilityFuLocale-esES.lua
+DurabilityFu.lua
diff --git a/FuBar_DurabilityFu/embeds.xml b/FuBar_DurabilityFu/embeds.xml
new file mode 100644
index 0000000..8048003
--- /dev/null
+++ b/FuBar_DurabilityFu/embeds.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FuBar_DurabilityFu/icon.tga b/FuBar_DurabilityFu/icon.tga
new file mode 100644
index 0000000..d70b432
Binary files /dev/null and b/FuBar_DurabilityFu/icon.tga differ
diff --git a/FuBar_DurabilityFu/libs/Abacus-2.0/Abacus-2.0.lua b/FuBar_DurabilityFu/libs/Abacus-2.0/Abacus-2.0.lua
new file mode 100644
index 0000000..ae27ceb
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/Abacus-2.0/Abacus-2.0.lua
@@ -0,0 +1,498 @@
+--[[
+Name: Abacus-2.0
+Revision: $Rev: 74 $
+Author(s): ckknight (ckknight@gmail.com)
+Website: http://ckknight.wowinterface.com/
+Documentation: http://wiki.wowace.com/index.php/Abacus-2.0
+SVN: http://svn.wowace.com/root/trunk/AbacusLib/Abacus-2.0
+Description: A library to provide tools for formatting money and time.
+Dependencies: AceLibrary
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "Abacus-2.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 74 $"):match("(%d+)"))
+
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+local Abacus = {}
+
+local COPPER_ABBR = "c"
+local SILVER_ABBR = "s"
+local GOLD_ABBR = "g"
+
+local COLOR_WHITE = "ffffff"
+local COLOR_GREEN = "00ff00"
+local COLOR_RED = "ff0000"
+local COLOR_COPPER = "eda55f"
+local COLOR_SILVER = "c7c7cf"
+local COLOR_GOLD = "ffd700"
+
+local GOLD, SILVER, COPPER = GOLD, SILVER, COPPER
+
+if not COPPER and COPPER_AMOUNT then
+ GOLD = GOLD_AMOUNT:gsub("%s*%%d%s*", "")
+ SILVER = SILVER_AMOUNT:gsub("%s*%%d%s*", "")
+ COPPER = COPPER_AMOUNT:gsub("%s*%%d%s*", "")
+end
+
+local L_DAY_ONELETTER_ABBR = DAY_ONELETTER_ABBR:gsub("%s*%%d%s*", "")
+local L_HOUR_ONELETTER_ABBR = HOUR_ONELETTER_ABBR:gsub("%s*%%d%s*", "")
+local L_MINUTE_ONELETTER_ABBR = MINUTE_ONELETTER_ABBR:gsub("%s*%%d%s*", "")
+local L_SECOND_ONELETTER_ABBR = SECOND_ONELETTER_ABBR:gsub("%s*%%d%s*", "")
+
+local _, DAYS_ABBR_P1 = strsplit(":", DAYS_ABBR);
+local _, HOURS_ABBR_P1 = strsplit(":", HOURS_ABBR);
+local _, MINUTES_ABBR_P1 = strsplit(":", MINUTES_ABBR);
+local _, SECONDS_ABBR_P1 = strsplit(":", SECONDS_ABBR);
+
+local L_UNDETERMINED = "Undetermined"
+
+local l = GetLocale()
+if l == "koKR" then
+ L_UNDETERMINED = "측정불가"
+elseif l == "zhTW" then
+ COPPER_ABBR = "銅"
+ SILVER_ABBR = "銀"
+ GOLD_ABBR = "金"
+ L_UNDETERMINED = "未定義的"
+elseif l == "deDE" then
+ COPPER_ABBR = "k"
+ SILVER_ABBR = "s"
+ GOLD_ABBR = "g"
+ L_UNDETERMINED = "Unbestimmt"
+elseif l == "esES" then
+ COPPER_ABBR = "b"
+ SILVER_ABBR = "p"
+ GOLD_ABBR = "o"
+ L_UNDETERMINED = "Indeterminado"
+elseif l == "zhCN" then
+ COPPER_ABBR = "铜"
+ SILVER_ABBR = "银"
+ GOLD_ABBR = "金"
+ L_UNDETERMINED = "未定义"
+end
+
+local inf = 1/0
+
+function Abacus:FormatMoneyExtended(value, colorize, textColor)
+ self:argCheck(value, 2, "number")
+ local gold = abs(value / 10000)
+ local silver = abs(mod(value / 100, 100))
+ local copper = abs(mod(value, 100))
+
+ local negl = ""
+ local color = COLOR_WHITE
+ if value > 0 then
+ if textColor then
+ color = COLOR_GREEN
+ end
+ elseif value < 0 then
+ negl = "-"
+ if textColor then
+ color = COLOR_RED
+ end
+ end
+ if colorize then
+ if value == inf or value == -inf then
+ return format("|cff%s%s|r", color, value)
+ elseif value ~= value then
+ return format("|cff%s0|r|cff%s %s|r", COLOR_WHITE, COLOR_COPPER, COPPER)
+ elseif value >= 10000 or value <= -10000 then
+ return format("|cff%s%s%d|r|cff%s %s|r |cff%s%d|r|cff%s %s|r |cff%s%d|r|cff%s %s|r", color, negl, gold, COLOR_GOLD, GOLD, color, silver, COLOR_SILVER, SILVER, color, copper, COLOR_COPPER, COPPER)
+ elseif value >= 100 or value <= -100 then
+ return format("|cff%s%s%d|r|cff%s %s|r |cff%s%d|r|cff%s %s|r", color, negl, silver, COLOR_SILVER, SILVER, color, copper, COLOR_COPPER, COPPER)
+ else
+ return format("|cff%s%s%d|r|cff%s %s|r", color, negl, copper, COLOR_COPPER, COPPER)
+ end
+ else
+ if value == inf or value == -inf then
+ return format("%s", value)
+ elseif value ~= value then
+ return format("0 %s", COPPER)
+ elseif value >= 10000 or value <= -10000 then
+ return format("%s%d %s %d %s %d %s", negl, gold, GOLD, silver, SILVER, copper, COPPER)
+ elseif value >= 100 or value <= -100 then
+ return format("%s%d %s %d %s", negl, silver, SILVER, copper, COPPER)
+ else
+ return format("%s%d %s", negl, copper, COPPER)
+ end
+ end
+end
+
+function Abacus:FormatMoneyFull(value, colorize, textColor)
+ self:argCheck(value, 2, "number")
+ local gold = abs(value / 10000)
+ local silver = abs(mod(value / 100, 100))
+ local copper = abs(mod(value, 100))
+
+ local negl = ""
+ local color = COLOR_WHITE
+ if value > 0 then
+ if textColor then
+ color = COLOR_GREEN
+ end
+ elseif value < 0 then
+ negl = "-"
+ if textColor then
+ color = COLOR_RED
+ end
+ end
+ if colorize then
+ if value == inf or value == -inf then
+ return format("|cff%s%s|r", color, value)
+ elseif value ~= value then
+ return format("|cff%s0|r|cff%s%s|r", COLOR_WHITE, COLOR_COPPER, COPPER_ABBR)
+ elseif value >= 10000 or value <= -10000 then
+ return format("|cff%s%s%d|r|cff%s%s|r |cff%s%d|r|cff%s%s|r |cff%s%d|r|cff%s%s|r", color, negl, gold, COLOR_GOLD, GOLD_ABBR, color, silver, COLOR_SILVER, SILVER_ABBR, color, copper, COLOR_COPPER, COPPER_ABBR)
+ elseif value >= 100 or value <= -100 then
+ return format("|cff%s%s%d|r|cff%s%s|r |cff%s%d|r|cff%s%s|r", color, negl, silver, COLOR_SILVER, SILVER_ABBR, color, copper, COLOR_COPPER, COPPER_ABBR)
+ else
+ return format("|cff%s%s%d|r|cff%s%s|r", color, negl, copper, COLOR_COPPER, COPPER_ABBR)
+ end
+ else
+ if value == inf or value == -inf then
+ return format("%s", value)
+ elseif value ~= value then
+ return format("0%s", COPPER_ABBR)
+ elseif value >= 10000 or value <= -10000 then
+ return format("%s%d%s %d%s %d%s", negl, gold, GOLD_ABBR, silver, SILVER_ABBR, copper, COPPER_ABBR)
+ elseif value >= 100 or value <= -100 then
+ return format("%s%d%s %d%s", negl, silver, SILVER_ABBR, copper, COPPER_ABBR)
+ else
+ return format("%s%d%s", negl, copper, COPPER_ABBR)
+ end
+ end
+end
+
+function Abacus:FormatMoneyShort(copper, colorize, textColor)
+ self:argCheck(copper, 2, "number")
+ local color = COLOR_WHITE
+ if textColor then
+ if copper > 0 then
+ color = COLOR_GREEN
+ elseif copper < 0 then
+ color = COLOR_RED
+ end
+ end
+ if colorize then
+ if copper == inf or copper == -inf then
+ return format("|cff%s%s|r", color, copper)
+ elseif copper ~= copper then
+ return format("|cff%s0|r|cff%s%s|r", COLOR_WHITE, COLOR_COPPER, COPPER_ABBR)
+ elseif copper >= 10000 or copper <= -10000 then
+ return format("|cff%s%.1f|r|cff%s%s|r", color, copper / 10000, COLOR_GOLD, GOLD_ABBR)
+ elseif copper >= 100 or copper <= -100 then
+ return format("|cff%s%.1f|r|cff%s%s|r", color, copper / 100, COLOR_SILVER, SILVER_ABBR)
+ else
+ return format("|cff%s%d|r|cff%s%s|r", color, copper, COLOR_COPPER, COPPER_ABBR)
+ end
+ else
+ if value == copper or value == -copper then
+ return format("%s", copper)
+ elseif copper ~= copper then
+ return format("0%s", COPPER_ABBR)
+ elseif copper >= 10000 or copper <= -10000 then
+ return format("%.1f%s", copper / 10000, GOLD_ABBR)
+ elseif copper >= 100 or copper <= -100 then
+ return format("%.1f%s", copper / 100, SILVER_ABBR)
+ else
+ return format("%.0f%s", copper, COPPER_ABBR)
+ end
+ end
+end
+
+function Abacus:FormatMoneyCondensed(value, colorize, textColor)
+ self:argCheck(value, 2, "number")
+ local negl = ""
+ local negr = ""
+ if value < 0 then
+ if colorize and textColor then
+ negl = "|cffff0000-(|r"
+ negr = "|cffff0000)|r"
+ else
+ negl = "-("
+ negr = ")"
+ end
+ end
+ local gold = floor(math.abs(value) / 10000)
+ local silver = mod(floor(math.abs(value) / 100), 100)
+ local copper = mod(floor(math.abs(value)), 100)
+ if colorize then
+ if value == inf or value == -inf then
+ return format("%s|cff%s%s|r%s", negl, COLOR_COPPER, math.abs(value), negr)
+ elseif value ~= value then
+ return format("|cff%s0|r", COLOR_COPPER)
+ elseif gold ~= 0 then
+ return format("%s|cff%s%d|r.|cff%s%02d|r.|cff%s%02d|r%s", negl, COLOR_GOLD, gold, COLOR_SILVER, silver, COLOR_COPPER, copper, negr)
+ elseif silver ~= 0 then
+ return format("%s|cff%s%d|r.|cff%s%02d|r%s", negl, COLOR_SILVER, silver, COLOR_COPPER, copper, negr)
+ else
+ return format("%s|cff%s%d|r%s", negl, COLOR_COPPER, copper, negr)
+ end
+ else
+ if value == inf or value == -inf then
+ return tostring(value)
+ elseif value ~= value then
+ return "0"
+ elseif gold ~= 0 then
+ return format("%s%d.%02d.%02d%s", negl, gold, silver, copper, negr)
+ elseif silver ~= 0 then
+ return format("%s%d.%02d%s", negl, silver, copper, negr)
+ else
+ return format("%s%d%s", negl, copper, negr)
+ end
+ end
+end
+
+local t
+function Abacus:FormatDurationExtended(duration, colorize, hideSeconds)
+ self:argCheck(duration, 2, "number")
+ local negative = ""
+ if duration ~= duration then
+ duration = 0
+ end
+ if duration < 0 then
+ negative = "-"
+ duration = -duration
+ end
+ local days = floor(duration / 86400)
+ local hours = mod(floor(duration / 3600), 24)
+ local mins = mod(floor(duration / 60), 60)
+ local secs = mod(floor(duration), 60)
+ if not t then
+ t = {}
+ else
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ end
+ if not colorize then
+ if not duration or duration > 86400*36500 then -- 100 years
+ return L_UNDETERMINED
+ end
+ if days > 1 then
+ table.insert(t, format("%d %s", days, DAYS_ABBR_P1))
+ elseif days == 1 then
+ table.insert(t, format("%d %s", days, DAYS_ABBR))
+ end
+ if hours > 1 then
+ table.insert(t, format("%d %s", hours, HOURS_ABBR_P1))
+ elseif hours == 1 then
+ table.insert(t, format("%d %s", hours, HOURS_ABBR))
+ end
+ if mins > 1 then
+ table.insert(t, format("%d %s", mins, MINUTES_ABBR_P1))
+ elseif mins == 1 then
+ table.insert(t, format("%d %s", mins, MINUTES_ABBR))
+ end
+ if not hideSeconds then
+ if secs > 1 then
+ table.insert(t, format("%d %s", secs, SECONDS_ABBR_P1))
+ elseif secs == 1 then
+ table.insert(t, format("%d %s", secs, SECONDS_ABBR))
+ end
+ end
+ if table.getn(t) == 0 then
+ if not hideSeconds then
+ return "0 " .. SECONDS_ABBR_P1
+ else
+ return "0 " .. MINUTES_ABBR_P1
+ end
+ else
+ return negative .. table.concat(t, " ")
+ end
+ else
+ if not duration or duration > 86400*36500 then -- 100 years
+ return "|cffffffff"..L_UNDETERMINED.."|r"
+ end
+ if days > 1 then
+ table.insert(t, format("|cffffffff%d|r %s", days, DAYS_ABBR_P1))
+ elseif days == 1 then
+ table.insert(t, format("|cffffffff%d|r %s", days, DAYS_ABBR))
+ end
+ if hours > 1 then
+ table.insert(t, format("|cffffffff%d|r %s", hours, HOURS_ABBR_P1))
+ elseif hours == 1 then
+ table.insert(t, format("|cffffffff%d|r %s", hours, HOURS_ABBR))
+ end
+ if mins > 1 then
+ table.insert(t, format("|cffffffff%d|r %s", mins, MINUTES_ABBR_P1))
+ elseif mins == 1 then
+ table.insert(t, format("|cffffffff%d|r %s", mins, MINUTES_ABBR))
+ end
+ if not hideSeconds then
+ if secs > 1 then
+ table.insert(t, format("|cffffffff%d|r %s", secs, SECONDS_ABBR_P1))
+ elseif secs == 1 then
+ table.insert(t, format("|cffffffff%d|r %s", secs, SECONDS_ABBR))
+ end
+ end
+ if table.getn(t) == 0 then
+ if not hideSeconds then
+ return "|cffffffff0|r " .. SECONDS_ABBR_P1
+ else
+ return "|cffffffff0|r " .. MINUTES_ABBR_P1
+ end
+ elseif negative == "-" then
+ return "|cffffffff-|r" .. table.concat(t, " ")
+ else
+ return table.concat(t, " ")
+ end
+ end
+end
+
+function Abacus:FormatDurationFull(duration, colorize, hideSeconds)
+ self:argCheck(duration, 2, "number")
+ local negative = ""
+ if duration ~= duration then
+ duration = 0
+ end
+ if duration < 0 then
+ negative = "-"
+ duration = -duration
+ end
+ if not colorize then
+ if not hideSeconds then
+ if not duration or duration > 86400*36500 then -- 100 years
+ return L_UNDETERMINED
+ elseif duration >= 86400 then
+ return format("%s%d%s %02d%s %02d%s %02d%s", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR)
+ elseif duration >= 3600 then
+ return format("%s%d%s %02d%s %02d%s", negative, duration/3600, L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR)
+ elseif duration >= 120 then
+ return format("%s%d%s %02d%s", negative, duration/60, L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR)
+ else
+ return format("%s%d%s", negative, duration, L_SECOND_ONELETTER_ABBR)
+ end
+ else
+ if not duration or duration > 86400*36500 then -- 100 years
+ return L_UNDETERMINED
+ elseif duration >= 86400 then
+ return format("%s%d%s %02d%s %02d%s", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR)
+ elseif duration >= 3600 then
+ return format("%s%d%s %02d%s", negative, duration/3600, L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR)
+ else
+ return format("%s%d%s", negative, duration/60, L_MINUTE_ONELETTER_ABBR)
+ end
+ end
+ else
+ if not hideSeconds then
+ if not duration or duration > 86400*36500 then -- 100 years
+ return "|cffffffff"..L_UNDETERMINED.."|r"
+ elseif duration >= 86400 then
+ return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR)
+ elseif duration >= 3600 then
+ return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s", negative, duration/3600, L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR)
+ elseif duration >= 120 then
+ return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s", negative, duration/60, L_MINUTE_ONELETTER_ABBR, mod(duration, 60), L_SECOND_ONELETTER_ABBR)
+ else
+ return format("|cffffffff%s%d|r%s", negative, duration, L_SECOND_ONELETTER_ABBR)
+ end
+ else
+ if not duration or duration > 86400*36500 then -- 100 years
+ return "|cffffffff"..L_UNDETERMINED.."|r"
+ elseif duration >= 86400 then
+ return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s |cffffffff%02d|r%s", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR)
+ elseif duration >= 3600 then
+ return format("|cffffffff%s%d|r%s |cffffffff%02d|r%s", negative, duration/3600, L_HOUR_ONELETTER_ABBR, mod(duration/60, 60), L_MINUTE_ONELETTER_ABBR)
+ else
+ return format("|cffffffff%s%d|r%s", negative, duration/60, L_MINUTE_ONELETTER_ABBR)
+ end
+ end
+ end
+end
+
+function Abacus:FormatDurationShort(duration, colorize, hideSeconds)
+ self:argCheck(duration, 2, "number")
+ local negative = ""
+ if duration ~= duration then
+ duration = 0
+ end
+ if duration < 0 then
+ negative = "-"
+ duration = -duration
+ end
+ if not colorize then
+ if not duration or duration >= 86400*36500 then -- 100 years
+ return "***"
+ elseif duration >= 172800 then
+ return format("%s%.1f %s", negative, duration/86400, DAYS_ABBR_P1)
+ elseif duration >= 7200 then
+ return format("%s%.1f %s", negative, duration/3600, HOURS_ABBR_P1)
+ elseif duration >= 120 or not hideSeconds then
+ return format("%s%.1f %s", negative, duration/60, MINUTES_ABBR_P1)
+ else
+ return format("%s%.0f %s", negative, duration, SECONDS_ABBR_P1)
+ end
+ else
+ if not duration or duration >= 86400*36500 then -- 100 years
+ return "|cffffffff***|r"
+ elseif duration >= 172800 then
+ return format("|cffffffff%s%.1f|r %s", negative, duration/86400, DAYS_ABBR_P1)
+ elseif duration >= 7200 then
+ return format("|cffffffff%s%.1f|r %s", negative, duration/3600, HOURS_ABBR_P1)
+ elseif duration >= 120 or not hideSeconds then
+ return format("|cffffffff%s%.1f|r %s", negative, duration/60, MINUTES_ABBR_P1)
+ else
+ return format("|cffffffff%s%.0f|r %s", negative, duration, SECONDS_ABBR_P1)
+ end
+ end
+end
+
+function Abacus:FormatDurationCondensed(duration, colorize, hideSeconds)
+ self:argCheck(duration, 2, "number")
+ local negative = ""
+ if duration ~= duration then
+ duration = 0
+ end
+ if duration < 0 then
+ negative = "-"
+ duration = -duration
+ end
+ if not colorize then
+ if hideSeconds then
+ if not duration or duration >= 86400*36500 then -- 100 years
+ return format("%s**%s **:**", negative, L_DAY_ONELETTER_ABBR)
+ elseif duration >= 86400 then
+ return format("%s%d%s %d:%02d", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60))
+ else
+ return format("%s%d:%02d", negative, duration/3600, mod(duration/60, 60))
+ end
+ else
+ if not duration or duration >= 86400*36500 then -- 100 years
+ return negative .. "**:**:**:**"
+ elseif duration >= 86400 then
+ return format("%s%d%s %d:%02d:%02d", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60), mod(duration, 60))
+ elseif duration >= 3600 then
+ return format("%s%d:%02d:%02d", negative, duration/3600, mod(duration/60, 60), mod(duration, 60))
+ else
+ return format("%s%d:%02d", negative, duration/60, mod(duration, 60))
+ end
+ end
+ else
+ if hideSeconds then
+ if not duration or duration >= 86400*36500 then -- 100 years
+ return format("|cffffffff%s**|r%s |cffffffff**|r:|cffffffff**|r", negative, L_DAY_ONELETTER_ABBR)
+ elseif duration >= 86400 then
+ return format("|cffffffff%s%d|r%s |cffffffff%d|r:|cffffffff%02d|r", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60))
+ else
+ return format("|cffffffff%s%d|r:|cffffffff%02d|r", negative, duration/3600, mod(duration/60, 60))
+ end
+ else
+ if not duration or duration >= 86400*36500 then -- 100 years
+ return format("|cffffffff%s**|r%s |cffffffff**|r:|cffffffff**|r:|cffffffff**|r", negative, L_DAY_ONELETTER_ABBR)
+ elseif duration >= 86400 then
+ return format("|cffffffff%s%d|r%s |cffffffff%d|r:|cffffffff%02d|r:|cffffffff%02d|r", negative, duration/86400, L_DAY_ONELETTER_ABBR, mod(duration/3600, 24), mod(duration/60, 60), mod(duration, 60))
+ elseif duration >= 3600 then
+ return format("|cffffffff%s%d|r:|cffffffff%02d|r:|cffffffff%02d|r", negative, duration/3600, mod(duration/60, 60), mod(duration, 60))
+ else
+ return format("|cffffffff%s%d|r:|cffffffff%02d|r", negative, duration/60, mod(duration, 60))
+ end
+ end
+ end
+end
+
+AceLibrary:Register(Abacus, MAJOR_VERSION, MINOR_VERSION)
+Abacus = nil
diff --git a/FuBar_DurabilityFu/libs/AceAddon-2.0/AceAddon-2.0.lua b/FuBar_DurabilityFu/libs/AceAddon-2.0/AceAddon-2.0.lua
new file mode 100644
index 0000000..3d3e128
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceAddon-2.0/AceAddon-2.0.lua
@@ -0,0 +1,1459 @@
+--[[
+Name: AceAddon-2.0
+Revision: $Rev: 1100 $
+Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team)
+Inspired By: Ace 1.x by Turan (turan@gryphon.com)
+Website: http://www.wowace.com/
+Documentation: http://www.wowace.com/wiki/AceAddon-2.0
+SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceAddon-2.0
+Description: Base for all Ace addons to inherit from.
+Dependencies: AceLibrary, AceOO-2.0, AceEvent-2.0, (optional) AceConsole-2.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "AceAddon-2.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 1100 $"):match("(%d+)"))
+
+-- This ensures the code is only executed if the libary doesn't already exist, or is a newer version
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+if not AceLibrary:HasInstance("AceOO-2.0") then error(MAJOR_VERSION .. " requires AceOO-2.0.") end
+
+local function safecall(func,...)
+ local success, err = pcall(func,...)
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("\n(.-: )in.-\n") or "") .. err) end
+end
+-- Localization
+local STANDBY, TITLE, NOTES, VERSION, AUTHOR, DATE, CATEGORY, EMAIL, CREDITS, WEBSITE, CATEGORIES, ABOUT, LICENSE, PRINT_ADDON_INFO, DONATE, DONATE_DESC, HOWTO_DONATE_WINDOWS, HOWTO_DONATE_MAC
+if GetLocale() == "deDE" then
+ STANDBY = "|cffff5050(Standby)|r" -- capitalized
+
+ TITLE = "Titel"
+ NOTES = "Anmerkung"
+ VERSION = "Version"
+ AUTHOR = "Autor"
+ DATE = "Datum"
+ CATEGORY = "Kategorie"
+ EMAIL = "E-Mail"
+ WEBSITE = "Webseite"
+ CREDITS = "Credits" -- fix
+ LICENSE = "License" -- fix
+
+ ABOUT = "Über"
+ PRINT_ADDON_INFO = "Gibt Addondaten aus"
+ DONATE = "Donate" -- fix
+ DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix
+ HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix
+ HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix
+
+ CATEGORIES = {
+ ["Action Bars"] = "Aktionsleisten",
+ ["Auction"] = "Auktion",
+ ["Audio"] = "Audio",
+ ["Battlegrounds/PvP"] = "Schlachtfeld/PvP",
+ ["Buffs"] = "Stärkungszauber",
+ ["Chat/Communication"] = "Chat/Kommunikation",
+ ["Druid"] = "Druide",
+ ["Hunter"] = "Jäger",
+ ["Mage"] = "Magier",
+ ["Paladin"] = "Paladin",
+ ["Priest"] = "Priester",
+ ["Rogue"] = "Schurke",
+ ["Shaman"] = "Schamane",
+ ["Warlock"] = "Hexenmeister",
+ ["Warrior"] = "Krieger",
+ ["Healer"] = "Heiler",
+ ["Tank"] = "Tank",
+ ["Caster"] = "Zauberer",
+ ["Combat"] = "Kampf",
+ ["Compilations"] = "Zusammenstellungen",
+ ["Data Export"] = "Datenexport",
+ ["Development Tools"] = "Entwicklungs Tools",
+ ["Guild"] = "Gilde",
+ ["Frame Modification"] = "Frame Veränderungen",
+ ["Interface Enhancements"] = "Interface Verbesserungen",
+ ["Inventory"] = "Inventar",
+ ["Library"] = "Bibliotheken",
+ ["Map"] = "Karte",
+ ["Mail"] = "Post",
+ ["Miscellaneous"] = "Diverses",
+ ["Quest"] = "Quest",
+ ["Raid"] = "Schlachtzug",
+ ["Tradeskill"] = "Beruf",
+ ["UnitFrame"] = "Einheiten-Fenster",
+ }
+elseif GetLocale() == "frFR" then
+ STANDBY = "|cffff5050(attente)|r"
+
+ TITLE = "Titre"
+ NOTES = "Notes"
+ VERSION = "Version"
+ AUTHOR = "Auteur"
+ DATE = "Date"
+ CATEGORY = "Catégorie"
+ EMAIL = "E-mail"
+ WEBSITE = "Site web"
+ CREDITS = "Credits" -- fix
+ LICENSE = "License" -- fix
+
+ ABOUT = "A propos"
+ PRINT_ADDON_INFO = "Afficher les informations sur l'addon"
+ DONATE = "Donate" -- fix
+ DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix
+ HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix
+ HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix
+
+ CATEGORIES = {
+ ["Action Bars"] = "Barres d'action",
+ ["Auction"] = "Hôtel des ventes",
+ ["Audio"] = "Audio",
+ ["Battlegrounds/PvP"] = "Champs de bataille/JcJ",
+ ["Buffs"] = "Buffs",
+ ["Chat/Communication"] = "Chat/Communication",
+ ["Druid"] = "Druide",
+ ["Hunter"] = "Chasseur",
+ ["Mage"] = "Mage",
+ ["Paladin"] = "Paladin",
+ ["Priest"] = "Prêtre",
+ ["Rogue"] = "Voleur",
+ ["Shaman"] = "Chaman",
+ ["Warlock"] = "Démoniste",
+ ["Warrior"] = "Guerrier",
+ ["Healer"] = "Soigneur",
+ ["Tank"] = "Tank",
+ ["Caster"] = "Casteur",
+ ["Combat"] = "Combat",
+ ["Compilations"] = "Compilations",
+ ["Data Export"] = "Exportation de données",
+ ["Development Tools"] = "Outils de développement",
+ ["Guild"] = "Guilde",
+ ["Frame Modification"] = "Modification des fenêtres",
+ ["Interface Enhancements"] = "Améliorations de l'interface",
+ ["Inventory"] = "Inventaire",
+ ["Library"] = "Bibliothèques",
+ ["Map"] = "Carte",
+ ["Mail"] = "Courrier",
+ ["Miscellaneous"] = "Divers",
+ ["Quest"] = "Quêtes",
+ ["Raid"] = "Raid",
+ ["Tradeskill"] = "Métiers",
+ ["UnitFrame"] = "Fenêtres d'unité",
+ }
+elseif GetLocale() == "koKR" then
+ STANDBY = "|cffff5050(사용가능)|r"
+
+ TITLE = "제목"
+ NOTES = "노트"
+ VERSION = "버전"
+ AUTHOR = "저작자"
+ DATE = "날짜"
+ CATEGORY = "분류"
+ EMAIL = "전자 우편"
+ WEBSITE = "웹 사이트"
+ CREDITS = "공로자"
+ LICENSE = "라이센스"
+
+ ABOUT = "정보"
+ PRINT_ADDON_INFO = "애드온에 대한 정보를 출력합니다."
+ DONATE = "기부"
+ DONATE_DESC = "이 애드온의 저작자에게 기부를 합니다."
+ HOWTO_DONATE_WINDOWS = "Ctrl-A를 눌려 링크를 선택후, Ctrl-C로 복사합니다. Alt-Tab 눌려 게임으로 부터 나간후 웹 브라우저를 엽니다. 복사된 링크를 주소 창에 붙여넣기 합니다."
+ HOWTO_DONATE_MAC = "Cmd-A를 눌려 링크를 선택후, Cmd-C로 복사합니다. Cmd-Tab 눌려 게임으로 부터 나간후 웹 브라우저를 엽니다. 복사된 링크를 주소 창에 붙여넣기 합니다."
+
+ CATEGORIES = {
+ ["Action Bars"] = "액션바",
+ ["Auction"] = "경매",
+ ["Audio"] = "음향",
+ ["Battlegrounds/PvP"] = "전장/PvP",
+ ["Buffs"] = "버프",
+ ["Chat/Communication"] = "대화/의사소통",
+ ["Druid"] = "드루이드",
+ ["Hunter"] = "사냥꾼",
+ ["Mage"] = "마법사",
+ ["Paladin"] = "성기사",
+ ["Priest"] = "사제",
+ ["Rogue"] = "도적",
+ ["Shaman"] = "주술사",
+ ["Warlock"] = "흑마법사",
+ ["Warrior"] = "전사",
+ ["Healer"] = "힐러",
+ ["Tank"] = "탱커",
+ ["Caster"] = "캐스터",
+ ["Combat"] = "전투",
+ ["Compilations"] = "복합",
+ ["Data Export"] = "자료 출력",
+ ["Development Tools"] = "개발 도구",
+ ["Guild"] = "길드",
+ ["Frame Modification"] = "구조 변경",
+ ["Interface Enhancements"] = "인터페이스 강화",
+ ["Inventory"] = "인벤토리",
+ ["Library"] = "라이브러리",
+ ["Map"] = "지도",
+ ["Mail"] = "우편",
+ ["Miscellaneous"] = "기타",
+ ["Quest"] = "퀘스트",
+ ["Raid"] = "공격대",
+ ["Tradeskill"] = "전문기술",
+ ["UnitFrame"] = "유닛 프레임",
+ }
+elseif GetLocale() == "zhTW" then
+ STANDBY = "|cffff5050(待命)|r"
+
+ TITLE = "標題"
+ NOTES = "註記"
+ VERSION = "版本"
+ AUTHOR = "作者"
+ DATE = "日期"
+ CATEGORY = "類別"
+ EMAIL = "電子郵件"
+ WEBSITE = "網站"
+ CREDITS = "特別感謝"
+ LICENSE = "版權"
+
+ ABOUT = "關於"
+ PRINT_ADDON_INFO = "顯示插件資訊。"
+ DONATE = "捐贈"
+ DONATE_DESC = "捐贈金錢給插件作者。"
+ HOWTO_DONATE_WINDOWS = "請按Ctrl-A選擇網站連結,Ctrl-C複製網址,Alt-Tab切換到電腦桌面,打開瀏覽器,在網址列貼上網址。"
+ HOWTO_DONATE_MAC = "請按Cmd-A選擇網站連結,Cmd-C複製網址,Cmd-Tab切換到電腦桌面,打開瀏覽器,在網址列貼上網址。"
+
+ CATEGORIES = {
+ ["Action Bars"] = "動作條",
+ ["Auction"] = "拍賣",
+ ["Audio"] = "音效",
+ ["Battlegrounds/PvP"] = "戰場/PvP",
+ ["Buffs"] = "增益",
+ ["Chat/Communication"] = "聊天/通訊",
+ ["Druid"] = "德魯伊",
+ ["Hunter"] = "獵人",
+ ["Mage"] = "法師",
+ ["Paladin"] = "聖騎士",
+ ["Priest"] = "牧師",
+ ["Rogue"] = "盜賊",
+ ["Shaman"] = "薩滿",
+ ["Warlock"] = "術士",
+ ["Warrior"] = "戰士",
+ ["Healer"] = "治療者",
+ ["Tank"] = "坦克",
+ ["Caster"] = "施法者",
+ ["Combat"] = "戰鬥",
+ ["Compilations"] = "整合",
+ ["Data Export"] = "資料匯出",
+ ["Development Tools"] = "開發工具",
+ ["Guild"] = "公會",
+ ["Frame Modification"] = "框架修改",
+ ["Interface Enhancements"] = "介面增強",
+ ["Inventory"] = "庫存",
+ ["Library"] = "程式庫",
+ ["Map"] = "地圖",
+ ["Mail"] = "郵件",
+ ["Miscellaneous"] = "雜項",
+ ["Quest"] = "任務",
+ ["Raid"] = "團隊",
+ ["Tradeskill"] = "交易技能",
+ ["UnitFrame"] = "單位框架",
+ }
+elseif GetLocale() == "zhCN" then
+ STANDBY = "|cffff5050(暂挂)|r"
+
+ TITLE = "标题"
+ NOTES = "附注"
+ VERSION = "版本"
+ AUTHOR = "作者"
+ DATE = "日期"
+ CATEGORY = "分类"
+ EMAIL = "电子邮件"
+ WEBSITE = "网站"
+ CREDITS = "Credits" -- fix
+ LICENSE = "License" -- fix
+
+ ABOUT = "关于"
+ PRINT_ADDON_INFO = "印列出插件信息"
+ DONATE = "Donate" -- fix
+ DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix
+ HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix
+ HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix
+
+ CATEGORIES = {
+ ["Action Bars"] = "动作条",
+ ["Auction"] = "拍卖",
+ ["Audio"] = "音频",
+ ["Battlegrounds/PvP"] = "战场/PvP",
+ ["Buffs"] = "增益魔法",
+ ["Chat/Communication"] = "聊天/交流",
+ ["Druid"] = "德鲁伊",
+ ["Hunter"] = "猎人",
+ ["Mage"] = "法师",
+ ["Paladin"] = "圣骑士",
+ ["Priest"] = "牧师",
+ ["Rogue"] = "盗贼",
+ ["Shaman"] = "萨满祭司",
+ ["Warlock"] = "术士",
+ ["Warrior"] = "战士",
+ ["Healer"] = "Healer",
+ ["Tank"] = "Tank",
+ ["Caster"] = "Caster",
+ ["Combat"] = "战斗",
+ ["Compilations"] = "编译",
+ ["Data Export"] = "数据导出",
+ ["Development Tools"] = "开发工具",
+ ["Guild"] = "公会",
+ ["Frame Modification"] = "框架修改",
+ ["Interface Enhancements"] = "界面增强",
+ ["Inventory"] = "背包",
+ ["Library"] = "库",
+ ["Map"] = "地图",
+ ["Mail"] = "邮件",
+ ["Miscellaneous"] = "杂项",
+ ["Quest"] = "任务",
+ ["Raid"] = "团队",
+ ["Tradeskill"] = "商业技能",
+ ["UnitFrame"] = "头像框架",
+ }
+elseif GetLocale() == "esES" then
+ STANDBY = "|cffff5050(espera)|r"
+
+ TITLE = "Título"
+ NOTES = "Notas"
+ VERSION = "Versión"
+ AUTHOR = "Autor"
+ DATE = "Fecha"
+ CATEGORY = "Categoría"
+ EMAIL = "E-mail"
+ WEBSITE = "Web"
+ CREDITS = "Créditos"
+ LICENSE = "License" -- fix
+
+ ABOUT = "Acerca de"
+ PRINT_ADDON_INFO = "Muestra información acerca del accesorio."
+ DONATE = "Donate" -- fix
+ DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix
+ HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix
+ HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix
+
+ CATEGORIES = {
+ ["Action Bars"] = "Barras de Acción",
+ ["Auction"] = "Subasta",
+ ["Audio"] = "Audio",
+ ["Battlegrounds/PvP"] = "Campos de Batalla/JcJ",
+ ["Buffs"] = "Buffs",
+ ["Chat/Communication"] = "Chat/Comunicación",
+ ["Druid"] = "Druida",
+ ["Hunter"] = "Cazador",
+ ["Mage"] = "Mago",
+ ["Paladin"] = "Paladín",
+ ["Priest"] = "Sacerdote",
+ ["Rogue"] = "Pícaro",
+ ["Shaman"] = "Chamán",
+ ["Warlock"] = "Brujo",
+ ["Warrior"] = "Guerrero",
+ ["Healer"] = "Sanador",
+ ["Tank"] = "Tanque",
+ ["Caster"] = "Conjurador",
+ ["Combat"] = "Combate",
+ ["Compilations"] = "Compilaciones",
+ ["Data Export"] = "Exportar Datos",
+ ["Development Tools"] = "Herramientas de Desarrollo",
+ ["Guild"] = "Hermandad",
+ ["Frame Modification"] = "Modificación de Marcos",
+ ["Interface Enhancements"] = "Mejoras de la Interfaz",
+ ["Inventory"] = "Inventario",
+ ["Library"] = "Biblioteca",
+ ["Map"] = "Mapa",
+ ["Mail"] = "Correo",
+ ["Miscellaneous"] = "Misceláneo",
+ ["Quest"] = "Misión",
+ ["Raid"] = "Banda",
+ ["Tradeskill"] = "Habilidad de Comercio",
+ ["UnitFrame"] = "Marco de Unidades",
+ }
+elseif GetLocale() == "ruRU" then
+ STANDBY = "|cffff5050(в режиме ожидания)|r"
+
+ TITLE = "Название"
+ NOTES = "Описание"
+ VERSION = "Версия"
+ AUTHOR = "Автор"
+ DATE = "Дата"
+ CATEGORY = "Категория"
+ EMAIL = "E-mail"
+ WEBSITE = "Сайт"
+ CREDITS = "Титры"
+ LICENSE = "Лицензия"
+
+ ABOUT = "Об аддоне"
+ PRINT_ADDON_INFO = "Показать информацию об аддоне."
+ DONATE = "Пожертвовать"
+ DONATE_DESC = "Отблагодарить автора за разработку аддона."
+ HOWTO_DONATE_WINDOWS = "Для выделения всей ссылки нажмите Ctrl-A, потом для её копирования Ctrl-C, чтобы свернуть игру - Alt-Tab, откройте ваш браузер и вставьте ссылку в адресную строку - Ctrl-V"
+ HOWTO_DONATE_MAC = "Для выделения всей ссылки нажмите Cmd-A, потом для её копирования Ctrl-C, чтобы свернуть игру - Cmd-Tab, откройте ваш браузер и вставьте ссылку в адресную строку Cmd-V"
+
+ CATEGORIES = {
+ ["Action Bars"] = "Панели команд",
+ ["Auction"] = "Аукцион",
+ ["Audio"] = "Аудио",
+ ["Battlegrounds/PvP"] = "Поля сражений/PvP",
+ ["Buffs"] = "Баффы",
+ ["Chat/Communication"] = "Чат/Коммуникация",
+ ["Druid"] = "Друид",
+ ["Hunter"] = "Охотник",
+ ["Mage"] = "Маг",
+ ["Paladin"] = "Паладин",
+ ["Priest"] = "Жрец",
+ ["Rogue"] = "Разбойник",
+ ["Shaman"] = "Шаман",
+ ["Warlock"] = "Чернокнижник",
+ ["Warrior"] = "Воин",
+ ["Healer"] = "Лекарь",
+ ["Tank"] = "Танк",
+ ["Caster"] = "Кастер",
+ ["Combat"] = "Сражения",
+ ["Compilations"] = "Компиляция",
+ ["Data Export"] = "Экспорт данных",
+ ["Development Tools"] = "Инструменты разработчика",
+ ["Guild"] = "Гильдия",
+ ["Frame Modification"] = "Модификация фреймов",
+ ["Interface Enhancements"] = "Улучшение интерфейса",
+ ["Inventory"] = "Инвентарь",
+ ["Library"] = "Библиотеки",
+ ["Map"] = "Карта",
+ ["Mail"] = "Почта",
+ ["Miscellaneous"] = "Разное",
+ ["Quest"] = "Задания",
+ ["Raid"] = "Рейд",
+ ["Tradeskill"] = "Умения",
+ ["UnitFrame"] = "Фреймы персонажей",
+ }
+else -- enUS
+ STANDBY = "|cffff5050(standby)|r"
+
+ TITLE = "Title"
+ NOTES = "Notes"
+ VERSION = "Version"
+ AUTHOR = "Author"
+ DATE = "Date"
+ CATEGORY = "Category"
+ EMAIL = "E-mail"
+ WEBSITE = "Website"
+ CREDITS = "Credits"
+ LICENSE = "License"
+
+ ABOUT = "About"
+ PRINT_ADDON_INFO = "Show information about the addon."
+ DONATE = "Donate"
+ DONATE_DESC = "Give a much-needed donation to the author of this addon."
+ HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar."
+ HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar."
+
+ CATEGORIES = {
+ ["Action Bars"] = "Action Bars",
+ ["Auction"] = "Auction",
+ ["Audio"] = "Audio",
+ ["Battlegrounds/PvP"] = "Battlegrounds/PvP",
+ ["Buffs"] = "Buffs",
+ ["Chat/Communication"] = "Chat/Communication",
+ ["Druid"] = "Druid",
+ ["Hunter"] = "Hunter",
+ ["Mage"] = "Mage",
+ ["Paladin"] = "Paladin",
+ ["Priest"] = "Priest",
+ ["Rogue"] = "Rogue",
+ ["Shaman"] = "Shaman",
+ ["Warlock"] = "Warlock",
+ ["Warrior"] = "Warrior",
+ ["Healer"] = "Healer",
+ ["Tank"] = "Tank",
+ ["Caster"] = "Caster",
+ ["Combat"] = "Combat",
+ ["Compilations"] = "Compilations",
+ ["Data Export"] = "Data Export",
+ ["Development Tools"] = "Development Tools",
+ ["Guild"] = "Guild",
+ ["Frame Modification"] = "Frame Modification",
+ ["Interface Enhancements"] = "Interface Enhancements",
+ ["Inventory"] = "Inventory",
+ ["Library"] = "Library",
+ ["Map"] = "Map",
+ ["Mail"] = "Mail",
+ ["Miscellaneous"] = "Miscellaneous",
+ ["Quest"] = "Quest",
+ ["Raid"] = "Raid",
+ ["Tradeskill"] = "Tradeskill",
+ ["UnitFrame"] = "UnitFrame",
+ }
+end
+
+setmetatable(CATEGORIES, { __index = function(self, key) -- case-insensitive
+ local lowerKey = key:lower()
+ for k,v in pairs(CATEGORIES) do
+ if k:lower() == lowerKey then
+ self[lowerKey] = v
+ return v
+ end
+ end
+end })
+
+-- Create the library object
+
+local AceOO = AceLibrary("AceOO-2.0")
+local AceAddon = AceOO.Class()
+local AceEvent
+local AceConsole
+local AceModuleCore
+
+function AceAddon:GetLocalizedCategory(name)
+ self:argCheck(name, 2, "string")
+ return CATEGORIES[name] or UNKNOWN
+end
+
+function AceAddon:ToString()
+ return "AceAddon"
+end
+
+local function print(text)
+ DEFAULT_CHAT_FRAME:AddMessage(text)
+end
+
+function AceAddon:ADDON_LOADED(name)
+ local unregister = true
+ local initAddon = {}
+ while #self.nextAddon > 0 do
+ local addon = table.remove(self.nextAddon, 1)
+ if addon.possibleNames[name] then
+ table.insert(initAddon, addon)
+ else
+ unregister = nil
+ table.insert(self.skipAddon, addon)
+ end
+ end
+ self.nextAddon, self.skipAddon = self.skipAddon, self.nextAddon
+ if unregister then
+ AceAddon:UnregisterEvent("ADDON_LOADED")
+ end
+ while #initAddon > 0 do
+ local addon = table.remove(initAddon, 1)
+ table.insert(self.addons, addon)
+ if not self.addons[name] then
+ self.addons[name] = addon
+ end
+ addon.possibleNames = nil
+ self:InitializeAddon(addon, name)
+ end
+end
+
+local function RegisterOnEnable(self)
+ if IsLoggedIn() then
+ AceAddon.addonsStarted[self] = true
+ if (type(self.IsActive) ~= "function" or self:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(self) or AceModuleCore:IsModuleActive(self)) then
+ AceAddon:ManualEnable(self)
+ end
+ else
+ if not AceAddon.addonsToOnEnable then
+ AceAddon.addonsToOnEnable = {}
+ end
+ table.insert(AceAddon.addonsToOnEnable, self)
+ end
+end
+
+function AceAddon:InitializeAddon(addon, name)
+ if addon.name == nil then
+ addon.name = name
+ end
+ if GetAddOnMetadata then
+ -- TOC checks
+ if addon.title == nil then
+ addon.title = GetAddOnMetadata(name, "Title")
+ end
+ if type(addon.title) == "string" then
+ local num = addon.title:find(" |cff7fff7f %-Ace2%-|r$")
+ if num then
+ addon.title = addon.title:sub(1, num - 1)
+ end
+ addon.title = addon.title:trim()
+ end
+ if addon.notes == nil then
+ addon.notes = GetAddOnMetadata(name, "Notes")
+ end
+ if type(addon.notes) == "string" then
+ addon.notes = addon.notes:trim()
+ end
+ if addon.version == nil then
+ addon.version = GetAddOnMetadata(name, "Version")
+ end
+ if type(addon.version) == "string" then
+ if addon.version:find("%$Revision: (%d+) %$") then
+ addon.version = addon.version:gsub("%$Revision: (%d+) %$", "%1")
+ elseif addon.version:find("%$Rev: (%d+) %$") then
+ addon.version = addon.version:gsub("%$Rev: (%d+) %$", "%1")
+ elseif addon.version:find("%$LastChangedRevision: (%d+) %$") then
+ addon.version = addon.version:gsub("%$LastChangedRevision: (%d+) %$", "%1")
+ end
+ addon.version = addon.version:trim()
+ end
+ if addon.author == nil then
+ addon.author = GetAddOnMetadata(name, "Author")
+ end
+ if type(addon.author) == "string" then
+ addon.author = addon.author:trim()
+ end
+ if addon.credits == nil then
+ addon.credits = GetAddOnMetadata(name, "X-Credits")
+ end
+ if type(addon.credits) == "string" then
+ addon.credits = addon.credits:trim()
+ end
+ if addon.donate == nil then
+ addon.donate = GetAddOnMetadata(name, "X-Donate")
+ end
+ if type(addon.donate) == "string" then
+ addon.donate = addon.donate:trim()
+ end
+ if addon.date == nil then
+ addon.date = GetAddOnMetadata(name, "X-Date") or GetAddOnMetadata(name, "X-ReleaseDate")
+ end
+ if type(addon.date) == "string" then
+ if addon.date:find("%$Date: (.-) %$") then
+ addon.date = addon.date:gsub("%$Date: (.-) %$", "%1")
+ elseif addon.date:find("%$LastChangedDate: (.-) %$") then
+ addon.date = addon.date:gsub("%$LastChangedDate: (.-) %$", "%1")
+ end
+ addon.date = addon.date:trim()
+ end
+
+ if addon.category == nil then
+ addon.category = GetAddOnMetadata(name, "X-Category")
+ end
+ if type(addon.category) == "string" then
+ addon.category = addon.category:trim()
+ end
+ if addon.email == nil then
+ addon.email = GetAddOnMetadata(name, "X-eMail") or GetAddOnMetadata(name, "X-Email")
+ end
+ if type(addon.email) == "string" then
+ addon.email = addon.email:trim()
+ end
+ if addon.license == nil then
+ addon.license = GetAddOnMetadata(name, "X-License")
+ end
+ if type(addon.license) == "string" then
+ addon.license = addon.license:trim()
+ end
+ if addon.website == nil then
+ addon.website = GetAddOnMetadata(name, "X-Website")
+ end
+ if type(addon.website) == "string" then
+ addon.website = addon.website:trim()
+ end
+ end
+ local current = addon.class
+ while true do
+ if current == AceOO.Class or not current then
+ break
+ end
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedInitialize) == "function" then
+ mixin:OnEmbedInitialize(addon, name)
+ end
+ end
+ end
+ current = current.super
+ end
+ local n = AceAddon.addonsToOnEnable and #AceAddon.addonsToOnEnable or 0
+
+ if type(addon.OnInitialize) == "function" then
+ safecall(addon.OnInitialize, addon, name)
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("Ace2_AddonInitialized", addon)
+ end
+ RegisterOnEnable(addon)
+ local n2 = AceAddon.addonsToOnEnable and #AceAddon.addonsToOnEnable or 0
+ if n2 - n > 1 then
+ local mine = table.remove(AceAddon.addonsToOnEnable)
+ table.insert(AceAddon.addonsToOnEnable, n+1, mine)
+ end
+end
+
+local aboutFrame
+local function createAboutFrame()
+ aboutFrame = CreateFrame("Frame", "AceAddon20AboutFrame", UIParent, "DialogBoxFrame")
+ aboutFrame:SetWidth(500)
+ aboutFrame:SetHeight(400)
+ aboutFrame:SetPoint("CENTER")
+ aboutFrame:SetBackdrop({
+ bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]],
+ edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 5, right = 5, top = 5, bottom = 5 }
+ })
+ aboutFrame:SetBackdropColor(0,0,0,1)
+
+ local donateButton = CreateFrame("Button", "AceAddon20AboutFrameDonateButton", aboutFrame, "UIPanelButtonTemplate")
+ aboutFrame.donateButton = donateButton
+ donateButton:SetPoint("BOTTOMRIGHT", -20, 20)
+ _G.AceAddon20AboutFrameDonateButtonText:SetText(DONATE)
+ donateButton:SetWidth(_G.AceAddon20AboutFrameDonateButtonText:GetWidth() + 20)
+ donateButton:SetScript("OnClick", function()
+ aboutFrame.currentAddon:OpenDonationFrame()
+ end)
+
+ local text = aboutFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
+ aboutFrame.title = text
+ text:SetPoint("TOP", 0, -18)
+
+ aboutFrame:Hide()
+
+ aboutFrame.lefts = {}
+ aboutFrame.rights = {}
+ aboutFrame.textLefts = {}
+ aboutFrame.textRights = {}
+ function aboutFrame:Clear()
+ self.title:SetText("")
+ for i = 1, #self.lefts do
+ self.lefts[i] = nil
+ self.rights[i] = nil
+ end
+ end
+
+ function aboutFrame:AddLine(left, right)
+ aboutFrame.lefts[#aboutFrame.lefts+1] = left
+ aboutFrame.rights[#aboutFrame.rights+1] = right
+ end
+
+ local aboutFrame_Show = aboutFrame.Show
+ function aboutFrame:Show(...)
+ local maxLeftWidth = 0
+ local maxRightWidth = 0
+ local textHeight = 0
+ for i = 1, #self.lefts do
+ if not self.textLefts[i] then
+ local left = aboutFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
+ self.textLefts[i] = left
+ local right = aboutFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
+ self.textRights[i] = right
+ if i == 1 then
+ left:SetPoint("TOPRIGHT", aboutFrame, "TOPLEFT", 75, -60)
+ else
+ left:SetPoint("TOPRIGHT", self.textLefts[i - 1], "BOTTOMRIGHT", 0, -5)
+ end
+ right:SetPoint("LEFT", left, "RIGHT", 5, 0)
+ end
+ self.textLefts[i]:SetText(self.lefts[i] .. ":")
+ self.textRights[i]:SetText(self.rights[i])
+ local leftWidth = self.textLefts[i]:GetWidth()
+ local rightWidth = self.textRights[i]:GetWidth()
+ textHeight = self.textLefts[i]:GetHeight()
+ if maxLeftWidth < leftWidth then
+ maxLeftWidth = leftWidth
+ end
+ if maxRightWidth < rightWidth then
+ maxRightWidth = rightWidth
+ end
+ end
+ for i = #self.lefts+1, #self.textLefts do
+ self.textLefts[i]:SetText('')
+ self.textRights[i]:SetText('')
+ end
+ aboutFrame:SetWidth(75 + maxRightWidth + 20)
+ aboutFrame:SetHeight(#self.lefts * (textHeight + 5) + 120)
+
+ aboutFrame_Show(self, ...)
+ end
+ aboutFrame:Hide()
+
+ createAboutFrame = nil
+end
+local donateFrame
+
+local function unobfuscateEmail(email)
+ return email:gsub(" AT ", "@"):gsub(" DOT ", ".")
+end
+
+local function isGoodVariable(var)
+ return type(var) == "string" or type(var) == "number"
+end
+function AceAddon.prototype:PrintAddonInfo()
+ if createAboutFrame then
+ createAboutFrame()
+ end
+ aboutFrame:Clear()
+ local x
+ if isGoodVariable(self.title) then
+ x = tostring(self.title)
+ elseif isGoodVariable(self.name) then
+ x = tostring(self.name)
+ else
+ x = "<" .. tostring(self.class) .. " instance>"
+ end
+ if type(self.IsActive) == "function" then
+ if not self:IsActive() then
+ x = x .. " " .. STANDBY
+ end
+ end
+ aboutFrame.title:SetText(x)
+
+ if isGoodVariable(self.version) then
+ aboutFrame:AddLine(VERSION, tostring(self.version))
+ end
+ if isGoodVariable(self.notes) then
+ aboutFrame:AddLine(NOTES, tostring(self.notes))
+ end
+ if isGoodVariable(self.author) then
+ aboutFrame:AddLine(AUTHOR, tostring(self.author))
+ end
+ if isGoodVariable(self.credits) then
+ aboutFrame:AddLine(CREDITS, tostring(self.credits))
+ end
+ if isGoodVariable(self.date) then
+ aboutFrame:AddLine(DATE, tostring(self.date))
+ end
+ if isGoodVariable(self.category) then
+ local category = CATEGORIES[self.category]
+ aboutFrame:AddLine(CATEGORY, category or tostring(self.category))
+ end
+ if isGoodVariable(self.email) then
+ aboutFrame:AddLine(EMAIL, unobfuscateEmail(tostring(self.email)))
+ end
+ if isGoodVariable(self.website) then
+ aboutFrame:AddLine(WEBSITE, tostring(self.website))
+ end
+ if isGoodVariable(self.license) then
+ aboutFrame:AddLine(LICENSE, tostring(self.license))
+ end
+
+ if donateFrame and donateFrame:IsShown() then
+ donateFrame:Hide()
+ end
+
+ aboutFrame.currentAddon = self
+
+ aboutFrame:Show()
+
+ if self.donate then
+ aboutFrame.donateButton:Show()
+ else
+ aboutFrame.donateButton:Hide()
+ end
+end
+
+local function createDonateFrame()
+ donateFrame = CreateFrame("Frame", "AceAddon20Frame", UIParent, "DialogBoxFrame")
+
+ donateFrame:SetWidth(500)
+ donateFrame:SetHeight(200)
+ donateFrame:SetPoint("CENTER")
+ donateFrame:SetBackdrop({
+ bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]],
+ edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
+ tile = true, tileSize = 16, edgeSize = 16,
+ insets = { left = 5, right = 5, top = 5, bottom = 5 }
+ })
+ donateFrame:SetBackdropColor(0,0,0,1)
+
+ local text = donateFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
+ text:SetPoint("TOP", 0, -5)
+ text:SetText(DONATE)
+
+ local howto = donateFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
+ howto:SetPoint("TOP", text, "BOTTOM", 0, -5)
+ howto:SetPoint("LEFT", 16, 0)
+ howto:SetPoint("RIGHT", -16, 0)
+ if not IsMacClient() then
+ -- Windows or Linux
+ howto:SetText(HOWTO_DONATE_WINDOWS)
+ else
+ howto:SetText(HOWTO_DONATE_MAC)
+ end
+
+ local scrollFrame = CreateFrame("ScrollFrame", "AceAddon20FrameScrollFrame", donateFrame, "UIPanelScrollFrameTemplate")
+ scrollFrame:SetToplevel(true)
+ scrollFrame:SetPoint("TOP", -10, -76)
+ scrollFrame:SetWidth(455)
+ scrollFrame:SetHeight(70)
+ howto:SetPoint("BOTTOM", scrollFrame, "TOP")
+
+ local editBox = CreateFrame("EditBox", nil, scrollFrame)
+ donateFrame.editBox = editBox
+ scrollFrame:SetScrollChild(editBox)
+ editBox:SetFontObject(ChatFontNormal)
+ editBox:SetMultiLine(true)
+ editBox:SetMaxLetters(99999)
+ editBox:SetWidth(450)
+ editBox:SetHeight(54)
+ editBox:SetPoint("BOTTOM", 5, 0)
+ editBox:SetJustifyH("LEFT")
+ editBox:SetJustifyV("TOP")
+ editBox:SetAutoFocus(false)
+ editBox:SetScript("OnTextChanged", function(this)
+ if this:GetText() ~= this.text then
+ this:SetText(this.text)
+ end
+ end)
+ editBox:SetScript("OnEscapePressed", function(this)
+ this:ClearFocus()
+ end)
+ createDonateFrame = nil
+end
+
+local function fix(char)
+ return ("%%%02x"):format(char:byte())
+end
+
+local function urlencode(text)
+ return text:gsub("[^0-9A-Za-z]", fix)
+end
+
+function AceAddon.prototype:OpenDonationFrame()
+ if createDonateFrame then
+ createDonateFrame()
+ end
+ local donate = self.donate
+ if type(donate) ~= "string" then
+ donate = "Wowace"
+ end
+ local style, data = (":"):split(donate, 2)
+ style = style:lower()
+ if style ~= "website" and style ~= "paypal" then
+ style = "wowace"
+ end
+ if style == "wowace" then
+ donateFrame.editBox.text = "http://www.wowace.com/wiki/Donations"
+ elseif style == "website" then
+ donateFrame.editBox.text = data
+ else -- PayPal
+ local text = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" .. urlencode(unobfuscateEmail(data))
+ local name
+ if type(self.title) == "string" then
+ name = self.title
+ elseif type(self.name) == "string" then
+ name = self.name
+ end
+ if name then
+ name = name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "")
+ text = text .. "&item_name=" .. urlencode(name)
+ end
+ donateFrame.editBox.text = text
+ end
+ donateFrame.editBox:SetText(donateFrame.editBox.text)
+
+ if aboutFrame and aboutFrame:IsShown() then
+ aboutFrame:Hide()
+ end
+
+ donateFrame:Show()
+
+ donateFrame.editBox:SetFocus()
+end
+
+local options
+function AceAddon:GetAceOptionsDataTable(target)
+ return {
+ about = {
+ name = ABOUT,
+ desc = PRINT_ADDON_INFO,
+ type = "execute",
+ func = "PrintAddonInfo",
+ order = -1,
+ },
+ donate = {
+ name = DONATE,
+ desc = DONATE_DESC,
+ type = "execute",
+ func = "OpenDonationFrame",
+ order = -1,
+ hidden = function()
+ return not target.donate
+ end
+ }
+ }
+end
+
+function AceAddon:PLAYER_LOGIN()
+ if self.addonsToOnEnable then
+ while #self.addonsToOnEnable > 0 do
+ local addon = table.remove(self.addonsToOnEnable, 1)
+ self.addonsStarted[addon] = true
+ if (type(addon.IsActive) ~= "function" or addon:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(addon) or AceModuleCore:IsModuleActive(addon)) then
+ AceAddon:ManualEnable(addon)
+ end
+ end
+ self.addonsToOnEnable = nil
+ end
+end
+
+function AceAddon.prototype:Inject(t)
+ AceAddon:argCheck(t, 2, "table")
+ for k,v in pairs(t) do
+ self[k] = v
+ end
+end
+
+function AceAddon.prototype:init()
+ if not AceEvent then
+ error(MAJOR_VERSION .. " requires AceEvent-2.0", 4)
+ end
+ AceAddon.super.prototype.init(self)
+
+ self.super = self.class.prototype
+
+ AceAddon:RegisterEvent("ADDON_LOADED", "ADDON_LOADED")
+ local names = {}
+ for i = 1, GetNumAddOns() do
+ if IsAddOnLoaded(i) then names[GetAddOnInfo(i)] = true end
+ end
+ self.possibleNames = names
+ table.insert(AceAddon.nextAddon, self)
+end
+
+function AceAddon.prototype:ToString()
+ local x
+ if type(self.title) == "string" then
+ x = self.title
+ elseif type(self.name) == "string" then
+ x = self.name
+ else
+ x = "<" .. tostring(self.class) .. " instance>"
+ end
+ if (type(self.IsActive) == "function" and not self:IsActive()) or (AceModuleCore and AceModuleCore:IsModule(addon) and AceModuleCore:IsModuleActive(addon)) then
+ x = x .. " " .. STANDBY
+ end
+ return x
+end
+
+AceAddon.new = function(self, ...)
+ local class = AceAddon:pcall(AceOO.Classpool, self, ...)
+ return class:new()
+end
+
+function AceAddon:ManualEnable(addon)
+ AceAddon:argCheck(addon, 2, "table")
+ local first = nil
+ if AceOO.inherits(addon, "AceAddon-2.0") then
+ if AceAddon.addonsEnabled and not AceAddon.addonsEnabled[addon] then
+ first = true
+ AceAddon.addonsEnabled[addon] = true
+ end
+ end
+ local current = addon.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedEnable) == "function" then
+ safecall(mixin.OnEmbedEnable, mixin, addon, first)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(addon.OnEnable) == "function" then
+ safecall(addon.OnEnable, addon, first)
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("Ace2_AddonEnabled", addon, first)
+ end
+end
+
+function AceAddon:ManualDisable(addon)
+ AceAddon:argCheck(addon, 2, "table")
+ local current = addon.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedDisable) == "function" then
+ safecall(mixin.OnEmbedDisable, mixin, addon)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(module.OnDisable) == "function" then
+ safecall(module.OnDisable, addon)
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("Ace2_AddonDisabled", addon)
+ end
+end
+
+local function external(self, major, instance)
+ if major == "AceEvent-2.0" then
+ AceEvent = instance
+
+ AceEvent:embed(self)
+
+ self:RegisterEvent("PLAYER_LOGIN", "PLAYER_LOGIN", true)
+ elseif major == "AceConsole-2.0" then
+ AceConsole = instance
+
+ local slashCommands = { "/ace2" }
+ local _,_,_,enabled,loadable = GetAddOnInfo("Ace")
+ if not enabled or not loadable then
+ table.insert(slashCommands, "/ace")
+ end
+ local function listAddon(addon, depth)
+ if not depth then
+ depth = 0
+ end
+
+ local s = (" "):rep(depth) .. " - " .. tostring(addon)
+ if rawget(addon, 'version') then
+ s = s .. " - |cffffff7f" .. tostring(addon.version) .. "|r"
+ end
+ if rawget(addon, 'slashCommand') then
+ s = s .. " |cffffff7f(" .. tostring(addon.slashCommand) .. ")|r"
+ end
+ print(s)
+ if type(rawget(addon, 'modules')) == "table" then
+ local i = 0
+ for k,v in pairs(addon.modules) do
+ i = i + 1
+ if i == 6 then
+ print((" "):rep(depth + 1) .. " - more...")
+ break
+ else
+ listAddon(v, depth + 1)
+ end
+ end
+ end
+ end
+
+ local function listNormalAddon(i)
+ local name,_,_,loadable = GetAddOnInfo(i)
+ -- local enableState = GetAddOnEnableState(nil, i)
+ -- local enabled = enableState == 1 or enableState == 2
+ local enabled = loadable
+ if self.addons[name] then
+ listAddon(self.addons[name])
+ else
+ local s = " - " .. tostring(GetAddOnMetadata(i, "Title") or name)
+ local version = GetAddOnMetadata(i, "Version")
+ if version then
+ if version:find("%$Revision: (%d+) %$") then
+ version = version:gsub("%$Revision: (%d+) %$", "%1")
+ elseif version:find("%$Rev: (%d+) %$") then
+ version = version:gsub("%$Rev: (%d+) %$", "%1")
+ elseif version:find("%$LastChangedRevision: (%d+) %$") then
+ version = version:gsub("%$LastChangedRevision: (%d+) %$", "%1")
+ end
+ s = s .. " - |cffffff7f" .. version .. "|r"
+ end
+ if not enabled then
+ s = s .. " |cffff0000(disabled)|r"
+ end
+ if IsAddOnLoadOnDemand(i) then
+ s = s .. " |cff00ff00[LoD]|r"
+ end
+ print(s)
+ end
+ end
+
+ local function mySort(alpha, bravo)
+ return tostring(alpha) < tostring(bravo)
+ end
+
+ AceConsole.RegisterChatCommand(self, slashCommands, {
+ desc = "AddOn development framework",
+ name = "Ace2",
+ type = "group",
+ args = {
+ about = {
+ desc = "Get information about Ace2",
+ name = "About",
+ type = "execute",
+ func = function()
+ print("|cffffff7fAce2|r - |cffffff7f2.0." .. MINOR_VERSION:gsub("%$Revision: (%d+) %$", "%1") .. "|r - AddOn development framework")
+ print(" - |cffffff7f" .. AUTHOR .. ":|r Ace Development Team")
+ print(" - |cffffff7f" .. WEBSITE .. ":|r http://www.wowace.com/")
+ end
+ },
+ list = {
+ desc = "List addons",
+ name = "List",
+ type = "group",
+ args = {
+ ace2 = {
+ desc = "List addons using Ace2",
+ name = "Ace2",
+ type = "execute",
+ func = function()
+ print("|cffffff7fAddon list:|r")
+ table.sort(self.addons, mySort)
+ for _,v in ipairs(self.addons) do
+ listAddon(v)
+ end
+ end
+ },
+ all = {
+ desc = "List all addons",
+ name = "All",
+ type = "execute",
+ func = function()
+ print("|cffffff7fAddon list:|r")
+ local count = GetNumAddOns()
+ for i = 1, count do
+ listNormalAddon(i)
+ end
+ end
+ },
+ enabled = {
+ desc = "List all enabled addons",
+ name = "Enabled",
+ type = "execute",
+ func = function()
+ print("|cffffff7fAddon list:|r")
+ local count = GetNumAddOns()
+ for i = 1, count do
+ local _,_,_,loadable = GetAddOnInfo(i)
+ if loadable then
+ listNormalAddon(i)
+ end
+ end
+ end
+ },
+ disabled = {
+ desc = "List all disabled addons",
+ name = "Disabled",
+ type = "execute",
+ func = function()
+ print("|cffffff7fAddon list:|r")
+ local count = GetNumAddOns()
+ for i = 1, count do
+ local _,_,_,loadable = GetAddOnInfo(i)
+ if not loadable then
+ listNormalAddon(i)
+ end
+ end
+ end
+ },
+ lod = {
+ desc = "List all LoadOnDemand addons",
+ name = "LoadOnDemand",
+ type = "execute",
+ func = function()
+ print("|cffffff7fAddon list:|r")
+ local count = GetNumAddOns()
+ for i = 1, count do
+ if IsAddOnLoadOnDemand(i) then
+ listNormalAddon(i)
+ end
+ end
+ end
+ },
+ ace1 = {
+ desc = "List all addons using Ace1",
+ name = "Ace 1.x",
+ type = "execute",
+ func = function()
+ print("|cffffff7fAddon list:|r")
+ local count = GetNumAddOns()
+ for i = 1, count do
+ local dep1, dep2, dep3, dep4 = GetAddOnDependencies(i)
+ if dep1 == "Ace" or dep2 == "Ace" or dep3 == "Ace" or dep4 == "Ace" then
+ listNormalAddon(i)
+ end
+ end
+ end
+ },
+ libs = {
+ desc = "List all libraries using AceLibrary",
+ name = "Libraries",
+ type = "execute",
+ func = function()
+ if type(AceLibrary) == "table" and type(AceLibrary.libs) == "table" then
+ print("|cffffff7fLibrary list:|r")
+ for name, data in pairs(AceLibrary.libs) do
+ local s
+ if data.minor then
+ s = " - " .. tostring(name) .. "." .. tostring(data.minor)
+ else
+ s = " - " .. tostring(name)
+ end
+ if rawget(AceLibrary(name), 'slashCommand') then
+ s = s .. " |cffffff7f(" .. tostring(AceLibrary(name).slashCommand) .. "|cffffff7f)"
+ end
+ print(s)
+ end
+ end
+ end
+ },
+ search = {
+ desc = "Search by name",
+ name = "Search",
+ type = "text",
+ usage = "",
+ input = true,
+ get = false,
+ set = function(...)
+ local arg = { ... }
+ for i,v in ipairs(arg) do
+ arg[i] = v:gsub('%*', '.*'):gsub('%%', '%%%%'):lower()
+ end
+ local count = GetNumAddOns()
+ for i = 1, count do
+ local name = GetAddOnInfo(i)
+ local good = true
+ for _,v in ipairs(arg) do
+ if not name:lower():find(v) then
+ good = false
+ break
+ end
+ end
+ if good then
+ listNormalAddon(i)
+ end
+ end
+ end
+ }
+ },
+ },
+ enable = {
+ desc = "Enable addon(s).",
+ name = "Enable",
+ type = "text",
+ usage = " ...",
+ get = false,
+ input = true,
+ set = function(...)
+ for i = 1, select("#", ...) do
+ local addon = select(i, ...)
+ local name, title, _, loadable, reason = GetAddOnInfo(addon)
+ local enableState = GetAddOnEnableState(nil, addon)
+
+ if reason == "MISSING" then
+ print(("|cffffff7fAce2:|r AddOn %q does not exist."):format(addon))
+ elseif loadable then
+ if enableState == 0 then
+ EnableAddOn(addon)
+ print(("|cffffff7fAce2:|r %s is now enabled."):format(addon or name))
+ else
+ print(("|cffffff7fAce2:|r %s is already enabled."):format(addon or name))
+ end
+ end
+ end
+ end,
+ },
+ disable = {
+ desc = "Disable addon(s).",
+ name = "Disable",
+ type = "text",
+ usage = " ...",
+ get = false,
+ input = true,
+ set = function(...)
+ for i = 1, select("#", ...) do
+ local addon = select(i, ...)
+
+ local name, title, _, loadable, reason = GetAddOnInfo(addon)
+ local enableState = GetAddOnEnableState(nil, addon)
+
+ if reason == "MISSING" then
+ print(("|cffffff7fAce2:|r AddOn %q does not exist."):format(addon))
+ elseif loadable then
+ if enableState == 1 or enableState == 2 then
+ DisableAddOn(addon)
+ print(("|cffffff7fAce2:|r %s is now disabled."):format(addon or name))
+ else
+ print(("|cffffff7fAce2:|r %s is already disabled."):format(addon or name))
+ end
+ end
+ end
+ end,
+ },
+ load = {
+ desc = "Load addon(s).",
+ name = "Load",
+ type = "text",
+ usage = " ...",
+ get = false,
+ input = true,
+ set = function(...)
+ for i = 1, select("#", ...) do
+ local addon = select(i, ...)
+ local name, title, _, loadable, reason = GetAddOnInfo(addon)
+ if reason == "MISSING" then
+ print(("|cffffff7fAce2:|r AddOn %q does not exist."):format(addon))
+ elseif not loadable then
+ print(("|cffffff7fAce2:|r AddOn %q is not loadable. Reason: %s."):format(addon, reason))
+ else
+ LoadAddOn(addon)
+ print(("|cffffff7fAce2:|r %s is now loaded."):format(addon or name))
+ end
+ end
+ end
+ },
+ info = {
+ desc = "Display information",
+ name = "Information",
+ type = "execute",
+ func = function()
+ local mem, threshold = gcinfo()
+ print((" - |cffffff7fMemory usage [|r%.3f MiB|cffffff7f]|r"):format(mem / 1024))
+ if threshold then
+ print((" - |cffffff7fThreshold [|r%.3f MiB|cffffff7f]|r"):format(threshold / 1024))
+ end
+ print((" - |cffffff7fFramerate [|r%.0f fps|cffffff7f]|r"):format(GetFramerate()))
+ local bandwidthIn, bandwidthOut, latency = GetNetStats()
+ bandwidthIn, bandwidthOut = floor(bandwidthIn * 1024), floor(bandwidthOut * 1024)
+ print((" - |cffffff7fLatency [|r%.0f ms|cffffff7f]|r"):format(latency))
+ print((" - |cffffff7fBandwidth in [|r%.0f B/s|cffffff7f]|r"):format(bandwidthIn))
+ print((" - |cffffff7fBandwidth out [|r%.0f B/s|cffffff7f]|r"):format(bandwidthOut))
+ print((" - |cffffff7fTotal addons [|r%d|cffffff7f]|r"):format(GetNumAddOns()))
+ print((" - |cffffff7fAce2 addons [|r%d|cffffff7f]|r"):format(#self.addons))
+ local ace = 0
+ local enabled = 0
+ local disabled = 0
+ local lod = 0
+ for i = 1, GetNumAddOns() do
+ local dep1, dep2, dep3, dep4 = GetAddOnDependencies(i)
+ if dep1 == "Ace" or dep2 == "Ace" or dep3 == "Ace" or dep4 == "Ace" then
+ ace = ace + 1
+ end
+ if IsAddOnLoadOnDemand(i) then
+ lod = lod + 1
+ end
+ local loadable = select(4, GetAddOnInfo(i))
+ local enableState = GetAddOnEnableState(nil, i)
+
+ if not loadable or enableState == 0 then
+ disabled = disabled + 1
+ else
+ enabled = enabled + 1
+ end
+ end
+ print((" - |cffffff7fAce 1.x addons [|r%d|cffffff7f]|r"):format(ace))
+ print((" - |cffffff7fLoadOnDemand addons [|r%d|cffffff7f]|r"):format(lod))
+ print((" - |cffffff7fenabled addons [|r%d|cffffff7f]|r"):format(enabled))
+ print((" - |cffffff7fdisabled addons [|r%d|cffffff7f]|r"):format(disabled))
+ local libs = 0
+ if type(AceLibrary) == "table" and type(AceLibrary.libs) == "table" then
+ for _ in pairs(AceLibrary.libs) do
+ libs = libs + 1
+ end
+ end
+ print((" - |cffffff7fAceLibrary instances [|r%d|cffffff7f]|r"):format(libs))
+ end
+ }
+ }
+ })
+ elseif major == "AceModuleCore-2.0" then
+ AceModuleCore = instance
+ end
+end
+
+local function activate(self, oldLib, oldDeactivate)
+ AceAddon = self
+
+ self.addonsToOnEnable = oldLib and oldLib.addonsToOnEnable
+ self.addons = oldLib and oldLib.addons or {}
+ self.nextAddon = oldLib and oldLib.nextAddon or {}
+ self.skipAddon = oldLib and oldLib.skipAddon or {}
+ self.addonsStarted = oldLib and oldLib.addonsStarted or {}
+ self.addonsEnabled = oldLib and oldLib.addonsEnabled or {}
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+AceLibrary:Register(AceAddon, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)
diff --git a/FuBar_DurabilityFu/libs/AceAddon-2.0/AceAddon-2.0.toc b/FuBar_DurabilityFu/libs/AceAddon-2.0/AceAddon-2.0.toc
new file mode 100644
index 0000000..77caa32
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceAddon-2.0/AceAddon-2.0.toc
@@ -0,0 +1,16 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r1098
+## X-Curse-Project-Name: Ace2
+## X-Curse-Project-ID: ace2
+## X-Curse-Repository-ID: wow/ace2/mainline
+
+## Title: Lib: AceAddon-2.0
+## Notes: AddOn development framework
+## Author: Ace Development Team
+## LoadOnDemand: 1
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-License: LGPL v2.1 + MIT for AceOO-2.0
+## Dependencies: AceLibrary, AceOO-2.0
+
+AceAddon-2.0.lua
diff --git a/FuBar_DurabilityFu/libs/AceConsole-2.0/AceConsole-2.0.lua b/FuBar_DurabilityFu/libs/AceConsole-2.0/AceConsole-2.0.lua
new file mode 100644
index 0000000..c72036a
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceConsole-2.0/AceConsole-2.0.lua
@@ -0,0 +1,2688 @@
+--[[
+Name: AceConsole-2.0
+Revision: $Rev: 1094 $
+Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team)
+Inspired By: Ace 1.x by Turan (turan@gryphon.com)
+Website: http://www.wowace.com/
+Documentation: http://www.wowace.com/index.php/AceConsole-2.0
+SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceConsole-2.0
+Description: Mixin to allow for input/output capabilities. This uses the
+ AceOptions data table format to determine input.
+ http://www.wowace.com/index.php/AceOptions_data_table
+Dependencies: AceLibrary, AceOO-2.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "AceConsole-2.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 1094 $"):match("(%d+)"))
+
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+if not AceLibrary:HasInstance("AceOO-2.0") then error(MAJOR_VERSION .. " requires AceOO-2.0.") end
+
+local WotLK = select(4,GetBuildInfo()) >= 30000
+
+-- #AUTODOC_NAMESPACE AceConsole
+
+local MAP_ONOFF, USAGE, IS_CURRENTLY_SET_TO, IS_NOW_SET_TO, IS_NOT_A_VALID_OPTION_FOR, IS_NOT_A_VALID_VALUE_FOR, NO_OPTIONS_AVAILABLE, OPTION_HANDLER_NOT_FOUND, OPTION_HANDLER_NOT_VALID, OPTION_IS_DISABLED, KEYBINDING_USAGE, DEFAULT_CONFIRM_MESSAGE
+if GetLocale() == "deDE" then
+ MAP_ONOFF = { [false] = "|cffff0000Aus|r", [true] = "|cff00ff00An|r" }
+ USAGE = "Benutzung"
+ IS_CURRENTLY_SET_TO = "|cffffff7f%s|r steht momentan auf |cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOW_SET_TO = "|cffffff7f%s|r ist nun auf |cffffff7f[|r%s|cffffff7f]|r gesetzt"
+ IS_NOT_A_VALID_OPTION_FOR = "[|cffffff7f%s|r] ist keine g\195\188ltige Option f\195\188r |cffffff7f%s|r"
+ IS_NOT_A_VALID_VALUE_FOR = "[|cffffff7f%s|r] ist kein g\195\188ltiger Wert f\195\188r |cffffff7f%s|r"
+ NO_OPTIONS_AVAILABLE = "Keine Optionen verfügbar"
+ OPTION_HANDLER_NOT_FOUND = "Optionen handler |cffffff7f%q|r nicht gefunden."
+ OPTION_HANDLER_NOT_VALID = "Optionen handler nicht g\195\188ltig."
+ OPTION_IS_DISABLED = "Option |cffffff7f%s|r deaktiviert."
+ KEYBINDING_USAGE = "" -- fix
+ DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?" -- fix
+elseif GetLocale() == "frFR" then
+ MAP_ONOFF = { [false] = "|cffff0000Inactif|r", [true] = "|cff00ff00Actif|r" }
+ USAGE = "Utilisation"
+ IS_CURRENTLY_SET_TO = "|cffffff7f%s|r est actuellement positionn\195\169 sur |cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOW_SET_TO = "|cffffff7f%s|r est maintenant positionn\195\169 sur |cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOT_A_VALID_OPTION_FOR = "[|cffffff7f%s|r] n'est pas une option valide pour |cffffff7f%s|r"
+ IS_NOT_A_VALID_VALUE_FOR = "[|cffffff7f%s|r] n'est pas une valeur valide pour |cffffff7f%s|r"
+ NO_OPTIONS_AVAILABLE = "Pas d'options disponibles"
+ OPTION_HANDLER_NOT_FOUND = "Le gestionnaire d'option |cffffff7f%q|r n'a pas \195\169t\195\169 trouv\195\169."
+ OPTION_HANDLER_NOT_VALID = "Le gestionnaire d'option n'est pas valide."
+ OPTION_IS_DISABLED = "L'option |cffffff7f%s|r est d\195\169sactiv\195\169e."
+ KEYBINDING_USAGE = "" -- fix
+ DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?" -- fix
+elseif GetLocale() == "koKR" then
+ MAP_ONOFF = { [false] = "|cffff0000끔|r", [true] = "|cff00ff00켬|r" }
+ USAGE = "사용법"
+ IS_CURRENTLY_SET_TO = "|cffffff7f%s|r|1은;는; 현재 상태는 |cffffff7f[|r%s|cffffff7f]|r|1으로;로; 설정되어 있습니다."
+ IS_NOW_SET_TO = "|cffffff7f%s|r|1을;를; |cffffff7f[|r%s|cffffff7f]|r 상태로 변경합니다."
+ IS_NOT_A_VALID_OPTION_FOR = "[|cffffff7f%s|r]|1은;는; |cffffff7f%s|r에서 사용 불가능한 설정입니다."
+ IS_NOT_A_VALID_VALUE_FOR = "[|cffffff7f%s|r]|1은;는; |cffffff7f%s|r에서 사용 불가능한 설정 값입니다."
+ NO_OPTIONS_AVAILABLE = "가능한 설정이 없습니다."
+ OPTION_HANDLER_NOT_FOUND = "설정 조정 값인 |cffffff7f%q|r|1을;를; 찾지 못했습니다."
+ OPTION_HANDLER_NOT_VALID = "설정 조정 값이 올바르지 않습니다."
+ OPTION_IS_DISABLED = "|cffffff7f%s|r 설정은 사용할 수 없습니다."
+ KEYBINDING_USAGE = ""
+ DEFAULT_CONFIRM_MESSAGE = "정말 당신은 `%s'|1을;를; 하시겠습니까?"
+elseif GetLocale() == "zhCN" then
+ MAP_ONOFF = { [false] = "|cffff0000\229\133\179\233\151\173|r", [true] = "|cff00ff00\229\188\128\229\144\175|r" }
+ USAGE = "\231\148\168\230\179\149"
+ IS_CURRENTLY_SET_TO = "|cffffff7f%s|r \229\189\147\229\137\141\232\162\171\232\174\190\231\189\174 |cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOW_SET_TO = "|cffffff7f%s|r \231\142\176\229\156\168\232\162\171\232\174\190\231\189\174\228\184\186 |cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOT_A_VALID_OPTION_FOR = "[|cffffff7f%s|r] \228\184\141\230\152\175\228\184\128\228\184\170\230\156\137\230\149\136\231\154\132\233\128\137\233\161\185 \228\184\186 |cffffff7f%s|r"
+ IS_NOT_A_VALID_VALUE_FOR = "[|cffffff7f%s|r] \228\184\141\230\152\175\228\184\128\228\184\170\230\156\137\230\149\136\229\128\188 \228\184\186 |cffffff7f%s|r"
+ NO_OPTIONS_AVAILABLE = "\230\178\161\230\156\137\233\128\137\233\161\185\229\143\175\231\148\168"
+ OPTION_HANDLER_NOT_FOUND = "\233\128\137\233\161\185\229\164\132\231\144\134\231\168\139\229\186\143 |cffffff7f%q|r \230\178\161\230\159\165\230\137\190."
+ OPTION_HANDLER_NOT_VALID = "\233\128\137\233\161\185\229\164\132\231\144\134\231\168\139\229\186\143 \230\151\160\230\149\136."
+ OPTION_IS_DISABLED = "\233\128\137\233\161\185 |cffffff7f%s|r \228\184\141\229\174\140\230\149\180."
+ KEYBINDING_USAGE = "" -- fix
+ DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?" -- fix
+elseif GetLocale() == "zhTW" then
+ MAP_ONOFF = { [false] = "|cffff0000關閉|r", [true] = "|cff00ff00開啟|r" }
+ USAGE = "用法"
+ IS_CURRENTLY_SET_TO = "|cffffff7f%s|r目前的設定為|cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOW_SET_TO = "|cffffff7f%s|r現在被設定為|cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOT_A_VALID_OPTION_FOR = "對於|cffffff7f%2$s|r,[|cffffff7f%1$s|r]是一個不符合規定的選項"
+ IS_NOT_A_VALID_VALUE_FOR = "對於|cffffff7f%2$s|r,[|cffffff7f%1$s|r]是一個不符合規定的數值"
+ NO_OPTIONS_AVAILABLE = "沒有可用的選項"
+ OPTION_HANDLER_NOT_FOUND = "找不到|cffffff7f%q|r選項處理器。"
+ OPTION_HANDLER_NOT_VALID = "選項處理器不符合規定。"
+ OPTION_IS_DISABLED = "|cffffff7f%s|r已被停用。"
+ KEYBINDING_USAGE = ""
+ DEFAULT_CONFIRM_MESSAGE = "是否執行「%s」?"
+elseif GetLocale() == "esES" then
+ MAP_ONOFF = { [false] = "|cffff0000Desactivado|r", [true] = "|cff00ff00Activado|r" }
+ USAGE = "Uso"
+ IS_CURRENTLY_SET_TO = "|cffffff7f%s|r est\195\161 establecido actualmente a |cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOW_SET_TO = "|cffffff7f%s|r se ha establecido a |cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOT_A_VALID_OPTION_FOR = "[|cffffff7f%s|r] no es una opci\195\179n valida para |cffffff7f%s|r"
+ IS_NOT_A_VALID_VALUE_FOR = "[|cffffff7f%s|r] no es un valor v\195\161lido para |cffffff7f%s|r"
+ NO_OPTIONS_AVAILABLE = "No hay opciones disponibles"
+ OPTION_HANDLER_NOT_FOUND = "Gestor de opciones |cffffff7f%q|r no encontrado."
+ OPTION_HANDLER_NOT_VALID = "Gestor de opciones no v\195\161lido."
+ OPTION_IS_DISABLED = "La opci\195\179n |cffffff7f%s|r est\195\161 desactivada."
+ KEYBINDING_USAGE = ""
+ DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?" -- fix
+elseif GetLocale() == "ruRU" then
+ MAP_ONOFF = { [false] = "|cffff0000Off|r", [true] = "|cff00ff00On|r" }
+ USAGE = "Использование"
+ IS_CURRENTLY_SET_TO = "|cffffff7f%s|r в настоящее время установлен на |cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOW_SET_TO = "|cffffff7f%s|r теперь установлен |cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOT_A_VALID_OPTION_FOR = "[|cffffff7f%s|r] - недействительная опция для |cffffff7f%s|r"
+ IS_NOT_A_VALID_VALUE_FOR = "[|cffffff7f%s|r] - недействительное значение для |cffffff7f%s|r"
+ NO_OPTIONS_AVAILABLE = "Нет доступных опций"
+ OPTION_HANDLER_NOT_FOUND = "Оператор опции |cffffff7f%q|r не найден."
+ OPTION_HANDLER_NOT_VALID = "Оператор опции недействителен."
+ OPTION_IS_DISABLED = "Опция |cffffff7f%s|r отключена."
+ KEYBINDING_USAGE = ""
+ DEFAULT_CONFIRM_MESSAGE = "Вы уверены, что хотите выполнить `%s'?"
+else -- enUS
+ MAP_ONOFF = { [false] = "|cffff0000Off|r", [true] = "|cff00ff00On|r" }
+ USAGE = "Usage"
+ IS_CURRENTLY_SET_TO = "|cffffff7f%s|r is currently set to |cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOW_SET_TO = "|cffffff7f%s|r is now set to |cffffff7f[|r%s|cffffff7f]|r"
+ IS_NOT_A_VALID_OPTION_FOR = "[|cffffff7f%s|r] is not a valid option for |cffffff7f%s|r"
+ IS_NOT_A_VALID_VALUE_FOR = "[|cffffff7f%s|r] is not a valid value for |cffffff7f%s|r"
+ NO_OPTIONS_AVAILABLE = "No options available"
+ OPTION_HANDLER_NOT_FOUND = "Option handler |cffffff7f%q|r not found."
+ OPTION_HANDLER_NOT_VALID = "Option handler not valid."
+ OPTION_IS_DISABLED = "Option |cffffff7f%s|r is disabled."
+ KEYBINDING_USAGE = ""
+ DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?"
+end
+
+local NONE = NONE or "None"
+
+local AceOO = AceLibrary("AceOO-2.0")
+local AceEvent
+
+local AceConsole = AceOO.Mixin { "Print", "PrintComma", "PrintLiteral", "CustomPrint", "RegisterChatCommand" }
+local Dewdrop
+
+local _G = getfenv(0)
+
+local function print(text, name, r, g, b, frame, delay)
+ if not text or text:len() == 0 then
+ text = " "
+ end
+ if not name or name == AceConsole then
+ else
+ text = "|cffffff78" .. tostring(name) .. ":|r " .. text
+ end
+ local last_color
+ for t in text:gmatch("[^\n]+") do
+ (frame or DEFAULT_CHAT_FRAME):AddMessage(last_color and "|cff" .. last_color .. t or t, r, g, b, nil, delay or 5)
+ if not last_color or t:find("|r") or t:find("|c") then
+ last_color = t:match(".*|c[fF][fF](%x%x%x%x%x%x)[^|]-$")
+ end
+ end
+ return text
+end
+
+local real_tostring = tostring
+
+local function tostring(t)
+ if type(t) == "table" then
+ if type(rawget(t, 0)) == "userdata" and type(t.GetObjectType) == "function" then
+ return ("<%s:%s>"):format(t:GetObjectType(), t:GetName() or "(anon)")
+ end
+ end
+ return real_tostring(t)
+end
+
+local getkeystring
+
+local function isList(t)
+ local n = #t
+ for k,v in pairs(t) do
+ if type(k) ~= "number" then
+ return false
+ elseif k < 1 or k > n then
+ return false
+ end
+ end
+ return true
+end
+
+local findGlobal = setmetatable({}, {__index=function(self, t)
+ for k,v in pairs(_G) do
+ if v == t then
+ k = tostring(k)
+ self[v] = k
+ return k
+ end
+ end
+ self[t] = false
+ return false
+end})
+
+local recurse = {}
+local timeToEnd
+local GetTime = GetTime
+local type = type
+
+local new, del
+do
+ local cache = setmetatable({},{__mode='k'})
+ function new()
+ local t = next(cache)
+ if t then
+ cache[t] = nil
+ return t
+ else
+ return {}
+ end
+ end
+
+ function del(t)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ cache[t] = true
+ return nil
+ end
+end
+
+local function ignoreCaseSort(alpha, bravo)
+ if not alpha or not bravo then
+ return false
+ end
+ return tostring(alpha):lower() < tostring(bravo):lower()
+end
+
+local function specialSort(alpha, bravo)
+ if alpha == nil or bravo == nil then
+ return false
+ end
+ local type_alpha, type_bravo = type(alpha), type(bravo)
+ if type_alpha ~= type_bravo then
+ return type_alpha < type_bravo
+ end
+ if type_alpha == "string" then
+ return alpha:lower() < bravo:lower()
+ elseif type_alpha == "number" then
+ return alpha < bravo
+ elseif type_alpha == "table" then
+ return #alpha < #bravo
+ elseif type_alpha == "boolean" then
+ return not alpha
+ else
+ return false
+ end
+end
+
+local function escapeChar(c)
+ return ("\\%03d"):format(c:byte())
+end
+
+local function literal_tostring_prime(t, depth)
+ if type(t) == "string" then
+ return ("|cff00ff00%q|r"):format((t:gsub("|", "||"))):gsub("[%z\001-\009\011-\031\127-\255]", escapeChar)
+ elseif type(t) == "table" then
+ if t == _G then
+ return "|cffffea00_G|r"
+ end
+ if type(rawget(t, 0)) == "userdata" and type(t.GetObjectType) == "function" then
+ return ("|cffffea00<%s:%s>|r"):format(t:GetObjectType(), t:GetName() or "(anon)")
+ end
+ if next(t) == nil then
+ local mt = getmetatable(t)
+ if type(mt) == "table" and type(mt.__raw) == "table" then
+ t = mt.__raw
+ end
+ end
+ if recurse[t] then
+ local g = findGlobal[t]
+ if g then
+ return ("|cff9f9f9f|r"):format(g)
+ else
+ return ("|cff9f9f9f|r"):format(real_tostring(t):gsub("|", "||"))
+ end
+ elseif GetTime() > timeToEnd then
+ local g = findGlobal[t]
+ if g then
+ return ("|cff9f9f9f|r"):format(g)
+ else
+ return ("|cff9f9f9f|r"):format(real_tostring(t):gsub("|", "||"))
+ end
+ elseif depth >= 2 then
+ local g = findGlobal[t]
+ if g then
+ return ("|cff9f9f9f<_G[%q]>|r"):format(g)
+ else
+ return ("|cff9f9f9f<%s>|r"):format(real_tostring(t):gsub("|", "||"))
+ end
+ end
+ recurse[t] = true
+ if next(t) == nil then
+ return "{}"
+ elseif next(t, (next(t))) == nil then
+ local k, v = next(t)
+ if k == 1 then
+ return "{ " .. literal_tostring_prime(v, depth+1) .. " }"
+ else
+ return "{ " .. getkeystring(k, depth+1) .. " = " .. literal_tostring_prime(v, depth+1) .. " }"
+ end
+ end
+ local s
+ local g = findGlobal[t]
+ if g then
+ s = ("{ |cff9f9f9f-- _G[%q]|r\n"):format(g)
+ else
+ s = "{ |cff9f9f9f-- " .. real_tostring(t):gsub("|", "||") .. "|r\n"
+ end
+ if isList(t) then
+ for i = 1, #t do
+ s = s .. (" "):rep(depth+1) .. literal_tostring_prime(t[i], depth+1) .. (i == #t and "\n" or ",\n")
+ end
+ else
+ local tmp = new()
+ for k in pairs(t) do
+ tmp[#tmp+1] = k
+ end
+ table.sort(tmp, specialSort)
+ for i,k in ipairs(tmp) do
+ tmp[i] = nil
+ local v = t[k]
+ s = s .. (" "):rep(depth+1) .. getkeystring(k, depth+1) .. " = " .. literal_tostring_prime(v, depth+1) .. (tmp[i+1] == nil and "\n" or ",\n")
+ end
+ tmp = del(tmp)
+ end
+ if g then
+ s = s .. (" "):rep(depth) .. string.format("} |cff9f9f9f-- _G[%q]|r", g)
+ else
+ s = s .. (" "):rep(depth) .. "} |cff9f9f9f-- " .. real_tostring(t):gsub("|", "||")
+ end
+ return s
+ end
+ if type(t) == "number" then
+ return "|cffff7fff" .. real_tostring(t) .. "|r"
+ elseif type(t) == "boolean" then
+ return "|cffff9100" .. real_tostring(t) .. "|r"
+ elseif t == nil then
+ return "|cffff7f7f" .. real_tostring(t) .. "|r"
+ else
+ return "|cffffea00" .. real_tostring(t) .. "|r"
+ end
+end
+
+function getkeystring(t, depth)
+ if type(t) == "string" then
+ if t:find("^[%a_][%a%d_]*$") then
+ return "|cff7fd5ff" .. t .. "|r"
+ end
+ end
+ return "[" .. literal_tostring_prime(t, depth) .. "]"
+end
+
+local get_stringed_args
+do
+ local function g(value, ...)
+ if select('#', ...) == 0 then
+ return literal_tostring_prime(value, 1)
+ end
+ return literal_tostring_prime(value, 1) .. ", " .. g(...)
+ end
+
+ local function f(success, ...)
+ if not success then
+ return
+ end
+ return g(...)
+ end
+
+ function get_stringed_args(func, ...)
+ return f(pcall(func, ...))
+ end
+end
+
+local function literal_tostring_frame(t)
+ local s = ("|cffffea00<%s:%s|r\n"):format(t:GetObjectType(), t:GetName() or "(anon)")
+ local __index = getmetatable(t).__index
+ local tmp, tmp2, tmp3 = new(), new(), new()
+ for k in pairs(t) do
+ if k ~= 0 then
+ tmp3[k] = true
+ tmp2[k] = true
+ end
+ end
+ for k in pairs(__index) do
+ tmp2[k] = true
+ end
+ for k in pairs(tmp2) do
+ tmp[#tmp+1] = k
+ tmp2[k] = nil
+ end
+ table.sort(tmp, ignoreCaseSort)
+ local first = true
+ for i,k in ipairs(tmp) do
+ local v = t[k]
+ local good = true
+ if k == "GetPoint" then
+ for i = 1, t:GetNumPoints() do
+ if not first then
+ s = s .. ",\n"
+ else
+ first = false
+ end
+ s = s .. " " .. getkeystring(k, 1) .. "(" .. literal_tostring_prime(i, 1) .. ") => " .. get_stringed_args(v, t, i)
+ end
+ elseif type(v) == "function" and type(k) == "string" and (k:find("^Is") or k:find("^Get") or k:find("^Can")) then
+ local q = get_stringed_args(v, t)
+ if q then
+ if not first then
+ s = s .. ",\n"
+ else
+ first = false
+ end
+ s = s .. " " .. getkeystring(k, 1) .. "() => " .. q
+ end
+ elseif type(v) ~= "function" or (type(v) == "function" and type(k) == "string" and tmp3[k]) then
+ if not first then
+ s = s .. ",\n"
+ else
+ first = false
+ end
+ s = s .. " " .. getkeystring(k, 1) .. " = " .. literal_tostring_prime(v, 1)
+ else
+ good = false
+ end
+ end
+ tmp, tmp2, tmp3 = del(tmp), del(tmp2), del(tmp3)
+ s = s .. "\n|cffffea00>|r"
+ return s
+end
+
+local function literal_tostring(t, only)
+ timeToEnd = GetTime() + 0.2
+ local s
+ if only and type(t) == "table" and type(rawget(t, 0)) == "userdata" and type(t.GetObjectType) == "function" then
+ s = literal_tostring_frame(t)
+ else
+ s = literal_tostring_prime(t, 0)
+ end
+ for k,v in pairs(recurse) do
+ recurse[k] = nil
+ end
+ for k,v in pairs(findGlobal) do
+ findGlobal[k] = nil
+ end
+ return s
+end
+
+local function tostring_args(a1, ...)
+ if select('#', ...) < 1 then
+ return tostring(a1)
+ end
+ return tostring(a1), tostring_args(...)
+end
+
+local function literal_tostring_args(a1, ...)
+ if select('#', ...) < 1 then
+ return literal_tostring(a1)
+ end
+ return literal_tostring(a1), literal_tostring_args(...)
+end
+
+function AceConsole:CustomPrint(r, g, b, frame, delay, connector, a1, ...)
+ if connector == true then
+ local s
+ if select('#', ...) == 0 then
+ s = literal_tostring(a1, true)
+ else
+ s = (", "):join(literal_tostring_args(a1, ...))
+ end
+ return print(s, self, r, g, b, frame or self.printFrame, delay)
+ elseif tostring(a1):find("%%") and select('#', ...) >= 1 then
+ local success, text = pcall(string.format, tostring_args(a1, ...))
+ if success then
+ return print(text, self, r, g, b, frame or self.printFrame, delay)
+ end
+ end
+ return print((connector or " "):join(tostring_args(a1, ...)), self, r, g, b, frame or self.printFrame, delay)
+end
+
+function AceConsole:Print(...)
+ return AceConsole.CustomPrint(self, nil, nil, nil, nil, nil, " ", ...)
+end
+
+function AceConsole:PrintComma(...)
+ return AceConsole.CustomPrint(self, nil, nil, nil, nil, nil, ", ", ...)
+end
+
+function AceConsole:PrintLiteral(...)
+ return AceConsole.CustomPrint(self, nil, nil, nil, nil, nil, true, ...)
+end
+
+local work
+local argwork
+
+local function findTableLevel(self, options, chat, text, index, passTable)
+ if not index then
+ index = 1
+ if work then
+ for k,v in pairs(work) do
+ work[k] = nil
+ end
+ for k,v in pairs(argwork) do
+ argwork[k] = nil
+ end
+ else
+ work = {}
+ argwork = {}
+ end
+ local len = text:len()
+ local count
+ repeat
+ text, count = text:gsub("(|cff%x%x%x%x%x%x|Hitem:%d-:%d-:%d-:%d-|h%[[^%]]-) (.-%]|h|r)", "%1\001%2")
+ until count == 0
+ text = text:gsub("(%]|h|r)(|cff%x%x%x%x%x%x|Hitem:%d-:%d-:%d-:%d-|h%[)", "%1 %2")
+ for token in text:gmatch("([^%s]+)") do
+ local token = token
+ local num = tonumber(token)
+ if num then
+ token = num
+ else
+ token = token:gsub("\001", " ")
+ end
+ table.insert(work, token)
+ end
+ end
+
+ local path = chat
+ for i = 1, index - 1 do
+ path = path .. " " .. tostring(work[i])
+ end
+
+ local passValue = options.passValue or (passTable and work[index-1])
+ passTable = passTable or options
+
+ if type(options.args) == "table" then
+ local disabled, hidden = options.disabled, options.cmdHidden or options.hidden
+ if hidden then
+ if type(hidden) == "function" then
+ hidden = hidden(passValue)
+ elseif type(hidden) == "string" then
+ local handler = options.handler or self
+ local f = hidden
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ if type(handler[f]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ hidden = handler[f](handler, passValue)
+ if neg then
+ hidden = not hidden
+ end
+ end
+ end
+ if hidden then
+ disabled = true
+ elseif disabled then
+ if type(disabled) == "function" then
+ disabled = disabled(passValue)
+ elseif type(disabled) == "string" then
+ local handler = options.handler or self
+ local f = disabled
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ if type(handler[f]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ disabled = handler[f](handler, passValue)
+ if neg then
+ disabled = not disabled
+ end
+ end
+ end
+ if not disabled then
+ local next = work[index] and tostring(work[index]):lower()
+ local next_num = tonumber(next)
+ if next then
+ for k,v in pairs(options.args) do
+ local good = false
+ if tostring(k):gsub("%s", "-"):lower() == next then
+ good = true
+ elseif k == next_num then
+ good = true
+ elseif type(v.aliases) == "table" then
+ for _,alias in ipairs(v.aliases) do
+ if alias:gsub("%s", "-"):lower() == next then
+ good = true
+ break
+ end
+ end
+ elseif type(v.aliases) == "string" and v.aliases:gsub("%s", "-"):lower() == next then
+ good = true
+ end
+ if good then
+ work[index] = k -- revert it back to its original form as supplied in args
+ if options.pass then
+ passTable = passTable or options
+ if options.get and options.set then
+ passTable = options
+ end
+ else
+ passTable = nil
+ end
+ return findTableLevel(options.handler or self, v, chat, text, index + 1, passTable)
+ end
+ end
+ end
+ end
+ end
+ for i = index, #work do
+ table.insert(argwork, work[i])
+ end
+ return options, path, argwork, options.handler or self, passTable, passValue
+end
+
+local function validateOptionsMethods(self, options, position)
+ if type(options) ~= "table" then
+ return "Options must be a table.", position
+ end
+ self = options.handler or self
+ if options.type == "execute" then
+ if options.func and type(options.func) ~= "string" and type(options.func) ~= "function" then
+ return "func must be a string or function", position
+ end
+ if options.func and type(options.func) == "string" and type(self[options.func]) ~= "function" then
+ return ("%q is not a proper function"):format(tostring(options.func)), position
+ end
+ else
+ if options.get then
+ if type(options.get) ~= "string" and type(options.get) ~= "function" then
+ return "get must be a string or function", position
+ end
+ if type(options.get) == "string" then
+ local f = options.get
+ if options.type == "toggle" then
+ f = f:match("^~(.-)$") or f
+ end
+ if type(self[f]) ~= "function" then
+ return ("%q is not a proper function"):format(tostring(f)), position
+ end
+ end
+ end
+ if options.set then
+ if type(options.set) ~= "string" and type(options.set) ~= "function" then
+ return "set must be a string or function", position
+ end
+ if type(options.set) == "string" and type(self[options.set]) ~= "function" then
+ return ("%q is not a proper function"):format(tostring(options.set)), position
+ end
+ end
+ if options.validate and type(options.validate) ~= "table" and options.validate ~= "keybinding" then
+ if type(options.validate) ~= "string" and type(options.validate) ~= "function" then
+ return "validate must be a string or function", position
+ end
+ if type(options.validate) == "string" and type(self[options.validate]) ~= "function" then
+ return ("%q is not a proper function"):format(tostring(options.validate)), position
+ end
+ end
+ end
+ if options.disabled and type(options.disabled) == "string" then
+ local f = options.disabled
+ f = f:match("^~(.-)$") or f
+ if type(self[f]) ~= "function" then
+ return ("%q is not a proper function"):format(tostring(f)), position
+ end
+ end
+ if options.cmdHidden and type(options.cmdHidden) == "string" then
+ local f = options.cmdHidden
+ f = f:match("^~(.-)$") or f
+ if type(self[f]) ~= "function" then
+ return ("%q is not a proper function"):format(tostring(f)), position
+ end
+ end
+ if options.guiHidden and type(options.guiHidden) == "string" then
+ local f = options.guiHidden
+ f = f:match("^~(.-)$") or f
+ if type(self[f]) ~= "function" then
+ return ("%q is not a proper function"):format(tostring(f)), position
+ end
+ end
+ if options.hidden and type(options.hidden) == "string" then
+ local f = options.hidden
+ f = f:match("^~(.-)$") or f
+ if type(self[f]) ~= "function" then
+ return ("%q is not a proper function"):format(tostring(f)), position
+ end
+ end
+ if options.type == "group" and type(options.args) == "table" then
+ for k,v in pairs(options.args) do
+ if type(v) == "table" then
+ local newposition
+ if position then
+ newposition = position .. ".args." .. k
+ else
+ newposition = "args." .. k
+ end
+ local err, pos = validateOptionsMethods(self, v, newposition)
+ if err then
+ return err, pos
+ end
+ end
+ end
+ end
+end
+
+local function validateOptions(options, position, baseOptions, fromPass)
+ if not baseOptions then
+ baseOptions = options
+ end
+ if type(options) ~= "table" then
+ return "Options must be a table.", position
+ end
+ local kind = options.type
+ if type(kind) ~= "string" then
+ return '"type" must be a string.', position
+ elseif kind ~= "group" and kind ~= "range" and kind ~= "text" and kind ~= "execute" and kind ~= "toggle" and kind ~= "color" and kind ~= "header" then
+ return '"type" must either be "range", "text", "group", "toggle", "execute", "color", or "header".', position
+ end
+ if options.aliases then
+ if type(options.aliases) ~= "table" and type(options.aliases) ~= "string" then
+ return '"alias" must be a table or string', position
+ end
+ end
+ if not fromPass then
+ if kind == "execute" then
+ if type(options.func) ~= "string" and type(options.func) ~= "function" then
+ return '"func" must be a string or function', position
+ end
+ elseif kind == "range" or kind == "text" or kind == "toggle" then
+ if type(options.set) ~= "string" and type(options.set) ~= "function" then
+ return '"set" must be a string or function', position
+ end
+ if kind == "text" and options.get == false then
+ elseif type(options.get) ~= "string" and type(options.get) ~= "function" then
+ return '"get" must be a string or function', position
+ end
+ elseif kind == "group" and options.pass then
+ if options.pass ~= true then
+ return '"pass" must be either nil, true, or false', position
+ end
+ if not options.func then
+ if type(options.set) ~= "string" and type(options.set) ~= "function" then
+ return '"set" must be a string or function', position
+ end
+ if type(options.get) ~= "string" and type(options.get) ~= "function" then
+ return '"get" must be a string or function', position
+ end
+ elseif type(options.func) ~= "string" and type(options.func) ~= "function" then
+ return '"func" must be a string or function', position
+ end
+ end
+ end
+ if options ~= baseOptions then
+ if kind == "header" then
+ elseif type(options.desc) ~= "string" then
+ return '"desc" must be a string', position
+ elseif options.desc:len() == 0 then
+ return '"desc" cannot be a 0-length string', position
+ end
+ end
+
+ if options ~= baseOptions or kind == "range" or kind == "text" or kind == "toggle" or kind == "color" then
+ if options.type == "header" and not options.cmdName and not options.name then
+ elseif options.cmdName then
+ if type(options.cmdName) ~= "string" then
+ return '"cmdName" must be a string or nil', position
+ elseif options.cmdName:len() == 0 then
+ return '"cmdName" cannot be a 0-length string', position
+ end
+ if type(options.guiName) ~= "string" then
+ if not options.guiNameIsMap then
+ return '"guiName" must be a string or nil', position
+ end
+ elseif options.guiName:len() == 0 then
+ return '"guiName" cannot be a 0-length string', position
+ end
+ else
+ if type(options.name) ~= "string" then
+ return '"name" must be a string', position
+ elseif options.name:len() == 0 then
+ return '"name" cannot be a 0-length string', position
+ end
+ end
+ end
+ if options.guiNameIsMap then
+ if type(options.guiNameIsMap) ~= "boolean" then
+ return '"guiNameIsMap" must be a boolean or nil', position
+ elseif options.type ~= "toggle" then
+ return 'if "guiNameIsMap" is true, then "type" must be set to \'toggle\'', position
+ elseif type(options.map) ~= "table" then
+ return '"map" must be a table', position
+ end
+ end
+ if options.message and type(options.message) ~= "string" then
+ return '"message" must be a string or nil', position
+ end
+ if options.error and type(options.error) ~= "string" then
+ return '"error" must be a string or nil', position
+ end
+ if options.current and type(options.current) ~= "string" then
+ return '"current" must be a string or nil', position
+ end
+ if options.order then
+ if type(options.order) ~= "number" or (-1 < options.order and options.order < 0.999) then
+ return '"order" must be a non-zero number or nil', position
+ end
+ end
+ if options.disabled then
+ if type(options.disabled) ~= "function" and type(options.disabled) ~= "string" and options.disabled ~= true then
+ return '"disabled" must be a function, string, or boolean', position
+ end
+ end
+ if options.cmdHidden then
+ if type(options.cmdHidden) ~= "function" and type(options.cmdHidden) ~= "string" and options.cmdHidden ~= true then
+ return '"cmdHidden" must be a function, string, or boolean', position
+ end
+ end
+ if options.guiHidden then
+ if type(options.guiHidden) ~= "function" and type(options.guiHidden) ~= "string" and options.guiHidden ~= true then
+ return '"guiHidden" must be a function, string, or boolean', position
+ end
+ end
+ if options.hidden then
+ if type(options.hidden) ~= "function" and type(options.hidden) ~= "string" and options.hidden ~= true then
+ return '"hidden" must be a function, string, or boolean', position
+ end
+ end
+ if kind == "text" then
+ if type(options.validate) == "table" then
+ local t = options.validate
+ local iTable = nil
+ for k,v in pairs(t) do
+ if type(k) == "number" then
+ if iTable == nil then
+ iTable = true
+ elseif not iTable then
+ return '"validate" must either have all keys be indexed numbers or strings', position
+ elseif k < 1 or k > #t then
+ return '"validate" numeric keys must be indexed properly. >= 1 and <= #validate', position
+ end
+ else
+ if iTable == nil then
+ iTable = false
+ elseif iTable then
+ return '"validate" must either have all keys be indexed numbers or strings', position
+ end
+ end
+ if type(v) ~= "string" then
+ return '"validate" values must all be strings', position
+ end
+ end
+ if options.multiToggle and options.multiToggle ~= true then
+ return '"multiToggle" must be a boolean or nil if "validate" is a table', position
+ end
+ elseif options.validate == "keybinding" then
+
+ else
+ if type(options.usage) ~= "string" then
+ return '"usage" must be a string', position
+ elseif options.validate and type(options.validate) ~= "string" and type(options.validate) ~= "function" then
+ return '"validate" must be a string, function, or table', position
+ end
+ end
+ if options.multiToggle and type(options.validate) ~= "table" then
+ return '"validate" must be a table if "multiToggle" is true', position
+ end
+ elseif kind == "range" then
+ if options.min or options.max then
+ if type(options.min) ~= "number" then
+ return '"min" must be a number', position
+ elseif type(options.max) ~= "number" then
+ return '"max" must be a number', position
+ elseif options.min >= options.max then
+ return '"min" must be less than "max"', position
+ end
+ end
+ if options.step then
+ if type(options.step) ~= "number" then
+ return '"step" must be a number', position
+ elseif options.step < 0 then
+ return '"step" must be nonnegative', position
+ end
+ end
+ if options.isPercent and options.isPercent ~= true then
+ return '"isPercent" must either be nil, true, or false', position
+ end
+ elseif kind == "toggle" then
+ if options.map then
+ if type(options.map) ~= "table" then
+ return '"map" must be a table', position
+ elseif type(options.map[true]) ~= "string" then
+ return '"map[true]" must be a string', position
+ elseif type(options.map[false]) ~= "string" then
+ return '"map[false]" must be a string', position
+ end
+ end
+ elseif kind == "color" then
+ if options.hasAlpha and options.hasAlpha ~= true then
+ return '"hasAlpha" must be nil, true, or false', position
+ end
+ elseif kind == "group" then
+ if options.pass and options.pass ~= true then
+ return '"pass" must be nil, true, or false', position
+ end
+ if type(options.args) ~= "table" then
+ return '"args" must be a table', position
+ end
+ for k,v in pairs(options.args) do
+ if type(k) ~= "number" then
+ if type(k) ~= "string" then
+ return '"args" keys must be strings or numbers', position
+ elseif k:len() == 0 then
+ return '"args" keys must not be 0-length strings.', position
+ end
+ end
+ if type(v) ~= "table" then
+ if type(k) == "number" then
+ return '"args" values must be tables', position and position .. "[" .. k .. "]" or "[" .. k .. "]"
+ else
+ return '"args" values must be tables', position and position .. "." .. k or k
+ end
+ end
+ local newposition
+ if type(k) == "number" then
+ newposition = position and position .. ".args[" .. k .. "]" or "args[" .. k .. "]"
+ else
+ newposition = position and position .. ".args." .. k or "args." .. k
+ end
+ local err, pos = validateOptions(v, newposition, baseOptions, options.pass)
+ if err then
+ return err, pos
+ end
+ end
+ elseif kind == "execute" then
+ if type(options.confirm) ~= "string" and type(options.confirm) ~= "boolean" and type(options.confirm) ~= "nil" then
+ return '"confirm" must be a string, boolean, or nil', position
+ end
+ end
+end
+
+local colorTable
+local colorFunc
+local colorCancelFunc
+
+local function keybindingValidateFunc(text)
+ if text == nil or text == "NONE" then
+ return nil
+ end
+ text = text:upper()
+ local shift, ctrl, alt
+ local modifier
+ while true do
+ if text == "-" then
+ break
+ end
+ modifier, text = strsplit('-', text, 2)
+ if text then
+ if modifier ~= "SHIFT" and modifier ~= "CTRL" and modifier ~= "ALT" then
+ return false
+ end
+ if modifier == "SHIFT" then
+ if shift then
+ return false
+ end
+ shift = true
+ end
+ if modifier == "CTRL" then
+ if ctrl then
+ return false
+ end
+ ctrl = true
+ end
+ if modifier == "ALT" then
+ if alt then
+ return false
+ end
+ alt = true
+ end
+ else
+ text = modifier
+ break
+ end
+ end
+ if not text:find("^F%d+$") and text ~= "CAPSLOCK" and text:len() ~= 1 and (text:byte() < 128 or text:len() > 4) and not _G["KEY_" .. text] then
+ return false
+ end
+ local s = text
+ if shift then
+ s = "SHIFT-" .. s
+ end
+ if ctrl then
+ s = "CTRL-" .. s
+ end
+ if alt then
+ s = "ALT-" .. s
+ end
+ return s
+end
+AceConsole.keybindingValidateFunc = keybindingValidateFunc
+
+local order
+
+local mysort_args
+local mysort
+
+local function icaseSort(alpha, bravo)
+ if type(alpha) == "number" and type(bravo) == "number" then
+ return alpha < bravo
+ end
+ return tostring(alpha):lower() < tostring(bravo):lower()
+end
+
+local tmp = {}
+local function printUsage(self, handler, realOptions, options, path, args, passValue, quiet, filter)
+ if filter then
+ filter = "^" .. filter:gsub("([%(%)%.%*%+%-%[%]%?%^%$%%])", "%%%1")
+ end
+ local hidden, disabled = options.cmdHidden or options.hidden, options.disabled
+ if hidden then
+ if type(hidden) == "function" then
+ hidden = hidden(options.passValue)
+ elseif type(hidden) == "string" then
+ local f = hidden
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ if type(handler[f]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ hidden = handler[f](handler, options.passValue)
+ if neg then
+ hidden = not hidden
+ end
+ end
+ end
+ if hidden then
+ disabled = true
+ elseif disabled then
+ if type(disabled) == "function" then
+ disabled = disabled(options.passValue)
+ elseif type(disabled) == "string" then
+ local f = disabled
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ if type(handler[f]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ disabled = handler[f](handler, options.passValue)
+ if neg then
+ disabled = not disabled
+ end
+ end
+ end
+ local kind = (options.type or "group"):lower()
+ if disabled then
+ print(OPTION_IS_DISABLED:format(path), realOptions.cmdName or realOptions.name or self)
+ elseif kind == "text" then
+ local var
+ local multiToggle
+ for k in pairs(tmp) do
+ tmp[k] = nil
+ end
+ if passTable then
+ multiToggle = passTable.multiToggle
+ if not passTable.get then
+ elseif type(passTable.get) == "function" then
+ if not multiToggle then
+ var = passTable.get(passValue)
+ else
+ var = tmp
+ for k,v in pairs(options.validate) do
+ local val = type(k) ~= "number" and k or v
+ if passValue == nil then
+ var[val] = passTable.get(val) or nil
+ else
+ var[val] = passTable.get(passValue, val) or nil
+ end
+ end
+ end
+ else
+ local handler = passTable.handler or handler
+ if type(handler[passTable.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get)))
+ end
+ var = handler[passTable.get](handler, passValue)
+ if not multiToggle then
+ var = handler[passTable.get](handler, passValue)
+ else
+ var = tmp
+ for k,v in pairs(options.validate) do
+ local val = type(k) ~= "number" and k or v
+ if passValue == nil then
+ var[val] = handler[passTable.get](handler, val) or nil
+ else
+ var[val] = handler[passTable.get](handler, passValue, val) or nil
+ end
+ end
+ end
+ end
+ else
+ multiToggle = options.multiToggle
+ if not options.get then
+ elseif type(options.get) == "function" then
+ if not multiToggle then
+ var = options.get(passValue)
+ else
+ var = tmp
+ for k,v in pairs(options.validate) do
+ local val = type(k) ~= "number" and k or v
+ if passValue == nil then
+ var[val] = options.get(val) or nil
+ else
+ var[val] = options.get(passValue, val) or nil
+ end
+ end
+ end
+ else
+ local handler = options.handler or handler
+ if type(handler[options.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get)))
+ end
+ if not multiToggle then
+ var = handler[options.get](handler, passValue)
+ else
+ var = tmp
+ for k,v in pairs(options.validate) do
+ local val = type(k) ~= "number" and k or v
+ if passValue == nil then
+ var[val] = handler[options.get](handler, val) or nil
+ else
+ var[val] = handler[options.get](handler, passValue, val) or nil
+ end
+ end
+ end
+ end
+ end
+
+ local usage
+ if type(options.validate) == "table" then
+ if filter then
+ if not order then
+ order = {}
+ end
+ for k,v in pairs(options.validate) do
+ if v:find(filter) then
+ table.insert(order, v)
+ end
+ end
+ table.sort(order, icaseSort)
+ usage = "{" .. table.concat(order, " || ") .. "}"
+ for k in pairs(order) do
+ order[k] = nil
+ end
+ else
+ if not order then
+ order = {}
+ end
+ for k,v in pairs(options.validate) do
+ table.insert(order, v)
+ end
+ table.sort(order, icaseSort)
+ usage = "{" .. table.concat(order, " || ") .. "}"
+ for k in pairs(order) do
+ order[k] = nil
+ end
+ end
+ if multiToggle then
+ if not next(var) then
+ var = NONE
+ else
+ if not order then
+ order = {}
+ end
+ for k in pairs(var) do
+ if options.validate[k] then
+ order[#order+1] = options.validate[k]
+ else
+ for _,v in pairs(options.validate) do
+ if v == k or (type(v) == "string" and type(k) == "string" and v:lower() == k:lower()) then
+ order[#order+1] = v
+ break
+ end
+ end
+ end
+ end
+ table.sort(order, icaseSort)
+ var = table.concat(order, ", ")
+ for k in pairs(order) do
+ order[k] = nil
+ end
+ end
+ else
+ var = options.validate[var] or var
+ end
+ elseif options.validate == "keybinding" then
+ usage = KEYBINDING_USAGE
+ else
+ usage = options.usage or ""
+ end
+ if not quiet then
+ print(("|cffffff7f%s:|r %s %s"):format(USAGE, path, usage), realOptions.cmdName or realOptions.name or self)
+ end
+ if (passTable and passTable.get) or options.get then
+ print((options.current or IS_CURRENTLY_SET_TO):format(tostring(options.cmdName or options.name), tostring(var or NONE)))
+ end
+ elseif kind == "range" then
+ local var
+ if passTable then
+ if type(passTable.get) == "function" then
+ var = passTable.get(passValue)
+ else
+ local handler = passTable.handler or handler
+ if type(handler[passTable.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get)))
+ end
+ var = handler[passTable.get](handler, passValue)
+ end
+ else
+ if type(options.get) == "function" then
+ var = options.get(passValue)
+ else
+ local handler = options.handler or handler
+ if type(handler[options.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get)))
+ end
+ var = handler[options.get](handler, passValue)
+ end
+ end
+
+ local usage
+ local min = options.min or 0
+ local max = options.max or 1
+ if options.isPercent then
+ min, max = min * 100, max * 100
+ var = tostring(var * 100) .. "%"
+ end
+ local bit = "-"
+ if min < 0 or max < 0 then
+ bit = " - "
+ end
+ usage = ("(%s%s%s)"):format(min, bit, max)
+ if not quiet then
+ print(("|cffffff7f%s:|r %s %s"):format(USAGE, path, usage), realOptions.cmdName or realOptions.name or self)
+ end
+ print((options.current or IS_CURRENTLY_SET_TO):format(tostring(options.cmdName or options.name), tostring(var or NONE)))
+ elseif kind == "group" then
+ local usage
+ if next(options.args) then
+ if not order then
+ order = {}
+ end
+ for k,v in pairs(options.args) do
+ if v.type ~= "header" then
+ local hidden = v.cmdHidden or v.hidden
+ if hidden then
+ if type(hidden) == "function" then
+ hidden = hidden()
+ elseif type(hidden) == "string" then
+ local f = hidden
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ if type(handler[f]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ hidden = handler[f](handler)
+ if neg then
+ hidden = not hidden
+ end
+ end
+ end
+ if not hidden then
+ if filter then
+ if k:find(filter) then
+ table.insert(order, k)
+ elseif type(v.aliases) == "table" then
+ for _,bit in ipairs(v.aliases) do
+ if bit:find(filter) then
+ table.insert(order, k)
+ break
+ end
+ end
+ elseif type(v.aliases) == "string" then
+ if v.aliases:find(filter) then
+ table.insert(order, k)
+ end
+ end
+ else
+ table.insert(order, k)
+ end
+ end
+ end
+ end
+ if not mysort then
+ mysort = function(a, b)
+ local alpha, bravo = mysort_args[a], mysort_args[b]
+ local alpha_order = alpha and alpha.order or 100
+ local bravo_order = bravo and bravo.order or 100
+ if alpha_order == bravo_order then
+ return tostring(a):lower() < tostring(b):lower()
+ else
+ if alpha_order < 0 then
+ if bravo_order > 0 then
+ return false
+ end
+ else
+ if bravo_order < 0 then
+ return true
+ end
+ end
+ if alpha_order > 0 and bravo_order > 0 then
+ return tostring(a):lower() < tostring(b):lower()
+ end
+ return alpha_order < bravo_order
+ end
+ end
+ end
+ mysort_args = options.args
+ table.sort(order, mysort)
+ mysort_args = nil
+ if not quiet then
+ if options == realOptions then
+ if options.desc then
+ print(tostring(options.desc), realOptions.cmdName or realOptions.name or self)
+ print(("|cffffff7f%s:|r %s %s"):format(USAGE, path, "{" .. table.concat(order, " || ") .. "}"))
+ elseif self.description or self.notes then
+ print(tostring(self.description or self.notes), realOptions.cmdName or realOptions.name or self)
+ print(("|cffffff7f%s:|r %s %s"):format(USAGE, path, "{" .. table.concat(order, " || ") .. "}"))
+ else
+ print(("|cffffff7f%s:|r %s %s"):format(USAGE, path, "{" .. table.concat(order, " || ") .. "}"), realOptions.cmdName or realOptions.name or self)
+ end
+ else
+ if options.desc then
+ print(("|cffffff7f%s:|r %s %s"):format(USAGE, path, "{" .. table.concat(order, " || ") .. "}"), realOptions.cmdName or realOptions.name or self)
+ print(tostring(options.desc))
+ else
+ print(("|cffffff7f%s:|r %s %s"):format(USAGE, path, "{" .. table.concat(order, " || ") .. "}"), realOptions.cmdName or realOptions.name or self)
+ end
+ end
+ end
+ local passTable = options.pass and options or nil
+ for _,k in ipairs(order) do
+ local passValue = passTable and k or nil
+ local real_k = k
+ local v = options.args[k]
+ if v then
+ local v_p = passTable or v
+ if v.get and v.set then
+ v_p = v
+ passValue = nil
+ end
+ if v.passValue then
+ passValue = v.passValue
+ end
+ local k = tostring(k):gsub("%s", "-")
+ local disabled = v.disabled
+ if disabled then
+ if type(disabled) == "function" then
+ disabled = disabled(passValue)
+ elseif type(disabled) == "string" then
+ local f = disabled
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ if type(handler[f]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ disabled = handler[f](handler, passValue)
+ if neg then
+ disabled = not disabled
+ end
+ end
+ end
+ if type(v.aliases) == "table" then
+ for _,s in ipairs(v.aliases) do
+ k = k .. " || " .. s:gsub("%s", "-")
+ end
+ elseif type(v.aliases) == "string" then
+ k = k .. " || " .. v.aliases:gsub("%s", "-")
+ end
+ if v_p.get then
+ local a1,a2,a3,a4
+ local multiToggle = v_p.type == "text" and v_p.multiToggle
+ for k in pairs(tmp) do
+ tmp[k] = nil
+ end
+ if type(v_p.get) == "function" then
+ if multiToggle then
+ a1 = tmp
+ for k,v in pairs(v.validate) do
+ local val = type(k) ~= "number" and k or v
+ if passValue == nil then
+ a1[val] = v_p.get(val) or nil
+ else
+ a1[val] = v_p.get(passValue, val) or nil
+ end
+ end
+ else
+ a1,a2,a3,a4 = v_p.get(passValue)
+ end
+ else
+ local handler = v_p.handler or handler
+ local f = v_p.get
+ local neg
+ if v.type == "toggle" then
+ neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ end
+ if type(handler[f]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ if multiToggle then
+ a1 = tmp
+ for k,v in pairs(v.validate) do
+ local val = type(k) ~= "number" and k or v
+ if passValue == nil then
+ a1[val] = handler[f](handler, val) or nil
+ else
+ a1[val] = handler[f](handler, passValue, val) or nil
+ end
+ end
+ else
+ a1,a2,a3,a4 = handler[f](handler, passValue)
+ end
+ if neg then
+ a1 = not a1
+ end
+ end
+ local s
+ if v.type == "color" then
+ if v.hasAlpha then
+ if not a1 or not a2 or not a3 or not a4 then
+ s = NONE
+ else
+ s = ("|c%02x%02x%02x%02x%02x%02x%02x%02x|r"):format(a4*255, a1*255, a2*255, a3*255, a4*255, a1*255, a2*255, a3*255)
+ end
+ else
+ if not a1 or not a2 or not a3 then
+ s = NONE
+ else
+ s = ("|cff%02x%02x%02x%02x%02x%02x|r"):format(a1*255, a2*255, a3*255, a1*255, a2*255, a3*255)
+ end
+ end
+ elseif v.type == "toggle" then
+ if v.map then
+ s = tostring(v.map[a1 and true or false] or NONE)
+ else
+ s = tostring(MAP_ONOFF[a1 and true or false] or NONE)
+ end
+ elseif v.type == "range" then
+ if v.isPercent then
+ s = tostring(a1 * 100) .. "%"
+ else
+ s = tostring(a1)
+ end
+ elseif v.type == "text" and type(v.validate) == "table" then
+ if multiToggle then
+ if not next(a1) then
+ s = NONE
+ else
+ s = ''
+ for k in pairs(a1) do
+ if v.validate[k] then
+ if s == '' then
+ s = v.validate[k]
+ else
+ s = s .. ', ' .. v.validate[k]
+ end
+ else
+ for _,u in pairs(v.validate) do
+ if u == k or (type(v) == "string" and type(k) == "string" and v:lower() == k:lower()) then
+ if s == '' then
+ s = u
+ else
+ s = s .. ', ' .. u
+ end
+ break
+ end
+ end
+ end
+ end
+ end
+ else
+ s = tostring(v.validate[a1] or a1 or NONE)
+ end
+ else
+ s = tostring(a1 or NONE)
+ end
+ if disabled then
+ local s = s:gsub("|cff%x%x%x%x%x%x(.-)|r", "%1")
+ local desc = (v.desc or NONE):gsub("|cff%x%x%x%x%x%x(.-)|r", "%1")
+ print(("|cffcfcfcf - %s: [%s] %s|r"):format(k, s, desc))
+ else
+ print((" - |cffffff7f%s: [|r%s|cffffff7f]|r %s"):format(k, s, v.desc or NONE))
+ end
+ else
+ if disabled then
+ local desc = (v.desc or NONE):gsub("|cff%x%x%x%x%x%x(.-)|r", "%1")
+ print(("|cffcfcfcf - %s: %s"):format(k, desc))
+ else
+ print((" - |cffffff7f%s:|r %s"):format(k, v.desc or NONE))
+ end
+ end
+ end
+ end
+ for k in pairs(order) do
+ order[k] = nil
+ end
+ else
+ if options.desc then
+ print(("|cffffff7f%s:|r %s"):format(USAGE, path), realOptions.cmdName or realOptions.name or self)
+ print(tostring(options.desc))
+ elseif options == realOptions and (self.description or self.notes) then
+ print(tostring(self.description or self.notes), realOptions.cmdName or realOptions.name or self)
+ print(("|cffffff7f%s:|r %s"):format(USAGE, path))
+ else
+ print(("|cffffff7f%s:|r %s"):format(USAGE, path), realOptions.cmdName or realOptions.name or self)
+ end
+ print(NO_OPTIONS_AVAILABLE)
+ end
+ end
+end
+
+local function confirmPopup(message, func, ...)
+ if not StaticPopupDialogs["ACECONSOLE20_CONFIRM_DIALOG"] then
+ StaticPopupDialogs["ACECONSOLE20_CONFIRM_DIALOG"] = {}
+ end
+ local t = StaticPopupDialogs["ACECONSOLE20_CONFIRM_DIALOG"]
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t.text = message
+ t.button1 = ACCEPT or "Accept"
+ t.button2 = CANCEL or "Cancel"
+ t.OnAccept = function()
+ func(unpack(t))
+ end
+ for i = 1, select('#', ...) do
+ t[i] = select(i, ...)
+ end
+ t.timeout = 0
+ t.whileDead = 1
+ t.hideOnEscape = 1
+
+ StaticPopup_Show("ACECONSOLE20_CONFIRM_DIALOG")
+end
+
+local function handlerFunc(self, chat, msg, options)
+ if not msg then
+ msg = ""
+ else
+ msg = msg:gsub("^%s*(.-)%s*$", "%1")
+ msg = msg:gsub("%s+", " ")
+ end
+
+ local realOptions = options
+ local options, path, args, handler, passTable, passValue = findTableLevel(self, options, chat, msg)
+ if options.type == "execute" then
+ if options.func then
+ passTable = nil
+ end
+ else
+ if options.get and options.set then
+ passTable = nil
+ end
+ end
+ passValue = options.passValue or passTable and passValue
+
+ local hidden, disabled = options.cmdHidden or options.hidden, options.disabled
+ if hidden then
+ if type(hidden) == "function" then
+ hidden = hidden(passValue)
+ elseif type(hidden) == "string" then
+ local f = hidden
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ if type(handler[f]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ hidden = handler[f](handler, passValue)
+ if neg then
+ hidden = not hidden
+ end
+ end
+ end
+ if hidden then
+ disabled = true
+ elseif disabled then
+ if type(disabled) == "function" then
+ disabled = disabled(passValue)
+ elseif type(disabled) == "string" then
+ local f = disabled
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ if type(handler[f]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ disabled = handler[f](handler, passValue)
+ if neg then
+ disabled = not disabled
+ end
+ end
+ end
+ local kind = (options.type or "group"):lower()
+ local options_p = passTable or options
+ if disabled then
+ print(OPTION_IS_DISABLED:format(path), realOptions.cmdName or realOptions.name or self)
+ elseif kind == "text" then
+ if #args > 0 then
+ if (type(options.validate) == "table" and #args > 1) or (type(options.validate) ~= "table" and not options.input) then
+ local arg = table.concat(args, " ")
+ for k,v in pairs(args) do
+ args[k] = nil
+ end
+ args[1] = arg
+ end
+ if options.validate then
+ local good
+ if type(options.validate) == "function" then
+ good = options.validate(unpack(args))
+ elseif type(options.validate) == "table" then
+ local arg = args[1]
+ arg = tostring(arg):lower()
+ for k,v in pairs(options.validate) do
+ if v:lower() == arg then
+ args[1] = type(k) == "string" and k or v
+ good = true
+ break
+ end
+ end
+ if not good and type((next(options.validate))) == "string" then
+ for k,v in pairs(options.validate) do
+ if type(k) == "string" and k:lower() == arg then
+ args[1] = k
+ good = true
+ break
+ end
+ end
+ end
+ elseif options.validate == "keybinding" then
+ good = keybindingValidateFunc(unpack(args))
+ if good ~= false then
+ args[1] = good
+ end
+ else
+ if type(handler[options.validate]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.validate)))
+ end
+ good = handler[options.validate](handler, unpack(args))
+ end
+ if not good then
+ local usage
+ if type(options.validate) == "table" then
+ if not order then
+ order = {}
+ end
+ for k,v in pairs(options.validate) do
+ table.insert(order, v)
+ end
+ usage = "{" .. table.concat(order, " || ") .. "}"
+ for k in pairs(order) do
+ order[k] = nil
+ end
+ elseif options.validate == "keybinding" then
+ usage = KEYBINDING_USAGE
+ else
+ usage = options.usage or ""
+ end
+ print((options.error or IS_NOT_A_VALID_OPTION_FOR):format(tostring(table.concat(args, " ")), path), realOptions.cmdName or realOptions.name or self)
+ print(("|cffffff7f%s:|r %s %s"):format(USAGE, path, usage))
+ return
+ end
+ end
+
+ local var
+ local multiToggle
+ for k in pairs(tmp) do
+ tmp[k] = nil
+ end
+ multiToggle = options_p.multiToggle
+ if not options_p.get then
+ elseif type(options_p.get) == "function" then
+ if multiToggle then
+ var = tmp
+ for k,v in pairs(options.validate) do
+ local val = type(k) ~= "number" and k or v
+ if passValue then
+ var[val] = options_p.get(passValue, val) or nil
+ else
+ var[val] = options_p.get(val) or nil
+ end
+ end
+ else
+ var = options_p.get(passValue)
+ end
+ else
+ if type(handler[options_p.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get)))
+ end
+ if multiToggle then
+ var = tmp
+ for k,v in pairs(options.validate) do
+ local val = type(k) ~= "number" and k or v
+ if passValue then
+ var[val] = handler[options_p.get](handler, passValue, val) or nil
+ else
+ var[val] = handler[options_p.get](handler, val) or nil
+ end
+ end
+ else
+ var = handler[options_p.get](handler, passValue)
+ end
+ end
+
+ if multiToggle or var ~= args[1] then
+ if multiToggle then
+ local current = var[args[1]]
+ if current == nil and type(args[1]) == "string" then
+ for k in pairs(var) do
+ if type(k) == "string" and k:lower() == args[1]:lower() then
+ current = true
+ break
+ end
+ end
+ end
+ args[2] = not current
+ end
+ if type(options_p.set) == "function" then
+ if passValue then
+ options_p.set(passValue, unpack(args))
+ else
+ options_p.set(unpack(args))
+ end
+ else
+ if type(handler[options_p.set]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.set)))
+ end
+ if passValue then
+ handler[options_p.set](handler, passValue, unpack(args))
+ else
+ handler[options_p.set](handler, unpack(args))
+ end
+ end
+ end
+ end
+
+ if #args > 0 then
+ local var
+ local multiToggle
+ for k in pairs(tmp) do
+ tmp[k] = nil
+ end
+ multiToggle = options_p.multiToggle
+ if not options_p.get then
+ elseif type(options_p.get) == "function" then
+ if multiToggle then
+ var = tmp
+ for k,v in pairs(options_p.validate) do
+ local val = type(k) ~= "number" and k or v
+ if passValue then
+ var[val] = options_p.get(passValue, val) or nil
+ else
+ var[val] = options_p.get(val) or nil
+ end
+ end
+ else
+ var = options_p.get(passValue)
+ end
+ else
+ if type(handler[options_p.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get)))
+ end
+ if multiToggle then
+ var = tmp
+ for k,v in pairs(options.validate) do
+ local val = type(k) ~= "number" and k or v
+ if passValue then
+ var[val] = handler[options_p.get](handler, passValue, val) or nil
+ else
+ var[val] = handler[options_p.get](handler, val) or nil
+ end
+ end
+ else
+ var = handler[options_p.get](handler, passValue)
+ end
+ end
+ if multiToggle then
+ if not next(var) then
+ var = NONE
+ else
+ if not order then
+ order = {}
+ end
+ for k in pairs(var) do
+ if options.validate[k] then
+ order[#order+1] = options.validate[k]
+ else
+ for _,v in pairs(options.validate) do
+ if v == k or (type(v) == "string" and type(k) == "string" and v:lower() == k:lower()) then
+ order[#order+1] = v
+ break
+ end
+ end
+ end
+ end
+ table.sort(order, icaseSort)
+ var = table.concat(order, ", ")
+ for k in pairs(order) do
+ order[k] = nil
+ end
+ end
+ elseif type(options.validate) == "table" then
+ var = options.validate[var] or var
+ end
+ if options_p.get then
+ print((options.message or IS_NOW_SET_TO):format(tostring(options.cmdName or options.name), tostring(var or NONE)), realOptions.cmdName or realOptions.name or self)
+ end
+ if var == args[1] then
+ return
+ end
+ else
+ printUsage(self, handler, realOptions, options, path, args, passValue)
+ return
+ end
+ elseif kind == "execute" then
+ local confirm = options.confirm
+ if confirm == true then
+ confirm = DEFAULT_CONFIRM_MESSAGE:format(options.desc or options.name or UNKNOWN or "Unknown")
+ end
+ if type(options_p.func) == "function" then
+ if confirm then
+ confirmPopup(confirm, options_p.func, passValue)
+ else
+ options_p.func(passValue)
+ end
+ else
+ if type(handler[options_p.func]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.func)))
+ end
+ if confirm then
+ confirmPopup(confirm, handler[options_p.func], handler, passValue)
+ else
+ handler[options_p.func](handler, passValue)
+ end
+ end
+ elseif kind == "toggle" then
+ local var
+ if type(options_p.get) == "function" then
+ var = options_p.get(passValue)
+ else
+ local f = options_p.get
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ if type(handler[f]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ var = handler[f](handler, passValue)
+ if neg then
+ var = not var
+ end
+ end
+ if type(options_p.set) == "function" then
+ if passValue then
+ options_p.set(passValue, not var)
+ else
+ options_p.set(not var)
+ end
+ else
+ if type(handler[options_p.set]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.set)))
+ end
+ if passValue then
+ handler[options_p.set](handler, passValue, not var)
+ else
+ handler[options_p.set](handler, not var)
+ end
+ end
+ if type(options_p.get) == "function" then
+ var = options_p.get(passValue)
+ else
+ local f = options_p.get
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ var = handler[f](handler, passValue)
+ if neg then
+ var = not var
+ end
+ end
+
+ print((options.message or IS_NOW_SET_TO):format(tostring(options.cmdName or options.name), (options.map or MAP_ONOFF)[var and true or false] or NONE), realOptions.cmdName or realOptions.name or self)
+ elseif kind == "range" then
+ local arg
+ if #args <= 1 then
+ arg = args[1]
+ else
+ arg = table.concat(args, " ")
+ end
+
+ if arg then
+ local min = options.min or 0
+ local max = options.max or 1
+ local good = false
+ if type(arg) == "number" then
+ if options.isPercent then
+ arg = arg / 100
+ end
+
+ if arg >= min and arg <= max then
+ good = true
+ end
+
+ if good and type(options.step) == "number" and options.step > 0 then
+ local step = options.step
+ arg = math.floor((arg - min) / step + 0.5) * step + min
+ if arg > max then
+ arg = max
+ elseif arg < min then
+ arg = min
+ end
+ end
+ end
+ if not good then
+ local usage
+ local min = options.min or 0
+ local max = options.max or 1
+ if options.isPercent then
+ min, max = min * 100, max * 100
+ end
+ local bit = "-"
+ if min < 0 or max < 0 then
+ bit = " - "
+ end
+ usage = ("(%s%s%s)"):format(min, bit, max)
+ print((options.error or IS_NOT_A_VALID_VALUE_FOR):format(tostring(arg), path), realOptions.cmdName or realOptions.name or self)
+ print(("|cffffff7f%s:|r %s %s"):format(USAGE, path, usage))
+ return
+ end
+
+ local var
+ if type(options_p.get) == "function" then
+ var = options_p.get(passValue)
+ else
+ if type(handler[options_p.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get)))
+ end
+ var = handler[options_p.get](handler, passValue)
+ end
+
+ if var ~= arg then
+ if type(options_p.set) == "function" then
+ if passValue then
+ options_p.set(passValue, arg)
+ else
+ options_p.set(arg)
+ end
+ else
+ if type(handler[options_p.set]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.set)))
+ end
+ if passValue then
+ handler[options_p.set](handler, passValue, arg)
+ else
+ handler[options_p.set](handler, arg)
+ end
+ end
+ end
+ end
+
+ if arg then
+ local var
+ if type(options_p.get) == "function" then
+ var = options_p.get(passValue)
+ else
+ if type(handler[options_p.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get)))
+ end
+ var = handler[options_p.get](handler, passValue)
+ end
+
+ if var and options.isPercent then
+ var = tostring(var * 100) .. "%"
+ end
+ print((options.message or IS_NOW_SET_TO):format(tostring(options.cmdName or options.name), tostring(var or NONE)), realOptions.cmdName or realOptions.name or self)
+ if var == arg then
+ return
+ end
+ else
+ printUsage(self, handler, realOptions, options, path, args, passValue)
+ return
+ end
+ elseif kind == "color" then
+ if #args > 0 then
+ local r,g,b,a
+ if #args == 1 then
+ local arg = tostring(args[1])
+ if options.hasAlpha then
+ if arg:len() == 8 and arg:find("^%x*$") then
+ r,g,b,a = tonumber(arg:sub(1, 2), 16) / 255, tonumber(arg:sub(3, 4), 16) / 255, tonumber(arg:sub(5, 6), 16) / 255, tonumber(arg:sub(7, 8), 16) / 255
+ end
+ else
+ if arg:len() == 6 and arg:find("^%x*$") then
+ r,g,b = tonumber(arg:sub(1, 2), 16) / 255, tonumber(arg:sub(3, 4), 16) / 255, tonumber(arg:sub(5, 6), 16) / 255
+ end
+ end
+ elseif #args == 4 and options.hasAlpha then
+ local a1,a2,a3,a4 = args[1], args[2], args[3], args[4]
+ if type(a1) == "number" and type(a2) == "number" and type(a3) == "number" and type(a4) == "number" and a1 <= 1 and a2 <= 1 and a3 <= 1 and a4 <= 1 then
+ r,g,b,a = a1,a2,a3,a4
+ elseif (type(a1) == "number" or a1:len() == 2) and a1:find("^%x*$") and (type(a2) == "number" or a2:len() == 2) and a2:find("^%x*$") and (type(a3) == "number" or a3:len() == 2) and a3:find("^%x*$") and (type(a4) == "number" or a4:len() == 2) and a4:find("^%x*$") then
+ r,g,b,a = tonumber(a1, 16) / 255, tonumber(a2, 16) / 255, tonumber(a3, 16) / 255, tonumber(a4, 16) / 255
+ end
+ elseif #args == 3 and not options.hasAlpha then
+ local a1,a2,a3 = args[1], args[2], args[3]
+ if type(a1) == "number" and type(a2) == "number" and type(a3) == "number" and a1 <= 1 and a2 <= 1 and a3 <= 1 then
+ r,g,b = a1,a2,a3
+ elseif (type(a1) == "number" or a1:len() == 2) and a1:find("^%x*$") and (type(a2) == "number" or a2:len() == 2) and a2:find("^%x*$") and (type(a3) == "number" or a3:len() == 2) and a3:find("^%x*$") then
+ r,g,b = tonumber(a1, 16) / 255, tonumber(a2, 16) / 255, tonumber(a3, 16) / 255
+ end
+ end
+ if not r then
+ print((options.error or IS_NOT_A_VALID_OPTION_FOR):format(table.concat(args, ' '), path), realOptions.cmdName or realOptions.name or self)
+ print(("|cffffff7f%s:|r %s {0-1} {0-1} {0-1}%s"):format(USAGE, path, options.hasAlpha and " {0-1}" or ""))
+ return
+ end
+
+ if type(options_p.set) == "function" then
+ if passValue then
+ options_p.set(passValue, r,g,b,a)
+ else
+ options_p.set(r,g,b,a)
+ end
+ else
+ if type(handler[options_p.set]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.set)))
+ end
+ if passValue then
+ handler[options_p.set](handler, passValue, r,g,b,a)
+ else
+ handler[options_p.set](handler, r,g,b,a)
+ end
+ end
+
+ local r,g,b,a
+ if type(options_p.get) == "function" then
+ r,g,b,a = options_p.get(passValue)
+ else
+ if type(handler[options_p.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get)))
+ end
+ r,g,b,a = handler[options_p.get](handler, passValue)
+ end
+
+ local s
+ if type(r) == "number" and type(g) == "number" and type(b) == "number" then
+ if options.hasAlpha and type(a) == "number" then
+ s = ("|c%02x%02x%02x%02x%02x%02x%02x%02x|r"):format(a*255, r*255, g*255, b*255, r*255, g*255, b*255, a*255)
+ else
+ s = ("|cff%02x%02x%02x%02x%02x%02x|r"):format(r*255, g*255, b*255, r*255, g*255, b*255)
+ end
+ else
+ s = NONE
+ end
+ print((options.message or IS_NOW_SET_TO):format(tostring(options.cmdName or options.name), s), realOptions.cmdName or realOptions.name or self)
+ else
+ local r,g,b,a
+ if type(options_p.get) == "function" then
+ r,g,b,a = options_p.get(passValue)
+ else
+ if type(handler[options_p.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get)))
+ end
+ r,g,b,a = handler[options_p.get](handler, passValue)
+ end
+
+ if not colorTable then
+ colorTable = {}
+ local t = colorTable
+
+ if ColorPickerOkayButton then
+ local ColorPickerOkayButton_OnClick = ColorPickerOkayButton:GetScript("OnClick")
+ ColorPickerOkayButton:SetScript("OnClick", function()
+ if ColorPickerOkayButton_OnClick then
+ ColorPickerOkayButton_OnClick()
+ end
+ if t.active then
+ ColorPickerFrame.cancelFunc = nil
+ ColorPickerFrame.func = nil
+ ColorPickerFrame.opacityFunc = nil
+ local r,g,b,a
+ if t.passValue then
+ if type(t.get) == "function" then
+ r,g,b,a = t.get(t.passValue)
+ else
+ if type(t.handler[t.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(t.get)))
+ end
+ r,g,b,a = t.handler[t.get](t.handler, t.passValue)
+ end
+ else
+ if type(t.get) == "function" then
+ r,g,b,a = t.get()
+ else
+ if type(t.handler[t.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(t.get)))
+ end
+ r,g,b,a = t.handler[t.get](t.handler)
+ end
+ end
+ if r ~= t.r or g ~= t.g or b ~= t.b or (t.hasAlpha and a ~= t.a) then
+ local s
+ if type(r) == "number" and type(g) == "number" and type(b) == "number" then
+ if t.hasAlpha and type(a) == "number" then
+ s = ("|c%02x%02x%02x%02x%02x%02x%02x%02x|r"):format(a*255, r*255, g*255, b*255, r*255, g*255, b*255, a*255)
+ else
+ s = ("|cff%02x%02x%02x%02x%02x%02x|r"):format(r*255, g*255, b*255, r*255, g*255, b*255)
+ end
+ else
+ s = NONE
+ end
+ print(t.message:format(tostring(t.name), s), t.realOptions.cmdName or t.realOptions.name or self)
+ end
+ for k,v in pairs(t) do
+ t[k] = nil
+ end
+ end
+ end)
+ end
+ else
+ for k,v in pairs(colorTable) do
+ colorTable[k] = nil
+ end
+ end
+
+ if type(r) ~= "number" or type(g) ~= "number" or type(b) ~= "number" then
+ r,g,b = 1, 1, 1
+ end
+ if type(a) ~= "number" then
+ a = 1
+ end
+ local t = colorTable
+ t.r = r
+ t.g = g
+ t.b = b
+ if hasAlpha then
+ t.a = a
+ end
+ t.realOptions = realOptions
+ t.hasAlpha = options.hasAlpha
+ t.handler = handler
+ t.set = options_p.set
+ t.get = options_p.get
+ t.name = options.cmdName or options.name
+ t.message = options.message or IS_NOW_SET_TO
+ t.passValue = passValue
+ t.active = true
+
+ if not colorFunc then
+ colorFunc = function()
+ local r,g,b = ColorPickerFrame:GetColorRGB()
+ if t.hasAlpha then
+ local a = 1 - OpacitySliderFrame:GetValue()
+ if type(t.set) == "function" then
+ if t.passValue then
+ t.set(t.passValue, r,g,b,a)
+ else
+ t.set(r,g,b,a)
+ end
+ else
+ if type(t.handler[t.set]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(t.set)))
+ end
+ if t.passValue then
+ t.handler[t.set](t.handler, t.passValue, r,g,b,a)
+ else
+ t.handler[t.set](t.handler, r,g,b,a)
+ end
+ end
+ else
+ if type(t.set) == "function" then
+ if t.passValue then
+ t.set(t.passValue, r,g,b)
+ else
+ t.set(r,g,b)
+ end
+ else
+ if type(t.handler[t.set]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(t.set)))
+ end
+ if t.passValue then
+ t.handler[t.set](t.handler, t.passValue, r,g,b)
+ else
+ t.handler[t.set](t.handler, r,g,b)
+ end
+ end
+ end
+ end
+ end
+
+ ColorPickerFrame.func = colorFunc
+ ColorPickerFrame.hasOpacity = options.hasAlpha
+ if options.hasAlpha then
+ ColorPickerFrame.opacityFunc = ColorPickerFrame.func
+ ColorPickerFrame.opacity = 1 - a
+ end
+ ColorPickerFrame:SetColorRGB(r,g,b)
+
+ if not colorCancelFunc then
+ colorCancelFunc = function()
+ if t.hasAlpha then
+ if type(t.set) == "function" then
+ if t.passValue then
+ t.set(t.passValue, t.r,t.g,t.b,t.a)
+ else
+ t.set(t.r,t.g,t.b,t.a)
+ end
+ else
+ if type(t.handler[t.get]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(t.get)))
+ end
+ if t.passValue then
+ t.handler[t.set](t.handler, t.passValue, t.r,t.g,t.b,t.a)
+ else
+ t.handler[t.set](t.handler, t.r,t.g,t.b,t.a)
+ end
+ end
+ else
+ if type(t.set) == "function" then
+ if t.passValue then
+ t.set(t.passValue, t.r,t.g,t.b)
+ else
+ t.set(t.r,t.g,t.b)
+ end
+ else
+ if type(t.handler[t.set]) ~= "function" then
+ AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(t.set)))
+ end
+ if t.passValue then
+ t.handler[t.set](t.handler, t.passValue, t.r,t.g,t.b)
+ else
+ t.handler[t.set](t.handler, t.r,t.g,t.b)
+ end
+ end
+ end
+ for k,v in pairs(t) do
+ t[k] = nil
+ end
+ ColorPickerFrame.cancelFunc = nil
+ ColorPickerFrame.func = nil
+ ColorPickerFrame.opacityFunc = nil
+ end
+ end
+
+ ColorPickerFrame.cancelFunc = colorCancelFunc
+
+ ShowUIPanel(ColorPickerFrame)
+ end
+ return
+ elseif kind == "group" then
+ if #args == 0 then
+ printUsage(self, handler, realOptions, options, path, args, passValue)
+ else
+ -- invalid argument
+ print((options.error or IS_NOT_A_VALID_OPTION_FOR):format(args[1], path), realOptions.cmdName or realOptions.name or self)
+ end
+ return
+ end
+ if Dewdrop then
+ Dewdrop:Refresh()
+ end
+end
+
+local external
+local tmp
+function AceConsole:RegisterChatCommand(...) -- slashCommands, options, name
+ local slashCommands, options, name
+ if type((...)) == "string" then
+ if not tmp then
+ tmp = {}
+ else
+ for i in ipairs(tmp) do
+ tmp[i] = nil
+ end
+ end
+ for i = 1, select('#', ...)+1 do
+ local v = select(i, ...)
+ if type(v) == "string" then
+ tmp[#tmp+1] = v
+ else
+ slashCommands = tmp
+ options = v
+ name = select(i+1, ...)
+ break
+ end
+ end
+ else
+ slashCommands, options, name = ...
+ end
+ if type(slashCommands) ~= "table" and slashCommands ~= false then
+ AceConsole:error("Bad argument #2 to `RegisterChatCommand' (expected table, got %s)", type(slashCommands))
+ end
+ if not slashCommands and type(name) ~= "string" then
+ AceConsole:error("Bad argument #4 to `RegisterChatCommand' (expected string, got %s)", type(name))
+ end
+ if type(options) ~= "table" and type(options) ~= "function" and options ~= nil then
+ AceConsole:error("Bad argument #3 to `RegisterChatCommand' (expected table, function, or nil, got %s)", type(options))
+ end
+ if name then
+ if type(name) ~= "string" then
+ AceConsole:error("Bad argument #4 to `RegisterChatCommand' (expected string or nil, got %s)", type(name))
+ elseif not name:find("^%w+$") or name:upper() ~= name or name:len() == 0 then
+ AceConsole:error("Argument #4 must be an uppercase, letters-only string with at least 1 character")
+ end
+ end
+ if slashCommands then
+ if #slashCommands == 0 then
+ AceConsole:error("Argument #2 to `RegisterChatCommand' must include at least one string")
+ end
+
+ for k,v in pairs(slashCommands) do
+ if type(k) ~= "number" then
+ AceConsole:error("All keys in argument #2 to `RegisterChatCommand' must be numbers")
+ end
+ if type(v) ~= "string" then
+ AceConsole:error("All values in argument #2 to `RegisterChatCommand' must be strings")
+ elseif not v:find("^/[A-Za-z][A-Za-z0-9_]*$") then
+ AceConsole:error("All values in argument #2 to `RegisterChatCommand' must be in the form of \"/word\"")
+ end
+ end
+ end
+
+ if not options then
+ options = {
+ type = 'group',
+ args = {},
+ handler = self
+ }
+ end
+
+ if type(options) == "table" then
+ local err, position = validateOptions(options)
+ if err then
+ if position then
+ AceConsole:error(position .. ": " .. err)
+ else
+ AceConsole:error(err)
+ end
+ end
+
+ if not options.handler then
+ options.handler = self
+ end
+
+ if options.handler == self and options.type:lower() == "group" and self.class then
+ AceConsole:InjectAceOptionsTable(self, options)
+ end
+ end
+
+ local chat
+ if slashCommands then
+ chat = slashCommands[1]
+ else
+ chat = _G["SLASH_"..name..1]
+ end
+
+ local handler
+ if type(options) == "function" then
+ handler = options
+ for k,v in pairs(_G) do
+ if handler == v then
+ handler = function(msg, chatFrame)
+ return _G[k](msg, chatFrame)
+ end
+ break
+ end
+ end
+ else
+ function handler(msg, chatFrame)
+ handlerFunc(self, chat, msg, options)
+ end
+ end
+
+ if not _G.SlashCmdList then
+ _G.SlashCmdList = {}
+ end
+
+ if not name and type(slashCommands) == "table" and type(slashCommands[1]) == "string" then
+ name = slashCommands[1]:gsub("%A", ""):upper()
+ end
+
+ if not name then
+ local A = ('A'):byte()
+ repeat
+ name = string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1)
+ until not _G.SlashCmdList[name]
+ end
+
+ if slashCommands then
+ if _G.SlashCmdList[name] then
+ local i = 0
+ while true do
+ i = i + 1
+ if _G["SLASH_"..name..i] then
+ _G["SLASH_"..name..i] = nil
+ else
+ break
+ end
+ end
+ end
+
+ local i = 0
+ for _,command in ipairs(slashCommands) do
+ i = i + 1
+ _G["SLASH_"..name..i] = command
+ if command:lower() ~= command then
+ i = i + 1
+ _G["SLASH_"..name..i] = command:lower()
+ end
+ end
+ end
+ _G.SlashCmdList[name] = handler
+ if self ~= AceConsole and self.slashCommand == nil then
+ self.slashCommand = chat
+ end
+
+ if not AceEvent and AceLibrary:HasInstance("AceEvent-2.0") then
+ external(AceConsole, "AceEvent-2.0", AceLibrary("AceEvent-2.0"))
+ end
+ if AceEvent then
+ if not AceConsole.nextAddon then
+ AceConsole.nextAddon = {}
+ end
+ if type(options) == "table" then
+ AceConsole.nextAddon[self] = options
+ if not self.playerLogin then
+ AceConsole:RegisterEvent("PLAYER_LOGIN", "PLAYER_LOGIN", true)
+ end
+ end
+ end
+
+ AceConsole.registry[name] = options
+
+ if slashCommands == tmp then
+ for i in ipairs(tmp) do
+ tmp[i] = nil
+ end
+ end
+end
+
+function AceConsole:InjectAceOptionsTable(handler, options)
+ self:argCheck(handler, 2, "table")
+ self:argCheck(options, 3, "table")
+ if options.type:lower() ~= "group" then
+ self:error('Cannot inject into options table argument #3 if its type is not "group"')
+ end
+ if options.handler ~= nil and options.handler ~= handler then
+ self:error("Cannot inject into options table argument #3 if it has a different handler than argument #2")
+ end
+ options.handler = handler
+ local class = handler.class
+ if not AceLibrary:HasInstance("AceOO-2.0") or not class then
+ if Rock then
+ -- possible Rock object
+ for mixin in Rock:IterateObjectMixins(handler) do
+ if type(mixin.GetAceOptionsDataTable) == "function" then
+ local t = mixin:GetAceOptionsDataTable(handler)
+ for k,v in pairs(t) do
+ if type(options.args) ~= "table" then
+ options.args = {}
+ end
+ if options.args[k] == nil then
+ options.args[k] = v
+ end
+ end
+ end
+ end
+ end
+ else
+ -- Ace2 object
+ while class and class ~= AceLibrary("AceOO-2.0").Class do
+ if type(class.GetAceOptionsDataTable) == "function" then
+ local t = class:GetAceOptionsDataTable(handler)
+ for k,v in pairs(t) do
+ if type(options.args) ~= "table" then
+ options.args = {}
+ end
+ if options.args[k] == nil then
+ options.args[k] = v
+ end
+ end
+ end
+ local mixins = class.mixins
+ if mixins then
+ for mixin in pairs(mixins) do
+ if type(mixin.GetAceOptionsDataTable) == "function" then
+ local t = mixin:GetAceOptionsDataTable(handler)
+ for k,v in pairs(t) do
+ if type(options.args) ~= "table" then
+ options.args = {}
+ end
+ if options.args[k] == nil then
+ options.args[k] = v
+ end
+ end
+ end
+ end
+ end
+ class = class.super
+ end
+ end
+
+ return options
+end
+
+function AceConsole:PLAYER_LOGIN()
+ self.playerLogin = true
+ for addon, options in pairs(self.nextAddon) do
+ local err, position = validateOptionsMethods(addon, options)
+ if err then
+ if position then
+ geterrorhandler()(tostring(addon) .. ": AceConsole: " .. position .. ": " .. err)
+ else
+ geterrorhandler()(tostring(addon) .. ": AceConsole: " .. err)
+ end
+ end
+ self.nextAddon[addon] = nil
+ end
+end
+
+function AceConsole:TabCompleteInfo(cmdpath)
+ local cmd = cmdpath:match("(/%S+)")
+ if not cmd then
+ return
+ end
+ local path = cmdpath:sub(cmd:len() + 2)
+ for name in pairs(SlashCmdList) do --global
+ if AceConsole.registry[name] then
+ local i = 0
+ while true do
+ i = i + 1
+ local scmd = _G["SLASH_"..name..i]
+ if not scmd then break end
+ if cmd == scmd then
+ return name, cmd, path
+ end
+ end
+ end
+ end
+end
+
+function external(self, major, instance)
+ if major == "AceEvent-2.0" then
+ if not AceEvent then
+ AceEvent = instance
+
+ AceEvent:embed(self)
+ end
+ elseif major == "AceTab-2.0" then
+ instance:RegisterTabCompletion("AceConsole", "%/.*", function(t, cmdpath, pos)
+ local name, cmd, path = self:TabCompleteInfo(cmdpath:sub(1, pos))
+
+ if not self.registry[name] then
+ return false
+ else
+ local validArgs, _, _, handler = findTableLevel(self, self.registry[name], cmd, path or "")
+ if validArgs.args then
+ for arg, v in pairs(validArgs.args) do
+ local hidden = v.hidden
+ local handler = v.handler or handler
+ if hidden then
+ if type(hidden) == "function" then
+ hidden = hidden(v.passValue)
+ elseif type(hidden) == "string" then
+ local f = hidden
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ if type(handler[f]) ~= "function" then
+ self:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ hidden = handler[f](handler, v.passValue)
+ if neg then
+ hidden = not hidden
+ end
+ end
+ end
+ local disabled = hidden or v.disabled
+ if disabled then
+ if type(disabled) == "function" then
+ disabled = disabled(v.passValue)
+ elseif type(disabled) == "string" then
+ local f = disabled
+ local neg = f:match("^~(.-)$")
+ if neg then
+ f = neg
+ end
+ if type(handler[f]) ~= "function" then
+ self:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f)))
+ end
+ disabled = handler[f](handler, v.passValue)
+ if neg then
+ disabled = not disabled
+ end
+ end
+ end
+ if not hidden and not disabled and v.type ~= "header" then
+ table.insert(t, (tostring(arg):gsub("%s", "-")))
+ end
+ end
+ end
+ end
+ end, function(u, matches, gcs, cmdpath)
+ local name, cmd, path = self:TabCompleteInfo(cmdpath)
+ if self.registry[name] then
+ local validArgs, path2, argwork, handler = findTableLevel(self, self.registry[name], cmd, path)
+ printUsage(self, validArgs.handler or handler, self.registry[name], validArgs, path2, argwork, argwork[#argwork], not gcs or gcs ~= "", gcs)
+ end
+ end)
+ elseif major == "Dewdrop-2.0" then
+ Dewdrop = instance
+ end
+end
+
+local function activate(self, oldLib, oldDeactivate)
+ AceConsole = self
+
+ if oldLib then
+ self.registry = oldLib.registry
+ self.nextAddon = oldLib.nextAddon
+ end
+
+ if not self.registry then
+ self.registry = {}
+ else
+ for name,options in pairs(self.registry) do
+ self:RegisterChatCommand(false, options, name)
+ end
+ end
+
+ self:RegisterChatCommand("/reload", "/rl", "/reloadui", ReloadUI, "RELOAD")
+ self:RegisterChatCommand("/gm", ToggleHelpFrame, "GM")
+ local t = { "/print", "/echo" }
+ local _,_,_,enabled,loadable = GetAddOnInfo("DevTools")
+ if not enabled and not loadable then
+ table.insert(t, "/dump")
+ end
+ self:RegisterChatCommand(t, function(text)
+ text = text:trim():match("^(.-);*$")
+ local f, err = loadstring("AceLibrary('AceConsole-2.0'):PrintLiteral(" .. text .. ")")
+ if not f then
+ self:Print("|cffff0000Error:|r", err)
+ else
+ f()
+ end
+ end, "PRINT")
+
+ self:activate(oldLib, oldDeactivate)
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+AceLibrary:Register(AceConsole, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)
diff --git a/FuBar_DurabilityFu/libs/AceConsole-2.0/AceConsole-2.0.toc b/FuBar_DurabilityFu/libs/AceConsole-2.0/AceConsole-2.0.toc
new file mode 100644
index 0000000..0d5662b
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceConsole-2.0/AceConsole-2.0.toc
@@ -0,0 +1,16 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r1098
+## X-Curse-Project-Name: Ace2
+## X-Curse-Project-ID: ace2
+## X-Curse-Repository-ID: wow/ace2/mainline
+
+## Title: Lib: AceConsole-2.0
+## Notes: AddOn development framework
+## Author: Ace Development Team
+## LoadOnDemand: 1
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-License: LGPL v2.1 + MIT for AceOO-2.0
+## Dependencies: AceLibrary, AceEvent-2.0, AceOO-2.0
+
+AceConsole-2.0.lua
diff --git a/FuBar_DurabilityFu/libs/AceDB-2.0/AceDB-2.0.lua b/FuBar_DurabilityFu/libs/AceDB-2.0/AceDB-2.0.lua
new file mode 100644
index 0000000..1d8ffc3
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceDB-2.0/AceDB-2.0.lua
@@ -0,0 +1,2222 @@
+--[[
+Name: AceDB-2.0
+Revision: $Rev: 1094 $
+Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team)
+Inspired By: Ace 1.x by Turan (turan@gryphon.com)
+Website: http://www.wowace.com/
+Documentation: http://www.wowace.com/index.php/AceDB-2.0
+SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceDB-2.0
+Description: Mixin to allow for fast, clean, and featureful saved variable
+ access.
+Dependencies: AceLibrary, AceOO-2.0, AceEvent-2.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "AceDB-2.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 1094 $"):match("(%d+)"))
+
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+if not AceLibrary:HasInstance("AceOO-2.0") then error(MAJOR_VERSION .. " requires AceOO-2.0") end
+
+local function safecall(func,...)
+ local success, err = pcall(func,...)
+ if not success then geterrorhandler()(err) end
+end
+
+local ACTIVE, ENABLED, STATE, TOGGLE_ACTIVE, MAP_ACTIVESUSPENDED, SET_PROFILE, SET_PROFILE_USAGE, PROFILE, PLAYER_OF_REALM, CHOOSE_PROFILE_DESC, CHOOSE_PROFILE_GUI, COPY_PROFILE_DESC, COPY_PROFILE_GUI, OTHER_PROFILE_DESC, OTHER_PROFILE_GUI, OTHER_PROFILE_USAGE, RESET_PROFILE, RESET_PROFILE_DESC, CHARACTER_COLON, REALM_COLON, CLASS_COLON, DEFAULT, ALTERNATIVE
+
+-- Move these into "enUS" when they've been translated in all other locales
+local DELETE_PROFILE = "Delete"
+local DELETE_PROFILE_DESC = "Deletes a profile. Note that no check is made whether this profile is in use by other characters or not."
+local DELETE_PROFILE_USAGE = ""
+
+if GetLocale() == "deDE" then
+ DELETE_PROFILE = "L\195\182schen"
+ DELETE_PROFILE_DESC = "L\195\182scht ein Profil. Beachte das nicht \195\188berpr\195\188ft wird ob das zu l\195\182schende Profil von anderen Charakteren genutzt wird oder nicht."
+ DELETE_PROFILE_USAGE = ""
+
+ ACTIVE = "Aktiv"
+ ENABLED = "Aktiviert"
+ STATE = "Status"
+ TOGGLE_ACTIVE = "Stoppt/Aktiviert dieses Addon."
+ MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00Aktiv|r", [false] = "|cffff0000Gestoppt|r" }
+ SET_PROFILE = "Setzt das Profil f\195\188r dieses Addon."
+ SET_PROFILE_USAGE = "{Charakter || Klasse || Realm || }"
+ PROFILE = "Profil"
+ PLAYER_OF_REALM = "%s von %s"
+ CHOOSE_PROFILE_DESC = "W\195\164hle ein Profil."
+ CHOOSE_PROFILE_GUI = "W\195\164hle"
+ COPY_PROFILE_DESC = "Kopiert Einstellungen von einem anderem Profil."
+ COPY_PROFILE_GUI = "Kopiere von"
+ OTHER_PROFILE_DESC = "W\195\164hle ein anderes Profil."
+ OTHER_PROFILE_GUI = "Anderes"
+ OTHER_PROFILE_USAGE = ""
+ RESET_PROFILE = "Resette das Profil"
+ RESET_PROFILE_DESC = "Entfernt alle Einstellungen des gegenw\195\164rtigen Profils."
+
+ CHARACTER_COLON = "Charakter: "
+ REALM_COLON = "Realm: "
+ CLASS_COLON = "Klasse: "
+
+ DEFAULT = "Vorgabe"
+ ALTERNATIVE = "Alternativ"
+elseif GetLocale() == "frFR" then
+ ACTIVE = "Actif"
+ ENABLED = "Activ\195\169"
+ STATE = "Etat"
+ TOGGLE_ACTIVE = "Suspend/active cet addon."
+ MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00Actif|r", [false] = "|cffff0000Suspendu|r" }
+ SET_PROFILE = "S\195\169lectionne le profil pour cet addon."
+ SET_PROFILE_USAGE = "{perso || classe || royaume || }"
+ PROFILE = "Profil"
+ PLAYER_OF_REALM = "%s de %s"
+ CHOOSE_PROFILE_DESC = "Choisissez un profil."
+ CHOOSE_PROFILE_GUI = "Choix"
+ COPY_PROFILE_DESC = "Copier les param\195\168tres d'un autre profil."
+ COPY_PROFILE_GUI = "Copier \195\160 partir de"
+ OTHER_PROFILE_DESC = "Choisissez un autre profil."
+ OTHER_PROFILE_GUI = "Autre"
+ OTHER_PROFILE_USAGE = ""
+ RESET_PROFILE = "Reset profile" -- fix
+ RESET_PROFILE_DESC = "Clear all settings of the current profile." -- fix
+
+ CHARACTER_COLON = "Personnage: "
+ REALM_COLON = "Royaume: "
+ CLASS_COLON = "Classe: "
+
+ DEFAULT = "Default" -- fix
+ ALTERNATIVE = "Alternative" -- fix
+elseif GetLocale() == "koKR" then
+ DELETE_PROFILE = "삭제"
+ DELETE_PROFILE_DESC = "프로필을 삭제합니다."
+ DELETE_PROFILE_USAGE = "<프로필명>"
+
+ ACTIVE = "사용"
+ ENABLED = "사용"
+ STATE = "상태"
+ TOGGLE_ACTIVE = "이 애드온 중지/다시 시작"
+ MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00사용|r", [false] = "|cffff0000중지|r" }
+ SET_PROFILE = "이 애드온에 프로필 설정"
+ SET_PROFILE_USAGE = "{캐릭터명 || 직업 || 서버명 || <프로필명>}"
+ PROFILE = "프로필"
+ PLAYER_OF_REALM = "%s (%s 서버)"
+ CHOOSE_PROFILE_DESC = "프로필을 선택합니다."
+ CHOOSE_PROFILE_GUI = "선택"
+ COPY_PROFILE_DESC = "다른 프로필 설정을 복사합니다."
+ COPY_PROFILE_GUI = "복사"
+ OTHER_PROFILE_DESC = "다른 프로필을 선택합니다."
+ OTHER_PROFILE_GUI = "기타"
+ OTHER_PROFILE_USAGE = "<프로필명>"
+ RESET_PROFILE = "프로필 초기화"
+ RESET_PROFILE_DESC = "모든 세팅에서 현재 프로필을 초기화 합니다."
+
+ CHARACTER_COLON = "캐릭터: "
+ REALM_COLON = "서버: "
+ CLASS_COLON = "직업: "
+
+ DEFAULT = "기본값"
+ ALTERNATIVE = "대체"
+elseif GetLocale() == "zhTW" then
+ DELETE_PROFILE = "刪除"
+ DELETE_PROFILE_DESC = "刪除記錄檔。注意,有可能別的角色也使用這個記錄檔。"
+ DELETE_PROFILE_USAGE = "<記錄檔名稱>"
+
+ ACTIVE = "啟動"
+ ENABLED = "啟用"
+ STATE = "狀態"
+ TOGGLE_ACTIVE = "暫停/繼續使用這個插件。"
+ MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00啟動|r", [false] = "|cffff0000已暫停|r" }
+ SET_PROFILE = "設定這插件的記錄檔。"
+ SET_PROFILE_USAGE = "{角色 || 職業 || 伺服器 || <記錄檔名稱>}"
+ PROFILE = "記錄檔"
+ PLAYER_OF_REALM = "%s - %s"
+ CHOOSE_PROFILE_DESC = "選擇一個記錄檔。"
+ CHOOSE_PROFILE_GUI = "選擇"
+ COPY_PROFILE_DESC = "由其他記錄檔複製設定。"
+ COPY_PROFILE_GUI = "複製自"
+ OTHER_PROFILE_DESC = "選擇其他記錄檔。"
+ OTHER_PROFILE_GUI = "其他"
+ OTHER_PROFILE_USAGE = "<記錄檔名稱>"
+ RESET_PROFILE = "重設記錄檔"
+ RESET_PROFILE_DESC = "清除目前的記錄檔上的所有設定。"
+
+ CHARACTER_COLON = "角色: "
+ REALM_COLON = "伺服器: "
+ CLASS_COLON = "職業: "
+
+ DEFAULT = "預設"
+ ALTERNATIVE = "替代"
+elseif GetLocale() == "zhCN" then
+ ACTIVE = "\230\156\137\230\149\136"
+ ENABLED = "\229\144\175\231\148\168"
+ STATE = "\231\138\182\230\128\129"
+ TOGGLE_ACTIVE = "\230\154\130\229\129\156/\230\129\162\229\164\141 \230\173\164\230\143\146\228\187\182."
+ MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00\230\156\137\230\149\136|r", [false] = "|cffff0000\230\154\130\229\129\156|r" }
+ SET_PROFILE = "\232\174\190\231\189\174\233\133\141\231\189\174\230\150\135\228\187\182\228\184\186\232\191\153\230\143\146\228\187\182."
+ SET_PROFILE_USAGE = "{\229\173\151\231\172\166 || \233\128\137\228\187\182\231\177\187 || \229\159\159 || <\233\133\141\231\189\174\230\150\135\228\187\182\229\144\141\229\173\151>}"
+ PROFILE = "\233\133\141\231\189\174\230\150\135\228\187\182"
+ PLAYER_OF_REALM = "%s \231\154\132 %s"
+ CHOOSE_PROFILE_DESC = "\233\128\137\230\139\169\233\133\141\231\189\174\230\150\135\228\187\182."
+ CHOOSE_PROFILE_GUI = "\233\128\137\230\139\169"
+ COPY_PROFILE_DESC = "\229\164\141\229\136\182\232\174\190\231\189\174\228\187\142\229\143\166\228\184\128\228\184\170\233\133\141\231\189\174\230\150\135\228\187\182."
+ COPY_PROFILE_GUI = "\229\164\141\229\136\182\228\187\142"
+ OTHER_PROFILE_DESC = "\233\128\137\230\139\169\229\143\166\228\184\128\228\184\170\233\133\141\231\189\174\230\150\135\228\187\182."
+ OTHER_PROFILE_GUI = "\229\133\182\228\187\150"
+ OTHER_PROFILE_USAGE = "<\233\133\141\231\189\174\230\150\135\228\187\182\229\144\141\229\173\151>"
+ RESET_PROFILE = "Reset profile" -- fix
+ RESET_PROFILE_DESC = "Clear all settings of the current profile." -- fix
+
+ CHARACTER_COLON = "\229\173\151\231\172\166: "
+ REALM_COLON = "\229\159\159: "
+ CLASS_COLON = "\233\128\137\228\187\182\231\177\187: "
+
+ DEFAULT = "Default" -- fix
+ ALTERNATIVE = "Alternative" -- fix
+elseif GetLocale() == "esES" then
+ ACTIVE = "Activo"
+ ENABLED = "Activado"
+ STATE = "Estado"
+ TOGGLE_ACTIVE = "Parar/Continuar este accesorio"
+ MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00Activo|r", [false] = "|cffff0000Parado|r" }
+ SET_PROFILE = "Selecciona el perfil para este accesorio."
+ SET_PROFILE_USAGE = "{perso || clase || reino || }"
+ PROFILE = "Perfil"
+ PLAYER_OF_REALM = "%s de %s"
+ CHOOSE_PROFILE_DESC = "Elige un perfil."
+ CHOOSE_PROFILE_GUI = "Elige"
+ COPY_PROFILE_DESC = "Copiar de un perfil a otro"
+ COPY_PROFILE_GUI = "Copiar desde"
+ OTHER_PROFILE_DESC = "Elige otro perfil."
+ OTHER_PROFILE_GUI = "Otro"
+ OTHER_PROFILE_USAGE = ""
+ RESET_PROFILE = "Reset profile" -- fix
+ RESET_PROFILE_DESC = "Clear all settings of the current profile." -- fix
+
+ CHARACTER_COLON = "Personaje: "
+ REALM_COLON = "Reino: "
+ CLASS_COLON = "Clase: "
+
+ DEFAULT = "Por defecto"
+ ALTERNATIVE = "Alternativo"
+elseif GetLocale() == "ruRU" then
+ DELETE_PROFILE = "Удалить"
+ DELETE_PROFILE_DESC = "Удалить профиль. Изначально проверьте не используется ли этот профиль другими персонажами, чтобы не натворить себе неудобств."
+ DELETE_PROFILE_USAGE = "<название профиля>"
+
+ ACTIVE = "Активный"
+ ENABLED = "Включён"
+ STATE = "Состояние"
+ TOGGLE_ACTIVE = "Отключить/Запустить аддон."
+ MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00Активный|r", [false] = "|cffff0000Suspended|r" }
+ SET_PROFILE = "Установить профиль для этого аддона."
+ SET_PROFILE_USAGE = "{чар || класс || сервер || <название профиля>}"
+ PROFILE = "Профиль"
+ PLAYER_OF_REALM = "%s из %s"
+ CHOOSE_PROFILE_DESC = "Выберите профиль."
+ CHOOSE_PROFILE_GUI = "Выбор"
+ COPY_PROFILE_DESC = "Скопировать настройки из другого профиля."
+ COPY_PROFILE_GUI = "Скопировать из"
+ OTHER_PROFILE_DESC = "Выбрать другой профиль."
+ OTHER_PROFILE_GUI = "Другое"
+ OTHER_PROFILE_USAGE = "<название профиля>"
+ RESET_PROFILE = "Сброс профиля"
+ RESET_PROFILE_DESC = "Очистить все настройки для текущего профиля."
+
+ CHARACTER_COLON = "Персонаж: "
+ REALM_COLON = "Сервер: "
+ CLASS_COLON = "Класс: "
+
+ DEFAULT = "По-умолчанию"
+ ALTERNATIVE = "Альтернатива"
+else -- enUS
+ ACTIVE = "Active"
+ ENABLED = "Enabled"
+ STATE = "State"
+ TOGGLE_ACTIVE = "Suspend/resume this addon."
+ MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00Active|r", [false] = "|cffff0000Suspended|r" }
+ SET_PROFILE = "Set profile for this addon."
+ SET_PROFILE_USAGE = "{char || class || realm || }"
+ PROFILE = "Profile"
+ PLAYER_OF_REALM = "%s of %s"
+ CHOOSE_PROFILE_DESC = "Choose a profile."
+ CHOOSE_PROFILE_GUI = "Choose"
+ COPY_PROFILE_DESC = "Copy settings from another profile."
+ COPY_PROFILE_GUI = "Copy from"
+ OTHER_PROFILE_DESC = "Choose another profile."
+ OTHER_PROFILE_GUI = "Other"
+ OTHER_PROFILE_USAGE = ""
+ RESET_PROFILE = "Reset profile"
+ RESET_PROFILE_DESC = "Clear all settings of the current profile."
+
+ CHARACTER_COLON = "Character: "
+ REALM_COLON = "Realm: "
+ CLASS_COLON = "Class: "
+
+ DEFAULT = "Default"
+ ALTERNATIVE = "Alternative"
+end
+local convertFromOldCharID
+do
+ local matchStr = "^" .. PLAYER_OF_REALM:gsub("([%(%)%.%*%+%-%[%]%?%^%$%%])", "%%%1"):gsub("%%s", "(.+)") .. "$"
+ function convertFromOldCharID(str)
+ local player, realm = str:match(matchStr)
+ if not player then
+ return str
+ end
+ return player .. " - " .. realm
+ end
+end
+
+local AceOO = AceLibrary("AceOO-2.0")
+local AceEvent
+local Mixin = AceOO.Mixin
+local AceDB = Mixin {
+ "RegisterDB",
+ "RegisterDefaults",
+ "ResetDB",
+ "SetProfile",
+ "GetProfile",
+ "CopyProfileFrom",
+ "DeleteProfile",
+ "ToggleActive",
+ "IsActive",
+ "AcquireDBNamespace",
+ }
+local Dewdrop = AceLibrary:HasInstance("Dewdrop-2.0") and AceLibrary("Dewdrop-2.0")
+
+local _G = getfenv(0)
+
+local function inheritDefaults(t, defaults)
+ if not defaults then
+ return t
+ end
+ for k,v in pairs(defaults) do
+ if k == "*" or k == "**" then
+ local v = v
+ if type(v) == "table" then
+ setmetatable(t, {
+ __index = function(self, key)
+ if key == nil then
+ return nil
+ end
+ self[key] = {}
+ inheritDefaults(self[key], v)
+ return self[key]
+ end
+ } )
+ else
+ setmetatable(t, {
+ __index = function(self, key)
+ if key == nil then
+ return nil
+ end
+ self[key] = v
+ return self[key]
+ end
+ } )
+ end
+ for key in pairs(t) do
+ if (defaults[key] == nil or key == k) and type(t[key]) == "table" then
+ inheritDefaults(t[key], v)
+ end
+ end
+ else
+ if type(v) == "table" then
+ if type(rawget(t, k)) ~= "table" then
+ t[k] = {}
+ end
+ inheritDefaults(t[k], v)
+ if defaults["**"] then
+ inheritDefaults(t[k], defaults["**"])
+ end
+ elseif rawget(t, k) == nil then
+ t[k] = v
+ end
+ end
+ end
+ return t
+end
+
+local _,race = UnitRace("player")
+local faction
+if race == "Orc" or race == "Scourge" or race == "Troll" or race == "Tauren" or race == "BloodElf" then
+ faction = FACTION_HORDE
+else
+ faction = FACTION_ALLIANCE
+end
+local server = GetRealmName():trim()
+local charID = UnitName("player") .. " - " .. server
+local realmID = server .. " - " .. faction
+local classID = UnitClass("player")
+
+AceDB.CHAR_ID = charID
+AceDB.REALM_ID = realmID
+AceDB.CLASS_ID = classID
+
+AceDB.FACTION = faction
+AceDB.REALM = server
+AceDB.NAME = UnitName("player")
+
+local new, del
+do
+ local list = setmetatable({}, {__mode="k"})
+ function new()
+ local t = next(list)
+ if t then
+ list[t] = nil
+ return t
+ else
+ return {}
+ end
+ end
+
+ function del(t)
+ setmetatable(t, nil)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ list[t] = true
+ end
+end
+
+local caseInsensitive_mt = {
+ __index = function(self, key)
+ if type(key) ~= "string" then
+ return nil
+ end
+ local lowerKey = key:lower()
+ for k,v in pairs(self) do
+ if k:lower() == lowerKey then
+ return self[k]
+ end
+ end
+ end,
+ __newindex = function(self, key, value)
+ if type(key) ~= "string" then
+ return error("table index is nil", 2)
+ end
+ local lowerKey = key:lower()
+ for k in pairs(self) do
+ if k:lower() == lowerKey then
+ rawset(self, k, nil)
+ rawset(self, key, value)
+ return
+ end
+ end
+ rawset(self, key, value)
+ end
+}
+
+local db_mt = { __index = function(db, key)
+ if key == "char" then
+ if db.charName then
+ if type(_G[db.charName]) ~= "table" then
+ _G[db.charName] = {}
+ end
+ if type(_G[db.charName].global) ~= "table" then
+ _G[db.charName].global = {}
+ end
+ rawset(db, 'char', _G[db.charName].global)
+ else
+ if type(db.raw.chars) ~= "table" then
+ db.raw.chars = {}
+ end
+ local id = charID
+ if type(db.raw.chars[id]) ~= "table" then
+ db.raw.chars[id] = {}
+ end
+ rawset(db, 'char', db.raw.chars[id])
+ end
+ if db.defaults and db.defaults.char then
+ inheritDefaults(db.char, db.defaults.char)
+ end
+ return db.char
+ elseif key == "realm" then
+ if type(db.raw.realms) ~= "table" then
+ db.raw.realms = {}
+ end
+ local id = realmID
+ if type(db.raw.realms[id]) ~= "table" then
+ db.raw.realms[id] = {}
+ end
+ rawset(db, 'realm', db.raw.realms[id])
+ if db.defaults and db.defaults.realm then
+ inheritDefaults(db.realm, db.defaults.realm)
+ end
+ return db.realm
+ elseif key == "server" then
+ if type(db.raw.servers) ~= "table" then
+ db.raw.servers = {}
+ end
+ local id = server
+ if type(db.raw.servers[id]) ~= "table" then
+ db.raw.servers[id] = {}
+ end
+ rawset(db, 'server', db.raw.servers[id])
+ if db.defaults and db.defaults.server then
+ inheritDefaults(db.server, db.defaults.server)
+ end
+ return db.server
+ elseif key == "account" then
+ if type(db.raw.account) ~= "table" then
+ db.raw.account = {}
+ end
+ rawset(db, 'account', db.raw.account)
+ if db.defaults and db.defaults.account then
+ inheritDefaults(db.account, db.defaults.account)
+ end
+ return db.account
+ elseif key == "faction" then
+ if type(db.raw.factions) ~= "table" then
+ db.raw.factions = {}
+ end
+ local id = faction
+ if type(db.raw.factions[id]) ~= "table" then
+ db.raw.factions[id] = {}
+ end
+ rawset(db, 'faction', db.raw.factions[id])
+ if db.defaults and db.defaults.faction then
+ inheritDefaults(db.faction, db.defaults.faction)
+ end
+ return db.faction
+ elseif key == "class" then
+ if type(db.raw.classes) ~= "table" then
+ db.raw.classes = {}
+ end
+ local id = classID
+ if type(db.raw.classes[id]) ~= "table" then
+ db.raw.classes[id] = {}
+ end
+ rawset(db, 'class', db.raw.classes[id])
+ if db.defaults and db.defaults.class then
+ inheritDefaults(db.class, db.defaults.class)
+ end
+ return db.class
+ elseif key == "profile" then
+ if type(db.raw.profiles) ~= "table" then
+ db.raw.profiles = setmetatable({}, caseInsensitive_mt)
+ else
+ setmetatable(db.raw.profiles, caseInsensitive_mt)
+ end
+ local id = db.raw.currentProfile[charID]
+ if id == "char" then
+ id = "char/" .. charID
+ elseif id == "class" then
+ id = "class/" .. classID
+ elseif id == "realm" then
+ id = "realm/" .. realmID
+ end
+ if type(db.raw.profiles[id]) ~= "table" then
+ db.raw.profiles[id] = {}
+ end
+ rawset(db, 'profile', db.raw.profiles[id])
+ if db.defaults and db.defaults.profile then
+ inheritDefaults(db.profile, db.defaults.profile)
+ end
+ return db.profile
+ elseif key == "raw" or key == "defaults" or key == "name" or key == "charName" or key == "namespaces" then
+ return nil
+ end
+ error(("Cannot access key %q in db table. You may want to use db.profile[%q]"):format(tostring(key), tostring(key)), 2)
+end, __newindex = function(db, key, value)
+ error(("Cannot access key %q in db table. You may want to use db.profile[%q]"):format(tostring(key), tostring(key)), 2)
+end }
+
+local function RecalculateAceDBCopyFromList(target)
+ local db = target.db
+ local t = target['acedb-profile-copylist']
+ for k,v in pairs(t) do
+ t[k] = nil
+ end
+ local _,currentProfile = AceDB.GetProfile(target)
+ if db and db.raw then
+ if db.raw.profiles then
+ for k in pairs(db.raw.profiles) do
+ if currentProfile ~= k then
+ if k:find("^char/") then
+ local name = k:sub(6)
+ local player, realm = name:match("^(.*) %- (.*)$")
+ if player then
+ name = PLAYER_OF_REALM:format(player, realm)
+ end
+ t[k] = CHARACTER_COLON .. name
+ elseif k:find("^realm/") then
+ local name = k:sub(7)
+ t[k] = REALM_COLON .. name
+ elseif k:find("^class/") then
+ local name = k:sub(7)
+ t[k] = CLASS_COLON .. name
+ else
+ t[k] = k
+ end
+ end
+ end
+ end
+ if db.raw.namespaces then
+ for _,n in pairs(db.raw.namespaces) do
+ if n.profiles then
+ for k in pairs(n.profiles) do
+ if currentProfile ~= k then
+ if k:find('^char/') then
+ local name = k:sub(6)
+ local player, realm = name:match("^(.*) %- (.*)$")
+ if player then
+ name = PLAYER_OF_REALM:format(player, realm)
+ end
+ t[k] = CHARACTER_COLON .. name
+ elseif k:find('^realm/') then
+ local name = k:sub(7)
+ t[k] = REALM_COLON .. name
+ elseif k:find('^class/') then
+ local name = k:sub(7)
+ t[k] = CLASS_COLON .. name
+ else
+ t[k] = k
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ if t.Default then
+ t.Default = DEFAULT
+ end
+ if t.Alternative then
+ t.Alternative = ALTERNATIVE
+ end
+end
+
+local function RecalculateAceDBProfileList(target)
+ local t = target['acedb-profile-list']
+ for k,v in pairs(t) do
+ t[k] = nil
+ end
+ t.char = CHARACTER_COLON .. PLAYER_OF_REALM:format(UnitName("player"), server)
+ t.realm = REALM_COLON .. realmID
+ t.class = CLASS_COLON .. classID
+ t.Default = DEFAULT
+ local db = target.db
+ if db and db.raw then
+ if db.raw.profiles then
+ for k in pairs(db.raw.profiles) do
+ if not k:find("^char/") and not k:find("^realm/") and not k:find("^class/") then
+ t[k] = k
+ end
+ end
+ end
+ if db.raw.namespaces then
+ for _,n in pairs(db.raw.namespaces) do
+ if n.profiles then
+ for k in pairs(n.profiles) do
+ if not k:find("^char/") and not k:find("^realm/") and not k:find("^class/") then
+ t[k] = k
+ end
+ end
+ end
+ end
+ end
+ local curr = db.raw.currentProfile and db.raw.currentProfile[charID]
+ if curr and not t[curr] then
+ t[curr] = curr
+ end
+ end
+ if t.Alternative then
+ t.Alternative = ALTERNATIVE
+ end
+end
+
+local CrawlForSerialization
+local CrawlForDeserialization
+
+local function SerializeObject(o)
+ local t = { o:Serialize() }
+ CrawlForSerialization(t)
+ t[0] = o.class:GetLibraryVersion()
+ return t
+end
+
+local function DeserializeObject(t)
+ CrawlForDeserialization(t)
+ local className = t[0]
+ t[0] = nil
+ return AceLibrary(className):Deserialize(unpack(t))
+end
+
+local function IsSerializable(t)
+ return AceOO.inherits(t, AceOO.Class) and t.class and type(t.class.Deserialize) == "function" and type(t.Serialize) == "function" and type(t.class.GetLibraryVersion) == "function"
+end
+
+function CrawlForSerialization(t)
+ local tmp = new()
+ for k,v in pairs(t) do
+ tmp[k] = v
+ end
+ for k,v in pairs(tmp) do
+ if type(v) == "table" and type(rawget(v, 0)) ~= "userdata" then
+ if IsSerializable(v) then
+ v = SerializeObject(v)
+ t[k] = v
+ else
+ CrawlForSerialization(v)
+ end
+ end
+ if type(k) == "table" and type(rawget(k, 0)) ~= "userdata" then
+ if IsSerializable(k) then
+ t[k] = nil
+ t[SerializeObject(k)] = v
+ else
+ CrawlForSerialization(k)
+ end
+ end
+ tmp[k] = nil
+ k = nil
+ end
+ tmp = del(tmp)
+end
+
+local function IsDeserializable(t)
+ return type(rawget(t, 0)) == "string" and AceLibrary:HasInstance(rawget(t, 0))
+end
+
+function CrawlForDeserialization(t)
+ local tmp = new()
+ for k,v in pairs(t) do
+ tmp[k] = v
+ end
+ for k,v in pairs(tmp) do
+ if type(v) == "table" then
+ if IsDeserializable(v) then
+ t[k] = DeserializeObject(v)
+ del(v)
+ v = t[k]
+ elseif type(rawget(v, 0)) ~= "userdata" then
+ CrawlForDeserialization(v)
+ end
+ end
+ if type(k) == "table" then
+ if IsDeserializable(k) then
+ t[k] = nil
+ t[DeserializeObject(k)] = v
+ del(k)
+ elseif type(rawget(k, 0)) ~= "userdata" then
+ CrawlForDeserialization(k)
+ end
+ end
+ tmp[k] = nil
+ k = nil
+ end
+ tmp = del(tmp)
+end
+
+local namespace_mt = { __index = function(namespace, key)
+ local db = namespace.db
+ local name = namespace.name
+ if key == "char" then
+ if db.charName then
+ if type(_G[db.charName]) ~= "table" then
+ _G[db.charName] = {}
+ end
+ if type(_G[db.charName].namespaces) ~= "table" then
+ _G[db.charName].namespaces = {}
+ end
+ if type(_G[db.charName].namespaces[name]) ~= "table" then
+ _G[db.charName].namespaces[name] = {}
+ end
+ rawset(namespace, 'char', _G[db.charName].namespaces[name])
+ else
+ if type(db.raw.namespaces) ~= "table" then
+ db.raw.namespaces = {}
+ end
+ if type(db.raw.namespaces[name]) ~= "table" then
+ db.raw.namespaces[name] = {}
+ end
+ if type(db.raw.namespaces[name].chars) ~= "table" then
+ db.raw.namespaces[name].chars = {}
+ end
+ local id = charID
+ if type(db.raw.namespaces[name].chars[id]) ~= "table" then
+ db.raw.namespaces[name].chars[id] = {}
+ end
+ rawset(namespace, 'char', db.raw.namespaces[name].chars[id])
+ end
+ if namespace.defaults and namespace.defaults.char then
+ inheritDefaults(namespace.char, namespace.defaults.char)
+ end
+ return namespace.char
+ elseif key == "realm" then
+ if type(db.raw.namespaces) ~= "table" then
+ db.raw.namespaces = {}
+ end
+ if type(db.raw.namespaces[name]) ~= "table" then
+ db.raw.namespaces[name] = {}
+ end
+ if type(db.raw.namespaces[name].realms) ~= "table" then
+ db.raw.namespaces[name].realms = {}
+ end
+ local id = realmID
+ if type(db.raw.namespaces[name].realms[id]) ~= "table" then
+ db.raw.namespaces[name].realms[id] = {}
+ end
+ rawset(namespace, 'realm', db.raw.namespaces[name].realms[id])
+ if namespace.defaults and namespace.defaults.realm then
+ inheritDefaults(namespace.realm, namespace.defaults.realm)
+ end
+ return namespace.realm
+ elseif key == "server" then
+ if type(db.raw.namespaces) ~= "table" then
+ db.raw.namespaces = {}
+ end
+ if type(db.raw.namespaces[name]) ~= "table" then
+ db.raw.namespaces[name] = {}
+ end
+ if type(db.raw.namespaces[name].servers) ~= "table" then
+ db.raw.namespaces[name].servers = {}
+ end
+ local id = server
+ if type(db.raw.namespaces[name].servers[id]) ~= "table" then
+ db.raw.namespaces[name].servers[id] = {}
+ end
+ rawset(namespace, 'server', db.raw.namespaces[name].servers[id])
+ if namespace.defaults and namespace.defaults.server then
+ inheritDefaults(namespace.server, namespace.defaults.server)
+ end
+ return namespace.server
+ elseif key == "account" then
+ if type(db.raw.namespaces) ~= "table" then
+ db.raw.namespaces = {}
+ end
+ if type(db.raw.namespaces[name]) ~= "table" then
+ db.raw.namespaces[name] = {}
+ end
+ if type(db.raw.namespaces[name].account) ~= "table" then
+ db.raw.namespaces[name].account = {}
+ end
+ rawset(namespace, 'account', db.raw.namespaces[name].account)
+ if namespace.defaults and namespace.defaults.account then
+ inheritDefaults(namespace.account, namespace.defaults.account)
+ end
+ return namespace.account
+ elseif key == "faction" then
+ if type(db.raw.namespaces) ~= "table" then
+ db.raw.namespaces = {}
+ end
+ if type(db.raw.namespaces[name]) ~= "table" then
+ db.raw.namespaces[name] = {}
+ end
+ if type(db.raw.namespaces[name].factions) ~= "table" then
+ db.raw.namespaces[name].factions = {}
+ end
+ local id = faction
+ if type(db.raw.namespaces[name].factions[id]) ~= "table" then
+ db.raw.namespaces[name].factions[id] = {}
+ end
+ rawset(namespace, 'faction', db.raw.namespaces[name].factions[id])
+ if namespace.defaults and namespace.defaults.faction then
+ inheritDefaults(namespace.faction, namespace.defaults.faction)
+ end
+ return namespace.faction
+ elseif key == "class" then
+ if type(db.raw.namespaces) ~= "table" then
+ db.raw.namespaces = {}
+ end
+ if type(db.raw.namespaces[name]) ~= "table" then
+ db.raw.namespaces[name] = {}
+ end
+ if type(db.raw.namespaces[name].classes) ~= "table" then
+ db.raw.namespaces[name].classes = {}
+ end
+ local id = classID
+ if type(db.raw.namespaces[name].classes[id]) ~= "table" then
+ db.raw.namespaces[name].classes[id] = {}
+ end
+ rawset(namespace, 'class', db.raw.namespaces[name].classes[id])
+ if namespace.defaults and namespace.defaults.class then
+ inheritDefaults(namespace.class, namespace.defaults.class)
+ end
+ return namespace.class
+ elseif key == "profile" then
+ if type(db.raw.namespaces) ~= "table" then
+ db.raw.namespaces = {}
+ end
+ if type(db.raw.namespaces[name]) ~= "table" then
+ db.raw.namespaces[name] = {}
+ end
+ if type(db.raw.namespaces[name].profiles) ~= "table" then
+ db.raw.namespaces[name].profiles = setmetatable({}, caseInsensitive_mt)
+ else
+ setmetatable(db.raw.namespaces[name].profiles, caseInsensitive_mt)
+ end
+ local id = db.raw.currentProfile[charID]
+ if id == "char" then
+ id = "char/" .. charID
+ elseif id == "class" then
+ id = "class/" .. classID
+ elseif id == "realm" then
+ id = "realm/" .. realmID
+ end
+ if type(db.raw.namespaces[name].profiles[id]) ~= "table" then
+ db.raw.namespaces[name].profiles[id] = {}
+ end
+ rawset(namespace, 'profile', db.raw.namespaces[name].profiles[id])
+ if namespace.defaults and namespace.defaults.profile then
+ inheritDefaults(namespace.profile, namespace.defaults.profile)
+ end
+ return namespace.profile
+ elseif key == "defaults" or key == "name" or key == "db" then
+ return nil
+ end
+ error(("Cannot access key %q in db table. You may want to use db.profile[%q]"):format(tostring(key), tostring(key)), 2)
+end, __newindex = function(db, key, value)
+ error(("Cannot access key %q in db table. You may want to use db.profile[%q]"):format(tostring(key), tostring(key)), 2)
+end }
+
+local tmp = {}
+function AceDB:InitializeDB(addonName)
+ local db = self.db
+
+ if not db then
+ if addonName then
+ AceDB.addonsLoaded[addonName] = true
+ end
+ return
+ end
+
+ if db.raw then
+ -- someone manually initialized
+ return
+ end
+
+ if type(_G[db.name]) ~= "table" then
+ _G[db.name] = {}
+ else
+ CrawlForDeserialization(_G[db.name])
+ end
+ if db.charName then
+ if type(_G[db.charName]) ~= "table" then
+ _G[db.charName] = {}
+ else
+ CrawlForDeserialization(_G[db.charName])
+ end
+ end
+ rawset(db, 'raw', _G[db.name])
+ if not db.raw.currentProfile then
+ db.raw.currentProfile = {}
+ else
+ for k,v in pairs(db.raw.currentProfile) do
+ tmp[convertFromOldCharID(k)] = v
+ db.raw.currentProfile[k] = nil
+ end
+ for k,v in pairs(tmp) do
+ db.raw.currentProfile[k] = v
+ tmp[k] = nil
+ end
+ end
+ if not db.raw.currentProfile[charID] then
+ db.raw.currentProfile[charID] = AceDB.registry[self] or "Default"
+ end
+ if db.raw.profiles then
+ for k,v in pairs(db.raw.profiles) do
+ local new_k = k
+ if k:find("^char/") then
+ new_k = "char/" .. convertFromOldCharID(k:sub(6))
+ end
+ tmp[new_k] = v
+ db.raw.profiles[k] = nil
+ end
+ for k,v in pairs(tmp) do
+ db.raw.profiles[k] = v
+ tmp[k] = nil
+ end
+ end
+ if db.raw.disabledModules then -- AceModuleCore-2.0
+ for k,v in pairs(db.raw.disabledModules) do
+ local new_k = k
+ if k:find("^char/") then
+ new_k = "char/" .. convertFromOldCharID(k:sub(6))
+ end
+ tmp[new_k] = v
+ db.raw.disabledModules[k] = nil
+ end
+ for k,v in pairs(tmp) do
+ db.raw.disabledModules[k] = v
+ tmp[k] = nil
+ end
+ end
+ if db.raw.chars then
+ for k,v in pairs(db.raw.chars) do
+ tmp[convertFromOldCharID(k)] = v
+ db.raw.chars[k] = nil
+ end
+ for k,v in pairs(tmp) do
+ db.raw.chars[k] = v
+ tmp[k] = nil
+ end
+ end
+ if db.raw.namespaces then
+ for l,u in pairs(db.raw.namespaces) do
+ if u.chars then
+ for k,v in pairs(u.chars) do
+ tmp[convertFromOldCharID(k)] = v
+ u.chars[k] = nil
+ end
+ for k,v in pairs(tmp) do
+ u.chars[k] = v
+ tmp[k] = nil
+ end
+ end
+ end
+ end
+ if db.raw.disabled then
+ setmetatable(db.raw.disabled, caseInsensitive_mt)
+ end
+ if self['acedb-profile-copylist'] then
+ RecalculateAceDBCopyFromList(self)
+ end
+ if self['acedb-profile-list'] then
+ RecalculateAceDBProfileList(self)
+ end
+ setmetatable(db, db_mt)
+end
+
+function AceDB:OnEmbedInitialize(target, name)
+ if name then
+ self:ADDON_LOADED(name)
+ end
+ self.InitializeDB(target, name)
+end
+
+function AceDB:RegisterDB(name, charName, defaultProfile)
+ AceDB:argCheck(name, 2, "string")
+ AceDB:argCheck(charName, 3, "string", "nil")
+ AceDB:argCheck(defaultProfile, 4, "string", "nil")
+ if self.db then
+ AceDB:error("Cannot call \"RegisterDB\" if self.db is set.")
+ end
+ local stack = debugstack()
+ local addonName = stack:gsub(".-\n.-/AddOns/(.-)/.*", "%1")
+
+ self.db = {
+ name = name,
+ charName = charName
+ }
+ AceDB.registry[self] = defaultProfile or "Default"
+ if AceDB.addonsLoaded[addonName] then
+ AceDB.InitializeDB(self, addonName)
+ else
+ AceDB.addonsToBeInitialized[self] = addonName
+ end
+end
+
+function AceDB:RegisterDefaults(kind, defaults, a3)
+ local name
+ if a3 then
+ name, kind, defaults = kind, defaults, a3
+ AceDB:argCheck(name, 2, "string")
+ AceDB:argCheck(kind, 3, "string")
+ AceDB:argCheck(defaults, 4, "table")
+ else
+ AceDB:argCheck(kind, 2, "string")
+ AceDB:argCheck(defaults, 3, "table")
+ end
+ if kind ~= "char" and kind ~= "class" and kind ~= "profile" and kind ~= "account" and kind ~= "realm" and kind ~= "faction" and kind ~= "server" then
+ AceDB:error("Bad argument #%d to `RegisterDefaults' (\"char\", \"class\", \"profile\", \"account\", \"realm\", \"server\", or \"faction\" expected, got %q)", a3 and 3 or 2, kind)
+ end
+ if type(self.db) ~= "table" or type(self.db.name) ~= "string" then
+ AceDB:error("Cannot call \"RegisterDefaults\" unless \"RegisterDB\" has been previously called.")
+ end
+ local db
+ if name then
+ local namespace = self:AcquireDBNamespace(name)
+ if namespace.defaults and namespace.defaults[kind] then
+ AceDB:error("\"RegisterDefaults\" has already been called for %q::%q.", name, kind)
+ end
+ db = namespace
+ else
+ if self.db.defaults and self.db.defaults[kind] then
+ AceDB:error("\"RegisterDefaults\" has already been called for %q.", kind)
+ end
+ db = self.db
+ end
+ if not db.defaults then
+ rawset(db, 'defaults', {})
+ end
+ db.defaults[kind] = defaults
+ if rawget(db, kind) then
+ inheritDefaults(db[kind], defaults)
+ end
+end
+
+function AceDB:ResetDB(kind, a2)
+ local name
+ if a2 then
+ name, kind = kind, a2
+ AceDB:argCheck(name, 2, "nil", "string")
+ AceDB:argCheck(kind, 3, "nil", "string")
+ else
+ AceDB:argCheck(kind, 2, "nil", "string")
+ if kind ~= "char" and kind ~= "class" and kind ~= "profile" and kind ~= "account" and kind ~= "realm" and kind ~= "faction" and kind ~= "server" then
+ name, kind = kind, nil
+ end
+ end
+ if not self.db or not self.db.raw then
+ AceDB:error("Cannot call \"ResetDB\" before \"RegisterDB\" has been called and before \"ADDON_LOADED\" has been fired.")
+ end
+ local db = self.db
+ if not kind then
+ if not name then
+ if db.charName then
+ _G[db.charName] = nil
+ end
+ _G[db.name] = nil
+ rawset(db, 'raw', nil)
+ AceDB.InitializeDB(self)
+ if db.namespaces then
+ for name,v in pairs(db.namespaces) do
+ rawset(v, 'account', nil)
+ rawset(v, 'char', nil)
+ rawset(v, 'class', nil)
+ rawset(v, 'profile', nil)
+ rawset(v, 'realm', nil)
+ rawset(v, 'server', nil)
+ rawset(v, 'faction', nil)
+ end
+ end
+ else
+ if db.raw.namespaces then
+ db.raw.namespaces[name] = nil
+ end
+ if db.namespaces then
+ local v = db.namespaces[name]
+ if v then
+ rawset(v, 'account', nil)
+ rawset(v, 'char', nil)
+ rawset(v, 'class', nil)
+ rawset(v, 'profile', nil)
+ rawset(v, 'realm', nil)
+ rawset(v, 'server', nil)
+ rawset(v, 'faction', nil)
+ end
+ end
+ end
+ elseif kind == "account" then
+ if name then
+ db.raw.account = nil
+ rawset(db, 'account', nil)
+ if db.raw.namespaces then
+ for name,v in pairs(db.raw.namespaces) do
+ v.account = nil
+ end
+ end
+ if db.namespaces then
+ for name,v in pairs(db.namespaces) do
+ rawset(v, 'account', nil)
+ end
+ end
+ else
+ if db.raw.namespaces and db.raw.namespaces[name] then
+ db.raw.namespaces[name].account = nil
+ end
+ if db.namespaces then
+ local v = db.namespaces[name]
+ if v then
+ rawset(v, 'account', nil)
+ end
+ end
+ end
+ elseif kind == "char" then
+ if name then
+ if db.charName then
+ _G[db.charName] = nil
+ else
+ if db.raw.chars then
+ db.raw.chars[charID] = nil
+ end
+ if db.raw.namespaces then
+ for name,v in pairs(db.raw.namespaces) do
+ if v.chars then
+ v.chars[charID] = nil
+ end
+ end
+ end
+ end
+ rawset(db, 'char', nil)
+ if db.namespaces then
+ for name,v in pairs(db.namespaces) do
+ rawset(v, 'char', nil)
+ end
+ end
+ else
+ if db.charName then
+ local x = _G[db.charName]
+ if x.namespaces then
+ x.namespaces[name] = nil
+ end
+ else
+ if db.raw.namespaces then
+ local v = db.namespaces[name]
+ if v and v.chars then
+ v.chars[charID] = nil
+ end
+ end
+ end
+ if db.namespaces then
+ local v = db.namespaces[name]
+ if v then
+ rawset(v, 'char', nil)
+ end
+ end
+ end
+ elseif kind == "realm" then
+ if not name then
+ if db.raw.realms then
+ db.raw.realms[realmID] = nil
+ end
+ rawset(db, 'realm', nil)
+ if db.raw.namespaces then
+ for name,v in pairs(db.raw.namespaces) do
+ if v.realms then
+ v.realms[realmID] = nil
+ end
+ end
+ end
+ if db.namespaces then
+ for name,v in pairs(db.namespaces) do
+ rawset(v, 'realm', nil)
+ end
+ end
+ else
+ if db.raw.namespaces then
+ local v = db.raw.namespaces[name]
+ if v and v.realms then
+ v.realms[realmID] = nil
+ end
+ end
+ if db.namespaces then
+ local v = db.namespaces[name]
+ if v then
+ rawset(v, 'realm', nil)
+ end
+ end
+ end
+ elseif kind == "server" then
+ if not name then
+ if db.raw.servers then
+ db.raw.servers[server] = nil
+ end
+ rawset(db, 'server', nil)
+ if db.raw.namespaces then
+ for name,v in pairs(db.raw.namespaces) do
+ if v.servers then
+ v.servers[server] = nil
+ end
+ end
+ end
+ if db.namespaces then
+ for name,v in pairs(db.namespaces) do
+ rawset(v, 'server', nil)
+ end
+ end
+ else
+ if db.raw.namespaces then
+ local v = db.raw.namespaces[name]
+ if v and v.servers then
+ v.servers[server] = nil
+ end
+ end
+ if db.namespaces then
+ local v = db.namespaces[name]
+ if v then
+ rawset(v, 'server', nil)
+ end
+ end
+ end
+ elseif kind == "faction" then
+ if not name then
+ if db.raw.factions then
+ db.raw.factions[faction] = nil
+ end
+ rawset(db, 'faction', nil)
+ if db.raw.namespaces then
+ for name,v in pairs(db.raw.namespaces) do
+ if v.factions then
+ v.factions[faction] = nil
+ end
+ end
+ end
+ if db.namespaces then
+ for name,v in pairs(db.namespaces) do
+ rawset(v, 'faction', nil)
+ end
+ end
+ else
+ if db.raw.namespaces then
+ local v = db.raw.namespaces[name]
+ if v and v.factions then
+ v.factions[faction] = nil
+ end
+ end
+ if db.namespaces then
+ local v = db.namespaces[name]
+ if v then
+ rawset(v, 'faction', nil)
+ end
+ end
+ end
+ elseif kind == "class" then
+ if not name then
+ if db.raw.realms then
+ db.raw.realms[classID] = nil
+ end
+ rawset(db, 'class', nil)
+ if db.raw.namespaces then
+ for name,v in pairs(db.raw.namespaces) do
+ if v.classes then
+ v.classes[classID] = nil
+ end
+ end
+ end
+ if db.namespaces then
+ for name,v in pairs(db.namespaces) do
+ rawset(v, 'class', nil)
+ end
+ end
+ else
+ if db.raw.namespaces then
+ local v = db.raw.namespaces[name]
+ if v and v.classes then
+ v.classes[classID] = nil
+ end
+ end
+ if db.namespaces then
+ local v = db.namespaces[name]
+ if v then
+ rawset(v, 'class', nil)
+ end
+ end
+ end
+ elseif kind == "profile" then
+ local id = db.raw.currentProfile and db.raw.currentProfile[charID] or AceDB.registry[self] or "Default"
+ if id == "char" then
+ id = "char/" .. charID
+ elseif id == "class" then
+ id = "class/" .. classID
+ elseif id == "realm" then
+ id = "realm/" .. realmID
+ end
+
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedProfileDisable) == "function" then
+ safecall(mixin.OnEmbedProfileDisable, mixin, self, id)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnProfileDisable) == "function" then
+ safecall(self.OnProfileDisable, self, id)
+ end
+ local active = self:IsActive()
+
+ if not name then
+ if db.raw.profiles then
+ db.raw.profiles[id] = nil
+ end
+ rawset(db, 'profile', nil)
+ if db.raw.namespaces then
+ for name,v in pairs(db.raw.namespaces) do
+ if v.profiles then
+ v.profiles[id] = nil
+ end
+ end
+ end
+ if db.namespaces then
+ for name,v in pairs(db.namespaces) do
+ rawset(v, 'profile', nil)
+ end
+ end
+ else
+ if db.raw.namespaces then
+ local v = db.raw.namespaces[name]
+ if v and v.profiles then
+ v.profiles[id] = nil
+ end
+ end
+ if db.namespaces then
+ local v = db.namespaces[name]
+ if v then
+ rawset(v, 'profile', nil)
+ end
+ end
+ end
+
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedProfileEnable) == "function" then
+ safecall(mixin.OnEmbedProfileEnable, mixin, self, id)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnProfileEnable) == "function" then
+ safecall(self.OnProfileEnable, self, id)
+ end
+ local newactive = self:IsActive()
+ if active ~= newactive then
+ if newactive then
+ local first = nil
+ if AceOO.inherits(self, "AceAddon-2.0") then
+ local AceAddon = AceLibrary("AceAddon-2.0")
+ if not AceAddon.addonsStarted[self] then
+ return
+ end
+ if AceAddon.addonsEnabled and not AceAddon.addonsEnabled[self] then
+ AceAddon.addonsEnabled[self] = true
+ first = true
+ end
+ end
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedEnable) == "function" then
+ safecall(mixin.OnEmbedEnable, mixin, self, first)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnEnable) == "function" then
+ safecall(self.OnEnable, self, first)
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("Ace2_AddonEnabled", self, first)
+ end
+ else
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedDisable) == "function" then
+ safecall(mixin.OnEmbedDisable, mixin, self)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnDisable) == "function" then
+ safecall(self.OnDisable, self)
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("Ace2_AddonDisabled", self)
+ end
+ end
+ end
+ else
+ return -- skip event
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("AceDB20_ResetDB", self, self.db.name, kind)
+ end
+end
+
+local function cleanDefaults(t, defaults, blocker)
+ if defaults then
+ for k,v in pairs(t) do
+ if (not blocker or (blocker[k] == nil and blocker['*'] == nil and blocker['**'] == nil)) and (defaults[k] ~= nil or defaults['*'] ~= nil or defaults['**'] ~= nil) then
+ local u = defaults[k]
+ if u == nil then
+ u = defaults['*']
+ if u == nil then
+ u = defaults['**']
+ end
+ end
+ if v == u then
+ t[k] = nil
+ elseif type(v) == "table" and type(u) == "table" then
+ if cleanDefaults(v, u) then
+ t[k] = nil
+ else
+ local w = defaults['**']
+ if w ~= u then
+ if cleanDefaults(v, w, u) then
+ t[k] = nil
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ return t and next(t) == nil
+end
+
+function AceDB:GetProfile()
+ if not self.db or not self.db.raw then
+ return nil
+ end
+ if not self.db.raw.currentProfile then
+ self.db.raw.currentProfile = {}
+ end
+ if not self.db.raw.currentProfile[charID] then
+ self.db.raw.currentProfile[charID] = AceDB.registry[self] or "Default"
+ end
+ local profile = self.db.raw.currentProfile[charID]
+ if profile == "char" then
+ return "char", "char/" .. charID
+ elseif profile == "class" then
+ return "class", "class/" .. classID
+ elseif profile == "realm" then
+ return "realm", "realm/" .. realmID
+ end
+ return profile, profile
+end
+
+local function copyTable(to, from)
+ setmetatable(to, nil)
+ for k,v in pairs(from) do
+ if type(k) == "table" then
+ k = copyTable({}, k)
+ end
+ if type(v) == "table" then
+ v = copyTable({}, v)
+ end
+ to[k] = v
+ end
+ setmetatable(to, from)
+ return to
+end
+
+function AceDB:SetProfile(name)
+ AceDB:argCheck(name, 2, "string")
+ if not self.db or not self.db.raw then
+ AceDB:error("Cannot call \"SetProfile\" before \"RegisterDB\" has been called and before \"ADDON_LOADED\" has been fired.")
+ end
+ local db = self.db
+ local lowerName = name:lower()
+ if lowerName:find("^char/") or lowerName:find("^realm/") or lowerName:find("^class/") then
+ if lowerName:find("^char/") then
+ name = "char"
+ else
+ name = lowerName:sub(1, 5)
+ end
+ lowerName = name:lower()
+ end
+ local oldName = db.raw.currentProfile[charID]
+ if oldName:lower() == name:lower() then
+ return
+ end
+ local oldProfileData = db.profile
+ local realName = name
+ if lowerName == "char" then
+ realName = name .. "/" .. charID
+ elseif lowerName == "realm" then
+ realName = name .. "/" .. realmID
+ elseif lowerName == "class" then
+ realName = name .. "/" .. classID
+ end
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedProfileDisable) == "function" then
+ safecall(mixin.OnEmbedProfileDisable, mixin, self, realName)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnProfileDisable) == "function" then
+ safecall(self.OnProfileDisable, self, realName)
+ end
+ local active = self:IsActive()
+ db.raw.currentProfile[charID] = name
+ rawset(db, 'profile', nil)
+ if db.namespaces then
+ for k,v in pairs(db.namespaces) do
+ rawset(v, 'profile', nil)
+ end
+ end
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedProfileEnable) == "function" then
+ safecall(mixin.OnEmbedProfileEnable, mixin, self, oldName, oldProfileData)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnProfileEnable) == "function" then
+ safecall(self.OnProfileEnable, self, oldName, oldProfileData)
+ end
+ if cleanDefaults(oldProfileData, db.defaults and db.defaults.profile) then
+ db.raw.profiles[oldName] = nil
+ if not next(db.raw.profiles) then
+ db.raw.profiles = nil
+ end
+ end
+ local newactive = self:IsActive()
+ if active ~= newactive then
+ local first = nil
+ if AceOO.inherits(self, "AceAddon-2.0") then
+ local AceAddon = AceLibrary("AceAddon-2.0")
+ if not AceAddon.addonsStarted[self] then
+ return
+ end
+ if AceAddon.addonsEnabled and not AceAddon.addonsEnabled[self] then
+ first = true
+ end
+ end
+ if newactive then
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedEnable) == "function" then
+ safecall(mixin.OnEmbedEnable, mixin, self, first)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnEnable) == "function" then
+ safecall(self.OnEnable, self, first)
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("Ace2_AddonEnabled", self, first)
+ end
+ else
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedDisable) == "function" then
+ safecall(mixin.OnEmbedDisable, mixin, self)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnDisable) == "function" then
+ safecall(self.OnDisable, self)
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("Ace2_AddonDisabled", self)
+ end
+ end
+ end
+ if self['acedb-profile-list'] then
+ RecalculateAceDBProfileList(self)
+ end
+ if self['acedb-profile-copylist'] then
+ RecalculateAceDBCopyFromList(self)
+ end
+ if Dewdrop then
+ Dewdrop:Refresh()
+ end
+end
+
+function AceDB:CopyProfileFrom(copyFrom)
+ AceDB:argCheck(copyFrom, 2, "string")
+ if not self.db or not self.db.raw then
+ AceDB:error("Cannot call \"CopyProfileFrom\" before \"RegisterDB\" has been called and before \"ADDON_LOADED\" has been fired.")
+ end
+ local db = self.db
+ local lowerCopyFrom = copyFrom:lower()
+ if not db.raw.profiles or not db.raw.profiles[copyFrom] then
+ local good = false
+ if db.raw.namespaces then
+ for _,n in pairs(db.raw.namespaces) do
+ if n.profiles and n.profiles[copyFrom] then
+ good = true
+ break
+ end
+ end
+ end
+ if not good then
+ AceDB:error("Cannot copy from profile %q, it does not exist.", copyFrom)
+ end
+ end
+ local currentProfile = db.raw.currentProfile[charID]
+ if currentProfile:lower() == lowerCopyFrom then
+ AceDB:error("Cannot copy from profile %q, it is currently in use.", copyFrom)
+ end
+ local oldProfileData = db.profile
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedProfileDisable) == "function" then
+ safecall(mixin.OnEmbedProfileDisable, mixin, self, currentProfile)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnProfileDisable) == "function" then
+ safecall(self.OnProfileDisable, self, realName)
+ end
+ local active = self:IsActive()
+ for k,v in pairs(db.profile) do
+ db.profile[k] = nil
+ end
+ if db.raw.profiles[copyFrom] then
+ copyTable(db.profile, db.raw.profiles[copyFrom])
+ end
+ inheritDefaults(db.profile, db.defaults and db.defaults.profile)
+ if db.namespaces then
+ for l,u in pairs(db.namespaces) do
+ for k,v in pairs(u.profile) do
+ u.profile[k] = nil
+ end
+ if db.raw.namespaces[l].profiles[copyFrom] then
+ copyTable(u.profile, db.raw.namespaces[l].profiles[copyFrom])
+ end
+ inheritDefaults(u.profile, u.defaults and u.defaults.profile)
+ end
+ end
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedProfileEnable) == "function" then
+ safecall(mixin.OnEmbedProfileEnable, mixin, self, copyFrom, oldProfileData, copyFrom)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnProfileEnable) == "function" then
+ safecall(self.OnProfileEnable, self, copyFrom, oldProfileData, copyFrom)
+ end
+ local newactive = self:IsActive()
+ if active ~= newactive then
+ if AceOO.inherits(self, "AceAddon-2.0") then
+ local AceAddon = AceLibrary("AceAddon-2.0")
+ if not AceAddon.addonsStarted[self] then
+ return
+ end
+ end
+ if newactive then
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedEnable) == "function" then
+ safecall(mixin.OnEmbedEnable, mixin, self)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnEnable) == "function" then
+ safecall(self.OnEnable, self)
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("Ace2_AddonEnabled", self)
+ end
+ else
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedDisable) == "function" then
+ safecall(mixin.OnEmbedDisable, mixin, self)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnDisable) == "function" then
+ safecall(self.OnDisable, self)
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("Ace2_AddonDisabled", self)
+ end
+ end
+ end
+ if self['acedb-profile-list'] then
+ RecalculateAceDBProfileList(self)
+ end
+ if self['acedb-profile-copylist'] then
+ RecalculateAceDBCopyFromList(self)
+ end
+ if Dewdrop then
+ Dewdrop:Refresh()
+ end
+end
+
+function AceDB:DeleteProfile(profile, noconfirm)
+ AceDB:argCheck(profile , 2, "string")
+ if not self.db or not self.db.raw then
+ AceDB:error("Cannot call \"DeleteProfile\" before \"RegisterDB\" has been called and before \"ADDON_LOADED\" has been fired.")
+ end
+ local db = self.db
+
+ local currentProfile = db.raw.currentProfile[charID]
+ if currentProfile:lower() == profile:lower() then
+ AceDB:error("Cannot delete profile %q, it is currently in use.", profile)
+ end
+
+ if not (noconfirm or IsShiftKeyDown()) then
+ if not StaticPopupDialogs["ACEDB20_CONFIRM_DELETE_DIALOG"] then
+ StaticPopupDialogs["ACEDB20_CONFIRM_DELETE_DIALOG"] = {}
+ end
+ local t = StaticPopupDialogs["ACEDB20_CONFIRM_DELETE_DIALOG"]
+ t.text = format("%s: %s?", DELETE_PROFILE, profile)
+ t.button1 = DELETE_PROFILE
+ t.button2 = CANCEL or "Cancel"
+ t.OnAccept = function()
+ self:DeleteProfile(profile, true)
+ end
+ t.timeout = 0
+ t.whileDead = 1
+ t.hideOnEscape = 1
+
+ StaticPopup_Show("ACEDB20_CONFIRM_DELETE_DIALOG")
+ return;
+ end
+
+ local good = false
+ if db.raw.profiles and db.raw.profiles[profile] then
+ good = true;
+ db.raw.profiles[profile] = nil;
+ end
+
+ if db.raw.namespaces then
+ for _,n in pairs(db.raw.namespaces) do
+ if n.profiles and n.profiles[profile] then
+ n.profiles[profile] = nil;
+ good = true
+ end
+ end
+ end
+
+ if not good then
+ AceDB:error("Cannot delete profile %q, it does not exist.", profile)
+ end
+
+ if self['acedb-profile-list'] then
+ RecalculateAceDBProfileList(self)
+ end
+ if self['acedb-profile-copylist'] then
+ RecalculateAceDBCopyFromList(self)
+ end
+
+ if Dewdrop then
+ Dewdrop:Refresh()
+ end
+end
+
+function AceDB:IsActive()
+ return not self.db or not self.db.raw or not self.db.raw.disabled or not self.db.raw.disabled[self.db.raw.currentProfile[charID]]
+end
+
+function AceDB:ToggleActive(state)
+ AceDB:argCheck(state, 2, "boolean", "nil")
+ if not self.db or not self.db.raw then
+ AceDB:error("Cannot call \"ToggleActive\" before \"RegisterDB\" has been called and before \"ADDON_LOADED\" has been fired.")
+ end
+ local db = self.db
+ if not db.raw.disabled then
+ db.raw.disabled = setmetatable({}, caseInsensitive_mt)
+ end
+ local profile = db.raw.currentProfile[charID]
+ local disable
+ if state == nil then
+ disable = not db.raw.disabled[profile]
+ else
+ disable = not state
+ if disable == db.raw.disabled[profile] then
+ return
+ end
+ end
+ db.raw.disabled[profile] = disable or nil
+ if AceOO.inherits(self, "AceAddon-2.0") then
+ local AceAddon = AceLibrary("AceAddon-2.0")
+ if not AceAddon.addonsStarted[self] then
+ return
+ end
+ end
+ if not disable then
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedEnable) == "function" then
+ safecall(mixin.OnEmbedEnable, mixin, self)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnEnable) == "function" then
+ safecall(self.OnEnable, self)
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("Ace2_AddonEnabled", self)
+ end
+ else
+ local current = self.class
+ while current and current ~= AceOO.Class do
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnEmbedDisable) == "function" then
+ safecall(mixin.OnEmbedDisable, mixin, self)
+ end
+ end
+ end
+ current = current.super
+ end
+ if type(self.OnDisable) == "function" then
+ safecall(self.OnDisable, self)
+ end
+ if AceEvent then
+ AceEvent:TriggerEvent("Ace2_AddonDisabled", self)
+ end
+ end
+ return not disable
+end
+
+function AceDB:embed(target)
+ self.super.embed(self, target)
+ if not AceEvent then
+ AceDB:error(MAJOR_VERSION .. " requires AceEvent-2.0")
+ end
+end
+
+function AceDB:ADDON_LOADED(name)
+ AceDB.addonsLoaded[name] = true
+ for addon, addonName in pairs(AceDB.addonsToBeInitialized) do
+ if name == addonName then
+ AceDB.InitializeDB(addon, name)
+ AceDB.addonsToBeInitialized[addon] = nil
+ end
+ end
+end
+
+function AceDB:PLAYER_LOGOUT()
+ for addon, defaultProfile in pairs(AceDB.registry) do
+ local db = addon.db
+ if db then
+ if type(addon.OnDatabaseCleanup) == "function" then
+ safecall(addon.OnDatabaseCleanup, addon)
+ end
+ setmetatable(db, nil)
+ CrawlForSerialization(db.raw)
+ if type(_G[db.charName]) == "table" then
+ CrawlForSerialization(_G[db.charName])
+ end
+ if db.char and cleanDefaults(db.char, db.defaults and db.defaults.char) then
+ if db.charName and _G[db.charName] and _G[db.charName].global == db.char then
+ _G[db.charName].global = nil
+ if not next(_G[db.charName]) then
+ _G[db.charName] = nil
+ end
+ else
+ if db.raw.chars then
+ db.raw.chars[charID] = nil
+ if not next(db.raw.chars) then
+ db.raw.chars = nil
+ end
+ end
+ end
+ end
+ if db.realm and cleanDefaults(db.realm, db.defaults and db.defaults.realm) then
+ if db.raw.realms then
+ db.raw.realms[realmID] = nil
+ if not next(db.raw.realms) then
+ db.raw.realms = nil
+ end
+ end
+ end
+ if db.server and cleanDefaults(db.server, db.defaults and db.defaults.server) then
+ if db.raw.servers then
+ db.raw.servers[server] = nil
+ if not next(db.raw.servers) then
+ db.raw.servers = nil
+ end
+ end
+ end
+ if db.faction and cleanDefaults(db.faction, db.defaults and db.defaults.faction) then
+ if db.raw.factions then
+ db.raw.factions[faction] = nil
+ if not next(db.raw.factions) then
+ db.raw.factions = nil
+ end
+ end
+ end
+ if db.class and cleanDefaults(db.class, db.defaults and db.defaults.class) then
+ if db.raw.classes then
+ db.raw.classes[classID] = nil
+ if not next(db.raw.classes) then
+ db.raw.classes = nil
+ end
+ end
+ end
+ if db.account and cleanDefaults(db.account, db.defaults and db.defaults.account) then
+ db.raw.account = nil
+ end
+ if db.profile and cleanDefaults(db.profile, db.defaults and db.defaults.profile) then
+ if db.raw.profiles then
+ db.raw.profiles[db.raw.currentProfile and db.raw.currentProfile[charID] or defaultProfile or "Default"] = nil
+ if not next(db.raw.profiles) then
+ db.raw.profiles = nil
+ end
+ end
+ end
+ if db.namespaces and db.raw.namespaces then
+ for name,v in pairs(db.namespaces) do
+ if db.raw.namespaces[name] then
+ setmetatable(v, nil)
+ if v.char and cleanDefaults(v.char, v.defaults and v.defaults.char) then
+ if db.charName and _G[db.charName] and _G[db.charName].namespaces and _G[db.charName].namespaces[name] == v then
+ _G[db.charName].namespaces[name] = nil
+ if not next(_G[db.charName].namespaces) then
+ _G[db.charName].namespaces = nil
+ if not next(_G[db.charName]) then
+ _G[db.charName] = nil
+ end
+ end
+ else
+ if db.raw.namespaces[name].chars then
+ db.raw.namespaces[name].chars[charID] = nil
+ if not next(db.raw.namespaces[name].chars) then
+ db.raw.namespaces[name].chars = nil
+ end
+ end
+ end
+ end
+ if v.realm and cleanDefaults(v.realm, v.defaults and v.defaults.realm) then
+ if db.raw.namespaces[name].realms then
+ db.raw.namespaces[name].realms[realmID] = nil
+ if not next(db.raw.namespaces[name].realms) then
+ db.raw.namespaces[name].realms = nil
+ end
+ end
+ end
+ if v.server and cleanDefaults(v.server, v.defaults and v.defaults.server) then
+ if db.raw.namespaces[name].servers then
+ db.raw.namespaces[name].servers[server] = nil
+ if not next(db.raw.namespaces[name].servers) then
+ db.raw.namespaces[name].servers = nil
+ end
+ end
+ end
+ if v.faction and cleanDefaults(v.faction, v.defaults and v.defaults.faction) then
+ if db.raw.namespaces[name].factions then
+ db.raw.namespaces[name].factions[faction] = nil
+ if not next(db.raw.namespaces[name].factions) then
+ db.raw.namespaces[name].factions = nil
+ end
+ end
+ end
+ if v.class and cleanDefaults(v.class, v.defaults and v.defaults.class) then
+ if db.raw.namespaces[name].classes then
+ db.raw.namespaces[name].classes[classID] = nil
+ if not next(db.raw.namespaces[name].classes) then
+ db.raw.namespaces[name].classes = nil
+ end
+ end
+ end
+ if v.account and cleanDefaults(v.account, v.defaults and v.defaults.account) then
+ db.raw.namespaces[name].account = nil
+ end
+ if v.profile and cleanDefaults(v.profile, v.defaults and v.defaults.profile) then
+ if db.raw.namespaces[name].profiles then
+ db.raw.namespaces[name].profiles[db.raw.currentProfile and db.raw.currentProfile[charID] or defaultProfile or "Default"] = nil
+ if not next(db.raw.namespaces[name].profiles) then
+ db.raw.namespaces[name].profiles = nil
+ end
+ end
+ end
+ if not next(db.raw.namespaces[name]) then
+ db.raw.namespaces[name] = nil
+ end
+ end
+ end
+ if not next(db.raw.namespaces) then
+ db.raw.namespaces = nil
+ end
+ end
+ if db.raw.disabled and not next(db.raw.disabled) then
+ db.raw.disabled = nil
+ end
+ if db.raw.currentProfile then
+ for k,v in pairs(db.raw.currentProfile) do
+ if v:lower() == (defaultProfile or "Default"):lower() then
+ db.raw.currentProfile[k] = nil
+ end
+ end
+ if not next(db.raw.currentProfile) then
+ db.raw.currentProfile = nil
+ end
+ end
+ if _G[db.name] and not next(_G[db.name]) then
+ _G[db.name] = nil
+ end
+ end
+ end
+end
+
+function AceDB:AcquireDBNamespace(name)
+ AceDB:argCheck(name, 2, "string")
+ local db = self.db
+ if not db then
+ AceDB:error("Cannot call `AcquireDBNamespace' before `RegisterDB' has been called.", 2)
+ end
+ if not db.namespaces then
+ rawset(db, 'namespaces', {})
+ end
+ if not db.namespaces[name] then
+ local namespace = {}
+ db.namespaces[name] = namespace
+ namespace.db = db
+ namespace.name = name
+ setmetatable(namespace, namespace_mt)
+ end
+ return db.namespaces[name]
+end
+
+function AceDB:GetAceOptionsDataTable(target)
+ if not target['acedb-profile-list'] then
+ target['acedb-profile-list'] = setmetatable({}, caseInsensitive_mt)
+ RecalculateAceDBProfileList(target)
+ end
+ if not target['acedb-profile-copylist'] then
+ target['acedb-profile-copylist'] = setmetatable({}, caseInsensitive_mt)
+ RecalculateAceDBCopyFromList(target)
+ end
+ return {
+ standby = {
+ cmdName = STATE,
+ guiName = ENABLED,
+ name = ACTIVE,
+ desc = TOGGLE_ACTIVE,
+ type = "toggle",
+ get = "IsActive",
+ set = "ToggleActive",
+ map = MAP_ACTIVESUSPENDED,
+ order = -3,
+ },
+ profile = {
+ type = 'group',
+ name = PROFILE,
+ desc = SET_PROFILE,
+ order = -3.5,
+ get = "GetProfile",
+ args = {
+ choose = {
+ guiName = CHOOSE_PROFILE_GUI,
+ cmdName = PROFILE,
+ desc = CHOOSE_PROFILE_DESC,
+ type = 'text',
+ get = "GetProfile",
+ set = "SetProfile",
+ validate = target['acedb-profile-list']
+ },
+ copy = {
+ guiName = COPY_PROFILE_GUI,
+ cmdName = PROFILE,
+ desc = COPY_PROFILE_DESC,
+ type = 'text',
+ get = false,
+ set = "CopyProfileFrom",
+ validate = target['acedb-profile-copylist'],
+ disabled = function()
+ return not next(target['acedb-profile-copylist'])
+ end,
+ },
+ other = {
+ guiName = OTHER_PROFILE_GUI,
+ cmdName = PROFILE,
+ desc = OTHER_PROFILE_DESC,
+ usage = OTHER_PROFILE_USAGE,
+ type = 'text',
+ get = "GetProfile",
+ set = "SetProfile",
+ },
+ delete = {
+ name = DELETE_PROFILE,
+ desc = DELETE_PROFILE_DESC,
+ usage = DELETE_PROFILE_USAGE,
+ type = 'text',
+ set = "DeleteProfile",
+ get = false,
+ validate = target['acedb-profile-copylist'],
+ disabled = function()
+ return not next(target['acedb-profile-copylist'])
+ end,
+ },
+ reset = {
+ name = RESET_PROFILE,
+ desc = RESET_PROFILE_DESC,
+ type = 'execute',
+ func = function()
+ target:ResetDB('profile')
+ end,
+ confirm = true,
+ }
+ }
+ },
+ }
+end
+
+local function activate(self, oldLib, oldDeactivate)
+ AceDB = self
+ AceEvent = AceLibrary:HasInstance("AceEvent-2.0") and AceLibrary("AceEvent-2.0")
+
+ self.addonsToBeInitialized = oldLib and oldLib.addonsToBeInitialized or {}
+ self.addonsLoaded = oldLib and oldLib.addonsLoaded or {}
+ self.registry = oldLib and oldLib.registry or {}
+ for k, v in pairs(self.registry) do
+ if v == true then
+ self.registry[k] = "Default"
+ end
+ end
+
+ self:activate(oldLib, oldDeactivate)
+
+ for t in pairs(self.embedList) do
+ if t.db then
+ rawset(t.db, 'char', nil)
+ rawset(t.db, 'realm', nil)
+ rawset(t.db, 'class', nil)
+ rawset(t.db, 'account', nil)
+ rawset(t.db, 'server', nil)
+ rawset(t.db, 'faction', nil)
+ rawset(t.db, 'profile', nil)
+ setmetatable(t.db, db_mt)
+ end
+ end
+
+ if oldLib then
+ oldDeactivate(oldLib)
+ end
+end
+
+local function external(self, major, instance)
+ if major == "AceEvent-2.0" then
+ AceEvent = instance
+
+ AceEvent:embed(self)
+
+ self:RegisterEvent("ADDON_LOADED")
+ self:RegisterEvent("PLAYER_LOGOUT")
+ elseif major == "Dewdrop-2.0" then
+ Dewdrop = instance
+ end
+end
+
+AceLibrary:Register(AceDB, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)
+AceDB = AceLibrary(MAJOR_VERSION)
diff --git a/FuBar_DurabilityFu/libs/AceDB-2.0/AceDB-2.0.toc b/FuBar_DurabilityFu/libs/AceDB-2.0/AceDB-2.0.toc
new file mode 100644
index 0000000..40250b4
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceDB-2.0/AceDB-2.0.toc
@@ -0,0 +1,16 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r1098
+## X-Curse-Project-Name: Ace2
+## X-Curse-Project-ID: ace2
+## X-Curse-Repository-ID: wow/ace2/mainline
+
+## Title: Lib: AceDB-2.0
+## Notes: AddOn development framework
+## Author: Ace Development Team
+## LoadOnDemand: 1
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-License: LGPL v2.1 + MIT for AceOO-2.0
+## Dependencies: AceLibrary, AceEvent-2.0, AceOO-2.0
+
+AceDB-2.0.lua
diff --git a/FuBar_DurabilityFu/libs/AceEvent-2.0/AceEvent-2.0.lua b/FuBar_DurabilityFu/libs/AceEvent-2.0/AceEvent-2.0.lua
new file mode 100644
index 0000000..66a4f71
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceEvent-2.0/AceEvent-2.0.lua
@@ -0,0 +1,998 @@
+--[[
+Name: AceEvent-2.0
+Revision: $Rev: 1097 $
+Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team)
+Inspired By: Ace 1.x by Turan (turan@gryphon.com)
+Website: http://www.wowace.com/
+Documentation: http://www.wowace.com/index.php/AceEvent-2.0
+SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceEvent-2.0
+Description: Mixin to allow for event handling, scheduling, and inter-addon
+ communication.
+Dependencies: AceLibrary, AceOO-2.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "AceEvent-2.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 1097 $"):match("(%d+)"))
+
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+if not AceLibrary:HasInstance("AceOO-2.0") then error(MAJOR_VERSION .. " requires AceOO-2.0") end
+
+local AceOO = AceLibrary:GetInstance("AceOO-2.0")
+local Mixin = AceOO.Mixin
+local AceEvent = Mixin {
+ "RegisterEvent",
+ "RegisterAllEvents",
+ "UnregisterEvent",
+ "UnregisterAllEvents",
+ "TriggerEvent",
+ "ScheduleEvent",
+ "ScheduleRepeatingEvent",
+ "CancelScheduledEvent",
+ "CancelAllScheduledEvents",
+ "IsEventRegistered",
+ "IsEventScheduled",
+ "RegisterBucketEvent",
+ "UnregisterBucketEvent",
+ "UnregisterAllBucketEvents",
+ "IsBucketEventRegistered",
+ "ScheduleLeaveCombatAction",
+ "CancelAllCombatSchedules",
+}
+
+local weakKey = {__mode="k"}
+
+local FAKE_NIL
+local RATE
+
+local eventsWhichHappenOnce = {
+ PLAYER_LOGIN = true,
+ AceEvent_FullyInitialized = true,
+ VARIABLES_LOADED = true,
+ PLAYER_LOGOUT = true,
+}
+local next = next
+local pairs = pairs
+local pcall = pcall
+local type = type
+local GetTime = GetTime
+local gcinfo = gcinfo
+local unpack = unpack
+local geterrorhandler = geterrorhandler
+
+local new, del
+do
+ local cache = setmetatable({}, {__mode='k'})
+ function new(...)
+ local t = next(cache)
+ if t then
+ cache[t] = nil
+ for i = 1, select('#', ...) do
+ t[i] = select(i, ...)
+ end
+ return t
+ else
+ return { ... }
+ end
+ end
+ function del(t)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ cache[t] = true
+ return nil
+ end
+end
+
+local registeringFromAceEvent
+--[[----------------------------------------------------------------------------------
+Notes:
+ * Registers the addon with a Blizzard event or a custom AceEvent, which will cause the given method to be called when that is triggered.
+Arguments:
+ string - name of the event to register
+ [optional] string or function - name of the method or function to call. Default: same name as "event".
+ [optional] boolean - whether to have method called only once. Default: false
+------------------------------------------------------------------------------------]]
+function AceEvent:RegisterEvent(event, method, once)
+ AceEvent:argCheck(event, 2, "string")
+ if self == AceEvent and not registeringFromAceEvent then
+ AceEvent:argCheck(method, 3, "function")
+ self = method
+ else
+ AceEvent:argCheck(method, 3, "string", "function", "nil", "boolean", "number")
+ if type(method) == "boolean" or type(method) == "number" then
+ AceEvent:argCheck(once, 4, "nil")
+ once, method = method, event
+ end
+ end
+ AceEvent:argCheck(once, 4, "number", "boolean", "nil")
+ if eventsWhichHappenOnce[event] then
+ once = true
+ end
+ local throttleRate
+ if type(once) == "number" then
+ throttleRate, once = once
+ end
+ if not method then
+ method = event
+ end
+ if type(method) == "string" and type(self[method]) ~= "function" then
+ AceEvent:error("Cannot register event %q to method %q, it does not exist", event, method)
+ else
+ assert(type(method) == "function" or type(method) == "string")
+ end
+
+ local AceEvent_registry = AceEvent.registry
+ if not AceEvent_registry[event] then
+ AceEvent_registry[event] = new()
+ AceEvent.frame:RegisterEvent(event)
+ end
+
+ local remember = true
+ if AceEvent_registry[event][self] then
+ remember = false
+ end
+ AceEvent_registry[event][self] = method
+
+ local AceEvent_onceRegistry = AceEvent.onceRegistry
+ if once then
+ if not AceEvent_onceRegistry then
+ AceEvent.onceRegistry = {}
+ AceEvent_onceRegistry = AceEvent.onceRegistry
+ end
+ if not AceEvent_onceRegistry[event] then
+ AceEvent_onceRegistry[event] = new()
+ end
+ AceEvent_onceRegistry[event][self] = true
+ else
+ if AceEvent_onceRegistry and AceEvent_onceRegistry[event] then
+ AceEvent_onceRegistry[event][self] = nil
+ if not next(AceEvent_onceRegistry[event]) then
+ AceEvent_onceRegistry[event] = del(AceEvent_onceRegistry[event])
+ end
+ end
+ end
+
+ local AceEvent_throttleRegistry = AceEvent.throttleRegistry
+ if throttleRate then
+ if not AceEvent_throttleRegistry then
+ AceEvent.throttleRegistry = {}
+ AceEvent_throttleRegistry = AceEvent.throttleRegistry
+ end
+ if not AceEvent_throttleRegistry[event] then
+ AceEvent_throttleRegistry[event] = new()
+ end
+ if AceEvent_throttleRegistry[event][self] then
+ AceEvent_throttleRegistry[event][self] = nil
+ end
+ AceEvent_throttleRegistry[event][self] = setmetatable(new(), weakKey)
+ local t = AceEvent_throttleRegistry[event][self]
+ t[RATE] = throttleRate
+ else
+ if AceEvent_throttleRegistry and AceEvent_throttleRegistry[event] then
+ if AceEvent_throttleRegistry[event][self] then
+ AceEvent_throttleRegistry[event][self] = nil
+ end
+ if not next(AceEvent_throttleRegistry[event]) then
+ AceEvent_throttleRegistry[event] = del(AceEvent_throttleRegistry[event])
+ end
+ end
+ end
+
+ if remember then
+ AceEvent:TriggerEvent("AceEvent_EventRegistered", self, event)
+ end
+end
+
+local ALL_EVENTS
+
+--[[----------------------------------------------------------------------------------
+Notes:
+ * Registers all events to the given method
+ * To access the current event, check AceEvent.currentEvent
+ * To access the current event's unique identifier, check AceEvent.currentEventUID
+ * This is only for debugging purposes.
+Arguments:
+ [optional] string or function - name of the method or function to call. Default: same name as "event".
+------------------------------------------------------------------------------------]]
+function AceEvent:RegisterAllEvents(method)
+ if self == AceEvent then
+ AceEvent:argCheck(method, 1, "function")
+ self = method
+ else
+ AceEvent:argCheck(method, 1, "string", "function")
+ if type(method) == "string" and type(self[method]) ~= "function" then
+ AceEvent:error("Cannot register all events to method %q, it does not exist", method)
+ end
+ end
+
+ local AceEvent_registry = AceEvent.registry
+ if not AceEvent_registry[ALL_EVENTS] then
+ AceEvent_registry[ALL_EVENTS] = new()
+ AceEvent.frame:RegisterAllEvents()
+ end
+
+ local remember = not AceEvent_registry[ALL_EVENTS][self]
+ AceEvent_registry[ALL_EVENTS][self] = method
+ if remember then
+ AceEvent:TriggerEvent("AceEvent_EventRegistered", self, "all")
+ end
+end
+
+--[[----------------------------------------------------------------------------------
+Notes:
+ * Trigger a custom AceEvent.
+ * This should never be called to simulate fake Blizzard events.
+ * Custom events should be in the form of AddonName_SpecificEvent
+Arguments:
+ string - name of the event
+ tuple - list of arguments to pass along
+------------------------------------------------------------------------------------]]
+function AceEvent:TriggerEvent(event, ...)
+ AceEvent:argCheck(event, 2, "string")
+ local AceEvent_registry = AceEvent.registry
+ if (not AceEvent_registry[event] or not next(AceEvent_registry[event])) and (not AceEvent_registry[ALL_EVENTS] or not next(AceEvent_registry[ALL_EVENTS])) then
+ return
+ end
+ local lastEvent = AceEvent.currentEvent
+ AceEvent.currentEvent = event
+ local lastEventUID = AceEvent.currentEventUID
+ local uid = AceEvent.UID_NUM + 1
+ AceEvent.UID_NUM = uid
+ AceEvent.currentEventUID = uid
+
+ local tmp = new()
+
+ local AceEvent_onceRegistry = AceEvent.onceRegistry
+ if AceEvent_onceRegistry and AceEvent_onceRegistry[event] then
+ for obj, method in pairs(AceEvent_onceRegistry[event]) do
+ tmp[obj] = AceEvent_registry[event] and AceEvent_registry[event][obj] or nil
+ end
+ local obj = next(tmp)
+ while obj do
+ local method = tmp[obj]
+ AceEvent.UnregisterEvent(obj, event)
+ if type(method) == "string" then
+ local obj_method = obj[method]
+ if obj_method then
+ local success, err = pcall(obj_method, obj, ...)
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("(.-: )in.-\n") or "") .. err) end
+ end
+ elseif method then -- function
+ local success, err = pcall(method, ...)
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("(.-: )in.-\n") or "") .. err) end
+ end
+ tmp[obj] = nil
+ obj = next(tmp)
+ end
+ end
+
+ local AceEvent_throttleRegistry = AceEvent.throttleRegistry
+ local throttleTable = AceEvent_throttleRegistry and AceEvent_throttleRegistry[event]
+ if AceEvent_registry[event] then
+ for obj, method in pairs(AceEvent_registry[event]) do
+ tmp[obj] = method
+ end
+ local obj = next(tmp)
+ while obj do
+ local cont = nil
+ if throttleTable and throttleTable[obj] then
+ local a1 = ...
+ if a1 == nil then
+ a1 = FAKE_NIL
+ end
+ if not throttleTable[obj][a1] or GetTime() - throttleTable[obj][a1] >= throttleTable[obj][RATE] then
+ throttleTable[obj][a1] = GetTime()
+ else
+ cont = true
+ end
+ end
+ if not cont then
+ local method = tmp[obj]
+ local t = type(method)
+ if t == "string" then
+ local obj_method = obj[method]
+ if obj_method then
+ local success, err = pcall(obj_method, obj, ...)
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("(.-: )in.-\n") or "") .. err) end
+ end
+ elseif t == "function" then -- function
+ local success, err = pcall(method, ...)
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("(.-: )in.-\n") or "") .. err) end
+ else
+ AceEvent:error("Cannot trigger event %q. %q's handler, %q, is not a method or function (%s).", event, obj, method, t)
+ end
+ end
+ tmp[obj] = nil
+ obj = next(tmp)
+ end
+ end
+ if AceEvent_registry[ALL_EVENTS] then
+ for obj, method in pairs(AceEvent_registry[ALL_EVENTS]) do
+ tmp[obj] = method
+ end
+ local obj = next(tmp)
+ while obj do
+ local method = tmp[obj]
+ local t = type(method)
+ if t == "string" then
+ local obj_method = obj[method]
+ if obj_method then
+ local success, err = pcall(obj_method, obj, ...)
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("(.-: )in.-\n") or "") .. err) end
+ end
+ elseif t == "function" then
+ local success, err = pcall(method, ...)
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("(.-: )in.-\n") or "") .. err) end
+ else
+ AceEvent:error("Cannot trigger event %q. %q's handler, %q, is not a method or function (%s).", event, obj, method, t)
+ end
+ tmp[obj] = nil
+ obj = next(tmp)
+ end
+ end
+ tmp = del(tmp)
+ AceEvent.currentEvent = lastEvent
+ AceEvent.currentEventUID = lastEventUID
+end
+
+local delayRegistry
+local OnUpdate
+do
+ local tmp = {}
+ OnUpdate = function()
+ local t = GetTime()
+ for k,v in pairs(delayRegistry) do
+ tmp[k] = true
+ end
+ for k in pairs(tmp) do
+ local v = delayRegistry[k]
+ if v then
+ local v_time = v.time
+ if not v_time then
+ delayRegistry[k] = nil
+ elseif v_time <= t then
+ local v_repeatDelay = v.repeatDelay
+ if v_repeatDelay then
+ -- use the event time, not the current time, else timing inaccuracies add up over time
+ v.time = v_time + v_repeatDelay
+ end
+ local event = v.event
+ local t = type(event)
+ if t == "function" then
+ local uid = AceEvent.UID_NUM + 1
+ AceEvent.UID_NUM = uid
+ AceEvent.currentEventUID = uid
+ local success, err = pcall(event, unpack(v, 1, v.n))
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("(.-: )in.-\n") or "") .. err) end
+ AceEvent.currentEventUID = nil
+ elseif t == "string" then
+ AceEvent:TriggerEvent(event, unpack(v, 1, v.n))
+ else
+ AceEvent:error("Cannot trigger event %q, it's not a method or function (%s).", event, t)
+ end
+ if not v_repeatDelay then
+ local x = delayRegistry[k]
+ if x and x.time == v_time then -- check if it was manually reset
+ if type(k) == "string" then
+ del(delayRegistry[k])
+ end
+ delayRegistry[k] = nil
+ end
+ end
+ end
+ end
+ end
+ for k in pairs(tmp) do
+ tmp[k] = nil
+ end
+ if not next(delayRegistry) then
+ AceEvent.frame:Hide()
+ end
+ end
+end
+
+local function ScheduleEvent(self, repeating, event, delay, ...)
+ local id
+ if type(event) == "string" and type(delay) ~= "number" then
+ id, event, delay = event, delay, ...
+ AceEvent:argCheck(event, 3, "string", "function", --[[ so message is right ]] "number")
+ AceEvent:argCheck(delay, 4, "number")
+ self:CancelScheduledEvent(id)
+ else
+ AceEvent:argCheck(event, 2, "string", "function")
+ AceEvent:argCheck(delay, 3, "number")
+ end
+
+ if not delayRegistry then
+ AceEvent.delayRegistry = {}
+ delayRegistry = AceEvent.delayRegistry
+ AceEvent.frame:SetScript("OnUpdate", OnUpdate)
+ end
+ local t
+ if id then
+ t = new(select(2, ...))
+ t.n = select('#', ...) - 1
+ else
+ t = new(...)
+ t.n = select('#', ...)
+ end
+ t.event = event
+ t.time = GetTime() + delay
+ t.self = self
+ t.id = id or t
+ t.repeatDelay = repeating and delay
+ delayRegistry[t.id] = t
+ AceEvent.frame:Show()
+end
+
+--[[----------------------------------------------------------------------------------
+Notes:
+ * Schedule an event to fire.
+ * To fire on the next frame, specify a delay of 0.
+Arguments:
+ string or function - name of the event to fire, or a function to call.
+ number - the amount of time to wait until calling.
+ tuple - a list of arguments to pass along.
+------------------------------------------------------------------------------------]]
+function AceEvent:ScheduleEvent(event, delay, ...)
+ if type(event) == "string" and type(delay) ~= "number" then
+ AceEvent:argCheck(delay, 3, "string", "function", --[[ so message is right ]] "number")
+ AceEvent:argCheck(..., 4, "number")
+ else
+ AceEvent:argCheck(event, 2, "string", "function")
+ AceEvent:argCheck(delay, 3, "number")
+ end
+
+ return ScheduleEvent(self, false, event, delay, ...)
+end
+
+function AceEvent:ScheduleRepeatingEvent(event, delay, ...)
+ if type(event) == "string" and type(delay) ~= "number" then
+ AceEvent:argCheck(delay, 3, "string", "function", --[[ so message is right ]] "number")
+ AceEvent:argCheck(..., 4, "number")
+ else
+ AceEvent:argCheck(event, 2, "string", "function")
+ AceEvent:argCheck(delay, 3, "number")
+ end
+
+ return ScheduleEvent(self, true, event, delay, ...)
+end
+
+function AceEvent:CancelScheduledEvent(t)
+ AceEvent:argCheck(t, 2, "string")
+ if delayRegistry then
+ local v = delayRegistry[t]
+ if v then
+ if type(t) == "string" then
+ del(delayRegistry[t])
+ end
+ delayRegistry[t] = nil
+ if not next(delayRegistry) then
+ AceEvent.frame:Hide()
+ end
+ return true
+ end
+ end
+ return false
+end
+
+function AceEvent:IsEventScheduled(t)
+ AceEvent:argCheck(t, 2, "string")
+ if delayRegistry then
+ local v = delayRegistry[t]
+ if v then
+ return true, v.time - GetTime()
+ end
+ end
+ return false, nil
+end
+
+function AceEvent:UnregisterEvent(event)
+ AceEvent:argCheck(event, 2, "string")
+ local AceEvent_registry = AceEvent.registry
+ if AceEvent_registry[event] and AceEvent_registry[event][self] then
+ AceEvent_registry[event][self] = nil
+ local AceEvent_onceRegistry = AceEvent.onceRegistry
+ if AceEvent_onceRegistry and AceEvent_onceRegistry[event] and AceEvent_onceRegistry[event][self] then
+ AceEvent_onceRegistry[event][self] = nil
+ if not next(AceEvent_onceRegistry[event]) then
+ AceEvent_onceRegistry[event] = del(AceEvent_onceRegistry[event])
+ end
+ end
+ local AceEvent_throttleRegistry = AceEvent.throttleRegistry
+ if AceEvent_throttleRegistry and AceEvent_throttleRegistry[event] and AceEvent_throttleRegistry[event][self] then
+ AceEvent_throttleRegistry[event][self] = nil
+ if not next(AceEvent_throttleRegistry[event]) then
+ AceEvent_throttleRegistry[event] = del(AceEvent_throttleRegistry[event])
+ end
+ end
+ if not next(AceEvent_registry[event]) then
+ AceEvent_registry[event] = del(AceEvent_registry[event])
+ if not AceEvent_registry[ALL_EVENTS] or not next(AceEvent_registry[ALL_EVENTS]) then
+ AceEvent.frame:UnregisterEvent(event)
+ end
+ end
+ else
+ if self == AceEvent then
+ error(("Cannot unregister event %q. Improperly unregistering from AceEvent-2.0."):format(event), 2)
+ else
+ AceEvent:error("Cannot unregister event %q. %q is not registered with it.", event, self)
+ end
+ end
+ AceEvent:TriggerEvent("AceEvent_EventUnregistered", self, event)
+end
+
+function AceEvent:UnregisterAllEvents()
+ local AceEvent_registry = AceEvent.registry
+ if AceEvent_registry[ALL_EVENTS] and AceEvent_registry[ALL_EVENTS][self] then
+ AceEvent_registry[ALL_EVENTS][self] = nil
+ if not next(AceEvent_registry[ALL_EVENTS]) then
+ AceEvent_registry[ALL_EVENTS] = del(AceEvent_registry[ALL_EVENTS])
+ AceEvent.frame:UnregisterAllEvents()
+ for k,v in pairs(AceEvent_registry) do
+ AceEvent.frame:RegisterEvent(k)
+ end
+ end
+ end
+ if AceEvent_registry.AceEvent_EventUnregistered then
+ local event, data = "AceEvent_EventUnregistered", AceEvent_registry.AceEvent_EventUnregistered
+ local x = data[self]
+ data[self] = nil
+ if x then
+ if not next(data) then
+ if not AceEvent_registry[ALL_EVENTS] then
+ AceEvent.frame:UnregisterEvent(event)
+ end
+ AceEvent_registry[event] = del(AceEvent_registry[event])
+ end
+ AceEvent:TriggerEvent("AceEvent_EventUnregistered", self, event)
+ end
+ end
+ for event, data in pairs(AceEvent_registry) do
+ local x = data[self]
+ data[self] = nil
+ if x and event ~= ALL_EVENTS then
+ if not next(data) then
+ if not AceEvent_registry[ALL_EVENTS] then
+ AceEvent.frame:UnregisterEvent(event)
+ end
+ AceEvent_registry[event] = del(AceEvent_registry[event])
+ end
+ AceEvent:TriggerEvent("AceEvent_EventUnregistered", self, event)
+ end
+ end
+ if AceEvent.onceRegistry then
+ for event, data in pairs(AceEvent.onceRegistry) do
+ data[self] = nil
+ end
+ end
+end
+
+function AceEvent:CancelAllScheduledEvents()
+ if delayRegistry then
+ for k,v in pairs(delayRegistry) do
+ if v.self == self then
+ if type(k) == "string" then
+ del(delayRegistry[k])
+ end
+ delayRegistry[k] = nil
+ end
+ end
+ if not next(delayRegistry) then
+ AceEvent.frame:Hide()
+ end
+ end
+end
+
+function AceEvent:IsEventRegistered(event)
+ AceEvent:argCheck(event, 2, "string")
+ local AceEvent_registry = AceEvent.registry
+ if self == AceEvent then
+ return AceEvent_registry[event] and next(AceEvent_registry[event]) or AceEvent_registry[ALL_EVENTS] and next(AceEvent_registry[ALL_EVENTS]) and true or false
+ end
+ if AceEvent_registry[event] and AceEvent_registry[event][self] then
+ return true, AceEvent_registry[event][self]
+ end
+ if AceEvent_registry[ALL_EVENTS] and AceEvent_registry[ALL_EVENTS][self] then
+ return true, AceEvent_registry[ALL_EVENTS][self]
+ end
+ return false, nil
+end
+
+local UnitExists = UnitExists
+local bucketfunc
+function AceEvent:RegisterBucketEvent(event, delay, method, ...)
+ AceEvent:argCheck(event, 2, "string", "table")
+ if type(event) == "table" then
+ for k,v in pairs(event) do
+ if type(k) ~= "number" then
+ AceEvent:error("All keys to argument #2 to `RegisterBucketEvent' must be numbers.")
+ elseif type(v) ~= "string" then
+ AceEvent:error("All values to argument #2 to `RegisterBucketEvent' must be strings.")
+ end
+ end
+ end
+ AceEvent:argCheck(delay, 3, "number")
+ if AceEvent == self then
+ AceEvent:argCheck(method, 4, "function")
+ self = method
+ else
+ if type(event) == "string" then
+ AceEvent:argCheck(method, 4, "string", "function", "nil")
+ if not method then
+ method = event
+ end
+ else
+ AceEvent:argCheck(method, 4, "string", "function")
+ end
+
+ if type(method) == "string" and type(self[method]) ~= "function" then
+ AceEvent:error("Cannot register event %q to method %q, it does not exist", event, method)
+ end
+ end
+ local buckets = AceEvent.buckets
+ if not buckets[event] then
+ buckets[event] = new()
+ end
+ if not buckets[event][self] then
+ local t = {}
+ t.current = {}
+ t.self = self
+ buckets[event][self] = t
+ else
+ AceEvent.CancelScheduledEvent(self, buckets[event][self].id)
+ end
+ local bucket = buckets[event][self]
+ bucket.method = method
+
+ local n = select('#', ...)
+ if n > 0 then
+ for i = 1, n do
+ bucket[i] = select(i, ...)
+ end
+ end
+ bucket.n = n
+
+ local func = function(arg1)
+ bucket.run = true
+ if arg1 then
+ bucket.current[arg1] = true
+ end
+ end
+ buckets[event][self].func = func
+ local isUnitBucket = true
+ if type(event) == "string" then
+ AceEvent.RegisterEvent(self, event, func)
+ if not event:find("^UNIT_") then
+ isUnitBucket = nil
+ end
+ else
+ for _,v in ipairs(event) do
+ AceEvent.RegisterEvent(self, v, func)
+ if isUnitBucket and not v:find("^UNIT_") then
+ isUnitBucket = nil
+ end
+ end
+ end
+ bucket.unit = isUnitBucket
+ if not bucketfunc then
+ bucketfunc = function(bucket)
+ if bucket.run then
+ local current = bucket.current
+ local method = bucket.method
+ local self = bucket.self
+ if bucket.unit then
+ for unit in pairs(current) do
+ if not UnitExists(unit) then
+ current[unit] = nil
+ end
+ end
+ end
+ if type(method) == "string" then
+ self[method](self, current, unpack(bucket, 1, bucket.n))
+ elseif method then -- function
+ method(current, unpack(bucket, 1, bucket.n))
+ end
+ for k in pairs(current) do
+ current[k] = nil
+ k = nil
+ end
+ bucket.run = nil
+ end
+ end
+ end
+ bucket.id = "AceEvent-Bucket-" .. tostring(bucket)
+ AceEvent.ScheduleRepeatingEvent(self, bucket.id, bucketfunc, delay, bucket)
+end
+
+function AceEvent:IsBucketEventRegistered(event)
+ AceEvent:argCheck(event, 2, "string", "table")
+ return AceEvent.buckets and AceEvent.buckets[event] and AceEvent.buckets[event][self]
+end
+
+function AceEvent:UnregisterBucketEvent(event)
+ AceEvent:argCheck(event, 2, "string", "table")
+ if not AceEvent.buckets or not AceEvent.buckets[event] or not AceEvent.buckets[event][self] then
+ AceEvent:error("Cannot unregister bucket event %q. %q is not registered with it.", event, self)
+ end
+
+ local bucket = AceEvent.buckets[event][self]
+
+ if type(event) == "string" then
+ AceEvent.UnregisterEvent(self, event)
+ else
+ for _,v in ipairs(event) do
+ AceEvent.UnregisterEvent(self, v)
+ end
+ end
+ AceEvent:CancelScheduledEvent(bucket.id)
+
+ bucket.current = nil
+ AceEvent.buckets[event][self] = nil
+ if not next(AceEvent.buckets[event]) then
+ AceEvent.buckets[event] = del(AceEvent.buckets[event])
+ end
+end
+
+function AceEvent:UnregisterAllBucketEvents()
+ if not AceEvent.buckets or not next(AceEvent.buckets) then
+ return
+ end
+ for k,v in pairs(AceEvent.buckets) do
+ if v == self then
+ AceEvent.UnregisterBucketEvent(self, k)
+ k = nil
+ end
+ end
+end
+
+local combatSchedules
+function AceEvent:CancelAllCombatSchedules()
+ local i = 0
+ while true do
+ i = i + 1
+ if not combatSchedules[i] then
+ break
+ end
+ local v = combatSchedules[i]
+ if v.self == self then
+ v = del(v)
+ table.remove(combatSchedules, i)
+ i = i - 1
+ end
+ end
+end
+
+local inCombat = false
+
+function AceEvent:PLAYER_REGEN_DISABLED()
+ inCombat = true
+end
+
+do
+ local tmp = {}
+ function AceEvent:PLAYER_REGEN_ENABLED()
+ inCombat = false
+ for i, v in ipairs(combatSchedules) do
+ tmp[i] = v
+ combatSchedules[i] = nil
+ end
+ for i, v in ipairs(tmp) do
+ local func = v.func
+ if func then
+ local success, err = pcall(func, unpack(v, 1, v.n))
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("(.-: )in.-\n") or "") .. err) end
+ else
+ local obj = v.obj or v.self
+ local method = v.method
+ local obj_method = obj[method]
+ if obj_method then
+ local success, err = pcall(obj_method, obj, unpack(v, 1, v.n))
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("(.-: )in.-\n") or "") .. err) end
+ end
+ end
+ tmp[i] = del(v)
+ end
+ end
+end
+
+function AceEvent:ScheduleLeaveCombatAction(method, ...)
+ local style = type(method)
+ if self == AceEvent then
+ if style == "table" then
+ local func = (...)
+ AceEvent:argCheck(func, 3, "string")
+ if type(method[func]) ~= "function" then
+ AceEvent:error("Cannot schedule a combat action to method %q, it does not exist", func)
+ end
+ else
+ AceEvent:argCheck(method, 2, "function", --[[so message is right]] "table")
+ end
+ self = method
+ else
+ AceEvent:argCheck(method, 2, "function", "string", "table")
+ if style == "string" and type(self[method]) ~= "function" then
+ AceEvent:error("Cannot schedule a combat action to method %q, it does not exist", method)
+ elseif style == "table" then
+ local func = (...)
+ AceEvent:argCheck(func, 3, "string")
+ if type(method[func]) ~= "function" then
+ AceEvent:error("Cannot schedule a combat action to method %q, it does not exist", func)
+ end
+ end
+ end
+
+ if not inCombat then
+ local success, err
+ if type(method) == "function" then
+ success, err = pcall(method, ...)
+ elseif type(method) == "table" then
+ local func = (...)
+ success, err = pcall(method[func], method, select(2, ...))
+ else
+ success, err = pcall(self[method], self, ...)
+ end
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("(.-: )in.-\n") or "") .. err) end
+ return
+ end
+ local t
+ local n = select('#', ...)
+ if style == "table" then
+ t = new(select(2, ...))
+ t.obj = method
+ t.method = (...)
+ t.n = n-1
+ else
+ t = new(...)
+ t.n = n
+ if style == "function" then
+ t.func = method
+ else
+ t.method = method
+ end
+ end
+ t.self = self
+ table.insert(combatSchedules, t)
+end
+
+function AceEvent:OnEmbedDisable(target)
+ self.UnregisterAllEvents(target)
+
+ self.CancelAllScheduledEvents(target)
+
+ self.UnregisterAllBucketEvents(target)
+
+ self.CancelAllCombatSchedules(target)
+end
+
+function AceEvent:IsFullyInitialized()
+ return self.postInit or false
+end
+
+local function activate(self, oldLib, oldDeactivate)
+ AceEvent = self
+
+ self.onceRegistry = oldLib and oldLib.onceRegistry or {}
+ self.throttleRegistry = oldLib and oldLib.throttleRegistry or {}
+ self.delayRegistry = oldLib and oldLib.delayRegistry or {}
+ self.buckets = oldLib and oldLib.buckets or {}
+ self.registry = oldLib and oldLib.registry or {}
+ self.frame = oldLib and oldLib.frame or CreateFrame("Frame", "AceEvent20Frame")
+ self.playerLogin = IsLoggedIn() and true
+ self.postInit = oldLib and oldLib.postInit or self.playerLogin and ChatTypeInfo and ChatTypeInfo.WHISPER and ChatTypeInfo.WHISPER.r and true
+ self.ALL_EVENTS = oldLib and oldLib.ALL_EVENTS or _G.newproxy()
+ self.FAKE_NIL = oldLib and oldLib.FAKE_NIL or _G.newproxy()
+ self.RATE = oldLib and oldLib.RATE or _G.newproxy()
+ self.combatSchedules = oldLib and oldLib.combatSchedules or {}
+ self.UID_NUM = oldLib and oldLib.UID_NUM or 0
+
+ combatSchedules = self.combatSchedules
+ ALL_EVENTS = self.ALL_EVENTS
+ FAKE_NIL = self.FAKE_NIL
+ RATE = self.RATE
+ local inPlw = false
+ local blacklist = {
+ UNIT_INVENTORY_CHANGED = true,
+ BAG_UPDATE = true,
+ ITEM_LOCK_CHANGED = true,
+ ACTIONBAR_SLOT_CHANGED = true,
+ }
+ self.frame:SetScript("OnEvent", function(_, event, ...)
+ if event == "PLAYER_ENTERING_WORLD" then
+ inPlw = false
+ elseif event == "PLAYER_LEAVING_WORLD" then
+ inPlw = true
+ end
+ if event and (not inPlw or not blacklist[event]) then
+ self:TriggerEvent(event, ...)
+ end
+ end)
+ if self.delayRegistry then
+ delayRegistry = self.delayRegistry
+ self.frame:SetScript("OnUpdate", OnUpdate)
+ end
+
+ self:UnregisterAllEvents()
+ self:CancelAllScheduledEvents()
+
+ local function handleFullInit()
+ if not self.postInit then
+ local function func()
+ self.postInit = true
+ self:TriggerEvent("AceEvent_FullyInitialized")
+ if self.registry["CHAT_MSG_CHANNEL_NOTICE"] and self.registry["CHAT_MSG_CHANNEL_NOTICE"][self] then
+ self:UnregisterEvent("CHAT_MSG_CHANNEL_NOTICE")
+ end
+ if self.registry["PLAYER_ALIVE"] and self.registry["PLAYER_ALIVE"][self] then
+ self:UnregisterEvent("PLAYER_ALIVE")
+ end
+ end
+ registeringFromAceEvent = true
+ self:RegisterEvent("PLAYER_ALIVE", func, true)
+ self:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE", func, true)
+
+ self:ScheduleEvent("AceEvent_FullyInitialized", func, 10)
+ registeringFromAceEvent = nil
+ end
+ end
+
+ if not self.playerLogin then
+ registeringFromAceEvent = true
+ self:RegisterEvent("PLAYER_LOGIN", function()
+ self.playerLogin = true
+ handleFullInit()
+ handleFullInit = nil
+ end, true)
+ registeringFromAceEvent = nil
+ else
+ handleFullInit()
+ handleFullInit = nil
+ end
+
+ if not AceEvent20EditBox then
+ CreateFrame("Editbox", "AceEvent20EditBox")
+ end
+ local editbox = AceEvent20EditBox
+ function editbox:Execute(line)
+ local defaulteditbox = DEFAULT_CHAT_FRAME.editBox
+ self:SetAttribute("chatType", defaulteditbox:GetAttribute("chatType"))
+ self:SetAttribute("tellTarget", defaulteditbox:GetAttribute("tellTarget"))
+ self:SetAttribute("channelTarget", defaulteditbox:GetAttribute("channelTarget"))
+ self:SetText(line)
+ ChatEdit_SendText(self)
+ end
+ editbox:Hide()
+ _G["SLASH_IN1"] = "/in"
+ SlashCmdList["IN"] = function(msg)
+ local seconds, command, rest = msg:match("^([^%s]+)%s+(/[^%s]+)(.*)$")
+ seconds = tonumber(seconds)
+ if not seconds then
+ DEFAULT_CHAT_FRAME:AddMessage("Error, bad arguments to /in. Must be in the form of `/in 5 /say hi'")
+ return
+ end
+ if IsSecureCmd(command) then
+ DEFAULT_CHAT_FRAME:AddMessage(("Error, /in cannot call secure command: %s"):format(command))
+ return
+ end
+ self:ScheduleEvent("AceEventSlashIn-" .. math.random(1, 1000000000), editbox.Execute, seconds, editbox, command .. rest)
+ end
+
+ registeringFromAceEvent = true
+ self:RegisterEvent("PLAYER_REGEN_ENABLED")
+ self:RegisterEvent("PLAYER_REGEN_DISABLED")
+ self:RegisterEvent("LOOT_OPENED", function()
+ if GetNumGroupMembers() > 0 or GetNumSubgroupMembers() > 0 then C_ChatInfo.SendAddonMessage("LOOT_OPENED", "", "RAID") end
+ end)
+ inCombat = InCombatLockdown()
+ registeringFromAceEvent = nil
+
+ self:activate(oldLib, oldDeactivate)
+ if oldLib then
+ oldDeactivate(oldLib)
+ end
+end
+
+AceLibrary:Register(AceEvent, MAJOR_VERSION, MINOR_VERSION, activate)
diff --git a/FuBar_DurabilityFu/libs/AceEvent-2.0/AceEvent-2.0.toc b/FuBar_DurabilityFu/libs/AceEvent-2.0/AceEvent-2.0.toc
new file mode 100644
index 0000000..da417fa
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceEvent-2.0/AceEvent-2.0.toc
@@ -0,0 +1,17 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r1101
+## X-Curse-Project-Name: Ace2
+## X-Curse-Project-ID: ace2
+## X-Curse-Repository-ID: wow/ace2/mainline
+
+## Title: Lib: AceEvent-2.0
+## Notes: AddOn development framework
+## Author: Ace Development Team
+## LoadOnDemand: 1
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-License: LGPL v2.1 + MIT for AceOO-2.0
+## Dependencies: AceLibrary, AceOO-2.0
+
+AceEvent-2.0.lua
+
diff --git a/FuBar_DurabilityFu/libs/AceHook-2.1/AceHook-2.1.lua b/FuBar_DurabilityFu/libs/AceHook-2.1/AceHook-2.1.lua
new file mode 100644
index 0000000..a54dbda
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceHook-2.1/AceHook-2.1.lua
@@ -0,0 +1,553 @@
+--[[
+Name: AceHook-2.1
+Revision: $Rev: 1091 $
+Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team)
+Inspired By: Ace 1.x by Turan (turan@gryphon.com)
+Website: http://www.wowace.com/
+Documentation: http://www.wowace.com/index.php/AceHook-2.1
+SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceHook-2.1
+Description: Mixin to allow for safe hooking of functions, methods, and scripts.
+Dependencies: AceLibrary, AceOO-2.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "AceHook-2.1"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 1091 $"):match("(%d+)"))
+
+-- This ensures the code is only executed if the libary doesn't already exist, or is a newer version
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+if not AceLibrary:HasInstance("AceOO-2.0") then error(MAJOR_VERSION .. " requires AceOO-2.0") end
+
+--[[---------------------------------------------------------------------------------
+ Create the library object
+----------------------------------------------------------------------------------]]
+
+local AceOO = AceLibrary:GetInstance("AceOO-2.0")
+local AceHook = AceOO.Mixin {
+ "Hook",
+ "HookScript",
+ "SecureHook",
+ "SecureHookScript",
+ "Unhook",
+ "UnhookAll",
+ "HookReport",
+ "IsHooked",
+ }
+
+--[[---------------------------------------------------------------------------------
+ Library Definitions
+----------------------------------------------------------------------------------]]
+
+local protectedScripts = {
+ OnClick = true,
+}
+
+local _G = getfenv(0)
+
+local handlers, scripts, actives, registry, onceSecure
+
+--[[---------------------------------------------------------------------------------
+ Private definitions (Not exposed)
+----------------------------------------------------------------------------------]]
+
+local new, del
+do
+ local list = setmetatable({}, {__mode = "k"})
+ function new()
+ local t = next(list)
+ if not t then
+ return {}
+ end
+ list[t] = nil
+ return t
+ end
+
+ function del(t)
+ setmetatable(t, nil)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ list[t] = true
+ end
+end
+
+local function createFunctionHook(self, func, handler, orig, secure)
+ if not secure then
+ if type(handler) == "string" then
+ -- The handler is a method, need to self it
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return self[handler](self, ...)
+ else
+ return orig(...)
+ end
+ end
+ return uid
+ else
+ -- The handler is a function, just call it
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return handler(...)
+ else
+ return orig(...)
+ end
+ end
+ return uid
+ end
+ else
+ -- secure hooks don't call the original method
+ if type(handler) == "string" then
+ -- The handler is a method, need to self it
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return self[handler](self, ...)
+ end
+ end
+ return uid
+ else
+ -- The handler is a function, just call it
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return handler(...)
+ end
+ end
+ return uid
+ end
+ end
+end
+
+local function createMethodHook(self, object, method, handler, orig, secure)
+ if not secure then
+ if type(handler) == "string" then
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return self[handler](self, ...)
+ else
+ return orig(...)
+ end
+ end
+ return uid
+ else
+ -- The handler is a function, just call it
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return handler(...)
+ else
+ return orig(...)
+ end
+ end
+ return uid
+ end
+ else
+ -- secure hooks don't call the original method
+ if type(handler) == "string" then
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return self[handler](self, ...)
+ end
+ end
+ return uid
+ else
+ -- The handler is a function, just call it
+ local uid
+ uid = function(...)
+ if actives[uid] then
+ return handler(...)
+ end
+ end
+ return uid
+ end
+ end
+end
+
+local function hookFunction(self, func, handler, secure)
+ local orig = _G[func]
+ if not orig or type(orig) ~= "function" then
+ AceHook:error("Attempt to hook a non-existant function %q", func)
+ end
+
+ if not handler then
+ handler = func
+ end
+
+ local uid = registry[self][func]
+ if uid then
+ if actives[uid] then
+ -- We have an active hook from this source. Don't multi-hook
+ AceHook:error("%q already has an active hook from this source.", func)
+ end
+
+ if handlers[uid] == handler then
+ -- The hook is inactive, so reactivate it
+ actives[uid] = true
+ return
+ else
+ self.hooks[func] = nil
+ registry[self][func] = nil
+ handlers[uid] = nil
+ uid = nil
+ end
+ end
+
+ if type(handler) == "string" then
+ if type(self[handler]) ~= "function" then
+ AceHook:error("Could not find the the handler %q when hooking function %q", handler, func)
+ end
+ elseif type(handler) ~= "function" then
+ AceHook:error("Could not find the handler you supplied when hooking %q", func)
+ end
+
+ uid = createFunctionHook(self, func, handler, orig, secure)
+ registry[self][func] = uid
+ actives[uid] = true
+ handlers[uid] = handler
+
+ if not secure then
+ _G[func] = uid
+ self.hooks[func] = orig
+ else
+ hooksecurefunc(func, uid)
+ end
+end
+
+local function unhookFunction(self, func)
+ if not registry[self][func] then
+ AceHook:error("Tried to unhook %q which is not currently hooked.", func)
+ end
+
+ local uid = registry[self][func]
+
+ if actives[uid] then
+ -- See if we own the global function
+ if self.hooks[func] and _G[func] == uid then
+ _G[func] = self.hooks[func]
+ self.hooks[func] = nil
+ registry[self][func] = nil
+ handlers[uid] = nil
+ actives[uid] = nil
+ -- Magically all-done
+ else
+ actives[uid] = nil
+ end
+ end
+end
+
+local donothing = function() end
+
+local function hookMethod(self, obj, method, handler, script, secure)
+ if not handler then
+ handler = method
+ end
+
+ if not obj or type(obj) ~= "table" then
+ AceHook:error("The object you supplied could not be found, or isn't a table.")
+ end
+
+ local uid = registry[self][obj] and registry[self][obj][method]
+ if uid then
+ if actives[uid] then
+ -- We have an active hook from this source. Don't multi-hook
+ AceHook:error("%q already has an active hook from this source.", method)
+ end
+
+ if handlers[uid] == handler then
+ -- The hook is inactive, reactivate it.
+ actives[uid] = true
+ return
+ else
+ if self.hooks[obj] then
+ self.hooks[obj][method] = nil
+ end
+ registry[self][obj][method] = nil
+ handlers[uid] = nil
+ actives[uid] = nil
+ scripts[uid] = nil
+ uid = nil
+ end
+ end
+
+ if type(handler) == "string" then
+ if type(self[handler]) ~= "function" then
+ AceHook:error("Could not find the handler %q you supplied when hooking method %q", handler, method)
+ end
+ elseif type(handler) ~= "function" then
+ AceHook:error("Could not find the handler you supplied when hooking method %q", method)
+ end
+
+ local orig
+ if script then
+ if not obj.GetScript then
+ AceHook:error("The object you supplied does not have a GetScript method.")
+ end
+ if not obj:HasScript(method) then
+ AceHook:error("The object you supplied doesn't allow the %q method.", method)
+ end
+
+ orig = obj:GetScript(method)
+ if type(orig) ~= "function" then
+ -- Sometimes there is not a original function for a script.
+ orig = donothing
+ end
+ else
+ orig = obj[method]
+ end
+ if not orig then
+ AceHook:error("Could not find the method or script %q you are trying to hook.", method)
+ end
+
+ if not self.hooks[obj] then
+ self.hooks[obj] = new()
+ end
+ if not registry[self][obj] then
+ registry[self][obj] = new()
+ end
+
+ local uid = createMethodHook(self, obj, method, handler, orig, secure)
+ registry[self][obj][method] = uid
+ actives[uid] = true
+ handlers[uid] = handler
+ scripts[uid] = script and true or nil
+
+ if script then
+ if not secure then
+ obj:SetScript(method, uid)
+ self.hooks[obj][method] = orig
+ else
+ obj:HookScript(method, uid)
+ end
+ else
+ if not secure then
+ obj[method] = uid
+ self.hooks[obj][method] = orig
+ else
+ hooksecurefunc(obj, method, uid)
+ end
+ end
+end
+
+local function unhookMethod(self, obj, method)
+ if not registry[self][obj] or not registry[self][obj][method] then
+ AceHook:error("Attempt to unhook a method %q that is not currently hooked.", method)
+ return
+ end
+
+ local uid = registry[self][obj][method]
+
+ if actives[uid] then
+ if scripts[uid] then -- If this is a script
+ if obj:GetScript(method) == uid then
+ -- We own the script. Revert to normal.
+ if self.hooks[obj][method] == donothing then
+ obj:SetScript(method, nil)
+ else
+ obj:SetScript(method, self.hooks[obj][method])
+ end
+ self.hooks[obj][method] = nil
+ registry[self][obj][method] = nil
+ handlers[uid] = nil
+ scripts[uid] = nil
+ actives[uid] = nil
+ else
+ actives[uid] = nil
+ end
+ else
+ if self.hooks[obj] and self.hooks[obj][method] and obj[method] == uid then
+ -- We own the method. Revert to normal.
+ obj[method] = self.hooks[obj][method]
+ self.hooks[obj][method] = nil
+ registry[self][obj][method] = nil
+ handlers[uid] = nil
+ actives[uid] = nil
+ else
+ actives[uid] = nil
+ end
+ end
+ end
+ if self.hooks[obj] and not next(self.hooks[obj]) then
+ self.hooks[obj] = del(self.hooks[obj])
+ end
+ if not next(registry[self][obj]) then
+ registry[self][obj] = del(registry[self][obj])
+ end
+end
+
+-- ("function" [, handler] [, hookSecure]) or (object, "method" [, handler] [, hookSecure])
+function AceHook:Hook(object, method, handler, hookSecure)
+ if type(object) == "string" then
+ method, handler, hookSecure = object, method, handler
+ if handler == true then
+ handler, hookSecure = nil, true
+ end
+ AceHook:argCheck(handler, 3, "function", "string", "nil")
+ AceHook:argCheck(hookSecure, 4, "boolean", "nil")
+ if issecurevariable(method) or onceSecure[method] then
+ if hookSecure then
+ onceSecure[method] = true
+ else
+ AceHook:error("Attempt to hook secure function %q. Use `SecureHook' or add `true' to the argument list to override.", method)
+ end
+ end
+ hookFunction(self, method, handler, false)
+ else
+ if handler == true then
+ handler, hookSecure = nil, true
+ end
+ AceHook:argCheck(object, 2, "table")
+ AceHook:argCheck(method, 3, "string")
+ AceHook:argCheck(handler, 4, "function", "string", "nil")
+ AceHook:argCheck(hookSecure, 5, "boolean", "nil")
+ if not object[method] then
+ AceHook:error("Attempt to hook method %q failed, it does not exist in the given object %q.", method, object)
+ end
+ if not hookSecure and issecurevariable(object, method) then
+ AceHook:error("Attempt to hook secure method %q. Use `SecureHook' or add `true' to the argument list to override.", method)
+ end
+ hookMethod(self, object, method, handler, false, false)
+ end
+end
+
+-- ("function", handler) or (object, "method", handler)
+function AceHook:SecureHook(object, method, handler)
+ if type(object) == "string" then
+ method, handler = object, method
+ AceHook:argCheck(handler, 3, "function", "string", "nil")
+ hookFunction(self, method, handler, true)
+ else
+ AceHook:argCheck(object, 2, "table")
+ AceHook:argCheck(method, 3, "string")
+ AceHook:argCheck(handler, 4, "function", "string", "nil")
+ if not object[method] then
+ AceHook:error("Attempt to hook method %q failed, it does not exist in the given object %q.", method, object)
+ end
+ hookMethod(self, object, method, handler, false, true)
+ end
+end
+
+function AceHook:HookScript(frame, script, handler)
+ AceHook:argCheck(frame, 2, "table")
+ if not frame[0] or type(frame.IsProtected) ~= "function" then
+ AceHook:error("Bad argument #2 to `HookScript'. Expected frame.")
+ end
+ AceHook:argCheck(script, 3, "string")
+ AceHook:argCheck(handler, 4, "function", "string", "nil")
+ if frame:IsProtected() and protectedScripts[script] then
+ AceHook:error("Cannot hook secure script %q.", script)
+ end
+ hookMethod(self, frame, script, handler, true, false)
+end
+
+function AceHook:SecureHookScript(frame, script, handler)
+ AceHook:argCheck(frame, 2, "table")
+ if not frame[0] or type(frame.IsProtected) ~= "function" then
+ AceHook:error("Bad argument #2 to `HookScript'. Expected frame.")
+ end
+ AceHook:argCheck(script, 3, "string")
+ AceHook:argCheck(handler, 4, "function", "string", "nil")
+ hookMethod(self, frame, script, handler, true, true)
+end
+
+-- ("function") or (object, "method")
+function AceHook:IsHooked(obj, method)
+ if type(obj) == "string" then
+ if registry[self][obj] and actives[registry[self][obj]] then
+ return true, handlers[registry[self][obj]]
+ end
+ else
+ AceHook:argCheck(obj, 2, "string", "table")
+ AceHook:argCheck(method, 3, "string")
+ if registry[self][obj] and registry[self][obj][method] and actives[registry[self][obj][method]] then
+ return true, handlers[registry[self][obj][method]]
+ end
+ end
+
+ return false, nil
+end
+
+-- ("function") or (object, "method")
+function AceHook:Unhook(obj, method)
+ if type(obj) == "string" then
+ unhookFunction(self, obj)
+ else
+ AceHook:argCheck(obj, 2, "string", "table")
+ AceHook:argCheck(method, 3, "string")
+ unhookMethod(self, obj, method)
+ end
+end
+
+function AceHook:UnhookAll()
+ if type(registry[self]) ~= "table" then return end
+ for key, value in pairs(registry[self]) do
+ if type(key) == "table" then
+ for method in pairs(value) do
+ self:Unhook(key, method)
+ end
+ else
+ self:Unhook(key)
+ end
+ end
+end
+
+function AceHook:HookReport()
+ DEFAULT_CHAT_FRAME:AddMessage("This is a list of all active hooks for this object:")
+ if not next(registry[self]) then
+ DEFAULT_CHAT_FRAME:AddMessage("No hooks")
+ end
+
+ for key, value in pairs(registry[self]) do
+ if type(value) == "table" then
+ for method, uid in pairs(value) do
+ DEFAULT_CHAT_FRAME:AddMessage(("object: %s method: %q |cff%s|r%s"):format(tostring(key), method, actives[uid] and "00ff00Active" or "ffff00Inactive", not self.hooks[key][method] and " |cff7f7fff-Secure-|r" or ""))
+ end
+ else
+ DEFAULT_CHAT_FRAME:AddMessage(("function: %q |cff%s|r%s"):format(tostring(key), actives[value] and "00ff00Active" or "ffff00Inactive", not self.hooks[key] and " |cff7f7fff-Secure-|r" or ""))
+ end
+ end
+end
+
+function AceHook:OnInstanceInit(object)
+ if not object.hooks then
+ object.hooks = new()
+ end
+ if not registry[object] then
+ registry[object] = new()
+ end
+end
+
+AceHook.OnManualEmbed = AceHook.OnInstanceInit
+
+function AceHook:OnEmbedDisable(target)
+ self.UnhookAll(target)
+end
+
+local function activate(self, oldLib, oldDeactivate)
+ AceHook = self
+
+ self.handlers = oldLib and oldLib.handlers or {}
+ self.registry = oldLib and oldLib.registry or {}
+ self.scripts = oldLib and oldLib.scripts or {}
+ self.actives = oldLib and oldLib.actives or {}
+ self.onceSecure = oldLib and oldLib.onceSecure or {}
+
+ handlers = self.handlers
+ registry = self.registry
+ scripts = self.scripts
+ actives = self.actives
+ onceSecure = self.onceSecure
+
+ self:activate(oldLib, oldDeactivate)
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+AceLibrary:Register(AceHook, MAJOR_VERSION, MINOR_VERSION, activate)
diff --git a/FuBar_DurabilityFu/libs/AceHook-2.1/AceHook-2.1.toc b/FuBar_DurabilityFu/libs/AceHook-2.1/AceHook-2.1.toc
new file mode 100644
index 0000000..897e721
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceHook-2.1/AceHook-2.1.toc
@@ -0,0 +1,16 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r1098
+## X-Curse-Project-Name: Ace2
+## X-Curse-Project-ID: ace2
+## X-Curse-Repository-ID: wow/ace2/mainline
+
+## Title: Lib: AceHook-2.1
+## Notes: AddOn development framework
+## Author: Ace Development Team
+## LoadOnDemand: 1
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-License: LGPL v2.1 + MIT for AceOO-2.0
+## Dependencies: AceLibrary, AceOO-2.0
+
+AceHook-2.1.lua
diff --git a/FuBar_DurabilityFu/libs/AceLibrary/AceLibrary.lua b/FuBar_DurabilityFu/libs/AceLibrary/AceLibrary.lua
new file mode 100644
index 0000000..8ff1742
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceLibrary/AceLibrary.lua
@@ -0,0 +1,799 @@
+--[[
+Name: AceLibrary
+Revision: $Rev: 1091 $
+Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team)
+Inspired By: Iriel (iriel@vigilance-committee.org)
+ Tekkub (tekkub@gmail.com)
+ Revision: $Rev: 1091 $
+Website: http://www.wowace.com/
+Documentation: http://www.wowace.com/index.php/AceLibrary
+SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceLibrary
+Description: Versioning library to handle other library instances, upgrading,
+ and proper access.
+ It also provides a base for libraries to work off of, providing
+ proper error tools. It is handy because all the errors occur in the
+ file that called it, not in the library file itself.
+Dependencies: None
+License: LGPL v2.1
+]]
+
+local ACELIBRARY_MAJOR = "AceLibrary"
+local ACELIBRARY_MINOR = 90000 + tonumber(("$Revision: 1091 $"):match("(%d+)"))
+
+local _G = getfenv(0)
+local previous = _G[ACELIBRARY_MAJOR]
+if previous and not previous:IsNewVersion(ACELIBRARY_MAJOR, ACELIBRARY_MINOR) then return end
+
+do
+ -- 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
+end
+local LibStub = _G.LibStub
+
+-- If you don't want AceLibrary to enable libraries that are LoadOnDemand but
+-- disabled in the addon screen, set this to true.
+local DONT_ENABLE_LIBRARIES = nil
+
+local function safecall(func,...)
+ local success, err = pcall(func,...)
+ if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("\n(.-: )in.-\n") or "") .. err) end
+end
+
+-- @table AceLibrary
+-- @brief System to handle all versioning of libraries.
+local AceLibrary = {}
+local AceLibrary_mt = {}
+setmetatable(AceLibrary, AceLibrary_mt)
+
+local function error(self, message, ...)
+ if type(self) ~= "table" then
+ return _G.error(("Bad argument #1 to `error' (table expected, got %s)"):format(type(self)), 2)
+ end
+
+ local stack = debugstack()
+ if not message then
+ local second = stack:match("\n(.-)\n")
+ message = "error raised! " .. second
+ else
+ local arg = { ... } -- not worried about table creation, as errors don't happen often
+
+ for i = 1, #arg do
+ arg[i] = tostring(arg[i])
+ end
+ for i = 1, 10 do
+ table.insert(arg, "nil")
+ end
+ message = message:format(unpack(arg))
+ end
+
+ if getmetatable(self) and getmetatable(self).__tostring then
+ message = ("%s: %s"):format(tostring(self), message)
+ elseif type(rawget(self, 'GetLibraryVersion')) == "function" and AceLibrary:HasInstance(self:GetLibraryVersion()) then
+ message = ("%s: %s"):format(self:GetLibraryVersion(), message)
+ elseif type(rawget(self, 'class')) == "table" and type(rawget(self.class, 'GetLibraryVersion')) == "function" and AceLibrary:HasInstance(self.class:GetLibraryVersion()) then
+ message = ("%s: %s"):format(self.class:GetLibraryVersion(), message)
+ end
+
+ local first = stack:gsub("\n.*", "")
+ local file = first:gsub(".*\\(.*).lua:%d+: .*", "%1")
+ file = file:gsub("([%(%)%.%*%+%-%[%]%?%^%$%%])", "%%%1")
+
+
+ local i = 0
+ for s in stack:gmatch("\n([^\n]*)") do
+ i = i + 1
+ if not s:find(file .. "%.lua:%d+:") and not s:find("%(tail call%)") then
+ file = s:gsub("^.*\\(.*).lua:%d+: .*", "%1")
+ file = file:gsub("([%(%)%.%*%+%-%[%]%?%^%$%%])", "%%%1")
+ break
+ end
+ end
+ local j = 0
+ for s in stack:gmatch("\n([^\n]*)") do
+ j = j + 1
+ if j > i and not s:find(file .. "%.lua:%d+:") and not s:find("%(tail call%)") then
+ return _G.error(message, j+1)
+ end
+ end
+ return _G.error(message, 2)
+end
+
+local type = type
+local function argCheck(self, arg, num, kind, kind2, kind3, kind4, kind5)
+ if type(num) ~= "number" then
+ return error(self, "Bad argument #3 to `argCheck' (number expected, got %s)", type(num))
+ elseif type(kind) ~= "string" then
+ return error(self, "Bad argument #4 to `argCheck' (string expected, got %s)", type(kind))
+ end
+ arg = type(arg)
+ if arg ~= kind and arg ~= kind2 and arg ~= kind3 and arg ~= kind4 and arg ~= kind5 then
+ local stack = debugstack()
+ local func = stack:match("`argCheck'.-([`<].-['>])")
+ if not func then
+ func = stack:match("([`<].-['>])")
+ end
+ if kind5 then
+ return error(self, "Bad argument #%s to %s (%s, %s, %s, %s, or %s expected, got %s)", tonumber(num) or 0/0, func, kind, kind2, kind3, kind4, kind5, arg)
+ elseif kind4 then
+ return error(self, "Bad argument #%s to %s (%s, %s, %s, or %s expected, got %s)", tonumber(num) or 0/0, func, kind, kind2, kind3, kind4, arg)
+ elseif kind3 then
+ return error(self, "Bad argument #%s to %s (%s, %s, or %s expected, got %s)", tonumber(num) or 0/0, func, kind, kind2, kind3, arg)
+ elseif kind2 then
+ return error(self, "Bad argument #%s to %s (%s or %s expected, got %s)", tonumber(num) or 0/0, func, kind, kind2, arg)
+ else
+ return error(self, "Bad argument #%s to %s (%s expected, got %s)", tonumber(num) or 0/0, func, kind, arg)
+ end
+ end
+end
+
+local pcall
+do
+ local function check(self, ret, ...)
+ if not ret then
+ local s = ...
+ return error(self, (s:gsub(".-%.lua:%d-: ", "")))
+ else
+ return ...
+ end
+ end
+
+ function pcall(self, func, ...)
+ return check(self, _G.pcall(func, ...))
+ end
+end
+
+local recurse = {}
+local function addToPositions(t, major)
+ if not AceLibrary.positions[t] or AceLibrary.positions[t] == major then
+ rawset(t, recurse, true)
+ AceLibrary.positions[t] = major
+ for k,v in pairs(t) do
+ if type(v) == "table" and not rawget(v, recurse) then
+ addToPositions(v, major)
+ end
+ if type(k) == "table" and not rawget(k, recurse) then
+ addToPositions(k, major)
+ end
+ end
+ local mt = getmetatable(t)
+ if mt and not rawget(mt, recurse) then
+ addToPositions(mt, major)
+ end
+ rawset(t, recurse, nil)
+ end
+end
+
+local function svnRevisionToNumber(text)
+ local kind = type(text)
+ if kind == "number" or tonumber(text) then
+ return tonumber(text)
+ elseif kind == "string" then
+ if text:find("^%$Revision: (%d+) %$$") then
+ return tonumber((text:match("^%$Revision: (%d+) %$$")))
+ elseif text:find("^%$Rev: (%d+) %$$") then
+ return tonumber((text:match("^%$Rev: (%d+) %$$")))
+ elseif text:find("^%$LastChangedRevision: (%d+) %$$") then
+ return tonumber((text:match("^%$LastChangedRevision: (%d+) %$$")))
+ end
+ end
+ return nil
+end
+
+local crawlReplace
+do
+ local recurse = {}
+ local function func(t, to, from)
+ if recurse[t] then
+ return
+ end
+ recurse[t] = true
+ local mt = getmetatable(t)
+ setmetatable(t, nil)
+ rawset(t, to, rawget(t, from))
+ rawset(t, from, nil)
+ for k,v in pairs(t) do
+ if v == from then
+ t[k] = to
+ elseif type(v) == "table" then
+ if not recurse[v] then
+ func(v, to, from)
+ end
+ end
+
+ if type(k) == "table" then
+ if not recurse[k] then
+ func(k, to, from)
+ end
+ end
+ end
+ setmetatable(t, mt)
+ if mt then
+ if mt == from then
+ setmetatable(t, to)
+ elseif not recurse[mt] then
+ func(mt, to, from)
+ end
+ end
+ end
+ function crawlReplace(t, to, from)
+ func(t, to, from)
+ for k in pairs(recurse) do
+ recurse[k] = nil
+ end
+ end
+end
+
+-- @function destroyTable
+-- @brief remove all the contents of a table
+-- @param t table to destroy
+local function destroyTable(t)
+ setmetatable(t, nil)
+ for k,v in pairs(t) do
+ t[k] = nil
+ end
+end
+
+local function isFrame(frame)
+ return type(frame) == "table" and type(rawget(frame, 0)) == "userdata" and type(rawget(frame, 'IsFrameType')) == "function" and getmetatable(frame) and type(rawget(getmetatable(frame), '__index')) == "function"
+end
+
+-- @function copyTable
+-- @brief Create a shallow copy of a table and return it.
+-- @param from The table to copy from
+-- @return A shallow copy of the table
+local function copyTable(from, to)
+ if not to then
+ to = {}
+ end
+ for k,v in pairs(from) do
+ to[k] = v
+ end
+ setmetatable(to, getmetatable(from))
+ return to
+end
+
+-- @function deepTransfer
+-- @brief Fully transfer all data, keeping proper previous table
+-- backreferences stable.
+-- @param to The table with which data is to be injected into
+-- @param from The table whose data will be injected into the first
+-- @param saveFields If available, a shallow copy of the basic data is saved
+-- in here.
+-- @param list The account of table references
+-- @param list2 The current status on which tables have been traversed.
+local deepTransfer
+do
+ -- @function examine
+ -- @brief Take account of all the table references to be shared
+ -- between the to and from tables.
+ -- @param to The table with which data is to be injected into
+ -- @param from The table whose data will be injected into the first
+ -- @param list An account of the table references
+ local function examine(to, from, list, major)
+ list[from] = to
+ for k,v in pairs(from) do
+ if rawget(to, k) and type(from[k]) == "table" and type(to[k]) == "table" and not list[from[k]] then
+ if from[k] == to[k] then
+ list[from[k]] = to[k]
+ elseif AceLibrary.positions[from[v]] ~= major and AceLibrary.positions[from[v]] then
+ list[from[k]] = from[k]
+ elseif not list[from[k]] then
+ examine(to[k], from[k], list, major)
+ end
+ end
+ end
+ return list
+ end
+
+ function deepTransfer(to, from, saveFields, major, list, list2)
+ setmetatable(to, nil)
+ if not list then
+ list = {}
+ list2 = {}
+ examine(to, from, list, major)
+ end
+ list2[to] = to
+ for k,v in pairs(to) do
+ if type(rawget(from, k)) ~= "table" or type(v) ~= "table" or isFrame(v) then
+ if saveFields then
+ saveFields[k] = v
+ end
+ to[k] = nil
+ elseif v ~= _G then
+ if saveFields then
+ saveFields[k] = copyTable(v)
+ end
+ end
+ end
+ for k in pairs(from) do
+ if rawget(to, k) and to[k] ~= from[k] and AceLibrary.positions[to[k]] == major and from[k] ~= _G then
+ if not list2[to[k]] then
+ deepTransfer(to[k], from[k], nil, major, list, list2)
+ end
+ to[k] = list[to[k]] or list2[to[k]]
+ else
+ rawset(to, k, from[k])
+ end
+ end
+ setmetatable(to, getmetatable(from))
+ local mt = getmetatable(to)
+ if mt then
+ if list[mt] then
+ setmetatable(to, list[mt])
+ elseif mt.__index and list[mt.__index] then
+ mt.__index = list[mt.__index]
+ end
+ end
+ destroyTable(from)
+ end
+end
+
+local function TryToEnable(addon)
+ if DONT_ENABLE_LIBRARIES then return end
+ local isondemand = IsAddOnLoadOnDemand(addon)
+ if isondemand then
+ local _, _, _, enabled = GetAddOnInfo(addon)
+ EnableAddOn(addon)
+ local _, _, _, _, loadable = GetAddOnInfo(addon)
+ if not loadable and not enabled then
+ DisableAddOn(addon)
+ end
+
+ return loadable
+ end
+end
+
+-- @method TryToLoadStandalone
+-- @brief Attempt to find and load a standalone version of the requested library
+-- @param major A string representing the major version
+-- @return If library is found and loaded, true is return. If not loadable, false is returned.
+-- If the library has been requested previously, nil is returned.
+local function TryToLoadStandalone(major)
+ if not AceLibrary.scannedlibs then AceLibrary.scannedlibs = {} end
+ if AceLibrary.scannedlibs[major] then return end
+
+ AceLibrary.scannedlibs[major] = true
+
+ local name, _, _, enabled, loadable = GetAddOnInfo(major)
+
+ loadable = (enabled and loadable) or TryToEnable(name)
+
+ local loaded = false
+ if loadable then
+ loaded = true
+ LoadAddOn(name)
+ end
+
+ local field = "X-AceLibrary-" .. major
+ for i = 1, GetNumAddOns() do
+ if GetAddOnMetadata(i, field) then
+ name, _, _, enabled, loadable = GetAddOnInfo(i)
+
+ loadable = (enabled and loadable) or TryToEnable(name)
+ if loadable then
+ loaded = true
+ LoadAddOn(name)
+ end
+ end
+ end
+ return loaded
+end
+
+-- @method IsNewVersion
+-- @brief Obtain whether the supplied version would be an upgrade to the
+-- current version. This allows for bypass code in library
+-- declaration.
+-- @param major A string representing the major version
+-- @param minor An integer or an svn revision string representing the minor version
+-- @return whether the supplied version would be newer than what is
+-- currently available.
+function AceLibrary:IsNewVersion(major, minor)
+ argCheck(self, major, 2, "string")
+ TryToLoadStandalone(major)
+
+ if type(minor) == "string" then
+ local m = svnRevisionToNumber(minor)
+ if m then
+ minor = m
+ else
+ _G.error(("Bad argument #3 to `IsNewVersion'. Must be a number or SVN revision string. %q is not appropriate"):format(minor), 2)
+ end
+ end
+ argCheck(self, minor, 3, "number")
+ local lib, oldMinor = LibStub:GetLibrary(major, true)
+ if lib then
+ return oldMinor < minor
+ end
+ local data = self.libs[major]
+ if not data then
+ return true
+ end
+ return data.minor < minor
+end
+
+-- @method HasInstance
+-- @brief Returns whether an instance exists. This allows for optional support of a library.
+-- @param major A string representing the major version.
+-- @param minor (optional) An integer or an svn revision string representing the minor version.
+-- @return Whether an instance exists.
+function AceLibrary:HasInstance(major, minor)
+ argCheck(self, major, 2, "string")
+ if minor ~= false then
+ TryToLoadStandalone(major)
+ end
+
+ local lib, ver = LibStub:GetLibrary(major, true)
+ if not lib and self.libs[major] then
+ lib, ver = self.libs[major].instance, self.libs[major].minor
+ end
+ if minor then
+ if type(minor) == "string" then
+ local m = svnRevisionToNumber(minor)
+ if m then
+ minor = m
+ else
+ _G.error(("Bad argument #3 to `HasInstance'. Must be a number or SVN revision string. %q is not appropriate"):format(minor), 2)
+ end
+ end
+ argCheck(self, minor, 3, "number")
+ if not lib then
+ return false
+ end
+ return ver == minor
+ end
+ return not not lib
+end
+
+-- @method GetInstance
+-- @brief Returns the library with the given major/minor version.
+-- @param major A string representing the major version.
+-- @param minor (optional) An integer or an svn revision string representing the minor version.
+-- @return The library with the given major/minor version.
+function AceLibrary:GetInstance(major, minor)
+ argCheck(self, major, 2, "string")
+ if minor ~= false then
+ TryToLoadStandalone(major)
+ end
+
+ local data, ver = LibStub:GetLibrary(major, true)
+ if not data then
+ if self.libs[major] then
+ data, ver = self.libs[major].instance, self.libs[major].minor
+ else
+ _G.error(("Cannot find a library instance of %s."):format(major), 2)
+ return
+ end
+ end
+ if minor then
+ if type(minor) == "string" then
+ local m = svnRevisionToNumber(minor)
+ if m then
+ minor = m
+ else
+ _G.error(("Bad argument #3 to `GetInstance'. Must be a number or SVN revision string. %q is not appropriate"):format(minor), 2)
+ end
+ end
+ argCheck(self, minor, 2, "number")
+ if ver ~= minor then
+ _G.error(("Cannot find a library instance of %s, minor version %d."):format(major, minor), 2)
+ end
+ end
+ return data
+end
+
+-- Syntax sugar. AceLibrary("FooBar-1.0")
+AceLibrary_mt.__call = AceLibrary.GetInstance
+
+local donothing = function() end
+
+local AceEvent
+
+local tmp = {}
+
+-- @method Register
+-- @brief Registers a new version of a given library.
+-- @param newInstance the library to register
+-- @param major the major version of the library
+-- @param minor the minor version of the library
+-- @param activateFunc (optional) A function to be called when the library is
+-- fully activated. Takes the arguments
+-- (newInstance [, oldInstance, oldDeactivateFunc]). If
+-- oldInstance is given, you should probably call
+-- oldDeactivateFunc(oldInstance).
+-- @param deactivateFunc (optional) A function to be called by a newer library's
+-- activateFunc.
+-- @param externalFunc (optional) A function to be called whenever a new
+-- library is registered.
+function AceLibrary:Register(newInstance, major, minor, activateFunc, deactivateFunc, externalFunc)
+ argCheck(self, newInstance, 2, "table")
+ argCheck(self, major, 3, "string")
+ if major ~= ACELIBRARY_MAJOR then
+ for k,v in pairs(_G) do
+ if v == newInstance then
+ geterrorhandler()((debugstack():match("(.-: )in.-\n") or "") .. ("Cannot register library %q. It is part of the global table in _G[%q]."):format(major, k))
+ end
+ end
+ end
+ if major ~= ACELIBRARY_MAJOR and not major:find("^[%a%-][%a%d%-]*%-%d+%.%d+$") then
+ _G.error(string.format("Bad argument #3 to `Register'. Must be in the form of \"Name-1.0\". %q is not appropriate", major), 2)
+ end
+ if type(minor) == "string" then
+ local m = svnRevisionToNumber(minor)
+ if m then
+ minor = m
+ else
+ _G.error(("Bad argument #4 to `Register'. Must be a number or SVN revision string. %q is not appropriate"):format(minor), 2)
+ end
+ end
+ argCheck(self, minor, 4, "number")
+ if math.floor(minor) ~= minor or minor < 0 then
+ error(self, "Bad argument #4 to `Register' (integer >= 0 expected, got %s)", minor)
+ end
+ argCheck(self, activateFunc, 5, "function", "nil")
+ argCheck(self, deactivateFunc, 6, "function", "nil")
+ argCheck(self, externalFunc, 7, "function", "nil")
+ if not deactivateFunc then
+ deactivateFunc = donothing
+ end
+ local data = self.libs[major]
+ if not data then
+ -- This is new
+ if LibStub:GetLibrary(major, true) then
+ error(self, "Cannot register library %q. It is already registered with LibStub.", major)
+ end
+ local instance = LibStub:NewLibrary(major, minor)
+ copyTable(newInstance, instance)
+ crawlReplace(instance, instance, newInstance)
+ destroyTable(newInstance)
+ if AceLibrary == newInstance then
+ self = instance
+ AceLibrary = instance
+ end
+ self.libs[major] = {
+ instance = instance,
+ minor = minor,
+ deactivateFunc = deactivateFunc,
+ externalFunc = externalFunc,
+ }
+ rawset(instance, 'GetLibraryVersion', function(self)
+ return major, minor
+ end)
+ if not rawget(instance, 'error') then
+ rawset(instance, 'error', error)
+ end
+ if not rawget(instance, 'argCheck') then
+ rawset(instance, 'argCheck', argCheck)
+ end
+ if not rawget(instance, 'pcall') then
+ rawset(instance, 'pcall', pcall)
+ end
+ addToPositions(instance, major)
+ if activateFunc then
+ safecall(activateFunc, instance, nil, nil) -- no old version, so explicit nil
+ end
+
+ if externalFunc then
+ for k, data_instance in LibStub:IterateLibraries() do -- all libraries
+ tmp[k] = data_instance
+ end
+ for k, data in pairs(self.libs) do -- Ace libraries which may not have been registered with LibStub
+ tmp[k] = data.instance
+ end
+ for k, data_instance in pairs(tmp) do
+ if k ~= major then
+ safecall(externalFunc, instance, k, data_instance)
+ end
+ tmp[k] = nil
+ end
+ end
+
+ for k,data in pairs(self.libs) do -- only Ace libraries
+ if k ~= major and data.externalFunc then
+ safecall(data.externalFunc, data.instance, major, instance)
+ end
+ end
+ if major == "AceEvent-2.0" then
+ AceEvent = instance
+ end
+ if AceEvent then
+ AceEvent.TriggerEvent(self, "AceLibrary_Register", major, instance)
+ end
+
+ return instance
+ end
+ if minor <= data.minor then
+ -- This one is already obsolete, raise an error.
+ _G.error(("Obsolete library registered. %s is already registered at version %d. You are trying to register version %d. Hint: if not AceLibrary:IsNewVersion(%q, %d) then return end"):format(major, data.minor, minor, major, minor), 2)
+ return
+ end
+ local instance = data.instance
+ -- This is an update
+ local oldInstance = {}
+
+ local libStubInstance = LibStub:GetLibrary(major, true)
+ if not libStubInstance then -- non-LibStub AceLibrary registered the library
+ -- pass
+ elseif libStubInstance ~= instance then
+ error(self, "Cannot register library %q. It is already registered with LibStub.", major)
+ else
+ LibStub:NewLibrary(major, minor) -- upgrade the minor version
+ end
+
+ addToPositions(newInstance, major)
+ local isAceLibrary = (AceLibrary == newInstance)
+ local old_error, old_argCheck, old_pcall
+ if isAceLibrary then
+ self = instance
+ AceLibrary = instance
+
+ old_error = instance.error
+ old_argCheck = instance.argCheck
+ old_pcall = instance.pcall
+
+ self.error = error
+ self.argCheck = argCheck
+ self.pcall = pcall
+ end
+ deepTransfer(instance, newInstance, oldInstance, major)
+ crawlReplace(instance, instance, newInstance)
+ local oldDeactivateFunc = data.deactivateFunc
+ data.minor = minor
+ data.deactivateFunc = deactivateFunc
+ data.externalFunc = externalFunc
+ rawset(instance, 'GetLibraryVersion', function()
+ return major, minor
+ end)
+ if not rawget(instance, 'error') then
+ rawset(instance, 'error', error)
+ end
+ if not rawget(instance, 'argCheck') then
+ rawset(instance, 'argCheck', argCheck)
+ end
+ if not rawget(instance, 'pcall') then
+ rawset(instance, 'pcall', pcall)
+ end
+ if isAceLibrary then
+ for _,v in pairs(self.libs) do
+ local i = type(v) == "table" and v.instance
+ if type(i) == "table" then
+ if not rawget(i, 'error') or i.error == old_error then
+ rawset(i, 'error', error)
+ end
+ if not rawget(i, 'argCheck') or i.argCheck == old_argCheck then
+ rawset(i, 'argCheck', argCheck)
+ end
+ if not rawget(i, 'pcall') or i.pcall == old_pcall then
+ rawset(i, 'pcall', pcall)
+ end
+ end
+ end
+ end
+ if activateFunc then
+ safecall(activateFunc, instance, oldInstance, oldDeactivateFunc)
+ else
+ safecall(oldDeactivateFunc, oldInstance)
+ end
+ oldInstance = nil
+
+ if externalFunc then
+ for k, data_instance in LibStub:IterateLibraries() do -- all libraries
+ tmp[k] = data_instance
+ end
+ for k, data in pairs(self.libs) do -- Ace libraries which may not have been registered with LibStub
+ tmp[k] = data.instance
+ end
+ for k, data_instance in pairs(tmp) do
+ if k ~= major then
+ safecall(externalFunc, instance, k, data_instance)
+ end
+ tmp[k] = nil
+ end
+ end
+
+ return instance
+end
+
+function AceLibrary:IterateLibraries()
+ local t = {}
+ for major, instance in LibStub:IterateLibraries() do
+ t[major] = instance
+ end
+ for major, data in pairs(self.libs) do
+ t[major] = data.instance
+ end
+ return pairs(t)
+end
+
+local function manuallyFinalize(major, instance)
+ if AceLibrary.libs[major] then
+ -- don't work on Ace libraries
+ return
+ end
+ local finalizedExternalLibs = AceLibrary.finalizedExternalLibs
+ if finalizedExternalLibs[major] then
+ return
+ end
+ finalizedExternalLibs[major] = true
+
+ for k,data in pairs(AceLibrary.libs) do -- only Ace libraries
+ if k ~= major and data.externalFunc then
+ safecall(data.externalFunc, data.instance, major, instance)
+ end
+ end
+end
+
+-- @function Activate
+-- @brief The activateFunc for AceLibrary itself. Called when
+-- AceLibrary properly registers.
+-- @param self Reference to AceLibrary
+-- @param oldLib (optional) Reference to an old version of AceLibrary
+-- @param oldDeactivate (optional) Function to deactivate the old lib
+local function activate(self, oldLib, oldDeactivate)
+ AceLibrary = self
+ if not self.libs then
+ self.libs = oldLib and oldLib.libs or {}
+ self.scannedlibs = oldLib and oldLib.scannedlibs or {}
+ end
+ if not self.positions then
+ self.positions = oldLib and oldLib.positions or setmetatable({}, { __mode = "k" })
+ end
+ self.finalizedExternalLibs = oldLib and oldLib.finalizedExternalLibs or {}
+ self.frame = oldLib and oldLib.frame or CreateFrame("Frame")
+ self.frame:UnregisterAllEvents()
+ self.frame:RegisterEvent("ADDON_LOADED")
+ self.frame:SetScript("OnEvent", function()
+ for major, instance in LibStub:IterateLibraries() do
+ manuallyFinalize(major, instance)
+ end
+ end)
+ for major, instance in LibStub:IterateLibraries() do
+ manuallyFinalize(major, instance)
+ end
+
+ -- Expose the library in the global environment
+ _G[ACELIBRARY_MAJOR] = self
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+if not previous then
+ previous = AceLibrary
+end
+if not previous.libs then
+ previous.libs = {}
+end
+AceLibrary.libs = previous.libs
+if not previous.positions then
+ previous.positions = setmetatable({}, { __mode = "k" })
+end
+AceLibrary.positions = previous.positions
+AceLibrary:Register(AceLibrary, ACELIBRARY_MAJOR, ACELIBRARY_MINOR, activate, nil)
diff --git a/FuBar_DurabilityFu/libs/AceLibrary/AceLibrary.toc b/FuBar_DurabilityFu/libs/AceLibrary/AceLibrary.toc
new file mode 100644
index 0000000..68083d5
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceLibrary/AceLibrary.toc
@@ -0,0 +1,14 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r1098
+## X-Curse-Project-Name: Ace2
+## X-Curse-Project-ID: ace2
+## X-Curse-Repository-ID: wow/ace2/mainline
+
+## Title: Lib: AceLibrary
+## Notes: AddOn development framework
+## Author: Ace Development Team
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-License: LGPL v2.1 + MIT for AceOO-2.0
+
+AceLibrary.lua
diff --git a/FuBar_DurabilityFu/libs/AceLocale-2.2/AceLocale-2.2.lua b/FuBar_DurabilityFu/libs/AceLocale-2.2/AceLocale-2.2.lua
new file mode 100644
index 0000000..36a57cd
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceLocale-2.2/AceLocale-2.2.lua
@@ -0,0 +1,669 @@
+--[[
+Name: AceLocale-2.2
+Revision: $Rev: 1094 $
+Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team)
+Inspired By: Ace 1.x by Turan (turan@gryphon.com)
+Website: http://www.wowace.com/
+Documentation: http://www.wowace.com/index.php/AceLocale-2.2
+SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceLocale-2.2
+Description: Localization library for addons to use to handle proper
+ localization and internationalization.
+Dependencies: AceLibrary
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "AceLocale-2.2"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 1094 $"):match("(%d+)"))
+
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+local AceLocale = {}
+AceLocale.prototype = { class = AceLocale }
+
+local BASE_TRANSLATIONS, DEBUGGING, TRANSLATIONS, BASE_LOCALE, TRANSLATION_TABLES, REVERSE_TRANSLATIONS, STRICTNESS, DYNAMIC_LOCALES, CURRENT_LOCALE, NAME
+
+local _G = _G
+local rawget = rawget
+local rawset = rawset
+local type = type
+local pairs = pairs
+local next = next
+local getmetatable = getmetatable
+local setmetatable = setmetatable
+local GetTime = GetTime
+local geterrorhandler = geterrorhandler
+local pcall = pcall
+local ipairs = ipairs
+local GetLocale = GetLocale
+
+local newRegistries = {}
+local scheduleClear
+
+local lastSelf
+local strict__index = function(self, key)
+ lastSelf = self
+ local value = (rawget(self, TRANSLATIONS) or AceLocale.prototype)[key]
+ rawset(self, key, value)
+ return value
+end
+local nonstrict__index = function(self, key)
+ lastSelf = self
+ local t = rawget(self, TRANSLATIONS)
+ if t then
+ local value = rawget(t, key)
+ if value then
+ rawset(self, key, value)
+ return value
+ end
+ end
+ local value = (rawget(self, BASE_TRANSLATIONS) or AceLocale.prototype)[key]
+ rawset(self, key, value)
+ return value
+end
+
+local __newindex = function(self, k, v)
+ if type(v) ~= "function" and type(k) ~= "table" then
+ AceLocale.error(self, "Cannot change the values of an AceLocale instance.")
+ end
+ rawset(self, k, v)
+end
+
+local __tostring = function(self)
+ if type(rawget(self, 'GetLibraryVersion')) == "function" then
+ return self:GetLibraryVersion()
+ else
+ return "AceLocale(" .. self[NAME] .. ")"
+ end
+end
+
+local function clearCache(self)
+ for k, v in pairs(AceLocale.prototype) do
+ if type(v) == "function" and type(rawget(self, k)) == "function" then
+ self[k] = nil
+ end
+ end
+ if not rawget(self, BASE_TRANSLATIONS) then
+ return
+ end
+
+ local cache = self[BASE_TRANSLATIONS]
+ rawset(self, REVERSE_TRANSLATIONS, nil)
+
+ for k in pairs(self) do
+ if rawget(cache, k) ~= nil then
+ self[k] = nil
+ end
+ end
+ rawset(self, 'tmp', true)
+ self.tmp = nil
+end
+
+local strict_instance_mt, nonstrict_instance_mt
+local baseTranslations_mt
+
+local function refixInstance(instance)
+ if getmetatable(instance) then
+ setmetatable(instance, nil)
+ end
+ local translations = instance[TRANSLATIONS]
+ if translations then
+ if getmetatable(translations) then
+ setmetatable(translations, nil)
+ end
+ local baseTranslations = instance[BASE_TRANSLATIONS]
+ if getmetatable(baseTranslations) then
+ setmetatable(baseTranslations, nil)
+ end
+ if translations == baseTranslations or instance[STRICTNESS] then
+ setmetatable(instance, strict_instance_mt)
+
+ setmetatable(translations, baseTranslations_mt)
+ else
+ setmetatable(instance, nonstrict_instance_mt)
+
+ setmetatable(baseTranslations, baseTranslations_mt)
+ end
+ else
+ setmetatable(instance, strict_instance_mt)
+ end
+ clearCache(instance)
+ newRegistries[instance] = true
+ scheduleClear()
+ return instance
+end
+
+function AceLocale:new(name)
+ self:argCheck(name, 2, "string")
+
+ if self.registry[name] and type(rawget(self.registry[name], 'GetLibraryVersion')) ~= "function" then
+ return self.registry[name]
+ end
+
+ AceLocale.registry[name] = refixInstance({
+ [STRICTNESS] = false,
+ [NAME] = name,
+ })
+ newRegistries[AceLocale.registry[name]] = true
+ return AceLocale.registry[name]
+end
+
+function AceLocale.prototype:EnableDebugging()
+ if rawget(self, BASE_TRANSLATIONS) then
+ AceLocale.error(self, "Cannot enable debugging after a translation has been registered.")
+ end
+ rawset(self, DEBUGGING, true)
+end
+
+function AceLocale.prototype:EnableDynamicLocales(override)
+ AceLocale.argCheck(self, override, 2, "boolean", "nil")
+ if not override and rawget(self, BASE_TRANSLATIONS) then
+ AceLocale.error(self, "Cannot enable dynamic locales after a translation has been registered.")
+ end
+ if not rawget(self, DYNAMIC_LOCALES) then
+ rawset(self, DYNAMIC_LOCALES, true)
+ if rawget(self, BASE_LOCALE) then
+ if not rawget(self, TRANSLATION_TABLES) then
+ rawset(self, TRANSLATION_TABLES, {})
+ end
+ self[TRANSLATION_TABLES][self[BASE_LOCALE]] = self[BASE_TRANSLATIONS]
+ self[TRANSLATION_TABLES][self[CURRENT_LOCALE]] = self[TRANSLATIONS]
+ end
+ end
+end
+
+function AceLocale.prototype:RegisterTranslations(locale, func)
+ AceLocale.argCheck(self, locale, 2, "string")
+ AceLocale.argCheck(self, func, 3, "function")
+
+ if locale == rawget(self, BASE_LOCALE) then
+ AceLocale.error(self, "Cannot provide the same locale more than once. %q provided twice.", locale)
+ end
+
+ if rawget(self, BASE_TRANSLATIONS) and GetLocale() ~= locale then
+ if rawget(self, DEBUGGING) or rawget(self, DYNAMIC_LOCALES) then
+ if not rawget(self, TRANSLATION_TABLES) then
+ rawset(self, TRANSLATION_TABLES, {})
+ end
+ if self[TRANSLATION_TABLES][locale] then
+ AceLocale.error(self, "Cannot provide the same locale more than once. %q provided twice.", locale)
+ end
+ local t = func()
+ func = nil
+ if type(t) ~= "table" then
+ AceLocale.error(self, "Bad argument #3 to `RegisterTranslations'. function did not return a table. (expected table, got %s)", type(t))
+ end
+ self[TRANSLATION_TABLES][locale] = t
+ t = nil
+ end
+ func = nil
+ return
+ end
+ local t = func()
+ func = nil
+ if type(t) ~= "table" then
+ AceLocale.error(self, "Bad argument #3 to `RegisterTranslations'. function did not return a table. (expected table, got %s)", type(t))
+ end
+
+ rawset(self, TRANSLATIONS, t)
+ if not rawget(self, BASE_TRANSLATIONS) then
+ rawset(self, BASE_TRANSLATIONS, t)
+ rawset(self, BASE_LOCALE, locale)
+ for key,value in pairs(t) do
+ if value == true then
+ t[key] = key
+ end
+ end
+ else
+ for key, value in pairs(self[TRANSLATIONS]) do
+ if not rawget(self[BASE_TRANSLATIONS], key) then
+ AceLocale.error(self, "Improper translation exists. %q is likely misspelled for locale %s.", key, locale)
+ end
+ if value == true then
+ AceLocale.error(self, "Can only accept true as a value on the base locale. %q is the base locale, %q is not.", rawget(self, BASE_LOCALE), locale)
+ end
+ end
+ end
+ rawset(self, CURRENT_LOCALE, locale)
+ if not rawget(self, 'reverse') then
+ rawset(self, 'reverse', setmetatable({}, { __index = function(self2, key)
+ local self = AceLocale.reverseToBase[self2]
+ if not rawget(self, REVERSE_TRANSLATIONS) then
+ self:GetReverseTranslation(key)
+ end
+ self.reverse = self[REVERSE_TRANSLATIONS]
+ return self.reverse[key]
+ end }))
+ AceLocale.reverseToBase[self.reverse] = self
+ end
+ refixInstance(self)
+ if rawget(self, DEBUGGING) or rawget(self, DYNAMIC_LOCALES) then
+ if not rawget(self, TRANSLATION_TABLES) then
+ rawset(self, TRANSLATION_TABLES, {})
+ end
+ self[TRANSLATION_TABLES][locale] = t
+ end
+ t = nil
+end
+
+function AceLocale.prototype:SetLocale(locale)
+ AceLocale.argCheck(self, locale, 2, "string", "boolean")
+ if not rawget(self, DYNAMIC_LOCALES) then
+ AceLocale.error(self, "Cannot call `SetLocale' without first calling `EnableDynamicLocales'.")
+ end
+ if not rawget(self, TRANSLATION_TABLES) then
+ AceLocale.error(self, "Cannot call `SetLocale' without first calling `RegisterTranslations'.")
+ end
+ if locale == true then
+ locale = GetLocale()
+ if not self[TRANSLATION_TABLES][locale] then
+ locale = self[BASE_LOCALE]
+ end
+ end
+
+ if self[CURRENT_LOCALE] == locale then
+ return
+ end
+
+ if not self[TRANSLATION_TABLES][locale] then
+ AceLocale.error(self, "Locale %q not registered.", locale)
+ end
+
+ self[TRANSLATIONS] = self[TRANSLATION_TABLES][locale]
+ self[CURRENT_LOCALE] = locale
+ refixInstance(self)
+end
+
+function AceLocale.prototype:GetLocale()
+ if not rawget(self, TRANSLATION_TABLES) then
+ AceLocale.error(self, "Cannot call `GetLocale' without first calling `RegisterTranslations'.")
+ end
+ return self[CURRENT_LOCALE]
+end
+
+local function iter(t, position)
+ return (next(t, position))
+end
+
+function AceLocale.prototype:IterateAvailableLocales()
+ if not rawget(self, DYNAMIC_LOCALES) then
+ AceLocale.error(self, "Cannot call `IterateAvailableLocales' without first calling `EnableDynamicLocales'.")
+ end
+ if not rawget(self, TRANSLATION_TABLES) then
+ AceLocale.error(self, "Cannot call `IterateAvailableLocales' without first calling `RegisterTranslations'.")
+ end
+ return iter, self[TRANSLATION_TABLES], nil
+end
+
+function AceLocale.prototype:HasLocale(locale)
+ if not rawget(self, DYNAMIC_LOCALES) then
+ AceLocale.error(self, "Cannot call `HasLocale' without first calling `EnableDynamicLocales'.")
+ end
+ AceLocale.argCheck(self, locale, 2, "string")
+ return rawget(self, TRANSLATION_TABLES) and self[TRANSLATION_TABLES][locale] ~= nil
+end
+
+function AceLocale.prototype:SetStrictness(strict)
+ AceLocale.argCheck(self, strict, 2, "boolean")
+ local mt = getmetatable(self)
+ if not mt then
+ AceLocale.error(self, "Cannot call `SetStrictness' without a metatable.")
+ end
+ if not rawget(self, TRANSLATIONS) then
+ AceLocale.error(self, "No translations registered.")
+ end
+ rawset(self, STRICTNESS, strict)
+ refixInstance(self)
+end
+
+local function initReverse(self)
+ rawset(self, REVERSE_TRANSLATIONS, setmetatable({}, { __index = function(_, key)
+ AceLocale.error(self, "Reverse translation for %q does not exist", key)
+ end }))
+ local alpha = self[TRANSLATIONS]
+ local bravo = self[REVERSE_TRANSLATIONS]
+ for base, localized in pairs(alpha) do
+ bravo[localized] = base
+ end
+end
+
+function AceLocale.prototype:GetTranslation(text)
+ AceLocale.argCheck(self, text, 1, "string", "number")
+ if not rawget(self, TRANSLATIONS) then
+ AceLocale.error(self, "No translations registered")
+ end
+ return self[text]
+end
+
+function AceLocale.prototype:GetStrictTranslation(text)
+ AceLocale.argCheck(self, text, 1, "string", "number")
+ local x = rawget(self, TRANSLATIONS)
+ if not x then
+ AceLocale.error(self, "No translations registered")
+ end
+ local value = rawget(x, text)
+ if value == nil then
+ local _, ret = pcall(AceLocale.error, self, "Translation %q does not exist for locale %s", text, self[CURRENT_LOCALE])
+ geterrorhandler()(ret)
+ return text
+ end
+ return value
+end
+
+function AceLocale.prototype:GetReverseTranslation(text)
+ local x = rawget(self, REVERSE_TRANSLATIONS)
+ if not x then
+ if not rawget(self, TRANSLATIONS) then
+ AceLocale.error(self, "No translations registered")
+ end
+ initReverse(self)
+ x = self[REVERSE_TRANSLATIONS]
+ end
+ local translation = x[text]
+ if not translation then
+ local _, ret = pcall(AceLocale.error, self, "Reverse translation for %q does not exist", text)
+ geterrorhandler()(ret)
+ return text
+ end
+ return translation
+end
+
+function AceLocale.prototype:GetIterator()
+ local x = rawget(self, TRANSLATIONS)
+ if not x then
+ AceLocale.error(self, "No translations registered")
+ end
+ return next, x, nil
+end
+
+function AceLocale.prototype:GetReverseIterator()
+ local x = rawget(self, REVERSE_TRANSLATIONS)
+ if not x then
+ if not rawget(self, TRANSLATIONS) then
+ AceLocale.error(self, "No translations registered")
+ end
+ initReverse(self)
+ x = self[REVERSE_TRANSLATIONS]
+ end
+ return next, x, nil
+end
+
+function AceLocale.prototype:HasTranslation(text)
+ AceLocale.argCheck(self, text, 1, "string", "number")
+ local x = rawget(self, TRANSLATIONS)
+ if not x then
+ AceLocale.error(self, "No translations registered")
+ end
+ return rawget(x, text) and true
+end
+
+function AceLocale.prototype:HasBaseTranslation(text)
+ AceLocale.argCheck(self, text, 1, "string", "number")
+ local x = rawget(self, BASE_TRANSLATIONS)
+ if not x then
+ AceLocale.error(self, "No translations registered")
+ end
+ return rawget(x, text) and true
+end
+
+function AceLocale.prototype:HasReverseTranslation(text)
+ local x = rawget(self, REVERSE_TRANSLATIONS)
+ if not x then
+ if not rawget(self, TRANSLATIONS) then
+ AceLocale.error(self, "No translations registered")
+ end
+ initReverse(self)
+ x = self[REVERSE_TRANSLATIONS]
+ end
+ return rawget(x, text) and true
+end
+
+function AceLocale.prototype:Debug()
+ if not rawget(self, DEBUGGING) then
+ return
+ end
+ local words = {}
+ local locales = {"enUS", "deDE", "frFR", "koKR", "zhCN", "zhTW", "esES", "ruRU"}
+ local localizations = {}
+ DEFAULT_CHAT_FRAME:AddMessage("--- AceLocale Debug ---")
+ for _,locale in ipairs(locales) do
+ if not self[TRANSLATION_TABLES][locale] then
+ DEFAULT_CHAT_FRAME:AddMessage(("Locale %q not found"):format(locale))
+ else
+ localizations[locale] = self[TRANSLATION_TABLES][locale]
+ end
+ end
+ local localeDebug = {}
+ for locale, localization in pairs(localizations) do
+ localeDebug[locale] = {}
+ for word in pairs(localization) do
+ if type(localization[word]) == "table" then
+ if type(words[word]) ~= "table" then
+ words[word] = {}
+ end
+ for bit in pairs(localization[word]) do
+ if type(localization[word][bit]) == "string" then
+ words[word][bit] = true
+ end
+ end
+ elseif type(localization[word]) == "string" then
+ words[word] = true
+ end
+ end
+ end
+ for word in pairs(words) do
+ if type(words[word]) == "table" then
+ for bit in pairs(words[word]) do
+ for locale, localization in pairs(localizations) do
+ if not rawget(localization, word) or not localization[word][bit] then
+ localeDebug[locale][word .. "::" .. bit] = true
+ end
+ end
+ end
+ else
+ for locale, localization in pairs(localizations) do
+ if not rawget(localization, word) then
+ localeDebug[locale][word] = true
+ end
+ end
+ end
+ end
+ for locale, t in pairs(localeDebug) do
+ if not next(t) then
+ DEFAULT_CHAT_FRAME:AddMessage(("Locale %q complete"):format(locale))
+ else
+ DEFAULT_CHAT_FRAME:AddMessage(("Locale %q missing:"):format(locale))
+ for word in pairs(t) do
+ DEFAULT_CHAT_FRAME:AddMessage((" %q"):format(word))
+ end
+ end
+ end
+ DEFAULT_CHAT_FRAME:AddMessage("--- End AceLocale Debug ---")
+end
+
+setmetatable(AceLocale.prototype, {
+ __index = function(self, k)
+ if type(k) ~= "table" and k ~= 0 and k ~= "GetLibraryVersion" and k ~= "error" and k ~= "assert" and k ~= "argCheck" and k ~= "pcall" then -- HACK: remove "GetLibraryVersion" and such later.
+ local _, ret = pcall(AceLocale.error, lastSelf or self, "Translation %q does not exist.", k)
+ geterrorhandler()(ret)
+ return k
+ end
+ return nil
+ end
+})
+
+local function activate(self, oldLib, oldDeactivate)
+ AceLocale = self
+
+ self.frame = oldLib and oldLib.frame or CreateFrame("Frame")
+ self.registry = oldLib and oldLib.registry or {}
+ self.BASE_TRANSLATIONS = oldLib and oldLib.BASE_TRANSLATIONS or {}
+ self.DEBUGGING = oldLib and oldLib.DEBUGGING or {}
+ self.TRANSLATIONS = oldLib and oldLib.TRANSLATIONS or {}
+ self.BASE_LOCALE = oldLib and oldLib.BASE_LOCALE or {}
+ self.TRANSLATION_TABLES = oldLib and oldLib.TRANSLATION_TABLES or {}
+ self.REVERSE_TRANSLATIONS = oldLib and oldLib.REVERSE_TRANSLATIONS or {}
+ self.STRICTNESS = oldLib and oldLib.STRICTNESS or {}
+ self.NAME = oldLib and oldLib.NAME or {}
+ self.DYNAMIC_LOCALES = oldLib and oldLib.DYNAMIC_LOCALES or {}
+ self.CURRENT_LOCALE = oldLib and oldLib.CURRENT_LOCALE or {}
+ self.reverseToBase = oldLib and oldLib.reverseToBase or {}
+
+ BASE_TRANSLATIONS = self.BASE_TRANSLATIONS
+ DEBUGGING = self.DEBUGGING
+ TRANSLATIONS = self.TRANSLATIONS
+ BASE_LOCALE = self.BASE_LOCALE
+ TRANSLATION_TABLES = self.TRANSLATION_TABLES
+ REVERSE_TRANSLATIONS = self.REVERSE_TRANSLATIONS
+ STRICTNESS = self.STRICTNESS
+ NAME = self.NAME
+ DYNAMIC_LOCALES = self.DYNAMIC_LOCALES
+ CURRENT_LOCALE = self.CURRENT_LOCALE
+
+ strict_instance_mt = {
+ __index = strict__index,
+ __newindex = __newindex,
+ __tostring = __tostring
+ }
+
+ nonstrict_instance_mt = {
+ __index = nonstrict__index,
+ __newindex = __newindex,
+ __tostring = __tostring
+ }
+
+ baseTranslations_mt = {
+ __index = AceLocale.prototype
+ }
+
+ local GetTime = GetTime
+ local timeUntilClear = GetTime() + 5
+ scheduleClear = function()
+ if next(newRegistries) then
+ self.frame:Show()
+ timeUntilClear = GetTime() + 5
+ end
+ end
+
+ for name, instance in pairs(self.registry) do
+ local name = name
+ setmetatable(instance, nil)
+ instance[NAME] = name
+ local strict
+ if instance[STRICTNESS] ~= nil then
+ strict = instance[STRICTNESS]
+ elseif instance[TRANSLATIONS] ~= instance[BASE_TRANSLATIONS] then
+ if getmetatable(instance[TRANSLATIONS]).__index == oldLib.prototype then
+ strict = true
+ end
+ end
+ instance[STRICTNESS] = strict and true or false
+ refixInstance(instance)
+ end
+
+ self.frame:SetScript("OnEvent", scheduleClear)
+ self.frame:SetScript("OnUpdate", function() -- (this, elapsed)
+ if timeUntilClear - GetTime() <= 0 then
+ self.frame:Hide()
+ for k in pairs(newRegistries) do
+ clearCache(k)
+ newRegistries[k] = nil
+ k = nil
+ end
+ end
+ end)
+ self.frame:UnregisterAllEvents()
+ self.frame:RegisterEvent("ADDON_LOADED")
+ self.frame:RegisterEvent("PLAYER_ENTERING_WORLD")
+ self.frame:Show()
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+AceLibrary:Register(AceLocale, MAJOR_VERSION, MINOR_VERSION, activate)
+--[[
+if true then -- debug
+ local L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG" or "AceLocale_DEBUG3")
+ L:RegisterTranslations("enUS", function() return {
+ Monkey = true,
+ House = true,
+ } end)
+
+ L:RegisterTranslations("deDE", function() return {
+ Monkey = "Affe"
+ } end)
+
+ L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG" or "AceLocale_DEBUG3")
+ assert(L.Monkey == "Monkey")
+ assert(L.House == "House")
+ if not L.Debug then
+ local pants = L.Pants
+ assert(not pants)
+ end
+ assert(L.Debug)
+ assert(L.Debug == AceLocale.prototype.Debug)
+
+ if MINOR_VERSION == 100000 then
+ L = AceLocale:new("AceLocale_DEBUG")
+ assert(L.Monkey == "Monkey")
+ assert(L.House == "House")
+ assert(L.Debug)
+ assert(type(L.Debug) == "function")
+ assert(AceLocale.prototype.Debug)
+ assert(type(AceLocale.prototype.Debug) == "function")
+ assert(L.Debug == AceLocale.prototype.Debug)
+ end
+
+ local L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG2" or "AceLocale_DEBUG4")
+ L:RegisterTranslations("deDE", function() return {
+ Affe = true,
+ Haus = true,
+ } end)
+
+ L:RegisterTranslations("enUS", function() return {
+ Affe = "Monkey"
+ } end)
+
+ L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG2" or "AceLocale_DEBUG4")
+ assert(L.Affe == "Monkey")
+ assert(L.Haus == "Haus")
+ assert(L.Debug)
+ assert(L.Debug == AceLocale.prototype.Debug)
+
+ if MINOR_VERSION == 100000 then
+ L = AceLocale:new("AceLocale_DEBUG2")
+ assert(L.Affe == "Monkey")
+ assert(L.Haus == "Haus")
+ assert(L.Debug)
+ assert(L.Debug == AceLocale.prototype.Debug)
+ end
+
+ local L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG5" or "AceLocale_DEBUG6")
+ L:RegisterTranslations("deDE", function() return {
+ Affe = true,
+ Haus = true,
+ } end)
+
+ L:RegisterTranslations("enUS", function() return {
+ Affe = "Monkey"
+ } end)
+
+ L:SetStrictness(true)
+
+ L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG5" or "AceLocale_DEBUG6")
+ assert(L.Affe == "Monkey")
+ assert(L.Haus == "Haus")
+ assert(L.Debug)
+ assert(L.Debug == AceLocale.prototype.Debug)
+
+ if MINOR_VERSION == 100000 then
+ L = AceLocale:new("AceLocale_DEBUG5")
+ assert(L.Affe == "Monkey")
+ assert(L.Haus == "Haus")
+ assert(L.Debug)
+ assert(L.Debug == AceLocale.prototype.Debug)
+ end
+end
+]]
diff --git a/FuBar_DurabilityFu/libs/AceLocale-2.2/AceLocale-2.2.toc b/FuBar_DurabilityFu/libs/AceLocale-2.2/AceLocale-2.2.toc
new file mode 100644
index 0000000..811fa5b
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceLocale-2.2/AceLocale-2.2.toc
@@ -0,0 +1,16 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r1098
+## X-Curse-Project-Name: Ace2
+## X-Curse-Project-ID: ace2
+## X-Curse-Repository-ID: wow/ace2/mainline
+
+## Title: Lib: AceLocale-2.2
+## Notes: AddOn development framework
+## Author: Ace Development Team
+## LoadOnDemand: 1
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-License: LGPL v2.1 + MIT for AceOO-2.0
+## Dependencies: AceLibrary
+
+AceLocale-2.2.lua
diff --git a/FuBar_DurabilityFu/libs/AceOO-2.0/AceOO-2.0.lua b/FuBar_DurabilityFu/libs/AceOO-2.0/AceOO-2.0.lua
new file mode 100644
index 0000000..4a540f8
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceOO-2.0/AceOO-2.0.lua
@@ -0,0 +1,980 @@
+--[[
+Name: AceOO-2.0
+Revision: $Rev: 1091 $
+Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team)
+Inspired By: Ace 1.x by Turan (turan@gryphon.com)
+Website: http://www.wowace.com/
+Documentation: http://www.wowace.com/index.php/AceOO-2.0
+SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceOO-2.0
+Description: Library to provide an object-orientation framework.
+Dependencies: AceLibrary
+License: MIT
+]]
+
+local MAJOR_VERSION = "AceOO-2.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 1091 $"):match("(%d+)"))
+
+-- This ensures the code is only executed if the libary doesn't already exist, or is a newer version
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+local AceOO = {
+ error = AceLibrary.error,
+ argCheck = AceLibrary.argCheck
+}
+
+-- @function getuid
+-- @brief Obtain a unique string identifier for the object in question.
+-- @param t The object to obtain the uid for.
+-- @return The uid string.
+local function getuid(t)
+ local mt = getmetatable(t)
+ setmetatable(t, nil)
+ local str = tostring(t)
+ setmetatable(t, mt)
+ local cap = str:match("[^:]*: 0x(.*)$") or str:match("[^:]*: (.*)$")
+ if cap then
+ return ("0"):rep(8 - #cap) .. cap
+ end
+end
+
+local function getlibrary(o)
+ if type(o) == "table" then
+ return o
+ elseif type(o) == "string" then
+ if not AceLibrary:HasInstance(o) then
+ AceOO:error("Library %q does not exist.", o)
+ end
+ return AceLibrary(o)
+ end
+end
+
+local function deeprawget(self, k)
+ while true do
+ local v = rawget(self, k)
+ if v ~= nil then
+ return v
+ end
+ local mt = getmetatable(self)
+ if not mt or type(mt.__index) ~= "table" then
+ return nil
+ end
+ self = mt.__index
+ end
+end
+
+-- @function Factory
+-- @brief Construct a factory for the creation of objects.
+-- @param obj The object whose init method will be called on the new factory
+-- object.
+-- @param newobj The object whose init method will be called on the new
+-- objects that the Factory creates, to initialize them.
+-- @param (...) Arguments which will be passed to obj.init() in addition
+-- to the Factory object.
+-- @return The new factory which creates a newobj when its new method is called,
+-- or when it is called directly (__call metamethod).
+local Factory
+do
+ local function getlibraries(...)
+ if select('#', ...) == 0 then
+ return
+ end
+ return getlibrary((select(1, ...))), getlibraries(select(2, ...))
+ end
+ local arg = {}
+ local function new(obj, ...)
+ local t = {}
+ local uid = getuid(t)
+ obj:init(t, getlibraries(...))
+ t.uid = uid
+ return t
+ end
+
+ local function createnew(self, ...)
+ local o = self.prototype
+ local x = new(o, getlibraries(...))
+ return x
+ end
+
+ function Factory(obj, newobj, ...)
+ local t = new(obj, ...)
+ t.prototype = newobj
+ t.new = createnew
+ getmetatable(t).__call = t.new
+ return t
+ end
+end
+
+
+local function objtostring(self)
+ if self.ToString then
+ return self:ToString()
+ elseif self.GetLibraryVersion then
+ return (self:GetLibraryVersion())
+ elseif self.super then
+ local s = "Sub-" .. tostring(self.super)
+ local first = true
+ if self.interfaces then
+ for interface in pairs(self.interfaces) do
+ if first then
+ s = s .. "(" .. tostring(interface)
+ first = false
+ else
+ s = s .. ", " .. tostring(interface)
+ end
+ end
+ end
+ if self.mixins then
+ for mixin in pairs(self.mixins) do
+ if first then
+ s = s .. tostring(mixin)
+ first = false
+ else
+ s = s .. ", " .. tostring(mixin)
+ end
+ end
+ end
+ if first then
+ if self.uid then
+ return s .. ":" .. self.uid
+ else
+ return s
+ end
+ else
+ return s .. ")"
+ end
+ else
+ return self.uid and 'Subclass:' .. self.uid or 'Subclass'
+ end
+end
+
+-- @table Object
+-- @brief Base of all objects, including Class.
+--
+-- @method init
+-- @brief Initialize a new object.
+-- @param newobject The object to initialize
+-- @param class The class to make newobject inherit from
+local Object
+do
+ Object = {}
+ function Object:init(newobject, class)
+ local parent = class or self
+ if not rawget(newobject, 'uid') then
+ newobject.uid = getuid(newobject)
+ end
+ local mt = {
+ __index = parent,
+ __tostring = objtostring,
+ }
+ setmetatable(newobject, mt)
+ end
+ Object.uid = getuid(Object)
+ setmetatable(Object, { __tostring = function() return 'Object' end })
+end
+
+local Interface
+
+local function validateInterface(object, interface)
+ if not object.class and object.prototype then
+ object = object.prototype
+ end
+ for k,v in pairs(interface.interface) do
+ if tostring(type(object[k])) ~= v then
+ return false
+ end
+ end
+ if interface.superinterfaces then
+ for superinterface in pairs(interface.superinterfaces) do
+ if not validateInterface(object, superinterface) then
+ return false
+ end
+ end
+ end
+ if type(object.class) == "table" and rawequal(object.class.prototype, object) then
+ if not object.class.interfaces then
+ rawset(object.class, 'interfaces', {})
+ end
+ object.class.interfaces[interface] = true
+ elseif type(object.class) == "table" and type(object.class.prototype) == "table" then
+ validateInterface(object.class.prototype, interface)
+ -- check if class is proper, thus preventing future checks.
+ end
+ return true
+end
+
+-- @function inherits
+-- @brief Return whether an Object or Class inherits from a given
+-- parent.
+-- @param object Object or Class to check
+-- @param parent Parent to test inheritance from
+-- @return whether an Object or Class inherits from a given
+-- parent.
+local function inherits(object, parent)
+ object = getlibrary(object)
+ if type(parent) == "string" then
+ if not AceLibrary:HasInstance(parent) then
+ return false
+ else
+ parent = AceLibrary(parent)
+ end
+ end
+ AceOO:argCheck(parent, 2, "table")
+ if type(object) ~= "table" then
+ return false
+ end
+ local current
+ local class = deeprawget(object, 'class')
+ if class then
+ current = class
+ else
+ current = object
+ end
+ if type(current) ~= "table" then
+ return false
+ end
+ if rawequal(current, parent) then
+ return true
+ end
+ if parent.class then
+ while true do
+ if rawequal(current, Object) then
+ break
+ end
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if rawequal(mixin, parent) then
+ return true
+ end
+ end
+ end
+ if current.interfaces then
+ for interface in pairs(current.interfaces) do
+ if rawequal(interface, parent) then
+ return true
+ end
+ end
+ end
+ current = deeprawget(current, 'super')
+ if type(current) ~= "table" then
+ break
+ end
+ end
+
+ local isInterface = false
+ local curr = parent.class
+ while true do
+ if rawequal(curr, Object) then
+ break
+ elseif rawequal(curr, Interface) then
+ isInterface = true
+ break
+ end
+ curr = deeprawget(curr, 'super')
+ if type(curr) ~= "table" then
+ break
+ end
+ end
+ return isInterface and validateInterface(object, parent)
+ else
+ while true do
+ if rawequal(current, parent) then
+ return true
+ elseif rawequal(current, Object) then
+ return false
+ end
+ current = deeprawget(current, 'super')
+ if type(current) ~= "table" then
+ return false
+ end
+ end
+ end
+end
+
+-- @table Class
+-- @brief An object factory which sets up inheritence and supports
+-- 'mixins'.
+--
+-- @metamethod Class call
+-- @brief Call ClassFactory:new() to create a new class.
+--
+-- @method Class new
+-- @brief Construct a new object.
+-- @param (...) Arguments to pass to the object init function.
+-- @return The new object.
+--
+-- @method Class init
+-- @brief Initialize a new class.
+-- @param parent Superclass.
+-- @param (...) Mixins.
+--
+-- @method Class ToString
+-- @return A string representing the object, in this case 'Class'.
+local initStatus
+local Class
+local Mixin
+local autoEmbed = false
+local function traverseInterfaces(bit, total)
+ if bit.superinterfaces then
+ for interface in pairs(bit.superinterfaces) do
+ if not total[interface] then
+ total[interface] = true
+ traverseInterfaces(interface, total)
+ end
+ end
+ end
+end
+local class_new
+do
+ Class = Factory(Object, setmetatable({}, {__index = Object}), Object)
+ Class.super = Object
+
+ local function protostring(t)
+ return '<' .. tostring(t.class) .. ' prototype>'
+ end
+ local function classobjectstring(t)
+ if t.ToString then
+ return t:ToString()
+ elseif t.GetLibraryVersion then
+ return (t:GetLibraryVersion())
+ else
+ return '<' .. tostring(t.class) .. ' instance>'
+ end
+ end
+ local function classobjectequal(self, other)
+ if type(self) == "table" and self.Equals then
+ return self:Equals(other)
+ elseif type(other) == "table" and other.Equals then
+ return other:Equals(self)
+ elseif type(self) == "table" and self.CompareTo then
+ return self:CompareTo(other) == 0
+ elseif type(other) == "table" and other.CompareTo then
+ return other:CompareTo(self) == 0
+ else
+ return rawequal(self, other)
+ end
+ end
+ local function classobjectlessthan(self, other)
+ if type(self) == "table" and self.IsLessThan then
+ return self:IsLessThan(other)
+ elseif type(other) == "table" and other.IsLessThanOrEqualTo then
+ return not other:IsLessThanOrEqualTo(self)
+ elseif type(self) == "table" and self.CompareTo then
+ return self:CompareTo(other) < 0
+ elseif type(other) == "table" and other.CompareTo then
+ return other:CompareTo(self) > 0
+ elseif type(other) == "table" and other.IsLessThan and other.Equals then
+ return other:Equals(self) or other:IsLessThan(self)
+ else
+ AceOO:error("cannot compare two objects")
+ end
+ end
+ local function classobjectlessthanequal(self, other)
+ if type(self) == "table" and self.IsLessThanOrEqualTo then
+ return self:IsLessThanOrEqualTo(other)
+ elseif type(other) == "table" and other.IsLessThan then
+ return not other:IsLessThan(self)
+ elseif type(self) == "table" and self.CompareTo then
+ return self:CompareTo(other) <= 0
+ elseif type(other) == "table" and other.CompareTo then
+ return other:CompareTo(self) >= 0
+ elseif type(self) == "table" and self.IsLessThan and self.Equals then
+ return self:Equals(other) or self:IsLessThan(other)
+ else
+ AceOO:error("cannot compare two incompatible objects")
+ end
+ end
+ local function classobjectadd(self, other)
+ if type(self) == "table" and self.Add then
+ return self:Add(other)
+ else
+ AceOO:error("cannot add two incompatible objects")
+ end
+ end
+ local function classobjectsub(self, other)
+ if type(self) == "table" and self.Subtract then
+ return self:Subtract(other)
+ else
+ AceOO:error("cannot subtract two incompatible objects")
+ end
+ end
+ local function classobjectunm(self, other)
+ if type(self) == "table" and self.UnaryNegation then
+ return self:UnaryNegation(other)
+ else
+ AceOO:error("attempt to negate an incompatible object")
+ end
+ end
+ local function classobjectmul(self, other)
+ if type(self) == "table" and self.Multiply then
+ return self:Multiply(other)
+ else
+ AceOO:error("cannot multiply two incompatible objects")
+ end
+ end
+ local function classobjectdiv(self, other)
+ if type(self) == "table" and self.Divide then
+ return self:Divide(other)
+ else
+ AceOO:error("cannot divide two incompatible objects")
+ end
+ end
+ local function classobjectpow(self, other)
+ if type(self) == "table" and self.Exponent then
+ return self:Exponent(other)
+ else
+ AceOO:error("cannot exponentiate two incompatible objects")
+ end
+ end
+ local function classobjectconcat(self, other)
+ if type(self) == "table" and self.Concatenate then
+ return self:Concatenate(other)
+ else
+ AceOO:error("cannot concatenate two incompatible objects")
+ end
+ end
+ function class_new(self, ...)
+ if self.virtual then
+ AceOO:error("Cannot instantiate a virtual class.")
+ end
+
+ local o = self.prototype
+ local newobj = {}
+ if o.class and o.class.instancemeta then
+ setmetatable(newobj, o.class.instancemeta)
+ else
+ Object:init(newobj, o)
+ end
+
+ if self.interfaces and not self.interfacesVerified then
+ -- Verify the interfaces
+
+ for interface in pairs(self.interfaces) do
+ for field,kind in pairs(interface.interface) do
+ if tostring(type(newobj[field])) ~= kind then
+ AceOO:error("Class did not satisfy all interfaces. %q is required to be a %s. It is a %s", field, kind, tostring(type(newobj[field])))
+ end
+ end
+ end
+ self.interfacesVerified = true
+ end
+ local tmp = initStatus
+ initStatus = newobj
+ newobj:init(...)
+ if initStatus then
+ initStatus = tmp
+ AceOO:error("Initialization not completed, be sure to call the superclass's init method.")
+ return
+ end
+ initStatus = tmp
+ return newobj
+ end
+ local classmeta = {
+ __tostring = objtostring,
+ __call = function(self, ...)
+ return self:new(...)
+ end,
+ }
+ function Class:init(newclass, parent, ...)
+ parent = parent or self
+
+ local total
+
+ if parent.class then
+ total = { parent, ... }
+ parent = self
+ else
+ total = { ... }
+ end
+ if not inherits(parent, Class) then
+ AceOO:error("Classes must inherit from a proper class")
+ end
+ if parent.sealed then
+ AceOO:error("Cannot inherit from a sealed class")
+ end
+ for i,v in ipairs(total) do
+ if inherits(v, Mixin) and v.class then
+ if v.__deprecated then
+ AceOO:error(v.__deprecated)
+ end
+ if not newclass.mixins then
+ newclass.mixins = {}
+ end
+ if newclass.mixins[v] then
+ AceOO:error("Cannot explicitly inherit from the same mixin twice")
+ end
+ newclass.mixins[v] = true
+ elseif inherits(v, Interface) and v.class then
+ if not newclass.interfaces then
+ newclass.interfaces = {}
+ end
+ if newclass.interfaces[v] then
+ AceOO:error("Cannot explicitly inherit from the same interface twice")
+ end
+ newclass.interfaces[v] = true
+ else
+ AceOO:error("Classes can only inherit from one or zero classes and any number of mixins or interfaces")
+ end
+ end
+ if parent.interfaces then
+ if not newclass.interfaces then
+ newclass.interfaces = {}
+ end
+ for interface in pairs(parent.interfaces) do
+ newclass.interfaces[interface] = true
+ end
+ end
+ for k in pairs(total) do
+ total[k] = nil
+ end
+
+ newclass.super = parent
+
+ newclass.prototype = setmetatable(total, {
+ __index = parent.prototype,
+ __tostring = protostring,
+ })
+ total = nil
+
+ newclass.instancemeta = {
+ __index = newclass.prototype,
+ __tostring = classobjectstring,
+ __eq = classobjectequal,
+ __lt = classobjectlessthan,
+ __le = classobjectlessthanequal,
+ __add = classobjectadd,
+ __sub = classobjectsub,
+ __unm = classobjectunm,
+ __mul = classobjectmul,
+ __div = classobjectdiv,
+ __pow = classobjectpow,
+ __concat = classobjectconcat,
+ }
+
+ setmetatable(newclass, classmeta)
+
+ newclass.new = class_new
+
+ if newclass.mixins then
+ -- Fold in the mixins
+ local err, msg
+ for mixin in pairs(newclass.mixins) do
+ local ret
+ autoEmbed = true
+ ret, msg = pcall(mixin.embed, mixin, newclass.prototype)
+ autoEmbed = false
+ if not ret then
+ err = true
+ break
+ end
+ end
+
+ if err then
+ local pt = newclass.prototype
+ for k,v in pairs(pt) do
+ pt[k] = nil
+ end
+
+ -- method conflict
+ AceOO:error(msg)
+ end
+ end
+
+ newclass.prototype.class = newclass
+
+ if newclass.interfaces then
+ for interface in pairs(newclass.interfaces) do
+ traverseInterfaces(interface, newclass.interfaces)
+ end
+ end
+ if newclass.mixins then
+ for mixin in pairs(newclass.mixins) do
+ if mixin.interfaces then
+ if not newclass.interfaces then
+ newclass.interfaces = {}
+ end
+ for interface in pairs(mixin.interfaces) do
+ newclass.interfaces[interface] = true
+ end
+ end
+ end
+ end
+ end
+ function Class:ToString()
+ if type(self.GetLibraryVersion) == "function" then
+ return (self:GetLibraryVersion())
+ else
+ return "Class"
+ end
+ end
+
+ local tmp
+ function Class.prototype:init()
+ if rawequal(self, initStatus) then
+ initStatus = nil
+ else
+ AceOO:error("Improper self passed to init. You must do MyClass.super.prototype.init(self, ...)", 2)
+ end
+ self.uid = getuid(self)
+ local current = self.class
+ while true do
+ if current == Class then
+ break
+ end
+ if current.mixins then
+ for mixin in pairs(current.mixins) do
+ if type(mixin.OnInstanceInit) == "function" then
+ mixin:OnInstanceInit(self)
+ end
+ end
+ end
+ current = current.super
+ end
+ end
+end
+
+
+-- @object ClassFactory
+-- @brief A factory for creating classes. Rarely used directly.
+local ClassFactory = Factory(Object, Class, Object)
+
+function Class:new(...)
+ local x = ClassFactory:new(...)
+ if AceOO.classes then
+ AceOO.classes[x] = true
+ end
+ return x
+end
+getmetatable(Class).__call = Class.new
+
+-- @class Mixin
+-- @brief A class to create mixin objects, which contain methods that get
+-- "mixed in" to class prototypes.
+--
+-- @object Mixin prototype
+-- @brief The prototype that mixin objects inherit their methods from.
+--
+-- @method Mixin prototype embed
+-- @brief Mix in the methods of our object which are listed in our interface
+-- to the supplied target table.
+--
+-- @method Mixin prototype init
+-- @brief Initialize the mixin object.
+-- @param newobj The new object we're initializing.
+-- @param interface The interface we implement (the list of methods our
+-- prototype provides which should be mixed into the target
+-- table by embed).
+do
+ Mixin = Class()
+ function Mixin:ToString()
+ if self.GetLibraryVersion then
+ return (self:GetLibraryVersion())
+ else
+ return 'Mixin'
+ end
+ end
+ local function _Embed(state, field, target)
+ field = next(state.export, field)
+ if field == nil then
+ return
+ end
+
+ if rawget(target, field) or (target[field] and target[field] ~= state[field]) then
+ AceOO:error("Method conflict in attempt to mixin. Field %q", field)
+ end
+
+ target[field] = state[field]
+
+ local ret,msg = pcall(_Embed, state, field, target)
+ if not ret then
+ -- Mix in the next method according to the defined interface. If that
+ -- fails due to a conflict, re-raise to back out the previous mixed
+ -- methods.
+
+ target[field] = nil
+ AceOO:error(msg)
+ end
+ end
+ function Mixin.prototype:embed(target)
+ if self.__deprecated then
+ AceOO:error(self.__deprecated)
+ end
+ local mt = getmetatable(target)
+ setmetatable(target, nil)
+ local err, msg = pcall(_Embed, self, nil, target)
+ if not err then
+ setmetatable(target, mt)
+ AceOO:error(msg)
+ return
+ end
+ if type(self.embedList) == "table" then
+ self.embedList[target] = true
+ end
+ if type(target.class) ~= "table" then
+ target[self] = true
+ end
+ if not autoEmbed and type(self.OnManualEmbed) == "function" then
+ self:OnManualEmbed(target)
+ end
+ setmetatable(target, mt)
+ end
+
+ function Mixin.prototype:activate(oldLib, oldDeactivate)
+ if oldLib and oldLib.embedList then
+ for target in pairs(oldLib.embedList) do
+ local mt = getmetatable(target)
+ setmetatable(target, nil)
+ for field in pairs(oldLib.export) do
+ target[field] = nil
+ end
+ setmetatable(target, mt)
+ end
+ self.embedList = oldLib.embedList
+ for target in pairs(self.embedList) do
+ self:embed(target)
+ end
+ else
+ self.embedList = setmetatable({}, {__mode="k"})
+ end
+ end
+
+ function Mixin.prototype:init(export, ...)
+ AceOO:argCheck(export, 2, "table")
+ for k,v in pairs(export) do
+ if type(k) ~= "number" then
+ AceOO:error("All keys to argument #2 must be numbers.")
+ elseif type(v) ~= "string" then
+ AceOO:error("All values to argument #2 must be strings.")
+ end
+ end
+ local num = #export
+ for i = 1, num do
+ local v = export[i]
+ export[i] = nil
+ export[v] = true
+ end
+
+ local interfaces
+ if select('#', ...) >= 1 then
+ interfaces = { ... }
+ for i,v in ipairs(interfaces) do
+ v = getlibrary(v)
+ interfaces[i] = v
+ if not v.class or not inherits(v, Interface) then
+ AceOO:error("Mixins can inherit only from interfaces")
+ end
+ end
+ local num = #interfaces
+ for i = 1, num do
+ local v = interfaces[i]
+ interfaces[i] = nil
+ interfaces[v] = true
+ end
+ for interface in pairs(interfaces) do
+ traverseInterfaces(interface, interfaces)
+ end
+ for interface in pairs(interfaces) do
+ for field,kind in pairs(interface.interface) do
+ if kind ~= "nil" then
+ local good = false
+ for bit in pairs(export) do
+ if bit == field then
+ good = true
+ break
+ end
+ end
+ if not good then
+ AceOO:error("Mixin does not fully accommodate field %q", field)
+ end
+ end
+ end
+ end
+ end
+ self.super = Mixin.prototype
+ Mixin.super.prototype.init(self)
+ self.export = export
+ self.interfaces = interfaces
+ end
+end
+
+-- @class Interface
+-- @brief A class to create interfaces, which contain contracts that classes
+-- which inherit from this must comply with.
+--
+-- @object Interface prototype
+-- @brief The prototype that interface objects must adhere to.
+--
+-- @method Interface prototype init
+-- @brief Initialize the mixin object.
+-- @param interface The interface we contract (the hash of fields forced).
+-- @param (...) Superinterfaces
+do
+ Interface = Class()
+ function Interface:ToString()
+ if self.GetLibraryVersion then
+ return (self:GetLibraryVersion())
+ else
+ return 'Instance'
+ end
+ end
+ function Interface.prototype:init(interface, ...)
+ Interface.super.prototype.init(self)
+ AceOO:argCheck(interface, 2, "table")
+ for k,v in pairs(interface) do
+ if type(k) ~= "string" then
+ AceOO:error("All keys to argument #2 must be numbers.")
+ elseif type(v) ~= "string" then
+ AceOO:error("All values to argument #2 must be strings.")
+ elseif v ~= "nil" and v ~= "string" and v ~= "number" and v ~= "table" and v ~= "function" then
+ AceOO:error('All values to argument #2 must either be "nil", "string", "number", "table", or "function".')
+ end
+ end
+ if select('#', ...) >= 1 then
+ self.superinterfaces = { ... }
+ for i,v in ipairs(self.superinterfaces) do
+ v = getlibrary(v)
+ self.superinterfaces[i] = v
+ if not inherits(v, Interface) or not v.class then
+ AceOO:error('Cannot provide a non-Interface to inherit from')
+ end
+ end
+ local num = #self.superinterfaces
+ for i = 1, num do
+ local v = self.superinterfaces[i]
+ self.superinterfaces[i] = nil
+ self.superinterfaces[v] = true
+ end
+ end
+ self.interface = interface
+ end
+end
+
+-- @function Classpool
+-- @brief Obtain a read only class from our pool of classes, indexed by the
+-- superclass and mixins.
+-- @param sc The superclass of the class we want.
+-- @param (m1..m20) Mixins of the class we want's objects.
+-- @return A read only class from the class pool.
+local Classpool
+do
+ local pool = setmetatable({}, {__mode = 'v'})
+ local function newindex(k, v)
+ AceOO:error('Attempt to modify a read-only class.')
+ end
+ local function protonewindex(k, v)
+ AceOO:error('Attempt to modify a read-only class prototype.')
+ end
+ local function ts(bit)
+ if type(bit) ~= "table" then
+ return tostring(bit)
+ elseif getmetatable(bit) and bit.__tostring then
+ return tostring(bit)
+ elseif type(bit.GetLibraryVersion) == "function" then
+ return bit:GetLibraryVersion()
+ else
+ return tostring(bit)
+ end
+ end
+ local t = {}
+ local function getcomplexuid(sc, ...)
+ if sc then
+ if sc.uid then
+ table.insert(t, sc.uid)
+ else
+ AceOO:error("%s is not an appropriate class/mixin", ts(sc))
+ end
+ end
+ for i = 1, select('#', ...) do
+ local m = select(i, ...)
+ if m.uid then
+ table.insert(t, m.uid)
+ else
+ AceOO:error("%s is not an appropriate mixin", ts(m))
+ end
+ end
+ table.sort(t)
+ local uid = table.concat(t, '')
+ local num = #t
+ for i = 1, num do
+ t[i] = nil
+ end
+ return uid
+ end
+ local classmeta
+ local arg = {}
+ function Classpool(superclass, ...)
+ local l = getlibrary
+ superclass = getlibrary(superclass)
+ arg = { ... }
+ for i, v in ipairs(arg) do
+ arg[i] = getlibrary(v)
+ end
+ if superclass then
+ if superclass.class then -- mixin
+ table.insert(arg, 1, superclass)
+ superclass = Class
+ end
+ else
+ superclass = Class
+ end
+ local key = getcomplexuid(superclass, unpack(arg))
+ if not pool[key] then
+ local class = Class(superclass, unpack(arg))
+ if not classmeta then
+ classmeta = {}
+ local mt = getmetatable(class)
+ for k,v in pairs(mt) do
+ classmeta[k] = v
+ end
+ classmeta.__newindex = newindex
+ end
+ -- Prevent the user from adding methods to this class.
+ -- NOTE: I'm not preventing modifications of existing class members,
+ -- but it's likely that only a truly malicious user will be doing so.
+ class.sealed = true
+ setmetatable(class, classmeta)
+ getmetatable(class.prototype).__newindex = protonewindex
+ pool[key] = class
+ end
+ return pool[key]
+ end
+end
+
+AceOO.Factory = Factory
+AceOO.Object = Object
+AceOO.Class = Class
+AceOO.Mixin = Mixin
+AceOO.Interface = Interface
+AceOO.Classpool = Classpool
+AceOO.inherits = inherits
+
+-- Library handling bits
+
+local function activate(self, oldLib, oldDeactivate)
+ AceOO = self
+ Factory = self.Factory
+ Object = self.Object
+ Class = self.Class
+ ClassFactory.prototype = Class
+ Mixin = self.Mixin
+ Interface = self.Interface
+ Classpool = self.Classpool
+
+ if oldLib then
+ self.classes = oldLib.classes
+ end
+ if not self.classes then
+ self.classes = setmetatable({}, {__mode="k"})
+ else
+ for class in pairs(self.classes) do
+ class.new = class_new
+ end
+ end
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+AceLibrary:Register(AceOO, MAJOR_VERSION, MINOR_VERSION, activate)
+AceOO = AceLibrary(MAJOR_VERSION)
diff --git a/FuBar_DurabilityFu/libs/AceOO-2.0/AceOO-2.0.toc b/FuBar_DurabilityFu/libs/AceOO-2.0/AceOO-2.0.toc
new file mode 100644
index 0000000..b9aa862
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/AceOO-2.0/AceOO-2.0.toc
@@ -0,0 +1,16 @@
+## Interface: 100002
+## X-Curse-Packaged-Version: r1098
+## X-Curse-Project-Name: Ace2
+## X-Curse-Project-ID: ace2
+## X-Curse-Repository-ID: wow/ace2/mainline
+
+## Title: Lib: AceOO-2.0
+## Notes: AddOn development framework
+## Author: Ace Development Team
+## LoadOnDemand: 1
+## X-Website: http://www.wowace.com
+## X-Category: Library
+## X-License: LGPL v2.1 + MIT for AceOO-2.0
+## Dependencies: AceLibrary
+
+AceOO-2.0.lua
diff --git a/FuBar_DurabilityFu/libs/Crayon-2.0/Crayon-2.0.lua b/FuBar_DurabilityFu/libs/Crayon-2.0/Crayon-2.0.lua
new file mode 100644
index 0000000..1445fa7
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/Crayon-2.0/Crayon-2.0.lua
@@ -0,0 +1,232 @@
+--[[
+Name: Crayon-2.0
+Revision: $Rev: 61 $
+Author(s): ckknight (ckknight@gmail.com)
+Website: http://ckknight.wowinterface.com/
+Documentation: http://wiki.wowace.com/index.php/Crayon-2.0
+SVN: http://svn.wowace.com/root/trunk/CrayonLib/Crayon-2.0
+Description: A library to provide coloring tools.
+Dependencies: AceLibrary
+]]
+
+--Theondry (theondry@gmail.com) added the purple. yell at me if it's wrong, please
+
+local MAJOR_VERSION = "Crayon-2.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 61 $"):match("(%d+)"))
+
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+local Crayon = {}
+
+Crayon.COLOR_HEX_RED = "ff0000"
+Crayon.COLOR_HEX_ORANGE = "ff7f00"
+Crayon.COLOR_HEX_YELLOW = "ffff00"
+Crayon.COLOR_HEX_GREEN = "00ff00"
+Crayon.COLOR_HEX_WHITE = "ffffff"
+Crayon.COLOR_HEX_COPPER = "eda55f"
+Crayon.COLOR_HEX_SILVER = "c7c7cf"
+Crayon.COLOR_HEX_GOLD = "ffd700"
+Crayon.COLOR_HEX_PURPLE = "9980CC"
+Crayon.COLOR_HEX_BLUE = "0000ff"
+Crayon.COLOR_HEX_BLACK = "000000"
+
+function Crayon:Colorize(hexColor, text)
+ return "|cff" .. tostring(hexColor or 'ffffff') .. tostring(text) .. "|r"
+end
+function Crayon:Red(text) return self:Colorize(self.COLOR_HEX_RED, text) end
+function Crayon:Orange(text) return self:Colorize(self.COLOR_HEX_ORANGE, text) end
+function Crayon:Yellow(text) return self:Colorize(self.COLOR_HEX_YELLOW, text) end
+function Crayon:Green(text) return self:Colorize(self.COLOR_HEX_GREEN, text) end
+function Crayon:White(text) return self:Colorize(self.COLOR_HEX_WHITE, text) end
+function Crayon:Copper(text) return self:Colorize(self.COLOR_HEX_COPPER, text) end
+function Crayon:Silver(text) return self:Colorize(self.COLOR_HEX_SILVER, text) end
+function Crayon:Gold(text) return self:Colorize(self.COLOR_HEX_GOLD, text) end
+function Crayon:Purple(text) return self:Colorize(self.COLOR_HEX_PURPLE, text) end
+function Crayon:Blue(text) return self:Colorize(self.COLOR_HEX_BLUE, text) end
+function Crayon:Black(text) return self:Colorize(self.COLOR_HEX_BLACK, text) end
+
+local inf = 1/0
+
+local function GetThresholdPercentage(quality, ...)
+ local n = select('#', ...)
+ if n <= 1 then
+ return GetThresholdPercentage(quality, 0, ... or 1)
+ end
+
+ local worst = ...
+ local best = select(n, ...)
+
+ if worst == best and quality == worst then
+ return 0.5
+ end
+
+ if worst <= best then
+ if quality <= worst then
+ return 0
+ elseif quality >= best then
+ return 1
+ end
+ local last = worst
+ for i = 2, n-1 do
+ local value = select(i, ...)
+ if quality <= value then
+ return ((i-2) + (quality - last) / (value - last)) / (n-1)
+ end
+ last = value
+ end
+
+ local value = select(n, ...)
+ return ((n-2) + (quality - last) / (value - last)) / (n-1)
+ else
+ if quality >= worst then
+ return 0
+ elseif quality <= best then
+ return 1
+ end
+ local last = worst
+ for i = 2, n-1 do
+ local value = select(i, ...)
+ if quality >= value then
+ return ((i-2) + (quality - last) / (value - last)) / (n-1)
+ end
+ last = value
+ end
+
+ local value = select(n, ...)
+ return ((n-2) + (quality - last) / (value - last)) / (n-1)
+ end
+end
+
+function Crayon:GetThresholdColor(quality, ...)
+ self:argCheck(quality, 2, "number")
+ if quality ~= quality or quality == inf or quality == -inf then
+ return 1, 1, 1
+ end
+
+ local percent = GetThresholdPercentage(quality, ...)
+
+ if percent <= 0 then
+ return 1, 0, 0
+ elseif percent <= 0.5 then
+ return 1, percent*2, 0
+ elseif percent >= 1 then
+ return 0, 1, 0
+ else
+ return 2 - percent*2, 1, 0
+ end
+end
+
+function Crayon:GetThresholdHexColor(quality, ...)
+ local r, g, b = self:GetThresholdColor(quality, ...)
+ return string.format("%02x%02x%02x", r*255, g*255, b*255)
+end
+
+function Crayon:GetThresholdColorTrivial(quality, ...)
+ self:argCheck(quality, 2, "number")
+ if quality ~= quality or quality == inf or quality == -inf then
+ return 1, 1, 1
+ end
+
+ local percent = GetThresholdPercentage(quality, ...)
+
+ if percent <= 0 then
+ return 1, 0, 0
+ elseif percent <= 0.5 then
+ return 1, percent*2, 0
+ elseif percent <= 0.75 then
+ return 3 - percent*4, 1, 0
+ elseif percent >= 1 then
+ return 0.5, 0.5, 0.5
+ else
+ return percent*2 - 1.5, 2.5 - percent*2, percent*2 - 1.5
+ end
+end
+
+function Crayon:GetThresholdHexColorTrivial(quality, ...)
+ local r, g, b = self:GetThresholdColorTrivial(quality, ...)
+ return string.format("%02x%02x%02x", r*255, g*255, b*255)
+end
+
+function Crayon:RGBtoHSL(red, green, blue)
+ local hue, saturation, luminance
+ local minimum = math.min( red, green, blue )
+ local maximum = math.max( red, green, blue )
+ local difference = maximum - minimum
+
+ luminance = ( maximum + minimum ) / 2
+
+ if difference == 0 then --Greyscale
+ hue = 0
+ saturation = 0
+ else --Colour
+ if luminance < 0.5 then
+ saturation = difference / ( maximum + minimum )
+ else
+ saturation = difference / ( 2 - maximum- minimum )
+ end
+
+ local tmpRed = ( ( ( maximum - red ) / 6 ) + ( difference / 2 ) ) / difference
+ local tmpGreen = ( ( ( maximum - green ) / 6 ) + ( difference / 2 ) ) / difference
+ local tmpBlue = ( ( ( maximum - blue ) / 6 ) + ( difference / 2 ) ) / difference
+
+ if red == maximum then
+ hue = tmpBlue - tmpGreen
+ elseif green == maximum then
+ hue = ( 1 / 3 ) + tmpRed - tmpBlue
+ elseif blue == maximum then
+ hue = ( 2 / 3 ) + tmpGreen - tmpRed
+ end
+
+ hue = hue % 1
+ if hue < 0 then hue = hue + 1 end
+ end
+
+ return hue, saturation, luminance
+end
+
+function Crayon:HSLtoRGB(hue, saturation, luminance)
+ local red, green, blue
+
+ if ( S == 0 ) then
+ red, green, blue = luminance, luminance, luminance
+ else
+ if luminance < 0.5 then
+ var2 = luminance * ( 1 + saturation )
+ else
+ var2 = ( luminance + saturation ) - ( saturation * luminance )
+ end
+
+ var1 = 2 * luminance - var2
+
+ red = self:HueToColor( var1, var2, hue + ( 1 / 3 ) )
+ green = self:HueToColor( var1, var2, hue )
+ blue = self:HueToColor( var1, var2, hue - ( 1 / 3 ) )
+ end
+
+ return red, green, blue
+end
+
+function Crayon:HueToColor(var1, var2, hue)
+ hue = hue % 1
+ if hue < 0 then hue = hue + 1 end
+
+ if ( 6 * hue ) < 1 then
+ return hue + ( var2 - var1 ) * 6 * hue
+ elseif ( 2 * hue ) < 1 then
+ return var2
+ elseif ( 3 * hue ) < 2 then
+ return var1 + ( var2 - var1 ) * ( ( 2 / 3 ) - hue ) * 6
+ else
+ return var1
+ end
+end
+
+function Crayon:RotateRGBHue(red, green, blue, rotation)
+ local hue, saturation, luminance = self:RGBtoHSL(red, green, blue)
+ red, green, blue = self:HSLtoRGB(hue + rotation , saturation, luminance)
+ return red, green, blue
+end
+
+AceLibrary:Register(Crayon, MAJOR_VERSION, MINOR_VERSION)
+Crayon = nil
diff --git a/FuBar_DurabilityFu/libs/Deformat-2.0/Deformat-2.0.lua b/FuBar_DurabilityFu/libs/Deformat-2.0/Deformat-2.0.lua
new file mode 100644
index 0000000..aa67807
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/Deformat-2.0/Deformat-2.0.lua
@@ -0,0 +1,218 @@
+--[[
+Name: Deformat-2.0
+Revision: $Rev: 49 $
+Author(s): ckknight (ckknight@gmail.com)
+Website: http://ckknight.wowinterface.com/
+Documentation: http://wiki.wowace.com/index.php/Deformat-2.0
+SVN: http://svn.wowace.com/root/trunk/Deformat/Deformat-2.0
+Description: A library to deformat format strings.
+Dependencies: AceLibrary
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "Deformat-2.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 49 $"):match("(%d+)"))
+
+
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+local Deformat = {}
+
+do
+ local sequences = {
+ ["%d*d"] = "%%-?%%d+",
+ ["s"] = ".+",
+ ["[fg]"] = "%%-?%%d+%%.?%%d*",
+ ["%%%.%d[fg]"] = "%%-?%%d+%%.?%%d*",
+ ["c"] = ".",
+ }
+ local curries = {}
+
+ local function donothing() end
+
+ local select = select
+
+ local function concat(left, right, ...)
+ if not right then
+ return left
+ elseif select('#', ...) >= 1 then
+ return concat(concat(left, right), ...)
+ end
+ if not left:find("%%1%$") and not right:find("%%1%$") then
+ return left .. right
+ elseif not right:find("%%1%$") then
+ local i
+ for j = 9, 1, -1 do
+ if left:find("%%" .. j .. "%$") then
+ i = j
+ break
+ end
+ end
+ while true do
+ local first
+ local firstPat
+ for x, y in pairs(sequences) do
+ local i = right:find("%%" .. x)
+ if not first or (i and i < first) then
+ first = i
+ firstPat = x
+ end
+ end
+ if not first then
+ break
+ end
+ i = i + 1
+ right = right:gsub("%%(" .. firstPat .. ")", "%%" .. i .. "$%1")
+ end
+ return left .. right
+ elseif not left:find("%%1%$") then
+ local i = 0
+ while true do
+ local first
+ local firstPat
+ for x, y in pairs(sequences) do
+ local i = left:find("%%" .. x)
+ if not first or (i and i < first) then
+ first = i
+ firstPat = x
+ end
+ end
+ if not first then
+ break
+ end
+ i = i + 1
+ left = left:gsub("%%(" .. firstPat .. ")", "%%" .. i .. "$%1")
+ end
+ return concat(left, right)
+ else
+ local i
+ for j = 9, 1, -1 do
+ if left:find("%%" .. j .. "%$") then
+ i = j
+ break
+ end
+ end
+ local j
+ for k = 9, 1, -1 do
+ if right:find("%%" .. k .. "%$") then
+ j = k
+ break
+ end
+ end
+ for k = j, 1, -1 do
+ right = right:gsub("%%" .. k .. "%$", "%%" .. k + i .. "%$")
+ end
+ return left .. right
+ end
+ end
+
+ local function bubble(f, i, a1, ...)
+ if not a1 then
+ return
+ end
+ if f[i] then
+ return tonumber(a1), bubble(f, i+1, ...)
+ else
+ return a1, bubble(f, i+1, ...)
+ end
+ end
+
+ local function bubbleNum(f, o, i, ...)
+ if i > select('#', ...) then
+ return
+ end
+ if f[i] then
+ return tonumber((select(o[i], ...))), bubbleNum(f, o, i+1, ...)
+ else
+ return (select(o[i], ...)), bubbleNum(f, o, i+1, ...)
+ end
+ end
+
+ local function Curry(...)
+ local pattern = concat(...)
+ local unpattern = '^' .. pattern:gsub("([%(%)%.%*%+%-%[%]%?%^%$%%])", "%%%1") .. '$'
+ local f = {}
+ if not pattern:find("%%1%$") then
+ local i = 0
+ while true do
+ local first
+ local firstPat
+ for x, y in pairs(sequences) do
+ local i = unpattern:find("%%%%" .. x)
+ if not first or (i and i < first) then
+ first = i
+ firstPat = x
+ end
+ end
+ if not first then
+ break
+ end
+ unpattern = unpattern:gsub("%%%%" .. firstPat, "(" .. sequences[firstPat] .. ")", 1)
+ i = i + 1
+ if firstPat == "c" or firstPat == "s" then
+ f[i] = false
+ else
+ f[i] = true
+ end
+ end
+
+ if i == 0 then
+ return donothing
+ else
+ return function(text)
+ return bubble(f, 1, text:match(unpattern))
+ end
+ end
+ else
+ local o = {}
+ local i = 1
+ while true do
+ local pat
+ for x, y in pairs(sequences) do
+ if not pat and unpattern:find("%%%%" .. i .. "%%%$" .. x) then
+ pat = x
+ break
+ end
+ end
+ if not pat then
+ break
+ end
+ unpattern = unpattern:gsub("%%%%" .. i .. "%%%$" .. pat, "(" .. sequences[pat] .. ")", 1)
+ if pat == "c" or pat == "s" then
+ f[i] = false
+ else
+ f[i] = true
+ end
+ i = i + 1
+ end
+ i = 1
+ pattern:gsub("%%(%d)%$", function(w) o[i] = tonumber(w); i = i + 1; end)
+
+ if i == 1 then
+ return donothing
+ else
+ return function(text)
+ return bubbleNum(f, o, 1, text:match(unpattern))
+ end
+ end
+ end
+ end
+
+ function Deformat:Deformat(text, a1, ...)
+ self:argCheck(text, 2, "string")
+ self:argCheck(a1, 3, "string")
+ local pattern = (''):join(a1, ...)
+ if curries[pattern] == nil then
+ curries[pattern] = Curry(a1, ...)
+ end
+ return curries[pattern](text)
+ end
+end
+
+local mt = getmetatable(Deformat) or {}
+mt.__call = Deformat.Deformat
+setmetatable(Deformat, mt)
+
+AceLibrary:Register(Deformat, MAJOR_VERSION, MINOR_VERSION)
+Deformat = nil
diff --git a/FuBar_DurabilityFu/libs/Dewdrop-2.0/Dewdrop-2.0.lua b/FuBar_DurabilityFu/libs/Dewdrop-2.0/Dewdrop-2.0.lua
new file mode 100644
index 0000000..971d5f1
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/Dewdrop-2.0/Dewdrop-2.0.lua
@@ -0,0 +1,3511 @@
+--[[
+Name: Dewdrop-2.0
+Revision: $Rev: 326 $
+Author(s): ckknight (ckknight@gmail.com)
+Website: http://ckknight.wowinterface.com/
+Documentation: http://wiki.wowace.com/index.php/Dewdrop-2.0
+SVN: http://svn.wowace.com/root/trunk/DewdropLib/Dewdrop-2.0
+Description: A library to provide a clean dropdown menu interface.
+Dependencies: AceLibrary
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "Dewdrop-2.0"
+local MINOR_VERSION = tonumber(strmatch("$Revision: 326 $", "%d+")) + 90000
+
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+local Dewdrop = {}
+
+local SharedMedia
+
+local CLOSE = "Close"
+local CLOSE_DESC = "Close the menu."
+local VALIDATION_ERROR = "Validation error."
+local USAGE_TOOLTIP = "Usage: %s."
+local RANGE_TOOLTIP = "Note that you can scroll your mouse wheel while over the slider to step by one."
+local RESET_KEYBINDING_DESC = "Hit escape to clear the keybinding."
+local KEY_BUTTON1 = "Left Mouse"
+local KEY_BUTTON2 = "Right Mouse"
+local DISABLED = "Disabled"
+local DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?"
+
+if GetLocale() == "deDE" then
+ CLOSE = "Schlie\195\159en"
+ CLOSE_DESC = "Men\195\188 schlie\195\159en."
+ VALIDATION_ERROR = "Validierungsfehler."
+ USAGE_TOOLTIP = "Benutzung: %s."
+ RANGE_TOOLTIP = "Beachte das du mit dem Mausrad scrollen kannst solange du mit dem Mauszeiger \195\188ber dem Schieberegler bist, um feinere Spr\195\188nge zu machen."
+ RESET_KEYBINDING_DESC = "Escape dr\195\188cken, um die Tastenbelegung zu l\195\182schen."
+ KEY_BUTTON1 = "Linke Maustaste"
+ KEY_BUTTON2 = "Rechte Maustaste"
+ DISABLED = "Deaktiviert"
+ DEFAULT_CONFIRM_MESSAGE = "Bist du sicher das du `%s' machen willst?"
+elseif GetLocale() == "koKR" then
+ CLOSE = "닫기"
+ CLOSE_DESC = "메뉴를 닫습니다."
+ VALIDATION_ERROR = "오류 확인."
+ USAGE_TOOLTIP = "사용법: %s."
+ RANGE_TOOLTIP = "알림 : 슬라이더 위에서 마우스 휠을 사용하면 한단계씩 조절할 수 있습니다."
+ RESET_KEYBINDING_DESC = "단축키를 해제하려면 ESC키를 누르세요."
+ KEY_BUTTON1 = "왼쪽 마우스"
+ KEY_BUTTON2 = "오른쪽 마우스"
+ DISABLED = "비활성화됨"
+ DEFAULT_CONFIRM_MESSAGE = "정말로 `%s' 실행을 하시겠습니까 ?"
+elseif GetLocale() == "frFR" then
+ CLOSE = "Fermer"
+ CLOSE_DESC = "Ferme le menu."
+ VALIDATION_ERROR = "Erreur de validation."
+ USAGE_TOOLTIP = "Utilisation : %s."
+ RANGE_TOOLTIP = "Vous pouvez aussi utiliser la molette de la souris pour pour modifier progressivement."
+ RESET_KEYBINDING_DESC = "Appuyez sur la touche Echappement pour effacer le raccourci."
+ KEY_BUTTON1 = "Clic gauche"
+ KEY_BUTTON2 = "Clic droit"
+ DISABLED = "D\195\169sactiv\195\169"
+ DEFAULT_CONFIRM_MESSAGE = "\195\138tes-vous s\195\187r de vouloir effectuer '%s' ?"
+elseif GetLocale() == "esES" then
+ CLOSE = "Cerrar"
+ CLOSE_DESC = "Cierra el menú."
+ VALIDATION_ERROR = "Error de validación."
+ USAGE_TOOLTIP = "Uso: %s."
+ RANGE_TOOLTIP = "Puedes desplazarte verticalmente con la rueda del ratón sobre el desplazador."
+ RESET_KEYBINDING_DESC = "Pulsa Escape para borrar la asignación de tecla."
+ KEY_BUTTON1 = "Clic Izquierdo"
+ KEY_BUTTON2 = "Clic Derecho"
+ DISABLED = "Desactivado"
+ DEFAULT_CONFIRM_MESSAGE = "¿Estás seguro de querer realizar `%s'?"
+elseif GetLocale() == "zhTW" then
+ CLOSE = "關閉"
+ CLOSE_DESC = "關閉選單。"
+ VALIDATION_ERROR = "驗證錯誤。"
+ USAGE_TOOLTIP = "用法: %s。"
+ RANGE_TOOLTIP = "你可以在捲動條上使用滑鼠滾輪來捲動。"
+ RESET_KEYBINDING_DESC = "按Esc鍵清除快捷鍵。"
+ KEY_BUTTON1 = "滑鼠左鍵"
+ KEY_BUTTON2 = "滑鼠右鍵"
+ DISABLED = "停用"
+ DEFAULT_CONFIRM_MESSAGE = "是否執行「%s」?"
+elseif GetLocale() == "zhCN" then
+ CLOSE = "关闭"
+ CLOSE_DESC = "关闭菜单"
+ VALIDATION_ERROR = "验证错误."
+ USAGE_TOOLTIP = "用法: %s."
+ RANGE_TOOLTIP = "你可以在滚动条上使用鼠标滚轮来翻页."
+ RESET_KEYBINDING_DESC = "按ESC键清除按键绑定"
+ KEY_BUTTON1 = "鼠标左键"
+ KEY_BUTTON2 = "鼠标右键"
+ DISABLED = "禁用"
+ DEFAULT_CONFIRM_MESSAGE = "是否执行'%s'?"
+elseif GetLocale() == "ruRU" then
+ CLOSE = "Закрыть"
+ CLOSE_DESC = "Закрыть меню."
+ VALIDATION_ERROR = "Ошибка проверки данных."
+ USAGE_TOOLTIP = "Используйте: %s."
+ RANGE_TOOLTIP = "Используйте колесо мыши для прокрутки ползунка."
+ RESET_KEYBINDING_DESC = "Нажмите клавишу Escape для очистки клавиши."
+ KEY_BUTTON1 = "ЛКМ"
+ KEY_BUTTON2 = "ПКМ"
+ DISABLED = "Отключено"
+ DEFAULT_CONFIRM_MESSAGE = "Вы уверены что вы хотите выполнять `%s'?"
+end
+
+Dewdrop.KEY_BUTTON1 = KEY_BUTTON1
+Dewdrop.KEY_BUTTON2 = KEY_BUTTON2
+
+local function new(...)
+ local t = {}
+ for i = 1, select('#', ...), 2 do
+ local k = select(i, ...)
+ if k then
+ t[k] = select(i+1, ...)
+ else
+ break
+ end
+ end
+ return t
+end
+
+local tmp
+do
+ local t = {}
+ function tmp(...)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ for i = 1, select('#', ...), 2 do
+ local k = select(i, ...)
+ if k then
+ t[k] = select(i+1, ...)
+ else
+ break
+ end
+ end
+ return t
+ end
+end
+local tmp2
+do
+ local t = {}
+ function tmp2(...)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ for i = 1, select('#', ...), 2 do
+ local k = select(i, ...)
+ if k then
+ t[k] = select(i+1, ...)
+ else
+ break
+ end
+ end
+ return t
+ end
+end
+local levels
+local buttons
+
+
+-- Secure frame handling:
+-- Rather than using secure buttons in the menu (has problems), we have one
+-- master secureframe that we pop onto menu items on mouseover. This requires
+-- some dark magic with OnLeave etc, but it's not too bad.
+
+local eventFrame = CreateFrame("Button")
+local secureFrame
+local createSecureFrame
+
+local function secureFrame_Show(self)
+ local owner = self.owner
+
+ if self.secure then -- Leftovers from previos owner, clean up! ("Shouldn't" happen but does..)
+ for k,v in pairs(self.secure) do
+ self:SetAttribute(k, nil)
+ end
+ end
+ self.secure = owner.secure; -- Grab hold of new secure data
+
+ local scale = owner:GetEffectiveScale()
+
+ self:SetPoint("TOPLEFT", nil, "BOTTOMLEFT", owner:GetLeft() * scale, owner:GetTop() * scale)
+ self:SetPoint("BOTTOMRIGHT", nil, "BOTTOMLEFT", owner:GetRight() * scale, owner:GetBottom() * scale)
+ self:EnableMouse(true)
+ for k,v in pairs(self.secure) do
+ self:SetAttribute(k, v)
+ end
+
+ secureFrame:SetFrameStrata(owner:GetFrameStrata())
+ secureFrame:SetFrameLevel(owner:GetFrameLevel()+1)
+
+ self:Show()
+end
+
+local function secureFrame_Hide(self)
+ self:Hide()
+ if self.secure then
+ for k,v in pairs(self.secure) do
+ self:SetAttribute(k, nil)
+ end
+ end
+ self.secure = nil
+end
+
+eventFrame:SetScript("OnEvent",
+ function(this, event)
+ if event=="PLAYER_REGEN_ENABLED" then
+ createSecureFrame()
+ secureFrame.combat = false
+ if not secureFrame:IsShown() and secureFrame.owner then
+ secureFrame_Show(secureFrame)
+ end
+ elseif event=="PLAYER_REGEN_DISABLED" and secureFrame then
+ secureFrame.combat = true
+ if secureFrame:IsShown() then
+ secureFrame_Hide(secureFrame)
+ end
+ end
+ end
+)
+eventFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
+eventFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
+
+function createSecureFrame()
+ if secureFrame or InCombatLockdown() then return end
+ secureFrame = CreateFrame("Button", nil, nil, "SecureActionButtonTemplate")
+ secureFrame:Hide()
+
+secureFrame:SetScript("OnLeave",
+ function(this)
+ local owner=this.owner
+ this:Deactivate()
+ owner:GetScript("OnLeave")(owner)
+ end
+)
+
+-- secureFrame:HookScript("OnClick",
+-- function(this)
+-- local realthis = this
+-- this = this.owner
+-- this:GetScript("OnClick")(this)
+-- end
+-- )
+
+function secureFrame:IsOwnedBy(frame)
+ return self.owner == frame
+end
+
+function secureFrame:Activate(owner)
+ if self.owner then -- "Shouldn't" happen but apparently it does and I cba to troubleshoot...
+ if not self.combat then
+ secureFrame_Hide(self)
+ end
+ end
+ self.owner = owner
+ if not self.combat then
+ secureFrame_Show(self)
+ end
+end
+
+function secureFrame:Deactivate()
+ if not self.combat then
+ secureFrame_Hide(self)
+ end
+ self.owner = nil
+end
+
+end
+createSecureFrame()
+-- END secure frame utilities
+
+
+-- Underline on mouseover - use a single global underline that we move around, no point in creating lots of copies
+local underlineFrame = CreateFrame("Frame", nil)
+underlineFrame.tx = underlineFrame:CreateTexture()
+underlineFrame.tx:SetTexture(1,1,0.5,0.75)
+underlineFrame:SetScript("OnHide", function(this) this:Hide(); end)
+underlineFrame:SetScript("OnShow", function(this) -- change sizing on the fly to catch runtime uiscale changes
+ underlineFrame.tx:SetPoint("TOPLEFT", -1, -2/this:GetEffectiveScale())
+ underlineFrame.tx:SetPoint("RIGHT", 1,0)
+ underlineFrame.tx:SetHeight(0.6 / this:GetEffectiveScale());
+end)
+underlineFrame:SetHeight(1)
+
+-- END underline on mouseover
+
+
+local function GetScaledCursorPosition()
+ local x, y = GetCursorPosition()
+ local scale = UIParent:GetEffectiveScale()
+ return x / scale, y / scale
+end
+
+local function StartCounting(self, level)
+ for i = level, 1, -1 do
+ if levels[i] then
+ levels[i].count = 3
+ end
+ end
+end
+
+local function StopCounting(self, level)
+ for i = level, 1, -1 do
+ if levels[i] then
+ levels[i].count = nil
+ end
+ end
+end
+
+local function OnUpdate(self, elapsed)
+ for _,level in ipairs(levels) do
+ local count = level.count
+ if count then
+ count = count - elapsed
+ if count < 0 then
+ level.count = nil
+ self:Close(level.num)
+ else
+ level.count = count
+ end
+ end
+ end
+end
+
+local function CheckDualMonitor(self, frame)
+ local ratio = GetScreenWidth() / GetScreenHeight()
+ if ratio >= 2.4 and frame:GetRight() > GetScreenWidth() / 2 and frame:GetLeft() < GetScreenWidth() / 2 then
+ local offsetx
+ if GetCursorPosition() / GetScreenHeight() * 768 < GetScreenWidth() / 2 then
+ offsetx = GetScreenWidth() / 2 - frame:GetRight()
+ else
+ offsetx = GetScreenWidth() / 2 - frame:GetLeft()
+ end
+ local point, parent, relativePoint, x, y = frame:GetPoint(1)
+ frame:SetPoint(point, parent, relativePoint, (x or 0) + offsetx, y or 0)
+ end
+end
+
+local function CheckSize(self, level)
+ if not level.buttons then
+ return
+ end
+ local height = 20
+ for _, button in ipairs(level.buttons) do
+ height = height + button:GetHeight()
+ end
+ level:SetHeight(height)
+ local width = 160
+ for _, button in ipairs(level.buttons) do
+ local extra = 1
+ if button.hasArrow or button.hasColorSwatch then
+ extra = extra + 16
+ end
+ if not button.notCheckable then
+ extra = extra + 24
+ end
+ button.text:SetFont(STANDARD_TEXT_FONT, button.textHeight)
+ if button.text:GetStringWidth() + extra > width then
+ width = button.text:GetStringWidth() + extra
+ end
+ end
+ level:SetWidth(width + 20)
+ if level:GetLeft() and level:GetRight() and level:GetTop() and level:GetBottom() and (level:GetLeft() < 0 or level:GetRight() > GetScreenWidth() or level:GetTop() > GetScreenHeight() or level:GetBottom() < 0) then
+ level:ClearAllPoints()
+ local parent = level.parent or level:GetParent()
+ if type(parent) ~= "table" then
+ parent = UIParent
+ end
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ end
+ local dirty = false
+ if not level:GetRight() then
+ self:Close()
+ return
+ end
+ if level:GetRight() > GetScreenWidth() and level.lastDirection == "RIGHT" then
+ level.lastDirection = "LEFT"
+ dirty = true
+ elseif level:GetLeft() < 0 and level.lastDirection == "LEFT" then
+ level.lastDirection = "RIGHT"
+ dirty = true
+ end
+ if level:GetTop() > GetScreenHeight() and level.lastVDirection == "UP" then
+ level.lastVDirection = "DOWN"
+ dirty = true
+ elseif level:GetBottom() < 0 and level.lastVDirection == "DOWN" then
+ level.lastVDirection = "UP"
+ dirty = true
+ end
+ if dirty then
+ level:ClearAllPoints()
+ local parent = level.parent or level:GetParent()
+ if type(parent) ~= "table" then
+ parent = UIParent
+ end
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ end
+ if level:GetTop() > GetScreenHeight() then
+ local top = level:GetTop()
+ local point, parent, relativePoint, x, y = level:GetPoint(1)
+ level:ClearAllPoints()
+ level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) + GetScreenHeight() - top)
+ elseif level:GetBottom() < 0 then
+ local bottom = level:GetBottom()
+ local point, parent, relativePoint, x, y = level:GetPoint(1)
+ level:ClearAllPoints()
+ level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) - bottom)
+ end
+ CheckDualMonitor(self, level)
+ if mod(level.num, 5) == 0 then
+ local left, bottom = level:GetLeft(), level:GetBottom()
+ level:ClearAllPoints()
+ level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
+ end
+end
+
+local Open
+local OpenSlider
+local OpenEditBox
+local Refresh
+local Clear
+local function ReleaseButton(self, level, index)
+ if not level.buttons then
+ return
+ end
+ if not level.buttons[index] then
+ return
+ end
+ local button = level.buttons[index]
+ button:Hide()
+ if button.highlight then
+ button.highlight:Hide()
+ end
+-- button.arrow:SetVertexColor(1, 1, 1)
+-- button.arrow:SetHeight(16)
+-- button.arrow:SetWidth(16)
+ table.remove(level.buttons, index)
+ table.insert(buttons, button)
+ for k in pairs(button) do
+ if k ~= 0 and k ~= "text" and k ~= "check" and k ~= "arrow" and k ~= "colorSwatch" and k ~= "highlight" and k ~= "radioHighlight" then
+ button[k] = nil
+ end
+ end
+ return true
+end
+
+local function Scroll(self, level, down)
+ if down then
+ if level:GetBottom() < 0 then
+ local point, parent, relativePoint, x, y = level:GetPoint(1)
+ level:SetPoint(point, parent, relativePoint, x, y + 50)
+ if level:GetBottom() > 0 then
+ level:SetPoint(point, parent, relativePoint, x, y + 50 - level:GetBottom())
+ end
+ end
+ else
+ if level:GetTop() > GetScreenHeight() then
+ local point, parent, relativePoint, x, y = level:GetPoint(1)
+ level:SetPoint(point, parent, relativePoint, x, y - 50)
+ if level:GetTop() < GetScreenHeight() then
+ level:SetPoint(point, parent, relativePoint, x, y - 50 + GetScreenHeight() - level:GetTop())
+ end
+ end
+ end
+end
+
+local function getArgs(t, str, num, ...)
+ local x = t[str .. num]
+ if x == nil then
+ return ...
+ else
+ return x, getArgs(t, str, num + 1, ...)
+ end
+end
+
+local sliderFrame
+local editBoxFrame
+
+local normalFont
+local lastSetFont
+local justSetFont = false
+local regionTmp = {}
+local function fillRegionTmp(...)
+ for i = 1, select('#', ...) do
+ regionTmp[i] = select(i, ...)
+ end
+end
+
+local function showGameTooltip(this)
+ if this.tooltipTitle or this.tooltipText then
+ GameTooltip_SetDefaultAnchor(GameTooltip, this)
+ local disabled = not this.isTitle and this.disabled
+ local font
+ if this.tooltipTitle then
+ if SharedMedia and SharedMedia:IsValid("font", this.tooltipTitle) then
+ font = SharedMedia:Fetch("font", this.tooltipTitle)
+ end
+ if disabled then
+ GameTooltip:SetText(this.tooltipTitle, 0.5, 0.5, 0.5, 1)
+ else
+ GameTooltip:SetText(this.tooltipTitle, 1, 1, 1, 1)
+ end
+ if this.tooltipText then
+ if not font and SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then
+ font = SharedMedia:Fetch("font", this.tooltipText)
+ end
+ if disabled then
+ GameTooltip:AddLine(this.tooltipText, (NORMAL_FONT_COLOR.r + 0.5) / 2, (NORMAL_FONT_COLOR.g + 0.5) / 2, (NORMAL_FONT_COLOR.b + 0.5) / 2, 1)
+ else
+ GameTooltip:AddLine(this.tooltipText, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
+ end
+ end
+ else
+ if SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then
+ font = SharedMedia:Fetch("font", this.tooltipText)
+ end
+ if disabled then
+ GameTooltip:SetText(this.tooltipText, 0.5, 0.5, 0.5, 1)
+ else
+ GameTooltip:SetText(this.tooltipText, 1, 1, 1, 1)
+ end
+ end
+ if font then
+ fillRegionTmp(GameTooltip:GetRegions())
+ lastSetFont = font
+ justSetFont = true
+ for i,v in ipairs(regionTmp) do
+ if v.SetFont then
+ local norm,size,outline = v:GetFont()
+ v:SetFont(font, size, outline)
+ if not normalFont then
+ normalFont = norm
+ end
+ end
+ regionTmp[i] = nil
+ end
+ elseif not normalFont then
+ fillRegionTmp(GameTooltip:GetRegions())
+ for i,v in ipairs(regionTmp) do
+ if v.GetFont and not normalFont then
+ normalFont = v:GetFont()
+ end
+ regionTmp[i] = nil
+ end
+ end
+ GameTooltip:Show()
+ end
+ if this.tooltipFunc then
+ GameTooltip:SetOwner(this, "ANCHOR_NONE")
+ GameTooltip:SetPoint("TOPLEFT", this, "TOPRIGHT", 5, 0)
+ this.tooltipFunc(getArgs(this, 'tooltipArg', 1))
+ GameTooltip:Show()
+ end
+end
+
+local tmpt = setmetatable({}, {mode='v'})
+local numButtons = 0
+local function AcquireButton(self, level)
+ if not levels[level] then
+ return
+ end
+ level = levels[level]
+ if not level.buttons then
+ level.buttons = {}
+ end
+ local button
+ if #buttons == 0 then
+ numButtons = numButtons + 1
+ button = CreateFrame("Button", "Dewdrop20Button" .. numButtons, nil)
+ button:SetFrameStrata("FULLSCREEN_DIALOG")
+ button:SetHeight(16)
+ local highlight = button:CreateTexture(nil, "BACKGROUND")
+ highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
+ button.highlight = highlight
+ highlight:SetBlendMode("ADD")
+ highlight:SetAllPoints(button)
+ highlight:Hide()
+ local check = button:CreateTexture(nil, "ARTWORK")
+ button.check = check
+ check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
+ check:SetPoint("CENTER", button, "LEFT", 12, 0)
+ check:SetWidth(24)
+ check:SetHeight(24)
+ local radioHighlight = button:CreateTexture(nil, "ARTWORK")
+ button.radioHighlight = radioHighlight
+ radioHighlight:SetTexture("Interface\\Buttons\\UI-RadioButton")
+ radioHighlight:SetAllPoints(check)
+ radioHighlight:SetBlendMode("ADD")
+ radioHighlight:SetTexCoord(0.5, 0.75, 0, 1)
+ radioHighlight:Hide()
+ button:SetScript("OnEnter", function(this)
+ if (sliderFrame and sliderFrame:IsShown() and sliderFrame.mouseDown and sliderFrame.level == this.level.num + 1) or (editBoxFrame and editBoxFrame:IsShown() and editBoxFrame.mouseDown and editBoxFrame.level == this.level.num + 1) then
+ for i = 1, this.level.num do
+ Refresh(self, levels[i])
+ end
+ return
+ end
+ self:Close(this.level.num + 1)
+ if not this.disabled then
+ if this.secure then
+ secureFrame:Activate(this)
+ elseif this.hasSlider then
+ OpenSlider(self, this)
+ elseif this.hasEditBox then
+ OpenEditBox(self, this)
+ elseif this.hasArrow then
+ Open(self, this, nil, this.level.num + 1, this.value)
+ end
+ end
+ if not this.level then -- button reclaimed
+ return
+ end
+ StopCounting(self, this.level.num + 1)
+ if not this.disabled then
+ highlight:Show()
+ if this.isRadio then
+ button.radioHighlight:Show()
+ end
+ if this.mouseoverUnderline then
+ underlineFrame:SetParent(this)
+ underlineFrame:SetPoint("BOTTOMLEFT",this.text,0,0)
+ underlineFrame:SetWidth(this.text:GetWidth())
+ underlineFrame:Show()
+ end
+ end
+ showGameTooltip(this)
+ end)
+ button:SetScript("OnHide", function(this)
+ if this.secure and secureFrame:IsOwnedBy(this) then
+ secureFrame:Deactivate()
+ end
+ end)
+ button:SetScript("OnLeave", function(this)
+ if this.secure and secureFrame:IsShown() then
+ return; -- it's ok, we didn't actually mouse out of the button, only onto the secure frame on top of it
+ end
+ underlineFrame:Hide()
+ if not this.selected then
+ highlight:Hide()
+ end
+ button.radioHighlight:Hide()
+ if this.level then
+ StartCounting(self, this.level.num)
+ end
+ GameTooltip:Hide()
+ end)
+ local first = true
+ button:SetScript("OnClick", function(this)
+ if not this.disabled then
+ if this.hasColorSwatch then
+ local func = button.colorFunc
+ local hasOpacity = this.hasOpacity
+ local this = this
+ for k in pairs(tmpt) do
+ tmpt[k] = nil
+ end
+ for i = 1, 1000 do
+ local x = this['colorArg'..i]
+ if x == nil then
+ break
+ else
+ tmpt[i] = x
+ end
+ end
+ ColorPickerFrame.func = function()
+ if func then
+ local r,g,b = ColorPickerFrame:GetColorRGB()
+ local a = hasOpacity and 1 - OpacitySliderFrame:GetValue() or nil
+ local n = #tmpt
+ tmpt[n+1] = r
+ tmpt[n+2] = g
+ tmpt[n+3] = b
+ tmpt[n+4] = a
+ func(unpack(tmpt))
+ tmpt[n+1] = nil
+ tmpt[n+2] = nil
+ tmpt[n+3] = nil
+ tmpt[n+4] = nil
+ end
+ end
+ ColorPickerFrame.hasOpacity = this.hasOpacity
+ ColorPickerFrame.opacityFunc = ColorPickerFrame.func
+ ColorPickerFrame.opacity = 1 - this.opacity
+ ColorPickerFrame:SetColorRGB(this.r, this.g, this.b)
+ local r, g, b, a = this.r, this.g, this.b, this.opacity
+ ColorPickerFrame.cancelFunc = function()
+ if func then
+ local n = #tmpt
+ tmpt[n+1] = r
+ tmpt[n+2] = g
+ tmpt[n+3] = b
+ tmpt[n+4] = a
+ func(unpack(tmpt))
+ for i = 1, n+4 do
+ tmpt[i] = nil
+ end
+ end
+ end
+ self:Close(1)
+ ShowUIPanel(ColorPickerFrame)
+ elseif this.func then
+ local level = this.level
+ if type(this.func) == "string" then
+ if type(this.arg1[this.func]) ~= "function" then
+ self:error("Cannot call method %q", this.func)
+ end
+ this.arg1[this.func](this.arg1, getArgs(this, 'arg', 2))
+ else
+ this.func(getArgs(this, 'arg', 1))
+ end
+ if this.closeWhenClicked then
+ self:Close()
+ elseif level:IsShown() then
+ for i = 1, level.num do
+ Refresh(self, levels[i])
+ end
+ local value = levels[level.num].value
+ for i = level.num-1, 1, -1 do
+ local level = levels[i]
+ local good = false
+ for _,button in ipairs(level.buttons) do
+ if button.value == value then
+ good = true
+ break
+ end
+ end
+ if not good then
+ Dewdrop:Close(i+1)
+ end
+ value = levels[i].value
+ end
+ end
+ elseif this.closeWhenClicked then
+ self:Close()
+ end
+ end
+ end)
+ local text = button:CreateFontString(nil, "ARTWORK")
+ button.text = text
+ text:SetFontObject(GameFontHighlightSmall)
+ button.text:SetFont(STANDARD_TEXT_FONT, UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT)
+ button:SetScript("OnMouseDown", function(this, type)
+ if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then
+ text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 1 or 25, -1)
+ end
+ end)
+ button:SetScript("OnMouseUp", function(this)
+ if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then
+ text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 0 or 24, 0)
+ end
+ end)
+ local arrow = button:CreateTexture(nil, "ARTWORK")
+ button.arrow = arrow
+ arrow:SetPoint("LEFT", button, "RIGHT", -16, 0)
+ arrow:SetWidth(16)
+ arrow:SetHeight(16)
+ arrow:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
+ local colorSwatch = button:CreateTexture(nil, "ARTWORK")
+ button.colorSwatch = colorSwatch
+ colorSwatch:SetWidth(20)
+ colorSwatch:SetHeight(20)
+ colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
+ local texture = button:CreateTexture(nil, "OVERLAY")
+ colorSwatch.texture = texture
+ texture:SetTexture("Interface\\Buttons\\WHITE8X8")
+ texture:SetWidth(11.5)
+ texture:SetHeight(11.5)
+ texture:Show()
+ texture:SetPoint("CENTER", colorSwatch, "CENTER")
+ colorSwatch:SetPoint("RIGHT", button, "RIGHT", 0, 0)
+ else
+ button = table.remove(buttons)
+ end
+ button:ClearAllPoints()
+ button:SetParent(level)
+ button:SetFrameStrata(level:GetFrameStrata())
+ button:SetFrameLevel(level:GetFrameLevel() + 1)
+ button:SetPoint("LEFT", level, "LEFT", 10, 0)
+ button:SetPoint("RIGHT", level, "RIGHT", -10, 0)
+ if #level.buttons == 0 then
+ button:SetPoint("TOP", level, "TOP", 0, -10)
+ else
+ button:SetPoint("TOP", level.buttons[#level.buttons], "BOTTOM", 0, 0)
+ end
+ button.text:SetPoint("LEFT", button, "LEFT", 24, 0)
+ button:Show()
+ button.level = level
+ table.insert(level.buttons, button)
+ if not level.parented then
+ level.parented = true
+ level:ClearAllPoints()
+ if level.num == 1 then
+ if level.parent ~= UIParent and type(level.parent) == "table" then
+ level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT")
+ else
+ level:SetPoint("CENTER", UIParent, "CENTER")
+ end
+ else
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPLEFT", level.parent, "TOPRIGHT", 5, 10)
+ else
+ level:SetPoint("BOTTOMLEFT", level.parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT", -5, 10)
+ else
+ level:SetPoint("BOTTOMRIGHT", level.parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ end
+ level:SetFrameStrata("FULLSCREEN_DIALOG")
+ end
+ button:SetAlpha(1)
+ return button
+end
+
+local numLevels = 0
+local function AcquireLevel(self, level)
+ if not levels[level] then
+ for i = #levels + 1, level, -1 do
+ local i = i
+ numLevels = numLevels + 1
+ local frame = CreateFrame("Button", "Dewdrop20Level" .. numLevels, nil)
+ if i == 1 then
+ local old_CloseSpecialWindows = CloseSpecialWindows
+ function CloseSpecialWindows()
+ local found = old_CloseSpecialWindows()
+ if levels[1]:IsShown() then
+ self:Close()
+ return 1
+ end
+ return found
+ end
+ end
+ levels[i] = frame
+ frame.num = i
+ frame:SetParent(UIParent)
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ frame:Hide()
+ frame:SetWidth(180)
+ frame:SetHeight(10)
+ frame:SetFrameLevel(i * 3)
+ frame:SetScript("OnHide", function()
+ self:Close(level + 1)
+ end)
+ if frame.SetTopLevel then
+ frame:SetTopLevel(true)
+ end
+ frame:EnableMouse(true)
+ frame:EnableMouseWheel(true)
+ local backdrop = CreateFrame("Frame", nil, frame)
+ backdrop:SetAllPoints(frame)
+ backdrop:SetBackdrop(tmp(
+ 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
+ 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
+ 'tile', true,
+ 'insets', tmp2(
+ 'left', 5,
+ 'right', 5,
+ 'top', 5,
+ 'bottom', 5
+ ),
+ 'tileSize', 16,
+ 'edgeSize', 16
+ ))
+ backdrop:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
+ backdrop:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
+ frame:SetScript("OnClick", function()
+ self:Close(i)
+ end)
+ frame:SetScript("OnEnter", function()
+ StopCounting(self, i)
+ end)
+ frame:SetScript("OnLeave", function()
+ StartCounting(self, i)
+ end)
+ frame:SetScript("OnMouseWheel", function(this, arg1)
+ Scroll(self, frame, arg1 < 0)
+ end)
+ if i == 1 then
+ frame:SetScript("OnUpdate", function(this, arg1)
+ OnUpdate(self, arg1)
+ end)
+ levels[1].lastDirection = "RIGHT"
+ levels[1].lastVDirection = "DOWN"
+ else
+ levels[i].lastDirection = levels[i - 1].lastDirection
+ levels[i].lastVDirection = levels[i - 1].lastVDirection
+ end
+ end
+ end
+ local fullscreenFrame = GetUIPanel("fullscreen")
+ local l = levels[level]
+ local strata, framelevel = l:GetFrameStrata(), l:GetFrameLevel()
+ if fullscreenFrame then
+ l:SetParent(fullscreenFrame)
+ else
+ l:SetParent(UIParent)
+ end
+ l:SetFrameStrata(strata)
+ l:SetFrameLevel(framelevel)
+ l:SetAlpha(1)
+ return l
+end
+
+local function validateOptions(options, position, baseOptions, fromPass)
+ if not baseOptions then
+ baseOptions = options
+ end
+ if type(options) ~= "table" then
+ return "Options must be a table.", position
+ end
+ local kind = options.type
+ if type(kind) ~= "string" then
+ return '"type" must be a string.', position
+ elseif kind ~= "group" and kind ~= "range" and kind ~= "text" and kind ~= "execute" and kind ~= "toggle" and kind ~= "color" and kind ~= "dragLink" and kind ~= "header" then
+ return '"type" must either be "range", "text", "group", "toggle", "execute", "color", "dragLink", or "header".', position
+ end
+ if options.aliases then
+ if type(options.aliases) ~= "table" and type(options.aliases) ~= "string" then
+ return '"alias" must be a table or string', position
+ end
+ end
+ if not fromPass then
+ if kind == "execute" then
+ if type(options.func) ~= "string" and type(options.func) ~= "function" then
+ return '"func" must be a string or function', position
+ end
+ elseif kind == "range" or kind == "text" or kind == "toggle" then
+ if type(options.set) ~= "string" and type(options.set) ~= "function" then
+ return '"set" must be a string or function', position
+ end
+ if kind == "text" and options.get == false then
+ elseif type(options.get) ~= "string" and type(options.get) ~= "function" then
+ return '"get" must be a string or function', position
+ end
+ elseif kind == "group" and options.pass then
+ if options.pass ~= true then
+ return '"pass" must be either nil, true, or false', position
+ end
+ if not options.func then
+ if type(options.set) ~= "string" and type(options.set) ~= "function" then
+ return '"set" must be a string or function', position
+ end
+ if type(options.get) ~= "string" and type(options.get) ~= "function" then
+ return '"get" must be a string or function', position
+ end
+ elseif type(options.func) ~= "string" and type(options.func) ~= "function" then
+ return '"func" must be a string or function', position
+ end
+ end
+ end
+ if options ~= baseOptions then
+ if kind == "header" then
+ elseif type(options.desc) ~= "string" then
+ return '"desc" must be a string', position
+ elseif options.desc:len() == 0 then
+ return '"desc" cannot be a 0-length string', position
+ end
+ end
+ if options ~= baseOptions or kind == "range" or kind == "text" or kind == "toggle" or kind == "color" then
+ if options.type == "header" and not options.cmdName and not options.name then
+ elseif options.cmdName then
+ if type(options.cmdName) ~= "string" then
+ return '"cmdName" must be a string or nil', position
+ elseif options.cmdName:len() == 0 then
+ return '"cmdName" cannot be a 0-length string', position
+ end
+ if type(options.guiName) ~= "string" then
+ if not options.guiNameIsMap then
+ return '"guiName" must be a string or nil', position
+ end
+ elseif options.guiName:len() == 0 then
+ return '"guiName" cannot be a 0-length string', position
+ end
+ else
+ if type(options.name) ~= "string" then
+ return '"name" must be a string', position
+ elseif options.name:len() == 0 then
+ return '"name" cannot be a 0-length string', position
+ end
+ end
+ end
+ if options.guiNameIsMap then
+ if type(options.guiNameIsMap) ~= "boolean" then
+ return '"guiNameIsMap" must be a boolean or nil', position
+ elseif options.type ~= "toggle" then
+ return 'if "guiNameIsMap" is true, then "type" must be set to \'toggle\'', position
+ elseif type(options.map) ~= "table" then
+ return '"map" must be a table', position
+ end
+ end
+ if options.message and type(options.message) ~= "string" then
+ return '"message" must be a string or nil', position
+ end
+ if options.error and type(options.error) ~= "string" then
+ return '"error" must be a string or nil', position
+ end
+ if options.current and type(options.current) ~= "string" then
+ return '"current" must be a string or nil', position
+ end
+ if options.order then
+ if type(options.order) ~= "number" or (-1 < options.order and options.order < 0.999) then
+ return '"order" must be a non-zero number or nil', position
+ end
+ end
+ if options.disabled then
+ if type(options.disabled) ~= "function" and type(options.disabled) ~= "string" and options.disabled ~= true then
+ return '"disabled" must be a function, string, or boolean', position
+ end
+ end
+ if options.cmdHidden then
+ if type(options.cmdHidden) ~= "function" and type(options.cmdHidden) ~= "string" and options.cmdHidden ~= true then
+ return '"cmdHidden" must be a function, string, or boolean', position
+ end
+ end
+ if options.guiHidden then
+ if type(options.guiHidden) ~= "function" and type(options.guiHidden) ~= "string" and options.guiHidden ~= true then
+ return '"guiHidden" must be a function, string, or boolean', position
+ end
+ end
+ if options.hidden then
+ if type(options.hidden) ~= "function" and type(options.hidden) ~= "string" and options.hidden ~= true then
+ return '"hidden" must be a function, string, or boolean', position
+ end
+ end
+ if kind == "text" then
+ if type(options.validate) == "table" then
+ local t = options.validate
+ local iTable = nil
+ for k,v in pairs(t) do
+ if type(k) == "number" then
+ if iTable == nil then
+ iTable = true
+ elseif not iTable then
+ return '"validate" must either have all keys be indexed numbers or strings', position
+ elseif k < 1 or k > #t then
+ return '"validate" numeric keys must be indexed properly. >= 1 and <= #t', position
+ end
+ else
+ if iTable == nil then
+ iTable = false
+ elseif iTable then
+ return '"validate" must either have all keys be indexed numbers or strings', position
+ end
+ end
+ if type(v) ~= "string" then
+ return '"validate" values must all be strings', position
+ end
+ end
+ if options.multiToggle and options.multiToggle ~= true then
+ return '"multiToggle" must be a boolean or nil if "validate" is a table', position
+ end
+ elseif options.validate == "keybinding" then
+ -- no other checks
+ else
+ if type(options.usage) ~= "string" then
+ return '"usage" must be a string', position
+ elseif options.validate and type(options.validate) ~= "string" and type(options.validate) ~= "function" then
+ return '"validate" must be a string, function, or table', position
+ end
+ end
+ if options.multiToggle and type(options.validate) ~= "table" then
+ return '"validate" must be a table if "multiToggle" is true', position
+ end
+ elseif kind == "range" then
+ if options.min or options.max then
+ if type(options.min) ~= "number" then
+ return '"min" must be a number', position
+ elseif type(options.max) ~= "number" then
+ return '"max" must be a number', position
+ elseif options.min >= options.max then
+ return '"min" must be less than "max"', position
+ end
+ end
+ if options.step then
+ if type(options.step) ~= "number" then
+ return '"step" must be a number', position
+ elseif options.step < 0 then
+ return '"step" must be nonnegative', position
+ end
+ end
+ if options.bigStep then
+ if type(options.bigStep) ~= "number" then
+ return '"bigStep" must be a number', position
+ elseif options.bigStep < 0 then
+ return '"bigStep" must be nonnegative', position
+ end
+ end
+ if options.isPercent and options.isPercent ~= true then
+ return '"isPercent" must either be nil, true, or false', position
+ end
+ elseif kind == "toggle" then
+ if options.map then
+ if type(options.map) ~= "table" then
+ return '"map" must be a table', position
+ elseif type(options.map[true]) ~= "string" then
+ return '"map[true]" must be a string', position
+ elseif type(options.map[false]) ~= "string" then
+ return '"map[false]" must be a string', position
+ end
+ end
+ elseif kind == "color" then
+ if options.hasAlpha and options.hasAlpha ~= true then
+ return '"hasAlpha" must be nil, true, or false', position
+ end
+ elseif kind == "group" then
+ if options.pass and options.pass ~= true then
+ return '"pass" must be nil, true, or false', position
+ end
+ if type(options.args) ~= "table" then
+ return '"args" must be a table', position
+ end
+ for k,v in pairs(options.args) do
+ if type(k) ~= "number" then
+ if type(k) ~= "string" then
+ return '"args" keys must be strings or numbers', position
+ elseif k:len() == 0 then
+ return '"args" keys must not be 0-length strings.', position
+ end
+ end
+ if type(v) ~= "table" then
+ return '"args" values must be tables', position and position .. "." .. k or k
+ end
+ local newposition
+ if position then
+ newposition = position .. ".args." .. k
+ else
+ newposition = "args." .. k
+ end
+ local err, pos = validateOptions(v, newposition, baseOptions, options.pass)
+ if err then
+ return err, pos
+ end
+ end
+ elseif kind == "execute" then
+ if type(options.confirm) ~= "string" and type(options.confirm) ~= "boolean" and type(options.confirm) ~= "nil" then
+ return '"confirm" must be a string, boolean, or nil', position
+ end
+ end
+ if options.icon and type(options.icon) ~= "string" then
+ return'"icon" must be a string', position
+ end
+ if options.iconWidth or options.iconHeight then
+ if type(options.iconWidth) ~= "number" or type(options.iconHeight) ~= "number" then
+ return '"iconHeight" and "iconWidth" must be numbers', position
+ end
+ end
+ if options.iconCoordLeft or options.iconCoordRight or options.iconCoordTop or options.iconCoordBottom then
+ if type(options.iconCoordLeft) ~= "number" or type(options.iconCoordRight) ~= "number" or type(options.iconCoordTop) ~= "number" or type(options.iconCoordBottom) ~= "number" then
+ return '"iconCoordLeft", "iconCoordRight", "iconCoordTop", and "iconCoordBottom" must be numbers', position
+ end
+ end
+end
+
+local validatedOptions
+
+local values
+local mysort_args
+local mysort
+local othersort
+local othersort_validate
+
+local baseFunc, currentLevel
+
+local function confirmPopup(message, func, ...)
+ if not StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"] then
+ StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"] = {}
+ end
+ local t = StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"]
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t.text = message
+ t.button1 = ACCEPT or "Accept"
+ t.button2 = CANCEL or "Cancel"
+ t.OnAccept = function()
+ func(unpack(t))
+ end
+ for i = 1, select('#', ...) do
+ t[i] = select(i, ...)
+ end
+ t.timeout = 0
+ t.whileDead = 1
+ t.hideOnEscape = 1
+
+ Dewdrop:Close()
+ StaticPopup_Show("DEWDROP20_CONFIRM_DIALOG")
+end
+
+
+local function getMethod(settingname, handler, v, methodName, ...) -- "..." is simply returned straight out cause you can't do "a,b,c = 111,f(),222"
+ assert(v and type(v)=="table")
+ assert(methodName and type(methodName)=="string")
+
+ local method = v[methodName]
+ if type(method)=="function" then
+ return method, ...
+ elseif type(method)=="string" then
+ if not handler then
+ Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method)
+ elseif not handler[method] then
+ Dewdrop:error("[%s] 'handler' method %q not defined", tostring(settingname), method)
+ end
+ return handler[method], handler, ...
+ end
+
+ Dewdrop:error("[%s] Missing %q directive", tostring(settingname), methodName)
+end
+
+local function callMethod(settingname, handler, v, methodName, ...)
+ assert(v and type(v)=="table")
+ assert(methodName and type(methodName)=="string")
+
+ local method = v[methodName]
+ if type(method)=="function" then
+ local success, ret,ret2,ret3,ret4 = pcall(v[methodName], ...)
+ if not success then
+ geterrorhandler()(ret)
+ return nil
+ end
+ return ret,ret2,ret3,ret4
+
+ elseif type(method)=="string" then
+
+ local neg = method:match("^~(.-)$")
+ if neg then
+ method = neg
+ end
+ if not handler then
+ Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method)
+ elseif not handler[method] then
+ Dewdrop:error("[%s] 'handler' (%q) method %q not defined", tostring(settingname), handler.name or "(unnamed)", method)
+ end
+ local success, ret,ret2,ret3,ret4 = pcall(handler[method], handler, ...)
+ if not success then
+ geterrorhandler()(ret)
+ return nil
+ end
+ if neg then
+ return not ret
+ end
+ return ret,ret2,ret3,ret4
+ elseif method == false then
+ return nil
+ end
+
+ Dewdrop:error("[%s] Missing %q directive in %q", tostring(settingname), methodName, v.name or "(unnamed)")
+end
+
+local function skip1Nil(...)
+ if select(1,...)==nil then
+ return select(2,...)
+ end
+ return ...
+end
+
+function Dewdrop:FeedAceOptionsTable(options, difference)
+ self:argCheck(options, 2, "table")
+ self:argCheck(difference, 3, "nil", "number")
+ if not currentLevel then
+ self:error("Cannot call `FeedAceOptionsTable' outside of a Dewdrop declaration")
+ end
+ if not difference then
+ difference = 0
+ end
+ if not validatedOptions then
+ validatedOptions = {}
+ end
+ if not validatedOptions[options] then
+ local err, position = validateOptions(options)
+
+ if err then
+ if position then
+ Dewdrop:error(position .. ": " .. err)
+ else
+ Dewdrop:error(err)
+ end
+ end
+
+ validatedOptions[options] = true
+ end
+ local level = levels[currentLevel]
+ if not level then
+ self:error("Improper level given")
+ end
+ if not values then
+ values = {}
+ else
+ for k,v in pairs(values) do
+ values[k] = nil
+ end
+ end
+
+ local current = level
+ while current do -- this traverses from higher level numbers to lower, building "values" with leaf nodes first and trunk nodes later
+ if current.num == difference + 1 then
+ break
+ end
+ table.insert(values, current.value)
+ current = levels[current.num - 1]
+ end
+
+ local realOptions = options
+ local handler = options.handler
+ local passTable
+ local passValue
+ while #values > 0 do -- This loop traverses values from the END (trunk nodes first, then onto leaf nodes)
+ if options.pass then
+ if options.get and options.set then
+ passTable = options
+ elseif not passTable then
+ passTable = options
+ end
+ else
+ passTable = nil
+ end
+ local value = table.remove(values)
+ options = options.args and options.args[value]
+ if not options then
+ return
+ end
+ handler = options.handler or handler
+ passValue = passTable and value or nil
+ end
+
+ if options.type == "group" then
+ local hidden = options.hidden
+ if type(hidden) == "function" or type(hidden) == "string" then
+ hidden = callMethod(options.name or "(options root)", handler, options, "hidden", options.passValue) or false
+ end
+ if hidden then
+ return
+ end
+ local disabled = options.disabled
+ if type(disabled) == "function" or type(disabled) == "string" then
+ disabled = callMethod(options.name or "(options root)", handler, options, "disabled", options.passValue) or false
+ end
+ if disabled then
+ self:AddLine(
+ 'text', DISABLED,
+ 'disabled', true
+ )
+ return
+ end
+ for k in pairs(options.args) do
+ table.insert(values, k)
+ end
+ if options.pass then
+ if options.get and options.set then
+ passTable = options
+ elseif not passTable then
+ passTable = options
+ end
+ else
+ passTable = nil
+ end
+ if not mysort then
+ mysort = function(a, b)
+ local alpha, bravo = mysort_args[a], mysort_args[b]
+ local alpha_order = alpha.order or 100
+ local bravo_order = bravo.order or 100
+ local alpha_name = alpha.guiName or alpha.name
+ local bravo_name = bravo.guiName or bravo.name
+ if alpha_order == bravo_order then
+ if not alpha_name then
+ return bravo_name
+ elseif not bravo_name then
+ return false
+ else
+ return alpha_name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper() < bravo_name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper()
+ end
+ else
+ if alpha_order < 0 then
+ if bravo_order > 0 then
+ return false
+ end
+ else
+ if bravo_order < 0 then
+ return true
+ end
+ end
+ return alpha_order < bravo_order
+ end
+ end
+ end
+ mysort_args = options.args
+ table.sort(values, mysort)
+ mysort_args = nil
+ local hasBoth = #values >= 1 and (options.args[values[1]].order or 100) > 0 and (options.args[values[#values]].order or 100) < 0
+ local last_order = 1
+ for _,k in ipairs(values) do
+ local v = options.args[k]
+
+ local handler = v.handler or handler
+ if hasBoth and last_order > 0 and (v.order or 100) < 0 then
+ hasBoth = false
+ self:AddLine()
+ end
+ local hidden, disabled = v.guiHidden or v.hidden, v.disabled
+
+ if type(hidden) == "function" or type(hidden) == "string" then
+ hidden = callMethod(k, handler, v, "hidden", v.passValue) or false
+ end
+ if not hidden then
+ if type(disabled) == "function" or type(disabled) == "string" then
+ disabled = callMethod(k, handler, v, "disabled", v.passValue) or false
+ end
+ local name = (v.guiIconOnly and v.icon) and "" or (v.guiName or v.name)
+ local desc = v.guiDesc or v.desc
+ local iconHeight = v.iconHeight or 16
+ local iconWidth = v.iconWidth or 16
+ local iconCoordLeft = v.iconCoordLeft
+ local iconCoordRight = v.iconCoordRight
+ local iconCoordBottom = v.iconCoordBottom
+ local iconCoordTop = v.iconCoordTop
+ local tooltipTitle, tooltipText
+ tooltipTitle = name
+ if name ~= desc then
+ tooltipText = desc
+ end
+ if type(v.usage) == "string" and v.usage:trim():len() > 0 then
+ if tooltipText then
+ tooltipText = tooltipText .. "\n\n" .. USAGE_TOOLTIP:format(v.usage)
+ else
+ tooltipText = USAGE_TOOLTIP:format(v.usage)
+ end
+ end
+ local v_p = passTable
+ if not v_p or (v.type ~= "execute" and v.get and v.set) or (v.type == "execute" and v.func) then
+ v_p = v
+ end
+ local passValue = v.passValue or (v_p~=v and k) or nil
+ if v.type == "toggle" then
+ local checked = callMethod(name, handler, v_p, "get", passValue) or false
+ local checked_arg = checked
+ if type(v_p.get)=="string" and v_p.get:match("^~") then
+ checked_arg = not checked
+ end
+ local func, arg1, arg2, arg3 = getMethod(name, handler, v_p, "set", skip1Nil(passValue, not checked_arg))
+ if v.guiNameIsMap then
+ checked = checked and true or false
+ name = tostring(v.map and v.map[checked]):gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
+ tooltipTitle = name
+ checked = true--nil
+ end
+ self:AddLine(
+ 'text', name,
+ 'checked', checked,
+ 'isRadio', v.isRadio,
+ 'func', func,
+ 'arg1', arg1,
+ 'arg2', arg2,
+ 'arg3', arg3,
+ 'disabled', disabled,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText
+ )
+ elseif v.type == "execute" then
+ local func, arg1, arg2, arg3, arg4
+ local confirm = v.confirm
+ if confirm == true then
+ confirm = DEFAULT_CONFIRM_MESSAGE:format(tooltipText or tooltipTitle)
+ func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue)
+ elseif type(confirm) == "string" then
+ func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue)
+ else
+ func,arg1,arg2 = getMethod(name, handler, v_p, "func", passValue)
+ end
+ self:AddLine(
+ 'text', name,
+ 'checked', checked,
+ 'func', func,
+ 'arg1', arg1,
+ 'arg2', arg2,
+ 'arg3', arg3,
+ 'arg4', arg4,
+ 'disabled', disabled,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ elseif v.type == "range" then
+ local sliderValue
+ sliderValue = callMethod(name, handler, v_p, "get", passValue) or 0
+ local sliderFunc, sliderArg1, sliderArg2 = getMethod(name, handler, v_p, "set", passValue)
+ if tooltipText then
+ tooltipText = format("%s\n\n%s", tooltipText, RANGE_TOOLTIP)
+ else
+ tooltipText = RANGE_TOOLTIP
+ end
+ self:AddLine(
+ 'text', name,
+ 'hasArrow', true,
+ 'hasSlider', true,
+ 'sliderMin', v.min or 0,
+ 'sliderMax', v.max or 1,
+ 'sliderStep', v.step or 0,
+ 'sliderBigStep', v.bigStep or nil,
+ 'sliderIsPercent', v.isPercent or false,
+ 'sliderValue', sliderValue,
+ 'sliderFunc', sliderFunc,
+ 'sliderArg1', sliderArg1,
+ 'sliderArg2', sliderArg2,
+ 'fromAceOptions', true,
+ 'disabled', disabled,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ elseif v.type == "color" then
+ local r,g,b,a = callMethod(name, handler, v_p, "get", passValue)
+ if not r then
+ r,g,b,a = 0,0,0,0
+ end
+ local colorFunc, colorArg1, colorArg2 = getMethod(name, handler, v_p, "set", passValue)
+ self:AddLine(
+ 'text', name,
+ 'hasArrow', true,
+ 'hasColorSwatch', true,
+ 'r', r,
+ 'g', g,
+ 'b', b,
+ 'opacity', v.hasAlpha and a or nil,
+ 'hasOpacity', v.hasAlpha,
+ 'colorFunc', colorFunc,
+ 'colorArg1', colorArg1,
+ 'colorArg2', colorArg2,
+ 'disabled', disabled,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText
+ )
+ elseif v.type == "text" then
+ if type(v.validate) == "table" then
+ local func,arg1,arg2
+ if v.onClick then
+ func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue)
+ end
+ local checked
+ if v.isChecked then
+ checked = callMethod(name, handler, v, "isChecked", passValue) or false
+ end
+ self:AddLine(
+ 'text', name,
+ 'hasArrow', true,
+ 'value', k,
+ 'func', func,
+ 'arg1', arg1,
+ 'arg2', arg2,
+ 'mouseoverUnderline', func and true or nil,
+ 'disabled', disabled,
+ 'checked', checked,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ else
+ local editBoxText
+ editBoxText = callMethod(name, handler, v_p, "get", passValue) or ""
+ local editBoxFunc, editBoxArg1, editBoxArg2 = getMethod(name, handler, v_p, "set", passValue)
+
+ local editBoxValidateFunc, editBoxValidateArg1
+
+ if v.validate and v.validate ~= "keybinding" then
+ if v.validate == "keybinding" then
+ if tooltipText then
+ tooltipText = format("%s\n\n%s", tooltipText, RESET_KEYBINDING_DESC)
+ else
+ tooltipText = RESET_KEYBINDING_DESC
+ end
+ else
+ editBoxValidateFunc, editBoxValidateArg1 = getMethod(name, handler, v, "validate") -- no passvalue!
+ end
+ end
+
+ self:AddLine(
+ 'text', name,
+ 'hasArrow', true,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom,
+ 'hasEditBox', true,
+ 'editBoxText', editBoxText,
+ 'editBoxFunc', editBoxFunc,
+ 'editBoxArg1', editBoxArg1,
+ 'editBoxArg2', editBoxArg2,
+ 'editBoxValidateFunc', editBoxValidateFunc,
+ 'editBoxValidateArg1', editBoxValidateArg1,
+ 'editBoxIsKeybinding', v.validate == "keybinding",
+ 'editBoxKeybindingOnly', v.keybindingOnly,
+ 'editBoxKeybindingExcept', v.keybindingExcept,
+ 'disabled', disabled,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText
+ )
+ end
+ elseif v.type == "group" then
+ local func,arg1,arg2
+ if v.onClick then
+ func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue)
+ end
+ local checked
+ if v.isChecked then
+ checked = callMethod(name, handler, v, "isChecked", passValue) or false
+ end
+ self:AddLine(
+ 'text', name,
+ 'hasArrow', true,
+ 'value', k,
+ 'func', func,
+ 'arg1', arg1,
+ 'arg2', arg2,
+ 'mouseoverUnderline', func and true or nil,
+ 'disabled', disabled,
+ 'checked', checked,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ elseif v.type == "header" then
+ if name == "" or not name then
+ self:AddLine(
+ 'isTitle', true,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ else
+ self:AddLine(
+ 'text', name,
+ 'isTitle', true,
+ 'icon', v.icon,
+ 'iconHeight', iconHeight,
+ 'iconWidth', iconWidth,
+ 'iconCoordLeft', iconCoordLeft,
+ 'iconCoordRight', iconCoordRight,
+ 'iconCoordTop', iconCoordTop,
+ 'iconCoordBottom', iconCoordBottom
+ )
+ end
+ end
+ end
+ last_order = v.order or 100
+ end
+ elseif options.type == "text" and type(options.validate) == "table" then
+ local current
+ local options_p = passTable
+ if not options_p or (options.get and options.set) then
+ options_p = options
+ passTable = nil
+ passValue = nil
+ end
+ local multiToggle = options.multiToggle
+ local passValue = options.passValue or passValue
+ if not multiToggle then
+ current = callMethod(k, handler, options_p, "get", passValue)
+ end
+ local indexed = true
+ for k,v in pairs(options.validate) do
+ if type(k) ~= "number" then
+ indexed = false
+ end
+ table.insert(values, k)
+ end
+ if not indexed then
+ if not othersort then
+ othersort = function(alpha, bravo)
+ return othersort_validate[alpha]:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper() < othersort_validate[bravo]:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper()
+ end
+ end
+ othersort_validate = options.validate
+ table.sort(values, othersort)
+ othersort_validate = nil
+ end
+ for _,k in ipairs(values) do
+ local v = options.validate[k]
+ if type(k) == "number" then
+ k = v
+ end
+ local func, arg1, arg2, arg3, arg4 = getMethod(k, handler, options_p, "set", skip1Nil(passValue, k))
+ local checked
+ if multiToggle then
+ checked = callMethod(k, handler, options_p, "get", skip1Nil(passValue, k)) or false
+ if arg2 == nil then
+ arg2 = not checked
+ elseif arg3 == nil then
+ arg3 = not checked
+ else
+ arg4 = not checked
+ end
+ else
+ checked = (k == current or (type(k) == "string" and type(current) == "string" and k:lower() == current:lower()))
+ if checked then
+ func, arg1, arg2, arg3, arg4 = nil, nil, nil, nil, nil
+ end
+ end
+ local tooltipTitle
+ local tooltipText
+ if options.validateDesc then
+ tooltipTitle = v
+ tooltipText = options.validateDesc[k]
+ else
+ tooltipTitle = options.guiName or options.name
+ tooltipText = v
+ end
+ self:AddLine(
+ 'text', v,
+ 'func', func,
+ 'arg1', arg1,
+ 'arg2', arg2,
+ 'arg3', arg3,
+ 'arg4', arg4,
+ 'isRadio', not multiToggle,
+ 'checked', checked,
+ 'tooltipTitle', tooltipTitle,
+ 'tooltipText', tooltipText
+ )
+ end
+ for k in pairs(values) do
+ values[k] = nil
+ end
+ else
+ return false
+ end
+ return true
+end
+
+function Dewdrop:FeedTable(s, difference)
+ self:argCheck(s, 2, "table")
+ self:argCheck(difference, 3, "nil", "number")
+ if not currentLevel then
+ self:error("Cannot call `FeedTable' outside of a Dewdrop declaration")
+ end
+ if not difference then
+ difference = 0
+ end
+ local level = levels[currentLevel]
+ if not level then
+ self:error("Improper level given")
+ end
+ if not values then
+ values = {}
+ else
+ for k,v in pairs(values) do
+ values[k] = nil
+ end
+ end
+ local t = s.subMenu and s or {subMenu = s}
+ local current = level
+ while current do
+ if current.num == difference + 1 then
+ break
+ end
+ table.insert(values, current.value)
+ current = levels[current.num - 1]
+ end
+
+ while #values > 0 do
+ local value = table.remove(values)
+ t = t.subMenu and t.subMenu[value]
+ if not t then
+ return
+ end
+ end
+
+ if t.subMenu or current.num == 1 then
+ for k in pairs(t.subMenu) do
+ table.insert(values, k)
+ end
+ table.sort(values)
+ for _,k in ipairs(values) do
+ local argTable = {"value", k}
+ for key, val in pairs(t.subMenu[k]) do
+ table.insert(argTable, key)
+ table.insert(argTable, val)
+ end
+ self:AddLine(unpack(argTable))
+ end
+ for k in pairs(values) do
+ values[k] = nil
+ end
+ return false
+ end
+ return true
+end
+
+function Refresh(self, level)
+ if type(level) == "number" then
+ level = levels[level]
+ end
+ if not level then
+ return
+ end
+ if baseFunc then
+ Clear(self, level)
+ currentLevel = level.num
+ if type(baseFunc) == "table" then
+ if currentLevel == 1 then
+ local handler = baseFunc.handler
+ if handler then
+ local name = tostring(handler)
+ if not name:find('^table:') and not handler.hideMenuTitle then
+ name = name:gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
+ self:AddLine(
+ 'text', name,
+ 'isTitle', true
+ )
+ end
+ end
+-- elseif level.parentText then
+-- self:AddLine(
+-- 'text', level.parentText,
+-- 'tooltipTitle', level.parentTooltipTitle,
+-- 'tooltipText', level.parentTooltipText,
+-- 'tooltipFunc', level.parentTooltipFunc,
+-- 'isTitle', true
+-- )
+ end
+ self:FeedAceOptionsTable(baseFunc)
+ if currentLevel == 1 then
+ self:AddLine(
+ 'text', CLOSE,
+ 'tooltipTitle', CLOSE,
+ 'tooltipText', CLOSE_DESC,
+ 'closeWhenClicked', true
+ )
+ end
+ else
+-- if level.parentText then
+-- self:AddLine(
+-- 'text', level.parentText,
+-- 'tooltipTitle', level.parentTooltipTitle,
+-- 'tooltipText', level.parentTooltipText,
+-- 'tooltipFunc', level.parentTooltipFunc,
+-- 'isTitle', true
+-- )
+-- end
+ baseFunc(currentLevel, level.value, levels[level.num - 1] and levels[level.num - 1].value, levels[level.num - 2] and levels[level.num - 2].value, levels[level.num - 3] and levels[level.num - 3].value, levels[level.num - 4] and levels[level.num - 4].value)
+ end
+ currentLevel = nil
+ CheckSize(self, level)
+ end
+end
+
+function Dewdrop:Refresh(level)
+ self:argCheck(level, 2, "number", "nil")
+ if not level then
+ for k,v in pairs(levels) do
+ Refresh(self, v)
+ end
+ else
+ Refresh(self, levels[level])
+ end
+end
+
+function OpenSlider(self, parent)
+ if not sliderFrame then
+ sliderFrame = CreateFrame("Frame", nil, nil)
+ sliderFrame:SetWidth(100)
+ sliderFrame:SetHeight(170)
+ sliderFrame:SetScale(UIParent:GetScale())
+ sliderFrame:SetBackdrop(tmp(
+ 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
+ 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
+ 'tile', true,
+ 'insets', tmp2(
+ 'left', 5,
+ 'right', 5,
+ 'top', 5,
+ 'bottom', 5
+ ),
+ 'tileSize', 16,
+ 'edgeSize', 16
+ ))
+ sliderFrame:SetFrameStrata("FULLSCREEN_DIALOG")
+ if sliderFrame.SetTopLevel then
+ sliderFrame:SetTopLevel(true)
+ end
+ sliderFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
+ sliderFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
+ sliderFrame:EnableMouse(true)
+ sliderFrame:EnableMouseWheel(true)
+ sliderFrame:Hide()
+ sliderFrame:SetPoint("CENTER", UIParent, "CENTER")
+ local slider = CreateFrame("Slider", nil, sliderFrame)
+ sliderFrame.slider = slider
+ slider:SetOrientation("VERTICAL")
+ slider:SetMinMaxValues(0, 1)
+ slider:SetValueStep(0.000000001)
+ slider:SetValue(0.5)
+ slider:SetWidth(16)
+ slider:SetHeight(128)
+ slider:SetPoint("LEFT", sliderFrame, "LEFT", 15, 0)
+ slider:SetBackdrop(tmp(
+ 'bgFile', "Interface\\Buttons\\UI-SliderBar-Background",
+ 'edgeFile', "Interface\\Buttons\\UI-SliderBar-Border",
+ 'tile', true,
+ 'edgeSize', 8,
+ 'tileSize', 8,
+ 'insets', tmp2(
+ 'left', 3,
+ 'right', 3,
+ 'top', 3,
+ 'bottom', 3
+ )
+ ))
+ local texture = slider:CreateTexture()
+ slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
+ local text = slider:CreateFontString(nil, "ARTWORK")
+ sliderFrame.topText = text
+ text:SetFontObject(GameFontGreenSmall)
+ text:SetText("100%")
+ text:SetPoint("BOTTOM", slider, "TOP")
+ local text = slider:CreateFontString(nil, "ARTWORK")
+ sliderFrame.bottomText = text
+ text:SetFontObject(GameFontGreenSmall)
+ text:SetText("0%")
+ text:SetPoint("TOP", slider, "BOTTOM")
+ local editBox = CreateFrame("EditBox", nil, sliderFrame)
+ sliderFrame.currentText = editBox
+ editBox:SetFontObject(ChatFontNormal)
+ editBox:SetHeight(13)
+ editBox:SetPoint("RIGHT", sliderFrame, "RIGHT", -16, 0)
+ editBox:SetPoint("LEFT", slider, "RIGHT", 12, 0)
+ editBox:SetText("50%")
+ editBox:SetJustifyH("CENTER")
+
+ local width = editBox:GetWidth()/2 + 10
+ local left = editBox:CreateTexture(nil, "BACKGROUND")
+ left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left")
+ left:SetTexCoord(0, width / 256, 0, 1)
+ left:SetWidth(width)
+ left:SetHeight(32)
+ left:SetPoint("LEFT", editBox, "LEFT", -10, 0)
+ local right = editBox:CreateTexture(nil, "BACKGROUND")
+ right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right")
+ right:SetTexCoord(1 - width / 256, 1, 0, 1)
+ right:SetWidth(width)
+ right:SetHeight(32)
+ right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0)
+
+ local changed = false
+ local inside = false
+ slider:SetScript("OnValueChanged", function()
+ if sliderFrame.changing then
+ return
+ end
+ changed = true
+ local done = false
+ if sliderFrame.parent and sliderFrame.parent.sliderFunc then
+ local min = sliderFrame.parent.sliderMin or 0
+ local max = sliderFrame.parent.sliderMax or 1
+ local step
+ if sliderFrame.fineStep then
+ step = sliderFrame.parent.sliderStep or (max - min) / 100
+ else
+ step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100
+ end
+ local value = (1 - slider:GetValue()) * (max - min) + min
+ if step > 0 then
+ value = math.floor((value - min) / step + 0.5) * step + min
+ if value > max then
+ value = max
+ elseif value < min then
+ value = min
+ end
+ end
+ if value == sliderFrame.lastValue then
+ return
+ end
+ sliderFrame.lastValue = value
+ local text = sliderFrame.parent.sliderFunc(getArgs(sliderFrame.parent, 'sliderArg', 1, value))
+ if sliderFrame.parent.fromAceOptions then
+ text = nil
+ elseif type(text) == "string" or type(text) == "number" then
+ sliderFrame.currentText:SetText(text)
+ done = true
+ end
+ end
+ if not done then
+ local min = sliderFrame.parent.sliderMin or 0
+ local max = sliderFrame.parent.sliderMax or 1
+ local step
+ if sliderFrame.fineStep then
+ step = sliderFrame.parent.sliderStep or (max - min) / 100
+ else
+ step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100
+ end
+ local value = (1 - slider:GetValue()) * (max - min) + min
+ if step > 0 then
+ value = math.floor((value - min) / step + 0.5) * step + min
+ if value > max then
+ value = max
+ elseif value < min then
+ value = min
+ end
+ end
+ if sliderFrame.parent.sliderIsPercent then
+ sliderFrame.currentText:SetText(string.format("%.0f%%", value * 100))
+ else
+ if step < 0.1 then
+ sliderFrame.currentText:SetText(string.format("%.2f", value))
+ elseif step < 1 then
+ sliderFrame.currentText:SetText(string.format("%.1f", value))
+ else
+ sliderFrame.currentText:SetText(string.format("%.0f", value))
+ end
+ end
+ end
+ end)
+ local function onEnter()
+ StopCounting(self, sliderFrame.level)
+ showGameTooltip(sliderFrame.parent)
+ end
+ local function onLeave()
+ GameTooltip:Hide()
+ end
+ sliderFrame:SetScript("OnEnter", onEnter)
+ sliderFrame:SetScript("OnLeave", function()
+ GameTooltip:Hide()
+ if changed then
+ local parent = sliderFrame.parent
+ local sliderFunc = parent.sliderFunc
+ for i = 1, sliderFrame.level - 1 do
+ Refresh(self, levels[i])
+ end
+ local newParent
+ for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
+ if button.sliderFunc == sliderFunc then
+ newParent = button
+ break
+ end
+ end
+ if newParent then
+ OpenSlider(self, newParent)
+ else
+ sliderFrame:Hide()
+ end
+ end
+ end)
+ editBox:SetScript("OnEnter", onEnter)
+ editBox:SetScript("OnLeave", onLeave)
+ slider:SetScript("OnMouseDown", function()
+ sliderFrame.mouseDown = true
+ GameTooltip:Hide()
+ end)
+ slider:SetScript("OnMouseUp", function()
+ sliderFrame.mouseDown = false
+ if changed--[[ and not inside]] then
+ local parent = sliderFrame.parent
+ local sliderFunc = parent.sliderFunc
+ for i = 1, sliderFrame.level - 1 do
+ Refresh(self, levels[i])
+ end
+ local newParent
+ for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
+ if button.sliderFunc == sliderFunc then
+ newParent = button
+ break
+ end
+ end
+ if newParent then
+ OpenSlider(self, newParent)
+ else
+ sliderFrame:Hide()
+ end
+ end
+ if inside then
+ showGameTooltip(sliderFrame.parent)
+ end
+ end)
+ slider:SetScript("OnEnter", function()
+ inside = true
+ StopCounting(self, sliderFrame.level)
+ showGameTooltip(sliderFrame.parent)
+ end)
+ slider:SetScript("OnLeave", function()
+ inside = false
+ GameTooltip:Hide()
+ if changed and not sliderFrame.mouseDown then
+ local parent = sliderFrame.parent
+ local sliderFunc = parent.sliderFunc
+ for i = 1, sliderFrame.level - 1 do
+ Refresh(self, levels[i])
+ end
+ local newParent
+ for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
+ if button.sliderFunc == sliderFunc then
+ newParent = button
+ break
+ end
+ end
+ if newParent then
+ OpenSlider(self, newParent)
+ else
+ sliderFrame:Hide()
+ end
+
+ changed = false
+ end
+ end)
+ sliderFrame:SetScript("OnMouseWheel", function(t, a1)
+ local arg1 = a1 or arg1
+ local up = arg1 > 0
+
+ local min = sliderFrame.parent.sliderMin or 0
+ local max = sliderFrame.parent.sliderMax or 1
+ local step = sliderFrame.parent.sliderStep or (max - min) / 100
+ if step <= 0 then
+ step = (max - min) / 100
+ end
+
+ local value = (1 - slider:GetValue()) * (max - min) + min
+ if up then
+ value = value + step
+ else
+ value = value - step
+ end
+ if value > max then
+ value = max
+ elseif value < min then
+ value = min
+ end
+ sliderFrame.fineStep = true
+ if max<=min then
+ slider:SetValue(0)
+ else
+ slider:SetValue(1 - (value - min) / (max - min))
+ end
+ sliderFrame.fineStep = nil
+ end)
+ slider:SetScript("OnMouseWheel", sliderFrame:GetScript("OnMouseWheel"))
+ editBox:SetScript("OnEnterPressed", function(t, a1)
+ local value = editBox:GetNumber()
+
+ if sliderFrame.parent.sliderIsPercent then
+ value = value / 100
+ end
+
+ local min = sliderFrame.parent.sliderMin or 0
+ local max = sliderFrame.parent.sliderMax or 1
+
+ if value > max then
+ value = max
+ elseif value < min then
+ value = min
+ end
+ sliderFrame.fineStep = true
+ if max <= min then
+ slider:SetValue(0)
+ else
+ slider:SetValue(1 - (value - min) / (max - min))
+ end
+ sliderFrame.fineStep = nil
+
+ StartCounting(self, sliderFrame.level)
+ end)
+ editBox:SetScript("OnEscapePressed", function()
+ self:Close(sliderFrame.level)
+ StartCounting(self, sliderFrame.level)
+ end)
+ editBox:SetAutoFocus(false)
+ end
+ sliderFrame.parent = parent
+ sliderFrame.level = parent.level.num + 1
+ sliderFrame.parentValue = parent.level.value
+ sliderFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3)
+ sliderFrame.slider:SetFrameLevel(sliderFrame:GetFrameLevel() + 1)
+ sliderFrame.currentText:SetFrameLevel(sliderFrame:GetFrameLevel() + 1)
+ sliderFrame.currentText:ClearFocus()
+ sliderFrame.changing = true
+ if not parent.sliderMin or not parent.sliderMax then
+ return
+ end
+
+ if parent.arrow then
+-- parent.arrow:SetVertexColor(0.2, 0.6, 0)
+-- parent.arrow:SetHeight(24)
+-- parent.arrow:SetWidth(24)
+ parent.selected = true
+ parent.highlight:Show()
+ end
+
+ sliderFrame:SetClampedToScreen(false)
+ if not parent.sliderValue then
+ parent.sliderValue = (parent.sliderMin + parent.sliderMax) / 2
+ end
+ if parent.sliderMax <= parent.sliderMin then
+ sliderFrame.slider:SetValue(0)
+ else
+ sliderFrame.slider:SetValue(1 - (parent.sliderValue - parent.sliderMin) / (parent.sliderMax - parent.sliderMin))
+ end
+ sliderFrame.changing = false
+ sliderFrame.bottomText:SetText(parent.sliderMinText or "0")
+ sliderFrame.topText:SetText(parent.sliderMaxText or "1")
+ local text
+ if parent.sliderFunc and not parent.fromAceOptions then
+ text = parent.sliderFunc(getArgs(parent, 'sliderArg', 1, parent.sliderValue))
+ end
+ if type(text) == "number" or type(text) == "string" then
+ sliderFrame.currentText:SetText(text)
+ elseif parent.sliderIsPercent then
+ sliderFrame.currentText:SetText(string.format("%.0f%%", parent.sliderValue * 100))
+ else
+ if parent.sliderStep < 0.1 then
+ sliderFrame.currentText:SetText(string.format("%.2f", parent.sliderValue))
+ elseif parent.sliderStep < 1 then
+ sliderFrame.currentText:SetText(string.format("%.1f", parent.sliderValue))
+ else
+ sliderFrame.currentText:SetText(string.format("%.0f", parent.sliderValue))
+ end
+ end
+
+
+ sliderFrame.lastValue = parent.sliderValue
+
+ local level = parent.level
+ sliderFrame:Show()
+ sliderFrame:ClearAllPoints()
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ local dirty
+ if level.lastDirection == "RIGHT" then
+ if sliderFrame:GetRight() > GetScreenWidth() then
+ level.lastDirection = "LEFT"
+ dirty = true
+ end
+ elseif sliderFrame:GetLeft() < 0 then
+ level.lastDirection = "RIGHT"
+ dirty = true
+ end
+ if level.lastVDirection == "DOWN" then
+ if sliderFrame:GetBottom() < 0 then
+ level.lastVDirection = "UP"
+ dirty = true
+ end
+ elseif sliderFrame:GetTop() > GetScreenWidth() then
+ level.lastVDirection = "DOWN"
+ dirty = true
+ end
+ if dirty then
+ sliderFrame:ClearAllPoints()
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ end
+ local left, bottom = sliderFrame:GetLeft(), sliderFrame:GetBottom()
+ sliderFrame:ClearAllPoints()
+ sliderFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
+ if mod(level.num, 5) == 0 then
+ local left, bottom = level:GetLeft(), level:GetBottom()
+ level:ClearAllPoints()
+ level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
+ end
+ sliderFrame:SetClampedToScreen(true)
+end
+
+function OpenEditBox(self, parent)
+ if not editBoxFrame then
+ editBoxFrame = CreateFrame("Frame", nil, nil)
+ editBoxFrame:SetWidth(200)
+ editBoxFrame:SetHeight(40)
+ editBoxFrame:SetScale(UIParent:GetScale())
+ editBoxFrame:SetBackdrop(tmp(
+ 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
+ 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
+ 'tile', true,
+ 'insets', tmp2(
+ 'left', 5,
+ 'right', 5,
+ 'top', 5,
+ 'bottom', 5
+ ),
+ 'tileSize', 16,
+ 'edgeSize', 16
+ ))
+ editBoxFrame:SetFrameStrata("FULLSCREEN_DIALOG")
+ if editBoxFrame.SetTopLevel then
+ editBoxFrame:SetTopLevel(true)
+ end
+ editBoxFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
+ editBoxFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
+ editBoxFrame:EnableMouse(true)
+ editBoxFrame:EnableMouseWheel(true)
+ editBoxFrame:Hide()
+ editBoxFrame:SetPoint("CENTER", UIParent, "CENTER")
+
+ local editBox = CreateFrame("EditBox", nil, editBoxFrame)
+ editBoxFrame.editBox = editBox
+ editBox:SetFontObject(ChatFontNormal)
+ editBox:SetWidth(160)
+ editBox:SetHeight(13)
+ editBox:SetPoint("CENTER", editBoxFrame, "CENTER", 0, 0)
+
+ local left = editBox:CreateTexture(nil, "BACKGROUND")
+ left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left")
+ left:SetTexCoord(0, 100 / 256, 0, 1)
+ left:SetWidth(100)
+ left:SetHeight(32)
+ left:SetPoint("LEFT", editBox, "LEFT", -10, 0)
+ local right = editBox:CreateTexture(nil, "BACKGROUND")
+ right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right")
+ right:SetTexCoord(156/256, 1, 0, 1)
+ right:SetWidth(100)
+ right:SetHeight(32)
+ right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0)
+
+ editBox:SetScript("OnEnterPressed", function()
+ if editBoxFrame.parent and editBoxFrame.parent.editBoxValidateFunc then
+ local t = editBox.realText or editBox:GetText() or ""
+ local result = editBoxFrame.parent.editBoxValidateFunc(getArgs(editBoxFrame.parent, 'editBoxValidateArg', 1, t))
+ if not result then
+ UIErrorsFrame:AddMessage(VALIDATION_ERROR, 1, 0, 0)
+ return
+ end
+ end
+ if editBoxFrame.parent and editBoxFrame.parent.editBoxFunc then
+ local t
+ if editBox.realText ~= "NONE" then
+ t = editBox.realText or editBox:GetText() or ""
+ end
+ editBoxFrame.parent.editBoxFunc(getArgs(editBoxFrame.parent, 'editBoxArg', 1, t))
+ end
+ self:Close(editBoxFrame.level)
+ for i = 1, editBoxFrame.level - 1 do
+ Refresh(self, levels[i])
+ end
+ StartCounting(self, editBoxFrame.level-1)
+ end)
+ editBox:SetScript("OnEscapePressed", function()
+ self:Close(editBoxFrame.level)
+ StartCounting(self, editBoxFrame.level-1)
+ end)
+ editBox:SetScript("OnReceiveDrag", function(this)
+ if GetCursorInfo then
+ local type, alpha, bravo = GetCursorInfo()
+ local text
+ if type == "spell" then
+ text = GetSpellName(alpha, bravo)
+ elseif type == "item" then
+ text = bravo
+ end
+ if not text then
+ return
+ end
+ ClearCursor()
+ editBox:SetText(text)
+ end
+ end)
+ local changing = false
+ local skipNext = false
+
+ function editBox:SpecialSetText(text)
+ local oldText = editBox:GetText() or ""
+ if not text then
+ text = ""
+ end
+ if text ~= oldText then
+ changing = true
+ self:SetText(tostring(text))
+ changing = false
+ skipNext = true
+ end
+ end
+
+ editBox:SetScript("OnTextChanged", function()
+ if skipNext then
+ skipNext = false
+ elseif not changing and editBoxFrame.parent and editBoxFrame.parent.editBoxChangeFunc then
+ local t
+ if editBox.realText ~= "NONE" then
+ t = editBox.realText or editBox:GetText() or ""
+ end
+ local text = editBoxFrame.parent.editBoxChangeFunc(getArgs(editBoxFrame.parent, 'editBoxChangeArg', 1, t))
+ if text then
+ editBox:SpecialSetText(text)
+ end
+ end
+ end)
+ editBoxFrame:SetScript("OnEnter", function()
+ StopCounting(self, editBoxFrame.level)
+ showGameTooltip(editBoxFrame.parent)
+ end)
+ editBoxFrame:SetScript("OnLeave", function()
+ GameTooltip:Hide()
+ end)
+ editBox:SetScript("OnEnter", function()
+ StopCounting(self, editBoxFrame.level)
+ showGameTooltip(editBoxFrame.parent)
+ end)
+ editBox:SetScript("OnLeave", function()
+ GameTooltip:Hide()
+ end)
+ editBoxFrame:SetScript("OnKeyDown", function(this, a1)
+ if not editBox.keybinding then
+ return
+ end
+ local arg1 = a1 or arg1
+ local screenshotKey = GetBindingKey("SCREENSHOT")
+ if screenshotKey and arg1 == screenshotKey then
+ Screenshot()
+ return
+ end
+
+ if arg1 == "LeftButton" then
+ arg1 = "BUTTON1"
+ elseif arg1 == "RightButton" then
+ arg1 = "BUTTON2"
+ elseif arg1 == "MiddleButton" then
+ arg1 = "BUTTON3"
+ elseif arg1 == "Button4" then
+ arg1 = "BUTTON4"
+ elseif arg1 == "Button5" then
+ arg1 = "BUTTON5"
+ end
+ if arg1 == "UNKNOWN" then
+ return
+ elseif arg1 == "SHIFT" or arg1 == "CTRL" or arg1 == "ALT" then
+ return
+ elseif arg1 == "ENTER" then
+ if editBox.keybindingOnly and not editBox.keybindingOnly[editBox.realText] then
+ return editBox:GetScript("OnEscapePressed")()
+ elseif editBox.keybindingExcept and editBox.keybindingExcept[editBox.realText] then
+ return editBox:GetScript("OnEscapePressed")()
+ else
+ return editBox:GetScript("OnEnterPressed")()
+ end
+ elseif arg1 == "ESCAPE" then
+ if editBox.realText == "NONE" then
+ return editBox:GetScript("OnEscapePressed")()
+ else
+ editBox:SpecialSetText(NONE or "NONE")
+ editBox.realText = "NONE"
+ return
+ end
+ elseif editBox.keybindingOnly and not editBox.keybindingOnly[arg1] then
+ return
+ elseif editBox.keybindingExcept and editBox.keybindingExcept[arg1] then
+ return
+ end
+ local s = GetBindingText(arg1, "KEY_")
+ if s == "BUTTON1" then
+ s = KEY_BUTTON1
+ elseif s == "BUTTON2" then
+ s = KEY_BUTTON2
+ end
+ local real = arg1
+ if IsShiftKeyDown() then
+ s = "Shift-" .. s
+ real = "SHIFT-" .. real
+ end
+ if IsControlKeyDown() then
+ s = "Ctrl-" .. s
+ real = "CTRL-" .. real
+ end
+ if IsAltKeyDown() then
+ s = "Alt-" .. s
+ real = "ALT-" .. real
+ end
+ if editBox:GetText() ~= s then
+ editBox:SpecialSetText("-")
+ editBox:SpecialSetText(s)
+ editBox.realText = real
+ return editBox:GetScript("OnTextChanged")()
+ end
+ end)
+ editBoxFrame:SetScript("OnMouseDown", editBoxFrame:GetScript("OnKeyDown"))
+ editBox:SetScript("OnMouseDown", function(this, ...)
+ if GetCursorInfo and (CursorHasItem() or CursorHasSpell()) then
+ return editBox:GetScript("OnReceiveDrag")(this, ...)
+ end
+ return editBoxFrame:GetScript("OnKeyDown")(this, ...)
+ end)
+ editBoxFrame:SetScript("OnMouseWheel", function(t, a1)
+ local arg1 = a1 or arg1
+ local up = arg1 > 0
+ arg1 = up and "MOUSEWHEELUP" or "MOUSEWHEELDOWN"
+ return editBoxFrame:GetScript("OnKeyDown")(t or this, arg1)
+ end)
+ editBox:SetScript("OnMouseWheel", editBoxFrame:GetScript("OnMouseWheel"))
+ end
+ editBoxFrame.parent = parent
+ editBoxFrame.level = parent.level.num + 1
+ editBoxFrame.parentValue = parent.level.value
+ editBoxFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3)
+ editBoxFrame.editBox:SetFrameLevel(editBoxFrame:GetFrameLevel() + 1)
+ editBoxFrame.editBox.realText = nil
+ editBoxFrame:SetClampedToScreen(false)
+
+ editBoxFrame.editBox:SpecialSetText("")
+ if parent.editBoxIsKeybinding then
+ local s = parent.editBoxText
+ if s == "" then
+ s = "NONE"
+ end
+ editBoxFrame.editBox.realText = s
+ if s and s ~= "NONE" then
+ local alpha,bravo = s:match("^(.+)%-(.+)$")
+ if not bravo then
+ alpha = nil
+ bravo = s
+ end
+ bravo = GetBindingText(bravo, "KEY_")
+ if alpha then
+ editBoxFrame.editBox:SpecialSetText(alpha:upper() .. "-" .. bravo)
+ else
+ editBoxFrame.editBox:SpecialSetText(bravo)
+ end
+ else
+ editBoxFrame.editBox:SpecialSetText(NONE or "NONE")
+ end
+ else
+ editBoxFrame.editBox:SpecialSetText(parent.editBoxText)
+ end
+
+ editBoxFrame.editBox.keybinding = parent.editBoxIsKeybinding
+ editBoxFrame.editBox.keybindingOnly = parent.editBoxKeybindingOnly
+ editBoxFrame.editBox.keybindingExcept = parent.editBoxKeybindingExcept
+ editBoxFrame.editBox:EnableKeyboard(not parent.editBoxIsKeybinding)
+ editBoxFrame:EnableKeyboard(parent.editBoxIsKeybinding)
+
+ if parent.arrow then
+-- parent.arrow:SetVertexColor(0.2, 0.6, 0)
+-- parent.arrow:SetHeight(24)
+-- parent.arrow:SetWidth(24)
+ parent.selected = true
+ parent.highlight:Show()
+ end
+
+ local level = parent.level
+ editBoxFrame:Show()
+ editBoxFrame:ClearAllPoints()
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ local dirty
+ if level.lastDirection == "RIGHT" then
+ if editBoxFrame:GetRight() > GetScreenWidth() then
+ level.lastDirection = "LEFT"
+ dirty = true
+ end
+ elseif editBoxFrame:GetLeft() < 0 then
+ level.lastDirection = "RIGHT"
+ dirty = true
+ end
+ if level.lastVDirection == "DOWN" then
+ if editBoxFrame:GetBottom() < 0 then
+ level.lastVDirection = "UP"
+ dirty = true
+ end
+ elseif editBoxFrame:GetTop() > GetScreenWidth() then
+ level.lastVDirection = "DOWN"
+ dirty = true
+ end
+ if dirty then
+ editBoxFrame:ClearAllPoints()
+ if level.lastDirection == "RIGHT" then
+ if level.lastVDirection == "DOWN" then
+ editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
+ else
+ editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
+ end
+ else
+ if level.lastVDirection == "DOWN" then
+ editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
+ else
+ editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
+ end
+ end
+ end
+ local left, bottom = editBoxFrame:GetLeft(), editBoxFrame:GetBottom()
+ editBoxFrame:ClearAllPoints()
+ editBoxFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
+ if mod(level.num, 5) == 0 then
+ local left, bottom = level:GetLeft(), level:GetBottom()
+ level:ClearAllPoints()
+ level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
+ end
+ editBoxFrame:SetClampedToScreen(true)
+end
+
+function Dewdrop:EncodeKeybinding(text)
+ if text == nil or text == "NONE" then
+ return nil
+ end
+ text = tostring(text):upper()
+ local shift, ctrl, alt
+ local modifier
+ while true do
+ if text == "-" then
+ break
+ end
+ modifier, text = strsplit('-', text, 2)
+ if text then
+ if modifier ~= "SHIFT" and modifier ~= "CTRL" and modifier ~= "ALT" then
+ return false
+ end
+ if modifier == "SHIFT" then
+ if shift then
+ return false
+ end
+ shift = true
+ end
+ if modifier == "CTRL" then
+ if ctrl then
+ return false
+ end
+ ctrl = true
+ end
+ if modifier == "ALT" then
+ if alt then
+ return false
+ end
+ alt = true
+ end
+ else
+ text = modifier
+ break
+ end
+ end
+ if not text:find("^F%d+$") and text ~= "CAPSLOCK" and text:len() ~= 1 and (text:len() == 0 or text:byte() < 128 or text:len() > 4) and not _G["KEY_" .. text] and text ~= "BUTTON1" and text ~= "BUTTON2" then
+ return false
+ end
+ local s = GetBindingText(text, "KEY_")
+ if s == "BUTTON1" then
+ s = KEY_BUTTON1
+ elseif s == "BUTTON2" then
+ s = KEY_BUTTON2
+ end
+ if shift then
+ s = "Shift-" .. s
+ end
+ if ctrl then
+ s = "Ctrl-" .. s
+ end
+ if alt then
+ s = "Alt-" .. s
+ end
+ return s
+end
+
+function Dewdrop:IsOpen(parent)
+ self:argCheck(parent, 2, "table", "string", "nil")
+ return levels[1] and levels[1]:IsShown() and (not parent or parent == levels[1].parent or parent == levels[1]:GetParent())
+end
+
+function Dewdrop:GetOpenedParent()
+ return (levels[1] and levels[1]:IsShown()) and (levels[1].parent or levels[1]:GetParent())
+end
+
+function Open(self, parent, func, level, value, point, relativePoint, cursorX, cursorY)
+ self:Close(level)
+ if DewdropLib then
+ local d = DewdropLib:GetInstance('1.0')
+ local ret, val = pcall(d, IsOpen, d)
+ if ret and val then
+ DewdropLib:GetInstance('1.0'):Close()
+ end
+ end
+ if type(parent) == "table" then
+ parent:GetCenter()
+ end
+ local frame = AcquireLevel(self, level)
+ if level == 1 then
+ frame.lastDirection = "RIGHT"
+ frame.lastVDirection = "DOWN"
+ else
+ frame.lastDirection = levels[level - 1].lastDirection
+ frame.lastVDirection = levels[level - 1].lastVDirection
+ end
+ frame:SetFrameStrata("FULLSCREEN_DIALOG")
+ frame:ClearAllPoints()
+ frame.parent = parent
+ frame:SetPoint("LEFT", UIParent, "RIGHT", 10000, 0)
+ frame:Show()
+ if level == 1 then
+ baseFunc = func
+ end
+ levels[level].value = value
+-- levels[level].parentText = parent.text and parent.text:GetText() or nil
+-- levels[level].parentTooltipTitle = parent.tooltipTitle
+-- levels[level].parentTooltipText = parent.tooltipText
+-- levels[level].parentTooltipFunc = parent.tooltipFunc
+ if type(parent) == "table" and parent.arrow then
+-- parent.arrow:SetVertexColor(0.2, 0.6, 0)
+-- parent.arrow:SetHeight(24)
+-- parent.arrow:SetWidth(24)
+ parent.selected = true
+ parent.highlight:Show()
+ end
+ relativePoint = relativePoint or point
+ Refresh(self, levels[level])
+ if point or (cursorX and cursorY) then
+ frame:ClearAllPoints()
+ if cursorX and cursorY then
+ local curX, curY = GetScaledCursorPosition()
+ if curY < GetScreenHeight() / 2 then
+ point, relativePoint = "BOTTOM", "BOTTOM"
+ else
+ point, relativePoint = "TOP", "TOP"
+ end
+ if curX < GetScreenWidth() / 2 then
+ point, relativePoint = point .. "LEFT", relativePoint .. "RIGHT"
+ else
+ point, relativePoint = point .. "RIGHT", relativePoint .. "LEFT"
+ end
+ end
+ frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint)
+ if cursorX and cursorY then
+ local left = frame:GetLeft()
+ local width = frame:GetWidth()
+ local bottom = frame:GetBottom()
+ local height = frame:GetHeight()
+ local curX, curY = GetScaledCursorPosition()
+ frame:ClearAllPoints()
+ relativePoint = relativePoint or point
+ if point == "BOTTOM" or point == "TOP" then
+ if curX < GetScreenWidth() / 2 then
+ point = point .. "LEFT"
+ else
+ point = point .. "RIGHT"
+ end
+ elseif point == "CENTER" then
+ if curX < GetScreenWidth() / 2 then
+ point = "LEFT"
+ else
+ point = "RIGHT"
+ end
+ end
+ local xOffset, yOffset = 0, 0
+ if curY > GetScreenHeight() / 2 then
+ yOffset = -height
+ end
+ if curX > GetScreenWidth() / 2 then
+ xOffset = -width
+ end
+ frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left + xOffset, curY - bottom + yOffset)
+ if level == 1 then
+ frame.lastDirection = "RIGHT"
+ end
+ elseif cursorX then
+ local left = frame:GetLeft()
+ local width = frame:GetWidth()
+ local curX, curY = GetScaledCursorPosition()
+ frame:ClearAllPoints()
+ relativePoint = relativePoint or point
+ if point == "BOTTOM" or point == "TOP" then
+ if curX < GetScreenWidth() / 2 then
+ point = point .. "LEFT"
+ else
+ point = point .. "RIGHT"
+ end
+ elseif point == "CENTER" then
+ if curX < GetScreenWidth() / 2 then
+ point = "LEFT"
+ else
+ point = "RIGHT"
+ end
+ end
+ frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left - width / 2, 0)
+ if level == 1 then
+ frame.lastDirection = "RIGHT"
+ end
+ elseif cursorY then
+ local bottom = frame:GetBottom()
+ local height = frame:GetHeight()
+ local curX, curY = GetScaledCursorPosition()
+ frame:ClearAllPoints()
+ relativePoint = relativePoint or point
+ if point == "LEFT" or point == "RIGHT" then
+ if curX < GetScreenHeight() / 2 then
+ point = point .. "BOTTOM"
+ else
+ point = point .. "TOP"
+ end
+ elseif point == "CENTER" then
+ if curX < GetScreenHeight() / 2 then
+ point = "BOTTOM"
+ else
+ point = "TOP"
+ end
+ end
+ frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, 0, curY - bottom - height / 2)
+ if level == 1 then
+ frame.lastDirection = "DOWN"
+ end
+ end
+ if (strsub(point, 1, 3) ~= strsub(relativePoint, 1, 3)) then
+ if frame:GetBottom() < 0 then
+ local point, parent, relativePoint, x, y = frame:GetPoint(1)
+ local change = GetScreenHeight() - frame:GetTop()
+ local otherChange = -frame:GetBottom()
+ if otherChange < change then
+ change = otherChange
+ end
+ frame:SetPoint(point, parent, relativePoint, x, y + change)
+ elseif frame:GetTop() > GetScreenHeight() then
+ local point, parent, relativePoint, x, y = frame:GetPoint(1)
+ local change = GetScreenHeight() - frame:GetTop()
+ local otherChange = -frame:GetBottom()
+ if otherChange < change then
+ change = otherChange
+ end
+ frame:SetPoint(point, parent, relativePoint, x, y + change)
+ end
+ end
+ end
+ CheckDualMonitor(self, frame)
+ frame:SetClampedToScreen(true)
+ frame:SetClampedToScreen(false)
+ StartCounting(self, level)
+end
+
+function Dewdrop:IsRegistered(parent)
+ self:argCheck(parent, 2, "table", "string")
+ return not not self.registry[parent]
+end
+
+function Dewdrop:Register(parent, ...)
+ self:argCheck(parent, 2, "table", "string")
+ if self.registry[parent] then
+ self:Unregister(parent)
+ end
+ local info = new(...)
+ if type(info.children) == "table" then
+ local err, position = validateOptions(info.children)
+
+ if err then
+ if position then
+ Dewdrop:error(position .. ": " .. err)
+ else
+ Dewdrop:error(err)
+ end
+ end
+ end
+ self.registry[parent] = info
+ if not info.dontHook and not self.onceRegistered[parent] and type(parent) == "table" then
+ if parent:HasScript("OnMouseUp") then
+ local script = parent:GetScript("OnMouseUp")
+ parent:SetScript("OnMouseUp", function(this, ...)
+ local arg1 = ...
+ if script then
+ script(this, ...)
+ end
+ if arg1 == "RightButton" and self.registry[parent] then
+ if self:IsOpen(parent) then
+ self:Close()
+ else
+ self:Open(parent)
+ end
+ end
+ end)
+ end
+ if parent:HasScript("OnMouseDown") then
+ local script = parent:GetScript("OnMouseDown")
+ parent:SetScript("OnMouseDown", function(this, ...)
+ if script then
+ script(this, ...)
+ end
+ if self.registry[parent] then
+ self:Close()
+ end
+ end)
+ end
+ end
+ self.onceRegistered[parent] = true
+end
+
+function Dewdrop:Unregister(parent)
+ self:argCheck(parent, 2, "table", "string")
+ self.registry[parent] = nil
+end
+
+function Dewdrop:Open(parent, ...)
+ self:argCheck(parent, 2, "table", "string")
+ local info
+ local k1 = ...
+ if type(k1) == "table" and k1[0] and k1.IsObjectType and self.registry[k1] then
+ info = tmp(select(2, ...))
+ for k,v in pairs(self.registry[k1]) do
+ if info[k] == nil then
+ info[k] = v
+ end
+ end
+ else
+ info = tmp(...)
+ if self.registry[parent] then
+ for k,v in pairs(self.registry[parent]) do
+ if info[k] == nil then
+ info[k] = v
+ end
+ end
+ end
+ end
+ local point = info.point
+ local relativePoint = info.relativePoint
+ local cursorX = info.cursorX
+ local cursorY = info.cursorY
+ if type(point) == "function" then
+ local b
+ point, b = point(parent)
+ if b then
+ relativePoint = b
+ end
+ end
+ if type(relativePoint) == "function" then
+ relativePoint = relativePoint(parent)
+ end
+ Open(self, parent, info.children, 1, nil, point, relativePoint, cursorX, cursorY)
+end
+
+function Clear(self, level)
+ if level then
+ if level.buttons then
+ for i = #level.buttons, 1, -1 do
+ ReleaseButton(self, level, i)
+ end
+ end
+ end
+end
+
+function Dewdrop:Close(level)
+ if DropDownList1:IsShown() then
+ DropDownList1:Hide()
+ end
+ if DewdropLib then
+ local d = DewdropLib:GetInstance('1.0')
+ local ret, val = pcall(d, IsOpen, d)
+ if ret and val then
+ DewdropLib:GetInstance('1.0'):Close()
+ end
+ end
+ self:argCheck(level, 2, "number", "nil")
+ if not level then
+ level = 1
+ end
+ if level == 1 and levels[level] then
+ levels[level].parented = false
+ end
+ if level > 1 and levels[level-1].buttons then
+ local buttons = levels[level-1].buttons
+ for _,button in ipairs(buttons) do
+-- button.arrow:SetWidth(16)
+-- button.arrow:SetHeight(16)
+ button.selected = nil
+ button.highlight:Hide()
+-- button.arrow:SetVertexColor(1, 1, 1)
+ end
+ end
+ if sliderFrame and sliderFrame.level >= level then
+ sliderFrame:Hide()
+ end
+ if editBoxFrame and editBoxFrame.level >= level then
+ editBoxFrame:Hide()
+ end
+ for i = level, #levels do
+ Clear(self, levels[level])
+ levels[i]:Hide()
+ levels[i]:ClearAllPoints()
+ levels[i]:SetPoint("CENTER", UIParent, "CENTER")
+ levels[i].value = nil
+ end
+end
+
+function Dewdrop:AddSeparator(level)
+ level = levels[level or currentLevel]
+ if not level or not level.buttons then return; end
+
+ local prevbutton = level.buttons[#level.buttons]
+ if not prevbutton then return; end
+
+ if prevbutton.disabled and prevbutton.text:GetText() == "" then
+ return
+ end
+ self:AddLine("text", "", "disabled", true)
+end
+
+function Dewdrop:AddLine(...)
+ local info = tmp(...)
+ local level = info.level or currentLevel
+ info.level = nil
+ local button = AcquireButton(self, level)
+ if not next(info) then
+ info.disabled = true
+ end
+ button.disabled = info.isTitle or info.notClickable or info.disabled or (self.combat and info.secure)
+ button.isTitle = info.isTitle
+ button.notClickable = info.notClickable
+ if button.isTitle then
+ button.text:SetFontObject(GameFontNormalSmall)
+ elseif button.notClickable then
+ button.text:SetFontObject(GameFontHighlightSmall)
+ elseif button.disabled then
+ button.text:SetFontObject(GameFontDisableSmall)
+ else
+ button.text:SetFontObject(GameFontHighlightSmall)
+ end
+ if info.disabled then
+ button.arrow:SetDesaturated(true)
+ button.check:SetDesaturated(true)
+ else
+ button.arrow:SetDesaturated(false)
+ button.check:SetDesaturated(false)
+ end
+ if info.textR and info.textG and info.textB then
+ button.textR = info.textR
+ button.textG = info.textG
+ button.textB = info.textB
+ button.text:SetTextColor(button.textR, button.textG, button.textB)
+ else
+ button.text:SetTextColor(button.text:GetFontObject():GetTextColor())
+ end
+ button.notCheckable = info.notCheckable
+ button.text:SetPoint("LEFT", button, "LEFT", button.notCheckable and 0 or 24, 0)
+ button.checked = not info.notCheckable and info.checked
+ button.mouseoverUnderline = info.mouseoverUnderline
+ button.isRadio = not info.notCheckable and info.isRadio
+ if info.isRadio then
+ button.check:Show()
+ button.check:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
+ if button.checked then
+ button.check:SetTexCoord(0.25, 0.5, 0, 1)
+ button.check:SetVertexColor(1, 1, 1, 1)
+ else
+ button.check:SetTexCoord(0, 0.25, 0, 1)
+ button.check:SetVertexColor(1, 1, 1, 0.5)
+ end
+ button.radioHighlight:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
+ button.check:SetWidth(16)
+ button.check:SetHeight(16)
+ elseif info.icon then
+ button.check:Show()
+ button.check:SetTexture(info.icon)
+ if info.iconWidth and info.iconHeight then
+ button.check:SetWidth(info.iconWidth)
+ button.check:SetHeight(info.iconHeight)
+ else
+ button.check:SetWidth(16)
+ button.check:SetHeight(16)
+ end
+ if info.iconCoordLeft and info.iconCoordRight and info.iconCoordTop and info.iconCoordBottom then
+ button.check:SetTexCoord(info.iconCoordLeft, info.iconCoordRight, info.iconCoordTop, info.iconCoordBottom)
+ elseif info.icon:find("^Interface\\Icons\\") then
+ button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ button.check:SetTexCoord(0, 1, 0, 1)
+ end
+ button.check:SetVertexColor(1, 1, 1, 1)
+ else
+ if button.checked then
+ if info.checkIcon then
+ button.check:SetWidth(16)
+ button.check:SetHeight(16)
+ button.check:SetTexture(info.checkIcon)
+ if info.checkIcon:find("^Interface\\Icons\\") then
+ button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ button.check:SetTexCoord(0, 1, 0, 1)
+ end
+ else
+ button.check:SetWidth(24)
+ button.check:SetHeight(24)
+ button.check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
+ button.check:SetTexCoord(0, 1, 0, 1)
+ end
+ button.check:SetVertexColor(1, 1, 1, 1)
+ else
+ button.check:SetVertexColor(1, 1, 1, 0)
+ end
+ end
+ if not button.disabled then
+ button.func = info.func
+ button.secure = info.secure
+ end
+ button.hasColorSwatch = info.hasColorSwatch
+ if button.hasColorSwatch then
+ button.colorSwatch:Show()
+ button.colorSwatch.texture:Show()
+ button.r = info.r or 1
+ button.g = info.g or 1
+ button.b = info.b or 1
+ button.colorSwatch.texture:SetVertexColor(button.r, button.g, button.b)
+ button.checked = false
+ button.func = nil
+ button.colorFunc = info.colorFunc
+ local i = 1
+ while true do
+ local k = "colorArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ button.hasOpacity = info.hasOpacity
+ button.opacity = info.opacity or 1
+ else
+ button.colorSwatch:Hide()
+ button.colorSwatch.texture:Hide()
+ end
+ button.hasArrow = not button.hasColorSwatch and (info.value or info.hasSlider or info.hasEditBox) and info.hasArrow
+ if button.hasArrow then
+ button.arrow:SetAlpha(1)
+ if info.hasSlider then
+ button.hasSlider = true
+ button.sliderMin = info.sliderMin or 0
+ button.sliderMax = info.sliderMax or 1
+ button.sliderStep = info.sliderStep or 0
+ button.sliderBigStep = info.sliderBigStep or button.sliderStep
+ if button.sliderBigStep < button.sliderStep then
+ button.sliderBigStep = button.sliderStep
+ end
+ button.sliderIsPercent = info.sliderIsPercent and true or false
+ button.sliderMinText = info.sliderMinText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMin * 100) or button.sliderMin
+ button.sliderMaxText = info.sliderMaxText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMax * 100) or button.sliderMax
+ button.sliderFunc = info.sliderFunc
+ button.sliderValue = info.sliderValue
+ button.fromAceOptions = info.fromAceOptions
+ local i = 1
+ while true do
+ local k = "sliderArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ elseif info.hasEditBox then
+ button.hasEditBox = true
+ button.editBoxText = info.editBoxText or ""
+ button.editBoxFunc = info.editBoxFunc
+ local i = 1
+ while true do
+ local k = "editBoxArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ button.editBoxChangeFunc = info.editBoxChangeFunc
+ local i = 1
+ while true do
+ local k = "editBoxChangeArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ button.editBoxValidateFunc = info.editBoxValidateFunc
+ local i = 1
+ while true do
+ local k = "editBoxValidateArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ button.editBoxIsKeybinding = info.editBoxIsKeybinding
+ button.editBoxKeybindingOnly = info.editBoxKeybindingOnly
+ button.editBoxKeybindingExcept = info.editBoxKeybindingExcept
+ else
+ button.value = info.value
+ local l = levels[level+1]
+ if l and info.value == l.value then
+-- button.arrow:SetWidth(24)
+-- button.arrow:SetHeight(24)
+ button.selected = true
+ button.highlight:Show()
+ end
+ end
+ else
+ button.arrow:SetAlpha(0)
+ end
+ local i = 1
+ while true do
+ local k = "arg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ button.closeWhenClicked = info.closeWhenClicked
+ button.textHeight = info.textHeight or UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT or 10
+ local font,_ = button.text:GetFont()
+ button.text:SetFont(STANDARD_TEXT_FONT or "Fonts\\FRIZQT__.TTF", button.textHeight)
+ button:SetHeight(button.textHeight + 6)
+ button.text:SetPoint("RIGHT", button.arrow, (button.hasColorSwatch or button.hasArrow) and "LEFT" or "RIGHT")
+ button.text:SetJustifyH(info.justifyH or "LEFT")
+ button.text:SetText(info.text)
+ button.tooltipTitle = info.tooltipTitle
+ button.tooltipText = info.tooltipText
+ button.tooltipFunc = info.tooltipFunc
+ local i = 1
+ while true do
+ local k = "tooltipArg" .. i
+ local x = info[k]
+ if x == nil then
+ break
+ end
+ button[k] = x
+ i = i + 1
+ end
+ if not button.tooltipTitle and not button.tooltipText and not button.tooltipFunc and not info.isTitle then
+ button.tooltipTitle = info.text
+ end
+ if type(button.func) == "string" then
+ if type(button.arg1) ~= "table" then
+ self:error("Cannot call method %q on a non-table", button.func)
+ end
+ if type(button.arg1[button.func]) ~= "function" then
+ self:error("Method %q nonexistant.", button.func)
+ end
+ end
+end
+
+function Dewdrop:InjectAceOptionsTable(handler, options)
+ self:argCheck(handler, 2, "table")
+ self:argCheck(options, 3, "table")
+ if tostring(options.type):lower() ~= "group" then
+ self:error('Cannot inject into options table argument #3 if its type is not "group"')
+ end
+ if options.handler ~= nil and options.handler ~= handler then
+ self:error("Cannot inject into options table argument #3 if it has a different handler than argument #2")
+ end
+ options.handler = handler
+ local class = handler.class
+ if not AceLibrary:HasInstance("AceOO-2.0") or not class then
+ if Rock then
+ -- possible Rock object
+ for mixin in Rock:IterateObjectMixins(handler) do
+ if type(mixin.GetAceOptionsDataTable) == "function" then
+ local t = mixin:GetAceOptionsDataTable(handler)
+ for k,v in pairs(t) do
+ if type(options.args) ~= "table" then
+ options.args = {}
+ end
+ if options.args[k] == nil then
+ options.args[k] = v
+ end
+ end
+ end
+ end
+ end
+ else
+ -- Ace2 object
+ while class and class ~= AceLibrary("AceOO-2.0").Class do
+ if type(class.GetAceOptionsDataTable) == "function" then
+ local t = class:GetAceOptionsDataTable(handler)
+ for k,v in pairs(t) do
+ if type(options.args) ~= "table" then
+ options.args = {}
+ end
+ if options.args[k] == nil then
+ options.args[k] = v
+ end
+ end
+ end
+ local mixins = class.mixins
+ if mixins then
+ for mixin in pairs(mixins) do
+ if type(mixin.GetAceOptionsDataTable) == "function" then
+ local t = mixin:GetAceOptionsDataTable(handler)
+ for k,v in pairs(t) do
+ if type(options.args) ~= "table" then
+ options.args = {}
+ end
+ if options.args[k] == nil then
+ options.args[k] = v
+ end
+ end
+ end
+ end
+ end
+ class = class.super
+ end
+ end
+ return options
+end
+
+function Dewdrop:OnTooltipHide()
+ if lastSetFont then
+ if lastSetFont == normalFont then
+ lastSetFont = nil
+ return
+ end
+ fillRegionTmp(GameTooltip:GetRegions())
+ for i,v in ipairs(regionTmp) do
+ if v.GetFont then
+ local font,size,outline = v:GetFont()
+ if font == lastSetFont then
+ v:SetFont(normalFont, size, outline)
+ end
+ end
+ regionTmp[i] = nil
+ end
+ lastSetFont = nil
+ end
+end
+
+local function activate(self, oldLib, oldDeactivate)
+ Dewdrop = self
+ if oldLib and oldLib.registry then
+ self.registry = oldLib.registry
+ self.onceRegistered = oldLib.onceRegistered
+ else
+ self.registry = {}
+ self.onceRegistered = {}
+
+ local WorldFrame_OnMouseDown = WorldFrame:GetScript("OnMouseDown")
+ local WorldFrame_OnMouseUp = WorldFrame:GetScript("OnMouseUp")
+ local oldX, oldY, clickTime
+ WorldFrame:SetScript("OnMouseDown", function(this, ...)
+ oldX,oldY = GetCursorPosition()
+ clickTime = GetTime()
+ if WorldFrame_OnMouseDown then
+ WorldFrame_OnMouseDown(this, ...)
+ end
+ end)
+
+ WorldFrame:SetScript("OnMouseUp", function(this, ...)
+ local x,y = GetCursorPosition()
+ if not oldX or not oldY or not x or not y or not clickTime then
+ self:Close()
+ if WorldFrame_OnMouseUp then
+ WorldFrame_OnMouseUp(this, ...)
+ end
+ return
+ end
+ local d = math.abs(x - oldX) + math.abs(y - oldY)
+ if d <= 5 and GetTime() - clickTime < 0.5 then
+ self:Close()
+ end
+ if WorldFrame_OnMouseUp then
+ WorldFrame_OnMouseUp(this, ...)
+ end
+ end)
+
+ hooksecurefunc(DropDownList1, "Show", function()
+ if levels[1] and levels[1]:IsVisible() then
+ self:Close()
+ end
+ end)
+
+ hooksecurefunc("HideDropDownMenu", function()
+ if levels[1] and levels[1]:IsVisible() then
+ self:Close()
+ end
+ end)
+
+ -- hooksecurefunc("CloseDropDownMenus", function()
+ -- if levels[1] and levels[1]:IsVisible() then
+ -- local stack = debugstack()
+ -- print(stack)
+ -- if not stack:find("`TargetFrame_OnHide'") then
+ -- -- self:Close()
+ -- end
+ -- end
+ -- end)
+ end
+
+ self.frame = oldLib and oldLib.frame or CreateFrame("Frame")
+ self.frame:UnregisterAllEvents()
+ self.frame:RegisterEvent("PLAYER_REGEN_ENABLED")
+ self.frame:RegisterEvent("PLAYER_REGEN_DISABLED")
+ self.frame:Hide()
+ self.frame:SetScript("OnEvent", function(this, event)
+ this:Show()
+ if event=="PLAYER_REGEN_ENABLED" then -- track combat state for secure frame operations
+ self.combat = false
+ elseif event=="PLAYER_REGEN_DISABLED" then
+ self.combat = true
+ end
+ end)
+ self.frame:SetScript("OnUpdate", function(this)
+ this:Hide()
+ self:Refresh(1)
+ end)
+ self.hookedTooltip = true
+ if not oldLib or not oldLib.hookedTooltip then
+ local OnTooltipHide = GameTooltip:GetScript("OnHide")
+ GameTooltip:SetScript("OnHide", function(this, ...)
+ if OnTooltipHide then
+ OnTooltipHide(this, ...)
+ end
+ if type(self.OnTooltipHide) == "function" then
+ self:OnTooltipHide()
+ end
+ end)
+ end
+ levels = {}
+ buttons = {}
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+local function external(lib, major, instance)
+ if major == "LibSharedMedia-3.0" then
+ SharedMedia = instance
+ end
+end
+
+AceLibrary:Register(Dewdrop, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)
diff --git a/FuBar_DurabilityFu/libs/FuBarPlugin-2.0/FuBarPlugin-2.0.lua b/FuBar_DurabilityFu/libs/FuBarPlugin-2.0/FuBarPlugin-2.0.lua
new file mode 100644
index 0000000..ad11fbd
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/FuBarPlugin-2.0/FuBarPlugin-2.0.lua
@@ -0,0 +1,1855 @@
+--[[
+Name: FuBarPlugin-2.0
+Revision: $Rev: 9 $
+Author: Cameron Kenneth Knight (ckknight@gmail.com)
+Website: http://wiki.wowace.com/index.php/FuBarPlugin-2.0
+Documentation: http://wiki.wowace.com/index.php/FuBarPlugin-2.0
+SVN: svn://svn.wowace.com/wowace/trunk/FuBarPlugin-2.0/FuBarPlugin-2.0/
+Description: Plugin for FuBar.
+Dependencies: AceLibrary, AceOO-2.0, AceEvent-2.0, (optional) Tablet-2.0, Dewdrop-2.0
+License: LGPL v2.1
+
+Notes: When embeding this library, FuBar should be set as an optional dependency.
+]]
+
+local MAJOR_VERSION = "FuBarPlugin-2.0"
+local MINIMAPCONTAINER_MAJOR_VERSION = "FuBarPlugin-MinimapContainer-2.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 9 $"):match("(%d+)"))
+
+-- This ensures the code is only executed if the libary doesn't already exist, or is a newer version
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+if not AceLibrary:HasInstance("AceOO-2.0") then error(MAJOR_VERSION .. " requires AceOO-2.0.") end
+
+local AceEvent = AceLibrary:HasInstance("AceEvent-2.0") and AceLibrary("AceEvent-2.0")
+local Tablet = AceLibrary:HasInstance("Tablet-2.0") and AceLibrary("Tablet-2.0")
+local Dewdrop = AceLibrary:HasInstance("Dewdrop-2.0") and AceLibrary("Dewdrop-2.0")
+local AceAddon
+
+local epsilon = 1e-5
+local _G = getfenv(0)
+
+local SHOW_ICON = "Show icon"
+local SHOW_ICON_DESC = "Show the plugins icon on the panel."
+local SHOW_TEXT = "Show text"
+local SHOW_TEXT_DESC = "Show the plugins text on the panel."
+local SHOW_COLORED_TEXT = "Show colored text"
+local SHOW_COLORED_TEXT_DESC = "Allow the plugin to color its text."
+local DETACH_TOOLTIP = "Detach tooltip"
+local DETACH_TOOLTIP_DESC = "Detach the tooltip from the panel."
+local LOCK_TOOLTIP = "Lock tooltip"
+local LOCK_TOOLTIP_DESC = "Lock the tooltips position. When the tooltip is locked, you must use Alt to access it with your mouse."
+local POSITION = "Position"
+local POSITION_DESC = "Position the plugin on the panel."
+local POSITION_LEFT = "Left"
+local POSITION_RIGHT = "Right"
+local POSITION_CENTER = "Center"
+local ATTACH_TO_MINIMAP = "Attach to minimap"
+local ATTACH_TO_MINIMAP_DESC = "Attach the plugin to the minimap instead of the panel."
+local HIDE_FUBAR_PLUGIN = "Hide plugin"
+local HIDE_FUBAR_PLUGIN_CMD = "Hidden"
+local HIDE_FUBAR_PLUGIN_DESC = "Hide the plugin from the panel or minimap, leaving the addon running."
+local OTHER = "Other"
+local CLOSE = "Close"
+local CLOSE_DESC = "Close the menu."
+
+if GetLocale() == "koKR" then
+ SHOW_ICON = "아이콘 표시"
+ SHOW_ICON_DESC = "패널에 플러그인 아이콘을 표시합니다."
+ SHOW_TEXT = "텍스트 표시"
+ SHOW_TEXT_DESC = "페널에 플러그인 텍스트를 표시합니다."
+ SHOW_COLORED_TEXT = "색상화된 텍스트 표시"
+ SHOW_COLORED_TEXT_DESC = "플러그인의 텍스트 색상을 허용합니다."
+ DETACH_TOOLTIP = "툴팁 분리"
+ DETACH_TOOLTIP_DESC = "패널에서 툴팁을 분리 합니다."
+ LOCK_TOOLTIP = "툴팁 고정"
+ LOCK_TOOLTIP_DESC = "툴팁 위치를 고정합니다."
+ POSITION = "위치"
+ POSITION_DESC = "패널에서 플러그인의 위치를 설정합니다."
+ POSITION_LEFT = "왼쪽"
+ POSITION_RIGHT = "오른쪽"
+ POSITION_CENTER = "가운데"
+ ATTACH_TO_MINIMAP = "미니맵에 표시"
+ ATTACH_TO_MINIMAP_DESC = "플러그인을 패널 대신 미니맵에 표시합니다."
+ HIDE_FUBAR_PLUGIN = "FuBar 플러그인 숨기기"
+ HIDE_FUBAR_PLUGIN_CMD = "숨겨짐"
+ HIDE_FUBAR_PLUGIN_DESC = "패널에서 플러그인을 숨깁니다."
+ OTHER = "기타"
+ CLOSE = "닫기"
+ CLOSE_DESC = "메뉴 닫기."
+elseif GetLocale() == "deDE" then
+ SHOW_ICON = "Zeige Icon"
+ SHOW_ICON_DESC = "Zeige das Plugin-Icon auf der Leiste."
+ SHOW_TEXT = "Zeige Text"
+ SHOW_TEXT_DESC = "Zeige den Plugin-Text auf der Leiste."
+ SHOW_COLORED_TEXT = "Zeige gef\195\164rbten Text"
+ SHOW_COLORED_TEXT_DESC = "Dem Plugin erlauben sein Text zu f\195\164rben."
+ DETACH_TOOLTIP = "Tooltip l\195\182sen"
+ DETACH_TOOLTIP_DESC = "Tooltip von der Leiste l\195\182sen."
+ LOCK_TOOLTIP = "Tooltip sperren"
+ LOCK_TOOLTIP_DESC = "Tooltip an der Position sperren."
+ POSITION = "Position"
+ POSITION_DESC = "Positioniert das Plugin auf der Leiste."
+ POSITION_LEFT = "Links"
+ POSITION_RIGHT = "Rechts"
+ POSITION_CENTER = "Mitte"
+ ATTACH_TO_MINIMAP = "An der Minimap anbringen"
+ ATTACH_TO_MINIMAP_DESC = "Bringt das Plugin an der Minimap anstelle der Leiste an."
+ HIDE_FUBAR_PLUGIN = "Versteckt das FuBar Plugin"
+ HIDE_FUBAR_PLUGIN_CMD = "Verstecken"
+ HIDE_FUBAR_PLUGIN_DESC = "Versteckt das Plugin von der Leiste."
+ CLOSE = "Schlie\195\159en"
+ CLOSE_DESC = "Men\195\188 schlie\195\159en."
+elseif GetLocale() == "frFR" then
+ SHOW_ICON = "Afficher l'ic\195\180ne"
+ SHOW_ICON_DESC = "Afficher l'ic\195\180ne du plugin sur le panneau."
+ SHOW_TEXT = "Afficher le texte"
+ SHOW_TEXT_DESC = "Afficher le texte du plugin sur le panneau."
+ SHOW_COLORED_TEXT = "Afficher la couleur du texte"
+ SHOW_COLORED_TEXT_DESC = "Permet au plugin de colorer le texte."
+ DETACH_TOOLTIP = "D\195\169tacher le tooltip"
+ DETACH_TOOLTIP_DESC = "Permet de d\195\169tacher le tooltip du panneau."
+ LOCK_TOOLTIP = "Bloquer le tooltip"
+ LOCK_TOOLTIP_DESC = "Permet de bloquer le tooltip \195\160 sa position actuelle. Une fois le tooltip bloqu\195\169, vous devez utiliser la touche Alt pour le d\195\169placer avec votre souris."
+ POSITION = "Position"
+ POSITION_DESC = "Permet de changer la position du plugin dans le panneau."
+ POSITION_LEFT = "Gauche"
+ POSITION_RIGHT = "Droite"
+ POSITION_CENTER = "Centre"
+ ATTACH_TO_MINIMAP = "Attacher \195\160 la minicarte"
+ ATTACH_TO_MINIMAP_DESC = "Attache l'ic\195\180ne du plugin \195\160 la minicarte."
+ HIDE_FUBAR_PLUGIN = "Masquer le plugin"
+ HIDE_FUBAR_PLUGIN_CMD = "Masqu\195\169"
+ HIDE_FUBAR_PLUGIN_DESC = "Permet de masquer compl\195\168tement le plugin du panneau, mais laisse l'addon fonctionner."
+ OTHER = "Autre"
+ CLOSE = "Fermer"
+ CLOSE_DESC = "Ferme le menu."
+elseif GetLocale() == "zhCN" then
+ SHOW_ICON = "显示图标"
+ SHOW_ICON_DESC = "在面板上显示插件图标。"
+ SHOW_TEXT = "显示文字"
+ SHOW_TEXT_DESC = "在面板上显示文字标题。"
+ SHOW_COLORED_TEXT = "显示彩色文字"
+ SHOW_COLORED_TEXT_DESC = "允许插件显示彩色文字。"
+ DETACH_TOOLTIP = "独立提示信息"
+ DETACH_TOOLTIP_DESC = "从面板上独立提示信息。"
+ LOCK_TOOLTIP = "锁定提示信息"
+ LOCK_TOOLTIP_DESC = "锁定提示信息位置。"
+ POSITION = "位置"
+ POSITION_DESC = "插件在面板上的位置。"
+ POSITION_LEFT = "居左"
+ POSITION_RIGHT = "居右"
+ POSITION_CENTER = "居中"
+ ATTACH_TO_MINIMAP = "依附在小地图"
+ ATTACH_TO_MINIMAP_DESC = "插件图标依附在小地图而不显示在面板上。"
+ HIDE_FUBAR_PLUGIN = "隐藏 FuBar 插件"
+ HIDE_FUBAR_PLUGIN_CMD = "隐藏"
+ HIDE_FUBAR_PLUGIN_DESC = "在面板上隐藏该插件。"
+ OTHER = "其他"
+ CLOSE = "关闭"
+ CLOSE_DESC = "关闭菜单"
+elseif GetLocale() == "zhTW" then
+ SHOW_ICON = "顯示圖示"
+ SHOW_ICON_DESC = "在面板上顯示插件圖示。"
+ SHOW_TEXT = "顯示文字"
+ SHOW_TEXT_DESC = "在面板上顯示插件文字。"
+ SHOW_COLORED_TEXT = "允許彩色文字"
+ SHOW_COLORED_TEXT_DESC = "允許插件在面板上使用彩色文字。"
+ DETACH_TOOLTIP = "獨立提示訊息"
+ DETACH_TOOLTIP_DESC = "從面板上獨立提示訊息。"
+ LOCK_TOOLTIP = "鎖定提示訊息"
+ LOCK_TOOLTIP_DESC = "鎖定提示訊息位置。當提示訊息鎖定時,需要用Alt鍵使用提示訊息的功能。"
+ POSITION = "位置"
+ POSITION_DESC = "插件在面板上的位置。"
+ POSITION_LEFT = "靠左"
+ POSITION_RIGHT = "靠右"
+ POSITION_CENTER = "置中"
+ ATTACH_TO_MINIMAP = "依附在小地圖"
+ ATTACH_TO_MINIMAP_DESC = "插件圖標依附在小地圖而不顯示在面板上。"
+ HIDE_FUBAR_PLUGIN = "隱藏插件"
+ HIDE_FUBAR_PLUGIN_CMD = "隱藏"
+ HIDE_FUBAR_PLUGIN_DESC = "在面板或小地圖上隱藏該插件,但保持執行狀態。"
+ OTHER = "其他"
+ CLOSE = "關閉"
+ CLOSE_DESC = "關閉選單。"
+elseif GetLocale() == "esES" then
+ SHOW_ICON = "Mostrar icono"
+ SHOW_ICON_DESC = "Muestra el icono del plugin en el panel"
+ SHOW_TEXT = "Mostrar texto"
+ SHOW_TEXT_DESC = "Muestra el texto del plugin en el panel"
+ SHOW_COLORED_TEXT = "Mostrar el texto en color"
+ SHOW_COLORED_TEXT_DESC = "Permite al plugin colorear su texto"
+ DETACH_TOOLTIP = "Separar tooltip"
+ DETACH_TOOLTIP_DESC = "Separa el tooltip del panel"
+ LOCK_TOOLTIP = "Bloquear tooltip"
+ LOCK_TOOLTIP_DESC = "Bloquea la posici\195\179n de los tooltips. Cuando el tooltip est\195\161 bloqueado debes usar Alt para acceder a \195\169l con el rat\195\179n"
+ POSITION = "Posici\195\179n"
+ POSITION_DESC = "Posici\195\179n del plugin en el panel"
+ POSITION_LEFT = "Izquierda"
+ POSITION_RIGHT = "Derecha"
+ POSITION_CENTER = "Centro"
+ ATTACH_TO_MINIMAP = "Adjuntar al minimapa"
+ ATTACH_TO_MINIMAP_DESC = "Adjunta el plugin al minimapa en vez de al panel."
+ HIDE_FUBAR_PLUGIN = "Ocultar plugin"
+ HIDE_FUBAR_PLUGIN_CMD = "Oculto"
+ HIDE_FUBAR_PLUGIN_DESC = "Oculta el plugin del panel o minimapa, dejando el accesorio funcionando."
+ OTHER = "Otros"
+ CLOSE = "Cerrar"
+ CLOSE_DESC = "Cierra el men\195\186."
+elseif GetLocale() == "ruRU" then
+ SHOW_ICON = "Показывать иконку"
+ SHOW_ICON_DESC = "Показывать иконку плагина на панели."
+ SHOW_TEXT = "Показывать текст"
+ SHOW_TEXT_DESC = "Показывать текст плагина на панели."
+ SHOW_COLORED_TEXT = "Показывать цветной текст"
+ SHOW_COLORED_TEXT_DESC = "Позволить плагину использовать его цвета в тексте."
+ DETACH_TOOLTIP = "Отделить подсказку"
+ DETACH_TOOLTIP_DESC = "Отделить всплывающую подсказку от панели."
+ LOCK_TOOLTIP = "Закрепить подсказку"
+ LOCK_TOOLTIP_DESC = "Закрепить позицию всплывающей подсказки. Когда всплывающая подсказка закреплена, используйте Alt для отображения ее у мыши."
+ POSITION = "Позиция"
+ POSITION_DESC = "Позиция плагина на панели."
+ POSITION_LEFT = "Слева"
+ POSITION_RIGHT = "Справа"
+ POSITION_CENTER = "По центру"
+ ATTACH_TO_MINIMAP = "Закрепить у мини-карты"
+ ATTACH_TO_MINIMAP_DESC = "Закрепить плагин у мини-карты, вместо панели."
+ HIDE_FUBAR_PLUGIN = "Скрыть плагин"
+ HIDE_FUBAR_PLUGIN_CMD = "Скрыть"
+ HIDE_FUBAR_PLUGIN_DESC = "Скрыть плагин с панели или мини-карты, но оставить аддон в рабочем состоянии."
+ OTHER = "Другое"
+ CLOSE = "Закрыть"
+ CLOSE_DESC = "Закрыть меню."
+end
+
+local AceOO = AceLibrary("AceOO-2.0")
+local FuBarPlugin = AceOO.Mixin {
+ "GetTitle",
+ "GetName",
+ "GetCategory",
+ "SetFontSize",
+ "GetFrame",
+ "Show",
+ "Hide",
+ "GetPanel",
+ "IsTextColored",
+ "ToggleTextColored",
+ "IsMinimapAttached",
+ "ToggleMinimapAttached",
+ "Update",
+ "UpdateDisplay",
+ "UpdateData",
+ "UpdateText",
+ "UpdateTooltip",
+ "SetIcon",
+ "GetIcon",
+ "CheckWidth",
+ "SetText",
+ "GetText",
+ "IsIconShown",
+ "ToggleIconShown",
+ "ShowIcon",
+ "HideIcon",
+ "IsTextShown",
+ "ToggleTextShown",
+ "ShowText",
+ "HideText",
+ "IsTooltipDetached",
+ "ToggleTooltipDetached",
+ "DetachTooltip",
+ "ReattachTooltip",
+ "GetDefaultPosition",
+ "SetPanel",
+ "IsLoadOnDemand",
+ "IsDisabled",
+ "CreateBasicPluginFrame",
+ "CreatePluginChildFrame",
+ "OpenMenu",
+ "AddImpliedMenuOptions",
+}
+local MinimapContainer
+
+local good = nil
+local function CheckFuBar()
+ if not good then
+ good = FuBar and tonumber(FuBar.version:sub(1, 3)) and tonumber(FuBar.version:sub(1, 3)) >= 2 and true
+ end
+ return good
+end
+
+function FuBarPlugin:GetTitle()
+ local name = self.title or self.name
+ if not name then
+ FuBarPlugin:error("You must provide self.title or self.name")
+ end
+ local title = select(3, name:find("FuBar %- (.-)%s*$"))
+ if not title then
+ title = name
+ end
+ return title:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "")
+end
+
+function FuBarPlugin:GetName()
+ return self.name
+end
+
+function FuBarPlugin:GetCategory()
+ return self.category or OTHER
+end
+
+function FuBarPlugin:GetFrame()
+ return self.frame
+end
+
+function FuBarPlugin:GetPanel()
+ return self.panel
+end
+
+function FuBarPlugin:IsTextColored()
+ return not self.db or not self.db.profile or not self.db.profile.uncolored
+end
+
+function FuBarPlugin:ToggleTextColored()
+ if not self.db then
+ FuBarPlugin:error("Cannot change text color if self.db is not available. (" .. self:GetTitle() .. ")")
+ end
+ self.db.profile.uncolored = not self.db.profile.uncolored or nil
+ self:UpdateText()
+end
+
+function FuBarPlugin:ToggleMinimapAttached()
+ if CheckFuBar() and not self.cannotAttachToMinimap then
+ local value = self:IsMinimapAttached()
+ if value then
+ if self.panel then
+ self.panel:RemovePlugin(self)
+ end
+ if self.defaultPosition == "MINIMAP" then
+ FuBar:GetPanel(1):AddPlugin(self, nil, "LEFT")
+ else
+ FuBar:GetPanel(1):AddPlugin(self, nil, self.defaultPosition)
+ end
+ else
+ if self.panel then
+ self.panel:RemovePlugin(self)
+ end
+ MinimapContainer:AddPlugin(self)
+ end
+ end
+ Dewdrop:Close()
+end
+
+function FuBarPlugin:IsMinimapAttached()
+ if not CheckFuBar() then
+ return true
+ end
+ return self.panel == MinimapContainer
+end
+
+function FuBarPlugin:Update()
+ self:UpdateData()
+ self:UpdateText()
+ self:UpdateTooltip()
+end
+
+function FuBarPlugin:UpdateDisplay()
+ self:UpdateText()
+ self:UpdateTooltip()
+end
+
+function FuBarPlugin:UpdateData()
+ if type(self.OnDataUpdate) == "function" then
+ if not self:IsDisabled() then
+ self:OnDataUpdate()
+ end
+ end
+end
+
+function FuBarPlugin:UpdateText()
+ if type(self.OnTextUpdate) == "function" then
+ if not self:IsDisabled() then
+ self:OnTextUpdate()
+ end
+ elseif self:IsTextShown() then
+ self:SetText(self:GetTitle())
+ end
+end
+
+function FuBarPlugin:RegisterTablet()
+ if self.blizzardTooltip or self.overrideTooltip or not Tablet then
+ return
+ end
+
+ if not Tablet:IsRegistered(self.frame) then
+ if self.db and self.db.profile and not self.db.profile.detachedTooltip then
+ self.db.profile.detachedTooltip = {}
+ end
+ Tablet:Register(self.frame,
+ 'children', function()
+ -- Tablet:SetTitle(self:GetTitle())
+ if type(self.OnTooltipUpdate) == "function" then
+ if not self:IsDisabled() then
+ self:OnTooltipUpdate()
+ end
+ end
+ end,
+ 'clickable', self.clickableTooltip,
+ 'data', CheckFuBar() and FuBar.db.profile.tooltip or self.db and self.db.profile.detachedTooltip or {},
+ 'detachedData', self.db and self.db.profile.detachedTooltip or {},
+ 'point', function(frame)
+ if frame:GetTop() > GetScreenHeight() / 2 then
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 3 then
+ return "TOPLEFT", "BOTTOMLEFT"
+ elseif x < GetScreenWidth() * 2 / 3 then
+ return "TOP", "BOTTOM"
+ else
+ return "TOPRIGHT", "BOTTOMRIGHT"
+ end
+ else
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 3 then
+ return "BOTTOMLEFT", "TOPLEFT"
+ elseif x < GetScreenWidth() * 2 / 3 then
+ return "BOTTOM", "TOP"
+ else
+ return "BOTTOMRIGHT", "TOPRIGHT"
+ end
+ end
+ end,
+ 'menu', self.OnMenuRequest and function(level, value, valueN_1, valueN_2, valueN_3, valueN_4)
+ -- if level == 1 then
+ -- local name = tostring(self)
+ -- if not name:find('^table:') then
+ -- name = name:gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
+ -- Dewdrop:AddLine(
+ -- 'text', name,
+ -- 'isTitle', true
+ -- )
+ -- end
+ -- end
+ if type(self.OnMenuRequest) == "function" then
+ self:OnMenuRequest(level, value, true, valueN_1, valueN_2, valueN_3, valueN_4)
+ elseif type(self.OnMenuRequest) == "table" then
+ Dewdrop:FeedAceOptionsTable(self.OnMenuRequest)
+ end
+ end,
+ 'hideWhenEmpty', self.tooltipHiddenWhenEmpty
+ )
+ local func = self.frame:GetScript("OnEnter")
+ local function newFunc(this, ...)
+ func(this, ...)
+
+ if FuBar and FuBar.IsHidingTooltipsInCombat and FuBar:IsHidingTooltipsInCombat() and InCombatLockdown() then
+ local frame = this.self.frame
+ if self.blizzardTooltip then
+ if GameTooltip:IsOwned(self:IsMinimapAttached() and self.minimapFrame or self.frame) then
+ GameTooltip:Hide()
+ end
+ elseif self.overrideTooltip and type(self.CloseTooltip) == "function" then
+ self:CloseTooltip()
+ elseif not self.overrideTooltip and Tablet and Tablet:IsAttached(frame) then
+ Tablet:Close(frame)
+ end
+ end
+ end
+ self.frame:SetScript("OnEnter", newFunc)
+ end
+end
+
+function FuBarPlugin:UpdateTooltip()
+ if self.blizzardTooltip then
+ if GameTooltip:IsOwned(self:IsMinimapAttached() and self.minimapFrame or self.frame) then
+ GameTooltip:Hide()
+
+ local frame = self:IsMinimapAttached() and self.minimapFrame or self.frame
+ local anchor
+ if frame:GetTop() > GetScreenHeight() / 2 then
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 2 then
+ anchor = "ANCHOR_BOTTOMRIGHT"
+ else
+ anchor = "ANCHOR_BOTTOMLEFT"
+ end
+ else
+ local x = frame:GetCenter()
+ if x < GetScreenWidth() / 2 then
+ anchor = "ANCHOR_TOPLEFT"
+ else
+ anchor = "ANCHOR_TOPRIGHT"
+ end
+ end
+ GameTooltip:SetOwner(frame, anchor)
+ if type(self.OnTooltipUpdate) == "function" and not self:IsDisabled() then
+ self:OnTooltipUpdate()
+ end
+ GameTooltip:Show()
+ end
+ return
+ elseif self.overrideTooltip then
+ if type(self.OnTooltipUpdate) == "function" and not self:IsDisabled() then
+ self:OnTooltipUpdate()
+ end
+ return
+ end
+ if not Tablet then return end
+
+ FuBarPlugin.RegisterTablet(self)
+ if self:IsMinimapAttached() and not self:IsTooltipDetached() and self.minimapFrame then
+ Tablet:Refresh(self.minimapFrame)
+ else
+ Tablet:Refresh(self.frame)
+ end
+end
+
+function FuBarPlugin:OnProfileEnable()
+ self:Update()
+end
+
+function FuBarPlugin:Show(panelId)
+ if self.frame:IsShown() or (self.minimapFrame and self.minimapFrame:IsShown()) then
+ return
+ end
+ if panelId ~= false then
+ if self.db then
+ self.db.profile.hidden = nil
+ end
+ end
+ if self.IsActive and not self:IsActive() then
+ self.panelIdTmp = panelId
+ self:ToggleActive()
+ self.panelIdTmp = nil
+ if self.db then
+ self.db.profile.disabled = nil
+ end
+ elseif not self.db or not self.db.profile.hidden then
+ if panelId == 0 or not CheckFuBar() then
+ MinimapContainer:AddPlugin(self)
+ else
+ FuBar:ShowPlugin(self, panelId or self.panelIdTmp)
+ end
+ if not self.userDefinedFrame then
+ if not self:IsTextShown() then
+ self.textFrame:SetText("")
+ self.textFrame:SetWidth(epsilon)
+ self.textFrame:Hide()
+ end
+ if not self:IsIconShown() then
+ self.iconFrame:SetWidth(epsilon)
+ self.iconFrame:Hide()
+ end
+ end
+ if AceOO.inherits(self, "AceAddon-2.0") then
+ if not AceAddon then
+ AceAddon = AceLibrary("AceAddon-2.0")
+ end
+ if AceAddon.addonsEnabled and not AceAddon.addonsEnabled[self] then
+ return
+ end
+ end
+ self:Update()
+ end
+end
+
+function FuBarPlugin:Hide(check)
+ if not self.frame:IsShown() and (not self.minimapFrame or not self.minimapFrame:IsShown()) then
+ return
+ end
+ if self.hideWithoutStandby and self.db and check ~= false then
+ self.db.profile.hidden = true
+ end
+ if not self.hideWithoutStandby then
+ if self.db and not self.overrideTooltip and not self.blizzardTooltip and not self.cannotDetachTooltip and self:IsTooltipDetached() and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then
+ self:ReattachTooltip()
+ self.db.profile.detachedTooltip.detached = true
+ end
+ if self.IsActive and self:IsActive() and self.ToggleActive and (not CheckFuBar() or not FuBar:IsChangingProfile()) then
+ self:ToggleActive()
+ end
+ end
+ if self.panel then
+ self.panel:RemovePlugin(self)
+ end
+ self.frame:Hide()
+ if self.minimapFrame then
+ self.minimapFrame:Hide()
+ end
+
+ if Dewdrop:IsOpen(self.frame) or (self.minimapFrame and Dewdrop:IsOpen(self.minimapFrame)) then
+ Dewdrop:Close()
+ end
+end
+
+function FuBarPlugin:SetIcon(path)
+ if not path then
+ return
+ end
+ FuBarPlugin:argCheck(path, 2, "string", "boolean")
+ if not self.hasIcon then
+ FuBarPlugin:error("Cannot set icon unless self.hasIcon is set. (" .. self:GetTitle() .. ")")
+ end
+ if not self.iconFrame then
+ return
+ end
+ if type(path) ~= "string" then
+ path = format("Interface\\AddOns\\%s\\icon", FuBarPlugin.folderNames[self] or self.folderName)
+ elseif not path:find('^Interface[\\/]') then
+ path = format("Interface\\AddOns\\%s\\%s", FuBarPlugin.folderNames[self] or self.folderName, path)
+ end
+ if path:sub(1, 16) == "Interface\\Icons\\" then
+ self.iconFrame:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ self.iconFrame:SetTexCoord(0, 1, 0, 1)
+ end
+ self.iconFrame:SetTexture(path)
+
+ if self.minimapIcon then
+ if path:sub(1, 16) == "Interface\\Icons\\" then
+ self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ self.minimapIcon:SetTexCoord(0, 1, 0, 1)
+ end
+ self.minimapIcon:SetTexture(path)
+ end
+end
+
+function FuBarPlugin:GetIcon()
+ if self.hasIcon then
+ return self.iconFrame:GetTexture()
+ end
+end
+
+function FuBarPlugin:CheckWidth(force)
+ FuBarPlugin:argCheck(force, 2, "boolean", "nil")
+ if (self.iconFrame and self.iconFrame:IsShown()) or (self.textFrame and self.textFrame:IsShown()) then
+ if (self.db and self.db.profile and not self:IsIconShown()) or not self.hasIcon then
+ self.iconFrame:SetWidth(epsilon)
+ end
+ local width
+ if not self.hasNoText then
+ self.textFrame:SetHeight(0)
+ self.textFrame:SetWidth(500)
+ width = self.textFrame:GetStringWidth() + 1
+ self.textFrame:SetWidth(width)
+ self.textFrame:SetHeight(self.textFrame:GetHeight())
+ end
+ if self.hasNoText or not self.textFrame:IsShown() then
+ self.frame:SetWidth(self.iconFrame:GetWidth())
+ if self.panel and self.panel:GetPluginSide(self) == "CENTER" then
+ self.panel:UpdateCenteredPosition()
+ end
+ elseif force or not self.textWidth or self.textWidth < width or self.textWidth - 8 > width then
+ self.textWidth = width
+ self.textFrame:SetWidth(width)
+ if self.iconFrame and self.iconFrame:IsShown() then
+ self.frame:SetWidth(width + self.iconFrame:GetWidth())
+ else
+ self.frame:SetWidth(width)
+ end
+ if self.panel and self.panel:GetPluginSide(self) == "CENTER" then
+ self.panel:UpdateCenteredPosition()
+ end
+ end
+ end
+end
+
+function FuBarPlugin:SetText(text)
+ if not self.textFrame then
+ return
+ end
+ if self.hasNoText then
+ FuBarPlugin:error("Cannot set text if self.hasNoText has been set. (" .. self:GetTitle() .. ")")
+ end
+ FuBarPlugin:argCheck(text, 2, "string", "number")
+ if text == "" then
+ if self.hasIcon then
+ self:ShowIcon()
+ else
+ text = self:GetTitle()
+ end
+ end
+ if not self:IsTextColored() then
+ text = text:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "")
+ end
+ self.textFrame:SetText(text)
+ self:CheckWidth()
+end
+
+function FuBarPlugin:GetText()
+ if not self.textFrame then
+ FuBarPlugin:error("Cannot get text without a self.textFrame (" .. self:GetTitle() .. ")")
+ end
+ if not self.hasNoText then
+ return self.textFrame:GetText() or ""
+ end
+end
+
+function FuBarPlugin:IsIconShown()
+ if not self.hasIcon then
+ return false
+ elseif self.hasNoText then
+ return true
+ elseif not self.db then
+ return true
+ elseif self.db and self.db.profile.showIcon == nil then
+ return true
+ else
+ return (self.db and (self.db.profile.showIcon == 1 or self.db.profile.showIcon == true)) and true or false
+ end
+end
+
+function FuBarPlugin:ToggleIconShown()
+ if not self.iconFrame then
+ FuBarPlugin:error("Cannot toggle icon without a self.iconFrame (" .. self:GetTitle() .. ")")
+ end
+ if not self.hasIcon then
+ FuBarPlugin:error("Cannot show icon unless self.hasIcon is set. (" .. self:GetTitle() .. ")")
+ end
+ if self.hasNoText then
+ FuBarPlugin:error("Cannot hide icon if self.hasNoText is set. (" .. self:GetTitle() .. ")")
+ end
+ if not self.textFrame then
+ FuBarPlugin:error("Cannot hide icon if self.textFrame is not set. (" .. self:GetTitle() .. ")")
+ end
+ if not self.iconFrame then
+ FuBarPlugin:error("Cannot hide icon if self.iconFrame is not set. (" .. self:GetTitle() .. ")")
+ end
+ if not self.db then
+ FuBarPlugin:error("Cannot hide icon if self.db is not available. (" .. self:GetTitle() .. ")")
+ end
+ local value = not self:IsIconShown()
+ self.db.profile.showIcon = value
+ if value then
+ if not self:IsTextShown() and self.textFrame:IsShown() and self.textFrame:GetText() == self:GetTitle() then
+ self.textFrame:Hide()
+ self.textFrame:SetText("")
+ end
+ self.iconFrame:Show()
+ self.iconFrame:SetWidth(self.iconFrame:GetHeight())
+ else
+ if not self.textFrame:IsShown() or not self.textFrame:GetText() then
+ self.textFrame:Show()
+ self.textFrame:SetText(self:GetTitle())
+ end
+ self.iconFrame:Hide()
+ self.iconFrame:SetWidth(epsilon)
+ end
+ self:CheckWidth(true)
+ return value
+end
+
+function FuBarPlugin:ShowIcon()
+ if not self:IsIconShown() then
+ self:ToggleIconShown()
+ end
+end
+
+function FuBarPlugin:HideIcon()
+ if self:IsIconShown() then
+ self:ToggleIconShown()
+ end
+end
+
+function FuBarPlugin:IsTextShown()
+ if self.hasNoText then
+ return false
+ elseif not self.hasIcon then
+ return true
+ elseif not self.db then
+ return true
+ elseif self.db and self.db.profile.showText == nil then
+ return true
+ else
+ return (self.db and (self.db.profile.showText == 1 or self.db.profile.showText == true)) and true or false
+ end
+end
+
+function FuBarPlugin:ToggleTextShown()
+ if self.cannotHideText then
+ FuBarPlugin:error("Cannot hide text unless self.cannotHideText is unset. (" .. self:GetTitle() .. ")")
+ end
+ if not self.hasIcon then
+ FuBarPlugin:error("Cannot show text unless self.hasIcon is set. (" .. self:GetTitle() .. ")")
+ end
+ if self.hasNoText then
+ FuBarPlugin:error("Cannot hide text if self.hasNoText is set. (" .. self:GetTitle() .. ")")
+ end
+ if not self.textFrame then
+ FuBarPlugin:error("Cannot hide text if self.textFrame is not set. (" .. self:GetTitle() .. ")")
+ end
+ if not self.iconFrame then
+ FuBarPlugin:error("Cannot hide text if self.iconFrame is not set. (" .. self:GetTitle() .. ")")
+ end
+ if not self.db then
+ FuBarPlugin:error("Cannot hide text if self.db is not available. (" .. self:GetTitle() .. ")")
+ end
+ local value = not self:IsTextShown()
+ self.db.profile.showText = value
+ if value then
+ self.textFrame:Show()
+ self:UpdateText()
+ else
+ self.textFrame:SetText("")
+ self.textFrame:SetWidth(epsilon)
+ self.textFrame:Hide()
+ if not self:IsIconShown() then
+ DropDownList1:Hide()
+ end
+ self:ShowIcon()
+ end
+ self:CheckWidth(true)
+ return value
+end
+
+function FuBarPlugin:ShowText()
+ if not self:IsTextShown() then
+ self:ToggleTextShown()
+ end
+end
+
+function FuBarPlugin:HideText()
+ if self:IsTextShown() then
+ self:ToggleTextShown()
+ end
+end
+
+function FuBarPlugin:IsTooltipDetached()
+ if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end
+
+ FuBarPlugin.RegisterTablet(self)
+ return not Tablet:IsAttached(self.frame)
+end
+
+function FuBarPlugin:ToggleTooltipDetached()
+ if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end
+
+ FuBarPlugin.RegisterTablet(self)
+ if self:IsTooltipDetached() then
+ Tablet:Attach(self.frame)
+ else
+ Tablet:Detach(self.frame)
+ end
+ if Dewdrop then Dewdrop:Close() end
+end
+
+function FuBarPlugin:DetachTooltip()
+ if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end
+
+ FuBarPlugin.RegisterTablet(self)
+ Tablet:Detach(self.frame)
+end
+
+function FuBarPlugin:ReattachTooltip()
+ if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end
+
+ FuBarPlugin.RegisterTablet(self)
+ Tablet:Attach(self.frame)
+end
+
+function FuBarPlugin:GetDefaultPosition()
+ return self.defaultPosition or "LEFT"
+end
+
+local function IsCorrectPanel(panel)
+ if type(panel) ~= "table" then
+ return false
+ elseif type(panel.AddPlugin) ~= "function" then
+ return false
+ elseif type(panel.RemovePlugin) ~= "function" then
+ return false
+ elseif type(panel.GetNumPlugins) ~= "function" then
+ return false
+ elseif type(panel:GetNumPlugins()) ~= "number" then
+ return false
+ elseif type(panel.GetPlugin) ~= "function" then
+ return false
+ elseif type(panel.HasPlugin) ~= "function" then
+ return false
+ elseif type(panel.GetPluginSide) ~= "function" then
+ return false
+ end
+ return true
+end
+
+function FuBarPlugin:SetPanel(panel)
+ if panel and not IsCorrectPanel(panel) then
+ FuBarPlugin:error("Bad argument #2 to `SetPanel'. Panel does not have the correct API.")
+ end
+ self.panel = panel
+end
+
+function FuBarPlugin:SetFontSize(size)
+ if self.userDefinedFrame then
+ FuBarPlugin:error((self.name and self.name .. ": " or "") .. "You must provide a SetFontSize(size) method if you provide your own frame.")
+ end
+ if self.hasIcon then
+ if not self.iconFrame then
+ FuBarPlugin:error((self.name and self.name .. ": " or "") .. "No iconFrame found")
+ end
+ self.iconFrame:SetWidth(size + 3)
+ self.iconFrame:SetHeight(size + 3)
+ end
+ if not self.hasNoText then
+ if not self.textFrame then
+ FuBarPlugin:error((self.name and self.name .. ": " or "") .. "No textFrame found")
+ end
+ local font, _, flags = self.textFrame:GetFont()
+ self.textFrame:SetFont(font, size, flags)
+ end
+ self:CheckWidth()
+end
+
+function FuBarPlugin:IsLoadOnDemand()
+ local addon = FuBarPlugin.folderNames[self] or self.folderName
+ if not addon then
+ return
+ end
+ return IsAddOnLoadOnDemand(addon)
+end
+
+function FuBarPlugin:IsDisabled()
+ return self.IsActive and not self:IsActive() or false
+end
+
+function FuBarPlugin:OnInstanceInit(target)
+ if not AceEvent then
+ self:error(MAJOR_VERSION .. " requires AceEvent-2.0.")
+ elseif not Dewdrop then
+ self:error(MAJOR_VERSION .. " requires Dewdrop-2.0.")
+ end
+ self.registry[target] = true
+
+ local folderName
+ for i = 6, 3, -1 do
+ folderName = debugstack(i, 1, 0):match("/AddOns/(.*)/")
+ if folderName then
+ break
+ end
+ end
+ target.folderName = folderName
+ self.folderNames[target] = folderName
+end
+FuBarPlugin.OnManualEmbed = FuBarPlugin.OnInstanceInit
+
+local frame_OnClick, frame_OnDoubleClick, frame_OnMouseDown, frame_OnMouseUp, frame_OnReceiveDrag, frame_OnEnter, frame_OnLeave
+function FuBarPlugin:CreateBasicPluginFrame(name)
+ local frame = CreateFrame("Button", name, UIParent)
+ frame:SetFrameStrata("HIGH")
+ frame:SetFrameLevel(7)
+ frame:EnableMouse(true)
+ frame:EnableMouseWheel(true)
+ frame:SetMovable(true)
+ frame:SetWidth(150)
+ frame:SetHeight(24)
+ frame:SetPoint("CENTER", UIParent, "CENTER")
+ frame.self = self
+ if not frame_OnEnter then
+ function frame_OnEnter(this, ...)
+ local self = this.self
+ if self.blizzardTooltip then
+ GameTooltip:SetOwner(self:IsMinimapAttached() and self.minimapFrame or self.frame, "ANCHOR_CURSOR")
+ self:UpdateTooltip()
+ end
+ if type(self.OnEnter) == "function" then
+ self:OnEnter(...)
+ end
+ end
+ end
+ frame:SetScript("OnEnter", frame_OnEnter)
+ if not frame_OnLeave then
+ function frame_OnLeave(this, ...)
+ local self = this.self
+ if type(self.OnLeave) == "function" then
+ self:OnLeave(...)
+ end
+ if self.blizzardTooltip and GameTooltip:IsOwned(self:IsMinimapAttached() and self.minimapFrame or self.frame) then
+ GameTooltip:Hide()
+ end
+ end
+ end
+ frame:SetScript("OnLeave", frame_OnLeave)
+ if not frame_OnClick then
+ function frame_OnClick(this, ...)
+ if this.self:IsMinimapAttached() and this.dragged then return end
+ if type(this.self.OnClick) == "function" then
+ this.self:OnClick(...)
+ end
+ end
+ end
+ frame:SetScript("OnClick", frame_OnClick)
+ if not frame_OnDoubleClick then
+ function frame_OnDoubleClick(this, ...)
+ if type(this.self.OnDoubleClick) == "function" then
+ this.self:OnDoubleClick(...)
+ end
+ end
+ end
+ frame:SetScript("OnDoubleClick", frame_OnDoubleClick)
+ if not frame_OnMouseDown then
+ function frame_OnMouseDown(this, ...)
+ if (...) == "RightButton" and not IsModifierKeyDown() then
+ this.self:OpenMenu()
+ return
+ else
+ HideDropDownMenu(1)
+ if type(this.self.OnMouseDown) == "function" then
+ this.self:OnMouseDown(...)
+ end
+ end
+ end
+ end
+ frame:SetScript("OnMouseDown", frame_OnMouseDown)
+ if not frame_OnMouseUp then
+ function frame_OnMouseUp(this, ...)
+ if type(this.self.OnMouseUp) == "function" then
+ this.self:OnMouseUp(...)
+ end
+ end
+ end
+ frame:SetScript("OnMouseUp", frame_OnMouseUp)
+ if not frame_OnReceiveDrag then
+ function frame_OnReceiveDrag(this, ...)
+ if (this.self:IsMinimapAttached() and not this.dragged) and type(this.self.OnReceiveDrag) == "function" then
+ this.self:OnReceiveDrag(...)
+ end
+ end
+ end
+ frame:SetScript("OnReceiveDrag", frame_OnReceiveDrag)
+ return frame
+end
+
+local child_OnEnter, child_OnLeave, child_OnClick, child_OnDoubleClick, child_OnMouseDown, child_OnMouseUp, child_OnReceiveDrag
+function FuBarPlugin:CreatePluginChildFrame(frameType, name, parent)
+ if not self.frame then
+ FuBarPlugin:error((self.name and self.name .. ": " or "") .. "You must have self.frame declared in order to add child frames")
+ end
+ FuBarPlugin:argCheck(frameType, 1, "string")
+ local child = CreateFrame(frameType, name, parent)
+ if parent then
+ child:SetFrameLevel(parent:GetFrameLevel() + 2)
+ end
+ child.self = self
+ if not child_OnEnter then
+ function child_OnEnter(this, ...)
+ if this.self.frame:GetScript("OnEnter") then
+ this.self.frame:GetScript("OnEnter")(this, ...)
+ end
+ end
+ end
+ child:SetScript("OnEnter", child_OnEnter)
+ if not child_OnLeave then
+ function child_OnLeave(this, ...)
+ if this.self.frame:GetScript("OnLeave") then
+ this.self.frame:GetScript("OnLeave")(this, ...)
+ end
+ end
+ end
+ child:SetScript("OnLeave", child_OnLeave)
+ if child:HasScript("OnClick") then
+ if not child_OnClick then
+ function child_OnClick(this, ...)
+ if this.self.frame:HasScript("OnClick") and this.self.frame:GetScript("OnClick") then
+ this.self.frame:GetScript("OnClick")(this, ...)
+ end
+ end
+ end
+ child:SetScript("OnClick", child_OnClick)
+ end
+ if child:HasScript("OnDoubleClick") then
+ if not child_OnDoubleClick then
+ function child_OnDoubleClick(this, ...)
+ if this.self.frame:HasScript("OnDoubleClick") and this.self.frame:GetScript("OnDoubleClick") then
+ this.self.frame:GetScript("OnDoubleClick")(this, ...)
+ end
+ end
+ end
+ child:SetScript("OnDoubleClick", child_OnDoubleClick)
+ end
+ if not child_OnMouseDown then
+ function child_OnMouseDown(this, ...)
+ if this.self.frame:HasScript("OnMouseDown") and this.self.frame:GetScript("OnMouseDown") then
+ this.self.frame:GetScript("OnMouseDown")(this, ...)
+ end
+ end
+ end
+ child:SetScript("OnMouseDown", child_OnMouseDown)
+ if not child_OnMouseUp then
+ function child_OnMouseUp(this, ...)
+ if this.self.frame:HasScript("OnMouseUp") and this.self.frame:GetScript("OnMouseUp") then
+ this.self.frame:GetScript("OnMouseUp")(this, ...)
+ end
+ end
+ end
+ child:SetScript("OnMouseUp", child_OnMouseUp)
+ if not child_OnReceiveDrag then
+ function child_OnReceiveDrag(this, ...)
+ if this.self.frame:HasScript("OnReceiveDrag") and this.self.frame:GetScript("OnReceiveDrag") then
+ this.self.frame:GetScript("OnReceiveDrag")(this, ...)
+ end
+ end
+ end
+ child:SetScript("OnReceiveDrag", child_OnReceiveDrag)
+ return child
+end
+
+function FuBarPlugin:OpenMenu(frame)
+ if not frame then
+ frame = self:IsMinimapAttached() and self.minimapFrame or self.frame
+ end
+ if not frame:IsVisible() then
+ frame = UIParent
+ end
+ if not frame or not self:GetFrame() or Dewdrop:IsOpen(frame) then
+ Dewdrop:Close()
+ return
+ end
+ if self.blizzardTooltip then
+ if GameTooltip:IsOwned(frame) then
+ GameTooltip:Hide()
+ end
+ elseif self.overrideTooltip and type(self.CloseTooltip) == "function" then
+ self:CloseTooltip()
+ elseif not self.overrideTooltip and Tablet then
+ Tablet:Close()
+ end
+
+ if not Dewdrop:IsRegistered(self:GetFrame()) then
+ if type(self.OnMenuRequest) == "table" and (not self.OnMenuRequest.handler or self.OnMenuRequest.handler == self) and self.OnMenuRequest.type == "group" then
+ Dewdrop:InjectAceOptionsTable(self, self.OnMenuRequest)
+ if self.OnMenuRequest.args and CheckFuBar() and not self.independentProfile then
+ self.OnMenuRequest.args.profile = nil
+ end
+ end
+
+ Dewdrop:Register(self:GetFrame(),
+ 'children', type(self.OnMenuRequest) == "table" and self.OnMenuRequest or function(level, value, valueN_1, valueN_2, valueN_3, valueN_4)
+ if level == 1 then
+ if not self.hideMenuTitle then
+ Dewdrop:AddLine(
+ 'text', self:GetTitle(),
+ 'isTitle', true
+ )
+ end
+
+ if self.OnMenuRequest then
+ self:OnMenuRequest(level, value, false, valueN_1, valueN_2, valueN_3, valueN_4)
+ end
+
+ if not self.overrideMenu then
+ if self.MenuSettings and not self.hideMenuTitle then
+ Dewdrop:AddLine()
+ end
+ self:AddImpliedMenuOptions()
+ end
+ else
+ if not self.overrideMenu and self:AddImpliedMenuOptions() then
+ else
+ if self.OnMenuRequest then
+ self:OnMenuRequest(level, value, false, valueN_1, valueN_2, valueN_3, valueN_4)
+ end
+ end
+ end
+ if level == 1 then
+ Dewdrop:AddLine(
+ 'text', CLOSE,
+ 'tooltipTitle', CLOSE,
+ 'tooltipText', CLOSE_DESC,
+ 'func', Dewdrop.Close,
+ 'arg1', Dewdrop
+ )
+ end
+ end,
+ 'point', function(frame)
+ local x, y = frame:GetCenter()
+ local leftRight
+ if x < GetScreenWidth() / 2 then
+ leftRight = "LEFT"
+ else
+ leftRight = "RIGHT"
+ end
+ if y < GetScreenHeight() / 2 then
+ return "BOTTOM" .. leftRight, "TOP" .. leftRight
+ else
+ return "TOP" .. leftRight, "BOTTOM" .. leftRight
+ end
+ end,
+ 'dontHook', true
+ )
+ end
+ if frame == self:GetFrame() then
+ Dewdrop:Open(self:GetFrame())
+ elseif frame ~= UIParent then
+ Dewdrop:Open(frame, self:GetFrame())
+ else
+ Dewdrop:Open(frame, self:GetFrame(), 'cursorX', true, 'cursorY', true)
+ end
+end
+
+local impliedMenuOptions
+function FuBarPlugin:AddImpliedMenuOptions(level)
+ FuBarPlugin:argCheck(level, 2, "number", "nil")
+ if not impliedMenuOptions then
+ impliedMenuOptions = {}
+ end
+ if not impliedMenuOptions[self] then
+ impliedMenuOptions[self] = { type = 'group', args = {} }
+ Dewdrop:InjectAceOptionsTable(self, impliedMenuOptions[self])
+ if impliedMenuOptions[self].args and CheckFuBar() and not self.independentProfile then
+ impliedMenuOptions[self].args.profile = nil
+ end
+ end
+ return Dewdrop:FeedAceOptionsTable(impliedMenuOptions[self], level and level - 1)
+end
+
+function FuBarPlugin.OnEmbedInitialize(FuBarPlugin, self)
+ if not self.frame then
+ local name = "FuBarPlugin" .. self:GetTitle() .. "Frame"
+ local frame = _G[name]
+ if not frame or not _G[name .. "Text"] or not _G[name .. "Icon"] then
+ frame = self:CreateBasicPluginFrame(name)
+
+ local icon = frame:CreateTexture(name .. "Icon", "ARTWORK")
+ icon:SetWidth(16)
+ icon:SetHeight(16)
+ icon:SetPoint("LEFT", frame, "LEFT")
+
+ local text = frame:CreateFontString(name .. "Text", "ARTWORK")
+ text:SetWidth(134)
+ text:SetHeight(24)
+ text:SetPoint("LEFT", icon, "RIGHT", 0, 1)
+ text:SetFontObject(GameFontNormal)
+ end
+ self.frame = frame
+ self.textFrame = _G[name .. "Text"]
+ self.iconFrame = _G[name .. "Icon"]
+ else
+ self.userDefinedFrame = true
+ end
+
+ self.frame.plugin = self
+ self.frame:SetParent(UIParent)
+ self.frame:SetPoint("RIGHT", UIParent, "LEFT", -5, 0)
+ self.frame:Hide()
+
+ if self.hasIcon then
+ self:SetIcon(self.hasIcon)
+ end
+
+ if CheckFuBar() then
+ FuBar:RegisterPlugin(self)
+ end
+end
+
+local CheckShow = function(self, panelId)
+ if not self.frame:IsShown() and (not self.minimapFrame or not self.minimapFrame:IsShown()) then
+ self:Show(panelId)
+ Dewdrop:Refresh(2)
+ end
+end
+
+local recheckPlugins
+local AceConsole
+function FuBarPlugin.OnEmbedEnable(FuBarPlugin, self)
+ if not self.userDefinedFrame then
+ if self:IsIconShown() then
+ self.iconFrame:Show()
+ else
+ self.iconFrame:Hide()
+ end
+ end
+ self:CheckWidth(true)
+
+ if not self.hideWithoutStandby or (self.db and not self.db.profile.hidden) then
+ if FuBarPlugin.enabledPlugins[self] then
+ CheckShow(self, self.panelIdTmp)
+ else
+ FuBarPlugin:ScheduleEvent("FuBarPlugin-CheckShow-" .. tostring(self), CheckShow, 0, self, self.panelIdTmp)
+ end
+ end
+ FuBarPlugin.enabledPlugins[self] = true
+
+ if not self.blizzardTooltip and not self.overrideTooltip and not self.cannotDetachTooltip and self.db and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then
+ FuBarPlugin:ScheduleEvent("FuBarPlugin-DetachTooltip-" .. tostring(self), self.DetachTooltip, 0, self)
+ end
+
+ if self:IsLoadOnDemand() and CheckFuBar() then
+ if not FuBar.db.profile.loadOnDemand then
+ FuBar.db.profile.loadOnDemand = {}
+ end
+ if not FuBar.db.profile.loadOnDemand[FuBarPlugin.folderNames[self] or self.folderName] then
+ FuBar.db.profile.loadOnDemand[FuBarPlugin.folderNames[self] or self.folderName] = {}
+ end
+ FuBar.db.profile.loadOnDemand[FuBarPlugin.folderNames[self] or self.folderName].disabled = nil
+ end
+
+ if CheckFuBar() and AceLibrary:HasInstance("AceConsole-2.0") then
+ if not recheckPlugins then
+ if not AceConsole then
+ AceConsole = AceLibrary("AceConsole-2.0")
+ end
+ recheckPlugins = function()
+ for k,v in pairs(AceConsole.registry) do
+ if type(v) == "table" and v.args and AceOO.inherits(v.handler, FuBarPlugin) and not v.handler.independentProfile then
+ v.args.profile = nil
+ end
+ end
+ end
+ end
+ FuBarPlugin:ScheduleEvent("FuBarPlugin-recheckPlugins", recheckPlugins, 0)
+ end
+end
+
+function FuBarPlugin.OnEmbedDisable(FuBarPlugin, self)
+ self:Hide(false)
+
+ if self:IsLoadOnDemand() and CheckFuBar() then
+ if not FuBar.db.profile.loadOnDemand then
+ FuBar.db.profile.loadOnDemand = {}
+ end
+ if not FuBar.db.profile.loadOnDemand[FuBarPlugin.folderNames[self] or self.folderName] then
+ FuBar.db.profile.loadOnDemand[FuBarPlugin.folderNames[self] or self.folderName] = {}
+ end
+ FuBar.db.profile.loadOnDemand[FuBarPlugin.folderNames[self] or self.folderName].disabled = true
+ end
+end
+
+function FuBarPlugin.OnEmbedProfileEnable(FuBarPlugin, self)
+ self:Update()
+ if self.db and self.db.profile then
+ if not self.db.profile.detachedTooltip then
+ self.db.profile.detachedTooltip = {}
+ end
+ if not self.blizzardTooltip and not self.overrideTooltip and Tablet then
+ if Tablet.registry[self.frame] then
+ Tablet:UpdateDetachedData(self.frame, self.db.profile.detachedTooltip)
+ else
+ FuBarPlugin.RegisterTablet(self)
+ end
+ end
+ if MinimapContainer:HasPlugin(self) then
+ MinimapContainer:ReadjustLocation(self)
+ end
+ end
+end
+
+function FuBarPlugin.GetAceOptionsDataTable(FuBarPlugin, self)
+ return {
+ icon = {
+ type = "toggle",
+ name = SHOW_ICON,
+ desc = SHOW_ICON_DESC,
+ set = "ToggleIconShown",
+ get = "IsIconShown",
+ hidden = function()
+ return not self.hasIcon or self.hasNoText or self:IsDisabled() or self:IsMinimapAttached() or not self.db
+ end,
+ order = -13.7,
+ handler = self,
+ },
+ text = {
+ type = "toggle",
+ name = SHOW_TEXT,
+ desc = SHOW_TEXT_DESC,
+ set = "ToggleTextShown",
+ get = "IsTextShown",
+ hidden = function()
+ return self.cannotHideText or not self.hasIcon or self.hasNoText or self:IsDisabled() or self:IsMinimapAttached() or not self.db
+ end,
+ order = -13.6,
+ handler = self,
+ },
+ colorText = {
+ type = "toggle",
+ name = SHOW_COLORED_TEXT,
+ desc = SHOW_COLORED_TEXT_DESC,
+ set = "ToggleTextColored",
+ get = "IsTextColored",
+ hidden = function()
+ return self.userDefinedFrame or self.hasNoText or self.hasNoColor or self:IsDisabled() or self:IsMinimapAttached() or not self.db
+ end,
+ order = -13.5,
+ handler = self,
+ },
+ detachTooltip = {
+ type = "toggle",
+ name = DETACH_TOOLTIP,
+ desc = DETACH_TOOLTIP_DESC,
+ get = "IsTooltipDetached",
+ set = "ToggleTooltipDetached",
+ hidden = function()
+ return not Tablet or self.blizzardTooltip or self.overrideTooltip or self.cannotDetachTooltip or self:IsDisabled()
+ end,
+ order = -13.4,
+ handler = self,
+ },
+ lockTooltip = {
+ type = "toggle",
+ name = LOCK_TOOLTIP,
+ desc = LOCK_TOOLTIP_DESC,
+ get = function()
+ return Tablet:IsLocked(self.frame)
+ end,
+ set = function()
+ return Tablet:ToggleLocked(self.frame)
+ end,
+ disabled = function()
+ return not self:IsTooltipDetached()
+ end,
+ hidden = function()
+ return not Tablet or self.blizzardTooltip or self.overrideTooltip or self.cannotDetachTooltip or self:IsDisabled()
+ end,
+ order = -13.3,
+ handler = self,
+ },
+ position = {
+ type = "text",
+ name = POSITION,
+ desc = POSITION_DESC,
+ validate = {
+ LEFT = POSITION_LEFT,
+ CENTER = POSITION_CENTER,
+ RIGHT = POSITION_RIGHT
+ },
+ get = function()
+ return self.panel and self.panel:GetPluginSide(self)
+ end,
+ set = function(value)
+ if self.panel then
+ self.panel:SetPluginSide(self, value)
+ end
+ end,
+ hidden = function()
+ return self:IsMinimapAttached() or self:IsDisabled() or not self.panel
+ end,
+ order = -13.2,
+ handler = self,
+ },
+ minimapAttach = {
+ type = "toggle",
+ name = ATTACH_TO_MINIMAP,
+ desc = ATTACH_TO_MINIMAP_DESC,
+ get = "IsMinimapAttached",
+ set = "ToggleMinimapAttached",
+ hidden = function()
+ -- return (self.cannotAttachToMinimap and not self:IsMinimapAttached()) or not CheckFuBar() or self:IsDisabled()
+ return self.cannotAttachToMinimap or not CheckFuBar() or self:IsDisabled()
+ end,
+ order = -13.1,
+ handler = self,
+ },
+ hide = {
+ type = "toggle",
+ cmdName = HIDE_FUBAR_PLUGIN_CMD,
+ guiName = HIDE_FUBAR_PLUGIN,
+ desc = HIDE_FUBAR_PLUGIN_DESC,
+ get = function()
+ return not self.frame:IsShown() and (not self.minimapFrame or not self.minimapFrame:IsShown())
+ end,
+ set = function()
+ if not self.frame:IsShown() and (not self.minimapFrame or not self.minimapFrame:IsShown()) then
+ self:Show()
+ else
+ self:Hide()
+ end
+ end,
+ hidden = function()
+ return not self.hideWithoutStandby or self:IsDisabled()
+ end,
+ order = -13,
+ handler = self,
+ },
+ }
+end
+
+local function activate(self, oldLib, oldDeactivate)
+ FuBarPlugin = self
+
+ if oldLib then
+ self.registry = oldLib.registry
+ self.folderNames = oldLib.folderNames
+ self.enabledPlugins = oldLib.enabledPlugins
+ end
+
+ if not self.registry then
+ self.registry = {}
+ end
+ if not self.folderNames then
+ self.folderNames = {}
+ end
+ if not self.enabledPlugins then
+ self.enabledPlugins = {}
+ end
+
+ FuBarPlugin.activate(self, oldLib, oldDeactivate)
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+local function external(self, major, instance)
+ if major == "AceEvent-2.0" then
+ AceEvent = instance
+ AceEvent:embed(self)
+ elseif major == "Tablet-2.0" then
+ Tablet = instance
+ elseif major == "Dewdrop-2.0" then
+ Dewdrop = instance
+ end
+end
+
+AceLibrary:Register(FuBarPlugin, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)
+
+MinimapContainer = {}
+
+local minimap_OnMouseDown, minimap_OnMouseUp
+function MinimapContainer:AddPlugin(plugin)
+ if CheckFuBar() and FuBar:IsChangingProfile() then
+ return
+ end
+ if plugin.panel ~= nil then
+ plugin.panel:RemovePlugin(plugin)
+ end
+ plugin.panel = self
+
+ if not plugin.minimapFrame then
+ local frame = CreateFrame("Button", plugin.frame:GetName() .. "MinimapButton", Minimap)
+ plugin.minimapFrame = frame
+ frame.plugin = plugin
+ frame:SetWidth(31)
+ frame:SetHeight(31)
+ frame:SetFrameStrata("BACKGROUND")
+ frame:SetFrameLevel(4)
+ frame:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight")
+ local icon = frame:CreateTexture(frame:GetName() .. "Icon", "BACKGROUND")
+ plugin.minimapIcon = icon
+
+ local path = plugin:GetIcon() or (plugin.iconFrame and plugin.iconFrame:GetTexture()) or "Interface\\Icons\\INV_Misc_QuestionMark"
+ icon:SetTexture(path)
+
+ if type(path) == "string" and path:sub(1, 16) == "Interface\\Icons\\" then
+ icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ icon:SetTexCoord(0, 1, 0, 1)
+ end
+ icon:SetWidth(20)
+ icon:SetHeight(20)
+ icon:SetPoint("TOPLEFT", frame, "TOPLEFT", 7, -5)
+ local overlay = frame:CreateTexture(frame:GetName() .. "Overlay","OVERLAY")
+ overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder")
+ overlay:SetWidth(53)
+ overlay:SetHeight(53)
+ overlay:SetPoint("TOPLEFT",frame,"TOPLEFT")
+ frame:EnableMouse(true)
+ frame:RegisterForClicks("LeftButtonUp")
+
+ frame.self = plugin
+ if not frame_OnEnter then
+ function frame_OnEnter(this, ...)
+ if type(this.self.OnEnter) == "function" then
+ this.self:OnEnter(...)
+ end
+ end
+ end
+ frame:SetScript("OnEnter", frame_OnEnter)
+ if not frame_OnLeave then
+ function frame_OnLeave(this, ...)
+ if type(this.self.OnLeave) == "function" then
+ this.self:OnLeave(...)
+ end
+ end
+ end
+ frame:SetScript("OnLeave", frame_OnLeave)
+ if not frame_OnClick then
+ function frame_OnClick(this, ...)
+ if this.self:IsMinimapAttached() and this.dragged then return end
+ if type(this.self.OnClick) == "function" then
+ this.self:OnClick(...)
+ end
+ end
+ end
+ frame:SetScript("OnClick", frame_OnClick)
+ if not frame_OnDoubleClick then
+ function frame_OnDoubleClick(this, ...)
+ if type(this.self.OnDoubleClick) == "function" then
+ this.self:OnDoubleClick(...)
+ end
+ end
+ end
+ frame:SetScript("OnDoubleClick", frame_OnDoubleClick)
+ if not frame_OnReceiveDrag then
+ function frame_OnReceiveDrag(this, ...)
+ if (this.self:IsMinimapAttached() and not this.dragged) and type(this.self.OnReceiveDrag) == "function" then
+ this.self:OnReceiveDrag(...)
+ end
+ end
+ end
+ frame:SetScript("OnReceiveDrag", frame_OnReceiveDrag)
+ if not minimap_OnMouseDown then
+ function minimap_OnMouseDown(this, ...)
+ this.dragged = false
+ if (...) == "RightButton" and not IsModifierKeyDown() then
+ this.self:OpenMenu(this)
+ else
+ HideDropDownMenu(1)
+ if type(this.self.OnMouseDown) == "function" then
+ this.self:OnMouseDown(...)
+ end
+ end
+ if this.self.OnClick or this.self.OnMouseDown or this.self.OnMouseUp or this.self.OnDoubleClick then
+ if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then
+ this.self.minimapIcon:SetTexCoord(0.14, 0.86, 0.14, 0.86)
+ else
+ this.self.minimapIcon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
+ end
+ end
+ end
+ end
+ frame:SetScript("OnMouseDown", minimap_OnMouseDown)
+ if not minimap_OnMouseUp then
+ function minimap_OnMouseUp(this, ...)
+ if not this.dragged and type(this.self.OnMouseUp) == "function" then
+ this.self:OnMouseUp(...)
+ end
+ if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then
+ this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ this.self.minimapIcon:SetTexCoord(0, 1, 0, 1)
+ end
+ end
+ end
+ frame:SetScript("OnMouseUp", minimap_OnMouseUp)
+ frame:RegisterForDrag("LeftButton")
+ frame:SetScript("OnDragStart", self.OnDragStart)
+ frame:SetScript("OnDragStop", self.OnDragStop)
+
+ if not plugin.blizzardTooltip and not plugin.overrideTooltip and Tablet then
+ -- Note that we have to do this after :SetScript("OnEnter"), etc,
+ -- so that Tablet-2.0 can override it properly.
+ FuBarPlugin.RegisterTablet(plugin)
+ Tablet:Register(frame, plugin.frame)
+ end
+ end
+ plugin.frame:Hide()
+ plugin.minimapFrame:Show()
+ self:ReadjustLocation(plugin)
+ table.insert(self.plugins, plugin)
+ local exists = false
+ return true
+end
+
+function MinimapContainer:RemovePlugin(index)
+ if CheckFuBar() and FuBar:IsChangingProfile() then
+ return
+ end
+ if type(index) == "table" then
+ index = self:IndexOfPlugin(index)
+ if not index then
+ return
+ end
+ end
+ local t = self.plugins
+ local plugin = t[index]
+ assert(plugin.panel == self, "Plugin has improper panel field")
+ plugin:SetPanel(nil)
+ table.remove(t, index)
+ return true
+end
+
+function MinimapContainer:ReadjustLocation(plugin)
+ local frame = plugin.minimapFrame
+ if plugin.db and plugin.db.profile.minimapPositionWild then
+ frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", plugin.db.profile.minimapPositionX, plugin.db.profile.minimapPositionY)
+ elseif not plugin.db and plugin.minimapPositionWild then
+ frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", plugin.minimapPositionX, plugin.minimapPositionY)
+ else
+ local position
+ if plugin.db then
+ position = plugin.db.profile.minimapPosition or plugin.defaultMinimapPosition or math.random(1, 360)
+ else
+ position = plugin.minimapPosition or plugin.defaultMinimapPosition or math.random(1, 360)
+ end
+ local angle = math.rad(position or 0)
+ local x,y
+ local minimapShape = GetMinimapShape and GetMinimapShape() or "ROUND"
+ local cos = math.cos(angle)
+ local sin = math.sin(angle)
+
+ local round = true
+ if minimapShape == "ROUND" then
+ -- do nothing
+ elseif minimapShape == "SQUARE" then
+ round = false
+ elseif minimapShape == "CORNER-TOPRIGHT" then
+ if cos < 0 or sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-TOPLEFT" then
+ if cos > 0 or sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-BOTTOMRIGHT" then
+ if cos < 0 or sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "CORNER-BOTTOMLEFT" then
+ if cos > 0 or sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-LEFT" then
+ if cos > 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-RIGHT" then
+ if cos < 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-TOP" then
+ if sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "SIDE-BOTTOM" then
+ if sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-TOPRIGHT" then
+ if cos < 0 and sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-TOPLEFT" then
+ if cos > 0 and sin < 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-BOTTOMRIGHT" then
+ if cos < 0 and sin > 0 then
+ round = false
+ end
+ elseif minimapShape == "TRICORNER-BOTTOMLEFT" then
+ if cos > 0 and sin > 0 then
+ round = false
+ end
+ end
+
+ if round then
+ x = cos * 80
+ y = sin * 80
+ else
+ x = 80 * 2^0.5 * cos
+ y = 80 * 2^0.5 * sin
+ if x < -80 then
+ x = -80
+ elseif x > 80 then
+ x = 80
+ end
+ if y < -80 then
+ y = -80
+ elseif y > 80 then
+ y = 80
+ end
+ end
+ frame:SetPoint("CENTER", Minimap, "CENTER", x, y)
+ end
+end
+
+function MinimapContainer:GetPlugin(index)
+ return self.plugins[index]
+end
+
+function MinimapContainer:GetNumPlugins()
+ return #self.plugins
+end
+
+function MinimapContainer:IndexOfPlugin(plugin)
+ for i,p in ipairs(self.plugins) do
+ if p == plugin then
+ return i, "MINIMAP"
+ end
+ end
+end
+
+function MinimapContainer:HasPlugin(plugin)
+ return self:IndexOfPlugin(plugin) ~= nil
+end
+
+function MinimapContainer:GetPluginSide(plugin)
+ local index = self:IndexOfPlugin(plugin)
+ assert(index, "Plugin not in panel")
+ return "MINIMAP"
+end
+
+function MinimapContainer.OnDragStart(this)
+ this.dragged = true
+ this:LockHighlight()
+ this:SetScript("OnUpdate", MinimapContainer.OnUpdate)
+ if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then
+ this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
+ else
+ this.self.minimapIcon:SetTexCoord(0, 1, 0, 1)
+ end
+end
+
+function MinimapContainer.OnDragStop(this)
+ this:SetScript("OnUpdate", nil)
+ this:UnlockHighlight()
+end
+
+function MinimapContainer.OnUpdate(this)
+ if not IsAltKeyDown() then
+ local mx, my = Minimap:GetCenter()
+ local px, py = GetCursorPosition()
+ local scale = UIParent:GetEffectiveScale()
+ px, py = px / scale, py / scale
+ local position = math.deg(math.atan2(py - my, px - mx))
+ if position <= 0 then
+ position = position + 360
+ elseif position > 360 then
+ position = position - 360
+ end
+ if this.self.db then
+ this.self.db.profile.minimapPosition = position
+ this.self.db.profile.minimapPositionX = nil
+ this.self.db.profile.minimapPositionY = nil
+ this.self.db.profile.minimapPositionWild = nil
+ else
+ this.self.minimapPosition = position
+ this.self.minimapPositionX = nil
+ this.self.minimapPositionY = nil
+ this.self.minimapPositionWild = nil
+ end
+ else
+ local px, py = GetCursorPosition()
+ local scale = UIParent:GetEffectiveScale()
+ px, py = px / scale, py / scale
+ if this.self.db then
+ this.self.db.profile.minimapPositionX = px
+ this.self.db.profile.minimapPositionY = py
+ this.self.db.profile.minimapPosition = nil
+ this.self.db.profile.minimapPositionWild = true
+ else
+ this.self.minimapPositionX = px
+ this.self.minimapPositionY = py
+ this.self.minimapPosition = nil
+ this.self.minimapPositionWild = true
+ end
+ end
+ MinimapContainer:ReadjustLocation(this.self)
+end
+
+local function activate(self, oldLib, oldDeactivate)
+ MinimapContainer = self
+
+ if oldLib then
+ self.plugins = oldLib.plugins
+ end
+
+ if not self.plugins then
+ self.plugins = {}
+ end
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+AceLibrary:Register(MinimapContainer, MINIMAPCONTAINER_MAJOR_VERSION, MINOR_VERSION, activate)
diff --git a/FuBar_DurabilityFu/libs/Tablet-2.0/Tablet-2.0.lua b/FuBar_DurabilityFu/libs/Tablet-2.0/Tablet-2.0.lua
new file mode 100644
index 0000000..f800ae5
--- /dev/null
+++ b/FuBar_DurabilityFu/libs/Tablet-2.0/Tablet-2.0.lua
@@ -0,0 +1,2973 @@
+--[[
+Name: Tablet-2.0
+Revision: $Rev: 216 $
+Author(s): ckknight (ckknight@gmail.com)
+Website: http://ckknight.wowinterface.com/
+Documentation: http://www.wowace.com/index.php/Tablet-2.0
+SVN: http://svn.wowace.com/wowace/trunk/TabletLib/Tablet-2.0
+Description: A library to provide an efficient, featureful tooltip-style display.
+Dependencies: AceLibrary, (optional) Dewdrop-2.0
+License: LGPL v2.1
+]]
+
+local MAJOR_VERSION = "Tablet-2.0"
+local MINOR_VERSION = 90000 + tonumber(("$Revision: 216 $"):match("(%d+)"))
+
+if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
+if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
+
+local DEBUG = false
+
+local SCROLL_UP = "Scroll up"
+local SCROLL_DOWN = "Scroll down"
+local HINT = "Hint"
+local DETACH = "Detach"
+local DETACH_DESC = "Detach the tablet from its source."
+local SIZE = "Size"
+local SIZE_DESC = "Scale the tablet."
+local CLOSE_MENU = "Close menu"
+local CLOSE_MENU_DESC = "Close the menu."
+local COLOR = "Background color"
+local COLOR_DESC = "Set the background color."
+local LOCK = "Lock"
+local LOCK_DESC = "Lock the tablet in its current position. Alt+Right-click for menu or Alt+drag to drag it when locked."
+
+if GetLocale() == "deDE" then
+ SCROLL_UP = "Hochscrollen"
+ SCROLL_DOWN = "Runterscrollen"
+ HINT = "Hinweis"
+ DETACH = "L\195\182sen"
+ DETACH_DESC = "L\195\182st den Tooltip aus seiner Verankerung."
+ SIZE = "Gr\195\182\195\159e"
+ SIZE_DESC = "Gr\195\182\195\159e des Tooltips \195\164ndern."
+ CLOSE_MENU = "Menu schlie\195\159en"
+ CLOSE_MENU_DESC = "Schlie\195\159t das Menu."
+ COLOR = "Hintergrundfarbe"
+ COLOR_DESC = "Hintergrundfarbe setzen."
+ LOCK = "Sperren"
+ LOCK_DESC = "Sperrt die aktuelle Position vom Tooltip. Alt+Rechts-klick f\195\188rs Men\195\188 oder Alt+Verschieben f\195\188rs verschieben wenn es gesperrt ist."
+elseif GetLocale() == "koKR" then
+ SCROLL_UP = "위로 스크롤"
+ SCROLL_DOWN = "아래로 스크롤"
+ HINT = "힌트"
+ DETACH = "분리"
+ DETACH_DESC = "테이블을 분리합니다."
+ SIZE = "크기"
+ SIZE_DESC = "테이블의 크기입니다."
+ CLOSE_MENU = "메뉴 닫기"
+ CLOSE_MENU_DESC = "메뉴를 닫습니다."
+ COLOR = "배경 색상"
+ COLOR_DESC = "배경 색상을 설정합니다."
+ LOCK = "고정"
+ LOCK_DESC = "현재 위치에 테이블을 고정합니다. 알트+우클릭 : 메뉴열기, 알트+드래그 : 고정된것을 드래그합니다."
+elseif GetLocale() == "zhCN" then
+ SCROLL_UP = "向上翻转"
+ SCROLL_DOWN = "向上翻转"
+ HINT = "提示"
+ DETACH = "分离"
+ DETACH_DESC = "分离菜单为独立提示."
+ SIZE = "尺寸"
+ SIZE_DESC = "缩放菜单显示尺寸."
+ CLOSE_MENU = "关闭菜单"
+ CLOSE_MENU_DESC = "关闭菜单"
+ COLOR = "背景颜色"
+ COLOR_DESC = "设置菜单背景颜色."
+ LOCK = "锁定"
+ LOCK_DESC = "锁定菜单当前位置. alt+右键 将显示选项, alt+拖动 可以移动已锁定的菜单."
+elseif GetLocale() == "zhTW" then
+ SCROLL_UP = "向上翻捲"
+ SCROLL_DOWN = "向上翻捲"
+ HINT = "提示"
+ DETACH = "分離"
+ DETACH_DESC = "分離選單為獨立提示。"
+ SIZE = "尺寸"
+ SIZE_DESC = "縮放選單顯示尺寸。"
+ CLOSE_MENU = "關閉選單"
+ CLOSE_MENU_DESC = "關閉選單。"
+ COLOR = "背景顏色"
+ COLOR_DESC = "設定選單背景顏色。"
+ LOCK = "鎖定"
+ LOCK_DESC = "鎖定選單目前位置設定。Alt-右鍵將顯示選項,Alt-拖動可以移動已鎖定的選單。"
+elseif GetLocale() == "frFR" then
+ SCROLL_UP = "Parcourir vers le haut"
+ SCROLL_DOWN = "Parcourir vers le bas"
+ HINT = "Astuce"
+ DETACH = "D\195\169tacher"
+ DETACH_DESC = "Permet de d\195\169tacher le tableau de sa source."
+ SIZE = "Taille"
+ SIZE_DESC = "Permet de changer l'\195\169chelle du tableau."
+ CLOSE_MENU = "Fermer le menu"
+ CLOSE_MENU_DESC = "Ferme ce menu."
+ COLOR = "Couleur du fond"
+ COLOR_DESC = "Permet de d\195\169finir la couleur du fond."
+ LOCK = "Bloquer"
+ LOCK_DESC = "Bloque le tableau \195\160 sa position actuelle. Alt+clic-droit pour le menu ou Alt+glisser pour le d\195\169placer quand il est bloqu\195\169."
+elseif GetLocale() == "esES" then
+ SCROLL_UP = "Desplazar hacia arriba"
+ SCROLL_DOWN = "Desplazar hacia abajo"
+ HINT = "Consejo"
+ DETACH = "Separar"
+ DETACH_DESC = "Separa el tooltip de su fuente."
+ SIZE = "Tama\195\177o"
+ SIZE_DESC = "Escala el tooltip"
+ CLOSE_MENU = "Cerrar men\195\186"
+ CLOSE_MENU_DESC = "Cierra el men\195\186"
+ COLOR = "Color de fondo"
+ COLOR_DESC = "Establece el color de fondo"
+ LOCK = "Bloquear"
+ LOCK_DESC = "Bloquea el tooltip en su posici\195\179n actual. Clic+Alt para el men\195\186 y arrastra+Alt para arrastrarlo cuando est\195\161 bloqueado"
+elseif GetLocale() == "ruRU" then
+ SCROLL_UP = "Прокрутка вверх"
+ SCROLL_DOWN = "Прокрутка вниз"
+ HINT = "Совет"
+ DETACH = "Отделить"
+ DETACH_DESC = "Отделить планшет от его источника."
+ SIZE = "Размер"
+ SIZE_DESC = "Масштаб планшета."
+ CLOSE_MENU = "Закрыть меню"
+ CLOSE_MENU_DESC = "Закрыть меню."
+ COLOR = "Цвет фона"
+ COLOR_DESC = "Установить цвет фона."
+ LOCK = "Зафиксировать"
+ LOCK_DESC = "Зафиксировать планшет в его текущем позиции. Alt+ПКМ для меню или Alt+перетаскивание для перетаскивания когда планшет зафиксирован."
+end
+
+local start = GetTime()
+local wrap
+local GetProfileInfo
+if DEBUG then
+ local tree = {}
+ local treeMemories = {}
+ local treeTimes = {}
+ local memories = {}
+ local times = {}
+ function wrap(value, name)
+ if type(value) == "function" then
+ local oldFunction = value
+ memories[name] = 0
+ times[name] = 0
+ return function(self, ...)
+ local pos = #tree
+ tree[#tree+1] = name
+ treeMemories[#treeMemories+1] = 0
+ treeTimes[#treeTimes+1] = 0
+ local t, mem = GetTime(), gcinfo()
+ local r1, r2, r3, r4, r5, r6, r7, r8 = oldFunction(self, ...)
+ mem, t = gcinfo() - mem, GetTime() - t
+ if pos > 0 then
+ treeMemories[pos] = treeMemories[pos] + mem
+ treeTimes[pos] = treeTimes[pos] + t
+ end
+ local otherMem = table.remove(treeMemories)
+ if mem - otherMem > 0 then
+ memories[name] = memories[name] + mem - otherMem
+ end
+ times[name] = times[name] + t - table.remove(treeTimes)
+ table.remove(tree)
+ return r1, r2, r3, r4, r5, r6, r7, r8
+ end
+ end
+ end
+
+ function GetProfileInfo()
+ return GetTime() - start, times, memories
+ end
+else
+ function wrap(value)
+ return value
+ end
+end
+
+local function GetMainFrame()
+ if UIParent:IsShown() then
+ return UIParent
+ end
+ local f = GetUIPanel("fullscreen")
+ if f and f:IsShown() then
+ return f
+ end
+ return nil
+end
+GetMainFrame = wrap(GetMainFrame, "GetMainFrame")
+
+local MIN_TOOLTIP_SIZE = 200
+local TESTSTRING_EXTRA_WIDTH = 8
+local Tablet = {}
+local Dewdrop = nil
+local CleanCategoryPool
+local pool = {}
+
+local function del(t)
+ setmetatable(t, nil)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ t[''] = true
+ t[''] = nil
+ pool[t] = true
+ return nil
+end
+
+local function copy(parent)
+ local t = next(pool)
+ if not t then
+ t = {}
+ else
+ pool[t] = nil
+ end
+ if parent then
+ for k,v in pairs(parent) do
+ t[k] = v
+ end
+ setmetatable(t, getmetatable(parent))
+ end
+ return t
+end
+
+local function new(...)
+ local t = next(pool)
+ if not t then
+ t = {}
+ else
+ pool[t] = nil
+ end
+
+ for i = 1, select('#', ...), 2 do
+ local k = select(i, ...)
+ if k then
+ t[k] = select(i+1, ...)
+ else
+ break
+ end
+ end
+ return t
+end
+
+local tmp
+tmp = setmetatable({}, {__index = function(self, key)
+ local t = {}
+ tmp[key] = function(...)
+ for k in pairs(t) do
+ t[k] = nil
+ end
+ for i = 1, select('#', ...), 2 do
+ local k = select(i, ...)
+ if k then
+ t[k] = select(i+1, ...)
+ else
+ break
+ end
+ end
+ return t
+ end
+ return tmp[key]
+end})
+
+local headerSize, normalSize
+if GameTooltipHeaderText then
+ headerSize = select(2,GameTooltipHeaderText:GetFont())
+else
+ headerSize = 14
+end
+if GameTooltipText then
+ normalSize = select(2,GameTooltipText:GetFont())
+else
+ normalSize = 12
+end
+local tooltip
+local testString
+local TabletData = {}
+local Category = {}
+local Line = {}
+local function getTestWidth(font, size, text)
+ if not testString then
+ return MIN_TOOLTIP_SIZE + 40
+ end
+ testString:SetWidth(0)
+ testString:SetFontObject(font)
+ local a,_,b = font:GetFont()
+ testString:SetFont(a, size, b)
+ testString:SetText(text)
+ return testString:GetStringWidth()-- + TESTSTRING_EXTRA_WIDTH
+end
+getTestWidth = wrap(getTestWidth, "getTestWidth")
+do
+ local TabletData_mt = { __index = TabletData }
+ function TabletData:new(tablet)
+ local self = new()
+ self.categories = new()
+ self.id = 0
+ self.width = 0 -- (MIN_TOOLTIP_SIZE - 20)*tablet.fontSizePercent
+ self.tablet = tablet
+ self.title = nil
+ self.titleR, self.titleG, self.titleB = nil, nil, nil
+ self.num_lines = 0
+ setmetatable(self, TabletData_mt)
+ return self
+ end
+ TabletData.new = wrap(TabletData.new, "TabletData:new")
+
+ function TabletData:checkMinWidth()
+ local min = self.minWidth or MIN_TOOLTIP_SIZE
+ local width = (min - 20)*self.tablet.fontSizePercent
+ if self.width < width then
+ self.width = width
+ end
+ end
+ TabletData.checkMinWidth = wrap(TabletData.checkMinWidth, "TabletData:checkMinWidth")
+
+ function TabletData:del()
+ for k, v in ipairs(self.categories) do
+ v:del()
+ end
+ del(self.categories)
+ del(self)
+ end
+ TabletData.del = wrap(TabletData.del, "TabletData:del")
+
+ function TabletData:Display()
+ if self.title and (self.tablet == tooltip or self.tablet.registration.showTitleWhenDetached) then
+ local info = new(
+ 'hideBlankLine', true,
+ 'text', self.title,
+ 'justify', "CENTER",
+ 'font', GameTooltipHeaderText,
+ 'isTitle', true
+ )
+ if self.titleR then
+ info.textR = self.titleR
+ info.textG = self.titleG
+ info.textB = self.titleB
+ end
+ self:AddCategory(info, 1)
+ del(info)
+ end
+ if self.tablet == tooltip or self.tablet.registration.showHintWhenDetached then
+ if self.hint then
+ self:AddCategory(nil):AddLine(
+ 'text', HINT .. ": " .. self.hint,
+ 'textR', 0,
+ 'textG', 1,
+ 'textB', 0,
+ 'wrap', true
+ )
+ end
+ end
+
+ local tabletData = self.tabletData
+ for k, v in ipairs(self.categories) do
+ local width
+ if v.columns <= 2 then
+ width = v.x1
+ else
+ width = (v.columns - 1)*20
+ for i = 1, v.columns do
+ width = width + v['x' .. i]
+ end
+ end
+ if self.width < width then
+ self.width = width
+ end
+ end
+
+ local good = false
+ local lastTitle = true
+ for k, v in ipairs(self.categories) do
+ if lastTitle then
+ v.hideBlankLine = true
+ lastTitle = false
+ end
+ if v:Display(self.tablet) and (not v.isTitle or not self.tablet.registration.hideWhenEmpty or next(self.categories, k)) then
+ good = true
+ end
+ if v.isTitle then
+ lastTitle = true
+ end
+ end
+ if not good then
+ if self.tablet == tooltip or not self.tablet.registration.hideWhenEmpty then
+ local width
+ local info = new(
+ 'hideBlankLine', true,
+ 'text', self.title,
+ 'justify', "CENTER",
+ 'font', GameTooltipHeaderText,
+ 'isTitle', true
+ )
+ local cat = self:AddCategory(info)
+ del(info)
+ self.width = self.categories[#self.categories].x1
+ cat:Display(self.tablet)
+ else
+ self.tablet:__Hide()
+ self.tablet.tmpHidden = true
+ end
+ else
+ self.tablet:__Show()
+ self.tablet.tmpHidden = nil
+ end
+ end
+ TabletData.Display = wrap(TabletData.Display, "TabletData:Display")
+
+ function TabletData:AddCategory(info, index)
+ local made = false
+ if not info then
+ made = true
+ info = new()
+ end
+ local cat = Category:new(self, info)
+ if index then
+ table.insert(self.categories, index, cat)
+ else
+ self.categories[#self.categories+1] = cat
+ end
+ if made then
+ del(info)
+ end
+ return cat
+ end
+ TabletData.AddCategory = wrap(TabletData.AddCategory, "TabletData:AddCategory")
+
+ function TabletData:SetHint(hint)
+ self.hint = hint
+ end
+ TabletData.SetHint = wrap(TabletData.SetHint, "TabletData:SetHint")
+
+ function TabletData:SetTitle(title)
+ self.title = title or "Title"
+ end
+ TabletData.SetTitle = wrap(TabletData.SetTitle, "TabletData:SetTitle")
+
+ function TabletData:SetTitleColor(r, g, b)
+ self.titleR = r
+ self.titleG = g
+ self.titleB = b
+ end
+ TabletData.SetTitleColor = wrap(TabletData.SetTitleColor, "TabletData:SetTitleColor")
+end
+do
+ local Category_mt = { __index = Category }
+ function Category:new(tabletData, info, superCategory)
+ local self = copy(info)
+ if superCategory and not self.noInherit then
+ self.superCategory = superCategory.superCategory
+ for k, v in pairs(superCategory) do
+ if k:find("^child_") then
+ local k = strsub(k, 7)
+ if self[k] == nil then
+ self[k] = v
+ end
+ end
+ end
+ self.columns = superCategory.columns
+ else
+ self.superCategory = self
+ end
+ self.tabletData = tabletData
+ self.lines = new()
+ if not self.columns then
+ self.columns = 1
+ end
+ for i = 1, self.columns do
+ self['x' .. i] = 0
+ end
+ setmetatable(self, Category_mt)
+ self.lastWasTitle = nil
+ local good = self.text
+ if not good then
+ for i = 2, self.columns do
+ if self['text' .. i] then
+ good = true
+ break
+ end
+ end
+ end
+ if good then
+ local x = new(
+ 'category', category,
+ 'text', self.text,
+ 'fakeChild', true,
+ 'func', self.func,
+ 'onEnterFunc', self.onEnterFunc,
+ 'onLeaveFunc', self.onLeaveFunc,
+ 'hasCheck', self.hasCheck,
+ 'checked', self.checked,
+ 'checkIcon', self.checkIcon,
+ 'isRadio', self.isRadio,
+ 'font', self.font,
+ 'size', self.size,
+ 'wrap', self.wrap,
+ 'catStart', true,
+ 'indentation', self.indentation,
+ 'noInherit', true,
+ 'justify', self.justify,
+ 'isTitle', self.isTitle
+ )
+ local i = 1
+ while true do
+ local k = 'arg' .. i
+ local v = self[k]
+ if v == nil then
+ break
+ end
+ x[k] = v
+ i = i + 1
+ end
+ i = 1
+ while true do
+ local k = 'onEnterArg' .. i
+ local v = self[k]
+ if v == nil then
+ break
+ end
+ x[k] = v
+ i = i + 1
+ end
+ i = 1
+ while true do
+ local k = 'onLeaveArg' .. i
+ local v = self[k]
+ if v == nil then
+ break
+ end
+ x[k] = v
+ i = i + 1
+ end
+ if self.isTitle then
+ x.textR = self.textR or 1
+ x.textG = self.textG or 0.823529
+ x.textB = self.textB or 0
+ else
+ x.textR = self.textR or 1
+ x.textG = self.textG or 1
+ x.textB = self.textB or 1
+ end
+ for i = 2, self.columns do
+ x['text' .. i] = self['text' .. i]
+ x['text' .. i .. 'R'] = self['text' .. i .. 'R'] or self['textR' .. i] or 1
+ x['text' .. i .. 'G'] = self['text' .. i .. 'G'] or self['textG' .. i] or 1
+ x['text' .. i .. 'B'] = self['text' .. i .. 'B'] or self['textB' .. i] or 1
+ x['font' .. i] = self['font' .. i]
+ x['size' .. i] = self['size' .. i]
+ x['justify' .. i] = self['justify' .. i]
+ end
+ if self.checkIcon and self.checkIcon:find("^Interface\\Icons\\") then
+ x.checkCoordLeft = self.checkCoordLeft or 0.05
+ x.checkCoordRight = self.checkCoordRight or 0.95
+ x.checkCoordTop = self.checkCoordTop or 0.05
+ x.checkCoordBottom = self.checkCoordBottom or 0.95
+ else
+ x.checkCoordLeft = self.checkCoordLeft or 0
+ x.checkCoordRight = self.checkCoordRight or 1
+ x.checkCoordTop = self.checkCoordTop or 0
+ x.checkCoordBottom = self.checkCoordBottom or 1
+ end
+ x.checkColorR = self.checkColorR or 1
+ x.checkColorG = self.checkColorG or 1
+ x.checkColorB = self.checkColorB or 1
+ self:AddLine(x)
+ del(x)
+ self.lastWasTitle = true
+ end
+ return self
+ end
+ Category.new = wrap(Category.new, "Category:new")
+
+ function Category:del()
+ local prev = garbageLine
+ for k, v in pairs(self.lines) do
+ v:del()
+ end
+ del(self.lines)
+ del(self)
+ end
+ Category.del = wrap(Category.del, "Category:del")
+
+ function Category:AddLine(...)
+ self.lastWasTitle = nil
+ local line
+ local k1 = ...
+ if type(k1) == "table" then
+ local k2 = select(2, ...)
+ Line:new(self, k1, k2)
+ else
+ local info = new(...)
+ Line:new(self, info)
+ info = del(info)
+ end
+ end
+ Category.AddLine = wrap(Category.AddLine, "Category:AddLine")
+
+ function Category:AddCategory(...)
+ local lastWasTitle = self.lastWasTitle
+ self.lastWasTitle = nil
+ local info
+ local k1 = ...
+ if type(k1) == "table" then
+ info = k1
+ else
+ info = new(...)
+ end
+ if lastWasTitle or #self.lines == 0 then
+ info.hideBlankLine = true
+ end
+ local cat = Category:new(self.tabletData, info, self)
+ self.lines[#self.lines+1] = cat
+ if info ~= k1 then
+ info = del(info)
+ end
+ return cat
+ end
+ Category.AddCategory = wrap(Category.AddCategory, "Category:AddCategory")
+
+ function Category:HasChildren()
+ local hasChildren = false
+ for k, v in ipairs(self.lines) do
+ if v.HasChildren then
+ if v:HasChildren() then
+ return true
+ end
+ end
+ if not v.fakeChild then
+ return true
+ end
+ end
+ return false
+ end
+ Category.HasChildren = wrap(Category.HasChildren, "Category:HasChildren")
+
+ local lastWasTitle = false
+ function Category:Display(tablet)
+ if not self.isTitle and not self.showWithoutChildren and not self:HasChildren() then
+ return false
+ end
+ if not self.hideBlankLine and not lastWasTitle then
+ local info = new(
+ 'blank', true,
+ 'fakeChild', true,
+ 'noInherit', true
+ )
+ self:AddLine(info, 1)
+ del(info)
+ end
+ local good = false
+ if #self.lines > 0 then
+ self.tabletData.id = self.tabletData.id + 1
+ self.id = self.tabletData.id
+ for k, v in ipairs(self.lines) do
+ if v:Display(tablet) then
+ good = true
+ end
+ end
+ end
+ lastWasTitle = self.isTitle
+ return good
+ end
+ Category.Display = wrap(Category.Display, "Category:Display")
+end
+do
+ local Line_mt = { __index = Line }
+ function Line:new(category, info, position)
+ local self = copy(info)
+ if not info.noInherit then
+ for k, v in pairs(category) do
+ if k:find("^child_") then
+ local k = strsub(k, 7)
+ if self[k] == nil then
+ self[k] = v
+ end
+ end
+ end
+ end
+ self.category = category
+ if position then
+ table.insert(category.lines, position, self)
+ else
+ category.lines[#category.lines+1] = self
+ end
+ setmetatable(self, Line_mt)
+ local n = category.tabletData.num_lines + 1
+ category.tabletData.num_lines = n
+ if n == 10 then
+ category.tabletData:checkMinWidth()
+ end
+ local columns = category.columns
+ if columns == 1 then
+ if not self.justify then
+ self.justify = "LEFT"
+ end
+ elseif columns == 2 then
+ self.justify = "LEFT"
+ self.justify2 = "RIGHT"
+ if self.wrap then
+ self.wrap2 = false
+ end
+ else
+ for i = 2, columns-1 do
+ if not self['justify' .. i] then
+ self['justify' .. i] = "CENTER"
+ end
+ end
+ if not self.justify then
+ self.justify = "LEFT"
+ end
+ if not self['justify' .. columns] then
+ self['justify' .. columns] = "RIGHT"
+ end
+ if self.wrap then
+ for i = 2, columns do
+ self['wrap' .. i] = false
+ end
+ else
+ for i = 2, columns do
+ if self['wrap' .. i] then
+ for j = i+1, columns do
+ self['wrap' .. i] = false
+ end
+ break
+ end
+ end
+ end
+ end
+ if not self.indentation or self.indentation < 0 then
+ self.indentation = 0
+ end
+ if not self.font then
+ self.font = GameTooltipText
+ end
+ for i = 2, columns do
+ if not self['font' .. i] then
+ self['font' .. i] = self.font
+ end
+ end
+ if not self.size then
+ self.size = select(2,self.font:GetFont())
+ end
+ for i = 2, columns do
+ if not self['size' .. i] then
+ self['size' .. i] = select(2,self['font' .. i]:GetFont())
+ end
+ end
+ if self.checkIcon and self.checkIcon:find("^Interface\\Icons\\") then
+ if not self.checkCoordLeft then
+ self.checkCoordLeft = 0.05
+ end
+ if not self.checkCoordRight then
+ self.checkCoordRight = 0.95
+ end
+ if not self.checkCoordTop then
+ self.checkCoordTop = 0.05
+ end
+ if not self.checkCoordBottom then
+ self.checkCoordBottom = 0.95
+ end
+ else
+ if not self.checkCoordLeft then
+ self.checkCoordLeft = 0
+ end
+ if not self.checkCoordRight then
+ self.checkCoordRight = 1
+ end
+ if not self.checkCoordTop then
+ self.checkCoordTop = 0
+ end
+ if not self.checkCoordBottom then
+ self.checkCoordBottom = 1
+ end
+ end
+ if not self.checkColorR then
+ self.checkColorR = 1
+ end
+ if not self.checkColorG then
+ self.checkColorG = 1
+ end
+ if not self.checkColorB then
+ self.checkColorB = 1
+ end
+
+ local fontSizePercent = category.tabletData.tablet.fontSizePercent
+ local w = 0
+ self.checkWidth = 0
+ testString = category.tabletData.tablet.buttons[1].col1
+ if self.text then
+ if not self.wrap then
+ local testWidth = getTestWidth(self.font, self.size * fontSizePercent, self.text)
+ local checkWidth = self.hasCheck and self.size * fontSizePercent or 0
+ self.checkWidth = checkWidth
+ w = testWidth + self.indentation * fontSizePercent + checkWidth
+ if category.superCategory.x1 < w then
+ category.superCategory.x1 = w
+ end
+ else
+ if columns == 1 then
+ local testWidth = getTestWidth(self.font, self.size * fontSizePercent, self.text)
+ local checkWidth = self.hasCheck and self.size * fontSizePercent or 0
+ self.checkWidth = checkWidth
+ w = testWidth + self.indentation * fontSizePercent + checkWidth
+ if w > (MIN_TOOLTIP_SIZE - 20) * fontSizePercent then
+ w = (MIN_TOOLTIP_SIZE - 20) * fontSizePercent
+ end
+ else
+ w = MIN_TOOLTIP_SIZE * fontSizePercent / 2
+ end
+ if category.superCategory.x1 < w then
+ category.superCategory.x1 = w
+ end
+ end
+ end
+ if columns == 2 and self.text2 then
+ if not self.wrap2 then
+ local testWidth = getTestWidth(self.font2, self.size2 * fontSizePercent, self.text2)
+ w = w + 40 * fontSizePercent + testWidth
+ if category.superCategory.x1 < w then
+ category.superCategory.x1 = w
+ end
+ else
+ w = w + 40 * fontSizePercent + MIN_TOOLTIP_SIZE * fontSizePercent / 2
+ if category.superCategory.x1 < w then
+ category.superCategory.x1 = w
+ end
+ end
+ elseif columns >= 3 then
+ if self.text2 then
+ if not self.wrap2 then
+ local testWidth = getTestWidth(self.font2, self.size2 * fontSizePercent, self.text2)
+ local w = testWidth
+ if category.superCategory.x2 < w then
+ category.superCategory.x2 = w
+ end
+ else
+ local w = MIN_TOOLTIP_SIZE / 2
+ if category.superCategory.x2 < w then
+ category.superCategory.x2 = w
+ end
+ end
+ end
+
+ for i = 3, columns do
+ local text = self['text' .. i]
+ if text then
+ local x_i = 'x' .. i
+ if not self['wrap' .. i] then
+ local testWidth = getTestWidth(self['font' .. i], self['size' .. i] * fontSizePercent, text)
+ local w = testWidth
+ if category.superCategory[x_i] < w then
+ category.superCategory[x_i] = w
+ end
+ else
+ local w = MIN_TOOLTIP_SIZE / 2
+ if category.superCategory[x_i] < w then
+ category.superCategory[x_i] = w
+ end
+ end
+ end
+ end
+ end
+ return self
+ end
+ Line.new = wrap(Line.new, "Line:new")
+
+ function Line:del()
+ del(self)
+ end
+ Line.del = wrap(Line.del, "Line:del")
+
+ function Line:Display(tablet)
+ tablet:AddLine(self)
+ return true
+ end
+ Line.Display = wrap(Line.Display, "Line:Display")
+end
+
+local fake_ipairs
+do
+ local function iter(tmp, i)
+ i = i + 1
+ local x = tmp[i]
+ tmp[i] = nil
+ if x then
+ return i, x
+ end
+ end
+
+ local tmp = {}
+ function fake_ipairs(...)
+ for i = 1, select('#', ...) do
+ tmp[i] = select(i, ...)
+ end
+ return iter, tmp, 0
+ end
+ fake_ipairs = wrap(fake_ipairs, "fake_ipairs")
+end
+
+local function argunpack(t, key, i)
+ if not i then
+ i = 1
+ end
+ local k = key .. i
+ local v = t[k]
+ if v then
+ return v, argunpack(t, key, i+1)
+ end
+end
+argunpack = wrap(argunpack, "argunpack")
+
+
+local delstring, newstring
+do
+ local cache = {}
+ function delstring(t)
+ cache[#cache+1] = t
+ t:SetText(nil)
+ t:ClearAllPoints()
+ t:Hide()
+ t:SetParent(UIParent)
+ return nil
+ end
+ delstring = wrap(delstring, "delstring")
+ function newstring(parent)
+ if #cache ~= 0 then
+ local t = cache[#cache]
+ cache[#cache] = nil
+ t:Show()
+ t:SetParent(parent)
+ return t
+ end
+ local t = parent:CreateFontString(nil, "ARTWORK")
+ return t
+ end
+ newstring = wrap(newstring, "newstring")
+end
+
+local function button_OnEnter(this, ...)
+ if type(this.self:GetScript("OnEnter")) == "function" then
+ this.self:GetScript("OnEnter")(this.self, ...)
+ end
+ this.highlight:Show()
+ if this.onEnterFunc then
+ local success, ret = pcall(this.onEnterFunc, argunpack(this, 'onEnterArg'))
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+end
+button_OnEnter = wrap(button_OnEnter, "button_OnEnter")
+
+local function button_OnLeave(this, ...)
+ if type(this.self:GetScript("OnLeave")) == "function" then
+ this.self:GetScript("OnLeave")(this.self, ...)
+ end
+ this.highlight:Hide()
+ if this.onLeaveFunc then
+ local success, ret = pcall(this.onLeaveFunc, argunpack(this, 'onLeaveArg'))
+ if not success then
+ geterrorhandler()(ret)
+ end
+ end
+end
+button_OnLeave = wrap(button_OnLeave, "button_OnLeave")
+local lastMouseDown
+local function button_OnClick(this, arg1, ...)
+ if this.self:HasScript("OnClick") and type(this.self:GetScript("OnClick")) == "function" then
+ this.self:GetScript("OnClick")(this.self, arg1, ...)
+ end
+ if arg1 == "RightButton" then
+ if this.self:HasScript("OnClick") and type(this.self:GetScript("OnClick")) == "function" then
+ this.self:GetScript("OnClick")(this.self, arg1, ...)
+ end
+ elseif arg1 == "LeftButton" then
+ if this.self.preventClick == nil or GetTime() > this.self.preventClick and GetTime() < lastMouseDown + 0.5 then
+ this.self.preventClick = nil
+ this.self.updating = true
+ this.self.preventRefresh = true
+ local success, ret = pcall(this.func, argunpack(this, 'arg'))
+ if not success then
+ geterrorhandler()(ret)
+ end
+ if this.self and this.self.registration then
+ this.self.preventRefresh = false
+ this.self:children()
+ this.self.updating = false
+ end
+ end
+ end
+end
+button_OnClick = wrap(button_OnClick, "button_OnClick")
+local function button_OnMouseUp(this, arg1, ...)
+ if this.self:HasScript("OnMouseUp") and type(this.self:GetScript("OnMouseUp")) == "function" then
+ this.self:GetScript("OnMouseUp")(this.self, arg1, ...)
+ end
+ if arg1 ~= "RightButton" then
+ if this.clicked then
+ local a,b,c,d,e = this.check:GetPoint(1)
+ this.check:SetPoint(a,b,c,d-1,e+1)
+ this.clicked = false
+ end
+ end
+end
+button_OnMouseUp = wrap(button_OnMouseUp, "button_OnMouseUp")
+local function button_OnMouseDown(this, arg1, ...)
+ if this.self:HasScript("OnMouseDown") and type(this.self:GetScript("OnMouseDown")) == "function" then
+ this.self:GetScript("OnMouseDown")(this.self, arg1, ...)
+ end
+ lastMouseDown = GetTime()
+ if arg1 ~= "RightButton" then
+ local a,b,c,d,e = this.check:GetPoint(1)
+ this.check:SetPoint(a,b,c,d+1,e-1)
+ this.clicked = true
+ end
+end
+button_OnMouseDown = wrap(button_OnMouseDown, "button_OnMouseDown")
+local function button_OnDragStart(this, ...)
+ local parent = this:GetParent() and this:GetParent().tablet
+ if parent:GetScript("OnDragStart") then
+ return parent:GetScript("OnDragStart")(parent, ...)
+ end
+end
+button_OnDragStart = wrap(button_OnDragStart, "button_OnDragStart")
+local function button_OnDragStop(this, ...)
+ local parent = this:GetParent() and this:GetParent().tablet
+ if parent:GetScript("OnDragStop") then
+ return parent:GetScript("OnDragStop")(parent, ...)
+ end
+end
+button_OnDragStop = wrap(button_OnDragStop, "button_OnDragStop")
+
+local num_buttons = 0
+local function NewLine(self)
+ if self.maxLines <= self.numLines then
+ self.maxLines = self.maxLines + 1
+ num_buttons = num_buttons + 1
+ local button = CreateFrame("Button", "Tablet20Button" .. num_buttons, self.scrollChild)
+ button:SetFrameLevel(12)
+ button.indentation = 0
+ local check = button:CreateTexture(nil, "ARTWORK")
+ local col1 = newstring(button)
+ testString = col1
+ local highlight = button:CreateTexture(nil, "BACKGROUND")
+ highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
+ button.highlight = highlight
+ highlight:SetBlendMode("ADD")
+ highlight:SetAllPoints(button)
+ highlight:Hide()
+ self.buttons[#self.buttons+1] = button
+ button.check = check
+ button.col1 = col1
+ col1:SetWidth(0)
+ if self.maxLines == 1 then
+ col1:SetFontObject(GameTooltipHeaderText)
+ col1:SetJustifyH("CENTER")
+ button:SetPoint("TOPLEFT", self.scrollFrame, "TOPLEFT", 3, -5)
+ else
+ col1:SetFontObject(GameTooltipText)
+ button:SetPoint("TOPLEFT", self.buttons[self.maxLines - 1], "BOTTOMLEFT", 0, -2)
+ end
+ button:SetScript("OnEnter", button_OnEnter)
+ button:SetScript("OnLeave", button_OnLeave)
+ button.check = check
+ button.self = self
+ button:SetPoint("RIGHT", self.scrollFrame, "RIGHT", -7, 0)
+ check.shown = false
+ check:SetPoint("TOPLEFT", button, "TOPLEFT")
+ col1:SetPoint("TOPLEFT", check, "TOPLEFT")
+ local size = select(2,GameTooltipText:GetFont())
+ check:SetHeight(size * 1.5)
+ check:SetWidth(size * 1.5)
+ check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
+ check:SetAlpha(0)
+ if not button.clicked then
+ button:SetScript("OnMouseWheel", self:GetScript("OnMouseWheel"))
+ button:EnableMouseWheel(true)
+ button:Hide()
+ end
+ check:Show()
+ col1:Hide()
+ end
+end
+NewLine = wrap(NewLine, "NewLine")
+
+local function RecalculateTabletHeight(detached)
+ detached.height_ = nil
+ if detached.registration and detached.registration.positionFunc then
+ local height = detached:GetHeight()
+ if height > 0 then
+ detached.height_ = height
+ else
+ local top, bottom
+ for i = 1, detached:GetNumPoints() do
+ local a,b,c,d,e = detached:GetPoint(i)
+
+ if a:find("^TOP") then
+ if c:find("^TOP") then
+ top = b:GetTop()
+ elseif c:find("^BOTTOM") then
+ top = b:GetBottom()
+ else
+ top = select(2,b:GetCenter())
+ end
+ if top then
+ top = top + e
+ end
+ elseif a:find("^BOTTOM") then
+ if c:find("^TOP") then
+ bottom = b:GetTop()
+ elseif c:find("^BOTTOM") then
+ bottom = b:GetBottom()
+ else
+ bottom = select(2,b:GetCenter())
+ end
+ if bottom then
+ bottom = bottom + e
+ end
+ end
+ end
+ if top and bottom then
+ detached.height_ = top - bottom
+ end
+ end
+ end
+end
+RecalculateTabletHeight = wrap(RecalculateTabletHeight, "RecalculateTabletHeight")
+
+local function GetTooltipHeight(self)
+ RecalculateTabletHeight(self)
+ if self.height_ then
+ local height = self:GetTop() and self:GetBottom() and self:GetTop() - self:GetBottom() or self:GetHeight()
+ if height == 0 then
+ height = self.height_
+ end
+ return height
+ end
+ if self.registration.maxHeight then
+ return self.registration.maxHeight
+ end
+ if self == tooltip then
+ return GetScreenHeight()*3/4
+ else
+ return GetScreenHeight()*2/3
+ end
+end
+GetTooltipHeight = wrap(GetTooltipHeight, "GetTooltipHeight")
+
+local overFrame = nil
+local detachedTooltips = {}
+local AcquireDetachedFrame, ReleaseDetachedFrame
+local function AcquireFrame(self, registration, data, detachedData)
+ if not detachedData then
+ detachedData = data
+ end
+ if tooltip then
+ tooltip.data = data
+ tooltip.detachedData = detachedData
+ local fontSizePercent = tooltip.data and tooltip.data.fontSizePercent or 1
+ local transparency = tooltip.data and tooltip.data.transparency or 0.75
+ local r = tooltip.data and tooltip.data.r or 0
+ local g = tooltip.data and tooltip.data.g or 0
+ local b = tooltip.data and tooltip.data.b or 0
+ tooltip:SetFontSizePercent(fontSizePercent)
+ tooltip:SetTransparency(transparency)
+ tooltip:SetColor(r, g, b)
+ tooltip:SetParent(GetMainFrame())
+ tooltip:SetFrameStrata(registration.strata or "TOOLTIP")
+ tooltip:SetFrameLevel(10)
+ for _,frame in fake_ipairs(tooltip:GetChildren()) do
+ frame:SetFrameLevel(12)
+ end
+ else
+ tooltip = CreateFrame("Frame", "Tablet20Frame", UIParent)
+ tooltip:SetParent(GetMainFrame())
+ self.tooltip = tooltip
+ tooltip.data = data
+ tooltip.detachedData = detachedData
+ tooltip:EnableMouse(true)
+ tooltip:EnableMouseWheel(true)
+ tooltip:SetFrameStrata(registration.strata or "TOOLTIP")
+ tooltip:SetFrameLevel(10)
+ local backdrop = new(
+ 'bgFile', "Interface\\Buttons\\WHITE8X8",
+ 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
+ 'tile', true,
+ 'tileSize', 16,
+ 'edgeSize', 16,
+ 'insets', new(
+ 'left', 5,
+ 'right', 5,
+ 'top', 5,
+ 'bottom', 5
+ )
+ )
+ tooltip:SetBackdrop(backdrop)
+ del(backdrop.insets)
+ del(backdrop)
+ tooltip:SetBackdropColor(0, 0, 0, 1)
+
+ tooltip.numLines = 0
+ tooltip.owner = nil
+ tooltip.fontSizePercent = tooltip.data and tooltip.data.fontSizePercent or 1
+ tooltip.maxLines = 0
+ tooltip.buttons = {}
+ tooltip.transparency = tooltip.data and tooltip.data.transparency or 0.75
+ tooltip:SetBackdropColor(0, 0, 0, tooltip.transparency)
+ tooltip:SetBackdropBorderColor(1, 1, 1, tooltip.transparency)
+
+ tooltip:SetScript("OnUpdate", function(this, elapsed)
+ if not tooltip.updating and (not tooltip.enteredFrame or (overFrame and not MouseIsOver(overFrame))) then
+ tooltip.scrollFrame:SetVerticalScroll(0)
+ tooltip.slider:SetValue(0)
+ tooltip:Hide()
+ tooltip.registration.tooltip = nil
+ tooltip.registration = nil
+ overFrame = nil
+ end
+ end)
+
+ tooltip:SetScript("OnEnter", function(this)
+ if tooltip.clickable then
+ tooltip.enteredFrame = true
+ overFrame = nil
+ end
+ end)
+
+ tooltip:SetScript("OnLeave", function(this)
+ if not tooltip.updating then
+ tooltip.enteredFrame = false
+ end
+ end)
+
+ tooltip:SetScript("OnMouseWheel", function(this, arg1)
+ tooltip.updating = true
+ tooltip:Scroll(arg1 < 0)
+ tooltip.updating = false
+ end)
+
+ local scrollFrame = CreateFrame("ScrollFrame", "Tablet20FrameScrollFrame", tooltip)
+ scrollFrame:SetFrameLevel(11)
+ local scrollChild = CreateFrame("Frame", "Tablet20FrameScrollChild", scrollFrame)
+ scrollChild.tablet = tooltip
+ scrollFrame:SetScrollChild(scrollChild)
+ tooltip.scrollFrame = scrollFrame
+ tooltip.scrollChild = scrollChild
+ scrollFrame:SetPoint("TOPLEFT", 5, -5)
+ scrollFrame:SetPoint("TOPRIGHT", -5, -5)
+ scrollFrame:SetPoint("BOTTOMLEFT", 5, 5)
+ scrollFrame:SetPoint("BOTTOMRIGHT", -5, 5)
+ scrollChild:SetWidth(1)
+ scrollChild:SetHeight(1)
+ local slider = CreateFrame("Slider", "Tablet20FrameSlider", scrollFrame)
+ tooltip.slider = slider
+ slider:SetOrientation("VERTICAL")
+ slider:SetMinMaxValues(0, 1)
+ slider:SetValueStep(0.001)
+ slider:SetValue(0)
+ slider:SetWidth(8)
+ slider:SetPoint("TOPRIGHT", 0, 0)
+ slider:SetPoint("BOTTOMRIGHT", 0, 0)
+ slider:SetBackdrop(new(
+ 'bgFile', "Interface\\Buttons\\UI-SliderBar-Background",
+ 'edgeFile', "Interface\\Buttons\\UI-SliderBar-Border",
+ 'tile', true,
+ 'edgeSize', 8,
+ 'tileSize', 8,
+ 'insets', new(
+ 'left', 3,
+ 'right', 3,
+ 'top', 3,
+ 'bottom', 3
+ )
+ ))
+ slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
+ slider:SetScript("OnEnter", tooltip:GetScript("OnEnter"))
+ slider:SetScript("OnLeave", tooltip:GetScript("OnLeave"))
+ slider.tablet = tooltip
+ slider:SetScript("OnValueChanged", function(this)
+ local max = this.tablet.scrollChild:GetHeight() - this.tablet:GetHeight()
+
+ local val = this:GetValue() * max
+
+ if math.abs(this.tablet.scrollFrame:GetVerticalScroll() - val) < 1 then
+ return
+ end
+
+ this.tablet.scrollFrame:SetVerticalScroll(val)
+ end)
+
+ NewLine(tooltip)
+
+ function tooltip:SetOwner(o)
+ self:Hide(o)
+ self.owner = o
+ end
+ tooltip.SetOwner = wrap(tooltip.SetOwner, "tooltip:SetOwner")
+
+ function tooltip:IsOwned(o)
+ return self.owner == o
+ end
+ tooltip.IsOwned = wrap(tooltip.IsOwned, "tooltip:IsOwned")
+
+ function tooltip:ClearLines(hide)
+ CleanCategoryPool(self)
+ for i = 1, self.numLines do
+ local button = self.buttons[i]
+ local check = button.check
+ if not button.clicked or hide then
+ button:Hide()
+ end
+ check.shown = false
+ check:SetAlpha(0)
+ end
+ self.numLines = 0
+ end
+ tooltip.ClearLines = wrap(tooltip.ClearLines, "tooltip:ClearLines")
+
+ function tooltip:NumLines()
+ return self.numLines
+ end
+
+ local lastWidth
+ local old_tooltip_Hide = tooltip.Hide
+ tooltip.__Hide = old_tooltip_Hide
+ function tooltip:Hide(newOwner)
+ if self == tooltip or newOwner == nil then
+ old_tooltip_Hide(self)
+ end
+ self:ClearLines(true)
+ self.owner = nil
+ self.lastWidth = nil
+ self.tmpHidden = nil
+ end
+ tooltip.Hide = wrap(tooltip.Hide, "tooltip:Hide")
+
+ local old_tooltip_Show = tooltip.Show
+ tooltip.__Show = old_tooltip_Show
+ function tooltip:Show(tabletData)
+ if self.owner == nil or self.notInUse then
+ return
+ end
+ if not self.tmpHidden then
+ old_tooltip_Show(self)
+ end
+
+ testString = self.buttons[1].col1
+
+ local maxWidth = tabletData and tabletData.width or self:GetWidth() - 20
+ local hasWrap = false
+ local numColumns
+
+ local height = 20
+ self:SetWidth(maxWidth + 20)
+
+ for i = 1, self.numLines do
+ local button = self.buttons[i]
+ local col1 = button.col1
+ local col2 = button.col2
+ local check = button.check
+ button:SetWidth(maxWidth)
+ button:SetHeight(col2 and math.max(col1:GetHeight(), col2:GetHeight()) or col1:GetHeight())
+ height = height + button:GetHeight() + 2
+ if i == 1 then
+ button:SetPoint("TOPLEFT", self.scrollChild, "TOPLEFT", 5, -5)
+ else
+ button:SetPoint("TOPLEFT", self.buttons[i - 1], "BOTTOMLEFT", 0, -2)
+ end
+ if button.clicked then
+ check:SetPoint("TOPLEFT", button, "TOPLEFT", button.indentation * self.fontSizePercent + (check.width - check:GetWidth()) / 2 + 1, -1)
+ else
+ check:SetPoint("TOPLEFT", button, "TOPLEFT", button.indentation * self.fontSizePercent + (check.width - check:GetWidth()) / 2, 0)
+ end
+ button:Show()
+ end
+ self.scrollFrame:SetFrameLevel(11)
+ self.scrollChild:SetWidth(maxWidth)
+ self.scrollChild:SetHeight(height)
+ local maxHeight = GetTooltipHeight(self)
+ if height > maxHeight then
+ height = maxHeight
+ self.slider:Show()
+ else
+ self.slider:Hide()
+ end
+ self:SetHeight(height)
+ self.scrollFrame:SetScrollChild(self.scrollChild)
+ local val = self.scrollFrame:GetVerticalScroll()
+ local max = self.scrollChild:GetHeight() - self:GetHeight()
+ if val > max then
+ val = max
+ end
+ if val < 0 then
+ val = 0
+ end
+ self.scrollFrame:SetVerticalScroll(val)
+ self.slider:SetValue(val/max)
+ end
+ tooltip.Show = wrap(tooltip.Show, "tooltip:Show")
+
+ function tooltip:AddLine(info)
+ local category = info.category.superCategory
+ local maxWidth = category.tabletData.width
+ local text = info.blank and "\n" or info.text
+ local id = info.id
+ local func = info.func
+ local checked = info.checked
+ local isRadio = info.isRadio
+ local checkTexture = info.checkTexture
+ local fontSizePercent = self.fontSizePercent
+ if not info.font then
+ info.font = GameTooltipText
+ end
+ if not info.size then
+ info.size = select(2,info.font:GetFont())
+ end
+ local catStart = false
+ local columns = category and category.columns or 1
+ local x_total = 0
+ local x1, x2
+ if category then
+ for i = 1, category.columns do
+ x_total = x_total + category['x' .. i]
+ end
+ x1, x2 = category.x1, category.x2
+ else
+ x1, x2 = 0, 0
+ end
+
+ self.numLines = self.numLines + 1
+ NewLine(self)
+ local num = self.numLines
+
+ local button = self.buttons[num]
+ button:Show()
+ button.col1:Show()
+ button.indentation = info.indentation
+ local col1 = button.col1
+ local check = button.check
+ do -- if columns >= 1 then
+ col1:SetWidth(0)
+ col1:SetFontObject(info.font)
+ local font,_,flags = info.font:GetFont()
+ col1:SetFont(font, info.size * fontSizePercent, flags)
+ col1:SetText(text)
+ col1:SetJustifyH(info.justify)
+ col1:Show()
+
+ if info.textR and info.textG and info.textB then
+ col1:SetTextColor(info.textR, info.textG, info.textB)
+ else
+ col1:SetTextColor(1, 0.823529, 0)
+ end
+ if columns < 2 then
+ local i = 2
+ while true do
+ local col = button['col' .. i]
+ if col then
+ button['col' .. i] = delstring(col)
+ else
+ break
+ end
+ i = i + 1
+ end
+ else
+ local i = 2
+ while true do
+ local col = button['col' .. i]
+ if not col then
+ button['col' .. i] = newstring(button)
+ col = button['col' .. i]
+ end
+ col:SetFontObject(info['font' .. i])
+ col:SetText(info['text' .. i])
+ col:Show()
+ local r,g,b = info['text' .. i .. 'R']
+ if r then
+ g = info['text' .. i .. 'G']
+ if g then
+ b = info['text' .. i .. 'B']
+ end
+ end
+ if b then
+ col:SetTextColor(r, g, b)
+ else
+ col:SetTextColor(1, 0.823529, 0)
+ end
+ local a,_,b = info.font2:GetFont()
+ col:SetFont(a, info['size' .. i] * fontSizePercent, b)
+ col:SetJustifyH(info['justify' .. i])
+ if columns == i then
+ if i == 2 then
+ col:SetPoint("TOPLEFT", col1, "TOPRIGHT", 40 * fontSizePercent, 0)
+ col:SetPoint("TOPRIGHT", button, "TOPRIGHT", -5, 0)
+ else
+ local col2 = button.col2
+ col2:ClearAllPoints()
+ col2:SetPoint("TOPLEFT", col1, "TOPRIGHT", (20 - info.indentation) * fontSizePercent, 0)
+ end
+ i = i + 1
+ while true do
+ local col = button['col' .. i]
+ if col then
+ button['col' .. i] = delstring(col)
+ else
+ break
+ end
+ i = i + 1
+ end
+ break
+ end
+ i = i + 1
+ end
+ end
+ end
+
+ check:SetWidth(info.size * fontSizePercent)
+ check:SetHeight(info.size * fontSizePercent)
+ check.width = info.size * fontSizePercent
+ if info.hasCheck then
+ check.shown = true
+ check:Show()
+ if isRadio then
+ check:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
+ if info.checked then
+ check:SetAlpha(1)
+ check:SetTexCoord(0.25, 0.5, 0, 1)
+ else
+ check:SetAlpha(self.transparency)
+ check:SetTexCoord(0, 0.25, 0, 1)
+ end
+ check:SetVertexColor(1, 1, 1)
+ else
+ if info.checkIcon then
+ check:SetTexture(info.checkIcon)
+ check:SetTexCoord(info.checkCoordLeft, info.checkCoordRight, info.checkCoordTop, info.checkCoordBottom)
+ check:SetVertexColor(info.checkColorR, info.checkColorG, info.checkColorB)
+ else
+ check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
+ check:SetWidth(info.size * fontSizePercent * 1.5)
+ check:SetHeight(info.size * fontSizePercent * 1.5)
+ check.width = info.size * fontSizePercent * 1.2
+ check:SetTexCoord(0, 1, 0, 1)
+ check:SetVertexColor(1, 1, 1)
+ end
+ check:SetAlpha(info.checked and 1 or 0)
+ end
+ col1:SetPoint("TOPLEFT", check, "TOPLEFT", check.width, 0)
+ else
+ col1:SetPoint("TOPLEFT", check, "TOPLEFT")
+ end
+ local col2 = button.col2
+ if columns == 1 then
+ col1:SetWidth(maxWidth)
+ elseif columns == 2 then
+ if info.wrap then
+ col1:SetWidth(maxWidth - col2:GetWidth() - 40 * fontSizePercent)
+ col2:SetWidth(0)
+ elseif info.wrap2 then
+ col1:SetWidth(0)
+ col2:SetWidth(maxWidth - col1:GetWidth() - 40 * fontSizePercent)
+ else
+ col1:SetWidth(0)
+ col2:SetWidth(0)
+ end
+ col2:ClearAllPoints()
+ col2:SetPoint("TOPRIGHT", button, "TOPRIGHT", 0, 0)
+ if not info.text2 then
+ col1:SetJustifyH(info.justify or "LEFT")
+ end
+ else
+ col1:SetWidth(x1 - info.checkWidth)
+ col2:SetWidth(x2)
+ local num = (category.tabletData.width - x_total) / (columns - 1)
+ col2:SetPoint("TOPLEFT", col1, "TOPRIGHT", num - info.indentation * fontSizePercent, 0)
+ local last = col2
+ for i = 3, category.columns do
+ local col = button['col' .. i]
+ col:SetWidth(category['x' .. i])
+ col:SetPoint("TOPLEFT", last, "TOPRIGHT", num, 0)
+ last = col
+ end
+ end
+ button.func = nil
+ button.onEnterFunc = nil
+ button.onLeaveFunc = nil
+ button:SetFrameLevel(12) -- hack suggested on forum. Added 06/17/2007. (hC)
+ if not self.locked or IsAltKeyDown() then
+ local func = info.func
+ if func then
+ if type(func) == "string" then
+ if type(info.arg1) ~= "table" then
+ Tablet:error("Cannot call method " .. info.func .. " on a non-table")
+ end
+ func = info.arg1[func]
+ if type(func) ~= "function" then
+ Tablet:error("Method " .. info.func .. " nonexistant")
+ end
+ else
+ if type(func) ~= "function" then
+ Tablet:error("func must be a function or method")
+ end
+ end
+ button.func = func
+ local i = 1
+ while true do
+ local k = 'arg' .. i
+ if button[k] ~= nil then
+ button[k] = nil
+ else
+ break
+ end
+ i = i + 1
+ end
+ i = 1
+ while true do
+ local k = 'arg' .. i
+ local v = info[k]
+ if v == nil then
+ break
+ end
+ button[k] = v
+ i = i + 1
+ end
+ local onEnterFunc = info.onEnterFunc
+ if onEnterFunc then
+ if type(onEnterFunc) == "string" then
+ if type(info.onEnterArg1) ~= "table" then
+ Tablet:error("Cannot call method " .. info.onEnterFunc .. " on a non-table")
+ end
+ onEventFunc = info.onEnterArg1[onEnterFunc]
+ if type(onEnterFunc) ~= "function" then
+ Tablet:error("Method " .. info.onEnterFunc .. " nonexistant")
+ end
+ else
+ if type(onEnterFunc) ~= "function" then
+ Tablet:error("func must be a function or method")
+ end
+ end
+ button.onEnterFunc = onEnterFunc
+ local i = 1
+ while true do
+ local k = 'onEnterArg' .. i
+ if button[k] ~= nil then
+ button[k] = nil
+ else
+ break
+ end
+ i = i + 1
+ end
+ i = 1
+ while true do
+ local k = 'onEnterArg' .. i
+ local v = info[k]
+ if v == nil then
+ break
+ end
+ button[k] = v
+ i = i + 1
+ end
+ end
+ local onLeaveFunc = info.onLeaveFunc
+ if onLeaveFunc then
+ if type(onLeaveFunc) == "string" then
+ if type(info.onLeaveArg1) ~= "table" then
+ Tablet:error("Cannot call method " .. info.onLeaveFunc .. " on a non-table")
+ end
+ onLeaveFunc = info.onLeaveArg1[onLeaveFunc]
+ if type(onLeaveFunc) ~= "function" then
+ Tablet:error("Method " .. info.onLeaveFunc .. " nonexistant")
+ end
+ else
+ if type(onLeaveFunc) ~= "function" then
+ Tablet:error("func must be a function or method")
+ end
+ end
+ button.onLeaveFunc = onLeaveFunc
+ local i = 1
+ while true do
+ local k = 'onLeaveArg' .. i
+ if button[k] ~= nil then
+ button[k] = nil
+ else
+ break
+ end
+ i = i + 1
+ end
+ i = 1
+ while true do
+ local k = 'onLeaveArg' .. i
+ local v = info[k]
+ if v == nil then
+ break
+ end
+ button[k] = v
+ i = i + 1
+ end
+ end
+ button.self = self
+ button:SetScript("OnMouseUp", button_OnMouseUp)
+ button:SetScript("OnMouseDown", button_OnMouseDown)
+ button:RegisterForDrag("LeftButton")
+ button:SetScript("OnDragStart", button_OnDragStart)
+ button:SetScript("OnDragStop", button_OnDragStop)
+ button:SetScript("OnClick", button_OnClick)
+ if button.clicked then
+ button:SetButtonState("PUSHED")
+ end
+ button:EnableMouse(true)
+ else
+ button:SetScript("OnMouseDown", nil)
+ button:SetScript("OnMouseUp", nil)
+ button:RegisterForDrag()
+ button:SetScript("OnDragStart", nil)
+ button:SetScript("OnDragStop", nil)
+ button:SetScript("OnClick", nil)
+ button:EnableMouse(false)
+ end
+ else
+ button:SetScript("OnMouseDown", nil)
+ button:SetScript("OnMouseUp", nil)
+ button:RegisterForDrag()
+ button:SetScript("OnDragStart", nil)
+ button:SetScript("OnDragStop", nil)
+ button:SetScript("OnClick", nil)
+ button:EnableMouse(false)
+ end
+ end
+ tooltip.AddLine = wrap(tooltip.AddLine, "tooltip:AddLine")
+
+ function tooltip:SetFontSizePercent(percent)
+ local data, detachedData = self.data, self.detachedData
+ if detachedData and detachedData.detached then
+ data = detachedData
+ end
+ local lastSize = self.fontSizePercent
+ percent = tonumber(percent) or 1
+ if percent < 0.25 then
+ percent = 0.25
+ elseif percent > 4 then
+ percent = 4
+ end
+ self.fontSizePercent = percent
+ if data then
+ data.fontSizePercent = percent
+ end
+ local ratio = self.fontSizePercent / lastSize
+ for i = 1, self.numLines do
+ local button = self.buttons[i]
+ local j = 1
+ while true do
+ local col = button['col' .. j]
+ if not col then
+ break
+ end
+ local font, size, flags = col:GetFont()
+ col:SetFont(font, size * ratio, flags)
+ j = j + 1
+ end
+ local check = button.check
+ check.width = check.width * ratio
+ check:SetWidth(check:GetWidth() * ratio)
+ check:SetHeight(check:GetHeight() * ratio)
+ end
+ self:SetWidth((self:GetWidth() - 51) * ratio + 51)
+ self:SetHeight((self:GetHeight() - 51) * ratio + 51)
+ if self:IsShown() and self.children then
+ self:children()
+ self:Show()
+ end
+ end
+ tooltip.SetFontSizePercent = wrap(tooltip.SetFontSizePercent, "tooltip:SetFontSizePercent")
+
+ function tooltip:GetFontSizePercent()
+ return self.fontSizePercent
+ end
+
+ function tooltip:SetTransparency(alpha)
+ local data, detachedData = self.data, self.detachedData
+ if detachedData and detachedData.detached then
+ data = detachedData
+ end
+ self.transparency = alpha
+ if data then
+ data.transparency = alpha ~= 0.75 and alpha or nil
+ end
+ self:SetBackdropColor(self.r or 0, self.g or 0, self.b or 0, alpha)
+ self:SetBackdropBorderColor(1, 1, 1, alpha)
+ self.slider:SetBackdropColor(self.r or 0, self.g or 0, self.b or 0, alpha)
+ self.slider:SetBackdropBorderColor(1, 1, 1, alpha)
+ end
+ tooltip.SetTransparency = wrap(tooltip.SetTransparency, "tooltip:SetTransparency")
+
+ function tooltip:GetTransparency()
+ return self.transparency
+ end
+
+ function tooltip:SetColor(r, g, b)
+ local data, detachedData = self.data, self.detachedData
+ if detachedData and detachedData.detached then
+ data = detachedData
+ end
+ self.r = r
+ self.g = g
+ self.b = b
+ if data then
+ data.r = r ~= 0 and r or nil
+ data.g = g ~= 0 and g or nil
+ data.b = b ~= 0 and b or nil
+ end
+ self:SetBackdropColor(r or 0, g or 0, b or 0, self.transparency)
+ self:SetBackdropBorderColor(1, 1, 1, self.transparency)
+ end
+ tooltip.SetColor = wrap(tooltip.SetColor, "tooltip:SetColor")
+
+ function tooltip:GetColor()
+ return self.r, self.g, self.b
+ end
+
+ function tooltip:Scroll(down)
+ local val
+ local max = self.scrollChild:GetHeight() - self:GetHeight()
+ if down then
+ if IsShiftKeyDown() then
+ val = max
+ else
+ val = self.scrollFrame:GetVerticalScroll() + 36
+ if val > max then
+ val = max
+ end
+ end
+ else
+ if IsShiftKeyDown() then
+ val = 0
+ else
+ val = self.scrollFrame:GetVerticalScroll() - 36
+ if val < 0 then
+ val = 0
+ end
+ end
+ end
+ self.scrollFrame:SetVerticalScroll(val)
+ self.slider:SetValue(val/max)
+ end
+ tooltip.Scroll = wrap(tooltip.Scroll, "tooltip:Scroll")
+
+ function tooltip.Detach(tooltip)
+ local owner = tooltip.owner
+ tooltip:Hide()
+ if not tooltip.detachedData then
+ self:error("You cannot detach if detachedData is not present")
+ end
+ tooltip.detachedData.detached = true
+ local detached = AcquireDetachedFrame(self, tooltip.registration, tooltip.data, tooltip.detachedData)
+
+ detached.menu, tooltip.menu = tooltip.menu, nil
+ detached.runChildren = tooltip.runChildren
+ detached.children = tooltip.children
+ detached.minWidth = tooltip.minWidth
+ tooltip.runChildren = nil
+ tooltip.children = nil
+ tooltip.minWidth = nil
+ detached:SetOwner(owner)
+ detached:children()
+ detached:Show()
+ end
+ tooltip.Detach = wrap(tooltip.Detach, "tooltip:Detach")
+
+ end
+
+ tooltip.registration = registration
+ registration.tooltip = tooltip
+ return tooltip
+end
+AcquireFrame = wrap(AcquireFrame, "AcquireFrame")
+
+function ReleaseDetachedFrame(self, data, detachedData)
+ if not detachedData then
+ detachedData = data
+ end
+ for _, detached in ipairs(detachedTooltips) do
+ if detached.detachedData == detachedData then
+ detached.notInUse = true
+ detached:Hide()
+ detached.registration.tooltip = nil
+ detached.registration = nil
+ detached.detachedData = nil
+ end
+ end
+end
+ReleaseDetachedFrame = wrap(ReleaseDetachedFrame, "ReleaseDetachedFrame")
+
+local StartCheckingAlt, StopCheckingAlt
+do
+ local frame
+ function StartCheckingAlt(func)
+ if not frame then
+ frame = CreateFrame("Frame")
+ frame:SetScript("OnEvent", function(this, _, modifier)
+ if modifier == "LALT" or modifier == "RALT" then
+ this.func()
+ end
+ end)
+ end
+ frame:RegisterEvent("MODIFIER_STATE_CHANGED")
+ frame.func = func
+ end
+ StartCheckingAlt = wrap(StartCheckingAlt, "StartCheckingAlt")
+ function StopCheckingAlt()
+ if frame then
+ frame:UnregisterEvent("MODIFIER_STATE_CHANGED")
+ end
+ end
+ StopCheckingAlt = wrap(StopCheckingAlt, "StopCheckingAlt")
+end
+
+function AcquireDetachedFrame(self, registration, data, detachedData)
+ if not detachedData then
+ detachedData = data
+ end
+ for _, detached in ipairs(detachedTooltips) do
+ if detached.notInUse then
+ detached.data = data
+ detached.detachedData = detachedData
+ detached.notInUse = nil
+ local fontSizePercent = detachedData.fontSizePercent or 1
+ local transparency = detachedData.transparency or 0.75
+ local r = detachedData.r or 0
+ local g = detachedData.g or 0
+ local b = detachedData.b or 0
+ detached:SetFontSizePercent(fontSizePercent)
+ detached:SetTransparency(transparency)
+ detached:SetColor(r, g, b)
+ detached:ClearAllPoints()
+ detached:SetWidth(0)
+ detached:SetHeight(0)
+ if not registration.strata then
+ detached:SetFrameStrata("BACKGROUND")
+ end
+ if not registration.frameLevel then
+ detached:SetFrameLevel(10)
+ for _,frame in fake_ipairs(detached:GetChildren()) do
+ frame:SetFrameLevel(12)
+ end
+ end
+ detached:SetParent(registration.parent or GetMainFrame())
+ if registration.strata then
+ detached:SetFrameStrata(registration.strata)
+ end
+ if registration.frameLevel then
+ detached:SetFrameLevel(registration.frameLevel)
+ for _,frame in fake_ipairs(detached:GetChildren()) do
+ frame:SetFrameLevel(registration.frameLevel+2)
+ end
+ end
+ detached.height_ = nil
+ if registration.positionFunc then
+ registration.positionFunc(detached)
+ RecalculateTabletHeight(detached)
+ else
+ detached:SetPoint(detachedData.anchor or "CENTER", GetMainFrame(), detachedData.anchor or "CENTER", detachedData.offsetx or 0, detachedData.offsety or 0)
+ end
+ detached.registration = registration
+ registration.tooltip = detached
+ if registration.movable == false then
+ detached:RegisterForDrag()
+ else
+ detached:RegisterForDrag("LeftButton")
+ end
+ return detached
+ end
+ end
+
+ if not Dewdrop and AceLibrary:HasInstance("Dewdrop-2.0") then
+ Dewdrop = AceLibrary("Dewdrop-2.0")
+ end
+ StartCheckingAlt(function()
+ for _, detached in ipairs(detachedTooltips) do
+ if detached:IsShown() and detached.locked then
+ detached:EnableMouse(IsAltKeyDown())
+ detached:children()
+ if detached.moving then
+ local a1 = arg1
+ arg1 = "LeftButton"
+ if type(detached:GetScript("OnMouseUp")) == "function" then
+ detached:GetScript("OnMouseUp")(detached, arg1)
+ end
+ arg1 = a1
+ end
+ end
+ end
+ end)
+ if not tooltip then
+ AcquireFrame(self, {})
+ end
+ local detached = CreateFrame("Frame", "Tablet20DetachedFrame" .. (#detachedTooltips + 1), GetMainFrame())
+ detachedTooltips[#detachedTooltips+1] = detached
+ detached.notInUse = true
+ detached:EnableMouse(not data.locked)
+ detached:EnableMouseWheel(true)
+ detached:SetMovable(true)
+ detached:SetPoint(data.anchor or "CENTER", GetMainFrame(), data.anchor or "CENTER", data.offsetx or 0, data.offsety or 0)
+
+ detached.numLines = 0
+ detached.owner = nil
+ detached.fontSizePercent = 1
+ detached.maxLines = 0
+ detached.buttons = {}
+ detached.transparency = 0.75
+ detached.r = 0
+ detached.g = 0
+ detached.b = 0
+ detached:SetFrameStrata(registration and registration.strata or "BACKGROUND")
+ detached:SetBackdrop(tmp.a(
+ 'bgFile', "Interface\\Buttons\\WHITE8X8",
+ 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
+ 'tile', true,
+ 'tileSize', 16,
+ 'edgeSize', 16,
+ 'insets', tmp.b(
+ 'left', 5,
+ 'right', 5,
+ 'top', 5,
+ 'bottom', 5
+ )
+ ))
+ detached.locked = detachedData.locked
+ detached:EnableMouse(not detached.locked)
+
+ local width = GetScreenWidth()
+ local height = GetScreenHeight()
+ if registration and registration.movable == false then
+ detached:RegisterForDrag()
+ else
+ detached:RegisterForDrag("LeftButton")
+ end
+ detached:SetScript("OnDragStart", function(this)
+ detached:StartMoving()
+ detached.moving = true
+ end)
+
+ detached:SetScript("OnDragStop", function(this)
+ detached:StopMovingOrSizing()
+ detached.moving = nil
+ detached:SetClampedToScreen(1)
+ detached:SetClampedToScreen(nil)
+ local anchor
+ local offsetx
+ local offsety
+ if detached:GetTop() + detached:GetBottom() < height then
+ anchor = "BOTTOM"
+ offsety = detached:GetBottom()
+ if offsety < 0 then
+ offsety = 0
+ end
+ if offsety < MainMenuBar:GetTop() and MainMenuBar:IsVisible() then
+ offsety = MainMenuBar:GetTop()
+ end
+ local top = 0
+ if FuBar then
+ for i = 1, FuBar:GetNumPanels() do
+ local panel = FuBar:GetPanel(i)
+ if panel:GetAttachPoint() == "BOTTOM" then
+ if panel.frame:GetTop() > top then
+ top = panel.frame:GetTop()
+ break
+ end
+ end
+ end
+ end
+ if offsety < top then
+ offsety = top
+ end
+ else
+ anchor = "TOP"
+ offsety = detached:GetTop() - height
+ if offsety > 0 then
+ offsety = 0
+ end
+ local bottom = GetScreenHeight()
+ if FuBar then
+ for i = 1, FuBar:GetNumPanels() do
+ local panel = FuBar:GetPanel(i)
+ if panel:GetAttachPoint() == "TOP" then
+ if panel.frame:GetBottom() < bottom then
+ bottom = panel.frame:GetBottom()
+ break
+ end
+ end
+ end
+ end
+ bottom = bottom - GetScreenHeight()
+ if offsety > bottom then
+ offsety = bottom
+ end
+ end
+ if detached:GetLeft() + detached:GetRight() < width * 2 / 3 then
+ anchor = anchor .. "LEFT"
+ offsetx = detached:GetLeft()
+ if offsetx < 0 then
+ offsetx = 0
+ end
+ elseif detached:GetLeft() + detached:GetRight() < width * 4 / 3 then
+ if anchor == "" then
+ anchor = "CENTER"
+ end
+ offsetx = (detached:GetLeft() + detached:GetRight() - GetScreenWidth()) / 2
+ else
+ anchor = anchor .. "RIGHT"
+ offsetx = detached:GetRight() - width
+ if offsetx > 0 then
+ offsetx = 0
+ end
+ end
+ detached:ClearAllPoints()
+ detached:SetPoint(anchor, GetMainFrame(), anchor, offsetx, offsety)
+ local t = detached.detachedData
+ if t.anchor ~= anchor or math.abs(t.offsetx - offsetx) > 8 or math.abs(t.offsety - offsety) > 8 then
+ detached.preventClick = GetTime() + 0.05
+ end
+ t.anchor = anchor
+ t.offsetx = offsetx
+ t.offsety = offsety
+ detached:Show()
+ end)
+
+ if Dewdrop then
+ Dewdrop:Register(detached,
+ 'children', function(level, value)
+ if not detached.registration then
+ return
+ end
+ if detached.menu then
+ if type(detached.menu) == "function" then
+ detached.menu(level, value)
+ else
+ Dewdrop:FeedAceOptionsTable(detached.menu)
+ end
+ if level == 1 then
+ Dewdrop:AddLine()
+ end
+ end
+ if level == 1 then
+ if not detached.registration.cantAttach then
+ Dewdrop:AddLine(
+ 'text', DETACH,
+ 'tooltipTitle', DETACH,
+ 'tooltipText', DETACH_DESC,
+ 'checked', true,
+ 'arg1', detached,
+ 'func', "Attach",
+ 'closeWhenClicked', true
+ )
+ end
+ if not detached.registration.positionFunc then
+ Dewdrop:AddLine(
+ 'text', LOCK,
+ 'tooltipTitle', LOCK,
+ 'tooltipText', LOCK_DESC,
+ 'checked', detached:IsLocked(),
+ 'arg1', detached,
+ 'func', "Lock",
+ 'closeWhenClicked', not detached:IsLocked()
+ )
+ end
+ Dewdrop:AddLine(
+ 'text', COLOR,
+ 'tooltipTitle', COLOR,
+ 'tooltipText', COLOR_DESC,
+ 'hasColorSwatch', true,
+ 'r', detached.r,
+ 'g', detached.g,
+ 'b', detached.b,
+ 'hasOpacity', true,
+ 'opacity', detached.transparency,
+ 'colorFunc', function(r, g, b, a)
+ detached:SetColor(r, g, b)
+ detached:SetTransparency(a)
+ end
+ )
+ Dewdrop:AddLine(
+ 'text', SIZE,
+ 'tooltipTitle', SIZE,
+ 'tooltipText', SIZE_DESC,
+ 'hasArrow', true,
+ 'hasSlider', true,
+ 'sliderFunc', function(value)
+ detached:SetFontSizePercent(value)
+ end,
+ 'sliderMax', 2,
+ 'sliderMin', 0.5,
+ 'sliderStep', 0.05,
+ 'sliderIsPercent', true,
+ 'sliderValue', detached:GetFontSizePercent()
+ )
+ Dewdrop:AddLine(
+ 'text', CLOSE_MENU,
+ 'tooltipTitle', CLOSE_MENU,
+ 'tooltipText', CLOSE_MENU_DESC,
+ 'func', function()
+ Dewdrop:Close()
+ end
+ )
+ end
+ end,
+ 'point', function()
+ local x, y = detached:GetCenter()
+ if x < GetScreenWidth() / 2 then
+ if y < GetScreenHeight() / 2 then
+ return "BOTTOMLEFT", "BOTTOMRIGHT"
+ else
+ return "TOPLEFT", "TOPRIGHT"
+ end
+ else
+ if y < GetScreenHeight() / 2 then
+ return "BOTTOMRIGHT", "BOTTOMLEFT"
+ else
+ return "TOPRIGHT", "TOPLEFT"
+ end
+ end
+ end
+ )
+ end
+
+ local scrollFrame = CreateFrame("ScrollFrame", detached:GetName() .. "ScrollFrame", detached)
+ local scrollChild = CreateFrame("Frame", detached:GetName() .. "ScrollChild", scrollFrame)
+ scrollFrame:SetFrameLevel(11)
+ scrollFrame:SetScrollChild(scrollChild)
+ scrollChild.tablet = detached
+ detached.scrollFrame = scrollFrame
+ detached.scrollChild = scrollChild
+ scrollFrame:SetPoint("TOPLEFT", 5, -5)
+ scrollFrame:SetPoint("BOTTOMRIGHT", -5, 5)
+ scrollChild:SetWidth(1)
+ scrollChild:SetHeight(1)
+ local slider = CreateFrame("Slider", detached:GetName() .. "Slider", scrollFrame)
+ detached.slider = slider
+ slider:SetOrientation("VERTICAL")
+ slider:SetMinMaxValues(0, 1)
+ slider:SetValueStep(0.001)
+ slider:SetValue(0)
+ slider:SetWidth(8)
+ slider:SetPoint("TOPRIGHT", 0, 0)
+ slider:SetPoint("BOTTOMRIGHT", 0, 0)
+ slider:SetBackdrop(new(
+ 'bgFile', "Interface\\Buttons\\UI-SliderBar-Background",
+ 'edgeFile', "Interface\\Buttons\\UI-SliderBar-Border",
+ 'tile', true,
+ 'edgeSize', 8,
+ 'tileSize', 8,
+ 'insets', new(
+ 'left', 3,
+ 'right', 3,
+ 'top', 3,
+ 'bottom', 3
+ )
+ ))
+ slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
+ slider:SetScript("OnEnter", detached:GetScript("OnEnter"))
+ slider:SetScript("OnLeave", detached:GetScript("OnLeave"))
+ slider.tablet = detached
+ slider:SetScript("OnValueChanged", Tablet20FrameSlider:GetScript("OnValueChanged"))
+
+ NewLine(detached)
+
+ detached:SetScript("OnMouseWheel", function(this, arg1)
+ detached:Scroll(arg1 < 0)
+ end)
+
+ detached.SetTransparency = tooltip.SetTransparency
+ detached.GetTransparency = tooltip.GetTransparency
+ detached.SetColor = tooltip.SetColor
+ detached.GetColor = tooltip.GetColor
+ detached.SetFontSizePercent = tooltip.SetFontSizePercent
+ detached.GetFontSizePercent = tooltip.GetFontSizePercent
+ detached.SetOwner = tooltip.SetOwner
+ detached.IsOwned = tooltip.IsOwned
+ detached.ClearLines = tooltip.ClearLines
+ detached.NumLines = tooltip.NumLines
+ detached.__Hide = detached.Hide
+ detached.__Show = detached.Show
+ detached.Hide = tooltip.Hide
+ detached.Show = tooltip.Show
+ local old_IsShown = detached.IsShown
+ function detached:IsShown()
+ if self.tmpHidden then
+ return true
+ else
+ return old_IsShown(self)
+ end
+ end
+ detached.AddLine = tooltip.AddLine
+ detached.Scroll = tooltip.Scroll
+ function detached:IsLocked()
+ return self.locked
+ end
+ function detached:Lock()
+ self:EnableMouse(self.locked)
+ self.locked = not self.locked
+ if self.detachedData then
+ self.detachedData.locked = self.locked or nil
+ end
+ self:children()
+ end
+
+ function detached.Attach(detached)
+ if not detached then
+ self:error("Detached tooltip not given.")
+ end
+ if not detached.AddLine then
+ self:error("detached argument not a Tooltip.")
+ end
+ if not detached.owner then
+ self:error("Detached tooltip has no owner.")
+ end
+ if detached.notInUse then
+ self:error("Detached tooltip not in use.")
+ end
+ detached.menu = nil
+ detached.detachedData.detached = nil
+ detached:SetOwner(nil)
+ detached.notInUse = true
+ end
+
+ return AcquireDetachedFrame(self, registration, data, detachedData)
+end
+AcquireDetachedFrame = wrap(AcquireDetachedFrame, "AcquireDetachedFrame")
+
+function Tablet:Close(parent)
+ if not parent then
+ if tooltip and tooltip:IsShown() then
+ tooltip:Hide()
+ tooltip.registration.tooltip = nil
+ tooltip.registration = nil
+ tooltip.enteredFrame = false
+ end
+ return
+ else
+ self:argCheck(parent, 2, "table", "string")
+ end
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot close a tablet with an unregistered parent frame.")
+ end
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData and detachedData.detached then
+ ReleaseDetachedFrame(self, data, detachedData)
+ elseif tooltip and tooltip.data == data then
+ tooltip:Hide()
+ if tooltip.registration then
+ tooltip.registration.tooltip = nil
+ tooltip.registration = nil
+ end
+ end
+ if tooltip then tooltip.enteredFrame = false end
+end
+Tablet.Close = wrap(Tablet.Close, "Tablet:Close")
+
+local function frame_children(self)
+ if not self.preventRefresh and self:GetParent() and self:GetParent():IsShown() then
+ Tablet.currentFrame = self
+ Tablet.currentTabletData = TabletData:new(self)
+ Tablet.currentTabletData.minWidth = self.minWidth
+ self:ClearLines()
+ if self.runChildren then
+ self.runChildren()
+ end
+ Tablet.currentTabletData:Display(Tablet.currentFrame)
+ self:Show(Tablet.currentTabletData)
+ Tablet.currentTabletData:del()
+ Tablet.currentTabletData = nil
+ Tablet.currentFrame = nil
+ end
+end
+frame_children = wrap(frame_children, "frame_children")
+
+function Tablet:Open(fakeParent, parent)
+ self:argCheck(fakeParent, 2, "table", "string")
+ self:argCheck(parent, 3, "nil", "table", "string")
+ if not parent then
+ parent = fakeParent
+ end
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot open a tablet with an unregistered parent frame.")
+ end
+ local detachedData = info.detachedData
+ if detachedData then
+ for _, detached in ipairs(detachedTooltips) do
+ if not detached.notInUse and detached.detachedData == detachedData then
+ return
+ end
+ end
+ end
+ local data = info.data
+ local children = info.children
+ if not children then
+ return
+ end
+ local frame = AcquireFrame(self, info, data, detachedData)
+ frame.clickable = info.clickable
+ frame.menu = info.menu
+ frame.runChildren = info.children
+ frame.minWidth = info.minWidth
+ if not frame.children or not frame.childrenVer or frame.childrenVer < MINOR_VERSION then
+ frame.childrenVer = MINOR_VERSION
+ frame.children = frame_children
+ end
+ frame:SetOwner(fakeParent)
+ frame:children()
+ local point = info.point
+ local relativePoint = info.relativePoint
+ if type(point) == "function" then
+ local b
+ point, b = point(fakeParent)
+ if b then
+ relativePoint = b
+ end
+ end
+ if type(relativePoint) == "function" then
+ relativePoint = relativePoint(fakeParent)
+ end
+ if not point then
+ point = "CENTER"
+ end
+ if not relativePoint then
+ relativePoint = point
+ end
+ frame:ClearAllPoints()
+ if type(parent) ~= "string" then
+ frame:SetPoint(point, fakeParent, relativePoint)
+ end
+ local offsetx = 0
+ local offsety = 0
+ frame:SetClampedToScreen(1)
+ frame:SetClampedToScreen(nil)
+ if frame:GetBottom() and frame:GetLeft() then
+ if frame:GetRight() > GetScreenWidth() then
+ offsetx = frame:GetRight() - GetScreenWidth()
+ elseif frame:GetLeft() < 0 then
+ offsetx = -frame:GetLeft()
+ end
+ local ratio = GetScreenWidth() / GetScreenHeight()
+ if ratio >= 2.4 and frame:GetRight() > GetScreenWidth() / 2 and frame:GetLeft() < GetScreenWidth() / 2 then
+ if frame:GetCenter() < GetScreenWidth() / 2 then
+ offsetx = frame:GetRight() - GetScreenWidth() / 2
+ else
+ offsetx = frame:GetLeft() - GetScreenWidth() / 2
+ end
+ end
+ if frame:GetBottom() < 0 then
+ offsety = frame:GetBottom()
+ elseif frame:GetTop() and frame:GetTop() > GetScreenHeight() then
+ offsety = frame:GetTop() - GetScreenHeight()
+ end
+ if MainMenuBar:IsVisible() and frame:GetBottom() < MainMenuBar:GetTop() and offsety < frame:GetBottom() - MainMenuBar:GetTop() then
+ offsety = frame:GetBottom() - MainMenuBar:GetTop()
+ end
+
+ if FuBar then
+ local top = 0
+ if FuBar then
+ for i = 1, FuBar:GetNumPanels() do
+ local panel = FuBar:GetPanel(i)
+ if panel:GetAttachPoint() == "BOTTOM" then
+ if panel.frame:GetTop() and panel.frame:GetTop() > top then
+ top = panel.frame:GetTop()
+ break
+ end
+ end
+ end
+ end
+ if frame:GetBottom() < top and offsety < frame:GetBottom() - top then
+ offsety = frame:GetBottom() - top
+ end
+ local bottom = GetScreenHeight()
+ if FuBar then
+ for i = 1, FuBar:GetNumPanels() do
+ local panel = FuBar:GetPanel(i)
+ if panel:GetAttachPoint() == "TOP" then
+ if panel.frame:GetBottom() and panel.frame:GetBottom() < bottom then
+ bottom = panel.frame:GetBottom()
+ break
+ end
+ end
+ end
+ end
+ if frame:GetTop() > bottom and offsety < frame:GetTop() - bottom then
+ offsety = frame:GetTop() - bottom
+ end
+ end
+ end
+ if type(fakeParent) ~= "string" then
+ frame:SetPoint(point, fakeParent, relativePoint, -offsetx, -offsety)
+ end
+
+ if detachedData and (info.cantAttach or detachedData.detached) and frame == tooltip then
+ detachedData.detached = false
+ frame:Detach()
+ end
+ if (not detachedData or not detachedData.detached) and GetMouseFocus() == fakeParent then
+ self.tooltip.enteredFrame = true
+ end
+ overFrame = type(fakeParent) == "table" and MouseIsOver(fakeParent) and fakeParent
+end
+Tablet.Open = wrap(Tablet.Open, "Tablet:Open")
+
+function Tablet:Register(parent, ...)
+ self:argCheck(parent, 2, "table", "string")
+ if self.registry[parent] then
+ self:Unregister(parent)
+ end
+ local info
+ local k1 = ...
+ if type(k1) == "table" and k1[0] then
+ if type(self.registry[k1]) ~= "table" then
+ self:error("Other parent not registered")
+ end
+ info = copy(self.registry[k1])
+ local v1 = select(2, ...)
+ if type(v1) == "function" then
+ info.point = v1
+ info.relativePoint = nil
+ end
+ else
+ info = new(...)
+ end
+ self.registry[parent] = info
+ info.data = info.data or info.detachedData or new()
+ info.detachedData = info.detachedData or info.data
+ local data = info.data
+ local detachedData = info.detachedData
+ if not self.onceRegistered[parent] and type(parent) == "table" and type(parent.SetScript) == "function" and not info.dontHook then
+ if not Dewdrop and AceLibrary:HasInstance("Dewdrop-2.0") then
+ Dewdrop = AceLibrary("Dewdrop-2.0")
+ end
+ local script = parent:GetScript("OnEnter")
+ parent:SetScript("OnEnter", function(...)
+ if script then
+ script(...)
+ end
+ if self.registry[parent] then
+ if (not data or not detachedData.detached) and (Dewdrop and not Dewdrop:IsOpen(parent)) then
+ self:Open(parent)
+ end
+ end
+ end)
+ if parent:HasScript("OnMouseDown") then
+ local script = parent:GetScript("OnMouseDown")
+ parent:SetScript("OnMouseDown", function(...)
+ if script then
+ script(...)
+ end
+ if self.registry[parent] and self.registry[parent].tooltip and self.registry[parent].tooltip == self.tooltip then
+ self.tooltip:Hide()
+ end
+ end)
+ end
+ if parent:HasScript("OnMouseWheel") then
+ local script = parent:GetScript("OnMouseWheel")
+ parent:SetScript("OnMouseWheel", function(...)
+ if script then
+ script(...)
+ end
+ if self.registry[parent] and self.registry[parent].tooltip then
+ self.registry[parent].tooltip:Scroll(arg1 < 0)
+ end
+ end)
+ end
+ end
+ self.onceRegistered[parent] = true
+ if GetMouseFocus() == parent then
+ self:Open(parent)
+ end
+end
+Tablet.Register = wrap(Tablet.Register, "Tablet:Register")
+
+function Tablet:Unregister(parent)
+ self:argCheck(parent, 2, "table", "string")
+ if not self.registry[parent] then
+ self:error("You cannot unregister a parent frame if it has not been registered already.")
+ end
+ self.registry[parent] = nil
+end
+Tablet.Unregister = wrap(Tablet.Unregister, "Tablet:Unregister")
+
+function Tablet:IsRegistered(parent)
+ self:argCheck(parent, 2, "table", "string")
+ return self.registry[parent] and true
+end
+Tablet.IsRegistered = wrap(Tablet.IsRegistered, "Tablet:IsRegistered")
+
+local _id = 0
+local addedCategory
+local depth = 0
+local categoryPool = {}
+function CleanCategoryPool(self)
+ for k,v in pairs(categoryPool) do
+ del(v)
+ categoryPool[k] = nil
+ end
+ _id = 0
+end
+CleanCategoryPool = wrap(CleanCategoryPool, "CleanCategoryPool")
+
+function Tablet:AddCategory(...)
+ if not self.currentFrame then
+ self:error("You must add categories in within a registration.")
+ end
+ local info = new(...)
+ local cat = self.currentTabletData:AddCategory(info)
+ info = del(info)
+ return cat
+end
+Tablet.AddCategory = wrap(Tablet.AddCategory, "Tablet:AddCategory")
+
+function Tablet:SetHint(text)
+ if not self.currentFrame then
+ self:error("You must set hint within a registration.")
+ end
+ self.currentTabletData:SetHint(text)
+end
+Tablet.SetHint = wrap(Tablet.SetHint, "Tablet:SetHint")
+
+function Tablet:SetTitle(text)
+ if not self.currentFrame then
+ self:error("You must set title within a registration.")
+ end
+ self.currentTabletData:SetTitle(text)
+end
+Tablet.SetTitle = wrap(Tablet.SetTitle, "Tablet:SetTitle")
+
+function Tablet:SetTitleColor(r, g, b)
+ if not self.currentFrame then
+ self:error("You must set title color within a registration.")
+ end
+ self:argCheck(r, 2, "number")
+ self:argCheck(g, 3, "number")
+ self:argCheck(b, 4, "number")
+ self.currentTabletData:SetTitleColor(r, g, b)
+end
+Tablet.SetTitleColor = wrap(Tablet.SetTitleColor, "Tablet:SetTitleColor")
+
+function Tablet:GetNormalFontSize()
+ return normalSize
+end
+Tablet.GetNormalFontSize = wrap(Tablet.GetNormalFontSize, "Tablet:GetNormalFontSize")
+
+function Tablet:GetHeaderFontSize()
+ return headerSize
+end
+Tablet.GetHeaderFontSize = wrap(Tablet.GetHeaderFontSize, "Tablet:GetHeaderFontSize")
+
+function Tablet:GetNormalFontObject()
+ return GameTooltipText
+end
+Tablet.GetNormalFontObject = wrap(Tablet.GetNormalFontObject, "Tablet:GetNormalFontObject")
+
+function Tablet:GetHeaderFontObject()
+ return GameTooltipHeaderText
+end
+Tablet.GetHeaderFontObject = wrap(Tablet.GetHeaderFontObject, "Tablet:GetHeaderFontObject")
+
+function Tablet:SetFontSizePercent(parent, percent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ if info.tooltip then
+ info.tooltip:SetFontSizePercent(percent)
+ else
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ detachedData.fontSizePercent = percent
+ else
+ data.fontSizePercent = percent
+ end
+ end
+ elseif type(parent) == "table" then
+ parent.fontSizePercent = percent
+ else
+ self:error("You cannot change font size with an unregistered parent frame.")
+ end
+end
+Tablet.SetFontSizePercent = wrap(Tablet.SetFontSizePercent, "Tablet:SetFontSizePercent")
+
+function Tablet:GetFontSizePercent(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ return detachedData.fontSizePercent or 1
+ else
+ return data.fontSizePercent or 1
+ end
+ elseif type(parent) == "table" then
+ return parent.fontSizePercent or 1
+ else
+ self:error("You cannot check font size with an unregistered parent frame.")
+ end
+end
+Tablet.GetFontSizePercent = wrap(Tablet.GetFontSizePercent, "Tablet:GetFontSizePercent")
+
+function Tablet:SetTransparency(parent, percent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ if info.tooltip then
+ info.tooltip:SetTransparency(percent)
+ else
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ detachedData.transparency = percent
+ elseif data then
+ data.transparency = percent
+ end
+ end
+ elseif type(parent) == "table" then
+ parent.transparency = percent
+ else
+ self:error("You cannot change transparency with an unregistered parent frame.")
+ end
+end
+Tablet.SetTransparency = wrap(Tablet.SetTransparency, "Tablet:SetTransparency")
+
+function Tablet:GetTransparency(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ return detachedData.transparency or 0.75
+ else
+ return data.transparency or 0.75
+ end
+ elseif type(parent) == "table" then
+ return parent.transparency or 0.75
+ else
+ self:error("You cannot get transparency with an unregistered parent frame.")
+ end
+end
+Tablet.GetTransparency = wrap(Tablet.GetTransparency, "Tablet:GetTransparency")
+
+function Tablet:SetColor(parent, r, g, b)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ if info.tooltip then
+ info.tooltip:SetColor(r, g, b)
+ else
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ detachedData.r = r
+ detachedData.g = g
+ detachedData.b = b
+ else
+ data.r = r
+ data.g = g
+ data.b = b
+ end
+ end
+ elseif type(parent) == "table" then
+ parent.r = r
+ parent.g = g
+ parent.b = b
+ else
+ self:error("You cannot change color with an unregistered parent frame.")
+ end
+end
+Tablet.SetColor = wrap(Tablet.SetColor, "Tablet:SetColor")
+
+function Tablet:GetColor(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if info then
+ local data = info.data
+ local detachedData = info.detachedData
+ if detachedData.detached then
+ return detachedData.r or 0, detachedData.g or 0, detachedData.b or 0
+ else
+ return data.r or 0, data.g or 0, data.b or 0
+ end
+ elseif type(parent) == "table" then
+ return parent.r or 0, parent.g or 0, parent.b or 0
+ else
+ self:error("You must provide a registered parent frame to check color")
+ end
+end
+Tablet.GetColor = wrap(Tablet.GetColor, "Tablet:GetColor")
+
+function Tablet:Detach(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot detach tablet with an unregistered parent frame.")
+ end
+ if not info.detachedData then
+ self:error("You cannot detach tablet without a data field.")
+ end
+ if info.tooltip and info.tooltip == tooltip and tooltip.registration then
+ tooltip:Detach()
+ else
+ info.detachedData.detached = true
+ local detached = AcquireDetachedFrame(self, info, info.data, info.detachedData)
+
+ detached.menu = info.menu
+ detached.runChildren = info.children
+ detached.minWidth = info.minWidth
+ if not detached.children or not detached.childrenVer or detached.childrenVer < MINOR_VERSION then
+ detached.childrenVer = MINOR_VERSION
+ detached.children = frame_children
+ end
+ detached:SetOwner(parent)
+ detached:children()
+ end
+end
+Tablet.Detach = wrap(Tablet.Detach, "Tablet:Detach")
+
+function Tablet:Attach(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot detach tablet with an unregistered parent frame.")
+ end
+ if not info.detachedData then
+ self:error("You cannot attach tablet without a data field.")
+ end
+ if info.tooltip and info.tooltip ~= tooltip then
+ info.tooltip:Attach()
+ else
+ info.detachedData.detached = false
+ end
+end
+Tablet.Attach = wrap(Tablet.Attach, "Tablet:Attach")
+
+function Tablet:IsAttached(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot check tablet with an unregistered parent frame.")
+ end
+ return not info.detachedData or not info.detachedData.detached
+end
+Tablet.IsAttached = wrap(Tablet.IsAttached, "Tablet:IsAttached")
+
+function Tablet:Refresh(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot refresh tablet with an unregistered parent frame.")
+ end
+ local tt = info.tooltip
+ if tt and not tt.preventRefresh and tt:IsShown() then
+ tt.updating = true
+ tt:children()
+ tt.updating = false
+ end
+end
+Tablet.Refresh = wrap(Tablet.Refresh, "Tablet:Refresh")
+
+function Tablet:IsLocked(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot check tablet with an unregistered parent frame.")
+ end
+ return info.detachedData and info.detachedData.locked
+end
+Tablet.IsLocked = wrap(Tablet.IsLocked, "Tablet:IsLocked")
+
+function Tablet:ToggleLocked(parent)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot lock tablet with an unregistered parent frame.")
+ end
+ if info.tooltip and info.tooltip ~= tooltip then
+ info.tooltip:Lock()
+ elseif info.detachedData then
+ info.detachedData.locked = info.detachedData.locked
+ end
+end
+Tablet.ToggleLocked = wrap(Tablet.ToggleLocked, "Tablet:ToggleLocked")
+
+function Tablet:UpdateDetachedData(parent, detachedData)
+ self:argCheck(parent, 2, "table", "string")
+ local info = self.registry[parent]
+ if not info then
+ self:error("You cannot update tablet with an unregistered parent frame.")
+ end
+ self:argCheck(detachedData, 3, "table")
+ if info.data == info.detachedData then
+ info.data = detachedData
+ end
+ info.detachedData = detachedData
+ if info.detachedData.detached then
+ self:Detach(parent)
+ elseif info.tooltip and info.tooltip.owner then
+ self:Attach(parent)
+ end
+end
+Tablet.UpdateDetachedData = wrap(Tablet.UpdateDetachedData, "Tablet:UpdateDetachedData")
+
+if DEBUG then
+ function Tablet:ListProfileInfo()
+ local duration, times, memories = GetProfileInfo()
+ if not duration or not time or not memories then
+ self:error("Problems")
+ end
+ local t = new()
+ for method in pairs(memories) do
+ t[#t+1] = method
+ end
+ table.sort(t, function(alpha, bravo)
+ if memories[alpha] ~= memories[bravo] then
+ return memories[alpha] < memories[bravo]
+ elseif times[alpha] ~= times[bravo] then
+ return times[alpha] < times[bravo]
+ else
+ return alpha < bravo
+ end
+ end)
+ local memory = 0
+ local time = 0
+ for _,method in ipairs(t) do
+ DEFAULT_CHAT_FRAME:AddMessage(format("%s || %.3f s || %.3f%% || %d KiB", method, times[method], times[method] / duration * 100, memories[method]))
+ memory = memory + memories[method]
+ time = time + times[method]
+ end
+ DEFAULT_CHAT_FRAME:AddMessage(format("%s || %.3f s || %.3f%% || %d KiB", "Total", time, time / duration * 100, memory))
+ del(t)
+ end
+ SLASH_TABLET1 = "/tablet"
+ SLASH_TABLET2 = "/tabletlib"
+ SlashCmdList["TABLET"] = function(msg)
+ AceLibrary(MAJOR_VERSION):ListProfileInfo()
+ end
+end
+
+local function activate(self, oldLib, oldDeactivate)
+ Tablet = self
+ if oldLib then
+ self.registry = oldLib.registry
+ self.onceRegistered = oldLib.onceRegistered
+ self.tooltip = oldLib.tooltip
+ self.currentFrame = oldLib.currentFrame
+ self.currentTabletData = oldLib.currentTabletData
+ else
+ self.registry = {}
+ self.onceRegistered = {}
+ end
+
+ tooltip = self.tooltip
+
+ if oldDeactivate then
+ oldDeactivate(oldLib)
+ end
+end
+
+local function deactivate(self)
+ StopCheckingAlt()
+end
+
+AceLibrary:Register(Tablet, MAJOR_VERSION, MINOR_VERSION, activate, deactivate)