2023-04-19 16:53:24 +00:00
|
|
|
@tool
|
|
|
|
|
|
|
|
|
|
extends Control
|
|
|
|
|
class_name Card
|
2023-05-27 23:43:52 +00:00
|
|
|
var compatible_postits: Array[PostIt] = []
|
|
|
|
|
var own_postits: Array[PostIt] = []
|
2023-04-19 16:53:24 +00:00
|
|
|
|
|
|
|
|
@export var text: String = "" :
|
|
|
|
|
set (value):
|
2023-05-28 14:18:26 +00:00
|
|
|
text = value
|
2023-04-19 16:53:24 +00:00
|
|
|
if is_inside_tree() or Engine.is_editor_hint():
|
|
|
|
|
$Label.text = value
|
2023-05-28 13:21:19 +00:00
|
|
|
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
2023-05-28 14:18:26 +00:00
|
|
|
if is_inside_tree():
|
|
|
|
|
$BackgroundSprite.void_active = value == ""
|
2023-04-19 16:53:24 +00:00
|
|
|
@export var voice_line: AudioStream = null
|
|
|
|
|
|
2023-05-28 13:21:19 +00:00
|
|
|
func _ready():
|
2023-04-19 16:53:24 +00:00
|
|
|
if not Engine.is_editor_hint() and is_inside_tree():
|
2023-05-28 10:38:46 +00:00
|
|
|
for postit in self.get_children():
|
|
|
|
|
if postit is PostIt: self.own_postits.append(postit as PostIt)
|
|
|
|
|
|
|
|
|
|
for postit in get_tree().get_nodes_in_group(name):
|
|
|
|
|
if postit is PostIt: self.compatible_postits.append(postit as PostIt)
|
|
|
|
|
|
|
|
|
|
compatible_postits.append_array(own_postits)
|
|
|
|
|
|
2023-05-28 13:21:19 +00:00
|
|
|
if own_postits.size() == 2:
|
|
|
|
|
own_postits[0].sibling = own_postits[1]
|
|
|
|
|
own_postits[1].sibling = own_postits[0]
|
|
|
|
|
|
2023-05-18 07:27:59 +00:00
|
|
|
$BackgroundSprite.frame = randi() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
2023-04-19 16:53:24 +00:00
|
|
|
$Label.text = self.text
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> void:
|
|
|
|
|
pass
|
|
|
|
|
|
2023-05-28 13:21:19 +00:00
|
|
|
func replace_with(card: Card):
|
|
|
|
|
self.text = card.text
|
|
|
|
|
self.compatible_postits = card.compatible_postits
|
|
|
|
|
self.own_postits = card.own_postits
|
|
|
|
|
self.voice_line = card.voice_line
|
|
|
|
|
|
2023-04-19 16:53:24 +00:00
|
|
|
func _on_focus_entered():
|
|
|
|
|
print(self, "is focused")
|
|
|
|
|
|
|
|
|
|
func _on_focus_exited():
|
|
|
|
|
print(self, "is not focused")
|