WoWInterface SVN Accountant

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 9 to Rev 8
    Reverse comparison

Rev 9 → Rev 8

trunk/AccountantData.lua
36,5 → 36,4
SC.GOLD_COLOR = "|cFFFFFF00"
SC.GREEN_COLOR = GREEN_FONT_COLOR_CODE
SC.TITLE = "Accountant"
SC.DIVIDER = "-"
 
\ No newline at end of file
trunk/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua
1,38 → 1,30
--- 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".
--- AceConfigRegistry-3.0 handles central registration of options tables in use by addons and modules.
-- Options tables can be registered as raw tables, or as function refs that return a table.<br>
-- These functions receive two arguments: "uiType" and "uiName". <br>
-- Valid "uiTypes": "cmd", "dropdown", "dialog". This is verified by the library at call time. <br>
-- The "uiName" field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.<br>
-- :IterateOptionsTables() and :GetOptionsTable() always return a function reference that the requesting config handling addon must call with the above arguments.
-- @class file
-- @name AceConfigRegistry-3.0
-- @release $Id: AceConfigRegistry-3.0.lua 890 2009-12-06 12:50:05Z nevcairiel $
local MAJOR, MINOR = "AceConfigRegistry-3.0", 11
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
-- @release $Id: AceConfigRegistry-3.0.lua 710 2008-12-19 10:14:39Z nevcairiel $
local MAJOR, MINOR = "AceConfigRegistry-3.0", 6
local lib = LibStub:NewLibrary(MAJOR, MINOR)
 
if not AceConfigRegistry then return end
if not lib then return end
 
AceConfigRegistry.tables = AceConfigRegistry.tables or {}
lib.tables = lib.tables or {}
 
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
 
if not AceConfigRegistry.callbacks then
AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
if not lib.callbacks then
lib.callbacks = CallbackHandler:New(lib)
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 = {
lib.validated = {
-- list of options table names ran through :ValidateOptionsTable automatically.
-- CLEARED ON PURPOSE, since newer versions may have newer validators
cmd = {},
47,7 → 39,7
for i=select("#",...),1,-1 do
tinsert(t, (select(i, ...)))
end
error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2)
error(MAJOR..":ValidateOptionsTable(): "..table.concat(t,".")..msg, errlvl+2)
end
 
 
71,7 → 63,6
type=isstring,
name=isstringfunc,
desc=optstringfunc,
descStyle=optstring,
order=optmethodnumber,
validate=optmethodfalse,
confirm=optmethodbool,
99,7 → 90,6
imageCoords=optmethodtable,
imageHeight=optnumber,
imageWidth=optnumber,
fontSize=optstringfunc,
},
group={
args=istable,
112,10 → 102,11
childGroups=optstring,
},
execute={
image=optstringfunc,
imageCoords=optmethodtable,
imageHeight=optnumber,
imageWidth=optnumber,
-- func={
-- ["function"]=true,
-- ["string"]=true,
-- _="methodname or funcref"
-- },
},
input={
pattern=optstring,
127,8 → 118,6
},
toggle={
tristate=optbool,
image=optstringfunc,
imageCoords=optmethodtable,
},
tristate={
},
171,8 → 160,8
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,...)
if strfind(k, "[%c \127]") then
err("["..tostring(k).."] - key name contained spaces (or control characters)", errlvl,...)
end
end
 
241,13 → 230,16
end
end
 
---------------------------------------------------------------------
-- :ValidateOptionsTable(options,name,errlvl)
-- - options - the table
-- - name - (string) name of table, used in error reports
-- - errlvl - (optional number) error level offset, default 0
--
-- 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
 
--- 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)
function lib:ValidateOptionsTable(options,name,errlvl)
errlvl=(errlvl or 0)+1
name = name or "Optionstable"
if not options.name then
256,16 → 248,19
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)
------------------------------
-- :NotifyChange(appName)
-- - appName - string identifying the addon
--
-- Fires a ConfigTableChange callback for those listening in on it, allowing config GUIs to refresh
------------------------------
 
function lib:NotifyChange(appName)
if not lib.tables[appName] then return end
lib.callbacks:Fire("ConfigTableChange", appName)
end
 
-- -------------------------------------------------------------------
---------------------------------------------------------------------
-- Registering and retreiving options tables:
 
 
281,32 → 276,34
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.
function AceConfigRegistry:RegisterOptionsTable(appName, options)
 
---------------------------------------------------------------------
-- :RegisterOptionsTable(appName, options)
-- - appName - string identifying the addon
-- - options - table or function reference
 
function lib:RegisterOptionsTable(appName, options)
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)
lib.tables[appName] = function(uiType, uiName, errlvl)
errlvl=(errlvl or 0)+1
validateGetterArgs(uiType, uiName, errlvl)
if not AceConfigRegistry.validated[uiType][appName] then
AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable
AceConfigRegistry.validated[uiType][appName] = true
if not lib.validated[uiType][appName] then
lib:ValidateOptionsTable(options, appName, errlvl) -- upgradable
lib.validated[uiType][appName] = true
end
return options
end
elseif type(options)=="function" then
AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
lib.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] then
AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable
AceConfigRegistry.validated[uiType][appName] = true
local tab = assert(options(uiType, uiName))
if not lib.validated[uiType][appName] then
lib:ValidateOptionsTable(tab, appName, errlvl) -- upgradable
lib.validated[uiType][appName] = true
end
return tab
end
315,23 → 312,30
end
end
 
--- Returns an iterator of ["appName"]=funcref pairs
function AceConfigRegistry:IterateOptionsTables()
return pairs(AceConfigRegistry.tables)
end
 
---------------------------------------------------------------------
-- :IterateOptionsTables()
--
-- Returns an iterator of ["appName"]=funcref pairs
 
