theming cards and randomising card backgrounds

This commit is contained in:
betalars 2023-05-18 09:27:59 +02:00
parent 59aadd00a4
commit 12d6717736
4 changed files with 188 additions and 48 deletions

View File

@ -15,7 +15,7 @@ func _ready():
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(false): for postit in self.get_children(false):
self.compatible_postits.append(postit as PostIt) self.compatible_postits.append(postit as PostIt)
$BackgroundSprite.frame = randi() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
$Label.text = self.text $Label.text = self.text
func _process(delta: float) -> void: func _process(delta: float) -> void:

View File

@ -1,42 +1,84 @@
[gd_scene load_steps=5 format=3 uid="uid://dy5rd437h5hsw"] [gd_scene load_steps=10 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://ccncau1yfqyuf" path="res://logic-scenes/board/cardsheet.png" id="2_x4r1c"] [ext_resource type="Texture2D" uid="uid://sv0nhkkur1tt" path="res://logic-scenes/board/card-textures/cardsheet.png" id="2_ioijn"]
[ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/messy.theme" id="3_rktsa"] [ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/messy.theme" id="3_rktsa"]
[sub_resource type="AtlasTexture" id="AtlasTexture_olf16"] [sub_resource type="AtlasTexture" id="AtlasTexture_ykk13"]
atlas = ExtResource("2_x4r1c") atlas = ExtResource("2_ioijn")
region = Rect2(49, 472.5, 528, 366) region = Rect2(0, 0, 600, 440)
[sub_resource type="AtlasTexture" id="AtlasTexture_l43eo"]
atlas = ExtResource("2_ioijn")
region = Rect2(600, 0, 600, 440)
[sub_resource type="AtlasTexture" id="AtlasTexture_x2vcn"]
atlas = ExtResource("2_ioijn")
region = Rect2(0, 440, 600, 440)
[sub_resource type="AtlasTexture" id="AtlasTexture_e7401"]
atlas = ExtResource("2_ioijn")
region = Rect2(600, 440, 600, 440)
[sub_resource type="AtlasTexture" id="AtlasTexture_j7wh6"]
atlas = ExtResource("2_ioijn")
region = Rect2(0, 880, 600, 440)
[sub_resource type="SpriteFrames" id="SpriteFrames_ckivt"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ykk13")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_l43eo")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_x2vcn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_e7401")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_j7wh6")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="card" type="Control"] [node name="card" type="Control"]
layout_mode = 3 layout_mode = 3
anchor_right = 0.179 anchors_preset = 0
anchor_bottom = 0.239 offset_left = -150.0
offset_right = 0.23999 offset_top = -110.0
offset_bottom = -0.119995 offset_right = 150.0
grow_horizontal = 2 offset_bottom = 110.0
grow_vertical = 2
focus_mode = 2 focus_mode = 2
script = ExtResource("1_emip0") script = ExtResource("1_emip0")
compatible_postits = Array[Resource("res://logic-scenes/board/post-it.gd")]([null, null, null]) compatible_postits = Array[Resource("res://logic-scenes/board/post-it.gd")]([null, null, null])
[node name="TextureRect" type="TextureRect" parent="."] [node name="BackgroundSprite" type="AnimatedSprite2D" parent="."]
layout_mode = 0 position = Vector2(150, 110)
offset_right = 528.0
offset_bottom = 366.0
scale = Vector2(0.6, 0.6) scale = Vector2(0.6, 0.6)
texture = SubResource("AtlasTexture_olf16") sprite_frames = SubResource("SpriteFrames_ckivt")
frame_progress = 0.407616
[node name="Label" type="Label" parent="."] [node name="Label" type="Label" parent="."]
layout_mode = 0 layout_mode = 1
offset_left = 22.0 anchors_preset = 8
offset_top = 35.0 anchor_left = 0.5
offset_right = 298.0 anchor_top = 0.5
offset_bottom = 215.0 anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -127.0
offset_top = -82.5
offset_right = 127.0
offset_bottom = 82.5
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("3_rktsa") theme = ExtResource("3_rktsa")
theme_type_variation = &"card_text" theme_type_variation = &"card_text"
text = "this is a test
with a second line"
autowrap_mode = 3 autowrap_mode = 3
[node name="postit anchor" type="Control" parent="."] [node name="postit anchor" type="Control" parent="."]

