Thread Tools Display Modes
04/15/14, 08:09 AM   #1
zireko
 
zireko's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 63
Help with my xml coding

This is my xml code so far. What I'm trying to do is have a box with a list of quests in it and later in my lua I want to make each quest clickable so that the text well turn to a dark gray and if they click it again it'll go back to the original color. I currently have just two quest in it. How I want it to look is like this example below.

A Pinch of Sugar
Cast Adrift

My question is if my code has errors and if so what do I need to do to fix them so far?

Lua Code:
  1. <GuiXml>
  2.     <Controls>
  3.         <TopLevelControl name="QuestMaster" mouseEnabled="true" movable="true">
  4.             <Dimensions x="300" y="400" />
  5.             <Anchor point="CENTER" />
  6.  
  7.             <OnUpdate>
  8.                 QuestMasterUpdate()
  9.             </OnUpdate>
  10.  
  11.             <OnMouseDown>
  12.                 QuestMasterReset()
  13.             </OnMouseDown>
  14.  
  15.             <Controls>
  16.                 <Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" />
  17.                 <Label name="$(parent)" font="ZoFontAnnounceSmall" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="A Pinch of Sugar">
  18.                 <Label name="$(parent)" font="ZoFontWindowSmall" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="Cast Adrift">
  19.                     <AnchorFill />
  20.                 </Label>
  21.             </Controls>
  22.         </TopLevelControl>
  23.     </Controls>
  24. </GuiXml>
  Reply With Quote
04/15/14, 09:04 AM   #2
Ouijan
 
Ouijan's Avatar
Join Date: Apr 2014
Posts: 13
I can't test it right now (Server is down) but I'm pretty sure u need to close your first <label> tag and add an <AnchorFill /> to it To display them they way you want you will have to look into anchors and offsets you could either just offset them each a certain distance OR anchor the top of one to the bottom of the one above it which is a bit trickier

As for the functions what do you plan to do with QuestMasterUpdate() and QuestMasterReset()?

Edit: also you need to give your <Label>s different names currently both of them will be named "QuestMaster"
  Reply With Quote
04/15/14, 09:23 AM   #3
zireko
 
zireko's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 63
Here is my updated code so far. And as for the QuestMasterUpdate & QuestMasterReset I'm not sure yet I want to make the text change colors to dark gray and if they click on it again turn back to the original color. I don't know exactly if I need to pull the update and reset out or if they can be used for the text color.

Lua Code:
  1. <GuiXml>
  2.     <Controls>
  3.         <TopLevelControl name="QuestMaster" mouseEnabled="true" movable="true">
  4.             <Dimensions x="300" y="400" />
  5.             <Anchor point="CENTER" />
  6.  
  7.             <OnUpdate>
  8.                 QuestMasterUpdate()
  9.             </OnUpdate>
  10.  
  11.             <OnMouseDown>
  12.                 QuestMasterReset()
  13.             </OnMouseDown>
  14.  
  15.             <Controls>
  16.                 <Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" />
  17.                 <Label name="$(parent)" font="ZoFontAnnounceSmall" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="A Pinch of Sugar">
  18.                     <AnchorFill />
  19.                 </Label>
  20.                 <Label name="$(parent)" font="ZoFontWindowSmall" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="Cast Adrift">
  21.                     <AnchorFill />
  22.                 </Label>
  23.             </Controls>
  24.         </TopLevelControl>
  25.     </Controls>
  26. </GuiXml>
  Reply With Quote
04/15/14, 09:23 AM   #4
Total-Khaos
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 6
Originally Posted by Ouijan View Post
I can't test it right now (Server is down) but I'm pretty sure u need to close your first <label> tag and add an <AnchorFill /> to it To display them they way you want you will have to look into anchors and offsets you could either just offset them each a certain distance OR anchor the top of one to the bottom of the one above it which is a bit trickier

