45 lines
927 B
GDScript
45 lines
927 B
GDScript
extends Control
|
|
|
|
@export var login: Login
|
|
@export var text: RichTextLabel
|
|
|
|
|
|
func _ready() -> void:
|
|
if not login:
|
|
push_error("No Login connectd")
|
|
return
|
|
if not text:
|
|
push_error("No Text label connectd")
|
|
return
|
|
login.connect("login_successful", on_successful)
|
|
login.connect("login_error", on_error)
|
|
hide_banner()
|
|
|
|
|
|
func on_successful(_session: PlayerLoginSession) -> void:
|
|
hide_banner()
|
|
|
|
|
|
func on_error(error: ApiError) -> void:
|
|
if error.identifier == "apibee.request.no_response":
|
|
return
|
|
|
|
show_banner()
|
|
var msg: String = ""
|
|
|
|
if error.identifier == "apibee.connect_to_host.status_failure":
|
|
msg = "Server nicht ereichbar"
|
|
if error.response_code == HTTPClient.RESPONSE_UNAUTHORIZED:
|
|
msg = "Falscher Benutzername oder Passwort"
|
|
|
|
if msg == "":
|
|
msg = error.message
|
|
text.text = msg
|
|
|
|
|
|
func hide_banner() -> void:
|
|
self.modulate = Color.TRANSPARENT
|
|
|
|
|
|
func show_banner() -> void:
|
|
self.modulate = Color.WHITE
|