protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            _logger = LogManager.GetCurrentClassLogger();
            _logger.Debug("QueueController Activate.");
            _ui = TwitchIntegrationUi.Instance;

            _songListTableCellInstance = Resources.FindObjectsOfTypeAll <StandardLevelListTableCell>().First(x => (x.name == "SongListTableCell"));
            _queuedSongs = StaticData.QueueList.OfType <QueuedSong>().ToList();
            _top5Queued  = (List <QueuedSong>)_queuedSongs.Take(5);

            if (_titleText == null)
            {
                _titleText           = _ui.CreateText(rectTransform, "REQUEST QUEUE", new Vector2(0f, -6f));
                _titleText.alignment = TextAlignmentOptions.Top;
                _titleText.fontSize  = 8;
            }

            if (_queuedSongsTableView == null)
            {
                _queuedSongsTableView = new GameObject().AddComponent <TableView>();

                _queuedSongsTableView.transform.SetParent(rectTransform, false);

                _queuedSongsTableView.dataSource = this;

                ((RectTransform)_queuedSongsTableView.transform).anchorMin        = new Vector2(0.3f, 0.5f);
                ((RectTransform)_queuedSongsTableView.transform).anchorMax        = new Vector2(0.7f, 0.5f);
                ((RectTransform)_queuedSongsTableView.transform).sizeDelta        = new Vector2(0f, 60f);
                ((RectTransform)_queuedSongsTableView.transform).anchoredPosition = new Vector3(0f, -3f);

                _queuedSongsTableView.didSelectRowEvent += _queuedSongsTableView_DidSelectRowEvent;
            }
        }
Ejemplo n.º 2
0
        public TableCell CellForRow(int row)
        {
            StandardLevelListTableCell cell = Instantiate(_songListTableCellInstance);

            cell.author     = songs[row].songAuthorName;
            cell.coverImage = songs[row].coverImage;
            cell.songName   = $"{songs[row].songName}\n<size=80%>{songs[row].songSubName}</size>";

            return(cell);
        }
        public TableCell CellForRow(int row)
        {
            StandardLevelListTableCell cell = Instantiate(_serverTableCellInstance);

            Destroy(cell.GetComponentsInChildren <UnityEngine.UI.Image>().First(x => x.name.ToLower().Contains("cover")));
            cell.songName = ((availableServers[row].MaxPlayers == 0) ? $"({availableServers[row].Players}/INF) " : $"({availableServers[row].Players}/{availableServers[row].MaxPlayers}) ") + availableServers[row].Name;
            cell.author   = $"{availableServers[row].IPv4}:{availableServers[row].Port}";

            return(cell);
        }
Ejemplo n.º 4
0
        public TableCell CellForRow(int row)
        {
            StandardLevelListTableCell _tableCell = Instantiate(_songListTableCellInstance);

            CustomPlatform platform = PlatformLoader.Instance.GetPlatform(row);

            _tableCell.songName   = platform.platName;
            _tableCell.author     = platform.platAuthor;
            _tableCell.coverImage = platform.icon;

            return(_tableCell);
        }
Ejemplo n.º 5
0
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            if (_pageUpButton == null)
            {
                _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageUpButton")), rectTransform, false);
                (_pageUpButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 1f);
                (_pageUpButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 1f);
                (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -14f);
                _pageUpButton.interactable = true;
                _pageUpButton.onClick.AddListener(delegate()
                {
                    _songsTableView.PageScrollUp();
                });
            }

            if (_pageDownButton == null)
            {
                _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageDownButton")), rectTransform, false);
                (_pageDownButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0f);
                (_pageDownButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0f);
                (_pageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 8f);
                _pageDownButton.interactable = true;
                _pageDownButton.onClick.AddListener(delegate()
                {
                    _songsTableView.PageScrollDown();
                });
            }

            _songListTableCellInstance = Resources.FindObjectsOfTypeAll <StandardLevelListTableCell>().First(x => (x.name == "StandardLevelListTableCell"));

            if (_songsTableView == null)
            {
                _songsTableView = new GameObject().AddComponent <TableView>();

                _songsTableView.transform.SetParent(rectTransform, false);

                Mask viewportMask = Instantiate(Resources.FindObjectsOfTypeAll <Mask>().First(), _songsTableView.transform, false);
                viewportMask.transform.DetachChildren();

                _songsTableView.GetComponentsInChildren <RectTransform>().First(x => x.name == "Content").transform.SetParent(viewportMask.rectTransform, false);

                (_songsTableView.transform as RectTransform).anchorMin        = new Vector2(0f, 0.5f);
                (_songsTableView.transform as RectTransform).anchorMax        = new Vector2(1f, 0.5f);
                (_songsTableView.transform as RectTransform).sizeDelta        = new Vector2(0f, 60f);
                (_songsTableView.transform as RectTransform).position         = new Vector3(0f, 0f, 2.4f);
                (_songsTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, -3f);

                ReflectionUtil.SetPrivateField(_songsTableView, "_pageUpButton", _pageUpButton);
                ReflectionUtil.SetPrivateField(_songsTableView, "_pageDownButton", _pageDownButton);

                _songsTableView.didSelectRowEvent += _songsTableView_DidSelectRowEvent;
            }
        }
