Compare commits

...

12 Commits

22 changed files with 582 additions and 1065 deletions

View File

@ -7,9 +7,6 @@ extends RoomTemplate
@onready var card_picker: CardPicker = %Picker
@onready var ui: Control = %UI
# Is populated by child cardboard instead of onready.
var card_board: CardBoard
func start_room():
%UI.show()
$logic/PlayerController.process_mode = Node.PROCESS_MODE_INHERIT

31
src/dev-util/i18n.gd Normal file
View File

@ -0,0 +1,31 @@
## Localization Utility class to move lists of keys out of difficult to read code
extends Node
func get_memento_prompt(count: int) -> StringName:
return TranslationServer.translate(_memento_prompts.get(count, ""))
func get_story_caption(id: Scenes.id) -> StringName:
return TranslationServer.translate(_story_captions.get(id, ""))
const _memento_prompts: Dictionary[int, StringName] = {
1: "There are three Mementos left to find.",
2: "You have collected half of the mementos.",
3: "Find the last Memento to complete the Board.",
4: "Combine cards to order your thoughts.",
}
const _story_captions : Dictionary[Scenes.id, StringName] = {
Scenes.id.YOUTH_DRAVEN: "Starlight",
Scenes.id.YOUTH_CHILDHOOD: "crafted Mask",
Scenes.id.YOUTH_VOICE_TRAINING: "Comic Stash",
Scenes.id.YOUTH_JUI_JUTSU: "Sports Clothes",
Scenes.id.TRANSITION: "Move on",
Scenes.id.ADULT_DND: "colorful Dice",
Scenes.id.ADULT_VOLUNTARY: "Gemstone Art",
Scenes.id.ADULT_CHRISTMAS: "Chat Messages",
Scenes.id.ADULT_EATING: "Dishes",
Scenes.id.ADULT_UNI: "Science Poster",
Scenes.id.ADULT_THERAPY: "Doctors Note",
Scenes.id.ADULT_BURNOUT: "Paperwork",
}

1
src/dev-util/i18n.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://26fa8xwylhxl

View File

@ -4,6 +4,7 @@ var initialised: bool = false
var id: State.rooms = State.rooms.NULL
@onready var scene_player : AnimationPlayer = %ScenePlayer
@onready var card_board : CardBoard # Optional Board, if present - set by the board in its own _ready()
var is_active: bool:
set(value):
@ -23,11 +24,11 @@ func _ready() -> void:
func disable()-> void:
is_active = false
set_process_input(false)
set_process(false)
set_process(false)
func get_ready():
pass
func load():
# Override this function to load the state of the chapter from State.save_game
pass
@ -47,13 +48,13 @@ func pull_save_state(_save: SaveGame) -> void:
## Attempts to find player controller and restore position/rotation from save
func restore_player_from_save(save: SaveGame) -> void:
var player: PlayerController = null
# Try to find player controller in common locations
if has_node("%PlayerController"):
player = get_node("%PlayerController")
elif has_node("logic/PlayerController"):
player = get_node("logic/PlayerController")
if player and player is PlayerController:
player.restore_from_save(save)
else:
@ -72,4 +73,3 @@ func unload():
## Override in subclasses to add custom scene preparation logic
func prepare_scene_start(_scene_id: Scenes.id, _is_repeating: bool) -> void:
await get_tree().process_frame # Dummy wait for LSP warning otherwise

View File

