mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
add a way to start RPC from default renderer (#112)
Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/112 Co-authored-by: Lera Elvoé <yagich@poto.cafe> Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
parent
6f5454bf3a
commit
0d546f4fc4
6 changed files with 147 additions and 5 deletions
|
@ -45,6 +45,7 @@ var recent_path: String
|
||||||
enum ConnectionsMenuId {
|
enum ConnectionsMenuId {
|
||||||
OBS,
|
OBS,
|
||||||
TWITCH,
|
TWITCH,
|
||||||
|
RPC,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DebugMenuId {
|
enum DebugMenuId {
|
||||||
|
@ -67,9 +68,13 @@ var _deck_to_save: WeakRef
|
||||||
|
|
||||||
@onready var obs_setup_dialog := $OBSWebsocketSetupDialog as OBSWebsocketSetupDialog
|
@onready var obs_setup_dialog := $OBSWebsocketSetupDialog as OBSWebsocketSetupDialog
|
||||||
@onready var twitch_setup_dialog := $Twitch_Setup_Dialog as TwitchSetupDialog
|
@onready var twitch_setup_dialog := $Twitch_Setup_Dialog as TwitchSetupDialog
|
||||||
|
@onready var rpc_setup_dialog := $RPCSetupDialog as RPCSetupDialog
|
||||||
|
|
||||||
@onready var bottom_dock: BottomDock = %BottomDock
|
@onready var bottom_dock: BottomDock = %BottomDock
|
||||||
|
|
||||||
signal quit_completed
|
signal quit_completed()
|
||||||
|
signal rpc_start_requested(port: int)
|
||||||
|
signal rpc_stop_requested()
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -97,6 +102,32 @@ func _ready() -> void:
|
||||||
)
|
)
|
||||||
add_recents_to_menu()
|
add_recents_to_menu()
|
||||||
|
|
||||||
|
var rpc_port: int = RendererPersistence.get_or_create(
|
||||||
|
PERSISTENCE_NAMESPACE, "config",
|
||||||
|
"rpc_server_port", 6907
|
||||||
|
)
|
||||||
|
rpc_setup_dialog.set_port(rpc_port)
|
||||||
|
rpc_setup_dialog.start_requested.connect(
|
||||||
|
func(port: int):
|
||||||
|
rpc_start_requested.emit(port)
|
||||||
|
RendererPersistence.set_value(
|
||||||
|
PERSISTENCE_NAMESPACE, "config",
|
||||||
|
"rpc_server_port", port
|
||||||
|
)
|
||||||
|
)
|
||||||
|
rpc_setup_dialog.stop_requested.connect(
|
||||||
|
func():
|
||||||
|
rpc_stop_requested.emit()
|
||||||
|
)
|
||||||
|
|
||||||
|
rpc_setup_dialog.confirmed.connect(
|
||||||
|
func():
|
||||||
|
RendererPersistence.set_value(
|
||||||
|
PERSISTENCE_NAMESPACE, "config",
|
||||||
|
"rpc_server_port", rpc_setup_dialog.get_port()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
tab_container.tab_close_requested.connect(
|
tab_container.tab_close_requested.connect(
|
||||||
func(tab: int):
|
func(tab: int):
|
||||||
if tab_container.get_tab_metadata(tab, "dirty") and not tab_container.get_tab_metadata(tab, "group"):
|
if tab_container.get_tab_metadata(tab, "dirty") and not tab_container.get_tab_metadata(tab, "group"):
|
||||||
|
@ -349,6 +380,8 @@ func _on_connections_id_pressed(id: int) -> void:
|
||||||
obs_setup_dialog.popup_centered()
|
obs_setup_dialog.popup_centered()
|
||||||
ConnectionsMenuId.TWITCH:
|
ConnectionsMenuId.TWITCH:
|
||||||
twitch_setup_dialog.popup_centered()
|
twitch_setup_dialog.popup_centered()
|
||||||
|
ConnectionsMenuId.RPC:
|
||||||
|
rpc_setup_dialog.popup_centered()
|
||||||
|
|
||||||
|
|
||||||
func _on_obs_websocket_setup_dialog_connect_button_pressed(state: OBSWebsocketSetupDialog.ConnectionState) -> void:
|
func _on_obs_websocket_setup_dialog_connect_button_pressed(state: OBSWebsocketSetupDialog.ConnectionState) -> void:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=25 format=3 uid="uid://duaah5x0jhkn6"]
|
[gd_scene load_steps=26 format=3 uid="uid://duaah5x0jhkn6"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://graph_node_renderer/deck_holder_renderer.gd" id="1_67g2g"]
|
[ext_resource type="Script" path="res://graph_node_renderer/deck_holder_renderer.gd" id="1_67g2g"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b84f2ngtcm5b8" path="res://graph_node_renderer/tab_container_custom.tscn" id="1_s3ug2"]
|
[ext_resource type="PackedScene" uid="uid://b84f2ngtcm5b8" path="res://graph_node_renderer/tab_container_custom.tscn" id="1_s3ug2"]
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://cuwou2aa7qfc2" path="res://graph_node_renderer/unsaved_changes_dialog_single_deck.tscn" id="8_qf6ve"]
|
[ext_resource type="PackedScene" uid="uid://cuwou2aa7qfc2" path="res://graph_node_renderer/unsaved_changes_dialog_single_deck.tscn" id="8_qf6ve"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cvvkj138fg8jg" path="res://graph_node_renderer/unsaved_changes_dialog.tscn" id="9_4n0q6"]
|
[ext_resource type="PackedScene" uid="uid://cvvkj138fg8jg" path="res://graph_node_renderer/unsaved_changes_dialog.tscn" id="9_4n0q6"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bu466w2w3q08c" path="res://graph_node_renderer/about_dialog.tscn" id="11_6ln7n"]
|
[ext_resource type="PackedScene" uid="uid://bu466w2w3q08c" path="res://graph_node_renderer/about_dialog.tscn" id="11_6ln7n"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://brfrufvkjwcor" path="res://graph_node_renderer/rpc_setup_dialog.tscn" id="12_1xrfk"]
|
||||||
|
|
||||||
[sub_resource type="InputEventKey" id="InputEventKey_giamc"]
|
[sub_resource type="InputEventKey" id="InputEventKey_giamc"]
|
||||||
device = -1
|
device = -1
|
||||||
|
@ -129,11 +130,13 @@ unique_name_in_owner = true
|
||||||
|
|
||||||
[node name="Connections" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"]
|
[node name="Connections" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
item_count = 2
|
item_count = 3
|
||||||
item_0/text = "OBS..."
|
item_0/text = "OBS..."
|
||||||
item_0/id = 0
|
item_0/id = 0
|
||||||
item_1/text = "Twitch.."
|
item_1/text = "Twitch.."
|
||||||
item_1/id = 1
|
item_1/id = 1
|
||||||
|
item_2/text = "RPC Server..."
|
||||||
|
item_2/id = 2
|
||||||
|
|
||||||
[node name="Debug" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"]
|
[node name="Debug" type="PopupMenu" parent="MarginContainer/VSplitContainer/VBoxContainer/MenuBar"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
@ -185,6 +188,8 @@ script = ExtResource("5_3n36q")
|
||||||
|
|
||||||
[node name="Twitch_Setup_Dialog" parent="." instance=ExtResource("7_7rhap")]
|
[node name="Twitch_Setup_Dialog" parent="." instance=ExtResource("7_7rhap")]
|
||||||
|
|
||||||
|
[node name="RPCSetupDialog" parent="." instance=ExtResource("12_1xrfk")]
|
||||||
|
|
||||||
[node name="UnsavedChangesDialogSingleDeck" parent="." instance=ExtResource("8_qf6ve")]
|
[node name="UnsavedChangesDialogSingleDeck" parent="." instance=ExtResource("8_qf6ve")]
|
||||||
|
|
||||||
[node name="UnsavedChangesDialog" parent="." instance=ExtResource("9_4n0q6")]
|
[node name="UnsavedChangesDialog" parent="." instance=ExtResource("9_4n0q6")]
|
||||||
|
|
50
graph_node_renderer/rpc_setup_dialog.gd
Normal file
50
graph_node_renderer/rpc_setup_dialog.gd
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# (c) 2023-present Eroax
|
||||||
|
# (c) 2023-present Yagich
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
extends ConfirmationDialog
|
||||||
|
class_name RPCSetupDialog
|
||||||
|
|
||||||
|
@onready var port_spin_box: SpinBox = %PortSpinBox
|
||||||
|
@onready var start_server_button: Button = %StartServerButton
|
||||||
|
|
||||||
|
var _old_port: int
|
||||||
|
|
||||||
|
var is_started: bool = false
|
||||||
|
|
||||||
|
signal start_requested(port: int)
|
||||||
|
signal stop_requested()
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
canceled.connect(
|
||||||
|
func():
|
||||||
|
port_spin_box.value = float(_old_port)
|
||||||
|
)
|
||||||
|
|
||||||
|
confirmed.connect(
|
||||||
|
func():
|
||||||
|
_old_port = int(port_spin_box.value)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_start_server_button_pressed() -> void:
|
||||||
|
if not is_started:
|
||||||
|
start_server_button.text = "Stop"
|
||||||
|
_old_port = int(port_spin_box.value)
|
||||||
|
start_requested.emit(int(port_spin_box.value))
|
||||||
|
port_spin_box.editable = true
|
||||||
|
is_started = true
|
||||||
|
else:
|
||||||
|
start_server_button.text = "Start"
|
||||||
|
stop_requested.emit()
|
||||||
|
port_spin_box.editable = true
|
||||||
|
is_started = false
|
||||||
|
|
||||||
|
|
||||||
|
func set_port(port: int) -> void:
|
||||||
|
port_spin_box.value = port
|
||||||
|
_old_port = port
|
||||||
|
|
||||||
|
|
||||||
|
func get_port() -> int:
|
||||||
|
return int(port_spin_box.value)
|
44
graph_node_renderer/rpc_setup_dialog.tscn
Normal file
44
graph_node_renderer/rpc_setup_dialog.tscn
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://brfrufvkjwcor"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://graph_node_renderer/rpc_setup_dialog.gd" id="1_7pkns"]
|
||||||
|
|
||||||
|
[node name="RPCSetupDialog" type="ConfirmationDialog"]
|
||||||
|
title = "RPC Server Setup"
|
||||||
|
initial_position = 4
|
||||||
|
size = Vector2i(320, 135)
|
||||||
|
script = ExtResource("1_7pkns")
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 8.0
|
||||||
|
offset_right = -8.0
|
||||||
|
offset_bottom = -49.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Port"
|
||||||
|
|
||||||
|
[node name="PortSpinBox" type="SpinBox" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
max_value = 25565.0
|
||||||
|
value = 6907.0
|
||||||
|
|
||||||
|
[node name="StartServerButton" type="Button" parent="VBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 6
|
||||||
|
text = "Start"
|
||||||
|
|
||||||
|
[connection signal="pressed" from="VBoxContainer/StartServerButton" to="." method="_on_start_server_button_pressed"]
|
12
main.gd
12
main.gd
|
@ -8,6 +8,8 @@ const DEFAULT_RENDERER := preload("res://graph_node_renderer/deck_holder_rendere
|
||||||
var deck_holder_renderer: DeckHolderRenderer = null
|
var deck_holder_renderer: DeckHolderRenderer = null
|
||||||
var deck_holder_renderer_finished := false
|
var deck_holder_renderer_finished := false
|
||||||
|
|
||||||
|
@onready var rpc_renderer := $RPCRenderer as RPCRenderer
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
get_tree().auto_accept_quit = false
|
get_tree().auto_accept_quit = false
|
||||||
|
@ -17,6 +19,8 @@ func _ready() -> void:
|
||||||
deck_holder_renderer = DEFAULT_RENDERER.instantiate()
|
deck_holder_renderer = DEFAULT_RENDERER.instantiate()
|
||||||
add_child(deck_holder_renderer)
|
add_child(deck_holder_renderer)
|
||||||
deck_holder_renderer.quit_completed.connect(_on_deck_holder_renderer_quit_completed)
|
deck_holder_renderer.quit_completed.connect(_on_deck_holder_renderer_quit_completed)
|
||||||
|
deck_holder_renderer.rpc_start_requested.connect(_on_deck_holder_renderer_rpc_start_requested)
|
||||||
|
deck_holder_renderer.rpc_stop_requested.connect(_on_deck_holder_renderer_rpc_stop_requested)
|
||||||
|
|
||||||
|
|
||||||
func _on_deck_holder_renderer_quit_completed() -> void:
|
func _on_deck_holder_renderer_quit_completed() -> void:
|
||||||
|
@ -26,6 +30,14 @@ func _on_deck_holder_renderer_quit_completed() -> void:
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_deck_holder_renderer_rpc_start_requested(port: int) -> void:
|
||||||
|
rpc_renderer.listen(port)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_deck_holder_renderer_rpc_stop_requested() -> void:
|
||||||
|
rpc_renderer.stop()
|
||||||
|
|
||||||
|
|
||||||
func _notification(what: int) -> void:
|
func _notification(what: int) -> void:
|
||||||
if what == NOTIFICATION_WM_CLOSE_REQUEST:
|
if what == NOTIFICATION_WM_CLOSE_REQUEST:
|
||||||
if deck_holder_renderer:
|
if deck_holder_renderer:
|
||||||
|
|
|
@ -94,8 +94,6 @@ func _ready() -> void:
|
||||||
_ws.client_disconnected.connect(_on_ws_client_disconnected)
|
_ws.client_disconnected.connect(_on_ws_client_disconnected)
|
||||||
_ws.message_received.connect(_on_ws_message)
|
_ws.message_received.connect(_on_ws_message)
|
||||||
|
|
||||||
listen()
|
|
||||||
|
|
||||||
|
|
||||||
func listen(port := default_port) -> void:
|
func listen(port := default_port) -> void:
|
||||||
if _ws.listen(port) != OK:
|
if _ws.listen(port) != OK:
|
||||||
|
|
Loading…
Reference in a new issue