Skip to content
Myrroddin edited this page Nov 1, 2023 · 3 revisions

LibAboutPanel-2.0 has two APIs: one works like Ackis' LibAboutPanel, and the second is embedded into AceConfig-3.0's options table for an addon.

Create a new About panel like Ackis' LibAboutPanel

@name addon:CreateAboutPanel
@paramsig AddOn[, parent]
@param AddOn the name of which you are attaching the panel. String
@param parent optional AddOn name in Interface Options. String or nil
-- If parent is provided, the panel will be under [+]
-- otherwise, the panel will be a normal AddOn category
@return frame to do as you wish
@usage local aboutFrame = MyAddOn:CreateAboutPanel("MyAddOn", "MyAddOn")
-- OR
MyAddOn:CreateAboutPanel("MyAddOn", "MyAddOn")

Creates a table of an AddOn's ToC fields. Requires AceConfig-3.0 options table

see http://www.wowace.com/addons/ace3/pages/api/ace-config-3-0/

@name addon:AboutOptionsTable
@param AddOn name string whose ToC you want parsed
@return aboutTable suitable for use with AceConfig-3.0
@usage -- assuming options is your top-level table
local options = {} -- put your regular stuff here
options.args.aboutTable = MyAddOn:AboutOptionsTable("MyAddOn")
options.args.aboutTable.order = -1 -- use any number in the hierarchy. -1 means "put it last"
LibStub("AceConfig-3.0"):RegisterOptionsTable("MyAddOn", options)

A full mini addon example showing AceConfig-3.0 and LibAboutPanel-2.0

local MyAddOn = LibStub("AceAddon-3.0"):NewAddon("MyAddOn", "LibAboutPanel-2.0") -- embed LAP2

function MyAddOn:OnInitialize()
    local options = {
        name = "MyAddOn",
        type = "group",
        args = {
            enableAddOn = {
                order = 10,
                name = ENABLE, -- use Blizzard's global string
                type = "toggle",
                get = function() return self.db.profile.enableAddOn end,
                set = function(info, value)
                    self.db.profile.enableAddOn = value
                    if value then 
                        self:OnEnable()
                    else
                        self:OnDisable()
                    end
                end
            }
        }
    }
    
    -- support for LibAboutPanel-2.0
    options.args.aboutTab = self:AboutOptionsTable("MyAddOn")
    options.args.aboutTab.order = -1 -- -1 means "put it last"

    -- Register your options with AceConfigRegistry
    LibStub("AceConfig-3.0"):RegisterOptionsTable("MyAddOn", options)
end