Thread Tools Display Modes
08-24-07, 04:34 PM   #1
Arachiel
A Murloc Raider
 
Arachiel's Avatar
Join Date: Aug 2007
Posts: 5
The Noob says: Huh? What is a SecureUnitButtonTemplate?

Hello!

First of all: My deep respect to all you who already programmed an Addon and thank you for your great work!
You inspired me to try programming myself, even though I didn't have ANY idea of XML, LUA or ANY programming language at all (i still don't get it -_-).
To cut things short: I sat down with all guidance gained and tried programming an Addon which would add a button to the UI that could be pressed to set "focus" on the current target or does nothing if the player didn't have a target. If pressed again the player would "clear" his "focus".
After hours messing with XML and Photoshop (completing the needed graphics and setting up the XML file) I finally started to work on (an until then empty) LUA file and though:
"Oookeeh. All you need is the proper API function and then find out how it works. Let's search WoWWiki for the API-List."
"Aaah, there it is. FocusUnit("unit") - Perfect! ....... What does "PROTECTED" mean?"
"AIIIEEE!!! Does that mean I can't program the button, because of some stupid bots?!?"
"AAAIIIIIEEEE!!! All my labor was in vain!?!?"
"Wait a second - there is a link to 'API Secure Templates'."
"...."
".... I don't get it." *bursts into tears*

Although my tears have dried by now, I still don't have the slightest idea how to go on with the addon - supposed i CAN continue!
My question would be: Is it possible to make the Addon I planned? How do I use the SecureUnitButtonTemplate? I couldn't make that out from WoWWiki alone.

I'm sorry to bother you all with my inferiority, but I just didn't want the whole day to go to waste. Thank you for the trouble reading my post. >_<



PS: I don't know wether this interests or bugs you but here is the XML I made so far.
<Script file="FocusEye.lua"/>

<Button name="FocusButton" parent="UIParent" toplevel="true" hidden="false" enableMouse="true" movable="true">
<NormalTexture file="Interface\AddOns\FocusEye\Focussed"/>
<DisabledTexture file="Interface\AddOns\FocusEye\Clear"/>
<Size>
<AbsDimension x="20" y="20"/>
</Size>
<Anchors>
<Anchor point="TOPRIGHT"/>
<Offset>
<AbsDimension x="-200" y="-200"/>
</Offset>
</Anchor>
</Anchors>

<Scripts>
<OnClick>
FocusToggle();
</OnClick>
</Scripts>

</Button>
The LUA didn't develop at all, since I don't know which function to use/since I'm afraid everything was good for nothing...

function FocusToggle()
if
elseif
end
end
Lousy, right? Sorry to get on your nerves.

PPS: Sorry about my warped english!

Last edited by Arachiel : 08-24-07 at 04:38 PM.
  Reply With Quote
08-25-07, 07:38 AM   #2
mulesh
A Chromatic Dragonspawn
 
mulesh's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 193
You could do this soooo much easier by making a simple focus macro.

Code:
/clearfocus [button:RightButton] [target=focus, dead] [target=focus, noexists]
/focus [target=focus, noexists]
If you have a target it will make it your focus, if your focus doesnt exist it will clear, if your focus is dead it will clear, if you right-click it will clear.
__________________
"Don"t tase me bro!" ~ Andrew Meyer
  Reply With Quote
08-25-07, 12:14 PM   #3
Arachiel
A Murloc Raider
 
Arachiel's Avatar
Join Date: Aug 2007
Posts: 5
Why thank you!
Yet that is my current status. The reason why I want to make this an AddOn is the quicker dispersion among friends and the fact I can make the Button look different if "focus" is active or not. Also I want to do it as a exercise to learn programming WoW-Stuff. ^-^

By the way - i refrained from using the already postet XML, since I'm starting to understand the SecureUnitButtonTemplate (yes, my working day was boring). I will edit this post, when I can show my progress without ashaming myself again.
Thank you for your answer Mulesh!

^.^
  Reply With Quote
08-25-07, 05:19 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I'm not a coder, but I was under the impression you had to use XML for secure buttons - is this incorrect?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
08-25-07, 06:17 PM   #5
mulesh
A Chromatic Dragonspawn
 
mulesh's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 193
I think this will work, havent play-tested it, but I have a good feeling

XML file:
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">

<Script file="FocusEye.lua"/>

