class_name CharacterSelectionItem extends PanelContainer signal selected var is_hovered := false: set(value): is_hovered = value draw_highlight(value) var is_selected := false: set(value): is_selected = value draw_highlight(false) if value: selected.emit() func _ready() -> void: clear() %SelectionBorder.visible = false func initialize_with_info(info: CharacterInformation): %Head.texture = load( "%s/%s/000.png" % [ "res://client_data/data/sprite", Constants.FilePaths.get_player_head(info.gender, info.head), ] ) %Head.visible = true %Body.texture = load( "%s/%s/000.png" % [ "res://client_data/data/sprite", Constants.FilePaths.get_player_body(info.gender, info.job), ] ) %Body.visible = true func clear(): %Head.visible = false %Body.visible = false func draw_highlight(is_highlighted: bool): var style_box: StyleBoxFlat = get_theme_stylebox("panel").duplicate() style_box.draw_center = is_highlighted add_theme_stylebox_override("panel", style_box) if is_selected: %SelectionBorder.visible = true var style_box2: StyleBoxFlat = get_theme_stylebox("panel").duplicate() style_box2.border_color.a = 0.0 add_theme_stylebox_override("panel", style_box2) # spacing "fix" #%SelectionBorder.top_level = true #await get_tree().process_frame #%SelectionBorder.global_position = global_position else: %SelectionBorder.visible = false var style_box2: StyleBoxFlat = get_theme_stylebox("panel").duplicate() style_box2.border_color.a = 1.0 add_theme_stylebox_override("panel", style_box2) func _on_gui_input(event: InputEvent) -> void: if event.is_pressed(): is_selected = true func _on_mouse_entered() -> void: is_hovered = true func _on_mouse_exited() -> void: is_hovered = false