Improved main scene code
This commit is contained in:
32
client/Main.gd
Normal file
32
client/Main.gd
Normal file
@ -0,0 +1,32 @@
|
||||
extends Node
|
||||
|
||||
func _ready():
|
||||
Global.instance_id = OS.get_process_id() % 4
|
||||
Global.username = "user%d" % Global.instance_id
|
||||
|
||||
%Login.success.connect(on_login)
|
||||
%Login.send_login()
|
||||
|
||||
mute_audio()
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("toggle_fullscreen"):
|
||||
toggle_fullscreen()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func mute_audio():
|
||||
var master_sound = AudioServer.get_bus_index("Master")
|
||||
AudioServer.set_bus_mute(master_sound, true)
|
||||
|
||||
func on_login():
|
||||
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))
|
||||
|
||||
func toggle_fullscreen():
|
||||
var mode = DisplayServer.window_get_mode()
|
||||
|
||||
match mode:
|
||||
DisplayServer.WINDOW_MODE_FULLSCREEN:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
||||
_:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
Reference in New Issue
Block a user