User Tools

Site Tools


dragengine:modules:dragonscript:behavior_customcolor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dragengine:modules:dragonscript:behavior_customcolor [2020/12/20 23:24] – [ECBehaviorCustomColor] dragonlorddragengine:modules:dragonscript:behavior_customcolor [2025/03/13 17:05] (current) dragonlord
Line 1: Line 1:
 {{tag>dragonscript behavior}} {{tag>dragonscript behavior}}
 <WRAP youarehere> <WRAP youarehere>
-[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorCustomColor**+[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[dragengine:modules:dragonscript:abstractions|Abstraction Layers: How you want to build your Game]] >> [[dragengine:modules:dragonscript:behavior_elements|Behavior Elements]] >> **ECBehaviorCustomColor**
 </WRAP> </WRAP>
  
Line 8: Line 8:
  
 ====== ECBehaviorCustomColor ====== ====== ECBehaviorCustomColor ======
- 
-Behavior element behavior adding custom color support. 
- 
-Custom colors are typically used to allow players to customize the look of their player actor by altering the color of individual body parts. This behavior allows to define custom color slots the player or artist can manipulate. This behavior does not define how custom colors are applied. This is left for other behaviors or game scripts to do. 
- 
-Custom colors compose of a display name and the currently assigned color. This color can be null to use the assigned default color. An optional list of colors can be used to restrict the colors the player can select. If the list is empty the player can choose the color unrestricted. In addition a display description can be added in case the game developer would like to communicate additional information about the custom color. 
  
 <WRAP center 100%> <WRAP center 100%>
 <WRAP center box 450px> <WRAP center box 450px>
-{{youtube>Gte74Jte8A0 ?medium}}+{{youtube>Gte74Jte8A0?medium}}
 <WRAP centeralign>Behavior in action</WRAP> <WRAP centeralign>Behavior in action</WRAP>
 </WRAP> </WRAP>
 </WRAP> </WRAP>
 +
 +Behavior element behavior adding custom color support.
 +
 +Custom colors are typically used to allow players to customize the look of their player actor by altering the color of individual body parts. This behavior allows to define custom color slots the player or artist can manipulate. This behavior does not define how custom colors are applied. This is left for other behaviors or game scripts to do.
 +
 +Custom colors compose of a display name and the currently assigned color. This color can be null to use the assigned default color. An optional list of colors can be used to restrict the colors the player can select. If the list is empty the player can choose the color unrestricted. In addition a display description can be added in case the game developer would like to communicate additional information about the custom color.
  
 ====== Instance Counts ====== ====== Instance Counts ======
Line 43: Line 43:
  
 ===== allowedColors ===== ===== allowedColors =====
-Optional list of allowed colors. If this list is not empty the player is only allowed to select one of the colors from this list. If the list is empty all colors are allowed. Typically this means the UI shows a list or combo box instead of a set of sliders for each color component. In XML Element Class files this is defined as a list-tag containing color-tag entries. In Stub Properties this is encoded in the form "r1,g1,b1 r2,g2,b3 ..." with rX,gX,bX defining the Xth color (you can use also newline instead of spaces).+Optional list of allowed colors. If this list is not empty the player is only allowed to select one of the colors from this list. If the list is empty all colors are allowed. Typically this means the UI shows a list or combo box instead of a set of sliders for each color component. In XML Element Class files this is defined as a list-tag containing color-tag entries. 
   * Full name: "customColor.allowedColors" or "customColor({id}).allowedColors"   * Full name: "customColor.allowedColors" or "customColor({id}).allowedColors"
-  * Type: list of color (3-component)+  * Type: list of color (3-component) or string
   * Default Value: empty list   * Default Value: empty list
   * Example (*.deeclass) <code xml><list name='customColor(body).allowedColors'>   * Example (*.deeclass) <code xml><list name='customColor(body).allowedColors'>
Line 52: Line 53:
   <color r='0' g='0' b='1'/>   <color r='0' g='0' b='1'/>
 </list></code> </list></code>
 +  * Example (*.deeclass) <code xml><string name='customColor(body).allowedColors'>"1 0 0" "0 1 0" "0 0 1"</string></code>
  
 +In stub properties the coding is of the form "color1 color2 ..." where color is encoded as "r g b". Since both uses space to separate tokens colors have to be wrapped in double quotes. This looks like the second example above. For easier reading and editing the first version (list version) is recommended to be used in XML Element Class files. The second form can be used to directly copy/paste stub property strings between XML/stub without needing to change the formatting.
 ===== defaultColor ===== ===== defaultColor =====
 Sets the default color for the custom color. If the user selects no color (null value) then the default color is used. This can also be used to reset the color to the default color. Sets the default color for the custom color. If the user selects no color (null value) then the default color is used. This can also be used to reset the color to the default color.
Line 68: Line 71:
   * Example (*.deeclass) <code xml><null name='customColor(body).color'/><!-- force no color set --></code>   * Example (*.deeclass) <code xml><null name='customColor(body).color'/><!-- force no color set --></code>
  
-===== Events =====+====== Events ======
  
 Since this behavior provides no support to apply the chosen color listening is used. Behaviors knowing how to apply the color add a listener and are notified if the color changes. These events can be received: Since this behavior provides no support to apply the chosen color listening is used. Behaviors knowing how to apply the color add a listener and are notified if the color changes. These events can be received:
  
-==== colorChanged ====+===== colorChanged =====
  
 Selected color changed. Use behavior to get the newly set color. Selected color changed. Use behavior to get the newly set color.
Line 90: Line 93:
 ====== API Documentation ====== ====== API Documentation ======
  
-[[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Scenery_1_1ECBehaviorCustomColor.html|ECBehaviorCustomcolor]].+#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorCustomColor.html,ECBehaviorCustomcolor~@#.
  
 Since DragonScript Module Version **1.5** Since DragonScript Module Version **1.5**
Line 110: Line 113:
   end   end
 end end
 +</code>
 +
 +====== Behavior Factory ======
 +
 +Using element class supporting adding behaviors the behavior can be added like this:
 +<code xml>
 +<?xml version='1.0' encoding='UTF-8'?>
 +<elementClass name='MyClass' class='GenericBehaviorElement'>
 +  <behavior type='ECBehaviorCustomColor'>
 +    <!-- set element properties. omit property prefix if used inside behavior tag -->
 +    <string name='.name'>Color 1</string>
 +  </behavior>
 +  
 +  <!-- for adding multiple behaviors use unique identifiers -->
 +  <behavior type='ECBehaviorCustomColor' id='second'/>
 +</elementClass>
 </code> </code>
  
dragengine/modules/dragonscript/behavior_customcolor.1608506671.txt.gz · Last modified: 2020/12/20 23:24 by dragonlord