private void _standardLevelResultsViewController_continueButtonPressedEvent(ResultsViewController sender) { try { TableView _levelListTableView = _levelListViewController.GetComponentInChildren <TableView>(); _levelListTableView.RefreshTable(); }catch (Exception e) { Logger.Warning("Unable to refresh song list! Exception: " + e); } }
private void _standardLevelResultsViewController_continueButtonPressedEvent(ResultsViewController sender) { try { TableView _levelListTableView = _levelListViewController.GetComponentInChildren <TableView>(); HashSet <int> rows = new HashSet <int>(_levelListTableView.GetPrivateField <HashSet <int> >("_selectedRows")); float scrollPosition = _levelListTableView.GetPrivateField <ScrollRect>("_scrollRect").verticalNormalizedPosition; _levelListTableView.ReloadData(); _levelListTableView.GetPrivateField <ScrollRect>("_scrollRect").verticalNormalizedPosition = scrollPosition; _levelListTableView.SetPrivateField("_targetVerticalNormalizedPosition", scrollPosition); if (rows.Count > 0) { _levelListTableView.SelectRow(rows.First(), true); } }catch (Exception e) { Logger.Warning("Unable to refresh song list! Exception: " + e); } }
public bool DeleteSong(Song song) { bool zippedSong = false; string path = ""; CustomLevel level = SongLoader.CustomLevels.FirstOrDefault(x => x.levelID.StartsWith(song.hash)); if (string.IsNullOrEmpty(song.path)) { if (level != null) { path = level.customSongInfo.path; } } else { path = song.path; } if (string.IsNullOrEmpty(path)) { return(false); } if (!Directory.Exists(path)) { return(false); } if (path.Contains("/.cache/")) { zippedSong = true; } if (zippedSong) { Logger.Log("Deleting \"" + path.Substring(path.LastIndexOf('/')) + "\"..."); if (PluginConfig.deleteToRecycleBin) { FileOperationAPIWrapper.MoveToRecycleBin(path); } else { Directory.Delete(path, true); } string songHash = Directory.GetParent(path).Name; try { if (Directory.GetFileSystemEntries(path.Substring(0, path.LastIndexOf('/'))).Length == 0) { Logger.Log("Deleting empty folder \"" + path.Substring(0, path.LastIndexOf('/')) + "\"..."); Directory.Delete(path.Substring(0, path.LastIndexOf('/')), false); } } catch { Logger.Warning("Can't find or delete empty folder!"); } string docPath = Application.dataPath; docPath = docPath.Substring(0, docPath.Length - 5); docPath = docPath.Substring(0, docPath.LastIndexOf("/")); string customSongsPath = docPath + "/CustomSongs/"; string hash = ""; foreach (string file in Directory.GetFiles(customSongsPath, "*.zip")) { if (CreateMD5FromFile(file, out hash)) { if (hash == songHash) { File.Delete(file); break; } } } } else { Logger.Log("Deleting \"" + path.Substring(path.LastIndexOf('/')) + "\"..."); if (PluginConfig.deleteToRecycleBin) { FileOperationAPIWrapper.MoveToRecycleBin(path); } else { Directory.Delete(path, true); } try { if (Directory.GetFileSystemEntries(path.Substring(0, path.LastIndexOf('/'))).Length == 0) { Logger.Log("Deleting empty folder \"" + path.Substring(0, path.LastIndexOf('/')) + "\"..."); Directory.Delete(path.Substring(0, path.LastIndexOf('/')), false); } } catch { Logger.Warning("Unable to delete empty folder!"); } } if (level != null) { SongLoader.Instance.RemoveSongWithLevelID(level.levelID); } Logger.Log($"{_alreadyDownloadedSongs.RemoveAll(x => x.Compare(song))} song removed"); return(true); }