View Single Post
01-14-13, 08:29 PM   #13
Billtopia
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 110
so this is what I got... and it works you just inherit the template into your button and set the color by ButtonVar.color = "red" or ButtonVar.color = "green" I know I need to put some checks in for wrong colors

another thing... be gentle, this is my first xml lol

and with your example, I see what you mean as you can customize the textures better in the longer method than trying to use a shortcut...

I have to thank you again for your help

Code:
<?xml version="1.0" encoding="utf-8"?>
<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.blizzard.com/wow/ui/" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
    <Button name="RedGreenButtonTemplate" virtual="true">
        <Size x="40" y="22"/>
        <Layers>
            <Layer level="BACKGROUND">
                <Texture parentKey="Left" file="Interface\Buttons\UI-Panel-Button-Up">
                    <Size x="12" y="22"/>
                    <Anchors>
                        <Anchor point="TOPLEFT"/>
                        <Anchor point="BOTTOMLEFT"/>
                    </Anchors>
                    <TexCoords left="0" right="0.09375" top="0" bottom="0.6875"/>
                </Texture>
                <Texture parentKey="Right" file="Interface\Buttons\UI-Panel-Button-Up">
                    <Size x="12" y="22"/>
                    <Anchors>
                        <Anchor point="TOPRIGHT"/>
                        <Anchor point="BOTTOMRIGHT"/>
                    </Anchors>
                    <TexCoords left="0.53125" right="0.625" top="0" bottom="0.6875"/>
                </Texture>
                <Texture parentKey="Middle" file="Interface\Buttons\UI-Panel-Button-Up">
                    <Size x="12" y="22"/>
                    <Anchors>
                        <Anchor point="TOPLEFT" relativeKey="$parent.Left" relativePoint="TOPRIGHT"/>
                        <Anchor point="BOTTOMRIGHT" relativeKey="$parent.Right" relativePoint="BOTTOMLEFT"/>
                    </Anchors>
                    <TexCoords left="0.09375" right="0.53125" top="0" bottom="0.6875"/>
                </Texture>
            </Layer>
        </Layers>
        <Scripts>
            <OnLoad>
                self.displayedColor = "red"
                self.color = "red"
                self.skins = {}
                self.skins.red = {}
                self.skins.red.up = "Interface\\Buttons\\UI-Panel-Button-Up"
                self.skins.red.down = "Interface\\Buttons\\UI-Panel-Button-Down"
                self.skins.red.highlight = "Interface\\Buttons\\UI-Panel-Button-Highlight"
                
                self.skins.green = {}
                self.skins.green.up = "Interface\\AddOns\\NickAlert\\Green-Panel-Button-Up.tga"
                self.skins.green.down = "Interface\\AddOns\\NickAlert\\Green-Panel-Button-Down.tga"
                self.skins.green.highlight = "Interface\\AddOns\\NickAlert\\Green-Panel-Button-Highlight.tga"
                
            </OnLoad>
            <OnUpdate>
                if self.displayedColor == self.color then
                    return
                end
                self.displayedColor = self.color
                self.Left:SetTexture(self.skins[self.displayedColor].up);
                self.Middle:SetTexture(self.skins[self.displayedColor].up);
                self.Right:SetTexture(self.skins[self.displayedColor].up);
                self:SetHighlightTexture(self.skins[self.displayedColor].highlight);
            </OnUpdate>
            <OnMouseDown>
                if ( self:IsEnabled() ) then
                    self.Left:SetTexture(self.skins[self.displayedColor].down);
                    self.Middle:SetTexture(self.skins[self.displayedColor].down);
                    self.Right:SetTexture(self.skins[self.displayedColor].down);
                end
            </OnMouseDown>
            <OnMouseUp>
                if ( self:IsEnabled() ) then
                    self.Left:SetTexture(self.skins[self.displayedColor].up);
                    self.Middle:SetTexture(self.skins[self.displayedColor].up);
                    self.Right:SetTexture(self.skins[self.displayedColor].up);
                end
            </OnMouseUp>
            <OnShow>
                if ( self:IsEnabled() ) then
                    self.Left:SetTexture(self.skins[self.displayedColor].up);
                    self.Middle:SetTexture(self.skins[self.displayedColor].up);
                    self.Right:SetTexture(self.skins[self.displayedColor].up);
                    self:SetHighlightTexture(self.skins[self.displayedColor].highlight)
                end
            </OnShow>
        </Scripts>
        <ButtonText name="$parentText"/>
        <NormalFont style="GameFontNormal"/>
        <HighlightFont style="GameFontHighlight"/>
        <HighlightTexture inherits="UIPanelButtonHighlightTexture"/>
    </Button>
</Ui>
  Reply With Quote