Implemented spawn points correctly. Added saving & loading (currently only implemented with the spawn_index). You can now set spawn indicies in the DynamicAreaLoader to automatically load when the game is set to that value (on ready). Added configuration warnings to DynamicAreaLoader & PlayerSpawnPoint Added some generic translation (pot) files. Added AudioManager autoload to play, stop, fade audio streams (and set the bus directly). Added SceneFader autoload. Added SaveManager autoload. Added OptionsMenu with currently only volume sliders and a fullscreen toggle button. Added PauseMenu
62 lines
1.4 KiB
GDScript
62 lines
1.4 KiB
GDScript
class_name MainMenu
|
|
extends Node
|
|
|
|
const AMBIENCE_STREAM: AudioStream = preload("res://Dark House.wav")
|
|
|
|
@onready var continue_button: Button = %ContinueButton
|
|
@onready var new_game_button: Button = %NewGameButton
|
|
@onready var quit_button: Button = %QuitButton
|
|
@onready var options_menu: Control = $OptionsMenu
|
|
@onready var main_menu_ui: Control = $MainMenuUI
|
|
|
|
|
|
func _ready() -> void:
|
|
continue_button.disabled = not SaveManager.save_exists()
|
|
|
|
AudioManager.play_audio(AMBIENCE_STREAM, AudioManager.MUSIC)
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if options_menu.is_visible_in_tree() and event.is_action_pressed(&"pause"):
|
|
main_menu_ui.show()
|
|
options_menu.hide()
|
|
|
|
|
|
func load_game() -> void:
|
|
AudioManager.fade_audio(AMBIENCE_STREAM, -80.0, SceneFader.fade_in_duration, AudioManager.MUSIC, true)
|
|
SceneFader.load_to_path(GameGlobals.GAME_PATH)
|
|
|
|
|
|
func _on_new_game_button_pressed() -> void:
|
|
if SceneFader.is_fading:
|
|
return
|
|
|
|
GameGlobals.reset_game()
|
|
SaveManager.delete_save()
|
|
SaveManager.save_game()
|
|
load_game()
|
|
|
|
|
|
func _on_continue_button_pressed() -> void:
|
|
if SceneFader.is_fading:
|
|
return
|
|
|
|
GameGlobals.reset_game()
|
|
SaveManager.load_game()
|
|
load_game()
|
|
|
|
|
|
func _on_quit_button_pressed() -> void:
|
|
if SceneFader.is_fading:
|
|
return
|
|
|
|
get_tree().quit()
|
|
|
|
|
|
func _on_settings_button_pressed() -> void:
|
|
if SceneFader.is_fading:
|
|
return
|
|
|
|
main_menu_ui.hide()
|
|
options_menu.show()
|