feat: added user registration
parent
2257bc4a9f
commit
77f5fc96ef
|
@ -5,6 +5,14 @@ extends Control
|
|||
@export var PasswordInput : LineEdit
|
||||
@export var LoginBtn : Button
|
||||
|
||||
@export var RegistrationInput : LineEdit
|
||||
@export var RegistrationPasswordInput : LineEdit
|
||||
@export var RegistrationPasswordInput_2 : LineEdit
|
||||
@export var RegistrationBtn : Button
|
||||
|
||||
@export var LoginContainer : VBoxContainer
|
||||
@export var RegistrationContainer : VBoxContainer
|
||||
|
||||
#--------------------------------------------------------------------------------------------------#
|
||||
# Initialization
|
||||
func _ready():
|
||||
|
@ -30,7 +38,7 @@ func _on_login_btn_button_down():
|
|||
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:
|
||||
response = GATEWAY.rpc_id(1, 'authorization', LoginInput.text, PasswordInput.text.md5_text())
|
||||
GATEWAY.rpc_id(1, 'authorization', LoginInput.text, PasswordInput.text.md5_text())
|
||||
|
||||
|
||||
func _on_connected_ok():
|
||||
|
@ -61,3 +69,27 @@ func _on_authorization_fail():
|
|||
|
||||
func _on_authorization_ok():
|
||||
pass
|
||||
|
||||
|
||||
func _on_registration_button_button_down():
|
||||
LoginContainer.visible = false
|
||||
RegistrationContainer.visible = true
|
||||
|
||||
|
||||
func _on_back_btn_button_down():
|
||||
LoginContainer.visible = true
|
||||
RegistrationContainer.visible = false
|
||||
|
||||
|
||||
func _on_registration_btn_button_up():
|
||||
RegistrationBtn.disabled = true
|
||||
RegistrationInput.editable = false
|
||||
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.md5_text() == RegistrationPasswordInput_2.text.md5_text():
|
||||
GATEWAY.rpc_id(1, 'registration', LoginInput.text, RegistrationPasswordInput.text.md5_text())
|
||||
|
|
|
@ -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")]
|
||||
[node name="LoginSreen" type="Control" node_paths=PackedStringArray("InfoText", "LoginInput", "PasswordInput", "LoginBtn", "RegistrationInput", "RegistrationPasswordInput", "RegistrationPasswordInput_2", "RegistrationBtn", "LoginContainer", "RegistrationContainer")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
@ -31,6 +31,12 @@ InfoText = NodePath("MainBox/InfoBob/InfoText")
|
|||
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")
|
||||
RegistrationPasswordInput = NodePath("MainBox/LoginBox/RegistrationPanelBox/PasswordInput")
|
||||
RegistrationPasswordInput_2 = NodePath("MainBox/LoginBox/RegistrationPanelBox/PasswordInput_2")
|
||||
RegistrationBtn = NodePath("MainBox/LoginBox/RegistrationPanelBox/RegistrationButtonsBox/RegistrationBtn")
|
||||
LoginContainer = NodePath("MainBox/LoginBox/LoginPanelBox")
|
||||
RegistrationContainer = NodePath("MainBox/LoginBox/RegistrationPanelBox")
|
||||
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
|
@ -126,6 +132,59 @@ layout_mode = 2
|
|||
size_flags_horizontal = 10
|
||||
text = "Exit"
|
||||
|
||||
[node name="RegistrationButton" type="Button" parent="MainBox/LoginBox/LoginPanelBox"]
|
||||
layout_mode = 2
|
||||
text = "Registration"
|
||||
flat = true
|
||||
|
||||
[node name="RegistrationPanelBox" type="VBoxContainer" parent="MainBox/LoginBox"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="RegistrationLabel" type="Label" parent="MainBox/LoginBox/RegistrationPanelBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 2
|
||||
text = "Registrate on Cashflow World"
|
||||
label_settings = SubResource("LabelSettings_iy7sm")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="LoginInput" type="LineEdit" parent="MainBox/LoginBox/RegistrationPanelBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 2
|
||||
placeholder_text = "login"
|
||||
alignment = 1
|
||||
|
||||
[node name="PasswordInput" type="LineEdit" parent="MainBox/LoginBox/RegistrationPanelBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 2
|
||||
placeholder_text = "password"
|
||||
alignment = 1
|
||||
secret = true
|
||||
|
||||
[node name="PasswordInput_2" type="LineEdit" parent="MainBox/LoginBox/RegistrationPanelBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 2
|
||||
placeholder_text = "password repeat"
|
||||
alignment = 1
|
||||
secret = true
|
||||
|
||||
[node name="RegistrationButtonsBox" type="HBoxContainer" parent="MainBox/LoginBox/RegistrationPanelBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="RegistrationBtn" type="Button" parent="MainBox/LoginBox/RegistrationPanelBox/RegistrationButtonsBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 2
|
||||
text = "Registrate"
|
||||
|
||||
[node name="BackBtn" type="Button" parent="MainBox/LoginBox/RegistrationPanelBox/RegistrationButtonsBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 10
|
||||
text = "Back"
|
||||
|
||||
[node name="InfoBob" type="MarginContainer" parent="MainBox"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 5
|
||||
|
@ -139,3 +198,6 @@ horizontal_alignment = 1
|
|||
|
||||
[connection signal="button_down" from="MainBox/LoginBox/LoginPanelBox/LoginButtonsBox/LoginBtn" to="." method="_on_login_btn_button_down"]
|
||||
[connection signal="pressed" from="MainBox/LoginBox/LoginPanelBox/LoginButtonsBox/ExitBtn" to="." method="_on_exit_btn_pressed"]
|
||||
[connection signal="button_down" from="MainBox/LoginBox/LoginPanelBox/RegistrationButton" to="." method="_on_registration_button_button_down"]
|
||||
[connection signal="button_up" from="MainBox/LoginBox/RegistrationPanelBox/RegistrationButtonsBox/RegistrationBtn" to="." method="_on_registration_btn_button_up"]
|
||||
[connection signal="button_down" from="MainBox/LoginBox/RegistrationPanelBox/RegistrationButtonsBox/BackBtn" to="." method="_on_back_btn_button_down"]
|
||||
|
|
|
@ -15,6 +15,9 @@ var clientId : int
|
|||
signal unauthorizated
|
||||
signal authorizated
|
||||
|
||||
signal unregistrated
|
||||
signal registrated
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------#
|
||||
# Initialization
|
||||
|
@ -40,6 +43,7 @@ func _ready():
|
|||
multiplayer.connected_to_server.connect(_on_connected_ok)
|
||||
multiplayer.connection_failed.connect(_on_connected_fail)
|
||||
self.unauthorizated.connect(_on_authorization_fail)
|
||||
self.unregistrated.connect(_on_registration_fail)
|
||||
|
||||
#--------------------------------------------------------------------------------------------------#
|
||||
# Methods
|
||||
|
@ -109,7 +113,26 @@ func _on_authorization_fail():
|
|||
multiplayer.emit_signal("server_disconnected")
|
||||
|
||||
|
||||
func _on_registration_fail(_reason : String):
|
||||
if debug:
|
||||
print('Authorization failed: ' + _reason)
|
||||
multiplayer.multiplayer_peer = null
|
||||
multiplayer.emit_signal("server_disconnected")
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------#
|
||||
# RPC Server
|
||||
@rpc("any_peer", "reliable", "call_local", 1)
|
||||
func authorization(): pass
|
||||
|
||||
@rpc("any_peer", "reliable", "call_local", 1)
|
||||
func registration(): pass
|
||||
|
||||
#--------------------------------------------------------------------------------------------------#
|
||||
# RPC Client
|
||||
@rpc("any_peer", "reliable", "call_local", 1)
|
||||
func is_registrated(_isRegistrated, _reason):
|
||||
if !_isRegistrated:
|
||||
self.registrated.emit(_reason)
|
||||
else:
|
||||
self.unregistrated.emit()
|
||||
|
|
Loading…
Reference in New Issue