This repository has been archived on 2024-07-02. You can view files and clone it, but cannot push or open issues or pull requests.
HoppyEaster/Scripts/UI/MainMenuManager.gd

43 lines
1.4 KiB
GDScript3
Raw Normal View History

extends Node
@export var game_scene : Resource
@export var settings_scene : Resource
2023-04-10 21:31:07 +00:00
@export var default_focus : Control
2023-04-11 08:33:19 +00:00
@export var autostart_animations : Array[NodePath]
2023-04-16 07:53:02 +00:00
@export var music_player : AudioStreamPlayer
# Engine Callbackss
func _ready():
2023-04-10 21:55:55 +00:00
GlobalSettings.set_controls_from_save_file()
GlobalSettings.set_display_mode(Save.game_data.display_mode)
GlobalSettings.toggle_vsync(Save.game_data.vsync_on)
2023-04-09 13:04:49 +00:00
GlobalSettings.set_resolution(Save.game_data.current_resolution_index)
2023-04-11 14:54:04 +00:00
DisplayServer.window_set_min_size(Vector2(640,480))
GlobalSettings.update_master_volume(Save.game_data.master_volume)
GlobalSettings.update_music_volume(Save.game_data.music_volume)
GlobalSettings.update_sfx_volume(Save.game_data.sfx_volume)
default_focus.grab_focus()
2023-04-11 08:33:19 +00:00
for animation in autostart_animations:
(get_node(animation) as AnimationPlayer).play("Autostart")
2023-04-16 07:53:02 +00:00
music_player.play(0.0)
pass
func _on_play_button_pressed():
load(game_scene.resource_path)
get_tree().change_scene_to_file(game_scene.resource_path)
pass
func _on_settings_button_pressed():
var settings_scene_instance = load(settings_scene.resource_path).instantiate()
2023-04-10 20:46:15 +00:00
settings_scene_instance.on_back = Callable(func(): default_focus.grab_focus())
get_tree().current_scene.add_child(settings_scene_instance)
pass
func _on_about_button_pressed():
OS.shell_open("https://git.euph.dev/GameDev/HoppyEaster")
pass
func _on_quit_button_pressed():
get_tree().quit()
pass