| Next revision | Previous revision |
| dragengine:modules:dragonscript:behavior_renderablepanel [2020/09/13 15:09] – created dragonlord | dragengine:modules:dragonscript:behavior_renderablepanel [2025/03/22 19:47] (current) – [Behavior Factory] dragonlord |
|---|
| {{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]] >> **ECBehaviorRenderablePanel** | [[: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]] >> **ECBehaviorRenderablePanel** |
| </WRAP> | </WRAP> |
| |
| Behavior element behavior adding a renderable Panel widget. | Behavior element behavior adding a renderable Panel widget. |
| |
| This behavior is useful for models with a complex dynamic texture where the content of the texture is provided by a [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Gui_1_1Panel.html|Panel]] widget. Multiple other behaviors can add their content [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Gui_1_1Widget.html|Widget]] to the [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Gui_1_1Panel.html|Panel]] separating logic for reuse. Using **ECBehaviorRenderablePanel** instead of [[behavior_renderablecanvas|ECBehaviorRenderableCanvas]] allows to use the full power of the GUI ToolKit including using [[dragengine:modules:dragonscript:guitheme|Gui Themes]] to create complex content easily. | This behavior is useful for models with a complex dynamic texture where the content of the texture is provided by a #@LinkApiDocDEDS2_HTML~classDragengine_1_1Gui_1_1Panel.html,Panel~@# widget. Multiple other behaviors can add their content #@LinkApiDocDEDS2_HTML~classDragengine_1_1Gui_1_1Widget.html,Widget~@# to the #@LinkApiDocDEDS2_HTML~classDragengine_1_1Gui_1_1Panel.html,Panel~@# separating logic for reuse. Using ECBehaviorRenderablePanel instead of [[behavior_renderablecanvas|ECBehaviorRenderableCanvas]] allows to use the full power of the GUI ToolKit including using [[dragengine:modules:dragonscript:guitheme|Gui Themes]] to create complex content easily. |
| |
| The default layout for the [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Gui_1_1Panel.html|Panel]] is [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Gui_1_1Layouts_1_1StackLayout.html|StackLayout]]]. The default gui theme is //"/shareddata/guithemes/modern/modern.guitheme.xml"//. The default [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Gui_1_1Panel.html|Panel]] designer selector is //"RenderablePanel"//. | The default layout for the #@LinkApiDocDEDS2_HTML~classDragengine_1_1Gui_1_1Panel.html,Panel~@# is #@LinkApiDocDEDS2_HTML~classDragengine_1_1Gui_1_1Layouts_1_1StackLayout.html,StackLayout~@#]. The default gui theme is //"/shareddata/guithemes/modern/modern.guitheme.xml"//. The default #@LinkApiDocDEDS2_HTML~classDragengine_1_1Gui_1_1Panel.html,Panel~@# designer selector is //"RenderablePanel"//. |
| |
| To use this behavior add an [[behavior_dynamicskin|ECBehaviorDynamicSkin]] to the element class before adding this behavior. Create **ECBehaviorRenderablePanel** behavior and set the dynamic skin and designer selector and [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Gui_1_1GuiTheme.html|GuiTheme]] for the [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Gui_1_1Panel.html|Panel]]. Now you can add other behaviors targeting the ECBehaviorRenderablePanel to add [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Gui_1_1Widget.html|Widget]] resources to. | To use this behavior add an [[behavior_dynamicskin|ECBehaviorDynamicSkin]] to the element class before adding this behavior. Create ECBehaviorRenderablePanel behavior and set the dynamic skin and designer selector and #@LinkApiDocDEDS2_HTML~classDragengine_1_1Gui_1_1GuiTheme.html,GuiTheme~@# for the #@LinkApiDocDEDS2_HTML~classDragengine_1_1Gui_1_1Panel.html,Panel~@#. Now you can add other behaviors targeting the ECBehaviorRenderablePanel to add #@LinkApiDocDEDS2_HTML~classDragengine_1_1Gui_1_1Widget.html,Widget~@# resources to. |
| |
| The [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Gui_1_1Panel.html|Panel]] is created with a default size of 512x512 . You can change the size using the element property to fit the texture requirements. | The #@LinkApiDocDEDS2_HTML~classDragengine_1_1Gui_1_1Panel.html,Panel~@# is created with a default size of 512x512 . You can change the size using the element property to fit the texture requirements. |
| | |
| | See also: |
| | * [[gamedev:renderables|Dynamic Content using Renderables]] |
| | * [[dragengine:modules:dragonscript:guitheme|Gui Themes]] |
| | * [[gamedev:deigde:editors:skin|IGDE Skin Editor]] |
| |
| ====== Instance Counts ====== | ====== Instance Counts ====== |
| |
| Multiple instances of **ECBehaviorRenderablePanel** can be added to affect individual dynamic skin textures. The example below uses one component with one dynamic skin to two individual renderables named //"content1"// and //"content2"// each allowing to be individiaully filled with content by different behaviors. | Multiple instances of ''ECBehaviorRenderablePanel'' can be added to affect individual dynamic skin textures. Use the behavior identifier to tell them apart. |
| | |
| <code> | |
| class MyElement extends BehaviorElementClass | |
| public func new() | |
| ECBehaviorComponent.new(this) | |
| ECBehaviorDynamicSkin.new(this) | |
| | |
| ECBehaviorCanvas.new(this) | |
| ECBehaviorCanvas.new(this, "canvas2") | |
| | |
| var ECBehaviorRenderablePanel behavior = ECBehaviorRenderablePanel.new(this) | |
| behavior.getRenderable().setValue("content1") | |
| behavior.getGuiTheme().setPath("/content/renderable.guitheme.xml") | |
| behavior.getDesignerSelector().setValue("Panel.MyElement") | |
| | |
| behavior = ECBehaviorRenderablePanel.new(this, "renderablePanel2") | |
| behavior.setBackgroundColor(Color.blue) | |
| behavior.getRenderable().setValue("intensity2") | |
| behavior.getGuiTheme().setPath("/content/renderable.guitheme.xml") | |
| behavior.getDesignerSelector().setValue("Panel.MyElement") | |
| end | |
| end | |
| </code> | |
| |
| ====== Element Class Properties ====== | ====== Element Class Properties ====== |
| |
| Element class properties have the prefix **renderablePanel.** or **renderablePanel(id).** if id is not empty. | Element class properties have the prefix ''renderablePanel.'' or ''renderablePanel(id).'' if id is not empty. |
| |
| ===== renderable ===== | ===== renderable ===== |
| Name of the [[gamedev:renderables|renderable]] in the component skin to modify. | Name of the renderable in the component skin to modify. |
| * Full name: "renderablePanel.renderable" or "renderablePanel(id).renderable" | * Full name: ''renderablePanel.renderable'' or ''renderablePanel(id).renderable'' |
| * Type: string | * Type: string |
| * Default Value: "" (empty string) | * Default Value: empty string |
| * Example (*.deeclass): <code xml><string name='renderablePanel.renderable'>monitor content</string></code> | * Example (*.deeclass): <code xml><string name='renderablePanel.renderable'>monitor content</string></code> |
| |
| ===== size ===== | ===== size ===== |
| Size of panel in pixels. | Size of panel in pixels. |
| * Full name: "renderablePanel.size" or "renderablePanel(id).size" | * Full name: ''renderablePanel.size'' or ''renderablePanel(id).size'' |
| * Type: [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Gui_1_1Point.html|Point]] | * Type: point |
| * Default value: (512, 512) | * Default value: ''(512, 512)'' |
| * Example (*.deeclass): <code xml><point name='renderablePanel.size' x='1024' y='512'/></code> | * Example (*.deeclass): <code xml><point name='renderablePanel.size' x='1024' y='512'/></code> |
| |
| ===== guiTheme ===== | ===== guiTheme ===== |
| Path to gui theme (*.guitheme.xml) to load. If the same gui theme is used in multiple elements it is loaded only once and shared. | Path to gui theme to load. If the same gui theme is used in multiple elements it is loaded only once and shared. |
| * Full name: "renderablePanel.guiTheme" or "renderablePanel(id).guiTheme" | * Full name: ''renderablePanel.guiTheme'' or ''renderablePanel(id).guiTheme'' |
| * Type: Path (*.guitheme.xml) | * Type: string |
| * Default value: "/shareddata/guithemes/modern/modern.guitheme.xml" | * Default value: ''/shareddata/guithemes/modern/modern.guitheme.xml'' |
| | * File Pattern: ''*.guitheme.xml'' |
| * Example (*.deeclass): <code xml><string name='renderablePanel.guiTheme'>/content/ui/ingame.guitheme.xml</string></code> | * Example (*.deeclass): <code xml><string name='renderablePanel.guiTheme'>/content/ui/ingame.guitheme.xml</string></code> |
| |
| ===== designerSelector ===== | ===== designerSelector ===== |
| Name of designer selector to use from gui theme specified in //guiTheme// property for panel widget. Allows to define multiple panels in one gui theme potentially sharing definitions. | Name of designer selector to use from gui theme specified in ''guiTheme'' property for panel widget. Allows to define multiple panels in one gui theme potentially sharing definitions. |
| * Full name: "renderablePanel.designerSelector" or "renderablePanel(id).designerSelector" | * Full name: ''renderablePanel.designerSelector'' or ''renderablePanel(id).designerSelector'' |
| * Type: string | * Type: string |
| * Default Value: "RenderablePanel" | * Default Value: ''RenderablePanel'' |
| * Example (*.deeclass): <code xml><string name='renderablePanel.designerSelector'>RenderablePanel.CockpitMonitor.Center</string></code> | * Example (*.deeclass): <code xml><string name='renderablePanel.designerSelector'>RenderablePanel.CockpitMonitor.Center</string></code> |
| |
| ====== Required Behaviors ====== | ====== Required Behaviors ====== |
| | |
| * [[behavior_dynamicskin|ECBehaviorDynamicSkin]] | * [[behavior_dynamicskin|ECBehaviorDynamicSkin]] |
| |
| ====== Persistency ====== | ====== Persistency ====== |
| |
| This behavior does not use persistency. | This behavior does not required element class to be persistable (setPersistable). |
| |
| ====== API Documentation ====== | ====== API Documentation ====== |
| |
| [[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Scenery_1_1ECBehaviorRenderablePanel.html|ECBehaviorRenderablePanel]]. | #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorRenderablePanel.html,ECBehaviorRenderablePanel~@#. |
| |
| Since DragonScript Module Version **1.3** | Since DragonScript Module Version ''1.3'' |
| |
| ====== Use Cases ====== | ====== Use Cases ====== |
| end | end |
| </code> | </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='ECBehaviorComponent'/> |
| | <behavior type='ECBehaviorCollider'/> |
| | <behavior type='ECBehaviorDynamicSkin'/> |
| | |
| | <behavior type='ECBehaviorRenderablePanel'> |
| | <!-- set element properties. omit property prefix if used inside behavior tag --> |
| | <string name='.renderable'>monitor content</string> |
| | </behavior> |
| | |
| | <!-- for adding multiple behaviors use unique identifiers --> |
| | <behavior type='ECBehaviorRenderablePanel' id='second'/> |
| | </elementClass> |
| | </code> |
| | |
| | ====== Live Examples ====== |
| | |
| | * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]] |
| | |