fix: typo #7
|
@ -0,0 +1,11 @@
|
|||
[gd_scene format=3 uid="uid://d4nhi3k0agm2q"]
|
||||
|
||||
[node name="Lobbies" type="Node"]
|
||||
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.125911, 0.125911, 0.125911, 1)
|
|
@ -20,8 +20,6 @@ func _init():
|
|||
@rpc("authority", "reliable", "call_remote", 1)
|
||||
func authorizated(_name, _token, _isAuthorized):
|
||||
if _isAuthorized:
|
||||
if GATEWAY.debug:
|
||||
print("Client token: " + _token)
|
||||
token = _token
|
||||
playerName = _name
|
||||
GATEWAY.emit_signal("authorizated")
|
||||
|
|
|
@ -6,6 +6,7 @@ extends Control
|
|||
@export var LoginBtn : Button
|
||||
|
||||
@export var RegistrationInput : LineEdit
|
||||
@export var RegistrationInputName : LineEdit
|
||||
@export var RegistrationPasswordInput : LineEdit
|
||||
@export var RegistrationPasswordInput_2 : LineEdit
|
||||
@export var RegistrationBtn : Button
|
||||
|
@ -21,6 +22,8 @@ func _ready():
|
|||
multiplayer.connection_failed.connect(_on_connected_fail)
|
||||
GATEWAY.unauthorizated.connect(_on_authorization_fail)
|
||||
GATEWAY.authorizated.connect(_on_authorization_ok)
|
||||
GATEWAY.unregistrated.connect(_on_registration_fail)
|
||||
GATEWAY.registrated.connect(_on_registration_ok)
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------#
|
||||
|
@ -68,7 +71,7 @@ func _on_authorization_fail():
|
|||
|
||||
|
||||
func _on_authorization_ok():
|
||||
pass
|
||||
start_lobbies()
|
||||
|
||||
|
||||
func _on_registration_button_button_down():
|
||||
|
@ -87,9 +90,39 @@ func _on_registration_btn_button_up():
|
|||
RegistrationPasswordInput.editable = false
|
||||
RegistrationPasswordInput_2.editable = false
|
||||
InfoText.text = "Try connected to %s on port %s...wait please..." % [GATEWAY.settings.Ip, GATEWAY.settings.Port]
|
||||
var response = await GATEWAY.connect_to_server()
|
||||
if response != Error.OK:
|
||||
InfoText.text = "Error connect to %s on port %s. ERROR: %s" % [GATEWAY.settings.Ip, GATEWAY.settings.Port, error_string(response)]
|
||||
else:
|
||||
if RegistrationPasswordInput.text != "" and RegistrationInput.text != "" and RegistrationInputName.text != "":
|
||||
if RegistrationPasswordInput.text.md5_text() == RegistrationPasswordInput_2.text.md5_text():
|
||||
GATEWAY.rpc_id(1, 'registration', LoginInput.text, RegistrationPasswordInput.text.md5_text())
|
||||
var response = await GATEWAY.connect_to_server()
|
||||
if response != Error.OK:
|
||||
InfoText.text = "Error connect to %s on port %s. ERROR: %s" % [GATEWAY.settings.Ip, GATEWAY.settings.Port, error_string(response)]
|
||||
else:
|
||||
GATEWAY.rpc_id(1, 'registration', RegistrationInput.text, RegistrationPasswordInput.text.md5_text(), RegistrationInputName.text)
|
||||
else:
|
||||
GATEWAY.unregistrated.emit("The passwords didn't match")
|
||||
else:
|
||||
GATEWAY.unregistrated.emit("Empty login or password or nikname")
|
||||
|
||||
|
||||
func _on_registration_fail(_reason):
|
||||
InfoText.text = "Registration failed: %s" % [_reason]
|
||||
RegistrationBtn.disabled = false
|
||||
RegistrationInput.editable = true
|
||||
RegistrationPasswordInput.editable = true
|
||||
RegistrationPasswordInput_2.editable = true
|
||||
|
||||
|
||||
func _on_registration_ok():
|
||||
InfoText.text = "You have successfully registered on %s on port %s" % [GATEWAY.settings.Ip, GATEWAY.settings.Port]
|
||||
RegistrationBtn.disabled = false
|
||||
RegistrationInput.editable = true
|
||||
RegistrationPasswordInput.editable = true
|
||||
RegistrationPasswordInput_2.editable = true
|
||||
LoginContainer.visible = true
|
||||
RegistrationContainer.visible = false
|
||||
start_lobbies()
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------#
|
||||
# Functions
|
||||
func start_lobbies():
|
||||
get_tree().change_scene_to_packed(load("res://data/scenes/Lobbies.tscn"))
|
||||
|
|
|
@ -17,7 +17,7 @@ font_color = Color(0.870032, 0.618438, 0.0727505, 1)
|
|||
outline_size = 1
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="LoginSreen" type="Control" node_paths=PackedStringArray("InfoText", "LoginInput", "PasswordInput", "LoginBtn", "RegistrationInput", "RegistrationPasswordInput", "RegistrationPasswordInput_2", "RegistrationBtn", "LoginContainer", "RegistrationContainer")]
|
||||
[node name="LoginSreen" type="Control" node_paths=PackedStringArray("InfoText", "LoginInput", "PasswordInput", "LoginBtn", "RegistrationInput", "RegistrationInputName", "RegistrationPasswordInput", "RegistrationPasswordInput_2", "RegistrationBtn", "LoginContainer", "RegistrationContainer")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
@ -32,6 +32,7 @@ LoginInput = NodePath("MainBox/LoginBox/LoginPanelBox/LoginInput")
|
|||
PasswordInput = NodePath("MainBox/LoginBox/LoginPanelBox/PasswordInput")
|
||||
LoginBtn = NodePath("MainBox/LoginBox/LoginPanelBox/LoginButtonsBox/LoginBtn")
|
||||
RegistrationInput = NodePath("MainBox/LoginBox/RegistrationPanelBox/LoginInput")
|
||||
RegistrationInputName = NodePath("MainBox/LoginBox/RegistrationPanelBox/NameInput")
|
||||
RegistrationPasswordInput = NodePath("MainBox/LoginBox/RegistrationPanelBox/PasswordInput")
|
||||
RegistrationPasswordInput_2 = NodePath("MainBox/LoginBox/RegistrationPanelBox/PasswordInput_2")
|
||||
RegistrationBtn = NodePath("MainBox/LoginBox/RegistrationPanelBox/RegistrationButtonsBox/RegistrationBtn")
|
||||
|
@ -156,6 +157,12 @@ size_flags_vertical = 2
|
|||
placeholder_text = "login"
|
||||
alignment = 1
|
||||
|
||||
[node name="NameInput" type="LineEdit" parent="MainBox/LoginBox/RegistrationPanelBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 2
|
||||
placeholder_text = "nikname"
|
||||
alignment = 1
|
||||
|
||||
[node name="PasswordInput" type="LineEdit" parent="MainBox/LoginBox/RegistrationPanelBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 2
|
||||
|
|
|
@ -131,8 +131,11 @@ func registration(): pass
|
|||
#--------------------------------------------------------------------------------------------------#
|
||||
# RPC Client
|
||||
@rpc("any_peer", "reliable", "call_local", 1)
|
||||
func is_registrated(_isRegistrated, _reason):
|
||||
func is_registrated(_isRegistrated, _reason, _name, _token):
|
||||
if !_isRegistrated:
|
||||
self.registrated.emit(_reason)
|
||||
self.unregistrated.emit(_reason)
|
||||
else:
|
||||
self.unregistrated.emit()
|
||||
var player = get_node(str(clientId))
|
||||
player.token = _token
|
||||
player.playerName = _name
|
||||
self.registrated.emit()
|
||||
|
|
Loading…
Reference in New Issue