Hello there! We are conducting a survey to better understand the user experience in making a first edit. If you have ever made an edit on Gamepedia, please fill out the survey. Thank you!

UI/Referencing

From SC2Mapster Wiki
< UI
Jump to: navigation, search

Certain Frame properties allow the uses of references, be it either other Frames or external assets and localized content.

Frame Referencing

$this
The element itself, useful for resetting anchors and targets in animations.
Example
<Animation name="Clicked">
    <Event event="OnCLick" action="Reset,Play" frame="$this"/>
    <Controller name="Property_0" type="Property" end="Pause" property="Visible" frame="$this">
        <Key type="Property" time="0" value="false"/>
    </Controller>
</Animation>
FrameName
Refers to a children of the current frame.
Example
<anchor relative="ChildName"/>
$parent
The parent of the object this is listed in. This reference can be chained to refer to the higher levels in the frame hierarchy.
Example
<anchor relative="$parent"/>
$root
The root element which is the parent frame of all layout files. Its usage is not required. Seems to be used for dynamic instancing.
Example
<HoverImage val="$root/StandardTemplates/StandardListBoxItemSelectedImage"/>
$ancestor
Refers to the closest parent frame with a specified type, e.g. "CommandPanel". @name can be used instead of @type to compare the name and not the type to the specified identifier.
Example
<anchor relative="$ancestor[@name=FullscreenUpperContainer]"/>
$CustomHandle
Used to reach directly a Frame with a Handle that matches the name regardless of its location in the frame hierarchy.
Example
<anchor relative="$HandleName"/>
Nesting References
It is also possible to nest references starting from the current frame, in order to reach other frames.
Example
<anchor relative="$Parent/$Parent/ChildName/ChildName"/>

Asset Reference

Frames that use assets like images, models and sounds, can use declarations in Assets.txt to access asset files. This permits the genericized use of localized assets and have multiple variations per race without having to declare different items for each of them.

Their notation is as follows:

@Path/To/Item
Will use the asset file with said path within Assets.txt.
@@Path/To/Item
Will use an asset fail with said path suffixed by the current race id, and will default to the exact path in case there is not a race specific variation.

Here is an example of an Assets.txt file which is imported to Base.SC2Data/GameData/ in the import editor.

UI/BorderTexture=Assets\Textures\MyBorder.dds
UI/BorderTexture_Prot=Assets\Textures\MyProtossBorder.dds
UI/BorderTexture_Zerg=Assets\Textures\MyZergBorder.dds
<Texture val="@UI/BorderTexture"/> <!-- Will always use Assets\Textures\MyBorder.dds -->
<!-- ... -->
<Texture val="@@UI/BorderTexture"/> <!-- Will use Assets\Textures\MyProtossBorder.dds if protoss, 
                                         Assets\Textures\MyZergBorder.dds if zerg, but will use
                                         Assets\Textures\MyBorder.dds if terran since there is no
                                         terran specific version of the asset declared -->

Constants

Description

If you want to use the same value over and over, but when changing you want to have it easy you can use constants.

Options

name = The name of the constant, when setting a value you can refer to this by using the name and prefixing a "#" to it. val = The value of the constant, when this constant is uses the value defined here.

Usage

<Constant name="InventoryButtonGap" val="-2"/>

<Anchor side="Right" relative="$parent/Button02" pos="Min" offset="#InventoryButtonGap"/>

Property Binding

Description

Property binding is used to bind a value to another value of the same type. Although there are cases where it works outside it's own type such as text.

Usage

<Text val="{$button/@PropertyWhateverItIsYouAreLookingAt}"/>