From 4d3d3ce4a2e02d7008d32ee92080c4cf3ed03c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= Date: Mon, 23 Jun 2025 13:57:44 -0300 Subject: [PATCH 1/6] Block: Translate property only if possible The TranslationServer.get_or_add_domain() method was added in Godot 4.4, but the addon may still work in Godot 4.3 if we disable property translations when the method isn't present. https://github.com/endlessm/godot-block-coding/discussions/397 --- addons/block_code/ui/blocks/block/block.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/block_code/ui/blocks/block/block.gd b/addons/block_code/ui/blocks/block/block.gd index 9972cdfb..6a006174 100644 --- a/addons/block_code/ui/blocks/block/block.gd +++ b/addons/block_code/ui/blocks/block/block.gd @@ -129,7 +129,7 @@ func _get_format_string() -> String: if not definition: return "" - if definition.property_name: + if definition.property_name and TranslationServer.has_method(&"get_or_add_domain"): var domain: TranslationDomain = TranslationServer.get_or_add_domain("godot.properties") var translated_property: String = domain.translate(definition.property_name.capitalize()) # TODO: Ideally we should be also passing the context. See: From 623ec3a2608d0b23e34c74e217148c7c39b2a605 Mon Sep 17 00:00:00 2001 From: Daze <183644421+DoomTas3r@users.noreply.github.com> Date: Tue, 5 Aug 2025 20:10:05 -0400 Subject: [PATCH 2/6] Repopulate variable code template Fixes regression from 947bd28 --- addons/block_code/code_generation/block_definition.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/block_code/code_generation/block_definition.gd b/addons/block_code/code_generation/block_definition.gd index 6ee55468..75273a73 100644 --- a/addons/block_code/code_generation/block_definition.gd +++ b/addons/block_code/code_generation/block_definition.gd @@ -289,6 +289,6 @@ static func new_variable_getter(variable: VariableDefinition) -> Resource: Types.BlockType.VALUE, variable.var_type, "%s" % variable.var_name, - "%s", + "%s" % variable.var_name, ) return block_definition From 5f5cbc9d9f8c9ea693a580c0ec154337d0fd9393 Mon Sep 17 00:00:00 2001 From: Daze <183644421+DoomTas3r@users.noreply.github.com> Date: Thu, 7 Aug 2025 14:26:51 -0400 Subject: [PATCH 3/6] Adds delete variable button and dialogue Fix for #360 Adds the delete variable button with a dialogue box and check boxes to select variable names and delete them if they exist. The delete variable functionality resembles the create variable functionality, including the ability to undo. Functionality missing from this commit might include hiding the delete variables button when there are no variables, and disabling the delete button if no check boxes are checked. --- addons/block_code/ui/main_panel.gd | 23 +++++++++++ .../delete_variables_button.gd | 20 ++++++++++ .../delete_variables_button.gd.uid | 1 + .../delete_variables_button.tscn | 37 ++++++++++++++++++ .../delete_variables_dialog.gd | 38 +++++++++++++++++++ .../delete_variables_dialog.gd.uid | 1 + .../delete_variables_dialog.tscn | 22 +++++++++++ .../variable_category_display.gd | 5 +++ .../variable_category_display.tscn | 9 ++++- addons/block_code/ui/picker/picker.gd | 2 + 10 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 addons/block_code/ui/picker/categories/variable_category/delete_variables_button.gd create mode 100644 addons/block_code/ui/picker/categories/variable_category/delete_variables_button.gd.uid create mode 100644 addons/block_code/ui/picker/categories/variable_category/delete_variables_button.tscn create mode 100644 addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.gd create mode 100644 addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.gd.uid create mode 100644 addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.tscn diff --git a/addons/block_code/ui/main_panel.gd b/addons/block_code/ui/main_panel.gd index cdc8e8f7..83d47618 100644 --- a/addons/block_code/ui/main_panel.gd +++ b/addons/block_code/ui/main_panel.gd @@ -50,6 +50,7 @@ func _ready(): _picker.block_picked.connect(_drag_manager.copy_picked_block_and_drag) _picker.variable_created.connect(_create_variable) + _picker.variables_deleted.connect(_delete_variables) _block_canvas.reconnect_block.connect(_drag_manager.connect_block_canvas_signals) _drag_manager.block_dropped.connect(save_script) _drag_manager.block_modified.connect(save_script) @@ -284,3 +285,25 @@ func _create_variable(variable: VariableDefinition): undo_redo.commit_action() _picker.reload_blocks() + + +func _delete_variables(variables_to_delete: Array): + if _context.block_code_node == null: + print("No script loaded to delete variables from.") + return + + var block_script: BlockScriptSerialization = _context.block_script + + undo_redo.create_action("Delete variables %s in %s's block code script" % [variables_to_delete, _context.parent_node.name]) + undo_redo.add_undo_property(_context.block_script, "variables", _context.block_script.variables) + + var new_variables = block_script.variables.duplicate() + for index in range(new_variables.size() - 1, -1, -1): + var variable = new_variables[index] + if variable.var_name in variables_to_delete: + new_variables.erase(variable) + + undo_redo.add_do_property(_context.block_script, "variables", new_variables) + undo_redo.commit_action() + + _picker.reload_blocks() diff --git a/addons/block_code/ui/picker/categories/variable_category/delete_variables_button.gd b/addons/block_code/ui/picker/categories/variable_category/delete_variables_button.gd new file mode 100644 index 00000000..1306b932 --- /dev/null +++ b/addons/block_code/ui/picker/categories/variable_category/delete_variables_button.gd @@ -0,0 +1,20 @@ +@tool +extends MarginContainer + +signal delete_variables(variables: Array[String]) + +@onready var _delete_variables_dialog := %DeleteVariablesDialog +@onready var _delete_button := %DeleteButton +@onready var _delete_variables_icon = _delete_button.get_theme_icon("Remove", "EditorIcons") + + +func _ready() -> void: + _delete_button.icon = _delete_variables_icon + + +func _on_delete_button_pressed(): + _delete_variables_dialog.popup() + + +func _on_delete_variables_dialog_delete_variables(variables): + delete_variables.emit(variables) diff --git a/addons/block_code/ui/picker/categories/variable_category/delete_variables_button.gd.uid b/addons/block_code/ui/picker/categories/variable_category/delete_variables_button.gd.uid new file mode 100644 index 00000000..105c60b0 --- /dev/null +++ b/addons/block_code/ui/picker/categories/variable_category/delete_variables_button.gd.uid @@ -0,0 +1 @@ +uid://8b8f5cd61gic diff --git a/addons/block_code/ui/picker/categories/variable_category/delete_variables_button.tscn b/addons/block_code/ui/picker/categories/variable_category/delete_variables_button.tscn new file mode 100644 index 00000000..7f360703 --- /dev/null +++ b/addons/block_code/ui/picker/categories/variable_category/delete_variables_button.tscn @@ -0,0 +1,37 @@ +[gd_scene load_steps=5 format=3 uid="uid://ba2ckluuotftw"] + +[ext_resource type="PackedScene" uid="uid://bxkdgyj0kpexu" path="res://addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.tscn" id="1_5id0e"] +[ext_resource type="Script" uid="uid://8b8f5cd61gic" path="res://addons/block_code/ui/picker/categories/variable_category/delete_variables_button.gd" id="1_fr423"] + +[sub_resource type="Image" id="Image_fr423"] +data = { +"data": PackedByteArray(255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 42, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 93, 93, 41, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 92, 92, 0, 255, 92, 92, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 93, 93, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0), +"format": "RGBA8", +"height": 16, +"mipmaps": false, +"width": 16 +} + +[sub_resource type="ImageTexture" id="ImageTexture_sdiwn"] +image = SubResource("Image_fr423") + +[node name="DeleteVariablesButton" type="MarginContainer"] +offset_right = 186.0 +offset_bottom = 43.0 +size_flags_horizontal = 0 +theme_override_constants/margin_bottom = 12 +script = ExtResource("1_fr423") + +[node name="DeleteButton" type="Button" parent="."] +unique_name_in_owner = true +layout_mode = 2 +theme_type_variation = &"InspectorActionButton" +text = "Delete Variables" +icon = SubResource("ImageTexture_sdiwn") + +[node name="DeleteVariablesDialog" parent="." instance=ExtResource("1_5id0e")] +unique_name_in_owner = true +visible = false + +[connection signal="pressed" from="DeleteButton" to="." method="_on_delete_button_pressed"] +[connection signal="delete_variables" from="DeleteVariablesDialog" to="." method="_on_delete_variables_dialog_delete_variables"] diff --git a/addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.gd b/addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.gd new file mode 100644 index 00000000..47644204 --- /dev/null +++ b/addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.gd @@ -0,0 +1,38 @@ +@tool +extends ConfirmationDialog + +const BlockCategoryDisplay = preload("res://addons/block_code/ui/picker/categories/block_category_display.gd") + +signal delete_variables(variables: Array[String]) + +@onready var _variables_container := %VariablesContainer +var _checkbox_template := CheckBox.new() +var _main_panel: Node + + +func _ready(): + _main_panel = get_parent() + + +func _on_confirmed(): + var variables := [] + for checkbox in _variables_container.get_children(): + if checkbox.button_pressed: + variables.append(checkbox.text) + + delete_variables.emit(variables) + + hide() + + +func _on_about_to_popup() -> void: + for checkbox in _variables_container.get_children(): + _variables_container.remove_child(checkbox) + checkbox.queue_free() + + while _main_panel.name != "MainPanel": + _main_panel = _main_panel.get_parent() + + for variable in _main_panel._context.block_script.variables: + _checkbox_template.text = variable.var_name + _variables_container.add_child(_checkbox_template.duplicate()) diff --git a/addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.gd.uid b/addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.gd.uid new file mode 100644 index 00000000..3fb38ae6 --- /dev/null +++ b/addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.gd.uid @@ -0,0 +1 @@ +uid://duu6fvcrvhxrh diff --git a/addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.tscn b/addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.tscn new file mode 100644 index 00000000..8fa29e15 --- /dev/null +++ b/addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=2 format=3 uid="uid://bxkdgyj0kpexu"] + +[ext_resource type="Script" uid="uid://duu6fvcrvhxrh" path="res://addons/block_code/ui/picker/categories/variable_category/delete_variables_dialog.gd" id="1_l45s3"] + +[node name="DeleteVariablesDialog" type="ConfirmationDialog"] +title = "Delete Variables" +initial_position = 1 +size = Vector2i(300, 183) +visible = true +ok_button_text = "Delete" +dialog_hide_on_ok = false +script = ExtResource("1_l45s3") + +[node name="VariablesContainer" type="VBoxContainer" parent="."] +unique_name_in_owner = true +offset_left = 8.0 +offset_top = 8.0 +offset_right = 292.0 +offset_bottom = 134.0 + +[connection signal="about_to_popup" from="." to="." method="_on_about_to_popup"] +[connection signal="confirmed" from="." to="." method="_on_confirmed"] diff --git a/addons/block_code/ui/picker/categories/variable_category/variable_category_display.gd b/addons/block_code/ui/picker/categories/variable_category/variable_category_display.gd index 23a0bd51..f497cea1 100644 --- a/addons/block_code/ui/picker/categories/variable_category/variable_category_display.gd +++ b/addons/block_code/ui/picker/categories/variable_category/variable_category_display.gd @@ -7,6 +7,7 @@ const VariableDefinition = preload("res://addons/block_code/code_generation/vari @onready var h_separator := %HSeparator signal variable_created(variable: VariableDefinition) +signal variables_deleted(variables: Array[String]) func _ready(): @@ -22,3 +23,7 @@ func _update_blocks(): func _on_create_variable(var_name, var_type): variable_created.emit(VariableDefinition.new(var_name, Types.STRING_TO_VARIANT_TYPE[var_type])) + + +func _on_delete_variables(variables): + variables_deleted.emit(variables) diff --git a/addons/block_code/ui/picker/categories/variable_category/variable_category_display.tscn b/addons/block_code/ui/picker/categories/variable_category/variable_category_display.tscn index 955747b4..92d687df 100644 --- a/addons/block_code/ui/picker/categories/variable_category/variable_category_display.tscn +++ b/addons/block_code/ui/picker/categories/variable_category/variable_category_display.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=5 format=3 uid="uid://byne4g2yvdf3"] +[gd_scene load_steps=6 format=3 uid="uid://byne4g2yvdf3"] [ext_resource type="PackedScene" uid="uid://duhpwtfo3k0sk" path="res://addons/block_code/ui/picker/categories/block_category_display.tscn" id="1_vermd"] -[ext_resource type="Script" path="res://addons/block_code/ui/picker/categories/variable_category/variable_category_display.gd" id="2_ggvi7"] +[ext_resource type="Script" uid="uid://d1owr45rep8tx" path="res://addons/block_code/ui/picker/categories/variable_category/variable_category_display.gd" id="2_ggvi7"] [ext_resource type="PackedScene" uid="uid://t0eoc4ekvjr1" path="res://addons/block_code/ui/picker/categories/variable_category/create_variable_button.tscn" id="3_gjvnq"] +[ext_resource type="PackedScene" uid="uid://ba2ckluuotftw" path="res://addons/block_code/ui/picker/categories/variable_category/delete_variables_button.tscn" id="4_ppkk1"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_0m6vh"] @@ -22,4 +23,8 @@ theme_override_styles/separator = SubResource("StyleBoxEmpty_0m6vh") [node name="CreateVariableButton" parent="VBoxContainer" index="3" instance=ExtResource("3_gjvnq")] layout_mode = 2 +[node name="DeleteVariablesButton" parent="VBoxContainer" index="4" instance=ExtResource("4_ppkk1")] +layout_mode = 2 + [connection signal="create_variable" from="VBoxContainer/CreateVariableButton" to="." method="_on_create_variable"] +[connection signal="delete_variables" from="VBoxContainer/DeleteVariablesButton" to="." method="_on_delete_variables"] diff --git a/addons/block_code/ui/picker/picker.gd b/addons/block_code/ui/picker/picker.gd index 92ffafdf..b09a4b56 100644 --- a/addons/block_code/ui/picker/picker.gd +++ b/addons/block_code/ui/picker/picker.gd @@ -26,6 +26,7 @@ const CATEGORY_ORDER_OVERRIDE = { signal block_picked(block: Block, offset: Vector2) signal variable_created(variable: VariableDefinition) +signal variables_deleted(variables: Array[String]) @onready var _context := BlockEditorContext.get_default() @@ -120,6 +121,7 @@ func _get_or_create_block_category_display(category: BlockCategory) -> BlockCate else: block_category_display = VariableCategoryDisplayScene.instantiate() block_category_display.variable_created.connect(func(variable): variable_created.emit(variable)) + block_category_display.variables_deleted.connect(func(variables): variables_deleted.emit(variables)) block_category_display.title = category.name if category else "" block_category_display.block_picked.connect(func(block: Block, offset: Vector2): block_picked.emit(block, offset)) From dac4d63532d3aee1630260f2c4b57eded9f2a280 Mon Sep 17 00:00:00 2001 From: Daze <183644421+DoomTas3r@users.noreply.github.com> Date: Fri, 8 Aug 2025 14:10:22 -0400 Subject: [PATCH 4/6] Adds to_string block with optional types The to_string block converts a parameter to a string. It includes an option input with an integer, a boolean, a vector2, a vector3, a color, and an object. The type of the selected input gets detected and displays as a normal parameter input with the detected type and snapping --- addons/block_code/blocks/log/to_string.tres | 25 +++++++++++++++++++ .../parameter_input/parameter_input.gd | 20 +++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 addons/block_code/blocks/log/to_string.tres diff --git a/addons/block_code/blocks/log/to_string.tres b/addons/block_code/blocks/log/to_string.tres new file mode 100644 index 00000000..73931305 --- /dev/null +++ b/addons/block_code/blocks/log/to_string.tres @@ -0,0 +1,25 @@ +[gd_resource type="Resource" load_steps=4 format=3 uid="uid://bfugvntm6mdjm"] + +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_i1nej"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="2_xs7a8"] + +[sub_resource type="Resource" id="Resource_ie4sg"] +script = ExtResource("1_i1nej") +selected = 0 +items = ["0", "true", "Vector2(0, 0)", "Vector3(0, 0, 0)", "Color(0, 0, 0, 1)", "Object(Object, \"script\": null)"] + +[resource] +script = ExtResource("2_xs7a8") +name = &"to_string" +target_node_class = "" +description = "Converts [i]parameter[/i] to a [b]String[/b]" +category = "Log" +type = 3 +variant_type = 4 +display_template = "{parameter: NIL} to string" +code_template = "str({{parameter}})" +defaults = { +"parameter": SubResource("Resource_ie4sg") +} +signal_name = "" +is_advanced = true diff --git a/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd b/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd index c9551bdf..6e03f275 100644 --- a/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd +++ b/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd @@ -6,6 +6,7 @@ signal drag_started(offset: Vector2) const Constants = preload("res://addons/block_code/ui/constants.gd") const OptionData = preload("res://addons/block_code/code_generation/option_data.gd") const Types = preload("res://addons/block_code/types/types.gd") +const Option_Theme = preload("res://addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.tscn::StyleBoxFlat_7m75r") signal modified @@ -286,6 +287,24 @@ func _switch_input(node: Node): c.visible = c == node _background.visible = node not in [_option_input, null] _background.is_pointy_value = node == _bool_input + if option_data: + _option_input.add_theme_stylebox_override("focus", Option_Theme) + _option_input.add_theme_stylebox_override("hover", Option_Theme) + _option_input.add_theme_stylebox_override("pressed", Option_Theme) + _option_input.add_theme_stylebox_override("normal", Option_Theme) + var raw_input = get_raw_input() + var data = str_to_var("" if raw_input == null or raw_input is Block else raw_input) + if typeof(data): + var empty_theme = StyleBoxEmpty.new() + _option_input.add_theme_stylebox_override("focus", empty_theme) + _option_input.add_theme_stylebox_override("hover", empty_theme) + _option_input.add_theme_stylebox_override("pressed", empty_theme) + _option_input.add_theme_stylebox_override("normal", empty_theme) + variant_type = typeof(data) + _background.visible = true + _background.is_pointy_value = variant_type == TYPE_BOOL + snap_point.visible = true + snap_point.variant_type = variant_type func _update_option_input(current_value: Variant = null): @@ -350,6 +369,7 @@ func _update_background_color(new_color): func _on_option_input_item_selected(index): if not editable: return + _update_visible_input() modified.emit() From c4476b5f92eb864af4cbfb279dd0f297c6baceba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Aug 2025 03:26:22 +0000 Subject: [PATCH 5/6] Bump actions/checkout from 4 to 5 Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/checks.yaml | 4 ++-- .github/workflows/godot-asset-library.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 179f780a..b4f9ddcf 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -16,7 +16,7 @@ jobs: name: Linting and Formatting runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: actions/setup-python@v5 with: python-version: '3.11' @@ -38,7 +38,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Godot uses: chickensoft-games/setup-godot@v2.2.0 with: diff --git a/.github/workflows/godot-asset-library.yaml b/.github/workflows/godot-asset-library.yaml index e57363a1..e5941831 100644 --- a/.github/workflows/godot-asset-library.yaml +++ b/.github/workflows/godot-asset-library.yaml @@ -11,7 +11,7 @@ jobs: name: Push new release steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Push to Godot Asset Library uses: deep-entertainment/godot-asset-lib-action@v0.6.0 with: From 097433786e2f49698303c70708722b80637b3679 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Aug 2025 12:16:06 +0000 Subject: [PATCH 6/6] Bump chickensoft-games/setup-godot from 2.2.0 to 2.3.0 Bumps [chickensoft-games/setup-godot](https://github.com/chickensoft-games/setup-godot) from 2.2.0 to 2.3.0. - [Release notes](https://github.com/chickensoft-games/setup-godot/releases) - [Commits](https://github.com/chickensoft-games/setup-godot/compare/v2.2.0...v2.3.0) --- updated-dependencies: - dependency-name: chickensoft-games/setup-godot dependency-version: 2.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index b4f9ddcf..1ca97690 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -40,7 +40,7 @@ jobs: - name: Checkout uses: actions/checkout@v5 - name: Setup Godot - uses: chickensoft-games/setup-godot@v2.2.0 + uses: chickensoft-games/setup-godot@v2.3.0 with: version: ${{ matrix.godot-version }} use-dotnet: false