views:

92

answers:

0

I am writing a UI to a pre-existing addon. Or, more specifically, adding configuration options and trying to take advantage of the Interface Options Addons (IOA) panel. I've been referencing wowwiki, specifically the page that talks about using that panel, but more generally a bunch of pages.

I'm running into a problem that I'm sure is just a result of my inexperience writing addons (I've written a few, but it's a learning experience every time). The basic concept is:

  • Create the main panel - using XML
  • Create sub-items for things that should be visible on the main panel (is, global options) - using XML
  • Create a sub-panel for each child item (configuration category) - using Lua (the number and names of the sub-panels is dynamic)
  • Create sub-items for each sub-panel - using Lua

The things that work are:

  • The main panel shows up in the IOA panel
  • The sub panels show up in the IOA panel, as sub-items of the main panel
  • The textures I put on the sub panels show up on them

The problems I'm having are:

  • If I create the sub-panels as children of the main panel, they show up on top of the main panel
  • If I create the sub-panels are children of the UIParent, they show up on the main screen (visible when the IOA window isn't open
  • Nothing I create in the XML file as a child Frame of the main panel shows up on it

The code I have so far (clipped for brevity) is at the bottom of the message. Any help/suggestions would be more than appreciated. I know there's a lot in the code section, but I wanted to be as clear as I could about what I was doing.

Note that I did post about this on the official Warcraft UI forum, but was unable to get any help there.

embeds.xml

...snip...
<Frame name="MyAddonFrame" parent="UIParent" hidden="false">
  <Scripts>
    <OnLoad>
      self:RegisterEvent("UNIT_TARGET");
      self:RegisterEvent("PLAYER_ENTERING_WORLD");
      MyAddon_OnLoad(self);
    </OnLoad>
    <OnEvent function="MyAddon_OnEvent" />
    </Scripts>

    <Frames>
      <Frame parent="MyAddonFrame" inherits="UIDropDownMenuTemplate">
        <Frames>
          <Button name="MyAddon_MacroSelectDropdownButton">
            <Anchors>
              <Anchor point="CENTER"/>
            </Anchors>

            <Scripts>
              <OnLoad>
                UIDropDownMenu_Initialize(this,
                MyAddon_MacroSelectDropdown_OnLoad);
              </OnLoad>
              <OnClick>
                MyAddon_MacroSelectDropdownButton_OnClick();
              </OnClick>
            </Scripts>
          </Button>
          <MessageFrame>
            <Anchors>
              <Anchor point="CENTER"/>
            </Anchors>
          <FontString text="Message Frame"/>
        </MessageFrame>
      </Frames>
    </Frame>
  </Frames>
</Frame>
...snip...

Lua Code

...snip...
function MyAddon_OnLoad(panel)
    MyAddon_CreateOptionsPanel(panel);
    MyAddon_ConsoleMessage("Loaded MyAddon: " .. tostring(panel));
end

function MyAddon_CreateOptionsPanel(panel)
    panel.name = "MyAddon " .. GetAddOnMetadata("MyAddon", "Version");  -- Set the name for the Category for the Panel
    panel.okay = function (self) MyAddonFrame_Close(); end;                 -- When the player clicks okay, run this function.
    panel.cancel = function (self)  MyAddonFrame_CancelOrLoad();  end;  -- When the player clicks cancel, run this function.
    InterfaceOptions_AddCategory(panel);                                    -- Add the panel to the Interface Options

    for name,text in pairs(ConfigData) do
        MyAddon_CreateMacroPanel(name, panel, panel.name);
    end
end

function MyAddon_CreateMacroPanel(macroName, parent, parentName)
    MyAddon_ConsoleMessage("Added macro option pane: " .. macroName);
    panel = CreateFrame( "Frame", "MyAddon_MacroPanel_" .. macroName, parent);
    panel.name = macroName;
    panel.parent = parentName;
    InterfaceOptions_AddCategory(panel);

    -- create a backdrop so we can see that the panel is created
    panel:SetFrameStrata("BACKGROUND");
    panel:SetWidth(128); -- Set these to whatever height/width is needed 
    panel:SetHeight(64); -- for your Texture

    local t = panel:CreateTexture(nil,"BACKGROUND");
    t:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Factions.blp");
    t:SetAllPoints(panel);
    panel.texture = t;

    panel:SetPoint("CENTER",0,0);
end



-- MyAddon_MacroSelectDropdown
function MyAddon_MacroSelectDropdown_OnLoad()
    info            = {};
    info.text       = "Auto";
    info.value      = "Auto";
    -- FunctionCalledWhenOptionIsClicked 
    info.func       = function (self) MyAddon_SetMacroAuto(); end;
    UIDropDownMenu_AddButton(info);
    for index,macro in pairs(ConfigData) do
        info.text       = name;
        info.value      = name;
        -- FunctionCalledWhenOptionIsClicked 
        info.func       = function (self) MyAddon_SetMacroByName(name); end;
        UIDropDownMenu_AddButton(info);
    end
    -- can also be done as function() FunctionCalledWhenOptionIsClicked() end;
end
...snip...