summaryrefslogtreecommitdiff
path: root/ui/login.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-20 11:42:22 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-20 11:42:22 +0100
commitf4e07d090cded56ebab54363f1b47f1ea45c8682 (patch)
tree616698bb4306184469b92d68d3f74dfb61d02c72 /ui/login.gd
parent75793bd23d275d10d6a0bd8024a7e412b64557ce (diff)
next commit
Diffstat (limited to 'ui/login.gd')
-rw-r--r--ui/login.gd35
1 files changed, 32 insertions, 3 deletions
diff --git a/ui/login.gd b/ui/login.gd
index 540355f..73b294c 100644
--- a/ui/login.gd
+++ b/ui/login.gd
@@ -9,7 +9,7 @@ var current_character_information: CharacterInformation
func _ready() -> void:
switch_screen(%Login)
- $BackgroundMusic.play()
+ #$BackgroundMusic.play()
%ChatWindow.visible = false
@@ -43,6 +43,11 @@ func _on_login_pressed() -> void:
select_character_server.pressed.connect(_on_character_server_login_pressed.bind(info))
%CharacterServerList.add_child(select_character_server)
+ # TODO: if setting is true to skip character server selection when only one server is available
+ #if character_server_information.size() == 1:
+ #(%CharacterServerList.get_child(0) as Button).pressed.emit()
+ #else:
+ #switch_screen(%CharacterServer)
switch_screen(%CharacterServer)
@@ -63,22 +68,36 @@ func _on_character_server_login_pressed(character_server_info: CharacterServerIn
var response = await Network.character_server.received_packet
if response is CharacterSelectionFailedPacket:
print("character server login failed")
- %ChatWindow.add_message("character server login failed")
+ %ChatWindow.add_message("character server login failed", ChatMessageFormat.new())
return
get_tree().root.add_child(Network.character_server.get_keep_alive_timer())
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/character_selection_item.tscn").instantiate()
character.initialize_with_info(info)
- character.pressed.connect(func():
+ character.activated.connect(func():
+ $CharacterSelection/VBoxContainer/HBoxContainer/CharacterInfo/Label.text = info.name
+ $CharacterSelection/VBoxContainer/HBoxContainer/CharacterInfo/HBoxContainer/Label2.text = str(info.level)
+ $CharacterSelection/VBoxContainer/HBoxContainer/CharacterInfo/HBoxContainer2/Label2.text = str(info.job_level)
+ $CharacterSelection/VBoxContainer/HBoxContainer/CharacterInfo/HBoxContainer4/Label2.text = Constants.Job.find_key(info.job)
+ $CharacterSelection/VBoxContainer/HBoxContainer/CharacterInfo/HBoxContainer3/Label2.text = str(info.strength)
+ )
+ character.selected.connect(func():
current_character_information = info
_on_character_selected_pressed(slot_idx)
)
%CharacterList.add_child(character)
+
+ # pre-select first character
+ if slot_idx == 0:
+ character.activated.emit()
switch_screen(%CharacterSelection)
@@ -118,3 +137,13 @@ func _on_character_selected_pressed(slot_idx: int):
Network.map_server.send(map_loaded_packet)
# TODO: check which map server packets to send next
+
+
+func _on_character_server_back_button_pressed() -> void:
+ $ButtonClickSound.play()
+ switch_screen(%Login)
+
+
+func _on_character_selection_back_button_pressed() -> void:
+ $ButtonClickSound.play()
+ switch_screen(%CharacterServer)