/trunk/FuBar_RecapFu/libs/AceConsole-2.0
## Interface: 30000 |
## X-Curse-Packaged-Version: r1096 |
## 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 |
--[[ |
--[[ |
Name: AceConsole-2.0 |
Revision: $Rev: 30624 $ |
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/ |
]] |
local MAJOR_VERSION = "AceConsole-2.0" |
local MINOR_VERSION = "$Revision: 30624 $" |
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" } |
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 = "ì¤ì ì¡°ì ê°ì´ ì¬ë°ë¥´ì§ ììµëë¤." |
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 = "<ALT-CTRL-SHIFT-KEY>" -- fix |
DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?" -- fix |
KEYBINDING_USAGE = "<ALT-CTRL-SHIFT-KEY>" |
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" |
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%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 é¸é èçå¨ã" |
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 = "<ALT-CTRL-SHIFT-KEY>" -- fix |
DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?" -- fix |
OPTION_IS_DISABLED = "|cffffff7f%s|r已被åç¨ã" |
KEYBINDING_USAGE = "<Alt-Ctrl-Shift-éµ>" |
DEFAULT_CONFIRM_MESSAGE = "æ¯å¦å·è¡ã%sã?" |
elseif GetLocale() == "esES" then |
MAP_ONOFF = { [false] = "|cffff0000Desactivado|r", [true] = "|cff00ff00Activado|r" } |
USAGE = "Uso" |
OPTION_IS_DISABLED = "La opci\195\179n |cffffff7f%s|r est\195\161 desactivada." |
KEYBINDING_USAGE = "<ALT-CTRL-SHIFT-KEY>" |
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 = "<ALT-CTRL-SHIFT-ÐÐÐÐÐШÐ>" |
DEFAULT_CONFIRM_MESSAGE = "ÐÑ ÑвеÑенÑ, ÑÑо Ñ Ð¾ÑиÑе вÑполниÑÑ `%s'?" |
else -- enUS |
MAP_ONOFF = { [false] = "|cffff0000Off|r", [true] = "|cff00ff00On|r" } |
USAGE = "Usage" |
return {} |
end |
end |
function del(t) |
for k in pairs(t) do |
t[k] = nil |
local function literal_tostring_prime(t, depth) |
if type(t) == "string" then |
return ("|cff00ff00%q|r"):format((t:gsub("|", "||"))):gsub("[\001-\012\014-\031\128-\255]", escapeChar) |
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" |
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 |
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() |
hidden = hidden(passValue) |
elseif type(hidden) == "string" then |
local handler = options.handler or self |
local f = hidden |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
hidden = handler[f](handler) |
hidden = handler[f](handler, passValue) |
if neg then |
hidden = not hidden |
end |
disabled = true |
elseif disabled then |
if type(disabled) == "function" then |
disabled = disabled() |
disabled = disabled(passValue) |
elseif type(disabled) == "string" then |
local handler = options.handler or self |
local f = disabled |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
disabled = handler[f](handler) |
disabled = handler[f](handler, passValue) |
if neg then |
disabled = not disabled |
end |
good = true |
end |
if good then |
return findTableLevel(options.handler or self, v, chat, text, index + 1, options.pass and options or nil) |
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 |
for i = index, #work do |
table.insert(argwork, work[i]) |
end |
return options, path, argwork, options.handler or self, passTable, passTable and work[index - 1] |
return options, path, argwork, options.handler or self, passTable, passValue |
end |
local function validateOptionsMethods(self, options, position) |
return '"func" must be a string or function', position |
end |
end |
else |
if kind == "group" then |
return 'cannot have "type" = "group" as a subgroup of a passing group', position |
end |
end |
if options ~= baseOptions then |
if kind == "header" 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 |
end |
local tmp = {} |
local function printUsage(self, handler, realOptions, options, path, args, quiet, filter) |
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() |
hidden = hidden(options.passValue) |
elseif type(hidden) == "string" then |
local f = hidden |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
hidden = handler[f](handler) |
hidden = handler[f](handler, options.passValue) |
if neg then |
hidden = not hidden |
end |
disabled = true |
elseif disabled then |
if type(disabled) == "function" then |
disabled = disabled() |
disabled = disabled(options.passValue) |
elseif type(disabled) == "string" then |
local f = disabled |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
disabled = handler[f](handler) |
disabled = handler[f](handler, options.passValue) |
if neg then |
disabled = not disabled |
end |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = passTable.get(passValue, val) or nil |
if passValue == nil then |
var[val] = passTable.get(val) or nil |
else |
var[val] = passTable.get(passValue, val) or nil |
end |
end |
end |
else |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = handler[passTable.get](handler, passValue, val) or nil |
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 |
if not options.get then |
elseif type(options.get) == "function" then |
if not multiToggle then |
var = options.get() |
var = options.get(passValue) |
else |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = options.get(val) or nil |
if passValue == nil then |
var[val] = options.get(val) or nil |
else |
var[val] = options.get(passValue, val) or nil |
end |
end |
end |
else |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
if not multiToggle then |
var = handler[options.get](handler) |
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 |
var[val] = handler[options.get](handler, val) or nil |
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 |
end |
else |
if type(options.get) == "function" then |
var = options.get() |
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) |
var = handler[options.get](handler, passValue) |
end |
end |
local usage |
local min = options.min or 0 |
local max = options.max or 1 |
end |
local passTable = options.pass and options or nil |
for _,k in ipairs(order) do |
local passValue = passTable and k |
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 |
local k = k:gsub("%s", "-") |
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() |
disabled = disabled(passValue) |
elseif type(disabled) == "string" then |
local f = disabled |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
disabled = handler[f](handler) |
disabled = handler[f](handler, passValue) |
if neg then |
disabled = not disabled |
end |
t.timeout = 0 |
t.whileDead = 1 |
t.hideOnEscape = 1 |
StaticPopup_Show("ACECONSOLE20_CONFIRM_DIALOG") |
end |
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() |
hidden = hidden(passValue) |
elseif type(hidden) == "string" then |
local f = hidden |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
hidden = handler[f](handler) |
hidden = handler[f](handler, passValue) |
if neg then |
hidden = not hidden |
end |
disabled = true |
elseif disabled then |
if type(disabled) == "function" then |
disabled = disabled() |
disabled = disabled(passValue) |
elseif type(disabled) == "string" then |
local f = disabled |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
disabled = handler[f](handler) |
disabled = handler[f](handler, passValue) |
if neg then |
disabled = not disabled |
end |
end |
end |
local _G_this = this |
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 |
return |
end |
end |
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 multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = passTable.get(passValue, val) |
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 |
else |
var = passTable.get(passValue) |
end |
else |
if type(handler[passTable.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get))) |
end |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = handler[passTable.get](handler, passValue, val) |
end |
else |
var = handler[passTable.get](handler, passValue) |
end |
var = options_p.get(passValue) |
end |
else |
multiToggle = options.multiToggle |
if not options.get then |
elseif type(options.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 |
var[val] = options.get(val) |
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 |
else |
var = options.get() |
end |
else |
if type(handler[options.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = handler[options.get](handler, val) |
end |
else |
var = handler[options.get](handler) |
end |
var = handler[options_p.get](handler, passValue) |
end |
end |
if multiToggle or var ~= args[1] then |
if multiToggle then |
local current = var[args[1]] |
end |
args[2] = not current |
end |
if passTable then |
if type(passTable.set) == "function" then |
passTable.set(passValue, unpack(args)) |
if type(options_p.set) == "function" then |
if passValue then |
options_p.set(passValue, unpack(args)) |
else |
if type(handler[passTable.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.set))) |
end |
handler[passTable.set](handler, passTable.set, unpack(args)) |
options_p.set(unpack(args)) |
end |
else |
if type(options.set) == "function" then |
options.set(unpack(args)) |
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 |
if type(handler[options.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.set))) |
end |
handler[options.set](handler, unpack(args)) |
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 |
if passTable then |
multiToggle = passTable.multiToggle |
if not passTable.get then |
elseif type(passTable.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 |
var[val] = passTable.get(passValue, val) |
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 |
else |
var = passTable.get(passValue) |
end |
else |
if type(handler[passTable.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get))) |
end |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = handler[passTable.get](handler, passValue, val) |
end |
else |
var = handler[passTable.get](handler, passValue) |
end |
var = options_p.get(passValue) |
end |
else |
multiToggle = options.multiToggle |
if not options.get then |
elseif type(options.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 |
var[val] = options.get(val) |
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 |
else |
var = options.get() |
end |
else |
if type(handler[options.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = handler[options.get](handler, val) |
end |
else |
var = handler[options.get](handler) |
end |
var = handler[options_p.get](handler, passValue) |
end |
end |
if multiToggle then |
elseif type(options.validate) == "table" then |
var = options.validate[var] or var |
end |
if (passTable and passTable.get) or options.get then |
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) |
printUsage(self, handler, realOptions, options, path, args, passValue) |
return |
end |
elseif kind == "execute" then |
if confirm == true then |
confirm = DEFAULT_CONFIRM_MESSAGE:format(options.desc or options.name or UNKNOWN or "Unknown") |
end |
if passTable then |
if type(passTable.func) == "function" then |
if confirm then |
confirmPopup(confirm, set, passValue) |
else |
passTable.func(passValue) |
end |
if type(options_p.func) == "function" then |
if confirm then |
confirmPopup(confirm, options_p.func, passValue) |
else |
if type(handler[passTable.func]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.func))) |
end |
if confirm then |
confirmPopup(confirm, handler[passTable.func], handler, passValue) |
else |
handler[passTable.func](handler, passValue) |
end |
options_p.func(passValue) |
end |
else |
local ret, msg |
if type(options.func) == "function" then |
if confirm then |
confirmPopup(confirm, options.func) |
else |
options.func() |
end |
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 |
local handler = options.handler or self |
if type(handler[options.func]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.func))) |
end |
if confirm then |
confirmPopup(confirm, handler[options.func], handler) |
else |
handler[options.func](handler) |
end |
handler[options_p.func](handler, passValue) |
end |
end |
elseif kind == "toggle" then |
local var |
if passTable then |
if type(passTable.get) == "function" then |
var = passTable.get(passValue) |
else |
local f = passTable.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 |
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(passTable.set) == "function" then |
passTable.set(passValue, not var) |
else |
if type(handler[passTable.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.set))) |
end |
handler[passTable.set](handler, passValue, not var) |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
if type(passTable.get) == "function" then |
var = passTable.get(passValue) |
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 |
local f = passTable.get |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
var = handler[f](handler, passValue) |
if neg then |
var = not var |
end |
options_p.set(not var) |
end |
else |
local handler = options.handler or self |
if type(options.get) == "function" then |
var = options.get() |
else |
local f = options.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) |
if neg then |
var = not var |
end |
if type(handler[options_p.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.set))) |
end |
if type(options.set) == "function" then |
options.set(not var) |
if passValue then |
handler[options_p.set](handler, passValue, not var) |
else |
if type(handler[options.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.set))) |
end |
handler[options.set](handler, not var) |
handler[options_p.set](handler, not var) |
end |
if type(options.get) == "function" then |
var = options.get() |
else |
local f = options.get |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
var = handler[f](handler) |
if neg then |
var = 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 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 |
print(("|cffffff7f%s:|r %s %s"):format(USAGE, path, usage)) |
return |
end |
local var |
if passTable then |
if type(passTable.get) == "function" then |
var = passTable.get(passValue) |
else |
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 |
if type(options_p.get) == "function" then |
var = options_p.get(passValue) |
else |
if type(options.get) == "function" then |
var = options.get() |
else |
local handler = options.handler or self |
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) |
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 passTable then |
if type(passTable.set) == "function" then |
passTable.set(passValue, arg) |
if type(options_p.set) == "function" then |
if passValue then |
options_p.set(passValue, arg) |
else |
if type(handler[passTable.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.set))) |
end |
handler[passTable.set](handler, passValue, arg) |
options_p.set(arg) |
end |
else |
if type(options.set) == "function" then |
options.set(arg) |
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 |
local handler = options.handler or self |
if type(handler[options.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.set))) |
end |
handler[options.set](handler, arg) |
handler[options_p.set](handler, arg) |
end |
end |
end |
end |
if arg then |
local var |
if passTable then |
if type(passTable.get) == "function" then |
var = passTable.get(passValue) |
else |
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 |
if type(options_p.get) == "function" then |
var = options_p.get(passValue) |
else |
if type(options.get) == "function" then |
var = options.get() |
else |
local handler = options.handler or self |
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) |
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 |
return |
end |
else |
printUsage(self, handler, realOptions, options, path, args) |
printUsage(self, handler, realOptions, options, path, args, passValue) |
return |
end |
elseif kind == "color" then |
print(("|cffffff7f%s:|r %s {0-1} {0-1} {0-1}%s"):format(USAGE, path, options.hasAlpha and " {0-1}" or "")) |
return |
end |
if passTable then |
if type(passTable.set) == "function" then |
passTable.set(passValue, r,g,b,a) |
if type(options_p.set) == "function" then |
if passValue then |
options_p.set(passValue, r,g,b,a) |
else |
if type(handler[passTable.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.set))) |
end |
handler[passTable.set](handler, passValue, r,g,b,a) |
options_p.set(r,g,b,a) |
end |
else |
if type(options.set) == "function" then |
options.set(r,g,b,a) |
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 |
if type(handler[options.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.set))) |
end |
handler[options.set](handler, r,g,b,a) |
handler[options_p.set](handler, r,g,b,a) |
end |
end |
local r,g,b,a |
if passTable then |
if type(passTable.get) == "function" then |
r,g,b,a = passTable.get(passValue) |
else |
if type(handler[passTable.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get))) |
end |
r,g,b,a = handler[passTable.get](handler, passValue) |
end |
if type(options_p.get) == "function" then |
r,g,b,a = options_p.get(passValue) |
else |
if type(options.get) == "function" then |
r,g,b,a = options.get() |
else |
if type(handler[options.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
r,g,b,a = handler[options.get](handler) |
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 |
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 passTable then |
if type(passTable.get) == "function" then |
r,g,b,a = passTable.get(passValue) |
else |
if type(handler[passTable.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get))) |
end |
r,g,b,a = handler[passTable.get](handler, passValue) |
end |
if type(options_p.get) == "function" then |
r,g,b,a = options_p.get(passValue) |
else |
if type(options.get) == "function" then |
r,g,b,a = options.get() |
else |
if type(handler[options.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
r,g,b,a = handler[options.get](handler) |
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() |
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 |
t.realOptions = realOptions |
t.hasAlpha = options.hasAlpha |
t.handler = handler |
t.set = passTable and passTable.set or options.set |
t.get = passTable and passTable.get or options.get |
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() |
end |
end |
end |
ColorPickerFrame.func = colorFunc |
ColorPickerFrame.hasOpacity = options.hasAlpha |
if options.hasAlpha then |
ColorPickerFrame.opacity = 1 - a |
end |
ColorPickerFrame:SetColorRGB(r,g,b) |
if not colorCancelFunc then |
colorCancelFunc = function() |
if t.hasAlpha then |
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) |
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 |
this = _G_this |
if Dewdrop then |
Dewdrop:Refresh(1) |
Dewdrop:Refresh(2) |
Dewdrop:Refresh(3) |
Dewdrop:Refresh(4) |
Dewdrop:Refresh(5) |
Dewdrop:Refresh() |
end |
end |
local external |
function AceConsole:RegisterChatCommand(slashCommands, options, name) |
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 #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 |
end |
end |
if not options then |
options = { |
type = 'group', |
handler = self |
} |
end |
if type(options) == "table" then |
local err, position = validateOptions(options) |
if err then |
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 |
local k = k |
handler = function(msg) |
return _G[k](msg) |
handler = function(msg, chatFrame) |
return _G[k](msg, chatFrame) |
end |
break |
end |
end |
else |
function handler(msg) |
function handler(msg, chatFrame) |
handlerFunc(self, chat, msg, options) |
end |
end |
if not _G.SlashCmdList then |
_G.SlashCmdList = {} |
end |
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 |
end |
end |
end |
local i = 0 |
for _,command in ipairs(slashCommands) do |
local good = true |
for k in pairs(_G.SlashCmdList) do |
local j = 0 |
while true do |
j = j + 1 |
local cmd = _G["SLASH_" .. k .. j] |
if not cmd then |
break |
end |
if command:lower() == cmd:lower() then |
good = false |
break |
end |
end |
if not good then |
break |
end |
end |
if good then |
i = i + 1 |
_G["SLASH_"..name..i] = command |
if command:lower() ~= command then |
i = i + 1 |
_G["SLASH_"..name..i] = command |
if command:lower() ~= command then |
i = i + 1 |
_G["SLASH_"..name..i] = command:lower() |
end |
_G["SLASH_"..name..i] = command:lower() |
end |
end |
end |
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 |
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) |
end |
options.handler = handler |
local class = handler.class |
if not class then |
self:error("Cannot retrieve AceOptions tables from a non-object argument #2") |
end |
while class and class ~= AceOO.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 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 |
end |
end |
end |
class = class.super |
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 |
if major == "AceEvent-2.0" then |
if not AceEvent then |
AceEvent = instance |
AceEvent:embed(self) |
end |
elseif major == "AceTab-2.0" then |
local handler = v.handler or handler |
if hidden then |
if type(hidden) == "function" then |
hidden = hidden() |
hidden = hidden(v.passValue) |
elseif type(hidden) == "string" then |
local f = hidden |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
self:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
hidden = handler[f](handler) |
hidden = handler[f](handler, v.passValue) |
if neg then |
hidden = not hidden |
end |
local disabled = hidden or v.disabled |
if disabled then |
if type(disabled) == "function" then |
disabled = disabled() |
disabled = disabled(v.passValue) |
elseif type(disabled) == "string" then |
local f = disabled |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
self:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
disabled = handler[f](handler) |
disabled = handler[f](handler, v.passValue) |
if neg then |
disabled = not disabled |
end |
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, not gcs or gcs ~= "", gcs) |
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 |
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 |
self:RegisterChatCommand(false, options, name) |
end |
end |
self:RegisterChatCommand({ "/reload", "/rl", "/reloadui" }, function() ReloadUI() end, "RELOAD") |
self:RegisterChatCommand({ "/gm" }, function() ToggleHelpFrame() end, "GM") |
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 |
f() |
end |
end, "PRINT") |
self:activate(oldLib, oldDeactivate) |
if oldDeactivate then |
oldDeactivate(oldLib) |
end |