Merge commit '83da4b0f1f490382f9232a380b98546bc6e8e043' into card-board-recovery

This commit is contained in:
betalars 2023-06-30 01:28:19 +02:00
commit 21193534b2
4 changed files with 119 additions and 43 deletions

View File

@ -1,9 +1,14 @@
@tool @tool
extends Control extends Area2D
class_name Card class_name Card
var compatible_postits: Array[PostIt] = [] var compatible_postits: Array[PostIt] = []
var own_postits: Array[PostIt] = [] var own_postits: Array[PostIt] = []
var wiggle_pos: float = randf_range(-100, 100)
var wiggle_intensity: float = 0
var noise: Noise = FastNoiseLite.new()
var wiggle_tween
var scale_tween
@export var text: String = "" : @export var text: String = "" :
set (value): set (value):
@ -13,9 +18,39 @@ var own_postits: Array[PostIt] = []
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation) $BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
if is_inside_tree(): if is_inside_tree():
$BackgroundSprite.void_active = value == "" $BackgroundSprite.void_active = value == ""
@export var wiggle_strength: float = 0.2
@export var wiggle_speed: float = 5
@export_range(1, 2) var scale_bump: float = 1.05
@export var highlighted: bool = false:
set(highlight):
if highlight != highlighted:
highlighted = highlight
if is_inside_tree() and is_node_ready():
if scale_tween: scale_tween.kill()
if wiggle_tween: wiggle_tween.kill()
if highlighted:
scale_tween = get_tree().create_tween()
scale_tween.tween_property(self, "scale", Vector2(scale_bump, scale_bump), 0.1)
wiggle_tween = get_tree().create_tween()
wiggle_tween.tween_property(self, "wiggle_intensity", 1, 0.2)
else:
scale_tween = get_tree().create_tween()
scale_tween.tween_property(self, "scale", Vector2(1, 1), 0.3)
wiggle_tween = get_tree().create_tween()
wiggle_tween.tween_property(self, "wiggle_intensity", 0, 0.5)
else:
if highlighted:
scale = Vector2(scale_bump, scale_bump)
wiggle_intensity = 1
else:
scale = Vector2(1,1)
wiggle_intensity = 0
@export var voice_line: AudioStream = null @export var voice_line: AudioStream = null
func _ready(): func _ready():
_handle_wiggle(0)
if not Engine.is_editor_hint() and is_inside_tree(): if not Engine.is_editor_hint() and is_inside_tree():
for postit in self.get_children(): for postit in self.get_children():
if postit is PostIt: self.own_postits.append(postit as PostIt) if postit is PostIt: self.own_postits.append(postit as PostIt)
@ -33,7 +68,14 @@ func _ready():
$Label.text = self.text $Label.text = self.text
func _process(delta: float) -> void: func _process(delta: float) -> void:
pass
if highlighted:
_handle_wiggle(delta)
func _handle_wiggle(delta):
wiggle_pos += delta * wiggle_speed * wiggle_intensity
rotation = noise.get_noise_1d(wiggle_pos)*wiggle_strength
func replace_with(card: Card): func replace_with(card: Card):
self.text = card.text self.text = card.text

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=3 uid="uid://dy5rd437h5hsw"] [gd_scene load_steps=21 format=3 uid="uid://dy5rd437h5hsw"]
[ext_resource type="Script" path="res://logic-scenes/board/card.gd" id="1_emip0"] [ext_resource type="Script" path="res://logic-scenes/board/card.gd" id="1_emip0"]
[ext_resource type="Texture2D" uid="uid://sv0nhkkur1tt" path="res://logic-scenes/board/card-textures/cardsheet.png" id="2_ioijn"] [ext_resource type="Texture2D" uid="uid://sv0nhkkur1tt" path="res://logic-scenes/board/card-textures/cardsheet.png" id="2_ioijn"]
@ -141,23 +141,19 @@ func _process(_delta):
self.visible = State.reduce_motion and is_void self.visible = State.reduce_motion and is_void
" "
[node name="card" type="Control"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_foovg"]
custom_minimum_size = Vector2(310, 210) radius = 110.0
layout_mode = 3 height = 336.0
anchors_preset = 0
offset_left = -150.0 [node name="card" type="Area2D"]
offset_top = -110.0 rotation = 0.197177
offset_right = 160.0
offset_bottom = 100.0
focus_mode = 2
script = ExtResource("1_emip0") script = ExtResource("1_emip0")
[node name="BackgroundSprite" type="AnimatedSprite2D" parent="."] [node name="BackgroundSprite" type="AnimatedSprite2D" parent="."]
clip_children = 2 clip_children = 2
position = Vector2(150, 110)
scale = Vector2(0.6, 0.6) scale = Vector2(0.6, 0.6)
sprite_frames = SubResource("SpriteFrames_ckivt") sprite_frames = SubResource("SpriteFrames_ckivt")
frame = 4 frame = 3
script = SubResource("GDScript_8bs16") script = SubResource("GDScript_8bs16")
[node name="GPUParticles2D" type="GPUParticles2D" parent="BackgroundSprite"] [node name="GPUParticles2D" type="GPUParticles2D" parent="BackgroundSprite"]
@ -179,7 +175,6 @@ texture = ExtResource("4_fwm1k")
script = SubResource("GDScript_tgc0b") script = SubResource("GDScript_tgc0b")
[node name="Label" type="Label" parent="."] [node name="Label" type="Label" parent="."]
layout_mode = 1
anchors_preset = 8 anchors_preset = 8
anchor_left = 0.5 anchor_left = 0.5
anchor_top = 0.5 anchor_top = 0.5
@ -196,12 +191,13 @@ theme_type_variation = &"card_text"
autowrap_mode = 3 autowrap_mode = 3
[node name="postit anchor" type="Control" parent="."] [node name="postit anchor" type="Control" parent="."]
layout_mode = 3
anchors_preset = 0 anchors_preset = 0
offset_left = 100.0 offset_left = 100.0
offset_top = 148.0 offset_top = 148.0
offset_right = 140.0 offset_right = 140.0
offset_bottom = 188.0 offset_bottom = 188.0
[connection signal="focus_entered" from="." to="." method="_on_focus_entered"] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
[connection signal="focus_exited" from="." to="." method="_on_focus_exited"] rotation = 1.5708
[connection signal="focus_entered" from="postit anchor" to="." method="_on_postit_anchor_focus_entered"] shape = SubResource("CapsuleShape2D_foovg")

View File

@ -1,20 +1,55 @@
@tool @tool
extends Control extends Area2D
class_name PostIt class_name PostIt
var sibling var sibling
var wiggle_pos: float = randf_range(-100, 100)
var wiggle_intensity: float = 0
var noise: Noise = FastNoiseLite.new()
var shift_tween
var modulate_tween
@export var text: String = "" : @export var text: String = "" :
set (value): set (value):
if is_inside_tree() or Engine.is_editor_hint(): if is_inside_tree() or Engine.is_editor_hint():
$Label.text = value $Content/Label.text = value
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation) $Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)
text = value text = value
@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
@export var voice_line: AudioStream = null @export var voice_line: AudioStream = null
func _ready() -> void: func _ready() -> void:
$Label.text = self.text $Content/Label.text = self.text
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation) $Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)
func replace_with(postit: PostIt): func replace_with(postit: PostIt):
self.text = postit.text self.text = postit.text

