Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
help i have to rebase because max has pushed something which i have m…
Browse files Browse the repository at this point in the history
…erged
  • Loading branch information
Alexander Rösel committed Apr 23, 2024
1 parent 69354bc commit 7b720e9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 40 deletions.
6 changes: 6 additions & 0 deletions godot/.godot/global_script_class_cache.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ list=Array[Dictionary]([{
"icon": "",
"language": &"GDScript",
"path": "res://src/widgets/AutoRefresh/auto_refresh.gd"
},{
"base": &"Button",
"class": &"DragAndDropItem",
"icon": "",
"language": &"GDScript",
"path": "res://src/widgets/dragable_item/dragable.gd"
}, {
"base": &"EditorPlugin",
"class": &"FormatOnSave",
Expand Down
15 changes: 8 additions & 7 deletions godot/src/sprite_selector/main.gd
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
extends Control

var Sprites: Resource = preload("res://src/sprite_selector/sprite.tscn")
var Sprites: Resource = preload("res://src/sprite_selector/sprite_test.tscn")


func _on_add_sprite_button_pressed():
$FileDialog.popup_centered()


func _on_file_dialog_file_selected(path):
var sprite: Button = Sprites.instantiate()
var sprite = 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)
#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)
get_node("VBoxContainer2/VBox/ScrollContainer/VBoxIntems").add_child(sprite)
37 changes: 16 additions & 21 deletions godot/src/sprite_selector/sprite.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
extends Control

@onready var target = 0
extends DragAndDropItem


func setup(path):
Expand All @@ -10,34 +8,31 @@ func setup(path):
tex.set_image(img)
var label = get_node("VBoxContainer/Label")
$VBoxContainer/TextureRect.texture = tex
label.text = path
$VBoxContainer/Label.text = path
self.expand_icon = true


func _ready():
set_process_input(false)


func _get_drag_data(_at_position: Vector2):
set_drag_preview(get_preview_controll())
target = get_parent().get_node(self.get_path()).get_index(true)
return self


func _can_drop_data(_at_position, data):
target = get_parent().get_node(self.get_path()).get_index(true)
var node = get_parent().get_node(data.get_path())
get_parent().move_child(node, target)
return true

#func _get_drag_data(_at_position: Vector2):
# set_drag_preview(get_preview_controll())
# target = get_parent().get_node(self.get_path()).get_index(true)
# return self

func get_preview_controll():
return duplicate()
#func _can_drop_data(_at_position, data):
# target = get_parent().get_node(self.get_path()).get_index(true)
# var node = get_parent().get_node(data.get_path())
# get_parent().move_child(node, target)
# return true

#func get_preview_controll():
# return duplicate()

func _drop_data(_at_position, data):
var node = get_parent().get_node(data.get_path())
get_parent().move_child(node, target)
#func _drop_data(_at_position, data):
# var node = get_parent().get_node(data.get_path())
# get_parent().move_child(node, target)


func _on_pressed():
Expand Down
26 changes: 14 additions & 12 deletions godot/src/sprite_selector/sprite.tscn
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
[gd_scene load_steps=2 format=3 uid="uid://rsvepepjglmt"]
[gd_scene load_steps=3 format=3 uid="uid://rsvepepjglmt"]

[ext_resource type="Script" path="res://src/widgets/dragable_item/dragable.gd" id="1_lsqbi"]
[ext_resource type="Script" path="res://src/sprite_selector/sprite.gd" id="1_p6m3n"]

[node name="SpriteButton" type="Button"]
clip_contents = true
custom_minimum_size = Vector2(100, 100)
offset_right = 100.0
offset_bottom = 200.0
size_flags_horizontal = 3
button_mask = 3
script = ExtResource("1_p6m3n")

[node name="VBoxContainer" type="VBoxContainer" parent="."]
[node name="DragAndDropItem" type="Button" parent="."]
offset_right = 8.0
offset_bottom = 8.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_lsqbi")

[node name="VBoxContainer" type="VBoxContainer" parent="DragAndDropItem"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = 70.0
offset_bottom = 97.0
grow_horizontal = 2
grow_vertical = 2
alignment = 1

[node name="TextureRect" type="TextureRect" parent="VBoxContainer"]
[node name="TextureRect" type="TextureRect" parent="DragAndDropItem/VBoxContainer"]
custom_minimum_size = Vector2(70, 70)
layout_mode = 2
size_flags_vertical = 3
expand_mode = 3
stretch_mode = 5

[node name="Label" type="Label" parent="VBoxContainer"]
[node name="Label" type="Label" parent="DragAndDropItem/VBoxContainer"]
layout_mode = 2
horizontal_alignment = 1

[connection signal="pressed" from="." to="." method="_on_pressed"]

0 comments on commit 7b720e9

Please sign in to comment.