public override void LoadNestedItems(object[] objectsToLoad = null) { CustomFolderInfo parent = null; AddFolder <CustomLevelFolderInfo>("Easy Day", null, NestedItems, ref parent); CustomFolderInfo easyDayFolder = NestedItems.FirstOrDefault(x => x.GetName() == "\\Easy Day" && x.GetPath() == null) as CustomFolderInfo; parent = null; CustomFolderInfo modIoFolder = null; var modIoMaps = LevelManager.Instance.ModLevels.Any(x => x.path.IsSubPathOf(PluginSettings.INSTALLATION_DIRECTORY)); if (modIoMaps) { AddFolder <CustomLevelFolderInfo>("mod.io", null, NestedItems, ref parent); modIoFolder = NestedItems.FirstOrDefault(x => x.GetName() == "\\mod.io" && x.GetPath() == null) as CustomFolderInfo; } foreach (var level in LevelManager.Instance.ModLevels) { AddLevel(level, easyDayFolder, modIoFolder, ref parent); } parent = null; foreach (var level in LevelManager.Instance.CommunityLevels) { AddLevel(level, easyDayFolder, modIoFolder, ref parent); } NestedItems = SortList(NestedItems); }
public override void LoadNestedItems(object[] objectsToLoad = null) { var gearToLoad = (GearInfo[])objectsToLoad; if (gearToLoad == null) { return; } if (LastLoaded != null && LastLoaded == gearToLoad) { return; } LastLoaded = gearToLoad; NestedItems.Clear(); CustomFolderInfo modIoFolder = null; foreach (var gear in gearToLoad) { GearInfo newGear = null; TextureChange textureChange = null; if (gear is GearInfoSingleMaterial singleMaterialGear) { textureChange = singleMaterialGear?.textureChanges?.FirstOrDefault(); newGear = singleMaterialGear; } else if (gear is CharacterBodyInfo characterBodyInfo) { var materialChange = characterBodyInfo.materialChanges.FirstOrDefault(); textureChange = materialChange?.textureChanges?.FirstOrDefault(); newGear = characterBodyInfo; } if (textureChange == null || string.IsNullOrEmpty(textureChange.texturePath)) { continue; } var isGearFolder = textureChange.texturePath.IsSubPathOf(SaveManager.Instance.CustomGearDir); var isModIo = textureChange.texturePath.IsSubPathOf(PluginSettings.INSTALLATION_DIRECTORY); CustomFolderInfo parent = null; if (isModIo) { AddFolder <CustomGearFolderInfo>("mod.io", null, NestedItems, ref parent); modIoFolder = NestedItems.FirstOrDefault(x => x.GetName() == "\\mod.io" && x.GetPath() == null) as CustomFolderInfo; var mod = InstalledGearMods.FirstOrDefault(x => textureChange.texturePath.IsSubPathOf(x.Key)); AddFolder <CustomGearFolderInfo>(mod.Value, null, modIoFolder.Children, ref parent); AddItem(newGear, parent.Children, ref modIoFolder); continue; } if (!isGearFolder && !isModIo) { continue; } string textureSubPath = string.Empty; string folderPath = string.Empty; if (isGearFolder) { textureSubPath = textureChange.texturePath.Replace(SaveManager.Instance.CustomGearDir + '\\', string.Empty); folderPath = SaveManager.Instance.CustomGearDir; } else if (isModIo) { textureSubPath = textureChange.texturePath.Replace(PluginSettings.INSTALLATION_DIRECTORY + '\\', string.Empty); folderPath = PluginSettings.INSTALLATION_DIRECTORY; } if (string.IsNullOrEmpty(textureSubPath) || string.IsNullOrEmpty(folderPath)) { continue; } var folders = textureSubPath.Split('\\').ToList(); if (!folders.Any()) { continue; } parent = null; if (folders.Count == 1 || IsImage(folders.First())) { // This gear item is at the root. AddItem(newGear, NestedItems, ref parent); continue; } parent = null; foreach (var folder in folders) { if (IsImage(folder)) { AddItem(newGear, parent == null ? NestedItems : parent.Children, ref parent); } else { folderPath = Path.Combine(folderPath, folder); AddFolder <CustomGearFolderInfo>(folder, folderPath, parent == null ? NestedItems : parent.Children, ref parent); } } } NestedItems = SortList(NestedItems); }