extends Node

var master_volume: float = 1.0
var fullscreen: bool = false
var vsync : bool = true
var max_fps: int = 60
var glow = true

func apply_volume():
	var bus_index := AudioServer.get_bus_index("Master")
	AudioServer.set_bus_volume_db(
		bus_index,
		linear_to_db(master_volume)
	)
	
func apply_glow():
	EventBus.change_glow.emit(glow)

func apply_fullscreen():
	DisplayServer.window_set_mode(
		DisplayServer.WINDOW_MODE_FULLSCREEN if fullscreen
		else DisplayServer.WINDOW_MODE_WINDOWED
	)
	if not fullscreen:
		get_window().size = Vector2i(640*2, 360*2);

func apply_vsync():
	DisplayServer.window_set_vsync_mode(
		DisplayServer.VSYNC_ENABLED if vsync
		else DisplayServer.VSYNC_DISABLED
	)

func apply_max_fps():
	Engine.max_fps = max_fps

func apply_all():
	apply_volume()
	apply_fullscreen()
	apply_vsync()
	apply_max_fps()
