diff --git a/extensions/reviewed/PanelSpriteButton.json b/extensions/reviewed/PanelSpriteButton.json index f23677204..3828b9267 100644 --- a/extensions/reviewed/PanelSpriteButton.json +++ b/extensions/reviewed/PanelSpriteButton.json @@ -9,7 +9,7 @@ "name": "PanelSpriteButton", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/Interface Elements/Interface Elements_interface_ui_button_ok_cta_clock_tap.svg", "shortDescription": "A button with a label.", - "version": "2.1.2", + "version": "2.2.0", "description": [ "A button that can be used for menus and most labelled buttons of a game. The button can be customized with a background for each state and a label. It handles user interactions and a simple condition can be used to check if it is clicked.", "", @@ -1249,6 +1249,953 @@ } ] } + }, + { + "description": "Change the text style when the button is hovered.", + "fullName": "Hover text style", + "name": "TextStyleState", + "objectType": "TextObject::Text", + "private": true, + "eventsFunctions": [ + { + "description": "Check if isHovered.", + "fullName": "IsHovered", + "functionType": "Condition", + "name": "IsHovered", + "sentence": "_PARAM0_ isHovered", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsHovered", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "TextObject::Text", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "PanelSpriteButton::TextStyleState", + "type": "behavior" + } + ], + "objectGroups": [] + }, + { + "description": "Change if isHovered.", + "fullName": "IsHovered", + "functionType": "Action", + "name": "SetIsHovered", + "sentence": "_PARAM0_ isHovered: _PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsHovered", + "False", + "" + ] + }, + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "Value", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsHovered", + "True", + "" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HoverFontSize", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "IdleFontSize", + "=", + "Object.FontSize()" + ] + }, + { + "type": { + "value": "TextObject::Text::SetFontSize" + }, + "parameters": [ + "Object", + "=", + "HoverFontSize" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "HoverColor", + "!=", + "\"\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "IdleColor", + "=", + "Object.Behavior::Color()" + ] + }, + { + "type": { + "value": "TextObject::ChangeColor" + }, + "parameters": [ + "Object", + "HoverColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldEnableShadowOnHover", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TextObject::ShowShadow" + }, + "parameters": [ + "Object", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldEnableOutlineOnHover", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TextObject::Text::SetOutlineEnabled" + }, + "parameters": [ + "Object", + "yes" + ] + } + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsHovered", + "True", + "" + ] + }, + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "Value", + "False", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsHovered", + "False", + "" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HoverFontSize", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "TextObject::Text::SetFontSize" + }, + "parameters": [ + "Object", + "=", + "IdleFontSize" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "HoverColor", + "!=", + "\"\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "TextObject::ChangeColor" + }, + "parameters": [ + "Object", + "IdleColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldEnableShadowOnHover", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TextObject::ShowShadow" + }, + "parameters": [ + "Object", + "no" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldEnableOutlineOnHover", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TextObject::Text::SetOutlineEnabled" + }, + "parameters": [ + "Object", + "no" + ] + } + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "TextObject::Text", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "PanelSpriteButton::TextStyleState", + "type": "behavior" + }, + { + "defaultValue": "yes", + "description": "IsHovered", + "name": "Value", + "optional": true, + "type": "yesorno" + } + ], + "objectGroups": [] + }, + { + "description": "Return the text color", + "fullName": "Text color", + "functionType": "StringExpression", + "name": "Color", + "private": true, + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {gdjs.TextRuntimeObject} */", + "const object = eventsFunctionContext.getObjects(\"Object\")[0];", + "", + "eventsFunctionContext.returnValue = object._color.join(\";\");" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "color" + }, + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "TextObject::Text", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "PanelSpriteButton::TextStyleState", + "type": "behavior" + } + ], + "objectGroups": [] + } + ], + "propertyDescriptors": [ + { + "value": "", + "type": "Boolean", + "label": "Outline on hover", + "name": "ShouldEnableOutlineOnHover" + }, + { + "value": "", + "type": "Color", + "label": "Hover color", + "name": "HoverColor" + }, + { + "value": "", + "type": "Boolean", + "label": "Enable shadow on hover", + "name": "ShouldEnableShadowOnHover" + }, + { + "value": "0", + "type": "Number", + "unit": "Pixel", + "label": "Hover font size", + "name": "HoverFontSize" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "hidden": true, + "name": "IsHovered" + }, + { + "value": "0", + "type": "Number", + "unit": "Pixel", + "label": "Idle font size", + "hidden": true, + "name": "IdleFontSize" + }, + { + "value": "", + "type": "Color", + "label": "Idle color", + "hidden": true, + "name": "IdleColor" + } + ], + "propertiesFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "propertyName": "IsHovered" + }, + { + "propertyName": "HoverFontSize" + }, + { + "propertyName": "IdleFontSize" + }, + { + "propertyName": "HoverColor" + }, + { + "propertyName": "IdleColor" + }, + { + "propertyName": "ShouldEnableOutlineOnHover" + }, + { + "propertyName": "ShouldEnableShadowOnHover" + } + ] + } + }, + { + "description": "Change the text style when the button is hovered.", + "fullName": "Hover bitmap text style", + "name": "BitmapTextStyleState", + "objectType": "BitmapText::BitmapTextObject", + "private": true, + "eventsFunctions": [ + { + "description": "Check if isHovered.", + "fullName": "IsHovered", + "functionType": "Condition", + "name": "IsHovered", + "sentence": "_PARAM0_ isHovered", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsHovered", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "BitmapText::BitmapTextObject", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "PanelSpriteButton::BitmapTextStyleState", + "type": "behavior" + } + ], + "objectGroups": [] + }, + { + "description": "Change if isHovered.", + "fullName": "IsHovered", + "functionType": "Action", + "name": "SetIsHovered", + "sentence": "_PARAM0_ isHovered: _PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsHovered", + "False", + "" + ] + }, + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "Value", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsHovered", + "True", + "" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "HoverColor", + "!=", + "\"\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "IdleColor", + "=", + "Object.Behavior::Color()" + ] + }, + { + "type": { + "value": "BitmapText::SetTint" + }, + "parameters": [ + "Object", + "HoverColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BuiltinCommonInstructions::Or" + }, + "parameters": [], + "subInstructions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "HoverPrefix", + "!=", + "\"\"" + ] + }, + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "HoverSuffix", + "!=", + "\"\"" + ] + } + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "IdleText", + "=", + "Object.Text::Value()" + ] + }, + { + "type": { + "value": "TextContainerCapability::TextContainerBehavior::SetValue" + }, + "parameters": [ + "Object", + "Text", + "=", + "HoverPrefix + Object.Text::Value() + HoverSuffix" + ] + } + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsHovered", + "True", + "" + ] + }, + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "Value", + "False", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsHovered", + "False", + "" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "HoverColor", + "!=", + "\"\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "BitmapText::SetTint" + }, + "parameters": [ + "Object", + "IdleColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BuiltinCommonInstructions::Or" + }, + "parameters": [], + "subInstructions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "HoverPrefix", + "!=", + "\"\"" + ] + }, + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "HoverSuffix", + "!=", + "\"\"" + ] + } + ] + } + ], + "actions": [ + { + "type": { + "value": "TextContainerCapability::TextContainerBehavior::SetValue" + }, + "parameters": [ + "Object", + "Text", + "=", + "IdleText" + ] + } + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "BitmapText::BitmapTextObject", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "PanelSpriteButton::BitmapTextStyleState", + "type": "behavior" + }, + { + "defaultValue": "yes", + "description": "IsHovered", + "name": "Value", + "optional": true, + "type": "yesorno" + } + ], + "objectGroups": [] + }, + { + "description": "Return the text color", + "fullName": "Text color", + "functionType": "StringExpression", + "name": "Color", + "private": true, + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {gdjs.BitmapTextRuntimeObject} */", + "const object = eventsFunctionContext.getObjects(\"Object\")[0];", + "", + "eventsFunctionContext.returnValue = object._tint.join(\";\");" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "color" + }, + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "BitmapText::BitmapTextObject", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "PanelSpriteButton::BitmapTextStyleState", + "type": "behavior" + } + ], + "objectGroups": [] + } + ], + "propertyDescriptors": [ + { + "value": "", + "type": "Color", + "label": "Hover color", + "name": "HoverColor" + }, + { + "value": "", + "type": "String", + "label": "Hover prefix", + "name": "HoverPrefix" + }, + { + "value": "", + "type": "String", + "label": "Hover suffix", + "name": "HoverSuffix" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "hidden": true, + "name": "IsHovered" + }, + { + "value": "", + "type": "String", + "label": "Idle text", + "hidden": true, + "name": "IdleText" + }, + { + "value": "", + "type": "Color", + "label": "Idle color", + "hidden": true, + "name": "IdleColor" + } + ], + "propertiesFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "propertyName": "IsHovered" + }, + { + "propertyName": "HoverPrefix" + }, + { + "propertyName": "HoverSuffix" + }, + { + "propertyName": "IdleText" + }, + { + "propertyName": "HoverColor" + }, + { + "propertyName": "IdleColor" + } + ] + } } ], "eventsBasedObjects": [ @@ -1287,6 +2234,17 @@ "relativeToOriginalWindowSize": true, "rightEdgeAnchor": 2, "useLegacyBottomAndRightAnchors": false + }, + { + "name": "TextStyleState", + "type": "PanelSpriteButton::TextStyleState", + "ShouldEnableOutlineOnHover": false, + "HoverColor": "", + "ShouldEnableShadowOnHover": false, + "HoverFontSize": 0, + "IsHovered": false, + "IdleFontSize": 0, + "IdleColor": "" } ], "string": "Text", @@ -1434,6 +2392,16 @@ "relativeToOriginalWindowSize": true, "rightEdgeAnchor": 2, "useLegacyBottomAndRightAnchors": false + }, + { + "name": "BitmapTextStyleState", + "type": "PanelSpriteButton::BitmapTextStyleState", + "HoverColor": "", + "HoverPrefix": "", + "HoverSuffix": "", + "IsHovered": false, + "IdleText": "", + "IdleColor": "" } ], "content": { @@ -1561,7 +2529,23 @@ "initialVariables": [] } ], - "editionSettings": {}, + "editionSettings": { + "grid": false, + "gridType": "rectangular", + "gridWidth": 32, + "gridHeight": 32, + "gridDepth": 32, + "gridOffsetX": 0, + "gridOffsetY": 0, + "gridOffsetZ": 0, + "gridColor": 10401023, + "gridAlpha": 0.8, + "snap": false, + "zoomFactor": 2.734375, + "windowMask": false, + "selectedLayer": "", + "gameEditorMode": "instances-editor" + }, "eventsFunctions": [ { "fullName": "", @@ -1814,6 +2798,28 @@ } ], "actions": [ + { + "type": { + "value": "PanelSpriteButton::TextStyleState::SetIsHovered" + }, + "parameters": [ + "Label", + "TextStyleState", + "no", + "" + ] + }, + { + "type": { + "value": "PanelSpriteButton::BitmapTextStyleState::SetIsHovered" + }, + "parameters": [ + "BitmapLabel", + "BitmapTextStyleState", + "no", + "" + ] + }, { "type": { "value": "PanelSpriteButton::PanelSpriteButton::SetLabelOffset" @@ -1967,6 +2973,28 @@ } ], "actions": [ + { + "type": { + "value": "PanelSpriteButton::TextStyleState::SetIsHovered" + }, + "parameters": [ + "Label", + "TextStyleState", + "", + "" + ] + }, + { + "type": { + "value": "PanelSpriteButton::BitmapTextStyleState::SetIsHovered" + }, + "parameters": [ + "BitmapLabel", + "BitmapTextStyleState", + "yes", + "" + ] + }, { "type": { "value": "PanelSpriteButton::PanelSpriteButton::SetLabelOffset" @@ -2065,6 +3093,28 @@ } ], "actions": [ + { + "type": { + "value": "PanelSpriteButton::TextStyleState::SetIsHovered" + }, + "parameters": [ + "Label", + "TextStyleState", + "no", + "" + ] + }, + { + "type": { + "value": "PanelSpriteButton::BitmapTextStyleState::SetIsHovered" + }, + "parameters": [ + "BitmapLabel", + "BitmapTextStyleState", + "no", + "" + ] + }, { "type": { "value": "PanelSpriteButton::PanelSpriteButton::SetLabelOffset" @@ -2123,6 +3173,28 @@ } ], "actions": [ + { + "type": { + "value": "PanelSpriteButton::TextStyleState::SetIsHovered" + }, + "parameters": [ + "Label", + "TextStyleState", + "yes", + "" + ] + }, + { + "type": { + "value": "PanelSpriteButton::BitmapTextStyleState::SetIsHovered" + }, + "parameters": [ + "BitmapLabel", + "BitmapTextStyleState", + "yes", + "" + ] + }, { "type": { "value": "PanelSpriteButton::PanelSpriteButton::SetLabelOffset" diff --git a/scripts/lib/ExtensionsValidatorExceptions.js b/scripts/lib/ExtensionsValidatorExceptions.js index 07af20636..fcf93cbdb 100644 --- a/scripts/lib/ExtensionsValidatorExceptions.js +++ b/scripts/lib/ExtensionsValidatorExceptions.js @@ -392,6 +392,12 @@ const extensionsAllowedProperties = { runtimeSceneAllowedProperties: ['_objectStackExtension'], javaScriptObjectAllowedProperties: [], }, + PanelSpriteButton: { + gdjsAllowedProperties: ['TextRuntimeObject', 'BitmapTextRuntimeObject'], + gdjsEvtToolsAllowedProperties: [], + runtimeSceneAllowedProperties: [], + javaScriptObjectAllowedProperties: [], + }, ParticleEmitter3D: { gdjsAllowedProperties: [ '__particleEmmiter3DExtension',