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
- form
- frame
- 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
- table
- template
- textbox
- textbuffer
- texture
- trigger
- webimage
- 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, up until watch9 with ontrigger9. |
| 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. | |
| oninstantiate | Called when this template instance is created. | Only works for <template>s |
| onreload | Probably only work on <interface>s | |
| onaddplayer | ||
| onentergame | When entering game, before pick screen |
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 rest of a division (Example: 9 % 4 = 1) |
| !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
| Operation/Function Signature | Description |
|---|---|
| string # string | Concatenates the two string before and after it. |
| CreateString(string <name>,string <value>) | Create a string variable. Example: CreateString('dev_spawnerType', 'Creep_LegionMelee'); |
| GetHeightFromString | |
| int GetStringWidth(string <font_type>,string <my_string>) | Example: GetStringWidth('dyn_10', 'hi there'); |
| GetStringWrapHeight | |
| GetTextWidth | |
| GetWidthFromString | |
| GetXFromString | |
| GetYFromString | |
| string LowerString(string) | Returns a lower-case version of string. |
| int SearchString(string <my_string>,string <search_string>,int <start_position>) | int returned is the location of the start of the string. |
| StringContains | |
| bool StringContainsOnly(string <my_string>,string <allowed_symbols>,string<allowed_ranges>) | For checking characters. Example: StringContainsOnly( my_string, '#$@!.,`\'~_-]', 'Aa0'); (I believe this means: String, Allowed Symbols, Allowed A(-Z) a(-z) and 0(-9)) |
| 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. |
| int StringLength(string) | Returns the amount of characters in a string. Example: ontrigger="If(StringLength(param) gt 0, SetTexture(param));" (Translates to, "if string has 1 or more characters in it, do whatever (set texture)") |
| string StringReplace(string <my_string>,string <search_string>,string <replace_string>) | Returns a string where each occurrence of search_string found in my_string is replaced with replace_string (crashes the game if search_string is empty). |
| string Substring(string <my_string>,int <starting_position>,int <length_of_substring>) | Returns the substring requested. |
| string Translate(string <identifier>,string <parameter>,string <value>,...) | Uses the game's current language setting to return a translation for the identifier string referenced in the stringtables folder (only seems to work for identifiers found in stringtables\interface_en.str - where the en is for English). One or more parameter-value pairs might be required, depending on identifier string. |
| string Trim(string) | Removes whitespace characters (tabs, spaces, line breaks) and returns it. |
| string TrimLeft(string) | Removes whitespace characters only in front of the string and returns it. |
| string TrimRight(string) | Removes whitespace characters only at the end of the string and returns it. |
| string UpperString(string) | Returns an upper-case version of string. |
[edit] Conversions
| int Floor(float); int Ceil(float); int Round(float); | Floor and ceiling functions map a float to the next smallest or next largest int, respectively. |
| 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(); | |
| Choose(int <select>,int <start_value>, string <choice0>, string <choice1>, string <choice2>, ...); | Selects a value from a range of given choices. Requires at least three arguments and always returns one of the arguments given or an empty string (or crashes the game). The choice selected is determined by the select parameter value, while the start_value parameter determines a starting value that would select choice0. If the first parameter refers to a value that is less than the start_value then the function could possibly return select, start_value, an empty string or else crash the game (dependant how much lower the select is value than the start_value). |
| 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. |
| Evaluate(string <code_string>); *(string <code_string>) | Executes a string as code. Has a shorthand alternate notation using the multiplication/star symbol and brackets. |
| For(int <start_value>, int <end_value>, int <amount to increment on iteration>, string <upon each iteration this code is executed> ); | A FOR loop. Inside the string part you can use any code you want, but remember to escape any single quotes (') with backslashes (\). You can get the current value of the loop's iteration by using iParam (case sensitive), this however is only accessible inside the For loop, so it is suggested that you also increment an external variable each time if this is necessary. Example: For(0, 4, 1, 'if(score_entry_iParam_vis, set(\'scores_size_legion\', scores_size_legion + 1));');
You can stack For loops but you can only access the iParam of the highest parent. |
| 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>); | An IF-THEN-ELSE structure. If you don't want to define an Else-Case, then simply close the brackets without a second ','. 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. |
| SleepWidget(int frames, string <command>); | Disables the widget for a specified amount of frames. Once it enables again, the onwake event is called. If a string is given it is interpreted as instructions to be executed when the onwake event is executed. Its important to note that if there are ' used inside the <command>, that you add a \ before it. Example: SleepWidget(30, 'Trigger(\'triggerName\', param0);') |
| 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. There have to be at least two commands. |
| 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] Errors in Console
| Type: | Function: | Description: | How To Fix: |
|---|---|---|---|
| ICVAR: | :Addreference() | Could not find a free reference slot. | Shorten the reference, FE: {the_variable_plus_attributes_witch_causes_long_referance} --> {var_plus_attri_w_cause_long_ref} |
[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.
The game only allows a maximum of 5 triggers, Trigger(), or events, CallEvent(), to be called within the same frame. Not keeping by this requirement will lead to the game crashing with a stack overflow error. To prevent this, you can delay calling the trigger until the next frame by using:
SleepWidget(1, 'Trigger(\'MyTrigger\');');
However, this workaround only works for up to 10 triggers or events, after that it all gets very messy.
[edit] Watches
| ActiveInventoryDescription{slot} | {slot}: number of the hero's ability [0 to 41]
|
|---|---|
| ActiveInventoryStatus{index} | {index}: 0 - 7 are for your skills. 0 - 2 are your first three skills, 3 is your ultimate, 4 is attribute boost. 5 - 7 are split skills (like Scout's Electric Eye) 8 is taunt 9 - 19 are for your buffs. 20 - 24 are unknown (not used) 25 - 27 are for team shared abilities. 25 is only in use which is the building fortification. 28 - 33 are for your inventory 34 is unknown (not used) 35 - 39 are for stash tooltips 41 is unknown (not used)
|
| 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 |
| ActivePlayerInfo AllyPlayerInfo{index} PlayerInfo | param0 string: Player's name param1: Player's color |
| 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) |
| 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{index} | {index}: int from 0 to 3, indicates the number of your ally param bool: if the hero is alive (true) or dead (false) |
| AltInfo{index}{option} | {index}: 0 for heros, 1 for creeps, 2 for neutrals, 3 for buildings
{option}: One of the following: Color (string), HasHealth (bool), HasMana (bool), ShieldPercent(float), HealthPercent (float), Level (int), ManaPercent (float), Name (string), Player (string) or Team (string).
|
| AttackModifier{index} | {index} int: from 0 to 7, indicates the slot of the AttackModifier. param0 string: Name of the item or skill related to the AttackModifier param1 string: Item/Skill Icon URL param2 string: Description of the AttackModifier? param3 bool: true if active param4 int: AttackModifier ID, -1 means does not exist |
| EndGame | param: bool: true if throne is destroyed else false. |
| EventDefeat EventVictory | Called when the throne has been destroyed. |
| GameListAdd | The information for each of the games added to the public games list.
|
| 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). |
| MenuPlayerInfo{index} | {index}: the index of the player, 0 to 4 is legion, 5 to 9 is hellbourne
|
| 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 hellbourne
|
| RecipeComponent{index} RecipeUsedIn{index} ShopItem{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 |
| SelectedPlayerInfo{index} | {index}: the number of the selected unit, starting from 0 param0 string: Player's name |
| ShopHeader ShopItemTooltip{slot} ShopItemType{index} ShopKey{slot} ShopName ShopType | All used for generating the shop. |
| 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.
|
| SelectedVisible{index} | {index}: the number of the selected unit, starting from 0
bool: True if there is a unit at this index that is selected and visible (the index 1 is often used to differentiate whether one or more units have been selected, as it will be true only if at least two units are selected). |
| VotePermissions | Will be called repeatedly until param2, 3 and 4 reach 0.
|
| VoteProgress |
|
Other Watches: ActiveAttributeInfo ActiveHasInventory EventPlayerGold Minimap PlayerCanShop PlayerGold SelectedVisible{index} SelectedType{index} SelectedName{index} SelectedLevel{index} SelectedDamage SelectedArmor SelectedLifetime SelectedMoveSpeed SelectedHasAtrributes SelectedAttribute SelectedType0 AltInfo0Name AltInfo0Player AltInfo0Level MatchInfoPlayer{index}

