namespace OkonaPad
{
    /// <summary>
    /// Control over the parts of the Okona shell that overlay your game.
    ///
    /// By default Okona shows a "Turn on a controller to play" screen (with a
    /// pairing QR) whenever no controller is connected. If your game presents its
    /// own way to join — a lobby with a scan code, a signage attract loop — call
    /// <see cref="HideJoinScreen"/> once at startup so players aren't shown two
    /// codes at the same time:
    ///
    /// <code>
    /// void Start() { SystemUI.HideJoinScreen(); }
    /// </code>
    ///
    /// The Game Menu (Home button) is unaffected and always keeps its pairing QR —
    /// it's the system's escape hatch, so anyone already holding a controller can
    /// still get a code even if your join screen isn't up.
    ///
    /// Because this is a call from your running game, it only takes effect once
    /// your build has loaded — the system screen still covers the loading period.
    /// For an unattended display, also add <c>&amp;joinui=off</c> to the share link
    /// so nothing shows before your game does. On the Okona Console the console
    /// builds its own URLs, so the runtime call is the only way in.
    /// </summary>
    public static class SystemUI
    {
        /// <summary>Whether Okona's own join screen is currently allowed to appear.</summary>
        public static bool JoinScreenVisible { get; private set; } = true;

        /// <summary>Take over joining: suppress Okona's "Turn on a controller to play" screen.</summary>
        public static void HideJoinScreen() => SetJoinScreenVisible(false);

        /// <summary>Hand joining back to Okona.</summary>
        public static void ShowJoinScreen() => SetJoinScreenVisible(true);

        /// <summary>Show or hide Okona's join screen. Safe to call at any time, repeatedly.</summary>
        public static void SetJoinScreenVisible(bool visible)
        {
            JoinScreenVisible = visible;
            OkonaInterop.SetJoinUi(visible);
        }
    }
}
