feat : update backend
This commit is contained in:
+36
-134
@@ -7,7 +7,6 @@ extends Control
|
||||
@onready var password_input := %PasswordInput as LineEdit
|
||||
@onready var remember_me := %RememberMe as CheckBox
|
||||
@onready var login_button := %LoginButton as Button
|
||||
@onready var register_link := %RegisterLink as LinkButton
|
||||
@onready var google_button := %GoogleButton as Button
|
||||
@onready var apple_button := %AppleButton as Button
|
||||
@onready var facebook_button := %FacebookButton as Button
|
||||
@@ -15,7 +14,7 @@ extends Control
|
||||
@onready var loading_spinner := %LoadingSpinner as TextureProgressBar
|
||||
|
||||
# Registration panel elements
|
||||
@onready var registration_panel := %RegistrationPanel as PanelContainer
|
||||
@onready var tab_container := %TabContainer as TabContainer
|
||||
@onready var reg_email_input := %RegEmailInput as LineEdit
|
||||
@onready var reg_username_input := %RegUsernameInput as LineEdit
|
||||
@onready var reg_password_input := %RegPasswordInput as LineEdit
|
||||
@@ -25,25 +24,33 @@ extends Control
|
||||
@onready var reg_captcha_question := %RegCaptchaQuestion as Label
|
||||
@onready var reg_captcha_input := %RegCaptchaInput as LineEdit
|
||||
@onready var register_button := %RegisterButton as Button
|
||||
@onready var back_to_login_link := %BackToLoginLink as LinkButton
|
||||
@onready var reg_status_label := %RegStatusLabel as Label
|
||||
|
||||
var current_captcha_answer: int = 0
|
||||
|
||||
# Main panel reference
|
||||
@onready var main_panel := $CenterContainer/MainPanel as PanelContainer
|
||||
|
||||
var is_loading: bool = false
|
||||
|
||||
# Server Selection Controls
|
||||
var server_option: OptionButton
|
||||
var server_ip_input: LineEdit
|
||||
var lan_section: VBoxContainer # LAN-specific controls
|
||||
@onready var server_option := %ServerOption as OptionButton
|
||||
@onready var server_ip_input := %ServerIPInput as LineEdit
|
||||
@onready var lan_section := %LANSection as VBoxContainer
|
||||
@onready var lan_host_btn := %LANHostBtn as Button
|
||||
@onready var lan_ip := %LANIPInput as LineEdit
|
||||
@onready var lan_join_btn := %LANJoinBtn as Button
|
||||
|
||||
func _ready() -> void:
|
||||
_connect_signals()
|
||||
_setup_ui()
|
||||
_setup_server_config_ui()
|
||||
|
||||
# Initialize connection mode view
|
||||
if NakamaManager.nakama_host == "localhost":
|
||||
server_option.selected = 0
|
||||
elif NakamaManager.nakama_host == "tektondash.vps.webdock.cloud":
|
||||
server_option.selected = 3
|
||||
else:
|
||||
server_option.selected = 1
|
||||
server_ip_input.text = NakamaManager.nakama_host if NakamaManager.nakama_host != "localhost" else "127.0.0.1"
|
||||
_on_server_option_selected(server_option.selected)
|
||||
|
||||
# Check if already authenticated
|
||||
if AuthManager.is_logged_in():
|
||||
@@ -53,7 +60,6 @@ func _connect_signals() -> void:
|
||||
# Login buttons
|
||||
guest_button.pressed.connect(_on_guest_pressed)
|
||||
login_button.pressed.connect(_on_login_pressed)
|
||||
register_link.pressed.connect(_show_registration)
|
||||
|
||||
# Social buttons
|
||||
google_button.pressed.connect(_on_google_pressed)
|
||||
@@ -62,7 +68,6 @@ func _connect_signals() -> void:
|
||||
|
||||
# Registration buttons
|
||||
register_button.pressed.connect(_on_register_pressed)
|
||||
back_to_login_link.pressed.connect(_show_login)
|
||||
|
||||
# Password strength checker
|
||||
reg_password_input.text_changed.connect(_check_password_strength)
|
||||
@@ -73,6 +78,13 @@ func _connect_signals() -> void:
|
||||
AuthManager.auth_failed.connect(_on_auth_failed)
|
||||
AuthManager.session_restored.connect(_on_session_restored)
|
||||
|
||||
tab_container.tab_changed.connect(_on_tab_changed)
|
||||
server_option.item_selected.connect(_on_server_option_selected)
|
||||
server_ip_input.text_submitted.connect(_on_server_ip_submitted)
|
||||
server_ip_input.focus_exited.connect(func(): _on_server_ip_submitted(server_ip_input.text))
|
||||
lan_host_btn.pressed.connect(_on_lan_host_pressed)
|
||||
lan_join_btn.pressed.connect(func(): _on_lan_join_pressed(lan_ip.text))
|
||||
|
||||
# Enter key to submit
|
||||
password_input.text_submitted.connect(func(_t): _on_login_pressed())
|
||||
reg_confirm_password_input.text_submitted.connect(func(_t): _on_register_pressed())
|
||||
@@ -81,8 +93,7 @@ func _setup_ui() -> void:
|
||||
status_label.text = ""
|
||||
reg_status_label.text = ""
|
||||
loading_spinner.visible = false
|
||||
registration_panel.visible = false
|
||||
main_panel.visible = true
|
||||
tab_container.current_tab = 0
|
||||
|
||||
# Hide social buttons on platforms where they're not supported
|
||||
_configure_social_buttons()
|
||||
@@ -102,12 +113,14 @@ func _configure_social_buttons() -> void:
|
||||
# Panel Switching
|
||||
# =============================================================================
|
||||
|
||||
func _show_registration() -> void:
|
||||
main_panel.visible = false
|
||||
registration_panel.visible = true
|
||||
reg_status_label.text = ""
|
||||
_generate_captcha()
|
||||
reg_email_input.grab_focus()
|
||||
func _on_tab_changed(tab: int) -> void:
|
||||
if tab == 0:
|
||||
status_label.text = ""
|
||||
email_input.grab_focus()
|
||||
elif tab == 1:
|
||||
reg_status_label.text = ""
|
||||
_generate_captcha()
|
||||
reg_email_input.grab_focus()
|
||||
|
||||
func _generate_captcha() -> void:
|
||||
var num1 := randi_range(1, 10)
|
||||
@@ -116,12 +129,6 @@ func _generate_captcha() -> void:
|
||||
reg_captcha_question.text = "Security Check: %d + %d = ?" % [num1, num2]
|
||||
reg_captcha_input.text = ""
|
||||
|
||||
func _show_login() -> void:
|
||||
registration_panel.visible = false
|
||||
main_panel.visible = true
|
||||
status_label.text = ""
|
||||
email_input.grab_focus()
|
||||
|
||||
# =============================================================================
|
||||
# Login Handlers
|
||||
# =============================================================================
|
||||
@@ -183,112 +190,7 @@ func _on_facebook_pressed() -> void:
|
||||
# When you have the access token from Facebook SDK:
|
||||
# AuthManager.login_with_facebook(access_token)
|
||||
|
||||
func _setup_server_config_ui() -> void:
|
||||
"""Inject server configuration controls into MainPanel."""
|
||||
if not main_panel: return
|
||||
|
||||
var vbox = main_panel.get_node_or_null("VBox")
|
||||
if not vbox: return
|
||||
|
||||
# Find where to insert (before GuestButton)
|
||||
var insert_pos = 3 # Default position
|
||||
if guest_button:
|
||||
insert_pos = guest_button.get_index()
|
||||
|
||||
# Create Server Section
|
||||
var server_section = VBoxContainer.new()
|
||||
server_section.name = "ServerSelectionSection"
|
||||
server_section.add_theme_constant_override("separation", 10)
|
||||
vbox.add_child(server_section)
|
||||
vbox.move_child(server_section, insert_pos)
|
||||
|
||||
# Server Label
|
||||
var label = Label.new()
|
||||
label.text = "CONNECTION MODE"
|
||||
label.add_theme_color_override("font_color", Color(0.69, 0.529, 0.357, 1))
|
||||
label.add_theme_font_size_override("font_size", 13)
|
||||
server_section.add_child(label)
|
||||
|
||||
# Server OptionButton
|
||||
server_option = OptionButton.new()
|
||||
server_option.name = "ServerOption"
|
||||
server_option.custom_minimum_size = Vector2(0, 44)
|
||||
server_option.add_item("Nakama - Localhost (Testing)")
|
||||
server_option.add_item("Nakama - Remote Server (Host IP)")
|
||||
server_option.add_item("LAN Direct (No Server)")
|
||||
server_option.add_item("Nakama - Tekton Dash EU")
|
||||
|
||||
# Set initial state based on NakamaManager
|
||||
if NakamaManager.nakama_host == "localhost":
|
||||
server_option.selected = 0
|
||||
elif NakamaManager.nakama_host == "tektondash.vps.webdock.cloud":
|
||||
server_option.selected = 3
|
||||
else:
|
||||
server_option.selected = 1
|
||||
|
||||
server_option.item_selected.connect(_on_server_option_selected)
|
||||
server_section.add_child(server_option)
|
||||
|
||||
# Nakama Server IP Input
|
||||
server_ip_input = LineEdit.new()
|
||||
server_ip_input.name = "ServerIPInput"
|
||||
server_ip_input.custom_minimum_size = Vector2(0, 44)
|
||||
server_ip_input.placeholder_text = "Enter Nakama Server IP..."
|
||||
server_ip_input.text = NakamaManager.nakama_host if NakamaManager.nakama_host != "localhost" else "127.0.0.1"
|
||||
server_ip_input.visible = server_option.selected == 1
|
||||
server_ip_input.text_submitted.connect(_on_server_ip_submitted)
|
||||
server_ip_input.focus_exited.connect(func(): _on_server_ip_submitted(server_ip_input.text))
|
||||
server_section.add_child(server_ip_input)
|
||||
|
||||
# --- LAN Section ---
|
||||
lan_section = VBoxContainer.new()
|
||||
lan_section.name = "LANSection"
|
||||
lan_section.add_theme_constant_override("separation", 8)
|
||||
lan_section.visible = false
|
||||
server_section.add_child(lan_section)
|
||||
|
||||
var lan_info = Label.new()
|
||||
lan_info.text = "Play over LAN without any server.\nFirewall may need to allow port 7777."
|
||||
lan_info.add_theme_color_override("font_color", Color(0.7, 0.7, 0.7, 1))
|
||||
lan_info.add_theme_font_size_override("font_size", 12)
|
||||
lan_info.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
lan_section.add_child(lan_info)
|
||||
|
||||
# Host LAN button
|
||||
var lan_host_btn = Button.new()
|
||||
lan_host_btn.name = "LANHostBtn"
|
||||
lan_host_btn.text = "HOST LAN GAME"
|
||||
lan_host_btn.custom_minimum_size = Vector2(0, 44)
|
||||
lan_host_btn.pressed.connect(_on_lan_host_pressed)
|
||||
lan_section.add_child(lan_host_btn)
|
||||
|
||||
var lan_sep = Label.new()
|
||||
lan_sep.text = "── or join a friend ──"
|
||||
lan_sep.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
lan_sep.add_theme_color_override("font_color", Color(0.5, 0.5, 0.5, 1))
|
||||
lan_sep.add_theme_font_size_override("font_size", 11)
|
||||
lan_section.add_child(lan_sep)
|
||||
|
||||
# LAN Host IP input
|
||||
var lan_ip = LineEdit.new()
|
||||
lan_ip.name = "LANIPInput"
|
||||
lan_ip.custom_minimum_size = Vector2(0, 44)
|
||||
lan_ip.placeholder_text = "Host IP (e.g. 192.168.1.10)"
|
||||
lan_ip.text = "127.0.0.1"
|
||||
lan_section.add_child(lan_ip)
|
||||
|
||||
# Join LAN button
|
||||
var lan_join_btn = Button.new()
|
||||
lan_join_btn.name = "LANJoinBtn"
|
||||
lan_join_btn.text = "JOIN LAN GAME"
|
||||
lan_join_btn.custom_minimum_size = Vector2(0, 44)
|
||||
lan_join_btn.pressed.connect(func(): _on_lan_join_pressed(lan_ip.text))
|
||||
lan_section.add_child(lan_join_btn)
|
||||
|
||||
# Add a separator after the section
|
||||
var separator = HSeparator.new()
|
||||
vbox.add_child(separator)
|
||||
vbox.move_child(separator, insert_pos + 1)
|
||||
|
||||
|
||||
func _on_server_option_selected(index: int) -> void:
|
||||
if index == 0:
|
||||
@@ -322,7 +224,7 @@ func _on_lan_host_pressed() -> void:
|
||||
player_name = "Host"
|
||||
LobbyManager.local_player_name = player_name
|
||||
|
||||
var ok = await LobbyManager.create_room_lan()
|
||||
var ok = LobbyManager.create_room_lan()
|
||||
if ok:
|
||||
_go_to_lobby()
|
||||
else:
|
||||
@@ -490,7 +392,7 @@ func _on_auth_failed(error: String) -> void:
|
||||
loading_spinner.visible = false
|
||||
_set_inputs_enabled(true)
|
||||
|
||||
if registration_panel.visible:
|
||||
if tab_container.current_tab == 1:
|
||||
_show_reg_error(error)
|
||||
else:
|
||||
_show_error(error)
|
||||
|
||||
Reference in New Issue
Block a user