Jump to content
Sign in to follow this  
You need to play a total of 5 battles to post in this section.
MatroseFuchs

Unbound framework (documentation)

2 comments in this topic

Recommended Posts

Administrator
16 posts
20 battles

Bindings

Bindings are directives assigning different behavior to elements: synchronization with the data model, tooltip display, drag-and-drop, etc.  

Bindings are defined as follows: (bind %binding_name% "binding_expression1; binding_expression2; ..."). The binding expressions syntax is a subset of the JS / AS3 syntax as it supports lines, numbers, true, false, null, arithmetical, logical operations,  comparison operators, access to array elements via [], access to object properties via . and a ternary operator. Binding expressions are calculated for the current scope (i.e. "player.name" is in fact "scope.player.name").

When an element is instantiated by the framework, a scope object is created automatically where the programmer can enter any data at their own choice. To control data in the scope you may write controllers that will obtain data from the game logic (e.g. via GameInfoHolder), process them and fill the scope with them.

public class NewWindowController extends UbController
{
  
    public var gameInfoHolder:GameInfoHolder;
     
    override public function init(... params):void
    {
        scope.playerName = ... // grab player name from GameInfoHolder
    }
  
}

For the controller not to be cut by a linker (or whatever this thing is called in SWF's compilation), you need to import it in the main window class and declare a private variable of a corresponding type.

When instantiating, necessary variables are injected into controllers – the framework does it for every public field.  All public methods of the controller are imported to the scope it is linked to.

A controller can be declared as follows:

(bind controller "lesta.dialogs.new_window.NewWindowController; arg1; arg2; ...")

Calculated arg1, arg2, arg3, ... are passed to the init method of the controller.

 

Frequently used controllers

Spoiler

EntitySingletonController

Creates a link to a singleton (an object with data that exists in a single copy) from GameInfoHolder in the в scope and updates the scope when data in this singleton is updated.

The only argument is the singleton id.

Example:

(bind controller "lesta.dialogs.controllers.EntitySingletonController; 'serverState' ")

There are cases when singleton data is not always required in one element. For example, in the battle type selection button the division data is only required if it is the Training Room button. It should be unavailable if the player is in a division.  Random and Co-op Battle buttons do not depend on the player being in a division.  In this case, instead of the singleton id you can have ‘null’, then there will be no data import and no subscription to updates.  

In case of the battle type selection button, it will look like this:

(bind controller "lesta.dialogs.controllers.EntitySingletonController; type == BattleTypes.TRAINING_BATTLE ? 'divisionData' : null")

 

CollectionController

Creates a link to a collection or one collection element from GameInfoHolder in the scope and updates the scope when the collection is updated. The behaviour depends on the number of passed arguments.

Importing the entire collection.
(bind controller "lesta.dialogs.controllers.CollectionController; 'collection_id'; 'scope_key'")

Creates the "scope_key" property in the scope, its value is the array of all collection elements 'collection_id'.

Importing the entire collection.
(bind controller "lesta.dialogs.controllers.CollectionController; 'collection_id'; 'element_id'; 'scope_key'")

Creates a "scope_key" property in the scope, its value is an element with id element_id' from the 'collection_id' collection.

Filtering the collection.
(bind controller "lesta.dialogs.controllers.CollectionController; 'collection_id'; 'property_name'; 'required_value'; 'scope_key'")

Creates a "scope_key" property in the scope, its value is an array of those elements of the 'collection_id' collection where 'property_name' equals 'required_value'.

A list of available bindings

UbChildBinding

Spoiler

(bind child "someExpression; 'elementName0'; 'elementName1'; ..."

Defines a child DisplayObject of the block. The expression ‘someExpression’ (it's usually just a field) calculates the scope index. The child class is selected from elementClass0, elementClass1, etc using the index (don’t forget to put the names between single quotes!), then it is instantiated by the framework and linked to the element. Properties of the parent scope become available in the child bindings by accessing $parent.

You can also have an object with parameters for child elements as the second parameter:

 (bind child "someExpression; {scopeKey : value, scopeKey : value}; 'elementName0'; 'elementName1'; ..."

It is more convenient sometimes to select a child element by the line and not by the index. In this case, the last (second or third) parameter should be the object setting the line-element correspondence:

(bind child "someExpression; {scopeKey : value, scopeKey : value}; {key1: 'elementName0', key2: 'elementName1'}")

or

 (bind child "someExpression; {key1: 'elementName0', key2: 'elementName0'}")

Please note that keys always have no quotes while element names are given between quotes if they are not written in a variable. For example:

 (bind child "reward.type; {subtype : reward.subtype, amount : reward.amount}; {Ship: 'ShipRewardElement', Exterior: 'ExteriorRewardElement', Resource: 'ResourceRewardElement'}")

Where the "Ship", "Exterior" or "Resource" line is in reward.type

UbInstanceBinding

Spoiler

(bind instance "'ElementClass'; someExpression")

Defines a child display object of the block if there are data for displaying it. Firstly, someExpression is calculated for the scope, and then if the result doesn’t equal null ElementClass is instantiated by the framework and is bound to the element. The child's bindings can access parent scope properties by using $parent.

UbEventBinding 

Spoiler

(bind event "'eventName'; method; arg1;arg2...")

When an element dispatches the eventName event (don’t forget to put it between single quotes!)  the method imported from the controller is called, and event, arg1, arg2, ... arguments are passed to it.

If the called method is not found in the scope then an attempt will be made to call a method of DisplayObject itself. For example:

 (bind event "'startHide'; 'gotoAndStop'; 'hide'")

The method name should be between single quotes. Only given arguments will be passed (arg1, arg2, ... )

It calling both methods fails there will be the following warning in the log: 
[WARNING] wrong usage of 'bind event'

UbSyncBinding 

Spoiler

(bind sync "someProperty; somePropertyNotifyAboutChangeEvent; someExpression")

Synchronizes the element’s property someProperty and someExpression (it should be lvalue). That is, when someProperty is changed then someValue is changed as well, and vice versa. When someProperty is changed, the element should dispatch the event somePropertyNotifyAboutChangeEvent.

UbRepeatBinding 

Spoiler

(bind repeat "dataList; 'itemRenderer'; {scopeKey : value}; _revert")

For every dataList array elementt, dataList instantiates an itemRenderer element with a child scope created for it (with $index property available in it) and binds it to the block.

Instead of dataList array, you can pass a number of elements that should be created. These elements will also have the $index property.

{scopeKey : value} a set of parameters can de added to every object’s scope

_revert[true/false] – sets the the order of elements (reversed or not). False by default (straight).

Important notice: If any array element is null then the binding will create an element for it anyway. You should better not pass an array with empty elements to it if you are not sure that it is the only correct solution.

UbGeneratorBinding 

Spoiler

Instantiates an itemRenderer element for every dataList array element.

It dynamically loads and unloads of elements rendering only those ones that really fits the parent container.

In this case, elements are sorted according to sortArray.

 (bind generator "dataList; 'itemRenderer'; {scopeKey : value}; sortArray; sortField")

Additional parameters (optional):

  • {scopeKey : value}  -  a set of parameters can be added to the scope of every object
  • sortArray - a sorted array or an array that needs sorting (if the sortField is given)
  • sortField - a field whereby the sortArray array is sorted.

UbDraggableBinding 

Spoiler

(bind draggable "elementName")

The current element becomes draggable. Drag-and-drop works when clicking on the descendant element named elementName (don’t forget to put it between single quotes!). You can set a name of a block with the following code: (bind name "'myName'").

UbClikListBinding 

Spoiler

(bind clikList "someExpression")

Synchronizes CLICK list with the someExpression expression (it is usually just a field containing an array). It works for mc only, the unboundClassName property should be set in the params tag – this is an element name, a line for the list.

(mc player_details_stats_list
    (params (rowHeight 20) (unboundClassName TeamResultStatRow) (scrollBar GreyScrollbar))
    (bind clikList "theirDetails.player.stats"))

UbStyleBinding 

Spoiler

(bind style "'styleName'; expression")

Synchronizes the styleName style property value (single quotes!) and the expression.

UbStyleClassBinding 

Spoiler

(bind class "'className'")

Applies the className style class to the element (single quotes!) and cancels the previous className of the element if it had a different className.

UbAppearBinding 

Spoiler

(bind appear "'eventName'; duration; delay; {start props}; {finish props}")

Once an object is added to the scene it plays a tween with set parameters. The following properties is supported officially: alpha, top, left, scaleX, scaleY, rotation. For mc, use x and y instead of top and left.

UbTransitionBinding 

Spoiler

(bind transition "someExpression; duration; {start props}; {finish props}; ({start props};) (easing;) (delay)")

When a condition is fulfilled it plays a tween with set parameters where someExpression is an event or expression calculated in true, duration is a length of the transition in seconds, {props} is an CSS style used for animation (e.g., alpha or top).
Optional parameters: easing is a transition function type, it is 0 by default, so that is a linear jump. Possible values are: 1 (slowing down animation), 2 (speeding it up), 3 (first speeding it up then slowing it down). Any value different from these ones equals 0.

UbTooltipBinding 

Spoiler

(bind tooltip "'TooltipElementName'; {tooltip scope}; tooltip_behaviour_id")

Binds a tooltip to the object.

  • TooltipElementName: the object to be displayed as a tooltip
  • {block scope} (optional): passes data to the scope of the BlockName object.
  • tooltip_behaviour_id(optional): integer, sets a tooltip behavior variant.

UbSequenceBinding 

Spoiler

(bind sequence "dataList; 'itemRenderer'; itemLifeTime; itemHideTime; gap")

Creates an element with id=itemRenderer for every element of the dataList array starting from zero with a child scope created for it (with the $index property available there), and binds it to the block. The settings for the newly created element are show=true, when the period itemLifeTime (seconds) elapses the settings change to show=false, and in itemHideTime seconds the element is deleted, and a new one is created.  An optional gap parameter sets a lag between deleting the previous element and adding the next one. The default setting is 0, that is, the next element will be added right after the previous one is deleted. The gap parameter can be negative, when a new element will be added gap seconds before the previous one is deleted.

f3ae4ffb61c43ab1e976670a92a3d6db.png

UbPropertyBinding 

Spoiler

Bindings with a name property that is different from the listed here variants are considered property bindings.

 (bind some_prop "someExpression")

The some_prop property (e.g., visible) of the object is unilaterally synchronized with the someExpression expression (it is usually just a field), that is, changes to someExpression will be reflected in some_prop.

You can also pass value expressions to the component method with the help of property binding (e.g., gotoAndStop) – to do it, you just need to add ! to the name attribute.

 (bind gotoAndStop! "state")
 (bind twoArgumentsMethod! "arg1; arg2")

UBVariablesBinding 

Spoiler

Binding for creating and assigning values to the current scope properties. 

 (bind var "{propertyName: propertyValue, propertyName1: propertyValue1}")

copies all properties of the object described in an expression in the scope

UbCatchEventBinding 

Spoiler

Binding for creating and setting values to current scope properties after receiving an event from the scope or from the current block.

(bind catch "'event_name';{propertyName: propertyValue, propertyName1: propertyValue1}")

when "catching" the event_name event, it copies all properties of the object described in an expression in the scope

UbDispatchBinding 

Spoiler

Binding for a reaction to an event. 

 (bind dispatch "'listen_event'; 'dispatch_event'; arguments; direction; delay")

Listens to events with the name listen_event. This can be both a scope event and a DisplayObject event (e.g., a mouse click). When the event occurs it dispatches the event named dispatch_event with arguments (this should be an array) to the scope. Direction and delay are optional parameters. Direction sets a direction of the dispatched event, if it is 0 it goes up to parents, if 1 then down to children. The default setting is 0. Delay is a delay before dispatching the event in seconds. There is no delay by default, events are dispatched immediately.

Usage example:

 (bind dispatch "'click'; 'gotoReward'; [type, subtype]; 0; 1.2")

UbDispatchDelayResetBinding 

Spoiler

Binding for a reaction to an event resetting the only delay timer when the event occurs.

 (bind dispatchDelayReset "'listen_event'; 'dispatch_event'; arguments; direction; delay")

Apart from this, it’s identical to UbDispatchBinding.

UbChangeDispatchBinding 

Spoiler

Binding for changing a scope property.  

 (bind changeDispatch "property; 'dispatch_event'; arguments; direction; condition")

Listens to property changes in the scope. When a change occurs it dispatches the event named dispatch_event with arguments (this should be an array) to the scope with a delay of timeout seconds.  Direction and condition are optional parameters. Direction sets a direction of the dispatched event; if it is false it goes up to parents, if true then down to children. The default setting is false. Condition is a condition for dispatching the event. It is compared to property.

Usage example:

 (bind changeDispatch "contactsInfotipIsVIsible; 'sendClearSearch'; {}; true; false")

If the contactsInfotipIsVIsible changes, when it is false, the sendClearSearch event is dispatched. 

UbCountdownBinding 

Spoiler

Binding for visualizing the countdown text.

 (bind countdown "server_time_stamp; 'scope_field'; format")

This binding calculates the time remaining before server_time_stamp. The server_time_stamp value is a moment in server time in seconds in the Unix Timestamp format. The binding writes the current countdown value in scope_field as a line, in a format from the format parameter. If the format is not set, it writes it as HH:MM:SS.

Supported formats (the case matters):

  • yyyy - year
  • yy - year, 2 last characters
  • M - month, (1 or 2 characters)
  • MM - month, always 2 characters
  • d - day, (1 or 2 characters)
  • dd - day, always 2 characters
  • H - hours, (1 or 2 characters)
  • HH - hours, always 2 characters
  • m - minutes, (1 or 2 characters)
  • mm - minutes, always 2 characters
  • s - seconds, (1 or 2 characters)
  • ss - seconds, always 2 characters

You can also set 'HIGHEST' as the format parameter. Then one time difference value will be displayed, the highest one starting from months rounded up or down to the nearest value, stating the measurement unit.  For example, if the remaining time is 4 days, 21 hours, and 10 minutes, then the displayed value will be “5 d”; if the time is 2 hours 20 minutes then it will be “2 h”; if it is 45 minutes 40 seconds then it will be “46 min”.

The binding takes into account the difference between the server and client time. NO updates are required for stable operation.   

It is not recommended to use (bind text "scope_field") to display the countdown line as it results in updating block transformation every second (usually incrementally) and wasting the performance resource. You should use  (bind pureText "scope_field") if possible as it allows you to set the text field value while avoiding updating block transformations.

UbClockBinding

Spoiler

System time binding.

 (bind clock "'scopeFieldName'; timeFormat")

Writes the system time value in the timeFormat format in the scopeFieldName field of the current object with a one second interval.

scopeFieldName is a line setting the field name for the field showing the current time, for example 'currentSystemTimeText'

timeFormat is a line setting the time display format, for example 'hh:mm:ss'

UbContainsBinding

Spoiler

Checks whether an array or dictionary contains elements meeting the given condition.

 (bind contains "collection; condition; 'resultFieldName'; returnIndex; listOfPropertiesToView")

collection - an array or dictionary to be searched

condition - a condition

resultFieldName - a line setting the field name for the field where the result will be written

returnIndex - the fourth optional parameter. Its default setting is false. When opting for true, then an index of the first element meeting the requirements will be written in the scope instead of true/false.

listOfPropertiesToView is an optional parameter. Due to peculiarities of this binding the update call may not happen when a variable in the condition changes, therefore variables should be given separately. This is a temporary workaround therefore you should only use it to fix bugs in a situation when the resultFieldName field is not updated.

This binding traverses collection elements and checks if the condition is met for every element. If the condition is true at least for one element then true is written in resultFieldName, otherwise it is false.

You can call the current element of the iteration using the identifier $item. 

(bind controller "lesta.dialogs.controllers.EntitySingletonController; 'exteriorConfigSingleton'")
...
# You check if the _exteriors dictionary contains permanent camouflages. Then you write the result in the _hasInstalledPermoflages field of the current object in the scope.
# _exteriors contains elements PlayerShipInfoExterior that look like {id:String, goldAutorecharge:Boolean}
# exteriorConfigSingleton.config contains an exterior configuration ExteriorConfig that looks like {..., type:String, ..., isPermanent:Boolean, ...}
# $item points at the current element PlayerShipInfoExterior
# using $item.id you find the exterior configuration in exteriorConfigSingleton.config and check field values in type and isPermanent configuration
(bind contains "_exteriors; (exteriorConfigSingleton.config[$item.id].type == ExteriorTypes.CAMOUFLAGE) && (exteriorConfigSingleton.config[$item.id].isPermanent); '_hasInstalledPermoflages'")

UbFileBinding

Spoiler

Uploads a text from an external file and writes it in the scope.

 (bind file " 'myFile'; '../../someTextFile.txt' ")

Parameter 1 is a property name in the scope where the file content should be written. Parameter 2 is a path to the file. The path should be given to the folder containing swf (wows/game/res/gui/flash/)

UbEventSequenceBinding

Spoiler

Listens to the event in the scope and dispatches events from the given queue as a reply. If there are no events left in the queue, it dispatches an event notifying that the queue is empty.

 (bind eventSequence "['event1', 'event2', 'event3', 'event4']; 'give'; 'done'; direction")

Parameter 1 is an event array. Parameter 2 is an event that should be listened to. Parameter 3 (optional) is an event that should be dispatched when the queue of events in the array is over. In this example the binding will listen to the event 'give' and when it occurs for the first time it will dispatch 'event1', when it occurs for the second time - 'event2', etc. In case of the 5th and the next 'give' events it will dispatch 'done'. If you pass an object with arguments to the event 'give', then this object will go to the dispatched event. Parameter 4 (optional) is direction; it is a direction of the event. 0, 1 or 2 if you need to send the event up to parents, down to children or apply it to the scope only. Alternatively, use true/false similar to UbDispatchBinding.

UbTimeFormatBinding

Spoiler

Formats the timestamp taking the format and time zone into account

 (bind timeFormat "timeStamp; formatString; scopeName; useLocalTime")

Converts  timeStamp into a date in the formatString format and writes the finished line to the scope.

If  useLocalTime is given it uses the local time, otherwise it uses GMT.

Introduces the time zone into the field scopeName + "_TimeZone"

Attention: if the data comes in as the number of seconds starting from the beginning of the day (e.g., prime time for team battles) and is displayed as hh:mm, then to convert it to UTC correctly you need to add the number of seconds in 24 hours (86,400)

UbRestrictFeedbackBinding

Spoiler

Informs about correspondence of symbols put in the text field to the set regular expression.

(bind restrictFeedback "regexp; 'isWrongSymbol_scopeFieldName'")

Checks if the input symbol matches the regular expression regexp and writes the check result to the variable isWrongSymbol_scopeFieldName in the scope.

If it matches the regular expression, then the result is false, otherwise it is true.

UbIndexOfBinding

Spoiler

Browses the initial array, finds the first element match for set fields and values and writes the element index to the target scope field.
All fields and values should match, otherwise if there is no match in the initial array, -1 is written in the target field.
If there is no array or object or a scope name where the index should be written, then the index is not calculated and is not written in the scope.

(bind indexOf "sourceScopeName; targetScopeName; {key1: value1, key2: scopeValue2, ...}")
Example
(bind indexOf "personalTasksCollection; currentIndex; {'isPersonalTask': true, 'isDaily': false }")

UBAccountLevelBinding

Spoiler

(bind feature "param; event")

It binds interface elements to rewards/unlocks received when reaching a certain level.

  • param – if an element is added by the repeat binding, then it is a data field showing the feature number for this element, otherwise it is the number of the feature
  • event – It is an event when the isNew sign is deleted from the element

Examples: (bind feature "3; 'click'") is an ordinary element, (bind feature "'featureId'; 'click'") is a list element.

Features and their indices.

BATTLE_TUTORIAL  = 0x00000001
BATTLE_COOP      = 0x00000002 feature_1
BATTLE_JUNIOR    = 0x00000004
BATTLE_SENIOR    = 0x00000008 feature_3
RESEARCH_USE     = 0x00000010
FREE_EXP_USE     = 0x00000020 feature_5
FREE_EXP_TRANSIT = 0x00000040
SKILL_TREE_USE   = 0x00000080
DAILYQUESTS_USE  = 0x00000100 feature_8
SSE_USE          = 0x00000200 feature_9
GOLD_USE         = 0x00000400
CHAT_USE         = 0x00000800
MODERNIZATIONS   = 0x00001000 feature_12
CREWS            = 0x00002000 feature_13
EXT_SIGNALS      = 0x00004000 feature_14
EXT_CAMOUFLAGE   = 0x00008000 feature_15
RANK_BATTLES     = 0x00010000 feature_16
NATIONS_TREE     = 0x00020000 feature_17
SSE              = 0x00040000
CLUBS            = 0x00080000 feature_19
ARMOR_VISIBLE    = 0x00100000

SFMRequestBinding and SFMActionBinding

Spoiler

It dispatches an event with set parameters to SFM. The difference is that SFM dispatches an event from action to Python immediately while ‘request’ causes a change in the SFM state resulting in taking a decision on dispatching the event and its data to Python.

 (bind request "'event_name';'action_name';{propertyName: propertyValue, propertyName1: propertyValue1}")
 (bind action  "'event_name';'action_name';{propertyName: propertyValue, propertyName1: propertyValue1}")

event_name – an event expected by the binding

action_name – an event dispatched to SFM 

{} – an object dispatched to SFM together with the event

FocusBinding

Spoiler

(bind focus "tabIndex;defaultFocused")

It makes a CLIK element focusable. It ensures correct operation of the focus when there are several windows on the screen. The focus works in the upper window only.  

tabIndex – a sequence number when tab-shifting the focus

defaultFocused – if the element should be focused when opening the window

Note: All CLIK elements are not focusable by default; you can make then focusable only with the help of this binding.

InputMappingBinding

Spoiler

(bind input)

When clicking on the block, it forwards the "gui.block_name" event to SFM where block_name is substituted by the name of the block.
Note: it is necessary to set (name block_name) for correct operation

UbScopeTraceBinding

Spoiler
(bind scopeTrace)
trace("$ScopeTrace")

It writes the entire scope content in the "$ScopeTrace" field in the scope. It is updated dynamically when the scope changes. 

Do not use in Production.

UbSubstituteBinding

Spoiler

(bind substitute "<imageOffset>; <substitutionMap>; <sourceText>; <prefix>")

It’s a binding replacing substrings with images in text fields. 

Parameters:

<Presets> - a line containing a list of presets separated by commas. The only preset implemented now is "KEYS"; it substitutes mentions of keybuttons [KEY_NAME] for images;

important You should avoid using presets unless it is a substantiated necessity and set specific substitutes via the substitutionMap instead.

<imageOffset> - shifting the image vertically against the text baseline;

<substitutionMap> - an optional parameter

{
    'key1':'icon_bitmap_1',
    'key2':'icon_bitmap_2'
}

Binding a text substring to a certain image.

important ONLY Bitmap static images can be used for substitution. Attempts to use Shape or MovieClip will results in crashes.

Examples:

To substitute all key button mentions for images with the vertical shift by 5:

(bind substitute "5; null; 'Press [KEY_LEFTMOUSE]'")

To substitute the "[DOUBLECLK]" text for the double-click icon

(bind substitute "5; {'[DOUBLECLK]':'[LEFTMOUSE_DOUBLE]'}; _externalText")

UbEventPlaySoundBinding

Spoiler

(bind soundOn "event; sound_name[; set_name]")

It binds interface element events or scope element events to playing a sound.

  • event – an event that triggers playing a sound;
  • sound_name – the sound name from the preset;
  • set_name - a name of the soundSet to select the sound from it; the soundSet of the current component is used by default if it is UbBlock. This parameter is optional only if the binding is related to UbBlock; otherwise it is obligatory and will cause crashes if it is not set;

Sound names called automatically by interface events:

Sound Action UIComponent UIButton UbBlock
State events

show
Visible -> true Y Y Y

hide
Visible -> false Y Y Y
Mouse events

out
mouse out   Y Y

click
mouse button up over control   Y Y

over
mouse over   Y Y

press
mouse button down   Y Y

select
custom logic   Y  

unselect
custom logic   Y  
Other events

press_hotkey
(hotkey manager)      

release_hotkey
(hotkey manager)      

list_expend
(CLIK dropdown menu)      

index_change
(CLIK list, dropdown menu)      

change
(CLIK slider, textinput)      

focused
(FocusHandler) Y Y  

scroll
(JellyScrollbar, Scrollindicator)      

enter
(FocusHandler textInput)      

The difference between press and click is the following: press is played when the mouse button is pressed above CTRL, and click is played when the mouse button is released.

Available soundSet:

  • default_component
  • default_button, hard_button, pause_login
  • default_checkbox
  • default_dropmenu
  • default_list
  • default_textinput, hard_textinput
  • default_listitem
  • default_listitem
  • dropmenu_button
  • weapon_control_button

The binding works together with (bind soundSet) and (bind enabled).

(bind soundSet 'preset_name')

It sets the soundSet value in the 'preset_name' line

important The soundSet is placed in an empty line by default, it does not produce any sounds and it is not subscribed to any mouse events.   

important When installing soundSet, UbBlock subscribes to 5 mouse events: ROLL_OVER, ROLL_OUT, MOUSE_DOWN, CLICK, DOUBLE_CLICK that can and will impact performance if these blocks are quite numerous.

info 100% When only one event is required from UbBlock it is preferable to use (bind soundOn).

(bind enabled "condition")

sets the enabled (true/false) value to switch events on/off by click/press.

DesignerCollectionBinding

Spoiler

This is a binding allowing tech artists to sort and filter collections.

It accepts either a datahub collection or a similar designer collection (that should be announced before usage) as an input. It is possible to expand the class of acceptable collections by adding a code to the actionscript 

(bind collectionDesign "'DES_' + parentCollectionNameInScope; designCollectionNameInScope; filterObject")

The filterObject is an object that consists of 3 fields:

  • filter - a function containing variables from the scope, constants and $entity (a collection element). Example:
$entity.crew.nationIndex + $entity.crew.level >= maxLevel + 5
  • sort - a list of entity fields included in sorting
  • sortOrder - a list of sorting parameters - SortType.DESCENDING is descending sorting,  SortType.CASEINTESITIVE is descending sorting,  0 is no flag

A complete example:

(bind collectionDesign "'DES_' + someScopeName; designCollectionNameInScope; {  'filter':$entity.crew.nationIndex + $entity.crew.level >= maxLevel + 5,
                                                                                'sort':['crew.nationIndex', 'crew.level', 'crew.name'],
                                                                                'sortOrder':[SortType.DESCENDING, 0, SortType.CASEINTESITIVE]}")

There can be no fields in the filter object, so if only sorting is required then the 'filter' field is omitted.

If the source (a data hub collection) is not sorting and filtering and only depends on a component, then it is possible to use the following replace

DESIGN_COLLECTION_COMPONENT("CC.crew", "'crewsCollection'""{'filter':!$entity.crew.isHistory, 'sort':['crew.nationIndex', 'crew.recentIndex', 'crew.level']}")

ConcatBinding

Spoiler

This is a binding allowing you to merge several collections

(bind concat "childCollectionNameInScope; [parentCollection1,..., parentCollectionN]")

ClipboardBinding

Spoiler

It copies a line from the scope to the buffer triggered by a certain event, at the moment this event occurs

(bind clipboard "'click'; scopeVar")

ColorTransformBinding

Spoiler

It applies a property of the scope object to the block property transform.colorTransform

(bind colorTransform "{
                       redMultiplier:1,
                       greenMultiplier:1,
                       blueMultiplier:1,
                       alphaMultiplier:1,
                       redOffset:0,
                       greenOffset:0,
                       blueOffset:0,
                       alphaOffset:0
  }")

SliceBinding

Spoiler

It allows splitting the collection into parts and creates collection slices.  

(bind slice "'outputCollectionNameInScope'; sourceCollectionNameInScope; startIndex; endIndex")

 

  • outputCollectionNameInScope – The property name in the scope where the result will be written.
  • sourceCollectionNameInScope – The collection a part of which is selected. If it is a collection from the datahub then the name format should be DES_collectionName.
  • startIndex – The number indicating the index for the starting slicing position. It is 0 by default.
    If startIndex is a negative number, the array end becomes a starting position with its last element assigned the “-1” position.
  • endIndex – The number indicating the index for the last slicing position.  If this position is left blank, the slice will include all elements from the starting positions to the end of the array.
    If endIndex is a negative number, the end position is the array's end, the last array element is assigned the “-1” position.  

 

Example
(bind collectionDH "CC.ownShip; 'playerShips'")
(bind slice "'sample1'; DES_playerShips; 0; 4")     # a slice of the playerShips collection containing elements playerShips[0], playerShips[1], playerShips[2], playerShips[3]
(bind slice "'sample2'; sample1; -1")               # a slice of the sample1 collection containing one last element sample1[sample1.length - 1]
(bind slice "'sample3'; sample1")                   # a copy of the sample1 collection

ResourceBinding

Spoiler

It uploads external resources via ResourceLoadingDelegator (it is required to play videos).

(bind resource "videoURL; scopeName; scopeEvent")
  • videoURL – a resource path.
  • scopeName – a name in the scope where the resource ID should be written
  • scopeEvent (optional) – an event name that should be dispatched when uploading ends. The event will be followed by an object with the only ‘success’ field containing a true or false value depending on the success of the upload.

 

Example
(bind resource "'./gui/video/level_up.usm'; 'levelUpResourceId'; 'videoReady'")

DHCollectionGeneratorBinding

Spoiler

It is similar to UbRepeatBinding but for collections from DataHub.
It supports dynamic upload and download of elements drawing just the part that really fits into the parent container.

(bind generatorDH "DataHubCollectionName; 'ItemRenderer'; 'sortBy'; {propertyName: propertyValue, ...}")

where:

  • DataHubCollectionName — a collection name in the DataHub;
  • ItemRenderer — the name of the class that will be used for display (similar to UbRepeatBinding;
  • sortBy — the field to sort the data by. If no sorting is required an empty line ''should be dispatched;
  • {propertyName: propertyValue, ...} — A set of variables that will be dispatched to the scope. It can be empty.


Its use is recommended if there can be any number of input elements (more than 10). A good example is a replay list:

(bind generatorDH "CC.replayMetadata; 'ReplaysTableRow'; ''; {_data: data, selectedTabIndex: selectedTabIndex}")

Mandatory condition

This binding should be placed in the container with the following styles set for it:

(overflow scroll)
(layout "<layout>")
(wheelScrollSpeed 45)
(itemWidth <number>px)
(itemHeight <number>px)

where <layout> is one of those described in the lesta.unbound.layout.measure package.
You can use the carousel for an ordinary list with vertical scrolling:

(layout "lesta.unbound.layout.measure.CarouselLayout")

If even one of these styles is not set the generator will not work (data will not be displayed).

GSTimelineBinding

Spoiler

It launches animation with the help of GreenSock TimelineMax: it creates the Timeline with tweens and manages them.

(bind timeline "startEvents;    timelineProps; tweensArray; (optional)timelineEvents; (optional)timelineSettings")

where:

  • startEvents are animation start events. There are three ways to set them:
    • As a line:
      (bind timeline "'rollOver'; {}; [0.2, {colorMatrixFilter: {saturation: 1}}]")

      Animation starts when the event with the set name occurs.
    • As a line array:
      (bind timeline "['addedToStage', 'rollOut'];    {}; [0.2, {colorMatrixFilter: {saturation: 0}}]")

      Animation starts when any of the set events occurs.
    • As an object with the ‘event-function’ match:
      (bind timeline "{addedToStage: 'play', rollOver: ['reverse', 0], rollOut: ['play', [0]]};   {}; [0.2, {colorMatrixFilter: {index: 0, saturation: 0}}]; [] ")

 

  • timelineProps  - timeline properties; the same properties that can be used in the TimelineMax according to GreenSock documentation.
(bind timeline "'addedToStage';
                {repeat: -1, repeatDelay: 2, yoyo: true};
                [3, {x: 1000, radius:70, ease:Easing.Bounce.easeOut}, 5, {x: 1500, radius:20, ease:Easing.Bounce.easeIn}]
            ")
  • Call-backs can also be used as parameters: onStart, onUpdate, onComplete, onReverseComplete, onRepeat. Their values are event names that should be dispatched when calling respective call-backs.
  • tweensArray - a tween array where tween time and tween parameters alternate each other (that is, the array length is always even). The length is given in seconds, animation parameters are the same as for an ordinary GreenSock tween. Easings have GreenSock constants.
  • timelineEvents - an optional parameter marking events that should be sent to the Scope when a certain place on the timeline is played.
(bind timeline "'addedToStage';
                {};
                [3, {x: 1000, radius:70, ease:Easing.Bounce.easeOut}, 5, {x: 1500, radius:20, ease:Easing.Bounce.easeIn}];
                [5, 'frameEvent1', {animState: 'A'}, 7, 'frameEvent2', {animState: 'C'}]
            ")
  • This is an array containing alternating positions, the event name and event data (so its length is divisible by thee).
  • timelineSettings - an optional parameter binding timeline setters to scope properties, such as delay, duration, paused, reversed, timeScale and totalDuration. This object is a match between a timeline property → a scope name (a line).

WowsResizeBinding

Spoiler

It instantiates a resizable object (for example, such as a chat window in the port).

(bind resize "gripName;  directions; userPrefsWidthName; userPrefsHeightName; subSectionName")

 

  • gripName - a name of a child clip, clicking on it initiates dragging
  • directions – how to change the size when dragging. It is a line with directions, separated by a comma. For example, 'down,right' or 'up,left'. It’s impossible to resize in opposite directions at the same time (up, down or left, right).
  • userPrefsWidthName - a name in userPrefs for saving (or reading) the object’s width.
  • userPrefsHeightName - a name in userPrefs for saving (or reading) the object’s height.
  • subSectionName - optional. This is a subsection name in userPrefs.

UbFadeBinding

Spoiler

This is a variant of UbTransitionBinding hiding the object in the initial animation stage.

UbPluralTextBinding

Spoiler

It applies a numeral in the required word form for the number.

(tf
  (bind pluralText "'IDS_PL_PLAYERS_COUNT'; count")
)

It is applied to a text field as it changes the text property of the object it is bound to. 

UbContextMenuBinding

Spoiler

This is syntactic sugar for UbTooltipBinding with context menu behavior.

(bind menu "'ShipTreeMenu'; { shipId: shipId, _disableShipActions: _disableShipActions }")

UbBlurLayerBinding, UbBlurMapBinding

Spoiler

They mark blocks they are bound to as layers for blurLayer / blurMap, respectively.

UbWatchBinding

Spoiler

It writes the expression value in the scope variable and updates it whet the expression changes.

(bind watch "'nameInScope'; (stageHeight - 124 - 62 - (10 + (stageHeight - 720) * 0.36))")

ActionIsDisplayBinding

Spoiler

It dispatches the action... event to SFM when a block bound by the binding is displayed and hidden.

(bind actionIsDisplay "actionName; ")
  • actionName - the name of the event to be dispatched
  • actionData - optional. This is the data that should be dispatched with the event.

UbRepeatWithScopeHoldBinding

Spoiler

DEPRECATED — using it is not recommended.
The difference between this binding and the ordinary UbRepeatBinding is that it binds child scopes not to the element’s index but to the id from the element data, which allows keeping data binding to a certain element when sorting changes.

(bind scopeHoldRepeat "array; elementName; idGetter; externalData")
  • array - an array where repeat occurs
  • elementName - an element name from Item Renderer
  • idGetter - an expression returning the scope id from a child element of the array  
  • externalData - optional. This is additional data in the scope.

UbStageSizeBinding

Spoiler

It places data about the stage size in scope fields stageWidth, stageHeight, uiScale and dispatches the stageResize event when they change.

UBClickSplitBinding

Spoiler

When clicking on an object, it dispatches events 'left_click', 'right_click', 'middle_click' together with the event depending on which mouse button was clicked.

UbLinearChartBinding

Spoiler

It draws a linear diagram based on given data in the block it is bound to.

UBServerTimeBinding

Spoiler

It puts the current server time (timestamp) in the scope field named serverTimeFieldName and also puts the number of the day in a week there if an optional parameter dayFieldName is given.

(bind serverTime "serverTimeFieldName; dayFieldName")

UbFeatureCheckBinding

Spoiler

It checks if the feature is available for the account level and puts the check result in the scope.

(bind levelToFeature "accountLevel; featureId; 'resultFieldName'")
  • accountLevel - the account level
  • featureId - the feature id, for example, 19 is team battles
  • resultFieldName - the field name where the result should be written (as a line)

UbGeneratorBinding

Spoiler

This is an optimized equivalent of repeat for the playing layout. It is necessary to have non-zero itemWidth and itemHeight in the block where it is used.

(hblock
   (style
      (width 100%f)
      (scrollbarController "lesta.unbound.style.UbScrollingControllerTouch")
      (layout "lesta.unbound.layout.measure.CarouselLayout")
      (itemWidth 416)
      (itemHeight 440)
   )
 
   (bind controller "lesta.unbound.controls.UbCarouselController")
   (bind generator "_repeatCollection; _repeatElement; externalData")

The difference between it and the ordinary repeat is that it does not create all elements at once but creates and displays only those elements that are on the screen. The first three parameters are the same as in case of repeat: the array, the element name and additional data.

UbInOutActionBinding

Spoiler

It dispatches events when the element appears on stage and leaves the stage.

(bind inoutAction "'showAction'; 'hideAction'; externalData")
  • showAction - an event when the element appears
  • hideAction - an event when the element disappears
  • externalData - additional data for the event

UbIMEEnableBinding

Spoiler

It searches for a child text field in the block and switches a language panel for hieroglyphic languages for it.

(bind imeEnable)

 

Share this post


Link to post
Share on other sites
Administrator
16 posts
20 battles

DataHub 2.0 Binding List

DHCollectionRepeatBinding

Spoiler

(bind collectionRepeatDH "ComponentClassID; itemRenderer; path; extraData; useInvertedDirection")

It operates similar to repeatBinding, but browses not the dispatched array but a collection in DataHub. Parameters:

  • ComponentClassID - a component class ID, they are dispatched to the scope as "CC" constants (an abbreviation of ComponentClass). For example, CC.crew, CC.channel
  • itemRenderer - an element name, similar to RepeatBinding.
  • path - an optional parameter showing the path to a child collection. For example, if you don’t need all crews, but only Japanese crews sorted by level, then the path will be like this: 'japan.sortByLevel'. Corresponding collections must be created in DataHub.
  • extraData - additional data for the element. If in is null then the binding will not process it. 
  • useInvertedDirection - the element display order (forward/reverse order). The default value is forward (false).

DHCollectionGeneratorBinding

Spoiler

This is an equivalent of UbGeneratorBinding optimization, but for DataHub collections. Parameters are the same as for DHCollectionRepeatBinding but without useInvertedDirection. Pros and restrictions are the same as for UbGeneratorBinding.

 (bind generatorDH "ComponentClassID; itemRenderer; path; extraData")

DHCollectionBinding

Spoiler

It retrieves a collection (as an array of entities) from DataHub and writes it into the scope.

 (bind generatorDH "ComponentClassID; scopeField; path")
  • ComponentClassID - a component class ID, they are dispatched to the scope as "CC" constants (an abbreviation of ComponentClass). For example, CC.crew, CC.channel
  • scopeField - a field in the scope where the collection will be written.
  • path - an optional parameter showing the path to a child collection. For example, if you don’t need all crews, but only Japanese crews sorted by level, then the path will be like this: 'japan.sortByLevel'. Corresponding collections must be created in DataHub

DHEntityBinding

Spoiler

It retrieves an entity from DataHub by its id and writes it in the scope.

 (bind entityDH "'scopeField'; entityId")
  • scopeField - a scope field where the entity will be written.
  • entityId - an entity id in DataHub

DHHandleEventBinding

Spoiler

It listens to the component event and dispatches the event to the scope based on that.

 (bind handleEventDH "path; event; externalData; direction")
  • path is a path to the event that we listen to in the scope. For example, 'someEntity.ssomeComponent.evSomeEvent'
  • event - an event name that should be dispatched 'evSomethingHappened'
  • externalData - optional (additional data for the event).
  • direction - optional. It is an event direction (similar to UbDispatchBinding).

DHWatchBinding

Spoiler

It retrieved a value from the component and keeps track of its updates.

 (bind watchDH "'scopeField'; eventsArray ; entity.component.value")
  • scopeField - a scope field where the value will be written.
  • eventsArray - an array of events where the value changes. For example, ['entity.component.evChangeEvent']
  • entity.component.value - a value that should be taken.

DHDataRefBinding

Spoiler

It keeps track of updates for the entity bound to the element scope, and dispatches a link to it to the scope. It is used inside elements used in DHCollectionRepeatBinding and DHCollectionGeneratorBinding.

 (bind dataRefDH "'entity'; '$dataRef.ref'")

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×