XAML reference
From HoNWiki
Contents |
[edit] Misc Info:
- The interface is 100h, the game-scene is 88h tall, the width of it depends on the resolution of the screen.
- To add a color to the text just write one of those codes before it.
- To override a template or item that HAS A NAME ATTRIBUTE without editing it, you can make another one with the same name attribute in a .package file and import the package at the beginning of the file where the template/element you want to override is. Only the first element with a given name will be loaded, so the original one won't load.
- Setting host_dynamicresreload 1 will reloadinterfaces automatically upon file change.
[edit] Elements:
- button
- combobox
- cvarlabel
- floater
- if (Note: condition is only evaluated on the first instance (templates), any subsequent instances will have the same condition as the first instance)
- image
- instance
- label
- listbox
- listitem
- menu
- modelpanel
- panel
- phase
- piegraph
- slider
- template
- textbox
- textbuffer
- texture
- widgetstate
Note: Clicking a hyperlinked element will take you to a list of attributes specific to that element.
[edit] Attributes:
- See List of XAML Attributes for complete attribute list
[edit] Events:
| Name | Description | Note |
|---|---|---|
| onclick | Called when something is left clicked down, then up. | Not sure if this adjusts for reassigned mouse binds. |
| onrightclick | Called when something is right clicked down, then up. | Not sure if this adjusts for reassigned mouse binds. |
| onhotkey | Called when hotkey is pressed. Can only have 1 hotkey. | |
| ontrigger | Called when watch attribute is triggered. | There can be multiple ontriggers; use watch0 with ontrigger0, watch1 with ontrigger1, and so on... |
| onfocus | ||
| onlosefocus | ||
| onchange | ||
| onenter | Called when the object is moused over for buttons and when the input cursor appears for textboxes. | Only works for <textbox> and <button>. |
| onmouseout | Called when cursor leaves the area the object cover. | |
| onmouseover | Called when cursor is over the object. | |
| onmouseldown | Called when object is clicked by left mouse button (mouse down). | |
| onmouselup | Called when object is clicked by left mouse button (mouse up). | |
| onmouserdown | Called when object is clicked by right mouse button (mouse down). | |
| onmouserup | Called when object is clicked by right mouse button (mouse up). | |
| onload | Called when the object is loaded/initialized. | Unable to use Trigger() from onload, |
| onframe | Occurs once per frame/sec (fps), only occurs when the object is visible | |
| onevent{id} | Called with CallEvent('{objectname}', {id}). Use CallEvent('{objectname}') to trigger onevent. | |
| onenddrag | ||
| ondoubleclick | ||
| onesc | ||
| onhide | ||
| onselect | ||
| onshow | Called when an object is set visible or drawn for the first time since the last page reload. | |
| onwake | Called when an widget is woken from the SleepWidget command or forced awake. | |
| onreload | Probably only work on <interface>s |
Note: to add more attribute-event couples of the same kind in the same element add a number at the end of them (Example: hotkey0="K" onhotkey0="do something" hotkey1="L" onhotkey1="do something else")
There might be (there are actually) other events, if you know or suspect the existence of any other event please add it to the appropriate list, and maybe add a short description.
[edit] Commands:
[edit] Operators
| +,-,*,/ | Add, Subtract, Multiply and Divide |
|---|---|
| % | Mod, gives the quotient of a division (Example: 7 % 3 = 1) |
| int Floor(float); int Ceil(float); | floor and ceiling functions map a real number to the next smallest or next largest integer |
| !bool | NOT operator, returns false if bool is true and vice-versa |
| gt | greater than |
| lt | less than |
| ge | greater than or equal to |
| le | less than or equal to |
| == | equals |
| |, or | OR |
| and | AND |
[edit] Strings
| string # string | Concatenates the two string before and after it. |
|---|---|
| CreateString | Create a string variable. CreateString('Name', 'value'); EX: CreateString('dev_spawnerType', 'Creep_LegionMelee'); |
| GetHeightFromString | |
| GetStringWidth | |
| GetStringWrapHeight | |
| GetTextWidth | |
| GetWidthFromString | |
| GetXFromString | |
| GetYFromString | |
| LowerString | |
| SearchString | int SearchString ( MyString, SearchString, startPosition ); int returned is the location of the string. |
| StringContains | |
| StringContainsOnly | StringContainsOnly( MyString, '#$@!.,`\'~_-]', 'Aa0'); I believe this means ( String, Allowed Symbols, Allowed A(-Z) a(-z) and 0(-9)) For checking characters. |
| bool StringEmpty(string); | Returns true if the string is empty |
| bool StringEquals(string, string); | Compares two strings and returns a bool, true if they're the same. |
| StringLength | Returns the amount of characters in a string. ex: ontrigger="SetVisible(StringLength(param) gt 0); SetTexture(param);" Translates to, "if string has 1 or more characters in it, do ___" |
| Substring | string substring( MyString, startingPosition, lengthOfSubstring); retutns the substring requested. |
| UpperString |
[edit] Conversions
| string FtoA(float, int) | Converts a float to a string, displaying int decimals. |
|---|---|
| string FtoA2(float, int min, int max) | Converts a float to a string displaying minimum int-1 decimals and maximum int-2 decimals |
| FtoP(float) | float to Percentage Returns a % but need to do %% to get a percent in a string. |
| FtoT(float time, int format, int approximation, string format2) FtoT(float, int) | Converts float to time format can be: * -1 -> MM:SS (appears the same as 1) * 0 -> in seconds * 1 -> MM:SS (minutes go over 60, used for match time display) * 2 -> H:MM:SS with a leading zero if less than 1 hour approximation: how many digits are considered for seconds after the "," format2: * a -> 12m 34s * - -> 12:34 * 0 -> 12:34 |
[edit] Common Commands
Feel free to add any and all commands that are used often in UI modding.
| AllChat(string <message>); | Sends a message to the All Chat in-game for all players to see. |
| Call(string <var_name>, string <value>); | Calls a Widget. |
| ClearText(); | |
| CreateBool(string <var_name>, bool <value>); | Creates a bool variable. |
| CreateInt(string <var_name>, int <value>); | Creates a int variable. |
| CreateFloat(string <var_name>, float <value>); | Creates a float variable. |
| CreateString(string <var_name>, string <value>); | Creates a string variable. |
| Echo(<text or value>, <text or value>, ...); | Prints to the console. Text and variables can be concatenated using the ',' character. |
| HideWidget(string); | Hides the widget whose name attribute is equal to the provided string. |
| If(bool <condition>, <if true do this>, <if false do this>); | a IF-THEN-ELSE structure. Example: If(param1 == 0, ClearText(), SetText(Ceil(param0) # '/' # Ceil(param1))); |
| Instantiate(string <template>, string attribute0, string value0, string attribute1, string value1, ...); | Creates an instance of the template with attributes and values as given. |
| TeamChat(string <message>); | Sends a message to the Team Chat in-game for only team members to see. |
| Set(string <var_name>, <value>); | Sets the given variable to the given value (value has to be of the same type of the variable of course). |
| SetColor(string <color>); | Sets the color of the element, accepts three formats of the color: html color name or codes that you can check here or a sequence of 4 float numbers divided by a space, ranging from 0 to 1 indicating in order Red, Green, Blue and Alpha (transparency), for example like '1 .7 0 .45' |
| SetText(string <text>); | Called from within a label element, sets the text of the label. |
| SetTextColor(string); | Sets the color of the text, accepts three formats of the color: html color name or codes that you can check here or a sequence of 4 float numbers divided by a space, ranging from 0 to 1 indicating in order Red, Green, Blue and Alpha (transparency), for example like '1 .7 0 .45'. |
| SetVisible(bool); | Set the visibility of the element, hidden if bool is false. |
| ShowWidget(string <widget_name>); | Shows the widget whose name attribute is equal to the provided string. |
| Split( <command_1>, <command_2>, <command_3>, ...); | Lets you execute multiple commands in place where only one could be normally be executed, like inside If statements. |
| ToggleWidget(string <widget_name>); | Toggles the status between shown and hidden of the widget whose name attribute is equal to the provided string. |
| VarExists(string); | Returns true if variable string exists. |
[edit] Full Lists
Updated October 28, 2009, Version 0.1.50.1:
- ActionList
- AxisList
- ButtonList
- CmdList
- ConsoleElementList
- EntityList
- EventCmdList
- FunctionList
- ProceduralList
- ShaderSamplerList
- ShaderVarList
- UICmdList
- UITriggerList
Updated August 14, 2009, Version 1.35:
[edit] Strings
Strings hold variables of all sorts. When reading a string, it should be refered to directly. Strings are stored without their apostrophes. Three examples of booleans reading strings:
StringEquals(variableheld, 'yes')
StringEmpty(variableheld)
!(integername == -1)
There is also the special case of concatenated strings. These are often used for cases where the string will be used multiple times for different reasons.
The underscores have no special significance.
StringEquals(*('player' # param27),*('player' # mod_Player))
*('number_' # param27) lt 100
When writing a string or the variable contained within it, apostrophes are used, noting what is a new string.
When any of these strings are referenced in the future, they will return what is inside of them.
CreateString('variableheld','yes')
CreateInt('integername',3)
CreateString('string3', string2 # param0)
Set('number_' # param27,*('number' # param27)+1)
[edit] Triggers
Triggers are user created "Watches." To create a trigger, declare it once, in one of the files you will be using.
<trigger name="MyTrigger">
Now My trigger can be set to a watch inside any tag
watch="MyTrigger"
To throw your trigger you call
Trigger('MyTrigger', 'blah', 'blah', true, false, 0, 2, 3, 'blah blah blah');
All of the inputs following the name of your trigger will be used as param0-whatever.
[edit] Watches
| ActiveExperience | param1 int: total exp param2 int: exp needed for next level (if its 167/200, this is 200) param3 ??: PROBABLY is the exp needed to level up (needs to be verified) param4 int: exp you have for the next level (ex: if xp needed for lvl 2 is 100, and you have 150, this is 50) |
|---|---|
| ActiveHealth | param0 float: current health param1 float: total health param2 float: health percentage as float (not sure if it's 0 to 1 or 0 to 100) |
| ActiveHealthRegen | param0 float: base health regeneration param1 float: current health regeneration including buffs |
| ActiveLevel | param0 int: indicates the level of the owned selected unit (your hero, your creeps, allied hero that is being shared) |
| ActiveInventoryStatus{index} | {index}: number of the ability [0 to 41]
|
| ActiveLifetime | param0: watch="ActiveLifetime" ontrigger="SetText(Ceil(param0 / 1000) # ' s');" param1: <panel watch="ActiveLifetime" ontrigger="SetVisible(param1 gt 0);" visible="false" noclick="true" pasivechildren="true"> param2: <piegraph texture="/ui/common/exp_ring.tga" watch="ActiveLifetime" ontrigger="SetValue(param2);" start="225" end="-49" square="1" color="#e5df2f" value=".2" noclick="true"/> |
| ActiveMana | param0 float: current mana param1 float: total mana param2 float: mana percentage as float (not sure if it's 0 to 1 or 0 to 100) |
| ActiveManaRegen | param0 float: base mana regeneration param1 float: current mana regeneration including buffs |
| AllyAbility{index}Cooldown{index2} | {index}: number of the ability [0 to 3] {index2}: number of the ally player in team [0 to 3] param int: cooldown time left on the ability in seconds |
| AllyAbility{index}Info{index2} | {index}: number of the ability [0 to 3] {index2}: number of the ally player in team [0 to 3]
|
| AllyDisconnected{index} | {index}: int from 0 to 3, indicates the number of your ally param bool: indicates if the ally is disconnected (true) or not (false) |
| AllyDisconnectTime{index} | {index}: int from 0 to 3, indicates the number of your ally param float: indicates disconnection time left, formatted as a clock with SetText(FtoT(param, 1, 0, '-')) |
| AllyExists{index} | {index}: int from 0 to 3, indicates the number of your ally parambool: true if there's a player on that index |
| AllyGold{index} | {index}: int from 0 to 3, indicates the number of your ally param: Ally's gold "SetText(Translate('tooltip_gold') # param);" |
| AllyHealth{index} | {index}: int from 0 to 3, indicates the number of your ally param0 float: current health param1 float: total health param2 float: health percentage as float (not sure if it's 0 to 1 or 0 to 100) |
| AllyHeroInfo{index} | {index}: int from 0 to 3, indicates the number of your ally param0string: Hero name param1: Hero Icon param2: Hero level ontrigger="SetText(Translate('tooltip_level', 'level', param2));" |
| AllyLoadingPercent{index} | {index}: int from 0 to 3, indicates the number of your ally param float indicates the loading percentage |
| AllyMana{index} | {index}: int from 0 to 3, indicates the number of your ally param0 float: current mana param1 float: total mana param2 float: mana percentage as float (not sure if it's 0 to 1 or 0 to 100) |
| AllyPlayerInfo{index} | param0 string: Player's name param1: Player's color |
| AllyRespawn{index} | {index}: int from 0 to 3, indicates the number of your ally param0 float: empty if hero is alive (can be checked with StringEquals(param0, ''); ), when hero is dead contains a float number indicating the time left until respawn in milliseconds (use Ceil(param0 / 1000); to convert into seconds). |
| AllyStatus{inedx} | {index}: int from 0 to 3, indicates the number of your ally param bool: if the hero is alive (true) or dead (false) |
| EndGame | param: bool: true if throne is destroyed else false. |
| EventDefeat EventVictory | Called when the throne has been destroyed. |
| HeroHealth | param0 float: current health param1 float: total health param2 float: health percentage as float (not sure if it's 0 to 1 or 0 to 100) |
| HeroIcon | param: hero icon, use with SetTexture(param); |
| HeroLevel | param0 int: current hero level param1 int: number of unused skill points |
| HeroMana | param0 float: current mana param1 float: total mana param2 float: mana percentage as float (not sure if it's 0 to 1 or 0 to 100) |
| HeroStatus | param bool: if the hero is alive (true) or dead (false) |
| HeroRespawn | param0 float: empty if hero is alive (can be checked with StringEquals(param0, ); ), when hero is dead contains a float number indicating the time left until respawn in milliseconds (use Ceil(param0 / 1000); to convert into seconds). |
| LobbyGameInfo | param0 string: Game Mode param1 string: Game Options param2 string: Server param3 string: Map Name param4 int: Players param5 int: MaxPlayers param6 int: Ping param7 string: Game Name param8 int: MatchID param9 string: Host Name |
| LobbyPlayerInfo{index} | {index}: the index of the player, 0 to 4 is legion, 5 to 9 is hellborne
|
| RecipeComponent{index}
| {index}: For RecipeComponent, the position of each item required to make up the recipe (Under Requires: heading). For RecipeUsedIn, the position of each recipe that the recipe can be used to make (Under Used In: heading). Range is from 0 to 3, left to right.
|
| ScoreboardPlayer{index} | {index}: the index of the player, 0 to 4 is legion, 5 to 9 is hellborne
|
| ScoreboardPlayerRespawn{index} | {index}: the index of the player, 0 to 4 is legion, 5 to 9 is hellborne param int: The time left before the hero respawns in seconds. |
| SelectedHealth{index} | {index}: the number of the selected unit, starting from 0 param0 float: current health param1 float: total health param2 float: health percentage as float (not sure if it's 0 to 1 or 0 to 100) |
| SelectedMana{index} | {index}: the number of the selected unit, starting from 0 param0 float: current mana param1 float: total mana param2 float: mana percentage as float (not sure if it's 0 to 1 or 0 to 100) |
| SelectedIcon{index} | {index}: the number of the selected unit, starting from 0 param: selected unit icon, use with SetTexture(param); |
| SelectedIllusion{index} | {index}: the number of the selected unit, starting from 0 param bool: true if the unit is a illusion |
| StashExists{slot} | {slot}: the targeted slot in your stash. Ranging from 0-5. 0 is top left, 5 is bottom right. param bool: True if slot is used else false. |
| StashIcon{slot} | {slot}: the targeted slot in your stash. Ranging from 0-5. 0 is top left, 5 is bottom right. param string: Path to item/recipe texture. |
| StashStatus{slot} | {slot}: the targeted slot in your stash. Ranging from 0-5. 0 is top left, 5 is bottom right.
|
| VotePermissions | Will be called repeatedly until param2, 3 and 4 reach 0.
|
| VoteProgress |
|
PlayerCanShop PlayerGold EventPlayerGold ActiveHasInventory ActiveAttributeInfo MenuPlayerInfo{index} Minimap SelectedVisible{index} SelectedType{index} SelectedName{index} SelectedLevel{index} SelectedDamage SelectedArmor SelectedMoveSpeed SelectedHasAtrributes SelectedAttribute

