Ejemplo n.º 1
0
        public static void LaunchServerBrowser()
        {
            ViewController viewToMount;

            if (Plugin.Config.UseNativeBrowserPreview)
            {
                // Native browser preview (in development)
                NativeServerBrowser.SetUp();

                viewToMount = NativeServerBrowser.ViewController;
            }
            else
            {
                // Original custom BSML based browser
                if (_serverBrowserViewController == null)
                {
                    _serverBrowserViewController = BeatSaberUI.CreateViewController <ServerBrowserViewController>();
                }

                viewToMount = _serverBrowserViewController;
            }

            if (viewToMount != null)
            {
                MpModeSelection.PresentViewController(viewToMount);
            }
        }
Ejemplo n.º 2
0
        public static bool Prefix(MultiplayerModeSelectionFlowCoordinator __instance, ConnectionFailedReason reason)
        {
            Plugin.Log.Warn($"Multiplayer connection failed, reason: {reason}");

            if (MpModeSelection.WeInitiatedConnection)
            {
                // We only take over error handling UI if we initiated the connection
                if (reason == ConnectionFailedReason.ConnectionCanceled)
                {
                    // ...and if it's just a self-cancel, return to the browser immediately.
                    MpModeSelection.CancelLobbyJoin();
                    MpModeSelection.MakeServerBrowserTopView();
                }
                else
                {
                    MpModeSelection.PresentConnectionFailedError
                    (
                        errorMessage: ConnectionErrorText.Generate(reason),
                        canRetry: reason != ConnectionFailedReason.InvalidPassword && reason != ConnectionFailedReason.VersionMismatch
                    );
                }
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        private void OnEnable()
        {
            MpModeSelection.SetTitle("Server Browser");

            HostedGameBrowser.OnUpdate        += OnBrowserUpdate;
            _tableView.joinButtonPressedEvent += OnJoinPressed;

            DoFullRefresh();
        }
Ejemplo n.º 4
0
        private void OnLateMenuSceneLoadedFresh(ScenesTransitionSetupDataSO obj)
        {
            // Bind multiplayer session events
            MpSession.SetUp();
            MpModeSelection.SetUp();

            // UI setup
            PluginUi.SetUp();

            // Initial state update
            GameStateManager.HandleUpdate();
        }
Ejemplo n.º 5
0
        public static bool Prefix(MultiplayerModeSelectionFlowCoordinator __instance, ConnectionFailedReason reason)
        {
            Plugin.Log.Warn($"Multiplayer connection failed, reason: {reason}");

            if (MpModeSelection.WeInitiatedConnection)
            {
                // We only take over error handling UI if we initiated the connection
                MpModeSelection.PresentConnectionError(reason);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
        private void SetInitialUiState()
        {
            MpModeSelection.SetTitle("Server Browser");

            StatusText.text  = "Loading...";
            StatusText.color = Color.gray;

            RefreshButton.interactable = false;
            SearchButton.interactable  = false;
            ConnectButton.interactable = false;

            PageUpButton.interactable   = false;
            PageDownButton.interactable = false;

            ClearSelection();
            CancelImageLoading();
        }
        private void SetInitialUiState()
        {
            MpModeSelection.SetTitle("Server Browser");

            StatusText.text  = "Loading...";
            StatusText.color = Color.gray;

            // sometimes the non-primary buttons become disabled if the server browser
            //  isn't opened until after level selection, so let's ensure they're active
            RefreshButton.gameObject.SetActive(true);
            SearchButton.gameObject.SetActive(true);
            CreateButton.gameObject.SetActive(true);

            RefreshButton.interactable = false;
            SearchButton.interactable  = false;
            ConnectButton.interactable = false;

            PageUpButton.interactable   = false;
            PageDownButton.interactable = false;

            ClearSelection();
            CancelImageLoading();
        }
Ejemplo n.º 8
0
 public static void LaunchServerBrowser()
 {
     MpModeSelection.PresentViewController(ServerBrowserViewController, animationDirection: AnimationDirection.Horizontal);
 }
Ejemplo n.º 9
0
        private void Awake()
        {
            // Create ModalKeyboard (BSML)
            var modalKeyboardTag = new ModalKeyboardTag();
            var modalKeyboardObj = modalKeyboardTag.CreateObject(transform);

            _modalKeyboard                        = modalKeyboardObj.GetComponent <ModalKeyboard>();
            _modalKeyboard.clearOnOpen            = false;
            _modalKeyboard.keyboard.EnterPressed += OnModalKeyboardSubmit;

            // Create server button
            var createServerButtonTransform = transform.Find("CreateServerButton");

            createServerButtonTransform.localPosition = new Vector3(-76.50f, 40.0f, 0.0f);

            _createServerButton = transform.Find("CreateServerButton").GetComponent <Button>();
            _createServerButton.onClick.AddListener(delegate
            {
                MpModeSelection.OpenCreateServerMenu();
            });

            // Move the top-right loading control up, so the refresh button aligns properly
            (transform.Find("Filters/SmallLoadingControl") as RectTransform).localPosition = new Vector3(62.0f, 3.5f, 0.0f);

            // Resize the filters bar so it doesn't overlap the refresh button
            var filterButtonTransform = (transform.Find("Filters/FilterButton") as RectTransform);

            filterButtonTransform.sizeDelta = new Vector2(-11.0f, 10.0f);
            filterButtonTransform.offsetMax = new Vector2(-11.0f, 5.0f);

            _filterButton = filterButtonTransform.GetComponent <Button>();
            _filterButton.onClick.AddListener(delegate
            {
                _modalKeyboard.keyboard.KeyboardText.text = !String.IsNullOrEmpty(_searchQuery) ? _searchQuery : "";
                //_modalKeyboard.keyboard.KeyboardText.fontSize = 4;

                _modalKeyboard.modalView.Show(true, true, null);
            });

            // Filters lable
            _filterButtonLabel      = transform.Find("Filters/FilterButton/Content/Text").GetComponent <CurvedTextMeshPro>();
            _filterButtonLabel.text = "Hello world!";

            // Hide top-right loading spinners
            Destroy(transform.Find("Filters/SmallLoadingControl/LoadingContainer").gameObject);
            Destroy(transform.Find("Filters/SmallLoadingControl/DownloadingContainer").gameObject);

            // Refresh button (add listener, make visible)
            var smallLoadingControl = transform.Find("Filters/SmallLoadingControl").GetComponent <LoadingControl>();

            smallLoadingControl.didPressRefreshButtonEvent += OnRefreshPressed;

            var refreshContainer = smallLoadingControl.transform.Find("RefreshContainer");

            refreshContainer.gameObject.SetActive(true);

            _refreshButton = refreshContainer.Find("RefreshButton").GetComponent <Button>();

            // Change "Music Packs" table header to "Type"
            transform.Find("GameServersListTableView/GameServerListTableHeader/LabelsContainer/MusicPack").GetComponent <CurvedTextMeshPro>()
            .SetText("Type");

            // Main loading control
            _mainLoadingControl = transform.Find("GameServersListTableView/TableView/Viewport/MainLoadingControl").GetComponent <LoadingControl>();
            _mainLoadingControl.didPressRefreshButtonEvent += OnRefreshPressed;

            _mainLoadingControl.ShowLoading("Initializing");

            // Table view
            _tableView = transform.Find("GameServersListTableView").GetComponent <GameServersListTableView>();

            // Modify content cell prefab (add a background)
            var contentCellPrefab = _tableView.GetField <GameServerListTableCell, GameServersListTableView>("_gameServerListCellPrefab");

            var backgroundBase = Resources.FindObjectsOfTypeAll <ImageView>().First(x => x.gameObject?.name == "Background" &&
                                                                                    x.sprite != null && x.sprite.name.StartsWith("RoundRect10"));

            var backgroundClone = UnityEngine.Object.Instantiate(backgroundBase);

            backgroundClone.transform.SetParent(contentCellPrefab.transform, false);
            backgroundClone.transform.SetAsFirstSibling();
            backgroundClone.name = "Background";

            var backgroundTransform = backgroundClone.transform as RectTransform;

            backgroundTransform.anchorMin = new Vector2(0.0f, 0.0f);
            backgroundTransform.anchorMax = new Vector2(0.95f, 1.0f);
            backgroundTransform.offsetMin = new Vector2(0.5f, 0.0f);
            backgroundTransform.offsetMax = new Vector2(5.0f, 0.0f);
            backgroundTransform.sizeDelta = new Vector2(4.50f, 0.0f);

            var cellBackgroundHelper = contentCellPrefab.gameObject.AddComponent <CellBackgroundHelper>();

            cellBackgroundHelper.Cell       = contentCellPrefab;
            cellBackgroundHelper.Background = backgroundClone;
        }