private void _songsTableView_DidSelectRowEvent(TableView sender, int row) { if (!_loading) { _selectedRow = row; _downloadButton.gameObject.SetActive(true); if (IsSongAlreadyDownloaded(_songs[row])) { ui.SetButtonText(ref _downloadButton, "Redownload"); } else { ui.SetButtonText(ref _downloadButton, "Download"); } } else { if (_selectedRow != -1) { _songsTableView.SelectRow(_selectedRow); } } }
protected override void DidActivate() { Debug.Log("Activated!"); ui = FindObjectOfType <CustomUI>(); _songLoader = FindObjectOfType <SongLoader>(); UpdateAlreadyDownloadedSongs(); try { _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().Where(x => (x.name == "PageUpButton")).First(), 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); _pageUpButton.interactable = true; _pageUpButton.onClick.AddListener(delegate() { if (_currentPage > 0) { if (!_loading) { _loading = true; _loadingText.text = "Loading..."; _selectedRow = -1; _downloadButton.gameObject.SetActive(false); StartCoroutine(GetSongs(_currentPage - 1)); } } }); _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().Where(x => (x.name == "PageDownButton")).First(), 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, 10f); _pageDownButton.interactable = true; _pageDownButton.onClick.AddListener(delegate() { if (!_loading) { _loading = true; _loadingText.text = "Loading..."; _selectedRow = -1; _downloadButton.gameObject.SetActive(false); StartCoroutine(GetSongs(_currentPage + 1)); } }); _songListTableCellInstance = Resources.FindObjectsOfTypeAll <SongListTableCell>().Where(x => (x.name == "SongListTableCell")).First(); } catch (Exception e) { Debug.Log("EXCEPTION IN DidActivate: " + e); } Button _backButton = ui.CreateBackButton(rectTransform); _backButton.onClick.AddListener(delegate() { try { _songLoader.RefreshSongs(); }catch (Exception e) { Debug.Log("Can't refresh songs!"); } DismissModalViewController(null, false); }); _downloadButton = ui.CreateUIButton(rectTransform); (_downloadButton.transform as RectTransform).anchorMin = new Vector2(0.5f, 1f); (_downloadButton.transform as RectTransform).anchorMax = new Vector2(0.5f, 1f); (_downloadButton.transform as RectTransform).anchoredPosition = new Vector2(-66f, -50f); (_downloadButton.transform as RectTransform).sizeDelta = new Vector2(32f, 10f); ui.SetButtonText(ref _downloadButton, "Download"); ui.SetButtonIcon(ref _downloadButton, CustomUI.icons.Where(x => x.name == "PlayIcon").First()); _downloadButton.onClick.AddListener(delegate() { if (_selectedRow != -1 && !_loading) { DownloadSong(_selectedRow); } }); _downloadButton.gameObject.SetActive(false); _loadingText = ui.CreateText(rectTransform, "Loading songs from BeatSaver...", new Vector2(-34f, -32f)); StartCoroutine(GetSongs(0)); base.DidActivate(); }