Skip to content

Commit 88a9e25

Browse files
committed
category_factory: Recategorize inherited blocks
Instead of categorizing inherited blocks by their class, add them to new categories describing their use. https://phabricator.endlessm.com/T35507
1 parent 859e293 commit 88a9e25

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

addons/block_code/ui/picker/categories/category_factory.gd

+27-12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ const BUILTIN_PROPS: Dictionary = {
1818
"color": Color("ffad76"),
1919
"order": 30,
2020
},
21+
"Graphics":
22+
{
23+
"color": Color("9be371"),
24+
"order": 110,
25+
},
2126
"Input":
2227
{
2328
"color": Color.SLATE_GRAY,
@@ -38,6 +43,11 @@ const BUILTIN_PROPS: Dictionary = {
3843
"color": Color("3042c5"),
3944
"order": 50,
4045
},
46+
"Movement":
47+
{
48+
"color": Color("e2e72b"),
49+
"order": 90,
50+
},
4151
"Signal":
4252
{
4353
"color": Color("f0c300"),
@@ -48,6 +58,11 @@ const BUILTIN_PROPS: Dictionary = {
4858
"color": Color("e30fc0"),
4959
"order": 80,
5060
},
61+
"Size":
62+
{
63+
"color": Color("f79511"),
64+
"order": 100,
65+
},
5166
"Test":
5267
{
5368
"color": Color("9989df"),
@@ -408,19 +423,19 @@ static func get_built_in_blocks(_class_name: String) -> Array[Block]:
408423
var b = BLOCKS["statement_block"].instantiate()
409424
b.block_format = "Set Rotation Degrees {angle: FLOAT}"
410425
b.statement = "rotation_degrees = {angle}"
411-
b.category = "Node2D"
426+
b.category = "Movement"
412427
block_list.append(b)
413428

414429
props = {
415-
"position": "Node2D",
416-
"rotation": "Node2D",
417-
"scale": "Node2D",
430+
"position": "Movement",
431+
"rotation": "Movement",
432+
"scale": "Size",
418433
}
419434

420435
"CanvasItem":
421436
props = {
422-
"modulate": "CanvasItem",
423-
"visible": "CanvasItem",
437+
"modulate": "Graphics",
438+
"visible": "Graphics",
424439
}
425440

426441
"RigidBody2D":
@@ -431,19 +446,19 @@ static func get_built_in_blocks(_class_name: String) -> Array[Block]:
431446
# convert to path
432447
b.statement = "func _on_body_%s(_body: Node):\n\tvar body: NodePath = _body.get_path()" % [verb]
433448
b.signal_name = "body_%s" % [verb]
434-
b.category = "RigidBody2D"
449+
b.category = "Signal"
435450
block_list.append(b)
436451

437452
var b = BLOCKS["statement_block"].instantiate()
438453
b.block_format = "Set Physics Position {position: VECTOR2}"
439454
b.statement = "PhysicsServer2D.body_set_state(get_rid(),PhysicsServer2D.BODY_STATE_TRANSFORM,Transform2D.IDENTITY.translated({position}))"
440-
b.category = "RigidBody2D"
455+
b.category = "Movement"
441456
block_list.append(b)
442457

443458
props = {
444-
"mass": "RigidBody2D",
445-
"linear_velocity": "RigidBody2D",
446-
"angular_velocity": "RigidBody2D",
459+
"mass": "Size",
460+
"linear_velocity": "Movement",
461+
"angular_velocity": "Movement",
447462
}
448463

449464
"Area2D":
@@ -454,7 +469,7 @@ static func get_built_in_blocks(_class_name: String) -> Array[Block]:
454469
# convert to path
455470
b.statement = "func _on_body_%s(_body: Node2D):\n\tvar body: NodePath = _body.get_path()" % [verb]
456471
b.signal_name = "body_%s" % [verb]
457-
b.category = "Area2D"
472+
b.category = "Signal"
458473
block_list.append(b)
459474

460475
var prop_list = ClassDB.class_get_property_list(_class_name, true)

tests/test_category_factory.gd

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ func test_general_category_names():
3434

3535

3636
const class_category_names = [
37-
["Node2D", ["CanvasItem", "Node2D"]],
38-
["Sprite2D", ["CanvasItem", "Node2D"]],
37+
["Node2D", ["Movement", "Size", "Graphics"]],
38+
["Sprite2D", ["Movement", "Size", "Graphics"]],
3939
["Node", []],
4040
["Object", []],
4141
]

0 commit comments

Comments
 (0)