class_name ScreenBase
extends Control

@export var fade_in_duration := 0.5
@export var fade_out_duration := 0.5

func _ready() -> void:
	get_tree().call_group(GameConstants.GROUP_BUTTONS, "set_disabled", true)
	visible = false
	modulate.a = 0.0


func _input(event: InputEvent) -> void:
	if event is InputEventMouseButton:
		if event.button_index == MOUSE_BUTTON_LEFT:
			if event.pressed:
				AudioManager.play_sfx(GameConstants.SFX_MOUSE_CLICK)


func fade_in():
	visible = true
	var tween = create_tween()
	tween.set_pause_mode(Tween.TWEEN_PAUSE_PROCESS)
	tween.tween_property(self, "modulate:a", 1.0, fade_in_duration)
	return tween


func fade_out():
	get_tree().call_group(GameConstants.GROUP_BUTTONS, "set_disabled", true)
	var tween = create_tween()
	tween.set_pause_mode(Tween.TWEEN_PAUSE_PROCESS)
	tween.tween_property(self, "modulate:a", 0.0, fade_out_duration)
	return tween
