extends PanelContainer

const npc_profile_window_template = preload("res://templates/npc_profile_window.tscn")
var _enabled: bool
var enabled: bool:
	get:
		return _enabled
	set(value):
		enable(value)
		
var data : Adventurer


func enable(en: bool) -> void:
	_enabled = en
	if en:
		mouse_filter=Control.MOUSE_FILTER_STOP
	else:
		mouse_filter=Control.MOUSE_FILTER_IGNORE

func setup(member : Adventurer) -> void:
	data = member
	%NameLabel.text = data.given_name + " " + data.surname
	%LevelLabel.text = str(data.level)
	if data.job:
		%JobLabel.text = data.job.name
	#TODO: Change portrait

func _on_gui_input(event: InputEvent) -> void:
	var evt = event as InputEventMouseButton
	if evt and evt.button_index == MOUSE_BUTTON_LEFT and evt.pressed:
		var window : Window = npc_profile_window_template.instantiate()
		Game.add_child(window)
		window.setup(data)
		window.popup_centered()
		window.grab_focus()