<Button name="FocusButton" parent="UIParent" toplevel="true" hidden="false" enableMouse="true" movable="true" inherits="SecureActionButtonTemplate">
  <Layers>
    <Layer level="ARTWORK">
      <Texture name="MyTexture" file="Interface\AddOns\FocusEye\Clear"/>
    </Layer>
  </Layers>
  <Size>
    <AbsDimension x="20" y="20"/>
  </Size>
  <Anchors>
    <Anchor point="TOPRIGHT"/>
      <Offset>
        <AbsDimension x="-200" y="-200"/>
      </Offset>
    </Anchor>
  </Anchors>

  <Scripts>
    <OnLoad>this:RegisterForDrag("LeftButton"); thisRegisterForClicks("LeftButtonUp");
    <OnClick>FocusToggle();</OnClick>
    <OnDragStart>this:StartMoving();</OnDragStart>
    <OnDragStop>this:StopMovingOrSizing();</OnDragStop>
    <OnEnter>FocusEnter();</OnEnter>
    <OnLeave>FocusLeave();</OnLeave>
  </Scripts>

</Button>
</Ui>
LUA file:
Code:
function FocusToggle()
  if UnitExists("focus") then
    FocusUnit("none");
    FocusButton:SetTexute(Interface\AddOns\FocusEye\Clear);
  elseif UnitExists("target") then
    FocusUnit("target");
    FocusButton:SetTexture(Interface\AddOns\FocusEye\Focussed);
  end
end

function FocusEnter()
  GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
  GameTooltip:SetText("Focus\nLeft-Click to set focus");
  GameTooltip:Show();
end

function FocusLeave()
  GameTooltip:Hide();
end
I added some tooltip code and some script events for dragging.

Good luck!
__________________
"Don"t tase me bro!" ~ Andrew Meyer

Last edited by mulesh : 08-25-07 at 06:25 PM.
  Reply With Quote
08-28-07, 02:39 PM   #6
Arachiel
A Murloc Raider
 
Arachiel's Avatar
Join Date: Aug 2007
Posts: 5
Thank you for your help, Mulesh.
Alas, as I mentioned earlier the "FocusUnit()" command does not work anymore. Therefore your beautiful coding has been for nougth. T_T
I also think Seerah is right. I tried messing with the LUA again, but nothing good came from it. Therefor I simply left it blank and voilá: The XML worked even without it.

The last few days I spend my (little) free time trying to understand the Templates and I think, the UnitTemplate only acts as a UnitFrame (I am possibly wrong T_T) and can only make the current target my focus. But until now I haven't found any way to clear focus via UnitTemplate.

Instead I stumbled across the "Macro"-Attribute for the ActionTemplate.
I am using the following Macro to set and clear my focus:
Code:
/focus [target=focus, noexists]; [target=none, noexists][target=none]
When I click the Button and no focus is set, it will be set. If focus=true, it will clear focus.

I embedded this macro into the ActionTemplate...
Code:
<Button name="FocusButton" inherits="SecureActionButtonTemplate">
	<Size>
		<AbsDimension x="36" y="36"/>
	</Size>
	<Anchors>
		<Anchor point="CENTER"/>
	</Anchors>
	<NormalTexture>
		<Color r="1" g="0" b="0" a="0.5"/>
	</NormalTexture>
	<Scripts>
		<OnLoad>
        FocusButton:SetAttribute("type1", "macro")			
        FocusButton:SetAttribute("macrotext", "/focus [target=focus, noexists]; [target=none, noexists][target=none]")
        </OnLoad>
	</Scripts>
</Button>
To my surprise, it did not work! Neither do the conditionals "modifier" or "button" work, since the Button does only accept leftclicks.
I once more reached my limit and have no idea what to do...
Would you mind looking at "my" code and help me?
I hope I don't get on your nerves.... -_-
  Reply With Quote
08-30-07, 01:28 AM   #7
Arachiel
A Murloc Raider
 
Arachiel's Avatar
Join Date: Aug 2007
Posts: 5
YAHOOO!

I did it! It works!
I just had to remove the ";" in "/focus [target=focus, noexists]; [target=none, noexists][target=none]" and now it works!
Superb!
Now I have to implement the graphics and move it away from the center. But that should be a piece of cake, considering the help here and HOWTOs elsewhere.
Thank you for reading this. ^-^
  Reply With Quote
08-30-07, 01:50 AM   #8
Jazradel
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 39
That's not really very elegant. Can't check the documentation, but:
SetAttribute("focus","target")
Would achieve it wouldn't it?
__________________
  Reply With Quote
08-30-07, 06:14 AM   #9
Arachiel
A Murloc Raider
 
Arachiel's Avatar
Join Date: Aug 2007
Posts: 5
It's not that I don't want to be elegant. I just wanted a solution. I'm sure, that there are BETTER solutions, but I haven't found it. Hey - I'm a noob after all. ^0^

Btw. SetAttribute("focus","target") does not work. Just tested it. T_T
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » The Noob says: Huh? What is a SecureUnitButtonTemplate?


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