function lib:IterateOptionsTables()
return pairs(lib.tables)
end
 
 
--- Query the registry for a specific options table.
---------------------------------------------------------------------
-- :GetOptionsTable(appName)
-- - appName - which addon to retreive the options table of
-- Optional:
-- - uiType - "cmd", "dropdown", "dialog"
-- - uiName - e.g. "MyLib-1.0"
--
-- If only appName is given, a function is returned which you
-- can call with (uiType,uiName) to get the table.\\
-- 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]
 
function lib:GetOptionsTable(appName, uiType, uiName)
local f = lib.tables[appName]
if not f then
return nil
end
trunk/libs/AceConfig-3.0/AceConfig-3.0.lua
3,45 → 3,37
-- as well as associate it with a slash command.
-- @class file
-- @name AceConfig-3.0
-- @release $Id: AceConfig-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $
-- @release $Id: AceConfig-3.0.lua 710 2008-12-19 10:14:39Z nevcairiel $
 
--[[
AceConfig-3.0
 
Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole.
 
Also automatically adds "config", "enable" and "disable" commands to options table as appropriate.
 
]]
 
local MAJOR, MINOR = "AceConfig-3.0", 2
local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
local lib = LibStub:NewLibrary(MAJOR, MINOR)
 
if not AceConfig then return end
if not lib then return end
 
 
local cfgreg = LibStub("AceConfigRegistry-3.0")
local cfgcmd = LibStub("AceConfigCmd-3.0")
local cfgdlg = LibStub("AceConfigDialog-3.0")
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0")
 
-- 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)
-- @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)
function lib:RegisterOptionsTable(appName, options, slashcmd)
local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
if not ok then error(msg, 2) end
 
trunk/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua
1,40 → 1,38
--- 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 902 2009-12-12 14:56:14Z nevcairiel $
-- @release $Id: AceConfigDialog-3.0.lua 736 2009-02-14 11:13:43Z nevcairiel $
 
local LibStub = LibStub
local MAJOR, MINOR = "AceConfigDialog-3.0", 43
local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
local MAJOR, MINOR = "AceConfigDialog-3.0", 26
local lib = LibStub:NewLibrary(MAJOR, MINOR)
 
if not AceConfigDialog then return end
if not lib then return end
 
AceConfigDialog.OpenFrames = AceConfigDialog.OpenFrames or {}
AceConfigDialog.Status = AceConfigDialog.Status or {}
AceConfigDialog.frame = AceConfigDialog.frame or CreateFrame("Frame")
lib.OpenFrames = lib.OpenFrames or {}
lib.Status = lib.Status or {}
lib.frame = lib.frame or CreateFrame("Frame")
 
AceConfigDialog.frame.apps = AceConfigDialog.frame.apps or {}
AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {}
lib.frame.apps = lib.frame.apps or {}
lib.frame.closing = lib.frame.closing or {}
 
local gui = LibStub("AceGUI-3.0")
local reg = LibStub("AceConfigRegistry-3.0")
 
-- Lua APIs
local tconcat, tinsert, tsort, tremove = table.concat, table.insert, table.sort, table.remove
local strmatch, format = string.match, string.format
local assert, loadstring, error = assert, loadstring, error
local pairs, next, select, type, unpack = pairs, next, select, type, unpack
local rawset, tostring = rawset, tostring
local math_min, math_max, math_floor = math.min, math.max, math.floor
local select = select
local pairs = pairs
local type = type
local assert = assert
local tinsert = tinsert
local tremove = tremove
local error = error
local table = table
local unpack = unpack
local string = string
local next = next
local math = math
local _
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: NORMAL_FONT_COLOR, GameTooltip, StaticPopupDialogs, ACCEPT, CANCEL, StaticPopup_Show
-- GLOBALS: PlaySound, GameFontHighlight, GameFontHighlightSmall, GameFontHighlightLarge
-- GLOBALS: CloseSpecialWindows, InterfaceOptions_AddCategory, geterrorhandler
 
local emptyTbl = {}
 
--[[
xpcall safecall implementation
]]
62,7 → 60,7
 
local ARGS = {}
for i = 1, argCount do ARGS[i] = "arg"..i end
code = code:gsub("ARGS", tconcat(ARGS, ", "))
code = code:gsub("ARGS", table.concat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
end
 
181,13 → 179,11
usage = true,
width = true,
image = true,
fontSize = true,
}
 
--Is Never a function or method
local allIsLiteral = {
type = true,
descStyle = true,
imageWidth = true,
imageHeight = true,
}
253,7 → 249,7
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))
error(string.format("Method %s doesn't exist in handler for type %s", member, membername))
end
end
del(info)
374,7 → 370,7
end
end
 
tsort(keySort, compareOptions)
table.sort(keySort, compareOptions)
 
del(tempOrders)
del(tempNames)
426,11 → 422,10
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)
--[[
Gets a status table for the given appname and options path
]]
function lib:GetStatusTable(appName, path)
local status = self.Status
 
if not status[appName] then
456,11 → 451,10
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, ...)
--[[
Sets the given path to be selected
]]
function lib:SelectGroup(appName, ...)
local path = new()
 
 
536,10 → 530,7
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
 
GameTooltip:SetText(name, 1, .82, 0, 1)
 
