@ -1,13 +1,13 @@
--- 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 1248 2021-02-05 14:27:49Z funkehdude $
-- @release $Id $
local LibStub = LibStub
local LibStub = LibStub
local gui = LibStub ( " AceGUI-3.0 " )
local gui = LibStub ( " AceGUI-3.0 " )
local reg = LibStub ( " AceConfigRegistry-3.0 " )
local reg = LibStub ( " AceConfigRegistry-3.0 " )
local MAJOR , MINOR = " AceConfigDialog-3.0 " , 8 1
local MAJOR , MINOR = " AceConfigDialog-3.0 " , 8 5
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
@ -29,12 +29,6 @@ local pairs, next, select, type, unpack, ipairs = pairs, next, select, type, unp
local tostring , tonumber = tostring , tonumber
local tostring , tonumber = 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
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: NORMAL_FONT_COLOR, ACCEPT, CANCEL
-- GLOBALS: PlaySound, GameFontHighlight, GameFontHighlightSmall, GameFontHighlightLarge
-- GLOBALS: CloseSpecialWindows, InterfaceOptions_AddCategory, geterrorhandler
local emptyTbl = { }
local emptyTbl = { }
--[[
--[[
@ -194,9 +188,8 @@ local function GetOptionsMemberValue(membername, option, options, path, appName,
--We have a function to call
--We have a function to call
local info = new ( )
local info = new ( )
--traverse the options table, picking up the handler and filling the info with the path
--traverse the options table, picking up the handler and filling the info with the path
local handler
local group = options
local group = options
handler = group.handler or handler
local handler = group.handler
for i = 1 , # path do
for i = 1 , # path do
group = GetSubOption ( group , path [ i ] )
group = GetSubOption ( group , path [ i ] )
@ -535,8 +528,7 @@ local function OptionOnMouseLeave(widget, event)
end
end
local function GetFuncName ( option )
local function GetFuncName ( option )
local type = option.type
if option.type == " execute " then
if type == " execute " then
return " func "
return " func "
else
else
return " set "
return " set "
@ -566,28 +558,17 @@ do
end
end
end )
end )
if not frame.SetFixedFrameStrata then -- API capability check (classic check)
frame : SetBackdrop ( {
bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]] ,
edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]] ,
tile = true ,
tileSize = 32 ,
edgeSize = 32 ,
insets = { left = 11 , right = 11 , top = 11 , bottom = 11 } ,
} )
else
local border = CreateFrame ( " Frame " , nil , frame , " DialogBorderOpaqueTemplate " )
local border = CreateFrame ( " Frame " , nil , frame , " DialogBorderOpaqueTemplate " )
border : SetAllPoints ( frame )
border : SetAllPoints ( frame )
frame : SetFixedFrameStrata ( true )
frame : SetFixedFrameStrata ( true )
frame : SetFixedFrameLevel ( true )
frame : SetFixedFrameLevel ( true )
end
local text = frame : CreateFontString ( nil , " ARTWORK " , " GameFontHighlight " )
local text = frame : CreateFontString ( nil , " ARTWORK " , " GameFontHighlight " )
text : SetSize ( 290 , 0 )
text : SetSize ( 290 , 0 )
text : SetPoint ( " TOP " , 0 , - 16 )
text : SetPoint ( " TOP " , 0 , - 16 )
frame.text = text
frame.text = text
local function newButton ( t ext)
local function newButton ( newT ext)
local button = CreateFrame ( " Button " , nil , frame )
local button = CreateFrame ( " Button " , nil , frame )
button : SetSize ( 128 , 21 )
button : SetSize ( 128 , 21 )
button : SetNormalFontObject ( GameFontNormal )
button : SetNormalFontObject ( GameFontNormal )
@ -598,7 +579,7 @@ do
button : GetPushedTexture ( ) : SetTexCoord ( 0.0 , 1.0 , 0.0 , 0.71875 )
button : GetPushedTexture ( ) : SetTexCoord ( 0.0 , 1.0 , 0.0 , 0.71875 )
button : SetHighlightTexture ( 130762 ) -- "Interface\\Buttons\\UI-DialogBox-Button-Highlight"
button : SetHighlightTexture ( 130762 ) -- "Interface\\Buttons\\UI-DialogBox-Button-Highlight"
button : GetHighlightTexture ( ) : SetTexCoord ( 0.0 , 1.0 , 0.0 , 0.71875 )
button : GetHighlightTexture ( ) : SetTexCoord ( 0.0 , 1.0 , 0.0 , 0.71875 )
button : SetText ( t ext)
button : SetText ( newT ext)
return button
return button
end
end
@ -685,7 +666,7 @@ local function ActivateControl(widget, event, ...)
if group [ funcname ] ~= nil then
if group [ funcname ] ~= nil then
func = group [ funcname ]
func = group [ funcname ]
end
end
handler = group.handler or handler
handler = group.handler
confirm = group.confirm
confirm = group.confirm
validate = group.validate
validate = group.validate
for i = 1 , # path do
for i = 1 , # path do
@ -749,7 +730,6 @@ local function ActivateControl(widget, event, ...)
end
end
end
end
local rootframe = user.rootframe
if not validated or type ( validated ) == " string " then
if not validated or type ( validated ) == " string " then
if not validated then
if not validated then
if usage then
if usage then
@ -764,8 +744,8 @@ local function ActivateControl(widget, event, ...)
end
end
-- show validate message
-- show validate message
if rootframe.SetStatusText then
if user. rootframe . SetStatusText then
rootframe: SetStatusText ( validated )
user. rootframe: SetStatusText ( validated )
else
else
validationErrorPopup ( validated )
validationErrorPopup ( validated )
end
end
@ -802,14 +782,14 @@ local function ActivateControl(widget, event, ...)
if type ( confirm ) == " boolean " then
if type ( confirm ) == " boolean " then
if confirm then
if confirm then
if not confirmText then
if not confirmText then
local name, desc = option.name , option.desc
local option_ name, desc = option.name , option.desc
if type ( name) == " function " then
if type ( option_ name) == " function " then
name = name( info )
option_ name = option_ name( info )
end
end
if type ( desc ) == " function " then
if type ( desc ) == " function " then
desc = desc ( info )
desc = desc ( info )
end
end
confirmText = name
confirmText = option_ name
if desc then
if desc then
confirmText = confirmText .. " - " .. desc
confirmText = confirmText .. " - " .. desc
end
end
@ -1151,8 +1131,6 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
--Control to feed
--Control to feed
local control
local control
local name = GetOptionsMemberValue ( " name " , v , options , path , appName )
if v.type == " execute " then
if v.type == " execute " then
local imageCoords = GetOptionsMemberValue ( " imageCoords " , v , options , path , appName )
local imageCoords = GetOptionsMemberValue ( " imageCoords " , v , options , path , appName )
@ -1255,7 +1233,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
end
end
tsort ( sorting , sortTblAsStrings )
tsort ( sorting , sortTblAsStrings )
end
end
for k , value in ipairs ( sorting ) do
for _ , value in ipairs ( sorting ) do
local text = values [ value ]
local text = values [ value ]
local radio = gui : Create ( " CheckBox " )
local radio = gui : Create ( " CheckBox " )
radio : SetLabel ( text )
radio : SetLabel ( text )
@ -1337,8 +1315,8 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
control : SetWidth ( width_multiplier )
control : SetWidth ( width_multiplier )
end
end
--check:SetTriState(v.tristate)
--check:SetTriState(v.tristate)
for i = 1 , # valuesort do
for s = 1 , # valuesort do
local key = valuesort [ i ]
local key = valuesort [ s ]
local value = GetOptionsMemberValue ( " get " , v , options , path , appName , key )
local value = GetOptionsMemberValue ( " get " , v , options , path , appName , key )
control : SetItemValue ( key , value )
control : SetItemValue ( key , value )
end
end
@ -1350,8 +1328,8 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
control : PauseLayout ( )
control : PauseLayout ( )
local width = GetOptionsMemberValue ( " width " , v , options , path , appName )
local width = GetOptionsMemberValue ( " width " , v , options , path , appName )
for i = 1 , # valuesort do
for s = 1 , # valuesort do
local value = valuesort [ i ]
local value = valuesort [ s ]
local text = values [ value ]
local text = values [ value ]
local check = gui : Create ( " CheckBox " )
local check = gui : Create ( " CheckBox " )
check : SetLabel ( text )
check : SetLabel ( text )
@ -1368,7 +1346,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
elseif width == " half " then
elseif width == " half " then
check : SetWidth ( width_multiplier / 2 )
check : SetWidth ( width_multiplier / 2 )
elseif ( type ( width ) == " number " ) then
elseif ( type ( width ) == " number " ) then
c ontrol : SetWidth ( width_multiplier * width )
c heck : SetWidth ( width_multiplier * width )
elseif width == " full " then
elseif width == " full " then
check.width = " fill "
check.width = " fill "
else
else
@ -1438,8 +1416,8 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
end
end
control : SetImageSize ( width , height )
control : SetImageSize ( width , height )
end
end
local w idth = GetOptionsMemberValue ( " width " , v , options , path , appName )
local controlW idth = GetOptionsMemberValue ( " width " , v , options , path , appName )
control.width = not w idth and " fill "
control.width = not controlW idth and " fill "
end
end
--Common Init
--Common Init
@ -1694,29 +1672,29 @@ function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isR
elseif grouptype == " select " then
elseif grouptype == " select " then
local select = gui : Create ( " DropdownGroup " )
local select Group = gui : Create ( " DropdownGroup " )
select : SetTitle ( name )
select Group : SetTitle ( name )
InjectInfo ( select , options , group , path , rootframe , appName )
InjectInfo ( select Group , options , group , path , rootframe , appName )
select : SetCallback ( " OnGroupSelected " , GroupSelected )
select Group : SetCallback ( " OnGroupSelected " , GroupSelected )
local status = AceConfigDialog : GetStatusTable ( appName , path )
local status = AceConfigDialog : GetStatusTable ( appName , path )
if not status.groups then
if not status.groups then
status.groups = { }
status.groups = { }
end
end
select : SetStatusTable ( status.groups )
select Group : SetStatusTable ( status.groups )
local grouplist , orderlist = BuildSelect ( group , options , path , appName )
local grouplist , orderlist = BuildSelect ( group , options , path , appName )
select : SetGroupList ( grouplist , orderlist )
select Group : SetGroupList ( grouplist , orderlist )
select : SetUserData ( " grouplist " , grouplist )
select Group : SetUserData ( " grouplist " , grouplist )
select : SetUserData ( " orderlist " , orderlist )
select Group : SetUserData ( " orderlist " , orderlist )
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 Group : SetGroup ( ( GroupExists ( appName , options , path , status.groups . selected ) and status.groups . selected ) or firstgroup )
end
end
select .width = " fill "
select Group .width = " fill "
select .height = " fill "
select Group .height = " fill "
container : AddChild ( select )
container : AddChild ( select Group )
--assume tree group by default
--assume tree group by default
--if parenttype is tree then this group is already a node on that tree
--if parenttype is tree then this group is already a node on that tree
@ -1944,13 +1922,13 @@ end
-- convert pre-39 BlizOptions structure to the new format
-- convert pre-39 BlizOptions structure to the new format
if oldminor and oldminor < 39 and AceConfigDialog.BlizOptions then
if oldminor and oldminor < 39 and AceConfigDialog.BlizOptions then
local old = AceConfigDialog.BlizOptions
local old = AceConfigDialog.BlizOptions
local new = { }
local new Opt = { }
for key , widget in pairs ( old ) do
for key , widget in pairs ( old ) do
local appName = widget : GetUserData ( " appName " )
local appName = widget : GetUserData ( " appName " )
if not new [ appName ] then new [ appName ] = { } end
if not new Opt [ appName ] then new Opt [ appName ] = { } end
new [ appName ] [ key ] = widget
new Opt [ appName ] [ key ] = widget
end
end
AceConfigDialog.BlizOptions = new
AceConfigDialog.BlizOptions = new Opt
else
else
AceConfigDialog.BlizOptions = AceConfigDialog.BlizOptions or { }
AceConfigDialog.BlizOptions = AceConfigDialog.BlizOptions or { }
end
end
@ -1983,6 +1961,7 @@ end
-- @param parent The parent to use in the interface options tree.
-- @param parent The parent to use in the interface options tree.
-- @param ... The path in the options table to feed into the interface options panel.
-- @param ... The path in the options table to feed into the interface options panel.
-- @return The reference to the frame registered into the Interface Options.
-- @return The reference to the frame registered into the Interface Options.
-- @return The category ID to pass to Settings.OpenToCategory (or InterfaceOptionsFrame_OpenToCategory)
function AceConfigDialog : AddToBlizOptions ( appName , name , parent , ... )
function AceConfigDialog : AddToBlizOptions ( appName , name , parent , ... )
local BlizOptions = AceConfigDialog.BlizOptions
local BlizOptions = AceConfigDialog.BlizOptions
@ -1998,7 +1977,6 @@ function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...)
if not BlizOptions [ appName ] [ key ] then
if not BlizOptions [ appName ] [ key ] then
local group = gui : Create ( " BlizOptionsGroup " )
local group = gui : Create ( " BlizOptionsGroup " )
BlizOptions [ appName ] [ key ] = group
BlizOptions [ appName ] [ key ] = group
group : SetName ( name or appName , parent )
group : SetTitle ( name or appName )
group : SetTitle ( name or appName )
group : SetUserData ( " appName " , appName )
group : SetUserData ( " appName " , appName )
@ -2011,8 +1989,30 @@ function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...)
end
end
group : SetCallback ( " OnShow " , FeedToBlizPanel )
group : SetCallback ( " OnShow " , FeedToBlizPanel )
group : SetCallback ( " OnHide " , ClearBlizPanel )
group : SetCallback ( " OnHide " , ClearBlizPanel )
if Settings and Settings.RegisterCanvasLayoutCategory then
local categoryName = name or appName
if parent then
local category = Settings.GetCategory ( parent )
if not category then
error ( ( " The parent category '%s' was not found " ) : format ( parent ) , 2 )
end
local subcategory = Settings.RegisterCanvasLayoutSubcategory ( category , group.frame , categoryName )
-- force the generated ID to be used for subcategories, as these can have very simple names like "Profiles"
group : SetName ( subcategory.ID , parent )
else
local category = Settings.RegisterCanvasLayoutCategory ( group.frame , categoryName )
-- using appName here would be cleaner, but would not be 100% compatible
-- but for top-level categories it should be fine, as these are typically addon names
category.ID = categoryName
group : SetName ( categoryName , parent )
Settings.RegisterAddOnCategory ( category )
end
else
group : SetName ( name or appName , parent )
InterfaceOptions_AddCategory ( group.frame )
InterfaceOptions_AddCategory ( group.frame )
return group.frame
end
return group.frame , group.frame . name
else
else
error ( ( " %s has already been added to the Blizzard Options Window with the given path " ) : format ( appName ) , 2 )
error ( ( " %s has already been added to the Blizzard Options Window with the given path " ) : format ( appName ) , 2 )
end
end