Skip to content

Commit 5618c2b

Browse files
authored
Merge pull request #574 from nekomatata/physics-tests-pause
Support for pause in 2D/3D physics tests
2 parents ca4cde1 + 3878948 commit 5618c2b

File tree

15 files changed

+106
-23
lines changed

15 files changed

+106
-23
lines changed

2d/physics_tests/main.tscn

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
[gd_scene load_steps=10 format=2]
1+
[gd_scene load_steps=11 format=2]
22

33
[ext_resource path="res://utils/label_fps.gd" type="Script" id=1]
44
[ext_resource path="res://utils/label_version.gd" type="Script" id=2]
55
[ext_resource path="res://utils/label_engine.gd" type="Script" id=3]
66
[ext_resource path="res://tests_menu.gd" type="Script" id=4]
77
[ext_resource path="res://utils/label_test.gd" type="Script" id=5]
8+
[ext_resource path="res://utils/label_pause.gd" type="Script" id=6]
89
[ext_resource path="res://utils/container_log.gd" type="Script" id=10]
910
[ext_resource path="res://utils/scroll_log.gd" type="Script" id=11]
1011
[ext_resource path="res://tests.gd" type="Script" id=12]
@@ -22,6 +23,7 @@ __meta__ = {
2223
}
2324

2425
[node name="TestsMenu" type="MenuButton" parent="."]
26+
pause_mode = 2
2527
margin_left = 10.0
2628
margin_top = 10.0
2729
margin_right = 125.0
@@ -34,16 +36,18 @@ __meta__ = {
3436
}
3537

3638
[node name="LabelControls" type="Label" parent="."]
39+
pause_mode = 2
3740
margin_left = 157.0
3841
margin_top = 13.0
3942
margin_right = 646.0
4043
margin_bottom = 27.0
41-
text = "R - RESTART / D - TOGGLE COLLISION / F - TOGGLE FULL SCREEN / ESC - QUIT"
44+
text = "P - TOGGLE PAUSE / R - RESTART / D - TOGGLE COLLISION / F - TOGGLE FULL SCREEN / ESC - QUIT"
4245
__meta__ = {
4346
"_edit_use_anchors_": false
4447
}
4548

4649
[node name="LabelFPS" type="Label" parent="."]
50+
pause_mode = 2
4751
anchor_top = 1.0
4852
anchor_bottom = 1.0
4953
margin_left = 10.0
@@ -57,6 +61,7 @@ __meta__ = {
5761
}
5862

5963
[node name="LabelEngine" type="Label" parent="."]
64+
pause_mode = 2
6065
anchor_top = 1.0
6166
anchor_bottom = 1.0
6267
margin_left = 10.0
@@ -70,6 +75,7 @@ __meta__ = {
7075
}
7176

7277
[node name="LabelVersion" type="Label" parent="."]
78+
pause_mode = 2
7379
anchor_top = 1.0
7480
anchor_bottom = 1.0
7581
margin_left = 10.0
@@ -83,6 +89,7 @@ __meta__ = {
8389
}
8490

8591
[node name="LabelTest" type="Label" parent="."]
92+
pause_mode = 2
8693
anchor_top = 1.0
8794
anchor_bottom = 1.0
8895
margin_left = 10.0
@@ -95,7 +102,24 @@ __meta__ = {
95102
"_edit_use_anchors_": false
96103
}
97104

105+
[node name="LabelPause" type="Label" parent="."]
106+
pause_mode = 2
107+
anchor_left = 0.5
108+
anchor_top = 1.0
109+
anchor_right = 0.5
110+
anchor_bottom = 1.0
111+
margin_left = -20.0
112+
margin_top = -40.9695
113+
margin_right = 31.0
114+
margin_bottom = -26.9695
115+
text = "PAUSED"
116+
script = ExtResource( 6 )
117+
__meta__ = {
118+
"_edit_use_anchors_": false
119+
}
120+
98121
[node name="PanelLog" type="Panel" parent="."]
122+
pause_mode = 2
99123
anchor_left = 1.0
100124
anchor_top = 1.0
101125
anchor_right = 1.0

2d/physics_tests/project.godot

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ restart_test={
6767
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"unicode":0,"echo":false,"script":null)
6868
]
6969
}
70+
toggle_pause={
71+
"deadzone": 0.5,
72+
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"unicode":0,"echo":false,"script":null)
73+
]
74+
}
7075

7176
[rendering]
7277

2d/physics_tests/tests/functional/test_collision_pairs.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ modulate = Color( 1, 1, 1, 0.392157 )
8585
texture = ExtResource( 2 )
8686

8787
[node name="Controls" type="VBoxContainer" parent="."]
88+
pause_mode = 2
8889
anchor_right = 1.0
8990
anchor_bottom = 1.0
9091
margin_left = 25.3619