if opt.type == 'multiselect' then
584,14 → 575,14
if dialog and oldstrata then
dialog:SetFrameStrata(oldstrata)
end
AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl))
lib:Open(appName, rootframe, basepath and unpack(basepath))
del(info)
end
t.OnCancel = function()
if dialog and oldstrata then
dialog:SetFrameStrata(oldstrata)
end
AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl))
lib:Open(appName, rootframe, basepath and unpack(basepath))
del(info)
end
for i = 1, select('#', ...) do
684,7 → 675,7
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))
error(string.format("Method %s doesn't exist in handler for type execute", validate))
end
elseif type(validate) == "function" then
success, validated = safecall(validate, info, ...)
697,8 → 688,6
--validate function returned a message to display
if rootframe.SetStatusText then
rootframe:SetStatusText(validated)
else
-- TODO: do something else.
end
PlaySound("igPlayerInviteDecline")
del(info)
715,8 → 704,6
rootframe:SetStatusText(name..": Invalid Value")
end
end
else
-- TODO: do something else
end
PlaySound("igPlayerInviteDecline")
del(info)
735,7 → 722,7
confirm = false
end
else
error(format("Method %s doesn't exist in handler for type confirm", confirm))
error(string.format("Method %s doesn't exist in handler for type confirm", confirm))
end
elseif type(confirm) == "function" then
success, confirm = safecall(confirm, info, ...)
775,7 → 762,7
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))
error(string.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, ...)
790,7 → 777,7
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))
error(string.format("Method %s doesn't exist in handler for type func", func))
end
elseif type(func) == "function" then
safecall(func,info, ...)
799,23 → 786,23
 
 
local iscustom = user.rootframe:GetUserData('iscustom')
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl
local basepath = user.rootframe:GetUserData('basepath')
--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))
lib:Open(user.appName, user.rootframe, basepath and unpack(basepath))
else
AceConfigDialog:Open(user.appName, unpack(basepath))
lib:Open(user.appName, basepath and unpack(basepath))
end
end
elseif option.type == "range" then
if event == "OnMouseUp" then
if iscustom then
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
lib:Open(user.appName, user.rootframe, basepath and unpack(basepath))
else
AceConfigDialog:Open(user.appName, unpack(basepath))
lib:Open(user.appName, basepath and unpack(basepath))
end
end
--multiselects don't cause a refresh on 'OnValueChanged' only 'OnClosed'
823,9 → 810,9
user.valuechanged = true
else
if iscustom then
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
lib:Open(user.appName, user.rootframe, basepath and unpack(basepath))
else
AceConfigDialog:Open(user.appName, unpack(basepath))
lib:Open(user.appName, basepath and unpack(basepath))
end
end
 
837,9 → 824,9
local option = widget:GetUserData('option')
local min, max, step = option.min or 0, option.max or 100, option.step
if step then
value = math_floor((value - min) / step + 0.5) * step + min
value = math.floor((value - min) / step + 0.5) * step + min
else
value = math_max(math_min(value,max),min)
value = math.max(math.min(value,max),min)
end
ActivateControl(widget,event,value)
end
850,11 → 837,11
ActivateControl(widget, event, widget:GetUserData('value'), ...)
local user = widget:GetUserDataTable()
local iscustom = user.rootframe:GetUserData('iscustom')
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl
local basepath = user.rootframe:GetUserData('basepath')
if iscustom then
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
lib:Open(user.appName, user.rootframe, basepath and unpack(basepath))
else
AceConfigDialog:Open(user.appName, unpack(basepath))
lib:Open(user.appName, basepath and unpack(basepath))
end
end
 
862,18 → 849,18
local user = widget:GetUserDataTable()
if user.valuechanged then
local iscustom = user.rootframe:GetUserData('iscustom')
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl
local basepath = user.rootframe:GetUserData('basepath')
if iscustom then
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
lib:Open(user.appName, user.rootframe, basepath and unpack(basepath))
else
AceConfigDialog:Open(user.appName, unpack(basepath))
lib:Open(user.appName, basepath and unpack(basepath))
end
end
end
 
local function FrameOnClose(widget, event)
local appName = widget:GetUserData('appName')
AceConfigDialog.OpenFrames[appName] = nil
lib.OpenFrames[appName] = nil
gui:Release(widget)
end
 
970,7 → 957,6
local entry = new()
entry.value = k
entry.text = GetOptionsMemberValue("name", v, options, path, appName)
entry.icon = GetOptionsMemberValue("icon", v, options, path, appName)
entry.disabled = CheckOptionDisabled(v, options, path, appName)
if not tree.children then tree.children = new() end
tinsert(tree.children,entry)
1004,7 → 990,6
local entry = new()
entry.value = k
entry.text = GetOptionsMemberValue("name", v, options, path, appName)
entry.icon = GetOptionsMemberValue("icon", v, options, path, appName)
entry.disabled = CheckOptionDisabled(v, options, path, appName)
tinsert(tree,entry)
if recurse and (v.childGroups or "tree") == "tree" then
1078,43 → 1063,15
local name = GetOptionsMemberValue("name", v, options, path, appName)
 
if v.type == "execute" then
 
local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName)
local image, width, height = GetOptionsMemberValue("image",v, options, path, appName)
 
if type(image) == 'string' then
control = gui:Create("Icon")
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 = gui:Create("Button")
control:SetText(name)
end
control = gui:Create("Button")
control:SetText(name)
control:SetCallback("OnClick",ActivateControl)
 
