From 69b6f40eb98e9b2f78b549631941422ff1d4a201 Mon Sep 17 00:00:00 2001 From: coder-bot Date: Wed, 19 Aug 2026 17:10:14 +0000 Subject: [PATCH] WIP checkpoint: Implementation: Login/Register UI wired to /api/auth --- scripts/main_menu.gd | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/scripts/main_menu.gd b/scripts/main_menu.gd index db5571f..08a0487 100644 --- a/scripts/main_menu.gd +++ b/scripts/main_menu.gd @@ -10,7 +10,7 @@ extends Control ## shows the username, and the Play button becomes enabled. -# ── UI references ────────────────────────────────────────────────────────── +# ── UI references ──────────────────────────────────────────────────────────── var _auth_panel: PanelContainer var _auth_mode_label: Label @@ -29,7 +29,7 @@ var _is_register_mode: bool = false var _is_authenticating: bool = false -# ── Lifecycle ────────────────────────────────────────────────────────────── +# ── Lifecycle ──────────────────────────────────────────────────────────────── func _ready() -> void: # Cache node references. @@ -56,7 +56,7 @@ func _ready() -> void: _update_auth_mode_ui() -# ── Play / Quit ─────────────────────────────────────────────────────────── +# ── Play / Quit ────────────────────────────────────────────────────────────── func _on_play_button_pressed() -> void: if _play_button.disabled: @@ -69,7 +69,7 @@ func _on_quit_button_pressed() -> void: get_tree().quit() -# ── Auth panel toggle ───────────────────────────────────────────────────── +# ── Auth panel toggle ──────────────────────────────────────────────────────── func _on_login_button_pressed() -> void: """Show the auth panel (called from a future Login button on the main menu).""" @@ -86,7 +86,7 @@ func _on_register_button_pressed() -> void: _clear_status() -# ── Mode toggle (Login / Register) ──────────────────────────────────────── +# ── Mode toggle (Login / Register) ─────────────────────────────────────────── func _on_mode_toggle_toggled(button_pressed: bool) -> void: _is_register_mode = button_pressed @@ -108,7 +108,7 @@ func _update_auth_mode_ui() -> void: _dob_edit.visible = false -# ── Auth submission ─────────────────────────────────────────────────────── +# ── Auth submission ────────────────────────────────────────────────────────── func _on_auth_button_pressed() -> void: """Handle login or register button press.""" @@ -174,15 +174,9 @@ func _on_auth_complete(result: Dictionary) -> void: else: # Failure — show backend error detail. _show_status(result.detail) - # Clear token if somehow it was set but request wasn't ok. - if not ApiClient.has_token(): - pass # No token to clear. -else: - # Network failure or unexpected response. - _show_status(result.detail) -# ── Status helpers ───────────────────────────────────────────────────────── +# ── Status helpers ─────────────────────────────────────────────────────────── func _show_status(message: String) -> void: _status_label.text = message @@ -194,7 +188,7 @@ func _clear_status() -> void: _status_label.visible = false -# ── Validation ───────────────────────────────────────────────────────────── +# ── Validation ─────────────────────────────────────────────────────────────── func _is_valid_date(date_str: String) -> bool: """Check if a string looks like a valid YYYY-MM-DD date."""