Thread Tools Display Modes
11-22-14, 10:21 PM   #1
Zireko
An Aku'mai Servant
Join Date: Nov 2014
Posts: 38
I Need some Help On an Addon I'm working On

Currently I'm just practicing and trying to build a very simple addon called ZBar. I will later anchor it to the bottom center of the screen. this addon is just supposed to add an image that can be moved around on the screen currently. It's a custom image and I've converted it to tga using power of 2 like I've read, (tga img size is 512x512). I'm not sure why the addon isn't currently showing up. I'm still very new to coding and I'm learning wows API I came from building a few addons for Elder Scrolls Online. Any way here is the current code I have and I've attached the addon I've built so far below.

Toc File
Lua Code:
  1. ## Interface: 60000
  2. ## Title: ZBar
  3. ## Notes: A simple skin addon that allows you to place your ui into it.
  4. ## Author: Zireko
  5. ## Version: 1.0
  6.  
  7. ZBar.xml

Xml File
Lua Code:
  1. <Ui xmlns="http://www.blizzard.com/wow/ui/"
  2.                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.                    xsi:schemaLocation="http://www.blizzard.com/wow/ui/
  4.                   ..\..\FrameXML\UI.xsd">
  5.     <frame name="barAWindow" parent="UIParent" moveable="true">
  6.         <Size x="800" y="300"/>
  7.             <Anchors>
  8.                 <Anchor point="CENTER">
  9.             </Anchors>
  10.             <Layers>
  11.                 <Layer level="BACKGROUND">
  12.                     <Texture file="ZBar\ZBarImgs\barA.tga" setAllPoints="true"/>
  13.                 </Layer>
  14.             </Layers>
  15.     <Scripts>
  16.         <OnMouseDown>
  17.             self:StartMoving()
  18.         </OnMouseDown>
  19.         <OnMouseUp>
  20.             self:StopMoving()
  21.         </OnMouseUp>
  22.     </Scripts>
  23.     </frame>
  24. </Ui>

My question for my code is simply "What am I missing and why do I need it?" please explain in full detail so I may learn more thoroughly.
Attached Files
File Type: zip ZBar.zip (176.6 KB, 197 views)
  Reply With Quote
11-22-14, 11:26 PM   #2
Zireko
An Aku'mai Servant
Join Date: Nov 2014
Posts: 38
Never Mind I figured out Most of it on my own. I'm still going to keep working on this if you would like to see my code now this is what I have and it made everything work correctly. I switched to using blp instead of a tga image.

XML
Lua Code:
  1. <Ui xmlns="http://www.blizzard.com/wow/ui/"
  2.                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.                    xsi:schemaLocation="http://www.blizzard.com/wow/ui/
  4.                   ..\..\FrameXML\UI.xsd">
  5.     <Frame name="barAWindow" parent="UIParent" movable="true" alpha="0.8">
  6.         <Size x="1800" y="300"/>
  7.             <Anchors>
  8.                 <Anchor point="CENTER"/>
  9.             </Anchors>
  10.             <Layers>
  11.                 <Layer level="BACKGROUND">
  12.                     <Texture file="Interface\AddOns\ZBar\ZBarImgs\barA.blp" setAllPoints="true"/>
  13.                 </Layer>
  14.             </Layers>
  15.     <Scripts>
  16.         <OnMouseDown>
  17.             self:StartMoving()
  18.         </OnMouseDown>
  19.         <OnMouseUp>
  20.             self:StopMovingOrSizing()
  21.         </OnMouseUp>
  22.     </Scripts>
  23.     </Frame>
  24. </Ui>

I'll be adding more to this as I go a long and making the main anchor at the bottom of the screen and get rid of the self:StartMoving() function / scripts , I'm just using this to get a general idea of where my addon is before I anchor it down.
  Reply With Quote
11-23-14, 01:20 AM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Unless you're really in love with XML from some prior programming experience, I'd suggest writing your addon in Lua only. It's much less verbose, and reduces the need for you to learn two separate syntaxes:

Code:
local frame = CreateFrame("Frame", "barAWindow", UIParent)
frame:SetSize(1800, 300)
frame:SetPoint("CENTER")
frame:SetAlpha(0.8)

local bg = frame:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints(true)
bg:SetTexture("Interface\\AddOns\\ZBar\\ZBarImgs\\barA")