elseif v.type == "input" then
local controlType = v.dialogControl or v.control or (v.multiline and "MultiLineEditBox") or "EditBox"
control = gui:Create(controlType)
if not control then
geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
control = gui:Create(v.multiline and "MultiLineEditBox" or "EditBox")
error(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
end
 
if v.multiline then
1139,22 → 1096,7
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' then
if type(imageCoords) == 'table' then
control:SetImage(image, unpack(imageCoords))
else
control:SetImage(image)
end
end
 
elseif v.type == "range" then
control = gui:Create("Slider")
control:SetLabel(name)
1173,8 → 1115,7
local controlType = v.dialogControl or v.control or "Dropdown"
control = gui:Create(controlType)
if not control then
geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
control = gui:Create("Dropdown")
error(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
end
control:SetLabel(name)
control:SetList(values)
1197,15 → 1138,13
tinsert(valuesort, value)
end
end
tsort(valuesort)
 
table.sort(valuesort)
 
if controlType then
control = gui:Create(controlType)
if not control then
geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
error(("Invalid Custom Control Type - %s"):format(tostring(controlType)))
end
end
if control then
control:SetMultiselect(true)
control:SetLabel(name)
control:SetList(values)
1289,16 → 1228,6
elseif v.type == "description" then
control = gui:Create("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)
 
1379,7 → 1308,7
feedpath[i] = path[i]
end
 
BuildPath(feedpath, ("\001"):split(uniquevalue))
BuildPath(feedpath, string.split("\001", uniquevalue))
local group = options
for i = 1, #feedpath do
if not group then return end
1391,9 → 1320,9
 
GameTooltip:SetOwner(button, "ANCHOR_NONE")
if widget.type == "TabGroup" then
GameTooltip:SetPoint("BOTTOM",button,"TOP")
GameTooltip:SetPoint("BOTTOM",button,"TOP")
else
GameTooltip:SetPoint("LEFT",button,"RIGHT")
GameTooltip:SetPoint("LEFT",button,"RIGHT")
end
 
GameTooltip:SetText(name, 1, .82, 0, 1)
1419,7 → 1348,7
feedpath[i] = path[i]
end
 
BuildPath(feedpath, ("\001"):split(uniquevalue))
BuildPath(feedpath, string.split("\001", uniquevalue))
 
local group = options
for i = 1, #feedpath do
1452,13 → 1381,13
feedpath[i] = path[i]
end
 
BuildPath(feedpath, ("\001"):split(uniquevalue))
BuildPath(feedpath, string.split("\001", uniquevalue))
local group = options
for i = 1, #feedpath do
group = GetSubOption(group, feedpath[i])
end
widget:ReleaseChildren()
AceConfigDialog:FeedGroup(user.appName,options,widget,rootframe,feedpath)
lib:FeedGroup(user.appName,options,widget,rootframe,feedpath)
 
del(feedpath)
end
1466,7 → 1395,6
 
 
--[[
-- 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
1481,7 → 1409,7
if its parent is a tree group, its already a node on a tree
--]]
 
function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isRoot)
function lib:FeedGroup(appName,options,container,rootframe,path, isRoot)
local group = options
--follow the path to get to the curent group
local inline
1507,14 → 1435,14
--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
if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) 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
if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) then
hasChildGroups = true
end
end
1526,7 → 1454,7
 
--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
if container.type ~= "InlineGroup" then
scroll = gui:Create("ScrollFrame")
scroll:SetLayout("flow")
scroll.width = "fill"
1549,7 → 1477,7
end
 
if hasChildGroups and not inline then
local name = GetOptionsMemberValue("name", group, options, path, appName)
 
if grouptype == "tab" then
 
local tab = gui:Create("TabGroup")
1558,7 → 1486,7
tab:SetCallback("OnTabEnter", TreeOnButtonEnter)
tab:SetCallback("OnTabLeave", TreeOnButtonLeave)
 
local status = AceConfigDialog:GetStatusTable(appName, path)
local status = lib:GetStatusTable(appName, path)
if not status.groups then
status.groups = {}
end
1583,10 → 1511,9
elseif grouptype == "select" then
 
local select = gui:Create("DropdownGroup")
select:SetTitle(name)
InjectInfo(select, options, group, path, rootframe, appName)
select:SetCallback("OnGroupSelected", GroupSelected)
local status = AceConfigDialog:GetStatusTable(appName, path)
local status = lib:GetStatusTable(appName, path)
if not status.groups then
status.groups = {}
end
1602,7 → 1529,7
end
 
if firstgroup then
select:SetGroup((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup)
select:SetGroup( (GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup)
end
 
select.width = "fill"
1624,7 → 1551,7
tree:SetCallback("OnButtonEnter", TreeOnButtonEnter)
tree:SetCallback("OnButtonLeave", TreeOnButtonLeave)
 
local status = AceConfigDialog:GetStatusTable(appName, path)
local status = lib:GetStatusTable(appName, path)
if not status.groups then
status.groups = {}
end
1652,37 → 1579,29
 
local function RefreshOnUpdate(this)
for appName in pairs(this.closing) do
if AceConfigDialog.OpenFrames[appName] then
AceConfigDialog.OpenFrames[appName]:Hide()
if lib.OpenFrames[appName] then
lib.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
for k, v in pairs(lib.OpenFrames) do
v:Hide()
end
this.closeAll = nil
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))
if lib.OpenFrames[appName] then
local user = lib.OpenFrames[appName]:GetUserDataTable()
lib:Open(appName, user.basepath and unpack(user.basepath))
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
if lib.BlizOptions and lib.BlizOptions[appName] then
local widget = lib.BlizOptions[appName]
local user = widget:GetUserDataTable()
if widget:IsVisible() then
lib:Open(widget:GetUserData('appName'), widget, user.basepath and unpack(user.basepath))
end
end
this.apps[appName] = nil
1690,58 → 1609,39
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)
function lib:CloseAll()
lib.frame.closeAll = true
lib.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)
function lib:Close(appName)
if self.OpenFrames[appName] then
AceConfigDialog.frame.closing[appName] = true
AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
lib.frame.closing[appName] = true
lib.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)
function lib:ConfigTableChanged(event, appName)
lib.frame.apps[appName] = true
lib.frame:SetScript("OnUpdate", RefreshOnUpdate)
end
 
reg.RegisterCallback(AceConfigDialog, "ConfigTableChange", "ConfigTableChanged")
reg.RegisterCallback(lib, "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)
function lib:SetDefaultSize(appName, width, height)
local status = lib: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, ...)
-- :Open(appName, [container], [path ...])
function lib:Open(appName, container, ...)
if not old_CloseSpecialWindows then
old_CloseSpecialWindows = CloseSpecialWindows
CloseSpecialWindows = function()
1779,7 → 1679,7
if #path > 0 then
f:SetUserData('basepath', copy(path))
end
local status = AceConfigDialog:GetStatusTable(appName)
local status = lib:GetStatusTable(appName)
if not status.width then
status.width = 700
end
1789,9 → 1689,6
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")
1806,7 → 1703,7
f:SetUserData('basepath', copy(path))
end
f:SetTitle(name or "")
local status = AceConfigDialog:GetStatusTable(appName)
local status = lib:GetStatusTable(appName)
f:SetStatusTable(status)
end
 
1817,63 → 1714,28
del(path)
end
 
