summaryrefslogtreecommitdiff
path: root/ui/login/character_selection_item.gd
diff options
context:
space:
mode:
Diffstat (limited to 'ui/login/character_selection_item.gd')
-rw-r--r--ui/login/character_selection_item.gd54
1 files changed, 38 insertions, 16 deletions
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)