update screen connection - just show network communication
This commit is contained in:
parent
4611d9a3b0
commit
3a8dcf0619
19 changed files with 636 additions and 499 deletions
Binary file not shown.
|
@ -46,12 +46,13 @@ func connect_to_server(host, port, user_addr, user_key, user_id, lang):
|
|||
#send_system_login(host, port, user_addr, user_key, user_id, lang)
|
||||
|
||||
func _process(delta):
|
||||
_networkconnection.process(delta)
|
||||
var data = _networkconnection.get_server_messages()
|
||||
#print("******* data:", data.size(), data)
|
||||
if data.size() > 0:
|
||||
var ele = data.pop_front()
|
||||
print("*** ele:" , ele)
|
||||
#_networkconnection.process(delta)
|
||||
#var data = _networkconnection.get_server_messages()
|
||||
##print("******* data:", data.size(), data)
|
||||
#if data.size() > 0:
|
||||
# var ele = data.pop_front()
|
||||
# print("*** ele:" , ele)
|
||||
pass
|
||||
|
||||
func _exit_tree():
|
||||
print("[net_low_level] End")
|
||||
|
|
|
@ -6,15 +6,24 @@ signal register_button_pressed
|
|||
var _username
|
||||
var _password
|
||||
|
||||
func _ready():
|
||||
$wait_connexion.hide()
|
||||
|
||||
func _on_login_button_pressed():
|
||||
emit_signal( "login_button_pressed" )
|
||||
|
||||
|
||||
func _on_play_button_pressed():
|
||||
$wait_connexion.show()
|
||||
|
||||
var username = $h_box_container/v_box_container/margin_container/login_box/email_box/email_edit.get_text();
|
||||
var password = $h_box_container/v_box_container/margin_container/login_box/password_box/password_edit.get_text();
|
||||
if username != null and username != "" and password != null and password != "":
|
||||
do_request_salt(username, password)
|
||||
else:
|
||||
$wait_connexion.hide()
|
||||
$error_dialog/v_box_container/label.text = "Username or Password empty"
|
||||
$error_dialog.popup_centered()
|
||||
|
||||
|
||||
func _on_play_without_connexion_pressed():
|
||||
|
@ -39,6 +48,7 @@ func do_request_salt(username, password):
|
|||
func _on_HTTPSalt_request_completed(result, response_code, headers, body):
|
||||
print("[login_menu:_on_HTTPSalt_request_completed] response_code:" + str(response_code))
|
||||
if response_code != 200: # || ProjectSettings.get_setting("khaganat/debug_mode"):
|
||||
$wait_connexion.hide()
|
||||
print("[login_menu:_on_HTTPSalt_request_completed] Impossible to connect")
|
||||
#emit_signal( "login_button_pressed" )
|
||||
$error_dialog/v_box_container/label.text = "Impossible to connect"
|
||||
|
@ -55,6 +65,7 @@ func _on_HTTPSalt_request_completed(result, response_code, headers, body):
|
|||
print("[login_menu] URL:" + url_login + "?" + message.get_request_string(str(s[1])));
|
||||
$HTTPRequest.request(url_login + "?" + message.get_request_string(str(s[1])));
|
||||
else:
|
||||
$wait_connexion.hide()
|
||||
print("[login_menu:_on_HTTPSalt_request_completed] error to connect")
|
||||
var regex = RegEx.new()
|
||||
regex.compile("^(\\d+)[:](?<comment>.+)$")
|
||||
|
@ -83,6 +94,7 @@ func do_request(username, password):
|
|||
func _on_HTTPRequest_request_completed(result, response_code, headers, body):
|
||||
print("[login_menu:_on_HTTPRequest_request_completed] response_code:" + str(response_code))
|
||||
if response_code != 200: # || ProjectSettings.get_setting("khaganat/debug_mode"):
|
||||
$wait_connexion.hide()
|
||||
# emit_signal( "login_button_pressed" )
|
||||
print("[login_menu:_on_HTTPRequest_request_completed] Impossible to connect")
|
||||
$error_dialog/v_box_container/label.text = "Impossible to connect"
|
||||
|
@ -91,6 +103,7 @@ func _on_HTTPRequest_request_completed(result, response_code, headers, body):
|
|||
var text = str2var(body.get_string_from_utf8())
|
||||
var lines = body.get_string_from_utf8().split("\n")
|
||||
if lines.size() != 2:
|
||||
$wait_connexion.hide()
|
||||
print("[login_menu] Impossible to connect (bad return)")
|
||||
$error_dialog/v_box_container/label.text = "Impossible to connect (bad return)"
|
||||
$error_dialog.popup_centered()
|
||||
|
@ -99,6 +112,7 @@ func _on_HTTPRequest_request_completed(result, response_code, headers, body):
|
|||
var line2 = lines[1].split("#")
|
||||
#print("[login_menu:_on_HTTPRequest_request_completed] return:'" + str(text) + "'" + str(lines.size()) + "'" + str(line1.size()) + "'" + str(line2.size()))
|
||||
if line1[0] != "1":
|
||||
$wait_connexion.hide()
|
||||
print("[login_menu] Impossible to connect (return" + line1[0] + ")")
|
||||
var regex = RegEx.new()
|
||||
regex.compile("^(\\d+)[:](?<comment>.+)$")
|
||||
|
@ -111,11 +125,13 @@ func _on_HTTPRequest_request_completed(result, response_code, headers, body):
|
|||
$error_dialog.popup_centered()
|
||||
return
|
||||
if line1.size() < 5:
|
||||
$wait_connexion.hide()
|
||||
print("[login_menu] Impossible to connect (bad return 1st line, size:" + str(line1.size()) + ")")
|
||||
$error_dialog/v_box_container/label.text = "Impossible to connect (bad return 1st line, size:" + str(line1.size()) + ")"
|
||||
$error_dialog.popup_centered()
|
||||
return
|
||||
if line2.size() != 3:
|
||||
$wait_connexion.hide()
|
||||
print("[login_menu] Impossible to connect (bad return 2nd line, size:" + str(line2.size()) + ")")
|
||||
$error_dialog/v_box_container/label.text = "Impossible to connect (bad return 2nd line, size:" + str(line2.size()) + ")"
|
||||
$error_dialog.popup_centered()
|
||||
|
@ -139,6 +155,7 @@ func _on_HTTPRequest_request_completed(result, response_code, headers, body):
|
|||
|
||||
var cookieSplit = cookie.split("|")
|
||||
if cookieSplit.size() != 3:
|
||||
$wait_connexion.hide()
|
||||
$error_dialog/v_box_container/label.text = "Impossible de se connecter (bad cookies size:" + str(cookieSplit.size()) + ")"
|
||||
$error_dialog.popup_centered()
|
||||
return
|
||||
|
@ -152,7 +169,7 @@ func _on_HTTPRequest_request_completed(result, response_code, headers, body):
|
|||
var lang = connexion.get_language()
|
||||
print("[login_menu:_on_HTTPRequest_request_completed] khaganat_host:" + khaganat_host + ", khaganat_port:" + str(khaganat_port))
|
||||
net_low_level.connect_to_server(khaganat_host, khaganat_port, UserAddr, UserKey, UserId, lang)
|
||||
|
||||
$wait_connexion.hide()
|
||||
emit_signal( "login_button_pressed" )
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
[gd_scene load_steps=8 format=2]
|
||||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://assets/GUI/themes/login_theme.theme" type="Theme" id=1]
|
||||
[ext_resource path="res://gui_scene/GUI/login/login_menu.gd" type="Script" id=2]
|
||||
[ext_resource path="res://assets/GUI/images/Login-Khanat-background.png" type="Texture" id=3]
|
||||
[ext_resource path="res://assets/GUI/fonts/ryzom.ttf" type="DynamicFontData" id=4]
|
||||
[ext_resource path="res://login_scene/wait_connexion.tscn" type="PackedScene" id=5]
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id=1]
|
||||
|
||||
|
@ -22,6 +23,9 @@ anchor_bottom = 1.0
|
|||
theme = ExtResource( 1 )
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="wait_connexion" parent="." instance=ExtResource( 5 )]
|
||||
visible = false
|
||||
|
||||
[node name="HTTPSalt" type="HTTPRequest" parent="."]
|
||||
|
||||
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
||||
|
|
|
@ -23,6 +23,9 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 1 )
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="viewport" type="Viewport" parent="."]
|
||||
size = Vector2( 1024, 1024 )
|
||||
|
@ -39,7 +42,6 @@ projection = 1
|
|||
size = 2.0
|
||||
|
||||
[node name="face_lights" type="Spatial" parent="viewport/character"]
|
||||
editor/display_folded = true
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.27005, 0 )
|
||||
|
||||
[node name="face_light_right" type="OmniLight" parent="viewport/character/face_lights"]
|
||||
|
@ -108,7 +110,6 @@ expand = true
|
|||
stretch_mode = 6
|
||||
|
||||
[node name="h_box_container" type="HBoxContainer" parent="margin_container/character_box/v_box_container"]
|
||||
editor/display_folded = true
|
||||
margin_left = 227.0
|
||||
margin_top = 672.0
|
||||
margin_right = 403.0
|
||||
|
|
|
@ -14,11 +14,13 @@ func _ready():
|
|||
$register_menu.hide()
|
||||
$license_menu.hide()
|
||||
$settings_menu.hide()
|
||||
$message_system.hide()
|
||||
|
||||
func _on_login_menu_login_button_pressed():
|
||||
print("[login_scene] Launch game")
|
||||
$login_menu.hide()
|
||||
$character_selection_menu.show()
|
||||
$message_system.show()
|
||||
# $character_selection_menu.show()
|
||||
|
||||
func _on_character_selection_menu_return_button_pressed():
|
||||
$login_menu.show()
|
||||
|
@ -60,36 +62,42 @@ func _on_login_menu_register_button_pressed():
|
|||
$register_menu.show()
|
||||
$license_menu.hide()
|
||||
$settings_menu.hide()
|
||||
$message_system.hide()
|
||||
|
||||
func _on_register_menu_cancel_button_pressed():
|
||||
$login_menu.show()
|
||||
$register_menu.hide()
|
||||
$license_menu.hide()
|
||||
$settings_menu.hide()
|
||||
$message_system.hide()
|
||||
|
||||
func _on_register_menu_license_button_pressed():
|
||||
$login_menu.hide()
|
||||
$register_menu.hide()
|
||||
$license_menu.show()
|
||||
$settings_menu.hide()
|
||||
$message_system.hide()
|
||||
|
||||
func _on_license_menu_return_button_pressed():
|
||||
$login_menu.hide()
|
||||
$register_menu.show()
|
||||
$license_menu.hide()
|
||||
$settings_menu.hide()
|
||||
$message_system.hide()
|
||||
|
||||
func _on_register_menu_register_account_created():
|
||||
$login_menu.show()
|
||||
$register_menu.hide()
|
||||
$license_menu.hide()
|
||||
$settings_menu.hide()
|
||||
$message_system.hide()
|
||||
|
||||
func _on_Settings_menu_return_pressed():
|
||||
$login_menu.show()
|
||||
$register_menu.hide()
|
||||
$license_menu.hide()
|
||||
$settings_menu.hide()
|
||||
$message_system.hide()
|
||||
|
||||
func _on_settings_button_pressed():
|
||||
$login_menu.hide()
|
||||
|
@ -97,3 +105,4 @@ func _on_settings_button_pressed():
|
|||
$license_menu.hide()
|
||||
$settings_menu.load_settings()
|
||||
$settings_menu.show()
|
||||
$message_system.hide()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=13 format=2]
|
||||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://login_scene/login_scene.gd" type="Script" id=1]
|
||||
[ext_resource path="res://login_scene/character_selection_menu.tscn" type="PackedScene" id=2]
|
||||
|
@ -12,6 +12,7 @@
|
|||
[ext_resource path="res://assets/GUI/images/Login-Khanat-help-button.png" type="Texture" id=10]
|
||||
[ext_resource path="res://assets/GUI/images/Login-Khanat-settings-button.png" type="Texture" id=11]
|
||||
[ext_resource path="res://assets/GUI/images/Login-Khanat-quit-button.png" type="Texture" id=12]
|
||||
[ext_resource path="res://login_scene/message_system.tscn" type="PackedScene" id=13]
|
||||
|
||||
[node name="login_scene" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
|
@ -29,6 +30,9 @@ visible = false
|
|||
[node name="license_menu" parent="." instance=ExtResource( 5 )]
|
||||
visible = false
|
||||
|
||||
[node name="message_system" parent="." instance=ExtResource( 13 )]
|
||||
visible = false
|
||||
|
||||
[node name="settings_menu" parent="." instance=ExtResource( 6 )]
|
||||
visible = false
|
||||
|
||||
|
@ -44,6 +48,9 @@ anchor_right = 1.0
|
|||
margin_bottom = 61.0
|
||||
rect_min_size = Vector2( 0, 61 )
|
||||
alignment = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="sound_button" type="TextureButton" parent="buttons"]
|
||||
margin_left = 1052.0
|
||||
|
@ -72,6 +79,7 @@ margin_bottom = 61.0
|
|||
texture_normal = ExtResource( 12 )
|
||||
[connection signal="character_selected" from="character_selection_menu" to="." method="_on_character_selection_menu_character_selected"]
|
||||
[connection signal="return_button_pressed" from="character_selection_menu" to="." method="_on_character_selection_menu_return_button_pressed"]
|
||||
[connection signal="login_button_pressed" from="login_menu" to="." method="_on_login_menu_login_button_pressed"]
|
||||
[connection signal="cancel_button_pressed" from="register_menu" to="." method="_on_register_menu_cancel_button_pressed"]
|
||||
[connection signal="license_button_pressed" from="register_menu" to="." method="_on_register_menu_license_button_pressed"]
|
||||
[connection signal="register_account_created" from="register_menu" to="." method="_on_register_menu_register_account_created"]
|
||||
|
|
31
login_scene/message_system.gd
Normal file
31
login_scene/message_system.gd
Normal file
|
@ -0,0 +1,31 @@
|
|||
extends Control
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
var _networkconnection = NetworkConnection.new()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
_networkconnection.process(delta)
|
||||
var data = _networkconnection.get_server_messages()
|
||||
##print("******* data:", data.size(), data)
|
||||
if data.size() > 0:
|
||||
# just to see last message (normally cleanned each time we read message)
|
||||
while data.size() > 10:
|
||||
var ele = data.pop_front()
|
||||
print("*** remove:" , ele)
|
||||
var message = "tick :" + String(_networkconnection.get_server_tick()) + '\n'
|
||||
for i in range(0, data.size()):
|
||||
message += String(data[i]) + '\n'
|
||||
$label.text = message
|
||||
|
||||
func _show():
|
||||
pass
|
29
login_scene/message_system.tscn
Normal file
29
login_scene/message_system.tscn
Normal file
|
@ -0,0 +1,29 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://assets/GUI/themes/login_theme.theme" type="Theme" id=1]
|
||||
[ext_resource path="res://assets/GUI/images/settings-Khanat-background.png" type="Texture" id=2]
|
||||
[ext_resource path="res://login_scene/message_system.gd" type="Script" id=3]
|
||||
|
||||
[node name="message_system" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="texture_rect" type="TextureRect" parent="."]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="label" type="Label" parent="."]
|
||||
margin_left = 301.0
|
||||
margin_top = 171.0
|
||||
margin_right = 1015.0
|
||||
margin_bottom = 605.0
|
||||
theme = ExtResource( 1 )
|
||||
text = "Server connecter"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
24
login_scene/wait_connexion.tscn
Normal file
24
login_scene/wait_connexion.tscn
Normal file
|
@ -0,0 +1,24 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://assets/GUI/themes/login_theme.theme" type="Theme" id=1]
|
||||
[ext_resource path="res://assets/GUI/images/register-Khanat-background.png" type="Texture" id=2]
|
||||
|
||||
[node name="wait_connexion" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="texture_rect" type="TextureRect" parent="."]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="label" type="Label" parent="."]
|
||||
margin_left = 519.333
|
||||
margin_top = 325.351
|
||||
margin_right = 696.333
|
||||
margin_bottom = 342.351
|
||||
theme = ExtResource( 1 )
|
||||
text = "Wait connexion to server"
|
|
@ -32,6 +32,7 @@ void NetworkConnection::_bind_methods()
|
|||
ClassDB::bind_method(D_METHOD("get_state"), &NetworkConnection::get_state);
|
||||
ClassDB::bind_method(D_METHOD("connect_to_server"), &NetworkConnection::connect_to_server);
|
||||
ClassDB::bind_method(D_METHOD("get_server_messages"), &NetworkConnection::get_server_messages);
|
||||
ClassDB::bind_method(D_METHOD("get_server_tick"), &NetworkConnection::get_server_tick);
|
||||
ClassDB::bind_method(D_METHOD("terminate_network_connection"), &NetworkConnection::terminate_network_connection);
|
||||
//ClassDB::bind_method(D_METHOD("get_master_message_description_node"), &NetworkConnection::get_master_message_description_node);
|
||||
}
|
||||
|
@ -96,6 +97,11 @@ Variant NetworkConnection::get_server_messages()
|
|||
return NetworkConnectionCore::get_singleton()->get_server_messages();
|
||||
}
|
||||
|
||||
Variant NetworkConnection::get_server_tick()
|
||||
{
|
||||
return NetworkConnectionCore::get_singleton()->get_server_tick();
|
||||
}
|
||||
|
||||
void NetworkConnection::terminate_network_connection()
|
||||
{
|
||||
NetworkConnectionCore::terminate_connexion();
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
int get_state();
|
||||
|
||||
Variant get_server_messages();
|
||||
Variant get_server_tick();
|
||||
|
||||
void terminate_network_connection();
|
||||
|
||||
|
|
|
@ -205,6 +205,11 @@ Variant NetworkConnectionCore::get_server_messages()
|
|||
return _network_data._server_messages;
|
||||
}
|
||||
|
||||
Variant NetworkConnectionCore::get_server_tick()
|
||||
{
|
||||
return _network_data._current_received_number;
|
||||
}
|
||||
|
||||
bool NetworkConnectionCore::is_active()
|
||||
{
|
||||
DBG_PRINT("is_active ..");
|
||||
|
|
|
@ -92,6 +92,7 @@ public:
|
|||
bool connected();
|
||||
|
||||
Variant get_server_messages();
|
||||
Variant get_server_tick();
|
||||
|
||||
static bool is_active();
|
||||
static void terminate_connexion();
|
||||
|
|
|
@ -25,7 +25,7 @@ config/icon="res://icon.png"
|
|||
global="*res://global.tscn"
|
||||
character="*res://game_scene/Game/Character/Character.tscn"
|
||||
net_low_level="*res://assets/Scripts/Network/net_low_level.gd"
|
||||
msg="*res://assets/Scripts/Definition/msg.gd"
|
||||
msg="res://assets/Scripts/Definition/msg.gd"
|
||||
|
||||
[debug]
|
||||
|
||||
|
|
Loading…
Reference in a new issue