mirror of
https://github.com/Cuteminded/jellyframe.git
synced 2026-10-18 10:00:29 +02:00
This change replaces the old playback button strip with a transparent overlay attached to the movie screen. It adds a seekable timeline, duration reporting, and proper seek routing for resumed/transcoded streams while preserving paused state and overlay behavior across settings and recenter actions. Pointer and scroll handling were also hardened to improve controller input stability, including hover tracking, exit handling, aim smoothing, and synthetic wheel release events. Regression tests and testing notes were extended to cover overlay toggling, timeline formatting, seek flows, recenter behavior, and pointer/scroll edge cases.
42 lines
1.3 KiB
GDScript
42 lines
1.3 KiB
GDScript
class_name MenuFeedback
|
|
extends Node
|
|
|
|
var player := AudioStreamPlayer.new()
|
|
|
|
func _ready() -> void:
|
|
player.stream = _click_sound()
|
|
player.volume_db = -16.0
|
|
player.max_polyphony = 4
|
|
add_child(player)
|
|
get_tree().node_added.connect(_connect_button)
|
|
_connect_existing(get_tree().root)
|
|
|
|
func _connect_existing(node: Node) -> void:
|
|
_connect_button(node)
|
|
for child in node.get_children(): _connect_existing(child)
|
|
|
|
func _connect_button(node: Node) -> void:
|
|
if not node is BaseButton: return
|
|
var button := node as BaseButton
|
|
button.action_mode = BaseButton.ACTION_MODE_BUTTON_PRESS
|
|
if not button.pressed.is_connected(_play): button.pressed.connect(_play)
|
|
|
|
func _play() -> void:
|
|
if OS.is_debug_build() and OS.get_name() == "Android": print("Jellyframe input: button activated")
|
|
player.play()
|
|
|
|
func _click_sound() -> AudioStreamWAV:
|
|
var sound := AudioStreamWAV.new()
|
|
sound.format = AudioStreamWAV.FORMAT_16_BITS
|
|
sound.mix_rate = 48000
|
|
var samples := 1440
|
|
var data := PackedByteArray()
|
|
data.resize(samples * 2)
|
|
for index in range(samples):
|
|
var time := float(index) / sound.mix_rate
|
|
var envelope := minf(time / 0.0015, 1.0) * exp(-time * 180.0) * (1.0 - float(index) / samples)
|
|
var sample := (sin(TAU * 1250.0 * time) + 0.3 * sin(TAU * 2300.0 * time)) * envelope * 0.65
|
|
data.encode_s16(index * 2, int(sample * 32767.0))
|
|
sound.data = data
|
|
return sound
|