-- convert pre-39 BlizOptions structure to the new format
if oldminor and oldminor < 39 and AceConfigDialog.BlizOptions then
local old = AceConfigDialog.BlizOptions
local new = {}
for key, widget in pairs(old) do
local appName = widget:GetUserData('appName')
if not new[appName] then new[appName] = {} end
new[appName][key] = widget
end
AceConfigDialog.BlizOptions = new
else
AceConfigDialog.BlizOptions = AceConfigDialog.BlizOptions or {}
end
lib.BlizOptions = lib.BlizOptions or {}
 
local function FeedToBlizPanel(widget, event)
local path = widget:GetUserData('path')
AceConfigDialog:Open(widget:GetUserData('appName'), widget, unpack(path or emptyTbl))
lib:Open(widget:GetUserData('appName'), widget, path and unpack(path))
end
 
local function ClearBlizPanel(widget, event)
local appName = widget:GetUserData('appName')
AceConfigDialog.frame.closing[appName] = true
AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
widget:ReleaseChildren()
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.
function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...)
local BlizOptions = AceConfigDialog.BlizOptions
function lib:AddToBlizOptions(appName, name, parent, ...)
local BlizOptions = lib.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
if not BlizOptions[key] then
local group = gui:Create("BlizOptionsGroup")
BlizOptions[appName][key] = group
BlizOptions[key] = group
group:SetName(name or appName, parent)
 
group:SetTitle(name or appName)
trunk/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua
1,7 → 1,7
--- AceConfigCmd-3.0 handles access to an options table through the "command line" interface via the ChatFrames.
--- AceConfigCmd-3.0 handles access to optionstable through the "command line" interface via the ChatFrames.
-- @class file
-- @name AceConfigCmd-3.0
-- @release $Id: AceConfigCmd-3.0.lua 904 2009-12-13 11:56:37Z nevcairiel $
-- @release $Id: AceConfigCmd-3.0.lua 733 2009-02-03 22:24:44Z nevcairiel $
 
--[[
AceConfigCmd-3.0
12,36 → 12,24
 
]]
 
-- TODO: handle disabled / hidden
-- TODO: implement handlers for all types
-- TODO: plugin args
 
 
local MAJOR, MINOR = "AceConfigCmd-3.0", 12
local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR)
local MAJOR, MINOR = "AceConfigCmd-3.0", 7
local lib = LibStub:NewLibrary(MAJOR, MINOR)
 
if not AceConfigCmd then return end
if not lib then return end
 
AceConfigCmd.commands = AceConfigCmd.commands or {}
local commands = AceConfigCmd.commands
lib.commands = lib.commands or {}
local commands = lib.commands
 
local cfgreg = LibStub("AceConfigRegistry-3.0")
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
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: LibStub, SELECTED_CHAT_FRAME, DEFAULT_CHAT_FRAME
 
 
local L = setmetatable({}, { -- TODO: replace with proper locale
__index = function(self,k) return k end
})
52,15 → 40,7
(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(...)
189,20 → 169,7
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)
local function showhelp(info, inputpos, tab, noHead)
if not noHead then
print("|cff33ff99"..info.appName.."|r: Arguments to |cffffff78/"..info[0].."|r "..strsub(info.input,1,inputpos-1)..":")
end
212,12 → 179,12
 
for k,v in iterateargs(tab) do
if not refTbl[k] then -- a plugin overriding something in .args
tinsert(sortTbl, k)
table.insert(sortTbl, k)
refTbl[k] = v
end
end
 
tsort(sortTbl, function(one, two)
table.sort(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
241,29 → 208,23
return o1<o2
end)
 
for i = 1, #sortTbl do
local k = sortTbl[i]
for _,k in ipairs(sortTbl) do
local v = refTbl[k]
if not checkhidden(info, inputpos, v) then
if v.type ~= "description" and v.type ~= "header" then
-- recursively show all inline groups
local name, desc = v.name, v.desc
if type(name) == "function" then
name = callfunction(info, v, 'name')
end
if type(desc) == "function" then
desc = callfunction(info, v, 'desc')
end
if v.type == "group" and pickfirstset(v.cmdInline, v.inline, false) then
print(" "..(desc or name)..":")
local oldhandler,oldhandler_at = getparam(info, inputpos, v, depth, "handler", handlertypes, handlermsg)
showhelp(info, inputpos, v, depth, true)
info.handler,info.handler_at = oldhandler,oldhandler_at
else
local key = k:gsub(" ", "_")
print(" |cffffff78"..key.."|r - "..(desc or name or ""))
end
if not pickfirstset(v.cmdHidden, v.hidden, false) then
-- recursively show all inline groups
local name, desc = v.name, v.desc
if type(name) == "function" then
name = callfunction(info, v, 'name')
end
if type(desc) == "function" then
desc = callfunction(info, v, 'desc')
end
if v.type == "group" and pickfirstset(v.cmdInline, v.inline, false) then
print(" "..(desc or name)..":")
showhelp(info, inputpos, v, true)
elseif v.type ~= "description" and v.type ~= "header" then
print(" |cffffff78"..k.."|r - "..(desc or name or ""))
end
end
end
end
327,6 → 288,14
return s
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"
 
-- 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)
357,9 → 326,9
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)
local _,nextpos,arg = string.find(info.input, " *([^ ]+) *", inputpos)
if not arg then
showhelp(info, inputpos, tab, depth)
showhelp(info, inputpos, tab)
return
end
nextpos=nextpos+1
378,7 → 347,7
return -- done, name was found in inline group
end
-- matching name and not a inline group
elseif strlower(arg)==strlower(k:gsub(" ", "_")) then
elseif strlower(arg)==strlower(k) then
info[depth+1] = k
return handle(info,nextpos,v,depth+1)
end
488,6 → 457,10
elseif tab.type=="select" then
------------ select ------------------------------------
local str = strtrim(strlower(str))
if str == "" then
--TODO: Show current selection and possible values
return
end
 
