Exemplo n.º 1
0
        static IEnumerable <PathPackageTuple> ccGetList(string ccPath)
        {
            List <PathPackageTuple> ppts = new List <PathPackageTuple>();

            if (ccPath != null && Directory.Exists(ccPath))
            {
                //Depth-first search
                foreach (var dir in Directory.GetDirectories(ccPath))
                {
                    foreach (var ppt in ccGetList(dir))
                    {
                        yield return(ppt);
                    }
                }
                foreach (string pattern in CCpkgPatterns)
                {
                    foreach (var path in Directory.GetFiles(ccPath, pattern))
                    {
                        PathPackageTuple ppt = null;
                        try
                        {
                            ppt = new PathPackageTuple(path);
                        }
                        catch (InvalidDataException) { continue; }
                        yield return(ppt);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Request <paramref name="resourceIndexEntry"/> from <paramref name="ppt"/>.
        /// </summary>
        /// <param name="ppt">The <see cref="PathPackageTuple"/> to use to resolve the request.</param>
        /// <param name="resourceIndexEntry">The requested <see cref="IResourceIndexEntry"/>.</param>
        /// <exception cref="ArgumentException">Thrown if <paramref name="ppt"/> does not contain <paramref name="resourceIndexEntry"/>.</exception>
        public SpecificIndexEntry(PathPackageTuple ppt, IResourceIndexEntry resourceIndexEntry)
        {
            if (FileTable.Current == ppt)
            {
                PPSource = "current";
            }
            else if (FileTable.CustomContentEnabled && FileTable.CustomContent.Contains(ppt))
            {
                PPSource = "cc";
            }
            else if (FileTable.GameContent != null && FileTable.GameContent.Contains(ppt))
            {
                PPSource = "fb0";
            }
            else if (FileTable.DDSImages != null && FileTable.DDSImages.Contains(ppt))
            {
                PPSource = "dds";
            }
            else if (FileTable.Thumbnails != null && FileTable.Thumbnails.Contains(ppt))
            {
                PPSource = "tmb";
            }
            else
            {
                PPSource = "unk";
            }

            if (ppt.Package.Find(rie => rie.Equals(resourceIndexEntry)) == null) // Avoid recursive call to ppt.Find()
            {
                throw new ArgumentException("Package does not contain specified ResourceIndexEntry", "resourceIndexEntry");
            }
            this.RequestedRK = new RK(resourceIndexEntry);
            this.PathPackage = ppt;

            this.specificIndexEntry = resourceIndexEntry;
            this.searchList         = null;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Extends the <see cref="SpecificIndexEntry"/> constructor by allowing an optional flag indicating
 /// whether to always resolve the request for <see cref="Resource"/> using the default wrapper.
 /// </summary>
 /// <param name="ppt">The <see cref="PathPackageTuple"/> to use to resolve the request.</param>
 /// <param name="specificRK">The requested <see cref="IResourceIndexEntry"/>.</param>
 /// <param name="defaultWrapper">If true, always resolve the request for <see cref="Resource"/> using the default wrapper;
 /// otherwise <see cref="s4pi.WrapperDealer.WrapperDealer.GetResource(int, IPackage, IResourceIndexEntry, bool)"/> will determine the correct resource wrapper.</param>
 public SpecificResource(PathPackageTuple ppt, IResourceIndexEntry specificRK, bool defaultWrapper = false) : base(ppt, specificRK)
 {
     DefaultWrapper = defaultWrapper;
 }