As for the functions what do you plan to do with QuestMasterUpdate() and QuestMasterReset()?

Edit: also you need to give your <Label>s different names currently both of them will be named "QuestMaster"
You saw the same things I did.
  Reply With Quote
04/15/14, 10:10 AM   #5
Ouijan
 
Ouijan's Avatar
Join Date: Apr 2014
Posts: 13
Originally Posted by Total-Khaos View Post
You saw the same things I did.
tehe

@Zireko
Cool man getting there! you need to give EVERYTHING on the screen a different name otherwise the game will have issues drawing it (learnt from experience xD) so where you have each <Label name="$(parent)"> it is essentially saying <Label name="QuestMaster"> because the parent frame of each label is your TopLevelControl which is named "QuestMaster". Currently your backdrop will be named it "QuestMasterBG" which is good, so stick something after the "$(parent)" in your <Label>s

The name of each frame is its identifier, you cant have two frames with the same name or the ui freaks out and doesn't know which frame to do what to :P

For the functions you only really need to have one function in the <OnMouseDown> (or <OnMouseUp> your choice) to toggle between two colours when clicked at the moment you don't need an OnUpdate
  Reply With Quote
04/15/14, 10:21 AM   #6
zireko
 
zireko's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 63
Ok I think I understand. So I've updated the code again. How does it look now?

Lua Code:
  1. <GuiXml>
  2.     <Controls>
  3.         <TopLevelControl name="QuestMaster" mouseEnabled="true" movable="true">
  4.             <Dimensions x="300" y="400" />
  5.             <Anchor point="CENTER" />        
  6.  
  7.             <OnMouseDown>
  8.                 QuestMasterReset()
  9.             </OnMouseDown>
  10.  
  11.             <Controls>
  12.                 <Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" />
  13.                 <Label name="$(parent)quest1" font="ZoFontAnnounceSmall" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="A Pinch of Sugar">
  14.                     <AnchorFill />
  15.                 </Label>
  16.                 <Label name="$(parent)quest2" font="ZoFontWindowSmall" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="Cast Adrift">
  17.                     <AnchorFill />
  18.                 </Label>
  19.             </Controls>
  20.         </TopLevelControl>
  21.     </Controls>
  22. </GuiXml>
  Reply With Quote
04/15/14, 10:40 AM   #7
zireko
 
zireko's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 63
This is the little lua I have currently I know it's geared for the counter from the tutorial. But I have taken out the Update part because I do not need it. What I'm asking here is how do I change this code so that instead of reset it would change the color to gray text instead.

Lua Code:
  1. local counter = 1
  2.  
  3. function QuestMasterReset()
  4.     counter = 0
  5. end
  Reply With Quote
04/15/14, 10:56 AM   #8
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Format is:
labelname:SetColor(red, green, blue, alpha)

Lua Code:
  1. QuestMasterquest1:SetColor(128, 128, 128, 1)

For colors see http://www.colorpicker.com/.
Alpha is number between 0 and 1. Where 0 means transparent and 1 fully visible.

Last edited by Garkin : 04/15/14 at 11:00 AM.
  Reply With Quote
04/15/14, 10:59 AM   #9
Ouijan
 
Ouijan's Avatar
Join Date: Apr 2014
Posts: 13
I'm not sure but if you go looking in the controls API there is likely to be a SetColor() or something and you will need to change the <OnMouseDown> to be inside each <label> At the moment it will run when you click the frame not each label individually. You will also need to give your function the name of which label you have clicked on so it knows which one to change, have a look at sending parameters to functions in lua for that

It's also a good plan to pre think things before you jump into coding. When I click this what exactly do I want to happen behind the scenes it saves a lot of time later

Most of what your looking for can be found in a quick google search you'll learn a lot quicker and feel like you've accomplished more if ya go digging
  Reply With Quote
04/15/14, 01:46 PM   #10
zireko
 
