コード例 #1
0
ファイル: CustomFolderInfo.cs プロジェクト: MCBTay/XLMenuMod
 public static bool HasChildren(this CustomFolderInfo folderInfo)
 {
     if (folderInfo != null && folderInfo.Children != null && folderInfo.Children.Any())
     {
         return(true);
     }
     return(false);
 }
コード例 #2
0
ファイル: CustomManager.cs プロジェクト: MCBTay/XLMenuMod
        public virtual void AddItem <T>(T source, List <ICustomInfo> sourceList, ref CustomFolderInfo parent) where T : class
        {
            if (source is LevelInfo level)
            {
                var existing = sourceList.FirstOrDefault(x => x.GetName() == level.name);

                if (existing == null)
                {
                    sourceList.Add(new CustomLevelInfo(level, parent).Info);
                }
            }
            else if (source is GearInfoSingleMaterial gear)
            {
                var existing = sourceList.FirstOrDefault(x => x.GetName() == gear.name);

                if (existing == null)
                {
                    if (source is BoardGearInfo)
                    {
                        var customGear = new CustomBoardGearInfo(gear.name, gear.type, gear.isCustom, gear.textureChanges, gear.tags);
                        customGear.Info.Parent = parent;
                        sourceList.Add(customGear.Info);
                    }
                    else if (source is CharacterGearInfo)
                    {
                        var customGear = new CustomCharacterGearInfo(gear.name, gear.type, gear.isCustom, gear.textureChanges, gear.tags);
                        customGear.Info.Parent = parent;
                        sourceList.Add(customGear.Info);
                    }
                }
            }
            else if (source is CharacterBodyInfo characterBodyInfo)
            {
                var existing = sourceList.FirstOrDefault(x => x.GetName() == characterBodyInfo.name);

                if (existing == null)
                {
                    var customGear = new CustomCharacterBodyInfo(characterBodyInfo.name, characterBodyInfo.type, characterBodyInfo.isCustom, characterBodyInfo.materialChanges, characterBodyInfo.tags);
                    customGear.Info.Parent = parent;
                    sourceList.Add(customGear.Info);
                }
            }
        }
コード例 #3
0
ファイル: CustomFolderInfo.cs プロジェクト: MCBTay/XLMenuMod
        public CustomFolderInfo(string name, string path, CustomFolderInfo parent) : base(name, path, parent, false)
        {
            Children = new List <ICustomInfo>();

            IsFolder = true;

            if (GetName() != "..\\")
            {
                if (!string.IsNullOrEmpty(path))
                {
                    Size = GetDirectorySize(path);
                }

                var childPath =
                    Parent == null ?
                    string.Empty :
                    string.IsNullOrEmpty(Parent.GetPath()) ?
                    string.Empty :
                    System.IO.Path.GetDirectoryName(Parent.GetPath());
                Children.Add(new CustomFolderInfo("..\\", childPath, Parent));
            }
        }
コード例 #4
0
ファイル: CustomInfo.cs プロジェクト: MCBTay/XLMenuMod
 public CustomInfo(string name, string path, CustomFolderInfo parent, bool getFileSize = true) : this(name, path, getFileSize)
 {
     Parent = parent;
 }
コード例 #5
0
ファイル: CustomManager.cs プロジェクト: MCBTay/XLMenuMod
        public virtual void AddFolder <T>(string folder, string path, List <ICustomInfo> sourceList, ref CustomFolderInfo parent) where T : ICustomFolderInfo
        {
            string folderName = $"\\{folder}";

            var child = sourceList.FirstOrDefault(x => x.GetName().Equals(folderName, StringComparison.InvariantCultureIgnoreCase) && x is CustomFolderInfo) as CustomFolderInfo;

            if (child == null)
            {
                ICustomFolderInfo newFolder;

                if (typeof(T) == typeof(CustomLevelFolderInfo))
                {
                    newFolder = new CustomLevelFolderInfo($"\\{folder}", Path.GetDirectoryName(path), parent);
                }
                else if (typeof(T) == typeof(CustomGearFolderInfo))
                {
                    newFolder = new CustomGearFolderInfo($"\\{folder}", path, parent);
                }
                else
                {
                    return;
                }

                SpriteHelper.Instance.LoadCustomFolderSprite(newFolder, path);

                sourceList.Add(newFolder.FolderInfo);
                parent = newFolder.FolderInfo;
            }
            else
            {
                parent = child;
            }
        }