37 lines
890 B
GDScript3
37 lines
890 B
GDScript3
|
extends HBoxContainer
|
||
|
|
||
|
class_name PeerControl
|
||
|
|
||
|
onready var ready_tex: Texture = load("res://assets/img/check.png")
|
||
|
onready var not_ready_tex: Texture = load("res://assets/img/cross.png")
|
||
|
|
||
|
export(String) var id = "Some UUID"
|
||
|
export(String) var display_name = "Lobby" setget set_display_name
|
||
|
export(bool) var ready = false setget set_ready
|
||
|
|
||
|
func _ready():
|
||
|
_update()
|
||
|
|
||
|
func _update():
|
||
|
$Label.text = "%s" % [display_name]
|
||
|
$TextureRect.texture = ready_tex if ready else not_ready_tex
|
||
|
$TextureRect.hint_tooltip = "Ready" if ready else "Not Ready"
|
||
|
|
||
|
const keys = ["id", "display_name", "ready"]
|
||
|
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()
|
||
|
|
||
|
func set_ready(n):
|
||
|
ready = n
|
||
|
_update()
|
||
|
|
||
|
func _on_join_pressed():
|
||
|
Global.client.signaller.join_lobby(id)
|