2018-08-25 08:05:54 +00:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
signal login_button_pressed
|
|
|
|
|
|
|
|
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();
|
|
|
|
if username != null and username != "" and password != null and password != "":
|
|
|
|
do_request(username, password)
|
|
|
|
|
|
|
|
|
2018-09-30 12:54:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_quit_button_pressed():
|
|
|
|
self.get_tree().quit()
|
2018-10-04 15:17:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_sound_button_toggled( button_pressed ):
|
|
|
|
if button_pressed:
|
|
|
|
global.get_node( "audio_stream_player" ).stop()
|
|
|
|
else:
|
|
|
|
global.get_node( "audio_stream_player" ).play()
|
2018-10-02 16:56:02 +00:00
|
|
|
|
|
|
|
|
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):
|
|
|
|
var s = body.get_string_from_utf8().split(":")
|
2018-10-09 11:13:29 +00:00
|
|
|
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());
|
|
|
|
print(server_info._cookie)
|
|
|
|
print(server_info._shardIp)
|
2018-10-08 10:24:07 +00:00
|
|
|
emit_signal( "login_button_pressed" )
|
2018-10-02 16:56:02 +00:00
|
|
|
|
2018-10-09 11:13:29 +00:00
|
|
|
# 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)
|