All checks were successful
Quality Check / Linting (push) Successful in 8s
Build Application / generate (push) Successful in 30s
Build Application / build (tower_defence_web, build/*, build, build/index.html, Web) (push) Successful in 15s
Build Application / build (tower_defence.elf, tower_defence.elf, tower_defence.elf, Linux) (push) Successful in 19s
Build Application / build (tower_defence.exe, tower_defence.exe, tower_defence.exe, Windows) (push) Successful in 21s
Build Application / build-docker (push) Successful in 18s
Build Application / release (push) Successful in 9s
37 lines
859 B
GDScript
37 lines
859 B
GDScript
extends Button
|
|
|
|
@export var username_field: LineEdit
|
|
@export var password_field: LineEdit
|
|
@export var api_config: ApiConfig
|
|
var api: ServerApi
|
|
|
|
|
|
func _ready() -> void:
|
|
if not username_field:
|
|
push_error("No Username Field set")
|
|
return
|
|
if not password_field:
|
|
push_error("No Password Field set")
|
|
return
|
|
if not api_config:
|
|
push_error("No API Configuration provided")
|
|
return
|
|
api = ServerApi.new(api_config)
|
|
connect("pressed", login)
|
|
username_field.connect("pressed", login)
|
|
password_field.connect("pressed", login)
|
|
|
|
|
|
func login() -> void:
|
|
var login_data = PlayerLoginData.new()
|
|
login_data.username = username_field.text
|
|
login_data.password = password_field.text
|
|
api.player_login(login_data, on_login_response, error)
|
|
|
|
|
|
func on_login_response(a: ApiResponse) -> void:
|
|
print(a.body)
|
|
|
|
|
|
func error(b: ApiError) -> void:
|
|
print(b.response_code)
|