godot-webrtc-mplayer-testing/scripts/objects/lobby.gd

38 lines
908 B
GDScript

extends HBoxContainer
class_name LobbyControl
export(String) var id = "Some UUID"
export(String) var display_name = "Lobby" setget set_display_name
export(int) var max_players = 20 setget set_max_players
export(int) var current_players = 1 setget set_current_players
export(bool) var locked = false
func _ready():
_update_text()
func _update_text():
$Label.text = "%s (%d/%d players)" % [display_name, current_players, max_players]
const keys = ["id", "display_name", "max_players", "current_players", "locked"]
func set_with_dict(dict):
if dict.has("name"): self.display_name = dict["name"]
for k in keys:
if dict.has(k):
self[k] = dict[k]
func set_display_name(t):
display_name = t
_update_text()
func set_max_players(n):
max_players = n
_update_text()
func set_current_players(n):
current_players = n
_update_text()
func _on_join_pressed():
Global.signaller_client.join_lobby(id)