2023-09-23 14:19:58 +00:00
|
|
|
class_name PostItPanel
|
|
|
|
|
extends Panel
|
|
|
|
|
|
|
|
|
|
var stored_costum_minimum_size:Vector2
|
|
|
|
|
var attatched_postIt: PostIt
|
|
|
|
|
@onready var ancor = $"post-it_anchor"
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
|
stored_costum_minimum_size = custom_minimum_size
|
|
|
|
|
ancor.position = Vector2(ancor.position.x, 0)
|
|
|
|
|
custom_minimum_size = Vector2(custom_minimum_size.x, 0)
|
|
|
|
|
|
|
|
|
|
func attatch_postit(attatchment: PostIt, tween:bool = true):
|
|
|
|
|
attatchment.on_board = false
|
|
|
|
|
if tween:
|
|
|
|
|
var height_tween: Tween = create_tween()
|
|
|
|
|
height_tween.tween_property(self, "custom_minimum_size", stored_costum_minimum_size, 0.3)
|
|
|
|
|
height_tween.tween_property(ancor, "position", Vector2(ancor.position.x, stored_costum_minimum_size.y/2), 0.3)
|
|
|
|
|
attatchment.tween_transform_to(ancor.global_position)
|
|
|
|
|
await attatchment.transform_tween_finished
|
|
|
|
|
attatchment.reparent(self)
|
|
|
|
|
attatched_postIt = attatchment
|
|
|
|
|
attatchment.owner = self.owner
|
2023-09-24 10:23:26 +00:00
|
|
|
attatchment.attatched_to = self
|
2023-09-23 14:19:58 +00:00
|
|
|
|
2023-09-24 10:23:26 +00:00
|
|
|
func reclaim_postit():
|
|
|
|
|
if is_empty():
|
|
|
|
|
attatched_postIt.on_board = false
|
|
|
|
|
attatched_postIt.tween_transform_to(ancor.global_position)
|
|
|
|
|
await attatched_postIt.transform_tween_finished
|
|
|
|
|
attatched_postIt.reparent(self)
|
|
|
|
|
attatched_postIt.owner = self.owner
|
|
|
|
|
|
2023-09-23 14:19:58 +00:00
|
|
|
func dissolve():
|
2023-09-24 10:23:26 +00:00
|
|
|
if attatched_postIt.attatched_to == self: attatched_postIt.attatched_to = null
|
2023-09-23 14:19:58 +00:00
|
|
|
var height_tween: Tween = create_tween()
|
|
|
|
|
height_tween.tween_property(self, "custom_minimum_size", Vector2.ZERO, 0.3)
|
|
|
|
|
await height_tween.finished
|
|
|
|
|
self.free()
|
2023-09-24 10:23:26 +00:00
|
|
|
|
|
|
|
|
func replace_postit_with(new_postit: PostIt):
|
|
|
|
|
if is_empty():
|
|
|
|
|
attatched_postIt = new_postit
|
|
|
|
|
|
|
|
|
|
func is_empty():
|
|
|
|
|
return ancor.get_child_count() == 0
|