newgrounds login system :)
This commit is contained in:
parent
a205fc3008
commit
644748463c
3 changed files with 215 additions and 4 deletions
43
menus/newgrounds_login.gd
Normal file
43
menus/newgrounds_login.gd
Normal file
|
@ -0,0 +1,43 @@
|
|||
extends Control
|
||||
|
||||
onready var tab_container: TabContainer = $"%TabContainer"
|
||||
|
||||
func _ready() -> void:
|
||||
visible = false
|
||||
Fade.fade_out(0.4)
|
||||
yield(Fade, "fade_finished")
|
||||
visible = true
|
||||
yield(get_tree(), "idle_frame")
|
||||
grab_focus()
|
||||
Fade.fade_in(0.4)
|
||||
if not Ngio.keys_loaded:
|
||||
tab_container.current_tab = 2
|
||||
return
|
||||
if Ngio.session.user == null and not Ngio.session.passport_url.empty():
|
||||
var passport_url = Ngio.session.passport_url
|
||||
# try to open in browser
|
||||
OS.shell_open(passport_url)
|
||||
# try to copy to clipboard
|
||||
OS.clipboard = passport_url
|
||||
if OS.has_clipboard():
|
||||
$"%Clipboard".modulate.a = 1.0
|
||||
_await_result()
|
||||
elif Ngio.session.user != null:
|
||||
tab_container.current_tab = 1
|
||||
else:
|
||||
tab_container.current_tab = 2
|
||||
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
if tab_container.current_tab == 0:
|
||||
Ngio.request_execute("App.endSession")
|
||||
queue_free()
|
||||
elif event.is_action_pressed("ui_accept") and tab_container.current_tab != 0:
|
||||
queue_free()
|
||||
|
||||
func _await_result() -> void:
|
||||
var success = yield(Ngio.passport_check(), "completed")
|
||||
if success:
|
||||
tab_container.current_tab = 1
|
||||
else:
|
||||
tab_container.current_tab = 2
|
Loading…
Add table
Add a link
Reference in a new issue