extends Control


@onready var picker = $"picker/picker"
@onready var pause_menu = $"pause_menu/pause_menu"


@onready var level_name_wrapper = $"level_name"
@onready var level_name_label = $"level_name/label"
var editor



			
func initialize(_editor):
	self.pause_menu.set_mode_editor(_editor)
	self.editor = _editor

func _ready():
	self.level_name_label.set_message_translation(false)
	self.level_name_label.notification(NOTIFICATION_TRANSLATION_CHANGED)
	
func _process(_delta):
	#when paused, it calls hide_pause_menu on the menu itself, which unpauses the scene tree
	if Input.is_action_just_pressed("ui_cancel"):
		if pause_menu.is_visible():
			hide_pause_menu()
	

func show_pause_menu():
	self.pause_menu.show_pause_menu()
	
	
func hide_pause_menu():
	if pause_menu.is_visible():
		self.pause_menu.hide_pause_menu()

func show_picker():
	self.picker.show_picker()


func hide_picker():
	self.picker.hide_picker()


func close_all_popups():
	if self.picker.is_visible():
		self.hide_picker()


func is_popup_open():
	if self.picker.is_visible():
		return true
	return false

func show_level_name():
	self.level_name_wrapper.show()

func set_level_name(level_name, skip_show=false):
	self.level_name_label.set_text(level_name)
	self.picker.set_level_name(level_name)

	if level_name != "" and not skip_show:
		self.level_name_wrapper.show()
	else:
		self.level_name_wrapper.hide()