View File

@ -1,9 +1,13 @@
[gd_scene load_steps=17 format=3 uid="uid://vkcdj8c3ytbq"] [gd_scene load_steps=18 format=3 uid="uid://vkcdj8c3ytbq"]
[ext_resource type="Script" path="res://logic-scenes/board/post-it.gd" id="1_yvh5n"] [ext_resource type="Script" path="res://logic-scenes/board/post-it.gd" id="1_yvh5n"]
[ext_resource type="Texture2D" uid="uid://c8ckkjmdegyis" path="res://logic-scenes/board/card-textures/postitsheet.png" id="2_j17jn"] [ext_resource type="Texture2D" uid="uid://c8ckkjmdegyis" path="res://logic-scenes/board/card-textures/postitsheet.png" id="2_j17jn"]
[ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/messy.theme" id="3_hu2as"] [ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/messy.theme" id="3_hu2as"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ml4q7"]
radius = 48.0
height = 312.0
[sub_resource type="AtlasTexture" id="AtlasTexture_nj16s"] [sub_resource type="AtlasTexture" id="AtlasTexture_nj16s"]
atlas = ExtResource("2_j17jn") atlas = ExtResource("2_j17jn")
region = Rect2(0, 0, 500, 220) region = Rect2(0, 0, 500, 220)
@ -96,39 +100,38 @@ animations = [{
"speed": 5.0 "speed": 5.0
}] }]
[node name="post-it" type="Control"] [node name="post-it" type="Area2D"]
layout_mode = 3
anchors_preset = 0
offset_left = -150.0
offset_top = -50.0
offset_right = 150.0
offset_bottom = 50.0
focus_mode = 2
script = ExtResource("1_yvh5n") script = ExtResource("1_yvh5n")
text = "Test"
highlight_color = Color(1.2, 1.2, 1.2, 1)
[node name="BackgroundSprite" type="AnimatedSprite2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(150, 50) position = Vector2(99.5, 0)
rotation = 1.5708
shape = SubResource("CapsuleShape2D_ml4q7")
[node name="Content" type="Node2D" parent="."]
[node name="BackgroundSprite" type="AnimatedSprite2D" parent="Content"]
position = Vector2(99.5, 0)
scale = Vector2(0.65, 0.65) scale = Vector2(0.65, 0.65)
sprite_frames = SubResource("SpriteFrames_2amsi") sprite_frames = SubResource("SpriteFrames_2amsi")
frame = 5 frame = 1
[node name="Label" type="Label" parent="."] [node name="Label" type="Label" parent="Content"]
layout_mode = 1
anchors_preset = 8 anchors_preset = 8
anchor_left = 0.5 anchor_left = 0.5
anchor_top = 0.5 anchor_top = 0.5
anchor_right = 0.5 anchor_right = 0.5
anchor_bottom = 0.5 anchor_bottom = 0.5
offset_left = -139.5 offset_left = -38.0
offset_top = -50.0 offset_top = -50.0
offset_right = 137.5 offset_right = 239.0
offset_bottom = 47.0 offset_bottom = 47.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme = ExtResource("3_hu2as") theme = ExtResource("3_hu2as")
theme_type_variation = &"card_text" theme_type_variation = &"card_text"
text = "Test"
vertical_alignment = 1 vertical_alignment = 1
autowrap_mode = 3 autowrap_mode = 3
[connection signal="focus_entered" from="." to="." method="_on_focus_entered"]
[connection signal="focus_exited" from="." to="." method="_on_focus_exited"]