miggor-StreamGraph/graph_node_renderer/obs_websocket_setup_dialog.gd

61 lines
1.3 KiB
GDScript3
Raw Permalink Normal View History

2023-11-27 08:52:29 +01:00
extends ConfirmationDialog
class_name OBSWebsocketSetupDialog
@onready var port_spin_box: SpinBox = %PortSpinBox
@onready var password_line_edit: LineEdit = %PasswordLineEdit
@onready var connect_button: Button = %ConnectButton
signal connect_button_pressed(state: ConnectionState)
enum ConnectionState {
DISCONNECTED,
CONNECTING,
CONNECTED,
}
var state: ConnectionState
@onready var _old_port: int = port_spin_box.value
@onready var _old_password: String = password_line_edit.text
func get_port() -> int:
return int(port_spin_box.value)
func get_password() -> String:
return password_line_edit.text
func set_button_state(p_state: ConnectionState) -> void:
connect_button.disabled = p_state == ConnectionState.CONNECTING
state = p_state
match p_state:
ConnectionState.DISCONNECTED:
connect_button.text = "Connect"
ConnectionState.CONNECTING:
connect_button.text = "Connecting..."
ConnectionState.CONNECTED:
connect_button.text = "Disconnect"
func _ready() -> void:
connect_button.pressed.connect(
func():
connect_button_pressed.emit(state)
)
canceled.connect(
func():
print("canceled")
port_spin_box.value = float(_old_port)
password_line_edit.text = _old_password
)
confirmed.connect(
func():
print("confirmed")
_old_port = int(port_spin_box.value)
_old_password = password_line_edit.text
)