Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions addons/script-ide/customrunbar/custom_run_bar.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@tool
class_name CustomRunBar extends Control

@export var buttons_container : HBoxContainer

func duplicate_engine_run_bar(engine_run_bar_buttons_container : Control) -> void:
for i in engine_run_bar_buttons_container.get_children().size():
var current_custom_run_bar_button: CustomRunBarButton = CustomRunBarButton.new()
var current_engine_run_bar_button = engine_run_bar_buttons_container.get_child(i)

if current_engine_run_bar_button is Button:
current_custom_run_bar_button.mimic_engine_button(current_engine_run_bar_button)
buttons_container.add_child(current_custom_run_bar_button)
pass
pass

21 changes: 21 additions & 0 deletions addons/script-ide/customrunbar/custom_run_bar.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[gd_scene load_steps=2 format=3 uid="uid://s7antvleeso"]

[ext_resource type="Script" path="res://addons/script-ide/addons/script-ide/customrunbar/custom_run_bar.gd" id="1_o5ls6"]

[node name="CustomRunBar" type="Control" node_paths=PackedStringArray("buttons_container")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_o5ls6")
buttons_container = NodePath("PanelContainer/HBoxContainer")

[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0

[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer"]
layout_mode = 2
16 changes: 16 additions & 0 deletions addons/script-ide/customrunbar/custom_run_bar_button.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@tool
class_name CustomRunBarButton extends Button

var engine_button : Button

func mimic_engine_button(engine_button : Button):
self.engine_button = engine_button
icon = engine_button.icon
flat = engine_button.flat
tooltip_text = engine_button.tooltip_text
focus_mode = engine_button.focus_mode

pressed.connect(_on_pressed)

func _on_pressed():
engine_button.pressed.emit()
22 changes: 21 additions & 1 deletion addons/script-ide/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var tab_cycle_backward_shc: Shortcut
#endregion

#region Existing controls we modify
var script_editor: ScriptEditor
var outline_container: Control
var outline_parent: Control
var scripts_tab_container: TabContainer
Expand Down Expand Up @@ -117,6 +118,7 @@ var property_btn: Button
var export_btn: Button
var func_btn: Button
var engine_func_btn: Button
var custom_run_bar : CustomRunBar
#endregion

#region Plugin variables
Expand Down Expand Up @@ -152,7 +154,7 @@ func _enter_tree() -> void:
# Sync settings changes for this plugin.
get_editor_settings().settings_changed.connect(sync_settings)

var script_editor: ScriptEditor = EditorInterface.get_script_editor()
script_editor = EditorInterface.get_script_editor()

# Change script item list visibility (based on settings).
scripts_item_list = find_or_null(script_editor.find_children("*", "ItemList", true, false))
Expand Down Expand Up @@ -234,11 +236,19 @@ func _enter_tree() -> void:
# Add callback when the sorting changed.
sort_btn = find_or_null(outline_container.find_children("*", "Button", true, false))
sort_btn.pressed.connect(update_outline)

# Add custom run buttons
custom_run_bar = load("res://addons/script-ide/customrunbar/custom_run_bar.tscn").instantiate()
var editor_run_bar : Node = _find_editor_run_bar(get_editor_interface().get_base_control())
var editor_run_bar_buttons_container : Control = editor_run_bar.get_child(0).get_child(0)
custom_run_bar.duplicate_engine_run_bar(editor_run_bar_buttons_container)
script_editor.get_child(0).get_child(0).get_child(3).add_child(custom_run_bar)

on_tab_changed(scripts_tab_bar.current_tab)

## Restore the old Godot script UI and free everything we created
func _exit_tree() -> void:
script_editor.get_child(0).get_child(0).get_child(3).remove_child(custom_run_bar)
var file_system: EditorFileSystem = EditorInterface.get_resource_filesystem()
file_system.filesystem_changed.disconnect(schedule_update)

Expand Down Expand Up @@ -1257,6 +1267,16 @@ This might be due to some other plugins or changes in the Engine.
Please report this to Script-IDE, so we can figure out a fix.""")
return null
return arr[index]

func _find_editor_run_bar(root: Node) -> Node:
#We go recursively accross godot base control childs until we found the EditorRunBar
for child in root.get_children():
if child is Control and child.name.contains("EditorRunBar"):
return child
var result: Node = _find_editor_run_bar(child)
if result:
return result
return null

## Cache for everything inside we collected to show in the Outline.
class OutlineCache:
Expand Down