diff --git a/addons/pronto/behaviors/MoveBehavior.gd b/addons/pronto/behaviors/MoveBehavior.gd index 7e7ff5b6..7e06a47a 100644 --- a/addons/pronto/behaviors/MoveBehavior.gd +++ b/addons/pronto/behaviors/MoveBehavior.gd @@ -29,9 +29,9 @@ signal touched_floor(velocity: float) @export_category("Rotation") ## Whether the velocity is applied according to the parent's local rotation or in global coordinates. -@export var rotated = false +@export var rotated = true ## Speed at which the parent rotates when asked to. -@export var rotation_speed = 0.0 +@export var rotation_speed = 300.0 ## Whether to also rotate the velocity vector when the character is rotated. Feels like the parent can drift when disabled. @export var rotate_velocity = true diff --git a/addons/pronto/behaviors/PrototypingUIBehavior.gd b/addons/pronto/behaviors/PrototypingUIBehavior.gd index 661dd1b2..ca87783e 100644 --- a/addons/pronto/behaviors/PrototypingUIBehavior.gd +++ b/addons/pronto/behaviors/PrototypingUIBehavior.gd @@ -30,10 +30,7 @@ func _ready(): vbox.size_flags_vertical = Control.SIZE_EXPAND_FILL for childNode in self.get_children(): - if is_instance_of(childNode, CodeBehavior): - vbox.add_child(create_ui_for_code(childNode)) - elif is_instance_of(childNode, ValueBehavior): - vbox.add_child(create_ui_for_value(childNode)) + maybe_add_config(childNode) scrollContainer.add_child(vbox) scrollContainer.size_flags_vertical = Control.SIZE_EXPAND_FILL @@ -52,7 +49,15 @@ func _ready(): panel.add_child.call_deferred(outerVbox) # print("Prototype UI generated successfully") - +func maybe_add_config(node: Node): + if is_instance_of(node, CodeBehavior): + vbox.add_child(create_ui_for_code(node)) + return true + elif is_instance_of(node, ValueBehavior): + vbox.add_child(create_ui_for_value(node)) + return true + return false + func create_ui_for_value(value: ValueBehavior): if not value.visible: return # Hide values that are hidden in the Editor if value.selectType == "Float": diff --git a/addons/pronto/helpers/G.gd b/addons/pronto/helpers/G.gd index b10be853..713ec9ca 100644 --- a/addons/pronto/helpers/G.gd +++ b/addons/pronto/helpers/G.gd @@ -41,3 +41,24 @@ func _put(name: String, value: Variant): func _register_store(store: StoreBehavior, prop: String): assert(not prop in _store_update, "Property {0} has already been registered by a store node. Are you spawning the same Store mutliple times?".format([prop])) _store_update[prop] = store + +func _ready(): + if not Engine.is_editor_hint(): + maybe_add_value_user_interface() + +func maybe_add_value_user_interface(): + if not Utils.all_nodes_that(get_tree().root, func (node): return node is PrototypingUIBehavior).is_empty(): + return + + var panel = PanelContainer.new() + panel.size = Vector2(200, 200) + var ui = PrototypingUIBehavior.new() + ui.name = 'Config' + panel.add_child(ui) + + var added_any = [false] + Utils.all_nodes_do(get_tree().root, func (node): + if ui.maybe_add_config(node): + added_any[0] = true) + if added_any[0]: + add_child(panel) diff --git a/examples/game_car.tscn b/examples/game_car.tscn index bca6eb3b..76888754 100644 --- a/examples/game_car.tscn +++ b/examples/game_car.tscn @@ -312,8 +312,6 @@ sprite_texture = ExtResource("2_fjkj2") position = Vector2(61, 47) script = ExtResource("3_e4ih0") friction = 2.0 -rotated = true -rotation_speed = 300.0 [node name="ControlsBehavior" type="Node2D" parent="car"] position = Vector2(143, 10)