This repository has been archived by the owner on Jun 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Member_Button.tscn
112 lines (95 loc) · 2.77 KB
/
Member_Button.tscn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
[gd_scene load_steps=3 format=2]
[ext_resource path="res://abomasnow.png" type="Texture" id=1]
[sub_resource type="GDScript" id=1]
script/source = "extends Button
signal dragged_and_dropped
const path = \"res://sprites/pokemon/icons/\"
onready var label = $VBoxContainer/Label
onready var sprite = $VBoxContainer/TextureRect
onready var hold_timer = $Timer
var id
var can_drag = true
func _ready():
pass
func pokeButton(var info):
label = $VBoxContainer/Label
sprite = $VBoxContainer/TextureRect
if info != null:
id = info
var pokemon = Pokemon.pokemon[info]
disabled = false
label.visible = true
sprite.visible = true
label.text = pokemon[\"nickname\"]
var path_name = str(pokemon[\"sprite\"])
var temp_path = path+path_name
sprite.set_texture(load(temp_path))
else:
id = null
disabled = true
label.visible = false
sprite.visible = false
func _on_Button_pressed():
for panel in get_tree().get_nodes_in_group(\"Info Panel\"):
panel.open(id)
hold_timer.stop()
func _on_Button_button_down():
yield(get_tree().create_timer(2.0), \"timeout\")
get_drag_data(Vector2(0.0,0.0))
func get_drag_data(position):
if not disabled and can_drag:
var data = {}
data[\"origin\"] = self
data[\"pokemon\"] = id
var drag_button = TextureRect.new()
drag_button.texture = get_child(0).get_child(0).texture
drag_button.rect_size = Vector2(100,100)
var control = Control.new()
control.add_child(drag_button)
drag_button.rect_position = -0.5 * drag_button.rect_size
set_drag_preview(control)
return data
func can_drop_data(position, data):
return true
func drop_data(position, data):
data[\"origin\"].pokeButton(id)
pokeButton(data[\"pokemon\"])
emit_signal(\"dragged_and_dropped\")
"
[node name="Button" type="Button"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
disabled = true
script = SubResource( 1 )
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="TextureRect" type="TextureRect" parent="VBoxContainer"]
visible = false
margin_right = 1024.0
margin_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
size_flags_stretch_ratio = 3.75
texture = ExtResource( 1 )
expand = true
stretch_mode = 6
[node name="Label" type="Label" parent="VBoxContainer"]
visible = false
margin_top = 474.0
margin_right = 1024.0
margin_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Name"
align = 1
valign = 1
[node name="Timer" type="Timer" parent="."]
wait_time = 2.0
[connection signal="button_down" from="." to="." method="_on_Button_button_down"]
[connection signal="button_up" from="." to="." method="_on_Button_button_up"]
[connection signal="pressed" from="." to="." method="_on_Button_pressed"]