XAML reference

From HoNWiki

Jump to: navigation, search

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 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

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

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: 8 % 3 = 2)
 !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.
Trim
TrimLeft
TrimRight
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.
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.
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.
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] 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:

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

See Category:Triggers

ActiveInventoryDescription{slot} {slot}: number of the hero's ability [0 to 41]


param0 string: ability's name
param1
param2 float: ability's mana cost
param3 int: item gold value
param4 (aura?)
param5 (aura type?)
param6 string: describes how the ability targets (e.g. 'Target Unit', 'Target Position', 'Self')
param7 string: describes what the ability targets (e.g. 'Enemy Units', 'Ally Units', 'All Other Units')
param8 string: describes the ability's type (e.g. 'Magic', 'Physical', 'Superior Magic')
param9 int: ability's range
param10 int: (always 0?)
param11 bool: seems to be true if ability is activatable and false if passive
param12 string: describes how to use the ability (e.g. 'Click to activate this ability', 'This ability is passive')
param13
param14 string: a humorous comment related to the ability (usually also in reference to famous quotes)
param15
param16 (description text?)
param17 (ability's channeling time in milliseconds?)
param18 float: (ability's mana upkeep per second?)
param19 float: (ability's triggered mana cost?)
param20 int: ability cooldown in milliseconds

ActiveInventoryStatus{index} {index}: number of the ability [0 to 41]


param0 bool: true if the ability can be used
param1 bool: true if the ability is currently actived (ie. channeling or autocasted)
param2 bool: true if you are silenced
param3 bool: true if you don't have enough mana to cast this ability
param4 bool: true if the ability is currently being cast
param5 int: the level of the ability
param6 bool: true if the ability can be leveled up further, at this time
param7 int: the max level of the ability
param8 bool: true if the hotkey has been pressed and you are currently selecting a target

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]


param0 :
param1 bool: true if you still don't have that skill (level 0) [Color: grey]
param2 bool: true if skill can be used
param3 bool: (used alongside param2 with code like: If(param2 or param3, SetColor('lime'); )
param4 bool: true if the ability is unavailable because of silence/stun or it's charge timer [Color: red]
param5 bool: true if you don't have enough mana to use the ability [Color: blue]
param6 : level of the ability
param7 bool:
param8 bool:
param9 :
param10 : name of the ability
param11 : icon of the ability, use with SetTexture(param);
param12 bool: true if the ability is a passive skill [Color: green]

Examples from code:
If(param2 or param3, SetColor('lime') -> true if the ability can be used (have mana and not in cooldown)
If(param8 and param7, SetColor('yellow') -> no clue
Color: Orange -> have mana, but in CD

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), HealthPercent (float), Level (int), ManaPercent (float), Name (string), Player (string) or Team (string).
These are variables that contain information that is known for any visible unit (without selecting them) and is mostly used to draw health and mana bars.

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.


param0 string: Server ip address and port.
param1 string: Game name.
param2 int: Ping.
param3 string: Map player size (e.g. '5v5').
param4 string: Game mode.
param5 int: Whether private.
param6 string: Server type (e.g. 'official').
param7 string: Game Options (default 'invis', otherwise e.g. 'allheroes').
param8 string: Game Options (default 'invis', otherwise e.g. 'devheroes').
param9 string: Game Options (default 'invis', otherwise e.g. 'easymode').
param10 string: Game Options (default 'invis', otherwise e.g. 'hardcore').
param11 string: Game Options (default 'invis', otherwise e.g. 'allheroes').
param12 string: A string which summarizes much of the game information.
param13 string: (e.g. 'general').
param14 bool: Is no leaver enabled.
param15 bool: Do your PSR stats qualify.
param16 int: Number of players in game.
param17 int: Max. number of players.
param18 string: Map name (e.g. 'caldavar').
param19 int: Min PSR
param20 int: Max PSR

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


param0 int:
param1:
param2 string: Player's name in colour
param3 bool:
param4 bool:
param5 bool:
param6 string: Location of image for hero icon
param7:
param8 bool: If player is disconnected
param9 bool:
param10 bool:
param11 int:
param12 int: Equal to 1 when they've selected yes to a vote (non-zero value indicates any type of status?)
param13 float: 0 to 1 value that indicates what percentage they have loaded while connecting
param14 string: Hero name
param15 bool:

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


param0 int: -1 is no player, 0 to * is the number of the player using that slot
param1 string: name of the player using the slot
param2: color of the slot in 'R G B A' format
param3 bool: True if the player is the host
param4:
param5:
param6:
param7 string: name of the color of the slot
param8 bool: True if you are in this slot.
param9 int: player ID
param10 int: PSR
param11:
param12 int: PSR gain if the game is won
param13 int: PSR loss if the game is lost (negative number)
param14:
param15 bool: Slot is locked true/false
param16 bool: Player Team - true if the player is on Hellborne, false if on Legion.
param17 bool: True if you are the host.
param18 bool: True if this slot is the top slot for its team.
param19 bool: True if the player is an S2 employee
param20 bool: True if the player is a prepaid account

RecipeComponent{index}


RecipeUsedIn{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.


param0 bool: true if a component/recipe exists in this index, false if not
param1 string: item/recipe name.
param2 string: Additional item info. For example for Post Haste it's: "When activated, teleports self to a selected allied structure or unit."
param3 string: Path to item/recipe texture.
param4 int: Price.
param5 int: Total cost all components to the recipe. If RecipeComponent, same as param4.
param6 bool: true if item is available to purchase at the current location, false if not
param7 string: Text to be added at bottom of item/recipe tooltip. Example: Click to VIEW this recipe
param8 bool: true if component is a recipe.
param9 string: Path to shop icon texture.
param10 string: Name of shop where item/recipe can be bought.
param11 bool: true if component is present in inventory, false if it is not
param12 bool:  ?
param13 string: A single letter like Q or E. The hotkey used to buy the component or access the recipe from the shop.
param14 int: 2 for RecipeComponent, 3 for RecipeUsedIn
param15 bool:  ?
param16 bool: ?
param17 bool: true if recipe automatically combines items once they are purchased, false if recipe purchase is required
param18 bool: true if clicking the component (button) will redirect you to another shop window.
param19: ?
param20 float: ?
param21 int: ?
param22 int: ?
param23 bool: true if the item is a recent (new) addition to the game.
param24 bool: ?

ScoreboardPlayer{index} {index}: the index of the player, 0 to 4 is legion, 5 to 9 is hellborne


param0 string: player's name
param1 string: player's hero name
param2: Player's Hero's Icon, use with SetTexture(param1);
param3: Player's color, use with SetColor(param3);
param4 int: Player's Hero's Level
param5 int: Number of Kills
param6 int: Number of Deaths
param7 int: Number of Assists
param8 bool: true if the player is alive, false is dead.

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
param1 string: Player's color

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.


param0 bool: True if player can interact with the stash, else false.
param1 bool: True if {slot} is used, else false.
param2 bool: ?

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.


param0 bool: ?
param1 int: Cooldown vote timer in milliseconds. Starting at 60000ms upon a vote call. Must reach 0 before user can vote again.
param2 int: Remake active timer in milliseconds. Starting at 300000ms at game start. Vote remake is available as long as this hasn't reached 0.
param3 int: Concede countdown timer in milliseconds. Starting at 900000ms at game start. Vote concede is unavailable as long as this isn't 0.
param4 bool: If a vote is in progress. (verify)
param5 bool: Have permission to call pause vote. (verify)
param6 bool: Have permission to unpause. (verify)
param7 bool: ?

VoteProgress


param0 float: Number of people that have voted.
param1 float: Total number of people eligible to vote.
param2 float: A number representing % of votes accepted. Use FtoP(param2) to get actual %.

ActiveAttributeInfo ActiveHasInventory EventPlayerGold MenuPlayerInfo{index} Minimap PlayerCanShop PlayerGold SelectedVisible{index} SelectedType{index} SelectedName{index} SelectedLevel{index} SelectedDamage SelectedArmor SelectedLifetime SelectedMoveSpeed SelectedHasAtrributes SelectedAttribute SelectedType0 AltInfo0Name AltInfo0Player AltInfo0Level

Personal tools
Google AdSense