summaryrefslogtreecommitdiff
path: root/login.gd
diff options
context:
space:
mode:
Diffstat (limited to 'login.gd')
-rw-r--r--login.gd83
1 files changed, 83 insertions, 0 deletions
diff --git a/login.gd b/login.gd
new file mode 100644
index 0000000..97daf51
--- /dev/null
+++ b/login.gd
@@ -0,0 +1,83 @@
+extends Control
+
+
+var account_information: LoginServerLoginSuccessPacket
+var character_server_information: Array
+
+var current_character_information: CharacterInformation
+
+
+func _ready() -> void:
+ switch_screen(%Login)
+
+
+func switch_screen(screen: Node):
+ for node in get_children():
+ node.visible = false
+
+ screen.visible = true
+
+
+func _on_login_pressed() -> void:
+ account_information = Network.login_server.login(%Username.text, %Password.text)
+ character_server_information = account_information.character_server_information
+
+ for node in %CharacterServerList.get_children():
+ node.queue_free()
+
+ for info: CharacterServerInformation in character_server_information:
+ var select_character_server = Button.new()
+ select_character_server.text = info.server_name
+ select_character_server.pressed.connect(func():
+ _on_character_server_login_pressed(info)
+ )
+ %CharacterServerList.add_child(select_character_server)
+
+ switch_screen(%CharacterServer)
+
+
+func _on_character_server_login_pressed(character_server_info: CharacterServerInformation) -> void:
+ Network.character_server = CharacterServer.new(
+ character_server_info.get_server_ip(),
+ character_server_info.server_port
+ )
+
+ var _response = Network.character_server.login(
+ account_information.account_id,
+ account_information.login_id1,
+ account_information.login_id2,
+ account_information.gender
+ )
+ print(inst_to_dict(_response))
+
+ var response = Network.character_server.request_character_list()
+
+ for slot_idx in response.character_information.size():
+ var info: CharacterInformation = response.character_information[slot_idx]
+ var character = Button.new()
+ character.text = info.name
+ character.pressed.connect(func():
+ current_character_information = info
+ _on_character_selected_pressed(slot_idx)
+ )
+ %CharacterList.add_child(character)
+
+ switch_screen(%CharacterSelection)
+
+
+func _on_character_selected_pressed(slot_idx: int):
+ var success = Network.character_server.select_character(slot_idx)
+
+ Network.map_server = MapServer.new(
+ success.get_map_server_ip(),
+ success.map_server_port
+ )
+
+ var _response = Network.map_server.login(
+ account_information.account_id,
+ current_character_information.character_id,
+ account_information.login_id1,
+ account_information.gender
+ )
+
+ # TODO: switch to game :)