WoW:SecureTemplates: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
[[Category:UI Technical Details]]
[[Category:UI technical details]]
[[API SecureTemplates|Secure Templates]] are an option for UI Developers to use secure functions indirectly by creating secure objects (through inheriting Secure Templates) and altering their attributes.
[[API SecureTemplates|Secure Templates]] are an option for UI Developers to use secure functions indirectly by creating secure objects (through inheriting Secure Templates) and altering their attributes.



Revision as of 21:06, 7 July 2008

Secure Templates are an option for UI Developers to use secure functions indirectly by creating secure objects (through inheriting Secure Templates) and altering their attributes.

However it is still not posiible to invoke protected functions directly from objects inheriting Secure Templates.

This article contains information taken from extracted .lua files on 25, Jan 2007

SecureFrameTemplate

This is the basic secure template. All other secure templates inherit it.

SecureActionButtonTemplate

A basic action button capable of using actions through ActionSlot or by given spell/ability names

Attributes

unit
any valid UnitId
type
known values for this are: action, actionbar, assist, attribute, click, focus, item, macro, menu, pet, spell, stop, target
action
any valid action - defined by the "type" argument
harmbutton
Special attribute that calls the attribute given by "type-string" and "typestring-string" instead of action. Well that seems a bit complicated so I should clarify this with an example
harmbutton1="myname1"
type-myname1="spell"
spell-myname1="Shadow Bolt"

harmbutton2="myname2"
type-myname2="action"
action-myname2="4"

(this example was not tested yet, it should work but may not, it is purely to make clear why 3 attributes are needed)

So the flow is like this: an attribute "harmbutton1" is found (because we clicked with the left mouse button), and it's value is used as the new action attribute. For this, the type attribute type-myname1 must be set to the type of action executed - spell in this case. Then WoW looks for the attribute spell-myname1 and executes it.
helpbutton
Same as harmbutton but for abilities that can only be used on friendly units


Any of the attributes may have a number attached that corresponds to the mouse button - i.e. action2 specifies an action executed when rightclicking the button. Or the special character "*" (asterisk) meaning any button.

Any of the attributes may have a modifier prepended that corresponds to modifier keys - i.e. alt-action means this action is only executed when the alt-key is pressed while clicking it. Or the special character "*" (asterisk) meaning any modifier key (this should be the default of the standard action buttons).

Example

A really basic example would be:

<Button name="ReallyBasicButtonTemplate" 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>
	<PushedTexture>
		<Color r="0" g="1" b="0" a="0.5"/>
	</PushedTexture>
	<Scripts>
		<OnLoad>
			this:SetAttribute("type*"  , "action");
			this:SetAttribute("action1", 1);
		</OnLoad>
	</Scripts>
</Button>

SecureUnitButtonTemplate

Unit button, for targeting units - like the group frames. Though it's basically a reduced version of SecureActionButton, since it calls the same functions anyway but overwriting type1 to target and type2 to menu which means it will open the unit menu on rightclick and target the given unit on leftclick.

Attributes

target
Any valid UnitId.


SecureStateHeaderTemplate

This is one more advanced template and I'm still not quite into it... Sorry. But I will write down what I know.

The template has four basic function it can control for it's child frames/objects

  1. Child Visibility
  2. (Mouse) Button Mapping
  3. State Transitions
  4. Key Rebinding


The template by itself will not do anything, it is meant to control child frames. But first a frame has to be registered with the state header. That means child frames don't have to be actual child frames in terms of setparent functions or parent attribute. (actually it won't probably work with only a parent attribute)

To register a frame with the template, use the following example:

SecureStateHeaderName:SetAttribute("addchild", ChildName);


State names

State names - according to the documentation - can be any string value, though I would not recommend using the characters '-', ',', ';' and ':' in them, though positive integer values are recommended. One reason is that they can be combined like "1,2,3,4,5,6,7,8,9" may also be written as "1-9". Naturally "pear,apple,cherry" can't be combined to "pear-cherry".


Attribute Syntax

The state header makes use of a specific attribute value syntax (other than the SecureActionButton's attribute name syntax, so they should not interfere). Any attribute can contain state specific information, telling WoW which value applies to which state. The basic syntax should be

attribute="value11:value12;value21:value22;..."
 or
attribute="value1,value2,value3,..."

meaning value11 is mapped to value12 and value21 maps to value22. Or just listing values/states. The specific syntax of the value depends on it's attribute.

There is a special syntax to combine integer values in a row. Use "1-5" instead of "1,2,3,4,5" or "1,3-9" instead of "1,3,4,5,6,7,8,9" etc.


State Transitions

After a child frame is clicked it's "newstate" attribute is parsed to retrieve the new state of the state header. The syntax is quite wicked though.

newstate="*:x"
 Means that no matter what state we're in, we go to state x
newstate="x-y"
newstate="1-4" (example)
 Means that if we are in state 1, the next state is 2.
 If we are in state 4, the next state is 1
newstate="x:y"
newstate="1-4:9" (example)
 Means that if we are in states 1 to 4, we will transit to state 9
newstate="x-y:u:v"
newstate="1-2:5-6" (example)
 Means that if we are in state 1 the new state is 5 and
 If we are in state 2 the new state is 6.
newstate="1-2:5-6;7-8:1" (example)
 A combination.

Attributes

newstate
Contains state transition rules
delaystate
Contains state transition rules to be executed after delaytime. The Syntax is the same as for newstate
delaytime
The time between parsing newstate and delaystate in seconds it is parsed similar to the attribute statebutton

Child Visibility

Controls visibility of child elements depending on two attributes. Note: This attribute is an attribute of the child elements not the header!

Attributes

showstates
Contains those states where the element should be visible
hidestates
Contains those states where the element should not be visible

The attribute value syntax is rather easy: A comma separated list, listing the desired states where the elements can be ranges (x-y) too.

attribute="x,y,z,..."
attribute="3,4,7-9"

SecureStateDriverTemplate

SecureAnchorButtonTemplate

SecureAnchorEnterTemplate

SecureAnchorUpDownTemplate

SecurePieButtonTemplate

SecurePartyHeaderTemplate

SecureRaidGroupHeaderTemplate

Also See