diff options
Diffstat (limited to 'ui/login.gd')
-rw-r--r-- | ui/login.gd | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/ui/login.gd b/ui/login.gd index 3180024..8cabec8 100644 --- a/ui/login.gd +++ b/ui/login.gd @@ -88,23 +88,20 @@ func _on_character_server_login_pressed(character_server_info: CharacterServerIn var character_list: CharacterServerLoginSuccessCharacterListPacket = await Network.character_server.logged_in_character_list - for node in %CharacterList.get_children(): - node.queue_free() - - for slot_idx in character_list.character_information.size(): - var info: CharacterInformation = character_list.character_information[slot_idx] - var character = preload("res://ui/login/character_selection_item.tscn").instantiate() - character.initialize_with_info(info) - character.selected.connect(func(): - current_character_slot_idx = slot_idx - current_character_information = info - %CharacterSelectionStatus.set_info(info) - ) - %CharacterList.add_child(character) + var login_character_list := LoginCharacterList.from_character_list_packet(character_list) + %CharacterSelectionList.login_character_list = login_character_list + %CharacterSelectionList.selected.connect(func(slot_idx: int): + current_character_slot_idx = slot_idx + %CharacterSelectionSlotLabel.text = "%s/%s" % [str(slot_idx + 1), login_character_list.slot_count] - # pre-select first character - if slot_idx == 0: - character.selected.emit() + if slot_idx < character_list.character_information.size(): + current_character_information = character_list.character_information[slot_idx] + else: + current_character_information = null + ) + + # pre-select first character + %CharacterSelectionList.select(0) switch_screen(%CharacterSelection) |