Ejemplo n.º 6
0
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            ui = PlatformUI._instance;
            _parentMasterViewController = transform.parent.GetComponent <PlatformMasterViewController>();

            try
            {
                _songListTableCellInstance = Resources.FindObjectsOfTypeAll <StandardLevelListTableCell>().First(x => (x.name == "StandardLevelListTableCell"));

                if (_platformsTableView == null)
                {
                    _platformsTableView = new GameObject().AddComponent <TableView>();

                    _platformsTableView.transform.SetParent(rectTransform, false);

                    _platformsTableView.dataSource = this;

                    (_platformsTableView.transform as RectTransform).anchorMin        = new Vector2(0f, 0.5f);
                    (_platformsTableView.transform as RectTransform).anchorMax        = new Vector2(1f, 0.5f);
                    (_platformsTableView.transform as RectTransform).sizeDelta        = new Vector2(0f, 60f);
                    (_platformsTableView.transform as RectTransform).position         = new Vector3(0f, 0f, 2.4f);
                    (_platformsTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, 0f); // -3

                    _platformsTableView.didSelectRowEvent += _PlatformTableView_DidSelectRowEvent;
                }
                else
                {
                    _platformsTableView.ReloadData();
                }

                if (_pageUpButton == null)
                {
                    _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageUpButton")), rectTransform, false);
                    (_pageUpButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 1f);
                    (_pageUpButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 1f);
                    (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -10f);//-14
                    _pageUpButton.interactable = true;
                    _pageUpButton.onClick.AddListener(delegate()
                    {
                        _platformsTableView.PageScrollUp();
                    });
                }

                if (_pageDownButton == null)
                {
                    _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageDownButton")), rectTransform, false);
                    (_pageDownButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0f);
                    (_pageDownButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0f);
                    (_pageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 10);//8
                    _pageDownButton.interactable = true;
                    _pageDownButton.onClick.AddListener(delegate()
                    {
                        _platformsTableView.PageScrollDown();
                    });
                }

                if (_versionNumber == null)
                {
                    _versionNumber = Instantiate(Resources.FindObjectsOfTypeAll <TextMeshProUGUI>().First(x => (x.name == "BuildInfoText")), rectTransform, false);
                    DestroyImmediate(_versionNumber.GetComponent <BuildInfoText>());

                    (_versionNumber.transform as RectTransform).anchoredPosition = new Vector2(44f, 2f);

                    string versionNumber = (IllusionInjector.PluginManager.Plugins.Where(x => x.Name == "Custom Platforms").First()).Version;
                    _versionNumber.text     = versionNumber;
                    _versionNumber.fontSize = 5;
                }

                _platformsTableView.SelectRow(PlatformLoader.Instance.GetPlatformIndex());
                _platformsTableView.ScrollToRow(PlatformLoader.Instance.GetPlatformIndex(), true);
            }
            catch (Exception e)
            {
                Console.WriteLine("EXCEPTION IN DidActivate: " + e);
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            ui = BSMultiplayerUI._instance;
            localPlayerInfo = new PlayerInfo(GetUserInfo.GetUserName(), GetUserInfo.GetUserID());

            if (_songPreviewPlayer == null)
            {
                ObjectProvider[] providers = Resources.FindObjectsOfTypeAll <ObjectProvider>().Where(x => x.name == "SongPreviewPlayerProvider").ToArray();

                if (providers.Length > 0)
                {
                    _songPreviewPlayer = providers[0].GetProvidedObject <SongPreviewPlayer>();
                }
            }

            if (_backButton == null)
            {
                _backButton = ui.CreateBackButton(rectTransform);

                _backButton.onClick.AddListener(delegate()
                {
                    BSMultiplayerClient._instance.DataReceived -= DataReceived;
                    BSMultiplayerClient._instance.DisconnectFromServer();
                    _songPreviewPlayer.CrossfadeToDefault();
                    try
                    {
                        transform.parent.GetComponent <MultiplayerServerHubViewController>().UpdatePage();
                    } catch (Exception e)
                    {
                        Console.WriteLine($"ServerHub exception: {e}");
                    }
                    foreach (AvatarController avatar in _avatars)
                    {
                        Destroy(avatar.gameObject);
                    }
                    DismissModalViewController(null, false);
                });
            }

            if (_timerText == null)
            {
                _timerText           = ui.CreateText(rectTransform, "", new Vector2(0f, -5f));
                _timerText.fontSize  = 8f;
                _timerText.alignment = TextAlignmentOptions.Center;
                _timerText.rectTransform.sizeDelta = new Vector2(30f, 6f);
            }

            if (_selectText == null)
            {
                _selectText           = ui.CreateText(rectTransform, "", new Vector2(0f, -36f));
                _selectText.fontSize  = 7f;
                _selectText.alignment = TextAlignmentOptions.Center;
                _selectText.rectTransform.sizeDelta = new Vector2(120f, 6f);
            }

            if (_loadingIndicator == null)
            {
                try
                {
                    _loadingIndicator = ui.CreateLoadingIndicator(rectTransform);
                    (_loadingIndicator.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0.5f);
                    (_loadingIndicator.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0.5f);
                    (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(0f, 0f);
                    _loadingIndicator.SetActive(true);
                }
                catch (Exception e)
                {
                    Console.WriteLine("EXCEPTION: " + e);
                }
            }

            if (_selectedSongCell == null)
            {
                _selectedSongCell = Instantiate(Resources.FindObjectsOfTypeAll <StandardLevelListTableCell>().First(x => x.name == "StandardLevelListTableCell"), rectTransform, false);

                (_selectedSongCell.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0.5f);
                (_selectedSongCell.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0.5f);
                (_selectedSongCell.transform as RectTransform).anchoredPosition = new Vector2(-25f, 0);

                _selectedSongCell.gameObject.SetActive(false);
            }
            else
            {
                _selectedSongCell.gameObject.SetActive(false);
            }

            if (BSMultiplayerClient._instance.ConnectToServer(selectedServerIP, selectedServerPort))
            {
                BSMultiplayerClient._instance.SendString(JsonUtility.ToJson(new ClientCommand(ClientCommandType.GetAvailableSongs)));
                BSMultiplayerClient._instance.SendString(JsonUtility.ToJson(new ClientCommand(ClientCommandType.GetServerState)));
                StartCoroutine(BSMultiplayerClient._instance.ReceiveFromServerCoroutine());
                BSMultiplayerClient._instance.DataReceived += DataReceived;
            }
            else
            {
                _loading = false;
                TextMeshProUGUI _errorText = ui.CreateText(rectTransform, String.Format("Can't connect to server!"), new Vector2(0f, -48f));
                _errorText.alignment = TextAlignmentOptions.Center;
                Destroy(_errorText.gameObject, 5f);
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            Console.WriteLine("checkpoint 1");
            previewparent = Instantiate(new GameObject("preview parent"));
            previewparent.transform.position = new Vector3(2.5f, 1, 0.3f);
            previewparent.transform.Rotate(new Vector3(0, -30, 0));
            _modMenuUi            = FindObjectOfType <ModMenuUi>();
            _parentViewController = transform.parent.GetComponent <ModMenuMasterViewController>();
            Console.WriteLine("checkpoint 2");
            try
            {
                if (_pageDownButton == null)
                {
                    try
                    {
                        _pageDownButton = _modMenuUi.CreateButton(rectTransform, "PageDownButton");
                        Console.WriteLine("checkpoint 3");
                        ((RectTransform)_pageDownButton.transform).anchorMin        = new Vector2(0.5f, 0f);
                        ((RectTransform)_pageDownButton.transform).anchorMax        = new Vector2(0.5f, 0f);
                        ((RectTransform)_pageDownButton.transform).anchoredPosition = new Vector2(0f, 10f);
                        _pageDownButton.interactable = true;
                        _pageDownButton.onClick.AddListener(delegate()
                        {
                            _modsTableView.PageScrollDown();
                        });
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }
                if (_pageUpButton == null)
                {
                    try
                    {
                        Console.WriteLine("checkpoint 4");
                        _pageUpButton = _modMenuUi.CreateButton(rectTransform, "PageUpButton");
                        ((RectTransform)_pageUpButton.transform).anchorMin        = new Vector2(0.5f, 1f);
                        ((RectTransform)_pageUpButton.transform).anchorMax        = new Vector2(0.5f, 1f);
                        ((RectTransform)_pageUpButton.transform).anchoredPosition = new Vector2(0f, -14f);
                        _pageUpButton.interactable = true;
                        _pageUpButton.onClick.AddListener(delegate()
                        {
                            _modsTableView.PageScrollUp();
                        });
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }


            _songListTableCellInstance = Resources.FindObjectsOfTypeAll <StandardLevelListTableCell>().First(x => (x.name == "StandardLevelListTableCell"));

            LoadMods();

            base.DidActivate(true, ActivationType.AddedToHierarchy);
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            previewparent = Instantiate(new GameObject("preview parent"));
            previewparent.transform.position = new Vector3(2.5f, 1, 0.3f);
            previewparent.transform.Rotate(new Vector3(0, -30, 0));
            _customSaberUI        = CustomSaberUI.Instance;
            _parentViewController = GetComponentInParent <CustomSaberMasterViewController>();
            try
            {
                if (_pageDownButton == null)
                {
                    try
                    {
                        _pageDownButton = _customSaberUI.CreateButton(rectTransform, "PageDownButton");
                        ((RectTransform)_pageDownButton.transform).anchorMin        = new Vector2(0.5f, 0f);
                        ((RectTransform)_pageDownButton.transform).anchorMax        = new Vector2(0.5f, 0f);
                        ((RectTransform)_pageDownButton.transform).anchoredPosition = new Vector2(0f, 10f);
                        _pageDownButton.interactable = true;
                        _pageDownButton.onClick.AddListener(delegate()
                        {
                            _sabersTableView.PageScrollDown();
                        });
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }
                if (_pageUpButton == null)
                {
                    try
                    {
                        _pageUpButton = _customSaberUI.CreateButton(rectTransform, "PageUpButton");
                        ((RectTransform)_pageUpButton.transform).anchorMin        = new Vector2(0.5f, 1f);
                        ((RectTransform)_pageUpButton.transform).anchorMax        = new Vector2(0.5f, 1f);
                        ((RectTransform)_pageUpButton.transform).anchoredPosition = new Vector2(0f, -14f);
                        _pageUpButton.interactable = true;
                        _pageUpButton.onClick.AddListener(delegate()
                        {
                            _sabersTableView.PageScrollUp();
                        });
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }


                if (_sabersTableView == null)
                {
                    _sabersTableView = new GameObject().AddComponent <TableView>();

                    _sabersTableView.transform.SetParent(rectTransform, false);

                    var viewportMask = Instantiate(Resources.FindObjectsOfTypeAll <Mask>().First(), _sabersTableView.transform, false);
                    viewportMask.transform.DetachChildren();
                    _sabersTableView.GetComponentsInChildren <RectTransform>().First(x => x.name == "Content").transform.SetParent(viewportMask.rectTransform, false);

                    ((RectTransform)_sabersTableView.transform).anchorMin        = new Vector2(0f, 0.5f);
                    ((RectTransform)_sabersTableView.transform).anchorMax        = new Vector2(1f, 0.5f);
                    ((RectTransform)_sabersTableView.transform).sizeDelta        = new Vector2(0f, 60f);
                    ((RectTransform)_sabersTableView.transform).anchoredPosition = new Vector2(0f, 0f);

                    _sabersTableView.didSelectRowEvent += _sabersTableView_DidSelectRowEvent;

                    ReflectionUtil.SetPrivateField(_sabersTableView, "_pageUpButton", _pageUpButton);
                    ReflectionUtil.SetPrivateField(_sabersTableView, "_pageDownButton", _pageDownButton);

                    _sabersTableView.dataSource = this;

                    _sabersTableView.ScrollToRow(0, false);
                }
                else
                {
                    _sabersTableView.ReloadData();
                    _sabersTableView.ScrollToRow(0, false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }


            _songListTableCellInstance = Resources.FindObjectsOfTypeAll <StandardLevelListTableCell>().First(x => (x.name == "StandardLevelListTableCell"));

            LoadSabers();

            base.DidActivate(true, ActivationType.AddedToHierarchy);
        }