Skip to content

Commit

Permalink
Merge pull request #337 from urbit-pilled/add_advanced
Browse files Browse the repository at this point in the history
Added advanced mode
  • Loading branch information
manuq authored Dec 17, 2024
2 parents a9c7193 + 6571f15 commit 0d0112e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions addons/block_code/code_generation/block_definition.gd
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const FORMAT_STRING_PATTERN = "\\[(?<out_parameter>[^\\]]+)\\]|\\{const (?<const
## Empty except for blocks that have a defined scope
@export var scope: String

@export var is_advanced: bool

@export var extension_script: GDScript

static var _display_template_regex := RegEx.create_from_string(FORMAT_STRING_PATTERN)
Expand All @@ -46,6 +48,7 @@ func _init(
p_signal_name: String = "",
p_scope: String = "",
p_extension_script: GDScript = null,
p_is_advanced: bool = false,
):
name = p_name
target_node_class = p_target_node_class
Expand All @@ -59,6 +62,7 @@ func _init(
signal_name = p_signal_name
scope = p_scope
extension_script = p_extension_script
is_advanced = p_is_advanced


func create_block_extension() -> BlockExtension:
Expand Down
5 changes: 5 additions & 0 deletions addons/block_code/ui/main_panel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func _on_delete_node_button_pressed():
dialog.connect("confirmed", _on_delete_dialog_confirmed.bind(_context.block_code_node))


func _on_advanced_checkbox_toggled(is_advanced: bool):
_picker.set_advanced(is_advanced)
_picker.reload_blocks()


func _on_delete_dialog_confirmed(block_code_node: BlockCode):
var parent_node = block_code_node.get_parent()

Expand Down
5 changes: 5 additions & 0 deletions addons/block_code/ui/main_panel.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3

[node name="AdvancedCheckBox" type="CheckBox" parent="MarginContainer/HBoxContainer/ScriptVBox/HBoxContainer"]
layout_mode = 2
text = "Advanced"

[node name="ShowScriptButton" type="Button" parent="MarginContainer/HBoxContainer/ScriptVBox/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 0
Expand Down Expand Up @@ -119,6 +123,7 @@ block_canvas_path = NodePath("../PickerSplit/MarginContainer/VBoxContainer/Block

[connection signal="pressed" from="MarginContainer/HBoxContainer/ScriptVBox/HBoxContainer/ShowScriptButton" to="." method="_on_show_script_button_pressed"]
[connection signal="pressed" from="MarginContainer/HBoxContainer/ScriptVBox/HBoxContainer/DeleteNodeButton" to="." method="_on_delete_node_button_pressed"]
[connection signal="toggled" from="MarginContainer/HBoxContainer/ScriptVBox/HBoxContainer/AdvancedCheckBox" to="." method="_on_advanced_checkbox_toggled"]
[connection signal="add_block_code" from="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/PickerSplit/MarginContainer/VBoxContainer/BlockCanvas" to="." method="_on_block_canvas_add_block_code"]
[connection signal="open_scene" from="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/PickerSplit/MarginContainer/VBoxContainer/BlockCanvas" to="." method="_on_block_canvas_open_scene"]
[connection signal="replace_block_code" from="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/PickerSplit/MarginContainer/VBoxContainer/BlockCanvas" to="." method="_on_block_canvas_replace_block_code"]
Expand Down
10 changes: 10 additions & 0 deletions addons/block_code/ui/picker/picker.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var scroll_tween: Tween

var _category_buttons: Dictionary # String, BlockCategoryButton
var _category_displays: Dictionary # String, BlockCategoryDisplay
var _advanced_mode: bool = false


func _ready() -> void:
Expand Down Expand Up @@ -74,6 +75,10 @@ func _update_block_components():

for category in block_categories:
var block_definitions := _context.block_script.get_blocks_in_category(category)

if not _advanced_mode:
block_definitions = block_definitions.filter(func(definition): return not definition.is_advanced)

var order_override = CATEGORY_ORDER_OVERRIDE.get(category.name)
if order_override:
block_definitions.sort_custom(_sort_blocks_by_list_order.bind(order_override))
Expand Down Expand Up @@ -136,3 +141,8 @@ func _category_selected(category_name: String):

func set_collapsed(collapsed: bool):
_widget_container.visible = not collapsed


func set_advanced(advanced: bool):
_advanced_mode = advanced
reload_blocks()

0 comments on commit 0d0112e

Please sign in to comment.