User Tools

Site Tools


democap:behavior_ecbdesktoplanguagechanged

ECBDesktopLanguageChanged

Behavior calling onTranslationChanged on ECBehaviorRenderableDesktop if language changed global event is send.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix desktopLanguageChanged..

Events

This behavior has no events.

Conversation Commands

This behavior adds no conversation commands.

Conversation Conditions

This behavior adds no conversation conditions.

Behavior Tree Actions

This behavior adds no behavior tree actions.

Behavior Tree Conditions

This behavior adds no behavior tree conditions.

Required Behaviors

Optional Behaviors

This behavior does not support optional behaviors.

API Documentation

Since DEMoCap Version 1.3

Use Cases

  • Update widget translation in renderable desktop behavior if language setting changed.

Element Class Example

Give an example. Has to include at least all behavior dependencies so it should at least prodduce a valid element class.

class MyElement extends BehaviorElementClass
  public var ECBehaviorComponent component
   public var ECBehaviorCollider collider
   public var ECBehaviorDynamicSkin dynamicSkin
   public var ECBehaviorRenderableDesktop renderableDesktop
   public var ECBDesktopLanguageChanged desktopLanguageChanged
   
   public func new() super("ExampleElement")
     // add required behaviors component and collider
     component = ECBehaviorComponent.new(this)
     collider = ECBehaviorCollider.new(this, component)
     
     // add dynamic skin to modify component
     dynamicSkin = ECBehaviorDynamicSkin.new(this, component)
     
     // create renderable desktop. the skin has to use a renderable named "board".
     // the panel has a size of 1024x1024 and uses gui theme loaded from "adboard.guitheme.xml".
     // the desktop uses by default a stack layout hence all widgets added fill the
     // entire desktop space and are layered ontop of each other. any behavior can
     // change the layout used for the desktop if required
     renderableDesktop = ECBehaviorRenderableDesktop.new(this, dynamicSkin)
     renderableDesktop.getRenderable().setValue("board")
     renderableDesktop.getSize().setPoint(Point.new(512, 256))
     renderableDesktop.getGuiTheme().setPath("/content/ui/adboard.guitheme.xml")

     // here you could now add behaviors adding content to the renderable.
     // the simply have to create (during their init(StubElement) call) one or more widgets
     // adding them to the renderable. using behavior makes this a reusable process
     //
     // MyContentBehavior.new(this, renderableDesktop)
     
     // update translations if language setting changed
     desktopLanguageChanged = ECBDesktopLanguageChanged.new(this, renderableDesktop)
   end
end

Behavior Factory

Using element class supporting adding behaviors the behavior can be added like this (again create an example which creates a valid element class):

<?xml version='1.0' encoding='UTF-8'?>
<elementClass name='MyClass' class='GenericBehaviorElement'>
  <behavior type='ECBehaviorComponent'/>
  <behavior type='ECBehaviorCollider'/>
  <behavior type='ECBehaviorDynamicSkin'/>
  <behavior type='ECBehaviorRenderableDesktop'>
    <string name='.renderable'>display</string>
  </behavior>
 
  <behavior type='ECBDesktopLanguageChanged'/>
</elementClass>

Live Examples

You could leave a comment if you were logged in.
democap/behavior_ecbdesktoplanguagechanged.txt · Last modified: 2025/03/22 17:33 by dragonlord