From e08a29e73ea4f7e6d78e8e7f5a6e7033dbc1f542 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Mon, 30 Dec 2024 15:15:01 +0100 Subject: next commit --- ui/login/character_selection_item.gd | 54 +++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 16 deletions(-) (limited to 'ui/login/character_selection_item.gd') diff --git a/ui/login/character_selection_item.gd b/ui/login/character_selection_item.gd index 7ad77b6..fa0fad8 100644 --- a/ui/login/character_selection_item.gd +++ b/ui/login/character_selection_item.gd @@ -4,14 +4,22 @@ extends PanelContainer signal selected -static var selected_item: CharacterSelectionItem: +var is_hovered := false: set(value): - var previous_item = selected_item - selected_item = value - if previous_item: - previous_item.draw_highlight(false) + is_hovered = value + draw_highlight(value) + +var is_selected := false: + set(value): + is_selected = value + draw_highlight(false) + if value: + selected.emit() -var is_hovered := false + +func _ready() -> void: + clear() + %SelectionBorder.visible = false func initialize_with_info(info: CharacterInformation): @@ -21,6 +29,7 @@ func initialize_with_info(info: CharacterInformation): Constants.FilePaths.get_player_head(info.gender, info.head), ] ) + %Head.visible = true %Body.texture = load( "%s/%s/000.png" % [ @@ -28,30 +37,43 @@ func initialize_with_info(info: CharacterInformation): Constants.FilePaths.get_player_body(info.gender, info.job), ] ) - - %Name.text = info.name + %Body.visible = true + + +func clear(): + %Head.visible = false + %Body.visible = false func draw_highlight(is_highlighted: bool): - if selected_item == self: - is_highlighted = true - 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(): - selected_item = self - draw_highlight(true) - selected.emit() + is_selected = true func _on_mouse_entered() -> void: is_hovered = true - draw_highlight(is_hovered) func _on_mouse_exited() -> void: is_hovered = false - draw_highlight(is_hovered) -- cgit v1.2.3