2d/physics_tests/tests/functional/test_one_way_collision.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ __meta__ = {
3131
[node name="Options" parent="." instance=ExtResource( 3 )]
3232

3333
[node name="Controls" type="VBoxContainer" parent="."]
34+
pause_mode = 2
3435
anchor_right = 1.0
3536
anchor_bottom = 1.0
3637
margin_left = 25.3619

2d/physics_tests/tests/functional/test_raycasting.tscn

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
[sub_resource type="RectangleShape2D" id=1]
77
extents = Vector2( 40, 60 )
88

9-
[sub_resource type="CircleShape2D" id=3]
9+
[sub_resource type="CircleShape2D" id=2]
1010
radius = 60.0
1111

12-
[sub_resource type="CapsuleShape2D" id=2]
12+
[sub_resource type="CapsuleShape2D" id=3]
1313
radius = 30.0
1414
height = 50.0
1515

@@ -37,7 +37,7 @@ position = Vector2( 314.894, 257.658 )
3737
mode = 1
3838

3939
[node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodySphere"]
40-
shape = SubResource( 3 )
40+
shape = SubResource( 2 )
4141

4242
[node name="RigidBodyCapsule" type="RigidBody2D" parent="Shapes"]
4343
position = Vector2( 465.629, 261.204 )
@@ -46,7 +46,7 @@ mode = 1
4646
[node name="CollisionShape2D" type="CollisionShape2D" parent="Shapes/RigidBodyCapsule"]
4747
rotation = -0.202458
4848
scale = Vector2( 1.2, 1.2 )
49-
shape = SubResource( 2 )
49+
shape = SubResource( 3 )
5050

5151
[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="Shapes"]
5252
position = Vector2( 613.385, 252.771 )

2d/physics_tests/tests/test_options.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[ext_resource path="res://utils/option_menu.gd" type="Script" id=1]
44

55
[node name="Options" type="MenuButton"]
6+
pause_mode = 2
67
margin_left = 10.0
78
margin_top = 106.719
89
margin_right = 125.0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
extends Label
2+
3+
4+
func _process(_delta):
5+
visible = get_tree().paused

2d/physics_tests/utils/system.gd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ var _engine = PhysicsEngine.OTHER
1010

1111

1212
func _enter_tree():
13+
pause_mode = Node.PAUSE_MODE_PROCESS
14+
1315
get_tree().debug_collisions_hint = true
1416

1517
var engine_string = ProjectSettings.get_setting("physics/2d/physics_engine")
@@ -34,6 +36,9 @@ func _process(_delta):
3436
else:
3537
Log.print_log("Debug Collision OFF")
3638

39+
if Input.is_action_just_pressed("toggle_pause"):
40+
get_tree().paused = not get_tree().paused
41+
3742
if Input.is_action_just_pressed("exit"):
3843
get_tree().quit()
3944

3d/physics_tests/main.tscn

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
[gd_scene load_steps=10 format=2]
1+
[gd_scene load_steps=11 format=2]
22

33
[ext_resource path="res://utils/label_fps.gd" type="Script" id=1]
44
[ext_resource path="res://utils/label_version.gd" type="Script" id=2]
55
[ext_resource path="res://utils/label_engine.gd" type="Script" id=3]
66
[ext_resource path="res://tests_menu.gd" type="Script" id=4]
77
[ext_resource path="res://utils/label_test.gd" type="Script" id=5]
8+
[ext_resource path="res://utils/label_pause.gd" type="Script" id=6]
89
[ext_resource path="res://utils/container_log.gd" type="Script" id=10]
910
[ext_resource path="res://utils/scroll_log.gd" type="Script" id=11]
1011
[ext_resource path="res://tests.gd" type="Script" id=12]
@@ -22,6 +23,7 @@ __meta__ = {
2223
}
2324

2425
[node name="TestsMenu" type="MenuButton" parent="."]
26+
pause_mode = 2
2527
margin_left = 10.0
2628
margin_top = 10.0
2729
margin_right = 125.0
@@ -34,6 +36,7 @@ __meta__ = {
3436
}
3537

3638
[node name="LabelControls" type="Label" parent="."]
39+
pause_mode = 2
3740
margin_left = 157.0
3841
margin_top = 13.0
3942
margin_right = 375.0
@@ -44,6 +47,7 @@ __meta__ = {
4447
}
4548

4649
[node name="LabelFPS" type="Label" parent="."]
50+
pause_mode = 2
4751
anchor_top = 1.0
4852
anchor_bottom = 1.0
4953
margin_left = 10.0
@@ -57,6 +61,7 @@ __meta__ = {
5761
}
5862

5963
[node name="LabelEngine" type="Label" parent="."]
64+
pause_mode = 2
6065
anchor_top = 1.0
6166
anchor_bottom = 1.0
6267
margin_left = 10.0
@@ -70,6 +75,7 @@ __meta__ = {
7075
}
7176

7277
[node name="LabelVersion" type="Label" parent="."]
78+
pause_mode = 2
7379
anchor_top = 1.0
7480
anchor_bottom = 1.0
7581
margin_left = 10.0
@@ -83,6 +89,7 @@ __meta__ = {
8389
}
8490

8591
[node name="LabelTest" type="Label" parent="."]
92+
pause_mode = 2
8693
anchor_top = 1.0
8794
anchor_bottom = 1.0
8895
margin_left = 10.0
@@ -95,7 +102,24 @@ __meta__ = {
95102
"_edit_use_anchors_": false
96103
}
97104

105+
[node name="LabelPause" type="Label" parent="."]
106+
pause_mode = 2
107+
anchor_left = 0.5
108+
anchor_top = 1.0
109+
anchor_right = 0.5
110+
anchor_bottom = 1.0
111+
margin_left = -25.5
112+
margin_top = -25.0
113+
margin_right = 25.5
114+
margin_bottom = -11.0
115+
text = "PAUSED"
116+
script = ExtResource( 6 )
117+
__meta__ = {
118+
"_edit_use_anchors_": false
119+
}
120+
98121
[node name="PanelLog" type="Panel" parent="."]
122+
pause_mode = 2
99123
anchor_left = 1.0
100124
anchor_top = 1.0
101125
anchor_right = 1.0

3d/physics_tests/project.godot

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ restart_test={
6767
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"unicode":0,"echo":false,"script":null)
6868
]
6969
}
70+
toggle_pause={
71+
"deadzone": 0.5,
72+
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"unicode":0,"echo":false,"script":null)
73+
]
74+
}
7075

7176
[rendering]
7277

0 commit comments

Comments
 (0)