-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Milestone
Description
Problem
Currently, the Twitch setup, authentication check, and welcome message are performed in Stages/Game/main/main.gd inside _ready(), which runs every time a scenario is loaded. This means:
- Twitch setup is re-run on each scenario load, which is unnecessary and potentially disruptive.
- The welcome message (if configured) is sent every time a scenario starts, rather than once when the game is launched.
- Twitch authentication state is not managed at the application level, leading to possible repeated setup attempts.
Relevant Code
File: Stages/Game/main/main.gd, lines 77–96
# Check if twitch integration is enabled and then set it up if so
if SettingsManager.twitch_enabled:
MyLogger.info("Main", "Twitch integration enabled - setting up Twitch connection")
var setup_successful: bool = await Twitch.setup()
if setup_successful:
MyLogger.info("Main", "Twitch setup successful")
var me = await Twitch.get_current_user()
MyLogger.info("Main", "Twitch authenticated as %s (ID: %s)" % [me.display_name, me.id])
if SettingsManager.twitch_welcome_message != "":
Twitch.chat(SettingsManager.twitch_welcome_message)
Twitch.api.unauthenticated.connect(_on_twitch_unauthenticated)
else:
# display a message to the user if Twitch setup failed, but don't disable the game features since Twitch is optional
MyLogger.error("Main", "Twitch setup failed - Twitch features will be unavailable")
ui.call_deferred("show_problem_message", "Twitch integration failed to set up. Twitch features will be unavailable. Please check the logs for more details.")Proposed Solution
Move the Twitch initialization logic to an earlier, application-level point — such as the main menu scene or an autoloaded system (e.g., GameManager) — so that:
- Twitch setup runs once when the game is launched, not per-scenario.
- The welcome message is sent once at game startup.
- The
unauthenticatedsignal handler is connected at the application level, with UI feedback routed appropriately regardless of which scene is active. - Twitch connection status is available globally so the main menu or HUD can reflect it.
Considerations
- The
uireference inmain.gdis aMainUInode; error/status messages would need to be surfaced differently if Twitch init moves out of the scenario scene. GameManager(already autoloaded) could be a good home for this logic, emitting a signal liketwitch_status_changedthat any scene can subscribe to.- Alternatively, a dedicated
TwitchManagerautoload could handle connection lifecycle. - Care should be taken to avoid re-connecting the
unauthenticatedsignal multiple times across scene reloads. - The TwitchCommand nodes in the Main scene and their signals and handlers will also need to move.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Projects
Status
Backlog