public static SeperateSongFolder AddSeperateSongFolder(string name, string folderPath, FolderLevelPack pack, Sprite?image = null, bool wip = false, bool cachezips = false) { UI.BasicUI.GetIcons(); if (!Directory.Exists(folderPath)) { try { Directory.CreateDirectory(folderPath); } catch (Exception ex) { Logging.Logger.Error($"Failed to make folder for: {name}"); Logging.Logger.Error(ex); } } var entry = new SongFolderEntry(name, folderPath, pack, "", wip, cachezips); var seperateSongFolder = new ModSeperateSongFolder(entry, image == null ? UI.BasicUI.FolderIcon ! : image); Loader.SeperateSongFolders.Add(seperateSongFolder); return(seperateSongFolder); }
//SongFolderEntry(string name, string path, FolderLevelPack pack, string imagePath = "", bool wip = false) public static SeperateSongFolder AddSeperateSongFolder(string name, string folderPath, FolderLevelPack pack, Sprite image = null, bool wip = false) { UI.BasicUI.GetIcons(); if (!Directory.Exists(folderPath)) { try { Directory.CreateDirectory(folderPath); } catch (Exception ex) { Logging.logger.Error("Failed to make folder for: " + name + "\n" + ex); } } Data.SongFolderEntry entry = new SongFolderEntry(name, folderPath, pack, "", wip); ModSeperateSongFolder seperateSongFolder = new ModSeperateSongFolder(entry, image == null ? UI.BasicUI.FolderIcon : image); if (Loader.SeperateSongFolders == null) { Loader.SeperateSongFolders = new List <SeperateSongFolder>(); } Loader.SeperateSongFolders.Add(seperateSongFolder); return(seperateSongFolder); }
// Taken from SongCore public static CustomPreviewBeatmapLevel LoadSong(StandardLevelInfoSaveData saveData, string songPath, out string hash, SongFolderEntry folderEntry = null) { CustomPreviewBeatmapLevel result; bool wip = false; if (songPath.Contains("CustomWIPLevels")) { wip = true; } if (folderEntry != null) { if (folderEntry.Pack == FolderLevelPack.CustomWIPLevels) { wip = true; } else if (folderEntry.WIP) { wip = true; } } hash = Hashing.GetCustomLevelHash(saveData, songPath); try { string folderName = new DirectoryInfo(songPath).Name; string levelID = CustomLevelLoader.kCustomLevelPrefixId + hash; if (wip) { levelID += " WIP"; } if (SongCore.Collections.hashForLevelID(levelID) != "") { levelID += "_" + folderName; } string songName = saveData.songName; string songSubName = saveData.songSubName; string songAuthorName = saveData.songAuthorName; string levelAuthorName = saveData.levelAuthorName; float beatsPerMinute = saveData.beatsPerMinute; float songTimeOffset = saveData.songTimeOffset; float shuffle = saveData.shuffle; float shufflePeriod = saveData.shufflePeriod; float previewStartTime = saveData.previewStartTime; float previewDuration = saveData.previewDuration; EnvironmentInfoSO environmentSceneInfo = _customLevelLoader.LoadEnvironmentInfo(saveData.environmentName, false); EnvironmentInfoSO allDirectionEnvironmentInfo = _customLevelLoader.LoadEnvironmentInfo(saveData.allDirectionsEnvironmentName, true); List <PreviewDifficultyBeatmapSet> list = new List <PreviewDifficultyBeatmapSet>(); foreach (StandardLevelInfoSaveData.DifficultyBeatmapSet difficultyBeatmapSet in saveData.difficultyBeatmapSets) { BeatmapCharacteristicSO beatmapCharacteristicBySerializedName = beatmapCharacteristicCollection.GetBeatmapCharacteristicBySerializedName(difficultyBeatmapSet.beatmapCharacteristicName); BeatmapDifficulty[] array = new BeatmapDifficulty[difficultyBeatmapSet.difficultyBeatmaps.Length]; for (int j = 0; j < difficultyBeatmapSet.difficultyBeatmaps.Length; j++) { BeatmapDifficulty beatmapDifficulty; difficultyBeatmapSet.difficultyBeatmaps[j].difficulty.BeatmapDifficultyFromSerializedName(out beatmapDifficulty); array[j] = beatmapDifficulty; } list.Add(new PreviewDifficultyBeatmapSet(beatmapCharacteristicBySerializedName, array)); } result = new CustomPreviewBeatmapLevel(defaultCoverImage.texture, saveData, songPath, cachedMediaAsyncLoaderSO, cachedMediaAsyncLoaderSO, levelID, songName, songSubName, songAuthorName, levelAuthorName, beatsPerMinute, songTimeOffset, shuffle, shufflePeriod, previewStartTime, previewDuration, environmentSceneInfo, allDirectionEnvironmentInfo, list.ToArray()); } catch { Plugin.log.Error("Failed to Load Song: " + songPath); result = null; } return(result); }