mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-28 08:54:43 +00:00
4
This commit is contained in:
@@ -9,16 +9,3 @@
|
|||||||
Libraries\Load_Libraries.xml
|
Libraries\Load_Libraries.xml
|
||||||
locales\load_locales.xml
|
locales\load_locales.xml
|
||||||
core.lua
|
core.lua
|
||||||
General.lua
|
|
||||||
actionbars.lua
|
|
||||||
auras.lua
|
|
||||||
bags.lua
|
|
||||||
chat.lua
|
|
||||||
datatexts.lua
|
|
||||||
filters.lua
|
|
||||||
nameplates.lua
|
|
||||||
skins.lua
|
|
||||||
tooltip.lua
|
|
||||||
unitframes.lua
|
|
||||||
DataBars.lua
|
|
||||||
maps.lua
|
|
||||||
@@ -12,15 +12,14 @@ Very light wrapper library that combines all the AceConfig subcomponents into on
|
|||||||
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local MAJOR, MINOR = "AceConfig-3.0", 2
|
local cfgreg = LibStub("AceConfigRegistry-3.0-ElvUI")
|
||||||
|
local cfgcmd = LibStub("AceConfigCmd-3.0-ElvUI")
|
||||||
|
|
||||||
|
local MAJOR, MINOR = "AceConfig-3.0-ElvUI", 2
|
||||||
local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
|
local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
|
||||||
|
|
||||||
if not AceConfig then return end
|
if not AceConfig then return end
|
||||||
|
|
||||||
AceConfig.embeds = AceConfig.embeds or {}
|
|
||||||
|
|
||||||
local cfgreg = LibStub("AceConfigRegistry-3.0")
|
|
||||||
local cfgcmd = LibStub("AceConfigCmd-3.0")
|
|
||||||
--TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true)
|
--TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true)
|
||||||
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true)
|
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true)
|
||||||
|
|
||||||
@@ -44,27 +43,16 @@ local pcall, error, type, pairs = pcall, error, type, pairs
|
|||||||
-- local AceConfig = LibStub("AceConfig-3.0")
|
-- local AceConfig = LibStub("AceConfig-3.0")
|
||||||
-- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
|
-- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
|
||||||
function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
|
function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
|
||||||
if self == AceConfig then
|
|
||||||
error([[Usage: RegisterOptionsTable(appName, options[, slashcmd]): 'self' - use your own 'self']], 2)
|
|
||||||
end
|
|
||||||
local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
|
local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
|
||||||
if not ok then error(msg, 2) end
|
if not ok then error(msg, 2) end
|
||||||
|
|
||||||
if slashcmd then
|
if slashcmd then
|
||||||
if type(slashcmd) == "table" then
|
if type(slashcmd) == "table" then
|
||||||
for _,cmd in pairs(slashcmd) do
|
for _,cmd in pairs(slashcmd) do
|
||||||
cfgcmd.CreateChatCommand(self, cmd, appName)
|
cfgcmd:CreateChatCommand(cmd, appName)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
cfgcmd.CreateChatCommand(self, slashcmd, appName)
|
cfgcmd:CreateChatCommand(slashcmd, appName)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function AceConfig:Embed(target)
|
|
||||||
target["RegisterOptionsTable"] = self["RegisterOptionsTable"]
|
|
||||||
end
|
|
||||||
|
|
||||||
for addon in pairs(AceConfig.embeds) do
|
|
||||||
AceConfig:Embed(addon)
|
|
||||||
end
|
|
||||||
+118
-185
@@ -14,37 +14,29 @@ REQUIRES: AceConsole-3.0 for command registration (loaded on demand)
|
|||||||
|
|
||||||
-- TODO: plugin args
|
-- TODO: plugin args
|
||||||
|
|
||||||
|
local cfgreg = LibStub("AceConfigRegistry-3.0-ElvUI")
|
||||||
|
|
||||||
local MAJOR, MINOR = "AceConfigCmd-3.0", 13
|
local MAJOR, MINOR = "AceConfigCmd-3.0-ElvUI", 2
|
||||||
local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR)
|
local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR)
|
||||||
|
|
||||||
if not AceConfigCmd then return end
|
if not AceConfigCmd then return end
|
||||||
|
|
||||||
local AceCore = LibStub("AceCore-3.0")
|
|
||||||
local Dispatchers = AceCore.Dispatchers
|
|
||||||
local strtrim = AceCore.strtrim
|
|
||||||
local strsplit = AceCore.strsplit
|
|
||||||
local new, del = AceCore.new, AceCore.del
|
|
||||||
local wipe = AceCore.wipe
|
|
||||||
|
|
||||||
AceConfigCmd.commands = AceConfigCmd.commands or {}
|
AceConfigCmd.commands = AceConfigCmd.commands or {}
|
||||||
AceConfigCmd.embeds = AceConfigCmd.embeds or {}
|
|
||||||
local commands = AceConfigCmd.commands
|
local commands = AceConfigCmd.commands
|
||||||
|
|
||||||
local cfgreg = LibStub("AceConfigRegistry-3.0")
|
|
||||||
local AceConsole -- LoD
|
local AceConsole -- LoD
|
||||||
local AceConsoleName = "AceConsole-3.0"
|
local AceConsoleName = "AceConsole-3.0"
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local strbyte, strsub = string.byte, string.sub
|
local strsub, strsplit, strlower, strmatch, strtrim, strupper = string.sub, string.split, string.lower, string.match, string.trim, string.upper
|
||||||
local strlen, strupper, strlower = string.len, string.upper, string.lower
|
local format, tonumber, tostring, len, find, byte = string.format, tonumber, tostring, string.len, string.find, string.byte
|
||||||
local strfind, strgfind, strgsub = string.find, string.gfind, string.gsub
|
local tsort, tinsert, tgetn = table.sort, table.insert, table.getn
|
||||||
|
local select, pairs, next, type, unpack = select, pairs, next, type, unpack
|
||||||
local format = string.format
|
local error, assert = error, assert
|
||||||
local tsort, tinsert, tgetn, tremove = table.sort, table.insert, table.getn, table.remove
|
local mod = math.mod
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local _G = AceCore._G
|
local _G = getfenv()
|
||||||
|
|
||||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||||
-- List them here for Mikk's FindGlobals script
|
-- List them here for Mikk's FindGlobals script
|
||||||
@@ -69,7 +61,18 @@ local handlermsg = "expected a table"
|
|||||||
local functypes = {["function"]=true, ["string"]=true}
|
local functypes = {["function"]=true, ["string"]=true}
|
||||||
local funcmsg = "expected function or member name"
|
local funcmsg = "expected function or member name"
|
||||||
|
|
||||||
local pickfirstset = AceCore.pickfirstset
|
|
||||||
|
-- pickfirstset() - picks the first non-nil value and returns it
|
||||||
|
|
||||||
|
local function pickfirstset(...)
|
||||||
|
local args = unpack(arg)
|
||||||
|
for i=1,select("#", args) do
|
||||||
|
if select(i,args)~=nil then
|
||||||
|
return select(i,args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- err() - produce real error() regarding malformed options tables etc
|
-- err() - produce real error() regarding malformed options tables etc
|
||||||
|
|
||||||
@@ -89,26 +92,23 @@ end
|
|||||||
|
|
||||||
-- callmethod() - call a given named method (e.g. "get", "set") with given arguments
|
-- callmethod() - call a given named method (e.g. "get", "set") with given arguments
|
||||||
|
|
||||||
|
local function callmethod(info, inputpos, tab, methodtype, ...)
|
||||||
|
|
||||||
local function callmethod(info, inputpos, tab, methodtype, argc, a1, a2, a3, a4)
|
|
||||||
local method = info[methodtype]
|
local method = info[methodtype]
|
||||||
if not method then
|
if not method then
|
||||||
err(info, inputpos, "'"..methodtype.."': not set")
|
err(info, inputpos, "'"..methodtype.."': not set")
|
||||||
end
|
end
|
||||||
|
|
||||||
argc = argc or 0
|
|
||||||
info.arg = tab.arg
|
info.arg = tab.arg
|
||||||
info.option = tab
|
info.option = tab
|
||||||
info.type = tab.type
|
info.type = tab.type
|
||||||
|
|
||||||
if type(method)=="function" then
|
if type(method)=="function" then
|
||||||
return Dispatchers[argc+1](method, info, a1, a2, a3, a4)
|
return method(info, unpack(arg))
|
||||||
elseif type(method)=="string" then
|
elseif type(method)=="string" then
|
||||||
if type(info.handler[method])~="function" then
|
if type(info.handler[method])~="function" then
|
||||||
err(info, inputpos, "'"..methodtype.."': '"..method.."' is not a member function of "..tostring(info.handler))
|
err(info, inputpos, "'"..methodtype.."': '"..method.."' is not a member function of "..tostring(info.handler))
|
||||||
end
|
end
|
||||||
return Dispatchers[argc+2](info.handler[method], info.handler, info, a1, a2, a3, a4)
|
return info.handler[method](info.handler, info, unpack(arg))
|
||||||
else
|
else
|
||||||
assert(false) -- type should have already been checked on read
|
assert(false) -- type should have already been checked on read
|
||||||
end
|
end
|
||||||
@@ -116,8 +116,7 @@ end
|
|||||||
|
|
||||||
-- callfunction() - call a given named function (e.g. "name", "desc") with given arguments
|
-- callfunction() - call a given named function (e.g. "name", "desc") with given arguments
|
||||||
|
|
||||||
-- Ace3v: the variable arguments are currently unused, so we removed it
|
local function callfunction(info, tab, methodtype, ...)
|
||||||
local function callfunction(info, tab, methodtype)
|
|
||||||
local method = tab[methodtype]
|
local method = tab[methodtype]
|
||||||
|
|
||||||
info.arg = tab.arg
|
info.arg = tab.arg
|
||||||
@@ -125,18 +124,17 @@ local function callfunction(info, tab, methodtype)
|
|||||||
info.type = tab.type
|
info.type = tab.type
|
||||||
|
|
||||||
if type(method)=="function" then
|
if type(method)=="function" then
|
||||||
return method(info)
|
return method(info, unpack(arg))
|
||||||
else
|
else
|
||||||
assert(false) -- type should have already been checked on read
|
assert(false) -- type should have already been checked on read
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- do_final() - do the final step (set/execute) along with validation and confirmation
|
-- do_final() - do the final step (set/execute) along with validation and confirmation
|
||||||
-- Ace3v: experimental
|
|
||||||
-- @param argc number of variable arguments
|
local function do_final(info, inputpos, tab, methodtype, ...)
|
||||||
local function do_final(info, inputpos, tab, methodtype, argc, a1, a2, a3, a4) -- currently maximum 4 arguments
|
|
||||||
if info.validate then
|
if info.validate then
|
||||||
local res = callmethod(info,inputpos,tab,"validate",argc,a1,a2,a3,a4)
|
local res = callmethod(info,inputpos,tab,"validate",unpack(arg))
|
||||||
if type(res)=="string" then
|
if type(res)=="string" then
|
||||||
usererr(info, inputpos, "'"..strsub(info.input, inputpos).."' - "..res)
|
usererr(info, inputpos, "'"..strsub(info.input, inputpos).."' - "..res)
|
||||||
return
|
return
|
||||||
@@ -144,7 +142,7 @@ local function do_final(info, inputpos, tab, methodtype, argc, a1, a2, a3, a4) -
|
|||||||
end
|
end
|
||||||
-- console ignores .confirm
|
-- console ignores .confirm
|
||||||
|
|
||||||
callmethod(info,inputpos,tab,methodtype,argc,a1,a2,a3,a4)
|
callmethod(info,inputpos,tab,methodtype, unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -167,6 +165,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- iterateargs(tab) - custom iterator that iterates both t.args and t.plugins.*
|
-- iterateargs(tab) - custom iterator that iterates both t.args and t.plugins.*
|
||||||
|
local dummytable={}
|
||||||
|
|
||||||
local function iterateargs(tab)
|
local function iterateargs(tab)
|
||||||
if not tab.plugins then
|
if not tab.plugins then
|
||||||
return pairs(tab.args)
|
return pairs(tab.args)
|
||||||
@@ -191,21 +191,17 @@ local function iterateargs(tab)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getValueFromTab(info, inputpos, tab, key)
|
|
||||||
local v = tab[key]
|
|
||||||
if type(v) == "function" or type(v) == "string" then
|
|
||||||
info[key] = v
|
|
||||||
v = callmethod(info, inputpos, tab, key)
|
|
||||||
info[key] = nil
|
|
||||||
end
|
|
||||||
return v
|
|
||||||
end
|
|
||||||
|
|
||||||
local function checkhidden(info, inputpos, tab)
|
local function checkhidden(info, inputpos, tab)
|
||||||
if tab.cmdHidden~=nil then
|
if tab.cmdHidden~=nil then
|
||||||
return tab.cmdHidden
|
return tab.cmdHidden
|
||||||
end
|
end
|
||||||
return getValueFromTab(info, inputpos, tab, "hidden")
|
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
|
end
|
||||||
|
|
||||||
local function showhelp(info, inputpos, tab, depth, noHead)
|
local function showhelp(info, inputpos, tab, depth, noHead)
|
||||||
@@ -213,8 +209,8 @@ local function showhelp(info, inputpos, tab, depth, noHead)
|
|||||||
print("|cff33ff99"..info.appName.."|r: Arguments to |cffffff78/"..info[0].."|r "..strsub(info.input,1,inputpos-1)..":")
|
print("|cff33ff99"..info.appName.."|r: Arguments to |cffffff78/"..info[0].."|r "..strsub(info.input,1,inputpos-1)..":")
|
||||||
end
|
end
|
||||||
|
|
||||||
local sortTbl = new() -- [1..n]=name
|
local sortTbl = {} -- [1..n]=name
|
||||||
local refTbl = new() -- [name]=tableref
|
local refTbl = {} -- [name]=tableref
|
||||||
|
|
||||||
for k,v in iterateargs(tab) do
|
for k,v in iterateargs(tab) do
|
||||||
if not refTbl[k] then -- a plugin overriding something in .args
|
if not refTbl[k] then -- a plugin overriding something in .args
|
||||||
@@ -228,16 +224,16 @@ local function showhelp(info, inputpos, tab, depth, noHead)
|
|||||||
local o2 = refTbl[two].order or 100
|
local o2 = refTbl[two].order or 100
|
||||||
if type(o1) == "function" or type(o1) == "string" then
|
if type(o1) == "function" or type(o1) == "string" then
|
||||||
info.order = o1
|
info.order = o1
|
||||||
tinsert(info, one)
|
info[tgetn(info)+1] = one
|
||||||
o1 = callmethod(info, inputpos, refTbl[one], "order")
|
o1 = callmethod(info, inputpos, refTbl[one], "order")
|
||||||
tremove(info)
|
info[tgetn(info)] = nil
|
||||||
info.order = nil
|
info.order = nil
|
||||||
end
|
end
|
||||||
if type(o2) == "function" or type(o1) == "string" then
|
if type(o2) == "function" or type(o1) == "string" then
|
||||||
info.order = o2
|
info.order = o2
|
||||||
tinsert(info, two)
|
info[tgetn(info)+1] = two
|
||||||
o2 = callmethod(info, inputpos, refTbl[two], "order")
|
o2 = callmethod(info, inputpos, refTbl[two], "order")
|
||||||
tremove(info)
|
info[tgetn(info)] = nil
|
||||||
info.order = nil
|
info.order = nil
|
||||||
end
|
end
|
||||||
if o1<0 and o2<0 then return o1<o2 end
|
if o1<0 and o2<0 then return o1<o2 end
|
||||||
@@ -260,22 +256,21 @@ local function showhelp(info, inputpos, tab, depth, noHead)
|
|||||||
if type(desc) == "function" then
|
if type(desc) == "function" then
|
||||||
desc = callfunction(info, v, 'desc')
|
desc = callfunction(info, v, 'desc')
|
||||||
end
|
end
|
||||||
if v.type == "group" and pickfirstset(3, v.cmdInline, v.inline, false) then
|
if v.type == "group" and pickfirstset(v.cmdInline, v.inline, false) then
|
||||||
print(" "..(desc or name)..":")
|
print(" "..(desc or name)..":")
|
||||||
local oldhandler,oldhandler_at = getparam(info, inputpos, v, depth, "handler", handlertypes, handlermsg)
|
local oldhandler,oldhandler_at = getparam(info, inputpos, v, depth, "handler", handlertypes, handlermsg)
|
||||||
showhelp(info, inputpos, v, depth, true)
|
showhelp(info, inputpos, v, depth, true)
|
||||||
info.handler,info.handler_at = oldhandler,oldhandler_at
|
info.handler,info.handler_at = oldhandler,oldhandler_at
|
||||||
else
|
else
|
||||||
local key = strgsub(k, " ", "_")
|
local key = gsub(k, " ", "_")
|
||||||
print(" |cffffff78"..key.."|r - "..(desc or name or ""))
|
print(" |cffffff78"..key.."|r - "..(desc or name or ""))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
del(sortTbl) -- Ace3v: release the tables
|
|
||||||
del(refTbl)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function keybindingValidateFunc(text)
|
local function keybindingValidateFunc(text)
|
||||||
if text == nil or text == "NONE" then
|
if text == nil or text == "NONE" then
|
||||||
return nil
|
return nil
|
||||||
@@ -318,7 +313,7 @@ local function keybindingValidateFunc(text)
|
|||||||
if text == "" then
|
if text == "" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if not strfind(text,"^F%d+$") and text ~= "CAPSLOCK" and strlen(text) ~= 1 and (strbyte(text) < 128 or strlen(text) > 4) and not _G["KEY_" .. text] then
|
if not find(text, "^F%d+$") and text ~= "CAPSLOCK" and len(text) ~= 1 and (byte(text) < 128 or len(text) > 4) and not _G["KEY_" .. text] then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local s = text
|
local s = text
|
||||||
@@ -364,7 +359,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
if tab.plugins and type(tab.plugins)~="table" then err(info,inputpos) end
|
if tab.plugins and type(tab.plugins)~="table" then err(info,inputpos) end
|
||||||
|
|
||||||
-- grab next arg from input
|
-- grab next arg from input
|
||||||
local _,nextpos,arg = strfind(info.input, " *([^ ]+) *", inputpos)
|
local _,nextpos,arg = find(info.input, " *([^ ]+) *", inputpos)
|
||||||
if not arg then
|
if not arg then
|
||||||
showhelp(info, inputpos, tab, depth)
|
showhelp(info, inputpos, tab, depth)
|
||||||
return
|
return
|
||||||
@@ -376,17 +371,17 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
if not(type(k)=="string" and type(v)=="table" and type(v.type)=="string") then err(info,inputpos, "options table child '"..tostring(k).."' is malformed") end
|
if not(type(k)=="string" and type(v)=="table" and type(v.type)=="string") then err(info,inputpos, "options table child '"..tostring(k).."' is malformed") end
|
||||||
|
|
||||||
-- is this child an inline group? if so, traverse into it
|
-- is this child an inline group? if so, traverse into it
|
||||||
if v.type=="group" and pickfirstset(3, v.cmdInline, v.inline, false) then
|
if v.type=="group" and pickfirstset(v.cmdInline, v.inline, false) then
|
||||||
tinsert(info,k)
|
info[depth+1] = k
|
||||||
if handle(info, inputpos, v, depth+1, true)==false then
|
if handle(info, inputpos, v, depth+1, true)==false then
|
||||||
tremove(info)
|
info[depth+1] = nil
|
||||||
-- wasn't found in there, but that's ok, we just keep looking down here
|
-- wasn't found in there, but that's ok, we just keep looking down here
|
||||||
else
|
else
|
||||||
return -- done, name was found in inline group
|
return -- done, name was found in inline group
|
||||||
end
|
end
|
||||||
-- matching name and not a inline group
|
-- matching name and not a inline group
|
||||||
elseif strlower(arg)==strlower(strgsub(k, " ", "_")) then
|
elseif strlower(arg)==strlower(gsub(k, " ", "_")) then
|
||||||
tinsert(info,k)
|
info[depth+1] = k
|
||||||
return handle(info,nextpos,v,depth+1)
|
return handle(info,nextpos,v,depth+1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -419,21 +414,16 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
elseif tab.type=="input" then
|
elseif tab.type=="input" then
|
||||||
------------ input --------------------------------------------
|
------------ input --------------------------------------------
|
||||||
|
|
||||||
if str=="" and tab.nullable == false then
|
|
||||||
usererr(info, inputpos, "'"..str.."' - " .. L["invalid input"])
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local res = true
|
local res = true
|
||||||
if tab.pattern then
|
if tab.pattern then
|
||||||
if not(type(tab.pattern)=="string") then err(info, inputpos, "'pattern' - expected a string") end
|
if not(type(tab.pattern)=="string") then err(info, inputpos, "'pattern' - expected a string") end
|
||||||
if not strfind(str, tab.pattern) then
|
if not strmatch(str, tab.pattern) then
|
||||||
usererr(info, inputpos, "'"..str.."' - " .. L["invalid input"])
|
usererr(info, inputpos, "'"..str.."' - " .. L["invalid input"])
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do_final(info, inputpos, tab, "set", 1, str)
|
do_final(info, inputpos, tab, "set", str)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -472,63 +462,47 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
do_final(info, inputpos, tab, "set", 1, b)
|
do_final(info, inputpos, tab, "set", b)
|
||||||
|
|
||||||
|
|
||||||
elseif tab.type=="range" then
|
elseif tab.type=="range" then
|
||||||
------------ range --------------------------------------------
|
------------ range --------------------------------------------
|
||||||
local str = strtrim(strlower(str))
|
|
||||||
if str == "" then
|
|
||||||
-- TODO: Show current value
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local val = tonumber(str)
|
local val = tonumber(str)
|
||||||
if not val then
|
if not val then
|
||||||
usererr(info, inputpos, "'"..str.."' - "..L["expected number"])
|
usererr(info, inputpos, "'"..str.."' - "..L["expected number"])
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if type(info.step)=="number" then
|
||||||
local step = getValueFromTab(info, inputpos, tab, "step")
|
val = val- mod(val, info.step)
|
||||||
local min = getValueFromTab(info, inputpos, tab, "min")
|
|
||||||
|
|
||||||
if type(step)=="number" then
|
|
||||||
val = min + math.floor((val-min)/step) * step
|
|
||||||
end
|
end
|
||||||
|
if type(info.min)=="number" and val<info.min then
|
||||||
if type(min)=="number" and val<min then
|
usererr(info, inputpos, val.." - "..format(L["must be equal to or higher than %s"], tostring(info.min)) )
|
||||||
usererr(info, inputpos, val.." - "..format(L["must be equal to or higher than %s"], tostring(min)) )
|
return
|
||||||
|
end
|
||||||
|
if type(info.max)=="number" and val>info.max then
|
||||||
|
usererr(info, inputpos, val.." - "..format(L["must be equal to or lower than %s"], tostring(info.max)) )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local max = getValueFromTab(info, inputpos, tab, "max")
|
do_final(info, inputpos, tab, "set", val)
|
||||||
if type(max)=="number" and val>max then
|
|
||||||
usererr(info, inputpos, val.." - "..format(L["must be equal to or lower than %s"], tostring(max)) )
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
do_final(info, inputpos, tab, "set", 1, val)
|
|
||||||
|
|
||||||
|
|
||||||
elseif tab.type=="select" then
|
elseif tab.type=="select" then
|
||||||
------------ select ------------------------------------
|
------------ select ------------------------------------
|
||||||
local str = strtrim(strlower(str))
|
local str = strtrim(strlower(str))
|
||||||
|
|
||||||
local values = getValueFromTab(info, inputpos, tab, "values")
|
local values = tab.values
|
||||||
|
if type(values) == "function" or type(values) == "string" then
|
||||||
if str == "" then
|
info.values = values
|
||||||
-- Ace3v: it is possbile to not have a current value
|
values = callmethod(info, inputpos, tab, "values")
|
||||||
-- we do this only for select but not for multiselect
|
info.values = nil
|
||||||
local b = tab.get
|
|
||||||
if type(b) == "function" or type(b) == "string" then
|
|
||||||
b = callmethod(info, inputpos, tab, "get")
|
|
||||||
else
|
|
||||||
b = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if str == "" then
|
||||||
|
local b = callmethod(info, inputpos, tab, "get")
|
||||||
local fmt = "|cffffff78- [%s]|r %s"
|
local fmt = "|cffffff78- [%s]|r %s"
|
||||||
local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
|
local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
|
||||||
print(L["Options for |cffffff78"..info[tgetn(info)].."|r:"])
|
print(L["Options for |cffffff78"..info[thetn(info)].."|r:"])
|
||||||
for k, v in pairs(values) do
|
for k, v in pairs(values) do
|
||||||
if b == k then
|
if b == k then
|
||||||
print(format(fmt_sel, k, v))
|
print(format(fmt_sel, k, v))
|
||||||
@@ -536,7 +510,6 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
print(format(fmt, k, v))
|
print(format(fmt, k, v))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if tab.valuesTableDestroyable then del(values) end
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -548,42 +521,45 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if tab.valuesTableDestroyable then del(values) end
|
|
||||||
if not ok then
|
if not ok then
|
||||||
usererr(info, inputpos, "'"..str.."' - "..L["unknown selection"])
|
usererr(info, inputpos, "'"..str.."' - "..L["unknown selection"])
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
do_final(info, inputpos, tab, "set", 1, str)
|
do_final(info, inputpos, tab, "set", str)
|
||||||
|
|
||||||
elseif tab.type=="multiselect" then
|
elseif tab.type=="multiselect" then
|
||||||
------------ multiselect -------------------------------------------
|
------------ multiselect -------------------------------------------
|
||||||
local str = strtrim(strlower(str))
|
local str = strtrim(strlower(str))
|
||||||
|
|
||||||
local values = getValueFromTab(info, inputpos, tab, "values")
|
local values = tab.values
|
||||||
|
if type(values) == "function" or type(values) == "string" then
|
||||||
|
info.values = values
|
||||||
|
values = callmethod(info, inputpos, tab, "values")
|
||||||
|
info.values = nil
|
||||||
|
end
|
||||||
|
|
||||||
if str == "" then
|
if str == "" then
|
||||||
local fmt = "|cffffff78- [%s]|r %s"
|
local fmt = "|cffffff78- [%s]|r %s"
|
||||||
local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
|
local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
|
||||||
print(L["Options for |cffffff78"..info[tgetn(info)].."|r (multiple possible):"])
|
print(L["Options for |cffffff78"..info[tgetn(info)].."|r (multiple possible):"])
|
||||||
for k, v in pairs(values) do
|
for k, v in pairs(values) do
|
||||||
if callmethod(info, inputpos, tab, "get", 1, k) then
|
if callmethod(info, inputpos, tab, "get", k) then
|
||||||
print(format(fmt_sel, k, v))
|
print(format(fmt_sel, k, v))
|
||||||
else
|
else
|
||||||
print(format(fmt, k, v))
|
print(format(fmt, k, v))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if tab.valuesTableDestroyable then del(values) end
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--build a table of the selections, checking that they exist
|
--build a table of the selections, checking that they exist
|
||||||
--parse for =on =off =default in the process
|
--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
|
--table will be key = true for options that should toggle, key = [on|off|default] for options to be set
|
||||||
local sels = new()
|
local sels = {}
|
||||||
for v in strgfind(str, "[^ ]+") do
|
for v in gmatch(str, "[^ ]+") do
|
||||||
--parse option=on etc
|
--parse option=on etc
|
||||||
local _, _, opt, val = strfind(v, '(.+)=(.+)')
|
local opt, val = strmatch(v, '(.+)=(.+)')
|
||||||
--get option if toggling
|
--get option if toggling
|
||||||
if not opt then
|
if not opt then
|
||||||
opt = v
|
opt = v
|
||||||
@@ -598,7 +574,6 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if tab.valuesTableDestroyable then del(values) end
|
|
||||||
|
|
||||||
if not ok then
|
if not ok then
|
||||||
usererr(info, inputpos, "'"..opt.."' - "..L["unknown selection"])
|
usererr(info, inputpos, "'"..opt.."' - "..L["unknown selection"])
|
||||||
@@ -616,7 +591,6 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
else
|
else
|
||||||
usererr(info, inputpos, format(L["'%s' '%s' - expected 'on' or 'off', or no argument to toggle."], v, val))
|
usererr(info, inputpos, format(L["'%s' '%s' - expected 'on' or 'off', or no argument to toggle."], v, val))
|
||||||
end
|
end
|
||||||
del(sels)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -630,7 +604,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
|
|
||||||
if (val == true) then
|
if (val == true) then
|
||||||
--toggle the option
|
--toggle the option
|
||||||
local b = callmethod(info, inputpos, tab, "get", 1, opt)
|
local b = callmethod(info, inputpos, tab, "get", opt)
|
||||||
|
|
||||||
if tab.tristate then
|
if tab.tristate then
|
||||||
--cycle in true, nil, false order
|
--cycle in true, nil, false order
|
||||||
@@ -656,9 +630,8 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do_final(info, inputpos, tab, "set", 2, opt, newval)
|
do_final(info, inputpos, tab, "set", opt, newval)
|
||||||
end
|
end
|
||||||
del(sels)
|
|
||||||
|
|
||||||
|
|
||||||
elseif tab.type=="color" then
|
elseif tab.type=="color" then
|
||||||
@@ -669,17 +642,22 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local _, r, g, b, a
|
local r, g, b, a
|
||||||
|
|
||||||
local hasAlpha = getValueFromTab(info, inputpos, tab, 'hasAlpha')
|
local hasAlpha = tab.hasAlpha
|
||||||
|
if type(hasAlpha) == "function" or type(hasAlpha) == "string" then
|
||||||
|
info.hasAlpha = hasAlpha
|
||||||
|
hasAlpha = callmethod(info, inputpos, tab, 'hasAlpha')
|
||||||
|
info.hasAlpha = nil
|
||||||
|
end
|
||||||
|
|
||||||
if hasAlpha then
|
if hasAlpha then
|
||||||
if strlen(str) == 8 and strfind(str, "^%x*$") then
|
if len(str) == 8 and find(str, "^%x*$") then
|
||||||
--parse a hex string
|
--parse a hex string
|
||||||
r,g,b,a = tonumber(strsub(str, 1, 2), 16) / 255, tonumber(strsub(str, 3, 4), 16) / 255, tonumber(strsub(str, 5, 6), 16) / 255, tonumber(strsub(str, 7, 8), 16) / 255
|
r,g,b,a = tonumber(sub(str, 1, 2), 16) / 255, tonumber(sub(str, 3, 4), 16) / 255, tonumber(sub(str, 5, 6), 16) / 255
|
||||||
else
|
else
|
||||||
--parse seperate values
|
--parse seperate values
|
||||||
_,_,r,g,b,a = strfind(str, "^([%d%.]+) ([%d%.]+) ([%d%.]+) ([%d%.]+)$")
|
r,g,b,a = strmatch(str, "^([%d%.]+) ([%d%.]+) ([%d%.]+) ([%d%.]+)$")
|
||||||
r,g,b,a = tonumber(r), tonumber(g), tonumber(b), tonumber(a)
|
r,g,b,a = tonumber(r), tonumber(g), tonumber(b), tonumber(a)
|
||||||
end
|
end
|
||||||
if not (r and g and b and a) then
|
if not (r and g and b and a) then
|
||||||
@@ -701,12 +679,12 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
a = 1.0
|
a = 1.0
|
||||||
if strlen(str) == 6 and strfind(str, "^%x*$") then
|
if len(str) == 6 and find(str, "^%x*$") then
|
||||||
--parse a hex string
|
--parse a hex string
|
||||||
r,g,b = tonumber(strsub(str, 1, 2), 16) / 255, tonumber(strsub(str, 3, 4), 16) / 255, tonumber(strsub(str, 5, 6), 16) / 255
|
r,g,b = tonumber(sub(str, 1, 2), 16) / 255, tonumber(sub(str, 3, 4), 16) / 255, tonumber(sub(str, 5, 6), 16) / 255
|
||||||
else
|
else
|
||||||
--parse seperate values
|
--parse seperate values
|
||||||
_,_,r,g,b = strfind(str, "^([%d%.]+) ([%d%.]+) ([%d%.]+)$")
|
r,g,b = strmatch(str, "^([%d%.]+) ([%d%.]+) ([%d%.]+)$")
|
||||||
r,g,b = tonumber(r), tonumber(g), tonumber(b)
|
r,g,b = tonumber(r), tonumber(g), tonumber(b)
|
||||||
end
|
end
|
||||||
if not (r and g and b) then
|
if not (r and g and b) then
|
||||||
@@ -726,7 +704,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do_final(info, inputpos, tab, "set", 4, r,g,b,a)
|
do_final(info, inputpos, tab, "set", r,g,b,a)
|
||||||
|
|
||||||
elseif tab.type=="keybinding" then
|
elseif tab.type=="keybinding" then
|
||||||
------------ keybinding --------------------------------------------
|
------------ keybinding --------------------------------------------
|
||||||
@@ -741,7 +719,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
do_final(info, inputpos, tab, "set", 1, value)
|
do_final(info, inputpos, tab, "set", value)
|
||||||
|
|
||||||
elseif tab.type=="description" then
|
elseif tab.type=="description" then
|
||||||
------------ description --------------------
|
------------ description --------------------
|
||||||
@@ -771,9 +749,6 @@ end
|
|||||||
-- LibStub("AceConfigCmd-3.0").HandleCommand(MyAddon, "mychat", "MyOptions", input)
|
-- LibStub("AceConfigCmd-3.0").HandleCommand(MyAddon, "mychat", "MyOptions", input)
|
||||||
-- end
|
-- end
|
||||||
-- end
|
-- end
|
||||||
-- Ace3v: experimental, user should copy info table if he wanna reuse it outside
|
|
||||||
-- then handler
|
|
||||||
local info_ = {}
|
|
||||||
function AceConfigCmd:HandleCommand(slashcmd, appName, input)
|
function AceConfigCmd:HandleCommand(slashcmd, appName, input)
|
||||||
|
|
||||||
local optgetter = cfgreg:GetOptionsTable(appName)
|
local optgetter = cfgreg:GetOptionsTable(appName)
|
||||||
@@ -782,65 +757,32 @@ function AceConfigCmd:HandleCommand(slashcmd, appName, input)
|
|||||||
end
|
end
|
||||||
local options = assert( optgetter("cmd", MAJOR) )
|
local options = assert( optgetter("cmd", MAJOR) )
|
||||||
|
|
||||||
-- Ace3v: prevent user from using AceConfigCmd as self
|
local info = { -- Don't try to recycle this, it gets handed off to callbacks and whatnot
|
||||||
if self == AceConfigCmd then
|
[0] = slashcmd,
|
||||||
error([[Usage: HandleCommand("slashcmd", "appName", "input"): 'self' - use your own 'self']], 2)
|
appName = appName,
|
||||||
end
|
options = options,
|
||||||
|
input = input,
|
||||||
|
self = self,
|
||||||
|
handler = self,
|
||||||
|
uiType = "cmd",
|
||||||
|
uiName = MAJOR,
|
||||||
|
}
|
||||||
|
|
||||||
--local info = { -- Don't try to recycle this, it gets handed off to callbacks and whatnot
|
handle(info, 1, options, 0) -- (info, inputpos, table, depth)
|
||||||
-- [0] = slashcmd,
|
|
||||||
-- appName = appName,
|
|
||||||
-- options = options,
|
|
||||||
-- input = input,
|
|
||||||
-- self = self,
|
|
||||||
-- handler = self,
|
|
||||||
-- uiType = "cmd",
|
|
||||||
-- uiName = MAJOR,
|
|
||||||
--}
|
|
||||||
|
|
||||||
wipe(info_)
|
|
||||||
info_[0] = slashcmd
|
|
||||||
info_.appName = appName
|
|
||||||
info_.options = options
|
|
||||||
info_.input = input
|
|
||||||
info_.self = self
|
|
||||||
info_.handler = self
|
|
||||||
info_.uiType = "cmd"
|
|
||||||
info_.uiName = MAJOR
|
|
||||||
|
|
||||||
handle(info_, 1, options, 0) -- (info, inputpos, table, depth)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Utility function to create a slash command handler.
|
--- Utility function to create a slash command handler.
|
||||||
-- Also registers tab completion with AceTab
|
-- Also registers tab completion with AceTab
|
||||||
-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
|
-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
|
||||||
-- @param appName The application name as given to `:RegisterOptionsTable()`
|
-- @param appName The application name as given to `:RegisterOptionsTable()`
|
||||||
function AceConfigCmd:CreateChatCommand(slashcmd, appName, func)
|
function AceConfigCmd:CreateChatCommand(slashcmd, appName)
|
||||||
if not AceConsole then
|
if not AceConsole then
|
||||||
AceConsole = LibStub(AceConsoleName)
|
AceConsole = LibStub(AceConsoleName)
|
||||||
end
|
end
|
||||||
|
if AceConsole.RegisterChatCommand(self, slashcmd, function(input)
|
||||||
-- Ace3v: prevent user from using AceConfigCmd as self
|
|
||||||
if self == AceConfigCmd then
|
|
||||||
error([[Usage: CreateChatCommand("slashcmd", "appName"[, "func"]): 'self' - use your own 'self']], 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
local t = type(func)
|
|
||||||
|
|
||||||
-- Ace3v: make it possible to call another function
|
|
||||||
local handler
|
|
||||||
if t == "string" then
|
|
||||||
handler = function(input) self[func](self, input, slashcmd, appName) end
|
|
||||||
elseif t ~= "function" then
|
|
||||||
handler = function(input)
|
|
||||||
AceConfigCmd.HandleCommand(self, slashcmd, appName, input) -- upgradable
|
AceConfigCmd.HandleCommand(self, slashcmd, appName, input) -- upgradable
|
||||||
end
|
end,
|
||||||
else
|
true) then -- succesfully registered so lets get the command -> app table in
|
||||||
handler = func
|
|
||||||
end
|
|
||||||
|
|
||||||
if AceConsole.RegisterChatCommand(self, slashcmd, handler, true) then
|
|
||||||
-- succesfully registered so lets get the command -> app table in
|
|
||||||
commands[slashcmd] = appName
|
commands[slashcmd] = appName
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -852,12 +794,3 @@ end
|
|||||||
function AceConfigCmd:GetChatCommandOptions(slashcmd)
|
function AceConfigCmd:GetChatCommandOptions(slashcmd)
|
||||||
return commands[slashcmd]
|
return commands[slashcmd]
|
||||||
end
|
end
|
||||||
|
|
||||||
function AceConfigCmd:Embed(target)
|
|
||||||
target["HandleCommand"] = self["HandleCommand"]
|
|
||||||
target["CreateChatCommand"] = self["CreateChatCommand"]
|
|
||||||
end
|
|
||||||
|
|
||||||
for addon in pairs(AceConfigCmd.embeds) do
|
|
||||||
AceConfigCmd:Embed(addon)
|
|
||||||
end
|
|
||||||
+238
-180
@@ -1,20 +1,17 @@
|
|||||||
--- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables.
|
--- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables.
|
||||||
-- @class file
|
-- @class file
|
||||||
-- @name AceConfigDialog-3.0
|
-- @name AceConfigDialog-3.0
|
||||||
-- @release $Id: AceConfigDialog-3.0.lua 1139 2016-07-03 07:43:51Z nevcairiel $
|
-- @release $Id: AceConfigDialog-3.0.lua 1126 2014-11-10 06:38:01Z nevcairiel $
|
||||||
|
|
||||||
local LibStub = LibStub
|
local LibStub = LibStub
|
||||||
local MAJOR, MINOR = "AceConfigDialog-3.0", 61
|
local gui = LibStub("AceGUI-3.0")
|
||||||
|
local reg = LibStub("AceConfigRegistry-3.0-ElvUI")
|
||||||
|
|
||||||
|
local MAJOR, MINOR = "AceConfigDialog-3.0-ElvUI", 2
|
||||||
local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
|
local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
|
||||||
|
|
||||||
if not AceConfigDialog then return end
|
if not AceConfigDialog then return end
|
||||||
|
|
||||||
local AceCore = LibStub("AceCore-3.0")
|
|
||||||
local wipe, strsplit = AceCore.wipe, AceCore.strsplit
|
|
||||||
local safecall = AceCore.safecall
|
|
||||||
local Dispatchers = AceCore.Dispatchers
|
|
||||||
local countargs = AceCore.countargs
|
|
||||||
|
|
||||||
AceConfigDialog.OpenFrames = AceConfigDialog.OpenFrames or {}
|
AceConfigDialog.OpenFrames = AceConfigDialog.OpenFrames or {}
|
||||||
AceConfigDialog.Status = AceConfigDialog.Status or {}
|
AceConfigDialog.Status = AceConfigDialog.Status or {}
|
||||||
AceConfigDialog.frame = AceConfigDialog.frame or CreateFrame("Frame")
|
AceConfigDialog.frame = AceConfigDialog.frame or CreateFrame("Frame")
|
||||||
@@ -23,25 +20,67 @@ AceConfigDialog.frame.apps = AceConfigDialog.frame.apps or {}
|
|||||||
AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {}
|
AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {}
|
||||||
AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {}
|
AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {}
|
||||||
|
|
||||||
local gui = LibStub("AceGUI-3.0")
|
|
||||||
local reg = LibStub("AceConfigRegistry-3.0")
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local tconcat, tinsert, tsort, tremove, tgetn, tsetn = table.concat, table.insert, table.sort, table.remove, table.getn, table.setn
|
local tconcat, tgetn, tinsert, tsort, tremove, tsort = table.concat, table.getn, table.insert, table.sort, table.remove, table.sort
|
||||||
local format, strfind, strupper = string.format, string.find, string.upper
|
local strmatch, format, strsplit, strupper = string.match, string.format, string.split, string.upper
|
||||||
local assert, loadstring, error = assert, loadstring, error
|
local assert, loadstring, error = assert, loadstring, error
|
||||||
local pairs, next, type, unpack, ipairs = pairs, next, type, unpack, ipairs
|
local pairs, next, select, type, unpack, wipe, ipairs = pairs, next, select, type, unpack, wipe, ipairs
|
||||||
local rawset, tostring, tonumber = rawset, tostring, tonumber
|
local rawset, tostring, tonumber = rawset, tostring, tonumber
|
||||||
local math_min, math_max, math_floor = math.min, math.max, math.floor
|
local math_min, math_max, math_floor = math.min, math.max, math.floor
|
||||||
|
|
||||||
|
local OKAY = OKAY
|
||||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||||
-- List them here for Mikk's FindGlobals script
|
-- List them here for Mikk's FindGlobals script
|
||||||
-- GLOBALS: NORMAL_FONT_COLOR, GameTooltip, StaticPopupDialogs, ACCEPT, CANCEL, StaticPopup_Show
|
-- GLOBALS: NORMAL_FONT_COLOR, GameTooltip, StaticPopupDialogs, ACCEPT, CANCEL, StaticPopup_Show
|
||||||
-- GLOBALS: PlaySound, GameFontHighlight, GameFontHighlightSmall, GameFontHighlightLarge
|
-- GLOBALS: PlaySound, GameFontHighlight, GameFontHighlightSmall, GameFontHighlightLarge
|
||||||
-- GLOBALS: CloseSpecialWindows, InterfaceOptions_AddCategory, geterrorhandler
|
-- GLOBALS: CloseSpecialWindows, InterfaceOptions_AddCategory, geterrorhandler
|
||||||
|
-- GLOBALS: STATICPOPUP_NUMDIALOGS
|
||||||
|
|
||||||
local emptyTbl = {}
|
local emptyTbl = {}
|
||||||
|
|
||||||
|
--[[
|
||||||
|
xpcall safecall implementation
|
||||||
|
]]
|
||||||
|
local xpcall = xpcall
|
||||||
|
|
||||||
|
local function errorhandler(err)
|
||||||
|
return geterrorhandler()(err)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function CreateDispatcher(argCount)
|
||||||
|
local code = [[
|
||||||
|
local method, ARGS
|
||||||
|
local function call() return method(ARGS) end
|
||||||
|
|
||||||
|
local function dispatch(func, ...)
|
||||||
|
method = func
|
||||||
|
if not method then return end
|
||||||
|
ARGS = unpack(arg)
|
||||||
|
return xpcall(call, function(err) return geterrorhandler()(err) end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return dispatch
|
||||||
|
]]
|
||||||
|
|
||||||
|
local ARGS = {}
|
||||||
|
for i = 1, argCount do ARGS[i] = "arg"..i end
|
||||||
|
code = gsub(code, "ARGS", tconcat(ARGS, ", "))
|
||||||
|
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
|
||||||
|
end
|
||||||
|
|
||||||
|
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
|
||||||
|
local dispatcher = CreateDispatcher(argCount)
|
||||||
|
rawset(self, argCount, dispatcher)
|
||||||
|
return dispatcher
|
||||||
|
end})
|
||||||
|
Dispatchers[0] = function(func)
|
||||||
|
return xpcall(func, errorhandler)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function safecall(func, ...)
|
||||||
|
return Dispatchers[tgetn(arg)](func, unpack(arg))
|
||||||
|
end
|
||||||
|
|
||||||
local width_multiplier = 170
|
local width_multiplier = 170
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@@ -83,7 +122,6 @@ do
|
|||||||
for k, v in pairs(t) do
|
for k, v in pairs(t) do
|
||||||
c[k] = v
|
c[k] = v
|
||||||
end
|
end
|
||||||
tsetn(c, tgetn(t))
|
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
function del(t)
|
function del(t)
|
||||||
@@ -101,7 +139,14 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- picks the first non-nil value and returns it
|
-- picks the first non-nil value and returns it
|
||||||
local pickfirstset = AceCore.pickfirstset
|
local function pickfirstset(...)
|
||||||
|
local args = unpack(arg)
|
||||||
|
for i=1,select("#", args) do
|
||||||
|
if select(i,args)~=nil then
|
||||||
|
return select(i,args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--gets an option from a given group, checking plugins
|
--gets an option from a given group, checking plugins
|
||||||
local function GetSubOption(group, key)
|
local function GetSubOption(group, key)
|
||||||
@@ -151,10 +196,11 @@ local allIsLiteral = {
|
|||||||
--gets the value for a member that could be a function
|
--gets the value for a member that could be a function
|
||||||
--function refs are called with an info arg
|
--function refs are called with an info arg
|
||||||
--every other type is returned
|
--every other type is returned
|
||||||
local function GetOptionsMemberValue(membername, option, options, path, appName, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
local function GetOptionsMemberValue(membername, option, options, path, appName, ...)
|
||||||
--get definition for the member
|
--get definition for the member
|
||||||
local inherits = isInherited[membername]
|
local inherits = isInherited[membername]
|
||||||
|
|
||||||
|
|
||||||
--get the member of the option, traversing the tree if it can be inherited
|
--get the member of the option, traversing the tree if it can be inherited
|
||||||
local member
|
local member
|
||||||
|
|
||||||
@@ -182,13 +228,11 @@ local function GetOptionsMemberValue(membername, option, options, path, appName,
|
|||||||
local group = options
|
local group = options
|
||||||
handler = group.handler or handler
|
handler = group.handler or handler
|
||||||
|
|
||||||
local l = tgetn(path)
|
for i = 1, tgetn(path) do
|
||||||
for i = 1, l do
|
|
||||||
group = GetSubOption(group, path[i])
|
group = GetSubOption(group, path[i])
|
||||||
info[i] = path[i]
|
info[i] = path[i]
|
||||||
handler = group.handler or handler
|
handler = group.handler or handler
|
||||||
end
|
end
|
||||||
tsetn(info, l)
|
|
||||||
|
|
||||||
info.options = options
|
info.options = options
|
||||||
info.appName = appName
|
info.appName = appName
|
||||||
@@ -200,22 +244,21 @@ local function GetOptionsMemberValue(membername, option, options, path, appName,
|
|||||||
info.uiType = "dialog"
|
info.uiType = "dialog"
|
||||||
info.uiName = MAJOR
|
info.uiName = MAJOR
|
||||||
|
|
||||||
argc = argc or 0
|
local a, b, c ,d, e, f, g, h
|
||||||
local a, b, c ,d
|
|
||||||
--using 4 returns for the get of a color type, increase if a type needs more
|
--using 4 returns for the get of a color type, increase if a type needs more
|
||||||
if type(member) == "function" then
|
if type(member) == "function" then
|
||||||
--Call the function
|
--Call the function
|
||||||
a,b,c,d = Dispatchers[argc+1](member,info,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
a,b,c,d, e, f, g, h = member(info, unpack(arg))
|
||||||
else
|
else
|
||||||
--Call the method
|
--Call the method
|
||||||
if handler and handler[member] then
|
if handler and handler[member] then
|
||||||
a,b,c,d = Dispatchers[argc+2](handler[member],handler,info,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
a,b,c,d,e, f, g, h = handler[member](handler, info, unpack(arg))
|
||||||
else
|
else
|
||||||
error(format("Method %s doesn't exist in handler for type %s", member, membername))
|
error(format("Method %s doesn't exist in handler for type %s", member, membername))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
del(info)
|
del(info)
|
||||||
return a,b,c,d
|
return a,b,c,d,e, f, g, h
|
||||||
else
|
else
|
||||||
--The value isnt a function to call, return it
|
--The value isnt a function to call, return it
|
||||||
return member
|
return member
|
||||||
@@ -253,12 +296,12 @@ local function CallOptionsFunction(funcname ,option, options, path, appName, ...
|
|||||||
local a, b, c ,d
|
local a, b, c ,d
|
||||||
if type(func) == "string" then
|
if type(func) == "string" then
|
||||||
if handler and handler[func] then
|
if handler and handler[func] then
|
||||||
a,b,c,d = handler[func](handler, info, ...)
|
a,b,c,d = handler[func](handler, info, unpack(arg))
|
||||||
else
|
else
|
||||||
error(string.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
|
end
|
||||||
elseif type(func) == "function" then
|
elseif type(func) == "function" then
|
||||||
a,b,c,d = func(info, ...)
|
a,b,c,d = func(info, unpack(arg))
|
||||||
end
|
end
|
||||||
del(info)
|
del(info)
|
||||||
return a,b,c,d
|
return a,b,c,d
|
||||||
@@ -311,10 +354,10 @@ local function BuildSortedOptionsTable(group, keySort, opts, options, path, appN
|
|||||||
tinsert(keySort, k)
|
tinsert(keySort, k)
|
||||||
opts[k] = v
|
opts[k] = v
|
||||||
|
|
||||||
tinsert(path,k)
|
path[tgetn(path)+1] = k
|
||||||
tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName)
|
tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName)
|
||||||
tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName)
|
tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName)
|
||||||
tremove(path)
|
path[tgetn(path)] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -325,10 +368,10 @@ local function BuildSortedOptionsTable(group, keySort, opts, options, path, appN
|
|||||||
tinsert(keySort, k)
|
tinsert(keySort, k)
|
||||||
opts[k] = v
|
opts[k] = v
|
||||||
|
|
||||||
tinsert(path,k)
|
path[tgetn(path)+1] = k
|
||||||
tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName)
|
tempOrders[k] = GetOptionsMemberValue("order", v, options, path, appName)
|
||||||
tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName)
|
tempNames[k] = GetOptionsMemberValue("name", v, options, path, appName)
|
||||||
tremove(path)
|
path[tgetn(path)] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -421,11 +464,10 @@ end
|
|||||||
-- The path specified has to match the keys of the groups in the table.
|
-- The path specified has to match the keys of the groups in the table.
|
||||||
-- @param appName The application name as given to `:RegisterOptionsTable()`
|
-- @param appName The application name as given to `:RegisterOptionsTable()`
|
||||||
-- @param ... The path to the key that should be selected
|
-- @param ... The path to the key that should be selected
|
||||||
do
|
function AceConfigDialog:SelectGroup(appName, ...)
|
||||||
local args = {nil,nil,nil,nil,nil,nil,nil,nil,nil,nil}
|
|
||||||
function AceConfigDialog:SelectGroup(appName, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
|
||||||
local path = new()
|
local path = new()
|
||||||
|
|
||||||
|
|
||||||
local app = reg:GetOptionsTable(appName)
|
local app = reg:GetOptionsTable(appName)
|
||||||
if not app then
|
if not app then
|
||||||
error(format("%s isn't registed with AceConfigRegistry, unable to open config", appName), 2)
|
error(format("%s isn't registed with AceConfigRegistry, unable to open config", appName), 2)
|
||||||
@@ -440,21 +482,8 @@ function AceConfigDialog:SelectGroup(appName, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
|||||||
local treevalue
|
local treevalue
|
||||||
local treestatus
|
local treestatus
|
||||||
|
|
||||||
args[1] = a1
|
for n = 1, tgetn(arg) do
|
||||||
args[2] = a2
|
local key = arg[n]
|
||||||
args[3] = a3
|
|
||||||
args[4] = a4
|
|
||||||
args[5] = a5
|
|
||||||
args[6] = a6
|
|
||||||
args[7] = a7
|
|
||||||
args[8] = a8
|
|
||||||
args[9] = a9
|
|
||||||
args[10] = a10
|
|
||||||
for n = 1, 10 do
|
|
||||||
local key = args[n]
|
|
||||||
arg[n] = nil
|
|
||||||
|
|
||||||
if not key then break end
|
|
||||||
|
|
||||||
if group.childGroups == "tab" or group.childGroups == "select" then
|
if group.childGroups == "tab" or group.childGroups == "select" then
|
||||||
--if this is a tab or select group, select the group
|
--if this is a tab or select group, select the group
|
||||||
@@ -498,7 +527,6 @@ function AceConfigDialog:SelectGroup(appName, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
|||||||
del(path)
|
del(path)
|
||||||
reg:NotifyChange(appName)
|
reg:NotifyChange(appName)
|
||||||
end
|
end
|
||||||
end -- AceConfigDialog:SelectGroup
|
|
||||||
|
|
||||||
local function OptionOnMouseOver(widget, event)
|
local function OptionOnMouseOver(widget, event)
|
||||||
--show a tooltip/set the status bar to the desc text
|
--show a tooltip/set the status bar to the desc text
|
||||||
@@ -519,13 +547,13 @@ local function OptionOnMouseOver(widget, event)
|
|||||||
GameTooltip:SetText(name, 1, .82, 0, true)
|
GameTooltip:SetText(name, 1, .82, 0, true)
|
||||||
|
|
||||||
if opt.type == "multiselect" then
|
if opt.type == "multiselect" then
|
||||||
GameTooltip:AddLine(user.text, 0.5, 0.5, 0.8, true)
|
GameTooltip:AddLine(user.text, 0.5, 0.5, 0.8, 1)
|
||||||
end
|
end
|
||||||
if type(desc) == "string" then
|
if type(desc) == "string" then
|
||||||
GameTooltip:AddLine(desc, 1, 1, 1, true)
|
GameTooltip:AddLine(desc, 1, 1, 1, 1)
|
||||||
end
|
end
|
||||||
if type(usage) == "string" then
|
if type(usage) == "string" then
|
||||||
GameTooltip:AddLine("Usage: "..usage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, true)
|
GameTooltip:AddLine("Usage: "..usage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
GameTooltip:Show()
|
GameTooltip:Show()
|
||||||
@@ -543,7 +571,7 @@ local function GetFuncName(option)
|
|||||||
return "set"
|
return "set"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function confirmPopup(appName, rootframe, basepath, info, message, func, argc,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
local function confirmPopup(appName, rootframe, basepath, info, message, func, ...)
|
||||||
if not StaticPopupDialogs["ACECONFIGDIALOG30_CONFIRM_DIALOG"] then
|
if not StaticPopupDialogs["ACECONFIGDIALOG30_CONFIRM_DIALOG"] then
|
||||||
StaticPopupDialogs["ACECONFIGDIALOG30_CONFIRM_DIALOG"] = {}
|
StaticPopupDialogs["ACECONFIGDIALOG30_CONFIRM_DIALOG"] = {}
|
||||||
end
|
end
|
||||||
@@ -557,7 +585,7 @@ local function confirmPopup(appName, rootframe, basepath, info, message, func, a
|
|||||||
t.preferredIndex = STATICPOPUP_NUMDIALOGS
|
t.preferredIndex = STATICPOPUP_NUMDIALOGS
|
||||||
local dialog, oldstrata
|
local dialog, oldstrata
|
||||||
t.OnAccept = function()
|
t.OnAccept = function()
|
||||||
safecall(func, tgetn(t), unpack(t))
|
safecall(func, unpack(t))
|
||||||
if dialog and oldstrata then
|
if dialog and oldstrata then
|
||||||
dialog:SetFrameStrata(oldstrata)
|
dialog:SetFrameStrata(oldstrata)
|
||||||
end
|
end
|
||||||
@@ -571,23 +599,9 @@ local function confirmPopup(appName, rootframe, basepath, info, message, func, a
|
|||||||
AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl))
|
AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl))
|
||||||
del(info)
|
del(info)
|
||||||
end
|
end
|
||||||
t[1] = a1
|
for i = 1, tgetn(arg) do
|
||||||
t[2] = a2
|
t[i] = arg[i] or false
|
||||||
t[3] = a3
|
|
||||||
t[4] = a4
|
|
||||||
t[5] = a5
|
|
||||||
t[6] = a6
|
|
||||||
t[7] = a7
|
|
||||||
t[8] = a8
|
|
||||||
t[9] = a9
|
|
||||||
t[10] = a10
|
|
||||||
for i=1,argc do
|
|
||||||
t[i] = t[i] or false
|
|
||||||
end
|
end
|
||||||
for i=argc+1,10 do
|
|
||||||
t[i] = nil
|
|
||||||
end
|
|
||||||
tsetn(t,argc)
|
|
||||||
t.timeout = 0
|
t.timeout = 0
|
||||||
t.whileDead = 1
|
t.whileDead = 1
|
||||||
t.hideOnEscape = 1
|
t.hideOnEscape = 1
|
||||||
@@ -599,7 +613,32 @@ local function confirmPopup(appName, rootframe, basepath, info, message, func, a
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ActivateControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
local function validationErrorPopup(message)
|
||||||
|
if not StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"] then
|
||||||
|
StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"] = {}
|
||||||
|
end
|
||||||
|
local t = StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"]
|
||||||
|
t.text = message
|
||||||
|
t.button1 = OKAY
|
||||||
|
t.preferredIndex = STATICPOPUP_NUMDIALOGS
|
||||||
|
local dialog, oldstrata
|
||||||
|
t.OnAccept = function()
|
||||||
|
if dialog and oldstrata then
|
||||||
|
dialog:SetFrameStrata(oldstrata)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
t.timeout = 0
|
||||||
|
t.whileDead = 1
|
||||||
|
t.hideOnEscape = 1
|
||||||
|
|
||||||
|
dialog = StaticPopup_Show("ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG")
|
||||||
|
if dialog then
|
||||||
|
oldstrata = dialog:GetFrameStrata()
|
||||||
|
dialog:SetFrameStrata("TOOLTIP")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ActivateControl(widget, event, ...)
|
||||||
--This function will call the set / execute handler for the widget
|
--This function will call the set / execute handler for the widget
|
||||||
--widget:GetUserDataTable() contains the needed info
|
--widget:GetUserDataTable() contains the needed info
|
||||||
local user = widget:GetUserDataTable()
|
local user = widget:GetUserDataTable()
|
||||||
@@ -622,9 +661,7 @@ local function ActivateControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a
|
|||||||
handler = group.handler or handler
|
handler = group.handler or handler
|
||||||
confirm = group.confirm
|
confirm = group.confirm
|
||||||
validate = group.validate
|
validate = group.validate
|
||||||
|
for i = 1, tgetn(path) do
|
||||||
local l = tgetn(path)
|
|
||||||
for i = 1, l do
|
|
||||||
local v = path[i]
|
local v = path[i]
|
||||||
group = GetSubOption(group, v)
|
group = GetSubOption(group, v)
|
||||||
info[i] = v
|
info[i] = v
|
||||||
@@ -639,7 +676,6 @@ local function ActivateControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a
|
|||||||
validate = group.validate
|
validate = group.validate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
tsetn(info, l)
|
|
||||||
|
|
||||||
info.options = options
|
info.options = options
|
||||||
info.appName = user.appName
|
info.appName = user.appName
|
||||||
@@ -651,7 +687,6 @@ local function ActivateControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a
|
|||||||
info.uiName = MAJOR
|
info.uiName = MAJOR
|
||||||
|
|
||||||
local name
|
local name
|
||||||
|
|
||||||
if type(option.name) == "function" then
|
if type(option.name) == "function" then
|
||||||
name = option.name(info)
|
name = option.name(info)
|
||||||
elseif type(option.name) == "string" then
|
elseif type(option.name) == "string" then
|
||||||
@@ -666,7 +701,7 @@ local function ActivateControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a
|
|||||||
|
|
||||||
if option.type == "input" then
|
if option.type == "input" then
|
||||||
if type(pattern)=="string" then
|
if type(pattern)=="string" then
|
||||||
if not strfind(a1, pattern) then
|
if not strmatch(unpack(arg), pattern) then
|
||||||
validated = false
|
validated = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -676,53 +711,46 @@ local function ActivateControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a
|
|||||||
if validated and option.type ~= "execute" then
|
if validated and option.type ~= "execute" then
|
||||||
if type(validate) == "string" then
|
if type(validate) == "string" then
|
||||||
if handler and handler[validate] then
|
if handler and handler[validate] then
|
||||||
success, validated = safecall(handler[validate], argc+2, handler, info, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
success, validated = safecall(handler[validate], handler, info, unpack(arg))
|
||||||
if not success then validated = false end
|
if not success then validated = false end
|
||||||
else
|
else
|
||||||
error(format("Method %s doesn't exist in handler for type execute", validate))
|
error(format("Method %s doesn't exist in handler for type execute", validate))
|
||||||
end
|
end
|
||||||
elseif type(validate) == "function" then
|
elseif type(validate) == "function" then
|
||||||
success, validated = safecall(validate, argc+1, info, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
success, validated = safecall(validate, info, unpack(arg))
|
||||||
if not success then validated = false end
|
if not success then validated = false end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local rootframe = user.rootframe
|
local rootframe = user.rootframe
|
||||||
if type(validated) == "string" then
|
if not validated or type(validated) == "string" then
|
||||||
--validate function returned a message to display
|
if not validated then
|
||||||
|
if usage then
|
||||||
|
validated = name..": "..usage
|
||||||
|
else
|
||||||
|
if pattern then
|
||||||
|
validated = name..": Expected "..pattern
|
||||||
|
else
|
||||||
|
validated = name..": Invalid Value"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- show validate message
|
||||||
if rootframe.SetStatusText then
|
if rootframe.SetStatusText then
|
||||||
rootframe:SetStatusText(validated)
|
rootframe:SetStatusText(validated)
|
||||||
else
|
else
|
||||||
-- TODO: do something else.
|
validationErrorPopup(validated)
|
||||||
end
|
|
||||||
PlaySound("igPlayerInviteDecline")
|
|
||||||
del(info)
|
|
||||||
return true
|
|
||||||
elseif not validated then
|
|
||||||
--validate returned false
|
|
||||||
if rootframe.SetStatusText then
|
|
||||||
if usage then
|
|
||||||
rootframe:SetStatusText(name..": "..usage)
|
|
||||||
else
|
|
||||||
if pattern then
|
|
||||||
rootframe:SetStatusText(name..": Expected "..pattern)
|
|
||||||
else
|
|
||||||
rootframe:SetStatusText(name..": Invalid Value")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- TODO: do something else
|
|
||||||
end
|
end
|
||||||
PlaySound("igPlayerInviteDecline")
|
PlaySound("igPlayerInviteDecline")
|
||||||
del(info)
|
del(info)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
|
|
||||||
local confirmText = option.confirmText
|
local confirmText = option.confirmText
|
||||||
--call confirm func/method
|
--call confirm func/method
|
||||||
if type(confirm) == "string" then
|
if type(confirm) == "string" then
|
||||||
if handler and handler[confirm] then
|
if handler and handler[confirm] then
|
||||||
success, confirm = safecall(handler[confirm], argc+2, handler, info, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
success, confirm = safecall(handler[confirm], handler, info, unpack(arg))
|
||||||
if success and type(confirm) == "string" then
|
if success and type(confirm) == "string" then
|
||||||
confirmText = confirm
|
confirmText = confirm
|
||||||
confirm = true
|
confirm = true
|
||||||
@@ -733,7 +761,7 @@ local function ActivateControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a
|
|||||||
error(format("Method %s doesn't exist in handler for type confirm", confirm))
|
error(format("Method %s doesn't exist in handler for type confirm", confirm))
|
||||||
end
|
end
|
||||||
elseif type(confirm) == "function" then
|
elseif type(confirm) == "function" then
|
||||||
success, confirm = safecall(confirm, argc+1, info, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
success, confirm = safecall(confirm, info, unpack(arg))
|
||||||
if success and type(confirm) == "string" then
|
if success and type(confirm) == "string" then
|
||||||
confirmText = confirm
|
confirmText = confirm
|
||||||
confirm = true
|
confirm = true
|
||||||
@@ -768,12 +796,12 @@ local function ActivateControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a
|
|||||||
local basepath = user.rootframe:GetUserData("basepath")
|
local basepath = user.rootframe:GetUserData("basepath")
|
||||||
if type(func) == "string" then
|
if type(func) == "string" then
|
||||||
if handler and handler[func] then
|
if handler and handler[func] then
|
||||||
confirmPopup(user.appName, rootframe, basepath, info, confirmText, handler[func], argc+2, handler, info, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
confirmPopup(user.appName, rootframe, basepath, info, confirmText, handler[func], handler, info, unpack(arg))
|
||||||
else
|
else
|
||||||
error(format("Method %s doesn't exist in handler for type func", func))
|
error(format("Method %s doesn't exist in handler for type func", func))
|
||||||
end
|
end
|
||||||
elseif type(func) == "function" then
|
elseif type(func) == "function" then
|
||||||
confirmPopup(user.appName, rootframe, basepath, info, confirmText, func, argc+1, info,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
confirmPopup(user.appName, rootframe, basepath, info, confirmText, func, info, unpack(arg))
|
||||||
end
|
end
|
||||||
--func will be called and info deleted when the confirm dialog is responded to
|
--func will be called and info deleted when the confirm dialog is responded to
|
||||||
return
|
return
|
||||||
@@ -783,14 +811,16 @@ local function ActivateControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a
|
|||||||
--call the function
|
--call the function
|
||||||
if type(func) == "string" then
|
if type(func) == "string" then
|
||||||
if handler and handler[func] then
|
if handler and handler[func] then
|
||||||
safecall(handler[func], argc+2, handler, info, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
safecall(handler[func],handler, info, unpack(arg))
|
||||||
else
|
else
|
||||||
error(format("Method %s doesn't exist in handler for type func", func))
|
error(format("Method %s doesn't exist in handler for type func", func))
|
||||||
end
|
end
|
||||||
elseif type(func) == "function" then
|
elseif type(func) == "function" then
|
||||||
safecall(func, argc+1, info, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
safecall(func,info, unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local iscustom = user.rootframe:GetUserData("iscustom")
|
local iscustom = user.rootframe:GetUserData("iscustom")
|
||||||
local basepath = user.rootframe:GetUserData("basepath") or emptyTbl
|
local basepath = user.rootframe:GetUserData("basepath") or emptyTbl
|
||||||
--full refresh of the frame, some controls dont cause this on all events
|
--full refresh of the frame, some controls dont cause this on all events
|
||||||
@@ -826,7 +856,7 @@ local function ActivateControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a
|
|||||||
del(info)
|
del(info)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ActivateSlider(widget, event, _, value)
|
local function ActivateSlider(widget, event, value)
|
||||||
local option = widget:GetUserData("option")
|
local option = widget:GetUserData("option")
|
||||||
local min, max, step = option.min or (not option.softMin and 0 or nil), option.max or (not option.softMax and 100 or nil), option.step
|
local min, max, step = option.min or (not option.softMin and 0 or nil), option.max or (not option.softMax and 100 or nil), option.step
|
||||||
if min then
|
if min then
|
||||||
@@ -838,13 +868,13 @@ local function ActivateSlider(widget, event, _, value)
|
|||||||
if max then
|
if max then
|
||||||
value = math_min(value, max)
|
value = math_min(value, max)
|
||||||
end
|
end
|
||||||
ActivateControl(widget,event,1,value)
|
ActivateControl(widget,event,value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--called from a checkbox that is part of an internally created multiselect group
|
--called from a checkbox that is part of an internally created multiselect group
|
||||||
--this type is safe to refresh on activation of one control
|
--this type is safe to refresh on activation of one control
|
||||||
local function ActivateMultiControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
local function ActivateMultiControl(widget, event, ...)
|
||||||
ActivateControl(widget, event, argc+1, widget:GetUserData("value"), a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
ActivateControl(widget, event, widget:GetUserData("value"), unpack(arg))
|
||||||
local user = widget:GetUserDataTable()
|
local user = widget:GetUserDataTable()
|
||||||
local iscustom = user.rootframe:GetUserData("iscustom")
|
local iscustom = user.rootframe:GetUserData("iscustom")
|
||||||
local basepath = user.rootframe:GetUserData("basepath") or emptyTbl
|
local basepath = user.rootframe:GetUserData("basepath") or emptyTbl
|
||||||
@@ -855,7 +885,7 @@ local function ActivateMultiControl(widget, event, argc, a1,a2,a3,a4,a5,a6,a7,a8
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function MultiControlOnClosed(widget, event)
|
local function MultiControlOnClosed(widget, event, ...)
|
||||||
local user = widget:GetUserDataTable()
|
local user = widget:GetUserDataTable()
|
||||||
if user.valuechanged then
|
if user.valuechanged then
|
||||||
local iscustom = user.rootframe:GetUserData("iscustom")
|
local iscustom = user.rootframe:GetUserData("iscustom")
|
||||||
@@ -876,7 +906,7 @@ end
|
|||||||
|
|
||||||
local function CheckOptionHidden(option, options, path, appName)
|
local function CheckOptionHidden(option, options, path, appName)
|
||||||
--check for a specific boolean option
|
--check for a specific boolean option
|
||||||
local hidden = pickfirstset(2,option.dialogHidden,option.guiHidden)
|
local hidden = pickfirstset(option.dialogHidden,option.guiHidden)
|
||||||
if hidden ~= nil then
|
if hidden ~= nil then
|
||||||
return hidden
|
return hidden
|
||||||
end
|
end
|
||||||
@@ -886,7 +916,7 @@ end
|
|||||||
|
|
||||||
local function CheckOptionDisabled(option, options, path, appName)
|
local function CheckOptionDisabled(option, options, path, appName)
|
||||||
--check for a specific boolean option
|
--check for a specific boolean option
|
||||||
local disabled = pickfirstset(2,option.dialogDisabled,option.guiDisabled)
|
local disabled = pickfirstset(option.dialogDisabled,option.guiDisabled)
|
||||||
if disabled ~= nil then
|
if disabled ~= nil then
|
||||||
return disabled
|
return disabled
|
||||||
end
|
end
|
||||||
@@ -902,18 +932,18 @@ local function BuildTabs(group, options, path, appName)
|
|||||||
|
|
||||||
BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
|
BuildSortedOptionsTable(group, keySort, opts, options, path, appName)
|
||||||
|
|
||||||
for i = 1, #keySort do
|
for i = 1, tgetn(keySort) do
|
||||||
local k = keySort[i]
|
local k = keySort[i]
|
||||||
local v = opts[k]
|
local v = opts[k]
|
||||||
if v.type == "group" then
|
if v.type == "group" then
|
||||||
path[#path+1] = k
|
path[tgetn(path)+1] = k
|
||||||
local inline = pickfirstset(4,v.dialogInline,v.guiInline,v.inline, false)
|
local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
|
||||||
local hidden = CheckOptionHidden(v, options, path, appName)
|
local hidden = CheckOptionHidden(v, options, path, appName)
|
||||||
if not inline and not hidden then
|
if not inline and not hidden then
|
||||||
tinsert(tabs, k)
|
tinsert(tabs, k)
|
||||||
text[k] = GetOptionsMemberValue("name", v, options, path, appName)
|
text[k] = GetOptionsMemberValue("name", v, options, path, appName)
|
||||||
end
|
end
|
||||||
path[#path] = nil
|
path[tgetn(path)] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -935,14 +965,14 @@ local function BuildSelect(group, options, path, appName)
|
|||||||
local k = keySort[i]
|
local k = keySort[i]
|
||||||
local v = opts[k]
|
local v = opts[k]
|
||||||
if v.type == "group" then
|
if v.type == "group" then
|
||||||
tinsert(path,k)
|
path[tgetn(path)+1] = k
|
||||||
local inline = pickfirstset(4,v.dialogInline,v.guiInline,v.inline, false)
|
local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
|
||||||
local hidden = CheckOptionHidden(v, options, path, appName)
|
local hidden = CheckOptionHidden(v, options, path, appName)
|
||||||
if not inline and not hidden then
|
if not inline and not hidden then
|
||||||
groups[k] = GetOptionsMemberValue("name", v, options, path, appName)
|
groups[k] = GetOptionsMemberValue("name", v, options, path, appName)
|
||||||
tinsert(order, k)
|
tinsert(order, k)
|
||||||
end
|
end
|
||||||
tremove(path)
|
path[tgetn(path)] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -962,8 +992,8 @@ local function BuildSubGroups(group, tree, options, path, appName)
|
|||||||
local k = keySort[i]
|
local k = keySort[i]
|
||||||
local v = opts[k]
|
local v = opts[k]
|
||||||
if v.type == "group" then
|
if v.type == "group" then
|
||||||
tinsert(path,k)
|
path[tgetn(path)+1] = k
|
||||||
local inline = pickfirstset(4,v.dialogInline,v.guiInline,v.inline, false)
|
local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
|
||||||
local hidden = CheckOptionHidden(v, options, path, appName)
|
local hidden = CheckOptionHidden(v, options, path, appName)
|
||||||
if not inline and not hidden then
|
if not inline and not hidden then
|
||||||
local entry = new()
|
local entry = new()
|
||||||
@@ -978,7 +1008,7 @@ local function BuildSubGroups(group, tree, options, path, appName)
|
|||||||
BuildSubGroups(v,entry, options, path, appName)
|
BuildSubGroups(v,entry, options, path, appName)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
tremove(path)
|
path[tgetn(path)] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -997,8 +1027,8 @@ local function BuildGroups(group, options, path, appName, recurse)
|
|||||||
local k = keySort[i]
|
local k = keySort[i]
|
||||||
local v = opts[k]
|
local v = opts[k]
|
||||||
if v.type == "group" then
|
if v.type == "group" then
|
||||||
tinsert(path,k)
|
path[tgetn(path)+1] = k
|
||||||
local inline = pickfirstset(4,v.dialogInline,v.guiInline,v.inline, false)
|
local inline = pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
|
||||||
local hidden = CheckOptionHidden(v, options, path, appName)
|
local hidden = CheckOptionHidden(v, options, path, appName)
|
||||||
if not inline and not hidden then
|
if not inline and not hidden then
|
||||||
local entry = new()
|
local entry = new()
|
||||||
@@ -1011,7 +1041,7 @@ local function BuildGroups(group, options, path, appName, recurse)
|
|||||||
BuildSubGroups(v,entry, options, path, appName)
|
BuildSubGroups(v,entry, options, path, appName)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
tremove(path)
|
path[tgetn(path)] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
del(keySort)
|
del(keySort)
|
||||||
@@ -1021,12 +1051,9 @@ end
|
|||||||
|
|
||||||
local function InjectInfo(control, options, option, path, rootframe, appName)
|
local function InjectInfo(control, options, option, path, rootframe, appName)
|
||||||
local user = control:GetUserDataTable()
|
local user = control:GetUserDataTable()
|
||||||
local l = tgetn(path)
|
for i = 1, tgetn(path) do
|
||||||
for i = 1, l do
|
|
||||||
user[i] = path[i]
|
user[i] = path[i]
|
||||||
end
|
end
|
||||||
tsetn(user,l)
|
|
||||||
|
|
||||||
user.rootframe = rootframe
|
user.rootframe = rootframe
|
||||||
user.option = option
|
user.option = option
|
||||||
user.options = options
|
user.options = options
|
||||||
@@ -1059,7 +1086,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
local name = GetOptionsMemberValue("name", v, options, path, appName)
|
local name = GetOptionsMemberValue("name", v, options, path, appName)
|
||||||
if not hidden then
|
if not hidden then
|
||||||
if v.type == "group" then
|
if v.type == "group" then
|
||||||
if inline or pickfirstset(4, v.dialogInline,v.guiInline,v.inline, false) then
|
if inline or pickfirstset(v.dialogInline,v.guiInline,v.inline, false) then
|
||||||
--Inline group
|
--Inline group
|
||||||
local GroupContainer
|
local GroupContainer
|
||||||
if name and name ~= "" then
|
if name and name ~= "" then
|
||||||
@@ -1107,7 +1134,8 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
control:SetImageSize(width, height)
|
control:SetImageSize(width, height)
|
||||||
control:SetLabel(name)
|
control:SetLabel(name)
|
||||||
else
|
else
|
||||||
control = gui:Create("Button")
|
local buttonElvUI = GetOptionsMemberValue("buttonElvUI",v, options, path, appName)
|
||||||
|
control = gui:Create(buttonElvUI and "Button-ElvUI" or "Button")
|
||||||
control:SetText(name)
|
control:SetText(name)
|
||||||
end
|
end
|
||||||
control:SetCallback("OnClick",ActivateControl)
|
control:SetCallback("OnClick",ActivateControl)
|
||||||
@@ -1133,7 +1161,12 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
|
|
||||||
elseif v.type == "toggle" then
|
elseif v.type == "toggle" then
|
||||||
control = gui:Create("CheckBox")
|
control = gui:Create("CheckBox")
|
||||||
|
control.textWidth = GetOptionsMemberValue("textWidth",v,options,path,appName)
|
||||||
control:SetLabel(name)
|
control:SetLabel(name)
|
||||||
|
if control.textWidth and control.frame and control.text then
|
||||||
|
local textWidth = control.text:GetWidth()+30
|
||||||
|
control.customWidth = (textWidth>=width_multiplier and textWidth<=width_multiplier*1.5) and textWidth
|
||||||
|
end
|
||||||
control:SetTriState(v.tristate)
|
control:SetTriState(v.tristate)
|
||||||
local value = GetOptionsMemberValue("get",v, options, path, appName)
|
local value = GetOptionsMemberValue("get",v, options, path, appName)
|
||||||
control:SetValue(value)
|
control:SetValue(value)
|
||||||
@@ -1181,7 +1214,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
local optionValue = GetOptionsMemberValue("get",v, options, path, appName)
|
local optionValue = GetOptionsMemberValue("get",v, options, path, appName)
|
||||||
local t = {}
|
local t = {}
|
||||||
for value, text in pairs(values) do
|
for value, text in pairs(values) do
|
||||||
tinsert(t,value)
|
t[tgetn(t)+1]=value
|
||||||
end
|
end
|
||||||
tsort(t)
|
tsort(t)
|
||||||
for k, value in ipairs(t) do
|
for k, value in ipairs(t) do
|
||||||
@@ -1214,7 +1247,6 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
if not control then
|
if not control then
|
||||||
geterrorhandler()(format("Invalid Custom Control Type - %s", tostring(controlType)))
|
geterrorhandler()(format("Invalid Custom Control Type - %s", tostring(controlType)))
|
||||||
control = gui:Create("Dropdown")
|
control = gui:Create("Dropdown")
|
||||||
|
|
||||||
end
|
end
|
||||||
local itemType = v.itemControl
|
local itemType = v.itemControl
|
||||||
if itemType and not gui:GetWidgetVersion(itemType) then
|
if itemType and not gui:GetWidgetVersion(itemType) then
|
||||||
@@ -1233,7 +1265,6 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
|
|
||||||
elseif v.type == "multiselect" then
|
elseif v.type == "multiselect" then
|
||||||
local values = GetOptionsMemberValue("values", v, options, path, appName)
|
local values = GetOptionsMemberValue("values", v, options, path, appName)
|
||||||
|
|
||||||
local disabled = CheckOptionDisabled(v, options, path, appName)
|
local disabled = CheckOptionDisabled(v, options, path, appName)
|
||||||
|
|
||||||
local controlType = v.dialogControl or v.control
|
local controlType = v.dialogControl or v.control
|
||||||
@@ -1272,27 +1303,57 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
--check:SetTriState(v.tristate)
|
--check:SetTriState(v.tristate)
|
||||||
for i = 1, tgetn(valuesort) do
|
for i = 1, tgetn(valuesort) do
|
||||||
local key = valuesort[i]
|
local key = valuesort[i]
|
||||||
local value = GetOptionsMemberValue("get", v, options, path, appName, 1, key)
|
local value = GetOptionsMemberValue("get",v, options, path, appName, key)
|
||||||
control:SetItemValue(key,value)
|
control:SetItemValue(key,value)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
local width = GetOptionsMemberValue("width",v,options,path,appName)
|
||||||
|
local dragdrop = GetOptionsMemberValue("dragdrop",v,options,path,appName)
|
||||||
|
|
||||||
control = gui:Create("InlineGroup")
|
control = gui:Create("InlineGroup")
|
||||||
control:SetLayout("Flow")
|
control:SetLayout("Flow")
|
||||||
control:SetTitle(name)
|
control:SetTitle(name)
|
||||||
control.width = "fill"
|
control.width = "fill"
|
||||||
|
|
||||||
control:PauseLayout()
|
control:PauseLayout()
|
||||||
local width = GetOptionsMemberValue("width",v,options,path,appName)
|
|
||||||
for i = 1, tgetn(valuesort) do
|
for i = 1, tgetn(valuesort) do
|
||||||
local value = valuesort[i]
|
local value = valuesort[i]
|
||||||
local text = values[value]
|
local text = values[value]
|
||||||
|
if dragdrop then
|
||||||
|
local button = gui:Create("Button-ElvUI")
|
||||||
|
button:SetDisabled(disabled)
|
||||||
|
button:SetUserData("value", value)
|
||||||
|
button:SetUserData("text", text)
|
||||||
|
local state = v.stateSwitchGetText and v.stateSwitchGetText(button, text, value)
|
||||||
|
button:SetText(format("|cFF888888%d|r %s", i, state or text))
|
||||||
|
button.stateSwitchOnClick = v.stateSwitchOnClick
|
||||||
|
button.dragOnMouseDown = v.dragOnMouseDown
|
||||||
|
button.dragOnMouseUp = v.dragOnMouseUp
|
||||||
|
button.dragOnEnter = v.dragOnEnter
|
||||||
|
button.dragOnLeave = v.dragOnLeave
|
||||||
|
button.dragOnClick = v.dragOnClick
|
||||||
|
button.dragdrop = true
|
||||||
|
button.ActivateMultiControl = ActivateMultiControl
|
||||||
|
button.value = GetOptionsMemberValue("get",v, options, path, appName, value)
|
||||||
|
InjectInfo(button, options, v, path, rootframe, appName)
|
||||||
|
control:AddChild(button)
|
||||||
|
if width == "double" then
|
||||||
|
button:SetWidth(width_multiplier * 2)
|
||||||
|
elseif width == "half" then
|
||||||
|
button:SetWidth(width_multiplier / 2)
|
||||||
|
elseif width == "full" then
|
||||||
|
button.width = "fill"
|
||||||
|
else
|
||||||
|
button:SetWidth(width_multiplier)
|
||||||
|
end
|
||||||
|
else
|
||||||
local check = gui:Create("CheckBox")
|
local check = gui:Create("CheckBox")
|
||||||
check:SetLabel(text)
|
check:SetLabel(text)
|
||||||
check:SetUserData("value", value)
|
check:SetUserData("value", value)
|
||||||
check:SetUserData("text", text)
|
check:SetUserData("text", text)
|
||||||
check:SetDisabled(disabled)
|
check:SetDisabled(disabled)
|
||||||
check:SetTriState(v.tristate)
|
check:SetTriState(v.tristate)
|
||||||
check:SetValue(GetOptionsMemberValue("get",v, options, path, appName, 1, value))
|
check:SetValue(GetOptionsMemberValue("get",v, options, path, appName, value))
|
||||||
check:SetCallback("OnValueChanged",ActivateMultiControl)
|
check:SetCallback("OnValueChanged",ActivateMultiControl)
|
||||||
InjectInfo(check, options, v, path, rootframe, appName)
|
InjectInfo(check, options, v, path, rootframe, appName)
|
||||||
control:AddChild(check)
|
control:AddChild(check)
|
||||||
@@ -1306,6 +1367,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
check:SetWidth(width_multiplier)
|
check:SetWidth(width_multiplier)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
control:ResumeLayout()
|
control:ResumeLayout()
|
||||||
control:DoLayout()
|
control:DoLayout()
|
||||||
|
|
||||||
@@ -1315,7 +1377,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
del(valuesort)
|
del(valuesort)
|
||||||
|
|
||||||
elseif v.type == "color" then
|
elseif v.type == "color" then
|
||||||
control = gui:Create("ColorPicker")
|
control = gui:Create("ColorPicker-ElvUI")
|
||||||
control:SetLabel(name)
|
control:SetLabel(name)
|
||||||
control:SetHasAlpha(GetOptionsMemberValue("hasAlpha",v, options, path, appName))
|
control:SetHasAlpha(GetOptionsMemberValue("hasAlpha",v, options, path, appName))
|
||||||
control:SetColor(GetOptionsMemberValue("get",v, options, path, appName))
|
control:SetColor(GetOptionsMemberValue("get",v, options, path, appName))
|
||||||
@@ -1375,7 +1437,11 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
|
|
||||||
--Common Init
|
--Common Init
|
||||||
if control then
|
if control then
|
||||||
if control.width ~= "fill" then
|
local customWidth = control.customWidth or GetOptionsMemberValue("customWidth",v,options,path,appName)
|
||||||
|
if control.width ~= "fill" or customWidth then
|
||||||
|
if customWidth then
|
||||||
|
control:SetWidth(customWidth)
|
||||||
|
else
|
||||||
local width = GetOptionsMemberValue("width",v,options,path,appName)
|
local width = GetOptionsMemberValue("width",v,options,path,appName)
|
||||||
if width == "double" then
|
if width == "double" then
|
||||||
control:SetWidth(width_multiplier * 2)
|
control:SetWidth(width_multiplier * 2)
|
||||||
@@ -1387,6 +1453,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
control:SetWidth(width_multiplier)
|
control:SetWidth(width_multiplier)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if control.SetDisabled then
|
if control.SetDisabled then
|
||||||
local disabled = CheckOptionDisabled(v, options, path, appName)
|
local disabled = CheckOptionDisabled(v, options, path, appName)
|
||||||
control:SetDisabled(disabled)
|
control:SetDisabled(disabled)
|
||||||
@@ -1406,15 +1473,14 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
|
|||||||
del(opts)
|
del(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ace3v: recursive
|
local function BuildPath(path, ...)
|
||||||
local function BuildPath(path, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
for i = 1, tgetn(arg) do
|
||||||
if a1 then
|
tinsert(path, arg[i])
|
||||||
tinsert(path,a1)
|
|
||||||
BuildPath(path,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function TreeOnButtonEnter(widget, event, _, uniquevalue, button)
|
|
||||||
|
local function TreeOnButtonEnter(widget, event, uniquevalue, button)
|
||||||
local user = widget:GetUserDataTable()
|
local user = widget:GetUserDataTable()
|
||||||
if not user then return end
|
if not user then return end
|
||||||
local options = user.options
|
local options = user.options
|
||||||
@@ -1423,11 +1489,9 @@ local function TreeOnButtonEnter(widget, event, _, uniquevalue, button)
|
|||||||
local appName = user.appName
|
local appName = user.appName
|
||||||
|
|
||||||
local feedpath = new()
|
local feedpath = new()
|
||||||
local l = tgetn(path)
|
for i = 1, tgetn(path) do
|
||||||
for i = 1, l do
|
|
||||||
feedpath[i] = path[i]
|
feedpath[i] = path[i]
|
||||||
end
|
end
|
||||||
tsetn(feedpath,l)
|
|
||||||
|
|
||||||
BuildPath(feedpath, strsplit("\001", uniquevalue))
|
BuildPath(feedpath, strsplit("\001", uniquevalue))
|
||||||
local group = options
|
local group = options
|
||||||
@@ -1439,37 +1503,35 @@ local function TreeOnButtonEnter(widget, event, _, uniquevalue, button)
|
|||||||
local name = GetOptionsMemberValue("name", group, options, feedpath, appName)
|
local name = GetOptionsMemberValue("name", group, options, feedpath, appName)
|
||||||
local desc = GetOptionsMemberValue("desc", group, options, feedpath, appName)
|
local desc = GetOptionsMemberValue("desc", group, options, feedpath, appName)
|
||||||
|
|
||||||
GameTooltip:SetOwner(button, "ANCHOR_NONE")
|
GameTooltip:SetOwner(button, "ANCHOR_CURSOR")
|
||||||
if widget.type == "TabGroup" then
|
if widget.type == "TabGroup" then
|
||||||
GameTooltip:SetPoint("BOTTOM",button,"TOP")
|
GameTooltip:SetPoint("BOTTOM",button,"TOP")
|
||||||
else
|
else
|
||||||
GameTooltip:SetPoint("LEFT",button,"RIGHT")
|
GameTooltip:SetPoint("LEFT",button,"RIGHT")
|
||||||
end
|
end
|
||||||
|
|
||||||
GameTooltip:SetText(name, 1, .82, 0, true)
|
GameTooltip:SetText(name, 1, .82, 0, 1)
|
||||||
|
|
||||||
if type(desc) == "string" then
|
if type(desc) == "string" then
|
||||||
GameTooltip:AddLine(desc, 1, 1, 1, true)
|
GameTooltip:AddLine(desc, 1, 1, 1, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
GameTooltip:Show()
|
GameTooltip:Show()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function TreeOnButtonLeave(widget, event, _, value, button)
|
local function TreeOnButtonLeave(widget, event, value, button)
|
||||||
GameTooltip:Hide()
|
GameTooltip:Hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function GroupExists(appName, options, path, uniquevalue)
|
local function GroupExists(appName, options, path, uniquevalue)
|
||||||
|
|
||||||
if not uniquevalue then return false end
|
if not uniquevalue then return false end
|
||||||
|
|
||||||
local feedpath = new()
|
local feedpath = new()
|
||||||
local temppath = new()
|
local temppath = new()
|
||||||
local l = tgetn(path)
|
for i = 1, tgetn(path) do
|
||||||
for i = 1, l do
|
|
||||||
feedpath[i] = path[i]
|
feedpath[i] = path[i]
|
||||||
end
|
end
|
||||||
tsetn(feedpath,l)
|
|
||||||
|
|
||||||
BuildPath(feedpath, strsplit("\001", uniquevalue))
|
BuildPath(feedpath, strsplit("\001", uniquevalue))
|
||||||
|
|
||||||
@@ -1490,8 +1552,7 @@ local function GroupExists(appName, options, path, uniquevalue)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function GroupSelected(widget, event, _, uniquevalue)
|
local function GroupSelected(widget, event, uniquevalue)
|
||||||
if not uniquevalue then widget:ReleaseChildren() return end
|
|
||||||
|
|
||||||
local user = widget:GetUserDataTable()
|
local user = widget:GetUserDataTable()
|
||||||
|
|
||||||
@@ -1501,11 +1562,9 @@ local function GroupSelected(widget, event, _, uniquevalue)
|
|||||||
local rootframe = user.rootframe
|
local rootframe = user.rootframe
|
||||||
|
|
||||||
local feedpath = new()
|
local feedpath = new()
|
||||||
local l = tgetn(path)
|
for i = 1, tgetn(path) do
|
||||||
for i = 1, l do
|
|
||||||
feedpath[i] = path[i]
|
feedpath[i] = path[i]
|
||||||
end
|
end
|
||||||
tsetn(feedpath,l)
|
|
||||||
|
|
||||||
BuildPath(feedpath, strsplit("\001", uniquevalue))
|
BuildPath(feedpath, strsplit("\001", uniquevalue))
|
||||||
local group = options
|
local group = options
|
||||||
@@ -1513,7 +1572,6 @@ local function GroupSelected(widget, event, _, uniquevalue)
|
|||||||
group = GetSubOption(group, feedpath[i])
|
group = GetSubOption(group, feedpath[i])
|
||||||
end
|
end
|
||||||
widget:ReleaseChildren()
|
widget:ReleaseChildren()
|
||||||
|
|
||||||
AceConfigDialog:FeedGroup(user.appName,options,widget,rootframe,feedpath)
|
AceConfigDialog:FeedGroup(user.appName,options,widget,rootframe,feedpath)
|
||||||
|
|
||||||
del(feedpath)
|
del(feedpath)
|
||||||
@@ -1538,16 +1596,16 @@ Rules:
|
|||||||
--]]
|
--]]
|
||||||
|
|
||||||
function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isRoot)
|
function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isRoot)
|
||||||
|
|
||||||
local group = options
|
local group = options
|
||||||
--follow the path to get to the curent group
|
--follow the path to get to the curent group
|
||||||
local inline
|
local inline
|
||||||
local grouptype, parenttype = options.childGroups, "none"
|
local grouptype, parenttype = options.childGroups, "none"
|
||||||
|
|
||||||
|
|
||||||
for i = 1, tgetn(path) do
|
for i = 1, tgetn(path) do
|
||||||
local v = path[i]
|
local v = path[i]
|
||||||
group = GetSubOption(group, v)
|
group = GetSubOption(group, v)
|
||||||
inline = inline or pickfirstset(4,group.dialogInline,group.guiInline,group.inline, false)
|
inline = inline or pickfirstset(v.dialogInline,v.guiInline,v.inline, false)
|
||||||
parenttype = grouptype
|
parenttype = grouptype
|
||||||
grouptype = group.childGroups
|
grouptype = group.childGroups
|
||||||
end
|
end
|
||||||
@@ -1559,14 +1617,14 @@ function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isR
|
|||||||
--check if the group has child groups
|
--check if the group has child groups
|
||||||
local hasChildGroups
|
local hasChildGroups
|
||||||
for k, v in pairs(group.args) do
|
for k, v in pairs(group.args) do
|
||||||
if v.type == "group" and not pickfirstset(4,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) and not CheckOptionHidden(v, options, path, appName) then
|
||||||
hasChildGroups = true
|
hasChildGroups = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if group.plugins then
|
if group.plugins then
|
||||||
for plugin, t in pairs(group.plugins) do
|
for plugin, t in pairs(group.plugins) do
|
||||||
for k, v in pairs(t) do
|
for k, v in pairs(t) do
|
||||||
if v.type == "group" and not pickfirstset(4,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) and not CheckOptionHidden(v, options, path, appName) then
|
||||||
hasChildGroups = true
|
hasChildGroups = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1650,7 +1708,7 @@ function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isR
|
|||||||
|
|
||||||
local firstgroup = orderlist[1]
|
local firstgroup = orderlist[1]
|
||||||
if firstgroup then
|
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
|
end
|
||||||
|
|
||||||
select.width = "fill"
|
select.width = "fill"
|
||||||
@@ -1792,7 +1850,7 @@ end
|
|||||||
-- @param appName The application name as given to `:RegisterOptionsTable()`
|
-- @param appName The application name as given to `:RegisterOptionsTable()`
|
||||||
-- @param container An optional container frame to feed the options into
|
-- @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)
|
-- @param ... The path to open after creating the options window (see `:SelectGroup` for details)
|
||||||
function AceConfigDialog:Open(appName, container, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
function AceConfigDialog:Open(appName, container, ...)
|
||||||
if not old_CloseSpecialWindows then
|
if not old_CloseSpecialWindows then
|
||||||
old_CloseSpecialWindows = CloseSpecialWindows
|
old_CloseSpecialWindows = CloseSpecialWindows
|
||||||
CloseSpecialWindows = function()
|
CloseSpecialWindows = function()
|
||||||
@@ -1817,7 +1875,9 @@ function AceConfigDialog:Open(appName, container, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10
|
|||||||
tinsert(path, container)
|
tinsert(path, container)
|
||||||
container = nil
|
container = nil
|
||||||
end
|
end
|
||||||
BuildPath(path, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
for n = 1, tgetn(arg) do
|
||||||
|
tinsert(path, arg[i])
|
||||||
|
end
|
||||||
|
|
||||||
local option = options
|
local option = options
|
||||||
if type(container) == "table" and container.type == "BlizOptionsGroup" and tgetn(path) > 0 then
|
if type(container) == "table" and container.type == "BlizOptionsGroup" and tgetn(path) > 0 then
|
||||||
@@ -1826,7 +1886,6 @@ function AceConfigDialog:Open(appName, container, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10
|
|||||||
end
|
end
|
||||||
name = format("%s - %s", name, GetOptionsMemberValue("name", option, options, path, appName))
|
name = format("%s - %s", name, GetOptionsMemberValue("name", option, options, path, appName))
|
||||||
end
|
end
|
||||||
|
|
||||||
--if a container is given feed into that
|
--if a container is given feed into that
|
||||||
if container then
|
if container then
|
||||||
f = container
|
f = container
|
||||||
@@ -1925,9 +1984,8 @@ function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...)
|
|||||||
local BlizOptions = AceConfigDialog.BlizOptions
|
local BlizOptions = AceConfigDialog.BlizOptions
|
||||||
|
|
||||||
local key = appName
|
local key = appName
|
||||||
local l = tgetn(arg)
|
for n = 1, tgetn(arg) do
|
||||||
for n = 1, l do
|
key = key.."\001"..arg[n]
|
||||||
key = key .. "\001" .. arg[n]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not BlizOptions[appName] then
|
if not BlizOptions[appName] then
|
||||||
@@ -1941,10 +1999,10 @@ function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...)
|
|||||||
|
|
||||||
group:SetTitle(name or appName)
|
group:SetTitle(name or appName)
|
||||||
group:SetUserData("appName", appName)
|
group:SetUserData("appName", appName)
|
||||||
if l > 0 then
|
if tgetn(arg) > 0 then
|
||||||
local path = {}
|
local path = {}
|
||||||
for n = 1, l do
|
for n = 1, tgetn(arg) do
|
||||||
tinsert(path, args[n])
|
tinsert(path, arg[n])
|
||||||
end
|
end
|
||||||
group:SetUserData("path", path)
|
group:SetUserData("path", path)
|
||||||
end
|
end
|
||||||
|
|||||||
+47
-37
@@ -8,24 +8,25 @@
|
|||||||
-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName".
|
-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName".
|
||||||
-- @class file
|
-- @class file
|
||||||
-- @name AceConfigRegistry-3.0
|
-- @name AceConfigRegistry-3.0
|
||||||
-- @release $Id: AceConfigRegistry-3.0.lua 1139 2016-07-03 07:43:51Z nevcairiel $
|
-- @release $Id: AceConfigRegistry-3.0.lua 1105 2013-12-08 22:11:58Z nevcairiel $
|
||||||
local MAJOR, MINOR = "AceConfigRegistry-3.0", 16
|
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
|
||||||
|
|
||||||
|
local MAJOR, MINOR = "AceConfigRegistry-3.0-ElvUI", 2
|
||||||
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
|
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
|
||||||
|
|
||||||
if not AceConfigRegistry then return end
|
if not AceConfigRegistry then return end
|
||||||
|
|
||||||
AceConfigRegistry.tables = AceConfigRegistry.tables or {}
|
AceConfigRegistry.tables = AceConfigRegistry.tables or {}
|
||||||
|
|
||||||
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
|
|
||||||
|
|
||||||
if not AceConfigRegistry.callbacks then
|
if not AceConfigRegistry.callbacks then
|
||||||
AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
|
AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local tinsert, tconcat, tgetn = table.insert, table.concat, table.getn
|
local tinsert, tconcat = table.insert, table.concat
|
||||||
local strfind = string.find
|
local strfind, strmatch = string.find, string.match
|
||||||
local type, tostring, pairs = type, tostring, pairs
|
local tgetn = table.getn
|
||||||
|
local type, tostring, select, pairs, unpack = type, tostring, select, pairs, unpack
|
||||||
local error, assert = error, assert
|
local error, assert = error, assert
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@@ -40,17 +41,17 @@ AceConfigRegistry.validated = {
|
|||||||
dialog = {},
|
dialog = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function err(msg, errlvl, ...)
|
local function err(msg, errlvl, ...)
|
||||||
local l = tgetn(arg)
|
local t = {}
|
||||||
local i,j = 1,l
|
for i=tgetn(arg),1,-1 do
|
||||||
while i < j do
|
tinsert(t, (arg[i]))
|
||||||
arg[i], arg[j] = arg[j], arg[i]
|
|
||||||
i = i+1
|
|
||||||
j = j-1
|
|
||||||
end
|
end
|
||||||
error(MAJOR..":ValidateOptionsTable(): "..tconcat(arg,".")..msg, errlvl+2)
|
error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local isstring={["string"]=true, _="string"}
|
local isstring={["string"]=true, _="string"}
|
||||||
local isstringfunc={["string"]=true,["function"]=true, _="string or funcref"}
|
local isstringfunc={["string"]=true,["function"]=true, _="string or funcref"}
|
||||||
local istable={["table"]=true, _="table"}
|
local istable={["table"]=true, _="table"}
|
||||||
@@ -91,6 +92,17 @@ local basekeys={
|
|||||||
func=optmethodfalse,
|
func=optmethodfalse,
|
||||||
arg={["*"]=true},
|
arg={["*"]=true},
|
||||||
width=optstring,
|
width=optstring,
|
||||||
|
customWidth=optnumber,
|
||||||
|
textWidth=optmethodbool,
|
||||||
|
buttonElvUI=optmethodbool,
|
||||||
|
dragdrop=optmethodbool,
|
||||||
|
dragOnEnter=optmethodfalse,
|
||||||
|
dragOnLeave=optmethodfalse,
|
||||||
|
dragOnClick=optmethodfalse,
|
||||||
|
dragOnMouseUp=optmethodfalse,
|
||||||
|
dragOnMouseDown=optmethodfalse,
|
||||||
|
stateSwitchOnClick=optmethodfalse,
|
||||||
|
stateSwitchGetText=optmethodfalse,
|
||||||
}
|
}
|
||||||
|
|
||||||
local typedkeys={
|
local typedkeys={
|
||||||
@@ -125,7 +137,6 @@ local typedkeys={
|
|||||||
dialogControl=optstring,
|
dialogControl=optstring,
|
||||||
dropdownControl=optstring,
|
dropdownControl=optstring,
|
||||||
multiline=optboolnumber,
|
multiline=optboolnumber,
|
||||||
nullable=optbool,
|
|
||||||
},
|
},
|
||||||
toggle={
|
toggle={
|
||||||
tristate=optbool,
|
tristate=optbool,
|
||||||
@@ -145,7 +156,6 @@ local typedkeys={
|
|||||||
},
|
},
|
||||||
select={
|
select={
|
||||||
values=ismethodtable,
|
values=ismethodtable,
|
||||||
valuesTableDestroyable=optbool, -- Ace3v: if the values table is generated by AceCore.new
|
|
||||||
style={
|
style={
|
||||||
["nil"]=true,
|
["nil"]=true,
|
||||||
["string"]={dropdown=true,radio=true},
|
["string"]={dropdown=true,radio=true},
|
||||||
@@ -158,7 +168,6 @@ local typedkeys={
|
|||||||
},
|
},
|
||||||
multiselect={
|
multiselect={
|
||||||
values=ismethodtable,
|
values=ismethodtable,
|
||||||
valuesTableDestroyable=optbool, -- Ace3v: if the values table is generated by AceCore.new
|
|
||||||
style=optstring,
|
style=optstring,
|
||||||
tristate=optbool,
|
tristate=optbool,
|
||||||
control=optstring,
|
control=optstring,
|
||||||
@@ -167,81 +176,82 @@ local typedkeys={
|
|||||||
},
|
},
|
||||||
color={
|
color={
|
||||||
hasAlpha=optmethodbool,
|
hasAlpha=optmethodbool,
|
||||||
|
reset=opttable,
|
||||||
},
|
},
|
||||||
keybinding={
|
keybinding={
|
||||||
-- TODO
|
-- TODO
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local function validateKey(k,errlvl,arg)
|
local function validateKey(k,errlvl,...)
|
||||||
errlvl=(errlvl or 0)+1
|
errlvl=(errlvl or 0)+1
|
||||||
if type(k)~="string" then
|
if type(k)~="string" then
|
||||||
err("["..tostring(k).."] - key is not a string", errlvl, arg)
|
err("["..tostring(k).."] - key is not a string", errlvl,unpack(arg))
|
||||||
end
|
end
|
||||||
if strfind(k, "[%c\127]") then
|
if strfind(k, "[%c\127]") then
|
||||||
err("["..tostring(k).."] - key name contained control characters", errlvl, arg)
|
err("["..tostring(k).."] - key name contained control characters", errlvl,unpack(arg))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function validateVal(v, oktypes, errlvl, arg)
|
local function validateVal(v, oktypes, errlvl,...)
|
||||||
errlvl=(errlvl or 0)+1
|
errlvl=(errlvl or 0)+1
|
||||||
local isok=oktypes[type(v)] or oktypes["*"]
|
local isok=oktypes[type(v)] or oktypes["*"]
|
||||||
|
|
||||||
if not isok then
|
if not isok then
|
||||||
err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl, arg)
|
err(": expected a "..oktypes._..", got '"..tostring(v).."'", errlvl,unpack(arg))
|
||||||
end
|
end
|
||||||
if type(isok)=="table" then -- isok was a table containing specific values to be tested for!
|
if type(isok)=="table" then -- isok was a table containing specific values to be tested for!
|
||||||
if not isok[v] then
|
if not isok[v] then
|
||||||
err(": did not expect "..type(v).." value '"..tostring(v).."'", errlvl, arg)
|
err(": did not expect "..type(v).." value '"..tostring(v).."'", errlvl,unpack(arg))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function validate(options,errlvl,arg)
|
local function validate(options,errlvl,...)
|
||||||
errlvl=(errlvl or 0)+1
|
errlvl=(errlvl or 0)+1
|
||||||
-- basic consistency
|
-- basic consistency
|
||||||
if type(options)~="table" then
|
if type(options)~="table" then
|
||||||
err(": expected a table, got a "..type(options), errlvl, arg)
|
err(": expected a table, got a "..type(options), errlvl,unpack(arg))
|
||||||
end
|
end
|
||||||
if type(options.type)~="string" then
|
if type(options.type)~="string" then
|
||||||
err(".type: expected a string, got a "..type(options.type), errlvl, arg)
|
err(".type: expected a string, got a "..type(options.type), errlvl,unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get type and 'typedkeys' member
|
-- get type and 'typedkeys' member
|
||||||
local tk = typedkeys[options.type]
|
local tk = typedkeys[options.type]
|
||||||
if not tk then
|
if not tk then
|
||||||
err(".type: unknown type '"..options.type.."'", errlvl, arg)
|
err(".type: unknown type '"..options.type.."'", errlvl,unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- make sure that all options[] are known parameters
|
-- make sure that all options[] are known parameters
|
||||||
for k,v in pairs(options) do
|
for k,v in pairs(options) do
|
||||||
if not (tk[k] or basekeys[k]) then
|
if not (tk[k] or basekeys[k]) then
|
||||||
err(": unknown parameter", errlvl,tostring(k), arg)
|
err(": unknown parameter", errlvl,tostring(k),unpack(arg))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- verify that required params are there, and that everything is the right type
|
-- verify that required params are there, and that everything is the right type
|
||||||
for k,oktypes in pairs(basekeys) do
|
for k,oktypes in pairs(basekeys) do
|
||||||
validateVal(options[k], oktypes, errlvl, k, arg)
|
validateVal(options[k], oktypes, errlvl,k,unpack(arg))
|
||||||
end
|
end
|
||||||
for k,oktypes in pairs(tk) do
|
for k,oktypes in pairs(tk) do
|
||||||
validateVal(options[k], oktypes, errlvl, k, arg)
|
validateVal(options[k], oktypes, errlvl,k,unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- extra logic for groups
|
-- extra logic for groups
|
||||||
if options.type=="group" then
|
if options.type=="group" then
|
||||||
for k,v in pairs(options.args) do
|
for k,v in pairs(options.args) do
|
||||||
validateKey(k,errlvl,"args", arg)
|
validateKey(k,errlvl,"args",unpack(arg))
|
||||||
validate(v, errlvl,k,"args", arg)
|
validate(v, errlvl,k,"args",unpack(arg))
|
||||||
end
|
end
|
||||||
if options.plugins then
|
if options.plugins then
|
||||||
for plugname,plugin in pairs(options.plugins) do
|
for plugname,plugin in pairs(options.plugins) do
|
||||||
if type(plugin)~="table" then
|
if type(plugin)~="table" then
|
||||||
err(": expected a table, got '"..tostring(plugin).."'", errlvl,tostring(plugname), "plugins", arg)
|
err(": expected a table, got '"..tostring(plugin).."'", errlvl,tostring(plugname),"plugins",unpack(arg))
|
||||||
end
|
end
|
||||||
for k,v in pairs(plugin) do
|
for k,v in pairs(plugin) do
|
||||||
validateKey(k,errlvl,tostring(plugname),"plugins",arg)
|
validateKey(k,errlvl,tostring(plugname),"plugins",unpack(arg))
|
||||||
validate(v, errlvl,k,tostring(plugname),"plugins",arg)
|
validate(v, errlvl,k,tostring(plugname),"plugins",unpack(arg))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -269,7 +279,7 @@ end
|
|||||||
-- @param appName The application name as given to `:RegisterOptionsTable()`
|
-- @param appName The application name as given to `:RegisterOptionsTable()`
|
||||||
function AceConfigRegistry:NotifyChange(appName)
|
function AceConfigRegistry:NotifyChange(appName)
|
||||||
if not AceConfigRegistry.tables[appName] then return end
|
if not AceConfigRegistry.tables[appName] then return end
|
||||||
AceConfigRegistry.callbacks:Fire("ConfigTableChange", 1, appName)
|
AceConfigRegistry.callbacks:Fire("ConfigTableChange", appName)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- -------------------------------------------------------------------
|
-- -------------------------------------------------------------------
|
||||||
@@ -283,7 +293,7 @@ local function validateGetterArgs(uiType, uiName, errlvl)
|
|||||||
if uiType~="cmd" and uiType~="dropdown" and uiType~="dialog" then
|
if uiType~="cmd" and uiType~="dropdown" and uiType~="dialog" then
|
||||||
error(MAJOR..": Requesting options table: 'uiType' - invalid configuration UI type, expected 'cmd', 'dropdown' or 'dialog'", errlvl)
|
error(MAJOR..": Requesting options table: 'uiType' - invalid configuration UI type, expected 'cmd', 'dropdown' or 'dialog'", errlvl)
|
||||||
end
|
end
|
||||||
if not strfind(uiName, "[A-Za-z]+-[0-9]") then -- Expecting e.g. "MyLib-1.2"
|
if not strmatch(uiName, "[A-Za-z]%-[0-9]") then -- Expecting e.g. "MyLib-1.2"
|
||||||
error(MAJOR..": Requesting options table: 'uiName' - badly formatted or missing version number. Expected e.g. 'MyLib-1.2'", errlvl)
|
error(MAJOR..": Requesting options table: 'uiName' - badly formatted or missing version number. Expected e.g. 'MyLib-1.2'", errlvl)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
--- AceDBOptions-3.0 provides a universal AceConfig options screen for managing AceDB-3.0 profiles.
|
--- AceDBOptions-3.0 provides a universal AceConfig options screen for managing AceDB-3.0 profiles.
|
||||||
-- @class file
|
-- @class file
|
||||||
-- @name AceDBOptions-3.0
|
-- @name AceDBOptions-3.0
|
||||||
-- @release $Id: AceDBOptions-3.0.lua 1140 2016-07-03 07:53:29Z nevcairiel $
|
-- @release $Id: AceDBOptions-3.0.lua 1066 2012-09-18 14:36:49Z nevcairiel $
|
||||||
local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 15
|
local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 15
|
||||||
local AceDBOptions, oldminor = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR)
|
local AceDBOptions, oldminor = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR)
|
||||||
|
|
||||||
if not AceDBOptions then return end -- No upgrade needed
|
if not AceDBOptions then return end -- No upgrade needed
|
||||||
|
|
||||||
local AceCore = LibStub("AceCore-3.0")
|
|
||||||
local new, del = AceCore.new, AceCore.del
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local pairs, next = pairs, next
|
local pairs, next = pairs, next
|
||||||
|
|
||||||
@@ -233,6 +230,7 @@ elseif LOCALE == "ptBR" then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local defaultProfiles
|
local defaultProfiles
|
||||||
|
local tmpprofiles = {}
|
||||||
|
|
||||||
-- Get a list of available profiles for the specified database.
|
-- Get a list of available profiles for the specified database.
|
||||||
-- You can specify which profiles to include/exclude in the list using the two boolean parameters listed below.
|
-- You can specify which profiles to include/exclude in the list using the two boolean parameters listed below.
|
||||||
@@ -241,8 +239,8 @@ local defaultProfiles
|
|||||||
-- @param nocurrent If true, then getProfileList will not display the current profile in the list
|
-- @param nocurrent If true, then getProfileList will not display the current profile in the list
|
||||||
-- @return Hashtable of all profiles with the internal name as keys and the display name as value.
|
-- @return Hashtable of all profiles with the internal name as keys and the display name as value.
|
||||||
local function getProfileList(db, common, nocurrent)
|
local function getProfileList(db, common, nocurrent)
|
||||||
local profiles = new()
|
local profiles = {}
|
||||||
local tmpprofiles = new()
|
|
||||||
-- copy existing profiles into the table
|
-- copy existing profiles into the table
|
||||||
local currentProfile = db:GetCurrentProfile()
|
local currentProfile = db:GetCurrentProfile()
|
||||||
for i,v in pairs(db:GetProfiles(tmpprofiles)) do
|
for i,v in pairs(db:GetProfiles(tmpprofiles)) do
|
||||||
@@ -250,7 +248,6 @@ local function getProfileList(db, common, nocurrent)
|
|||||||
profiles[v] = v
|
profiles[v] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
del(tmpprofiles)
|
|
||||||
|
|
||||||
-- add our default profiles to choose from ( or rename existing profiles)
|
-- add our default profiles to choose from ( or rename existing profiles)
|
||||||
for k,v in pairs(defaultProfiles) do
|
for k,v in pairs(defaultProfiles) do
|
||||||
@@ -293,8 +290,6 @@ end
|
|||||||
"common" - returns all avaialble profiles + some commonly used profiles ("char - realm", "realm", "class", "Default")
|
"common" - returns all avaialble profiles + some commonly used profiles ("char - realm", "realm", "class", "Default")
|
||||||
"both" - common except the active profile
|
"both" - common except the active profile
|
||||||
]]
|
]]
|
||||||
-- Ace3v: It is recommanded to destroy the returned table by AceCore.del
|
|
||||||
-- if it is no longer needed
|
|
||||||
function OptionsHandlerPrototype:ListProfiles(info)
|
function OptionsHandlerPrototype:ListProfiles(info)
|
||||||
local arg = info.arg
|
local arg = info.arg
|
||||||
local profiles
|
local profiles
|
||||||
@@ -313,9 +308,7 @@ end
|
|||||||
|
|
||||||
function OptionsHandlerPrototype:HasNoProfiles(info)
|
function OptionsHandlerPrototype:HasNoProfiles(info)
|
||||||
local profiles = self:ListProfiles(info)
|
local profiles = self:ListProfiles(info)
|
||||||
local r = (not next(profiles)) and true or false
|
return ((not next(profiles)) and true or false)
|
||||||
del(profiles)
|
|
||||||
return r
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ Copy a profile ]]
|
--[[ Copy a profile ]]
|
||||||
@@ -378,7 +371,8 @@ local optionsTable = {
|
|||||||
current = {
|
current = {
|
||||||
order = 11,
|
order = 11,
|
||||||
type = "description",
|
type = "description",
|
||||||
name = function(info) return L["current"] .. " " .. NORMAL_FONT_COLOR_CODE .. info.handler:GetCurrentProfile() .. FONT_COLOR_CODE_CLOSE end,
|
--name = function(info) return L["current"] .. " " .. NORMAL_FONT_COLOR_CODE .. info.handler:GetCurrentProfile() .. FONT_COLOR_CODE_CLOSE end,
|
||||||
|
name = "t",
|
||||||
width = "default",
|
width = "default",
|
||||||
},
|
},
|
||||||
choosedesc = {
|
choosedesc = {
|
||||||
@@ -393,7 +387,6 @@ local optionsTable = {
|
|||||||
order = 30,
|
order = 30,
|
||||||
get = false,
|
get = false,
|
||||||
set = "SetProfile",
|
set = "SetProfile",
|
||||||
nullable = false, -- Ace3v: we do not want a null or empty value
|
|
||||||
},
|
},
|
||||||
choose = {
|
choose = {
|
||||||
name = L["choose"],
|
name = L["choose"],
|
||||||
@@ -403,7 +396,6 @@ local optionsTable = {
|
|||||||
get = "GetCurrentProfile",
|
get = "GetCurrentProfile",
|
||||||
set = "SetProfile",
|
set = "SetProfile",
|
||||||
values = "ListProfiles",
|
values = "ListProfiles",
|
||||||
valuesTableDestroyable = true,
|
|
||||||
arg = "common",
|
arg = "common",
|
||||||
},
|
},
|
||||||
copydesc = {
|
copydesc = {
|
||||||
@@ -419,7 +411,6 @@ local optionsTable = {
|
|||||||
get = false,
|
get = false,
|
||||||
set = "CopyProfile",
|
set = "CopyProfile",
|
||||||
values = "ListProfiles",
|
values = "ListProfiles",
|
||||||
valuesTableDestroyable = true,
|
|
||||||
disabled = "HasNoProfiles",
|
disabled = "HasNoProfiles",
|
||||||
arg = "nocurrent",
|
arg = "nocurrent",
|
||||||
},
|
},
|
||||||
@@ -436,7 +427,6 @@ local optionsTable = {
|
|||||||
get = false,
|
get = false,
|
||||||
set = "DeleteProfile",
|
set = "DeleteProfile",
|
||||||
values = "ListProfiles",
|
values = "ListProfiles",
|
||||||
valuesTableDestroyable = true,
|
|
||||||
disabled = "HasNoProfiles",
|
disabled = "HasNoProfiles",
|
||||||
arg = "nocurrent",
|
arg = "nocurrent",
|
||||||
confirm = true,
|
confirm = true,
|
||||||
|
|||||||
@@ -30,17 +30,13 @@ local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR)
|
|||||||
|
|
||||||
if not AceGUI then return end -- No upgrade needed
|
if not AceGUI then return end -- No upgrade needed
|
||||||
|
|
||||||
local AceCore = LibStub("AceCore-3.0")
|
|
||||||
local hooksecurefunc = AceCore.hooksecurefunc
|
|
||||||
local safecall = AceCore.safecall
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local tconcat, tremove, tinsert, tgetn, tsetn = table.concat, table.remove, table.insert, table.getn, table.setn
|
local tconcat, tgetn, tremove, tinsert = table.concat, table.getn,table.remove, table.insert
|
||||||
local pairs, next, type = pairs, next, type
|
local gsub, strupper = string.gsub, string.upper
|
||||||
|
local select, pairs, next, type = select, pairs, next, type
|
||||||
local error, assert, loadstring = error, assert, loadstring
|
local error, assert, loadstring = error, assert, loadstring
|
||||||
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
|
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
|
||||||
local math_max = math.max
|
local math_max = math.max
|
||||||
local strupper, strfmt = string.upper, string.format
|
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local UIParent = UIParent
|
local UIParent = UIParent
|
||||||
@@ -56,17 +52,73 @@ AceGUI.LayoutRegistry = AceGUI.LayoutRegistry or {}
|
|||||||
AceGUI.WidgetBase = AceGUI.WidgetBase or {}
|
AceGUI.WidgetBase = AceGUI.WidgetBase or {}
|
||||||
AceGUI.WidgetContainerBase = AceGUI.WidgetContainerBase or {}
|
AceGUI.WidgetContainerBase = AceGUI.WidgetContainerBase or {}
|
||||||
AceGUI.WidgetVersions = AceGUI.WidgetVersions or {}
|
AceGUI.WidgetVersions = AceGUI.WidgetVersions or {}
|
||||||
AceGUI.HookedFunctions = AceGUI.HookedFunctions or {}
|
|
||||||
|
|
||||||
-- local upvalues
|
-- local upvalues
|
||||||
local WidgetRegistry = AceGUI.WidgetRegistry
|
local WidgetRegistry = AceGUI.WidgetRegistry
|
||||||
local LayoutRegistry = AceGUI.LayoutRegistry
|
local LayoutRegistry = AceGUI.LayoutRegistry
|
||||||
local WidgetVersions = AceGUI.WidgetVersions
|
local WidgetVersions = AceGUI.WidgetVersions
|
||||||
local HookedFunctions = AceGUI.HookedFunctions
|
|
||||||
|
--[[
|
||||||
|
xpcall safecall implementation
|
||||||
|
]]
|
||||||
|
local xpcall = xpcall
|
||||||
|
|
||||||
|
local function errorhandler(err)
|
||||||
|
return geterrorhandler()(err)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function CreateDispatcher(argCount)
|
||||||
|
local code = [[
|
||||||
|
local method, ARGS
|
||||||
|
local function call() return method(ARGS) end
|
||||||
|
|
||||||
|
local function dispatch(func, ...)
|
||||||
|
method = func
|
||||||
|
if not method then return end
|
||||||
|
ARGS = unpack(arg)
|
||||||
|
return xpcall(call, function(err) return geterrorhandler()(err) end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return dispatch
|
||||||
|
]]
|
||||||
|
|
||||||
|
local ARGS = {}
|
||||||
|
for i = 1, argCount do ARGS[i] = "arg"..i end
|
||||||
|
code = gsub(code, "ARGS", tconcat(ARGS, ", "))
|
||||||
|
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
|
||||||
|
end
|
||||||
|
|
||||||
|
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
|
||||||
|
local dispatcher = CreateDispatcher(argCount)
|
||||||
|
rawset(self, argCount, dispatcher)
|
||||||
|
return dispatcher
|
||||||
|
end})
|
||||||
|
Dispatchers[0] = function(func)
|
||||||
|
return xpcall(func, errorhandler)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function safecall(func, ...)
|
||||||
|
return Dispatchers[tgetn(arg)](func, unpack(arg))
|
||||||
|
end
|
||||||
|
|
||||||
-- Recycling functions
|
-- Recycling functions
|
||||||
local newWidget, delWidget
|
local newWidget, delWidget
|
||||||
do
|
do
|
||||||
|
-- Version Upgrade in Minor 29
|
||||||
|
-- Internal Storage of the objects changed, from an array table
|
||||||
|
-- to a hash table, and additionally we introduced versioning on
|
||||||
|
-- the widgets which would discard all widgets from a pre-29 version
|
||||||
|
-- anyway, so we just clear the storage now, and don't try to
|
||||||
|
-- convert the storage tables to the new format.
|
||||||
|
-- This should generally not cause *many* widgets to end up in trash,
|
||||||
|
-- since once dialogs are opened, all addons should be loaded already
|
||||||
|
-- and AceGUI should be on the latest version available on the users
|
||||||
|
-- setup.
|
||||||
|
-- -- nevcairiel - Nov 2nd, 2009
|
||||||
|
if oldminor and oldminor < 29 and AceGUI.objPools then
|
||||||
|
AceGUI.objPools = nil
|
||||||
|
end
|
||||||
|
|
||||||
AceGUI.objPools = AceGUI.objPools or {}
|
AceGUI.objPools = AceGUI.objPools or {}
|
||||||
local objPools = AceGUI.objPools
|
local objPools = AceGUI.objPools
|
||||||
--Returns a new instance, if none are available either returns a new table or calls the given contructor
|
--Returns a new instance, if none are available either returns a new table or calls the given contructor
|
||||||
@@ -105,35 +157,6 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ace3v: when a container contains many children, we can only use the variable arguments
|
|
||||||
local function _fixlevels(parent, ...)
|
|
||||||
local lv = parent:GetFrameLevel() + 1
|
|
||||||
for i = 1, tgetn(arg) do
|
|
||||||
local child = arg[i]
|
|
||||||
child:SetFrameLevel(lv)
|
|
||||||
_fixlevels(child, child:GetChildren())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function fixlevels(parent)
|
|
||||||
return _fixlevels(parent, parent:GetChildren())
|
|
||||||
end
|
|
||||||
AceGUI.fixlevels = fixlevels
|
|
||||||
|
|
||||||
-- Ace3v: attention! this function is recursive
|
|
||||||
local function _fixstrata(strata, parent, ...)
|
|
||||||
parent:SetFrameStrata(strata)
|
|
||||||
for i = 1, tgetn(arg) do
|
|
||||||
local child = arg[i]
|
|
||||||
_fixstrata(strata, child, child:GetChildren())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function fixstrata(strata, parent)
|
|
||||||
return _fixstrata(strata, parent, parent:GetChildren())
|
|
||||||
end
|
|
||||||
AceGUI.fixstrata = fixstrata
|
|
||||||
|
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
-- API Functions --
|
-- API Functions --
|
||||||
@@ -150,15 +173,27 @@ function AceGUI:Create(type)
|
|||||||
if WidgetRegistry[type] then
|
if WidgetRegistry[type] then
|
||||||
local widget = newWidget(type)
|
local widget = newWidget(type)
|
||||||
|
|
||||||
|
if rawget(widget, "Acquire") then
|
||||||
|
widget.OnAcquire = widget.Acquire
|
||||||
|
widget.Acquire = nil
|
||||||
|
elseif rawget(widget, "Aquire") then
|
||||||
|
widget.OnAcquire = widget.Aquire
|
||||||
|
widget.Aquire = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if rawget(widget, "Release") then
|
||||||
|
widget.OnRelease = rawget(widget, "Release")
|
||||||
|
widget.Release = nil
|
||||||
|
end
|
||||||
|
|
||||||
if widget.OnAcquire then
|
if widget.OnAcquire then
|
||||||
widget:OnAcquire()
|
widget:OnAcquire()
|
||||||
else
|
else
|
||||||
error(strfmt("Widget type %s doesn't supply an OnAcquire Function", type))
|
error(format("Widget type %s doesn't supply an OnAcquire Function", type))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set the default Layout ("List")
|
-- Set the default Layout ("List")
|
||||||
safecall(widget.SetLayout, 2, widget, "List")
|
safecall(widget.SetLayout, widget, "List")
|
||||||
safecall(widget.ResumeLayout, 1, widget)
|
safecall(widget.ResumeLayout, widget)
|
||||||
return widget
|
return widget
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -169,14 +204,14 @@ end
|
|||||||
-- If this widget is a Container-Widget, all of its Child-Widgets will be releases as well.
|
-- If this widget is a Container-Widget, all of its Child-Widgets will be releases as well.
|
||||||
-- @param widget The widget to release
|
-- @param widget The widget to release
|
||||||
function AceGUI:Release(widget)
|
function AceGUI:Release(widget)
|
||||||
safecall(widget.PauseLayout, 1, widget)
|
safecall(widget.PauseLayout, widget)
|
||||||
widget:Fire("OnRelease")
|
widget:Fire("OnRelease")
|
||||||
safecall(widget.ReleaseChildren, 1, widget)
|
safecall(widget.ReleaseChildren, widget)
|
||||||
|
|
||||||
if widget.OnRelease then
|
if widget.OnRelease then
|
||||||
widget:OnRelease()
|
widget:OnRelease()
|
||||||
-- else
|
-- else
|
||||||
-- error(strfmt("Widget type %s doesn't supply an OnRelease Function", widget.type))
|
-- error(format("Widget type %s doesn't supply an OnRelease Function", widget.type))
|
||||||
end
|
end
|
||||||
for k in pairs(widget.userdata) do
|
for k in pairs(widget.userdata) do
|
||||||
widget.userdata[k] = nil
|
widget.userdata[k] = nil
|
||||||
@@ -211,7 +246,7 @@ end
|
|||||||
-- @param widget The widget that should be focused
|
-- @param widget The widget that should be focused
|
||||||
function AceGUI:SetFocus(widget)
|
function AceGUI:SetFocus(widget)
|
||||||
if self.FocusedWidget and self.FocusedWidget ~= widget then
|
if self.FocusedWidget and self.FocusedWidget ~= widget then
|
||||||
safecall(self.FocusedWidget.ClearFocus, 1, self.FocusedWidget)
|
safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
|
||||||
end
|
end
|
||||||
self.FocusedWidget = widget
|
self.FocusedWidget = widget
|
||||||
end
|
end
|
||||||
@@ -221,7 +256,7 @@ end
|
|||||||
-- e.g. titlebar of a frame being clicked
|
-- e.g. titlebar of a frame being clicked
|
||||||
function AceGUI:ClearFocus()
|
function AceGUI:ClearFocus()
|
||||||
if self.FocusedWidget then
|
if self.FocusedWidget then
|
||||||
safecall(self.FocusedWidget.ClearFocus, 1, self.FocusedWidget)
|
safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
|
||||||
self.FocusedWidget = nil
|
self.FocusedWidget = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -266,7 +301,6 @@ do
|
|||||||
frame:SetParent(nil)
|
frame:SetParent(nil)
|
||||||
frame:SetParent(parent.content)
|
frame:SetParent(parent.content)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
fixlevels(frame)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
WidgetBase.SetCallback = function(self, name, func)
|
WidgetBase.SetCallback = function(self, name, func)
|
||||||
@@ -275,11 +309,9 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
WidgetBase.Fire = function(self,name,argc,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
WidgetBase.Fire = function(self, name, ...)
|
||||||
argc = argc or 0
|
if self.events[name] then
|
||||||
local func = self.events[name]
|
local success, ret = safecall(self.events[name], self, name, unpack(arg))
|
||||||
if func then
|
|
||||||
local success, ret = safecall(func,argc+3,self,name,argc,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
|
||||||
if success then
|
if success then
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
@@ -330,8 +362,8 @@ do
|
|||||||
AceGUI:Release(self)
|
AceGUI:Release(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
WidgetBase.SetPoint = function(self,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
WidgetBase.SetPoint = function(self, ...)
|
||||||
return self.frame:SetPoint(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
return self.frame:SetPoint(unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
WidgetBase.ClearAllPoints = function(self)
|
WidgetBase.ClearAllPoints = function(self)
|
||||||
@@ -342,8 +374,8 @@ do
|
|||||||
return self.frame:GetNumPoints()
|
return self.frame:GetNumPoints()
|
||||||
end
|
end
|
||||||
|
|
||||||
WidgetBase.GetPoint = function(self,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
WidgetBase.GetPoint = function(self, ...)
|
||||||
return self.frame:GetPoint(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
return self.frame:GetPoint(unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
WidgetBase.GetUserDataTable = function(self)
|
WidgetBase.GetUserDataTable = function(self)
|
||||||
@@ -401,7 +433,7 @@ do
|
|||||||
if self.LayoutPaused then
|
if self.LayoutPaused then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
safecall(self.LayoutFunc, 2, self.content, self.children)
|
safecall(self.LayoutFunc, self.content, self.children)
|
||||||
end
|
end
|
||||||
|
|
||||||
--call this function to layout, makes sure layed out objects get a frame to get sizes etc
|
--call this function to layout, makes sure layed out objects get a frame to get sizes etc
|
||||||
@@ -430,48 +462,21 @@ do
|
|||||||
self:DoLayout()
|
self:DoLayout()
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
WidgetContainerBase.AddChildren = function(self, ...)
|
||||||
local args = {nil,nil,nil,nil,nil,nil,nil,nil,nil,nil}
|
for i = 1, tgetn(arg) do
|
||||||
WidgetContainerBase.AddChildren = function(self,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
local child = arg[i]
|
||||||
args[1] = a1
|
|
||||||
args[2] = a2
|
|
||||||
args[3] = a3
|
|
||||||
args[4] = a4
|
|
||||||
args[5] = a5
|
|
||||||
args[6] = a6
|
|
||||||
args[7] = a7
|
|
||||||
args[8] = a8
|
|
||||||
args[9] = a9
|
|
||||||
args[10] = a10
|
|
||||||
for i = 1,10 do
|
|
||||||
local child = args[i]
|
|
||||||
arg[i] = nil
|
|
||||||
|
|
||||||
if not child then break end
|
|
||||||
tinsert(self.children, child)
|
tinsert(self.children, child)
|
||||||
child:SetParent(self)
|
child:SetParent(self)
|
||||||
child.frame:Show()
|
child.frame:Show()
|
||||||
end
|
end
|
||||||
self:DoLayout()
|
self:DoLayout()
|
||||||
end
|
end
|
||||||
end -- WidgetContainerBase.AddChildren
|
|
||||||
|
|
||||||
WidgetContainerBase.ReleaseChildren = function(self)
|
WidgetContainerBase.ReleaseChildren = function(self)
|
||||||
local children = self.children
|
local children = self.children
|
||||||
for i = 1,tgetn(children) do
|
for i = 1,tgetn(children) do
|
||||||
AceGUI:Release(tremove(children))
|
AceGUI:Release(children[i])
|
||||||
end
|
children[i] = nil
|
||||||
end
|
|
||||||
|
|
||||||
WidgetContainerBase.SetParent = function(self, parent)
|
|
||||||
WidgetBase.SetParent(self, parent)
|
|
||||||
|
|
||||||
local lv = self.frame:GetFrameLevel()
|
|
||||||
self.content:SetFrameLevel(lv+1)
|
|
||||||
local children = self.children
|
|
||||||
for i = 1,tgetn(children) do
|
|
||||||
local child = children[i]
|
|
||||||
child:SetParent(self)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -568,7 +573,7 @@ end
|
|||||||
function AceGUI:RegisterLayout(Name, LayoutFunc)
|
function AceGUI:RegisterLayout(Name, LayoutFunc)
|
||||||
assert(type(LayoutFunc) == "function")
|
assert(type(LayoutFunc) == "function")
|
||||||
if type(Name) == "string" then
|
if type(Name) == "string" then
|
||||||
Name = string.upper(Name)
|
Name = strupper(Name)
|
||||||
end
|
end
|
||||||
LayoutRegistry[Name] = LayoutFunc
|
LayoutRegistry[Name] = LayoutFunc
|
||||||
end
|
end
|
||||||
@@ -653,7 +658,7 @@ AceGUI:RegisterLayout("List",
|
|||||||
|
|
||||||
height = height + (frame.height or frame:GetHeight() or 0)
|
height = height + (frame.height or frame:GetHeight() or 0)
|
||||||
end
|
end
|
||||||
safecall(content.obj.LayoutFinished, 3, content.obj, nil, height)
|
safecall(content.obj.LayoutFinished, content.obj, nil, height)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- A single control fills the whole content area
|
-- A single control fills the whole content area
|
||||||
@@ -664,15 +669,14 @@ AceGUI:RegisterLayout("Fill",
|
|||||||
children[1]:SetHeight(content:GetHeight() or 0)
|
children[1]:SetHeight(content:GetHeight() or 0)
|
||||||
children[1].frame:SetAllPoints(content)
|
children[1].frame:SetAllPoints(content)
|
||||||
children[1].frame:Show()
|
children[1].frame:Show()
|
||||||
safecall(content.obj.LayoutFinished, 3, content.obj, nil, children[1].frame:GetHeight())
|
safecall(content.obj.LayoutFinished, content.obj, nil, children[1].frame:GetHeight())
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Ace3v: currently only a1 used
|
|
||||||
local layoutrecursionblock = nil
|
local layoutrecursionblock = nil
|
||||||
local function safelayoutcall(object, func, a1)
|
local function safelayoutcall(object, func, ...)
|
||||||
layoutrecursionblock = true
|
layoutrecursionblock = true
|
||||||
object[func](object, a1)
|
object[func](object, unpack(arg))
|
||||||
layoutrecursionblock = nil
|
layoutrecursionblock = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -805,5 +809,5 @@ AceGUI:RegisterLayout("Flow",
|
|||||||
end
|
end
|
||||||
|
|
||||||
height = height + rowheight + 3
|
height = height + rowheight + 3
|
||||||
safecall(content.obj.LayoutFinished, 3, content.obj, nil, height)
|
safecall(content.obj.LayoutFinished, content.obj, nil, height)
|
||||||
end)
|
end)
|
||||||
|
|||||||
+3
-3
@@ -15,11 +15,11 @@ local CreateFrame = CreateFrame
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local function SelectedGroup(self, event, _, value)
|
local function SelectedGroup(self, event, value)
|
||||||
local group = self.parentgroup
|
local group = self.parentgroup
|
||||||
local status = group.status or group.localstatus
|
local status = group.status or group.localstatus
|
||||||
status.selected = value
|
status.selected = value
|
||||||
self.parentgroup:Fire("OnGroupSelected", 1, value)
|
self.parentgroup:Fire("OnGroupSelected", value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
@@ -63,7 +63,7 @@ local methods = {
|
|||||||
self.dropdown:SetValue(group)
|
self.dropdown:SetValue(group)
|
||||||
local status = self.status or self.localstatus
|
local status = self.status or self.localstatus
|
||||||
status.selected = group
|
status.selected = group
|
||||||
self:Fire("OnGroupSelected", 1, group)
|
self:Fire("OnGroupSelected", group)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["OnWidthSet"] = function(self, width)
|
["OnWidthSet"] = function(self, width)
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Frame Container
|
Frame Container
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local Type, Version = "Frame", 24
|
local Type, Version = "Frame", 26
|
||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
local AceCore = LibStub("AceCore-3.0")
|
|
||||||
local wipe = AceCore.wipe
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local pairs, assert, type = pairs, assert, type
|
local pairs, assert, type = pairs, assert, type
|
||||||
|
local wipe = table.wipe
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local PlaySound = PlaySound
|
local PlaySound = PlaySound
|
||||||
@@ -27,6 +25,10 @@ local function Button_OnClick()
|
|||||||
this.obj:Hide()
|
this.obj:Hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function Frame_OnShow()
|
||||||
|
this.obj:Fire("OnShow")
|
||||||
|
end
|
||||||
|
|
||||||
local function Frame_OnClose()
|
local function Frame_OnClose()
|
||||||
this.obj:Fire("OnClose")
|
this.obj:Fire("OnClose")
|
||||||
end
|
end
|
||||||
@@ -188,6 +190,7 @@ local function Constructor()
|
|||||||
frame:SetBackdropColor(0, 0, 0, 1)
|
frame:SetBackdropColor(0, 0, 0, 1)
|
||||||
frame:SetMinResize(400, 200)
|
frame:SetMinResize(400, 200)
|
||||||
frame:SetToplevel(true)
|
frame:SetToplevel(true)
|
||||||
|
frame:SetScript("OnShow", Frame_OnShow)
|
||||||
frame:SetScript("OnHide", Frame_OnClose)
|
frame:SetScript("OnHide", Frame_OnClose)
|
||||||
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
|
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
|
||||||
|
|
||||||
@@ -245,7 +248,6 @@ local function Constructor()
|
|||||||
titlebg_r:SetWidth(30)
|
titlebg_r:SetWidth(30)
|
||||||
titlebg_r:SetHeight(40)
|
titlebg_r:SetHeight(40)
|
||||||
|
|
||||||
-- bottom right sizer
|
|
||||||
local sizer_se = CreateFrame("Frame", nil, frame)
|
local sizer_se = CreateFrame("Frame", nil, frame)
|
||||||
sizer_se:SetPoint("BOTTOMRIGHT", 0, 0)
|
sizer_se:SetPoint("BOTTOMRIGHT", 0, 0)
|
||||||
sizer_se:SetWidth(25)
|
sizer_se:SetWidth(25)
|
||||||
|
|||||||
+26
-35
@@ -6,12 +6,9 @@ local Type, Version = "ScrollFrame", 24
|
|||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
local fixlevels = AceGUI.fixlevels
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local pairs, assert, type = pairs, assert, type
|
local pairs, assert, type = pairs, assert, type
|
||||||
local min, max, floor, abs = math.min, math.max, math.floor, math.abs
|
local min, max, floor, abs = math.min, math.max, math.floor, math.abs
|
||||||
local format = string.format
|
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||||
@@ -27,16 +24,16 @@ end
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local function ScrollFrame_OnMouseWheel()
|
local function ScrollFrame_OnMouseWheel(frame, value)
|
||||||
this.obj:MoveScroll(arg1)
|
frame.obj:MoveScroll(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ScrollFrame_OnSizeChanged()
|
local function ScrollFrame_OnSizeChanged()
|
||||||
this:SetScript("OnUpdate", FixScrollOnUpdate)
|
this:SetScript("OnUpdate", FixScrollOnUpdate)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ScrollBar_OnScrollValueChanged()
|
local function ScrollBar_OnScrollValueChanged(frame, value)
|
||||||
this.obj:SetScroll(arg1)
|
frame.obj:SetScroll(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
@@ -53,7 +50,7 @@ local methods = {
|
|||||||
for k in pairs(self.localstatus) do
|
for k in pairs(self.localstatus) do
|
||||||
self.localstatus[k] = nil
|
self.localstatus[k] = nil
|
||||||
end
|
end
|
||||||
self.scrollframe:SetPoint("BOTTOMRIGHT",0,0)
|
self.scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
|
||||||
self.scrollbar:Hide()
|
self.scrollbar:Hide()
|
||||||
self.scrollBarShown = nil
|
self.scrollBarShown = nil
|
||||||
self.content.height, self.content.width = nil, nil
|
self.content.height, self.content.width = nil, nil
|
||||||
@@ -92,46 +89,40 @@ local methods = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
["FixScroll"] = function(self)
|
["FixScroll"] = function(self)
|
||||||
|
|
||||||
if self.updateLock then return end
|
if self.updateLock then return end
|
||||||
self.updateLock = true
|
self.updateLock = true
|
||||||
local status = self.status or self.localstatus
|
local status = self.status or self.localstatus
|
||||||
local scrollframe, content, scrollbar = self.scrollframe, self.content, self.scrollbar
|
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
|
||||||
local viewheight, height = self.scrollframe:GetHeight(), self.content:GetHeight()
|
|
||||||
local offset = status.offset or 0
|
local offset = status.offset or 0
|
||||||
local curvalue = scrollbar:GetValue()
|
local curvalue = self.scrollbar:GetValue()
|
||||||
-- Give us a margin of error of 2 pixels to stop some conditions that i would blame on floating point inaccuracys
|
-- Give us a margin of error of 2 pixels to stop some conditions that i would blame on floating point inaccuracys
|
||||||
-- No-one is going to miss 2 pixels at the bottom of the frame, anyhow!
|
-- No-one is going to miss 2 pixels at the bottom of the frame, anyhow!
|
||||||
|
if viewheight < height + 2 then
|
||||||
if height < viewheight + 2 then
|
|
||||||
if self.scrollBarShown then
|
if self.scrollBarShown then
|
||||||
self.scrollBarShown = nil
|
self.scrollBarShown = nil
|
||||||
scrollbar:Hide()
|
self.scrollbar:Hide()
|
||||||
scrollbar:SetValue(0)
|
self.scrollbar:SetValue(0)
|
||||||
scrollframe:SetPoint("BOTTOMRIGHT",0,0)
|
self.scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
|
||||||
self:DoLayout()
|
self:DoLayout()
|
||||||
end
|
end
|
||||||
offset = 0
|
|
||||||
else
|
else
|
||||||
if not self.scrollBarShown then
|
if not self.scrollBarShown then
|
||||||
self.scrollBarShown = true
|
self.scrollBarShown = true
|
||||||
scrollbar:Show()
|
self.scrollbar:Show()
|
||||||
scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
|
self.scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
|
||||||
self:DoLayout()
|
self:DoLayout()
|
||||||
end
|
end
|
||||||
local value = (offset / (height - viewheight) * 1000)
|
local value = (offset / (viewheight - height) * 1000)
|
||||||
if value > 1000 then
|
if value > 1000 then value = 1000 end
|
||||||
value = 1000
|
self.scrollbar:SetValue(value)
|
||||||
offset = height - viewheight
|
|
||||||
end
|
|
||||||
scrollbar:SetValue(value)
|
|
||||||
self:SetScroll(value)
|
self:SetScroll(value)
|
||||||
end
|
if value < 1000 then
|
||||||
|
self.content:ClearAllPoints()
|
||||||
|
self.content:SetPoint("TOPLEFT", 0, offset)
|
||||||
|
self.content:SetPoint("TOPRIGHT", 0, offset)
|
||||||
status.offset = offset
|
status.offset = offset
|
||||||
scrollframe:SetScrollChild(content)
|
end
|
||||||
content:ClearAllPoints()
|
end
|
||||||
content:SetPoint("TOPLEFT", 0, offset)
|
|
||||||
content:SetPoint("TOPRIGHT", 0, offset)
|
|
||||||
self.updateLock = nil
|
self.updateLock = nil
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -166,8 +157,8 @@ local function Constructor()
|
|||||||
local num = AceGUI:GetNextWidgetNum(Type)
|
local num = AceGUI:GetNextWidgetNum(Type)
|
||||||
|
|
||||||
local scrollframe = CreateFrame("ScrollFrame", nil, frame)
|
local scrollframe = CreateFrame("ScrollFrame", nil, frame)
|
||||||
scrollframe:SetPoint("TOPLEFT",0,0)
|
scrollframe:SetPoint("TOPLEFT", 0, 0)
|
||||||
scrollframe:SetPoint("BOTTOMRIGHT",0,0)
|
scrollframe:SetPoint("BOTTOMRIGHT", 0, 0)
|
||||||
scrollframe:EnableMouseWheel(true)
|
scrollframe:EnableMouseWheel(true)
|
||||||
scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
|
scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
|
||||||
scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
|
scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
|
||||||
@@ -189,8 +180,8 @@ local function Constructor()
|
|||||||
|
|
||||||
--Container Support
|
--Container Support
|
||||||
local content = CreateFrame("Frame", nil, scrollframe)
|
local content = CreateFrame("Frame", nil, scrollframe)
|
||||||
content:SetPoint("TOPLEFT",0,0)
|
content:SetPoint("TOPLEFT", 0, 0)
|
||||||
content:SetPoint("TOPRIGHT",0,0)
|
content:SetPoint("TOPRIGHT", 0, 0)
|
||||||
content:SetHeight(400)
|
content:SetHeight(400)
|
||||||
scrollframe:SetScrollChild(content)
|
scrollframe:SetScrollChild(content)
|
||||||
|
|
||||||
|
|||||||
+36
-63
@@ -2,22 +2,18 @@
|
|||||||
TabGroup Container
|
TabGroup Container
|
||||||
Container that uses tabs on top to switch between groups.
|
Container that uses tabs on top to switch between groups.
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local Type, Version = "TabGroup", 35
|
local Type, Version = "TabGroup", 36
|
||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
local AceCore = LibStub("AceCore-3.0")
|
|
||||||
local wipe = AceCore.wipe
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local pairs, ipairs, assert, type, wipe = pairs, ipairs, assert, type, wipe
|
local pairs, ipairs, assert, type, wipe = pairs, ipairs, assert, type, wipe
|
||||||
local tgetn = table.getn
|
local tgetn = table.getn
|
||||||
local strfmt = string.format
|
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local PlaySound = PlaySound
|
local PlaySound = PlaySound
|
||||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||||
local _G = AceCore._G
|
local _G = _G
|
||||||
|
|
||||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||||
-- List them here for Mikk's FindGlobals script
|
-- List them here for Mikk's FindGlobals script
|
||||||
@@ -34,60 +30,57 @@ Support functions
|
|||||||
local function UpdateTabLook(frame)
|
local function UpdateTabLook(frame)
|
||||||
if frame.disabled then
|
if frame.disabled then
|
||||||
PanelTemplates_SetDisabledTabState(frame)
|
PanelTemplates_SetDisabledTabState(frame)
|
||||||
frame:SetAlpha(0.5)
|
|
||||||
elseif frame.selected then
|
elseif frame.selected then
|
||||||
PanelTemplates_SelectTab(frame)
|
PanelTemplates_SelectTab(frame)
|
||||||
frame:SetAlpha(1)
|
|
||||||
else
|
else
|
||||||
PanelTemplates_DeselectTab(frame)
|
PanelTemplates_DeselectTab(frame)
|
||||||
frame:SetAlpha(0.5)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Tab_SetText(tab, text)
|
local function Tab_SetText(frame, text)
|
||||||
tab:_SetText(text)
|
frame:_SetText(text)
|
||||||
local width = tab.obj.frame.width or tab.obj.frame:GetWidth() or 0
|
local width = frame.obj.frame.width or frame.obj.frame:GetWidth() or 0
|
||||||
PanelTemplates_TabResize(0, tab, nil, width)
|
PanelTemplates_TabResize(frame, 0, nil, width, frame:GetFontString():GetStringWidth())
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Tab_SetSelected(tab, selected)
|
local function Tab_SetSelected(frame, selected)
|
||||||
tab.selected = selected
|
frame.selected = selected
|
||||||
UpdateTabLook(tab)
|
UpdateTabLook(frame)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Tab_SetDisabled(tab, disabled)
|
local function Tab_SetDisabled(frame, disabled)
|
||||||
tab.disabled = disabled
|
frame.disabled = disabled
|
||||||
UpdateTabLook(tab)
|
UpdateTabLook(frame)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function BuildTabsOnUpdate()
|
local function BuildTabsOnUpdate(frame)
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
self:BuildTabs()
|
self:BuildTabs()
|
||||||
this:SetScript("OnUpdate", nil)
|
frame:SetScript("OnUpdate", nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local function Tab_OnClick()
|
local function Tab_OnClick(frame)
|
||||||
if not (this.selected or this.disabled) then
|
if not (frame.selected or frame.disabled) then
|
||||||
PlaySound("igCharacterInfoTab")
|
PlaySound("igCharacterInfoTab")
|
||||||
this.obj:SelectTab(this.value)
|
frame.obj:SelectTab(frame.value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Tab_OnEnter()
|
local function Tab_OnEnter(frame)
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
self:Fire("OnTabEnter", 2, self.tabs[this.id].value, this)
|
self:Fire("OnTabEnter", self.tabs[frame.id].value, frame)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Tab_OnLeave()
|
local function Tab_OnLeave(frame)
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
self:Fire("OnTabLeave", 2, self.tabs[this.id].value, this)
|
self:Fire("OnTabLeave", self.tabs[frame.id].value, frame)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Tab_OnShow()
|
local function Tab_OnShow(frame)
|
||||||
_G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30)
|
_G[frame:GetName().."HighlightTexture"]:SetWidth(frame:GetTextWidth() + 30)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
@@ -110,31 +103,16 @@ local methods = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
["CreateTab"] = function(self, id)
|
["CreateTab"] = function(self, id)
|
||||||
local tabname = strfmt("AceGUITabGroup%dTab%d", self.num, id)
|
local tabname = format("AceGUITabGroup%dTab%d", self.num, id)
|
||||||
local tab = CreateFrame("Button", tabname, self.border, "TabButtonTemplate")
|
local tab = CreateFrame("Button", tabname, self.border, "OptionsFrameTabButtonTemplate")
|
||||||
-- Normal texture
|
|
||||||
local texture = getglobal(tabname.."Left")
|
|
||||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
|
||||||
texture:ClearAllPoints()
|
|
||||||
texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
|
|
||||||
texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
|
|
||||||
texture = getglobal(tabname.."Middle")
|
|
||||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
|
||||||
texture = getglobal(tabname.."Right")
|
|
||||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
|
||||||
-- Disabled texture
|
|
||||||
texture = getglobal(tabname.."LeftDisabled")
|
|
||||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
|
||||||
texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
|
|
||||||
texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
|
|
||||||
texture = getglobal(tabname.."MiddleDisabled")
|
|
||||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
|
||||||
texture = getglobal(tabname.."RightDisabled")
|
|
||||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
|
||||||
|
|
||||||
tab.obj = self
|
tab.obj = self
|
||||||
tab.id = id
|
tab.id = id
|
||||||
|
|
||||||
|
tab.text = _G[tabname .. "Text"]
|
||||||
|
tab.text:ClearAllPoints()
|
||||||
|
tab.text:SetPoint("LEFT", 14, -3)
|
||||||
|
tab.text:SetPoint("RIGHT", -12, -3)
|
||||||
|
|
||||||
tab:SetScript("OnClick", Tab_OnClick)
|
tab:SetScript("OnClick", Tab_OnClick)
|
||||||
tab:SetScript("OnEnter", Tab_OnEnter)
|
tab:SetScript("OnEnter", Tab_OnEnter)
|
||||||
tab:SetScript("OnLeave", Tab_OnLeave)
|
tab:SetScript("OnLeave", Tab_OnLeave)
|
||||||
@@ -176,7 +154,7 @@ local methods = {
|
|||||||
end
|
end
|
||||||
status.selected = value
|
status.selected = value
|
||||||
if found then
|
if found then
|
||||||
self:Fire("OnGroupSelected",1,value)
|
self:Fire("OnGroupSelected",value)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -209,14 +187,9 @@ local methods = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
tab:Show()
|
tab:Show()
|
||||||
if type(v) == "table" then
|
|
||||||
tab:SetText(v.text)
|
tab:SetText(v.text)
|
||||||
tab:SetDisabled(v.disabled)
|
tab:SetDisabled(v.disabled)
|
||||||
tab.value = v.value
|
tab.value = v.value
|
||||||
elseif type(v) == "string" then
|
|
||||||
tab:SetText(v)
|
|
||||||
tab.value = v
|
|
||||||
end
|
|
||||||
|
|
||||||
widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text
|
widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text
|
||||||
end
|
end
|
||||||
@@ -284,12 +257,12 @@ local methods = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
for i = starttab, endtab do
|
for i = starttab, endtab do
|
||||||
PanelTemplates_TabResize(padding + 4, tabs[i], nil, width)
|
PanelTemplates_TabResize(tabs[i], padding + 4, nil, width, tabs[i]:GetFontString():GetStringWidth())
|
||||||
end
|
end
|
||||||
starttab = endtab + 1
|
starttab = endtab + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
self.borderoffset = (hastitle and 17 or 10)+((numrows)*20)+7
|
self.borderoffset = (hastitle and 17 or 10)+((numrows)*20)
|
||||||
self.border:SetPoint("TOPLEFT", 1, -self.borderoffset)
|
self.border:SetPoint("TOPLEFT", 1, -self.borderoffset)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|||||||
+72
-129
@@ -6,15 +6,12 @@ local Type, Version = "TreeGroup", 40
|
|||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
local AceCore = LibStub("AceCore-3.0")
|
|
||||||
local strsplit = AceCore.strsplit
|
|
||||||
local _G = AceCore._G
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type
|
local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type
|
||||||
local math_min, math_max, floor = math.min, math.max, floor
|
local math_min, math_max, floor = math.min, math.max, floor
|
||||||
local tgetn, tremove, unpack, tconcat = table.getn, table.remove, unpack, table.concat
|
local select, tremove, unpack, tconcat = select, table.remove, unpack, table.concat
|
||||||
local strfmt = string.format
|
local strsplit = string.split
|
||||||
|
local tgetn = table.getn
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||||
@@ -84,13 +81,12 @@ local function UpdateButton(button, treeline, selected, canExpand, isExpanded)
|
|||||||
local normalTexture = button:GetNormalTexture()
|
local normalTexture = button:GetNormalTexture()
|
||||||
local line = button.line
|
local line = button.line
|
||||||
button.level = level
|
button.level = level
|
||||||
|
|
||||||
if ( level == 1 ) then
|
if ( level == 1 ) then
|
||||||
button.text:SetFontObject("GameFontNormal")
|
button:SetNormalFontObject("GameFontNormal")
|
||||||
button:SetHighlightFontObject("GameFontHighlight")
|
button:SetHighlightFontObject("GameFontHighlight")
|
||||||
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2)
|
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2)
|
||||||
else
|
else
|
||||||
button.text:SetFontObject("GameFontHighlightSmall")
|
button:SetNormalFontObject("GameFontHighlightSmall")
|
||||||
button:SetHighlightFontObject("GameFontHighlightSmall")
|
button:SetHighlightFontObject("GameFontHighlightSmall")
|
||||||
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2)
|
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2)
|
||||||
end
|
end
|
||||||
@@ -160,143 +156,134 @@ local function addLine(self, v, tree, level, parent)
|
|||||||
else
|
else
|
||||||
line.hasChildren = nil
|
line.hasChildren = nil
|
||||||
end
|
end
|
||||||
tinsert(self.lines, line)
|
self.lines[tgetn(self.lines)+1] = line
|
||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
|
|
||||||
--fire an update after one frame to catch the treeframes height
|
--fire an update after one frame to catch the treeframes height
|
||||||
local function FirstFrameUpdate()
|
local function FirstFrameUpdate(frame)
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
this:SetScript("OnUpdate", nil)
|
frame:SetScript("OnUpdate", nil)
|
||||||
self:RefreshTree()
|
self:RefreshTree()
|
||||||
end
|
end
|
||||||
|
|
||||||
local BuildUniqueValue
|
local function BuildUniqueValue(...)
|
||||||
do
|
local n = select('#', arg)
|
||||||
local args = {nil,nil,nil,nil,nil,nil,nil,nil,nil,nil}
|
if n == 1 then
|
||||||
function BuildUniqueValue(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
return arg1
|
||||||
args[1] = a1
|
else
|
||||||
args[2] = a2
|
return (unpack(arg)).."\001"..BuildUniqueValue(select(2,arg))
|
||||||
args[3] = a3
|
end
|
||||||
args[4] = a4
|
|
||||||
args[5] = a5
|
|
||||||
args[6] = a6
|
|
||||||
args[7] = a7
|
|
||||||
args[8] = a8
|
|
||||||
args[9] = a9
|
|
||||||
args[10] = a10
|
|
||||||
return tconcat(tmp, "\001", 1, tgetn(args))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local function Expand_OnClick()
|
local function Expand_OnClick(frame)
|
||||||
local button = this.button
|
local button = frame.button
|
||||||
local self = button.obj
|
local self = button.obj
|
||||||
local status = (self.status or self.localstatus).groups
|
local status = (self.status or self.localstatus).groups
|
||||||
status[button.uniquevalue] = not status[button.uniquevalue]
|
status[button.uniquevalue] = not status[button.uniquevalue]
|
||||||
self:RefreshTree()
|
self:RefreshTree()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Button_OnClick()
|
local function Button_OnClick(frame)
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
self:Fire("OnClick", 2, this.uniquevalue, this.selected)
|
self:Fire("OnClick", frame.uniquevalue, frame.selected)
|
||||||
if not this.selected then
|
if not frame.selected then
|
||||||
self:SetSelected(this.uniquevalue)
|
self:SetSelected(frame.uniquevalue)
|
||||||
this.selected = true
|
frame.selected = true
|
||||||
this:LockHighlight()
|
frame:LockHighlight()
|
||||||
self:RefreshTree()
|
self:RefreshTree()
|
||||||
end
|
end
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Button_OnDoubleClick()
|
local function Button_OnDoubleClick(button)
|
||||||
local self = this.obj
|
local self = button.obj
|
||||||
local status = self.status or self.localstatus
|
local status = self.status or self.localstatus
|
||||||
local status = (self.status or self.localstatus).groups
|
local status = (self.status or self.localstatus).groups
|
||||||
status[this.uniquevalue] = not status[this.uniquevalue]
|
status[button.uniquevalue] = not status[button.uniquevalue]
|
||||||
self:RefreshTree()
|
self:RefreshTree()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Button_OnEnter()
|
local function Button_OnEnter(frame)
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
self:Fire("OnButtonEnter", 2, this.uniquevalue, this)
|
self:Fire("OnButtonEnter", frame.uniquevalue, frame)
|
||||||
|
|
||||||
if self.enabletooltips then
|
if self.enabletooltips then
|
||||||
GameTooltip:SetOwner(this, "ANCHOR_NONE")
|
GameTooltip:SetOwner(frame, "ANCHOR_NONE")
|
||||||
GameTooltip:SetPoint("LEFT",this,"RIGHT")
|
GameTooltip:SetPoint("LEFT",frame,"RIGHT")
|
||||||
GameTooltip:SetText(this.text:GetText() or "", 1, .82, 0, true)
|
GameTooltip:SetText(frame.text:GetText() or "", 1, .82, 0, 1)
|
||||||
|
|
||||||
GameTooltip:Show()
|
GameTooltip:Show()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Button_OnLeave()
|
local function Button_OnLeave(frame)
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
self:Fire("OnButtonLeave", 2, this.uniquevalue, this)
|
self:Fire("OnButtonLeave", frame.uniquevalue, frame)
|
||||||
|
|
||||||
if self.enabletooltips then
|
if self.enabletooltips then
|
||||||
GameTooltip:Hide()
|
GameTooltip:Hide()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnScrollValueChanged()
|
local function OnScrollValueChanged(frame, value)
|
||||||
if this.obj.noupdate then return end
|
if frame.obj.noupdate then return end
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
local status = self.status or self.localstatus
|
local status = self.status or self.localstatus
|
||||||
status.scrollvalue = floor(arg1 + 0.5)
|
status.scrollvalue = floor(value + 0.5)
|
||||||
self:RefreshTree()
|
self:RefreshTree()
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Tree_OnSizeChanged()
|
local function Tree_OnSizeChanged(frame)
|
||||||
this.obj:RefreshTree()
|
frame.obj:RefreshTree()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Tree_OnMouseWheel()
|
local function Tree_OnMouseWheel(frame, delta)
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
if self.showscroll then
|
if self.showscroll then
|
||||||
local scrollbar = self.scrollbar
|
local scrollbar = self.scrollbar
|
||||||
local min, max = scrollbar:GetMinMaxValues()
|
local min, max = scrollbar:GetMinMaxValues()
|
||||||
local value = scrollbar:GetValue()
|
local value = scrollbar:GetValue()
|
||||||
local newvalue = math_min(max,math_max(min,value - arg1))
|
local newvalue = math_min(max,math_max(min,value - delta))
|
||||||
if value ~= newvalue then
|
if value ~= newvalue then
|
||||||
scrollbar:SetValue(newvalue)
|
scrollbar:SetValue(newvalue)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Dragger_OnLeave()
|
local function Dragger_OnLeave(frame)
|
||||||
this:SetBackdropColor(1, 1, 1, 0)
|
frame:SetBackdropColor(1, 1, 1, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Dragger_OnEnter()
|
local function Dragger_OnEnter(frame)
|
||||||
this:SetBackdropColor(1, 1, 1, 0.8)
|
frame:SetBackdropColor(1, 1, 1, 0.8)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Dragger_OnMouseDown()
|
local function Dragger_OnMouseDown(frame)
|
||||||
local treeframe = this:GetParent()
|
local treeframe = frame:GetParent()
|
||||||
treeframe:StartSizing("RIGHT")
|
treeframe:StartSizing("RIGHT")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Dragger_OnMouseUp()
|
local function Dragger_OnMouseUp(frame)
|
||||||
local treeframe = this:GetParent()
|
local treeframe = frame:GetParent()
|
||||||
local self = treeframe.obj
|
local self = treeframe.obj
|
||||||
local this = treeframe:GetParent()
|
local frame = treeframe:GetParent()
|
||||||
treeframe:StopMovingOrSizing()
|
treeframe:StopMovingOrSizing()
|
||||||
--treeframe:SetScript("OnUpdate", nil)
|
--treeframe:SetScript("OnUpdate", nil)
|
||||||
treeframe:SetUserPlaced(false)
|
treeframe:SetUserPlaced(false)
|
||||||
--Without this :GetHeight will get stuck on the current height, causing the tree contents to not resize
|
--Without this :GetHeight will get stuck on the current height, causing the tree contents to not resize
|
||||||
treeframe:SetHeight(0)
|
treeframe:SetHeight(0)
|
||||||
treeframe:SetPoint("TOPLEFT", this, "TOPLEFT",0,0)
|
treeframe:SetPoint("TOPLEFT", frame, "TOPLEFT",0,0)
|
||||||
treeframe:SetPoint("BOTTOMLEFT", this, "BOTTOMLEFT",0,0)
|
treeframe:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT",0,0)
|
||||||
|
|
||||||
local status = self.status or self.localstatus
|
local status = self.status or self.localstatus
|
||||||
status.treewidth = treeframe:GetWidth()
|
status.treewidth = treeframe:GetWidth()
|
||||||
|
|
||||||
treeframe.obj:Fire("OnTreeResize", 1, treeframe:GetWidth())
|
treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth())
|
||||||
-- recalculate the content width
|
-- recalculate the content width
|
||||||
treeframe.obj:OnWidthSet(status.fullwidth)
|
treeframe.obj:OnWidthSet(status.fullwidth)
|
||||||
-- update the layout of the content
|
-- update the layout of the content
|
||||||
@@ -306,10 +293,7 @@ end
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Methods
|
Methods
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local methods
|
local methods = {
|
||||||
do
|
|
||||||
local select_args = {nil,nil,nil,nil,nil,nil,nil,nil,nil,nil}
|
|
||||||
methods = {
|
|
||||||
["OnAcquire"] = function(self)
|
["OnAcquire"] = function(self)
|
||||||
self:SetTreeWidth(DEFAULT_TREE_WIDTH, DEFAULT_TREE_SIZABLE)
|
self:SetTreeWidth(DEFAULT_TREE_WIDTH, DEFAULT_TREE_SIZABLE)
|
||||||
self:EnableButtonTooltips(true)
|
self:EnableButtonTooltips(true)
|
||||||
@@ -338,39 +322,8 @@ methods = {
|
|||||||
|
|
||||||
["CreateButton"] = function(self)
|
["CreateButton"] = function(self)
|
||||||
local num = AceGUI:GetNextWidgetNum("TreeGroupButton")
|
local num = AceGUI:GetNextWidgetNum("TreeGroupButton")
|
||||||
|
local button = CreateFrame("Button", format("AceGUI30TreeButton%d", num), self.treeframe, "OptionsListButtonTemplate")
|
||||||
local button = CreateFrame("Button", strfmt("AceGUI30TreeButton%d", num), self.treeframe)
|
|
||||||
button.obj = self
|
button.obj = self
|
||||||
button:SetWidth(175)
|
|
||||||
button:SetHeight(18)
|
|
||||||
|
|
||||||
local toggle = CreateFrame("Button", nil, button)
|
|
||||||
toggle.obj = button
|
|
||||||
button.toggle = toggle
|
|
||||||
toggle:SetWidth(14)
|
|
||||||
toggle:SetHeight(14)
|
|
||||||
toggle:ClearAllPoints()
|
|
||||||
toggle:SetPoint("TOPRIGHT", button, "TOPRIGHT", -6, -1)
|
|
||||||
toggle:SetScript("OnClick", Button_OnClick)
|
|
||||||
toggle:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP")
|
|
||||||
toggle:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-DOWN")
|
|
||||||
toggle:SetHighlightTexture("Interface\Buttons\UI-PlusButton-Hilight", "ADD")
|
|
||||||
|
|
||||||
local text = button:CreateFontString()
|
|
||||||
button.text = text
|
|
||||||
text:SetFontObject(GameFontNormal)
|
|
||||||
button:SetHighlightFontObject(GameFontHighlight)
|
|
||||||
text:SetPoint("RIGHT", toggle, "LEFT", -2, 0);
|
|
||||||
text:SetJustifyH("LEFT")
|
|
||||||
|
|
||||||
local highlight = button:CreateTexture(nil, "HIGHLIGHT");
|
|
||||||
button.highlight = highlight
|
|
||||||
highlight:SetTexture("Interface\\QuestFrame\\UI-QuestLogTitleHighlight")
|
|
||||||
highlight:SetBlendMode("ADD")
|
|
||||||
highlight:SetVertexColor(.196, .388, .8);
|
|
||||||
highlight:ClearAllPoints()
|
|
||||||
highlight:SetPoint("TOPLEFT",0,1)
|
|
||||||
highlight:SetPoint("BOTTOMRIGHT",0,1)
|
|
||||||
|
|
||||||
local icon = button:CreateTexture(nil, "OVERLAY")
|
local icon = button:CreateTexture(nil, "OVERLAY")
|
||||||
icon:SetWidth(14)
|
icon:SetWidth(14)
|
||||||
@@ -553,34 +506,25 @@ methods = {
|
|||||||
local status = self.status or self.localstatus
|
local status = self.status or self.localstatus
|
||||||
if status.selected ~= value then
|
if status.selected ~= value then
|
||||||
status.selected = value
|
status.selected = value
|
||||||
self:Fire("OnGroupSelected", 1, value)
|
self:Fire("OnGroupSelected", value)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["Select"] = function(self, uniquevalue, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
["Select"] = function(self, uniquevalue, ...)
|
||||||
self.filter = false
|
self.filter = false
|
||||||
local status = self.status or self.localstatus
|
local status = self.status or self.localstatus
|
||||||
local groups = status.groups
|
local groups = status.groups
|
||||||
select_args[1] = a1
|
local path = {unpack(arg)}
|
||||||
select_args[2] = a2
|
for i = 1, tgetn(path) do
|
||||||
select_args[3] = a3
|
groups[tconcat(path, "\001", 1, i)] = true
|
||||||
select_args[4] = a4
|
|
||||||
select_args[5] = a5
|
|
||||||
select_args[6] = a6
|
|
||||||
select_args[7] = a7
|
|
||||||
select_args[8] = a8
|
|
||||||
select_args[9] = a9
|
|
||||||
select_args[10] = a10
|
|
||||||
for i = 1, tgetn(select_args) do
|
|
||||||
groups[tconcat(select_args, "\001", 1, i)] = true
|
|
||||||
end
|
end
|
||||||
status.selected = uniquevalue
|
status.selected = uniquevalue
|
||||||
self:RefreshTree(true)
|
self:RefreshTree(true)
|
||||||
self:Fire("OnGroupSelected", 1, uniquevalue)
|
self:Fire("OnGroupSelected", uniquevalue)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["SelectByPath"] = function(self, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
["SelectByPath"] = function(self, ...)
|
||||||
self:Select(BuildUniqueValue(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10), a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
self:Select(BuildUniqueValue(unpack(arg)), unpack(arg))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["SelectByValue"] = function(self, uniquevalue)
|
["SelectByValue"] = function(self, uniquevalue)
|
||||||
@@ -668,7 +612,6 @@ methods = {
|
|||||||
self:SetHeight((height or 0) + 20)
|
self:SetHeight((height or 0) + 20)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end -- method
|
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Constructor
|
Constructor
|
||||||
@@ -692,8 +635,8 @@ local function Constructor()
|
|||||||
local frame = CreateFrame("Frame", nil, UIParent)
|
local frame = CreateFrame("Frame", nil, UIParent)
|
||||||
|
|
||||||
local treeframe = CreateFrame("Frame", nil, frame)
|
local treeframe = CreateFrame("Frame", nil, frame)
|
||||||
treeframe:SetPoint("TOPLEFT", 0, 0)
|
treeframe:SetPoint("TOPLEFT")
|
||||||
treeframe:SetPoint("BOTTOMLEFT", 0, 0)
|
treeframe:SetPoint("BOTTOMLEFT")
|
||||||
treeframe:SetWidth(DEFAULT_TREE_WIDTH)
|
treeframe:SetWidth(DEFAULT_TREE_WIDTH)
|
||||||
treeframe:EnableMouseWheel(true)
|
treeframe:EnableMouseWheel(true)
|
||||||
treeframe:SetBackdrop(PaneBackdrop)
|
treeframe:SetBackdrop(PaneBackdrop)
|
||||||
@@ -717,7 +660,7 @@ local function Constructor()
|
|||||||
dragger:SetScript("OnMouseDown", Dragger_OnMouseDown)
|
dragger:SetScript("OnMouseDown", Dragger_OnMouseDown)
|
||||||
dragger:SetScript("OnMouseUp", Dragger_OnMouseUp)
|
dragger:SetScript("OnMouseUp", Dragger_OnMouseUp)
|
||||||
|
|
||||||
local scrollbar = CreateFrame("Slider", strfmt("AceConfigDialogTreeGroup%dScrollBar", num), treeframe, "UIPanelScrollBarTemplate")
|
local scrollbar = CreateFrame("Slider", format("AceConfigDialogTreeGroup%dScrollBar", num), treeframe, "UIPanelScrollBarTemplate")
|
||||||
scrollbar:SetScript("OnValueChanged", nil)
|
scrollbar:SetScript("OnValueChanged", nil)
|
||||||
scrollbar:SetPoint("TOPRIGHT", -10, -26)
|
scrollbar:SetPoint("TOPRIGHT", -10, -26)
|
||||||
scrollbar:SetPoint("BOTTOMRIGHT", -10, 26)
|
scrollbar:SetPoint("BOTTOMRIGHT", -10, 26)
|
||||||
@@ -733,7 +676,7 @@ local function Constructor()
|
|||||||
|
|
||||||
local border = CreateFrame("Frame",nil,frame)
|
local border = CreateFrame("Frame",nil,frame)
|
||||||
border:SetPoint("TOPLEFT", treeframe, "TOPRIGHT")
|
border:SetPoint("TOPLEFT", treeframe, "TOPRIGHT")
|
||||||
border:SetPoint("BOTTOMRIGHT", 0, 0)
|
border:SetPoint("BOTTOMRIGHT")
|
||||||
border:SetBackdrop(PaneBackdrop)
|
border:SetBackdrop(PaneBackdrop)
|
||||||
border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
|
border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
|
||||||
border:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
border:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
||||||
|
|||||||
@@ -21,27 +21,31 @@ local CreateFrame, UIParent = CreateFrame, UIParent
|
|||||||
]]
|
]]
|
||||||
do
|
do
|
||||||
local Type = "Window"
|
local Type = "Window"
|
||||||
local Version = 4
|
local Version = 6
|
||||||
|
|
||||||
local function frameOnClose()
|
local function frameOnShow(this)
|
||||||
|
this.obj:Fire("OnShow")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function frameOnClose(this)
|
||||||
this.obj:Fire("OnClose")
|
this.obj:Fire("OnClose")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function closeOnClick()
|
local function closeOnClick(this)
|
||||||
PlaySound("gsTitleOptionExit")
|
PlaySound("gsTitleOptionExit")
|
||||||
this.obj:Hide()
|
this.obj:Hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function frameOnMouseDown()
|
local function frameOnMouseDown(this)
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function titleOnMouseDown()
|
local function titleOnMouseDown(this)
|
||||||
this:GetParent():StartMoving()
|
this:GetParent():StartMoving()
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function frameOnMouseUp()
|
local function frameOnMouseUp(this)
|
||||||
local frame = this:GetParent()
|
local frame = this:GetParent()
|
||||||
frame:StopMovingOrSizing()
|
frame:StopMovingOrSizing()
|
||||||
local self = frame.obj
|
local self = frame.obj
|
||||||
@@ -52,22 +56,22 @@ do
|
|||||||
status.left = frame:GetLeft()
|
status.left = frame:GetLeft()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function sizerseOnMouseDown()
|
local function sizerseOnMouseDown(this)
|
||||||
this:GetParent():StartSizing("BOTTOMRIGHT")
|
this:GetParent():StartSizing("BOTTOMRIGHT")
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function sizersOnMouseDown()
|
local function sizersOnMouseDown(this)
|
||||||
this:GetParent():StartSizing("BOTTOM")
|
this:GetParent():StartSizing("BOTTOM")
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function sizereOnMouseDown()
|
local function sizereOnMouseDown(this)
|
||||||
this:GetParent():StartSizing("RIGHT")
|
this:GetParent():StartSizing("RIGHT")
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function sizerOnMouseUp()
|
local function sizerOnMouseUp(this)
|
||||||
this:GetParent():StopMovingOrSizing()
|
this:GetParent():StopMovingOrSizing()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -180,6 +184,7 @@ do
|
|||||||
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||||
frame:SetScript("OnMouseDown", frameOnMouseDown)
|
frame:SetScript("OnMouseDown", frameOnMouseDown)
|
||||||
|
|
||||||
|
frame:SetScript("OnShow",frameOnShow)
|
||||||
frame:SetScript("OnHide",frameOnClose)
|
frame:SetScript("OnHide",frameOnClose)
|
||||||
frame:SetMinResize(240,240)
|
frame:SetMinResize(240,240)
|
||||||
frame:SetToplevel(true)
|
frame:SetToplevel(true)
|
||||||
|
|||||||
+79
-5
@@ -2,24 +2,83 @@
|
|||||||
Button Widget (Modified to change text color on SetDisabled method)
|
Button Widget (Modified to change text color on SetDisabled method)
|
||||||
Graphical Button.
|
Graphical Button.
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local Type, Version = "Button-ElvUI", 23
|
local Type, Version = "Button-ElvUI", 2
|
||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local pairs = pairs
|
local pairs, unpack = pairs, unpack
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local _G = _G
|
local _G = _G
|
||||||
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
|
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
|
||||||
|
local IsShiftKeyDown = IsShiftKeyDown
|
||||||
|
-- GLOBALS: GameTooltip, ElvUI
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
|
local dragdropButton
|
||||||
|
local function lockTooltip()
|
||||||
|
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
|
||||||
|
GameTooltip:SetText(" ")
|
||||||
|
GameTooltip:Show()
|
||||||
|
end
|
||||||
|
local function dragdrop_OnMouseDown(frame, ...)
|
||||||
|
if frame.obj.dragOnMouseDown then
|
||||||
|
dragdropButton.mouseDownFrame = frame
|
||||||
|
dragdropButton:SetText(frame.obj.value or "Unknown")
|
||||||
|
dragdropButton:SetSize(frame:GetSize())
|
||||||
|
frame.obj.dragOnMouseDown(frame, unpack(arg))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function dragdrop_OnMouseUp(frame, ...)
|
||||||
|
if frame.obj.dragOnMouseUp then
|
||||||
|
frame:SetAlpha(1)
|
||||||
|
GameTooltip:Hide()
|
||||||
|
dragdropButton:Hide()
|
||||||
|
if dragdropButton.enteredFrame and dragdropButton.enteredFrame ~= frame and dragdropButton.enteredFrame:IsMouseOver() then
|
||||||
|
frame.obj.dragOnMouseUp(frame, unpack(arg))
|
||||||
|
frame.obj.ActivateMultiControl(frame.obj, unpack(arg))
|
||||||
|
end
|
||||||
|
dragdropButton.enteredFrame = nil
|
||||||
|
dragdropButton.mouseDownFrame = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function dragdrop_OnLeave(frame, ...)
|
||||||
|
if frame.obj.dragOnLeave then
|
||||||
|
if dragdropButton.mouseDownFrame then
|
||||||
|
lockTooltip()
|
||||||
|
end
|
||||||
|
if frame == dragdropButton.mouseDownFrame then
|
||||||
|
frame:SetAlpha(0)
|
||||||
|
dragdropButton:Show()
|
||||||
|
frame.obj.dragOnLeave(frame, unpack(arg))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function dragdrop_OnEnter(frame, ...)
|
||||||
|
if frame.obj.dragOnEnter and dragdropButton:IsShown() then
|
||||||
|
dragdropButton.enteredFrame = frame
|
||||||
|
lockTooltip()
|
||||||
|
frame.obj.dragOnEnter(frame, unpack(arg))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function dragdrop_OnClick(frame, ...)
|
||||||
|
local button = unpack(arg)
|
||||||
|
if frame.obj.dragOnClick and button == "RightButton" then
|
||||||
|
frame.obj.dragOnClick(frame, unpack(arg))
|
||||||
|
frame.obj.ActivateMultiControl(frame.obj, unpack(arg))
|
||||||
|
elseif frame.obj.stateSwitchOnClick and (button == "LeftButton") and IsShiftKeyDown() then
|
||||||
|
frame.obj.stateSwitchOnClick(frame, unpack(arg))
|
||||||
|
frame.obj.ActivateMultiControl(frame.obj, unpack(arg))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function Button_OnClick(frame, ...)
|
local function Button_OnClick(frame, ...)
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
PlaySound("igMainMenuOption")
|
PlaySound("igMainMenuOption")
|
||||||
frame.obj:Fire("OnClick", ...)
|
frame.obj:Fire("OnClick", unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Control_OnEnter(frame)
|
local function Control_OnEnter(frame)
|
||||||
@@ -76,14 +135,29 @@ Constructor
|
|||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local function Constructor()
|
local function Constructor()
|
||||||
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
|
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
|
||||||
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate2")
|
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
|
||||||
frame:Hide()
|
frame:Hide()
|
||||||
|
|
||||||
frame:EnableMouse(true)
|
frame:EnableMouse(true)
|
||||||
|
frame:RegisterForClicks("AnyUp")
|
||||||
frame:SetScript("OnClick", Button_OnClick)
|
frame:SetScript("OnClick", Button_OnClick)
|
||||||
frame:SetScript("OnEnter", Control_OnEnter)
|
frame:SetScript("OnEnter", Control_OnEnter)
|
||||||
frame:SetScript("OnLeave", Control_OnLeave)
|
frame:SetScript("OnLeave", Control_OnLeave)
|
||||||
|
|
||||||
|
-- dragdrop
|
||||||
|
if not dragdropButton then
|
||||||
|
dragdropButton = CreateFrame("Button", "ElvUIAceGUI30DragDropButton", UIParent, "UIPanelButtonTemplate")
|
||||||
|
dragdropButton:SetFrameStrata("TOOLTIP")
|
||||||
|
dragdropButton:SetFrameLevel(5)
|
||||||
|
dragdropButton:SetPoint('BOTTOM', GameTooltip, "BOTTOM", 0, 10)
|
||||||
|
dragdropButton:Hide()
|
||||||
|
ElvUI[1]:GetModule('Skins'):HandleButton(dragdropButton)
|
||||||
|
end
|
||||||
|
frame:HookScript("OnClick", dragdrop_OnClick)
|
||||||
|
frame:HookScript("OnEnter", dragdrop_OnEnter)
|
||||||
|
frame:HookScript("OnLeave", dragdrop_OnLeave)
|
||||||
|
frame:HookScript("OnMouseUp", dragdrop_OnMouseUp)
|
||||||
|
frame:HookScript("OnMouseDown", dragdrop_OnMouseDown)
|
||||||
|
|
||||||
local text = frame:GetFontString()
|
local text = frame:GetFontString()
|
||||||
text:ClearAllPoints()
|
text:ClearAllPoints()
|
||||||
text:SetPoint("TOPLEFT", 15, -1)
|
text:SetPoint("TOPLEFT", 15, -1)
|
||||||
|
|||||||
@@ -2,27 +2,24 @@
|
|||||||
Button Widget
|
Button Widget
|
||||||
Graphical Button.
|
Graphical Button.
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local Type, Version = "Button", 23
|
local Type, Version = "Button", 24
|
||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
local AceCore = LibStub("AceCore-3.0")
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local pairs = pairs
|
local pairs, unpack = pairs, unpack
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local _G = AceCore._G
|
local _G = _G
|
||||||
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
|
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
-- arg1 is the button for OnClick event
|
|
||||||
local function Button_OnClick()
|
local function Button_OnClick()
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
PlaySound("igMainMenuOption")
|
PlaySound("igMainMenuOption")
|
||||||
this.obj:Fire("OnClick", 1, arg1)
|
this.obj:Fire("OnClick", unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Control_OnEnter()
|
local function Control_OnEnter()
|
||||||
@@ -77,7 +74,7 @@ Constructor
|
|||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local function Constructor()
|
local function Constructor()
|
||||||
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
|
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
|
||||||
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate2")
|
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
|
||||||
frame:Hide()
|
frame:Hide()
|
||||||
|
|
||||||
frame:EnableMouse(true)
|
frame:EnableMouse(true)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Checkbox Widget
|
Checkbox Widget
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local Type, Version = "CheckBox", 22
|
local Type, Version = "CheckBox", 23
|
||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local pairs = pairs
|
local select, pairs, unpack = select, pairs, unpack
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local PlaySound = PlaySound
|
local PlaySound = PlaySound
|
||||||
@@ -24,10 +24,10 @@ local function AlignImage(self)
|
|||||||
self.text:ClearAllPoints()
|
self.text:ClearAllPoints()
|
||||||
if not img then
|
if not img then
|
||||||
self.text:SetPoint("LEFT", self.checkbg, "RIGHT")
|
self.text:SetPoint("LEFT", self.checkbg, "RIGHT")
|
||||||
self.text:SetPoint("RIGHT",0,0)
|
self.text:SetPoint("RIGHT", 0, 0)
|
||||||
else
|
else
|
||||||
self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0)
|
self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0)
|
||||||
self.text:SetPoint("RIGHT",0,0)
|
self.text:SetPoint("RIGHT", 0, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -55,7 +55,6 @@ local function CheckBox_OnMouseDown()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function CheckBox_OnMouseUp()
|
local function CheckBox_OnMouseUp()
|
||||||
|
|
||||||
local self = this.obj
|
local self = this.obj
|
||||||
if not self.disabled then
|
if not self.disabled then
|
||||||
self:ToggleChecked()
|
self:ToggleChecked()
|
||||||
@@ -66,7 +65,7 @@ local function CheckBox_OnMouseUp()
|
|||||||
PlaySound("igMainMenuOptionCheckBoxOff")
|
PlaySound("igMainMenuOptionCheckBoxOff")
|
||||||
end
|
end
|
||||||
|
|
||||||
self:Fire("OnValueChanged", 1, self.checked)
|
self:Fire("OnValueChanged", self.checked)
|
||||||
AlignImage(self)
|
AlignImage(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -173,7 +172,6 @@ local methods = {
|
|||||||
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
|
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
|
||||||
highlight:SetTexCoord(0, 1, 0, 1)
|
highlight:SetTexCoord(0, 1, 0, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
checkbg:SetHeight(size)
|
checkbg:SetHeight(size)
|
||||||
checkbg:SetWidth(size)
|
checkbg:SetWidth(size)
|
||||||
end,
|
end,
|
||||||
@@ -223,13 +221,14 @@ local methods = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
|
["SetImage"] = function(self, path, ...)
|
||||||
local image = self.image
|
local image = self.image
|
||||||
image:SetTexture(path)
|
image:SetTexture(path)
|
||||||
|
|
||||||
if image:GetTexture() then
|
if image:GetTexture() then
|
||||||
if a4 or a8 then
|
local n = select("#", arg)
|
||||||
image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
|
if n == 4 or n == 8 then
|
||||||
|
image:SetTexCoord(unpack(arg))
|
||||||
else
|
else
|
||||||
image:SetTexCoord(0, 1, 0, 1)
|
image:SetTexCoord(0, 1, 0, 1)
|
||||||
end
|
end
|
||||||
@@ -254,7 +253,7 @@ local function Constructor()
|
|||||||
local checkbg = frame:CreateTexture(nil, "ARTWORK")
|
local checkbg = frame:CreateTexture(nil, "ARTWORK")
|
||||||
checkbg:SetWidth(24)
|
checkbg:SetWidth(24)
|
||||||
checkbg:SetHeight(24)
|
checkbg:SetHeight(24)
|
||||||
checkbg:SetPoint("TOPLEFT",0,0)
|
checkbg:SetPoint("TOPLEFT", 0, 0)
|
||||||
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
|
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
|
||||||
|
|
||||||
local check = frame:CreateTexture(nil, "OVERLAY")
|
local check = frame:CreateTexture(nil, "OVERLAY")
|
||||||
@@ -262,10 +261,10 @@ local function Constructor()
|
|||||||
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
|
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
|
||||||
|
|
||||||
local text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
local text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
||||||
text:SetJustifyH("LEFT")
|
text:SetJustifyH("LEFT", 0, 0)
|
||||||
text:SetHeight(18)
|
text:SetHeight(18)
|
||||||
text:SetPoint("LEFT", checkbg, "RIGHT")
|
text:SetPoint("LEFT", checkbg, "RIGHT")
|
||||||
text:SetPoint("RIGHT",0,0)
|
text:SetPoint("RIGHT", 0, 0)
|
||||||
|
|
||||||
local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
|
local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
|
||||||
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
|
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
|
||||||
|
|||||||
+26
-13
@@ -1,7 +1,7 @@
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
ColorPicker Widget
|
ColorPicker Widget
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local Type, Version = "ColorPicker", 23
|
local Type, Version = "ColorPicker-ElvUI", 1
|
||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
@@ -25,12 +25,12 @@ local function ColorCallback(self, r, g, b, a, isAlpha)
|
|||||||
self:SetColor(r, g, b, a)
|
self:SetColor(r, g, b, a)
|
||||||
if ColorPickerFrame:IsVisible() then
|
if ColorPickerFrame:IsVisible() then
|
||||||
--colorpicker is still open
|
--colorpicker is still open
|
||||||
self:Fire("OnValueChanged", 4, r, g, b, a)
|
self:Fire("OnValueChanged", r, g, b, a)
|
||||||
else
|
else
|
||||||
--colorpicker is closed, color callback is first, ignore it,
|
--colorpicker is closed, color callback is first, ignore it,
|
||||||
--alpha callback is the final call after it closes so confirm now
|
--alpha callback is the final call after it closes so confirm now
|
||||||
if isAlpha then
|
if isAlpha then
|
||||||
self:Fire("OnValueConfirmed", 4, r, g, b, a)
|
self:Fire("OnValueConfirmed", r, g, b, a)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -38,19 +38,20 @@ end
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local function Control_OnEnter()
|
local function Control_OnEnter(frame)
|
||||||
this.obj:Fire("OnEnter")
|
frame.obj:Fire("OnEnter")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Control_OnLeave()
|
local function Control_OnLeave(frame)
|
||||||
this.obj:Fire("OnLeave")
|
frame.obj:Fire("OnLeave")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ColorSwatch_OnClick()
|
local function ColorSwatch_OnClick(frame)
|
||||||
HideUIPanel(ColorPickerFrame)
|
HideUIPanel(ColorPickerFrame)
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
if not self.disabled then
|
if not self.disabled then
|
||||||
ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG")
|
ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||||
|
ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10)
|
||||||
ColorPickerFrame:SetClampedToScreen(true)
|
ColorPickerFrame:SetClampedToScreen(true)
|
||||||
|
|
||||||
ColorPickerFrame.func = function()
|
ColorPickerFrame.func = function()
|
||||||
@@ -66,12 +67,20 @@ local function ColorSwatch_OnClick()
|
|||||||
ColorCallback(self, r, g, b, a, true)
|
ColorCallback(self, r, g, b, a, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local r, g, b, a = self.r, self.g, self.b, self.a
|
local r, g, b, a, dR, dG, dB, dA = self.r, self.g, self.b, self.a, self.dR, self.dG, self.dB, self.dA
|
||||||
if self.HasAlpha then
|
if self.HasAlpha then
|
||||||
ColorPickerFrame.opacity = 1 - (a or 0)
|
ColorPickerFrame.opacity = 1 - (a or 0)
|
||||||
end
|
end
|
||||||
ColorPickerFrame:SetColorRGB(r, g, b)
|
ColorPickerFrame:SetColorRGB(r, g, b)
|
||||||
|
|
||||||
|
if(ColorPPDefault and self.dR and self.dG and self.dB) then
|
||||||
|
local alpha = 1
|
||||||
|
if(self.dA) then
|
||||||
|
alpha = 1 - self.dA
|
||||||
|
end
|
||||||
|
ColorPPDefault.colors = {r = self.dR, g = self.dG, b = self.dB, a = alpha}
|
||||||
|
end
|
||||||
|
|
||||||
ColorPickerFrame.cancelFunc = function()
|
ColorPickerFrame.cancelFunc = function()
|
||||||
ColorCallback(self, r, g, b, a, true)
|
ColorCallback(self, r, g, b, a, true)
|
||||||
end
|
end
|
||||||
@@ -100,11 +109,15 @@ local methods = {
|
|||||||
self.text:SetText(text)
|
self.text:SetText(text)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["SetColor"] = function(self, r, g, b, a)
|
["SetColor"] = function(self, r, g, b, a, defaultR, defaultG, defaultB, defaultA)
|
||||||
self.r = r
|
self.r = r
|
||||||
self.g = g
|
self.g = g
|
||||||
self.b = b
|
self.b = b
|
||||||
self.a = a or 1
|
self.a = a or 1
|
||||||
|
self.dR = defaultR
|
||||||
|
self.dG = defaultG
|
||||||
|
self.dB = defaultB
|
||||||
|
self.dA = defaultA
|
||||||
self.colorSwatch:SetVertexColor(r, g, b, a)
|
self.colorSwatch:SetVertexColor(r, g, b, a)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -140,7 +153,7 @@ local function Constructor()
|
|||||||
colorSwatch:SetWidth(19)
|
colorSwatch:SetWidth(19)
|
||||||
colorSwatch:SetHeight(19)
|
colorSwatch:SetHeight(19)
|
||||||
colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
|
colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
|
||||||
colorSwatch:SetPoint("LEFT",0,0)
|
colorSwatch:SetPoint("LEFT")
|
||||||
|
|
||||||
local texture = frame:CreateTexture(nil, "BACKGROUND")
|
local texture = frame:CreateTexture(nil, "BACKGROUND")
|
||||||
texture:SetWidth(16)
|
texture:SetWidth(16)
|
||||||
@@ -164,7 +177,7 @@ local function Constructor()
|
|||||||
text:SetJustifyH("LEFT")
|
text:SetJustifyH("LEFT")
|
||||||
text:SetTextColor(1, 1, 1)
|
text:SetTextColor(1, 1, 1)
|
||||||
text:SetPoint("LEFT", colorSwatch, "RIGHT", 2, 0)
|
text:SetPoint("LEFT", colorSwatch, "RIGHT", 2, 0)
|
||||||
text:SetPoint("RIGHT",0,0)
|
text:SetPoint("RIGHT")
|
||||||
|
|
||||||
--local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
|
--local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
|
||||||
--highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
|
--highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
|
||||||
|
|||||||
+36
-22
@@ -1,19 +1,35 @@
|
|||||||
--[[ $Id: AceGUIWidget-DropDown-Items.lua 1137 2016-05-15 10:57:36Z nevcairiel $ ]]--
|
--[[ $Id: AceGUIWidget-DropDown-Items.lua 1153 2016-11-20 09:57:15Z nevcairiel $ ]]--
|
||||||
|
|
||||||
local AceGUI = LibStub("AceGUI-3.0")
|
local AceGUI = LibStub("AceGUI-3.0")
|
||||||
|
|
||||||
local IsLegion = false
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local assert = assert
|
local select, assert = select, assert
|
||||||
local tgetn = table.getn
|
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local PlaySound = PlaySound
|
local PlaySound = PlaySound
|
||||||
local CreateFrame = CreateFrame
|
local CreateFrame = CreateFrame
|
||||||
|
|
||||||
local fixlevels = AceGUI.fixlevels
|
local function fixlevels(parent,...)
|
||||||
local fixstrata = AceGUI.fixstrata
|
local i = 1
|
||||||
|
local child = select(i, arg)
|
||||||
|
while child do
|
||||||
|
child:SetFrameLevel(parent:GetFrameLevel()+1)
|
||||||
|
fixlevels(child, child:GetChildren())
|
||||||
|
i = i + 1
|
||||||
|
child = select(i, arg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function fixstrata(strata, parent, ...)
|
||||||
|
local i = 1
|
||||||
|
local child = select(i, arg)
|
||||||
|
parent:SetFrameStrata(strata)
|
||||||
|
while child do
|
||||||
|
fixstrata(strata, child, child:GetChildren())
|
||||||
|
i = i + 1
|
||||||
|
child = select(i, arg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- ItemBase is the base "class" for all dropdown items.
|
-- ItemBase is the base "class" for all dropdown items.
|
||||||
-- Each item has to use ItemBase.Create(widgetType) to
|
-- Each item has to use ItemBase.Create(widgetType) to
|
||||||
@@ -29,7 +45,7 @@ local ItemBase = {
|
|||||||
counter = 0,
|
counter = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
function ItemBase.Frame_OnEnter()
|
function ItemBase.Frame_OnEnter(this)
|
||||||
local self = this.obj
|
local self = this.obj
|
||||||
|
|
||||||
if self.useHighlight then
|
if self.useHighlight then
|
||||||
@@ -42,7 +58,7 @@ function ItemBase.Frame_OnEnter()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ItemBase.Frame_OnLeave()
|
function ItemBase.Frame_OnLeave(this)
|
||||||
local self = this.obj
|
local self = this.obj
|
||||||
|
|
||||||
self.highlight:Hide()
|
self.highlight:Hide()
|
||||||
@@ -75,10 +91,9 @@ function ItemBase.SetPullout(self, pullout)
|
|||||||
self.pullout = pullout
|
self.pullout = pullout
|
||||||
|
|
||||||
self.frame:SetParent(nil)
|
self.frame:SetParent(nil)
|
||||||
local itemFrame = pullout.itemFrame
|
self.frame:SetParent(pullout.itemFrame)
|
||||||
self.frame:SetParent(itemFrame)
|
self.parent = pullout.itemFrame
|
||||||
self.parent = itemFrame
|
fixlevels(pullout.itemFrame, pullout.itemFrame:GetChildren())
|
||||||
fixlevels(itemFrame)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- exported
|
-- exported
|
||||||
@@ -92,8 +107,8 @@ function ItemBase.GetText(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- exported
|
-- exported
|
||||||
function ItemBase.SetPoint(self, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
function ItemBase.SetPoint(self, ...)
|
||||||
self.frame:SetPoint(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
self.frame:SetPoint(unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- exported
|
-- exported
|
||||||
@@ -242,7 +257,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnLeave()
|
local function OnLeave(this)
|
||||||
local self = this.obj
|
local self = this.obj
|
||||||
self:Fire("OnLeave")
|
self:Fire("OnLeave")
|
||||||
|
|
||||||
@@ -308,7 +323,7 @@ end
|
|||||||
-- Does not close the pullout on click.
|
-- Does not close the pullout on click.
|
||||||
do
|
do
|
||||||
local widgetType = "Dropdown-Item-Toggle"
|
local widgetType = "Dropdown-Item-Toggle"
|
||||||
local widgetVersion = 3
|
local widgetVersion = 4
|
||||||
|
|
||||||
local function UpdateToggle(self)
|
local function UpdateToggle(self)
|
||||||
if self.value then
|
if self.value then
|
||||||
@@ -323,7 +338,7 @@ do
|
|||||||
self:SetValue(nil)
|
self:SetValue(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Frame_OnClick()
|
local function Frame_OnClick(this, button)
|
||||||
local self = this.obj
|
local self = this.obj
|
||||||
if self.disabled then return end
|
if self.disabled then return end
|
||||||
self.value = not self.value
|
self.value = not self.value
|
||||||
@@ -333,7 +348,7 @@ do
|
|||||||
PlaySound("igMainMenuOptionCheckBoxOff")
|
PlaySound("igMainMenuOptionCheckBoxOff")
|
||||||
end
|
end
|
||||||
UpdateToggle(self)
|
UpdateToggle(self)
|
||||||
self:Fire("OnValueChanged", 1, self.value)
|
self:Fire("OnValueChanged", self.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- exported
|
-- exported
|
||||||
@@ -370,7 +385,7 @@ do
|
|||||||
local widgetType = "Dropdown-Item-Menu"
|
local widgetType = "Dropdown-Item-Menu"
|
||||||
local widgetVersion = 2
|
local widgetVersion = 2
|
||||||
|
|
||||||
local function OnEnter()
|
local function OnEnter(this)
|
||||||
local self = this.obj
|
local self = this.obj
|
||||||
self:Fire("OnEnter")
|
self:Fire("OnEnter")
|
||||||
|
|
||||||
@@ -385,7 +400,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnHide()
|
local function OnHide(this)
|
||||||
local self = this.obj
|
local self = this.obj
|
||||||
if self.submenu then
|
if self.submenu then
|
||||||
self.submenu:Close()
|
self.submenu:Close()
|
||||||
@@ -441,7 +456,6 @@ do
|
|||||||
local line = self.frame:CreateTexture(nil, "OVERLAY")
|
local line = self.frame:CreateTexture(nil, "OVERLAY")
|
||||||
line:SetHeight(1)
|
line:SetHeight(1)
|
||||||
line:SetTexture(.5, .5, .5)
|
line:SetTexture(.5, .5, .5)
|
||||||
|
|
||||||
line:SetPoint("LEFT", self.frame, "LEFT", 10, 0)
|
line:SetPoint("LEFT", self.frame, "LEFT", 10, 0)
|
||||||
line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0)
|
line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0)
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,41 @@
|
|||||||
--[[ $Id: AceGUIWidget-DropDown.lua 1116 2014-10-12 08:15:46Z nevcairiel $ ]]--
|
--[[ $Id: AceGUIWidget-DropDown.lua 1116 2014-10-12 08:15:46Z nevcairiel $ ]]--
|
||||||
local AceGUI = LibStub("AceGUI-3.0")
|
local AceGUI = LibStub("AceGUI-3.0")
|
||||||
|
|
||||||
local AceCore = LibStub("AceCore-3.0")
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local min, max, floor = math.min, math.max, math.floor
|
local min, max, floor = math.min, math.max, math.floor
|
||||||
local pairs, ipairs, type = pairs, ipairs, type
|
local select, pairs, ipairs, type = select, pairs, ipairs, type
|
||||||
local tsort, tinsert, tgetn, tsetn = table.sort, table.insert, table.getn, table.setn
|
local tgetn, tsort = table.getn, table.sort
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local PlaySound = PlaySound
|
local PlaySound = PlaySound
|
||||||
local UIParent, CreateFrame = UIParent, CreateFrame
|
local UIParent, CreateFrame = UIParent, CreateFrame
|
||||||
local _G = AceCore._G
|
local _G = _G
|
||||||
|
|
||||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||||
-- List them here for Mikk's FindGlobals script
|
-- List them here for Mikk's FindGlobals script
|
||||||
-- GLOBALS: CLOSE
|
-- GLOBALS: CLOSE
|
||||||
|
|
||||||
local fixlevels = AceGUI.fixlevels
|
local function fixlevels(parent,...)
|
||||||
local fixstrata = AceGUI.fixstrata
|
local i = 1
|
||||||
|
local child = select(i, arg)
|
||||||
|
while child do
|
||||||
|
child:SetFrameLevel(parent:GetFrameLevel()+1)
|
||||||
|
fixlevels(child, child:GetChildren())
|
||||||
|
i = i + 1
|
||||||
|
child = select(i, arg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function fixstrata(strata, parent, ...)
|
||||||
|
local i = 1
|
||||||
|
local child = select(i, arg)
|
||||||
|
parent:SetFrameStrata(strata)
|
||||||
|
while child do
|
||||||
|
fixstrata(strata, child, child:GetChildren())
|
||||||
|
i = i + 1
|
||||||
|
child = select(i, arg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
local widgetType = "Dropdown-Pullout"
|
local widgetType = "Dropdown-Pullout"
|
||||||
@@ -59,15 +76,15 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- See the note in Constructor() for each scroll related function
|
-- See the note in Constructor() for each scroll related function
|
||||||
local function OnMouseWheel()
|
local function OnMouseWheel(this, value)
|
||||||
this.obj:MoveScroll(arg1)
|
this.obj:MoveScroll(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnScrollValueChanged()
|
local function OnScrollValueChanged(this, value)
|
||||||
this.obj:SetScroll(arg1)
|
this.obj:SetScroll(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnSizeChanged()
|
local function OnSizeChanged(this)
|
||||||
this.obj:FixScroll()
|
this.obj:FixScroll()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -152,7 +169,7 @@ do
|
|||||||
|
|
||||||
-- exported
|
-- exported
|
||||||
local function AddItem(self, item)
|
local function AddItem(self, item)
|
||||||
tinsert(self.items, item)
|
self.items[tgetn(self.items) + 1] = item
|
||||||
|
|
||||||
local h = tgetn(self.items) * 16
|
local h = tgetn(self.items) * 16
|
||||||
self.itemFrame:SetHeight(h)
|
self.itemFrame:SetHeight(h)
|
||||||
@@ -187,7 +204,7 @@ do
|
|||||||
height = height + 16
|
height = height + 16
|
||||||
end
|
end
|
||||||
itemFrame:SetHeight(height)
|
itemFrame:SetHeight(height)
|
||||||
fixstrata("TOOLTIP", frame)
|
fixstrata("TOOLTIP", frame, frame:GetChildren())
|
||||||
frame:Show()
|
frame:Show()
|
||||||
self:Fire("OnOpen")
|
self:Fire("OnOpen")
|
||||||
end
|
end
|
||||||
@@ -205,7 +222,6 @@ do
|
|||||||
AceGUI:Release(item)
|
AceGUI:Release(item)
|
||||||
items[i] = nil
|
items[i] = nil
|
||||||
end
|
end
|
||||||
tsetn(items,0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- exported
|
-- exported
|
||||||
@@ -340,30 +356,30 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local widgetType = "Dropdown"
|
local widgetType = "Dropdown"
|
||||||
local widgetVersion = 30
|
local widgetVersion = 31
|
||||||
|
|
||||||
--[[ Static data ]]--
|
--[[ Static data ]]--
|
||||||
|
|
||||||
--[[ UI event handler ]]--
|
--[[ UI event handler ]]--
|
||||||
|
|
||||||
local function Control_OnEnter()
|
local function Control_OnEnter(this)
|
||||||
this.obj.button:LockHighlight()
|
this.obj.button:LockHighlight()
|
||||||
this.obj:Fire("OnEnter")
|
this.obj:Fire("OnEnter")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Control_OnLeave()
|
local function Control_OnLeave(this)
|
||||||
this.obj.button:UnlockHighlight()
|
this.obj.button:UnlockHighlight()
|
||||||
this.obj:Fire("OnLeave")
|
this.obj:Fire("OnLeave")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Dropdown_OnHide()
|
local function Dropdown_OnHide(this)
|
||||||
local self = this.obj
|
local self = this.obj
|
||||||
if self.open then
|
if self.open then
|
||||||
self.pullout:Close()
|
self.pullout:Close()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Dropdown_TogglePullout()
|
local function Dropdown_TogglePullout(this)
|
||||||
local self = this.obj
|
local self = this.obj
|
||||||
PlaySound("igMainMenuOptionCheckBoxOn") -- missleading name, but the Blizzard code uses this sound
|
PlaySound("igMainMenuOptionCheckBoxOn") -- missleading name, but the Blizzard code uses this sound
|
||||||
if self.open then
|
if self.open then
|
||||||
@@ -414,20 +430,17 @@ do
|
|||||||
self:SetText(text)
|
self:SetText(text)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnItemValueChanged(this, event, _, checked)
|
local function OnItemValueChanged(this, event, checked)
|
||||||
local self = this.userdata.obj
|
local self = this.userdata.obj
|
||||||
|
|
||||||
if self.multiselect then
|
if self.multiselect then
|
||||||
self:Fire("OnValueChanged", 2, this.userdata.value, checked)
|
self:Fire("OnValueChanged", this.userdata.value, checked)
|
||||||
ShowMultiText(self)
|
ShowMultiText(self)
|
||||||
else
|
else
|
||||||
if checked then
|
if checked then
|
||||||
self:SetValue(this.userdata.value)
|
self:SetValue(this.userdata.value)
|
||||||
self:Fire("OnValueChanged", 1, this.userdata.value)
|
self:Fire("OnValueChanged", this.userdata.value)
|
||||||
this:SetValue(false)
|
|
||||||
else
|
else
|
||||||
self:SetValue(nil)
|
|
||||||
self:Fire("OnValueChanged", 1, nil)
|
|
||||||
this:SetValue(true)
|
this:SetValue(true)
|
||||||
end
|
end
|
||||||
if self.open then
|
if self.open then
|
||||||
@@ -446,8 +459,7 @@ do
|
|||||||
pullout:SetCallback("OnClose", OnPulloutClose)
|
pullout:SetCallback("OnClose", OnPulloutClose)
|
||||||
pullout:SetCallback("OnOpen", OnPulloutOpen)
|
pullout:SetCallback("OnOpen", OnPulloutOpen)
|
||||||
self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1)
|
self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1)
|
||||||
local frame = self.pullout.frame
|
fixlevels(self.pullout.frame, self.pullout.frame:GetChildren())
|
||||||
fixlevels(frame)
|
|
||||||
|
|
||||||
self:SetHeight(44)
|
self:SetHeight(44)
|
||||||
self:SetWidth(200)
|
self:SetWidth(200)
|
||||||
@@ -559,7 +571,7 @@ do
|
|||||||
local function AddListItem(self, value, text, itemType)
|
local function AddListItem(self, value, text, itemType)
|
||||||
if not itemType then itemType = "Dropdown-Item-Toggle" end
|
if not itemType then itemType = "Dropdown-Item-Toggle" end
|
||||||
local exists = AceGUI:GetWidgetVersion(itemType)
|
local exists = AceGUI:GetWidgetVersion(itemType)
|
||||||
if not exists then error(("The given item type, %q, does not exist within AceGUI-3.0"):format(tostring(itemType)), 2) end
|
if not exists then error(format("The given item type, %q, does not exist within AceGUI-3.0", tostring(itemType)), 2) end
|
||||||
|
|
||||||
local item = AceGUI:Create(itemType)
|
local item = AceGUI:Create(itemType)
|
||||||
item:SetText(text)
|
item:SetText(text)
|
||||||
@@ -588,7 +600,7 @@ do
|
|||||||
|
|
||||||
if type(order) ~= "table" then
|
if type(order) ~= "table" then
|
||||||
for v in pairs(list) do
|
for v in pairs(list) do
|
||||||
tinsert(sortlist, v)
|
sortlist[tgetn(sortlist) + 1] = v
|
||||||
end
|
end
|
||||||
tsort(sortlist)
|
tsort(sortlist)
|
||||||
|
|
||||||
@@ -596,7 +608,6 @@ do
|
|||||||
AddListItem(self, key, list[key], itemType)
|
AddListItem(self, key, list[key], itemType)
|
||||||
sortlist[i] = nil
|
sortlist[i] = nil
|
||||||
end
|
end
|
||||||
tsetn(sortlist,0)
|
|
||||||
else
|
else
|
||||||
for i, key in ipairs(order) do
|
for i, key in ipairs(order) do
|
||||||
AddListItem(self, key, list[key], itemType)
|
AddListItem(self, key, list[key], itemType)
|
||||||
|
|||||||
@@ -1,23 +1,18 @@
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
EditBox Widget
|
EditBox Widget
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local Type, Version = "EditBox", 26
|
local Type, Version = "EditBox", 27
|
||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
local AceCore = LibStub("AceCore-3.0")
|
|
||||||
local hooksecurefunc = AceCore.hooksecurefunc
|
|
||||||
local _G = AceCore._G
|
|
||||||
local GetCursorInfo = _G.GetCursorInfo
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local tostring, pairs = tostring, pairs
|
local tostring, pairs, unpack = tostring, pairs, unpack
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local PlaySound = PlaySound
|
local PlaySound = PlaySound
|
||||||
local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo
|
local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo
|
||||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||||
local strlen = string.len
|
local _G = _G
|
||||||
|
|
||||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||||
-- List them here for Mikk's FindGlobals script
|
-- List them here for Mikk's FindGlobals script
|
||||||
@@ -121,7 +116,7 @@ end
|
|||||||
function _G.AceGUIEditBoxInsertLink(text)
|
function _G.AceGUIEditBoxInsertLink(text)
|
||||||
for i = 1, AceGUI:GetWidgetCount(Type) do
|
for i = 1, AceGUI:GetWidgetCount(Type) do
|
||||||
local editbox = _G["AceGUI-3.0EditBox"..i]
|
local editbox = _G["AceGUI-3.0EditBox"..i]
|
||||||
if editbox and editbox:IsVisible() and editbox.hasfocus then
|
if editbox and editbox:IsVisible() and editbox:HasFocus() then
|
||||||
editbox:Insert(text)
|
editbox:Insert(text)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -143,82 +138,73 @@ end
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local function Control_OnEnter()
|
local function Control_OnEnter(frame)
|
||||||
this.obj:Fire("OnEnter")
|
frame.obj:Fire("OnEnter")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Control_OnLeave()
|
local function Control_OnLeave(frame)
|
||||||
this.obj:Fire("OnLeave")
|
frame.obj:Fire("OnLeave")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Frame_OnShowFocus()
|
local function Frame_OnShowFocus(frame)
|
||||||
this.obj.editbox:SetFocus()
|
frame.obj.editbox:SetFocus()
|
||||||
this:SetScript("OnShow", nil)
|
frame:SetScript("OnShow", nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function EditBox_OnEscapePressed()
|
local function EditBox_OnEscapePressed(frame)
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function EditBox_OnEnterPressed()
|
local function EditBox_OnEnterPressed(frame)
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
local value = this:GetText()
|
local value = frame:GetText()
|
||||||
local cancel = self:Fire("OnEnterPressed", 1, value)
|
local cancel = self:Fire("OnEnterPressed", value)
|
||||||
if not cancel then
|
if not cancel then
|
||||||
PlaySound("igMainMenuOptionCheckBoxOn")
|
PlaySound("igMainMenuOptionCheckBoxOn")
|
||||||
HideButton(self)
|
HideButton(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function EditBox_OnReceiveDrag()
|
local function EditBox_OnReceiveDrag(frame)
|
||||||
if not GetCursorInfo then return end
|
local self = frame.obj
|
||||||
local self = this.obj
|
|
||||||
local type, id, info = GetCursorInfo()
|
local type, id, info = GetCursorInfo()
|
||||||
if type == "item" then
|
if type == "item" then
|
||||||
self:SetText(info)
|
self:SetText(info)
|
||||||
self:Fire("OnEnterPressed", 1, info)
|
self:Fire("OnEnterPressed", info)
|
||||||
ClearCursor()
|
ClearCursor()
|
||||||
elseif type == "spell" then
|
elseif type == "spell" then
|
||||||
local spell, rank = GetSpellName(id, info)
|
local name = GetSpellInfo(id, info)
|
||||||
if rank ~= "" then spell = spell.."("..rank..")" end
|
self:SetText(name)
|
||||||
self:SetText(spell)
|
self:Fire("OnEnterPressed", name)
|
||||||
self:Fire("OnEnterPressed", 1, spell)
|
|
||||||
ClearCursor()
|
ClearCursor()
|
||||||
elseif type == "macro" then
|
elseif type == "macro" then
|
||||||
local name = GetMacroInfo(id)
|
local name = GetMacroInfo(id)
|
||||||
self:SetText(name)
|
self:SetText(name)
|
||||||
self:Fire("OnEnterPressed", 1, name)
|
self:Fire("OnEnterPressed", name)
|
||||||
ClearCursor()
|
ClearCursor()
|
||||||
end
|
end
|
||||||
HideButton(self)
|
HideButton(self)
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function EditBox_OnTextChanged(frame)
|
||||||
local function EditBox_OnTextChanged()
|
local self = frame.obj
|
||||||
local self = this.obj
|
local value = frame:GetText()
|
||||||
local value = this:GetText()
|
|
||||||
if tostring(value) ~= tostring(self.lasttext) then
|
if tostring(value) ~= tostring(self.lasttext) then
|
||||||
self:Fire("OnTextChanged", 1, value)
|
self:Fire("OnTextChanged", value)
|
||||||
self.lasttext = value
|
self.lasttext = value
|
||||||
ShowButton(self)
|
ShowButton(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function EditBox_OnFocusGained()
|
local function EditBox_OnFocusGained(frame)
|
||||||
this.hasfocus = true
|
AceGUI:SetFocus(frame.obj)
|
||||||
AceGUI:SetFocus(this.obj)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function EditBox_OnFocusLost()
|
local function Button_OnClick(frame)
|
||||||
this.hasfocus = nil
|
local editbox = frame.obj.editbox
|
||||||
end
|
|
||||||
|
|
||||||
local function Button_OnClick()
|
|
||||||
local editbox = this.obj.editbox
|
|
||||||
editbox:ClearFocus()
|
editbox:ClearFocus()
|
||||||
this = editbox -- Ace3v: this is kinda hack here
|
EditBox_OnEnterPressed(editbox)
|
||||||
EditBox_OnEnterPressed()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
@@ -256,7 +242,7 @@ local methods = {
|
|||||||
["SetText"] = function(self, text)
|
["SetText"] = function(self, text)
|
||||||
self.lasttext = text or ""
|
self.lasttext = text or ""
|
||||||
self.editbox:SetText(text or "")
|
self.editbox:SetText(text or "")
|
||||||
self.editbox:HighlightText(0)
|
self.editbox:SetCursorPosition(0)
|
||||||
HideButton(self)
|
HideButton(self)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -327,11 +313,10 @@ local function Constructor()
|
|||||||
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
|
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
|
||||||
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
|
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
|
||||||
editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained)
|
editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained)
|
||||||
editbox:SetScript("OnEditFocusLost", EditBox_OnFocusLost)
|
|
||||||
editbox:SetTextInsets(0, 0, 3, 3)
|
editbox:SetTextInsets(0, 0, 3, 3)
|
||||||
editbox:SetMaxLetters(256)
|
editbox:SetMaxLetters(256)
|
||||||
editbox:SetPoint("BOTTOMLEFT", 6, 0)
|
editbox:SetPoint("BOTTOMLEFT", 6, 0)
|
||||||
editbox:SetPoint("BOTTOMRIGHT", 0, 0)
|
editbox:SetPoint("BOTTOMRIGHT")
|
||||||
editbox:SetHeight(19)
|
editbox:SetHeight(19)
|
||||||
|
|
||||||
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ local function Constructor()
|
|||||||
frame:Hide()
|
frame:Hide()
|
||||||
|
|
||||||
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
|
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
|
||||||
label:SetPoint("TOP",0,0)
|
label:SetPoint("TOP", 0, 0)
|
||||||
label:SetPoint("BOTTOM",0,0)
|
label:SetPoint("BOTTOM", 0, 0)
|
||||||
label:SetJustifyH("CENTER")
|
label:SetJustifyH("CENTER", 0, 0)
|
||||||
|
|
||||||
local left = frame:CreateTexture(nil, "BACKGROUND")
|
local left = frame:CreateTexture(nil, "BACKGROUND")
|
||||||
left:SetHeight(8)
|
left:SetHeight(8)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
|||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local pairs, print = pairs, print
|
local select, pairs, print, unpack = select, pairs, print, unpack
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||||
@@ -14,16 +14,16 @@ local CreateFrame, UIParent = CreateFrame, UIParent
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local function Control_OnEnter()
|
local function Control_OnEnter(frame)
|
||||||
this.obj:Fire("OnEnter")
|
frame.obj:Fire("OnEnter")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Control_OnLeave()
|
local function Control_OnLeave(frame)
|
||||||
this.obj:Fire("OnLeave")
|
frame.obj:Fire("OnLeave")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Button_OnClick()
|
local function Button_OnClick(frame, button)
|
||||||
this.obj:Fire("OnClick", 1, arg1)
|
frame.obj:Fire("OnClick", button)
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -53,13 +53,14 @@ local methods = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
|
["SetImage"] = function(self, path, ...)
|
||||||
local image = self.image
|
local image = self.image
|
||||||
image:SetTexture(path)
|
image:SetTexture(path)
|
||||||
|
|
||||||
if image:GetTexture() then
|
if image:GetTexture() then
|
||||||
if a4 or a8 then
|
local n = select("#", arg)
|
||||||
image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
|
if n == 4 or n == 8 then
|
||||||
|
image:SetTexCoord(unpack(arg))
|
||||||
else
|
else
|
||||||
image:SetTexCoord(0, 1, 0, 1)
|
image:SetTexCoord(0, 1, 0, 1)
|
||||||
end
|
end
|
||||||
@@ -131,7 +132,7 @@ local function Constructor()
|
|||||||
widget[method] = func
|
widget[method] = func
|
||||||
end
|
end
|
||||||
|
|
||||||
widget.SetText = function(self,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) end
|
widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(unpack(arg)) end
|
||||||
|
|
||||||
return AceGUI:RegisterAsWidget(widget)
|
return AceGUI:RegisterAsWidget(widget)
|
||||||
end
|
end
|
||||||
|
|||||||
+14
-13
@@ -1,12 +1,12 @@
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
InteractiveLabel Widget
|
InteractiveLabel Widget
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local Type, Version = "InteractiveLabel", 20
|
local Type, Version = "InteractiveLabel", 21
|
||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local pairs = pairs
|
local select, pairs, unpack = select, pairs, unpack
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||||
@@ -18,16 +18,16 @@ local CreateFrame, UIParent = CreateFrame, UIParent
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local function Control_OnEnter()
|
local function Control_OnEnter(frame)
|
||||||
this.obj:Fire("OnEnter")
|
frame.obj:Fire("OnEnter")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Control_OnLeave()
|
local function Control_OnLeave(frame)
|
||||||
this.obj:Fire("OnLeave")
|
frame.obj:Fire("OnLeave")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Label_OnClick()
|
local function Label_OnClick(frame, button)
|
||||||
this.obj:Fire("OnClick", 1, arg1)
|
frame.obj:Fire("OnClick", button)
|
||||||
AceGUI:ClearFocus()
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -44,13 +44,14 @@ local methods = {
|
|||||||
|
|
||||||
-- ["OnRelease"] = nil,
|
-- ["OnRelease"] = nil,
|
||||||
|
|
||||||
["SetHighlight"] = function(self, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
["SetHighlight"] = function(self, ...)
|
||||||
self.highlight:SetTexture(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
self.highlight:SetTexture(unpack(arg))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["SetHighlightTexCoord"] = function(self, a1,a2,a3,a4,a5,a6,a7,a8)
|
["SetHighlightTexCoord"] = function(self, ...)
|
||||||
if a4 or a8 then
|
local c = select("#", arg)
|
||||||
self.highlight:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
|
if c == 4 or c == 8 then
|
||||||
|
self.highlight:SetTexCoord(unpack(arg))
|
||||||
else
|
else
|
||||||
self.highlight:SetTexCoord(0, 1, 0, 1)
|
self.highlight:SetTexCoord(0, 1, 0, 1)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,32 +21,44 @@ local CreateFrame, UIParent = CreateFrame, UIParent
|
|||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
|
|
||||||
local function Control_OnEnter()
|
local function Control_OnEnter(frame)
|
||||||
this.obj:Fire("OnEnter")
|
frame.obj:Fire("OnEnter")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Control_OnLeave()
|
local function Control_OnLeave(frame)
|
||||||
this.obj:Fire("OnLeave")
|
frame.obj:Fire("OnLeave")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Keybinding_OnHide()
|
local function Keybinding_OnClick(frame, button)
|
||||||
local self = this.obj
|
if button == "LeftButton" or button == "RightButton" then
|
||||||
this:EnableKeyboard(false)
|
local self = frame.obj
|
||||||
this:EnableMouseWheel(false)
|
if self.waitingForKey then
|
||||||
|
frame:EnableKeyboard(false)
|
||||||
|
frame:EnableMouseWheel(false)
|
||||||
self.msgframe:Hide()
|
self.msgframe:Hide()
|
||||||
this:UnlockHighlight()
|
frame:UnlockHighlight()
|
||||||
self.waitingForKey = nil
|
self.waitingForKey = nil
|
||||||
|
else
|
||||||
|
frame:EnableKeyboard(true)
|
||||||
|
frame:EnableMouseWheel(true)
|
||||||
|
self.msgframe:Show()
|
||||||
|
frame:LockHighlight()
|
||||||
|
self.waitingForKey = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
AceGUI:ClearFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
local ignoreKeys = {
|
local ignoreKeys = {
|
||||||
["BUTTON1"] = true, ["BUTTON2"] = true,
|
["BUTTON1"] = true, ["BUTTON2"] = true,
|
||||||
["UNKNOWN"] = true,
|
["UNKNOWN"] = true,
|
||||||
["SHIFT"] = true, ["CTRL"] = true, ["ALT"] = true,
|
["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true,
|
||||||
|
["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true,
|
||||||
}
|
}
|
||||||
local function Keybinding_OnKeyDown()
|
local function Keybinding_OnKeyDown(frame, key)
|
||||||
local self = this.obj
|
local self = frame.obj
|
||||||
if self.waitingForKey then
|
if self.waitingForKey then
|
||||||
local keyPressed = arg1
|
local keyPressed = key
|
||||||
if keyPressed == "ESCAPE" then
|
if keyPressed == "ESCAPE" then
|
||||||
keyPressed = ""
|
keyPressed = ""
|
||||||
else
|
else
|
||||||
@@ -62,58 +74,40 @@ local function Keybinding_OnKeyDown()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
this:EnableKeyboard(false)
|
frame:EnableKeyboard(false)
|
||||||
this:EnableMouseWheel(false)
|
frame:EnableMouseWheel(false)
|
||||||
self.msgframe:Hide()
|
self.msgframe:Hide()
|
||||||
this:UnlockHighlight()
|
frame:UnlockHighlight()
|
||||||
self.waitingForKey = nil
|
self.waitingForKey = nil
|
||||||
|
|
||||||
if not self.disabled then
|
if not self.disabled then
|
||||||
self:SetKey(keyPressed)
|
self:SetKey(keyPressed)
|
||||||
self:Fire("OnKeyChanged", 1, keyPressed)
|
self:Fire("OnKeyChanged", keyPressed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Keybinding_OnMouseDown()
|
local function Keybinding_OnMouseDown(frame, button)
|
||||||
getglobal(this:GetName().."Left"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Down");
|
if button == "LeftButton" or button == "RightButton" then
|
||||||
getglobal(this:GetName().."Middle"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Down");
|
return
|
||||||
getglobal(this:GetName().."Right"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Down");
|
elseif button == "MiddleButton" then
|
||||||
|
button = "BUTTON3"
|
||||||
|
elseif button == "Button4" then
|
||||||
|
button = "BUTTON4"
|
||||||
|
elseif button == "Button5" then
|
||||||
|
button = "BUTTON5"
|
||||||
|
end
|
||||||
|
Keybinding_OnKeyDown(frame, button)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Keybinding_OnMouseUp()
|
local function Keybinding_OnMouseWheel(frame, direction)
|
||||||
getglobal(this:GetName().."Left"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Up");
|
local button
|
||||||
getglobal(this:GetName().."Middle"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Up");
|
if direction >= 0 then
|
||||||
getglobal(this:GetName().."Right"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Up");
|
button = "MOUSEWHEELUP"
|
||||||
local self = this.obj
|
|
||||||
if MouseIsOver(this) and not self.disabled then
|
|
||||||
if self.waitingForKey then
|
|
||||||
if arg1 ~= "LeftButton" and arg1 ~= "RightButton" then
|
|
||||||
Keybinding_OnKeyDown()
|
|
||||||
end
|
|
||||||
this:EnableKeyboard(false)
|
|
||||||
this:EnableMouseWheel(false)
|
|
||||||
self.msgframe:Hide()
|
|
||||||
this:UnlockHighlight()
|
|
||||||
self.waitingForKey = nil
|
|
||||||
else
|
else
|
||||||
this:EnableKeyboard(true)
|
button = "MOUSEWHEELDOWN"
|
||||||
this:EnableMouseWheel(true)
|
|
||||||
self.msgframe:Show()
|
|
||||||
this:LockHighlight()
|
|
||||||
self.waitingForKey = true
|
|
||||||
end
|
end
|
||||||
end
|
Keybinding_OnKeyDown(frame, button)
|
||||||
AceGUI:ClearFocus()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function Keybinding_OnMouseWheel()
|
|
||||||
if arg1 >= 0 then
|
|
||||||
arg1 = "MOUSEWHEELUP"
|
|
||||||
else
|
|
||||||
arg1 = "MOUSEWHEELDOWN"
|
|
||||||
end
|
|
||||||
Keybinding_OnKeyDown()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
@@ -147,10 +141,10 @@ local methods = {
|
|||||||
["SetKey"] = function(self, key)
|
["SetKey"] = function(self, key)
|
||||||
if (key or "") == "" then
|
if (key or "") == "" then
|
||||||
self.button:SetText(NOT_BOUND)
|
self.button:SetText(NOT_BOUND)
|
||||||
self.text:SetFontObject("GameFontNormal")
|
self.button:SetNormalFontObject("GameFontNormal")
|
||||||
else
|
else
|
||||||
self.button:SetText(key)
|
self.button:SetText(key)
|
||||||
self.text:SetFontObject("GameFontHighlight")
|
self.button:SetNormalFontObject("GameFontHighlight")
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -185,31 +179,28 @@ local ControlBackdrop = {
|
|||||||
insets = { left = 3, right = 3, top = 3, bottom = 3 }
|
insets = { left = 3, right = 3, top = 3, bottom = 3 }
|
||||||
}
|
}
|
||||||
|
|
||||||
local function keybindingMsgFixWidth()
|
local function keybindingMsgFixWidth(frame)
|
||||||
this:SetWidth(this.msg:GetWidth() + 10)
|
frame:SetWidth(frame.msg:GetWidth() + 10)
|
||||||
this:SetScript("OnUpdate", nil)
|
frame:SetScript("OnUpdate", nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Constructor()
|
local function Constructor()
|
||||||
local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type)
|
local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type)
|
||||||
|
|
||||||
local frame = CreateFrame("Frame", nil, UIParent)
|
local frame = CreateFrame("Frame", nil, UIParent)
|
||||||
local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate2")
|
local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate")
|
||||||
|
|
||||||
button:EnableMouse(true)
|
button:EnableMouse(true)
|
||||||
button:EnableMouseWheel(false)
|
button:EnableMouseWheel(false)
|
||||||
|
button:RegisterForClicks("AnyDown")
|
||||||
button:SetScript("OnEnter", Control_OnEnter)
|
button:SetScript("OnEnter", Control_OnEnter)
|
||||||
button:SetScript("OnLeave", Control_OnLeave)
|
button:SetScript("OnLeave", Control_OnLeave)
|
||||||
|
button:SetScript("OnClick", Keybinding_OnClick)
|
||||||
button:SetScript("OnKeyDown", Keybinding_OnKeyDown)
|
button:SetScript("OnKeyDown", Keybinding_OnKeyDown)
|
||||||
button:RegisterForClicks("AnyDown","AnyUp")
|
|
||||||
-- Ace3v: RegisterForClicks means OnClick will not be triggered, so use OnKeyDown and OnKeyUp
|
|
||||||
button:SetScript("OnMouseDown", Keybinding_OnMouseDown)
|
button:SetScript("OnMouseDown", Keybinding_OnMouseDown)
|
||||||
button:SetScript("OnMouseUp", Keybinding_OnMouseUp)
|
|
||||||
button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel)
|
button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel)
|
||||||
button:SetScript("OnHide", Keybinding_OnHide)
|
button:SetPoint("BOTTOMLEFT")
|
||||||
button:SetPoint("BOTTOMLEFT",0,0)
|
button:SetPoint("BOTTOMRIGHT")
|
||||||
button:SetPoint("BOTTOMRIGHT",0,0)
|
|
||||||
button:SetHeight(24)
|
button:SetHeight(24)
|
||||||
button:EnableKeyboard(false)
|
button:EnableKeyboard(false)
|
||||||
|
|
||||||
@@ -218,8 +209,8 @@ local function Constructor()
|
|||||||
text:SetPoint("RIGHT", -7, 0)
|
text:SetPoint("RIGHT", -7, 0)
|
||||||
|
|
||||||
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
||||||
label:SetPoint("TOPLEFT",0,0)
|
label:SetPoint("TOPLEFT")
|
||||||
label:SetPoint("TOPRIGHT",0,0)
|
label:SetPoint("TOPRIGHT")
|
||||||
label:SetJustifyH("CENTER")
|
label:SetJustifyH("CENTER")
|
||||||
label:SetHeight(18)
|
label:SetHeight(18)
|
||||||
|
|
||||||
@@ -245,8 +236,7 @@ local function Constructor()
|
|||||||
msgframe = msgframe,
|
msgframe = msgframe,
|
||||||
frame = frame,
|
frame = frame,
|
||||||
alignoffset = 30,
|
alignoffset = 30,
|
||||||
type = Type,
|
type = Type
|
||||||
text = text
|
|
||||||
}
|
}
|
||||||
for method, func in pairs(methods) do
|
for method, func in pairs(methods) do
|
||||||
widget[method] = func
|
widget[method] = func
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
Label Widget
|
Label Widget
|
||||||
Displays text and optionally an icon.
|
Displays text and optionally an icon.
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local Type, Version = "Label", 23
|
local Type, Version = "Label", 24
|
||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local max, pairs = math.max, pairs
|
local max, select, pairs, unpack = math.max, select, pairs, unpack
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||||
@@ -35,14 +35,14 @@ local function UpdateImageAnchor(self)
|
|||||||
local imagewidth = image:GetWidth()
|
local imagewidth = image:GetWidth()
|
||||||
if (width - imagewidth) < 200 or (label:GetText() or "") == "" then
|
if (width - imagewidth) < 200 or (label:GetText() or "") == "" then
|
||||||
-- image goes on top centered when less than 200 width for the text, or if there is no text
|
-- image goes on top centered when less than 200 width for the text, or if there is no text
|
||||||
image:SetPoint("TOP",0,0)
|
image:SetPoint("TOP")
|
||||||
label:SetPoint("TOP", image, "BOTTOM")
|
label:SetPoint("TOP", image, "BOTTOM")
|
||||||
label:SetPoint("LEFT",0,0)
|
label:SetPoint("LEFT")
|
||||||
label:SetWidth(width)
|
label:SetWidth(width)
|
||||||
height = image:GetHeight() + label:GetHeight()
|
height = image:GetHeight() + label:GetHeight()
|
||||||
else
|
else
|
||||||
-- image on the left
|
-- image on the left
|
||||||
image:SetPoint("TOPLEFT",0,0)
|
image:SetPoint("TOPLEFT")
|
||||||
if image:GetHeight() > label:GetHeight() then
|
if image:GetHeight() > label:GetHeight() then
|
||||||
label:SetPoint("LEFT", image, "RIGHT", 4, 0)
|
label:SetPoint("LEFT", image, "RIGHT", 4, 0)
|
||||||
else
|
else
|
||||||
@@ -53,7 +53,7 @@ local function UpdateImageAnchor(self)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- no image shown
|
-- no image shown
|
||||||
label:SetPoint("TOPLEFT",0,0)
|
label:SetPoint("TOPLEFT")
|
||||||
label:SetWidth(width)
|
label:SetWidth(width)
|
||||||
height = label:GetHeight()
|
height = label:GetHeight()
|
||||||
end
|
end
|
||||||
@@ -78,6 +78,8 @@ local methods = {
|
|||||||
self:SetImageSize(16, 16)
|
self:SetImageSize(16, 16)
|
||||||
self:SetColor()
|
self:SetColor()
|
||||||
self:SetFontObject()
|
self:SetFontObject()
|
||||||
|
self:SetJustifyH("LEFT")
|
||||||
|
self:SetJustifyV("TOP")
|
||||||
|
|
||||||
-- reset the flag
|
-- reset the flag
|
||||||
self.resizing = nil
|
self.resizing = nil
|
||||||
@@ -103,14 +105,15 @@ local methods = {
|
|||||||
self.label:SetVertexColor(r, g, b)
|
self.label:SetVertexColor(r, g, b)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
|
["SetImage"] = function(self, path, ...)
|
||||||
local image = self.image
|
local image = self.image
|
||||||
image:SetTexture(path)
|
image:SetTexture(path)
|
||||||
|
|
||||||
if image:GetTexture() then
|
if image:GetTexture() then
|
||||||
self.imageshown = true
|
self.imageshown = true
|
||||||
if a4 or a8 then
|
local n = select("#", arg)
|
||||||
image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
|
if n == 4 or n == 8 then
|
||||||
|
image:SetTexCoord(unpack(arg))
|
||||||
else
|
else
|
||||||
image:SetTexCoord(0, 1, 0, 1)
|
image:SetTexCoord(0, 1, 0, 1)
|
||||||
end
|
end
|
||||||
@@ -133,6 +136,14 @@ local methods = {
|
|||||||
self.image:SetHeight(height)
|
self.image:SetHeight(height)
|
||||||
UpdateImageAnchor(self)
|
UpdateImageAnchor(self)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
["SetJustifyH"] = function(self, justifyH)
|
||||||
|
self.label:SetJustifyH(justifyH)
|
||||||
|
end,
|
||||||
|
|
||||||
|
["SetJustifyV"] = function(self, justifyV)
|
||||||
|
self.label:SetJustifyV(justifyV)
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
@@ -143,9 +154,6 @@ local function Constructor()
|
|||||||
frame:Hide()
|
frame:Hide()
|
||||||
|
|
||||||
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightSmall")
|
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightSmall")
|
||||||
label:SetJustifyH("LEFT")
|
|
||||||
label:SetJustifyV("TOP")
|
|
||||||
|
|
||||||
local image = frame:CreateTexture(nil, "BACKGROUND")
|
local image = frame:CreateTexture(nil, "BACKGROUND")
|
||||||
|
|
||||||
-- create widget
|
-- create widget
|
||||||
|
|||||||
+66
-88
@@ -2,17 +2,13 @@ local Type, Version = "MultiLineEditBox", 28
|
|||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
local AceCore = LibStub("AceCore-3.0")
|
|
||||||
local hooksecurefunc = AceCore.hooksecurefunc
|
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local strfmt = string.format
|
local pairs, unpack = pairs, unpack
|
||||||
local pairs = pairs
|
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor
|
local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor
|
||||||
local CreateFrame, UIParent = CreateFrame, UIParent
|
local CreateFrame, UIParent = CreateFrame, UIParent
|
||||||
local _G = AceCore._G
|
local _G = _G
|
||||||
|
|
||||||
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
||||||
-- List them here for Mikk's FindGlobals script
|
-- List them here for Mikk's FindGlobals script
|
||||||
@@ -21,6 +17,7 @@ local _G = AceCore._G
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Support functions
|
Support functions
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
|
|
||||||
if not AceGUIMultiLineEditBoxInsertLink then
|
if not AceGUIMultiLineEditBoxInsertLink then
|
||||||
-- upgradeable hook
|
-- upgradeable hook
|
||||||
hooksecurefunc("BankFrameItemButtonGeneric_OnClick",
|
hooksecurefunc("BankFrameItemButtonGeneric_OnClick",
|
||||||
@@ -115,14 +112,15 @@ end
|
|||||||
|
|
||||||
function _G.AceGUIMultiLineEditBoxInsertLink(text)
|
function _G.AceGUIMultiLineEditBoxInsertLink(text)
|
||||||
for i = 1, AceGUI:GetWidgetCount(Type) do
|
for i = 1, AceGUI:GetWidgetCount(Type) do
|
||||||
local editbox = _G[strfmt("MultiLineEditBox%uEdit",i)]
|
local editbox = _G[format("MultiLineEditBox%uEdit", i)]
|
||||||
if editbox and editbox:IsVisible() and editbox.hasfocus then
|
if editbox and editbox:IsVisible() and editbox:HasFocus() then
|
||||||
editbox:Insert(text)
|
editbox:Insert(text)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function Layout(self)
|
local function Layout(self)
|
||||||
self:SetHeight(self.numlines * 14 + (self.disablebutton and 19 or 41) + self.labelHeight)
|
self:SetHeight(self.numlines * 14 + (self.disablebutton and 19 or 41) + self.labelHeight)
|
||||||
|
|
||||||
@@ -144,122 +142,104 @@ end
|
|||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
Scripts
|
Scripts
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local function OnClick() -- Button
|
local function OnClick(self) -- Button
|
||||||
local self = this.obj
|
self = self.obj
|
||||||
self.editBox:ClearFocus()
|
self.editBox:ClearFocus()
|
||||||
if not self:Fire("OnEnterPressed", 1, self.editBox:GetText()) then
|
if not self:Fire("OnEnterPressed", self.editBox:GetText()) then
|
||||||
self.button:Disable()
|
self.button:Disable()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnCursorChanged() -- EditBox
|
local function OnCursorChanged(self, _, y, _, cursorHeight) -- EditBox
|
||||||
|
self, y = self.obj.scrollFrame, -y
|
||||||
local self, y = this.obj.scrollFrame, -arg2
|
|
||||||
local offset = self:GetVerticalScroll()
|
local offset = self:GetVerticalScroll()
|
||||||
if y < offset then
|
if y < offset then
|
||||||
self:SetVerticalScroll(y)
|
self:SetVerticalScroll(y)
|
||||||
else
|
else
|
||||||
y = y + arg4 - self:GetHeight()
|
y = y + cursorHeight - self:GetHeight()
|
||||||
if y > offset then
|
if y > offset then
|
||||||
self:SetVerticalScroll(y)
|
self:SetVerticalScroll(y)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnEditFocusLost() -- EditBox
|
local function OnEditFocusLost(self) -- EditBox
|
||||||
this.hasfocus = nil
|
self:HighlightText(0, 0)
|
||||||
this:HighlightText(0, 0)
|
self.obj:Fire("OnEditFocusLost")
|
||||||
this.obj:Fire("OnEditFocusLost")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnEnter() -- EditBox / ScrollFrame
|
local function OnEnter(self) -- EditBox / ScrollFrame
|
||||||
local self = this.obj
|
self = self.obj
|
||||||
if not self.entered then
|
if not self.entered then
|
||||||
self.entered = true
|
self.entered = true
|
||||||
self:Fire("OnEnter")
|
self:Fire("OnEnter")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnLeave() -- EditBox / ScrollFrame
|
local function OnLeave(self) -- EditBox / ScrollFrame
|
||||||
local self = this.obj
|
self = self.obj
|
||||||
if self.entered then
|
if self.entered then
|
||||||
self.entered = nil
|
self.entered = nil
|
||||||
self:Fire("OnLeave")
|
self:Fire("OnLeave")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnMouseUp() -- ScrollFrame
|
local function OnMouseUp(self) -- ScrollFrame
|
||||||
local self = this.obj.editBox
|
self = self.obj.editBox
|
||||||
self:SetFocus()
|
self:SetFocus()
|
||||||
local n = self:GetNumLetters()
|
self:SetCursorPosition(self:GetNumLetters())
|
||||||
self:HighlightText(n,n)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnReceiveDrag() -- EditBox / ScrollFrame
|
local function OnReceiveDrag(self) -- EditBox / ScrollFrame
|
||||||
if not GetCursorInfo then return end
|
|
||||||
local type, id, info = GetCursorInfo()
|
local type, id, info = GetCursorInfo()
|
||||||
if type == "spell" then
|
if type == "spell" then
|
||||||
local spell, rank = GetSpellName(id, info)
|
info = GetSpellInfo(id, info)
|
||||||
if rank ~= "" then spell = spell.."("..rank..")" end
|
|
||||||
info = spell
|
|
||||||
elseif type ~= "item" then
|
elseif type ~= "item" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
ClearCursor()
|
ClearCursor()
|
||||||
local self = this.obj
|
self = self.obj
|
||||||
local editBox = self.editBox
|
local editBox = self.editBox
|
||||||
if not this.hasfocus then
|
if not editBox:HasFocus() then
|
||||||
this.hasfocus = true
|
|
||||||
editBox:SetFocus()
|
editBox:SetFocus()
|
||||||
local n = editBox:GetNumLetters()
|
editBox:SetCursorPosition(editBox:GetNumLetters())
|
||||||
editBox:HighlightText(n,n)
|
|
||||||
end
|
end
|
||||||
editBox:Insert(info)
|
editBox:Insert(info)
|
||||||
self.button:Enable()
|
self.button:Enable()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnSizeChanged() -- ScrollFrame
|
local function OnSizeChanged(self, width, height) -- ScrollFrame
|
||||||
this.obj.editBox:SetWidth(arg1)
|
self.obj.editBox:SetWidth(width)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnTextChanged() -- EditBox
|
local function OnTextChanged(self, userInput) -- EditBox
|
||||||
local self = this.obj
|
if userInput then
|
||||||
local value = this:GetText()
|
self = self.obj
|
||||||
if tostring(value) ~= tostring(self.lasttext) then
|
self:Fire("OnTextChanged", self.editBox:GetText())
|
||||||
self:Fire("OnTextChanged", 1, value)
|
|
||||||
self.lasttext = value
|
|
||||||
self.button:Enable()
|
self.button:Enable()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnTextSet() -- EditBox
|
local function OnTextSet(self) -- EditBox
|
||||||
this:HighlightText(0, 0)
|
self:HighlightText(0, 0)
|
||||||
this.obj.button:Disable()
|
self:SetCursorPosition(self:GetNumLetters())
|
||||||
|
self:SetCursorPosition(0)
|
||||||
|
self.obj.button:Disable()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnVerticalScroll() -- ScrollFrame
|
local function OnVerticalScroll(self, offset) -- ScrollFrame
|
||||||
local self = this.obj
|
local editBox = self.obj.editBox
|
||||||
local editBox = self.editBox
|
editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight())
|
||||||
editBox:SetHitRectInsets(0, 0, arg1, editBox:GetHeight() - arg1 - this:GetHeight())
|
|
||||||
|
|
||||||
self.scrollFrame:SetScrollChild(self.editBox)
|
|
||||||
self.editBox:SetPoint("TOPLEFT",0,arg1)
|
|
||||||
self.editBox:SetPoint("TOPRIGHT",0,arg1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnShowFocus()
|
local function OnShowFocus(frame)
|
||||||
this.obj.editBox:SetFocus()
|
frame.obj.editBox:SetFocus()
|
||||||
this:SetScript("OnShow", nil)
|
frame:SetScript("OnShow", nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnEditFocusGained()
|
local function OnEditFocusGained(frame)
|
||||||
this.hasfocus = true
|
AceGUI:SetFocus(frame.obj)
|
||||||
AceGUI:SetFocus(this.obj)
|
frame.obj:Fire("OnEditFocusGained")
|
||||||
this.obj:Fire("OnEditFocusGained")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function OnEscapePressed() -- EditBox
|
|
||||||
AceGUI:ClearFocus()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
@@ -320,10 +300,7 @@ local methods = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
["SetText"] = function(self, text)
|
["SetText"] = function(self, text)
|
||||||
self.lasttext = text or ""
|
self.editBox:SetText(text)
|
||||||
self.editBox:SetText(text or "")
|
|
||||||
self.editBox:HighlightText(0)
|
|
||||||
self.button:Disable()
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["GetText"] = function(self)
|
["GetText"] = function(self)
|
||||||
@@ -359,6 +336,16 @@ local methods = {
|
|||||||
["HighlightText"] = function(self, from, to)
|
["HighlightText"] = function(self, from, to)
|
||||||
self.editBox:HighlightText(from, to)
|
self.editBox:HighlightText(from, to)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
["GetCursorPosition"] = function(self)
|
||||||
|
return self.editBox:GetCursorPosition()
|
||||||
|
end,
|
||||||
|
|
||||||
|
["SetCursorPosition"] = function(self, ...)
|
||||||
|
return self.editBox:SetCursorPosition(unpack(arg))
|
||||||
|
end,
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--[[-----------------------------------------------------------------------------
|
--[[-----------------------------------------------------------------------------
|
||||||
@@ -383,7 +370,7 @@ local function Constructor()
|
|||||||
label:SetText(ACCEPT)
|
label:SetText(ACCEPT)
|
||||||
label:SetHeight(10)
|
label:SetHeight(10)
|
||||||
|
|
||||||
local button = CreateFrame("Button", strfmt("%s%dButton", Type, widgetNum), frame, "UIPanelButtonTemplate")
|
local button = CreateFrame("Button", format("%s%dButton", Type, widgetNum), frame, "UIPanelButtonTemplate")
|
||||||
button:SetPoint("BOTTOMLEFT", 0, 4)
|
button:SetPoint("BOTTOMLEFT", 0, 4)
|
||||||
button:SetHeight(22)
|
button:SetHeight(22)
|
||||||
button:SetWidth(label:GetStringWidth() + 24)
|
button:SetWidth(label:GetStringWidth() + 24)
|
||||||
@@ -402,7 +389,7 @@ local function Constructor()
|
|||||||
scrollBG:SetBackdropColor(0, 0, 0)
|
scrollBG:SetBackdropColor(0, 0, 0)
|
||||||
scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
||||||
|
|
||||||
local scrollFrame = CreateFrame("ScrollFrame", strfmt("%s%dScrollFrame", Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
|
local scrollFrame = CreateFrame("ScrollFrame", format("%s%dScrollFrame", Type, widgetNum), frame, "UIPanelScrollFrameTemplate")
|
||||||
|
|
||||||
local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"]
|
local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"]
|
||||||
scrollBar:ClearAllPoints()
|
scrollBar:ClearAllPoints()
|
||||||
@@ -420,26 +407,19 @@ local function Constructor()
|
|||||||
scrollFrame:SetScript("OnMouseUp", OnMouseUp)
|
scrollFrame:SetScript("OnMouseUp", OnMouseUp)
|
||||||
scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag)
|
scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag)
|
||||||
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
|
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged)
|
||||||
local old = scrollFrame:GetScript("OnVerticalScroll");
|
scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll)
|
||||||
if old then
|
|
||||||
scrollFrame:SetScript("OnVerticalScroll", function()
|
|
||||||
old()
|
|
||||||
OnVerticalScroll()
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
scrollFrame:SetScript("OnVerticalScroll", OnVerticalScroll)
|
|
||||||
end
|
|
||||||
|
|
||||||
local editBox = CreateFrame("EditBox", strfmt("%s%dEdit", Type, widgetNum), scrollFrame)
|
local editBox = CreateFrame("EditBox", format("%s%dEdit", Type, widgetNum), scrollFrame)
|
||||||
|
editBox:SetAllPoints()
|
||||||
editBox:SetFontObject(ChatFontNormal)
|
editBox:SetFontObject(ChatFontNormal)
|
||||||
editBox:SetMultiLine(true)
|
editBox:SetMultiLine(true)
|
||||||
editBox:EnableMouse(true)
|
editBox:EnableMouse(true)
|
||||||
editBox:SetAutoFocus(false)
|
editBox:SetAutoFocus(false)
|
||||||
--editBox:SetCountInvisibleLetters(false)
|
editBox:SetCountInvisibleLetters(false)
|
||||||
editBox:SetScript("OnCursorChanged", OnCursorChanged)
|
editBox:SetScript("OnCursorChanged", OnCursorChanged)
|
||||||
editBox:SetScript("OnEditFocusLost", OnEditFocusLost)
|
editBox:SetScript("OnEditFocusLost", OnEditFocusLost)
|
||||||
editBox:SetScript("OnEnter", OnEnter)
|
editBox:SetScript("OnEnter", OnEnter)
|
||||||
editBox:SetScript("OnEscapePressed", OnEscapePressed)
|
editBox:SetScript("OnEscapePressed", editBox.ClearFocus)
|
||||||
editBox:SetScript("OnLeave", OnLeave)
|
editBox:SetScript("OnLeave", OnLeave)
|
||||||
editBox:SetScript("OnMouseDown", OnReceiveDrag)
|
editBox:SetScript("OnMouseDown", OnReceiveDrag)
|
||||||
editBox:SetScript("OnReceiveDrag", OnReceiveDrag)
|
editBox:SetScript("OnReceiveDrag", OnReceiveDrag)
|
||||||
@@ -447,10 +427,8 @@ local function Constructor()
|
|||||||
editBox:SetScript("OnTextSet", OnTextSet)
|
editBox:SetScript("OnTextSet", OnTextSet)
|
||||||
editBox:SetScript("OnEditFocusGained", OnEditFocusGained)
|
editBox:SetScript("OnEditFocusGained", OnEditFocusGained)
|
||||||
|
|
||||||
-- Ace3v: the orders are important here
|
|
||||||
scrollFrame:SetScrollChild(editBox)
|
scrollFrame:SetScrollChild(editBox)
|
||||||
editBox:SetPoint("TOPLEFT",0,0)
|
|
||||||
editBox:SetPoint("TOPRIGHT",0,0)
|
|
||||||
|
|
||||||
local widget = {
|
local widget = {
|
||||||
button = button,
|
button = button,
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
Slider Widget
|
Slider Widget
|
||||||
Graphical Slider, like, for Range values.
|
Graphical Slider, like, for Range values.
|
||||||
-------------------------------------------------------------------------------]]
|
-------------------------------------------------------------------------------]]
|
||||||
local Type, Version = "Slider", 21
|
local Type, Version = "Slider", 22
|
||||||
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
||||||
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local min, max, floor = math.min, math.max, math.floor
|
local min, max, floor = math.min, math.max, math.floor
|
||||||
|
local gsub = string.gsub
|
||||||
local tonumber, pairs = tonumber, pairs
|
local tonumber, pairs = tonumber, pairs
|
||||||
|
|
||||||
-- WoW APIs
|
-- WoW APIs
|
||||||
@@ -67,7 +68,7 @@ local function Slider_OnValueChanged()
|
|||||||
end
|
end
|
||||||
if newvalue ~= self.value and not self.disabled then
|
if newvalue ~= self.value and not self.disabled then
|
||||||
self.value = newvalue
|
self.value = newvalue
|
||||||
self:Fire("OnValueChanged", 1, newvalue)
|
self:Fire("OnValueChanged", newvalue)
|
||||||
end
|
end
|
||||||
if self.value then
|
if self.value then
|
||||||
UpdateText(self)
|
UpdateText(self)
|
||||||
@@ -77,7 +78,7 @@ end
|
|||||||
|
|
||||||
local function Slider_OnMouseUp()
|
local function Slider_OnMouseUp()
|
||||||
local self = this.obj
|
local self = this.obj
|
||||||
self:Fire("OnMouseUp", 1, self.value)
|
self:Fire("OnMouseUp", self.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Slider_OnMouseWheel()
|
local function Slider_OnMouseWheel()
|
||||||
@@ -101,7 +102,7 @@ local function EditBox_OnEnterPressed()
|
|||||||
local self = this.obj
|
local self = this.obj
|
||||||
local value = this:GetText()
|
local value = this:GetText()
|
||||||
if self.ispercent then
|
if self.ispercent then
|
||||||
value = value:gsub('%%', '')
|
value = gsub(value, '%%', '')
|
||||||
value = tonumber(value) / 100
|
value = tonumber(value) / 100
|
||||||
else
|
else
|
||||||
value = tonumber(value)
|
value = tonumber(value)
|
||||||
@@ -110,7 +111,7 @@ local function EditBox_OnEnterPressed()
|
|||||||
if value then
|
if value then
|
||||||
PlaySound("igMainMenuOptionCheckBoxOn")
|
PlaySound("igMainMenuOptionCheckBoxOn")
|
||||||
self.slider:SetValue(value)
|
self.slider:SetValue(value)
|
||||||
self:Fire("OnMouseUp", 1, value)
|
self:Fire("OnMouseUp", value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -221,9 +222,9 @@ local function Constructor()
|
|||||||
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
|
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
|
||||||
|
|
||||||
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
||||||
label:SetPoint("TOPLEFT",0,0)
|
label:SetPoint("TOPLEFT", 0, 0)
|
||||||
label:SetPoint("TOPRIGHT",0,0)
|
label:SetPoint("TOPRIGHT", 0, 0)
|
||||||
label:SetJustifyH("CENTER",0,0)
|
label:SetJustifyH("CENTER", 0, 0)
|
||||||
label:SetHeight(15)
|
label:SetHeight(15)
|
||||||
|
|
||||||
local slider = CreateFrame("Slider", nil, frame)
|
local slider = CreateFrame("Slider", nil, frame)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<Script file="AceGUIContainer-Window.lua"/>
|
<Script file="AceGUIContainer-Window.lua"/>
|
||||||
<!-- Widgets -->
|
<!-- Widgets -->
|
||||||
<Script file="AceGUIWidget-Button.lua"/>
|
<Script file="AceGUIWidget-Button.lua"/>
|
||||||
|
<Script file="AceGUIWidget-Button-ElvUI.lua"/>
|
||||||
<Script file="AceGUIWidget-CheckBox.lua"/>
|
<Script file="AceGUIWidget-CheckBox.lua"/>
|
||||||
<Script file="AceGUIWidget-ColorPicker.lua"/>
|
<Script file="AceGUIWidget-ColorPicker.lua"/>
|
||||||
<Script file="AceGUIWidget-DropDown.lua"/>
|
<Script file="AceGUIWidget-DropDown.lua"/>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||||
local AB = E:GetModule("ActionBars");
|
local AB = E:GetModule("ActionBars");
|
||||||
local ACD = LibStub("AceConfigDialog-3.0");
|
local ACD = LibStub("AceConfigDialog-3.0-ElvUI");
|
||||||
local group
|
local group
|
||||||
|
|
||||||
--Cache global variables
|
--Cache global variables
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local E, L, V, P, G = unpack(ElvUI);
|
local E, L, V, P, G = unpack(ElvUI);
|
||||||
local D = {};
|
--local D = E:GetModule("Distributor");
|
||||||
local AceGUI = LibStub("AceGUI-3.0");
|
local AceGUI = LibStub("AceGUI-3.0");
|
||||||
|
|
||||||
local pairs = pairs;
|
local pairs = pairs;
|
||||||
@@ -14,10 +14,11 @@ local UnitName = UnitName;
|
|||||||
|
|
||||||
local DEFAULT_WIDTH = 890;
|
local DEFAULT_WIDTH = 890;
|
||||||
local DEFAULT_HEIGHT = 651;
|
local DEFAULT_HEIGHT = 651;
|
||||||
local AC = LibStub("AceConfig-3.0");
|
local AC = LibStub("AceConfig-3.0-ElvUI");
|
||||||
local ACD = LibStub("AceConfigDialog-3.0");
|
local ACD = LibStub("AceConfigDialog-3.0-ElvUI");
|
||||||
local ACR = LibStub("AceConfigRegistry-3.0");
|
local ACR = LibStub("AceConfigRegistry-3.0-ElvUI");
|
||||||
AC.RegisterOptionsTable(E, "ElvUI", E.Options);
|
|
||||||
|
AC:RegisterOptionsTable("ElvUI", E.Options);
|
||||||
ACD:SetDefaultSize("ElvUI", DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
ACD:SetDefaultSize("ElvUI", DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||||
|
|
||||||
function E:RefreshGUI()
|
function E:RefreshGUI()
|
||||||
@@ -67,3 +68,98 @@ E.Options.args = {
|
|||||||
func = function() E:ResetUI(); end
|
func = function() E:ResetUI(); end
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
local DONATOR_STRING = "";
|
||||||
|
local DEVELOPER_STRING = "";
|
||||||
|
local TESTER_STRING = "";
|
||||||
|
local LINE_BREAK = "\n";
|
||||||
|
local DONATORS = {
|
||||||
|
"Dandruff",
|
||||||
|
"Tobur/Tarilya",
|
||||||
|
"Netu",
|
||||||
|
"Alluren",
|
||||||
|
"Thorgnir",
|
||||||
|
"Emalal",
|
||||||
|
"Bendmeova",
|
||||||
|
"Curl",
|
||||||
|
"Zarac",
|
||||||
|
"Emmo",
|
||||||
|
"Oz",
|
||||||
|
"Hawké",
|
||||||
|
"Aynya",
|
||||||
|
"Tahira",
|
||||||
|
"Karsten Lumbye Thomsen",
|
||||||
|
"Thomas B. aka Pitschiqüü",
|
||||||
|
"Sea Garnet",
|
||||||
|
"Paul Storry",
|
||||||
|
"Azagar",
|
||||||
|
"Archury",
|
||||||
|
"Donhorn",
|
||||||
|
"Woodson Harmon",
|
||||||
|
"Phoenyx",
|
||||||
|
"Feat",
|
||||||
|
"Konungr",
|
||||||
|
"Leyrin",
|
||||||
|
"Dragonsys",
|
||||||
|
"Tkalec",
|
||||||
|
"Paavi",
|
||||||
|
"Giorgio",
|
||||||
|
"Bearscantank",
|
||||||
|
"Eidolic",
|
||||||
|
"Cosmo",
|
||||||
|
"Adorno",
|
||||||
|
"Domoaligato",
|
||||||
|
"Smorg",
|
||||||
|
"Pyrokee",
|
||||||
|
"Portable",
|
||||||
|
"Ithilyn"
|
||||||
|
};
|
||||||
|
|
||||||
|
local DEVELOPERS = {
|
||||||
|
"Tukz",
|
||||||
|
"Haste",
|
||||||
|
"Nightcracker",
|
||||||
|
"Omega1970",
|
||||||
|
"Hydrazine"
|
||||||
|
};
|
||||||
|
|
||||||
|
local TESTERS = {
|
||||||
|
"Tukui Community",
|
||||||
|
"|cffF76ADBSarah|r - For Sarahing",
|
||||||
|
"Affinity",
|
||||||
|
"Modarch",
|
||||||
|
"Bladesdruid",
|
||||||
|
"Tirain",
|
||||||
|
"Phima",
|
||||||
|
"Veiled",
|
||||||
|
"Blazeflack",
|
||||||
|
"Repooc",
|
||||||
|
"Darth Predator",
|
||||||
|
"Alex",
|
||||||
|
"Nidra",
|
||||||
|
"Kurhyus",
|
||||||
|
"BuG",
|
||||||
|
"Yachanay",
|
||||||
|
"Catok"
|
||||||
|
}
|
||||||
|
|
||||||
|
tsort(DONATORS, function(a, b) return a < b end);
|
||||||
|
for _, donatorName in pairs(DONATORS) do
|
||||||
|
tinsert(E.CreditsList, donatorName);
|
||||||
|
DONATOR_STRING = DONATOR_STRING .. LINE_BREAK .. donatorName;
|
||||||
|
end
|
||||||
|
|
||||||
|
tsort(DEVELOPERS, function(a,b) return a < b end);
|
||||||
|
for _, devName in pairs(DEVELOPERS) do
|
||||||
|
tinsert(E.CreditsList, devName);
|
||||||
|
DEVELOPER_STRING = DEVELOPER_STRING .. LINE_BREAK .. devName;
|
||||||
|
end
|
||||||
|
|
||||||
|
tsort(TESTERS, function(a, b) return a < b end)
|
||||||
|
for _, testerName in pairs(TESTERS) do
|
||||||
|
tinsert(E.CreditsList, testerName);
|
||||||
|
TESTER_STRING = TESTER_STRING .. LINE_BREAK .. testerName;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user