/// <summary> /// Adds any new files that are currently not cached. /// Used if the user adds a file to the folder. /// </summary> /// <param name="files"></param> private static void AddNonCachedFiles(List <string> files) { var maps = FetchAll(); foreach (var file in files) { if (maps.Any(x => BackslashToForward(file) == BackslashToForward($"{GlobalConfig.Load().SongDirectory}/{x.Directory}/{x.Path}"))) { continue; } // Found map that isn't cached in the database yet. try { var map = Map.FromChart(ChartFile.Parse(file, false), file); map.CalculateDifficulties(); InsertMap(map, file); } catch (Exception e) { Logger.Log(e); } } }
/// <summary> /// </summary> public static void ForceUpdateMaps() { for (var i = 0; i < MapsToUpdate.Count; i++) { try { var path = $"{GlobalConfig.Load().SongDirectory}/{MapsToUpdate[i].Directory}/{MapsToUpdate[i].Path}"; if (!File.Exists(path)) { continue; } var map = Map.FromChart(ChartFile.Parse(path, false), path); map.CalculateDifficulties(); map.Id = MapsToUpdate[i].Id; if (map.Id == 0) { map.Id = InsertMap(map, path); } else { UpdateMap(map); } MapsToUpdate[i] = map; MapManager.Selected.Value = map; } catch (Exception e) { Logger.Log(e); } } MapsToUpdate.Clear(); OrderAndSetMapsets(); var selectedMapset = MapManager.Mapsets.Find(x => x.Maps.Any(y => y.Id == MapManager.Selected.Value.Id)); MapManager.Selected.Value = selectedMapset.Maps.Find(x => x.Id == MapManager.Selected.Value.Id); }
/// <summary> /// Loads the .chart, .osu or .sm file for a map. /// /// </summary> /// <returns></returns> /// <exception cref="ArgumentException"></exception> public ChartFile LoadChart(bool checkValidity = true) { // Reference to the parsed .chart file ChartFile chart; // Handle osu! maps as well switch (Game) { case MapGame.DrumSmasher: var chartPath = $"{GlobalConfig.Load().SongDirectory}/{Directory}/{Path}"; chart = ChartFile.Parse(chartPath, checkValidity); break; case MapGame.Osu: chart = null; //TODO: Load osu chart file break; default: throw new InvalidEnumArgumentException(); } return(chart); }