46 lines
1.3 KiB
GDScript3
Raw Normal View History

2024-01-14 11:22:14 +00:00
extends Node
func _ready():
2024-01-29 22:16:06 +00:00
pause(true)
2024-01-29 11:32:06 +00:00
Global.instance_id = OS.get_process_id() % 4
Global.username = "user%d" % Global.instance_id
2024-01-14 11:22:14 +00:00
2024-01-29 11:32:06 +00:00
%Login.success.connect(on_login)
2024-01-29 22:16:06 +00:00
%Logout.success.connect(on_logout)
2024-01-29 11:32:06 +00:00
%Login.send_login()
2024-01-14 11:22:14 +00:00
func _input(event):
if event.is_action_pressed("toggle_fullscreen"):
2024-01-15 23:22:14 +00:00
toggle_fullscreen()
2024-01-29 11:32:06 +00:00
get_viewport().set_input_as_handled()
func on_login():
2024-01-29 22:16:06 +00:00
print("[%s] Login succeeded." % Global.username)
print("[%s] ID: %s" % [Global.username, Global.account_id])
print("[%s] Auth token: %s" % [Global.username, Global.auth_token])
2024-01-29 11:32:06 +00:00
DisplayServer.window_set_title("%s - %s" % [Global.username, Global.account_id])
DisplayServer.window_set_position(Vector2((Global.instance_id % 2) * 960, (Global.instance_id / 2 % 2) * 540))
2024-01-29 22:16:06 +00:00
pause(false)
func on_logout():
print("[%s] Logout." % Global.username)
pause(true)
func pause(enabled: bool):
get_tree().paused = enabled
mute_audio(enabled)
func mute_audio(enabled: bool):
var master_sound = AudioServer.get_bus_index("Master")
AudioServer.set_bus_mute(master_sound, enabled)
2024-01-14 11:22:14 +00:00
2024-01-15 23:22:14 +00:00
func toggle_fullscreen():
var mode = DisplayServer.window_get_mode()
2024-01-14 11:22:14 +00:00
2024-01-15 23:22:14 +00:00
match mode:
DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
_:
2024-01-29 11:32:06 +00:00
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)