test-client-godot/gui_scene/GUI/login/login_menu.gd
2019-03-12 15:29:32 +01:00

41 lines
1.9 KiB
GDScript

extends Control
signal login_button_pressed
signal register_button_pressed
func _on_login_button_pressed():
emit_signal( "login_button_pressed" )
func _on_play_button_pressed():
var username = get_node("h_box_container/v_box_container/margin_container/login_box/email_box/email_edit").get_text();
var password = get_node("h_box_container/v_box_container/margin_container/login_box/password_box/password_edit").get_text();
emit_signal( "login_button_pressed" )
# if username != null and username != "" and password != null and password != "":
# do_request(username, password)
func do_request(username, password):
var message = load("res://assets/Scripts/Models/nel_login_message.gd").nel_login_message.new("https-login", username, password, "Lirria", "2", "en");
# $HTTPRequest.request("http://lirria.khaganat.net/login/r2_login.php?" + message.get_request_string());
$HTTPRequest.request("http://149.91.80.160/login/r2_login.php?" + message.get_request_string());
func _on_HTTPRequest_request_completed(result, response_code, headers, body):
if response_code != 200 || ProjectSettings.get_setting("kaghanat/debug_mode"):
emit_signal( "login_button_pressed" )
else:
var s = body.get_string_from_utf8().split(":")
if(s[0] != "0"):
var server_info_script = load("res://assets/Scripts/Models/nel_server_info.gd");
var server_info = server_info_script.nel_server_info.new(body.get_string_from_utf8());
emit_signal( "login_button_pressed" )
# No error so login was successful.
func _make_post_request(url, data_to_send, use_ssl):
# Convert data to json string:
var query = JSON.print(data_to_send)
# Add 'Content-Type' header:
var headers = ["Content-Type: application/json"]
$HTTPRequest.request(url, headers, use_ssl, HTTPClient.METHOD_POST, query)
func _on_register_button_pressed():
emit_signal( "register_button_pressed" )