From 8067575f2a6cc8481485e9184caa07cea9158bff Mon Sep 17 00:00:00 2001 From: betalars Date: Mon, 7 Apr 2025 17:26:06 +0200 Subject: [PATCH] WIP: converting card loading to hard-coded solution due to load errors --- src/dev-util/hardcoded_cards.gd | 34 +++++++ src/dev-util/hardcoded_cards.gd.uid | 1 + .../board/card-textures/card-sprites.tres | 46 ++++++++++ src/logic-scenes/board/card.gd | 21 +++-- src/logic-scenes/board/card.tscn | 55 ++---------- src/logic-scenes/board/sticky-note.gd | 9 ++ src/logic-scenes/board/sticky-note.tscn | 89 ++++++++++--------- 7 files changed, 158 insertions(+), 97 deletions(-) create mode 100644 src/dev-util/hardcoded_cards.gd create mode 100644 src/dev-util/hardcoded_cards.gd.uid create mode 100644 src/logic-scenes/board/card-textures/card-sprites.tres diff --git a/src/dev-util/hardcoded_cards.gd b/src/dev-util/hardcoded_cards.gd new file mode 100644 index 0000000..80612cf --- /dev/null +++ b/src/dev-util/hardcoded_cards.gd @@ -0,0 +1,34 @@ +class_name HardCards extends Node + +static var all_cards: Array[Dictionary] = [ + { + "out-of-world": ["unique", "few_friends", []], + "rejection": ["finding_friends", "laughed", []], + "confusion": ["inner_conflict", "outer_conflict", []] + }, + { + "homework": ["good_grades", "upset_teachers", []], + "teachers": ["volunteering", "becoming_teacher", []], + "joy": ["worried_mother", "thomas_gifted", []] + }, + { + "comic_heroes": ["effort", "thomas_gifted", []], + "boy_stuff": ["pretending", "girls", []], + "teasing": ["stubborn", "good_intended", []] + }, + { + "jui_jutsu": ["body", "girly", []], + "void": ["wet", "stop", []], + "hit": ["confidence", "vent", []] + }, +] + + +static func get_cards_by_scene_id(id: int) -> Array: + var output:Array + + for card_name in all_cards[id].keys(): + var card_id:StringName = "%d.%s" % [id, card_name] + output.append(Card.new(card_name, card_id)) + + return output diff --git a/src/dev-util/hardcoded_cards.gd.uid b/src/dev-util/hardcoded_cards.gd.uid new file mode 100644 index 0000000..2b4cc33 --- /dev/null +++ b/src/dev-util/hardcoded_cards.gd.uid @@ -0,0 +1 @@ +uid://dysgoaaesqjbg diff --git a/src/logic-scenes/board/card-textures/card-sprites.tres b/src/logic-scenes/board/card-textures/card-sprites.tres new file mode 100644 index 0000000..cf77ff4 --- /dev/null +++ b/src/logic-scenes/board/card-textures/card-sprites.tres @@ -0,0 +1,46 @@ +[gd_resource type="SpriteFrames" load_steps=7 format=3 uid="uid://db35k2lntld0o"] + +[ext_resource type="Texture2D" uid="uid://sv0nhkkur1tt" path="res://logic-scenes/board/card-textures/cardsheet.png" id="1_l4v2i"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_ykk13"] +atlas = ExtResource("1_l4v2i") +region = Rect2(0, 0, 600, 440) + +[sub_resource type="AtlasTexture" id="AtlasTexture_l43eo"] +atlas = ExtResource("1_l4v2i") +region = Rect2(600, 0, 600, 440) + +[sub_resource type="AtlasTexture" id="AtlasTexture_x2vcn"] +atlas = ExtResource("1_l4v2i") +region = Rect2(0, 440, 600, 440) + +[sub_resource type="AtlasTexture" id="AtlasTexture_e7401"] +atlas = ExtResource("1_l4v2i") +region = Rect2(600, 440, 600, 440) + +[sub_resource type="AtlasTexture" id="AtlasTexture_j7wh6"] +atlas = ExtResource("1_l4v2i") +region = Rect2(0, 880, 600, 440) + +[resource] +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 +}] diff --git a/src/logic-scenes/board/card.gd b/src/logic-scenes/board/card.gd index ee0ac13..cc46608 100644 --- a/src/logic-scenes/board/card.gd +++ b/src/logic-scenes/board/card.gd @@ -1,6 +1,10 @@ @tool extends Area2D class_name Card + +var card_id + +#FIXME remove this legacy stuff without loosing the evil notes ... var compatible_sticky_notes: Array[StickyNote] = [] @export var evil_sticky_notes: Array[StickyNote] = [] var own_sticky_notes: Array[StickyNote] = [] @@ -74,6 +78,12 @@ var is_dragged: bool = false: var is_mouse_entered: bool = false var mouse_offset: Vector2 +func _init(card_name: String = "card", own_id:StringName = "-1") -> void: + text = card_name + card_id = own_id + name = "c_%s" % card_name + + func _ready(): input_event.connect(_on_input_event) @@ -97,13 +107,13 @@ func _ready(): %BackgroundSprite.frame = text.hash() % %BackgroundSprite.sprite_frames.get_frame_count(%BackgroundSprite.animation) $Label.text = self.text - #$Label.theme = State.current_main_theme - #State.theme_changed.connect(func change_theme(new_theme): $Label.theme = new_theme) + $Label.theme = State.current_main_theme + State.theme_changed.connect(func change_theme(new_theme): $Label.theme = new_theme) wiggle_pos = float(text.hash() % 100) if not Engine.is_editor_hint(): _handle_wiggle(0) - + if text == "": become_void() @@ -205,9 +215,8 @@ func attach_sticky_note(sticky_note: StickyNote) -> bool: sticky_note.attached_to = self if name == "c_hit" and sticky_note.name == "p_effort": - #Steam.setAchievement("FIGHT_FOR_GOOD") - #Steam.storeStats() - pass + Steam.setAchievement("FIGHT_FOR_GOOD") + Steam.storeStats() return true diff --git a/src/logic-scenes/board/card.tscn b/src/logic-scenes/board/card.tscn index 965f760..52d1cf1 100644 --- a/src/logic-scenes/board/card.tscn +++ b/src/logic-scenes/board/card.tscn @@ -1,60 +1,19 @@ -[gd_scene load_steps=10 format=3 uid="uid://dy5rd437h5hsw"] +[gd_scene load_steps=5 format=3 uid="uid://dy5rd437h5hsw"] -[ext_resource type="Script" uid="uid://2loic2eeec5b" 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="Script" uid="uid://wv72dum1fe72" path="res://logic-scenes/board/card.gd" id="1_emip0"] +[ext_resource type="SpriteFrames" uid="uid://db35k2lntld0o" path="res://logic-scenes/board/card-textures/card-sprites.tres" id="2_mdi7r"] +[ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/handwriting.theme" id="3_1x4uh"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_foovg"] radius = 110.0 height = 336.0 -[sub_resource type="AtlasTexture" id="AtlasTexture_mdi7r"] -atlas = ExtResource("2_ioijn") -region = Rect2(0, 0, 600, 440) - -[sub_resource type="AtlasTexture" id="AtlasTexture_e1q5p"] -atlas = ExtResource("2_ioijn") -region = Rect2(600, 0, 600, 440) - -[sub_resource type="AtlasTexture" id="AtlasTexture_nu76f"] -atlas = ExtResource("2_ioijn") -region = Rect2(0, 440, 600, 440) - -[sub_resource type="AtlasTexture" id="AtlasTexture_es87b"] -atlas = ExtResource("2_ioijn") -region = Rect2(600, 440, 600, 440) - -[sub_resource type="AtlasTexture" id="AtlasTexture_7bi75"] -atlas = ExtResource("2_ioijn") -region = Rect2(0, 880, 600, 440) - -[sub_resource type="SpriteFrames" id="SpriteFrames_hkrkt"] -animations = [{ -"frames": [{ -"duration": 1.0, -"texture": SubResource("AtlasTexture_mdi7r") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_e1q5p") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_nu76f") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_es87b") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_7bi75") -}], -"loop": true, -"name": &"default", -"speed": 5.0 -}] - [node name="card" type="Area2D"] script = ExtResource("1_emip0") metadata/type = "card" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(-0.0713516, 0.997451) rotation = 1.5708 shape = SubResource("CapsuleShape2D_foovg") @@ -62,7 +21,7 @@ shape = SubResource("CapsuleShape2D_foovg") unique_name_in_owner = true clip_children = 2 scale = Vector2(0.6, 0.6) -sprite_frames = SubResource("SpriteFrames_hkrkt") +sprite_frames = ExtResource("2_mdi7r") frame = 1 [node name="Label" type="Label" parent="."] @@ -78,6 +37,8 @@ offset_bottom = 88.0 grow_horizontal = 2 grow_vertical = 2 rotation = 0.00872665 +theme = ExtResource("3_1x4uh") +theme_type_variation = &"card_text" autowrap_mode = 3 [node name="StickyNoteAncor" type="Node2D" parent="."] diff --git a/src/logic-scenes/board/sticky-note.gd b/src/logic-scenes/board/sticky-note.gd index ee07bad..e5fb0c0 100644 --- a/src/logic-scenes/board/sticky-note.gd +++ b/src/logic-scenes/board/sticky-note.gd @@ -2,6 +2,10 @@ extends Area2D class_name StickyNote + +var sticky_id +var parent_id + var sibling: StickyNote var shift_tween: Tween var modulate_tween: Tween @@ -69,6 +73,11 @@ var mouse_diff: Vector2 @export_range(1.0, 10.0) var bounce_speed: float = 8 var on_board: bool = false +func _init(sticky_name: String = "card", card_id: StringName = "-1", own_id:StringName = "-1") -> void: + text = sticky_name + parent_id = card_id + sticky_id = own_id + func _ready() -> void: input_event.connect(_on_input_event) diff --git a/src/logic-scenes/board/sticky-note.tscn b/src/logic-scenes/board/sticky-note.tscn index 926f835..a729e46 100644 --- a/src/logic-scenes/board/sticky-note.tscn +++ b/src/logic-scenes/board/sticky-note.tscn @@ -8,92 +8,92 @@ radius = 48.0 height = 312.0 -[sub_resource type="AtlasTexture" id="AtlasTexture_260t4"] +[sub_resource type="AtlasTexture" id="AtlasTexture_nj16s"] atlas = ExtResource("2_j17jn") region = Rect2(0, 0, 500, 220) -[sub_resource type="AtlasTexture" id="AtlasTexture_1dusx"] +[sub_resource type="AtlasTexture" id="AtlasTexture_23tiq"] atlas = ExtResource("2_j17jn") region = Rect2(500, 0, 500, 220) -[sub_resource type="AtlasTexture" id="AtlasTexture_3dfo6"] -atlas = ExtResource("2_j17jn") -region = Rect2(0, 220, 500, 220) - -[sub_resource type="AtlasTexture" id="AtlasTexture_ltrdw"] -atlas = ExtResource("2_j17jn") -region = Rect2(500, 220, 500, 220) - -[sub_resource type="AtlasTexture" id="AtlasTexture_spwka"] -atlas = ExtResource("2_j17jn") -region = Rect2(0, 440, 500, 220) - -[sub_resource type="AtlasTexture" id="AtlasTexture_62rvp"] -atlas = ExtResource("2_j17jn") -region = Rect2(500, 440, 500, 220) - -[sub_resource type="AtlasTexture" id="AtlasTexture_v1axh"] -atlas = ExtResource("2_j17jn") -region = Rect2(1000, 440, 500, 220) - -[sub_resource type="AtlasTexture" id="AtlasTexture_5ria3"] -atlas = ExtResource("2_j17jn") -region = Rect2(1000, 220, 500, 220) - -[sub_resource type="AtlasTexture" id="AtlasTexture_7ii0f"] +[sub_resource type="AtlasTexture" id="AtlasTexture_aomh0"] atlas = ExtResource("2_j17jn") region = Rect2(1000, 0, 500, 220) -[sub_resource type="AtlasTexture" id="AtlasTexture_7upwc"] +[sub_resource type="AtlasTexture" id="AtlasTexture_n3svg"] atlas = ExtResource("2_j17jn") region = Rect2(1500, 0, 500, 220) -[sub_resource type="AtlasTexture" id="AtlasTexture_drssb"] +[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_anws8"] +[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_5scpe"] +[sub_resource type="SpriteFrames" id="SpriteFrames_2amsi"] animations = [{ "frames": [{ "duration": 1.0, -"texture": SubResource("AtlasTexture_260t4") +"texture": SubResource("AtlasTexture_nj16s") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_1dusx") +"texture": SubResource("AtlasTexture_23tiq") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_3dfo6") +"texture": SubResource("AtlasTexture_aomh0") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_ltrdw") +"texture": SubResource("AtlasTexture_n3svg") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_spwka") +"texture": SubResource("AtlasTexture_tfg7a") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_62rvp") +"texture": SubResource("AtlasTexture_dtics") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_v1axh") +"texture": SubResource("AtlasTexture_e0ocs") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_5ria3") +"texture": SubResource("AtlasTexture_bpwg2") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_7ii0f") +"texture": SubResource("AtlasTexture_xaxol") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_7upwc") +"texture": SubResource("AtlasTexture_ifitb") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_drssb") +"texture": SubResource("AtlasTexture_6slhe") }, { "duration": 1.0, -"texture": SubResource("AtlasTexture_anws8") +"texture": SubResource("AtlasTexture_4tk5m") }], "loop": true, "name": &"default", @@ -115,7 +115,8 @@ shape = SubResource("CapsuleShape2D_ml4q7") [node name="BackgroundSprite" type="AnimatedSprite2D" parent="Content"] position = Vector2(99.5, 0) scale = Vector2(0.65, 0.65) -sprite_frames = SubResource("SpriteFrames_5scpe") +sprite_frames = SubResource("SpriteFrames_2amsi") +frame = 5 [node name="Label" type="Label" parent="Content"] anchors_preset = 8