feat(mvp): complete M13 clean-up milestone (real usernames, avatar studio redesign, pause menu, audio manager)
checkpoint / checkpoint (push) Successful in 6m22s
checkpoint / checkpoint (push) Successful in 6m22s
This commit is contained in:
+54
-1
@@ -52,6 +52,7 @@ var _quit_button: Button
|
||||
|
||||
var _is_register_mode: bool = false
|
||||
var _is_authenticating: bool = false
|
||||
var _sign_out_button: Button = null
|
||||
|
||||
|
||||
# ─── Lifecycle ────────────────────────────────────────────────────────────────
|
||||
@@ -112,6 +113,18 @@ func _ready() -> void:
|
||||
)
|
||||
add_child(fs_btn)
|
||||
|
||||
var ctrl_btn := Button.new()
|
||||
ctrl_btn.name = "ControlsButton"
|
||||
ctrl_btn.set_anchors_preset(Control.PRESET_TOP_RIGHT)
|
||||
ctrl_btn.offset_left = -300
|
||||
ctrl_btn.offset_top = 10
|
||||
ctrl_btn.offset_right = -170
|
||||
ctrl_btn.offset_bottom = 38
|
||||
ctrl_btn.text = "⌨️ Controls"
|
||||
ctrl_btn.add_theme_font_size_override("font_size", 12)
|
||||
ctrl_btn.pressed.connect(_on_controls_button_pressed)
|
||||
add_child(ctrl_btn)
|
||||
|
||||
# Cache node references.
|
||||
_auth_buttons_row = $CenterContainer/VBoxContainer/AuthButtonsRow
|
||||
_login_button = $CenterContainer/VBoxContainer/AuthButtonsRow/LoginButton
|
||||
@@ -121,6 +134,8 @@ func _ready() -> void:
|
||||
_username_edit = $CenterContainer/VBoxContainer/AuthPanel/MarginContainer/AuthVBox/UsernameEdit
|
||||
_password_edit = $CenterContainer/VBoxContainer/AuthPanel/MarginContainer/AuthVBox/PasswordEdit
|
||||
_email_edit = $CenterContainer/VBoxContainer/AuthPanel/MarginContainer/AuthVBox/EmailEdit
|
||||
if _email_edit and not _email_edit.text_submitted.is_connected(_on_auth_button_pressed):
|
||||
_email_edit.text_submitted.connect(_on_auth_button_pressed)
|
||||
_over_18_check = $CenterContainer/VBoxContainer/AuthPanel/MarginContainer/AuthVBox/Over18Check
|
||||
_auth_button = $CenterContainer/VBoxContainer/AuthPanel/MarginContainer/AuthVBox/AuthButton
|
||||
_status_label = $CenterContainer/VBoxContainer/AuthPanel/MarginContainer/AuthVBox/AuthStatusLabel
|
||||
@@ -198,6 +213,15 @@ func _show_authenticated(username: String) -> void:
|
||||
_auth_mode_label.visible = false
|
||||
_set_nav_enabled(true)
|
||||
_auth_buttons_row.visible = false
|
||||
if _sign_out_button == null or not is_instance_valid(_sign_out_button):
|
||||
_sign_out_button = Button.new()
|
||||
_sign_out_button.name = "SignOutButton"
|
||||
_sign_out_button.text = "Sign Out"
|
||||
_sign_out_button.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
_sign_out_button.add_theme_font_size_override("font_size", 12)
|
||||
_sign_out_button.pressed.connect(_on_sign_out_pressed)
|
||||
$CenterContainer/VBoxContainer/AuthPanel/MarginContainer/AuthVBox.add_child(_sign_out_button)
|
||||
_sign_out_button.visible = true
|
||||
print("Restored authenticated session for: ", username)
|
||||
|
||||
|
||||
@@ -207,6 +231,8 @@ func _reset_to_logged_out() -> void:
|
||||
_auth_panel.visible = false
|
||||
_status_label.visible = false
|
||||
_welcome_label.visible = false
|
||||
if _sign_out_button != null and is_instance_valid(_sign_out_button):
|
||||
_sign_out_button.visible = false
|
||||
_email_edit.visible = false
|
||||
_over_18_check.visible = false
|
||||
_over_18_check.button_pressed = true
|
||||
@@ -214,6 +240,13 @@ func _reset_to_logged_out() -> void:
|
||||
_update_auth_mode_ui()
|
||||
|
||||
|
||||
func _on_sign_out_pressed() -> void:
|
||||
ApiClient.clear_token()
|
||||
_reset_to_logged_out()
|
||||
_auth_buttons_row.visible = true
|
||||
_clear_status()
|
||||
|
||||
|
||||
# ─── Navigation ───────────────────────────────────────────────────────────────
|
||||
|
||||
func _on_discover_button_pressed() -> void:
|
||||
@@ -313,7 +346,7 @@ func _update_auth_mode_ui() -> void:
|
||||
|
||||
# ─── Auth submission ──────────────────────────────────────────────────────────
|
||||
|
||||
func _on_auth_button_pressed() -> void:
|
||||
func _on_auth_button_pressed(_text: String = "") -> void:
|
||||
"""Handle login or register button press."""
|
||||
if _is_authenticating:
|
||||
return
|
||||
@@ -428,3 +461,23 @@ func _show_status(message: String) -> void:
|
||||
func _clear_status() -> void:
|
||||
_status_label.text = ""
|
||||
_status_label.visible = false
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
if has_node("ControlsModal"):
|
||||
get_node("ControlsModal").queue_free()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if _auth_panel != null and _auth_panel.visible and not ApiClient.has_token():
|
||||
_auth_panel.visible = false
|
||||
_auth_buttons_row.visible = true
|
||||
_clear_status()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _on_controls_button_pressed() -> void:
|
||||
if has_node("ControlsModal"):
|
||||
return
|
||||
var modal := preload("res://scripts/controls_modal.gd").new()
|
||||
add_child(modal)
|
||||
|
||||
Reference in New Issue
Block a user