Exemplo n.º 1
0
        public static void Postfix(MultiplayerModeSelectionViewController __instance, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
        {
            // Enable the "game browser" button (it was left in the game but unused currently)
            var btnGameBrowser = ReflectionUtil.GetField <Button, MultiplayerModeSelectionViewController>(__instance, "_gameBrowserButton");

            btnGameBrowser.enabled = true;
            btnGameBrowser.gameObject.SetActive(true);

            foreach (var comp in btnGameBrowser.GetComponents <Component>())
            {
                comp.gameObject.SetActive(true);
            }

            if (firstActivation)
            {
                // Reposition and enlarge the button a bit
                var transform = btnGameBrowser.gameObject.transform;
                transform.position = new Vector3(
                    transform.position.x,
                    transform.position.y + 0.25f,
                    transform.position.z
                    );
                transform.localScale = new Vector3(1.25f, 1.25f, 1.25f);
                btnGameBrowser.GetComponentInChildren <CurvedTextMeshPro>()
                .SetText("Server Browser");
            }
        }
        private static void AddServerSelection(MultiplayerModeSelectionViewController __instance)
        {
            var servers         = Plugin.ServerDetailProvider.Servers;
            var serverSelection = UIFactory.CreateServerSelectionView(__instance);

            serverSelection.values = servers.ToList <object>();
            serverSelection.Value  = Plugin.ServerDetailProvider.Selection;
        }
        public void Init(ListSetting listSetting, MultiplayerModeSelectionViewController multiplayerView)
        {
            _multiplayerView = multiplayerView;
            var changed = new BSMLAction(this, typeof(ServerSelectionController).GetMethod("OnServerChanged"));

            listSetting.onChange = changed;
            UpdateUI(multiplayerView, Plugin.ServerDetailProvider.Selection);
            GameEventDispatcher.Instance.MultiplayerViewEntered += OnMultiplayerViewEntered;
        }
        internal static void Postfix(MultiplayerModeSelectionViewController __instance, bool firstActivation)
        {
            GameEventDispatcher.Instance.OnMultiplayerViewEntered(__instance);

            if (firstActivation)
            {
                GameClassInstanceProvider.Instance.MultiplayerModeSelectionViewController = __instance;
                AddServerSelection(__instance);
            }
        }
        private void UpdateUI(MultiplayerModeSelectionViewController multiplayerView, ServerDetails details)
        {
            var transform       = _multiplayerView.transform;
            var quickPlayButton = transform.Find("Buttons/QuickPlayButton").gameObject;

            quickPlayButton.SetActive(details.IsOfficial);

            var status = Plugin.StatusProvider.GetServerStatus(details.ServerName);

            multiplayerView.SetData(status);

            var textMesh = GetMaintenanceMessageText();

            if (textMesh.gameObject.activeSelf)
            {
                textMesh.richText = false;
                return;
            }

            textMesh.richText = true;
            if (status == null)
            {
                textMesh.SetText("Status: <color=\"yellow\">UNKNOWN");
                textMesh.gameObject.SetActive(true);
                return;
            }

            switch (status.status)
            {
            case MasterServerAvailabilityData.AvailabilityStatus.Offline:
                textMesh.SetText("Status: <color=\"red\">OFFLINE");
                break;

            case MasterServerAvailabilityData.AvailabilityStatus.MaintenanceUpcoming:
                textMesh.SetText("Status: <color=\"yellow\">MAINTENANCE UPCOMING");
                break;

            case MasterServerAvailabilityData.AvailabilityStatus.Online:
                textMesh.SetText("Status: <color=\"green\">ONLINE");
                break;
            }
            textMesh.gameObject.SetActive(true);
        }
Exemplo n.º 6
0
        internal static ListSetting CreateServerSelectionView(MultiplayerModeSelectionViewController multiplayerView)
        {
            Plugin.Logger.Info("Applying interface for server selection.");
            var parent = multiplayerView.gameObject.transform;
            FormattedFloatListSettingsValueController baseSetting = MonoBehaviour.Instantiate(Resources.FindObjectsOfTypeAll <FormattedFloatListSettingsValueController>().First(x => (x.name == "VRRenderingScale")), parent, false);

            baseSetting.name = "BSMLIncDecSetting";

            GameObject gameObject = baseSetting.gameObject;

            MonoBehaviour.Destroy(baseSetting);
            gameObject.SetActive(false);

            ListSetting serverSelection = gameObject.AddComponent <ListSetting>();

            gameObject.transform.position             += new Vector3(0.0f, 0.15f, 0.0f);
            gameObject.transform.GetChild(1).position += new Vector3(-1.0f, 0.0f, 0.0f);

            serverSelection.text          = gameObject.transform.GetChild(1).GetComponentsInChildren <TextMeshProUGUI>().First();
            serverSelection.text.richText = true;
            serverSelection.decButton     = gameObject.transform.GetChild(1).GetComponentsInChildren <Button>().First();
            serverSelection.incButton     = gameObject.transform.GetChild(1).GetComponentsInChildren <Button>().Last();
            (gameObject.transform.GetChild(1) as RectTransform).sizeDelta = new Vector2(60, 0);
            serverSelection.text.overflowMode = TextOverflowModes.Ellipsis;

            var controller = multiplayerView.gameObject.AddComponent <ServerSelectionController>();

            controller.Init(serverSelection, multiplayerView);

            TextMeshProUGUI text = gameObject.GetComponentInChildren <TextMeshProUGUI>();

            text.transform.position += new Vector3(1.2f, 0.0f, 0.0f);
            text.SetText("Playing on");
            text.richText = true;

            gameObject.GetComponent <LayoutElement>().preferredWidth = 90;
            gameObject.SetActive(true);

            // Initial Update for the SongPacks
            Patches.QuickPlaySongPacksDropdownPatch.UpdateSongPacks();
            return(serverSelection);
        }
 public static void Postfix(MultiplayerModeSelectionViewController __instance, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
 {
     //Set up multiplayer session manager
     EventMute.SetupMP();
 }
        private void OnMultiplayerViewEntered(object sender, MultiplayerModeSelectionViewController multiplayerView)
        {
            var selection = Plugin.ServerDetailProvider.Selection;

            UpdateUI(multiplayerView, selection);
        }
Exemplo n.º 9
0
 internal void OnMultiplayerViewEntered(MultiplayerModeSelectionViewController instance) =>
 MultiplayerViewEntered?.Invoke(this, instance);
        public static bool Prefix(MultiplayerModeSelectionFlowCoordinator __instance, MultiplayerModeSelectionViewController viewController, MultiplayerModeSelectionViewController.MenuButton menuButton)
        {
            // Make sure any overrides are cleared when we're going to connect or host
            MpConnect.ClearMasterServerOverride();

            if (menuButton == MenuButton.GameBrowser)
            {
                // When the "GameBrowser" button is clicked, bypass the game's own incomplete code & open our view instead
                PluginUi.LaunchServerBrowser();
                return(false);
            }
            else
            {
                // Going to a non-serverbrowser part of the online menu
                MpModeSelection.WeInitiatedConnection = false;
            }

            return(true);
        }