tiger-cleanup #1

Merged
tiger merged 97 commits from tiger-cleanup into development 2026-01-15 14:54:23 +00:00
14 changed files with 75 additions and 62 deletions
Showing only changes of commit 899760f97b - Show all commits

View File

@ -1,6 +1,9 @@
class_name HardCards extends Control class_name HardcodedCards extends Control
static var source_dicts: Array[Dictionary] = [ @onready var card_prefab : PackedScene = preload("res://logic-scenes/board/card.tscn")
@onready var note_prefab : PackedScene = preload("res://logic-scenes/board/sticky-note.tscn")
var source_dicts: Array[Dictionary] = [
{ {
"c_out_of_world": ["p_unique", "p_few_friends", []], "c_out_of_world": ["p_unique", "p_few_friends", []],
"c_rejection": ["p_finding_friends", "p_laughed_at", []], "c_rejection": ["p_finding_friends", "p_laughed_at", []],
@ -63,13 +66,13 @@ static var source_dicts: Array[Dictionary] = [
}, },
] ]
static var id_reference: Dictionary[StringName, StringName] = generate_id_reference(true, true) var id_reference: Dictionary[StringName, StringName] = generate_id_reference(true, true)
static var card_id_reference: Dictionary[StringName, StringName] = generate_id_reference(true, false) var card_id_reference: Dictionary[StringName, StringName] = generate_id_reference(true, false)
static var sticky_id_reference: Dictionary[StringName, StringName] = generate_id_reference(false, true) var sticky_id_reference: Dictionary[StringName, StringName] = generate_id_reference(false, true)
static var obscure_reference: Dictionary[StringName, StringName] = generate_obscure_reference() var obscure_reference: Dictionary[StringName, StringName] = generate_obscure_reference()
static func generate_id_reference(include_cards: bool, include_sticky: bool) -> Dictionary[StringName, StringName]: func generate_id_reference(include_cards: bool, include_sticky: bool) -> Dictionary[StringName, StringName]:
var out:Dictionary[StringName, StringName] = {} var out:Dictionary[StringName, StringName] = {}
for id in range(source_dicts.size()): for id in range(source_dicts.size()):
@ -83,7 +86,7 @@ static func generate_id_reference(include_cards: bool, include_sticky: bool) ->
return out return out
static func generate_obscure_reference(): func generate_obscure_reference():
var out:Dictionary[StringName, StringName] = {} var out:Dictionary[StringName, StringName] = {}
randomize() randomize()
@ -100,7 +103,7 @@ static func generate_obscure_reference():
return out return out
static func get_child_names_of(parent_id: StringName) -> Array[StringName]: func get_child_names_of(parent_id: StringName) -> Array[StringName]:
var out: Array[StringName] var out: Array[StringName]
for child_name: StringName in id_reference.keys(): for child_name: StringName in id_reference.keys():
if id_reference[child_name].contains(parent_id): if id_reference[child_name].contains(parent_id):
@ -109,10 +112,10 @@ static func get_child_names_of(parent_id: StringName) -> Array[StringName]:
return out return out
#FIXME: enhance typing! #FIXME: enhance typing!
static func get_children_of(parent_id: StringName) -> Array: func get_children_of(parent_id: StringName) -> Array:
return get_cards_by_name_array(get_child_names_of(parent_id))["sticky_notes"] return get_cards_by_name_array(get_child_names_of(parent_id))["sticky_notes"]
static func get_obscure_name(card_name: StringName): func get_obscure_name(card_name: StringName):
if State.obscure_logs and not OS.is_debug_build(): if State.obscure_logs and not OS.is_debug_build():
return obscure_reference[card_name] return obscure_reference[card_name]
else: else:
@ -178,16 +181,18 @@ func is_out_of_bounds(card: Card, rect: Rect2):
return true return true
return false return false
static func get_cards_by_scene_id(id: int) -> Array: func get_cards_by_scene_id(id: int) -> Array:
var output:Array var output:Array
for card_name in source_dicts[id].keys(): for card_name in source_dicts[id].keys():
output.append(Card.new(card_name, id_reference[card_name])) var card := card_prefab.instantiate() as Card
card.init(card_name, id_reference[card_name]);
output.append(card)
return output return output
# used to put cards on the dev board # used to put cards on the dev board
static func get_cards_by_name_array(names: Array[StringName]) -> Dictionary: func get_cards_by_name_array(names: Array[StringName]) -> Dictionary:
var output:Dictionary = { var output:Dictionary = {
"cards": [], "cards": [],
"sticky_notes": [] "sticky_notes": []
@ -201,21 +206,21 @@ static func get_cards_by_name_array(names: Array[StringName]) -> Dictionary:
return output return output
static func create_from_id(id:StringName) -> Area2D: func create_from_id(id:StringName) -> Area2D:
var parsed: PackedStringArray = id.rsplit(".") var parsed: PackedStringArray = id.rsplit(".")
#var helper := card_id_reference
#var keys := card_id_reference.keys()
if card_id_reference.values().has(id): if card_id_reference.values().has(id):
return Card.new(parsed[1], id) var card := card_prefab.instantiate() as Card
card.init(parsed[1], id);
return card
elif sticky_id_reference.values().has(id): elif sticky_id_reference.values().has(id):
return StickyNote.new(parsed[2], id) var note := note_prefab.instantiate() as StickyNote
note.init(parsed[2], id)
return note
else: else:
push_error("Attempted to create Card or Sticky from non-existent ID!") push_error("Attempted to create Card or Sticky from non-existent ID!")
return null return null
static func create_dev_board(parent: Control, _rect: Rect2) -> void: func create_dev_board(parent: Control, _rect: Rect2) -> void:
var scroll_container := ScrollContainer.new() var scroll_container := ScrollContainer.new()
var panel := Panel.new() var panel := Panel.new()

View File

@ -3,9 +3,12 @@
[ext_resource type="Script" uid="uid://dysgoaaesqjbg" path="res://dev-util/hardcoded_cards.gd" id="1_5kg6w"] [ext_resource type="Script" uid="uid://dysgoaaesqjbg" path="res://dev-util/hardcoded_cards.gd" id="1_5kg6w"]
[node name="Node2D" type="PanelContainer"] [node name="Node2D" type="PanelContainer"]
process_mode = 4
visible = false
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
focus_behavior_recursive = 1
script = ExtResource("1_5kg6w") script = ExtResource("1_5kg6w")

View File

@ -45,10 +45,11 @@ var has_stage := false:
sticky.is_dragged = false sticky.is_dragged = false
visible = has_stage visible = has_stage
@onready var dropzone = $HBoxContainer/dropzone
@onready var dropzone := $HBoxContainer/dropzone
var dropzone_size: Vector2 var dropzone_size: Vector2
@export var dropzone_padding:int = 100 @export var dropzone_padding:int = 100
@onready var sticky_note_container = $HBoxContainer/ScrollContainer/VBoxContainer @onready var sticky_note_container := $HBoxContainer/ScrollContainer/VBoxContainer
@onready var current_context:int = NAVIGATE: @onready var current_context:int = NAVIGATE:
set(context): set(context):
#if current_context == ASSIGN and !context == ASSIGN: #if current_context == ASSIGN and !context == ASSIGN:
@ -61,8 +62,8 @@ var dropzone_size: Vector2
# ASSIGN: # ASSIGN:
# pass # pass
current_context = context current_context = context
@onready var instructions = $instructions_panel/HBoxContainer/cards_remaining @onready var instructions := $instructions_panel/HBoxContainer/cards_remaining
@onready var timer: Timer = $Timer @onready var timer := $Timer
var mementos_collected: int = 0: var mementos_collected: int = 0:
set(mementos): set(mementos):
@ -96,7 +97,7 @@ var mementos_collected: int = 0:
if current_context == ASSIGN and not focus_stickies: if current_context == ASSIGN and not focus_stickies:
while not dropzone.get_child(current_dropzone_id) is Card: while not dropzone.get_child(current_dropzone_id) is Card:
current_dropzone_id = (current_dropzone_id + (1 if not new_id == -1 else -1)) % dropzone.get_child_count() current_dropzone_id = (current_dropzone_id + (1 if not new_id == -1 else -1)) % dropzone.get_child_count()
dropzone.get_child(current_dropzone_id).preview_sticky_note(currently_active_node) (dropzone.get_child(current_dropzone_id) as Card).preview_sticky_note(currently_active_node)
elif not focus_stickies: elif not focus_stickies:
currently_active_node = dropzone.get_child(current_dropzone_id) currently_active_node = dropzone.get_child(current_dropzone_id)
@ -133,7 +134,7 @@ signal board_completed
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
var size_reference = StickyNotePanel.new() var size_reference := StickyNotePanel.new()
dropzone_size = get_viewport_rect().size - Vector2(dropzone_padding + size_reference.minimum_size.x, dropzone_padding) dropzone_size = get_viewport_rect().size - Vector2(dropzone_padding + size_reference.minimum_size.x, dropzone_padding)

View File

@ -46,6 +46,7 @@ var transfor_arr: Array[Transform2D] = [
@export var highlighted: bool = false: @export var highlighted: bool = false:
set(highlight): set(highlight):
if highlight != highlighted: if highlight != highlighted:
printt(self, highlight)
highlighted = highlight highlighted = highlight
if is_inside_tree() and is_node_ready(): if is_inside_tree() and is_node_ready():
@ -130,7 +131,7 @@ var sticky_note_position: Vector2 = Vector2(-66, 83)
var is_mouse_entered: bool = false var is_mouse_entered: bool = false
var mouse_offset: Vector2 var mouse_offset: Vector2
func _init(card_name: String = "card", own_id:StringName = "-1") -> void: func init(card_name: String = "card", own_id:StringName = "-1") -> void:
if card_name != "c_void": if card_name != "c_void":
text = card_name text = card_name
card_id = own_id card_id = own_id
@ -139,8 +140,6 @@ func _init(card_name: String = "card", own_id:StringName = "-1") -> void:
func _ready(): func _ready():
input_event.connect(_on_input_event) input_event.connect(_on_input_event)
mouse_entered.connect(_on_mouse_entered)
mouse_exited.connect(_on_mouse_exited)
_handle_wiggle(0) _handle_wiggle(0)
_on_text_updated.call_deferred() _on_text_updated.call_deferred()
@ -149,7 +148,6 @@ func _on_text_updated():
if is_node_ready(): if is_node_ready():
var curr_frame := text.hash() % background_sprite.sprite_frames.get_frame_count(background_sprite.animation) var curr_frame := text.hash() % background_sprite.sprite_frames.get_frame_count(background_sprite.animation)
background_sprite.frame = curr_frame background_sprite.frame = curr_frame
background_sprite.scale = Vector2(0.6, 0.6)
if text == "": if text == "":
if background_sprite.get_child_count() == 0: if background_sprite.get_child_count() == 0:
@ -163,7 +161,7 @@ func _on_text_updated():
wiggle_pos = float(text.hash() % 100) wiggle_pos = float(text.hash() % 100)
label.rotation = deg_to_rad(transfor_arr[curr_frame].get_rotation()) label.rotation = deg_to_rad(transfor_arr[curr_frame].get_rotation())
label.position = transfor_arr[curr_frame].origin #label.position = transfor_arr[curr_frame].origin
burn_progress = burn_progress burn_progress = burn_progress
@ -190,25 +188,18 @@ func _handle_wiggle(delta):
rotation = noise.get_noise_1d(wiggle_pos)*wiggle_strength rotation = noise.get_noise_1d(wiggle_pos)*wiggle_strength
## Deprecated
func replace_with(card: Card):
self.text = card.text
self.compatible_sticky_notes = card.compatible_sticky_notes
self.own_sticky_notes = card.own_sticky_notes
self.voice_line = card.voice_line
self.name = card.name
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
if event is InputEventMouseButton: if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and not event.pressed: if event.button_index == MOUSE_BUTTON_LEFT and not event.pressed:
is_dragged = false is_dragged = false
func _on_mouse_entered(): func _on_mouse_entered() -> void:
is_mouse_entered = true is_mouse_entered = true
if not Input.is_action_pressed("mouse_left"): if not Input.is_action_pressed("mouse_left"):
# Do nothing if mouse hovers over sticky_note # Do nothing if mouse hovers over sticky_note
if has_sticky_note_attached(): if has_sticky_note_attached():
if current_sticky_note.highlighted: if current_sticky_note and current_sticky_note.highlighted:
return return
highlighted = true highlighted = true
if "handle_hover" in owner: if "handle_hover" in owner:

View File

@ -5,45 +5,38 @@
[ext_resource type="Theme" uid="uid://d1jvpqykmpfyg" path="res://logic-scenes/themes/serif.theme" id="3_mdi7r"] [ext_resource type="Theme" uid="uid://d1jvpqykmpfyg" path="res://logic-scenes/themes/serif.theme" id="3_mdi7r"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mai6h"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_mai6h"]
size = Vector2(511, 410) size = Vector2(277, 231)
[node name="Card" type="Area2D"] [node name="Card" type="Area2D"]
script = ExtResource("1_emip0") script = ExtResource("1_emip0")
text = "asdf" text = "asdf"
picked_random = null
wiggle_strength = null
wiggle_speed = null
scale_bump = null
bounce_speed = null
highlighted = null
is_dragable = null
diameter = null
burn_progress = null
burn_state = null
direction = null
metadata/_custom_type_script = "uid://ddy8kb2hjvgss" metadata/_custom_type_script = "uid://ddy8kb2hjvgss"
metadata/type = "card" metadata/type = "card"
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
scale = Vector2(0.6, 0.6)
sprite_frames = ExtResource("2_mai6h") sprite_frames = ExtResource("2_mai6h")
[node name="Label" type="Label" parent="."] [node name="Label" type="Label" parent="."]
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = -203.0 offset_left = -126.0
offset_top = -166.29167 offset_top = -88.0
offset_right = 224.0 offset_right = 136.0
offset_bottom = 173.12498 offset_bottom = 89.95834
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme = ExtResource("3_mdi7r") theme = ExtResource("3_mdi7r")
theme_type_variation = &"card_text" theme_type_variation = &"card_text"
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. " text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
horizontal_alignment = 1 horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
autowrap_mode = 3 autowrap_mode = 3
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(11, -2) position = Vector2(5.5, 0)
shape = SubResource("RectangleShape2D_mai6h") shape = SubResource("RectangleShape2D_mai6h")
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]

View File

@ -75,7 +75,7 @@ var mouse_diff: Vector2
@export_range(1.0, 10.0) var bounce_speed: float = 8 @export_range(1.0, 10.0) var bounce_speed: float = 8
var on_board: bool = false var on_board: bool = false
func _init(sticky_name: String = "sticky_note", card_id: StringName = "-1") -> void: func init(sticky_name: String = "sticky_note", card_id: StringName = "-1") -> void:
name = sticky_name name = sticky_name
text = sticky_name text = sticky_name
parent_id = StringName(card_id.rsplit(".", false, 1)[0]) parent_id = StringName(card_id.rsplit(".", false, 1)[0])

View File

@ -27,6 +27,7 @@ Steamworks="*res://dev-util/steamworks.gd"
PromptManager="*res://addons/input_prompts/input_prompt_manager.gd" PromptManager="*res://addons/input_prompts/input_prompt_manager.gd"
Steam="*res://dev-util/steam.gd" Steam="*res://dev-util/steam.gd"
Main="*res://singletons/main/main.tscn" Main="*res://singletons/main/main.tscn"
HardCards="*res://dev-util/hardcoded_cards.tscn"
[debug] [debug]

View File

@ -91,6 +91,7 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
mouse_filter = 2
script = ExtResource("1_rqkns") script = ExtResource("1_rqkns")
youth_room_path = "uid://b3b0gyvklqn50" youth_room_path = "uid://b3b0gyvklqn50"
transition_room_path = "uid://fgp3s28h7msy" transition_room_path = "uid://fgp3s28h7msy"
@ -107,6 +108,7 @@ offset_bottom = 0.0
[node name="MainMenu" parent="." instance=ExtResource("3_ik73t")] [node name="MainMenu" parent="." instance=ExtResource("3_ik73t")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false
layout_mode = 1 layout_mode = 1
[node name="FPSLabel" type="Label" parent="."] [node name="FPSLabel" type="Label" parent="."]

17
src/tests/card_tests.tscn Normal file
View File

@ -0,0 +1,17 @@
[gd_scene load_steps=2 format=3 uid="uid://j1g0cakfiusk"]
[ext_resource type="PackedScene" uid="uid://dy5rd437h5hsw" path="res://logic-scenes/board/card.tscn" id="1_qc7lg"]
[node name="CardTests" type="Node2D"]
[node name="Card" parent="." instance=ExtResource("1_qc7lg")]
position = Vector2(1416, 350)
[node name="Card2" parent="." instance=ExtResource("1_qc7lg")]
position = Vector2(418, 255)
[node name="Card3" parent="." instance=ExtResource("1_qc7lg")]
position = Vector2(415, 552)
[node name="Card4" parent="." instance=ExtResource("1_qc7lg")]
position = Vector2(877, 360)