Skip to content

Commit 0ff2b3d

Browse files
authored
[Reviewed] [Toggle switch] add a condition to check if the switch is pressed or held outside (#1860)
1 parent f842e76 commit 0ff2b3d

File tree

1 file changed

+141
-107
lines changed

1 file changed

+141
-107
lines changed

extensions/reviewed/SpriteToggleSwitch.json

Lines changed: 141 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"name": "SpriteToggleSwitch",
1010
"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",
1111
"shortDescription": "Toggle switch that users can click or touch.",
12-
"version": "2.0.1",
12+
"version": "2.0.2",
1313
"description": [
1414
"Toggle switch that users can click or touch. The switch can be customized with sprites.",
1515
"",
@@ -409,108 +409,16 @@
409409
"name": "SetChecked",
410410
"sentence": "Check _PARAM0_: _PARAM2_",
411411
"events": [
412-
{
413-
"type": "BuiltinCommonInstructions::Comment",
414-
"color": {
415-
"b": 109,
416-
"g": 230,
417-
"r": 255,
418-
"textB": 0,
419-
"textG": 0,
420-
"textR": 0
421-
},
422-
"comment": "Avoid a started touch to interfere with a state change from events."
423-
},
424-
{
425-
"type": "BuiltinCommonInstructions::Standard",
426-
"conditions": [
427-
{
428-
"type": {
429-
"value": "BuiltinCommonInstructions::Or"
430-
},
431-
"parameters": [],
432-
"subInstructions": [
433-
{
434-
"type": {
435-
"value": "BuiltinCommonInstructions::And"
436-
},
437-
"parameters": [],
438-
"subInstructions": [
439-
{
440-
"type": {
441-
"inverted": true,
442-
"value": "GetArgumentAsBoolean"
443-
},
444-
"parameters": [
445-
"\"Value\""
446-
]
447-
},
448-
{
449-
"type": {
450-
"value": "SpriteToggleSwitch::SwitchFSM::IsChecked"
451-
},
452-
"parameters": [
453-
"Object",
454-
"Behavior",
455-
""
456-
]
457-
}
458-
]
459-
},
460-
{
461-
"type": {
462-
"value": "BuiltinCommonInstructions::And"
463-
},
464-
"parameters": [],
465-
"subInstructions": [
466-
{
467-
"type": {
468-
"value": "GetArgumentAsBoolean"
469-
},
470-
"parameters": [
471-
"\"Value\""
472-
]
473-
},
474-
{
475-
"type": {
476-
"inverted": true,
477-
"value": "SpriteToggleSwitch::SwitchFSM::IsChecked"
478-
},
479-
"parameters": [
480-
"Object",
481-
"Behavior",
482-
""
483-
]
484-
}
485-
]
486-
}
487-
]
488-
}
489-
],
490-
"actions": [
491-
{
492-
"type": {
493-
"value": "SpriteToggleSwitch::ButtonFSM::ResetState"
494-
},
495-
"parameters": [
496-
"Object",
497-
"ButtonFSM",
498-
""
499-
]
500-
}
501-
]
502-
},
503412
{
504413
"type": "BuiltinCommonInstructions::Standard",
505414
"conditions": [
506415
{
507416
"type": {
508-
"inverted": true,
509417
"value": "BooleanVariable"
510418
},
511419
"parameters": [
512420
"Value",
513-
"True",
421+
"False",
514422
""
515423
]
516424
}
@@ -526,6 +434,47 @@
526434
""
527435
]
528436
}
437+
],
438+
"events": [
439+
{
440+
"type": "BuiltinCommonInstructions::Comment",
441+
"color": {
442+
"b": 109,
443+
"g": 230,
444+
"r": 255,
445+
"textB": 0,
446+
"textG": 0,
447+
"textR": 0
448+
},
449+
"comment": "Avoid a started touch to interfere with a state change from events."
450+
},
451+
{
452+
"type": "BuiltinCommonInstructions::Standard",
453+
"conditions": [
454+
{
455+
"type": {
456+
"value": "SpriteToggleSwitch::SwitchFSM::IsChecked"
457+
},
458+
"parameters": [
459+
"Object",
460+
"Behavior",
461+
""
462+
]
463+
}
464+
],
465+
"actions": [
466+
{
467+
"type": {
468+
"value": "SpriteToggleSwitch::ButtonFSM::ResetState"
469+
},
470+
"parameters": [
471+
"Object",
472+
"ButtonFSM",
473+
""
474+
]
475+
}
476+
]
477+
}
529478
]
530479
},
531480
{
@@ -553,6 +502,36 @@
553502
""
554503
]
555504
}
505+
],
506+
"events": [
507+
{
508+
"type": "BuiltinCommonInstructions::Standard",
509+
"conditions": [
510+
{
511+
"type": {
512+
"inverted": true,
513+
"value": "SpriteToggleSwitch::SwitchFSM::IsChecked"
514+
},
515+
"parameters": [
516+
"Object",
517+
"Behavior",
518+
""
519+
]
520+
}
521+
],
522+
"actions": [
523+
{
524+
"type": {
525+
"value": "SpriteToggleSwitch::ButtonFSM::ResetState"
526+
},
527+
"parameters": [
528+
"Object",
529+
"ButtonFSM",
530+
""
531+
]
532+
}
533+
]
534+
}
556535
]
557536
}
558537
],
@@ -710,6 +689,7 @@
710689
"extraInformation": [
711690
"SpriteToggleSwitch::ButtonFSM"
712691
],
692+
"choices": [],
713693
"name": "ButtonFSM"
714694
},
715695
{
@@ -1846,12 +1826,27 @@
18461826
"value": "Idle",
18471827
"type": "Choice",
18481828
"label": "State",
1849-
"extraInformation": [
1850-
"Idle",
1851-
"Hovered",
1852-
"PressedInside",
1853-
"PressedOutside",
1854-
"Validated"
1829+
"choices": [
1830+
{
1831+
"label": "Idle",
1832+
"value": "Idle"
1833+
},
1834+
{
1835+
"label": "Hovered",
1836+
"value": "Hovered"
1837+
},
1838+
{
1839+
"label": "PressedInside",
1840+
"value": "PressedInside"
1841+
},
1842+
{
1843+
"label": "PressedOutside",
1844+
"value": "PressedOutside"
1845+
},
1846+
{
1847+
"label": "Validated",
1848+
"value": "Validated"
1849+
}
18551850
],
18561851
"hidden": true,
18571852
"name": "State"
@@ -2074,12 +2069,11 @@
20742069
"conditions": [
20752070
{
20762071
"type": {
2077-
"inverted": true,
20782072
"value": "BooleanVariable"
20792073
},
20802074
"parameters": [
20812075
"IsChecked",
2082-
"True",
2076+
"False",
20832077
""
20842078
]
20852079
}
@@ -2180,12 +2174,11 @@
21802174
},
21812175
{
21822176
"type": {
2183-
"inverted": true,
21842177
"value": "BooleanVariable"
21852178
},
21862179
"parameters": [
21872180
"PreviousIsChecked",
2188-
"True",
2181+
"False",
21892182
""
21902183
]
21912184
}
@@ -2218,12 +2211,11 @@
22182211
"conditions": [
22192212
{
22202213
"type": {
2221-
"inverted": true,
22222214
"value": "BooleanVariable"
22232215
},
22242216
"parameters": [
22252217
"IsChecked",
2226-
"True",
2218+
"False",
22272219
""
22282220
]
22292221
},
@@ -2772,7 +2764,6 @@
27722764
"fullName": "Is pressed",
27732765
"functionType": "Condition",
27742766
"name": "IsPressed",
2775-
"private": true,
27762767
"sentence": "_PARAM0_ is pressed",
27772768
"events": [
27782769
{
@@ -2811,6 +2802,49 @@
28112802
],
28122803
"objectGroups": []
28132804
},
2805+
{
2806+
"description": "Check if the button is currently being pressed outside with mouse or touch.",
2807+
"fullName": "Is held outside",
2808+
"functionType": "Condition",
2809+
"name": "IsPressedOutside",
2810+
"sentence": "_PARAM0_ is held outside",
2811+
"events": [
2812+
{
2813+
"type": "BuiltinCommonInstructions::Standard",
2814+
"conditions": [
2815+
{
2816+
"type": {
2817+
"value": "SpriteToggleSwitch::ButtonFSM::IsPressedOutside"
2818+
},
2819+
"parameters": [
2820+
"State",
2821+
"ButtonFSM",
2822+
""
2823+
]
2824+
}
2825+
],
2826+
"actions": [
2827+
{
2828+
"type": {
2829+
"value": "SetReturnBoolean"
2830+
},
2831+
"parameters": [
2832+
"True"
2833+
]
2834+
}
2835+
]
2836+
}
2837+
],
2838+
"parameters": [
2839+
{
2840+
"description": "Object",
2841+
"name": "Object",
2842+
"supplementaryInformation": "SpriteToggleSwitch::SpriteToggleSwitch",
2843+
"type": "object"
2844+
}
2845+
],
2846+
"objectGroups": []
2847+
},
28142848
{
28152849
"description": "Update the state animation.",
28162850
"fullName": "Update state animation",

0 commit comments

Comments
 (0)