frame:SetMovable(true)
frame:SetScript("OnMouseDown", frame.StartMoving)
frame:SetScript("OnMouseUp", frame.StopMovingOrSizing)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-23-14, 01:48 AM   #4
Zireko
An Aku'mai Servant
Join Date: Nov 2014
Posts: 38
Originally Posted by Phanx View Post
Unless you're really in love with XML from some prior programming experience, I'd suggest writing your addon in Lua only. It's much less verbose, and reduces the need for you to learn two separate syntaxes:
It's not that I'm more interested in xml. It's simply the fact most tutorials and information I find is in xml and not lua. I would really like it much more to do it in lua code strictly but most of the learning information focuses deeply on xml instead of lua. But I've got the code working pretty good right now however the mini map and chat window sometime fall behind my image that I'm using. I'm using <Layer level="BACKGROUND"> which I thought was the furthest background you can get but for some reasone when I move the mini map or chat system around my addon is layred infront of it and not in the deepst background. It would be helpfull if you could show me how to fix this in xml and how to code it in lua instead of xml. Here is my current xml code.

XML
Lua Code:
  1. <Ui xmlns="http://www.blizzard.com/wow/ui/"
  2.                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.                    xsi:schemaLocation="http://www.blizzard.com/wow/ui/
  4.                   ..\..\FrameXML\UI.xsd">
  5.     <Frame name="barAWindow" parent="UIParent" movable="true" alpha="0.8">
  6.         <Size x="1800" y="300"/>
  7.             <Anchors>
  8.                 <Anchor point="CENTER"/>
  9.             </Anchors>
  10.             <Layers>
  11.                 <Layer level="BACKGROUND">
  12.                     <Texture file="Interface\AddOns\ZBar\ZBarImgs\barA.blp" setAllPoints="true"/>
  13.                 </Layer>
  14.             </Layers>
  15.     <Scripts>
  16.         <OnMouseDown>
  17.             self:StartMoving()
  18.         </OnMouseDown>
  19.         <OnMouseUp>
  20.             self:StopMovingOrSizing()
  21.         </OnMouseUp>
  22.     </Scripts>
  23.     </Frame>
  24. </Ui>
  Reply With Quote
11-23-14, 04:14 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The Lua code I posted is a direct conversion of the XML code in your previous post.

Originally Posted by Zireko View Post
the mini map and chat window sometime fall behind my image that I'm using. I'm using <Layer level="BACKGROUND"> which I thought was the furthest background you can get but for some reasone when I move the mini map or chat system around my addon is layred infront of it and not in the deepst background.
You may want to read the Wowpedia page about layers. Draw layers only affect the relative layering of the regions attached to the same parent frame -- they don't affect whether one frame is drawn in front of or behind other frames. To change that, you need to change the strata of the frame itself.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-23-14, 12:37 PM   #6
Zireko
An Aku'mai Servant
Join Date: Nov 2014
Posts: 38
How do I lock a frame with right mouse click. I am trying to look it up but not finding anything yet. I want the user to be able to move the frame where they want it then they can right click or middle click to lock they frame in place so they don't accidently move it again afterwards. If they want to move it again the can right click or middle click the frame to unlock it. Here is the code I have currently and Phanx ty I forgot all about the frameStrata to push the frame to the furthest background.

XML
Lua Code:
  1. <Ui xmlns="http://www.blizzard.com/wow/ui/"
  2.                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.                    xsi:schemaLocation="http://www.blizzard.com/wow/ui/
  4.                   ..\..\FrameXML\UI.xsd">
  5.     <Frame name="barAWindow" frameStrata="BACKGROUND" parent="UIParent" movable="true" alpha="0.8">
  6.         <Size x="600" y="300"/>
  7.             <Anchors>
  8.                 <Anchor point="BOTTOM"/>
  9.             </Anchors>
  10.             <Layers>
  11.                 <Layer level="BACKGROUND">
  12.                     <Texture file="Interface\AddOns\ZBar\ZBarImgs\barA.blp" setAllPoints="true"/>
  13.                 </Layer>
  14.             </Layers>
  15.     <Scripts>
  16.         <OnMouseDown>
  17.             self:StartMoving()
  18.         </OnMouseDown>
  19.         <OnMouseUp>
  20.             self:StopMovingOrSizing()
  21.         </OnMouseUp>
  22.     </Scripts>
  23.     </Frame>
  24. </Ui>
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » I Need some Help On an Addon I'm working On


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off