local values = tab.values
if type(values) == "function" or type(values) == "string" then
495,21 → 468,6
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
529,35 → 487,25
elseif tab.type=="multiselect" then
------------ multiselect -------------------------------------------
local str = strtrim(strlower(str))
if str == "" then
--TODO: Show current values
return
end
 
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
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
for v in string.gmatch(str, "[^ ]+") do
--parse option=on etc
local opt, val = v:match('(.+)=(.+)')
local opt, val = string.match(v,'(.+)=(.+)')
--get option if toggling
if not opt then
opt = v
720,28 → 668,18
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")
 
-----------------------------------------------------------------------
-- HandleCommand(slashcmd, appName, input)
--
-- Call this from a chat command handler to parse the command input as operations on an aceoptions table
--
-- -- 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)
-- slashcmd (string) - the slash command WITHOUT leading slash (only used for error output)
-- appName (string) - the application name as given to AceConfigRegistry:RegisterOptionsTable()
-- input (string) -- the commandline input (as given by the WoW handler, i.e. without the command itself)
 
function lib: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)
762,26 → 700,34
handle(info, 1, options, 0) -- (info, inputpos, table, depth)
end
 
--- Utility function to create a slash command handler.
 
 
-----------------------------------------------------------------------
-- CreateChatCommand(slashcmd, appName)
--
-- 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)
--
-- slashcmd (string) - the slash command WITHOUT leading slash (only used for error output)
-- appName (string) - the application name as given to AceConfigRegistry:RegisterOptionsTable()
 
function lib: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
lib.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)
-- GetChatCommandOptions(slashcmd)
--
-- Utility function that returns the options table that belongs to a slashcommand
-- mainly used by AceTab
 
function lib:GetChatCommandOptions(slashcmd)
return commands[slashcmd]
end
trunk/Accountant.lua
12,6 → 12,7
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
local AceConfig = LibStub("AceConfig-3.0")
 
 
-- Create a short cut
local SC = Accountant
 
22,6 → 23,7
SC.sender = "";
SC.current_money = 0;
SC.last_money = 0;
SC.verbose = false;
SC.got_name = false;
SC.current_tab = 1;
Accountant.player = "";
33,10 → 35,7
local Accountant_CursorHasItem_old;
local tmpstr = "";
 
SC.verbose = false;
SC.show_events = false -- could generate a lot of output!
SC.show_setup = false
SC.show_mode = false
 
function SC.TableContainsValue(table, value)
if table and value then
50,22 → 49,6
return nil
end
 
local function MatchRealm(player, realm)
local r = string.gsub (realm, "[%c%(%)%[%]%$%^]", "~")
local p = string.gsub (player, "[%c%(%)%[%]%$%^]", "~")
--[[
SC.Print("MatchRealm: "
.."p: '"..p.."'"
.."r: '"..r.."'"
)
--]]
if (string.find(p, r) == nil) then
return nil
else
return true
end
end
 
function SC.ClearData ()
--
-- Clear all data all modes
94,7 → 77,7
if realm then
strtmp = player
else
local str_pos = strfind(player, SC.DIVIDER)
local str_pos = strfind(player, "-")
strtmp = strsub(player, str_pos+1) -- remove the realm and dash
end
table.insert(toon_table, strtmp)
131,15 → 114,6
end
end
 
function SC.ToonShow()
--
-- Show all the toons in the array.
--
for i = 1, #SC.AllToons do
SC.Print("Name: '"..(SC.AllToons[i] or "?").."'")
end
end
 
function SC.ToonMerge (from, to)
--
-- Merge the data of the selected toons
166,7 → 140,7
 
if to == SC.player then
-- Reload the data for this toon
SC.LoadSavedData()
SC.LoadData()
end
DEFAULT_CHAT_FRAME:AddMessage(ACCLOC_TITLE..": "..ACCLOC_TOON_MERGE.." of "
..(from or "?").." "..ACCLOC_TO.." "..(to or "?").." "..ACCLOC_DONE)
195,7 → 169,7
-- Create the name so the right data can be looked up.
--
acc_realm = GetRealmName();
acc_name = acc_realm..SC.DIVIDER..UnitName("player");
acc_name = acc_realm.."-"..UnitName("player");
return acc_name;
end
 
