WoW:Using the Interface Options Addons panel

From AddOn Studio
Revision as of 14:15, 13 August 2008 by WoWWiki>Kirkburn (Creating (from email))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

These are the commands that are needed to use Blizzard's Interface Options Addons framework.

As we use a Frame, we can do anything we like within it. Just like doing any other GUI Frame. You can also do sub-categories within these panels as well.

Most of this has been taken from One Blue post on the World of Warcraft Forums (http://forums.worldofwarcraft.com/thread.html?topicId=2968233433&sid=1&pageNo=15 post 294).

Description of the panel parts

panel.name - a required string
is the name of the Category to be listed in the Interface Options - Addon list.
panel.okay - Optional function()
This is a function that is called when the player presses the Okay button.
panel.cancel - Optional function()
This is a function that is called when the player presses the Cancel Button.
panel.default - Optional function()
This is a function that is called when the player presses the Default Button.
panel.parent - an optional string
Name of the parent of the AddOn or group of configuration options. This identifies "panel" as the child of another category. If the parent category doesn't exist, "panel" will be displayed as a regular category.

Example XML with Okay and Cancel buttons

This example is taken from an addon called SC_ChaChing, available from http://wowui.worldofwar.net/?p=mod&m=4934.

The XML frame

All we need to do first is to create the Frame. As we are using the Interface Options - Addon panels, we do not need to use any sizing or movement options.

The OnLoad script calls he Panel_OnLoad() function.


XML Frame
    <Frame name="SC_ChaChingGUIFrame">
        . . .
        <Scripts>
            <OnLoad>
                SC_ChaChingPanel_OnLoad(self);
            </OnLoad>
        </Scripts>
    </Frame>


The Lua function

All we need to do with this function, is to set the name of the panel. Along with the Functions needed for the Okay and Cancel Buttons. Then to call the function that adds the Category to the Interface Options - Addon Category list.


Lua Function
    function SC_ChaChingPanel_OnLoad(panel)
        . . .

        -- Set the name for the Category for the Panel
        --
        panel.name = "SC_ChaChing " .. GetAddOnMetadata("SC_ChaChing", "Version");

        -- When the player clicks okay, run this function.
        --
        panel.okay = function (self) SC_ChaChingPanel_Close(); end;

        -- When the player clicks cancel, run this function.
        --
        panel.cancel = function (self)  SC_ChaChingPanel_CancelOrLoad();  end;

        -- Add the panel to the Interface Options
        --
        InterfaceOptions_AddCategory(panel);
    end