extends Control

var sphere_mesh = SphereMesh.new()
var quad_mesh = QuadMesh.new()

var screen_bound_mesh: MeshInstance2D

var button_pannel: 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
	button_pannel = get_node("VBoxContainer")
	screen_bound_mesh = get_node("ScreenBounds")
	
func update():
	if DisplayData.DISPLAY_MODE_IDX == 0:
		screen_bound_mesh.mesh = sphere_mesh
		screen_bound_mesh.mesh.radius = DisplayData.DISPLAY_PARAMETERS[0]
		screen_bound_mesh.mesh.height = DisplayData.DISPLAY_PARAMETERS[1]
	else:
		screen_bound_mesh.mesh = quad_mesh
		screen_bound_mesh.mesh.size = Vector2(DisplayData.DISPLAY_PARAMETERS[0], DisplayData.DISPLAY_PARAMETERS[1])
	screen_bound_mesh.position = DisplayData.WINDOW_CENTER
	
	var pannel_size = button_pannel.size
	var panel_position = DisplayData.WINDOW_CENTER + Vector2(0., 0.5) * DisplayData.DISPLAY_PARAMETERS[0]
	panel_position -= Vector2(pannel_size.x/2, pannel_size.y/2)
	button_pannel.position = panel_position


func _on_new_pressed() -> void:
	pass # Replace with function body.


func _on_save_pressed() -> void:
	SettingSignals.widget_settings_saved.emit()
	SettingSignals.widget_settings_closed.emit()


func _on_close_pressed() -> void:
	SettingSignals.widget_settings_closed.emit()
