Added mute button and volume slider to text log

This commit is contained in:
Bad Manners 2024-03-14 20:54:48 -03:00
parent 125e1e5edc
commit c76c9f7268
5 changed files with 154 additions and 15 deletions

View file

@ -56,17 +56,14 @@ func _process(delta):
func mute():
MusicManager.set_volume(-80.0)
#SoundManager.set_volume(-80.0)
FileGlobals.set_global_data("muted", true)
%MuteTextureRect.texture = load("res://images/ui/speaker-x-mark.svg")
func unmute():
var volume = FileGlobals.get_global_data("volume", 0.0)
MusicManager.set_volume(FileGlobals.get_global_data("volume", 0.0))
#SoundManager.set_volume(0.0)
#SoundManager.play("sfx_menu", "advance")
SoundManager.play_varied("sfx_menu", "advance", 1.0, volume)
FileGlobals.set_global_data("muted", false)
SoundManager.play_varied("sfx_menu", "advance", 1.0, volume)
%MuteTextureRect.texture = load("res://images/ui/speaker-wave.svg")
func init_credits():

View file

@ -27,6 +27,8 @@ func _ready():
$FishingMinigame.visible = false
$ChatLog.visible = false
%VolumeSlider.value = FileGlobals.get_global_data("volume", 0.0)
# Get current load source from file globals
load_game(FileGlobals.current_load_source, FileGlobals.current_load_file)
#run_visual_novel(vn_current_name, FileGlobals.current_load_source == FileGlobals.VNLoadSource.NEW_GAME, vn_save_state)
@ -270,5 +272,28 @@ func _on_close_chat_log_button_pressed():
toggle_chatlog()
func _on_quicksave_button_pressed():
$VNInterpreter.advance_sfx()
if save_game(FileGlobals.VNSaveTarget.MANUAL_SAVE):
quick_saved.emit()
func _on_mute_button_pressed():
if FileGlobals.get_global_data("muted"):
unmute()
else:
mute()
func mute():
MusicManager.set_volume(-80.0)
FileGlobals.set_global_data("muted", true)
%MuteTextureRect.texture = load("res://images/ui/speaker-x-mark.svg")
func unmute():
MusicManager.set_volume(FileGlobals.get_global_data("volume", 0.0))
FileGlobals.set_global_data("muted", false)
$VNInterpreter.advance_sfx()
%MuteTextureRect.texture = load("res://images/ui/speaker-wave.svg")
func _on_volume_slider_value_changed(value):
FileGlobals.set_global_data("volume", value)
if not FileGlobals.get_global_data("muted", false):
MusicManager.set_volume(value)

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=386 format=3 uid="uid://4v1jmfn8kjpg"]
[gd_scene load_steps=391 format=3 uid="uid://4v1jmfn8kjpg"]
[ext_resource type="PackedScene" uid="uid://b3hnb4vtqq6p3" path="res://scenes/ui_elements/textbox.tscn" id="1_7wls5"]
[ext_resource type="Script" path="res://scenes/screens/visual_novel.gd" id="1_hggao"]
@ -290,6 +290,7 @@
[ext_resource type="Texture2D" uid="uid://dub5udosnoiq" path="res://images/backgrounds/post_vore/7/0007.png" id="264_eaa5q"]
[ext_resource type="Texture2D" uid="uid://cqrhow2eq3or4" path="res://images/backgrounds/post_vore/7/0008.png" id="265_3v4cf"]
[ext_resource type="Texture2D" uid="uid://c3v27acg1h0b0" path="res://images/backgrounds/post_vore/7/0009.png" id="266_54x1f"]
[ext_resource type="Texture2D" uid="uid://c22jdpfc55mf6" path="res://images/ui/speaker-wave.svg" id="276_5v5x7"]
[ext_resource type="Script" path="res://addons/resonate/music_manager/music_bank.gd" id="276_lqqnr"]
[ext_resource type="Script" path="res://addons/resonate/music_manager/music_track_resource.gd" id="277_c7pkt"]
[ext_resource type="Script" path="res://addons/resonate/music_manager/music_stem_resource.gd" id="278_tabqe"]
@ -1286,6 +1287,50 @@ corner_radius_top_right = 14
corner_radius_bottom_right = 14
corner_radius_bottom_left = 14
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_72dix"]
bg_color = Color(0.74902, 0.74902, 0.74902, 1)
corner_radius_top_left = 14
corner_radius_top_right = 14
corner_radius_bottom_right = 14
corner_radius_bottom_left = 14
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_m03ku"]
bg_color = Color(0.517647, 0.517647, 0.517647, 1)
border_width_left = 3
border_width_top = 3
border_width_right = 3
border_width_bottom = 3
border_color = Color(0.203922, 0.482353, 0.85098, 1)
corner_radius_top_left = 14
corner_radius_top_right = 14
corner_radius_bottom_right = 14
corner_radius_bottom_left = 14
expand_margin_left = 3.0
expand_margin_top = 3.0
expand_margin_right = 3.0
expand_margin_bottom = 3.0
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jpjds"]
bg_color = Color(0.882353, 0.894118, 0.960784, 0.752941)
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dek81"]
bg_color = Color(0.882353, 0.894118, 0.960784, 1)
border_width_left = 2
border_width_top = 2
border_width_bottom = 2
border_color = Color(0.203922, 0.482353, 0.85098, 1)
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
expand_margin_left = 1.0
expand_margin_top = 1.0
expand_margin_bottom = 1.0
[sub_resource type="Animation" id="Animation_l8rvu"]
resource_name = "RESET"
length = 0.001
@ -1681,8 +1726,8 @@ theme_override_constants/margin_top = 20
[node name="CloseChatLogButton" type="Button" parent="ChatLog/CloseChatLogButtonContainer"]
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
focus_neighbor_right = NodePath("../../QuicksaveButtonContainer/QuicksaveButton")
focus_next = NodePath("../../QuicksaveButtonContainer/QuicksaveButton")
focus_neighbor_right = NodePath("../../MuteButtonContainer/VBoxContainer/MuteButton")
focus_next = NodePath("../../MuteButtonContainer/VBoxContainer/MuteButton")
focus_previous = NodePath("../../QuicksaveButtonContainer/QuicksaveButton")
mouse_default_cursor_shape = 2
theme_override_styles/hover = SubResource("StyleBoxFlat_0qrrw")
@ -1716,6 +1761,78 @@ texture = ExtResource("214_pyi0s")
expand_mode = 5
stretch_mode = 5
[node name="MuteButtonContainer" type="MarginContainer" parent="ChatLog"]
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -120.0
offset_bottom = 106.0
grow_horizontal = 0
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 80
[node name="VBoxContainer" type="VBoxContainer" parent="ChatLog/MuteButtonContainer"]
layout_mode = 2
theme_override_constants/separation = 2
[node name="MuteButton" type="Button" parent="ChatLog/MuteButtonContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
size_flags_horizontal = 4
focus_neighbor_left = NodePath("../../../CloseChatLogButtonContainer/CloseChatLogButton")
focus_neighbor_right = NodePath("../../../QuicksaveButtonContainer/QuicksaveButton")
focus_neighbor_bottom = NodePath("../VolumeSlider")
focus_next = NodePath("../VolumeSlider")
focus_previous = NodePath("../../../CloseChatLogButtonContainer/CloseChatLogButton")
mouse_default_cursor_shape = 2
theme_override_styles/hover = SubResource("StyleBoxFlat_72dix")
theme_override_styles/focus = SubResource("StyleBoxFlat_m03ku")
keep_pressed_outside = true
[node name="Panel" type="Panel" parent="ChatLog/MuteButtonContainer/VBoxContainer/MuteButton"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
theme_override_styles/panel = SubResource("StyleBoxFlat_ls78b")
[node name="MarginContainer" type="MarginContainer" parent="ChatLog/MuteButtonContainer/VBoxContainer/MuteButton"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="MuteTextureRect" type="TextureRect" parent="ChatLog/MuteButtonContainer/VBoxContainer/MuteButton/MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
texture = ExtResource("276_5v5x7")
expand_mode = 5
stretch_mode = 5
[node name="VolumeSlider" type="HSlider" parent="ChatLog/MuteButtonContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(100, 30)
layout_mode = 2
focus_neighbor_left = NodePath("../../../CloseChatLogButtonContainer/CloseChatLogButton")
focus_neighbor_top = NodePath("../MuteButton")
focus_neighbor_right = NodePath("../../../QuicksaveButtonContainer/QuicksaveButton")
focus_next = NodePath("../../../QuicksaveButtonContainer/QuicksaveButton")
focus_previous = NodePath("../MuteButton")
theme_override_styles/grabber_area = SubResource("StyleBoxFlat_jpjds")
theme_override_styles/grabber_area_highlight = SubResource("StyleBoxFlat_dek81")
min_value = -10.0
max_value = 10.0
[node name="QuicksaveButtonContainer" type="MarginContainer" parent="ChatLog"]
anchors_preset = 1
anchor_left = 1.0
@ -1729,9 +1846,9 @@ theme_override_constants/margin_right = 20
[node name="QuicksaveButton" type="Button" parent="ChatLog/QuicksaveButtonContainer"]
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
focus_neighbor_left = NodePath("../../CloseChatLogButtonContainer/CloseChatLogButton")
focus_next = NodePath(".")
focus_previous = NodePath("../../CloseChatLogButtonContainer/CloseChatLogButton")
focus_neighbor_left = NodePath("../../MuteButtonContainer/VBoxContainer/MuteButton")
focus_next = NodePath("../../CloseChatLogButtonContainer/CloseChatLogButton")
focus_previous = NodePath("../../MuteButtonContainer/VBoxContainer/VolumeSlider")
mouse_default_cursor_shape = 2
theme_override_styles/hover = SubResource("StyleBoxFlat_0qrrw")
theme_override_styles/focus = SubResource("StyleBoxFlat_22vmo")
@ -1813,6 +1930,8 @@ events = Array[ExtResource("291_53dgg")]([SubResource("Resource_o5ygy"), SubReso
[connection signal="fished_all_targets" from="FishingMinigame" to="." method="_on_fishing_minigame_fished_all_targets"]
[connection signal="gui_input" from="ChatLog/ScrollContainer" to="ChatLog" method="_on_scroll_container_gui_input"]
[connection signal="pressed" from="ChatLog/CloseChatLogButtonContainer/CloseChatLogButton" to="." method="_on_close_chat_log_button_pressed"]
[connection signal="pressed" from="ChatLog/MuteButtonContainer/VBoxContainer/MuteButton" to="." method="_on_mute_button_pressed"]
[connection signal="value_changed" from="ChatLog/MuteButtonContainer/VBoxContainer/VolumeSlider" to="." method="_on_volume_slider_value_changed"]
[connection signal="pressed" from="ChatLog/QuicksaveButtonContainer/QuicksaveButton" to="." method="_on_quicksave_button_pressed"]
[connection signal="timeout" from="TimerNetCanMove" to="." method="_on_timer_net_can_move_timeout"]
[connection signal="timeout" from="TimerCanAdvanceText" to="." method="_on_timer_can_advance_text_timeout"]