742,7 → 716,7
if SC.show_toons == ACCLOC_CHARS then
strtmp = ACCLOC_CHARS
else
local str_pos = strfind(SC.show_toons, SC.DIVIDER)
local str_pos = strfind(SC.show_toons, "-")
strtmp = strsub(SC.show_toons, str_pos+1) -- remove the realm and dash
end
tt_str =
788,7 → 762,7
for player in next,Accountant_SaveData do
-- Find the one player or all players of the faction(s) requested
faction = Accountant_SaveData[player]["options"]["faction"]
if (MatchRealm(player, SC.Realm) ~= nil)
if (string.find(player, SC.Realm) ~= nil)
and (( (faction == ACCLOC_ALLIANCE)
and (SC.ShowAlliance == true) )
or ( (faction == ACCLOC_HORDE)
927,7 → 901,7
SC.Realm = GetRealmName();
SC.Char = UnitName("player");
SC.Faction = UnitFactionGroup("player")
SC.player = SC.Realm..SC.DIVIDER..SC.Char;
SC.player = SC.Realm.."-"..SC.Char;
SC.AllDropdown = ACCLOC_CHARS
 
-- default behaviour
941,11 → 915,11
..FONT_COLOR_CODE_CLOSE
.."|cFFFFFF00"..SC.AUTHOR..FONT_COLOR_CODE_CLOSE
.." for "
.."'"..SC.player.."'"
..SC.player
);
 
-- Setup
SC.LoadSavedData();
SC.LoadData();
SC.SetLabels();
 
-- Current Cash
983,10 → 957,18
 
-- Set the tabs at the bottom of the Accountant window
AccountantFrameTab1:SetText(ACCLOC_SESS);
-- For some reason, WoW Lich King does not like _TabResize
-- but it does not effect the look so it is commented
-- out for now.
-- PanelTemplates_TabResize(10, AccountantFrameTab1);
AccountantFrameTab2:SetText(ACCLOC_DAY);
-- PanelTemplates_TabResize(10, AccountantFrameTab1);
AccountantFrameTab3:SetText(ACCLOC_WEEK);
-- PanelTemplates_TabResize(10, AccountantFrameTab2);
AccountantFrameTab4:SetText(ACCLOC_TOTAL);
-- PanelTemplates_TabResize(10, AccountantFrameTab4);
AccountantFrameTab5:SetText(ACCLOC_CHARS);
-- PanelTemplates_TabResize(10, AccountantFrameTab5);
PanelTemplates_SetNumTabs(AccountantFrame, 5);
PanelTemplates_SetTab(AccountantFrame, AccountantFrameTab1);
PanelTemplates_UpdateTabs(AccountantFrame);
996,7 → 978,7
SC:LDB_Update()
end
 
function SC.LoadSavedData()
function SC.LoadData()
--
-- Load the account data of the character that is being played
--
1050,7 → 1032,7
-- existing chars, otherwise it will prematurely wipe out the weekly totals.
for player in next,Accountant_SaveData do
-- Quel's mod: only consider chars on the same server
if (MatchRealm(player, SC.Realm) ~= nil) then
if (string.find(player, SC.Realm) ~= nil) then
if (Accountant_SaveData[player]["options"]["weekstart"] ~= nil) then
SC.Print2("Adding a new account for new character, "
..Accountant.player..", weekstart = "
1121,7 → 1103,7
-- Quel's modifications to track income/expense across all characters relies on the savedata structure,
-- so we have to reset the session totals for all players each time we log in, only for chars on this server.
for player in next,Accountant_SaveData do
if (MatchRealm(player, SC.Realm) ~= nil) then
if (string.find(player, SC.Realm) ~= nil) then
-- SC.Print2("Blanking session data for: "..player..", "..key);
Accountant_SaveData[player]["data"][key]["Session"].In = 0;
Accountant_SaveData[player]["data"][key]["Session"].Out = 0;
1152,7 → 1134,7
-- Quel's mod: make sure introdudction of a new character gets the same cdate as
-- existing chars on this realm, otherwise it will prematurely wipe out the daily totals
for player in next,Accountant_SaveData do
if (MatchRealm(player, SC.Realm) ~= nil) then
if (string.find(player, SC.Realm) ~= nil) then
if (Accountant_SaveData[player]["options"]["weekstart"] ~= nil) then
-- SC.Print2("Setting weekstart for "..AccountantPlayer.." to match "..player.." value: "..Accountant_SaveData[player]["options"]["weekstart"]);
Accountant_SaveData[Accountant.player]["options"]["weekstart"]
1166,7 → 1148,7
-- Quel's mod: make sure introdudction of a new character gets the same cdate as
-- existing chars on this server, otherwise it will prematurely wipe out the daily totals.
for player in next,Accountant_SaveData do
if (MatchRealm(player, SC.Realm) ~= nil) then
if (string.find(player, SC.Realm) ~= nil) then
if (Accountant_SaveData[player]["options"]["dateweek"] ~= nil) then
-- SC.Print2("Setting dateweek for "..Accountant.player.." to match "..player.." value: "..Accountant_SaveData[player]["options"]["dateweek"]);
Accountant_SaveData[Accountant.player]["options"]["dateweek"]
1183,7 → 1165,7
-- Quel's mod: make sure introdudction of a new character gets the same cdate as
-- existing chars on this server, otherwise it will prematurely wipe out the daily totals.
for player in next,Accountant_SaveData do
if (MatchRealm(player, SC.Realm) ~= nil) then
if (string.find(player, SC.Realm) ~= nil) then
if (Accountant_SaveData[player]["options"]["date"] ~= nil) then
-- SC.Print2("Setting date for "..AccountantPlayer.." to match "..player.." value: "..Accountant_SaveData[player]["options"]["date"]);
Accountant_SaveData[Accountant.player]["options"]["date"]
1212,7 → 1194,7
-- Quel's mod: have to clear data for all chars on this server when it rolls over and update
-- their date to match.
for player in next,Accountant_SaveData do
if (MatchRealm(player, SC.Realm) ~= nil) then
if (string.find(player, SC.Realm) ~= nil) then
-- SC.Print2(" Setting Accountant_SaveData["..player.."][data]["..mode.."][date] = "..cdate);
Accountant_SaveData[player]["data"][mode]["Day"].In = 0;
Accountant_SaveData[player]["data"][mode]["Day"].Out = 0;
1233,7 → 1215,7
-- Quel's mod: have to clear data for all chars on this server when it rolls over and update
-- their date to match.
for player in next,Accountant_SaveData do
if (MatchRealm(player, SC.Realm) ~= nil) then
if (string.find(player, SC.Realm) ~= nil) then
-- SC.Print2(" Setting Accountant_SaveData["..player.."][data]["..mode.."][dateweek] = "..SC.WeekStart() );
Accountant_SaveData[player]["data"][mode]["Week"].In = 0;
Accountant_SaveData[player]["data"][mode]["Week"].Out = 0;
1304,11 → 1286,10
local faction = ""
SC.Toons = {}
for player in next,Accountant_SaveData do
if MatchRealm(player, SC.Realm) then
local str_pos = strfind(player, SC.DIVIDER)
if (string.find(player, SC.Realm) ~= nil) then
local str_pos = strfind(player, "-")
local strtmp = strsub(player, str_pos+1) -- remove the realm and dash
faction = Accountant_SaveData[player]["options"]["faction"]
--SC.Print("ToonDropDownList: trim ".."'"..strtmp.."' faction '".."'"..faction.."'")
if ( (faction == ACCLOC_ALLIANCE)
and (SC.ShowAlliance == true) )
or ( (faction == ACCLOC_HORDE)
1338,6 → 1319,7
info.checked = nil
UIDropDownMenu_AddButton(info)
end
--DEFAULT_CHAT_FRAME:AddMessage("Acc char drop Init: ")
end
 
function SC.CharDropDown_Setup()
1346,11 → 1328,12
-- Used outside the XML controller
--
UIDropDownMenu_Initialize(Accountant_CharDropDown, SC.CharDropDown_Init);
-- UIDropDownMenu_SetSelectedID(Accountant_CharDropDown, 1)
 
--
local selected
for i = 1, #SC.Toons do
if SC.show_toons == SC.Realm..SC.DIVIDER..SC.Toons[i] then
if SC.show_toons == SC.Realm.."-"..SC.Toons[i] then
UIDropDownMenu_SetSelectedID(Accountant_CharDropDown, i+1)
selected = true
end
1380,7 → 1363,7
UIDropDownMenu_SetSelectedID(Accountant_CharDropDown, id);
 
if( id > 1) then
searchChar = SC.Realm..SC.DIVIDER..SC.Toons[id-1];
searchChar = SC.Realm.."-"..SC.Toons[id-1];
else
searchChar = SC.AllDropdown;
end
1424,10 → 1407,6
SC:LDB_Update()
end
 
function SC.ShowUsage()
SC.Print("/accountant log | verbose | week\n");
end
 
function SC.Slash(msg)
--
-- Consume and act on the Accountant slash commands
1448,26 → 1427,8
SC.verbose = nil;
SC.Print("Verbose Mode Off");
end
elseif args[1] == 'show_events' then
if SC.show_events == nil then
SC.show_events = 1;
SC.Print("show_events Mode On");
else
SC.show_events = nil;
SC.Print("show_events Mode Off");
end
elseif args[1] == 'show_setup' then
if SC.show_setup == nil then
SC.show_setup = 1;
SC.Print("show_setup Mode On");
else
SC.show_setup = nil;
SC.Print("show_setup Mode Off");
end
elseif args[1] == 'week' then
SC.Print(SC.WeekStart());
elseif args[1] == 'toons' then
SC.ToonShow()
else
SC.ShowUsage();
end
1478,10 → 1439,10
-- Handle the events Accountant registered for
--
local oldmode = SC.mode;
--[
--[[
if SC.show_events then
SC.Print(
"show_events "
DEFAULT_CHAT_FRAME:AddMessage(
"|cFFFFFF00".."Acc debug "..FONT_COLOR_CODE_CLOSE
..GREEN_FONT_COLOR_CODE.."ev: "
..event
.." arg: "
1498,9 → 1459,6
if ( playerName ~= UNKNOWNBEING
and playerName ~= UNKNOWNOBJECT
and playerName ~= nil ) then
if SC.show_start then
SC.Print("setup: init start");
end
SC.got_name = true;
SC.OnLoad();
SC.Button_Init();
1510,9 → 1468,6
SC:LDB_Update()
-- Create the options structures
SC.InitOptions()
if SC.show_start then
SC.Print("setup: init end");
end
end
return;
end
1724,7 → 1679,7
for player in next,Accountant_SaveData do
-- Find the one player or all players of the faction(s) requested
faction = Accountant_SaveData[player]["options"]["faction"]
if (MatchRealm(player, SC.Realm) ~= nil)
if (string.find(player, SC.Realm) ~= nil)
and (( (faction == ACCLOC_ALLIANCE)
and (SC.ShowAlliance == true) )
or ( (faction == ACCLOC_HORDE)
1763,7 → 1718,7
-- collect the total for the toon(s) selected
for player in next,Accountant_SaveData do
faction = Accountant_SaveData[player]["options"]["faction"]
if (MatchRealm(player, SC.Realm) ~= nil)
if (string.find(player, SC.Realm) ~= nil)
and (( (faction == ACCLOC_ALLIANCE)
and (SC.ShowAlliance == true) )
or ( (faction == ACCLOC_HORDE)
1796,13 → 1751,13
else
faction = "not set"
end
if (MatchRealm(char, SC.Realm) ~= nil)
if (string.find(char, SC.Realm) ~= nil)
and (( (faction == ACCLOC_ALLIANCE)
and (SC.ShowAlliance == true) )
or ( (faction == ACCLOC_HORDE)
and (SC.ShowHorde == true) ))
then
str_pos = strfind(char, SC.DIVIDER)
str_pos = strfind(char, "-")
strtmp = strsub(char, str_pos+1) -- remove the realm and dash
if for_display then
getglobal("AccountantFrameRow" ..i.."Title"):SetText(strtmp);
1914,10 → 1869,9
 
function SC.Print(msg)
--
-- Accountant print - debug or user requested info
-- Accountant print
--
-- DEFAULT_CHAT_FRAME:AddMessage(format("Accountant: "..msg));
DEFAULT_CHAT_FRAME:AddMessage("|cFFFFFF00".."Acc: "..FONT_COLOR_CODE_CLOSE..msg);
DEFAULT_CHAT_FRAME:AddMessage(format("Accountant: "..msg));
end
 
function SC.Print2(msg)
1927,6 → 1881,10
ChatFrame4:AddMessage(format("Accountant: "..msg));
end
 
function SC.ShowUsage()
QM_Print("/accountant log\n");
end
 
function SC.UpdateLog()
--
-- Update the Accountant data based on the current Accountant mode
trunk/Accountant.toc
1,6 → 1,6
## Interface: 30300
## Title: Accountant 3.10.30300
## Version: 3.10.30300
## Title: Accountant 3.8.30300
## Version: 3.8.30300
## Author: urnati
## Description: Logs where your WoW gold goes
## DefaultState: enabled
10,9 → 10,9
libs\LibStub\LibStub.lua
libs\CallbackHandler-1.0\CallbackHandler-1.0.xml
libs\LibDataBroker-1.1\LibDataBroker-1.1.lua
libs\AceGUI-3.0\AceGUI-3.0.xml
libs\AceConfig-3.0\AceGUI-3.0\AceGUI-3.0.xml
libs\AceConfig-3.0\AceConfig-3.0.xml
libs\AceConfig-3.0\AceConfigDialog-3.0\AceConfigDialog-3.0.xml
libs\AceConfig-3.0\AceConfigDialog-3.0.xml
 
AccountantData.lua
localization.lua