Added ChatBox to the window. Updated MainWin to handle setting Globals.main_win. Added code to handle ensuring the overlay is on the correct montior chosen by user. Added check for connecting to twitch automatically. Added Subscriptions, to setup subscriptions upon connection. Added ObsManager connection to scene changed. Added ObsManager connection on startup. Added handling of scene changed, adjusting ChatBox to dock to a specific location.
63 lines
2 KiB
GDScript
63 lines
2 KiB
GDScript
extends Control
|
|
class_name OverlayWindow
|
|
|
|
@onready var floating_menu: GDFloatingMenu = %FloatingMenu
|
|
|
|
|
|
#region Twitch Nodes
|
|
@onready var twitcher: TwitcherExtended = $TwitcherExtended
|
|
#endregion
|
|
|
|
@export var subscriptions: Array[TwitchEventsubConfig] = []
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
Globals.main_win = self
|
|
Globals.add_children_to_passthrough_exception(floating_menu, [floating_menu.indicators])
|
|
Globals.enable_mouse_passthrough()
|
|
floating_menu.start()
|
|
Globals.twitcher = twitcher
|
|
if Globals.settings.display_screen != -1:
|
|
get_window().current_screen = Globals.settings.display_screen
|
|
|
|
if Globals.settings.auto_connect_twitch:
|
|
var res := await twitcher.load_streamer_token()
|
|
if res == TwitcherExtended.AuthStatus.UNAUTHORIZED:
|
|
return
|
|
|
|
if await twitcher.setup_streamer():
|
|
for sub in subscriptions:
|
|
if sub.condition.has(&"broadcaster_user_id"):
|
|
sub.condition.broadcaster_user_id = twitcher.streamer_user.id
|
|
if sub.condition.has(&"moderator_user_id"):
|
|
sub.condition.moderator_user_id = twitcher.streamer_user.id
|
|
if sub.condition.has(&"to_broadcaster_user_id"):
|
|
sub.condition.to_broadcaster_user_id = twitcher.streamer_user.id
|
|
|
|
twitcher.subscribe_event(sub.definition, sub.condition)
|
|
|
|
res = await twitcher.load_chatbot_token()
|
|
if res == TwitcherExtended.AuthStatus.UNAUTHORIZED:
|
|
return
|
|
twitcher.setup_chatbot()
|
|
|
|
ObsManager.scene_changed.connect(_handle_scene_changed)
|
|
|
|
if Globals.settings.auto_connect_obs:
|
|
ObsManager.connect_to_host()
|
|
pass
|
|
|
|
func _handle_scene_changed(scene_name: String, scene_uuid: String) -> void:
|
|
match scene_name:
|
|
"StartingSoon":
|
|
%ChatBox.dock = ChatBox.ChatDock.RIGHT
|
|
"Talking":
|
|
%ChatBox.dock = ChatBox.ChatDock.RIGHT
|
|
"Desktop":
|
|
%ChatBox.dock = ChatBox.ChatDock.BOTTOM
|
|
"Gaming":
|
|
%ChatBox.dock = ChatBox.ChatDock.RIGHT
|
|
"BRB":
|
|
%ChatBox.dock = ChatBox.ChatDock.RIGHT
|
|
"EndingSoon":
|
|
%ChatBox.dock = ChatBox.ChatDock.RIGHT
|