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

38 lines
940 B
GDScript3
Raw Normal View History

2021-12-08 16:35:37 -06:00
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 peerId = "Some UUID"
2021-12-08 16:35:37 -06:00
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", "peerId"]
2021-12-08 16:35:37 -06:00
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)