View File

@ -7,11 +7,13 @@ class_name PostIt
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 $Label.text = value
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
text = value text = value
@export var voice_line: AudioStream = null @export var voice_line: AudioStream = null
func _ready() -> void: func _ready() -> void:
$Label.text = self.text $Label.text = self.text
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
func _process(delta: float) -> void: func _process(delta: float) -> void:
pass pass

View File

@ -1,38 +1,134 @@
[gd_scene load_steps=4 format=3 uid="uid://vkcdj8c3ytbq"] [gd_scene load_steps=17 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://dq7jm5ufknbb6" path="res://vfx/lens-flare-particle.png" id="2_jr288"] [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"]
[sub_resource type="LabelSettings" id="LabelSettings_vm4x4"] [sub_resource type="AtlasTexture" id="AtlasTexture_nj16s"]
font_size = 30 atlas = ExtResource("2_j17jn")
outline_size = 10 region = Rect2(0, 0, 500, 220)
outline_color = Color(0, 0, 0, 1)
[sub_resource type="AtlasTexture" id="AtlasTexture_23tiq"]
atlas = ExtResource("2_j17jn")
region = Rect2(500, 0, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_aomh0"]
atlas = ExtResource("2_j17jn")
region = Rect2(1000, 0, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_n3svg"]
atlas = ExtResource("2_j17jn")
region = Rect2(1500, 0, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_tfg7a"]
atlas = ExtResource("2_j17jn")
region = Rect2(0, 220, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_dtics"]
atlas = ExtResource("2_j17jn")
region = Rect2(500, 220, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_e0ocs"]
atlas = ExtResource("2_j17jn")
region = Rect2(1000, 220, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_bpwg2"]
atlas = ExtResource("2_j17jn")
region = Rect2(1500, 220, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_xaxol"]
atlas = ExtResource("2_j17jn")
region = Rect2(0, 440, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_ifitb"]
atlas = ExtResource("2_j17jn")
region = Rect2(500, 440, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_6slhe"]
atlas = ExtResource("2_j17jn")
region = Rect2(1000, 440, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_4tk5m"]
atlas = ExtResource("2_j17jn")
region = Rect2(1500, 440, 500, 220)
[sub_resource type="SpriteFrames" id="SpriteFrames_2amsi"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_nj16s")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_23tiq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_aomh0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_n3svg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_tfg7a")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dtics")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_e0ocs")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bpwg2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xaxol")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ifitb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_6slhe")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_4tk5m")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="post-it" type="Control"] [node name="post-it" type="Control"]
layout_mode = 3 layout_mode = 3
anchor_right = 0.187 anchors_preset = 0
anchor_bottom = 0.239 offset_left = -150.0
offset_right = -124.28 offset_top = -50.0
offset_bottom = -100.12 offset_right = 150.0
grow_horizontal = 2 offset_bottom = 50.0
grow_vertical = 2
focus_mode = 2 focus_mode = 2
script = ExtResource("1_yvh5n") script = ExtResource("1_yvh5n")
[node name="TextureRect" type="TextureRect" parent="."] [node name="BackgroundSprite" type="AnimatedSprite2D" parent="."]
layout_mode = 0 position = Vector2(150, 50)
offset_right = 135.0 scale = Vector2(0.65, 0.65)
offset_bottom = 138.0 sprite_frames = SubResource("SpriteFrames_2amsi")
texture = ExtResource("2_jr288") frame_progress = 0.366837
[node name="Label" type="Label" parent="."] [node name="Label" type="Label" parent="."]
layout_mode = 0 layout_mode = 1
offset_left = 6.0 anchors_preset = 8
offset_top = 7.0 anchor_left = 0.5
offset_right = 131.0 anchor_top = 0.5
offset_bottom = 134.0 anchor_right = 0.5
focus_mode = 2 anchor_bottom = 0.5
label_settings = SubResource("LabelSettings_vm4x4") offset_left = -139.5
offset_top = -50.0
offset_right = 137.5
offset_bottom = 47.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("3_hu2as")
theme_type_variation = &"card_text"
text = "Test"
vertical_alignment = 1
autowrap_mode = 3 autowrap_mode = 3
[connection signal="focus_entered" from="." to="." method="_on_focus_entered"] [connection signal="focus_entered" from="." to="." method="_on_focus_entered"]