From fd4a8b8375a37f9bf56eb84fe6a35ef19e17ea14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sat, 19 Jul 2025 18:06:36 +0200 Subject: [PATCH 1/4] Use slider variants. --- examples/3d-road-crosser/3d-road-crosser.json | 1266 +++++++++++------ 1 file changed, 797 insertions(+), 469 deletions(-) diff --git a/examples/3d-road-crosser/3d-road-crosser.json b/examples/3d-road-crosser/3d-road-crosser.json index 0af65be8c..ca80c3f54 100644 --- a/examples/3d-road-crosser/3d-road-crosser.json +++ b/examples/3d-road-crosser/3d-road-crosser.json @@ -1,7 +1,7 @@ { "firstLayout": "", "gdVersion": { - "build": 236, + "build": 237, "major": 5, "minor": 5, "revision": 0 @@ -349,42 +349,6 @@ "smoothed": true, "userAdded": true }, - { - "file": "assets/Square Green Slider Border.png", - "kind": "image", - "metadata": "", - "name": "Square Green Slider Border.png", - "smoothed": false, - "userAdded": false, - "origin": { - "identifier": "https://asset-resources.gdevelop.io/public-resources/Settings UI/Slider/pixel art/b20061f94d8b7288702975d6bd15d1a750a6b5ba429c22cb695b19210d0da8b9_Square Green Slider Border.png", - "name": "Square Green Slider Border.png" - } - }, - { - "file": "assets/Square Green Slider Fill Bar.png", - "kind": "image", - "metadata": "", - "name": "Square Green Slider Fill Bar.png", - "smoothed": false, - "userAdded": false, - "origin": { - "identifier": "https://asset-resources.gdevelop.io/public-resources/Settings UI/Slider/pixel art/553dd6c98bc6b7c3539f936e1c0815fef2796c9aa3468ae90d288bdb5931076b_Square Green Slider Fill Bar.png", - "name": "Square Green Slider Fill Bar.png" - } - }, - { - "file": "assets/Square Green Slider Thumb.png", - "kind": "image", - "metadata": "", - "name": "Square Green Slider Thumb.png", - "smoothed": false, - "userAdded": false, - "origin": { - "identifier": "https://asset-resources.gdevelop.io/public-resources/Settings UI/Slider/pixel art/7f9d3fcd723e6cd77452d818e3cba9775f63acdbf98378e7276cc95bf1213e86_Square Green Slider Thumb.png", - "name": "Square Green Slider Thumb.png" - } - }, { "file": "assets/Yellow Jelly Button_Hovered.png", "kind": "image", @@ -436,6 +400,42 @@ "name": "assets/rotate-screen-icon.png", "smoothed": true, "userAdded": false + }, + { + "file": "assets/Square Green Slider Border.png", + "kind": "image", + "metadata": "", + "name": "Square Green Slider Border.png", + "smoothed": false, + "userAdded": false, + "origin": { + "identifier": "https://asset-resources.gdevelop.io/public-resources/Settings UI/Slider/pixel art/b20061f94d8b7288702975d6bd15d1a750a6b5ba429c22cb695b19210d0da8b9_Square Green Slider Border.png", + "name": "Square Green Slider Border.png" + } + }, + { + "file": "assets/Square Green Slider Fill Bar.png", + "kind": "image", + "metadata": "", + "name": "Square Green Slider Fill Bar.png", + "smoothed": false, + "userAdded": false, + "origin": { + "identifier": "https://asset-resources.gdevelop.io/public-resources/Settings UI/Slider/pixel art/553dd6c98bc6b7c3539f936e1c0815fef2796c9aa3468ae90d288bdb5931076b_Square Green Slider Fill Bar.png", + "name": "Square Green Slider Fill Bar.png" + } + }, + { + "file": "assets/Square Green Slider Thumb.png", + "kind": "image", + "metadata": "", + "name": "Square Green Slider Thumb.png", + "smoothed": false, + "userAdded": false, + "origin": { + "identifier": "https://asset-resources.gdevelop.io/public-resources/Settings UI/Slider/pixel art/7f9d3fcd723e6cd77452d818e3cba9775f63acdbf98378e7276cc95bf1213e86_Square Green Slider Thumb.png", + "name": "Square Green Slider Thumb.png" + } } ], "resourceFolders": [] @@ -467,7 +467,7 @@ "gridColor": 0, "gridAlpha": 1, "snap": false, - "zoomFactor": 0.47893418845353314, + "zoomFactor": 1.2530387740590068, "windowMask": false }, "objectsGroups": [ @@ -1219,9 +1219,8 @@ { "angle": 0, "customSize": true, - "depth": 100.39840637450199, - "height": 37.64940239043825, - "keepRatio": true, + "depth": 64, + "height": 36, "layer": "Settings", "name": "SquareGreenSlider", "persistentUuid": "be089719-b69b-47e1-bcdf-b07eaccd46e9", @@ -3890,7 +3889,7 @@ "assetStoreId": "84dcf81d35efee74a6cab51b4103acc5443e7f39fd7366e2ac58641e60323b4a", "name": "SquareGreenSlider", "type": "PanelSpriteSlider::PanelSpriteSlider", - "variant": "", + "variant": "Big Square Green Slider", "variables": [], "effects": [], "behaviors": [], @@ -15545,13 +15544,13 @@ "category": "User interface", "extensionNamespace": "", "fullName": "Slider", - "gdevelopVersion": ">=5.5.222", + "gdevelopVersion": ">=5.5.230", "helpPath": "/objects/slider", "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMy4wLjMsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iSWNvbnMiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzIgMzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyIDMyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDpub25lO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9DQo8L3N0eWxlPg0KPGNpcmNsZSBjbGFzcz0ic3QwIiBjeD0iMjMiIGN5PSI3IiByPSIzIi8+DQo8bGluZSBjbGFzcz0ic3QwIiB4MT0iMyIgeTE9IjciIHgyPSIyMCIgeTI9IjciLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIyOSIgeTE9IjciIHgyPSIyNiIgeTI9IjciLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjEyIiBjeT0iMTYiIHI9IjMiLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIzIiB5MT0iMTYiIHgyPSI5IiB5Mj0iMTYiLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIyOSIgeTE9IjE2IiB4Mj0iMTUiIHkyPSIxNiIvPg0KPGNpcmNsZSBjbGFzcz0ic3QwIiBjeD0iMjMiIGN5PSIyNSIgcj0iMyIvPg0KPGxpbmUgY2xhc3M9InN0MCIgeDE9IjMiIHkxPSIyNSIgeDI9IjIwIiB5Mj0iMjUiLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIyOSIgeTE9IjI1IiB4Mj0iMjYiIHkyPSIyNSIvPg0KPC9zdmc+DQo=", "name": "PanelSpriteSlider", "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Line Hero Pack/Master/SVG/UI Essentials/1678c39a3b2bd3df4f82a8a293770db4986a6bcfd3f78e738ddfc86e39176423_UI Essentials_sliders_options.svg", "shortDescription": "A draggable slider that users can move to select a numerical value.", - "version": "1.5.1", + "version": "2.0.0", "description": [ "A draggable slider that users can move to select a numerical value. The slider can be customized with sprites.", "", @@ -15571,6 +15570,12 @@ "IWykYNRvhCZBN3vEgKEbBPOR3Oc2", "gqDaZjCfevOOxBYkK6zlhtZnXCg1" ], + "changelog": [ + { + "version": "2.0.0", + "breaking": "- Sliders now use \"variants\", allowing easy swapping of their visual aspect. You will have to make some adjustments to existing sliders in your project. Follow this [migration documentation](https://wiki.gdevelop.io/gdevelop5/objects/custom-objects-prefab-template/migrate-to-variants/) to do these changes." + } + ], "dependencies": [], "globalVariables": [], "sceneVariables": [], @@ -17143,7 +17148,7 @@ ], "eventsBasedObjects": [ { - "areaMaxX": 64, + "areaMaxX": 256, "areaMaxY": 64, "areaMaxZ": 64, "areaMinX": 0, @@ -17152,7 +17157,8 @@ "defaultName": "Slider", "description": "Let users select a numerical value by dragging a slider.", "fullName": "Slider", - "isUsingLegacyInstancesRenderer": true, + "isInnerAreaFollowingParentSize": true, + "isUsingLegacyInstancesRenderer": false, "name": "PanelSpriteSlider", "objects": [ { @@ -17212,6 +17218,16 @@ "variables": [], "effects": [], "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 4, + "leftEdgeAnchor": 0, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 4, + "useLegacyBottomAndRightAnchors": false + }, { "name": "Draggable", "type": "DraggableBehavior::Draggable", @@ -17227,13 +17243,23 @@ "name": "FillBar", "rightMargin": 0, "texture": "", - "tiled": true, + "tiled": false, "topMargin": 0, "type": "PanelSpriteObject::PanelSprite", "width": 32, "variables": [], "effects": [], "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "topEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "useLegacyBottomAndRightAnchors": false + }, { "name": "Slider", "type": "PanelSpriteSlider::Slider", @@ -17252,13 +17278,23 @@ "name": "Background", "rightMargin": 0, "texture": "", - "tiled": true, + "tiled": false, "topMargin": 0, "type": "PanelSpriteObject::PanelSprite", "width": 32, "variables": [], "effects": [], "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "topEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "useLegacyBottomAndRightAnchors": false + }, { "name": "ButtonFSM", "type": "PanelSpriteSlider::ButtonFSM", @@ -17320,7 +17356,56 @@ "effects": [] } ], - "instances": [], + "instances": [ + { + "angle": 0, + "customSize": true, + "depth": 0, + "height": 64, + "layer": "", + "name": "Background", + "persistentUuid": "7b36a716-8a01-496a-ad7d-0de60daff8f9", + "width": 256, + "x": 0, + "y": 0, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 44, + "layer": "", + "name": "FillBar", + "persistentUuid": "e775f69e-7845-4103-8a05-5266aba60742", + "width": 236, + "x": 10, + "y": 10, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 84, + "layer": "", + "name": "Thumb", + "persistentUuid": "476a27da-e34f-451f-b660-04a6bbefddbe", + "width": 32, + "x": 230, + "y": -10, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], "eventsFunctions": [ { "fullName": "", @@ -17338,35 +17423,7 @@ "textG": 0, "textR": 0 }, - "comment": "This allows to detect a change of \"intial value\" on hot reload." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "PreviousInitialValue", - "=", - "InitialValue" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Create the child-object instances." + "comment": "Anchors won't work as there is an absolute margin and a proportional size at the same time" }, { "type": "BuiltinCommonInstructions::Standard", @@ -17374,68 +17431,70 @@ "actions": [ { "type": { - "value": "Create" - }, - "parameters": [ - "", - "Background", - "0", - "0", - "" - ] - }, - { - "type": { - "value": "Create" + "value": "ActivateBehavior" }, "parameters": [ - "", "FillBar", - "0", - "0", + "Anchor", "" ] }, { "type": { - "value": "Create" + "value": "ActivateBehavior" }, "parameters": [ - "", "Thumb", - "0", - "0", + "Anchor", "" ] }, { "type": { - "value": "ChangePlan" + "value": "SetNumberVariable" }, "parameters": [ - "Background", + "BarLeftPlusRightMargin", "=", - "1" + "Object.Width() - FillBar.Width()" ] }, { "type": { - "value": "ChangePlan" + "value": "SetNumberVariable" }, "parameters": [ - "FillBar", + "BarTopPlusBottomMargin", "=", - "2" + "Object.Height() - FillBar.Height()" ] - }, + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "This allows to detect a change of \"intial value\" on hot reload." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ { "type": { - "value": "ChangePlan" + "value": "SetNumberVariable" }, "parameters": [ - "Thumb", + "PreviousInitialValue", "=", - "3" + "InitialValue" ] } ] @@ -17468,25 +17527,6 @@ "" ] }, - { - "type": { - "value": "ChangePlan" - }, - "parameters": [ - "Label", - "=", - "4" - ] - }, - { - "type": { - "value": "TextObject::SetWrapping" - }, - "parameters": [ - "Label", - "no" - ] - }, { "type": { "value": "Cache" @@ -17589,15 +17629,6 @@ "type": "BuiltinCommonInstructions::Standard", "conditions": [], "actions": [ - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, { "type": { "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateSliderConfiguration" @@ -17665,16 +17696,89 @@ "sentence": "", "events": [ { - "colorB": 228, - "colorG": 176, - "colorR": 74, - "creationTime": 0, - "name": "Handle touches", - "source": "", - "type": "BuiltinCommonInstructions::Group", - "events": [ + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ { - "type": "BuiltinCommonInstructions::Standard", + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "OldParentWidth", + "!=", + "Object.Width()" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "OldParentWidth", + "=", + "Object.Width()" + ] + }, + { + "type": { + "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetHeight" + }, + "parameters": [ + "FillBar", + "Resizable", + "=", + "Object.Height() - BarTopPlusBottomMargin" + ] + }, + { + "type": { + "value": "SetCenterY" + }, + "parameters": [ + "Thumb", + "=", + "FillBar.CenterY()" + ] + }, + { + "type": { + "value": "MettreY" + }, + "parameters": [ + "Label", + "=", + "Thumb.Y() - Label.Height() - LabelMargin" + ] + } + ] + }, + { + "colorB": 228, + "colorG": 176, + "colorR": 74, + "creationTime": 0, + "name": "Handle touches", + "source": "", + "type": "BuiltinCommonInstructions::Group", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", "conditions": [ { "type": { @@ -17748,7 +17852,7 @@ "parameters": [ "Object", "=", - "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (TouchX(Background.ButtonFSM::TouchId(), Object.Layer()) - Object.FullBarLeft()) / Object.FullBarWidth()", + "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (TouchX(Background.ButtonFSM::TouchId(), Object.Layer()) - FillBar.X()) / Object.FullBarWidth()", "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (MouseX() - Object.FullBarLeft()) / Object.FullBarWidth()" ] } @@ -17812,7 +17916,7 @@ "parameters": [ "Object", "=", - "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (Thumb.CenterX() - Object.FullBarLeft()) / Object.FullBarWidth()", + "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (Thumb.CenterX() - FillBar.X()) / Object.FullBarWidth()", "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (Thumb.CenterX() - Object.FullBarLeft()) / Object.FullBarWidth()" ] } @@ -17955,189 +18059,6 @@ } ], "parameters": [] - }, - { - "colorB": 228, - "colorG": 176, - "colorR": 74, - "creationTime": 0, - "name": "Resize", - "source": "", - "type": "BuiltinCommonInstructions::Group", - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Children instances must be resized when the parent size change:\n- background is resized to take the full dimensions of the parent\n- the label is put back at the center of the bar\n\nThe scale is set back to 1 because it means that the parent instance has the same dimensions as the union of its children instances." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "BuiltinCommonInstructions::Or" - }, - "parameters": [], - "subInstructions": [ - { - "type": { - "value": "BuiltinCommonInstructions::CompareNumbers" - }, - "parameters": [ - "Object.Width()", - "!=", - "max(Background.BoundingBoxRight(), max(Label.BoundingBoxRight(), Thumb.BoundingBoxRight())) - min(Background.BoundingBoxLeft(), min(Label.BoundingBoxLeft(), Thumb.BoundingBoxLeft()))" - ] - }, - { - "type": { - "value": "BuiltinCommonInstructions::CompareNumbers" - }, - "parameters": [ - "Object.Height()", - "!=", - "max(Background.BoundingBoxBottom(), max(Label.BoundingBoxBottom(), Thumb.BoundingBoxBottom())) - min(Background.BoundingBoxTop(), min(Label.BoundingBoxTop(), Thumb.BoundingBoxTop()))" - ] - } - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "Width", - "=", - "Object.Width()" - ] - }, - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "Height", - "=", - "Object.Height()" - ] - }, - { - "type": { - "value": "ScalableCapability::ScalableBehavior::SetValue" - }, - "parameters": [ - "Object", - "Scale", - "=", - "1" - ] - }, - { - "type": { - "value": "ResizableCapability::ResizableBehavior::SetWidth" - }, - "parameters": [ - "Background", - "Resizable", - "=", - "Width" - ] - }, - { - "type": { - "value": "ResizableCapability::ResizableBehavior::SetHeight" - }, - "parameters": [ - "Background", - "Resizable", - "=", - "Height" - ] - }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - } - ], - "variables": [ - { - "name": "Width", - "type": "number", - "value": 0 - }, - { - "name": "Height", - "type": "number", - "value": 0 - } - ] - } - ] - } - ], - "parameters": [] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "The parent size is not defined in onCreate so it needs to be done here." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "BuiltinCommonInstructions::Once" - }, - "parameters": [] - } - ], - "actions": [ - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" - }, - "parameters": [ - "Object", - "" - ] - } - ] } ], "parameters": [ @@ -18366,15 +18287,6 @@ "" ] }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, { "type": { "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" @@ -18462,15 +18374,6 @@ "" ] }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, { "type": { "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" @@ -18717,54 +18620,6 @@ ], "objectGroups": [] }, - { - "description": "Center the bar according to the button configuration. This is used in doStepPostEvents when the button is resized.", - "fullName": "Update layout", - "functionType": "Action", - "name": "UpdateLayout", - "private": true, - "sentence": "Update layout of _PARAM0_", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "MettreXY" - }, - "parameters": [ - "FillBar", - "=", - "Object.PropertyBarLeftPadding()", - "=", - "Object.PropertyBarTopPadding()" - ] - }, - { - "type": { - "value": "ResizableCapability::ResizableBehavior::SetHeight" - }, - "parameters": [ - "FillBar", - "Resizable", - "=", - "round(Background.Height() - Object.PropertyBarTopPadding() - Object.PropertyBarBottomPadding())" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", - "type": "object" - } - ], - "objectGroups": [] - }, { "description": "Update the thumb position according to the slider value.", "fullName": "Update thumb position", @@ -18819,7 +18674,7 @@ "parameters": [ "Thumb", "=", - "Object.FullBarLeft() + FillBar.Width()" + "FillBar.X() + FillBar.Width()" ] }, { @@ -18894,76 +18749,6 @@ ], "objectGroups": [] }, - { - "fullName": "", - "functionType": "Expression", - "name": "FullBarLeft", - "private": true, - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "BarLeftPadding" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", - "type": "object" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "Expression", - "name": "FullBarRight", - "private": true, - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Background.Width() - BarRightPadding" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", - "type": "object" - } - ], - "objectGroups": [] - }, { "fullName": "", "functionType": "Expression", @@ -18980,7 +18765,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "Background.Width() - BarLeftPadding - BarRightPadding" + "Object.Width() - BarLeftPlusRightMargin" ] } ] @@ -19228,6 +19013,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarLeftPadding" }, { @@ -19239,6 +19025,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarTopPadding" }, { @@ -19250,6 +19037,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarRightPadding" }, { @@ -19261,6 +19049,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarBottomPadding" }, { @@ -19273,6 +19062,7 @@ { "value": "8", "type": "Number", + "unit": "Pixel", "label": "Label margin", "group": "Label", "name": "LabelMargin" @@ -19280,6 +19070,7 @@ { "value": "0", "type": "Number", + "unit": "Dimensionless", "label": "Minimum value", "group": "Value", "name": "MinValue" @@ -19287,6 +19078,7 @@ { "value": "100", "type": "Number", + "unit": "Dimensionless", "label": "Maximum value", "group": "Value", "name": "MaxValue" @@ -19294,6 +19086,7 @@ { "value": "1", "type": "Number", + "unit": "Dimensionless", "label": "Step size", "group": "Value", "name": "StepSize" @@ -19301,6 +19094,7 @@ { "value": "50", "type": "Number", + "unit": "Dimensionless", "label": "Initial value", "group": "Value", "name": "InitialValue" @@ -19345,9 +19139,543 @@ ], "hidden": true, "name": "ShowLabel" + }, + { + "value": "0", + "type": "Number", + "label": "", + "hidden": true, + "name": "BarLeftPlusRightMargin" + }, + { + "value": "0", + "type": "Number", + "label": "", + "hidden": true, + "name": "BarTopPlusBottomMargin" + }, + { + "value": "0", + "type": "Number", + "label": "", + "hidden": true, + "name": "OldParentWidth" } ], - "variants": [] + "variants": [ + { + "areaMaxX": 215, + "areaMaxY": 36, + "areaMaxZ": 64, + "areaMinX": 0, + "areaMinY": 0, + "areaMinZ": 0, + "name": "Big Square Green Slider", + "objects": [ + { + "assetStoreId": "", + "bold": false, + "italic": false, + "name": "Label", + "smoothed": true, + "type": "TextObject::Text", + "underlined": false, + "variables": [], + "effects": [], + "behaviors": [], + "string": "It displays the value when it changes.", + "font": "", + "textAlignment": "", + "characterSize": 16, + "color": { + "b": 221, + "g": 221, + "r": 221 + }, + "content": { + "bold": false, + "isOutlineEnabled": false, + "isShadowEnabled": false, + "italic": false, + "outlineColor": "255;255;255", + "outlineThickness": 2, + "shadowAngle": 90, + "shadowBlurRadius": 2, + "shadowColor": "0;0;0", + "shadowDistance": 4, + "shadowOpacity": 127, + "smoothed": true, + "underlined": false, + "text": "It displays the value when it changes.", + "font": "", + "textAlignment": "", + "verticalTextAlignment": "top", + "characterSize": 16, + "color": "221;221;221" + } + }, + { + "assetStoreId": "", + "bottomMargin": 3, + "height": 21, + "leftMargin": 3, + "name": "Thumb", + "rightMargin": 3, + "texture": "Square Green Slider Thumb.png", + "tiled": false, + "topMargin": 3, + "type": "PanelSpriteObject::PanelSprite", + "width": 21, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 4, + "leftEdgeAnchor": 0, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 4, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "Draggable", + "type": "DraggableBehavior::Draggable", + "checkCollisionMask": false + } + ] + }, + { + "assetStoreId": "", + "bottomMargin": 1, + "height": 11, + "leftMargin": 1, + "name": "FillBar", + "rightMargin": 1, + "texture": "Square Green Slider Fill Bar.png", + "tiled": false, + "topMargin": 1, + "type": "PanelSpriteObject::PanelSprite", + "width": 209, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 1, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "Slider", + "type": "PanelSpriteSlider::Slider", + "Value": 0, + "MinValue": 0, + "MaxValue": 1, + "StepSize": 1 + } + ] + }, + { + "assetStoreId": "", + "bottomMargin": 4, + "height": 18, + "leftMargin": 2, + "name": "Background", + "rightMargin": 2, + "texture": "Square Green Slider Border.png", + "tiled": false, + "topMargin": 4, + "type": "PanelSpriteObject::PanelSprite", + "width": 215, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 1, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "ButtonFSM", + "type": "PanelSpriteSlider::ButtonFSM", + "ShouldCheckHovering": true, + "State": "Idle", + "TouchId": 0, + "TouchIsInside": false, + "MouseIsInside": false, + "Index": 0 + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Label" + }, + { + "objectName": "Thumb" + }, + { + "objectName": "FillBar" + }, + { + "objectName": "Background" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera3DFarPlaneDistance": 10000, + "camera3DFieldOfView": 45, + "camera3DNearPlaneDistance": 3, + "cameraType": "", + "followBaseLayerCamera": false, + "isLightingLayer": false, + "isLocked": false, + "name": "", + "renderingType": "", + "visibility": true, + "cameras": [ + { + "defaultSize": true, + "defaultViewport": true, + "height": 0, + "viewportBottom": 1, + "viewportLeft": 0, + "viewportRight": 1, + "viewportTop": 0, + "width": 0 + } + ], + "effects": [] + } + ], + "instances": [ + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 36, + "layer": "", + "name": "Background", + "persistentUuid": "24882334-eec8-403e-8bf1-70fc928a46e6", + "width": 215, + "x": 0, + "y": 0, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 24, + "layer": "", + "name": "FillBar", + "persistentUuid": "8b10aca6-93d2-4863-aa71-4d1484bec574", + "width": 207, + "x": 4, + "y": 6, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 0, + "height": 42, + "layer": "", + "name": "Thumb", + "persistentUuid": "0737b0d6-c26b-4458-97ef-bad4eca39e37", + "width": 21, + "x": 201, + "y": -3, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + }, + { + "areaMaxX": 215, + "areaMaxY": 18, + "areaMaxZ": 64, + "areaMinX": 0, + "areaMinY": 0, + "areaMinZ": 0, + "assetStoreAssetId": "84dcf81d35efee74a6cab51b4103acc5443e7f39fd7366e2ac58641e60323b4a", + "assetStoreOriginalName": "Square Green Slider", + "name": "Square Green Slider", + "objects": [ + { + "assetStoreId": "", + "bold": false, + "italic": false, + "name": "Label", + "smoothed": true, + "type": "TextObject::Text", + "underlined": false, + "variables": [], + "effects": [], + "behaviors": [], + "string": "It displays the value when it changes.", + "font": "", + "textAlignment": "", + "characterSize": 16, + "color": { + "b": 221, + "g": 221, + "r": 221 + }, + "content": { + "bold": false, + "isOutlineEnabled": false, + "isShadowEnabled": false, + "italic": false, + "outlineColor": "255;255;255", + "outlineThickness": 2, + "shadowAngle": 90, + "shadowBlurRadius": 2, + "shadowColor": "0;0;0", + "shadowDistance": 4, + "shadowOpacity": 127, + "smoothed": true, + "underlined": false, + "text": "It displays the value when it changes.", + "font": "", + "textAlignment": "", + "verticalTextAlignment": "top", + "characterSize": 16, + "color": "221;221;221" + } + }, + { + "assetStoreId": "", + "bottomMargin": 3, + "height": 21, + "leftMargin": 3, + "name": "Thumb", + "rightMargin": 3, + "texture": "Square Green Slider Thumb.png", + "tiled": false, + "topMargin": 3, + "type": "PanelSpriteObject::PanelSprite", + "width": 21, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 4, + "leftEdgeAnchor": 0, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 4, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "Draggable", + "type": "DraggableBehavior::Draggable", + "checkCollisionMask": false + } + ] + }, + { + "assetStoreId": "", + "bottomMargin": 1, + "height": 11, + "leftMargin": 1, + "name": "FillBar", + "rightMargin": 1, + "texture": "Square Green Slider Fill Bar.png", + "tiled": false, + "topMargin": 1, + "type": "PanelSpriteObject::PanelSprite", + "width": 209, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 1, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "Slider", + "type": "PanelSpriteSlider::Slider", + "Value": 0, + "MinValue": 0, + "MaxValue": 1, + "StepSize": 1 + } + ] + }, + { + "assetStoreId": "", + "bottomMargin": 4, + "height": 18, + "leftMargin": 2, + "name": "Background", + "rightMargin": 2, + "texture": "Square Green Slider Border.png", + "tiled": false, + "topMargin": 4, + "type": "PanelSpriteObject::PanelSprite", + "width": 215, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 1, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "ButtonFSM", + "type": "PanelSpriteSlider::ButtonFSM", + "ShouldCheckHovering": true, + "State": "Idle", + "TouchId": 0, + "TouchIsInside": false, + "MouseIsInside": false, + "Index": 0 + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Label" + }, + { + "objectName": "Thumb" + }, + { + "objectName": "FillBar" + }, + { + "objectName": "Background" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera3DFarPlaneDistance": 10000, + "camera3DFieldOfView": 45, + "camera3DNearPlaneDistance": 3, + "cameraType": "", + "followBaseLayerCamera": false, + "isLightingLayer": false, + "isLocked": false, + "name": "", + "renderingType": "", + "visibility": true, + "cameras": [ + { + "defaultSize": true, + "defaultViewport": true, + "height": 0, + "viewportBottom": 1, + "viewportLeft": 0, + "viewportRight": 1, + "viewportTop": 0, + "width": 0 + } + ], + "effects": [] + } + ], + "instances": [ + { + "angle": 0, + "customSize": false, + "depth": 1, + "height": 64, + "layer": "", + "name": "Background", + "persistentUuid": "24882334-eec8-403e-8bf1-70fc928a46e6", + "width": 64, + "x": 0, + "y": 0, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "keepRatio": true, + "layer": "", + "name": "FillBar", + "persistentUuid": "8b10aca6-93d2-4863-aa71-4d1484bec574", + "width": 0, + "x": 3, + "y": 3, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "keepRatio": true, + "layer": "", + "name": "Thumb", + "persistentUuid": "0737b0d6-c26b-4458-97ef-bad4eca39e37", + "width": 0, + "x": 194, + "y": -2, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] } ] }, From 992dfa6a63dbd4d765eca0256b879a5e9fbbe519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sat, 19 Jul 2025 18:14:06 +0200 Subject: [PATCH 2/4] Use slider variants. --- examples/3d-shark-frenzy/3d-shark-frenzy.json | 1334 ++++++++++------- 1 file changed, 832 insertions(+), 502 deletions(-) diff --git a/examples/3d-shark-frenzy/3d-shark-frenzy.json b/examples/3d-shark-frenzy/3d-shark-frenzy.json index ce8432639..dc275f28d 100644 --- a/examples/3d-shark-frenzy/3d-shark-frenzy.json +++ b/examples/3d-shark-frenzy/3d-shark-frenzy.json @@ -1,7 +1,7 @@ { "firstLayout": "Menu", "gdVersion": { - "build": 236, + "build": 237, "major": 5, "minor": 5, "revision": 0 @@ -606,7 +606,7 @@ "gridColor": 10401023, "gridAlpha": 0.8, "snap": false, - "zoomFactor": 0.3216911764705893, + "zoomFactor": 0.689778214010452, "windowMask": false }, "objectsGroups": [ @@ -725,9 +725,8 @@ { "angle": 0, "customSize": true, - "depth": 53, - "height": 20, - "keepRatio": true, + "depth": 64, + "height": 36, "layer": "Settings", "name": "VolumeSlider", "persistentUuid": "589499c8-431b-4690-9001-aae747e69a12", @@ -1222,7 +1221,7 @@ "assetStoreId": "d32eb2703c5acb4488d36fef28164ddf46d8f5b2f3f7a97fa11640cf8d1d91e9", "name": "VolumeSlider", "type": "PanelSpriteSlider::PanelSpriteSlider", - "variant": "", + "variant": "Big Square Blue Slider", "variables": [], "effects": [], "behaviors": [ @@ -1954,7 +1953,7 @@ "isLocked": false, "name": "Settings", "renderingType": "", - "visibility": true, + "visibility": false, "cameras": [], "effects": [] }, @@ -21022,13 +21021,13 @@ "category": "User interface", "extensionNamespace": "", "fullName": "Slider", - "gdevelopVersion": ">=5.5.222", + "gdevelopVersion": ">=5.5.230", "helpPath": "/objects/slider", "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMy4wLjMsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iSWNvbnMiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzIgMzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyIDMyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDpub25lO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9DQo8L3N0eWxlPg0KPGNpcmNsZSBjbGFzcz0ic3QwIiBjeD0iMjMiIGN5PSI3IiByPSIzIi8+DQo8bGluZSBjbGFzcz0ic3QwIiB4MT0iMyIgeTE9IjciIHgyPSIyMCIgeTI9IjciLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIyOSIgeTE9IjciIHgyPSIyNiIgeTI9IjciLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjEyIiBjeT0iMTYiIHI9IjMiLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIzIiB5MT0iMTYiIHgyPSI5IiB5Mj0iMTYiLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIyOSIgeTE9IjE2IiB4Mj0iMTUiIHkyPSIxNiIvPg0KPGNpcmNsZSBjbGFzcz0ic3QwIiBjeD0iMjMiIGN5PSIyNSIgcj0iMyIvPg0KPGxpbmUgY2xhc3M9InN0MCIgeDE9IjMiIHkxPSIyNSIgeDI9IjIwIiB5Mj0iMjUiLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIyOSIgeTE9IjI1IiB4Mj0iMjYiIHkyPSIyNSIvPg0KPC9zdmc+DQo=", "name": "PanelSpriteSlider", "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Line Hero Pack/Master/SVG/UI Essentials/1678c39a3b2bd3df4f82a8a293770db4986a6bcfd3f78e738ddfc86e39176423_UI Essentials_sliders_options.svg", "shortDescription": "A draggable slider that users can move to select a numerical value.", - "version": "1.5.1", + "version": "2.0.0", "description": [ "A draggable slider that users can move to select a numerical value. The slider can be customized with sprites.", "", @@ -21048,6 +21047,12 @@ "IWykYNRvhCZBN3vEgKEbBPOR3Oc2", "gqDaZjCfevOOxBYkK6zlhtZnXCg1" ], + "changelog": [ + { + "version": "2.0.0", + "breaking": "- Sliders now use \"variants\", allowing easy swapping of their visual aspect. You will have to make some adjustments to existing sliders in your project. Follow this [migration documentation](https://wiki.gdevelop.io/gdevelop5/objects/custom-objects-prefab-template/migrate-to-variants/) to do these changes." + } + ], "dependencies": [], "globalVariables": [], "sceneVariables": [], @@ -22620,7 +22625,7 @@ ], "eventsBasedObjects": [ { - "areaMaxX": 64, + "areaMaxX": 256, "areaMaxY": 64, "areaMaxZ": 64, "areaMinX": 0, @@ -22629,7 +22634,8 @@ "defaultName": "Slider", "description": "Let users select a numerical value by dragging a slider.", "fullName": "Slider", - "isUsingLegacyInstancesRenderer": true, + "isInnerAreaFollowingParentSize": true, + "isUsingLegacyInstancesRenderer": false, "name": "PanelSpriteSlider", "objects": [ { @@ -22689,6 +22695,16 @@ "variables": [], "effects": [], "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 4, + "leftEdgeAnchor": 0, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 4, + "useLegacyBottomAndRightAnchors": false + }, { "name": "Draggable", "type": "DraggableBehavior::Draggable", @@ -22704,13 +22720,23 @@ "name": "FillBar", "rightMargin": 0, "texture": "", - "tiled": true, + "tiled": false, "topMargin": 0, "type": "PanelSpriteObject::PanelSprite", "width": 32, "variables": [], "effects": [], "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "topEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "useLegacyBottomAndRightAnchors": false + }, { "name": "Slider", "type": "PanelSpriteSlider::Slider", @@ -22729,13 +22755,23 @@ "name": "Background", "rightMargin": 0, "texture": "", - "tiled": true, + "tiled": false, "topMargin": 0, "type": "PanelSpriteObject::PanelSprite", "width": 32, "variables": [], "effects": [], "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "topEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "useLegacyBottomAndRightAnchors": false + }, { "name": "ButtonFSM", "type": "PanelSpriteSlider::ButtonFSM", @@ -22797,7 +22833,56 @@ "effects": [] } ], - "instances": [], + "instances": [ + { + "angle": 0, + "customSize": true, + "depth": 0, + "height": 64, + "layer": "", + "name": "Background", + "persistentUuid": "7b36a716-8a01-496a-ad7d-0de60daff8f9", + "width": 256, + "x": 0, + "y": 0, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 44, + "layer": "", + "name": "FillBar", + "persistentUuid": "e775f69e-7845-4103-8a05-5266aba60742", + "width": 236, + "x": 10, + "y": 10, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 84, + "layer": "", + "name": "Thumb", + "persistentUuid": "476a27da-e34f-451f-b660-04a6bbefddbe", + "width": 32, + "x": 230, + "y": -10, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], "eventsFunctions": [ { "fullName": "", @@ -22815,35 +22900,7 @@ "textG": 0, "textR": 0 }, - "comment": "This allows to detect a change of \"intial value\" on hot reload." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "PreviousInitialValue", - "=", - "InitialValue" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Create the child-object instances." + "comment": "Anchors won't work as there is an absolute margin and a proportional size at the same time" }, { "type": "BuiltinCommonInstructions::Standard", @@ -22851,68 +22908,70 @@ "actions": [ { "type": { - "value": "Create" - }, - "parameters": [ - "", - "Background", - "0", - "0", - "" - ] - }, - { - "type": { - "value": "Create" + "value": "ActivateBehavior" }, "parameters": [ - "", "FillBar", - "0", - "0", + "Anchor", "" ] }, { "type": { - "value": "Create" + "value": "ActivateBehavior" }, "parameters": [ - "", "Thumb", - "0", - "0", + "Anchor", "" ] }, { "type": { - "value": "ChangePlan" + "value": "SetNumberVariable" }, "parameters": [ - "Background", + "BarLeftPlusRightMargin", "=", - "1" + "Object.Width() - FillBar.Width()" ] }, { "type": { - "value": "ChangePlan" + "value": "SetNumberVariable" }, "parameters": [ - "FillBar", + "BarTopPlusBottomMargin", "=", - "2" + "Object.Height() - FillBar.Height()" ] - }, + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "This allows to detect a change of \"intial value\" on hot reload." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ { "type": { - "value": "ChangePlan" + "value": "SetNumberVariable" }, "parameters": [ - "Thumb", + "PreviousInitialValue", "=", - "3" + "InitialValue" ] } ] @@ -22945,25 +23004,6 @@ "" ] }, - { - "type": { - "value": "ChangePlan" - }, - "parameters": [ - "Label", - "=", - "4" - ] - }, - { - "type": { - "value": "TextObject::SetWrapping" - }, - "parameters": [ - "Label", - "no" - ] - }, { "type": { "value": "Cache" @@ -23066,15 +23106,6 @@ "type": "BuiltinCommonInstructions::Standard", "conditions": [], "actions": [ - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, { "type": { "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateSliderConfiguration" @@ -23142,53 +23173,126 @@ "sentence": "", "events": [ { - "colorB": 228, - "colorG": 176, - "colorR": 74, - "creationTime": 0, - "name": "Handle touches", - "source": "", - "type": "BuiltinCommonInstructions::Group", - "events": [ + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "BehaviorActivated" - }, - "parameters": [ - "Background", - "ButtonFSM" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "inverted": true, - "value": "DraggableBehavior::Dragged" - }, - "parameters": [ - "Thumb", - "Draggable" - ] - }, - { - "type": { - "inverted": true, - "value": "DraggableBehavior::Dropped" - }, - "parameters": [ - "Thumb", - "Draggable" - ] - }, - { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "OldParentWidth", + "!=", + "Object.Width()" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "OldParentWidth", + "=", + "Object.Width()" + ] + }, + { + "type": { + "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetHeight" + }, + "parameters": [ + "FillBar", + "Resizable", + "=", + "Object.Height() - BarTopPlusBottomMargin" + ] + }, + { + "type": { + "value": "SetCenterY" + }, + "parameters": [ + "Thumb", + "=", + "FillBar.CenterY()" + ] + }, + { + "type": { + "value": "MettreY" + }, + "parameters": [ + "Label", + "=", + "Thumb.Y() - Label.Height() - LabelMargin" + ] + } + ] + }, + { + "colorB": 228, + "colorG": 176, + "colorR": 74, + "creationTime": 0, + "name": "Handle touches", + "source": "", + "type": "BuiltinCommonInstructions::Group", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BehaviorActivated" + }, + "parameters": [ + "Background", + "ButtonFSM" + ] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "DraggableBehavior::Dragged" + }, + "parameters": [ + "Thumb", + "Draggable" + ] + }, + { + "type": { + "inverted": true, + "value": "DraggableBehavior::Dropped" + }, + "parameters": [ + "Thumb", + "Draggable" + ] + }, + { "type": { "value": "BuiltinCommonInstructions::Or" }, @@ -23225,7 +23329,7 @@ "parameters": [ "Object", "=", - "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (TouchX(Background.ButtonFSM::TouchId(), Object.Layer()) - Object.FullBarLeft()) / Object.FullBarWidth()", + "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (TouchX(Background.ButtonFSM::TouchId(), Object.Layer()) - FillBar.X()) / Object.FullBarWidth()", "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (MouseX() - Object.FullBarLeft()) / Object.FullBarWidth()" ] } @@ -23289,7 +23393,7 @@ "parameters": [ "Object", "=", - "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (Thumb.CenterX() - Object.FullBarLeft()) / Object.FullBarWidth()", + "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (Thumb.CenterX() - FillBar.X()) / Object.FullBarWidth()", "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (Thumb.CenterX() - Object.FullBarLeft()) / Object.FullBarWidth()" ] } @@ -23432,227 +23536,44 @@ } ], "parameters": [] - }, + } + ], + "parameters": [ { - "colorB": 228, - "colorG": 176, - "colorR": 74, - "creationTime": 0, - "name": "Resize", - "source": "", - "type": "BuiltinCommonInstructions::Group", - "events": [ + "description": "Object", + "name": "Object", + "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "description": "Check if the slider is being dragged.", + "fullName": "Being dragged", + "functionType": "Condition", + "group": "Slider", + "name": "IsBeingDragged", + "sentence": "_PARAM0_ is being dragged", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 + "type": { + "value": "BuiltinCommonInstructions::Or" }, - "comment": "Children instances must be resized when the parent size change:\n- background is resized to take the full dimensions of the parent\n- the label is put back at the center of the bar\n\nThe scale is set back to 1 because it means that the parent instance has the same dimensions as the union of its children instances." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ + "parameters": [], + "subInstructions": [ { "type": { - "value": "BuiltinCommonInstructions::Or" + "value": "DraggableBehavior::Dragged" }, - "parameters": [], - "subInstructions": [ - { - "type": { - "value": "BuiltinCommonInstructions::CompareNumbers" - }, - "parameters": [ - "Object.Width()", - "!=", - "max(Background.BoundingBoxRight(), max(Label.BoundingBoxRight(), Thumb.BoundingBoxRight())) - min(Background.BoundingBoxLeft(), min(Label.BoundingBoxLeft(), Thumb.BoundingBoxLeft()))" - ] - }, - { - "type": { - "value": "BuiltinCommonInstructions::CompareNumbers" - }, - "parameters": [ - "Object.Height()", - "!=", - "max(Background.BoundingBoxBottom(), max(Label.BoundingBoxBottom(), Thumb.BoundingBoxBottom())) - min(Background.BoundingBoxTop(), min(Label.BoundingBoxTop(), Thumb.BoundingBoxTop()))" - ] - } + "parameters": [ + "Thumb", + "Draggable" ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "Width", - "=", - "Object.Width()" - ] - }, - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "Height", - "=", - "Object.Height()" - ] - }, - { - "type": { - "value": "ScalableCapability::ScalableBehavior::SetValue" - }, - "parameters": [ - "Object", - "Scale", - "=", - "1" - ] - }, - { - "type": { - "value": "ResizableCapability::ResizableBehavior::SetWidth" - }, - "parameters": [ - "Background", - "Resizable", - "=", - "Width" - ] - }, - { - "type": { - "value": "ResizableCapability::ResizableBehavior::SetHeight" - }, - "parameters": [ - "Background", - "Resizable", - "=", - "Height" - ] - }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - } - ], - "variables": [ - { - "name": "Width", - "type": "number", - "value": 0 - }, - { - "name": "Height", - "type": "number", - "value": 0 - } - ] - } - ] - } - ], - "parameters": [] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "The parent size is not defined in onCreate so it needs to be done here." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "BuiltinCommonInstructions::Once" - }, - "parameters": [] - } - ], - "actions": [ - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" - }, - "parameters": [ - "Object", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", - "type": "object" - } - ], - "objectGroups": [] - }, - { - "description": "Check if the slider is being dragged.", - "fullName": "Being dragged", - "functionType": "Condition", - "group": "Slider", - "name": "IsBeingDragged", - "sentence": "_PARAM0_ is being dragged", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "BuiltinCommonInstructions::Or" - }, - "parameters": [], - "subInstructions": [ - { - "type": { - "value": "DraggableBehavior::Dragged" - }, - "parameters": [ - "Thumb", - "Draggable" - ] - }, + }, { "type": { "value": "PanelSpriteSlider::ButtonFSM::IsPressed" @@ -23843,15 +23764,6 @@ "" ] }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, { "type": { "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" @@ -23939,15 +23851,6 @@ "" ] }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, { "type": { "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" @@ -24194,54 +24097,6 @@ ], "objectGroups": [] }, - { - "description": "Center the bar according to the button configuration. This is used in doStepPostEvents when the button is resized.", - "fullName": "Update layout", - "functionType": "Action", - "name": "UpdateLayout", - "private": true, - "sentence": "Update layout of _PARAM0_", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "MettreXY" - }, - "parameters": [ - "FillBar", - "=", - "Object.PropertyBarLeftPadding()", - "=", - "Object.PropertyBarTopPadding()" - ] - }, - { - "type": { - "value": "ResizableCapability::ResizableBehavior::SetHeight" - }, - "parameters": [ - "FillBar", - "Resizable", - "=", - "round(Background.Height() - Object.PropertyBarTopPadding() - Object.PropertyBarBottomPadding())" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", - "type": "object" - } - ], - "objectGroups": [] - }, { "description": "Update the thumb position according to the slider value.", "fullName": "Update thumb position", @@ -24296,7 +24151,7 @@ "parameters": [ "Thumb", "=", - "Object.FullBarLeft() + FillBar.Width()" + "FillBar.X() + FillBar.Width()" ] }, { @@ -24371,76 +24226,6 @@ ], "objectGroups": [] }, - { - "fullName": "", - "functionType": "Expression", - "name": "FullBarLeft", - "private": true, - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "BarLeftPadding" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", - "type": "object" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "Expression", - "name": "FullBarRight", - "private": true, - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Background.Width() - BarRightPadding" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", - "type": "object" - } - ], - "objectGroups": [] - }, { "fullName": "", "functionType": "Expression", @@ -24457,7 +24242,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "Background.Width() - BarLeftPadding - BarRightPadding" + "Object.Width() - BarLeftPlusRightMargin" ] } ] @@ -24705,6 +24490,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarLeftPadding" }, { @@ -24716,6 +24502,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarTopPadding" }, { @@ -24727,6 +24514,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarRightPadding" }, { @@ -24738,6 +24526,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarBottomPadding" }, { @@ -24750,6 +24539,7 @@ { "value": "8", "type": "Number", + "unit": "Pixel", "label": "Label margin", "group": "Label", "name": "LabelMargin" @@ -24757,6 +24547,7 @@ { "value": "0", "type": "Number", + "unit": "Dimensionless", "label": "Minimum value", "group": "Value", "name": "MinValue" @@ -24764,6 +24555,7 @@ { "value": "100", "type": "Number", + "unit": "Dimensionless", "label": "Maximum value", "group": "Value", "name": "MaxValue" @@ -24771,6 +24563,7 @@ { "value": "1", "type": "Number", + "unit": "Dimensionless", "label": "Step size", "group": "Value", "name": "StepSize" @@ -24778,6 +24571,7 @@ { "value": "50", "type": "Number", + "unit": "Dimensionless", "label": "Initial value", "group": "Value", "name": "InitialValue" @@ -24822,9 +24616,545 @@ ], "hidden": true, "name": "ShowLabel" + }, + { + "value": "0", + "type": "Number", + "label": "", + "hidden": true, + "name": "BarLeftPlusRightMargin" + }, + { + "value": "0", + "type": "Number", + "label": "", + "hidden": true, + "name": "BarTopPlusBottomMargin" + }, + { + "value": "0", + "type": "Number", + "label": "", + "hidden": true, + "name": "OldParentWidth" } ], - "variants": [] + "variants": [ + { + "areaMaxX": 215, + "areaMaxY": 36, + "areaMaxZ": 64, + "areaMinX": 0, + "areaMinY": 0, + "areaMinZ": 0, + "name": "Big Square Blue Slider", + "objects": [ + { + "assetStoreId": "", + "bold": false, + "italic": false, + "name": "Label", + "smoothed": true, + "type": "TextObject::Text", + "underlined": false, + "variables": [], + "effects": [], + "behaviors": [], + "string": "It displays the value when it changes.", + "font": "", + "textAlignment": "", + "characterSize": 16, + "color": { + "b": 221, + "g": 221, + "r": 221 + }, + "content": { + "bold": false, + "isOutlineEnabled": false, + "isShadowEnabled": false, + "italic": false, + "outlineColor": "255;255;255", + "outlineThickness": 2, + "shadowAngle": 90, + "shadowBlurRadius": 2, + "shadowColor": "0;0;0", + "shadowDistance": 4, + "shadowOpacity": 127, + "smoothed": true, + "underlined": false, + "text": "It displays the value when it changes.", + "font": "", + "textAlignment": "", + "verticalTextAlignment": "top", + "characterSize": 16, + "color": "221;221;221" + } + }, + { + "assetStoreId": "", + "bottomMargin": 3, + "height": 21, + "leftMargin": 3, + "name": "Thumb", + "rightMargin": 3, + "texture": "Square Blue Slider Thumb.png", + "tiled": false, + "topMargin": 3, + "type": "PanelSpriteObject::PanelSprite", + "width": 21, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 4, + "leftEdgeAnchor": 0, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 4, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "Draggable", + "type": "DraggableBehavior::Draggable", + "checkCollisionMask": false + } + ] + }, + { + "assetStoreId": "", + "bottomMargin": 1, + "height": 11, + "leftMargin": 1, + "name": "FillBar", + "rightMargin": 1, + "texture": "Square Blue Slider Fill Bar.png", + "tiled": false, + "topMargin": 1, + "type": "PanelSpriteObject::PanelSprite", + "width": 209, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 1, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "Slider", + "type": "PanelSpriteSlider::Slider", + "Value": 0, + "MinValue": 0, + "MaxValue": 1, + "StepSize": 1 + } + ] + }, + { + "assetStoreId": "", + "bottomMargin": 4, + "height": 18, + "leftMargin": 2, + "name": "Background", + "rightMargin": 2, + "texture": "Square Blue Slider Border.png", + "tiled": false, + "topMargin": 4, + "type": "PanelSpriteObject::PanelSprite", + "width": 215, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 1, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "ButtonFSM", + "type": "PanelSpriteSlider::ButtonFSM", + "ShouldCheckHovering": true, + "State": "Idle", + "TouchId": 0, + "TouchIsInside": false, + "MouseIsInside": false, + "Index": 0 + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Label" + }, + { + "objectName": "Thumb" + }, + { + "objectName": "FillBar" + }, + { + "objectName": "Background" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera3DFarPlaneDistance": 10000, + "camera3DFieldOfView": 45, + "camera3DNearPlaneDistance": 3, + "cameraType": "", + "followBaseLayerCamera": false, + "isLightingLayer": false, + "isLocked": false, + "name": "", + "renderingType": "", + "visibility": true, + "cameras": [ + { + "defaultSize": true, + "defaultViewport": true, + "height": 0, + "viewportBottom": 1, + "viewportLeft": 0, + "viewportRight": 1, + "viewportTop": 0, + "width": 0 + } + ], + "effects": [] + } + ], + "instances": [ + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 36, + "layer": "", + "name": "Background", + "persistentUuid": "24882334-eec8-403e-8bf1-70fc928a46e6", + "width": 215, + "x": 0, + "y": 0, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 26, + "keepRatio": true, + "layer": "", + "name": "FillBar", + "persistentUuid": "92813097-aee7-4422-8421-125e3ed61986", + "width": 207, + "x": 4, + "y": 4, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 0, + "height": 42, + "layer": "", + "name": "Thumb", + "persistentUuid": "ac167400-9a98-4f22-a0a2-8b28626074a6", + "width": 21, + "x": 195, + "y": -4, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + }, + { + "areaMaxX": 215, + "areaMaxY": 18, + "areaMaxZ": 64, + "areaMinX": 0, + "areaMinY": 0, + "areaMinZ": 0, + "assetStoreAssetId": "d32eb2703c5acb4488d36fef28164ddf46d8f5b2f3f7a97fa11640cf8d1d91e9", + "assetStoreOriginalName": "Square Blue Slider", + "name": "Square Blue Slider", + "objects": [ + { + "assetStoreId": "", + "bold": false, + "italic": false, + "name": "Label", + "smoothed": true, + "type": "TextObject::Text", + "underlined": false, + "variables": [], + "effects": [], + "behaviors": [], + "string": "It displays the value when it changes.", + "font": "", + "textAlignment": "", + "characterSize": 16, + "color": { + "b": 221, + "g": 221, + "r": 221 + }, + "content": { + "bold": false, + "isOutlineEnabled": false, + "isShadowEnabled": false, + "italic": false, + "outlineColor": "255;255;255", + "outlineThickness": 2, + "shadowAngle": 90, + "shadowBlurRadius": 2, + "shadowColor": "0;0;0", + "shadowDistance": 4, + "shadowOpacity": 127, + "smoothed": true, + "underlined": false, + "text": "It displays the value when it changes.", + "font": "", + "textAlignment": "", + "verticalTextAlignment": "top", + "characterSize": 16, + "color": "221;221;221" + } + }, + { + "assetStoreId": "", + "bottomMargin": 3, + "height": 21, + "leftMargin": 3, + "name": "Thumb", + "rightMargin": 3, + "texture": "Square Blue Slider Thumb.png", + "tiled": false, + "topMargin": 3, + "type": "PanelSpriteObject::PanelSprite", + "width": 21, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 4, + "leftEdgeAnchor": 0, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 4, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "Draggable", + "type": "DraggableBehavior::Draggable", + "checkCollisionMask": false + } + ] + }, + { + "assetStoreId": "", + "bottomMargin": 1, + "height": 11, + "leftMargin": 1, + "name": "FillBar", + "rightMargin": 1, + "texture": "Square Blue Slider Fill Bar.png", + "tiled": false, + "topMargin": 1, + "type": "PanelSpriteObject::PanelSprite", + "width": 209, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 1, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "Slider", + "type": "PanelSpriteSlider::Slider", + "Value": 0, + "MinValue": 0, + "MaxValue": 1, + "StepSize": 1 + } + ] + }, + { + "assetStoreId": "", + "bottomMargin": 4, + "height": 18, + "leftMargin": 2, + "name": "Background", + "rightMargin": 2, + "texture": "Square Blue Slider Border.png", + "tiled": false, + "topMargin": 4, + "type": "PanelSpriteObject::PanelSprite", + "width": 215, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 1, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "ButtonFSM", + "type": "PanelSpriteSlider::ButtonFSM", + "ShouldCheckHovering": true, + "State": "Idle", + "TouchId": 0, + "TouchIsInside": false, + "MouseIsInside": false, + "Index": 0 + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Label" + }, + { + "objectName": "Thumb" + }, + { + "objectName": "FillBar" + }, + { + "objectName": "Background" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera3DFarPlaneDistance": 10000, + "camera3DFieldOfView": 45, + "camera3DNearPlaneDistance": 3, + "cameraType": "", + "followBaseLayerCamera": false, + "isLightingLayer": false, + "isLocked": false, + "name": "", + "renderingType": "", + "visibility": true, + "cameras": [ + { + "defaultSize": true, + "defaultViewport": true, + "height": 0, + "viewportBottom": 1, + "viewportLeft": 0, + "viewportRight": 1, + "viewportTop": 0, + "width": 0 + } + ], + "effects": [] + } + ], + "instances": [ + { + "angle": 0, + "customSize": false, + "depth": 1, + "height": 64, + "layer": "", + "name": "Background", + "persistentUuid": "24882334-eec8-403e-8bf1-70fc928a46e6", + "width": 64, + "x": 0, + "y": 0, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 11, + "keepRatio": true, + "layer": "", + "name": "FillBar", + "persistentUuid": "92813097-aee7-4422-8421-125e3ed61986", + "width": 209, + "x": 3, + "y": 3, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "keepRatio": true, + "layer": "", + "name": "Thumb", + "persistentUuid": "ac167400-9a98-4f22-a0a2-8b28626074a6", + "width": 0, + "x": 194, + "y": -2, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] } ] }, From 1559f722a7096216944de582c3e14988ec643612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sat, 19 Jul 2025 18:22:21 +0200 Subject: [PATCH 3/4] Use slider variants. --- .../wave-defense-shooter.json | 1094 +++++++++-------- 1 file changed, 591 insertions(+), 503 deletions(-) diff --git a/examples/wave-defense-shooter/wave-defense-shooter.json b/examples/wave-defense-shooter/wave-defense-shooter.json index d7900aec1..1b0823b89 100644 --- a/examples/wave-defense-shooter/wave-defense-shooter.json +++ b/examples/wave-defense-shooter/wave-defense-shooter.json @@ -1,7 +1,7 @@ { "firstLayout": "", "gdVersion": { - "build": 236, + "build": 237, "major": 5, "minor": 5, "revision": 0 @@ -912,9 +912,9 @@ "gridOffsetX": 0, "gridOffsetY": 0, "gridColor": 10401023, - "gridAlpha": 0.8, + "gridAlpha": 0.2, "snap": true, - "zoomFactor": 0.6328535003246556, + "zoomFactor": 0.6122095908431373, "windowMask": false }, "objectsGroups": [ @@ -1530,7 +1530,7 @@ "assetStoreId": "bfeeb465a4a164b560a2215e3ff9e78e66123af43cbf7ef1f22d56fca4271c80", "name": "SoundSlider", "type": "PanelSpriteSlider::PanelSpriteSlider", - "variant": "", + "variant": "Square white slider", "variables": [], "effects": [], "behaviors": [], @@ -1614,7 +1614,7 @@ "assetStoreId": "bfeeb465a4a164b560a2215e3ff9e78e66123af43cbf7ef1f22d56fca4271c80", "name": "MusicSlider", "type": "PanelSpriteSlider::PanelSpriteSlider", - "variant": "", + "variant": "Square white slider", "variables": [], "effects": [], "behaviors": [], @@ -1919,48 +1919,6 @@ "SettingsMarker" ] }, - { - "type": { - "value": "ReadStringFromStorage" - }, - "parameters": [ - "\"Settings\"", - "\"Settings\"", - "", - "TempSettings" - ] - }, - { - "type": { - "value": "JSONToVariableStructure2" - }, - "parameters": [ - "TempSettings", - "Settings" - ] - }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::SetValue" - }, - "parameters": [ - "SoundSlider", - "=", - "Settings.Sound", - "" - ] - }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::SetValue" - }, - "parameters": [ - "MusicSlider", - "=", - "Settings.Music", - "" - ] - }, { "type": { "value": "ZoomCamera" @@ -1974,6 +1932,64 @@ } ], "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GroupExists" + }, + "parameters": [ + "\"Settings\"", + "\"Settings\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "ReadStringFromStorage" + }, + "parameters": [ + "\"Settings\"", + "\"Settings\"", + "", + "TempSettings" + ] + }, + { + "type": { + "value": "JSONToVariableStructure2" + }, + "parameters": [ + "TempSettings", + "Settings" + ] + }, + { + "type": { + "value": "PanelSpriteSlider::PanelSpriteSlider::SetValue" + }, + "parameters": [ + "SoundSlider", + "=", + "Settings.Sound", + "" + ] + }, + { + "type": { + "value": "PanelSpriteSlider::PanelSpriteSlider::SetValue" + }, + "parameters": [ + "MusicSlider", + "=", + "Settings.Music", + "" + ] + } + ] + }, { "type": "BuiltinCommonInstructions::Standard", "conditions": [ @@ -24224,13 +24240,13 @@ "category": "User interface", "extensionNamespace": "", "fullName": "Slider", - "gdevelopVersion": ">=5.5.222", + "gdevelopVersion": ">=5.5.230", "helpPath": "/objects/slider", "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMy4wLjMsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iSWNvbnMiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzIgMzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyIDMyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDpub25lO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9DQo8L3N0eWxlPg0KPGNpcmNsZSBjbGFzcz0ic3QwIiBjeD0iMjMiIGN5PSI3IiByPSIzIi8+DQo8bGluZSBjbGFzcz0ic3QwIiB4MT0iMyIgeTE9IjciIHgyPSIyMCIgeTI9IjciLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIyOSIgeTE9IjciIHgyPSIyNiIgeTI9IjciLz4NCjxjaXJjbGUgY2xhc3M9InN0MCIgY3g9IjEyIiBjeT0iMTYiIHI9IjMiLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIzIiB5MT0iMTYiIHgyPSI5IiB5Mj0iMTYiLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIyOSIgeTE9IjE2IiB4Mj0iMTUiIHkyPSIxNiIvPg0KPGNpcmNsZSBjbGFzcz0ic3QwIiBjeD0iMjMiIGN5PSIyNSIgcj0iMyIvPg0KPGxpbmUgY2xhc3M9InN0MCIgeDE9IjMiIHkxPSIyNSIgeDI9IjIwIiB5Mj0iMjUiLz4NCjxsaW5lIGNsYXNzPSJzdDAiIHgxPSIyOSIgeTE9IjI1IiB4Mj0iMjYiIHkyPSIyNSIvPg0KPC9zdmc+DQo=", "name": "PanelSpriteSlider", "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Line Hero Pack/Master/SVG/UI Essentials/1678c39a3b2bd3df4f82a8a293770db4986a6bcfd3f78e738ddfc86e39176423_UI Essentials_sliders_options.svg", "shortDescription": "A draggable slider that users can move to select a numerical value.", - "version": "1.5.1", + "version": "2.0.0", "description": [ "A draggable slider that users can move to select a numerical value. The slider can be customized with sprites.", "", @@ -24250,6 +24266,12 @@ "IWykYNRvhCZBN3vEgKEbBPOR3Oc2", "gqDaZjCfevOOxBYkK6zlhtZnXCg1" ], + "changelog": [ + { + "version": "2.0.0", + "breaking": "- Sliders now use \"variants\", allowing easy swapping of their visual aspect. You will have to make some adjustments to existing sliders in your project. Follow this [migration documentation](https://wiki.gdevelop.io/gdevelop5/objects/custom-objects-prefab-template/migrate-to-variants/) to do these changes." + } + ], "dependencies": [], "globalVariables": [], "sceneVariables": [], @@ -25822,7 +25844,7 @@ ], "eventsBasedObjects": [ { - "areaMaxX": 64, + "areaMaxX": 256, "areaMaxY": 64, "areaMaxZ": 64, "areaMinX": 0, @@ -25831,7 +25853,8 @@ "defaultName": "Slider", "description": "Let users select a numerical value by dragging a slider.", "fullName": "Slider", - "isUsingLegacyInstancesRenderer": true, + "isInnerAreaFollowingParentSize": true, + "isUsingLegacyInstancesRenderer": false, "name": "PanelSpriteSlider", "objects": [ { @@ -25891,6 +25914,16 @@ "variables": [], "effects": [], "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 4, + "leftEdgeAnchor": 0, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 4, + "useLegacyBottomAndRightAnchors": false + }, { "name": "Draggable", "type": "DraggableBehavior::Draggable", @@ -25906,13 +25939,23 @@ "name": "FillBar", "rightMargin": 0, "texture": "", - "tiled": true, + "tiled": false, "topMargin": 0, "type": "PanelSpriteObject::PanelSprite", "width": 32, "variables": [], "effects": [], "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "topEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "useLegacyBottomAndRightAnchors": false + }, { "name": "Slider", "type": "PanelSpriteSlider::Slider", @@ -25931,13 +25974,23 @@ "name": "Background", "rightMargin": 0, "texture": "", - "tiled": true, + "tiled": false, "topMargin": 0, "type": "PanelSpriteObject::PanelSprite", "width": 32, "variables": [], "effects": [], "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "topEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "useLegacyBottomAndRightAnchors": false + }, { "name": "ButtonFSM", "type": "PanelSpriteSlider::ButtonFSM", @@ -25999,7 +26052,56 @@ "effects": [] } ], - "instances": [], + "instances": [ + { + "angle": 0, + "customSize": true, + "depth": 0, + "height": 64, + "layer": "", + "name": "Background", + "persistentUuid": "7b36a716-8a01-496a-ad7d-0de60daff8f9", + "width": 256, + "x": 0, + "y": 0, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 44, + "layer": "", + "name": "FillBar", + "persistentUuid": "e775f69e-7845-4103-8a05-5266aba60742", + "width": 236, + "x": 10, + "y": 10, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 84, + "layer": "", + "name": "Thumb", + "persistentUuid": "476a27da-e34f-451f-b660-04a6bbefddbe", + "width": 32, + "x": 230, + "y": -10, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], "eventsFunctions": [ { "fullName": "", @@ -26017,35 +26119,7 @@ "textG": 0, "textR": 0 }, - "comment": "This allows to detect a change of \"intial value\" on hot reload." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "PreviousInitialValue", - "=", - "InitialValue" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Create the child-object instances." + "comment": "Anchors won't work as there is an absolute margin and a proportional size at the same time" }, { "type": "BuiltinCommonInstructions::Standard", @@ -26053,68 +26127,42 @@ "actions": [ { "type": { - "value": "Create" - }, - "parameters": [ - "", - "Background", - "0", - "0", - "" - ] - }, - { - "type": { - "value": "Create" + "value": "ActivateBehavior" }, "parameters": [ - "", "FillBar", - "0", - "0", + "Anchor", "" ] }, { "type": { - "value": "Create" + "value": "ActivateBehavior" }, "parameters": [ - "", "Thumb", - "0", - "0", + "Anchor", "" ] }, { "type": { - "value": "ChangePlan" - }, - "parameters": [ - "Background", - "=", - "1" - ] - }, - { - "type": { - "value": "ChangePlan" + "value": "SetNumberVariable" }, "parameters": [ - "FillBar", + "BarLeftPlusRightMargin", "=", - "2" + "Object.Width() - FillBar.Width()" ] }, { "type": { - "value": "ChangePlan" + "value": "SetNumberVariable" }, "parameters": [ - "Thumb", + "BarTopPlusBottomMargin", "=", - "3" + "Object.Height() - FillBar.Height()" ] } ] @@ -26129,7 +26177,7 @@ "textG": 0, "textR": 0 }, - "comment": "Create the label that is displayed over the thumb." + "comment": "This allows to detect a change of \"intial value\" on hot reload." }, { "type": "BuiltinCommonInstructions::Standard", @@ -26137,33 +26185,42 @@ "actions": [ { "type": { - "value": "Create" + "value": "SetNumberVariable" }, "parameters": [ - "", - "Label", - "0", - "0", - "" + "PreviousInitialValue", + "=", + "InitialValue" ] - }, - { - "type": { - "value": "ChangePlan" - }, - "parameters": [ - "Label", - "=", - "4" - ] - }, + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Create the label that is displayed over the thumb." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ { "type": { - "value": "TextObject::SetWrapping" + "value": "Create" }, "parameters": [ + "", "Label", - "no" + "0", + "0", + "" ] }, { @@ -26268,15 +26325,6 @@ "type": "BuiltinCommonInstructions::Standard", "conditions": [], "actions": [ - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, { "type": { "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateSliderConfiguration" @@ -26343,6 +26391,79 @@ "name": "doStepPostEvents", "sentence": "", "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "OldParentWidth", + "!=", + "Object.Width()" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "OldParentWidth", + "=", + "Object.Width()" + ] + }, + { + "type": { + "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetHeight" + }, + "parameters": [ + "FillBar", + "Resizable", + "=", + "Object.Height() - BarTopPlusBottomMargin" + ] + }, + { + "type": { + "value": "SetCenterY" + }, + "parameters": [ + "Thumb", + "=", + "FillBar.CenterY()" + ] + }, + { + "type": { + "value": "MettreY" + }, + "parameters": [ + "Label", + "=", + "Thumb.Y() - Label.Height() - LabelMargin" + ] + } + ] + }, { "colorB": 228, "colorG": 176, @@ -26427,7 +26548,7 @@ "parameters": [ "Object", "=", - "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (TouchX(Background.ButtonFSM::TouchId(), Object.Layer()) - Object.FullBarLeft()) / Object.FullBarWidth()", + "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (TouchX(Background.ButtonFSM::TouchId(), Object.Layer()) - FillBar.X()) / Object.FullBarWidth()", "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (MouseX() - Object.FullBarLeft()) / Object.FullBarWidth()" ] } @@ -26491,7 +26612,7 @@ "parameters": [ "Object", "=", - "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (Thumb.CenterX() - Object.FullBarLeft()) / Object.FullBarWidth()", + "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (Thumb.CenterX() - FillBar.X()) / Object.FullBarWidth()", "FillBar.Slider::MinValue() + FillBar.Slider::Size() * (Thumb.CenterX() - Object.FullBarLeft()) / Object.FullBarWidth()" ] } @@ -26634,227 +26755,44 @@ } ], "parameters": [] - }, + } + ], + "parameters": [ { - "colorB": 228, - "colorG": 176, - "colorR": 74, - "creationTime": 0, - "name": "Resize", - "source": "", - "type": "BuiltinCommonInstructions::Group", - "events": [ + "description": "Object", + "name": "Object", + "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "description": "Check if the slider is being dragged.", + "fullName": "Being dragged", + "functionType": "Condition", + "group": "Slider", + "name": "IsBeingDragged", + "sentence": "_PARAM0_ is being dragged", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 + "type": { + "value": "BuiltinCommonInstructions::Or" }, - "comment": "Children instances must be resized when the parent size change:\n- background is resized to take the full dimensions of the parent\n- the label is put back at the center of the bar\n\nThe scale is set back to 1 because it means that the parent instance has the same dimensions as the union of its children instances." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ + "parameters": [], + "subInstructions": [ { "type": { - "value": "BuiltinCommonInstructions::Or" + "value": "DraggableBehavior::Dragged" }, - "parameters": [], - "subInstructions": [ - { - "type": { - "value": "BuiltinCommonInstructions::CompareNumbers" - }, - "parameters": [ - "Object.Width()", - "!=", - "max(Background.BoundingBoxRight(), max(Label.BoundingBoxRight(), Thumb.BoundingBoxRight())) - min(Background.BoundingBoxLeft(), min(Label.BoundingBoxLeft(), Thumb.BoundingBoxLeft()))" - ] - }, - { - "type": { - "value": "BuiltinCommonInstructions::CompareNumbers" - }, - "parameters": [ - "Object.Height()", - "!=", - "max(Background.BoundingBoxBottom(), max(Label.BoundingBoxBottom(), Thumb.BoundingBoxBottom())) - min(Background.BoundingBoxTop(), min(Label.BoundingBoxTop(), Thumb.BoundingBoxTop()))" - ] - } + "parameters": [ + "Thumb", + "Draggable" ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "Width", - "=", - "Object.Width()" - ] - }, - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "Height", - "=", - "Object.Height()" - ] - }, - { - "type": { - "value": "ScalableCapability::ScalableBehavior::SetValue" - }, - "parameters": [ - "Object", - "Scale", - "=", - "1" - ] - }, - { - "type": { - "value": "ResizableCapability::ResizableBehavior::SetWidth" - }, - "parameters": [ - "Background", - "Resizable", - "=", - "Width" - ] - }, - { - "type": { - "value": "ResizableCapability::ResizableBehavior::SetHeight" - }, - "parameters": [ - "Background", - "Resizable", - "=", - "Height" - ] - }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - } - ], - "variables": [ - { - "name": "Width", - "type": "number", - "value": 0 - }, - { - "name": "Height", - "type": "number", - "value": 0 - } - ] - } - ] - } - ], - "parameters": [] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "The parent size is not defined in onCreate so it needs to be done here." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "BuiltinCommonInstructions::Once" - }, - "parameters": [] - } - ], - "actions": [ - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" - }, - "parameters": [ - "Object", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", - "type": "object" - } - ], - "objectGroups": [] - }, - { - "description": "Check if the slider is being dragged.", - "fullName": "Being dragged", - "functionType": "Condition", - "group": "Slider", - "name": "IsBeingDragged", - "sentence": "_PARAM0_ is being dragged", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "BuiltinCommonInstructions::Or" - }, - "parameters": [], - "subInstructions": [ - { - "type": { - "value": "DraggableBehavior::Dragged" - }, - "parameters": [ - "Thumb", - "Draggable" - ] - }, + }, { "type": { "value": "PanelSpriteSlider::ButtonFSM::IsPressed" @@ -27045,15 +26983,6 @@ "" ] }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, { "type": { "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" @@ -27141,15 +27070,6 @@ "" ] }, - { - "type": { - "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateLayout" - }, - "parameters": [ - "Object", - "" - ] - }, { "type": { "value": "PanelSpriteSlider::PanelSpriteSlider::UpdateThumbPosition" @@ -27396,54 +27316,6 @@ ], "objectGroups": [] }, - { - "description": "Center the bar according to the button configuration. This is used in doStepPostEvents when the button is resized.", - "fullName": "Update layout", - "functionType": "Action", - "name": "UpdateLayout", - "private": true, - "sentence": "Update layout of _PARAM0_", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "MettreXY" - }, - "parameters": [ - "FillBar", - "=", - "Object.PropertyBarLeftPadding()", - "=", - "Object.PropertyBarTopPadding()" - ] - }, - { - "type": { - "value": "ResizableCapability::ResizableBehavior::SetHeight" - }, - "parameters": [ - "FillBar", - "Resizable", - "=", - "round(Background.Height() - Object.PropertyBarTopPadding() - Object.PropertyBarBottomPadding())" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", - "type": "object" - } - ], - "objectGroups": [] - }, { "description": "Update the thumb position according to the slider value.", "fullName": "Update thumb position", @@ -27498,7 +27370,7 @@ "parameters": [ "Thumb", "=", - "Object.FullBarLeft() + FillBar.Width()" + "FillBar.X() + FillBar.Width()" ] }, { @@ -27573,76 +27445,6 @@ ], "objectGroups": [] }, - { - "fullName": "", - "functionType": "Expression", - "name": "FullBarLeft", - "private": true, - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "BarLeftPadding" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", - "type": "object" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "Expression", - "name": "FullBarRight", - "private": true, - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Background.Width() - BarRightPadding" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "PanelSpriteSlider::PanelSpriteSlider", - "type": "object" - } - ], - "objectGroups": [] - }, { "fullName": "", "functionType": "Expression", @@ -27659,7 +27461,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "Background.Width() - BarLeftPadding - BarRightPadding" + "Object.Width() - BarLeftPlusRightMargin" ] } ] @@ -27907,6 +27709,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarLeftPadding" }, { @@ -27918,6 +27721,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarTopPadding" }, { @@ -27929,6 +27733,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarRightPadding" }, { @@ -27940,6 +27745,7 @@ "Label", "FillBar" ], + "hidden": true, "name": "BarBottomPadding" }, { @@ -27952,6 +27758,7 @@ { "value": "8", "type": "Number", + "unit": "Pixel", "label": "Label margin", "group": "Label", "name": "LabelMargin" @@ -27959,6 +27766,7 @@ { "value": "0", "type": "Number", + "unit": "Dimensionless", "label": "Minimum value", "group": "Value", "name": "MinValue" @@ -27966,6 +27774,7 @@ { "value": "100", "type": "Number", + "unit": "Dimensionless", "label": "Maximum value", "group": "Value", "name": "MaxValue" @@ -27973,6 +27782,7 @@ { "value": "1", "type": "Number", + "unit": "Dimensionless", "label": "Step size", "group": "Value", "name": "StepSize" @@ -27980,6 +27790,7 @@ { "value": "50", "type": "Number", + "unit": "Dimensionless", "label": "Initial value", "group": "Value", "name": "InitialValue" @@ -28024,9 +27835,286 @@ ], "hidden": true, "name": "ShowLabel" + }, + { + "value": "0", + "type": "Number", + "label": "", + "hidden": true, + "name": "BarLeftPlusRightMargin" + }, + { + "value": "0", + "type": "Number", + "label": "", + "hidden": true, + "name": "BarTopPlusBottomMargin" + }, + { + "value": "0", + "type": "Number", + "label": "", + "hidden": true, + "name": "OldParentWidth" } ], - "variants": [] + "variants": [ + { + "areaMaxX": 265, + "areaMaxY": 28, + "areaMaxZ": 64, + "areaMinX": 0, + "areaMinY": 0, + "areaMinZ": 0, + "assetStoreAssetId": "bfeeb465a4a164b560a2215e3ff9e78e66123af43cbf7ef1f22d56fca4271c80", + "assetStoreOriginalName": "Square white slider", + "name": "Square white slider", + "objects": [ + { + "assetStoreId": "", + "bold": false, + "italic": false, + "name": "Label", + "smoothed": true, + "type": "TextObject::Text", + "underlined": false, + "variables": [], + "effects": [], + "behaviors": [], + "string": "It displays the value when it changes.", + "font": "", + "textAlignment": "", + "characterSize": 20, + "color": { + "b": 255, + "g": 255, + "r": 255 + }, + "content": { + "bold": false, + "isOutlineEnabled": false, + "isShadowEnabled": false, + "italic": false, + "outlineColor": "255;255;255", + "outlineThickness": 2, + "shadowAngle": 90, + "shadowBlurRadius": 2, + "shadowColor": "0;0;0", + "shadowDistance": 4, + "shadowOpacity": 127, + "smoothed": true, + "underlined": false, + "text": "It displays the value when it changes.", + "font": "", + "textAlignment": "", + "verticalTextAlignment": "top", + "characterSize": 20, + "color": "255;255;255" + } + }, + { + "assetStoreId": "", + "bottomMargin": 2, + "height": 36, + "leftMargin": 1, + "name": "Thumb", + "rightMargin": 2, + "texture": "Square White Slider Thumb.png", + "tiled": false, + "topMargin": 2, + "type": "PanelSpriteObject::PanelSprite", + "width": 22, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 4, + "leftEdgeAnchor": 0, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "topEdgeAnchor": 4, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "Draggable", + "type": "DraggableBehavior::Draggable", + "checkCollisionMask": false + } + ] + }, + { + "assetStoreId": "", + "bottomMargin": 2, + "height": 16, + "leftMargin": 0, + "name": "FillBar", + "rightMargin": 0, + "texture": "Square White Slider Fill Bar.png", + "tiled": false, + "topMargin": 0, + "type": "PanelSpriteObject::PanelSprite", + "width": 16, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "topEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "Slider", + "type": "PanelSpriteSlider::Slider", + "Value": 0, + "MinValue": 0, + "MaxValue": 1, + "StepSize": 1 + } + ] + }, + { + "assetStoreId": "", + "bottomMargin": 4, + "height": 28, + "leftMargin": 2, + "name": "Background", + "rightMargin": 2, + "texture": "Square White Slider Border.png", + "tiled": false, + "topMargin": 4, + "type": "PanelSpriteObject::PanelSprite", + "width": 265, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Anchor", + "type": "AnchorBehavior::AnchorBehavior", + "bottomEdgeAnchor": 2, + "leftEdgeAnchor": 1, + "topEdgeAnchor": 1, + "relativeToOriginalWindowSize": true, + "rightEdgeAnchor": 2, + "useLegacyBottomAndRightAnchors": false + }, + { + "name": "ButtonFSM", + "type": "PanelSpriteSlider::ButtonFSM", + "ShouldCheckHovering": true, + "State": "Idle", + "TouchId": 0, + "TouchIsInside": false, + "MouseIsInside": false, + "Index": 0 + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Label" + }, + { + "objectName": "Thumb" + }, + { + "objectName": "FillBar" + }, + { + "objectName": "Background" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera3DFarPlaneDistance": 10000, + "camera3DFieldOfView": 45, + "camera3DNearPlaneDistance": 3, + "cameraType": "", + "followBaseLayerCamera": false, + "isLightingLayer": false, + "isLocked": false, + "name": "", + "renderingType": "", + "visibility": true, + "cameras": [ + { + "defaultSize": true, + "defaultViewport": true, + "height": 0, + "viewportBottom": 1, + "viewportLeft": 0, + "viewportRight": 1, + "viewportTop": 0, + "width": 0 + } + ], + "effects": [] + } + ], + "instances": [ + { + "angle": 0, + "customSize": false, + "height": 64, + "layer": "", + "name": "Background", + "persistentUuid": "7b36a716-8a01-496a-ad7d-0de60daff8f9", + "width": 256, + "x": 0, + "y": 0, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 1, + "height": 16, + "layer": "", + "name": "FillBar", + "persistentUuid": "e775f69e-7845-4103-8a05-5266aba60742", + "width": 253, + "x": 6, + "y": 6, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 84, + "layer": "", + "name": "Thumb", + "persistentUuid": "476a27da-e34f-451f-b660-04a6bbefddbe", + "width": 32, + "x": 248, + "y": -4, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] } ] }, From 4393b0a1480fdcfee1b3293593aa358c8cc953ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sat, 19 Jul 2025 18:28:39 +0200 Subject: [PATCH 4/4] Use button effect behavior. --- .../wave-defense-shooter.json | 98 ++++++------------- 1 file changed, 31 insertions(+), 67 deletions(-) diff --git a/examples/wave-defense-shooter/wave-defense-shooter.json b/examples/wave-defense-shooter/wave-defense-shooter.json index 1b0823b89..818eac3cb 100644 --- a/examples/wave-defense-shooter/wave-defense-shooter.json +++ b/examples/wave-defense-shooter/wave-defense-shooter.json @@ -1235,6 +1235,15 @@ "TouchIsInside": false, "MouseIsInside": false, "Index": 0 + }, + { + "name": "ButtonObjectEffects", + "type": "ButtonStates::ButtonObjectEffects", + "ButtonFSM": "ButtonFSM", + "Effect": "Effect", + "IdleEffect": "", + "FocusedEffect": "Effect", + "PressedEffect": "" } ], "content": { @@ -1279,6 +1288,15 @@ "TouchIsInside": false, "MouseIsInside": false, "Index": 0 + }, + { + "name": "ButtonObjectEffects", + "type": "ButtonStates::ButtonObjectEffects", + "ButtonFSM": "ButtonFSM", + "Effect": "Effect", + "IdleEffect": "", + "FocusedEffect": "Effect", + "PressedEffect": "" } ], "content": { @@ -1429,6 +1447,15 @@ "TouchIsInside": false, "MouseIsInside": false, "Index": 0 + }, + { + "name": "ButtonObjectEffects", + "type": "ButtonStates::ButtonObjectEffects", + "ButtonFSM": "ButtonFSM", + "Effect": "Effect", + "IdleEffect": "", + "FocusedEffect": "Effect", + "PressedEffect": "" } ], "content": { @@ -2040,73 +2067,6 @@ } ] }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Visual and sound effects when interacting with the Buttons" - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "ButtonStates::ButtonFSM::IsHovered" - }, - "parameters": [ - "Buttons", - "ButtonFSM", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "EnableEffect" - }, - "parameters": [ - "Buttons", - "\"Effect\"", - "yes" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "inverted": true, - "value": "ButtonStates::ButtonFSM::IsHovered" - }, - "parameters": [ - "Buttons", - "ButtonFSM", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "EnableEffect" - }, - "parameters": [ - "Buttons", - "\"Effect\"", - "no" - ] - } - ] - }, { "type": "BuiltinCommonInstructions::Standard", "conditions": [ @@ -2438,6 +2398,10 @@ "name": "ButtonFSM", "type": "ButtonStates::ButtonFSM" }, + { + "name": "ButtonObjectEffects", + "type": "ButtonStates::ButtonObjectEffects" + }, { "name": "Effect", "type": "EffectCapability::EffectBehavior"