diff --git a/assets/Scripts/Models/nel_register_form.gd b/assets/Scripts/Models/nel_register_form.gd new file mode 100644 index 0000000..fd99677 --- /dev/null +++ b/assets/Scripts/Models/nel_register_form.gd @@ -0,0 +1,20 @@ +class nel_register_form: + var _username; + var _password; + var _email; + var _terms_accepted; + + func _init(username, password, email, terms_accepted): + self._username = username; + self._password = password; + self._email = email; + self._terms_accepted = terms_accepted; + + func get_form_data(): + return { + "Username": self._username, + "Password": self._password, + "ConfirmPass": self._password, + "Email": self._email, + "TaC": 1 if self._terms_accepted else 0 + } diff --git a/assets/Scripts/Models/nel_server_info.gd b/assets/Scripts/Models/nel_server_info.gd index e317ef1..0d69e37 100644 --- a/assets/Scripts/Models/nel_server_info.gd +++ b/assets/Scripts/Models/nel_server_info.gd @@ -3,7 +3,7 @@ class nel_server_info: var _shardIp; var _ringStartAdress; var _ringAddress; - var _patchVersion + var _patchVersion; var _backupPatchUrls; var _patchUrls; @@ -16,4 +16,4 @@ class nel_server_info: self._ringAddress = temp[0]; self._patchVersion = temp[1]; self._backupPatchUrls = params[5]; - self._patchUrls = params[6]; \ No newline at end of file + self._patchUrls = params[6]; diff --git a/gui_scene/GUI/login/register_menu.gd b/gui_scene/GUI/login/register_menu.gd index c552c12..21e0257 100644 --- a/gui_scene/GUI/login/register_menu.gd +++ b/gui_scene/GUI/login/register_menu.gd @@ -15,3 +15,37 @@ func _on_cancel_button_pressed(): func _on_license_button_pressed(): emit_signal( "license_button_pressed" ) + # No error so login was successful. + +func _on_HTTPRequest_request_completed(result, response_code, headers, body): + var s = body.get_string_from_utf8(); + print(s); + emit_signal( "cancel_button_pressed"); +# 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()); +# + + +func _on_register_button_pressed(): + var username = get_node("h_box_container/v_box_container/center_container/register_box/login_box/login_edit").get_text(); + var password = get_node("h_box_container/v_box_container/center_container/register_box/password_box/password_edit").get_text(); + var password_confirm = get_node("h_box_container/v_box_container/center_container/register_box/password_confirm_box/password_edit").get_text(); + var email = get_node("h_box_container/v_box_container/center_container/register_box/email_box/email_edit").get_text(); + var license_accepted = get_node("h_box_container/v_box_container/center_container/register_box/license_box/check_box").is_pressed(); + + if (username != null and username != ""): + if(password != null and password != ""): + if(password_confirm != null and password_confirm != ""): + if(password_confirm == password): + if(email != null and email != ""): + if(license_accepted == true): + print("Doing request"); + var body = load("res://assets/Scripts/Models/nel_register_form.gd").nel_register_form.new(username, password, email, license_accepted); + $HTTPRequest.request("http://149.91.80.160/ams/index.php?action=add_user", "", true,HTTPClient.METHOD_POST,body.get_form_data()); + + + + + + # emit_signal( "cancel_button_pressed" ) diff --git a/login_scene/login_scene.gd b/login_scene/login_scene.gd index 42d6c9c..94da66f 100644 --- a/login_scene/login_scene.gd +++ b/login_scene/login_scene.gd @@ -13,7 +13,7 @@ func _ready(): $login_menu.show() $register_menu.hide() $license_menu.hide() - + func _on_login_menu_login_button_pressed(): $login_menu.hide() $character_selection_menu.show() @@ -27,7 +27,7 @@ func _on_character_selection_menu_character_selected( slot ): var err = config_file.load( "user://player.cfg" ) if err: print("Error code when loading player config file: ", err) - + character.slot = slot character.pseudo = config_file.get_value( str(slot), "name", "player" ) character.gender = config_file.get_value( str(slot), "gender", 1 ) @@ -36,7 +36,7 @@ func _on_character_selection_menu_character_selected( slot ): character.ears_size = config_file.get_value( str(slot), "ears_size", 0.0 ) character.eyes_color = config_file.get_value( str(slot), "eyes_color", Color( 0.0, 1.0, 0.0, 1.0 ) ) character.update() - + emit_signal( "character_creation_finished" )