2021-12-07 16:43:37 -06:00
|
|
|
extends HBoxContainer
|
|
|
|
|
2021-12-08 16:35:37 -06:00
|
|
|
class_name LobbyControl
|
|
|
|
|
2021-12-07 16:43:37 -06:00
|
|
|
export(String) var id = "Some UUID"
|
2021-12-08 16:35:37 -06:00
|
|
|
export(String) var display_name = "Lobby" setget set_display_name
|
2021-12-07 16:43:37 -06:00
|
|
|
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():
|
2021-12-08 16:35:37 -06:00
|
|
|
$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]
|
2021-12-07 16:43:37 -06:00
|
|
|
|
2021-12-08 16:35:37 -06:00
|
|
|
func set_display_name(t):
|
|
|
|
display_name = t
|
2021-12-07 16:43:37 -06:00
|
|
|
_update_text()
|
|
|
|
|
|
|
|
func set_max_players(n):
|
|
|
|
max_players = n
|
|
|
|
_update_text()
|
|
|
|
|
|
|
|
func set_current_players(n):
|
|
|
|
current_players = n
|
|
|
|
_update_text()
|
2021-12-08 16:35:37 -06:00
|
|
|
|
|
|
|
func _on_join_pressed():
|
|
|
|
Global.client.signaller.join_lobby(id)
|