using Godot;

namespace Hellswipers;

public partial class MainMenu : Control {
	public override void _Ready() {
		Settings.Init();
		
		var sb = GetNode<TextureToggleButton>("Settings/SoundToggle");
		sb.State = Settings.SoundMute;
		sb.StateChanged = v => Settings.SoundMute = v;

		var mb = GetNode<TextureToggleButton>("Settings/MusicToggle");
		mb.State = Settings.MusicMute;
		mb.StateChanged = v => Settings.MusicMute = v;

		GetNode<Button>("StartButton").Pressed +=
			() => GetTree().ChangeSceneToPacked(ResourceLoader.Load<PackedScene>("res://game/game.tscn"));

		GetNode<Button>("ExitButton").Pressed += () => {
			var tree = GetTree();
			tree.Root.PropagateNotification((int)NotificationWMCloseRequest);
			tree.Quit();
		};
	}
}