@ -14,8 +14,6 @@ class_name SaveGame extends Resource
# Board state - properly typed fields
@export var board_positions: Dictionary[StringName, Vector2] = {} # Position of all cards and stickies
@export var board_attachments: Dictionary[StringName, StringName] = {} # Sticky name → Card name (if attached)
@export var board_in_panel: Array[StringName] = [] # Stickies currently in the side panel
@export var board_randoms: Array[StringName] = [] # Items picked randomly
@export var is_childhood_board_complete: bool = false
@export var player_position: Vector3 = Vector3.ZERO

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,6 @@ enum burned {
var compatible_sticky_notes: Array[StickyNote] = []
@export var evil_sticky_notes: Array[StickyNote] = []
var own_sticky_notes: Array[StickyNote] = []
var current_sticky_note: StickyNote = null
var wiggle_pos: float = 0
var wiggle_intensity: float = 0
var noise: Noise = FastNoiseLite.new()
@ -38,56 +37,41 @@ var transfor_arr: Array[Transform2D] = [
@onready var label: Label = $Label
@onready var background_sprite: AnimatedSprite2D = $AnimatedSprite2D
@export var picked_random: bool = false
@export var wiggle_strength: float = 0.2
@export var wiggle_speed: float = 5
@export_range(1, 2) var scale_bump: float = 1.05
@export_range(1.0, 10.0) var bounce_speed: float = 5
@export_range(1.0, 2.0) var highlight_brightness: float = 1.4
@export_color_no_alpha var highlight_color: Color = Color(1.4, 1.4, 1.4)
## Override set_highlight to add visual feedback for cards
func set_highlight(value: bool) -> void:
if value != _highlighted:
_highlighted = value
if value == _highlighted: return
_highlighted = value
if scale_tween: scale_tween.kill()
if wiggle_tween: wiggle_tween.kill()
if brightness_tween: brightness_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)
brightness_tween = get_tree().create_tween()
brightness_tween.set_parallel(true)
brightness_tween.tween_property(background_sprite, "modulate", highlight_color, 0.15)
brightness_tween.tween_property(label, "modulate", highlight_color, 0.15)
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)
brightness_tween = get_tree().create_tween()
brightness_tween.set_parallel(true)
brightness_tween.tween_property(background_sprite, "modulate", Color.WHITE, 0.2)
brightness_tween.tween_property(label, "modulate", Color.WHITE, 0.2)
if is_inside_tree() and is_node_ready():
if scale_tween: scale_tween.kill()
if wiggle_tween: wiggle_tween.kill()
if brightness_tween: brightness_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)
brightness_tween = get_tree().create_tween()
brightness_tween.set_parallel(true)
brightness_tween.tween_property(background_sprite, "modulate", Color(highlight_brightness, highlight_brightness, highlight_brightness), 0.15)
brightness_tween.tween_property(label, "modulate", Color(highlight_brightness, highlight_brightness, highlight_brightness), 0.15)
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)
brightness_tween = get_tree().create_tween()
brightness_tween.set_parallel(true)
brightness_tween.tween_property(background_sprite, "modulate", Color.WHITE, 0.2)
brightness_tween.tween_property(label, "modulate", Color.WHITE, 0.2)
else:
if _highlighted:
scale = Vector2(scale_bump, scale_bump)
wiggle_intensity = 1
if background_sprite:
background_sprite.modulate = Color(highlight_brightness, highlight_brightness, highlight_brightness)
if label:
label.modulate = Color(highlight_brightness, highlight_brightness, highlight_brightness)
else:
scale = Vector2(1,1)
wiggle_intensity = 0
if background_sprite:
background_sprite.modulate = Color.WHITE
if label:
label.modulate = Color.WHITE
@export var voice_line: AudioStream = null
@export var is_dragable: bool = false
@ -153,14 +137,13 @@ func init(card_name: String = "card", own_id:StringName = "-1") -> void:
if card_name != "c_void":
text = card_name
if !card_name.begins_with("c"):
push_error("Illegal card.")
push_error("Illegal card!", card_name, own_id)
card_id = own_id
name = card_name
func _ready():
input_event.connect(_on_input_event)
super._ready()
_handle_wiggle(0)
_on_text_updated.call_deferred()
@ -203,35 +186,17 @@ func _process(delta: float) -> void:
func _handle_wiggle(delta):
wiggle_pos += delta * wiggle_speed * wiggle_intensity
rotation = noise.get_noise_1d(wiggle_pos)*wiggle_strength
func _input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and not event.pressed:
is_dragged = false
func _on_mouse_entered() -> void:
if not Input.is_action_pressed("mouse_left"):
# Do nothing if mouse hovers over sticky_note (it has higher priority)
if has_sticky_note_attached():
if current_sticky_note and current_sticky_note.highlighted:
return
if "handle_hover" in owner:
owner.handle_hover(self)
super._on_mouse_entered()
func _on_mouse_exited():
highlighted = false
super._on_mouse_exited()
if burn_state == burned.SINGED:
burn_state = burned.NOT
func _on_input_event(_viewport, event, _shape_idx):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
if "handle_mouse_button" in owner and highlighted:
mouse_offset = get_viewport().get_mouse_position() - position
owner.handle_mouse_button(event, self)
func _move_card():
if is_dragged:
update_drag_position(get_viewport().get_mouse_position())
@ -249,8 +214,7 @@ func get_attached_sticky_note() -> StickyNote:
func preview_sticky_note(sticky_note: StickyNote):
if not is_instance_valid(sticky_note):
return
sticky_note.reparent(self.get_parent())
sticky_note.attached_to = self
# Keep sticky in current parent during preview (just move it visually)
# Use a safe transform with validated position
var target_pos := global_position + sticky_note_position
if is_finite(target_pos.x) and is_finite(target_pos.y):
@ -264,11 +228,7 @@ func attach_sticky_note(sticky_note: StickyNote) -> bool:
sticky_note.reparent(self)
sticky_note.position = sticky_note_position
sticky_note.on_board = false
sticky_note.is_dragable = false
current_sticky_note = sticky_note
#var former_parent = sticky_note.attached_to
sticky_note.attached_to = self
if name == "c_hit" and sticky_note.name == "c_effort" and Steamworks.has_initialized:
Steam.setAchievement("FIGHT_FOR_GOOD")
@ -277,30 +237,19 @@ func attach_sticky_note(sticky_note: StickyNote) -> bool:
return true
func remove_sticky_note() -> StickyNote:
var former_child:StickyNote = get_attached_sticky_note()
current_sticky_note = null
var former_child: StickyNote = get_attached_sticky_note()
if not former_child:
return null
former_child.reparent(get_parent())
former_child.owner = self.owner
former_child.on_board = true
former_child.attached_to = owner
return former_child
func exchange_sticky_note_with(new_note: StickyNote) -> StickyNote:
var tmp := remove_sticky_note()
if new_note == get_attached_sticky_note():
return null
var old_note := remove_sticky_note()
attach_sticky_note(new_note)
return tmp
# This makes sure this node highlights itself when focus has left the sticky note.
func check_hover():
# Re-trigger hover handling - owner will decide if this should be highlighted
_on_mouse_entered()
func reclaim_sticky_note():
current_sticky_note.on_board = false
current_sticky_note.tween_transform_to(Transform2D(0, to_global(sticky_note_position)))
await current_sticky_note.transform_tween_finished
current_sticky_note.reparent(self)
current_sticky_note.owner = self.owner
return old_note
# === DROP TARGET PATTERN IMPLEMENTATION ===
@ -337,7 +286,7 @@ func handle_drop(draggable: StickyNote) -> int:
## Retrieves the sticky that was exchanged during last drop
## Clears the reference after retrieval
func get_last_exchanged_sticky() -> StickyNote:
var result = _last_exchanged_sticky
var result := _last_exchanged_sticky
_last_exchanged_sticky = null
return result
@ -346,4 +295,4 @@ func get_last_exchanged_sticky() -> StickyNote:
## Cards always drop back to board dropzone
func find_drop_target() -> Node:
return owner if owner is CardBoard else get_parent()
return _get_board()

View File

@ -8,10 +8,11 @@
size = Vector2(277, 231)
[node name="Card" type="Area2D"]
collision_layer = 4
collision_mask = 0
priority = 50
script = ExtResource("1_emip0")
text = "asdf"
metadata/_custom_type_script = "uid://ddy8kb2hjvgss"
metadata/type = "card"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
@ -38,6 +39,3 @@ text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 3
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]

View File

@ -4,6 +4,9 @@ extends Area2D
## Base class for draggable UI elements (Cards and StickyNotes)
## Provides common dragging behavior and boundary protection
## Margin from screen edges when confining to screen bounds
@export var screen_margin: float = 50.0
## Drop result codes for DropTarget pattern
enum DropResult {
ACCEPTED, # Drop successful, item is now owned by target
@ -11,10 +14,7 @@ enum DropResult {
EXCHANGED # Swap occurred, exchanged item needs handling
}
## Static helper to check if a node implements DropTarget pattern
## DropTarget pattern requires: can_accept_drop(draggable) and handle_drop(draggable)
static func is_drop_target(node: Node) -> bool:
return node != null and node.has_method("can_accept_drop") and node.has_method("handle_drop")
var mouse_over: bool = false
var is_dragged: bool = false:
set(dragged):
@ -34,17 +34,72 @@ var highlighted: bool:
func set_highlight(value: bool) -> void:
_highlighted = value
## Margin from screen edges when confining to screen bounds
@export var screen_margin: float = 50.0
## Drag state tracking
var _drag_start_position: Vector2
var _mouse_drag_offset: Vector2
var _drag_source: Node = null # Where the drag started from
## === SETUP ###
func _ready() -> void:
mouse_entered.connect(_on_mouse_entered)
mouse_exited.connect(_on_mouse_exited)
input_event.connect(_on_input_event)
func _get_hover_handler() -> Node:
var parent := get_parent()
while parent and not parent.has_method("handle_hover"):
parent = parent.get_parent()
return parent
## Walks up the scene tree to find the CardBoard
func _get_board() -> Node:
var node := get_parent()
while node:
if node.has_method("handle_mouse_button"):
return node
node = node.get_parent()
return null
## === DRAG LIFECYCLE METHODS ===
## Override these in Card and StickyNote for specific behavior
func _on_mouse_entered() -> void:
prints("Draggable[base]._on_mouse_entered", self, self.name)
mouse_over = true
var handler := _get_hover_handler()
if handler: handler.handle_hover(self)
func _on_mouse_exited() -> void:
prints("Draggable[base]._on_mouse_exited", self, self.name)
mouse_over = false
var handler := _get_hover_handler()
if handler: handler.handle_hover(self)
## Handles global input events (used to catch mouse release during drag)
func _input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and not event.pressed:
if is_dragged:
is_dragged = false
# Trigger the drop logic
var board := _get_board()
if board and board.has_method("_end_drag"):
board._end_drag(self)
## Handles input events on this Area2D (used to start drag)
func _on_input_event(_viewport, event, _shape_idx):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
if highlighted:
var board := _get_board()
if board and board.has_method("handle_mouse_button"):
board.handle_mouse_button(event, self)
## Starts a drag operation
func start_drag(mouse_offset: Vector2) -> void:
_drag_start_position = global_position
@ -65,35 +120,28 @@ func find_drop_target() -> Node:
return get_parent()
## Called after drop to clean up drag state
func end_drag() -> void:
func end_drag() -> Node:
is_dragged = false
_drag_source = null
return null
## Confines this draggable element to stay within screen or container bounds
## Skip this check if a sticky note is attached to a card
func confine_to_screen() -> void:
# Skip if this is a sticky note attached to a card
if self is StickyNote:
var sticky := self as StickyNote
if sticky.attached_to is Card:
return
# Try to get bounds from parent container
var bounds := _get_container_bounds()
# If no container bounds, use viewport/screen bounds
if bounds == Rect2():
bounds = _get_viewport_bounds()
# If we have valid bounds, clamp position
if bounds != Rect2():
position.x = clampf(position.x, bounds.position.x, bounds.position.x + bounds.size.x)
position.y = clampf(position.y, bounds.position.y, bounds.position.y + bounds.size.y)
## Gets the bounds of the parent container if it exists and is a Control node
func _get_container_bounds() -> Rect2:
var parent := get_parent()
# Check if parent is a Control node with a defined rect
if parent is Control:
var control := parent as Control
@ -104,26 +152,12 @@ func _get_container_bounds() -> Rect2:
control.size.x - screen_margin * 2,
control.size.y - screen_margin * 2
)
# Check if parent is a Node2D with defined boundaries
# (for future support of non-Control containers)
if parent is Node2D:
# For now, return empty rect - could be extended in the future
# to check for custom boundary properties
pass
return Rect2()
## Gets the viewport bounds as fallback
func _get_viewport_bounds() -> Rect2:
var viewport := get_viewport()
if viewport:
var viewport_size := viewport.get_visible_rect().size
return Rect2(
screen_margin,
screen_margin,
viewport_size.x - screen_margin * 2,
viewport_size.y - screen_margin * 2
)
return Rect2()
# Default: whole screen
var viewport_size := get_viewport().get_visible_rect().size
return Rect2(
screen_margin,
screen_margin,
viewport_size.x - screen_margin * 2,
viewport_size.y - screen_margin * 2
)

View File

@ -147,7 +147,6 @@ _data = {
}
[node name="board" type="PanelContainer"]
z_index = -100
material = SubResource("ShaderMaterial_ttqei")
clip_contents = true
anchors_preset = 15
@ -164,20 +163,18 @@ script = ExtResource("3_8v4c4")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="dropzone" type="Panel" parent="HBoxContainer"]
[node name="CardZone" type="Control" parent="HBoxContainer"]
unique_name_in_owner = true
self_modulate = Color(1, 1, 1, 0)
layout_mode = 2
size_flags_horizontal = 3
mouse_filter = 1
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"]
clip_contents = false
layout_mode = 2
horizontal_scroll_mode = 0
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/ScrollContainer"]
z_index = 120
[node name="NoteZone" type="Control" parent="HBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(400, 0)
layout_mode = 2
mouse_filter = 1
[node name="instructions_panel" type="PanelContainer" parent="."]
layout_mode = 2

View File

@ -7,14 +7,21 @@ var parent_id
var sibling: StickyNote
var shift_tween: Tween
var modulate_tween: Tween
var attached_to: Node = null:
set(new_attatchement):
attached_to = new_attatchement
# cannot be explicitly typed, as this can be both handled by picker and physics-board
var current_handle: Node
var position_locked: bool = false
## Computed property: Is this currently attached to a card
var is_attached : bool:
get: return get_parent() is Card
## Replaces the need for tracking attached_to as state
var attached_to: Card:
get: return get_parent() as Card if is_attached else null
signal transform_tween_finished
@onready var background_sprite: AnimatedSprite2D = %BackgroundSprite
@ -27,34 +34,28 @@ signal transform_tween_finished
var content: Node2D
var label: Label
@export var picked_random: bool = false
@export var shift_by: Vector2 = Vector2(-32, 0)
@export_color_no_alpha var highlight_color: Color = Color(1.5, 1.5, 1.5)
## Override set_highlight to add visual feedback for sticky notes
func set_highlight(value: bool) -> void:
if value != _highlighted:
_highlighted = value
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)
if modulate_tween: modulate_tween.kill()
if shift_tween: shift_tween.kill()
if _highlighted:
modulate_tween = create_tween()
modulate_tween.tween_property(self, "modulate", highlight_color, 0.1)
shift_tween = create_tween()
shift_tween.tween_property(content, "position", shift_by, 0.2)
else:
if _highlighted:
modulate = Color(1, 1, 1)
else:
modulate = Color(1, 1, 1)
modulate_tween = create_tween()
modulate_tween.tween_property(self, "modulate", Color(1, 1, 1), 0.3)
shift_tween = create_tween()
shift_tween.tween_property(content, "position", Vector2.ZERO, 0.5)
@export var voice_line: AudioStream = null
@export var is_dragable: bool = false
@ -63,7 +64,13 @@ var mouse_offset: Vector2
@onready var diameter := 312.0
@export_range(1.0, 10.0) var bounce_speed: float = 8
var on_board: bool = false
## Computed property: Check if on the board (dropzone)
## Replaces on_board state tracking
var on_board: bool:
get:
var parent := get_parent()
return parent != null and parent.name == "dropzone"
func init(sticky_name: String = "sticky_note", card_id: StringName = "-1") -> void:
name = sticky_name
@ -72,19 +79,13 @@ func init(sticky_name: String = "sticky_note", card_id: StringName = "-1") -> vo
sticky_id = card_id
func _ready() -> void:
super._ready()
label = $Content/Label
background_sprite = $Content/BackgroundSprite
content = $Content
_on_text_updated.call_deferred()
input_event.connect(_on_input_event)
mouse_entered.connect(_on_mouse_entered)
mouse_exited.connect(_on_mouse_exited)
area_entered.connect(_on_area_enter)
area_exited.connect(_on_area_exit)
func _on_text_updated():
label.text = text
@ -92,62 +93,36 @@ func _on_text_updated():
func _process(delta: float) -> void:
if get_overlapping_areas().size() > 0 and is_dragable and on_board:
for area in get_overlapping_areas():
if area is Card:
if not area.highlighted or self.highlighted:
var diff:Vector2 = position - area.position
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
_move_sticky_note(delta)
_move_sticky_note()
func _on_mouse_entered():
if not Input.is_action_pressed("mouse_left") and "handle_hover" in current_handle:
current_handle.handle_hover(self)
## frame rate independent FIR smoothing filter
func _smooth(current: Vector2, goal: Vector2, delta: float) -> Vector2:
var k := pow(0.1, 60.0 * delta)
return (1.0-k) * current + k * goal
func _on_mouse_exited():
highlighted = false
# Let parent card re-check hover state if this sticky is attached to it
if is_sticky_note_attached() and "check_hover" in attached_to:
attached_to.check_hover()
func _on_area_enter(area: Area2D):
# Handle sticky note panel gap creation
if area is StickyNote and is_sticky_note_in_panel() and not is_dragged:
attached_to.create_gap()
func _on_area_exit(area: Area2D):
# Handle sticky note panel gap collapse
if area is StickyNote and is_sticky_note_in_panel():
attached_to.collapse_gap()
func _on_input_event(_viewport, event, _shape_idx):
if event is InputEventMouseButton and "handle_mouse_button" in current_handle:
if (event.button_index == MOUSE_BUTTON_LEFT and event.pressed) or event.button_index == MOUSE_BUTTON_RIGHT:
mouse_offset = get_viewport().get_mouse_position() - global_position
current_handle.handle_mouse_button(event, self)
func _move_sticky_note():
func _move_sticky_note(delta: float) -> void:
if is_dragged:
update_drag_position(get_viewport().get_mouse_position())
return
if is_attached:
var card := attached_to
position = _smooth(position, card.sticky_note_position, delta)
func is_sticky_note_attached() -> bool:
# FIXME: this breaks if attatched to is previousely freed because GODOT IS FUCKING STUPID
return attached_to is Card
func is_sticky_note_in_panel() -> bool:
## fixme ~> see above
return attached_to is StickyNotePanel
var transform_tween: Tween
func tween_transform_to(target: Transform2D, duration: float = 0.25):
func tween_transform_to(target: Transform2D, duration: float = 0.25) ->void:
# Validate position to prevent teleporting
if not is_finite(target.origin.x) or not is_finite(target.origin.y):
push_warning("StickyNote.tween_transform_to: Invalid position, skipping tween")
transform_tween_finished.emit()
return
if transform_tween and transform_tween.is_running():
transform_tween.stop()
@ -160,66 +135,46 @@ func tween_transform_to(target: Transform2D, duration: float = 0.25):
# === DRAG LIFECYCLE OVERRIDES ===
## Track whether this sticky came from a panel (for exchange logic)
var _came_from_panel: bool = false
func end_drag() -> Node:
super.end_drag()
return _find_drop_target()
## Start drag: if in panel, immediately move to board
func start_drag(offset: Vector2) -> void:
super.start_drag(offset)
_came_from_panel = is_sticky_note_in_panel()
# If attached to a card, detach it first
if is_sticky_note_attached():
var card := attached_to as Card
if card and card.has_method("remove_sticky_note"):
card.remove_sticky_note()
# If in panel, immediately reparent to board for dragging
if _came_from_panel and current_handle:
var board := current_handle
var dropzone := board.get_node_or_null("HBoxContainer/dropzone")
if dropzone:
reparent(dropzone)
else:
reparent(board)
on_board = true
attached_to = board
## Find best drop target: Card > Panel > Board (in priority order)
func find_drop_target() -> Node:
func _find_drop_target() -> Node:
# Priority 1: Check for overlapping cards in dropzone
var closest : Card = null
for area in get_overlapping_areas():
if area is Card and Draggable.is_drop_target(area):
return area
# Priority 2: Check if dropped outside dropzone (over panel area)
if current_handle and not current_handle.is_in_dropzone(self):
var target_panel := _find_nearest_panel()
if target_panel:
return target_panel
# Priority 3: Default to board (stay loose in dropzone)
return current_handle
if area is StickyNote and not area.is_attached: continue # Can only drop on attached stickies
if area is Card:
if (not closest) or ((area.position - position).length() < (closest.position - position).length()):
closest = area
return closest
## Find the nearest panel that can accept this sticky
func _find_nearest_panel() -> StickyNotePanel:
if not current_handle or not current_handle.has_node("HBoxContainer/ScrollContainer/VBoxContainer"):
return null
var panel_container := current_handle.get_node("HBoxContainer/ScrollContainer/VBoxContainer")
var sticky_rect := Rect2(global_position - Vector2(diameter/2, 10), Vector2(diameter/2, 10))
# First pass: look for empty panels we're hovering over
for panel in panel_container.get_children():
if panel is StickyNotePanel:
if panel.is_empty() and panel.get_global_rect().intersects(sticky_rect):
return panel
# Second pass: if no empty panel found, find first empty panel
for panel in panel_container.get_children():
if panel is StickyNotePanel and panel.is_empty():
return panel
# No empty panels found - will need to create one (handled by board)
return null
func confine_to_screen() -> void:
if attached_to is not Card: super.confine_to_screen()

