public bool Compare(Song compareTo) { if (compareTo != null) { //Logger.StaticLog("songName is " + string.IsNullOrEmpty(compareTo.songName)); //Logger.StaticLog("songSubName is " + string.IsNullOrEmpty(compareTo.songSubName)); //Logger.StaticLog("authorName is " + string.IsNullOrEmpty(compareTo.authorName)); //Logger.StaticLog("authorName is " + string.IsNullOrEmpty(compareTo.authorName)); if (HTML5Decode.HtmlDecode(songName) == HTML5Decode.HtmlDecode(compareTo.songName)) { if (difficultyLevels != null && compareTo.difficultyLevels != null) { return(HTML5Decode.HtmlDecode(songSubName) == HTML5Decode.HtmlDecode(compareTo.songSubName) && HTML5Decode.HtmlDecode(authorName) == HTML5Decode.HtmlDecode(compareTo.authorName) && difficultyLevels.Length == compareTo.difficultyLevels.Length); } else { return(HTML5Decode.HtmlDecode(songSubName) == HTML5Decode.HtmlDecode(compareTo.songSubName) && HTML5Decode.HtmlDecode(authorName) == HTML5Decode.HtmlDecode(compareTo.authorName)); } } else { return(false); } } else { return(false); } }
public bool Compare(Song compareTo) { if (compareTo != null) { /* * Console.WriteLine("songName = " + HTML5Decode.HtmlDecode(compareTo.songName) + " vs " + HTML5Decode.HtmlDecode(songName)+" is "+ (HTML5Decode.HtmlDecode(songName) == HTML5Decode.HtmlDecode(compareTo.songName))); * Console.WriteLine("songSubName = " + HTML5Decode.HtmlDecode(compareTo.songSubName) + " vs " + HTML5Decode.HtmlDecode(songSubName) + " is " + (HTML5Decode.HtmlDecode(songSubName) == HTML5Decode.HtmlDecode(compareTo.songSubName))); * Console.WriteLine("authorName = " + HTML5Decode.HtmlDecode(compareTo.authorName) + " vs " + HTML5Decode.HtmlDecode(authorName) + " is " + (HTML5Decode.HtmlDecode(authorName) == HTML5Decode.HtmlDecode(compareTo.authorName))); * Console.WriteLine("diffs = " + compareTo.difficultyLevels.Length + " vs " + difficultyLevels.Length + " is " + (difficultyLevels.Length == compareTo.difficultyLevels.Length)); */ if (HTML5Decode.HtmlDecode(songName) == HTML5Decode.HtmlDecode(compareTo.songName)) { if (difficultyLevels != null && compareTo.difficultyLevels != null) { return(HTML5Decode.HtmlDecode(songSubName) == HTML5Decode.HtmlDecode(compareTo.songSubName) && HTML5Decode.HtmlDecode(authorName) == HTML5Decode.HtmlDecode(compareTo.authorName) && difficultyLevels.Length == compareTo.difficultyLevels.Length); } else { return(HTML5Decode.HtmlDecode(songSubName) == HTML5Decode.HtmlDecode(compareTo.songSubName) && HTML5Decode.HtmlDecode(authorName) == HTML5Decode.HtmlDecode(compareTo.authorName)); } } else { return(false); } } else { return(false); } }
public bool Compare(Song compareTo) { bool diffisIdentical = true; if (difficultyLevels.Length != compareTo.difficultyLevels.Length) { diffisIdentical = false; } else { for (int i = 0; i < difficultyLevels.Length; i++) { diffisIdentical = diffisIdentical && difficultyLevels[i].Compare(compareTo.difficultyLevels[i]); } } return(HTML5Decode.HtmlDecode(songName) == HTML5Decode.HtmlDecode(compareTo.songName) && HTML5Decode.HtmlDecode(songSubName) == HTML5Decode.HtmlDecode(compareTo.songSubName) && HTML5Decode.HtmlDecode(authorName) == HTML5Decode.HtmlDecode(compareTo.authorName) && diffisIdentical); }
public TableCell CellForRow(int row) { SongListTableCell _tableCell = Instantiate(_songListTableCellInstance); _tableCell.songName = string.Format("{0}\n<size=80%>{1}</size>", HTML5Decode.HtmlDecode(_parentMasterViewController._songs[row].songName), HTML5Decode.HtmlDecode(_parentMasterViewController._songs[row].songSubName)); _tableCell.author = HTML5Decode.HtmlDecode(_parentMasterViewController._songs[row].authorName); StartCoroutine(_parentMasterViewController.LoadSprite("https://beatsaver.com/img/" + _parentMasterViewController._songs[row].id + "." + _parentMasterViewController._songs[row].img, _tableCell)); bool alreadyDownloaded = _parentMasterViewController.IsSongAlreadyDownloaded(_parentMasterViewController._songs[row]); if (alreadyDownloaded) { foreach (UnityEngine.UI.Image img in _tableCell.GetComponentsInChildren <UnityEngine.UI.Image>()) { img.color = new Color(1f, 1f, 1f, 0.2f); } foreach (TextMeshProUGUI text in _tableCell.GetComponentsInChildren <TextMeshProUGUI>()) { text.faceColor = new Color32(255, 255, 255, 50); } } return(_tableCell); }
private void RefreshDetails(int row) { if (_songs.Count <= row) { return; } RectTransform _levelDetails = _songDetailViewController.GetComponentsInChildren <RectTransform>().First(x => x.name == "LevelDetails"); _levelDetails.sizeDelta = new Vector2(44f, 20f); RectTransform _yourStats = _songDetailViewController.GetComponentsInChildren <RectTransform>().First(x => x.name == "YourStats"); _yourStats.sizeDelta = new Vector2(44f, 18f); TextMeshProUGUI[] _textComponents = _songDetailViewController.GetComponentsInChildren <TextMeshProUGUI>(); try { _textComponents.First(x => x.name == "SongNameText").text = string.Format("{0}\n<size=80%>{1}</size>", HTML5Decode.HtmlDecode(_songs[row].songName), HTML5Decode.HtmlDecode(_songs[row].songSubName)); _textComponents.First(x => x.name == "DurationValueText").text = HTML5Decode.HtmlDecode(_songs[row].downloads); _textComponents.First(x => x.name == "DurationText").text = "Downloads"; _textComponents.First(x => x.name == "BPMText").text = "Plays"; _textComponents.First(x => x.name == "BPMValueText").text = HTML5Decode.HtmlDecode(_songs[row].plays); _textComponents.First(x => x.name == "NotesCountText").text = "Author"; _textComponents.First(x => x.name == "NotesCountValueText").text = HTML5Decode.HtmlDecode(_songs[row].authorName); _textComponents.First(x => x.name == "NotesCountValueText").rectTransform.sizeDelta = new Vector2(16f, 3f); _textComponents.First(x => x.name == "NotesCountValueText").alignment = TextAlignmentOptions.CaplineRight; _textComponents.First(x => x.name == "Title").text = "Difficulties"; _textComponents.First(x => x.name == "HighScoreText").text = "Expert"; _textComponents.First(x => x.name == "HighScoreValueText").text = (_songs[row].difficultyLevels.Where(x => x.difficulty == "Expert").Count() > 0) ? "Yes" : "No"; _textComponents.First(x => x.name == "MaxComboText").text = "Hard"; _textComponents.First(x => x.name == "MaxComboValueText").text = (_songs[row].difficultyLevels.Where(x => x.difficulty == "Hard").Count() > 0) ? "Yes" : "No"; _textComponents.First(x => x.name == "MaxRankText").text = "Easy/Normal"; _textComponents.First(x => x.name == "MaxRankText").rectTransform.sizeDelta = new Vector2(18f, 3f); _textComponents.First(x => x.name == "MaxRankValueText").text = (_songs[row].difficultyLevels.Where(x => (x.difficulty == "Easy" || x.difficulty == "Normal")).Count() > 0) ? "Yes" : "No"; if (_textComponents.Where(x => x.name == "ObstaclesCountText").Count() != 0) { Destroy(_textComponents.First(x => x.name == "ObstaclesCountText").gameObject); Destroy(_textComponents.First(x => x.name == "ObstaclesCountValueText").gameObject); } }catch (Exception e) { log.Exception("EXCEPTION: " + e); } if (_downloadButton == null) { _downloadButton = _songDetailViewController.GetComponentInChildren <Button>(); (_downloadButton.transform as RectTransform).sizeDelta = new Vector2(30f, 10f); (_downloadButton.transform as RectTransform).anchoredPosition = new Vector2(2f, 6f); } _downloadButton.onClick.RemoveAllListeners(); _downloadButton.onClick.AddListener(delegate() { if (!_loading) { DownloadSong(row); } }); if (IsSongAlreadyDownloaded(_songs[row])) { ui.SetButtonText(ref _downloadButton, "Redownload"); } else { ui.SetButtonText(ref _downloadButton, "Download"); } }
IEnumerator DownloadSongByLevelId(string levelId) { Console.WriteLine("Donwloading " + levelId.Substring(0, levelId.IndexOf('∎'))); _selectText.text = "Connecting to BeatSaver.com..."; UnityWebRequest wwwId = UnityWebRequest.Get("https://beatsaver.com/api.php?mode=hashinfo&hash=" + levelId.Substring(0, levelId.IndexOf('∎'))); wwwId.timeout = 10; yield return(wwwId.SendWebRequest()); if (wwwId.isNetworkError || wwwId.isHttpError) { Console.WriteLine(wwwId.error); _selectText.text = ""; TextMeshProUGUI _errorText = ui.CreateText(rectTransform, String.Format(wwwId.error), new Vector2(0f, -48f)); _errorText.alignment = TextAlignmentOptions.Center; Destroy(_errorText.gameObject, 2f); } else { string parse = wwwId.downloadHandler.text; JSONNode node = JSON.Parse(parse); Song _tempSong = new Song(node[0]); UnityWebRequest wwwDl = UnityWebRequest.Get("https://beatsaver.com/dl.php?id=" + (_tempSong.id)); wwwDl.timeout = 10; _selectText.text = "Downloading " + HTML5Decode.HtmlDecode(_tempSong.beatname) + "..."; yield return(wwwDl.SendWebRequest()); if (wwwId.isNetworkError || wwwId.isHttpError) { Console.WriteLine(wwwId.error); TextMeshProUGUI _errorText = ui.CreateText(rectTransform, String.Format(wwwId.error), new Vector2(0f, -48f)); _errorText.alignment = TextAlignmentOptions.Center; Destroy(_errorText.gameObject, 2f); } else { string zipPath = ""; string docPath = ""; string customSongsPath = ""; try { byte[] data = wwwDl.downloadHandler.data; docPath = Application.dataPath; docPath = docPath.Substring(0, docPath.Length - 5); docPath = docPath.Substring(0, docPath.LastIndexOf("/")); customSongsPath = docPath + "/CustomSongs/"; zipPath = customSongsPath + _tempSong.beatname + ".zip"; File.WriteAllBytes(zipPath, data); Console.WriteLine("Downloaded zip file!"); FastZip zip = new FastZip(); Console.WriteLine("Extracting..."); zip.ExtractZip(zipPath, customSongsPath, null); File.Delete(zipPath); } catch (Exception e) { Console.WriteLine("EXCEPTION: " + e); yield break; } } } }