From 9a76089edbae93c874b24c53a9b79f1fe10ebe2f Mon Sep 17 00:00:00 2001 From: tpart Date: Sat, 29 Jun 2024 22:08:39 +0200 Subject: Add Sound singleton; Restructure sound system; Add button sounds to ingame menu --- client/audio/sound.gd | 19 +++++++++++++++++++ client/audio/sound.tscn | 16 ++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 client/audio/sound.gd create mode 100644 client/audio/sound.tscn (limited to 'client/audio') diff --git a/client/audio/sound.gd b/client/audio/sound.gd new file mode 100644 index 00000000..ddb610c5 --- /dev/null +++ b/client/audio/sound.gd @@ -0,0 +1,19 @@ +extends Node + +@onready var click_sound = $UI/Click +@onready var hover_sound = $UI/Hover + +func play_click(): + click_sound.play() + +func play_hover(): + hover_sound.play() + +func play_hover_maybe(element): + if Global.focus_auto_changed: + Global.focus_auto_changed = false + return + if element is Button: + if element.is_hovered(): + return + play_hover() diff --git a/client/audio/sound.tscn b/client/audio/sound.tscn new file mode 100644 index 00000000..7c0458dc --- /dev/null +++ b/client/audio/sound.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=4 format=3 uid="uid://d3h243yic44rr"] + +[ext_resource type="Script" path="res://audio/sound.gd" id="1_b0qb1"] +[ext_resource type="AudioStream" uid="uid://cpyn511c5mtni" path="res://menu/sounds/click.ogg" id="2_mhrce"] +[ext_resource type="AudioStream" uid="uid://dtr1khfyqr56o" path="res://menu/sounds/hover.ogg" id="3_qft2s"] + +[node name="Sound" type="Node"] +script = ExtResource("1_b0qb1") + +[node name="UI" type="Node" parent="."] + +[node name="Click" type="AudioStreamPlayer" parent="UI"] +stream = ExtResource("2_mhrce") + +[node name="Hover" type="AudioStreamPlayer" parent="UI"] +stream = ExtResource("3_qft2s") -- cgit v1.2.3-70-g09d2