diff --git a/mirror-godot-app/scripts/autoload/bootup.gd b/mirror-godot-app/scripts/autoload/bootup.gd index 560d94af..745b826c 100644 --- a/mirror-godot-app/scripts/autoload/bootup.gd +++ b/mirror-godot-app/scripts/autoload/bootup.gd @@ -11,9 +11,10 @@ func _start_client(): if ProjectSettings.get_setting("feature_flags/disable_login", false): LoginService.setup_deeplink_login(get_tree()) else: - await GameUI.ui_ready() - GameUI.instance.login_ui.start_login_ui() - GameUI.instance.login_ui.show() + var login_code: bool = ProjectSettings.get_setting("feature_flags/force_enable_login_code", false) + if not login_code: + GameUI.instance.login_ui.start_login_ui() + GameUI.instance.login_ui.show() Deeplinking.setup() await Zone.wait_till_notifications_ready() await Zone.wait_till_deeplink_ready() diff --git a/mirror-godot-app/scripts/net/auth.gd b/mirror-godot-app/scripts/net/auth.gd index f8b2f9b6..33096fd2 100644 --- a/mirror-godot-app/scripts/net/auth.gd +++ b/mirror-godot-app/scripts/net/auth.gd @@ -2,7 +2,8 @@ class_name MirrorAuth extends MirrorHttpClient enum { - POST_AUTH_USER_CREATE + POST_AUTH_USER_CREATE, + POST_CHECK_LOGIN_CODE } @@ -10,6 +11,14 @@ func create_account_if_missing() -> Promise: return self.post_request(POST_AUTH_USER_CREATE, "/auth/auth-user-create", {}) +func check_login_code(login_code: String) -> Promise: + return self.post_request( + POST_CHECK_LOGIN_CODE, + "/login-code/check-login-code?loginCode=" + login_code, + {} + ) + + func _promise_fulfill_successful(request: Dictionary, promise: Promise) -> void: var parsed_result = request.get("json_result") if parsed_result == null: diff --git a/mirror-godot-app/ui/game/game_ui.tscn b/mirror-godot-app/ui/game/game_ui.tscn index 18749564..6fd386ec 100644 --- a/mirror-godot-app/ui/game/game_ui.tscn +++ b/mirror-godot-app/ui/game/game_ui.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=28 format=3 uid="uid://bpn5kipaabot1"] +[gd_scene load_steps=29 format=3 uid="uid://bpn5kipaabot1"] [ext_resource type="Script" path="res://ui/game/game_ui_instance.gd" id="1_2ryxh"] [ext_resource type="PackedScene" uid="uid://pdt3sfnghnqp" path="res://ui/login/login_ui.tscn" id="2"] @@ -27,6 +27,7 @@ [ext_resource type="PackedScene" uid="uid://b7v8026760qqs" path="res://creator/asset_inventory/browser/file_search.tscn" id="22_0ljsg"] [ext_resource type="Theme" uid="uid://d1qd6ity2mdpl" path="res://creator/creator_ui.theme.tres" id="25_7pbh6"] [ext_resource type="Script" path="res://ui/game/connect_by_ip_ui.gd" id="26_viw1y"] +[ext_resource type="PackedScene" uid="uid://bb7qixdwwk0il" path="res://ui/login/login_code_ui.tscn" id="28_3eh7d"] [node name="GameUI" type="CanvasLayer"] script = ExtResource("1_2ryxh") @@ -65,8 +66,6 @@ visible = false [node name="LoginUI" parent="." instance=ExtResource("2")] visible = false -[node name="NotificationsUI" parent="." instance=ExtResource("13_gvu03")] - [node name="UserTutorial" parent="." instance=ExtResource("7_sxnd1")] offset_top = -2.0 offset_bottom = -2.0 @@ -149,6 +148,11 @@ placeholder_text = "127.0.0.1:27015" layout_mode = 2 text = "connect" +[node name="LoginUIVR" parent="." instance=ExtResource("28_3eh7d")] +visible = true + +[node name="NotificationsUI" parent="." instance=ExtResource("13_gvu03")] + [connection signal="select_asset_id" from="DragDetector" to="CreatorUI" method="_on_drag_detector_select_asset_id"] [connection signal="toggle_main_menu_open" from="CreatorUI" to="MainMenuUI" method="toggle_main_menu_open"] [connection signal="toggle_teams_editor_open" from="CreatorUI" to="TeamHandler" method="toggle_teams_editor"] diff --git a/mirror-godot-app/ui/login/login_code_ui.gd b/mirror-godot-app/ui/login/login_code_ui.gd new file mode 100644 index 00000000..a7c0f85b --- /dev/null +++ b/mirror-godot-app/ui/login/login_code_ui.gd @@ -0,0 +1,27 @@ +extends Control + +@onready var login_code = $VBoxContainer/SignInMenu/MarginContainer/LoginContainer/LoginCode + +func _on_sign_in_pressed() -> void: + if login_code.text.is_empty(): + return + var session_promise = Net.mirror_auth_client.check_login_code(login_code.text) + var data = await session_promise.wait_till_fulfilled() + if session_promise.is_error(): + Notify.error("Failed to login with code", session_promise.get_error_message()) + return + assert(data.userId) + assert(data.refreshToken) + assert(data.spaceId) + assert(data.loginCode) + print("login code data: ", data) + await LoginService.login_as_user_deeplink("", data.refreshToken, data.spaceId, get_tree() ) + +func _ready(): + var login_code: bool = ProjectSettings.get_setting("feature_flags/force_enable_login_code", false) + if login_code: + show() + await get_tree().process_frame + GameUI.instance.login_ui.hide() + else: + hide() diff --git a/mirror-godot-app/ui/login/login_code_ui.tscn b/mirror-godot-app/ui/login/login_code_ui.tscn new file mode 100644 index 00000000..1bed9ac7 --- /dev/null +++ b/mirror-godot-app/ui/login/login_code_ui.tscn @@ -0,0 +1,179 @@ +[gd_scene load_steps=23 format=3 uid="uid://bb7qixdwwk0il"] + +[ext_resource type="Theme" uid="uid://ggwm8asxintx" path="res://ui/common/themes/menu_ui.theme.tres" id="1_qcy1r"] +[ext_resource type="Script" path="res://ui/login/login_code_ui.gd" id="2_pm0hu"] +[ext_resource type="Texture2D" uid="uid://cteylgdhn7712" path="res://ui/login/new_bg.jpg" id="3_wbicg"] +[ext_resource type="Texture2D" uid="uid://b8a6plrtwhc1x" path="res://ui/login/mirror_light_horizontal_new.png" id="4_x0h3t"] +[ext_resource type="Script" path="res://ui/login/app_logo_branding_from_config.gd" id="5_q0xtk"] +[ext_resource type="Shader" path="res://ui/common/shaders/ui_blurr.gdshader" id="6_n3wu6"] +[ext_resource type="StyleBox" uid="uid://nen4cpg1225q" path="res://ui/common/panels/panel_basic_rounded.stylebox.tres" id="7_wg3xc"] +[ext_resource type="StyleBox" uid="uid://b14r8oqdqptk8" path="res://ui/common/panels/panel_round_border_only.tres" id="8_7qtch"] +[ext_resource type="FontFile" uid="uid://s44wjlc18fo7" path="res://ui/ui_rect_and_font/montserrat/static/montserrat_bold.ttf" id="9_h5s0f"] +[ext_resource type="FontFile" uid="uid://wnq6gpmrsr6v" path="res://ui/ui_rect_and_font/montserrat/static/montserrat_medium.ttf" id="10_6y5oa"] +[ext_resource type="FontFile" uid="uid://bjwepurchoc75" path="res://ui/ui_rect_and_font/montserrat/static/montserrat_semi_bold.ttf" id="11_eftmn"] +[ext_resource type="StyleBox" uid="uid://cfnh350gqlauw" path="res://ui/common/buttons/blue_underline/blue_underline_hover.stylebox.tres" id="12_dopow"] +[ext_resource type="StyleBox" uid="uid://ca63qjc22p8ek" path="res://ui/common/buttons/blue_underline/blue_underline_normal.stylebox.tres" id="13_uh7qe"] +[ext_resource type="PackedScene" uid="uid://b58iveuspbtyj" path="res://ui/button_sound/button_sound.tscn" id="19_rxcc2"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_rk4rc"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_tm8vm"] +shader = ExtResource("6_n3wu6") + +[sub_resource type="Theme" id="Theme_ij11x"] + +[sub_resource type="FontVariation" id="Font_mbwka"] +base_font = ExtResource("9_h5s0f") + +[sub_resource type="FontVariation" id="Font_d5673"] +base_font = ExtResource("10_6y5oa") +variation_embolden = 0.5 + +[sub_resource type="FontVariation" id="Font_oqr4b"] +base_font = ExtResource("11_eftmn") + +[sub_resource type="StyleBoxLine" id="StyleBoxLine_secha"] +color = Color(1, 1, 1, 0.2) + +[sub_resource type="FontVariation" id="Font_3a6vw"] +base_font = ExtResource("11_eftmn") + +[node name="LoginUIVR" type="Control"] +visible = false +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_qcy1r") +script = ExtResource("2_pm0hu") + +[node name="TextureRect" type="TextureRect" parent="."] +self_modulate = Color(0.239216, 0.247059, 0.309804, 0.878431) +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_wbicg") +expand_mode = 1 +stretch_mode = 6 + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 0 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -329.0 +offset_top = -369.0 +offset_right = 329.0 +offset_bottom = 369.0 +grow_horizontal = 2 +grow_vertical = 2 +metadata/_edit_layout_mode = 1 + +[node name="TextureRect" type="TextureRect" parent="VBoxContainer"] +custom_minimum_size = Vector2(0, 56) +layout_mode = 2 +texture = ExtResource("4_x0h3t") +expand_mode = 1 +stretch_mode = 5 +script = ExtResource("5_q0xtk") + +[node name="HSeparator" type="HSeparator" parent="VBoxContainer"] +custom_minimum_size = Vector2(0, 30) +layout_mode = 2 +theme_override_styles/separator = SubResource("StyleBoxEmpty_rk4rc") + +[node name="SignInMenu" type="Panel" parent="VBoxContainer"] +material = SubResource("ShaderMaterial_tm8vm") +custom_minimum_size = Vector2(500, 500) +layout_mode = 2 +size_flags_vertical = 3 +theme_override_styles/panel = ExtResource("7_wg3xc") + +[node name="Border" type="Panel" parent="VBoxContainer/SignInMenu"] +layout_mode = 0 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = SubResource("Theme_ij11x") +theme_override_styles/panel = ExtResource("8_7qtch") + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/SignInMenu"] +layout_mode = 0 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 150 +theme_override_constants/margin_top = 100 +theme_override_constants/margin_right = 150 +theme_override_constants/margin_bottom = 100 +metadata/_edit_layout_mode = 1 + +[node name="LoginContainer" type="VBoxContainer" parent="VBoxContainer/SignInMenu/MarginContainer"] +unique_name_in_owner = true +layout_mode = 2 +theme_override_constants/separation = 30 + +[node name="Label" type="Label" parent="VBoxContainer/SignInMenu/MarginContainer/LoginContainer"] +layout_mode = 2 +theme_override_fonts/font = SubResource("Font_mbwka") +theme_override_font_sizes/font_size = 40 +text = "Sign In - Login Code" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="SignUpHereContainer" type="HBoxContainer" parent="VBoxContainer/SignInMenu/MarginContainer/LoginContainer"] +layout_direction = 2 +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 6 +theme_override_constants/separation = 0 +alignment = 1 + +[node name="Label2" type="Label" parent="VBoxContainer/SignInMenu/MarginContainer/LoginContainer/SignUpHereContainer"] +layout_mode = 2 +theme_override_fonts/font = SubResource("Font_d5673") +theme_override_font_sizes/font_size = 14 +text = "Please enter the login code from your meeting or your email." +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="SignUpHere" type="Button" parent="VBoxContainer/SignInMenu/MarginContainer/LoginContainer/SignUpHereContainer"] +visible = false +layout_mode = 2 +size_flags_horizontal = 4 +theme_override_colors/font_color = Color(0.145098, 0.419608, 0.984314, 1) +theme_override_fonts/font = SubResource("Font_oqr4b") +theme_override_font_sizes/font_size = 14 +theme_override_styles/hover = ExtResource("12_dopow") +theme_override_styles/normal = ExtResource("13_uh7qe") +text = "sign up here" + +[node name="LineSeparator" type="HSeparator" parent="VBoxContainer/SignInMenu/MarginContainer/LoginContainer"] +custom_minimum_size = Vector2(450, 1) +layout_mode = 2 +theme_override_styles/separator = SubResource("StyleBoxLine_secha") + +[node name="LoginCode" type="LineEdit" parent="VBoxContainer/SignInMenu/MarginContainer/LoginContainer"] +custom_minimum_size = Vector2(0, 40) +layout_mode = 2 +placeholder_text = "Login Code" +caret_blink = true + +[node name="SignIn" type="Button" parent="VBoxContainer/SignInMenu/MarginContainer/LoginContainer"] +custom_minimum_size = Vector2(0, 50) +layout_mode = 2 +theme_override_fonts/font = SubResource("Font_3a6vw") +text = "Sign In" + +[node name="ButtonSound" parent="." instance=ExtResource("19_rxcc2")] + +[connection signal="pressed" from="VBoxContainer/SignInMenu/MarginContainer/LoginContainer/SignUpHereContainer/SignUpHere" to="." method="_on_sign_up_here_pressed"] +[connection signal="pressed" from="VBoxContainer/SignInMenu/MarginContainer/LoginContainer/SignIn" to="." method="_on_sign_in_pressed"]