This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Max Oberaigner
committed
Apr 23, 2024
1 parent
aebb970
commit 1a03db0
Showing
9 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
extends AutoRefresh | ||
|
||
const MoveFragmentLabel: Resource = preload("res://src/script_editor/code_fragment_move.tscn") | ||
|
||
|
||
func _refresh_contents(): | ||
var ast = Api.get_ast() | ||
render_ast(ast) | ||
|
||
|
||
func render_ast(ast): | ||
var code_container := $Code | ||
for old in code_container.get_children(): | ||
code_container.remove_child(old) | ||
|
||
for fragment in ast: | ||
code_container.add_child(MoveFragmentLabel.instantiate()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extends Button | ||
|
||
|
||
func _on_pressed(): | ||
API.insert(200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extends Button | ||
|
||
|
||
func _on_pressed(): | ||
get_tree().change_scene_to_file("res://src/runtime/runtime.tscn") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[gd_scene format=3 uid="uid://qfu2qre10e3g"] | ||
|
||
[node name="RichTextLabel" type="RichTextLabel"] | ||
offset_right = 1.0 | ||
offset_bottom = 23.0 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 3 | ||
text = "MOVE [randomly]" | ||
fit_content = true | ||
scroll_active = false | ||
autowrap_mode = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
[gd_scene load_steps=4 format=3 uid="uid://rsvepepjglmt"] | ||
|
||
[ext_resource type="Script" path="res://src/script_editor/button_run.gd" id="1_2l7lb"] | ||
[ext_resource type="Script" path="res://src/script_editor/button_add.gd" id="2_vfewj"] | ||
[ext_resource type="Script" path="res://src/script_editor/auto_refresh_fragments.gd" id="3_6u76r"] | ||
|
||
[node name="ScriptEditor" type="Control"] | ||
layout_mode = 3 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 3 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="."] | ||
layout_mode = 1 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 3 | ||
|
||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="RunButton" type="Button" parent="VBoxContainer/HBoxContainer"] | ||
layout_mode = 2 | ||
text = "Run" | ||
script = ExtResource("1_2l7lb") | ||
|
||
[node name="AddButton" type="Button" parent="VBoxContainer/HBoxContainer"] | ||
layout_mode = 2 | ||
text = "Add Move" | ||
script = ExtResource("2_vfewj") | ||
|
||
[node name="VScrollContainer" type="ScrollContainer" parent="VBoxContainer"] | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 3 | ||
|
||
[node name="AutoRefresh" type="VBoxContainer" parent="VBoxContainer/VScrollContainer"] | ||
layout_mode = 2 | ||
script = ExtResource("3_6u76r") | ||
|
||
[node name="Code" type="VBoxContainer" parent="VBoxContainer/VScrollContainer/AutoRefresh"] | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
|
||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/RunButton" to="VBoxContainer/HBoxContainer/RunButton" method="_on_pressed"] | ||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/AddButton" to="VBoxContainer/HBoxContainer/AddButton" method="_on_pressed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
extends Control | ||
|
||
var Sprites: Resource = preload("res://src/sprite_selector/sprite.tscn") | ||
|
||
|
||
func _on_add_sprite_button_pressed(): | ||
$FileDialog.popup_centered() | ||
|
||
|
||
func _on_file_dialog_file_selected(path): | ||
var sprite: Button = Sprites.instantiate() | ||
sprite.setup(path) | ||
var margin_container = MarginContainer.new() | ||
var margin_value = 10 | ||
margin_container.add_theme_constant_override("margin_top", margin_value / 2) | ||
margin_container.add_theme_constant_override("margin_left", margin_value) | ||
margin_container.add_theme_constant_override("margin_bottom", margin_value / 2) | ||
margin_container.add_theme_constant_override("margin_right", margin_value) | ||
get_node("VBoxContainer2/VBox/ScrollContainer/VBoxIntems").add_child(sprite) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
[gd_scene load_steps=5 format=3 uid="uid://bs2465qtho3bu"] | ||
|
||
[ext_resource type="Script" path="res://src/sprite_selector/main.gd" id="1_w6ncu"] | ||
[ext_resource type="Script" path="res://src/sprite_selector/sprite_list.gd" id="2_y3h1p"] | ||
|
||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_kefq6"] | ||
|
||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_s6hla"] | ||
|
||
[node name="Control" type="Control"] | ||
layout_mode = 3 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 3 | ||
script = ExtResource("1_w6ncu") | ||
|
||
[node name="FileDialog" type="FileDialog" parent="."] | ||
title = "Open a File" | ||
size = Vector2i(479, 400) | ||
exclusive = false | ||
ok_button_text = "Open" | ||
dialog_hide_on_ok = true | ||
dialog_autowrap = true | ||
file_mode = 0 | ||
access = 2 | ||
filters = PackedStringArray("*.png", "*.jpg", "*.jpeg", "*.svg") | ||
use_native_dialog = true | ||
|
||
[node name="VBoxContainer2" type="VBoxContainer" parent="."] | ||
layout_direction = 2 | ||
layout_mode = 1 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
|
||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer2"] | ||
layout_mode = 2 | ||
|
||
[node name="BoxContainer" type="BoxContainer" parent="VBoxContainer2/HBoxContainer"] | ||
layout_direction = 2 | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
|
||
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer2/HBoxContainer"] | ||
layout_direction = 3 | ||
layout_mode = 2 | ||
size_flags_horizontal = 8 | ||
size_flags_vertical = 0 | ||
theme_override_constants/margin_top = 10 | ||
theme_override_constants/margin_right = 10 | ||
|
||
[node name="AddSpriteButton" type="Button" parent="VBoxContainer2/HBoxContainer/MarginContainer"] | ||
custom_minimum_size = Vector2(50, 20) | ||
layout_direction = 2 | ||
layout_mode = 2 | ||
size_flags_horizontal = 0 | ||
theme_override_styles/pressed = SubResource("StyleBoxEmpty_kefq6") | ||
theme_override_styles/focus = SubResource("StyleBoxEmpty_s6hla") | ||
text = "Add Sprite" | ||
|
||
[node name="VBox" type="VBoxContainer" parent="VBoxContainer2"] | ||
layout_mode = 2 | ||
size_flags_vertical = 3 | ||
|
||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer2/VBox"] | ||
layout_mode = 2 | ||
size_flags_vertical = 3 | ||
|
||
[node name="VBoxIntems" type="VBoxContainer" parent="VBoxContainer2/VBox/ScrollContainer"] | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 3 | ||
script = ExtResource("2_y3h1p") | ||
|
||
[connection signal="file_selected" from="FileDialog" to="." method="_on_file_dialog_file_selected"] | ||
[connection signal="pressed" from="VBoxContainer2/HBoxContainer/MarginContainer/AddSpriteButton" to="." method="_on_add_sprite_button_pressed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
extends VBoxContainer | ||
|
||
const Sprite: Resource = preload("res://src/sprite_selector/sprite.tscn") | ||
|
||
|
||
func render_ast(ast): | ||
var code_container := get_tree() | ||
for old in code_container.get_children(): | ||
code_container.remove_child(old) | ||
|
||
for fragment in ast: | ||
code_container.add_child(Sprite.instantiate()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class_name AutoRefresh | ||
extends VBoxContainer | ||
|
||
|
||
func _ready(): | ||
# get a signal when underlying data changed | ||
GlobalSignals.script_updated.connect(_refresh_contents) | ||
|
||
# initial rendering | ||
_refresh_contents() | ||
|
||
|
||
func _refresh_contents(): | ||
# update children of this node here! | ||
assert(false, "_refresh_contents not implemented") |