Updated GeneralPanel

Updated UI to have Section for Display
Added logic to handle Authorizing Streamer and Bot.
Added logic to handle Connecting to OBS.
Added Loading/Saving Logic for other settings in the General Panel.
This commit is contained in:
Mario Steele 2026-03-02 02:17:42 -06:00
parent 73615a9bb4
commit ba537bc791
2 changed files with 80 additions and 3 deletions

View file

@ -11,6 +11,15 @@ func _ready() -> void:
%ObsPass.right = EYE_SLASH
%ObsPass.secret = true
%ObsPass.right_button_pressed.connect(_handle_password_show)
%DisplayScreen.item_selected.connect(func(x): Globals.main_win.get_window().current_screen = x)
%UseScreen.pressed.connect(func():
Globals.main_win.get_window().current_screen = ProjectSettings.get_setting("display/window/size/initial_screen")
%DisplayScreen.select(Globals.main_win.get_window().current_screen)
%DisplayScreen.disabled = !%UseScreen.button_pressed
)
%AuthStreamer.pressed.connect(func(): %AuthStreamer.disabled = await Globals.twitcher.authorize_streamer())
%AuthBot.pressed.connect(func(): %AuthBot.disabled = await Globals.twitcher.authorize_chatbot())
%ConnectObs.pressed.connect(func(): ObsManager.connect_to_host())
_load_settings()
func _load_settings() -> void:
@ -19,6 +28,42 @@ func _load_settings() -> void:
%ObsPass.text = Globals.settings.obs_pass
%AutoTwitch.button_pressed = Globals.settings.auto_connect_twitch
%AutoObs.button_pressed = Globals.settings.auto_connect_obs
%ObsRecon.button_pressed = Globals.settings.obs_reconnect
%ConnectTwitch.disabled = Globals.twitcher.eventsub.is_open
%ConnectTwitch.text = "Connect Twitch" if not Globals.twitcher.eventsub.is_open else "Disconnect Twitch"
for scr in DisplayServer.get_screen_count():
%DisplayScreen.add_item("Monitor %d" % (scr + 1))
if Globals.settings.display_screen == -1:
%UseScreen.button_pressed = false
%DisplayScreen.disabled = true
else:
%UseScreen.button_pressed = true
%DisplayScreen.select(Globals.settings.display_screen)
%DisplayScreen.disabled = false
if not Globals.twitcher.streamer_token_loaded:
var res := await Globals.twitcher.load_streamer_token()
if res == TwitcherExtended.AuthStatus.UNAUTHORIZED:
%AuthStreamer.disabled = false
else:
%AuthStreamer.disabled = true
%StreamerName.text = Globals.twitcher.streamer_user.display_name
else:
%AuthStreamer.disabled = true
%StreamerName.text = Globals.twitcher.streamer_user.display_name
if not Globals.twitcher.chatbot_token_loaded:
var res := await Globals.twitcher.load_chatbot_token()
if res == TwitcherExtended.AuthStatus.UNAUTHORIZED:
%AuthBot.disabled = false
else:
%AuthBot.disabled = true
%BotName.text = Globals.twitcher.bot_user.display_name
else:
%AuthBot.disabled = true
%BotName.text = Globals.twitcher.bot_user.display_name
func apply_settings() -> void:
Globals.settings.obs_host = %ObsHost.text
@ -26,6 +71,12 @@ func apply_settings() -> void:
Globals.settings.obs_pass = %ObsPass.text
Globals.settings.auto_connect_twitch = %AutoTwitch.button_pressed
Globals.settings.auto_connect_obs = %AutoObs.button_pressed
Globals.settings.obs_reconnect = %ObsRecon.button_pressed
if %UseScreen.button_pressed:
Globals.settings.display_screen = %DisplayScreen.selected
else:
Globals.settings.display_screen = -1
Globals.main_win.get_window().current_screen = ProjectSettings.get_setting("display/window/size/initial_screen")
func _handle_password_show() -> void:
if %ObsPass.right == EYE_SLASH:
@ -34,3 +85,6 @@ func _handle_password_show() -> void:
else:
%ObsPass.right = EYE_SLASH
%ObsPass.secret = true
func _exit_tree() -> void:
apply_settings()

View file

@ -8,7 +8,7 @@
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_7naex"]
content_margin_left = 10.0
content_margin_top = 8.0
content_margin_right = 78.538
content_margin_right = 181.345
texture = ExtResource("2_7naex")
texture_margin_left = 3.08429
texture_margin_top = 5.50548
@ -19,7 +19,7 @@ region_rect = Rect2(93, 474, 41, 33)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_en626"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 72.538
content_margin_right = 175.345
content_margin_bottom = 4.0
bg_color = Color(0.1, 0.1, 0.1, 0.3)
border_width_bottom = 2
@ -33,7 +33,7 @@ corner_detail = 5
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_v8ga3"]
content_margin_left = 10.0
content_margin_top = 8.0
content_margin_right = 78.538
content_margin_right = 181.345
texture = ExtResource("2_7naex")
texture_margin_left = 3.08429
texture_margin_top = 5.50548
@ -218,3 +218,26 @@ unique_name_in_owner = true
custom_minimum_size = Vector2(240, 0)
layout_mode = 2
text = "Connect OBS"
[node name="Control3" type="Control" parent="MarginContainer/VBoxContainer" unique_id=292441254]
custom_minimum_size = Vector2(0, 20)
layout_mode = 2
[node name="Label4" type="Label" parent="MarginContainer/VBoxContainer" unique_id=1102442861]
layout_mode = 2
text = "Display"
[node name="HSeparator4" type="HSeparator" parent="MarginContainer/VBoxContainer" unique_id=2077615507]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer" unique_id=1279240869]
layout_mode = 2
[node name="UseScreen" type="CheckBox" parent="MarginContainer/VBoxContainer/HBoxContainer" unique_id=480029198]
unique_name_in_owner = true
layout_mode = 2
text = "Use Specific Screen:"
[node name="DisplayScreen" type="OptionButton" parent="MarginContainer/VBoxContainer/HBoxContainer" unique_id=151546822]
unique_name_in_owner = true
layout_mode = 2