summaryrefslogtreecommitdiff
path: root/ui/login/login_character_selection_list.gd
diff options
context:
space:
mode:
Diffstat (limited to 'ui/login/login_character_selection_list.gd')
-rw-r--r--ui/login/login_character_selection_list.gd34
1 files changed, 26 insertions, 8 deletions
diff --git a/ui/login/login_character_selection_list.gd b/ui/login/login_character_selection_list.gd
index 221c47f..bd19fa1 100644
--- a/ui/login/login_character_selection_list.gd
+++ b/ui/login/login_character_selection_list.gd
@@ -3,6 +3,7 @@ extends Control
signal selected(slot_idx: int)
+signal requested_login(slot_idx: int)
var item_scene := preload("res://ui/login/character_selection_item.tscn")
@@ -40,7 +41,6 @@ func set_selected_slot_index(value: int) -> void:
if selected_slot_index == value:
return
- var character_list := login_character_list.character_information
var maximum_slot_count := login_character_list.slot_count
%CharacterList.get_child(selected_slot_index - slot_offset).is_selected = false
@@ -57,13 +57,14 @@ func set_selected_slot_index(value: int) -> void:
slot_offset = min(selected_slot_index, maximum_slot_count - displayed_slots_count)
elif selected_slot_index < slot_offset:
#slot_offset = selected_slot_index
- slot_offset = max(0, selected_slot_index - displayed_slots_count)
+ slot_offset = max(0, selected_slot_index - (displayed_slots_count - 1))
draw()
%CharacterList.get_child(selected_slot_index - slot_offset).is_selected = true
- if selected_slot_index < character_list.size():
- %CharacterSelectionStatus.set_info(character_list[selected_slot_index])
+ var info = login_character_list.get_info_for_slot(selected_slot_index)
+ if info:
+ %CharacterSelectionStatus.set_info(info)
else:
$CharacterSelectionStatus.clear()
@@ -79,14 +80,12 @@ func draw():
if not login_character_list:
return
- var character_information: Array[CharacterInformation] = login_character_list.character_information
-
for display_slot_idx in displayed_slots_count:
var item: CharacterSelectionItem = %CharacterList.get_child(display_slot_idx)
var slot_idx = slot_offset + display_slot_idx
- if slot_idx < character_information.size():
- var info: CharacterInformation = character_information[slot_idx]
+ var info = login_character_list.get_info_for_slot(slot_idx)
+ if info:
item.initialize_with_info(info)
else:
item.clear()
@@ -94,6 +93,10 @@ func draw():
if item.selected.is_connected(_on_item_selected):
item.selected.disconnect(_on_item_selected)
item.selected.connect(_on_item_selected.bind(slot_idx))
+
+ if item.gui_input.is_connected(_on_item_gui_input):
+ item.gui_input.disconnect(_on_item_gui_input)
+ item.gui_input.connect(_on_item_gui_input.bind(slot_idx))
func select(slot_idx: int):
@@ -104,6 +107,21 @@ func _on_item_selected(slot_idx: int):
selected_slot_index = slot_idx
+func _on_item_gui_input(event: InputEvent, slot_idx: int) -> void:
+ if event is InputEventMouseButton and event.double_click:
+ requested_login.emit(slot_idx)
+
+
+func _input(event: InputEvent) -> void:
+ if event.is_action_pressed("ui_accept"):
+ requested_login.emit(selected_slot_index)
+
+ if event.is_action_pressed("ui_left"):
+ %ButtonLeft.pressed.emit()
+ if event.is_action_pressed("ui_right"):
+ %ButtonRight.pressed.emit()
+
+
func _on_button_left_pressed() -> void:
selected_slot_index -= 1