48 lines
1.3 KiB
GDScript3
48 lines
1.3 KiB
GDScript3
|
extends TextureButton
|
||
|
|
||
|
const MUTE_NORMAL = preload("res://user_interface/call_panel/icons/mute.png")
|
||
|
const MUTE_HOVER = preload("res://user_interface/call_panel/icons/mute_hover.png")
|
||
|
const MUTE_PRESSED = preload("res://user_interface/call_panel/icons/mute_pressed.png")
|
||
|
|
||
|
const UNMUTE_NORMAL = preload("res://user_interface/call_panel/icons/unmute.png")
|
||
|
const UNMUTE_HOVER = preload("res://user_interface/call_panel/icons/unmute_hover.png")
|
||
|
const UNMUTE_PRESSED = preload("res://user_interface/call_panel/icons/unmute_pressed.png")
|
||
|
|
||
|
|
||
|
func _ready():
|
||
|
# warning-ignore:return_value_discarded
|
||
|
Call.connect("mute_toggled", self, "_on_mute_toggled")
|
||
|
# warning-ignore:return_value_discarded
|
||
|
Users.connect("switched", self, "_on_user_switched")
|
||
|
|
||
|
|
||
|
func _change_icon_to_mute():
|
||
|
texture_normal = MUTE_NORMAL
|
||
|
texture_hover = MUTE_HOVER
|
||
|
texture_pressed = MUTE_PRESSED
|
||
|
|
||
|
|
||
|
func _change_icon_to_unmute():
|
||
|
texture_normal = UNMUTE_NORMAL
|
||
|
texture_hover = UNMUTE_HOVER
|
||
|
texture_pressed = UNMUTE_PRESSED
|
||
|
|
||
|
|
||
|
func _on_pressed():
|
||
|
if Users.get_primary().is_current():
|
||
|
Call.toggle_mute()
|
||
|
|
||
|
|
||
|
func _on_mute_toggled(value):
|
||
|
if value:
|
||
|
_change_icon_to_unmute()
|
||
|
else:
|
||
|
_change_icon_to_mute()
|
||
|
|
||
|
|
||
|
func _on_user_switched():
|
||
|
if Users.get_helper().is_current():
|
||
|
_change_icon_to_unmute()
|
||
|
else:
|
||
|
_on_mute_toggled(Call.is_muted)
|