Cow_Life_Sim_RPG/UI/MainMenu/MainMenu.gd

51 lines
1.4 KiB
GDScript

extends Node2D
func _ready():
var currentTotalVol = SaveManager.get_global_value("totalVol", 0.5)
SaveManager.set_global_value("totalVol", currentTotalVol)
AudioServer.set_bus_volume_db(0, linear_to_db(currentTotalVol))
var savedMusicVol = SaveManager.get_global_value("musicVol", 1)
AudioServer.set_bus_volume_db(1, linear_to_db(savedMusicVol))
var savedSFXVol = SaveManager.get_global_value("sfxVol", 1)
AudioServer.set_bus_volume_db(2, linear_to_db(savedSFXVol))
if currentTotalVol > 0:
%MuteButton.text = "Mute"
else:
%MuteButton.text = "Unmute"
SoundManager.play_menu_music()
func _on_enter_button_pressed():
%SaveMenu.visible = true
%InitialMenu.visible = false
%SavesDisplayer.update_save_displays()
%SavesDisplayer.hide_delete_buttons()
func _on_save_back_button_pressed():
%SaveMenu.visible = false
%InitialMenu.visible = true
func _on_mute_button_pressed():
var currentTotalVol = SaveManager.get_global_value("totalVol", 0.5)
if currentTotalVol > 0:
currentTotalVol = 0
%MuteButton.text = "Unmute"
else:
currentTotalVol = 0.5
%MuteButton.text = "Mute"
SaveManager.set_global_value("totalVol", currentTotalVol)
AudioServer.set_bus_volume_db(0, linear_to_db(currentTotalVol))
func _on_quit_button_pressed():
get_tree().quit()
func _on_discord_button_pressed():
OS.shell_open("http://discord.gg/XC8sy7kCx2")
func _on_twitch_button_pressed():
OS.shell_open("https://www.twitch.tv/pajamabee_vegan")