WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   XML question (https://www.wowinterface.com/forums/showthread.php?t=598)

LaRIC 04-10-05 02:15 AM

XML question
 
Is there some sort of tutorial that explains the syntax of the XML and what it does?

I have managed to write my LUA code as that was plain and simple but now I want a config window for my addon. This seems like the real pain.


I need something like

a couple of checkboxes.
An edit line
and a color setting. (something like the one from the channels color setting)

An ok and a cancel button.

Hopefully someone can point me in the right direction on where to find information or someone can make my simple page above for me.

Michael

Gello 04-10-05 10:20 AM

This one you may have seen already so not sure it's much help: http://wow.mmhell.com/articles/inter...rst_addon.html

Basically goes through and describes how to make a clock window.

A lot can be learned going through the XML files on others' mods. XML seems to be totally implementation specific so unfortunately generic mods won't help at all. I'm not even sure why XML is considered a language since it's more a convention. Some things I wish I knew right off but didn't (hence the poor spaghetti xml of my mods):

- Go here: http://www.cosmosui.org/vjeux/ and grab WinMPQ and unpack the FrameXML directory in interface.mpq someplace away from your install. It's an invaluable resource to poke around and see how things are declared and used. It contains all the default .lua and .xml of the interface.

- From the same site above grab the BLP2 viewer also. When you Load MPQ on the interface.mpq, you can see all the interface textures and use them in your mod by name.

- If you plan to create many of one control, it's better to make a template for it and reuse that template. This is surprisingly easy.

For instance you can declare this:
Code:

<CheckButton name="MyButtonTemplate" virtual="true">
        <Size>
                <AbsDimension x="28" y="28"/>
        </Size>
        <Layers>
                <Layer level="BACKGROUND">
                        <Texture name="$parentIcon"/>
                </Layer>
        </Layers>
        <Scripts>
                <OnEnter>
                        MyButton_OnEnter();
                </OnEnter>
                <OnLeave>
                        GameTooltip:Hide();
                </OnLeave>
                <OnClick>
                        MyButton_OnClick();
                </OnClick>
        </Scripts>
        <NormalTexture name="$parentNormalTexture" />
        <PushedTexture file="Interface\Buttons\UI-Quickslot-Depress"/>
</CheckButton>

And instead of copy-pasting that for every button, you can use the template for each button with inherits="MyButtonTemplate":
Code:

<CheckButton name="MyFirstButton" inherits="MyButtonTemplate">
        <Anchors>
                <Anchor point="TOPLEFT"/> <- only attribute likely to change
        </Anchors>
</CheckButton>

- Only really applicable to multiple controls like above, but if you declare an "id=x" in the control's tag, you can use index = this:GetID(id) in the lua, and index will be the x you defined in the control.

Code:

<CheckButton name="MyFirstButton" inherits="MyButtonTemplate" id="1">
        <Anchors>
                <Anchor point="TOPLEFT"/>
        </Anchors>
</CheckButton>

<CheckButton name="MySecondButton" inherits="MyButtonTemplate" id="2">
        <Anchors>
                <Anchor point="BOTTOMLEFT"/>
        </Anchors>
</CheckButton>

Then in the lua to use the functions described in the template:
Code:

function MyButton_OnEnter()
    local id = this:GetID();
    GameTooltip_SetDefaultAnchor(GameTooltip,this);
    GameTooltip:SetText("This is button "..id);
    GameTooltip:Show();
end

function MyButton_OnClick()
    local id = this:GetID();
    message("You clicked button #"..id);
end

Doesn't help much starting out but definitely check the .xml files in interface.mpq and others' mods.

Inokis 04-10-05 12:47 PM

Thanks for that Gello. I've been trying to get checkboxes to show in a window for a bit now and haven't been able to do it yet. I'll be fiddling with your examples to see if i can get them working.

LaRIC 04-10-05 03:37 PM

Thanks
 
thanks alot for a ll the info.. Will take a look at it and figure out how to make a nice config screen.

Michael

Suppi 12-21-06 03:23 AM

Hi,

writing my own Addon i used this for the checkbuttons in my configuration frame and i works really fine. But as the programming gets further I have to put some sliders on this frame and to to not blow up my XML file I tried to create a virtual Slider-Template which I used on my Configuration frame, but this won't work as expected. Is i possible that I can't create suche templates for Sliders?


All times are GMT -6. The time now is 12:48 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI