feat: added scroll keys and better scrolling

This commit is contained in:
tiger tiger tiger 2026-01-22 19:31:52 +01:00
parent 53fd4a7501
commit 92879b6bbf
8 changed files with 22 additions and 104 deletions

View File

@ -37,7 +37,8 @@ func get_ready_async():
func _on_scene_finished(_id: int, _repeat:bool): func _on_scene_finished(_id: int, _repeat:bool):
save_room.call_deferred() # Formerly there was a 3 second wait here. await get_tree().create_timer(1).timeout # Formerly there was a 3 second wait here.
save_room.call_deferred()
func save_room(): func save_room():

View File

@ -1,68 +0,0 @@
class_name StickyNotePanel
extends Panel
var minimum_size:Vector2 = Vector2(400, 100):
set(size):
minimum_size = size
custom_minimum_size = size
var attached_sticky_note: StickyNote
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
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)
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_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.z_index = 125 # On top during animation
# Reparent while keeping world position for smooth animation
attatchment.reparent(self, true)
# 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)
if attatchment.get_parent():
attatchment.reparent(self)
else:
add_child(attatchment)
attatchment.position = ancor_position
attatchment.rotation = 0.0
attatchment.scale = Vector2.ONE
func is_empty() -> bool:
return get_child_count() == 0

View File

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

View File

@ -1,15 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://chwf61qpn2sqw"]
[ext_resource type="Script" uid="uid://c8gsxyymrldcd" path="res://logic-scenes/board/sticky_note_panel.gd" id="1_1dtc4"]
[node name="Panel" type="Panel"]
self_modulate = Color(1, 1, 1, 0)
custom_minimum_size = Vector2(400, 100)
offset_right = 400.0
offset_bottom = 120.0
mouse_filter = 1
script = ExtResource("1_1dtc4")
[node name="sticky-note_anchor" type="Node2D" parent="."]
z_index = 110
position = Vector2(105, 57)

View File

@ -83,4 +83,5 @@ horizontal_alignment = 0
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 0, 0) transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 0, 0)
[node name="CanvasLayer" type="CanvasLayer" parent="."] [node name="CanvasLayer" type="CanvasLayer" parent="."]
layer = -1
visible = false visible = false

View File

@ -185,19 +185,16 @@ func play():
func _unhandled_input(event: InputEvent) -> void: func _unhandled_input(event: InputEvent) -> void:
#if event.is_action_type(): print_debug("Unhandled Input", event) if event.is_action_pressed("ui_text_scroll_down"):
var just_revealed_text := false accept_event()
if event is InputEventMouseButton: scroll_target += 40
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN: all_text_revealed = animation_complete
scroll_target += 40
if not all_text_revealed: if event.is_action_released("ui_text_scroll_up"):
just_revealed_text = true accept_event()
if event.button_index == MOUSE_BUTTON_WHEEL_UP: scroll_target -= 40
scroll_target -= 40 all_text_revealed = all_text_revealed or animation_complete
if not all_text_revealed:
just_revealed_text = true
if just_revealed_text and animation_complete:
all_text_revealed = true
var scroll_current : float = 0 var scroll_current : float = 0

View File

@ -99,6 +99,7 @@ ui_text_scroll_up={
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":8,"position":Vector2(179, 6),"global_position":Vector2(188, 54),"factor":1.0,"button_index":4,"canceled":false,"pressed":true,"double_click":false,"script":null) , Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":8,"position":Vector2(179, 6),"global_position":Vector2(188, 54),"factor":1.0,"button_index":4,"canceled":false,"pressed":true,"double_click":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":true,"script":null)
] ]
} }
ui_text_scroll_down={ ui_text_scroll_down={
@ -108,6 +109,7 @@ ui_text_scroll_down={
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":16,"position":Vector2(246, 6),"global_position":Vector2(255, 54),"factor":1.0,"button_index":5,"canceled":false,"pressed":true,"double_click":false,"script":null) , Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":16,"position":Vector2(246, 6),"global_position":Vector2(255, 54),"factor":1.0,"button_index":5,"canceled":false,"pressed":true,"double_click":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":true,"script":null)
] ]
} }
ui_menu={ ui_menu={

View File

@ -133,10 +133,17 @@ layout_mode = 1
visible = false visible = false
layout_mode = 1 layout_mode = 1
[node name="CreditsRoll" parent="." instance=ExtResource("11_wtpde")]
unique_name_in_owner = true
visible = false
modulate = Color(1, 1, 1, 0)
layout_mode = 1
[node name="PauseMenu" type="Panel" parent="."] [node name="PauseMenu" type="Panel" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
process_mode = 2 process_mode = 2
visible = false visible = false
z_index = 125
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@ -222,12 +229,6 @@ visible = false
layout_mode = 2 layout_mode = 2
text = "Skip this Story" text = "Skip this Story"
[node name="CreditsRoll" parent="." instance=ExtResource("11_wtpde")]
unique_name_in_owner = true
visible = false
modulate = Color(1, 1, 1, 0)
layout_mode = 1
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
bus = &"music" bus = &"music"