From bc319fa464e7162601c6d98f4eb25ebc9ca123a4 Mon Sep 17 00:00:00 2001 From: hpham474 Date: Mon, 1 Nov 2021 04:48:21 -0500 Subject: [PATCH] Background music volume can be adjusted --- godot_ship/project.godot | 2 +- ...AudioController.tscn => BackgroundMusic.tscn} | 4 +--- godot_ship/scenes/Options.tscn | 4 ++++ .../script/audio controller/AudioController.gd | 16 ---------------- godot_ship/script/options/OptionsController.gd | 2 ++ 5 files changed, 8 insertions(+), 20 deletions(-) rename godot_ship/scenes/{AudioController.tscn => BackgroundMusic.tscn} (66%) delete mode 100644 godot_ship/script/audio controller/AudioController.gd diff --git a/godot_ship/project.godot b/godot_ship/project.godot index 36867c8..200002f 100644 --- a/godot_ship/project.godot +++ b/godot_ship/project.godot @@ -18,7 +18,7 @@ config/icon="res://icon.png" MessageBus="*res://script/game/Message Bus.gd" OptionsController="*res://script/options/OptionsController.gd" -AudioController="*res://scenes/AudioController.tscn" +AudioController="*res://scenes/BackgroundMusic.tscn" [display] diff --git a/godot_ship/scenes/AudioController.tscn b/godot_ship/scenes/BackgroundMusic.tscn similarity index 66% rename from godot_ship/scenes/AudioController.tscn rename to godot_ship/scenes/BackgroundMusic.tscn index 2f790fd..ed365b8 100644 --- a/godot_ship/scenes/AudioController.tscn +++ b/godot_ship/scenes/BackgroundMusic.tscn @@ -1,12 +1,10 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=2 format=2] [ext_resource path="res://BGM - Captain Scurvy.ogg" type="AudioStream" id=1] -[ext_resource path="res://script/audio controller/AudioController.gd" type="Script" id=2] [node name="Control" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 -script = ExtResource( 2 ) __meta__ = { "_edit_use_anchors_": false } diff --git a/godot_ship/scenes/Options.tscn b/godot_ship/scenes/Options.tscn index 841e34e..89a9372 100644 --- a/godot_ship/scenes/Options.tscn +++ b/godot_ship/scenes/Options.tscn @@ -68,6 +68,8 @@ focus_neighbour_top = NodePath("../../../Back") focus_neighbour_bottom = NodePath("../../Volume Setting/Volume Slider") focus_next = NodePath("../../Volume Setting/Volume Slider") focus_previous = NodePath("../../../Back") +min_value = -80.0 +max_value = 0.0 step = 10.0 tick_count = 11 __meta__ = { @@ -98,6 +100,8 @@ focus_neighbour_top = NodePath("../../SFX Setting/SFX Slider") focus_neighbour_bottom = NodePath("../../../Buttons/Dark") focus_next = NodePath("../../../Buttons/Dark") focus_previous = NodePath("../../SFX Setting/SFX Slider") +min_value = -80.0 +max_value = 0.0 step = 10.0 tick_count = 11 ticks_on_borders = true diff --git a/godot_ship/script/audio controller/AudioController.gd b/godot_ship/script/audio controller/AudioController.gd deleted file mode 100644 index 4301c20..0000000 --- a/godot_ship/script/audio controller/AudioController.gd +++ /dev/null @@ -1,16 +0,0 @@ -extends Control - - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" - - -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): -# pass diff --git a/godot_ship/script/options/OptionsController.gd b/godot_ship/script/options/OptionsController.gd index 62169d8..82f018e 100644 --- a/godot_ship/script/options/OptionsController.gd +++ b/godot_ship/script/options/OptionsController.gd @@ -24,6 +24,7 @@ func set_theme(theme_name): emit_signal("change_theme", theme) func set_mus_vol(volume): mus_vol = volume + AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), mus_vol) emit_signal("change_mus_volume", mus_vol) func set_sfx_vol(volume): sfx_vol = volume @@ -43,6 +44,7 @@ func load_options(): mus_vol = f.get_var() sfx_vol = f.get_var() f.close() + AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), mus_vol) # Getters func get_theme():