zireko's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 63
This is my xml and lua. I will show a few images of what I'm getting.

XML
Lua Code:
  1. <GuiXml>
  2.     <Controls>
  3.         <TopLevelControl name="QuestMaster" mouseEnabled="true" movable="true">
  4.             <Dimensions x="300" y="400" />
  5.             <Anchor point="CENTER" />        
  6.  
  7.             <OnMouseDown>
  8.                 QuestMasterReset()
  9.             </OnMouseDown>
  10.  
  11.             <Controls>
  12.                 <Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" />
  13.                 <Label name="$(parent)quest1" font="ZoFontAnnounceSmall" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="A Pinch of Sugar">
  14.                     <AnchorFill />
  15.                 </Label>
  16.                 <Label name="$(parent)quest2" font="ZoFontWindowSmall" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="Cast Adrift">
  17.                     <AnchorFill />
  18.                 </Label>
  19.             </Controls>
  20.         </TopLevelControl>
  21.     </Controls>
  22. </GuiXml>

LUA
Lua Code:
  1. QuestMasterquest1:SetColor(128, 128, 128, 1)
Attached Thumbnails
Click image for larger version

Name:	e1.jpg
Views:	467
Size:	455.2 KB
ID:	141  Click image for larger version

Name:	e2.jpg
Views:	490
Size:	403.2 KB
ID:	142  
  Reply With Quote
04/15/14, 02:10 PM   #11
zireko
 
zireko's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 63
Originally Posted by zireko View Post
This is my xml and lua. I will show a few images of what I'm getting.
Also when I click on text it does not change I used the code the way I thought it might go. But something feels like its missing and I don't know what it is.
  Reply With Quote
04/15/14, 02:16 PM   #12
GetBackYouPansy
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 7
Originally Posted by Ouijan View Post
You will also need to give your function the name of which label you have clicked on so it knows which one to change, have a look at sending parameters to functions in lua for that
The On* event script blocks defined in XML have a "local self" so you don't need to pass names around, you can pass the thing itself

See the ScriptArguments at http://wiki.esoui.com/UI_XML#OnUpdate for example, or an example in the wild here: link.

Last edited by GetBackYouPansy : 04/15/14 at 02:19 PM.
  Reply With Quote
04/15/14, 03:32 PM   #13
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Please check this addon: http://www.esoui.com/downloads/info2...AddonTest.html

This addon is well commented tutorial for beginners. Just download it and read through the code.
  Reply With Quote
04/15/14, 04:17 PM   #14
zireko
 
zireko's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 63
Originally Posted by Garkin View Post
Please check this addon: http://www.esoui.com/downloads/info2...AddonTest.html

This addon is well commented tutorial for beginners. Just download it and read through the code.
Okies thank you. I just wish some people would make a few tutorials making a few different addons for eso. I tend to learn a lot better when I hear someone explaining things to me. This is as close as I can get currently so I'm reading through the insAddon coding a few times over and trying to comprehend it. Thanks again for the info and all the help.

Banana Attack lol sorry had to.
  Reply With Quote
04/15/14, 06:27 PM   #15
Ouijan
 
Ouijan's Avatar
Join Date: Apr 2014
Posts: 13
Originally Posted by GetBackYouPansy View Post
The On* event script blocks defined in XML have a "local self" so you don't need to pass names around, you can pass the thing itself

See the ScriptArguments at http://wiki.esoui.com/UI_XML#OnUpdate for example, or an example in the wild here: link.
Thanks GetBack, I'll have to re-investigate this I thought I had troubles before with the self referencing my addon table rather each individual frame From memory I was calling AddonName:Function(...) in an OnMoveStop and it would return my AddonName table. :P so I defined a FrameName:Function(...) as a work around. I might post my own thread if I get stuck

Edit// just had a look at your example and I get ya now xD

Last edited by Ouijan : 04/15/14 at 06:33 PM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Help with my xml coding


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