2018-08-25 08:05:54 +00:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
signal login_button_pressed
|
2018-10-09 13:20:55 +00:00
|
|
|
signal register_button_pressed
|
2018-08-25 08:05:54 +00:00
|
|
|
|
|
|
|
func _on_login_button_pressed():
|
|
|
|
emit_signal( "login_button_pressed" )
|
2018-09-30 12:54:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_play_button_pressed():
|
2018-10-02 16:56:02 +00:00
|
|
|
var username = get_node("h_box_container/v_box_container/margin_container/login_box/email_box/email_edit").get_text();
|
2018-10-08 10:18:33 +00:00
|
|
|
var password = get_node("h_box_container/v_box_container/margin_container/login_box/password_box/password_edit").get_text();
|
2019-03-12 14:29:32 +00:00
|
|
|
emit_signal( "login_button_pressed" )
|
|
|
|
# if username != null and username != "" and password != null and password != "":
|
|
|
|
# do_request(username, password)
|
2018-10-08 10:18:33 +00:00
|
|
|
|
|
|
|
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());
|
2018-10-02 16:56:02 +00:00
|
|
|
|
|
|
|
func _on_HTTPRequest_request_completed(result, response_code, headers, body):
|
2019-03-05 19:20:05 +00:00
|
|
|
if response_code != 200 || ProjectSettings.get_setting("kaghanat/debug_mode"):
|
2018-10-08 10:24:07 +00:00
|
|
|
emit_signal( "login_button_pressed" )
|
2019-03-05 19:20:05 +00:00
|
|
|
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.
|
2018-10-02 16:56:02 +00:00
|
|
|
|
|
|
|
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)
|
2018-10-09 13:20:55 +00:00
|
|
|
|
|
|
|
func _on_register_button_pressed():
|
|
|
|
emit_signal( "register_button_pressed" )
|