WoWInterface SVN RecapFu

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk/FuBar_RecapFu/libs/AceConsole-2.0
    from Rev 2 to Rev 3
    Reverse comparison

Rev 2 → Rev 3

AceConsole-2.0.toc New file
0,0 → 1,16
## 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
Property changes : Added: svn:eol-style + native
AceConsole-2.0.lua
1,6 → 1,6
--[[
--[[
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/
14,13 → 14,17
]]
 
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" }
51,16 → 55,16
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"
77,16 → 81,16
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"
100,6 → 104,19
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"
197,7 → 214,7
return {}
end
end
 
 
function del(t)
for k in pairs(t) do
t[k] = nil
241,7 → 258,7
 
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"
249,6 → 266,12
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
506,17 → 529,20
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
527,7 → 553,7
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
537,7 → 563,7
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
548,7 → 574,7
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
575,7 → 601,16
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
584,7 → 619,7
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)
723,10 → 758,6
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
831,7 → 862,7
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
989,14 → 1020,14
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("^~(.-)$")
1006,7 → 1037,7
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
1016,7 → 1047,7
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("^~(.-)$")
1026,7 → 1057,7
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
1051,7 → 1082,11
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
1066,7 → 1101,11
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
1075,12 → 1114,16
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
1089,17 → 1132,21
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
1182,16 → 1229,16
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
1306,16 → 1353,23
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("^~(.-)$")
1325,7 → 1379,7
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
1503,7 → 1557,7
t.timeout = 0
t.whileDead = 1
t.hideOnEscape = 1
 
 
StaticPopup_Show("ACECONSOLE20_CONFIRM_DIALOG")
end
 
1514,14 → 1568,24
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("^~(.-)$")
1531,7 → 1595,7
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
1541,7 → 1605,7
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("^~(.-)$")
1551,14 → 1615,14
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
1627,68 → 1691,47
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]]
1702,87 → 1745,63
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
1813,14 → 1832,14
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
1828,124 → 1847,70
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
1967,7 → 1932,7
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
1994,76 → 1959,48
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
2072,7 → 2009,7
return
end
else
printUsage(self, handler, realOptions, options, path, args)
printUsage(self, handler, realOptions, options, path, args, passValue)
return
end
elseif kind == "color" then
2109,47 → 2046,34
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
2163,30 → 2087,19
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()
2241,7 → 2154,7
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
2258,13 → 2171,13
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()
2306,7 → 2219,7
end
end
end
 
 
ColorPickerFrame.func = colorFunc
ColorPickerFrame.hasOpacity = options.hasAlpha
if options.hasAlpha then
2314,7 → 2227,7
ColorPickerFrame.opacity = 1 - a
end
ColorPickerFrame:SetColorRGB(r,g,b)
 
 
if not colorCancelFunc then
colorCancelFunc = function()
if t.hasAlpha then
2360,33 → 2273,52
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
2407,7 → 2339,7
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")
2419,7 → 2351,7
end
end
end
 
 
if not options then
options = {
type = 'group',
2427,7 → 2359,7
handler = self
}
end
 
 
if type(options) == "table" then
local err, position = validateOptions(options)
if err then
2437,40 → 2369,40
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
2485,7 → 2417,7
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
2498,34 → 2430,14
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
2533,7 → 2445,7
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
2548,8 → 2460,14
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)
2563,24 → 2481,10
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
2594,8 → 2498,40
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
 
2639,7 → 2575,7
if major == "AceEvent-2.0" then
if not AceEvent then
AceEvent = instance
 
 
AceEvent:embed(self)
end
elseif major == "AceTab-2.0" then
2656,7 → 2592,7
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("^~(.-)$")
2666,7 → 2602,7
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
2675,7 → 2611,7
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("^~(.-)$")
2685,7 → 2621,7
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
2701,7 → 2637,7
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
2711,12 → 2647,12
 
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
2724,9 → 2660,9
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
2741,9 → 2677,9
f()
end
end, "PRINT")
 
 
self:activate(oldLib, oldDeactivate)
 
 
if oldDeactivate then
oldDeactivate(oldLib)
end