diff options
author | Logan <logan@cflip.net> | 2023-01-31 21:06:38 -0700 |
---|---|---|
committer | Logan <logan@cflip.net> | 2023-01-31 21:06:38 -0700 |
commit | 463a9df0db94d0f6957de57e7532c34b0c1bc67f (patch) | |
tree | 1c54f641230973f6b2e9346fb14160c87f5068a0 /scripts | |
parent | f82b5ab78272913b48a48c93217c8559d3160725 (diff) |
Add inital version of options menu
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/global_variables.gd | 8 | ||||
-rw-r--r-- | scripts/mainmenu.gd | 11 | ||||
-rw-r--r-- | scripts/optionsmenu.gd | 41 | ||||
-rw-r--r-- | scripts/pausemenu.gd | 6 |
4 files changed, 57 insertions, 9 deletions
diff --git a/scripts/global_variables.gd b/scripts/global_variables.gd index 3f57f95..a5d0fd5 100644 --- a/scripts/global_variables.gd +++ b/scripts/global_variables.gd @@ -2,3 +2,11 @@ extends Node var score = 0 var timer_zero = false + +# Audio Settings +var volume_master = 50 +var volume_master_enabled = true +var volume_music = 50 +var volume_music_enabled = true +var volume_sfx = 50 +var volume_sfx_enabled = true diff --git a/scripts/mainmenu.gd b/scripts/mainmenu.gd index e07b88f..d63d1be 100644 --- a/scripts/mainmenu.gd +++ b/scripts/mainmenu.gd @@ -1,23 +1,22 @@ extends Control -func _ready(): - pass func _on_StartButton_pressed(): get_tree().change_scene("res://scenes/level.tscn") func _on_LeaderboardButton_pressed(): - pass # Replace with function body. + pass func _on_HelpButton_pressed(): - pass # Replace with function body. + pass func _on_OptionsButton_pressed(): - pass # Replace with function body. + add_child(preload("res://scenes/optionsmenu.tscn").instance()) + func _on_CreditsButton_pressed(): - pass # Replace with function body. + pass func _on_QuitButton_pressed(): get_tree().quit() diff --git a/scripts/optionsmenu.gd b/scripts/optionsmenu.gd new file mode 100644 index 0000000..6951425 --- /dev/null +++ b/scripts/optionsmenu.gd @@ -0,0 +1,41 @@ +extends Control + +func _ready(): + # When scene is instanced, load the settings from singleton + $Control/VBoxContainer/GridContainer/VolumeMasterContainer/VolumeMasterValue.text = str(global_variables.volume_master) + "%" + $Control/VBoxContainer/GridContainer/VolumeMasterContainer/VolumeMasterSlider.value = global_variables.volume_master + $Control/VBoxContainer/GridContainer/VolumeMusicContainer/VolumeMusicValue.text = str(global_variables.volume_music) + "%" + $Control/VBoxContainer/GridContainer/VolumeMusicContainer/VolumeMusicSlider.value = global_variables.volume_music + $Control/VBoxContainer/GridContainer/VolumeSFXContainer/VolumeSFXValue.text = str(global_variables.volume_sfx) + "%" + $Control/VBoxContainer/GridContainer/VolumeSFXContainer/VolumeSFXSlider.value = global_variables.volume_sfx + $Control/VBoxContainer/GridContainer/FullscreenCheckBox.pressed = OS.window_fullscreen + +func _on_ReturnButton_pressed(): + queue_free() + +func _on_VolumeMasterSlider_value_changed(value): + global_variables.volume_master = value + $Control/VBoxContainer/GridContainer/VolumeMasterContainer/VolumeMasterValue.text = str(value) + "%" + if value == $Control/VBoxContainer/GridContainer/VolumeMasterContainer/VolumeMasterSlider.min_value: + global_variables.volume_music_enabled = false + else: + global_variables.volume_music_enabled = true + +func _on_VolumeMusicSlider_value_changed(value): + global_variables.volume_music = value + $Control/VBoxContainer/GridContainer/VolumeMusicContainer/VolumeMusicValue.text = str(value) + "%" + if value == $Control/VBoxContainer/GridContainer/VolumeMusicContainer/VolumeMusicSlider.min_value: + global_variables.volume_music_enabled = false + else: + global_variables.volume_music_enabled = true + +func _on_VolumeSFXSlider_value_changed(value): + global_variables.volume_sfx = value + $Control/VBoxContainer/GridContainer/VolumeSFXContainer/VolumeSFXValue.text = str(value) + "%" + if value == $Control/VBoxContainer/GridContainer/VolumeSFXContainer/VolumeSFXSlider.min_value: + global_variables.volume_sfx_enabled = false + else: + global_variables.volume_sfx_enabled = true + +func _on_FullscreenCheckBox_pressed(): + OS.window_fullscreen = !OS.window_fullscreen diff --git a/scripts/pausemenu.gd b/scripts/pausemenu.gd index 6b0acdb..3fb525d 100644 --- a/scripts/pausemenu.gd +++ b/scripts/pausemenu.gd @@ -11,10 +11,10 @@ func _on_RestartButton_pressed(): get_tree().paused = false reset_variables() -func _on_HelpButton_pressed(): - pass - func _on_OptionsButton_pressed(): + add_child(preload("res://scenes/optionsmenu.tscn").instance()) + +func _on_HelpButton_pressed(): pass func _on_QuitButton_pressed(): |