extends Control

var menu_panel: Node
var display_settings_instance: Node
var widget_settings_instance: Node

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	DisplayData.WINDOW_SIZE = Vector2(DisplayServer.window_get_size())
	DisplayData.WINDOW_CENTER = DisplayData.WINDOW_SIZE / 2
	
	menu_panel = get_node("Panel")
	display_settings_instance = get_node("DisplaySettings")
	remove_child(display_settings_instance)
	widget_settings_instance = get_node("WidgetSettings")
	remove_child(widget_settings_instance)
	
	SettingSignals.display_settings_closed.connect(_on_display_settings_closed)
	SettingSignals.widget_settings_closed.connect(_on_widget_settings_closed)


func _on_open_display_settings_pressed() -> void:
	add_child(display_settings_instance)
	remove_child(menu_panel)
	display_settings_instance.update()

func _on_display_settings_closed():
	add_child(menu_panel)
	remove_child(display_settings_instance)
	display_settings_instance.update()

func _on_open_widget_settings_pressed() -> void:
	add_child(widget_settings_instance)
	remove_child(menu_panel)
	widget_settings_instance.update()

func _on_widget_settings_closed():
	add_child(menu_panel)
	remove_child(widget_settings_instance)

func _on_close_settings_menu_pressed() -> void:
	SettingSignals.settings_closed.emit()
