Created Test Script Editor
Starting work on allowing for GDScript to code various functionality in Overlay outside of normal backend code. Such as event handling, sending messages, alerts, etc, etc.
This commit is contained in:
parent
05c67aa19e
commit
5cf4cd512c
6 changed files with 3756 additions and 0 deletions
30
UI/Controls/script_editor.gd
Normal file
30
UI/Controls/script_editor.gd
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
extends PanelContainer
|
||||
|
||||
@onready var run_script: Button = %RunScript
|
||||
@onready var code_editor: TextEdit = %CodeEditor
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
%CodeEditor.text = "extends OverlayPlugin\n\nfunc run() -> void:\n\tpass"
|
||||
run_script.pressed.connect(_handle_run_script)
|
||||
|
||||
func _handle_run_script() -> void:
|
||||
var script = GDScript.new()
|
||||
script.source_code = %CodeEditor.text
|
||||
var error := script.reload()
|
||||
if error != OK:
|
||||
print("Failed to parse script!")
|
||||
return
|
||||
var context: Object = script.new()
|
||||
if not context is OverlayPlugin:
|
||||
print("Script doesn't inherit from OverlayPlugin!")
|
||||
if context.has_method(&"queue_free"):
|
||||
context.queue_free()
|
||||
elif context is RefCounted:
|
||||
context = null
|
||||
else:
|
||||
context.free()
|
||||
return
|
||||
context.ready.connect(func() -> void: context.run(); context.queue_free())
|
||||
add_child(context)
|
||||
1
UI/Controls/script_editor.gd.uid
Normal file
1
UI/Controls/script_editor.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d1t6dwda2ccbc
|
||||
48
UI/Controls/script_editor.tscn
Normal file
48
UI/Controls/script_editor.tscn
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
[gd_scene format=3 uid="uid://cetlbpyakk1vo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1t6dwda2ccbc" path="res://UI/Controls/script_editor.gd" id="1_2d8la"]
|
||||
[ext_resource type="Theme" uid="uid://bh8pw2ic1krk3" path="res://UI/assets/editor_theme.tres" id="2_b6d4x"]
|
||||
[ext_resource type="CodeHighlighter" uid="uid://cana6jwydsw5b" path="res://UI/assets/gdscript_highlighter4.tres" id="2_tuoer"]
|
||||
|
||||
[node name="ScriptEditor" type="PanelContainer" unique_id=1486890629]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_2d8la")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=357949885]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer" unique_id=140758909]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer" unique_id=2023186459]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="RunScript" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer" unique_id=356048785]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Run Script"
|
||||
|
||||
[node name="CodeEditor" type="CodeEdit" parent="MarginContainer/VBoxContainer" unique_id=1991835537]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme = ExtResource("2_b6d4x")
|
||||
scroll_smooth = true
|
||||
scroll_past_end_of_file = true
|
||||
syntax_highlighter = ExtResource("2_tuoer")
|
||||
line_folding = true
|
||||
gutters_draw_line_numbers = true
|
||||
gutters_zero_pad_line_numbers = true
|
||||
gutters_draw_fold_gutter = true
|
||||
indent_use_spaces = true
|
||||
indent_automatic = true
|
||||
auto_brace_completion_enabled = true
|
||||
auto_brace_completion_highlight_matching = true
|
||||
Loading…
Add table
Add a link
Reference in a new issue