From 2138e9359809c4ef920f2f334594e269b78b9745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sat, 21 Jan 2023 20:53:50 +0100 Subject: [PATCH] [Community] [Slider and Toggle Switch] Upgrade the ButtonFSM behavior. --- extensions/community/PanelSpriteSlider.json | 385 +---- extensions/community/SpriteToggleSwitch.json | 1396 +++++++----------- 2 files changed, 552 insertions(+), 1229 deletions(-) diff --git a/extensions/community/PanelSpriteSlider.json b/extensions/community/PanelSpriteSlider.json index 77206b6f0..e48981815 100644 --- a/extensions/community/PanelSpriteSlider.json +++ b/extensions/community/PanelSpriteSlider.json @@ -8,7 +8,7 @@ "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.1.3", + "version": "1.2.0", "description": "A draggable slider that users can move to select a numerical value. The slider can be customized with sprites.", "origin": { "identifier": "ResourceBar", @@ -518,45 +518,6 @@ "name": "doStepPostEvents", "sentence": "", "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "We don't use the touch capability condition because the device could have both touch and cursor.", - "comment2": "" - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "PanelSpriteSlider::AnyTouchPressed" - }, - "parameters": [ - "", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "PanelSpriteSlider::ButtonFSM::SetPropertyShouldCheckHovering" - }, - "parameters": [ - "Object", - "Behavior", - "" - ] - } - ] - }, { "colorB": 228, "colorG": 176, @@ -651,33 +612,21 @@ "conditions": [ { "type": { - "inverted": true, - "value": "PanelSpriteSlider::AnyTouchPressed" - }, - "parameters": [ - "", - "" - ] - }, - { - "type": { - "value": "PanelSpriteSlider::ButtonFSM::ShouldCheckMousePosition" + "value": "PanelSpriteSlider::ButtonFSM::PropertyShouldCheckHovering" }, "parameters": [ "Object", - "Behavior", - "" + "Behavior" ] }, { "type": { - "value": "SourisSurObjet" + "value": "CollisionPoint" }, "parameters": [ "Object", - "", - "no", - "" + "MouseOnlyCursorX(Object.Layer(), 0)", + "MouseOnlyCursorY(Object.Layer(), 0)" ] } ], @@ -778,7 +727,7 @@ "conditions": [ { "type": { - "value": "HasAnyTouchStarted" + "value": "HasAnyTouchOrMouseStarted" }, "parameters": [ "" @@ -801,7 +750,7 @@ "events": [ { "type": "BuiltinCommonInstructions::Repeat", - "repeatExpression": "StartedTouchCount()", + "repeatExpression": "StartedTouchOrMouseCount()", "conditions": [], "actions": [], "events": [ @@ -814,8 +763,8 @@ }, "parameters": [ "Object", - "TouchX(StartedTouchId(Object.Behavior::PropertyIndex()), Object.Layer(), 0)", - "TouchY(StartedTouchId(Object.Behavior::PropertyIndex()), Object.Layer(), 0)" + "TouchX(StartedTouchOrMouseId(Object.Behavior::PropertyIndex()), Object.Layer(), 0)", + "TouchY(StartedTouchOrMouseId(Object.Behavior::PropertyIndex()), Object.Layer(), 0)" ] } ], @@ -828,7 +777,7 @@ "Object", "Behavior", "=", - "StartedTouchId(Object.Behavior::PropertyIndex())" + "StartedTouchOrMouseId(Object.Behavior::PropertyIndex())" ] }, { @@ -913,130 +862,6 @@ ] } ] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Ignore mouse events when a touch is active because the mouse is probably an echo of touch events.\nThe mouse press could be a touch that has not the right TouchId.", - "comment2": "" - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "MouseButtonPressed" - }, - "parameters": [ - "", - "Left" - ] - }, - { - "type": { - "value": "BuiltinCommonInstructions::Once" - }, - "parameters": [] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "inverted": true, - "value": "PanelSpriteSlider::AnyTouchPressed" - }, - "parameters": [ - "", - "" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "The trigger once must be before the state condition to detect a new press.", - "comment2": "" - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "PanelSpriteSlider::ButtonFSM::PropertyMouseIsInside" - }, - "parameters": [ - "Object", - "Behavior" - ] - }, - { - "type": { - "value": "BuiltinCommonInstructions::Or" - }, - "parameters": [], - "subInstructions": [ - { - "type": { - "value": "PanelSpriteSlider::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Hovered\"" - ] - }, - { - "type": { - "value": "PanelSpriteSlider::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Idle\"" - ] - } - ] - } - ], - "actions": [ - { - "type": { - "value": "PanelSpriteSlider::ButtonFSM::SetPropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"PressedInside\"" - ] - } - ] - } - ] - } - ] } ], "parameters": [] @@ -1250,117 +1075,6 @@ "source": "", "type": "BuiltinCommonInstructions::Group", "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Ignore mouse events when a touch is active because the mouse is probably an echo of touch events.\nThe mouse release could be a touch release that has not the right TouchId.", - "comment2": "" - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "MouseButtonReleased" - }, - "parameters": [ - "", - "Left" - ] - }, - { - "type": { - "inverted": true, - "value": "PanelSpriteSlider::AnyTouchPressed" - }, - "parameters": [ - "", - "" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "PanelSpriteSlider::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"PressedInside\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PanelSpriteSlider::ButtonFSM::SetPropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Validated\"" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "inverted": true, - "value": "PanelSpriteSlider::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"PressedInside\"" - ] - }, - { - "type": { - "inverted": true, - "value": "PanelSpriteSlider::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Validated\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PanelSpriteSlider::ButtonFSM::SetPropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Idle\"" - ] - } - ] - } - ] - }, { "type": "BuiltinCommonInstructions::Standard", "conditions": [ @@ -1802,83 +1516,6 @@ } ], "objectGroups": [] - }, - { - "fullName": "Should check mouse position", - "functionType": "Condition", - "name": "ShouldCheckMousePosition", - "private": true, - "sentence": "_PARAM0_ should check mouse position", - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Using a function avoid the OR to unselect Object when the property is not set.", - "comment2": "" - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "BuiltinCommonInstructions::Or" - }, - "parameters": [], - "subInstructions": [ - { - "type": { - "value": "MouseButtonPressed" - }, - "parameters": [ - "", - "Left" - ] - }, - { - "type": { - "value": "PanelSpriteSlider::ButtonFSM::PropertyShouldCheckHovering" - }, - "parameters": [ - "Object", - "Behavior" - ] - } - ] - } - ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "PanelSpriteSlider::ButtonFSM", - "type": "behavior" - } - ], - "objectGroups": [] } ], "propertyDescriptors": [ diff --git a/extensions/community/SpriteToggleSwitch.json b/extensions/community/SpriteToggleSwitch.json index 8d16e82a4..b688da343 100644 --- a/extensions/community/SpriteToggleSwitch.json +++ b/extensions/community/SpriteToggleSwitch.json @@ -8,7 +8,7 @@ "name": "SpriteToggleSwitch", "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Line Hero Pack/Master/SVG/Interface Elements/8d0cd8cd0c9318f4f6efde6ee6b4c192bd19306467f80c9970387a259300f895_Interface Elements_interface_ui_toggle_switch_on_off.svg", "shortDescription": "Toggle switch that users can click or touch.", - "version": "1.0.1", + "version": "1.1.0", "description": "Toggle switch that users can click or touch. The switch can be customized with sprites.", "tags": [ "ui", @@ -46,57 +46,323 @@ ], "eventsBasedBehaviors": [ { - "description": "The finite state machine used internally by the button object.", - "fullName": "Button finite state machine", - "name": "ButtonFSM", + "description": "The finite state machine used internally by the switch object.", + "fullName": "Switch finite state machine", + "name": "SwitchFSM", "objectType": "", "private": true, "eventsFunctions": [ { "fullName": "", "functionType": "Action", - "name": "doStepPostEvents", + "name": "doStepPreEvents", "sentence": "", "events": [ { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "We don't use the touch capability condition because the device could have both touch and cursor.", - "comment2": "" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteToggleSwitch::ButtonFSM::IsClicked" + }, + "parameters": [ + "Object", + "ButtonFSM", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyWasChecked" + }, + "parameters": [ + "Object", + "Behavior", + "no" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteToggleSwitch::SwitchFSM::IsChecked" + }, + "parameters": [ + "Object", + "Behavior", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyWasChecked" + }, + "parameters": [ + "Object", + "Behavior", + "yes" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "SpriteToggleSwitch::SwitchFSM::PropertyWasChecked" + }, + "parameters": [ + "Object", + "Behavior" + ] + } + ], + "actions": [ + { + "type": { + "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyIsChecked" + }, + "parameters": [ + "Object", + "Behavior", + "yes" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteToggleSwitch::SwitchFSM::PropertyWasChecked" + }, + "parameters": [ + "Object", + "Behavior" + ] + } + ], + "actions": [ + { + "type": { + "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyIsChecked" + }, + "parameters": [ + "Object", + "Behavior", + "no" + ] + } + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "type": "object" }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "SpriteToggleSwitch::SwitchFSM", + "type": "behavior" + } + ], + "objectGroups": [] + }, + { + "description": "Check if is checked.", + "fullName": "Is checked", + "functionType": "Condition", + "group": "Switch finite state machine configuration", + "name": "IsChecked", + "sentence": "_PARAM0_ is checked", + "events": [ { "type": "BuiltinCommonInstructions::Standard", "conditions": [ { "type": { - "value": "SpriteToggleSwitch::AnyTouchPressed" + "value": "SpriteToggleSwitch::SwitchFSM::PropertyIsChecked" }, "parameters": [ - "", - "" + "Object", + "Behavior" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "SpriteToggleSwitch::SwitchFSM", + "type": "behavior" + } + ], + "objectGroups": [] + }, + { + "description": "Change if is checked.", + "fullName": "Is checked", + "functionType": "Action", + "group": "Switch finite state machine configuration", + "name": "SetChecked", + "sentence": "_PARAM0_ is checked: _PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"Value\"" ] } ], "actions": [ { "type": { - "value": "SpriteToggleSwitch::ButtonFSM::SetPropertyShouldCheckHovering" + "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyIsChecked" }, "parameters": [ "Object", "Behavior", - "" + "no" ] } ] }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"Value\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyIsChecked" + }, + "parameters": [ + "Object", + "Behavior", + "yes" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "SpriteToggleSwitch::SwitchFSM", + "type": "behavior" + }, + { + "defaultValue": "yes", + "description": "IsChecked", + "name": "Value", + "optional": true, + "type": "yesorno" + } + ], + "objectGroups": [] + } + ], + "propertyDescriptors": [ + { + "value": "", + "type": "Behavior", + "label": "Button finite state machine", + "description": "", + "group": "", + "extraInformation": [ + "SpriteToggleSwitch::ButtonFSM" + ], + "hidden": false, + "name": "ButtonFSM" + }, + { + "value": "false", + "type": "Boolean", + "label": "Is checked", + "description": "", + "group": "", + "extraInformation": [], + "hidden": false, + "name": "IsChecked" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "description": "", + "group": "", + "extraInformation": [], + "hidden": true, + "name": "WasChecked" + } + ], + "sharedPropertyDescriptors": [] + }, + { + "description": "The finite state machine used internally by the button object.", + "fullName": "Button finite state machine", + "name": "ButtonFSM", + "objectType": "", + "private": true, + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", + "events": [ { "colorB": 228, "colorG": 176, @@ -191,33 +457,21 @@ "conditions": [ { "type": { - "inverted": true, - "value": "SpriteToggleSwitch::AnyTouchPressed" - }, - "parameters": [ - "", - "" - ] - }, - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::ShouldCheckMousePosition" + "value": "SpriteToggleSwitch::ButtonFSM::PropertyShouldCheckHovering" }, "parameters": [ "Object", - "Behavior", - "" + "Behavior" ] }, { "type": { - "value": "SourisSurObjet" + "value": "CollisionPoint" }, "parameters": [ "Object", - "", - "no", - "" + "MouseOnlyCursorX(Object.Layer(), 0)", + "MouseOnlyCursorY(Object.Layer(), 0)" ] } ], @@ -318,7 +572,7 @@ "conditions": [ { "type": { - "value": "HasAnyTouchStarted" + "value": "HasAnyTouchOrMouseStarted" }, "parameters": [ "" @@ -341,7 +595,7 @@ "events": [ { "type": "BuiltinCommonInstructions::Repeat", - "repeatExpression": "StartedTouchCount()", + "repeatExpression": "StartedTouchOrMouseCount()", "conditions": [], "actions": [], "events": [ @@ -354,8 +608,8 @@ }, "parameters": [ "Object", - "TouchX(StartedTouchId(Object.Behavior::PropertyIndex()), Object.Layer(), 0)", - "TouchY(StartedTouchId(Object.Behavior::PropertyIndex()), Object.Layer(), 0)" + "TouchX(StartedTouchOrMouseId(Object.Behavior::PropertyIndex()), Object.Layer(), 0)", + "TouchY(StartedTouchOrMouseId(Object.Behavior::PropertyIndex()), Object.Layer(), 0)" ] } ], @@ -368,7 +622,7 @@ "Object", "Behavior", "=", - "StartedTouchId(Object.Behavior::PropertyIndex())" + "StartedTouchOrMouseId(Object.Behavior::PropertyIndex())" ] }, { @@ -453,130 +707,6 @@ ] } ] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Ignore mouse events when a touch is active because the mouse is probably an echo of touch events.\nThe mouse press could be a touch that has not the right TouchId.", - "comment2": "" - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "MouseButtonPressed" - }, - "parameters": [ - "", - "Left" - ] - }, - { - "type": { - "value": "BuiltinCommonInstructions::Once" - }, - "parameters": [] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "inverted": true, - "value": "SpriteToggleSwitch::AnyTouchPressed" - }, - "parameters": [ - "", - "" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "The trigger once must be before the state condition to detect a new press.", - "comment2": "" - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyMouseIsInside" - }, - "parameters": [ - "Object", - "Behavior" - ] - }, - { - "type": { - "value": "BuiltinCommonInstructions::Or" - }, - "parameters": [], - "subInstructions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Hovered\"" - ] - }, - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Idle\"" - ] - } - ] - } - ], - "actions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::SetPropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"PressedInside\"" - ] - } - ] - } - ] - } - ] } ], "parameters": [] @@ -656,173 +786,53 @@ "Object", "Behavior", "=", - "\"PressedInside\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::SetPropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"PressedOutside\"" - ] - } - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "BuiltinCommonInstructions::Or" - }, - "parameters": [], - "subInstructions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyMouseIsInside" - }, - "parameters": [ - "Object", - "Behavior" - ] - }, - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyTouchIsInside" - }, - "parameters": [ - "Object", - "Behavior" - ] - } - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"PressedOutside\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::SetPropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"PressedInside\"" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "inverted": true, - "value": "MouseButtonPressed" - }, - "parameters": [ - "", - "Left" - ] - }, - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Idle\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::SetPropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Hovered\"" - ] - } - ] - } - ] - } - ], - "parameters": [] - }, - { - "colorB": 228, - "colorG": 176, - "colorR": 74, - "creationTime": 0, - "name": "Handle touch end", - "source": "", - "type": "BuiltinCommonInstructions::Group", - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Ignore mouse events when a touch is active because the mouse is probably an echo of touch events.\nThe mouse release could be a touch release that has not the right TouchId.", - "comment2": "" + "\"PressedInside\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SpriteToggleSwitch::ButtonFSM::SetPropertyState" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"PressedOutside\"" + ] + } + ] + } + ] }, { "type": "BuiltinCommonInstructions::Standard", "conditions": [ { "type": { - "value": "MouseButtonReleased" - }, - "parameters": [ - "", - "Left" - ] - }, - { - "type": { - "inverted": true, - "value": "SpriteToggleSwitch::AnyTouchPressed" + "value": "BuiltinCommonInstructions::Or" }, - "parameters": [ - "", - "" + "parameters": [], + "subInstructions": [ + { + "type": { + "value": "SpriteToggleSwitch::ButtonFSM::PropertyMouseIsInside" + }, + "parameters": [ + "Object", + "Behavior" + ] + }, + { + "type": { + "value": "SpriteToggleSwitch::ButtonFSM::PropertyTouchIsInside" + }, + "parameters": [ + "Object", + "Behavior" + ] + } ] } ], @@ -839,7 +849,7 @@ "Object", "Behavior", "=", - "\"PressedInside\"" + "\"PressedOutside\"" ] } ], @@ -852,7 +862,7 @@ "Object", "Behavior", "=", - "\"Validated\"" + "\"PressedInside\"" ] } ] @@ -863,25 +873,22 @@ { "type": { "inverted": true, - "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" + "value": "MouseButtonPressed" }, "parameters": [ - "Object", - "Behavior", - "=", - "\"PressedInside\"" + "", + "Left" ] }, { "type": { - "inverted": true, "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" }, "parameters": [ "Object", "Behavior", "=", - "\"Validated\"" + "\"Idle\"" ] } ], @@ -894,13 +901,25 @@ "Object", "Behavior", "=", - "\"Idle\"" + "\"Hovered\"" ] } ] } ] - }, + } + ], + "parameters": [] + }, + { + "colorB": 228, + "colorG": 176, + "colorR": 74, + "creationTime": 0, + "name": "Handle touch end", + "source": "", + "type": "BuiltinCommonInstructions::Group", + "events": [ { "type": "BuiltinCommonInstructions::Standard", "conditions": [ @@ -967,192 +986,45 @@ }, "parameters": [ "Object", - "Behavior", - "=", - "\"PressedInside\"" - ] - }, - { - "type": { - "inverted": true, - "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Validated\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::SetPropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Idle\"" - ] - } - ] - } - ] - } - ], - "parameters": [] - } - ], - "parameters": [] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteToggleSwitch::ButtonFSM", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "Check if the button is not used.", - "fullName": "Is idle", - "functionType": "Condition", - "name": "IsIdle", - "sentence": "_PARAM0_ is idle", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Idle\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteToggleSwitch::ButtonFSM", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "Check if the button was just clicked.", - "fullName": "Is clicked", - "functionType": "Condition", - "name": "IsClicked", - "sentence": "_PARAM0_ is clicked", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Validated\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteToggleSwitch::ButtonFSM", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "Check if the cursor is hovered over the button.", - "fullName": "Is hovered", - "functionType": "Condition", - "name": "IsHovered", - "sentence": "_PARAM0_ is hovered", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Hovered\"" - ] + "Behavior", + "=", + "\"PressedInside\"" + ] + }, + { + "type": { + "inverted": true, + "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"Validated\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SpriteToggleSwitch::ButtonFSM::SetPropertyState" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"Idle\"" + ] + } + ] + } + ] + } + ], + "parameters": [] } ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] + "parameters": [] } ], "parameters": [ @@ -1171,11 +1043,11 @@ "objectGroups": [] }, { - "description": "Check if the button is either hovered or pressed but not hovered.", - "fullName": "Is focused", + "description": "Check if the button is not used.", + "fullName": "Is idle", "functionType": "Condition", - "name": "IsFocused", - "sentence": "_PARAM0_ is focused", + "name": "IsIdle", + "sentence": "_PARAM0_ is idle", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -1188,33 +1060,7 @@ "Object", "Behavior", "=", - "\"Hovered\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"PressedOutside\"" + "\"Idle\"" ] } ], @@ -1246,11 +1092,11 @@ "objectGroups": [] }, { - "description": "Check if the button is currently being pressed with mouse or touch.", - "fullName": "Is pressed", + "description": "Check if the button was just clicked.", + "fullName": "Is clicked", "functionType": "Condition", - "name": "IsPressed", - "sentence": "_PARAM0_ is pressed", + "name": "IsClicked", + "sentence": "_PARAM0_ is clicked", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -1263,7 +1109,7 @@ "Object", "Behavior", "=", - "\"PressedInside\"" + "\"Validated\"" ] } ], @@ -1295,271 +1141,34 @@ "objectGroups": [] }, { - "fullName": "Should check mouse position", + "description": "Check if the cursor is hovered over the button.", + "fullName": "Is hovered", "functionType": "Condition", - "name": "ShouldCheckMousePosition", - "private": true, - "sentence": "_PARAM0_ should check mouse position", - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Using a function avoid the OR to unselect Object when the property is not set.", - "comment2": "" - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "BuiltinCommonInstructions::Or" - }, - "parameters": [], - "subInstructions": [ - { - "type": { - "value": "MouseButtonPressed" - }, - "parameters": [ - "", - "Left" - ] - }, - { - "type": { - "value": "SpriteToggleSwitch::ButtonFSM::PropertyShouldCheckHovering" - }, - "parameters": [ - "Object", - "Behavior" - ] - } - ] - } - ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteToggleSwitch::ButtonFSM", - "type": "behavior" - } - ], - "objectGroups": [] - } - ], - "propertyDescriptors": [ - { - "value": "true", - "type": "Boolean", - "label": "", - "description": "Should check hovering", - "group": "", - "extraInformation": [], - "hidden": true, - "name": "ShouldCheckHovering" - }, - { - "value": "Idle", - "type": "Choice", - "label": "State", - "description": "", - "group": "", - "extraInformation": [ - "Idle", - "Hovered", - "PressedInside", - "PressedOutside", - "Validated" - ], - "hidden": true, - "name": "State" - }, - { - "value": "0", - "type": "Number", - "label": "Touch id", - "description": "", - "group": "", - "extraInformation": [], - "hidden": true, - "name": "TouchId" - }, - { - "value": "", - "type": "Boolean", - "label": "Touch is inside", - "description": "", - "group": "", - "extraInformation": [], - "hidden": true, - "name": "TouchIsInside" - }, - { - "value": "", - "type": "Boolean", - "label": "Mouse is inside", - "description": "", - "group": "", - "extraInformation": [], - "hidden": true, - "name": "MouseIsInside" - }, - { - "value": "", - "type": "Number", - "label": "", - "description": "", - "group": "", - "extraInformation": [], - "hidden": true, - "name": "Index" - } - ], - "sharedPropertyDescriptors": [] - }, - { - "description": "The finite state machine used internally by the switch object.", - "fullName": "Switch finite state machine", - "name": "SwitchFSM", - "objectType": "", - "private": true, - "eventsFunctions": [ - { - "fullName": "", - "functionType": "Action", - "name": "doStepPreEvents", - "sentence": "", + "name": "IsHovered", + "sentence": "_PARAM0_ is hovered", "events": [ { "type": "BuiltinCommonInstructions::Standard", "conditions": [ { "type": { - "value": "SpriteToggleSwitch::ButtonFSM::IsClicked" - }, - "parameters": [ - "Object", - "ButtonFSM", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyWasChecked" + "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" }, "parameters": [ "Object", "Behavior", - "no" + "=", + "\"Hovered\"" ] } ], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteToggleSwitch::SwitchFSM::IsChecked" - }, - "parameters": [ - "Object", - "Behavior", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyWasChecked" - }, - "parameters": [ - "Object", - "Behavior", - "yes" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "inverted": true, - "value": "SpriteToggleSwitch::SwitchFSM::PropertyWasChecked" - }, - "parameters": [ - "Object", - "Behavior" - ] - } - ], - "actions": [ - { - "type": { - "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyIsChecked" - }, - "parameters": [ - "Object", - "Behavior", - "yes" - ] - } - ] - }, + "actions": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteToggleSwitch::SwitchFSM::PropertyWasChecked" - }, - "parameters": [ - "Object", - "Behavior" - ] - } - ], - "actions": [ - { - "type": { - "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyIsChecked" - }, - "parameters": [ - "Object", - "Behavior", - "no" - ] - } + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" ] } ] @@ -1574,30 +1183,57 @@ { "description": "Behavior", "name": "Behavior", - "supplementaryInformation": "SpriteToggleSwitch::SwitchFSM", + "supplementaryInformation": "SpriteToggleSwitch::ButtonFSM", "type": "behavior" } ], "objectGroups": [] }, { - "description": "Check if is checked.", - "fullName": "Is checked", + "description": "Check if the button is either hovered or pressed but not hovered.", + "fullName": "Is focused", "functionType": "Condition", - "group": "Switch finite state machine configuration", - "name": "IsChecked", - "sentence": "_PARAM0_ is checked", + "name": "IsFocused", + "sentence": "_PARAM0_ is focused", "events": [ { "type": "BuiltinCommonInstructions::Standard", "conditions": [ { "type": { - "value": "SpriteToggleSwitch::SwitchFSM::PropertyIsChecked" + "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" }, "parameters": [ "Object", - "Behavior" + "Behavior", + "=", + "\"Hovered\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"PressedOutside\"" ] } ], @@ -1622,67 +1258,90 @@ { "description": "Behavior", "name": "Behavior", - "supplementaryInformation": "SpriteToggleSwitch::SwitchFSM", + "supplementaryInformation": "SpriteToggleSwitch::ButtonFSM", "type": "behavior" } ], "objectGroups": [] }, { - "description": "Change if is checked.", - "fullName": "Is checked", - "functionType": "Action", - "group": "Switch finite state machine configuration", - "name": "SetChecked", - "sentence": "_PARAM0_ is checked: _PARAM2_", + "description": "Check if the button is currently being pressed with mouse or touch.", + "fullName": "Is pressed", + "functionType": "Condition", + "name": "IsPressed", + "sentence": "_PARAM0_ is pressed", "events": [ { "type": "BuiltinCommonInstructions::Standard", "conditions": [ { "type": { - "inverted": true, - "value": "GetArgumentAsBoolean" + "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" }, "parameters": [ - "\"Value\"" + "Object", + "Behavior", + "=", + "\"PressedInside\"" ] } ], "actions": [ { "type": { - "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyIsChecked" + "value": "SetReturnBoolean" }, "parameters": [ - "Object", - "Behavior", - "no" + "True" ] } ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "type": "object" }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "SpriteToggleSwitch::ButtonFSM", + "type": "behavior" + } + ], + "objectGroups": [] + }, + { + "description": "Check if the button is currently being pressed outside with mouse or touch.", + "fullName": "Is held outside", + "functionType": "Condition", + "name": "IsPressedOutside", + "sentence": "_PARAM0_ is held outside", + "events": [ { "type": "BuiltinCommonInstructions::Standard", "conditions": [ { "type": { - "value": "GetArgumentAsBoolean" + "value": "SpriteToggleSwitch::ButtonFSM::PropertyState" }, "parameters": [ - "\"Value\"" + "Object", + "Behavior", + "=", + "\"PressedOutside\"" ] } ], "actions": [ { "type": { - "value": "SpriteToggleSwitch::SwitchFSM::SetPropertyIsChecked" + "value": "SetReturnBoolean" }, "parameters": [ - "Object", - "Behavior", - "yes" + "True" ] } ] @@ -1697,15 +1356,8 @@ { "description": "Behavior", "name": "Behavior", - "supplementaryInformation": "SpriteToggleSwitch::SwitchFSM", + "supplementaryInformation": "SpriteToggleSwitch::ButtonFSM", "type": "behavior" - }, - { - "defaultValue": "yes", - "description": "IsChecked", - "name": "Value", - "optional": true, - "type": "yesorno" } ], "objectGroups": [] @@ -1713,36 +1365,70 @@ ], "propertyDescriptors": [ { - "value": "", - "type": "Behavior", - "label": "Button finite state machine", + "value": "true", + "type": "Boolean", + "label": "", + "description": "Should check hovering", + "group": "", + "extraInformation": [], + "hidden": true, + "name": "ShouldCheckHovering" + }, + { + "value": "Idle", + "type": "Choice", + "label": "State", "description": "", "group": "", "extraInformation": [ - "SpriteToggleSwitch::ButtonFSM" + "Idle", + "Hovered", + "PressedInside", + "PressedOutside", + "Validated" ], - "hidden": false, - "name": "ButtonFSM" + "hidden": true, + "name": "State" }, { - "value": "false", + "value": "0", + "type": "Number", + "label": "Touch id", + "description": "", + "group": "", + "extraInformation": [], + "hidden": true, + "name": "TouchId" + }, + { + "value": "", "type": "Boolean", - "label": "Is checked", + "label": "Touch is inside", "description": "", "group": "", "extraInformation": [], - "hidden": false, - "name": "IsChecked" + "hidden": true, + "name": "TouchIsInside" }, { "value": "", "type": "Boolean", + "label": "Mouse is inside", + "description": "", + "group": "", + "extraInformation": [], + "hidden": true, + "name": "MouseIsInside" + }, + { + "value": "", + "type": "Number", "label": "", "description": "", "group": "", "extraInformation": [], "hidden": true, - "name": "WasChecked" + "name": "Index" } ], "sharedPropertyDescriptors": []