stepstead-client/scripts/login.gd
jts 6a1706051d İlk commit: Stepstead Godot istemci (4.6 Mobile)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 11:31:35 +03:00

32 lines
1.1 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends Control
@onready var email_input: LineEdit = $Panel/VBox/Email
@onready var pw_input: LineEdit = $Panel/VBox/Password
@onready var login_btn: Button = $Panel/VBox/LoginBtn
@onready var register_btn: Button = $Panel/VBox/RegisterBtn
@onready var error_label: Label = $Panel/VBox/Error
func _ready() -> void:
error_label.text = ""
login_btn.pressed.connect(_on_login)
register_btn.pressed.connect(_on_goto_register)
func _on_login() -> void:
error_label.text = ""
login_btn.disabled = true
var res: Dictionary = await Auth.login(email_input.text.strip_edges(), pw_input.text)
login_btn.disabled = false
if not res.ok:
var detail := "Giriş başarısız"
if res.body is Dictionary and res.body.has("detail"):
detail = str(res.body["detail"])
error_label.text = detail
return
var char_res: Dictionary = await GameState.load_character()
if char_res.ok:
get_tree().change_scene_to_file("res://scenes/world.tscn")
else:
get_tree().change_scene_to_file("res://scenes/character_create.tscn")
func _on_goto_register() -> void:
get_tree().change_scene_to_file("res://scenes/register.tscn")