2023-04-19 16:53:24 +00:00
|
|
|
@tool
|
|
|
|
|
|
2023-06-28 10:18:00 +00:00
|
|
|
extends Area2D
|
2023-04-19 16:53:24 +00:00
|
|
|
class_name PostIt
|
2023-05-28 13:21:19 +00:00
|
|
|
var sibling
|
2023-06-28 13:27:05 +00:00
|
|
|
var wiggle_pos: float = randf_range(-100, 100)
|
|
|
|
|
var wiggle_intensity: float = 0
|
|
|
|
|
var noise: Noise = FastNoiseLite.new()
|
|
|
|
|
var shift_tween
|
|
|
|
|
var modulate_tween
|
2023-04-19 16:53:24 +00:00
|
|
|
|
|
|
|
|
@export var text: String = "" :
|
|
|
|
|
set (value):
|
|
|
|
|
if is_inside_tree() or Engine.is_editor_hint():
|
2023-06-28 13:27:05 +00:00
|
|
|
$Content/Label.text = value
|
|
|
|
|
$Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)
|
2023-04-19 16:53:24 +00:00
|
|
|
text = value
|
2023-06-28 13:27:05 +00:00
|
|
|
|
|
|
|
|
@export var shift_by: Vector2 = Vector2(-32, 0)
|
|
|
|
|
@export_color_no_alpha var highlight_color: Color = Color(1.5, 1.5, 1.5)
|
|
|
|
|
@export var highlighted: bool = false:
|
|
|
|
|
set(highlight):
|
|
|
|
|
if highlight != highlighted:
|
|
|
|
|
highlighted = highlight
|
|
|
|
|
|
|
|
|
|
if is_inside_tree() and is_node_ready():
|
|
|
|
|
if modulate_tween: modulate_tween.kill()
|
|
|
|
|
if shift_tween: shift_tween.kill()
|
|
|
|
|
if highlighted:
|
|
|
|
|
modulate_tween = get_tree().create_tween()
|
|
|
|
|
modulate_tween.tween_property(self, "modulate", highlight_color, 0.1)
|
|
|
|
|
shift_tween = get_tree().create_tween()
|
|
|
|
|
shift_tween.tween_property($Content, "position", shift_by, 0.2)
|
|
|
|
|
else:
|
|
|
|
|
modulate_tween = get_tree().create_tween()
|
|
|
|
|
modulate_tween.tween_property(self, "modulate", Color(1, 1, 1), 0.3)
|
|
|
|
|
shift_tween = get_tree().create_tween()
|
|
|
|
|
shift_tween.tween_property($Content, "position", Vector2.ZERO, 0.5)
|
|
|
|
|
else:
|
|
|
|
|
if highlighted:
|
|
|
|
|
modulate = Color(1, 1, 1)
|
|
|
|
|
wiggle_intensity = 1
|
|
|
|
|
else:
|
|
|
|
|
modulate = Color(1, 1, 1)
|
|
|
|
|
wiggle_intensity = 0
|
|
|
|
|
|
2023-04-19 16:53:24 +00:00
|
|
|
@export var voice_line: AudioStream = null
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
2023-06-28 13:27:05 +00:00
|
|
|
$Content/Label.text = self.text
|
|
|
|
|
$Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)
|
|
|
|
|
|
2023-04-19 16:53:24 +00:00
|
|
|
|
2023-05-28 13:21:19 +00:00
|
|
|
func replace_with(postit: PostIt):
|
|
|
|
|
self.text = postit.text
|
|
|
|
|
self.voice_line = postit.voice_line
|
|
|
|
|
self.sibling = postit.sibling
|
|
|
|
|
|
2023-04-19 16:53:24 +00:00
|
|
|
func _process(delta: float) -> void:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
func _on_focus_entered():
|
|
|
|
|
print(self, "is focused")
|
|
|
|
|
|
|
|
|
|
func _on_focus_exited():
|
|
|
|
|
print(self, "is not focused")
|