View File

@ -9,8 +9,8 @@ radius = 48.0
height = 312.0
[node name="sticky-note" type="Area2D"]
z_index = 1
collision_layer = 2
collision_mask = 6
priority = 100
script = ExtResource("1_yvh5n")
text = "card"

View File

@ -11,43 +11,47 @@ var ancor_position: Vector2
func _init(cstm_minimum_size: Vector2 = minimum_size, note_position: Vector2 = Vector2(105, 57)) -> void:
minimum_size = cstm_minimum_size
ancor_position = note_position
mouse_filter = MOUSE_FILTER_PASS
mouse_filter = MOUSE_FILTER_PASS
self_modulate = Color(1, 1, 1, 0)
@onready var board : CardBoard = get_parent().get_parent() as CardBoard
func _ready():
custom_minimum_size = Vector2(custom_minimum_size.x, 0)
var is_attatching: bool = false
func attatch_sticky_note(attatchment: StickyNote, custom_owner: Node, animate:bool = true):
is_attatching = true
func _process(delta: float) -> void:
var child := get_child(0) as StickyNote
if child and not child.is_dragged:
var k := pow(0.1, 60.0 * delta)
child.position = child.position * (1.0-k) + ancor_position * (k)
var is_attaching: bool = false
func attatch_sticky_note(attatchment: StickyNote, custom_handle: Node, animate:bool = true):
attached_sticky_note = attatchment
attatchment.current_handle = custom_owner
attatchment.owner = custom_owner
attatchment.current_handle = custom_handle
# Expand panel height
if animate:
var height_tween: Tween = create_tween()
height_tween.tween_property(self, "custom_minimum_size", minimum_size, 0.1)
else:
custom_minimum_size = minimum_size
# Position sticky
if animate:
await get_tree().process_frame
attatchment.on_board = false
attatchment.z_index = 125 # On top during animation
# Reparent while keeping world position for smooth animation
attatchment.reparent(self, true)
attatchment.attached_to = self
# Tween to anchor position in panel's coordinate space
var tween := create_tween().set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_BACK)
tween.tween_property(attatchment, "position", ancor_position, 0.7)
tween.tween_property(attatchment, "rotation", 0.0, 0.7)
tween.parallel().tween_property(attatchment, "scale", Vector2.ONE, 0.7)
await tween.finished
attatchment.z_index = 0
else:
# Immediate placement (for initial board setup)
@ -55,71 +59,10 @@ func attatch_sticky_note(attatchment: StickyNote, custom_owner: Node, animate:bo
attatchment.reparent(self)
else:
add_child(attatchment)
attatchment.on_board = false
attatchment.attached_to = self
attatchment.position = ancor_position
attatchment.rotation = 0.0
attatchment.scale = Vector2.ONE
is_attatching = false
var is_gapped: bool = false
func create_gap():
var self_id := get_parent().get_children().find(self)
var next_id = min(self_id + 1, get_parent().get_child_count() - 1)
var previous_id = max(self_id - 1, 0)
if not (is_gapped or get_parent().get_child(next_id).attached_sticky_note.is_dragged or get_parent().get_child(previous_id).attached_sticky_note.is_dragged) and owner.current_context == CardBoard.DRAG:
is_gapped = true
var height_tween: Tween = create_tween()
height_tween.tween_property(self, "custom_minimum_size", minimum_size*Vector2(1.0, 1.8), 0.1)
get_parent().get_child(next_id).collapse_gap()
if not get_parent().get_children().find(self) == 0: get_parent().get_child(previous_id).collapse_gap()
func collapse_gap():
if is_gapped:
is_gapped = false
var height_tween: Tween = create_tween()
height_tween.tween_property(self, "custom_minimum_size", minimum_size, 0.1)
var invalid: bool = false
func clear_if_empty():
if !is_empty(): return
invalid = true
if attached_sticky_note.attached_to == self: attached_sticky_note.attached_to = null
var height_tween: Tween = create_tween()
height_tween.tween_property(self, "custom_minimum_size", Vector2.ZERO, 0.3)
await height_tween.finished
owner.on_sticky_panel_cleared(get_parent().get_children().find(self))
self.queue_free()
func replace_sticky_note_with(new_sticky_note: StickyNote):
if is_empty():
attached_sticky_note = new_sticky_note
func is_empty() -> bool:
return get_child_count() == 0 and not is_attatching
return get_child_count() == 0
# === DROP TARGET PATTERN IMPLEMENTATION ===
## Checks if this panel can accept the given draggable
func can_accept_drop(draggable: Draggable) -> bool:
return draggable is StickyNote and is_empty()
## Handles dropping a sticky note onto this panel
func handle_drop(draggable: StickyNote) -> int:
if not can_accept_drop(draggable):
return Draggable.DropResult.REJECTED
# Attach sticky to this panel with animation
attatch_sticky_note(draggable, owner, true)
# Clean up other empty panels
for panel in get_parent().get_children():
if panel is StickyNotePanel and panel != self:
panel.clear_if_empty()
return Draggable.DropResult.ACCEPTED

View File

@ -23,14 +23,14 @@ func _ready():
%SkipButton.pressed.connect(card_burned.emit)
func burn_cards(_id: int, _repeat: bool = false) -> void:
var random_card_names: Array = State.save_game.board_randoms.duplicate()
for card_name in random_card_names:
if card_name.begins_with("p"):
random_card_names.erase(card_name)
var random_cards: Array = HardCards.get_cards_by_name_array(random_card_names)["cards"]
# Get all card names from the board (excluding stickies which start with "p")
var card_names: Array[StringName] = []
for item_name in State.save_game.board_positions.keys():
if not item_name.begins_with("p"):
card_names.append(item_name)
# Get card instances and shuffle them
var random_cards: Array = HardCards.get_cards_by_name_array(card_names)["cards"]
random_cards.shuffle()
for ancor:Control in ancors:

View File

@ -1,4 +1,5 @@
class_name CardPicker extends CenterContainer
class_name CardPicker
extends Playable
#fixme INI is probably redundant.
enum {

View File

@ -1,7 +1,7 @@
class_name Interactable extends Node3D
@export var interaction: PackedScene = null
var interaction_ui : Control = null
var interaction_ui : Playable = null
@onready var view: Node3D = $View
@onready var frame: Sprite3D = $Frame
@ -65,6 +65,7 @@ func expand() -> void:
func collapse() -> void:
if not shown: return #TODO: test
shown = false
if tween and tween.is_valid(): tween.kill()
tween = create_tween().set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_BACK)
@ -143,7 +144,7 @@ func interact() -> void:
shown = false
await collapse()
# Hide mouse and collapse other interactables BEFORE showing canvas
# collapse other interactables BEFORE showing canvas
get_tree().call_group("interactables", "collapse")
# Show the CanvasLayer so the story is visible full-screen
@ -164,33 +165,7 @@ func interact() -> void:
func _update_caption() -> void:
if interaction_ui is StoryPlayable:
var story := interaction_ui as StoryPlayable
match story.scene_id:
Scenes.id.YOUTH_DRAVEN:
caption.text = TranslationServer.translate("Starlight")
Scenes.id.YOUTH_CHILDHOOD:
caption.text = TranslationServer.translate("crafted Mask")
Scenes.id.YOUTH_VOICE_TRAINING:
caption.text = TranslationServer.translate("Comic Stash")
Scenes.id.YOUTH_JUI_JUTSU:
caption.text = TranslationServer.translate("Sports Clothes")
Scenes.id.TRANSITION:
caption.text = TranslationServer.translate("Move on")
Scenes.id.ADULT_DND:
caption.text = TranslationServer.translate("colorful Dice")
Scenes.id.ADULT_VOLUNTARY:
caption.text = TranslationServer.translate("Gemstone Art")
Scenes.id.ADULT_CHRISTMAS:
caption.text = TranslationServer.translate("Chat Messages")
Scenes.id.ADULT_EATING:
caption.text = TranslationServer.translate("Dishes")
Scenes.id.ADULT_UNI:
caption.text = TranslationServer.translate("Science Poster")
Scenes.id.ADULT_THERAPY:
caption.text = TranslationServer.translate("Doctors Note")
Scenes.id.ADULT_BURNOUT:
caption.text = TranslationServer.translate("Paperwork")
_:
caption.text = ""
caption.text = I18n.get_story_caption(story.scene_id)
elif interaction_ui is CardBoard:
caption.text = TranslationServer.translate("Mind Board")

View File

@ -1,5 +1,5 @@
extends CenterContainer
class_name StoryPlayable
extends Playable
signal text_finished
signal finished
@ -148,7 +148,7 @@ func play():
show()
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
# Don't know how to do this.
# FIXME: Don't know how to do this.
#%StoryScroll.grab_focus()
if name == "draven":

View File

@ -0,0 +1,10 @@
extends Control
class_name Playable
## Awaitable that encapsulates the core interaction with this Playable
func play() -> void:
await get_tree().process_frame # Dummy wait so this is a coroutine
func handle_hover(area: Draggable):
prints("Playable[base].handle_hover", area, area.name)
pass

View File

@ -0,0 +1 @@
uid://dbmkkouhc0euw

View File

@ -28,6 +28,7 @@ PromptManager="*res://addons/input_prompts/input_prompt_manager.gd"
Steam="*res://dev-util/steam.gd"
Main="*res://singletons/main/main.tscn"
HardCards="*res://dev-util/hardcoded_cards.tscn"
I18n="*res://dev-util/i18n.gd"
[debug]
@ -200,7 +201,11 @@ locale/test="de"
[layer_names]
2d_physics/layer_1="World"
3d_physics/layer_1="Scene Geometry"
2d_physics/layer_2="Stickies"
2d_physics/layer_3="Cards"
2d_physics/layer_5="Interactable"
3d_physics/layer_5="UI_reveal"
3d_physics/layer_6="UI_handle"

View File

@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://b752f680edsnv"]
[ext_resource type="PackedScene" uid="uid://bnskiyx1sksww" path="res://logic-scenes/board/physics-board.tscn" id="1_b12jd"]
[node name="BoardTests" type="Node"]
[node name="board" parent="." instance=ExtResource("1_b12jd")]

View File

@ -55,7 +55,7 @@ func _load_games():
func _sort_saves() -> void:
saves.sort_custom(func(a: SaveGame, b: SaveGame) -> int:
saves.sort_custom(func(a: SaveGame, b: SaveGame) -> bool:
return a.last_saved > b.last_saved
)