-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemon_cards_margin_container.gd
143 lines (118 loc) · 3.69 KB
/
demon_cards_margin_container.gd
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
extends MarginContainer
var hovering = false
var expand = false
@onready var button : Button = %Button
@onready var button_collapse : Button = %CollapseButton
var startPosition
var mouseEnteredPositiony : int = 0
var buttonTextCombat = "Pick Demons to fight in Battle or"
var buttonTextNormal = "Demons of your Triumphirate"
var buttonTextStart = "Examine your Triumphirate"
var tw1
func _ready():
Signals.expandDemonCards.connect(expandDemonCards)
Signals.collapseDemonCards.connect(collapseDemonCards)
Signals.addDemonToUi.connect(_on_addDemon)
startPosition = position
%DemonHeaderLabel.text = buttonTextNormal
if not Data.chooseDemon:
collapse()
reset_size()
func _on_addDemon(demon):
%DemonHBoxContainer.add_child(demon)
reset_size()
func _process(delta):
return
if hovering and not expand:
if get_global_mouse_position().y > mouseEnteredPositiony + 10:
#return
# position -= Vector2(0, 650)
hovering = false
tw1 = get_tree().create_tween()
tw1.set_trans(Tween.TRANS_QUAD)
tw1.set_ease(Tween.EASE_IN_OUT)
tw1.parallel().tween_property(self, "position", startPosition - Vector2(0, 550), 0.2)
func collapse():
tw1 = get_tree().create_tween()
tw1.set_trans(Tween.TRANS_QUAD)
tw1.set_ease(Tween.EASE_IN_OUT)
tw1.parallel().tween_property(self, "position", startPosition - Vector2(0, 550), 0.2)
func removeDemon(rank : int):
for child in %DemonHBoxContainer.get_children():
if not child is Label:
if child.rank == rank:
child.queue_free()
reset_size()
func _on_mouse_entered():
mouseEnteredPositiony = get_global_mouse_position().y
hovering = true
# position = startPosition
tw1 = get_tree().create_tween()
tw1.set_trans(Tween.TRANS_QUAD)
tw1.set_ease(Tween.EASE_IN_OUT)
tw1.parallel().tween_property(self, "position", startPosition, 0.2)
func expandDemonCards(battle : bool = true):
#button = Button.new()
if battle:
expand = true
_on_mouse_entered()
%DemonHeaderLabel.text = buttonTextCombat
button.text = "Click me to go to Battle without Demon."
if not button.pressed.is_connected(_on_noDemonClicked):
button.pressed.connect(_on_noDemonClicked)
if button.pressed.is_connected(_on_proceedClicked):
button.pressed.disconnect(_on_proceedClicked)
button.show()
button_collapse.text = "Collapse"
button_collapse.show()
else:
expand = true
_on_mouse_entered()
%DemonHeaderLabel.text = buttonTextStart
button.text = "Proceed."
if not button.pressed.is_connected(_on_proceedClicked):
button.pressed.connect(_on_proceedClicked)
if button.pressed.is_connected(_on_noDemonClicked):
button.pressed.disconnect(_on_noDemonClicked)
button.show()
reset_size()
#%DemonVBoxContainer.add_child(button)
func collapseDemonCards():
%DemonHeaderLabel.text = buttonTextNormal
expand = false
collapse()
button.hide()
button_collapse.hide()
reset_size()
#if is_instance_valid(button):
#button.queue_free()
#if is_instance_valid(button_collapse):
#button_collapse.queue_free()
func _on_proceedClicked():
Signals.proceed.emit()
%DemonHeaderLabel.text = buttonTextNormal
collapseDemonCards()
func _on_noDemonClicked():
%DemonHeaderLabel.text = buttonTextNormal
expand = false
#button.queue_free()
button.hide()
reset_size()
Data.pickDemon = false
RpcCalls.pickedDemonForCombat.rpc_id(Connection.host, 0)
func _on_mouse_exited():
#return
if hovering and not expand:
hovering = false
tw1 = get_tree().create_tween()
tw1.set_trans(Tween.TRANS_QUAD)
tw1.set_ease(Tween.EASE_IN_OUT)
tw1.parallel().tween_property(self, "position", startPosition - Vector2(0, 550), 0.2)
func _on_collapse_button_pressed():
if expand:
expand = false
collapse()
button_collapse.text = "Expand"
else:
expand = true
button_collapse.text = "Collapse"