From aebb9704be677fb1bf7f0202985c57403ea6f3be Mon Sep 17 00:00:00 2001 From: Max Oberaigner Date: Tue, 23 Apr 2024 14:09:12 +0200 Subject: [PATCH] Initial update, some refactoring --- .../src/project_selector/project_selector.gd | 2 +- godot/src/sprite_selector/add_sprite.gd | 19 ----- godot/src/sprite_selector/add_sprite.tscn | 82 ------------------- godot/src/sprite_selector/sprite.gd | 4 + 4 files changed, 5 insertions(+), 102 deletions(-) delete mode 100644 godot/src/sprite_selector/add_sprite.gd delete mode 100644 godot/src/sprite_selector/add_sprite.tscn diff --git a/godot/src/project_selector/project_selector.gd b/godot/src/project_selector/project_selector.gd index 813e98e..b3271ee 100644 --- a/godot/src/project_selector/project_selector.gd +++ b/godot/src/project_selector/project_selector.gd @@ -50,7 +50,7 @@ func _on_project_name_line_edit_text_changed(new_text): func _on_new_project_button_pressed(_id: int): - get_tree().change_scene_to_file("res://src/sprite_selector/add_sprite.tscn") + get_tree().change_scene_to_file("res://src/sprite_selector/main.tscn") func _on_your_projects_menu_button_pressed(): diff --git a/godot/src/sprite_selector/add_sprite.gd b/godot/src/sprite_selector/add_sprite.gd deleted file mode 100644 index 2fb9d36..0000000 --- a/godot/src/sprite_selector/add_sprite.gd +++ /dev/null @@ -1,19 +0,0 @@ -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) diff --git a/godot/src/sprite_selector/add_sprite.tscn b/godot/src/sprite_selector/add_sprite.tscn deleted file mode 100644 index 91c1bd7..0000000 --- a/godot/src/sprite_selector/add_sprite.tscn +++ /dev/null @@ -1,82 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://bs2465qtho3bu"] - -[ext_resource type="Script" path="res://src/sprite_selector/add_sprite.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"] diff --git a/godot/src/sprite_selector/sprite.gd b/godot/src/sprite_selector/sprite.gd index ba51090..58fdf0c 100644 --- a/godot/src/sprite_selector/sprite.gd +++ b/godot/src/sprite_selector/sprite.gd @@ -38,3 +38,7 @@ func get_preview_controll(): func _drop_data(_at_position, data): var node = get_parent().get_node(data.get_path()) get_parent().move_child(node, target) + + +func _on_pressed(): + get_tree().change_scene_to_file("res://src/script_editor/main.tscn")