diff --git a/addons/block_code/block_code_plugin.gd b/addons/block_code/block_code_plugin.gd index ff960f1c..ec287e90 100644 --- a/addons/block_code/block_code_plugin.gd +++ b/addons/block_code/block_code_plugin.gd @@ -5,7 +5,6 @@ const MainPanelScene := preload("res://addons/block_code/ui/main_panel.tscn") const MainPanel = preload("res://addons/block_code/ui/main_panel.gd") const Types = preload("res://addons/block_code/types/types.gd") const TxUtils := preload("res://addons/block_code/translation/utils.gd") -const ScriptWindow := preload("res://addons/block_code/ui/script_window/script_window.tscn") static var main_panel: MainPanel static var block_code_button: Button @@ -44,7 +43,6 @@ func _enter_tree(): editor_inspector = EditorInterface.get_inspector() main_panel = MainPanelScene.instantiate() - main_panel.script_window_requested.connect(script_window_requested) main_panel.undo_redo = get_undo_redo() block_code_button = add_control_to_bottom_panel(main_panel, _get_plugin_name()) block_inspector_plugin = BlockInspectorPlugin.new() @@ -75,16 +73,6 @@ func _enter_tree(): EditorInterface.set_current_feature_profile("block_code") -func script_window_requested(script: String): - var script_window = ScriptWindow.instantiate() - script_window.script_content = script - EditorInterface.popup_dialog(script_window) - await script_window.close_requested - - script_window.queue_free() - script_window = null - - func _exit_tree(): remove_translation_parser_plugin(_tx_parser_plugin) remove_inspector_plugin(block_inspector_plugin) diff --git a/addons/block_code/blocks/communication/add_node_to_group.tres b/addons/block_code/blocks/communication/add_node_to_group.tres index 0531ce2f..9562cc93 100644 --- a/addons/block_code/blocks/communication/add_node_to_group.tres +++ b/addons/block_code/blocks/communication/add_node_to_group.tres @@ -23,6 +23,5 @@ defaults = { "group": SubResource("Resource_sus0f") } signal_name = "" -scope = "" is_advanced = false extension_script = ExtResource("1_p83c7") diff --git a/addons/block_code/blocks/communication/add_to_group.tres b/addons/block_code/blocks/communication/add_to_group.tres index 1d00f270..ae9b9c5d 100644 --- a/addons/block_code/blocks/communication/add_to_group.tres +++ b/addons/block_code/blocks/communication/add_to_group.tres @@ -23,6 +23,5 @@ defaults = { "group": SubResource("Resource_fk0wa") } signal_name = "" -scope = "" is_advanced = false extension_script = ExtResource("2_42ixf") diff --git a/addons/block_code/blocks/communication/call_method_group.tres b/addons/block_code/blocks/communication/call_method_group.tres index b7e38026..691acea0 100644 --- a/addons/block_code/blocks/communication/call_method_group.tres +++ b/addons/block_code/blocks/communication/call_method_group.tres @@ -23,6 +23,5 @@ defaults = { "group": SubResource("Resource_f4ctg") } signal_name = "" -scope = "" is_advanced = false extension_script = ExtResource("1_of577") diff --git a/addons/block_code/blocks/communication/get_node.tres b/addons/block_code/blocks/communication/get_node.tres index 79788891..cc01c441 100644 --- a/addons/block_code/blocks/communication/get_node.tres +++ b/addons/block_code/blocks/communication/get_node.tres @@ -23,6 +23,5 @@ defaults = { "path": SubResource("Resource_esr4a") } signal_name = "" -scope = "" is_advanced = false extension_script = ExtResource("1_we5wl") diff --git a/addons/block_code/blocks/communication/is_in_group.tres b/addons/block_code/blocks/communication/is_in_group.tres index 23fa4191..685f1c8d 100644 --- a/addons/block_code/blocks/communication/is_in_group.tres +++ b/addons/block_code/blocks/communication/is_in_group.tres @@ -23,6 +23,5 @@ defaults = { "group": SubResource("Resource_d0v0d") } signal_name = "" -scope = "" is_advanced = false extension_script = ExtResource("2_o165d") diff --git a/addons/block_code/blocks/communication/is_node_in_group.tres b/addons/block_code/blocks/communication/is_node_in_group.tres index 83b5611b..17612910 100644 --- a/addons/block_code/blocks/communication/is_node_in_group.tres +++ b/addons/block_code/blocks/communication/is_node_in_group.tres @@ -23,6 +23,5 @@ defaults = { "group": SubResource("Resource_o38ym") } signal_name = "" -scope = "" is_advanced = false extension_script = ExtResource("1_r4prw") diff --git a/addons/block_code/blocks/communication/remove_from_group.tres b/addons/block_code/blocks/communication/remove_from_group.tres index f33b5acb..54af6ee6 100644 --- a/addons/block_code/blocks/communication/remove_from_group.tres +++ b/addons/block_code/blocks/communication/remove_from_group.tres @@ -23,6 +23,5 @@ defaults = { "group": SubResource("Resource_45b71") } signal_name = "" -scope = "" is_advanced = false extension_script = ExtResource("1_i50fw") diff --git a/addons/block_code/blocks/communication/remove_node_from_group.tres b/addons/block_code/blocks/communication/remove_node_from_group.tres index 50f5195b..7dcc979d 100644 --- a/addons/block_code/blocks/communication/remove_node_from_group.tres +++ b/addons/block_code/blocks/communication/remove_node_from_group.tres @@ -23,6 +23,5 @@ defaults = { "group": SubResource("Resource_03rge") } signal_name = "" -scope = "" is_advanced = false extension_script = ExtResource("1_h3lhb") diff --git a/addons/block_code/blocks/graphics/animationplayer_play.tres b/addons/block_code/blocks/graphics/animationplayer_play.tres index c7d77924..0a86e5ff 100644 --- a/addons/block_code/blocks/graphics/animationplayer_play.tres +++ b/addons/block_code/blocks/graphics/animationplayer_play.tres @@ -41,6 +41,5 @@ defaults = { "wait_mode": SubResource("Resource_17pec") } signal_name = "" -scope = "" is_advanced = false extension_script = ExtResource("2_7ymgi") diff --git a/addons/block_code/blocks/input/is_input_actioned.tres b/addons/block_code/blocks/input/is_input_actioned.tres index a8412821..11733b1f 100644 --- a/addons/block_code/blocks/input/is_input_actioned.tres +++ b/addons/block_code/blocks/input/is_input_actioned.tres @@ -23,6 +23,5 @@ defaults = { "action": SubResource("Resource_ai5in") } signal_name = "" -scope = "" is_advanced = false extension_script = ExtResource("2_h11b7") diff --git a/addons/block_code/blocks/logic/compare.tres b/addons/block_code/blocks/logic/compare.tres index dca45e8d..b459fb9f 100644 --- a/addons/block_code/blocks/logic/compare.tres +++ b/addons/block_code/blocks/logic/compare.tres @@ -24,5 +24,4 @@ defaults = { "op": SubResource("Resource_ie4sg") } signal_name = "" -scope = "" is_advanced = false diff --git a/addons/block_code/blocks/math/vector2_xy.tres b/addons/block_code/blocks/math/vector2_xy.tres index 47fa7358..e30c260f 100644 --- a/addons/block_code/blocks/math/vector2_xy.tres +++ b/addons/block_code/blocks/math/vector2_xy.tres @@ -22,5 +22,4 @@ defaults = { "xy": SubResource("Resource_ie4sg") } signal_name = "" -scope = "" is_advanced = false diff --git a/addons/block_code/blocks/math/vector3_xyz.tres b/addons/block_code/blocks/math/vector3_xyz.tres index a49c3a41..7d4047de 100644 --- a/addons/block_code/blocks/math/vector3_xyz.tres +++ b/addons/block_code/blocks/math/vector3_xyz.tres @@ -22,5 +22,4 @@ defaults = { "xyz": SubResource("Resource_ie4sg") } signal_name = "" -scope = "" is_advanced = false diff --git a/addons/block_code/blocks/sounds/pause_continue_sound.tres b/addons/block_code/blocks/sounds/pause_continue_sound.tres index e66333f2..75f65b5f 100644 --- a/addons/block_code/blocks/sounds/pause_continue_sound.tres +++ b/addons/block_code/blocks/sounds/pause_continue_sound.tres @@ -27,5 +27,4 @@ defaults = { "pause": SubResource("Resource_lalgp") } signal_name = "" -scope = "" is_advanced = false diff --git a/addons/block_code/ui/main_panel.gd b/addons/block_code/ui/main_panel.gd index cdc8e8f7..e749df83 100644 --- a/addons/block_code/ui/main_panel.gd +++ b/addons/block_code/ui/main_panel.gd @@ -1,8 +1,6 @@ @tool extends Control -signal script_window_requested(script: String) - const BlockCanvas = preload("res://addons/block_code/ui/block_canvas/block_canvas.gd") const BlockCodePlugin = preload("res://addons/block_code/block_code_plugin.gd") const BlocksCatalog = preload("res://addons/block_code/code_generation/blocks_catalog.gd") @@ -11,6 +9,7 @@ const Picker = preload("res://addons/block_code/ui/picker/picker.gd") const TitleBar = preload("res://addons/block_code/ui/title_bar/title_bar.gd") const TxUtils := preload("res://addons/block_code/translation/utils.gd") const VariableDefinition = preload("res://addons/block_code/code_generation/variable_definition.gd") +const ScriptWindow := preload("res://addons/block_code/ui/script_window/script_window.tscn") @onready var _context := BlockEditorContext.get_default() @@ -23,6 +22,10 @@ const VariableDefinition = preload("res://addons/block_code/code_generation/vari @onready var _picker_split: HSplitContainer = %PickerSplit @onready var _collapse_button: Button = %CollapseButton +@onready var _show_script_button: Button = %ShowScriptButton +@onready var _split_script_container: MarginContainer = %SplitScriptContainer +@onready var _split_script_window := %SplitScriptWindow + @onready var _icon_delete := EditorInterface.get_editor_theme().get_icon("Remove", "EditorIcons") @onready var _icon_collapse := EditorInterface.get_editor_theme().get_icon("Back", "EditorIcons") @onready var _icon_expand := EditorInterface.get_editor_theme().get_icon("Forward", "EditorIcons") @@ -31,6 +34,13 @@ const Constants = preload("res://addons/block_code/ui/constants.gd") var _block_code_nodes: Array var _collapsed: bool = false +var _window_active: bool = false +var _script_window = null + +var split_script_visibility: bool = false: + set(value): + split_script_visibility = value + _change_split_script_visibility(split_script_visibility) var undo_redo: EditorUndoRedoManager: set(value): @@ -47,6 +57,7 @@ func _init(): func _ready(): _context.changed.connect(_on_context_changed) + _split_script_window.script_window_opened.connect(_on_script_window_opened) _picker.block_picked.connect(_drag_manager.copy_picked_block_and_drag) _picker.variable_created.connect(_create_variable) @@ -64,12 +75,6 @@ func _on_undo_redo_version_changed(): _context.force_update() -func _on_show_script_button_pressed(): - var script: String = _block_canvas.generate_script_from_current_window() - - script_window_requested.emit(script) - - func _on_delete_node_button_pressed(): var scene_root = EditorInterface.get_edited_scene_root() @@ -127,12 +132,14 @@ func switch_block_code_node(block_code_node: BlockCode): block_script.initialize() _context.block_code_node = block_code_node + _update_script() func _on_context_changed(): _delete_node_button.disabled = _context.block_code_node == null if _context.block_code_node != null: _try_migration() + _update_script() func save_script(): @@ -174,6 +181,7 @@ func save_script(): block_script.version = Constants.CURRENT_DATA_VERSION undo_redo.commit_action() + _update_script() func _input(event): @@ -213,6 +221,64 @@ func _on_collapse_button_pressed(): toggle_collapse() +#region Script Window UI +func _on_show_script_button_pressed(): + if split_script_visibility == true: + split_script_visibility = false + else: + split_script_visibility = true + _update_script() + + +func _on_script_window_opened() -> void: + split_script_visibility = false + _show_script_button.visible = false + _script_window_opened() + + +func _on_script_window_closed() -> void: + split_script_visibility = true + _show_script_button.visible = true + _update_script() + + +func _script_window_opened() -> void: + _script_window = ScriptWindow.instantiate() + EditorInterface.popup_dialog(_script_window) + _update_script() + await _script_window.close_requested + + _on_script_window_closed() + _script_window.queue_free() + _script_window = null + _update_script() + + +func _change_split_script_visibility(visibility: bool) -> void: + if visibility == false: + _split_script_container.visible = false + _show_script_button.text = "Show Generated Script" + else: + _split_script_container.visible = true + _show_script_button.text = "Hide Generated Script" + _update_script() + + +func _update_script() -> void: + var block_script: BlockScriptSerialization = _context.block_script + + if block_script != null: + block_script = block_script.duplicate(true) + _split_script_window.update_script(block_script.generated_script) + if _script_window != null: + _script_window.update_script(block_script.generated_script) + else: + _split_script_window.update_script(" ") + if _script_window != null: + _script_window.update_script(" ") +#endregion + + func _on_block_canvas_add_block_code(): var edited_node: Node = EditorInterface.get_inspector().get_edited_object() as Node var scene_root: Node = EditorInterface.get_edited_scene_root() @@ -234,6 +300,7 @@ func _on_block_canvas_add_block_code(): undo_redo.add_undo_property(block_code, "owner", null) undo_redo.commit_action() + _update_script() func _select_node(node: Node): @@ -248,6 +315,7 @@ func _on_block_canvas_open_scene(): return EditorInterface.open_scene_from_path(edited_node.scene_file_path) + _update_script() func _on_block_canvas_replace_block_code(): @@ -265,6 +333,7 @@ func _on_block_canvas_replace_block_code(): undo_redo.add_undo_method(scene_root, "set_editable_instance", edited_node, false) undo_redo.commit_action() + _update_script() func _create_variable(variable: VariableDefinition): @@ -284,3 +353,4 @@ func _create_variable(variable: VariableDefinition): undo_redo.commit_action() _picker.reload_blocks() + _update_script() diff --git a/addons/block_code/ui/main_panel.tscn b/addons/block_code/ui/main_panel.tscn index 838ee3fe..6c8a39e7 100644 --- a/addons/block_code/ui/main_panel.tscn +++ b/addons/block_code/ui/main_panel.tscn @@ -1,12 +1,13 @@ -[gd_scene load_steps=10 format=3 uid="uid://bq37yla8ya707"] +[gd_scene load_steps=11 format=3 uid="uid://bq37yla8ya707"] [ext_resource type="Script" path="res://addons/block_code/ui/main_panel.gd" id="1_u0xju"] [ext_resource type="PackedScene" uid="uid://dlabt3bgmpna2" path="res://addons/block_code/ui/picker/picker.tscn" id="2_hv5f3"] [ext_resource type="PackedScene" uid="uid://bm1183pm05p6a" path="res://addons/block_code/ui/title_bar/title_bar.tscn" id="2_k54yf"] [ext_resource type="PackedScene" uid="uid://c6vumewgnfquy" path="res://addons/block_code/ui/block_canvas/block_canvas.tscn" id="4_cu87g"] [ext_resource type="PackedScene" uid="uid://cph1k5cfximbf" path="res://addons/block_code/drag_manager/drag_manager.tscn" id="4_yijtu"] +[ext_resource type="PackedScene" uid="uid://dk1f21b8d2yp7" path="res://addons/block_code/ui/script_window/split_script_window.tscn" id="5_w4clm"] -[sub_resource type="Image" id="Image_p76b5"] +[sub_resource type="Image" id="Image_5pueq"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 92, 92, 92, 64, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 92, 92, 92, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 255, 90, 90, 90, 192, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 192, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 192, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 192, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 192, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 192, 90, 90, 90, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 128, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 128, 90, 90, 90, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 249, 90, 90, 90, 192, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 192, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 192, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 192, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 192, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 192, 90, 90, 90, 249, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 197, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 195, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 93, 93, 93, 52, 90, 90, 90, 238, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 236, 92, 92, 92, 50, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 96, 96, 96, 24, 91, 91, 91, 101, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 90, 90, 90, 128, 91, 91, 91, 101, 100, 100, 100, 23, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -16,9 +17,9 @@ data = { } [sub_resource type="ImageTexture" id="ImageTexture_mrr6q"] -image = SubResource("Image_p76b5") +image = SubResource("Image_5pueq") -[sub_resource type="Image" id="Image_jif7k"] +[sub_resource type="Image" id="Image_7ov04"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 92, 92, 92, 72, 91, 91, 91, 73, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 116, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 71, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 93, 93, 93, 41, 90, 90, 90, 248, 90, 90, 90, 255, 90, 90, 90, 255, 92, 92, 92, 75, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 170, 170, 170, 3, 90, 90, 90, 201, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 200, 170, 170, 170, 3, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 119, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 247, 96, 96, 96, 40, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 93, 93, 93, 41, 90, 90, 90, 248, 90, 90, 90, 255, 90, 90, 90, 255, 91, 91, 91, 118, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 170, 170, 170, 3, 90, 90, 90, 201, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 200, 170, 170, 170, 3, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 119, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 247, 96, 96, 96, 40, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 93, 93, 93, 41, 90, 90, 90, 248, 90, 90, 90, 255, 90, 90, 90, 255, 91, 91, 91, 118, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 170, 170, 170, 3, 90, 90, 90, 201, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 200, 170, 170, 170, 3, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 91, 91, 91, 84, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 96, 96, 96, 40, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 91, 91, 91, 84, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 255, 93, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 170, 170, 170, 3, 90, 90, 90, 200, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 200, 170, 170, 170, 3, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 93, 93, 93, 41, 90, 90, 90, 248, 90, 90, 90, 255, 90, 90, 90, 255, 91, 91, 91, 118, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 119, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 248, 93, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 170, 170, 170, 3, 90, 90, 90, 200, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 200, 170, 170, 170, 3, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 93, 93, 93, 41, 90, 90, 90, 248, 90, 90, 90, 255, 90, 90, 90, 255, 91, 91, 91, 118, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 119, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 248, 93, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 170, 170, 170, 3, 90, 90, 90, 200, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 200, 170, 170, 170, 3, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 93, 93, 93, 41, 90, 90, 90, 248, 90, 90, 90, 255, 90, 90, 90, 255, 92, 92, 92, 75, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 116, 90, 90, 90, 255, 90, 90, 90, 255, 90, 90, 90, 71, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 90, 90, 90, 71, 92, 92, 92, 72, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -28,7 +29,7 @@ data = { } [sub_resource type="ImageTexture" id="ImageTexture_2e128"] -image = SubResource("Image_jif7k") +image = SubResource("Image_7ov04") [node name="MainPanel" type="MarginContainer"] anchors_preset = 15 @@ -65,6 +66,7 @@ layout_mode = 2 text = "Advanced" [node name="ShowScriptButton" type="Button" parent="MarginContainer/HBoxContainer/ScriptVBox/HBoxContainer"] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 text = "Show Generated Script" @@ -73,37 +75,41 @@ text = "Show Generated Script" unique_name_in_owner = true layout_mode = 2 tooltip_text = "Delete Block Code" +disabled = true icon = SubResource("ImageTexture_mrr6q") [node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/ScriptVBox"] layout_mode = 2 size_flags_vertical = 3 -[node name="PickerSplit" type="HSplitContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer"] +[node name="HSplitContainer" type="HSplitContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer"] +layout_mode = 2 + +[node name="PickerSplit" type="HSplitContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="Picker" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/PickerSplit" instance=ExtResource("2_hv5f3")] +[node name="Picker" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/PickerSplit" instance=ExtResource("2_hv5f3")] unique_name_in_owner = true layout_mode = 2 -[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/PickerSplit"] +[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/PickerSplit"] layout_mode = 2 theme_override_constants/margin_bottom = 4 -[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/PickerSplit/MarginContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/PickerSplit/MarginContainer"] layout_mode = 2 -[node name="BlockCanvas" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/PickerSplit/MarginContainer/VBoxContainer" instance=ExtResource("4_cu87g")] +[node name="BlockCanvas" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/PickerSplit/MarginContainer/VBoxContainer" instance=ExtResource("4_cu87g")] unique_name_in_owner = true layout_mode = 2 -[node name="BottomBar" type="HBoxContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/PickerSplit/MarginContainer/VBoxContainer"] +[node name="BottomBar" type="HBoxContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/PickerSplit/MarginContainer/VBoxContainer"] layout_mode = 2 -[node name="CollapseButton" type="Button" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/PickerSplit/MarginContainer/VBoxContainer/BottomBar"] +[node name="CollapseButton" type="Button" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/PickerSplit/MarginContainer/VBoxContainer/BottomBar"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 8 @@ -111,20 +117,30 @@ tooltip_text = "Toggle Block Picker (Ctrl+BackSlash)" icon = SubResource("ImageTexture_2e128") flat = true -[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/PickerSplit/MarginContainer/VBoxContainer/BottomBar"] +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/PickerSplit/MarginContainer/VBoxContainer/BottomBar"] +layout_mode = 2 + +[node name="SplitScriptContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer"] +unique_name_in_owner = true +visible = false +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="SplitScriptWindow" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/SplitScriptContainer" instance=ExtResource("5_w4clm")] +unique_name_in_owner = true layout_mode = 2 [node name="DragManager" parent="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer" instance=ExtResource("4_yijtu")] unique_name_in_owner = true layout_mode = 2 mouse_filter = 2 -picker_path = NodePath("../PickerSplit/Picker") -block_canvas_path = NodePath("../PickerSplit/MarginContainer/VBoxContainer/BlockCanvas") +picker_path = NodePath("../HSplitContainer/PickerSplit/Picker") +block_canvas_path = NodePath("../HSplitContainer/PickerSplit/MarginContainer/VBoxContainer/BlockCanvas") +[connection signal="toggled" from="MarginContainer/HBoxContainer/ScriptVBox/HBoxContainer/AdvancedCheckBox" to="." method="_on_advanced_checkbox_toggled"] [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"] -[connection signal="pressed" from="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/PickerSplit/MarginContainer/VBoxContainer/BottomBar/CollapseButton" to="." method="_on_collapse_button_pressed"] +[connection signal="add_block_code" from="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/PickerSplit/MarginContainer/VBoxContainer/BlockCanvas" to="." method="_on_block_canvas_add_block_code"] +[connection signal="open_scene" from="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/PickerSplit/MarginContainer/VBoxContainer/BlockCanvas" to="." method="_on_block_canvas_open_scene"] +[connection signal="replace_block_code" from="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/PickerSplit/MarginContainer/VBoxContainer/BlockCanvas" to="." method="_on_block_canvas_replace_block_code"] +[connection signal="pressed" from="MarginContainer/HBoxContainer/ScriptVBox/MarginContainer/HSplitContainer/PickerSplit/MarginContainer/VBoxContainer/BottomBar/CollapseButton" to="." method="_on_collapse_button_pressed"] diff --git a/addons/block_code/ui/script_window/script_window.gd b/addons/block_code/ui/script_window/script_window.gd index 6926e111..c9229a50 100644 --- a/addons/block_code/ui/script_window/script_window.gd +++ b/addons/block_code/ui/script_window/script_window.gd @@ -9,7 +9,7 @@ var script_content: String = "" ## Attempts to match the syntax highlighting for some open script in the ## editor, which is more likely to be appropriate for the editor theme ## than our hardcoded default -func _apply_editor_syntax_highlighter(): +func _apply_editor_syntax_highlighter() -> void: var script_editor: ScriptEditor = EditorInterface.get_script_editor() for x in script_editor.get_open_script_editors(): var control: Control = x.get_base_editor() @@ -19,17 +19,24 @@ func _apply_editor_syntax_highlighter(): ## Undoes the effect of the CodeEdit being read-only -func _remove_font_color_alpha_clamp(): +func _remove_font_color_alpha_clamp() -> void: var font_readonly_color = script_label.get_theme_color("font_readonly_color") font_readonly_color.a = 1 script_label.add_theme_color_override("font_readonly_color", font_readonly_color) -func _ready(): +func _ready() -> void: _apply_editor_syntax_highlighter() _remove_font_color_alpha_clamp() script_label.text = script_content.replace("\t", " ") -func _on_copy_code_pressed(): +func update_script(script: String) -> void: + _apply_editor_syntax_highlighter() + _remove_font_color_alpha_clamp() + script_content = script + script_label.text = script_content.replace("\t", " ") + + +func _on_copy_code_pressed() -> void: DisplayServer.clipboard_set(script_content) diff --git a/addons/block_code/ui/script_window/script_window.tscn b/addons/block_code/ui/script_window/script_window.tscn index 0a72b48d..d29d2033 100644 --- a/addons/block_code/ui/script_window/script_window.tscn +++ b/addons/block_code/ui/script_window/script_window.tscn @@ -6,28 +6,9 @@ font_names = PackedStringArray("DejaVu Sans Mono") subpixel_positioning = 0 -[sub_resource type="CodeHighlighter" id="CodeHighlighter_yvmnf"] -number_color = Color(0.498039, 0.760784, 0.686275, 1) -symbol_color = Color(0.803922, 0.811765, 0.823529, 1) -function_color = Color(0.290196, 0.576471, 0.819608, 1) -member_variable_color = Color(0.615686, 0.729412, 0.831373, 1) -keyword_colors = { -"and": Color(1, 0.439216, 0.521569, 1), -"elif": Color(1, 0.54902, 0.8, 1), -"else": Color(1, 0.54902, 0.8, 1), -"extends": Color(1, 0.439216, 0.521569, 1), -"for": Color(1, 0.54902, 0.8, 1), -"func": Color(1, 0.439216, 0.521569, 1), -"if": Color(1, 0.54902, 0.8, 1), -"not": Color(1, 0.439216, 0.521569, 1), -"or": Color(1, 0.439216, 0.521569, 1), -"return": Color(1, 0.54902, 0.8, 1), -"var": Color(1, 0.439216, 0.521569, 1) -} -color_regions = { -"\" \"": Color(1, 0.929412, 0.627451, 1), -"' '": Color(1, 0.929412, 0.627451, 1) -} +[sub_resource type="GDScriptSyntaxHighlighter" id="GDScriptSyntaxHighlighter_3xcld"] +resource_local_to_scene = true +resource_name = "" [node name="ScriptWindow" type="Window"] title = "Block Code Generated GDScript" @@ -53,9 +34,10 @@ layout_mode = 2 unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 3 +theme_override_colors/font_readonly_color = Color(0.875, 0.875, 0.875, 1) theme_override_fonts/font = SubResource("SystemFont_r6ct2") editable = false -syntax_highlighter = SubResource("CodeHighlighter_yvmnf") +syntax_highlighter = SubResource("GDScriptSyntaxHighlighter_3xcld") [node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBox"] layout_mode = 2 diff --git a/addons/block_code/ui/script_window/split_script_window.gd b/addons/block_code/ui/script_window/split_script_window.gd new file mode 100644 index 00000000..8f5978f3 --- /dev/null +++ b/addons/block_code/ui/script_window/split_script_window.gd @@ -0,0 +1,45 @@ +@tool +extends HBoxContainer + +signal script_window_opened + +@onready var script_label: CodeEdit = $"PanelContainer/CodeContainer/Code" +@onready var window_button: Button = %WindowButton +@onready var code_container: VBoxContainer = $"PanelContainer/CodeContainer" + +var script_content: String = "" +var window_mode: bool = false + + +## Attempts to match the syntax highlighting for some open script in the +## editor, which is more likely to be appropriate for the editor theme +## than our hardcoded default +func _apply_editor_syntax_highlighter() -> void: + var script_editor: ScriptEditor = EditorInterface.get_script_editor() + for x in script_editor.get_open_script_editors(): + var control: Control = x.get_base_editor() + if control is TextEdit: + script_label.syntax_highlighter = control.syntax_highlighter + break + + +## Undoes the effect of the CodeEdit being read-only +func _remove_font_color_alpha_clamp() -> void: + var font_readonly_color = script_label.get_theme_color("font_readonly_color") + font_readonly_color.a = 1 + script_label.add_theme_color_override("font_readonly_color", font_readonly_color) + + +func update_script(script: String) -> void: + _apply_editor_syntax_highlighter() + _remove_font_color_alpha_clamp() + script_content = script + script_label.text = script_content.replace("\t", " ") + + +func _on_copy_code_pressed() -> void: + DisplayServer.clipboard_set(script_content) + + +func _on_window_button_pressed() -> void: + script_window_opened.emit() diff --git a/addons/block_code/ui/script_window/split_script_window.tscn b/addons/block_code/ui/script_window/split_script_window.tscn new file mode 100644 index 00000000..332b1c08 --- /dev/null +++ b/addons/block_code/ui/script_window/split_script_window.tscn @@ -0,0 +1,69 @@ +[gd_scene load_steps=3 format=3 uid="uid://dk1f21b8d2yp7"] + +[ext_resource type="Script" path="res://addons/block_code/ui/script_window/split_script_window.gd" id="1_slx3m"] + +[sub_resource type="SystemFont" id="SystemFont_r6ct2"] +font_names = PackedStringArray("DejaVu Sans Mono") +subpixel_positioning = 0 + +[node name="SplitScriptWindow" type="HBoxContainer"] +custom_minimum_size = Vector2(400, 0) +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -750.0 +offset_top = -375.0 +offset_bottom = 375.0 +grow_horizontal = 0 +grow_vertical = 2 +size_flags_horizontal = 0 +size_flags_vertical = 3 +script = ExtResource("1_slx3m") + +[node name="PanelContainer" type="PanelContainer" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Panel" type="Panel" parent="PanelContainer"] +layout_mode = 2 + +[node name="CodeContainer" type="VBoxContainer" parent="PanelContainer"] +unique_name_in_owner = true +layout_mode = 2 + +[node name="Code" type="CodeEdit" parent="PanelContainer/CodeContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_vertical = 3 +theme_override_colors/font_readonly_color = Color(0.875, 0.875, 0.875, 1) +theme_override_fonts/font = SubResource("SystemFont_r6ct2") +editable = false + +[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/CodeContainer"] +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/CodeContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/margin_left = 3 +theme_override_constants/margin_right = 3 +theme_override_constants/margin_bottom = 3 + +[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/CodeContainer/HBoxContainer/MarginContainer"] +layout_mode = 2 + +[node name="CopyCode" type="Button" parent="PanelContainer/CodeContainer/HBoxContainer/MarginContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 6 +text = "Copy" + +[node name="WindowButton" type="Button" parent="PanelContainer/CodeContainer/HBoxContainer/MarginContainer/HBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 6 +text = "Open Window" + +[connection signal="pressed" from="PanelContainer/CodeContainer/HBoxContainer/MarginContainer/HBoxContainer/CopyCode" to="." method="_on_copy_code_pressed"] +[connection signal="pressed" from="PanelContainer/CodeContainer/HBoxContainer/MarginContainer/HBoxContainer/WindowButton" to="." method="_on_window_button_pressed"]