コード例 #1
0
        void update_builds()
        {
            list_build.ClearItems();

            if (!Directory.Exists(Path_mod))
            {
                Directory.CreateDirectory(Path_mod);
            }
            foreach (string file in Directory.GetFiles(Path_mod))
            {
                if (Path.GetExtension(file) == ".scbuild")
                {
                    list_build.AddItem(Path.GetFileName(file));
                }
            }
        }
コード例 #2
0
    private void UpdateList()
    {
        WorldsManager.UpdateWorldsList();
        List <ListItem> list = new List <ListItem>();

        if (m_filter == ExternalContentType.BlocksTexture || m_filter == ExternalContentType.Unknown)
        {
            BlocksTexturesManager.UpdateBlocksTexturesList();
            foreach (string name2 in BlocksTexturesManager.BlockTexturesNames)
            {
                list.Add(new ListItem
                {
                    Name         = name2,
                    IsBuiltIn    = BlocksTexturesManager.IsBuiltIn(name2),
                    Type         = ExternalContentType.BlocksTexture,
                    DisplayName  = BlocksTexturesManager.GetDisplayName(name2),
                    CreationTime = BlocksTexturesManager.GetCreationDate(name2),
                    UseCount     = WorldsManager.WorldInfos.Count((WorldInfo wi) => wi.WorldSettings.BlocksTextureName == name2)
                });
            }
        }
        if (m_filter == ExternalContentType.CharacterSkin || m_filter == ExternalContentType.Unknown)
        {
            CharacterSkinsManager.UpdateCharacterSkinsList();
            foreach (string name in CharacterSkinsManager.CharacterSkinsNames)
            {
                list.Add(new ListItem
                {
                    Name         = name,
                    IsBuiltIn    = CharacterSkinsManager.IsBuiltIn(name),
                    Type         = ExternalContentType.CharacterSkin,
                    DisplayName  = CharacterSkinsManager.GetDisplayName(name),
                    CreationTime = CharacterSkinsManager.GetCreationDate(name),
                    UseCount     = WorldsManager.WorldInfos.Count((WorldInfo wi) => wi.PlayerInfos.Any((PlayerInfo pi) => pi.CharacterSkinName == name))
                });
            }
        }
        if (m_filter == ExternalContentType.FurniturePack || m_filter == ExternalContentType.Unknown)
        {
            FurniturePacksManager.UpdateFurniturePacksList();
            foreach (string furniturePackName in FurniturePacksManager.FurniturePackNames)
            {
                list.Add(new ListItem
                {
                    Name         = furniturePackName,
                    IsBuiltIn    = false,
                    Type         = ExternalContentType.FurniturePack,
                    DisplayName  = FurniturePacksManager.GetDisplayName(furniturePackName),
                    CreationTime = FurniturePacksManager.GetCreationDate(furniturePackName)
                });
            }
        }
        list.Sort(delegate(ListItem o1, ListItem o2)
        {
            if (o1.IsBuiltIn && !o2.IsBuiltIn)
            {
                return(-1);
            }
            if (o2.IsBuiltIn && !o1.IsBuiltIn)
            {
                return(1);
            }
            if (string.IsNullOrEmpty(o1.Name) && !string.IsNullOrEmpty(o2.Name))
            {
                return(-1);
            }
            return((!string.IsNullOrEmpty(o1.Name) && string.IsNullOrEmpty(o2.Name)) ? 1 : string.Compare(o1.DisplayName, o2.DisplayName));
        });
        m_contentList.ClearItems();
        foreach (ListItem item in list)
        {
            m_contentList.AddItem(item);
        }
    }