diff --git a/assets/Scripts/Config/connexion.gd b/assets/Scripts/Config/connexion.gd new file mode 100644 index 0000000..df7c061 --- /dev/null +++ b/assets/Scripts/Config/connexion.gd @@ -0,0 +1,49 @@ +# Manage configuration to connect on khaganat +# +# Copyright (C) 2019 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +class connexion: + var _url_login = "" + var _url_register = "" + var _valid_certificate = true + + func _init(): + print("Load connexion config"); + #var message = load("res://assets/Scripts/Models/nel_login_message.gd") + var config_file = ConfigFile.new() + + # /home//.local/share/godot/app_userdata/Khanat/connexion.cfg + var err = config_file.load("user://connexion.cfg") + if err: + print("Error code when loading player config file khanat.cfg: ", err) + config_file.set_value("login", "url", "http://149.91.80.160/login/r2_login.php") + config_file.set_value("register", "url", "http://149.91.80.160/ams/index.php?page=register") + config_file.set_value("global", "valid_certificate", false) + config_file.save("user://connexion.cfg") + + self._url_login = config_file.get_value( "login", "url", "http://172.17.0.3/login/r2_login.php") + self._url_register = config_file.get_value( "register", "url", "http://172.17.0.3/login/r2_login.php") + self._valid_certificate = config_file.get_value( "global", "valid_certificate", false) + config_file.save("user://connexion.cfg") + + func get_url_login(): + return self._url_login + + func get_url_register(): + return self._url_register + + func get_valid_certificate(): + return self._valid_certificate \ No newline at end of file diff --git a/assets/Scripts/Models/nel_register.gd b/assets/Scripts/Models/nel_register.gd new file mode 100644 index 0000000..0ec8bf0 --- /dev/null +++ b/assets/Scripts/Models/nel_register.gd @@ -0,0 +1,45 @@ +# Class to send parameter to register a new account +# +# Copyright (C) 2019 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +class nel_register: + var _username + var _password + var _confirmed + var _email + var _tac + var _url_encoding + + func _init(username, password, confirmed, email, tac): + self._username = username + self._password = password + self._confirmed = confirmed + self._email = email + self._tac = tac + self._url_encoding = load("res://assets/Scripts/Tools/url_encoding.gd").url_encoding.new() + + func get_request(): + return "/ams/index.php?page=register" + + func get_headers(): + return ["Content-Type: application/x-www-form-urlencoded", "User-Agent: Ryzom"] + + func get_user_agent(): + # HTTP_USER_AGENT + return "Ryzom" + + func get_param_add_user_string(): + return "Username=" + self._url_encoding.web_encode(self._username) + "&Password=" + self._url_encoding.web_encode(self._password) + "&ConfirmPass=" + self._url_encoding.web_encode(self._password) + "&Email=" + self._url_encoding.web_encode(self._email) + "&TaC=" + self._url_encoding.web_encode(self._tac) + "&function=add_user" \ No newline at end of file diff --git a/assets/Scripts/Tools/url_encoding.gd b/assets/Scripts/Tools/url_encoding.gd new file mode 100644 index 0000000..f9ddcc3 --- /dev/null +++ b/assets/Scripts/Tools/url_encoding.gd @@ -0,0 +1,51 @@ +# Class to encode string with escape web code +# +# Copyright (C) 2019 AleaJactaEst +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +class url_encoding: + + func _init(): + pass + + func web_encode(value): + var ret = value + ret = ret.replace("%", "%25") + ret = ret.replace(" ", "%20") + ret = ret.replace("\"","%22") + ret = ret.replace("<", "%3C") + ret = ret.replace(">", "%3E") + ret = ret.replace("#", "%23") + ret = ret.replace("{", "%7B") + ret = ret.replace("}", "%7D") + ret = ret.replace("|", "%7C") + ret = ret.replace("\\","%5C") + ret = ret.replace("^", "%5E") + ret = ret.replace("~", "%7E") + ret = ret.replace("[", "%5B") + ret = ret.replace("]", "%5D") + ret = ret.replace("`", "%60") + ret = ret.replace("@", "%40") + ret = ret.replace("$", "%24") + ret = ret.replace("&", "%26") + ret = ret.replace("+", "%2B") + ret = ret.replace(",", "%2C") + ret = ret.replace("/", "%2F") + ret = ret.replace(":", "%3A") + ret = ret.replace(";", "%3B") + ret = ret.replace("=", "%3D") + ret = ret.replace("?", "%3F") + ret = ret.replace("'", "%27") + return ret diff --git a/gui_scene/GUI/login/license_menu.tscn b/gui_scene/GUI/login/license_menu.tscn index 195c124..457975c 100644 --- a/gui_scene/GUI/login/license_menu.tscn +++ b/gui_scene/GUI/login/license_menu.tscn @@ -12,394 +12,144 @@ [sub_resource type="CanvasItemMaterial" id=1] -render_priority = 0 -blend_mode = 0 -light_mode = 0 - [sub_resource type="Gradient" id=2] - offsets = PoolRealArray( 0 ) colors = PoolColorArray( 1, 1, 1, 0.8 ) -_sections_unfolded = [ "Resource" ] [sub_resource type="GradientTexture" id=3] - -flags = 4 gradient = SubResource( 2 ) -width = 2048 - -[node name="register_menu" type="Control" index="0"] +[node name="register_menu" type="Control"] material = SubResource( 1 ) -anchor_left = 0.0 -anchor_top = 0.0 anchor_right = 1.0 anchor_bottom = 1.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 theme = ExtResource( 1 ) script = ExtResource( 2 ) -_sections_unfolded = [ "Material", "Theme", "Visibility", "custom_styles" ] -[node name="HTTPRequest" type="HTTPRequest" parent="." index="0"] +[node name="HTTPRequest" type="HTTPRequest" parent="."] -download_file = "" -use_threads = false -body_size_limit = -1 -max_redirects = 8 -_sections_unfolded = [ "Pause" ] - -[node name="background" type="TextureRect" parent="." index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 +[node name="background" type="TextureRect" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 texture = ExtResource( 3 ) expand = true stretch_mode = 7 -_sections_unfolded = [ "Visibility" ] -[node name="text_background" type="TextureRect" parent="." index="2"] - -anchor_left = 0.0 -anchor_top = 0.0 +[node name="text_background" type="TextureRect" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 margin_left = 248.0 margin_top = 128.0 margin_right = -120.0 margin_bottom = -120.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 texture = SubResource( 3 ) expand = true stretch_mode = 7 -_sections_unfolded = [ "Margin", "Visibility" ] - -[node name="buttons_background" type="TextureRect" parent="." index="3"] +[node name="buttons_background" type="TextureRect" parent="."] anchor_left = 1.0 -anchor_top = 0.0 anchor_right = 1.0 -anchor_bottom = 0.0 margin_left = -307.0 margin_bottom = 65.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 texture = ExtResource( 4 ) stretch_mode = 7 -_sections_unfolded = [ "Size Flags" ] -[node name="h_box_container" type="HBoxContainer" parent="." index="4"] - -anchor_left = 0.0 -anchor_top = 0.0 +[node name="h_box_container" type="HBoxContainer" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 -[node name="v_box_container" type="VBoxContainer" parent="h_box_container" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="v_box_container" type="VBoxContainer" parent="h_box_container"] margin_right = 1280.0 margin_bottom = 720.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 size_flags_horizontal = 3 -size_flags_vertical = 1 -alignment = 0 -_sections_unfolded = [ "Margin", "Size Flags", "custom_constants" ] - -[node name="buttons_box" type="HBoxContainer" parent="h_box_container/v_box_container" index="0"] +[node name="buttons_box" type="HBoxContainer" parent="h_box_container/v_box_container"] editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 margin_left = 1064.0 margin_right = 1280.0 margin_bottom = 61.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 size_flags_horizontal = 10 -size_flags_vertical = 1 custom_constants/separation = 0 alignment = 2 -_sections_unfolded = [ "Size Flags", "custom_constants" ] -[node name="help_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="help_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box"] margin_right = 54.0 margin_bottom = 61.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 size_flags_horizontal = 10 -size_flags_vertical = 1 -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null texture_normal = ExtResource( 5 ) -_sections_unfolded = [ "Margin", "Size Flags", "Textures" ] -[node name="settings_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="settings_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box"] margin_left = 54.0 margin_right = 108.0 margin_bottom = 61.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 size_flags_horizontal = 10 -size_flags_vertical = 1 -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null texture_normal = ExtResource( 6 ) -_sections_unfolded = [ "Size Flags", "Textures" ] -[node name="quit_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box" index="2"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="quit_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box"] margin_left = 108.0 margin_right = 162.0 margin_bottom = 61.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 size_flags_horizontal = 10 -size_flags_vertical = 1 -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null texture_normal = ExtResource( 7 ) -_sections_unfolded = [ "Size Flags", "Textures" ] -[node name="sound_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box" index="3"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="sound_button" type="TextureButton" parent="h_box_container/v_box_container/buttons_box"] margin_left = 162.0 margin_right = 216.0 margin_bottom = 61.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 size_flags_horizontal = 10 -size_flags_vertical = 1 toggle_mode = true -enabled_focus_mode = 2 -shortcut = null -group = null texture_normal = ExtResource( 8 ) texture_pressed = ExtResource( 9 ) -_sections_unfolded = [ "Size Flags", "Textures" ] -[node name="margin_container" type="MarginContainer" parent="h_box_container/v_box_container" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="margin_container" type="MarginContainer" parent="h_box_container/v_box_container"] margin_top = 65.0 margin_right = 1280.0 margin_bottom = 720.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -mouse_default_cursor_shape = 0 size_flags_horizontal = 3 size_flags_vertical = 3 custom_constants/margin_right = 128 custom_constants/margin_top = 128 custom_constants/margin_left = 256 custom_constants/margin_bottom = 128 -_sections_unfolded = [ "Size Flags", "custom_constants" ] - -[node name="v_box_container" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container" index="0"] +[node name="v_box_container" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container"] editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 margin_left = 256.0 margin_top = 128.0 margin_right = 1152.0 margin_bottom = 527.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 -[node name="h_box_container" type="HBoxContainer" parent="h_box_container/v_box_container/margin_container/v_box_container" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="h_box_container" type="HBoxContainer" parent="h_box_container/v_box_container/margin_container/v_box_container"] margin_right = 896.0 margin_bottom = 17.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 -[node name="label" type="Label" parent="h_box_container/v_box_container/margin_container/v_box_container/h_box_container" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="label" type="Label" parent="h_box_container/v_box_container/margin_container/v_box_container/h_box_container"] margin_right = 46.0 margin_bottom = 17.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 text = "From: " -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -[node name="license_url_link" type="LinkButton" parent="h_box_container/v_box_container/margin_container/v_box_container/h_box_container" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="license_url_link" type="LinkButton" parent="h_box_container/v_box_container/margin_container/v_box_container/h_box_container"] margin_left = 50.0 margin_right = 375.0 margin_bottom = 17.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -mouse_default_cursor_shape = 2 -size_flags_horizontal = 1 -size_flags_vertical = 1 -toggle_mode = false -enabled_focus_mode = 0 -shortcut = null -group = null text = "https://www.gnu.org/licenses/agpl-3.0.en.html" -[node name="scroll_container" type="ScrollContainer" parent="h_box_container/v_box_container/margin_container/v_box_container" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="scroll_container" type="ScrollContainer" parent="h_box_container/v_box_container/margin_container/v_box_container"] margin_top = 21.0 margin_right = 896.0 margin_bottom = 362.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = true -mouse_filter = 0 -mouse_default_cursor_shape = 0 size_flags_horizontal = 3 size_flags_vertical = 3 -scroll_horizontal_enabled = true -scroll_horizontal = 0 -scroll_vertical_enabled = true -scroll_vertical = 0 -scroll_deadzone = 0 -_sections_unfolded = [ "Margin", "Scroll", "Size Flags" ] -[node name="v_box_container" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container/v_box_container/scroll_container" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="v_box_container" type="VBoxContainer" parent="h_box_container/v_box_container/margin_container/v_box_container/scroll_container"] margin_right = 884.0 margin_bottom = 8557.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 size_flags_horizontal = 3 size_flags_vertical = 3 -alignment = 0 -_sections_unfolded = [ "Size Flags" ] -[node name="label" type="Label" parent="h_box_container/v_box_container/margin_container/v_box_container/scroll_container/v_box_container" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="label" type="Label" parent="h_box_container/v_box_container/margin_container/v_box_container/scroll_container/v_box_container"] margin_right = 884.0 margin_bottom = 8557.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 size_flags_vertical = 1 custom_colors/font_color = Color( 0.0627451, 0.0313726, 0.45098, 1 ) custom_colors/font_color_shadow = Color( 0, 0, 0, 1 ) @@ -617,46 +367,19 @@ If your software can interact with users remotely through a computer network, yo You should also get your employer (if you work as a programmer) or school, if any, to sign a \"copyright disclaimer\" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see ." autowrap = true -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "Size Flags", "custom_colors" ] -[node name="return_button" type="Button" parent="h_box_container/v_box_container/margin_container/v_box_container" index="2"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="return_button" type="Button" parent="h_box_container/v_box_container/margin_container/v_box_container"] margin_left = 384.0 margin_top = 366.0 margin_right = 512.0 margin_bottom = 399.0 rect_min_size = Vector2( 128, 0 ) -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 size_flags_horizontal = 6 size_flags_vertical = 0 -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null text = "Retour" -flat = false -align = 1 -_sections_unfolded = [ "Size Flags" ] [connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"] - [connection signal="pressed" from="h_box_container/v_box_container/buttons_box/quit_button" to="." method="_on_quit_button_pressed"] - [connection signal="toggled" from="h_box_container/v_box_container/buttons_box/sound_button" to="." method="_on_sound_button_toggled"] - [connection signal="pressed" from="h_box_container/v_box_container/margin_container/v_box_container/h_box_container/license_url_link" to="." method="_on_license_url_link_pressed"] - [connection signal="pressed" from="h_box_container/v_box_container/margin_container/v_box_container/return_button" to="." method="_on_return_button_pressed"] - - diff --git a/gui_scene/GUI/login/login_menu.gd b/gui_scene/GUI/login/login_menu.gd index 4c89b21..cdb4f88 100644 --- a/gui_scene/GUI/login/login_menu.gd +++ b/gui_scene/GUI/login/login_menu.gd @@ -3,6 +3,7 @@ extends Control signal login_button_pressed signal register_button_pressed + func _on_login_button_pressed(): emit_signal( "login_button_pressed" ) @@ -13,15 +14,21 @@ func _on_play_button_pressed(): if username != null and username != "" and password != null and password != "": do_request(username, password) + func _on_play_without_connexion_pressed(): emit_signal( "login_button_pressed" ) - + + func do_request(username, password): var message = load("res://assets/Scripts/Models/nel_login_message.gd") + var connexion = load("res://assets/Scripts/Config/connexion_config.gd") if message: - message = message.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()); + var url_login + message = message.nel_login_message.new("https-login", username, password, "Lirria", "2", "en") + url_login = connexion.get_url_login(); + $HTTPRequest.request(url_login + "?" + message.get_request_string()); + print("Login to URL:" + url_login + "?" + message.get_request_string()); + func _on_HTTPRequest_request_completed(result, response_code, headers, body): if response_code != 200 || ProjectSettings.get_setting("kaghanat/debug_mode"): @@ -34,6 +41,7 @@ func _on_HTTPRequest_request_completed(result, response_code, headers, body): 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) @@ -41,6 +49,7 @@ func _make_post_request(url, data_to_send, use_ssl): 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" ) diff --git a/gui_scene/GUI/login/register_menu.gd b/gui_scene/GUI/login/register_menu.gd index c552c12..302babb 100644 --- a/gui_scene/GUI/login/register_menu.gd +++ b/gui_scene/GUI/login/register_menu.gd @@ -3,6 +3,7 @@ extends Control signal sound_button_toggled( button_pressed ) signal cancel_button_pressed signal license_button_pressed +signal register_account_created func _on_sound_button_toggled( button_pressed ): @@ -15,3 +16,187 @@ func _on_cancel_button_pressed(): func _on_license_button_pressed(): emit_signal( "license_button_pressed" ) + + +func _on_check_box_pressed(): + do_enable_register_button(); + + +func do_enable_register_button(): + var username = get_node("h_box_container/v_box_container/center_container/register_box/login_box/login_edit").get_text(); + var register = get_node('h_box_container/v_box_container/center_container/register_box/h_box_container/register_button2') + var password = get_node("h_box_container/v_box_container/center_container/register_box/password_box/password_edit").get_text(); + var confirmed = 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 cur_state = get_node('h_box_container/v_box_container/center_container/register_box/license_box/check_box').is_pressed() + + if username == null or username == "": + #print("Register : username empty"); + register.disabled = true + elif password == null or password == "": + #print("Register : password empty"); + register.disabled = true + elif confirmed == null or confirmed == "": + #print("Register : confirmed empty"); + register.disabled = true + elif password != confirmed: + #print("Register : password != confirmed"); + register.disabled = true + elif email == null or email == "": + #print("Register : email empty"); + register.disabled = true + elif cur_state == false: + #print("Register : unchecked condition"); + register.disabled = true + else: + register.disabled = false + + +func _on_play_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 confirmed = 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 cur_state = get_node('h_box_container/v_box_container/center_container/register_box/license_box/check_box').is_pressed() + var enregister = get_node('h_box_container/v_box_container/center_container/register_box/h_box_container/register_button2') + var tac = "off"; + if cur_state == true: + tac = "on"; + if username != null and username != "" and password != null and password != "" and confirmed != null and confirmed != "" and email != null and email != "": + do_request(username, password, confirmed, email, tac) + + +func do_request(username, password, confirmed, email, tac): + var script_register = load("res://assets/Scripts/Models/nel_register.gd") + var script_connexion = load("res://assets/Scripts/Config/connexion.gd") + var connexion = script_connexion.connexion.new() + var url_register = connexion.get_url_register() + var valid_certificate = connexion.get_valid_certificate() + var request_data = script_register.nel_register.new(username, password, confirmed, email, tac) + #print("url:" + str(url_register)) + #print("headers:" + str(request_data.get_headers())) + #print("data:" + str(request_data.get_param_add_user_string())) + # Ignore redirect 302 (because khaganat response 302 when account is created !) + $HTTPRequest.set_max_redirects(0) + var err = $HTTPRequest.request(url_register, + request_data.get_headers(), + valid_certificate, + HTTPClient.METHOD_POST, + request_data.get_param_add_user_string() + ); + match err: + 0: + print("[Register] Send command") + get_node("wait_dialog").popup_centered() + _: + print("[Register] Command not sended : Failure! (code:" + str(err) + ")") + var comment_last = get_node('h_box_container/v_box_container/center_container/register_box/comment_last') + + comment_last.text = "Impossible de créer votre compte (Erreur dans l'envoie de la requette)" + comment_last.add_color_override("font_color", "b51111") + get_node("wait_dialog").hide() + get_node("error_dialog/v_box_container/label").text = "Impossible de créer votre compte\nErreur dans l'envoie de la requette\n" + get_node("error_dialog").popup_centered() + + +func _on_HTTPRequest_request_completed( result, response_code, headers, body ): + var pos + var search + var enregister = get_node('h_box_container/v_box_container/center_container/register_box/h_box_container/register_button2') + var comment_last = get_node('h_box_container/v_box_container/center_container/register_box/comment_last') + var comment_username = get_node('h_box_container/v_box_container/center_container/register_box/login_box/comment') + var comment_password = get_node('h_box_container/v_box_container/center_container/register_box/password_box/comment') + var comment_confirm_password = get_node('h_box_container/v_box_container/center_container/register_box/password_confirm_box/comment') + var comment_email = get_node('h_box_container/v_box_container/center_container/register_box/email_box/comment') + var regex = RegEx.new() + + comment_username.text = "" + comment_password.text = "" + comment_confirm_password.text = "" + comment_email.text = "" + comment_last.text = "" + comment_last.add_color_override("font_color", "000000") + + print("[Register] result:" + str(result) + ", response_code:" + str(response_code)) + if result == HTTPRequest.RESULT_REDIRECT_LIMIT_REACHED and response_code == 302: + get_node("wait_dialog").hide() + get_node("info_dialog/v_box_container/label").text = "Compte créé" + get_node("info_dialog").popup_centered() + return + + if result == HTTPRequest.RESULT_SUCCESS and response_code != 200: + comment_last.text = "Serveur a renvoyé une erreur (code retour HTTP:" + str(response_code) + ")" + comment_last.add_color_override("font_color", "b51111") + get_node("wait_dialog").hide() + get_node("error_dialog/v_box_container/label").text = "Impossible de créer le compte\nCode retour HTTP:" + str(response_code) + get_node("error_dialog").popup_centered() + return + + get_node("wait_dialog").hide() + + var text = str2var(body.get_string_from_utf8()) + regex.compile("(\\d+)") + var tab = text.split(":", true,2) + if tab.size() > 1 : + if regex.search(tab[0]): + if int(tab[0]) != 1: + comment_last.text = "Serveur a renvoyé une erreur (Code retour:" + str(tab[0]) + ", message:" + tab[1] +")" + comment_last.add_color_override("font_color", "b51111") + get_node("wait_dialog").hide() + get_node("error_dialog/v_box_container/label").text = "Serveur a renvoyé une erreur\nCode retour:" + str(tab[0]) + "\nMessage:" + tab[1] + get_node("error_dialog").popup_centered() + return + + tab = text.rsplit("\n") + regex.compile(">(?.+) 0 and search: + comment_username.text = search.get_string("comment") + print("[Register] Username issue : " + comment_username.text) + pos = item.find("comment-Password") + if pos > 0 and search: + comment_password.text = search.get_string("comment") + print("[Register] Password issue : " + comment_password.text) + pos = item.find("comment-ConfirmPass") + if pos > 0 and search: + comment_confirm_password.text = search.get_string("comment") + print("[Register] ConfirmPass issue : " + comment_confirm_password.text) + pos = item.find("comment-Email") + if pos > 0 and search: + comment_email.text = search.get_string("comment") + print("[Register] Email issue : " + comment_email.text) + pos = item.find("comment-Tac") + if pos > 0 and search: + comment_last.text = search.get_string("comment") + comment_last.add_color_override("font_color", "b51111") + print("[Register] Issue : " + comment_last.text) + + +func _on_login_edit_text_changed(new_text): + do_enable_register_button(); + + +func _on_password_edit_text_changed(new_text): + do_enable_register_button(); + + +func _on_email_edit_text_changed(new_text): + do_enable_register_button(); + + +func _on_button_pressed(): + $HTTPRequest.cancel_request() + get_node("wait_dialog").hide() + + +func _on_info_dialog_button_pressed(): + get_node("info_dialog").hide() + hide() + # _on_register_menu_register_button_pressed + emit_signal( "register_account_created" ) + +func _on_error_dialog_button_pressed(): + get_node("error_dialog").hide() diff --git a/gui_scene/GUI/login/register_menu.tscn b/gui_scene/GUI/login/register_menu.tscn index 35628fc..09d4712 100644 --- a/gui_scene/GUI/login/register_menu.tscn +++ b/gui_scene/GUI/login/register_menu.tscn @@ -7,576 +7,351 @@ [sub_resource type="CanvasItemMaterial" id=1] -render_priority = 0 -blend_mode = 0 -light_mode = 0 - [sub_resource type="DynamicFont" id=2] - size = 20 -use_mipmaps = false -use_filter = false font_data = ExtResource( 4 ) -_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ] [node name="register_menu" type="Control"] - material = SubResource( 1 ) -anchor_left = 0.0 -anchor_top = 0.0 anchor_right = 1.0 anchor_bottom = 1.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 theme = ExtResource( 1 ) script = ExtResource( 2 ) -_sections_unfolded = [ "Material", "Theme", "Visibility", "custom_styles" ] -[node name="HTTPRequest" type="HTTPRequest" parent="." index="0"] +[node name="HTTPRequest" type="HTTPRequest" parent="."] -download_file = "" -use_threads = false -body_size_limit = -1 -max_redirects = 8 -_sections_unfolded = [ "Pause" ] - -[node name="background" type="TextureRect" parent="." index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 +[node name="background" type="TextureRect" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 texture = ExtResource( 3 ) expand = true stretch_mode = 7 -_sections_unfolded = [ "Visibility" ] -[node name="h_box_container" type="HBoxContainer" parent="." index="2"] - -anchor_left = 0.0 -anchor_top = 0.0 +[node name="h_box_container" type="HBoxContainer" parent="."] +editor/display_folded = true anchor_right = 1.0 anchor_bottom = 1.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 -[node name="v_box_container" type="VBoxContainer" parent="h_box_container" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="v_box_container" type="VBoxContainer" parent="h_box_container"] margin_right = 1280.0 margin_bottom = 720.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 size_flags_horizontal = 3 -size_flags_vertical = 1 -alignment = 0 -_sections_unfolded = [ "Margin", "Size Flags", "custom_constants" ] -[node name="center_container" type="CenterContainer" parent="h_box_container/v_box_container" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="center_container" type="CenterContainer" parent="h_box_container/v_box_container"] margin_right = 1280.0 margin_bottom = 720.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -mouse_default_cursor_shape = 0 size_flags_horizontal = 3 size_flags_vertical = 3 -use_top_left = false -_sections_unfolded = [ "Size Flags", "custom_constants" ] -[node name="register_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="register_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container"] margin_left = 509.0 -margin_top = 159.0 +margin_top = 92.0 margin_right = 771.0 -margin_bottom = 561.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 +margin_bottom = 627.0 custom_constants/separation = 16 -alignment = 0 -_sections_unfolded = [ "Margin", "custom_constants" ] -[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box"] margin_right = 262.0 margin_bottom = 17.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 custom_colors/font_color = Color( 0.0627451, 0.0313726, 0.45098, 1 ) text = "INSCRIPTION" align = 1 -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "custom_colors" ] -[node name="login_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="1"] - -editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="login_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"] margin_top = 33.0 margin_right = 262.0 -margin_bottom = 91.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 +margin_bottom = 116.0 custom_constants/separation = 8 -alignment = 0 -_sections_unfolded = [ "custom_constants" ] -[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/login_box" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/login_box"] margin_right = 262.0 margin_bottom = 17.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 custom_colors/font_color = Color( 0, 0, 0, 1 ) text = "Login" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "custom_colors" ] -[node name="login_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/login_box" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="login_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/login_box"] margin_top = 25.0 margin_right = 262.0 margin_bottom = 58.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 1 -size_flags_horizontal = 1 -size_flags_vertical = 1 -focus_mode = 2 -context_menu_enabled = true placeholder_text = "Entrez votre login ici." -placeholder_alpha = 0.6 -caret_blink = false -caret_blink_speed = 0.65 -caret_position = 0 -_sections_unfolded = [ "Material", "Placeholder", "Visibility", "custom_colors", "custom_styles" ] -[node name="password_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="2"] - -editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 107.0 +[node name="comment" type="Label" parent="h_box_container/v_box_container/center_container/register_box/login_box"] +margin_top = 66.0 margin_right = 262.0 -margin_bottom = 165.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 +margin_bottom = 83.0 +custom_colors/font_color = Color( 0.709804, 0.0666667, 0.0666667, 1 ) + +[node name="password_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"] +margin_top = 132.0 +margin_right = 262.0 +margin_bottom = 215.0 custom_constants/separation = 8 -alignment = 0 -_sections_unfolded = [ "custom_constants" ] -[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_box" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_box"] margin_right = 262.0 margin_bottom = 17.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 custom_colors/font_color = Color( 0, 0, 0, 1 ) text = "Mot de passe" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "custom_colors" ] -[node name="password_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/password_box" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="password_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/password_box"] margin_top = 25.0 margin_right = 262.0 margin_bottom = 58.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 1 -size_flags_horizontal = 1 -size_flags_vertical = 1 secret = true -focus_mode = 2 -context_menu_enabled = true placeholder_text = "Entrez votre mot de passe ici." -placeholder_alpha = 0.6 -caret_blink = false -caret_blink_speed = 0.65 -caret_position = 0 -_sections_unfolded = [ "Material", "Placeholder", "Visibility", "custom_colors", "custom_styles" ] -[node name="password_confirm_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="3"] - -editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 181.0 +[node name="comment" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_box"] +margin_top = 66.0 margin_right = 262.0 -margin_bottom = 239.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 +margin_bottom = 83.0 +custom_colors/font_color = Color( 0.709804, 0.0666667, 0.0666667, 1 ) + +[node name="password_confirm_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"] +margin_top = 231.0 +margin_right = 262.0 +margin_bottom = 314.0 custom_constants/separation = 8 -alignment = 0 -_sections_unfolded = [ "custom_constants" ] -[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_confirm_box" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_confirm_box"] margin_right = 262.0 margin_bottom = 17.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 custom_colors/font_color = Color( 0, 0, 0, 1 ) -text = "Confirmation du ot de passe" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "custom_colors" ] +text = "Confirmation du mot de passe" -[node name="password_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/password_confirm_box" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="password_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/password_confirm_box"] margin_top = 25.0 margin_right = 262.0 margin_bottom = 58.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 1 -size_flags_horizontal = 1 -size_flags_vertical = 1 secret = true -focus_mode = 2 -context_menu_enabled = true placeholder_text = "Entrez votre mot de passe ici." -placeholder_alpha = 0.6 -caret_blink = false -caret_blink_speed = 0.65 -caret_position = 0 -_sections_unfolded = [ "Material", "Placeholder", "Visibility", "custom_colors", "custom_styles" ] -[node name="email_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="4"] - -editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 255.0 +[node name="comment" type="Label" parent="h_box_container/v_box_container/center_container/register_box/password_confirm_box"] +margin_top = 66.0 margin_right = 262.0 -margin_bottom = 313.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 +margin_bottom = 83.0 +custom_colors/font_color = Color( 0.709804, 0.0666667, 0.0666667, 1 ) + +[node name="email_box" type="VBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"] +margin_top = 330.0 +margin_right = 262.0 +margin_bottom = 413.0 custom_constants/separation = 8 -alignment = 0 -_sections_unfolded = [ "custom_constants" ] -[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/email_box" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/email_box"] margin_right = 262.0 margin_bottom = 17.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 custom_colors/font_color = Color( 0, 0, 0, 1 ) text = "e-mail" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "custom_colors" ] -[node name="email_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/email_box" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="email_edit" type="LineEdit" parent="h_box_container/v_box_container/center_container/register_box/email_box"] margin_top = 25.0 margin_right = 262.0 margin_bottom = 58.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 1 -size_flags_horizontal = 1 -size_flags_vertical = 1 -focus_mode = 2 -context_menu_enabled = true placeholder_text = "Entrez votre adresse email ici." -placeholder_alpha = 0.6 -caret_blink = false -caret_blink_speed = 0.65 -caret_position = 0 -_sections_unfolded = [ "Material", "Placeholder", "Visibility", "custom_colors", "custom_styles" ] -[node name="license_box" type="HBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="5"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 329.0 +[node name="comment" type="Label" parent="h_box_container/v_box_container/center_container/register_box/email_box"] +margin_top = 66.0 margin_right = 262.0 -margin_bottom = 346.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 +margin_bottom = 83.0 +custom_colors/font_color = Color( 0.709804, 0.0666667, 0.0666667, 1 ) -[node name="check_box" type="CheckBox" parent="h_box_container/v_box_container/center_container/register_box/license_box" index="0"] +[node name="license_box" type="HBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"] +margin_top = 429.0 +margin_right = 262.0 +margin_bottom = 446.0 -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="check_box" type="CheckBox" parent="h_box_container/v_box_container/center_container/register_box/license_box"] margin_right = 16.0 margin_bottom = 17.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -toggle_mode = true -enabled_focus_mode = 2 -shortcut = null -group = null -flat = false -align = 0 -[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/license_box" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="label" type="Label" parent="h_box_container/v_box_container/center_container/register_box/license_box"] margin_left = 20.0 margin_right = 109.0 margin_bottom = 17.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 text = "j'accepte les" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -[node name="license_button" type="LinkButton" parent="h_box_container/v_box_container/center_container/register_box/license_box" index="2"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="license_button" type="LinkButton" parent="h_box_container/v_box_container/center_container/register_box/license_box"] margin_left = 113.0 margin_right = 262.0 margin_bottom = 17.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -mouse_default_cursor_shape = 2 -size_flags_horizontal = 1 -size_flags_vertical = 1 custom_colors/font_color = Color( 0.0627451, 0.0313726, 0.45098, 1 ) custom_colors/font_color_hover = Color( 0.305882, 0.294118, 0.454902, 1 ) custom_colors/font_color_pressed = Color( 0.0627451, 0.0313726, 0.45098, 1 ) -toggle_mode = false -enabled_focus_mode = 0 -shortcut = null -group = null text = "termes et conditions." -_sections_unfolded = [ "custom_colors" ] -[node name="h_box_container" type="HBoxContainer" parent="h_box_container/v_box_container/center_container/register_box" index="6"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 362.0 +[node name="comment_last" type="Label" parent="h_box_container/v_box_container/center_container/register_box"] +margin_top = 462.0 margin_right = 262.0 -margin_bottom = 402.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 +margin_bottom = 479.0 +custom_colors/font_color = Color( 0, 0, 0, 1 ) -[node name="cancel_button" type="Button" parent="h_box_container/v_box_container/center_container/register_box/h_box_container" index="0"] +[node name="h_box_container" type="HBoxContainer" parent="h_box_container/v_box_container/center_container/register_box"] +margin_top = 495.0 +margin_right = 262.0 +margin_bottom = 535.0 -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="cancel_button" type="Button" parent="h_box_container/v_box_container/center_container/register_box/h_box_container"] margin_right = 128.0 margin_bottom = 40.0 rect_min_size = Vector2( 128, 0 ) -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 size_flags_horizontal = 6 -size_flags_vertical = 1 custom_fonts/font = SubResource( 2 ) -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null text = "Annuler" -flat = false -align = 1 -_sections_unfolded = [ "Margin", "Material", "Rect", "Size Flags", "Theme", "Visibility", "custom_colors", "custom_constants", "custom_fonts" ] -[node name="register_button2" type="Button" parent="h_box_container/v_box_container/center_container/register_box/h_box_container" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="register_button2" type="Button" parent="h_box_container/v_box_container/center_container/register_box/h_box_container"] margin_left = 133.0 margin_right = 261.0 margin_bottom = 40.0 rect_min_size = Vector2( 128, 0 ) -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 size_flags_horizontal = 6 -size_flags_vertical = 1 custom_fonts/font = SubResource( 2 ) -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null +disabled = true text = "S'inscrire" -flat = false + +[node name="wait_dialog" type="PopupDialog" parent="."] +modulate = Color( 0.972549, 0.929412, 0.929412, 1 ) +self_modulate = Color( 0.929412, 0.847059, 0.847059, 1 ) +margin_left = 500.0 +margin_top = 300.0 +margin_right = 740.0 +margin_bottom = 420.0 +grow_horizontal = 2 +grow_vertical = 2 +hint_tooltip = "Server create your account" +mouse_default_cursor_shape = 4 +size_flags_horizontal = 2 +size_flags_vertical = 2 +popup_exclusive = true + +[node name="v_box_container" type="VBoxContainer" parent="wait_dialog"] +margin_right = 240.0 +margin_bottom = 120.0 +size_flags_horizontal = 2 +size_flags_vertical = 2 +custom_constants/separation = 10 +alignment = 1 + +[node name="label" type="Label" parent="wait_dialog/v_box_container"] +margin_left = 80.0 +margin_top = 27.0 +margin_right = 159.0 +margin_bottom = 44.0 +grow_horizontal = 2 +grow_vertical = 2 +hint_tooltip = "Server will create your account" +mouse_default_cursor_shape = 5 +size_flags_horizontal = 4 +text = "Please wait" align = 1 -_sections_unfolded = [ "Margin", "Material", "Rect", "Size Flags", "Theme", "Visibility", "custom_colors", "custom_constants", "custom_fonts" ] +valign = 1 + +[node name="button" type="Button" parent="wait_dialog/v_box_container"] +margin_left = 87.0 +margin_top = 81.0 +margin_right = 152.0 +margin_bottom = 114.0 +size_flags_horizontal = 4 +size_flags_vertical = 4 +text = "Cancel" + +[node name="info_dialog" type="PopupDialog" parent="."] +modulate = Color( 0.972549, 0.929412, 0.929412, 1 ) +self_modulate = Color( 0.929412, 0.847059, 0.847059, 1 ) +margin_left = 500.0 +margin_top = 300.0 +margin_right = 740.0 +margin_bottom = 420.0 +grow_horizontal = 2 +grow_vertical = 2 +hint_tooltip = "Server create your account" +mouse_default_cursor_shape = 4 +size_flags_horizontal = 2 +size_flags_vertical = 2 +popup_exclusive = true + +[node name="v_box_container" type="VBoxContainer" parent="info_dialog"] +margin_right = 240.0 +margin_bottom = 120.0 +custom_constants/separation = 10 +alignment = 1 + +[node name="label" type="Label" parent="info_dialog/v_box_container"] +margin_right = 117.0 +margin_bottom = 17.0 +grow_horizontal = 2 +grow_vertical = 2 +hint_tooltip = "Server will create your account" +mouse_default_cursor_shape = 5 +size_flags_horizontal = 4 +text = "Account created" +align = 1 +valign = 1 + +[node name="button" type="Button" parent="info_dialog/v_box_container"] +margin_left = 102.0 +margin_top = 81.0 +margin_right = 137.0 +margin_bottom = 114.0 +size_flags_horizontal = 4 +size_flags_vertical = 4 +text = "Ok" + +[node name="error_dialog" type="PopupDialog" parent="."] +modulate = Color( 0.972549, 0.929412, 0.929412, 1 ) +self_modulate = Color( 0.929412, 0.847059, 0.847059, 1 ) +margin_left = 500.0 +margin_top = 300.0 +margin_right = 900.0 +margin_bottom = 450.0 +grow_horizontal = 2 +grow_vertical = 2 +hint_tooltip = "Server create your account" +mouse_default_cursor_shape = 4 +size_flags_horizontal = 7 +size_flags_vertical = 7 +popup_exclusive = true + +[node name="v_box_container" type="VBoxContainer" parent="error_dialog"] +margin_right = 400.0 +margin_bottom = 140.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 7 +size_flags_vertical = 7 +custom_constants/separation = 10 +alignment = 1 + +[node name="label" type="Label" parent="error_dialog/v_box_container"] +margin_right = 400.0 +margin_bottom = 17.0 +grow_horizontal = 2 +grow_vertical = 2 +hint_tooltip = "Server will create your account" +mouse_default_cursor_shape = 5 +size_flags_horizontal = 7 +size_flags_vertical = 7 +text = "Error Detected" +align = 1 +valign = 1 + +[node name="button" type="Button" parent="error_dialog/v_box_container"] +margin_left = 102.0 +margin_top = 81.0 +margin_right = 137.0 +margin_bottom = 114.0 +size_flags_horizontal = 4 +size_flags_vertical = 4 +text = "Ok" [connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"] - +[connection signal="text_changed" from="h_box_container/v_box_container/center_container/register_box/login_box/login_edit" to="." method="_on_login_edit_text_changed"] +[connection signal="text_changed" from="h_box_container/v_box_container/center_container/register_box/password_box/password_edit" to="." method="_on_password_edit_text_changed"] +[connection signal="text_changed" from="h_box_container/v_box_container/center_container/register_box/password_confirm_box/password_edit" to="." method="_on_password_edit_text_changed"] +[connection signal="text_changed" from="h_box_container/v_box_container/center_container/register_box/email_box/email_edit" to="." method="_on_email_edit_text_changed"] +[connection signal="pressed" from="h_box_container/v_box_container/center_container/register_box/license_box/check_box" to="." method="_on_check_box_pressed"] [connection signal="pressed" from="h_box_container/v_box_container/center_container/register_box/license_box/license_button" to="." method="_on_license_button_pressed"] - [connection signal="pressed" from="h_box_container/v_box_container/center_container/register_box/h_box_container/cancel_button" to="." method="_on_cancel_button_pressed"] - [connection signal="pressed" from="h_box_container/v_box_container/center_container/register_box/h_box_container/register_button2" to="." method="_on_play_button_pressed"] - - +[connection signal="pressed" from="wait_dialog/v_box_container/button" to="." method="_on_button_pressed"] +[connection signal="pressed" from="info_dialog/v_box_container/button" to="." method="_on_info_dialog_button_pressed"] +[connection signal="pressed" from="error_dialog/v_box_container/button" to="." method="_on_error_dialog_button_pressed"] diff --git a/login_scene/login_scene.gd b/login_scene/login_scene.gd index 42d6c9c..bbfc087 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() @@ -26,8 +26,8 @@ func _on_character_selection_menu_character_selected( slot ): var config_file = ConfigFile.new() var err = config_file.load( "user://player.cfg" ) if err: - print("Error code when loading player config file: ", err) - + print("Error code when loading player config file player.cfg: ", 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" ) @@ -74,3 +74,8 @@ func _on_license_menu_return_button_pressed(): $register_menu.show() $license_menu.hide() + +func _on_register_menu_register_account_created(): + $login_menu.show() + $register_menu.hide() + $license_menu.hide() diff --git a/login_scene/login_scene.tscn b/login_scene/login_scene.tscn index 107e8d5..cf2ffaa 100644 --- a/login_scene/login_scene.tscn +++ b/login_scene/login_scene.tscn @@ -66,12 +66,14 @@ margin_left = 1226.0 margin_right = 1280.0 margin_bottom = 61.0 texture_normal = ExtResource( 11 ) + [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="register_button_pressed" from="login_menu" to="." method="_on_login_menu_register_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"] [connection signal="sound_button_toggled" from="register_menu" to="." method="_on_sound_button_toggled"] [connection signal="return_button_pressed" from="license_menu" to="." method="_on_license_menu_return_button_pressed"] [connection signal="toggled" from="buttons/sound_button" to="." method="_on_sound_button_toggled"]