Compare commits
No commits in common. "8feb7bbc47eb90f077baaec6fa7376fe58062ce5" and "f87278323dbf4efba19af808d2c98a0d4092623a" have entirely different histories.
8feb7bbc47
...
f87278323d
Binary file not shown.
@ -1,19 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="oggvorbisstr"
|
||||
type="AudioStreamOggVorbis"
|
||||
uid="uid://64dplcgx2icb"
|
||||
path="res://.godot/imported/silly-menu-hover-test.ogg-101de051c9810c756b28483653a4c618.oggvorbisstr"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/audio/silly-menu-hover-test.ogg"
|
||||
dest_files=["res://.godot/imported/silly-menu-hover-test.ogg-101de051c9810c756b28483653a4c618.oggvorbisstr"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
Binary file not shown.
@ -1,19 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="oggvorbisstr"
|
||||
type="AudioStreamOggVorbis"
|
||||
uid="uid://txgki0ijeuud"
|
||||
path="res://.godot/imported/silly-test.ogg-4a08df8a26b9ee1e5d13235e013c7cfc.oggvorbisstr"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/audio/silly-test.ogg"
|
||||
dest_files=["res://.godot/imported/silly-test.ogg-4a08df8a26b9ee1e5d13235e013c7cfc.oggvorbisstr"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
@ -1,12 +0,0 @@
|
||||
[gd_resource type="AudioBusLayout" format=3]
|
||||
|
||||
[resource]
|
||||
bus/0/name = "Master"
|
||||
bus/0/volume_db = 0.0
|
||||
bus/0/send = ""
|
||||
bus/1/name = "Music"
|
||||
bus/1/volume_db = 0.0
|
||||
bus/1/send = "Master"
|
||||
bus/2/name = "SFX"
|
||||
bus/2/volume_db = 0.0
|
||||
bus/2/send = "Master"
|
||||
@ -15,15 +15,6 @@ run/main_scene="uid://b4k81taauef4q"
|
||||
config/features=PackedStringArray("4.5", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[audio]
|
||||
|
||||
bus_layout="res://audio/bus_layout.tres"
|
||||
|
||||
[autoload]
|
||||
|
||||
MenuMusic="*res://scenes/UI/menu_music.tscn"
|
||||
MenuSfx="*res://scenes/UI/menu_sfx.tscn"
|
||||
|
||||
[dotnet]
|
||||
|
||||
project/assembly_name="Promiscuity"
|
||||
|
||||
@ -2,9 +2,6 @@ extends CanvasLayer
|
||||
|
||||
@onready var pause_menu = $Control
|
||||
|
||||
func _ready() -> void:
|
||||
_register_focus_sounds()
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
if get_tree().paused:
|
||||
@ -25,21 +22,3 @@ func _on_quit_button_pressed():
|
||||
|
||||
func _on_continue_button_pressed():
|
||||
resume_game()
|
||||
|
||||
func _register_focus_sounds() -> void:
|
||||
if pause_menu == null:
|
||||
return
|
||||
var vbox := pause_menu.get_node_or_null("VBoxContainer")
|
||||
if vbox == null:
|
||||
return
|
||||
for child in vbox.get_children():
|
||||
if child is BaseButton:
|
||||
var button: BaseButton = child
|
||||
if not button.is_connected("focus_entered", Callable(self, "_on_menu_item_focus")):
|
||||
button.focus_entered.connect(_on_menu_item_focus)
|
||||
if not button.is_connected("mouse_entered", Callable(self, "_on_menu_item_focus")):
|
||||
button.mouse_entered.connect(_on_menu_item_focus)
|
||||
|
||||
func _on_menu_item_focus() -> void:
|
||||
if MenuSfx:
|
||||
MenuSfx.play_hover()
|
||||
|
||||
@ -1,112 +1,5 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var _tab_bar: TabBar = $MarginContainer/VBoxContainer/TabBar
|
||||
@onready var _tab_container: TabContainer = $MarginContainer/VBoxContainer/TabContainer
|
||||
@onready var _music_volume_slider: HSlider = $MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/MusicVolumeGroup/MusicVolumeSlider
|
||||
@onready var _music_volume_value: Label = $MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/MusicVolumeGroup/MusicVolumeValue
|
||||
@onready var _music_mute_checkbox: CheckBox = $MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/MusicVolumeGroup/MusicMuteCheckBox
|
||||
@onready var _sfx_volume_slider: HSlider = $MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/SfxVolumeGroup/SfxVolumeSlider
|
||||
@onready var _sfx_volume_value: Label = $MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/SfxVolumeGroup/SfxVolumeValue
|
||||
@onready var _sfx_mute_checkbox: CheckBox = $MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/SfxVolumeGroup/SfxMuteCheckBox
|
||||
@onready var _menu_music: AudioStreamPlayer = get_tree().get_root().get_node_or_null("MenuMusic")
|
||||
@onready var _menu_sfx: AudioStreamPlayer = get_tree().get_root().get_node_or_null("MenuSfx")
|
||||
|
||||
func _ready() -> void:
|
||||
_tab_bar.tab_changed.connect(_on_tab_bar_tab_changed)
|
||||
_tab_container.tab_changed.connect(_on_tab_container_tab_changed)
|
||||
_tab_container.current_tab = _tab_bar.current_tab
|
||||
_music_volume_slider.value_changed.connect(_on_music_volume_changed)
|
||||
_music_mute_checkbox.toggled.connect(_on_music_mute_toggled)
|
||||
_sfx_volume_slider.value_changed.connect(_on_sfx_volume_changed)
|
||||
_sfx_mute_checkbox.toggled.connect(_on_sfx_mute_toggled)
|
||||
_sync_audio_controls()
|
||||
_register_focus_sounds()
|
||||
extends Node
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
if event.is_action_pressed("ui_cancel"): # 'ui_cancel' is a built-in action defined in Project > Project Settings > Input Map
|
||||
get_tree().change_scene_to_file("uid://b4k81taauef4q")
|
||||
|
||||
func _on_tab_bar_tab_changed(tab_index: int) -> void:
|
||||
if _tab_container.current_tab != tab_index:
|
||||
_tab_container.current_tab = tab_index
|
||||
|
||||
func _on_tab_container_tab_changed(tab_index: int) -> void:
|
||||
if _tab_bar.current_tab != tab_index:
|
||||
_tab_bar.current_tab = tab_index
|
||||
|
||||
func _sync_audio_controls() -> void:
|
||||
var value: float = 0.7
|
||||
var muted: bool = false
|
||||
if _menu_music:
|
||||
if _menu_music.has_method("get_user_volume"):
|
||||
value = _menu_music.get_user_volume()
|
||||
if _menu_music.has_method("is_user_muted"):
|
||||
muted = _menu_music.is_user_muted()
|
||||
_apply_audio_control_state(_music_volume_slider, _music_mute_checkbox, _music_volume_value, value, muted)
|
||||
|
||||
var sfx_value: float = 0.7
|
||||
var sfx_muted: bool = false
|
||||
if _menu_sfx:
|
||||
if _menu_sfx.has_method("get_user_volume"):
|
||||
sfx_value = _menu_sfx.get_user_volume()
|
||||
if _menu_sfx.has_method("is_user_muted"):
|
||||
sfx_muted = _menu_sfx.is_user_muted()
|
||||
_apply_audio_control_state(_sfx_volume_slider, _sfx_mute_checkbox, _sfx_volume_value, sfx_value, sfx_muted)
|
||||
|
||||
func _on_music_volume_changed(value: float) -> void:
|
||||
if _menu_music and _menu_music.has_method("set_user_volume"):
|
||||
_menu_music.set_user_volume(value)
|
||||
_update_volume_label(_music_volume_value, value, _music_mute_checkbox.button_pressed)
|
||||
|
||||
func _on_music_mute_toggled(pressed: bool) -> void:
|
||||
if _menu_music and _menu_music.has_method("set_user_muted"):
|
||||
_menu_music.set_user_muted(pressed)
|
||||
_music_volume_slider.editable = not pressed
|
||||
_update_volume_label(_music_volume_value, _music_volume_slider.value, pressed)
|
||||
|
||||
func _on_sfx_volume_changed(value: float) -> void:
|
||||
if _menu_sfx and _menu_sfx.has_method("set_user_volume"):
|
||||
_menu_sfx.set_user_volume(value)
|
||||
_update_volume_label(_sfx_volume_value, value, _sfx_mute_checkbox.button_pressed)
|
||||
|
||||
func _on_sfx_mute_toggled(pressed: bool) -> void:
|
||||
if _menu_sfx and _menu_sfx.has_method("set_user_muted"):
|
||||
_menu_sfx.set_user_muted(pressed)
|
||||
_sfx_volume_slider.editable = not pressed
|
||||
_update_volume_label(_sfx_volume_value, _sfx_volume_slider.value, pressed)
|
||||
|
||||
func _apply_audio_control_state(slider: HSlider, checkbox: CheckBox, value_label: Label, value: float, muted: bool) -> void:
|
||||
slider.set_block_signals(true)
|
||||
slider.value = value
|
||||
slider.set_block_signals(false)
|
||||
slider.editable = not muted
|
||||
checkbox.set_block_signals(true)
|
||||
checkbox.button_pressed = muted
|
||||
checkbox.set_block_signals(false)
|
||||
_update_volume_label(value_label, value, muted)
|
||||
|
||||
func _update_volume_label(value_label: Label, value: float, muted: bool) -> void:
|
||||
if muted:
|
||||
value_label.text = "Muted"
|
||||
else:
|
||||
var percent: int = int(round(value * 100.0))
|
||||
value_label.text = str(percent) + "%"
|
||||
|
||||
func _register_focus_sounds() -> void:
|
||||
_connect_focus_recursive(self)
|
||||
|
||||
func _connect_focus_recursive(node: Node) -> void:
|
||||
if node is Control:
|
||||
var control: Control = node
|
||||
if control.focus_mode != Control.FOCUS_NONE:
|
||||
if not control.is_connected("focus_entered", Callable(self, "_on_menu_item_focus")):
|
||||
control.focus_entered.connect(_on_menu_item_focus)
|
||||
if control.has_signal("mouse_entered") and (control is BaseButton or control.focus_mode != Control.FOCUS_NONE):
|
||||
if not control.is_connected("mouse_entered", Callable(self, "_on_menu_item_focus")):
|
||||
control.mouse_entered.connect(_on_menu_item_focus)
|
||||
for child in node.get_children():
|
||||
_connect_focus_recursive(child)
|
||||
|
||||
func _on_menu_item_focus() -> void:
|
||||
if MenuSfx:
|
||||
MenuSfx.play_hover()
|
||||
|
||||
@ -43,115 +43,3 @@ tab_3/title = "Dev"
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
tabs_visible = false
|
||||
|
||||
[node name="Gameplay" type="Control" parent="MarginContainer/VBoxContainer/TabContainer"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Video" type="Control" parent="MarginContainer/VBoxContainer/TabContainer"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Audio" type="Control" parent="MarginContainer/VBoxContainer/TabContainer"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="AudioVBox" type="VBoxContainer" parent="MarginContainer/VBoxContainer/TabContainer/Audio"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/separation = 10
|
||||
offset_left = 120.0
|
||||
offset_top = 240.0
|
||||
offset_right = -120.0
|
||||
offset_bottom = -40.0
|
||||
|
||||
[node name="MusicVolumeLabel" type="Label" parent="MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox"]
|
||||
layout_mode = 2
|
||||
text = "Music Volume"
|
||||
horizontal_alignment = 1
|
||||
size_flags_horizontal = 4
|
||||
|
||||
[node name="MusicVolumeGroup" type="HBoxContainer" parent="MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
theme_override_constants/separation = 12
|
||||
alignment = 1
|
||||
custom_minimum_size = Vector2(0, 40)
|
||||
|
||||
[node name="MusicVolumeSlider" type="HSlider" parent="MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/MusicVolumeGroup"]
|
||||
layout_mode = 2
|
||||
min_value = 0.0
|
||||
max_value = 1.0
|
||||
step = 0.01
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(320, 0)
|
||||
|
||||
[node name="MusicVolumeValue" type="Label" parent="MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/MusicVolumeGroup"]
|
||||
layout_mode = 2
|
||||
text = "70%"
|
||||
size_flags_horizontal = 1
|
||||
horizontal_alignment = 1
|
||||
custom_minimum_size = Vector2(60, 0)
|
||||
|
||||
[node name="MusicMuteCheckBox" type="CheckBox" parent="MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/MusicVolumeGroup"]
|
||||
layout_mode = 2
|
||||
text = "Mute"
|
||||
size_flags_horizontal = 1
|
||||
|
||||
[node name="SfxVolumeLabel" type="Label" parent="MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox"]
|
||||
layout_mode = 2
|
||||
text = "Menu SFX Volume"
|
||||
horizontal_alignment = 1
|
||||
size_flags_horizontal = 4
|
||||
|
||||
[node name="SfxVolumeGroup" type="HBoxContainer" parent="MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
theme_override_constants/separation = 12
|
||||
alignment = 1
|
||||
custom_minimum_size = Vector2(0, 40)
|
||||
|
||||
[node name="SfxVolumeSlider" type="HSlider" parent="MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/SfxVolumeGroup"]
|
||||
layout_mode = 2
|
||||
min_value = 0.0
|
||||
max_value = 1.0
|
||||
step = 0.01
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(320, 0)
|
||||
|
||||
[node name="SfxVolumeValue" type="Label" parent="MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/SfxVolumeGroup"]
|
||||
layout_mode = 2
|
||||
text = "70%"
|
||||
size_flags_horizontal = 1
|
||||
horizontal_alignment = 1
|
||||
custom_minimum_size = Vector2(60, 0)
|
||||
|
||||
[node name="SfxMuteCheckBox" type="CheckBox" parent="MarginContainer/VBoxContainer/TabContainer/Audio/AudioVBox/SfxVolumeGroup"]
|
||||
layout_mode = 2
|
||||
text = "Mute"
|
||||
size_flags_horizontal = 1
|
||||
|
||||
[node name="Dev" type="Control" parent="MarginContainer/VBoxContainer/TabContainer"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
@ -1,106 +0,0 @@
|
||||
extends AudioStreamPlayer
|
||||
|
||||
const MENU_SCENES: Dictionary = {
|
||||
"res://scenes/UI/start_screen.tscn": true,
|
||||
"res://scenes/UI/Settings.tscn": true,
|
||||
}
|
||||
|
||||
const CONFIG_PATH := "user://settings.cfg"
|
||||
const CONFIG_SECTION := "audio"
|
||||
const CONFIG_KEY_MUSIC_VOLUME := "menu_music_volume"
|
||||
const CONFIG_KEY_MUSIC_MUTED := "menu_music_muted"
|
||||
const DEFAULT_VOLUME := 0.7
|
||||
|
||||
var _last_scene: Node = null
|
||||
var _user_volume_linear: float = DEFAULT_VOLUME
|
||||
var _is_muted: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
set_process(true)
|
||||
_load_settings()
|
||||
_apply_volume()
|
||||
_update_playback(get_tree().current_scene)
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var current := get_tree().current_scene
|
||||
if current != _last_scene:
|
||||
_update_playback(current)
|
||||
elif _should_play_scene(current) and not playing and not _is_muted and _user_volume_linear > 0.0:
|
||||
play()
|
||||
|
||||
func _update_playback(scene: Node) -> void:
|
||||
if scene == null:
|
||||
_last_scene = null
|
||||
return
|
||||
_last_scene = scene
|
||||
if _should_play_scene(scene):
|
||||
if not playing:
|
||||
play()
|
||||
elif playing:
|
||||
stop()
|
||||
|
||||
func _should_play_scene(scene: Node) -> bool:
|
||||
if scene == null:
|
||||
return false
|
||||
var scene_path: String = scene.get_scene_file_path()
|
||||
if scene_path.is_empty():
|
||||
return false
|
||||
return MENU_SCENES.has(scene_path)
|
||||
|
||||
func set_user_volume(value: float) -> void:
|
||||
var clamped_value: float = clamp(value, 0.0, 1.0)
|
||||
if is_equal_approx(_user_volume_linear, clamped_value):
|
||||
return
|
||||
_user_volume_linear = clamped_value
|
||||
_apply_volume()
|
||||
_save_settings()
|
||||
|
||||
func get_user_volume() -> float:
|
||||
return _user_volume_linear
|
||||
|
||||
func set_user_muted(muted: bool) -> void:
|
||||
var new_muted: bool = muted
|
||||
if _is_muted == new_muted:
|
||||
return
|
||||
_is_muted = new_muted
|
||||
_apply_volume()
|
||||
_save_settings()
|
||||
|
||||
func is_user_muted() -> bool:
|
||||
return _is_muted
|
||||
|
||||
func _apply_volume() -> void:
|
||||
if _is_muted or _user_volume_linear <= 0.0:
|
||||
volume_db = -80.0
|
||||
else:
|
||||
volume_db = linear_to_db(_user_volume_linear)
|
||||
|
||||
func _load_settings() -> void:
|
||||
var config: ConfigFile = ConfigFile.new()
|
||||
var err: int = config.load(CONFIG_PATH)
|
||||
if err == OK:
|
||||
var stored_volume: float = float(config.get_value(CONFIG_SECTION, CONFIG_KEY_MUSIC_VOLUME, DEFAULT_VOLUME))
|
||||
_user_volume_linear = clamp(stored_volume, 0.0, 1.0)
|
||||
var stored_muted: bool = bool(config.get_value(CONFIG_SECTION, CONFIG_KEY_MUSIC_MUTED, false))
|
||||
_is_muted = stored_muted
|
||||
elif err == ERR_DOES_NOT_EXIST:
|
||||
_user_volume_linear = DEFAULT_VOLUME
|
||||
_is_muted = false
|
||||
else:
|
||||
push_warning("Failed to load settings.cfg: %s" % err)
|
||||
_user_volume_linear = DEFAULT_VOLUME
|
||||
_is_muted = false
|
||||
|
||||
func _save_settings() -> void:
|
||||
var config: ConfigFile = ConfigFile.new()
|
||||
var err: int = config.load(CONFIG_PATH)
|
||||
if err != OK and err != ERR_DOES_NOT_EXIST:
|
||||
push_warning("Failed to load settings.cfg before saving: %s" % err)
|
||||
config = ConfigFile.new()
|
||||
elif err != OK:
|
||||
config = ConfigFile.new()
|
||||
config.set_value(CONFIG_SECTION, CONFIG_KEY_MUSIC_VOLUME, _user_volume_linear)
|
||||
config.set_value(CONFIG_SECTION, CONFIG_KEY_MUSIC_MUTED, _is_muted)
|
||||
var save_err: int = config.save(CONFIG_PATH)
|
||||
if save_err != OK:
|
||||
push_warning("Failed to save settings.cfg: %s" % save_err)
|
||||
@ -1 +0,0 @@
|
||||
uid://l0cqi7dvoou3
|
||||
@ -1,13 +0,0 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dfmq1n507y7d3"]
|
||||
|
||||
[ext_resource type="AudioStream" uid="uid://bftct74auklgw" path="res://assets/audio/silly-test.ogg" id="1_ek0t3"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/UI/menu_music.gd" id="2_21d4q"]
|
||||
|
||||
[node name="MenuMusic" type="AudioStreamPlayer"]
|
||||
bus = &"Music"
|
||||
stream = ExtResource("1_ek0t3")
|
||||
autoplay = true
|
||||
volume_db = -3.0
|
||||
priority = 10.0
|
||||
script = ExtResource("2_21d4q")
|
||||
@ -1,76 +0,0 @@
|
||||
extends AudioStreamPlayer
|
||||
|
||||
const CONFIG_PATH := "user://settings.cfg"
|
||||
const CONFIG_SECTION := "audio"
|
||||
const CONFIG_KEY_VOLUME := "menu_sfx_volume"
|
||||
const CONFIG_KEY_MUTED := "menu_sfx_muted"
|
||||
const DEFAULT_VOLUME := 0.7
|
||||
|
||||
var _user_volume_linear: float = DEFAULT_VOLUME
|
||||
var _is_muted: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
_load_settings()
|
||||
_apply_volume()
|
||||
|
||||
func play_hover() -> void:
|
||||
if stream == null or _is_muted or _user_volume_linear <= 0.0:
|
||||
return
|
||||
play(0.0)
|
||||
|
||||
func set_user_volume(value: float) -> void:
|
||||
var clamped_value: float = clamp(value, 0.0, 1.0)
|
||||
if is_equal_approx(_user_volume_linear, clamped_value):
|
||||
return
|
||||
_user_volume_linear = clamped_value
|
||||
_apply_volume()
|
||||
_save_settings()
|
||||
|
||||
func get_user_volume() -> float:
|
||||
return _user_volume_linear
|
||||
|
||||
func set_user_muted(muted: bool) -> void:
|
||||
if _is_muted == muted:
|
||||
return
|
||||
_is_muted = muted
|
||||
_apply_volume()
|
||||
_save_settings()
|
||||
if _is_muted:
|
||||
stop()
|
||||
|
||||
func is_user_muted() -> bool:
|
||||
return _is_muted
|
||||
|
||||
func _apply_volume() -> void:
|
||||
if _is_muted or _user_volume_linear <= 0.0:
|
||||
volume_db = -80.0
|
||||
else:
|
||||
volume_db = linear_to_db(_user_volume_linear)
|
||||
|
||||
func _load_settings() -> void:
|
||||
var config: ConfigFile = ConfigFile.new()
|
||||
var err: int = config.load(CONFIG_PATH)
|
||||
if err == OK:
|
||||
_user_volume_linear = clamp(float(config.get_value(CONFIG_SECTION, CONFIG_KEY_VOLUME, DEFAULT_VOLUME)), 0.0, 1.0)
|
||||
_is_muted = bool(config.get_value(CONFIG_SECTION, CONFIG_KEY_MUTED, false))
|
||||
elif err == ERR_DOES_NOT_EXIST:
|
||||
_user_volume_linear = DEFAULT_VOLUME
|
||||
_is_muted = false
|
||||
else:
|
||||
push_warning("Failed to load settings.cfg: %s" % err)
|
||||
_user_volume_linear = DEFAULT_VOLUME
|
||||
_is_muted = false
|
||||
|
||||
func _save_settings() -> void:
|
||||
var config: ConfigFile = ConfigFile.new()
|
||||
var err: int = config.load(CONFIG_PATH)
|
||||
if err != OK and err != ERR_DOES_NOT_EXIST:
|
||||
push_warning("Failed to load settings.cfg before saving: %s" % err)
|
||||
config = ConfigFile.new()
|
||||
elif err != OK:
|
||||
config = ConfigFile.new()
|
||||
config.set_value(CONFIG_SECTION, CONFIG_KEY_VOLUME, _user_volume_linear)
|
||||
config.set_value(CONFIG_SECTION, CONFIG_KEY_MUTED, _is_muted)
|
||||
var save_err: int = config.save(CONFIG_PATH)
|
||||
if save_err != OK:
|
||||
push_warning("Failed to save settings.cfg: %s" % save_err)
|
||||
@ -1 +0,0 @@
|
||||
uid://c7ixr4hbh5ad6
|
||||
@ -1,13 +0,0 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dt785sv7ie7uj"]
|
||||
|
||||
[ext_resource type="AudioStream" uid="uid://64dplcgx2icb" path="res://assets/audio/silly-menu-hover-test.ogg" id="1_a5j5k"]
|
||||
[ext_resource type="Script" path="res://scenes/UI/menu_sfx.gd" id="1_ijvfa"]
|
||||
|
||||
[node name="MenuSfx" type="AudioStreamPlayer"]
|
||||
bus = &"SFX"
|
||||
stream = ExtResource("1_a5j5k")
|
||||
volume_db = -6.0
|
||||
autoplay = false
|
||||
priority = 0.5
|
||||
max_polyphony = 4
|
||||
script = ExtResource("1_ijvfa")
|
||||
@ -1,17 +1,5 @@
|
||||
extends Control
|
||||
|
||||
func _ready():
|
||||
_register_focus_sounds()
|
||||
|
||||
func _register_focus_sounds() -> void:
|
||||
var button_container := $MarginContainer/MarginContainer/VBoxContainer
|
||||
for child in button_container.get_children():
|
||||
if child is BaseButton:
|
||||
var button: BaseButton = child
|
||||
if not button.is_connected("focus_entered", Callable(self, "_on_menu_item_focus")):
|
||||
button.focus_entered.connect(_on_menu_item_focus)
|
||||
if not button.is_connected("mouse_entered", Callable(self, "_on_menu_item_focus")):
|
||||
button.mouse_entered.connect(_on_menu_item_focus)
|
||||
|
||||
func _on_start_button_pressed():
|
||||
get_tree().change_scene_to_file("uid://dchj6g2i8ebph")
|
||||
@ -21,7 +9,3 @@ func _on_settings_button_pressed():
|
||||
|
||||
func _on_quit_button_pressed():
|
||||
get_tree().quit()
|
||||
|
||||
func _on_menu_item_focus() -> void:
|
||||
if MenuSfx:
|
||||
MenuSfx.play_hover()
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
[ext_resource type="Theme" uid="uid://wpxmub0n2dr3" path="res://themes/button_theme.tres" id="1_tx5wa"]
|
||||
[ext_resource type="Texture2D" uid="uid://dhuosr0p605gj" path="res://assets/images/pp_start_bg.png" id="2_r2jwc"]
|
||||
[ext_resource type="Theme" uid="uid://tn8qndst18d6" path="res://themes/title_font_theme.tres" id="4_hm208"]
|
||||
|
||||
[node name="StartScreen" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user