class_name ClosableMenu extends Control

@export var isOpen: bool:
  set(newValue):
    isOpen = newValue
    visible = newValue
    if newValue:
      opened.emit()
    else:
      closed.emit()
  get():
    return isOpen

signal closed
signal opened

func _enter_tree() -> void:
  visible = isOpen

func _exit_tree() -> void:
  visible = false

func _ready() -> void:
  visible = isOpen
  print("ClosableMenu is ready, isOpen: ", isOpen)

func close() -> void:
  isOpen = false

func open() -> void:
  isOpen = true

func toggle() -> void:
  isOpen = !isOpen
