class_name Game extends Node

@onready var debug_menu: DebugMenu = $DebugMenu
@onready var active_scene_container: Node = $ActiveSceneContainer

var _default_scene: PackedScene = preload("res://scenes/views/main_menu_view.tscn")

func _ready() -> void:
	debug_menu.active_scene_container = active_scene_container
	debug_menu.close_requested.connect(_close_debug_menu)
	debug_menu.visible = false
	var instance := _default_scene.instantiate()
	active_scene_container.add_child(instance)

func _unhandled_input(event: InputEvent) -> void:
	if event.is_action_pressed("debug_toggle"):
		_toggle_debug_menu()

func _toggle_debug_menu() -> void:
	if debug_menu.visible:
		_close_debug_menu()
	else:
		_open_debug_menu()

func _open_debug_menu() -> void:
	debug_menu.visible = true
	active_scene_container.process_mode = Node.PROCESS_MODE_DISABLED

func _close_debug_menu() -> void:
	debug_menu.visible = false
	active_scene_container.process_mode = Node.PROCESS_MODE_INHERIT
